llpanelenvsettings.cpp 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765
  1. /**
  2. * @file llpanelenvsettings.cpp
  3. * @brief Environment settings panel classes implementation
  4. *
  5. * $LicenseInfo:firstyear=2018&license=viewergpl$
  6. *
  7. * Copyright (c) 2018, Linden Research, Inc, (c) 2019-2023 Henri Beauchamp.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llpanelenvsettings.h"
  34. #include "llbutton.h"
  35. #include "llcallbacklist.h"
  36. #include "llcheckboxctrl.h"
  37. #include "llfloater.h"
  38. #include "llmultisliderctrl.h"
  39. #include "llnotifications.h"
  40. #include "llradiogroup.h"
  41. #include "llsliderctrl.h"
  42. #include "lluictrlfactory.h"
  43. #include "llvirtualtrackball.h"
  44. #include "llxyvector.h"
  45. #include "llagent.h" // For gAgentID
  46. #include "llappviewer.h" // For gDisconnected and gFrameTimeSeconds
  47. #include "llcolorswatch.h"
  48. #include "llenvsettings.h"
  49. #include "hbfloaterinvitemspicker.h"
  50. #include "llinventorymodel.h"
  51. #include "lllocalbitmaps.h"
  52. #include "lltexturectrl.h"
  53. #include "llviewercontrol.h"
  54. #include "llwlskyparammgr.h"
  55. ///////////////////////////////////////////////////////////////////////////////
  56. // LLPanelEnvSettingsSky class
  57. ///////////////////////////////////////////////////////////////////////////////
  58. constexpr F32 SLIDER_SCALE_SUN_AMBIENT = 3.f;
  59. constexpr F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY = 2.f;
  60. constexpr F32 SLIDER_SCALE_GLOW_R = 20.f;
  61. constexpr F32 SLIDER_SCALE_GLOW_B = -5.f;
  62. constexpr F32 SLIDER_SCALE_DENSITY_MULTIPLIER = 0.001f;
  63. LLPanelEnvSettingsSky::LLPanelEnvSettingsSky()
  64. : LLPanelEnvSettings()
  65. {
  66. LLEnvironment::addBeaconsUser();
  67. LLUICtrlFactory::getInstance()->buildPanel(this, "panel_settings_sky.xml");
  68. }
  69. //virtual
  70. LLPanelEnvSettingsSky::~LLPanelEnvSettingsSky()
  71. {
  72. LLEnvironment::delBeaconsUser();
  73. }
  74. //virtual
  75. bool LLPanelEnvSettingsSky::postBuild()
  76. {
  77. mAmbientColorCtrl = getChild<LLColorSwatchCtrl>("ambient_light");
  78. mAmbientColorCtrl->setCommitCallback(onAmbientLightChanged);
  79. mAmbientColorCtrl->setCallbackUserData(this);
  80. mBlueHorizonColorCtrl = getChild<LLColorSwatchCtrl>("blue_horizon");
  81. mBlueHorizonColorCtrl->setCommitCallback(onBlueHorizonChanged);
  82. mBlueHorizonColorCtrl->setCallbackUserData(this);
  83. mBlueDensityColorCtrl = getChild<LLColorSwatchCtrl>("blue_density");
  84. mBlueDensityColorCtrl->setCommitCallback(onBlueDensityChanged);
  85. mBlueDensityColorCtrl->setCallbackUserData(this);
  86. mHazeHorizonCtrl = getChild<LLSliderCtrl>("haze_horizon");
  87. mHazeHorizonCtrl->setCommitCallback(onHazeHorizonChanged);
  88. mHazeHorizonCtrl->setCallbackUserData(this);
  89. mHazeDensityCtrl = getChild<LLSliderCtrl>("haze_density");
  90. mHazeDensityCtrl->setCommitCallback(onHazeDensityChanged);
  91. mHazeDensityCtrl->setCallbackUserData(this);
  92. mMoistureLevelCtrl = getChild<LLSliderCtrl>("moisture_level");
  93. mMoistureLevelCtrl->setCommitCallback(onMoistureLevelChanged);
  94. mMoistureLevelCtrl->setCallbackUserData(this);
  95. mDropletRadiusCtrl = getChild<LLSliderCtrl>("droplet_radius");
  96. mDropletRadiusCtrl->setCommitCallback(onDropletRadiusChanged);
  97. mDropletRadiusCtrl->setCallbackUserData(this);
  98. mIceLevelCtrl = getChild<LLSliderCtrl>("ice_level");
  99. mIceLevelCtrl->setCommitCallback(onIceLevelChanged);
  100. mIceLevelCtrl->setCallbackUserData(this);
  101. mSceneGammaCtrl = getChild<LLSliderCtrl>("scene_gamma");
  102. mSceneGammaCtrl->setCommitCallback(onSceneGammaChanged);
  103. mSceneGammaCtrl->setCallbackUserData(this);
  104. mDensityMultCtrl = getChild<LLSliderCtrl>("density_mult");
  105. mDensityMultCtrl->setCommitCallback(onDensityMultipChanged);
  106. mDensityMultCtrl->setCallbackUserData(this);
  107. mDistanceMultCtrl = getChild<LLSliderCtrl>("distance_mult");
  108. mDistanceMultCtrl->setCommitCallback(onDistanceMultipChanged);
  109. mDistanceMultCtrl->setCallbackUserData(this);
  110. mMaxAltitudeCtrl = getChild<LLSliderCtrl>("max_alt");
  111. mMaxAltitudeCtrl->setCommitCallback(onMaxAltChanged);
  112. mMaxAltitudeCtrl->setCallbackUserData(this);
  113. mUseProbeAmbianceCtrl = getChild<LLCheckBoxCtrl>("probe_ambiance_enable");
  114. mUseProbeAmbianceCtrl->setCommitCallback(onProbeAmbianceChanged);
  115. mUseProbeAmbianceCtrl->setCallbackUserData(this);
  116. mProbeAmbianceCtrl = getChild<LLSliderCtrl>("probe_ambiance");
  117. mProbeAmbianceCtrl->setCommitCallback(onProbeAmbianceChanged);
  118. mProbeAmbianceCtrl->setCallbackUserData(this);
  119. mHdrAutoText = getChild<LLTextBox>("hdr_auto_text");
  120. mHdrOffText = getChild<LLTextBox>("hdr_never_text");
  121. mHdrOnText = getChild<LLTextBox>("hdr_always_text");
  122. mCloudColorCtrl = getChild<LLColorSwatchCtrl>("cloud_color");
  123. mCloudColorCtrl->setCommitCallback(onCloudColorChanged);
  124. mCloudColorCtrl->setCallbackUserData(this);
  125. mCloudMapCtrl = getChild<LLTextureCtrl>("cloud_map");
  126. mCloudMapCtrl->setDefaultImageAssetID(LLSettingsSky::getDefaultCloudNoiseTextureId());
  127. mCloudMapCtrl->setCommitCallback(onCloudMapChanged);
  128. mCloudMapCtrl->setCallbackUserData(this);
  129. mCloudCoverageCtrl = getChild<LLSliderCtrl>("cloud_coverage");
  130. mCloudCoverageCtrl->setCommitCallback(onCloudCoverageChanged);
  131. mCloudCoverageCtrl->setCallbackUserData(this);
  132. mCloudScaleCtrl = getChild<LLSliderCtrl>("cloud_scale");
  133. mCloudScaleCtrl->setCommitCallback(onCloudScaleChanged);
  134. mCloudScaleCtrl->setCallbackUserData(this);
  135. mCloudVarianceCtrl = getChild<LLSliderCtrl>("cloud_variance");
  136. mCloudVarianceCtrl->setCommitCallback(onCloudVarianceChanged);
  137. mCloudVarianceCtrl->setCallbackUserData(this);
  138. mCloudScrollCtrl = getChild<LLXYVector>("cloud_scroll_xy");
  139. mCloudScrollCtrl->setCommitCallback(onCloudScrollChanged);
  140. mCloudScrollCtrl->setCallbackUserData(this);
  141. mCloudDensityXCtrl = getChild<LLSliderCtrl>("cloud_density_x");
  142. mCloudDensityXCtrl->setCommitCallback(onCloudDensityChanged);
  143. mCloudDensityXCtrl->setCallbackUserData(this);
  144. mCloudDensityYCtrl = getChild<LLSliderCtrl>("cloud_density_y");
  145. mCloudDensityYCtrl->setCommitCallback(onCloudDensityChanged);
  146. mCloudDensityYCtrl->setCallbackUserData(this);
  147. mCloudDensityDCtrl = getChild<LLSliderCtrl>("cloud_density_d");
  148. mCloudDensityDCtrl->setCommitCallback(onCloudDensityChanged);
  149. mCloudDensityDCtrl->setCallbackUserData(this);
  150. mCloudDetailXCtrl = getChild<LLSliderCtrl>("cloud_detail_x");
  151. mCloudDetailXCtrl->setCommitCallback(onCloudDetailChanged);
  152. mCloudDetailXCtrl->setCallbackUserData(this);
  153. mCloudDetailYCtrl = getChild<LLSliderCtrl>("cloud_detail_y");
  154. mCloudDetailYCtrl->setCommitCallback(onCloudDetailChanged);
  155. mCloudDetailYCtrl->setCallbackUserData(this);
  156. mCloudDetailDCtrl = getChild<LLSliderCtrl>("cloud_detail_d");
  157. mCloudDetailDCtrl->setCommitCallback(onCloudDetailChanged);
  158. mCloudDetailDCtrl->setCallbackUserData(this);
  159. mSunRotationCtrl = getChild<LLVirtualTrackball>("sun_rotation");
  160. mSunRotationCtrl->setCommitCallback(onSunRotationChanged);
  161. mSunRotationCtrl->setCallbackUserData(this);
  162. mMoonRotationCtrl = getChild<LLVirtualTrackball>("moon_rotation");
  163. mMoonRotationCtrl->setCommitCallback(onMoonRotationChanged);
  164. mMoonRotationCtrl->setCallbackUserData(this);
  165. mSunImageCtrl = getChild<LLTextureCtrl>("sun_image");
  166. const LLUUID& blank_sun_id = LLSettingsSky::getBlankSunTextureId();
  167. mSunImageCtrl->setBlankImageAssetID(blank_sun_id);
  168. mSunImageCtrl->setDefaultImageAssetID(blank_sun_id);
  169. mSunImageCtrl->setCommitCallback(onSunImageChanged);
  170. mSunImageCtrl->setCallbackUserData(this);
  171. mMoonImageCtrl = getChild<LLTextureCtrl>("moon_image");
  172. const LLUUID& default_moon_id = LLSettingsSky::getDefaultMoonTextureId();
  173. mMoonImageCtrl->setBlankImageAssetID(default_moon_id);
  174. mMoonImageCtrl->setDefaultImageAssetID(default_moon_id);
  175. mMoonImageCtrl->setCommitCallback(onMoonImageChanged);
  176. mMoonImageCtrl->setCallbackUserData(this);
  177. mSunLightColorCtrl = getChild<LLColorSwatchCtrl>("sun_light_color");
  178. mSunLightColorCtrl->setCommitCallback(onSunlightColorChanged);
  179. mSunLightColorCtrl->setCallbackUserData(this);
  180. mSunScaleCtrl = getChild<LLSliderCtrl>("sun_scale");
  181. mSunScaleCtrl->setCommitCallback(onSunScaleChanged);
  182. mSunScaleCtrl->setCallbackUserData(this);
  183. mMoonScaleCtrl = getChild<LLSliderCtrl>("moon_scale");
  184. mMoonScaleCtrl->setCommitCallback(onMoonScaleChanged);
  185. mMoonScaleCtrl->setCallbackUserData(this);
  186. mGlowFocusCtrl = getChild<LLSliderCtrl>("glow_focus");
  187. mGlowFocusCtrl->setCommitCallback(onGlowChanged);
  188. mGlowFocusCtrl->setCallbackUserData(this);
  189. mGlowSizeCtrl = getChild<LLSliderCtrl>("glow_size");
  190. mGlowSizeCtrl->setCommitCallback(onGlowChanged);
  191. mGlowSizeCtrl->setCallbackUserData(this);
  192. mMoonBrightnessCtrl = getChild<LLSliderCtrl>("moon_brightness");
  193. mMoonBrightnessCtrl->setCommitCallback(onMoonBrightnessChanged);
  194. mMoonBrightnessCtrl->setCallbackUserData(this);
  195. mStarBrightnessCtrl = getChild<LLSliderCtrl>("star_brightness");
  196. mStarBrightnessCtrl->setCommitCallback(onStarBrightnessChanged);
  197. mStarBrightnessCtrl->setCallbackUserData(this);
  198. refresh();
  199. return true;
  200. }
  201. //virtual
  202. void LLPanelEnvSettingsSky::setEnabled(bool enabled)
  203. {
  204. mAmbientColorCtrl->setEnabled(enabled);
  205. mBlueHorizonColorCtrl->setEnabled(enabled);
  206. mBlueDensityColorCtrl->setEnabled(enabled);
  207. mCloudColorCtrl->setEnabled(enabled);
  208. mSunLightColorCtrl->setEnabled(enabled);
  209. mHazeHorizonCtrl->setEnabled(enabled);
  210. mHazeDensityCtrl->setEnabled(enabled);
  211. mMoistureLevelCtrl->setEnabled(enabled);
  212. mDropletRadiusCtrl->setEnabled(enabled);
  213. mIceLevelCtrl->setEnabled(enabled);
  214. mSceneGammaCtrl->setEnabled(enabled);
  215. mDensityMultCtrl->setEnabled(enabled);
  216. mDistanceMultCtrl->setEnabled(enabled);
  217. mMaxAltitudeCtrl->setEnabled(enabled);
  218. mUseProbeAmbianceCtrl->setEnabled(enabled);
  219. mProbeAmbianceCtrl->setEnabled(enabled);
  220. mCloudCoverageCtrl->setEnabled(enabled);
  221. mCloudScaleCtrl->setEnabled(enabled);
  222. mCloudVarianceCtrl->setEnabled(enabled);
  223. mCloudDensityXCtrl->setEnabled(enabled);
  224. mCloudDensityYCtrl->setEnabled(enabled);
  225. mCloudDensityDCtrl->setEnabled(enabled);
  226. mCloudDetailXCtrl->setEnabled(enabled);
  227. mCloudDetailYCtrl->setEnabled(enabled);
  228. mCloudDetailDCtrl->setEnabled(enabled);
  229. mSunScaleCtrl->setEnabled(enabled);
  230. mMoonScaleCtrl->setEnabled(enabled);
  231. mGlowFocusCtrl->setEnabled(enabled);
  232. mGlowSizeCtrl->setEnabled(enabled);
  233. mMoonBrightnessCtrl->setEnabled(enabled);
  234. mStarBrightnessCtrl->setEnabled(enabled);
  235. mCloudMapCtrl->setEnabled(enabled);
  236. mSunImageCtrl->setEnabled(enabled);
  237. mMoonImageCtrl->setEnabled(enabled);
  238. mSunRotationCtrl->setEnabled(enabled);
  239. mMoonRotationCtrl->setEnabled(enabled);
  240. mCloudScrollCtrl->setEnabled(enabled);
  241. mHdrAutoText->setEnabled(enabled);
  242. mHdrOffText->setEnabled(enabled);
  243. mHdrOnText->setEnabled(enabled);
  244. LLPanel::setEnabled(enabled);
  245. }
  246. //virtual
  247. void LLPanelEnvSettingsSky::refresh()
  248. {
  249. if (!mSkySettings || !canEdit())
  250. {
  251. setEnabled(false);
  252. return;
  253. }
  254. setEnabled(true);
  255. mAmbientColorCtrl->set(mSkySettings->getAmbientColor() /
  256. SLIDER_SCALE_SUN_AMBIENT);
  257. mBlueHorizonColorCtrl->set(mSkySettings->getBlueHorizon() /
  258. SLIDER_SCALE_BLUE_HORIZON_DENSITY);
  259. mBlueDensityColorCtrl->set(mSkySettings->getBlueDensity() /
  260. SLIDER_SCALE_BLUE_HORIZON_DENSITY);
  261. mHazeHorizonCtrl->setValue(mSkySettings->getHazeHorizon());
  262. mHazeDensityCtrl->setValue(mSkySettings->getHazeDensity());
  263. mMoistureLevelCtrl->setValue(mSkySettings->getSkyMoistureLevel());
  264. mDropletRadiusCtrl->setValue(mSkySettings->getSkyDropletRadius());
  265. mIceLevelCtrl->setValue(mSkySettings->getSkyIceLevel());
  266. mSceneGammaCtrl->setValue(mSkySettings->getGamma());
  267. mDensityMultCtrl->setValue(mSkySettings->getDensityMultiplier() /
  268. SLIDER_SCALE_DENSITY_MULTIPLIER);
  269. mDistanceMultCtrl->setValue(mSkySettings->getDistanceMultiplier());
  270. mMaxAltitudeCtrl->setValue(mSkySettings->getMaxY());
  271. if (mSkySettings->canAutoAdjust())
  272. {
  273. mUseProbeAmbianceCtrl->set(false);
  274. mProbeAmbianceCtrl->setValue(0.f);
  275. mProbeAmbianceCtrl->setEnabled(false);
  276. mHdrAutoText->setVisible(true);
  277. mHdrOffText->setVisible(false);
  278. mHdrOnText->setVisible(false);
  279. }
  280. else
  281. {
  282. mUseProbeAmbianceCtrl->set(true);
  283. F32 probe_ambiance = mSkySettings->getReflectionProbeAmbiance();
  284. mProbeAmbianceCtrl->setValue(probe_ambiance);
  285. mProbeAmbianceCtrl->setEnabled(true);
  286. bool hdr_off = probe_ambiance == 0.f;
  287. mHdrAutoText->setVisible(false);
  288. mHdrOffText->setVisible(hdr_off);
  289. mHdrOnText->setVisible(!hdr_off);
  290. }
  291. mCloudColorCtrl->set(mSkySettings->getCloudColor());
  292. mCloudCoverageCtrl->setValue(mSkySettings->getCloudShadow());
  293. mCloudScaleCtrl->setValue(mSkySettings->getCloudScale());
  294. mCloudVarianceCtrl->setValue(mSkySettings->getCloudVariance());
  295. LLVector2 scroll = mSkySettings->getCloudScrollRate();
  296. mCloudScrollCtrl->setValue(scroll.mV[VX], scroll.mV[VY]);
  297. mCloudMapCtrl->setImageAssetID(mSkySettings->getCloudNoiseTextureId());
  298. LLColor3 density = mSkySettings->getCloudPosDensity1();
  299. mCloudDensityXCtrl->setValue(density.mV[0]);
  300. mCloudDensityYCtrl->setValue(density.mV[1]);
  301. mCloudDensityDCtrl->setValue(density.mV[2]);
  302. LLColor3 detail = mSkySettings->getCloudPosDensity2();
  303. mCloudDetailXCtrl->setValue(detail.mV[0]);
  304. mCloudDetailYCtrl->setValue(detail.mV[1]);
  305. mCloudDetailDCtrl->setValue(detail.mV[2]);
  306. mSunRotationCtrl->setRotation(mSkySettings->getSunRotation());
  307. mMoonRotationCtrl->setRotation(mSkySettings->getMoonRotation());
  308. mSunImageCtrl->setImageAssetID(mSkySettings->getSunTextureId());
  309. mMoonImageCtrl->setImageAssetID(mSkySettings->getMoonTextureId());
  310. mSunLightColorCtrl->set(mSkySettings->getSunlightColor() /
  311. SLIDER_SCALE_SUN_AMBIENT);
  312. mSunScaleCtrl->setValue(mSkySettings->getSunScale());
  313. mMoonScaleCtrl->setValue(mSkySettings->getMoonScale());
  314. LLColor3 glow = mSkySettings->getGlow();
  315. mGlowFocusCtrl->setValue(glow.mV[2] / SLIDER_SCALE_GLOW_B);
  316. mGlowSizeCtrl->setValue(2.f - glow.mV[0] / SLIDER_SCALE_GLOW_R);
  317. mMoonBrightnessCtrl->setValue(mSkySettings->getMoonBrightness());
  318. mStarBrightnessCtrl->setValue(mSkySettings->getStarBrightness());
  319. LLPanel::refresh();
  320. }
  321. //virtual
  322. void LLPanelEnvSettingsSky::setSettings(const LLSettingsBase::ptr_t& settings,
  323. bool reset_dirty)
  324. {
  325. setSky(std::static_pointer_cast<LLSettingsSky>(settings), reset_dirty);
  326. }
  327. void LLPanelEnvSettingsSky::setSky(const LLSettingsSky::ptr_t& settings,
  328. bool reset_dirty)
  329. {
  330. mSkySettings = settings;
  331. if (reset_dirty)
  332. {
  333. setDirty(false);
  334. }
  335. refresh();
  336. }
  337. void LLPanelEnvSettingsSky::updateSettings()
  338. {
  339. if (mSkySettings)
  340. {
  341. mSkySettings->update();
  342. setDirty();
  343. gWLSkyParamMgr.setDirty();
  344. }
  345. }
  346. //virtual
  347. LLSettingsBase::ptr_t LLPanelEnvSettingsSky::getSettingsClone()
  348. {
  349. LLSettingsBase::ptr_t clone;
  350. if (mSkySettings)
  351. {
  352. clone = mSkySettings->buildClone();
  353. }
  354. return clone;
  355. }
  356. //virtual
  357. bool LLPanelEnvSettingsSky::hasLocalTextures(LLSD& args)
  358. {
  359. if (mSkySettings)
  360. {
  361. if (LLLocalBitmap::isLocal(mSkySettings->getSunTextureId()))
  362. {
  363. args["FIELD"] = getString("sun");
  364. return true;
  365. }
  366. if (LLLocalBitmap::isLocal(mSkySettings->getMoonTextureId()))
  367. {
  368. args["FIELD"] = getString("moon");
  369. return true;
  370. }
  371. if (LLLocalBitmap::isLocal(mSkySettings->getCloudNoiseTextureId()))
  372. {
  373. args["FIELD"] = getString("cloudnoise");
  374. return true;
  375. }
  376. if (LLLocalBitmap::isLocal(mSkySettings->getBloomTextureId()))
  377. {
  378. args["FIELD"] = getString("bloom");
  379. return true;
  380. }
  381. }
  382. return false;
  383. }
  384. //virtual
  385. void LLPanelEnvSettingsSky::updateEditEnvironment()
  386. {
  387. if (mSkySettings)
  388. {
  389. gEnvironment.setEnvironment(LLEnvironment::ENV_EDIT, mSkySettings);
  390. gEnvironment.updateEnvironment(LLEnvironment::TRANSITION_FAST);
  391. }
  392. }
  393. //virtual
  394. void LLPanelEnvSettingsSky::updateLocal()
  395. {
  396. if (mSkySettings)
  397. {
  398. gEnvironment.setEnvironment(LLEnvironment::ENV_LOCAL, mSkySettings);
  399. }
  400. }
  401. //virtual
  402. void LLPanelEnvSettingsSky::updateParcel(S32 parcel_id)
  403. {
  404. if (mSkySettings)
  405. {
  406. gEnvironment.updateParcel(parcel_id, mSkySettings, -1, -1);
  407. }
  408. }
  409. //virtual
  410. void LLPanelEnvSettingsSky::updateRegion()
  411. {
  412. if (mSkySettings)
  413. {
  414. gEnvironment.updateRegion(mSkySettings, -1, -1);
  415. }
  416. }
  417. //static
  418. void LLPanelEnvSettingsSky::onAmbientLightChanged(LLUICtrl*, void* userdata)
  419. {
  420. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  421. if (!self || !self->mSkySettings) return; // Paranoia
  422. self->mSkySettings->setAmbientColor(LLColor3(self->mAmbientColorCtrl->get() *
  423. SLIDER_SCALE_SUN_AMBIENT));
  424. self->updateSettings();
  425. }
  426. //static
  427. void LLPanelEnvSettingsSky::onBlueHorizonChanged(LLUICtrl*, void* userdata)
  428. {
  429. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  430. if (!self || !self->mSkySettings) return; // Paranoia
  431. self->mSkySettings->setBlueHorizon(LLColor3(self->mBlueHorizonColorCtrl->get() *
  432. SLIDER_SCALE_BLUE_HORIZON_DENSITY));
  433. self->updateSettings();
  434. }
  435. //static
  436. void LLPanelEnvSettingsSky::onBlueDensityChanged(LLUICtrl*, void* userdata)
  437. {
  438. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  439. if (!self || !self->mSkySettings) return; // Paranoia
  440. self->mSkySettings->setBlueDensity(LLColor3(self->mBlueDensityColorCtrl->get() *
  441. SLIDER_SCALE_BLUE_HORIZON_DENSITY));
  442. self->updateSettings();
  443. }
  444. //static
  445. void LLPanelEnvSettingsSky::onHazeHorizonChanged(LLUICtrl*, void* userdata)
  446. {
  447. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  448. if (!self || !self->mSkySettings) return; // Paranoia
  449. self->mSkySettings->setHazeHorizon(self->mHazeHorizonCtrl->getValueF32());
  450. self->updateSettings();
  451. }
  452. //static
  453. void LLPanelEnvSettingsSky::onHazeDensityChanged(LLUICtrl*, void* userdata)
  454. {
  455. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  456. if (!self || !self->mSkySettings) return; // Paranoia
  457. self->mSkySettings->setHazeDensity(self->mHazeDensityCtrl->getValueF32());
  458. self->updateSettings();
  459. }
  460. //static
  461. void LLPanelEnvSettingsSky::onMoistureLevelChanged(LLUICtrl*, void* userdata)
  462. {
  463. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  464. if (!self || !self->mSkySettings) return; // Paranoia
  465. F32 value = self->mMoistureLevelCtrl->getValueF32();
  466. self->mSkySettings->setSkyMoistureLevel(value);
  467. self->updateSettings();
  468. }
  469. //static
  470. void LLPanelEnvSettingsSky::onDropletRadiusChanged(LLUICtrl*, void* userdata)
  471. {
  472. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  473. if (!self || !self->mSkySettings) return; // Paranoia
  474. F32 value = self->mDropletRadiusCtrl->getValueF32();
  475. self->mSkySettings->setSkyDropletRadius(value);
  476. self->updateSettings();
  477. }
  478. //static
  479. void LLPanelEnvSettingsSky::onIceLevelChanged(LLUICtrl*, void* userdata)
  480. {
  481. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  482. if (!self || !self->mSkySettings) return; // Paranoia
  483. self->mSkySettings->setSkyIceLevel(self->mIceLevelCtrl->getValueF32());
  484. self->updateSettings();
  485. }
  486. //static
  487. void LLPanelEnvSettingsSky::onSceneGammaChanged(LLUICtrl*, void* userdata)
  488. {
  489. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  490. if (!self || !self->mSkySettings) return; // Paranoia
  491. self->mSkySettings->setGamma(self->mSceneGammaCtrl->getValueF32());
  492. self->updateSettings();
  493. }
  494. //static
  495. void LLPanelEnvSettingsSky::onDensityMultipChanged(LLUICtrl*, void* userdata)
  496. {
  497. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  498. if (!self || !self->mSkySettings) return; // Paranoia
  499. F32 value = self->mDensityMultCtrl->getValueF32() *
  500. SLIDER_SCALE_DENSITY_MULTIPLIER;
  501. self->mSkySettings->setDensityMultiplier(value);
  502. self->updateSettings();
  503. }
  504. //static
  505. void LLPanelEnvSettingsSky::onDistanceMultipChanged(LLUICtrl*, void* userdata)
  506. {
  507. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  508. if (!self || !self->mSkySettings) return; // Paranoia
  509. F32 value = self->mDistanceMultCtrl->getValueF32();
  510. self->mSkySettings->setDistanceMultiplier(value);
  511. self->updateSettings();
  512. }
  513. //static
  514. void LLPanelEnvSettingsSky::onMaxAltChanged(LLUICtrl*, void* userdata)
  515. {
  516. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  517. if (!self || !self->mSkySettings) return; // Paranoia
  518. self->mSkySettings->setMaxY(self->mMaxAltitudeCtrl->getValueF32());
  519. self->updateSettings();
  520. }
  521. //static
  522. void LLPanelEnvSettingsSky::onProbeAmbianceChanged(LLUICtrl*, void* userdata)
  523. {
  524. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  525. if (!self || !self->mSkySettings) return; // Paranoia
  526. if (self->mUseProbeAmbianceCtrl->get())
  527. {
  528. F32 probe_ambiance = self->mProbeAmbianceCtrl->getValueF32();
  529. self->mSkySettings->setReflectionProbeAmbiance(probe_ambiance);
  530. }
  531. else
  532. {
  533. self->mSkySettings->removeProbeAmbiance();
  534. }
  535. self->updateSettings();
  536. self->refresh();
  537. }
  538. //static
  539. void LLPanelEnvSettingsSky::onCloudColorChanged(LLUICtrl*, void* userdata)
  540. {
  541. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  542. if (!self || !self->mSkySettings) return; // Paranoia
  543. self->mSkySettings->setCloudColor(LLColor3(self->mCloudColorCtrl->get()));
  544. self->updateSettings();
  545. }
  546. //static
  547. void LLPanelEnvSettingsSky::onCloudMapChanged(LLUICtrl*, void* userdata)
  548. {
  549. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  550. if (!self || !self->mSkySettings) return; // Paranoia
  551. const LLUUID& map_id = self->mCloudMapCtrl->getImageAssetID();
  552. self->mSkySettings->setCloudNoiseTextureId(map_id);
  553. self->updateSettings();
  554. }
  555. //static
  556. void LLPanelEnvSettingsSky::onCloudCoverageChanged(LLUICtrl*, void* userdata)
  557. {
  558. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  559. if (!self || !self->mSkySettings) return; // Paranoia
  560. F32 value = self->mCloudCoverageCtrl->getValueF32();
  561. self->mSkySettings->setCloudShadow(value);
  562. self->updateSettings();
  563. }
  564. //static
  565. void LLPanelEnvSettingsSky::onCloudScaleChanged(LLUICtrl*, void* userdata)
  566. {
  567. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  568. if (!self || !self->mSkySettings) return; // Paranoia
  569. self->mSkySettings->setCloudScale(self->mCloudScaleCtrl->getValueF32());
  570. self->updateSettings();
  571. }
  572. //static
  573. void LLPanelEnvSettingsSky::onCloudVarianceChanged(LLUICtrl*, void* userdata)
  574. {
  575. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  576. if (!self || !self->mSkySettings) return; // Paranoia
  577. F32 value = self->mCloudVarianceCtrl->getValueF32();
  578. self->mSkySettings->setCloudVariance(value);
  579. self->updateSettings();
  580. }
  581. //static
  582. void LLPanelEnvSettingsSky::onCloudScrollChanged(LLUICtrl*, void* userdata)
  583. {
  584. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  585. if (!self || !self->mSkySettings) return; // Paranoia
  586. LLVector2 vect(self->mCloudScrollCtrl->getValue());
  587. self->mSkySettings->setCloudScrollRate(vect);
  588. self->updateSettings();
  589. }
  590. //static
  591. void LLPanelEnvSettingsSky::onCloudDensityChanged(LLUICtrl*, void* userdata)
  592. {
  593. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  594. if (!self || !self->mSkySettings) return; // Paranoia
  595. F32 x = self->mCloudDensityXCtrl->getValueF32();
  596. F32 y = self->mCloudDensityYCtrl->getValueF32();
  597. F32 z = self->mCloudDensityDCtrl->getValueF32();
  598. self->mSkySettings->setCloudPosDensity1(LLColor3(x, y, z));
  599. self->updateSettings();
  600. }
  601. //static
  602. void LLPanelEnvSettingsSky::onCloudDetailChanged(LLUICtrl*, void* userdata)
  603. {
  604. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  605. if (!self || !self->mSkySettings) return; // Paranoia
  606. F32 x = self->mCloudDetailXCtrl->getValueF32();
  607. F32 y = self->mCloudDetailYCtrl->getValueF32();
  608. F32 z = self->mCloudDetailDCtrl->getValueF32();
  609. self->mSkySettings->setCloudPosDensity2(LLColor3(x, y, z));
  610. self->updateSettings();
  611. }
  612. //static
  613. void LLPanelEnvSettingsSky::onSunRotationChanged(LLUICtrl*, void* userdata)
  614. {
  615. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  616. if (!self || !self->mSkySettings) return; // Paranoia
  617. self->mSkySettings->setSunRotation(self->mSunRotationCtrl->getRotation());
  618. self->updateSettings();
  619. }
  620. //static
  621. void LLPanelEnvSettingsSky::onMoonRotationChanged(LLUICtrl*, void* userdata)
  622. {
  623. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  624. if (!self || !self->mSkySettings) return; // Paranoia
  625. self->mSkySettings->setMoonRotation(self->mMoonRotationCtrl->getRotation());
  626. self->updateSettings();
  627. }
  628. //static
  629. void LLPanelEnvSettingsSky::onSunImageChanged(LLUICtrl*, void* userdata)
  630. {
  631. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  632. if (!self || !self->mSkySettings) return; // Paranoia
  633. const LLUUID& image_id = self->mSunImageCtrl->getImageAssetID();
  634. self->mSkySettings->setSunTextureId(image_id);
  635. self->updateSettings();
  636. }
  637. //static
  638. void LLPanelEnvSettingsSky::onMoonImageChanged(LLUICtrl*, void* userdata)
  639. {
  640. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  641. if (!self || !self->mSkySettings) return; // Paranoia
  642. const LLUUID& image_id = self->mMoonImageCtrl->getImageAssetID();
  643. self->mSkySettings->setMoonTextureId(image_id);
  644. self->updateSettings();
  645. }
  646. //static
  647. void LLPanelEnvSettingsSky::onSunlightColorChanged(LLUICtrl*, void* userdata)
  648. {
  649. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  650. if (!self || !self->mSkySettings) return; // Paranoia
  651. LLColor3 color(self->mSunLightColorCtrl->get());
  652. self->mSkySettings->setSunlightColor(color * SLIDER_SCALE_SUN_AMBIENT);
  653. self->updateSettings();
  654. }
  655. //static
  656. void LLPanelEnvSettingsSky::onSunScaleChanged(LLUICtrl*, void* userdata)
  657. {
  658. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  659. if (!self || !self->mSkySettings) return; // Paranoia
  660. self->mSkySettings->setSunScale(self->mSunScaleCtrl->getValueF32());
  661. self->updateSettings();
  662. }
  663. //static
  664. void LLPanelEnvSettingsSky::onMoonScaleChanged(LLUICtrl*, void* userdata)
  665. {
  666. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  667. if (!self || !self->mSkySettings) return; // Paranoia
  668. self->mSkySettings->setMoonScale(self->mMoonScaleCtrl->getValueF32());
  669. self->updateSettings();
  670. }
  671. //static
  672. void LLPanelEnvSettingsSky::onGlowChanged(LLUICtrl*, void* userdata)
  673. {
  674. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  675. if (!self || !self->mSkySettings) return; // Paranoia
  676. // Turns [0.0-1.99] UI range to [40.0-0.2] range
  677. F32 x = (2.f - self->mGlowSizeCtrl->getValueF32()) * SLIDER_SCALE_GLOW_R;
  678. F32 z = self->mGlowFocusCtrl->getValueF32() * SLIDER_SCALE_GLOW_B;
  679. self->mSkySettings->setGlow(LLColor3(x, 0.f, z));
  680. self->updateSettings();
  681. }
  682. //static
  683. void LLPanelEnvSettingsSky::onMoonBrightnessChanged(LLUICtrl*, void* userdata)
  684. {
  685. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  686. if (!self || !self->mSkySettings) return; // Paranoia
  687. F32 value = self->mMoonBrightnessCtrl->getValueF32();
  688. self->mSkySettings->setMoonBrightness(value);
  689. self->updateSettings();
  690. }
  691. //static
  692. void LLPanelEnvSettingsSky::onStarBrightnessChanged(LLUICtrl*, void* userdata)
  693. {
  694. LLPanelEnvSettingsSky* self = (LLPanelEnvSettingsSky*)userdata;
  695. if (!self || !self->mSkySettings) return; // Paranoia
  696. F32 value = self->mStarBrightnessCtrl->getValueF32();
  697. self->mSkySettings->setStarBrightness(value);
  698. self->updateSettings();
  699. }
  700. ///////////////////////////////////////////////////////////////////////////////
  701. // LLPanelEnvSettingsWater class
  702. ///////////////////////////////////////////////////////////////////////////////
  703. LLPanelEnvSettingsWater::LLPanelEnvSettingsWater()
  704. : LLPanelEnvSettings()
  705. {
  706. LLUICtrlFactory::getInstance()->buildPanel(this,
  707. "panel_settings_water.xml");
  708. }
  709. //virtual
  710. bool LLPanelEnvSettingsWater::postBuild()
  711. {
  712. mFogColorCtrl = getChild<LLColorSwatchCtrl>("water_fog_color");
  713. mFogColorCtrl->setCommitCallback(onFogColorChanged);
  714. mFogColorCtrl->setCallbackUserData(this);
  715. mFogDensityCtrl = getChild<LLSliderCtrl>("water_fog_density");
  716. mFogDensityCtrl->setCommitCallback(onFogDensityChanged);
  717. mFogDensityCtrl->setCallbackUserData(this);
  718. mUnderwaterModCtrl = getChild<LLSliderCtrl>("water_underwater_mod");
  719. mUnderwaterModCtrl->setCommitCallback(onFogUnderWaterChanged);
  720. mUnderwaterModCtrl->setCallbackUserData(this);
  721. mFresnelScaleCtrl = getChild<LLSliderCtrl>("water_fresnel_scale");
  722. mFresnelScaleCtrl->setCommitCallback(onFresnelScaleChanged);
  723. mFresnelScaleCtrl->setCallbackUserData(this);
  724. mFresnelOffsetCtrl = getChild<LLSliderCtrl>("water_fresnel_offset");
  725. mFresnelOffsetCtrl->setCommitCallback(onFresnelOffsetChanged);
  726. mFresnelOffsetCtrl->setCallbackUserData(this);
  727. mNormalMapCtrl = getChild<LLTextureCtrl>("water_normal_map");
  728. mNormalMapCtrl->setDefaultImageAssetID(LLSettingsWater::getDefaultWaterNormalAssetId());
  729. mNormalMapCtrl->setCommitCallback(onNormalMapChanged);
  730. mNormalMapCtrl->setCallbackUserData(this);
  731. mNormalScaleXCtrl = getChild<LLSliderCtrl>("water_normal_scale_x");
  732. mNormalScaleXCtrl->setCommitCallback(onNormalScaleChanged);
  733. mNormalScaleXCtrl->setCallbackUserData(this);
  734. mNormalScaleYCtrl = getChild<LLSliderCtrl>("water_normal_scale_y");
  735. mNormalScaleYCtrl->setCommitCallback(onNormalScaleChanged);
  736. mNormalScaleYCtrl->setCallbackUserData(this);
  737. mNormalScaleZCtrl = getChild<LLSliderCtrl>("water_normal_scale_z");
  738. mNormalScaleZCtrl->setCommitCallback(onNormalScaleChanged);
  739. mNormalScaleZCtrl->setCallbackUserData(this);
  740. mLargeWaveCtrl = getChild<LLXYVector>("large_wave_xy");
  741. mLargeWaveCtrl->setCommitCallback(onLargeWaveChanged);
  742. mLargeWaveCtrl->setCallbackUserData(this);
  743. mSmallWaveCtrl = getChild<LLXYVector>("small_wave_xy");
  744. mSmallWaveCtrl->setCommitCallback(onSmallWaveChanged);
  745. mSmallWaveCtrl->setCallbackUserData(this);
  746. mRefractionAboveCtrl = getChild<LLSliderCtrl>("water_scale_above");
  747. mRefractionAboveCtrl->setCommitCallback(onScaleAboveChanged);
  748. mRefractionAboveCtrl->setCallbackUserData(this);
  749. mRefractionBelowCtrl = getChild<LLSliderCtrl>("water_scale_below");
  750. mRefractionBelowCtrl->setCommitCallback(onScaleBelowChanged);
  751. mRefractionBelowCtrl->setCallbackUserData(this);
  752. mBlurMultiplierCtrl = getChild<LLSliderCtrl>("water_blur_mult");
  753. mBlurMultiplierCtrl->setCommitCallback(onBlurMultChanged);
  754. mBlurMultiplierCtrl->setCallbackUserData(this);
  755. refresh();
  756. return true;
  757. }
  758. //virtual
  759. void LLPanelEnvSettingsWater::setEnabled(bool enabled)
  760. {
  761. mFogColorCtrl->setEnabled(enabled);
  762. mFogDensityCtrl->setEnabled(enabled);
  763. mUnderwaterModCtrl->setEnabled(enabled);
  764. mFresnelScaleCtrl->setEnabled(enabled);
  765. mFresnelOffsetCtrl->setEnabled(enabled);
  766. mNormalMapCtrl->setEnabled(enabled);
  767. mNormalScaleXCtrl->setEnabled(enabled);
  768. mNormalScaleYCtrl->setEnabled(enabled);
  769. mNormalScaleZCtrl->setEnabled(enabled);
  770. mLargeWaveCtrl->setEnabled(enabled);
  771. mSmallWaveCtrl->setEnabled(enabled);
  772. mRefractionAboveCtrl->setEnabled(enabled);
  773. mRefractionBelowCtrl->setEnabled(enabled);
  774. mBlurMultiplierCtrl->setEnabled(enabled);
  775. LLPanel::setEnabled(enabled);
  776. }
  777. //virtual
  778. void LLPanelEnvSettingsWater::refresh()
  779. {
  780. if (!mWaterSettings || !canEdit())
  781. {
  782. setEnabled(false);
  783. return;
  784. }
  785. setEnabled(true);
  786. mFogColorCtrl->set(mWaterSettings->getWaterFogColor());
  787. mFogDensityCtrl->setValue(mWaterSettings->getWaterFogDensity());
  788. mUnderwaterModCtrl->setValue(mWaterSettings->getFogMod());
  789. mFresnelScaleCtrl->setValue(mWaterSettings->getFresnelScale());
  790. mFresnelOffsetCtrl->setValue(mWaterSettings->getFresnelOffset());
  791. mNormalMapCtrl->setImageAssetID(mWaterSettings->getNormalMapID());
  792. LLVector3 normal_scale = mWaterSettings->getNormalScale();
  793. mNormalScaleXCtrl->setValue(normal_scale[VX]);
  794. mNormalScaleYCtrl->setValue(normal_scale[VY]);
  795. mNormalScaleZCtrl->setValue(normal_scale[VZ]);
  796. // Flipped so that North and East are positive in UI
  797. LLVector2 dir = mWaterSettings->getWave1Dir();
  798. mLargeWaveCtrl->setValue(-dir.mV[VX], -dir.mV[VY]);
  799. dir = mWaterSettings->getWave2Dir();
  800. mSmallWaveCtrl->setValue(-dir.mV[VX], -dir.mV[VY]);
  801. mRefractionAboveCtrl->setValue(mWaterSettings->getScaleAbove());
  802. mRefractionBelowCtrl->setValue(mWaterSettings->getScaleBelow());
  803. mBlurMultiplierCtrl->setValue(mWaterSettings->getBlurMultiplier());
  804. LLPanel::refresh();
  805. }
  806. //virtual
  807. void LLPanelEnvSettingsWater::setSettings(const LLSettingsBase::ptr_t& settings,
  808. bool reset_dirty)
  809. {
  810. setWater(std::static_pointer_cast<LLSettingsWater>(settings), reset_dirty);
  811. }
  812. void LLPanelEnvSettingsWater::setWater(const LLSettingsWater::ptr_t& settings,
  813. bool reset_dirty)
  814. {
  815. mWaterSettings = settings;
  816. if (reset_dirty)
  817. {
  818. setDirty(false);
  819. }
  820. refresh();
  821. }
  822. //virtual
  823. LLSettingsBase::ptr_t LLPanelEnvSettingsWater::getSettingsClone()
  824. {
  825. LLSettingsBase::ptr_t clone;
  826. if (mWaterSettings)
  827. {
  828. clone = mWaterSettings->buildClone();
  829. }
  830. return clone;
  831. }
  832. //virtual
  833. bool LLPanelEnvSettingsWater::hasLocalTextures(LLSD& args)
  834. {
  835. if (mWaterSettings)
  836. {
  837. if (LLLocalBitmap::isLocal(mWaterSettings->getNormalMapID()))
  838. {
  839. args["FIELD"] = getString("normalmap");
  840. return true;
  841. }
  842. if (LLLocalBitmap::isLocal(mWaterSettings->getTransparentTextureID()))
  843. {
  844. args["FIELD"] = getString("transparent");
  845. return true;
  846. }
  847. }
  848. return false;
  849. }
  850. //virtual
  851. void LLPanelEnvSettingsWater::updateEditEnvironment()
  852. {
  853. if (mWaterSettings)
  854. {
  855. gEnvironment.setEnvironment(LLEnvironment::ENV_EDIT, mWaterSettings);
  856. gEnvironment.updateEnvironment(LLEnvironment::TRANSITION_FAST);
  857. }
  858. }
  859. //virtual
  860. void LLPanelEnvSettingsWater::updateLocal()
  861. {
  862. if (mWaterSettings)
  863. {
  864. gEnvironment.setEnvironment(LLEnvironment::ENV_LOCAL, mWaterSettings);
  865. }
  866. }
  867. //virtual
  868. void LLPanelEnvSettingsWater::updateParcel(S32 parcel_id)
  869. {
  870. if (mWaterSettings)
  871. {
  872. gEnvironment.updateParcel(parcel_id, mWaterSettings, -1, -1);
  873. }
  874. }
  875. //virtual
  876. void LLPanelEnvSettingsWater::updateRegion()
  877. {
  878. if (mWaterSettings)
  879. {
  880. gEnvironment.updateRegion(mWaterSettings, -1, -1);
  881. }
  882. }
  883. //static
  884. void LLPanelEnvSettingsWater::onFogColorChanged(LLUICtrl*, void* userdata)
  885. {
  886. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  887. if (!self || !self->mWaterSettings) return; // Paranoia
  888. self->mWaterSettings->setWaterFogColor(LLColor3(self->mFogColorCtrl->get()));
  889. self->mWaterSettings->update();
  890. self->setDirty();
  891. }
  892. //static
  893. void LLPanelEnvSettingsWater::onNormalMapChanged(LLUICtrl*, void* userdata)
  894. {
  895. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  896. if (!self || !self->mWaterSettings) return; // Paranoia
  897. const LLUUID& map_id = self->mNormalMapCtrl->getImageAssetID();
  898. self->mWaterSettings->setNormalMapID(map_id);
  899. self->mWaterSettings->update();
  900. self->setDirty();
  901. }
  902. //static
  903. void LLPanelEnvSettingsWater::onFogDensityChanged(LLUICtrl*, void* userdata)
  904. {
  905. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  906. if (!self || !self->mWaterSettings) return; // Paranoia
  907. F32 value = self->mFogDensityCtrl->getValueF32();
  908. self->mWaterSettings->setWaterFogDensity(value);
  909. self->mWaterSettings->update();
  910. self->setDirty();
  911. }
  912. //static
  913. void LLPanelEnvSettingsWater::onFogUnderWaterChanged(LLUICtrl*, void* userdata)
  914. {
  915. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  916. if (!self || !self->mWaterSettings) return; // Paranoia
  917. self->mWaterSettings->setFogMod(self->mUnderwaterModCtrl->getValueF32());
  918. self->mWaterSettings->update();
  919. self->setDirty();
  920. }
  921. //static
  922. void LLPanelEnvSettingsWater::onLargeWaveChanged(LLUICtrl*, void* userdata)
  923. {
  924. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  925. if (!self || !self->mWaterSettings) return; // Paranoia
  926. LLVector2 vect(self->mLargeWaveCtrl->getValue());
  927. // Vector flipped so that North and East are negative in settings
  928. self->mWaterSettings->setWave1Dir(-vect);
  929. self->mWaterSettings->update();
  930. self->setDirty();
  931. }
  932. //static
  933. void LLPanelEnvSettingsWater::onSmallWaveChanged(LLUICtrl*, void* userdata)
  934. {
  935. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  936. if (!self || !self->mWaterSettings) return; // Paranoia
  937. LLVector2 vect(self->mSmallWaveCtrl->getValue());
  938. // Vector flipped so that North and East are negative in settings
  939. self->mWaterSettings->setWave2Dir(-vect);
  940. self->mWaterSettings->update();
  941. self->setDirty();
  942. }
  943. //static
  944. void LLPanelEnvSettingsWater::onNormalScaleChanged(LLUICtrl*, void* userdata)
  945. {
  946. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  947. if (!self || !self->mWaterSettings) return; // Paranoia
  948. F32 x = self->mNormalScaleXCtrl->getValueF32();
  949. F32 y = self->mNormalScaleYCtrl->getValueF32();
  950. F32 z = self->mNormalScaleZCtrl->getValueF32();
  951. self->mWaterSettings->setNormalScale(LLVector3(x, y, z));
  952. self->mWaterSettings->update();
  953. self->setDirty();
  954. }
  955. //static
  956. void LLPanelEnvSettingsWater::onFresnelScaleChanged(LLUICtrl*, void* userdata)
  957. {
  958. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  959. if (!self || !self->mWaterSettings) return; // Paranoia
  960. F32 value = self->mFresnelScaleCtrl->getValueF32();
  961. self->mWaterSettings->setFresnelScale(value);
  962. self->mWaterSettings->update();
  963. self->setDirty();
  964. }
  965. //static
  966. void LLPanelEnvSettingsWater::onFresnelOffsetChanged(LLUICtrl*, void* userdata)
  967. {
  968. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  969. if (!self || !self->mWaterSettings) return; // Paranoia
  970. F32 value = self->mFresnelOffsetCtrl->getValueF32();
  971. self->mWaterSettings->setFresnelOffset(value);
  972. self->mWaterSettings->update();
  973. self->setDirty();
  974. }
  975. //static
  976. void LLPanelEnvSettingsWater::onScaleAboveChanged(LLUICtrl*, void* userdata)
  977. {
  978. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  979. if (!self || !self->mWaterSettings) return; // Paranoia
  980. F32 value = self->mRefractionAboveCtrl->getValueF32();
  981. self->mWaterSettings->setScaleAbove(value);
  982. self->mWaterSettings->update();
  983. self->setDirty();
  984. }
  985. //static
  986. void LLPanelEnvSettingsWater::onScaleBelowChanged(LLUICtrl*, void* userdata)
  987. {
  988. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  989. if (!self || !self->mWaterSettings) return; // Paranoia
  990. F32 value = self->mRefractionBelowCtrl->getValueF32();
  991. self->mWaterSettings->setScaleBelow(value);
  992. self->mWaterSettings->update();
  993. self->setDirty();
  994. }
  995. //static
  996. void LLPanelEnvSettingsWater::onBlurMultChanged(LLUICtrl*, void* userdata)
  997. {
  998. LLPanelEnvSettingsWater* self = (LLPanelEnvSettingsWater*)userdata;
  999. if (!self || !self->mWaterSettings) return; // Paranoia
  1000. F32 value = self->mBlurMultiplierCtrl->getValueF32();
  1001. self->mWaterSettings->setBlurMultiplier(value);
  1002. self->mWaterSettings->update();
  1003. self->setDirty();
  1004. }
  1005. ///////////////////////////////////////////////////////////////////////////////
  1006. // LLFloaterTrackPicker class
  1007. ///////////////////////////////////////////////////////////////////////////////
  1008. class LLFloaterTrackPicker final : public LLFloater
  1009. {
  1010. protected:
  1011. LOG_CLASS(LLFloaterTrackPicker);
  1012. public:
  1013. LLFloaterTrackPicker(LLPanelEnvSettingsDay* owner, const LLSD& args);
  1014. ~LLFloaterTrackPicker() override;
  1015. bool postBuild() override;
  1016. void onFocusLost() override;
  1017. private:
  1018. static void onButtonCancel(void* userdata);
  1019. static void onButtonSelect(void* userdata);
  1020. private:
  1021. LLPanelEnvSettingsDay* mOwner;
  1022. LLRadioGroup* mRadioGroup;
  1023. const LLSD mArgs;
  1024. };
  1025. LLFloaterTrackPicker::LLFloaterTrackPicker(LLPanelEnvSettingsDay* owner,
  1026. const LLSD& args)
  1027. : mOwner(owner),
  1028. mArgs(args)
  1029. {
  1030. LLUICtrlFactory::getInstance()->buildFloater(this,
  1031. "floater_pick_day_track.xml");
  1032. }
  1033. //virtual
  1034. LLFloaterTrackPicker::~LLFloaterTrackPicker()
  1035. {
  1036. gFocusMgr.releaseFocusIfNeeded(this);
  1037. }
  1038. //virtual
  1039. bool LLFloaterTrackPicker::postBuild()
  1040. {
  1041. childSetAction("select_btn", onButtonSelect, this);
  1042. childSetAction("cancel_btn", onButtonCancel, this);
  1043. mRadioGroup = getChild<LLRadioGroup>("track_selection");
  1044. std::string altitude;
  1045. bool select_item = true;
  1046. for (LLSD::array_const_iterator it = mArgs.beginArray(),
  1047. end = mArgs.endArray();
  1048. it != end; ++it)
  1049. {
  1050. const LLSD& element = *it;
  1051. S32 track_id = element["id"].asInteger();
  1052. bool enabled = element["enabled"].asBoolean();
  1053. if (element.has("altitude"))
  1054. {
  1055. altitude = element["altitude"].asString() + "m";
  1056. }
  1057. else
  1058. {
  1059. altitude = " ";
  1060. }
  1061. LLCheckBoxCtrl* checkboxp =
  1062. getChild<LLCheckBoxCtrl>(llformat("%d", track_id).c_str());
  1063. checkboxp->setEnabled(enabled);
  1064. checkboxp->setLabelArg("[ALT]", altitude);
  1065. if (enabled && select_item)
  1066. {
  1067. select_item = false;
  1068. mRadioGroup->setSelectedByValue(LLSD(track_id), true);
  1069. }
  1070. }
  1071. // Search for our owner's parent floater and register as dependent of it
  1072. // if found.
  1073. LLView* parentp = mOwner;
  1074. while (parentp)
  1075. {
  1076. LLFloater* floaterp = parentp->asFloater();
  1077. if (floaterp)
  1078. {
  1079. floaterp->addDependentFloater(this);
  1080. break;
  1081. }
  1082. parentp = parentp->getParent();
  1083. }
  1084. return true;
  1085. }
  1086. //virtual
  1087. void LLFloaterTrackPicker::onFocusLost()
  1088. {
  1089. close();
  1090. }
  1091. //static
  1092. void LLFloaterTrackPicker::onButtonCancel(void* userdata)
  1093. {
  1094. LLFloaterTrackPicker* self = (LLFloaterTrackPicker*)userdata;
  1095. if (self)
  1096. {
  1097. self->close();
  1098. }
  1099. }
  1100. //static
  1101. void LLFloaterTrackPicker::onButtonSelect(void* userdata)
  1102. {
  1103. LLFloaterTrackPicker* self = (LLFloaterTrackPicker*)userdata;
  1104. if (!self) return; // Paranoia
  1105. self->mOwner->onPickerCommitTrackId(self->mRadioGroup->getSelectedValue());
  1106. self->close();
  1107. }
  1108. ///////////////////////////////////////////////////////////////////////////////
  1109. // LLPanelEnvSettingsDay class
  1110. ///////////////////////////////////////////////////////////////////////////////
  1111. constexpr F32 DAY_CYCLE_PLAY_TIME_SECONDS = 60.f;
  1112. //static
  1113. void* LLPanelEnvSettingsDay::createSkySettingsPanel(void* userdata)
  1114. {
  1115. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  1116. self->mSkyPanel = new LLPanelEnvSettingsSky();
  1117. return self->mSkyPanel;
  1118. }
  1119. //static
  1120. void* LLPanelEnvSettingsDay::createWaterSettingsPanel(void* userdata)
  1121. {
  1122. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  1123. self->mWaterPanel = new LLPanelEnvSettingsWater();
  1124. return self->mWaterPanel;
  1125. }
  1126. LLPanelEnvSettingsDay::LLPanelEnvSettingsDay()
  1127. : LLPanelEnvSettings(),
  1128. mScratchSky(LLEnvSettingsSky::buildDefaultSky()),
  1129. mScratchWater(LLEnvSettingsWater::buildDefaultWater()),
  1130. mCurrentTrack(1),
  1131. mCurrentFrame(0.f),
  1132. mOnOpenRefreshTime(-1.f),
  1133. mPlayStartFrame(0.f),
  1134. mDayLength(0),
  1135. mIsPlaying(false)
  1136. {
  1137. LLCallbackMap::map_t factory_map;
  1138. factory_map["sky_panel"] = LLCallbackMap(createSkySettingsPanel, this);
  1139. factory_map["water_panel"] = LLCallbackMap(createWaterSettingsPanel, this);
  1140. LLUICtrlFactory::getInstance()->buildPanel(this, "panel_settings_day.xml",
  1141. &factory_map);
  1142. }
  1143. //virtual
  1144. LLPanelEnvSettingsDay::~LLPanelEnvSettingsDay()
  1145. {
  1146. stopPlay();
  1147. }
  1148. //virtual
  1149. bool LLPanelEnvSettingsDay::postBuild()
  1150. {
  1151. // If LLSettingsDay::TRACK_MAX ever changes, we will have to adjust the
  1152. // number of track buttons !
  1153. llassert_always(LLSettingsDay::TRACK_MAX == 5);
  1154. mWaterTrackBtn = getChild<LLButton>("water_track");
  1155. mWaterTrackBtn->setClickedCallback(onTrack0Button, this);
  1156. mTrackButtons.push_back(mWaterTrackBtn);
  1157. mSky1TrackBtn = getChild<LLButton>("sky1_track");
  1158. mSky1TrackBtn->setClickedCallback(onTrack1Button, this);
  1159. mTrackButtons.push_back(mSky1TrackBtn);
  1160. mSky2TrackBtn = getChild<LLButton>("sky2_track");
  1161. mSky2TrackBtn->setClickedCallback(onTrack2Button, this);
  1162. mTrackButtons.push_back(mSky2TrackBtn);
  1163. mSky3TrackBtn = getChild<LLButton>("sky3_track");
  1164. mSky3TrackBtn->setClickedCallback(onTrack3Button, this);
  1165. mTrackButtons.push_back(mSky3TrackBtn);
  1166. mSky4TrackBtn = getChild<LLButton>("sky4_track");
  1167. mSky4TrackBtn->setClickedCallback(onTrack4Button, this);
  1168. mTrackButtons.push_back(mSky4TrackBtn);
  1169. mCloneTrackBtn = getChild<LLButton>("clone_track");
  1170. mCloneTrackBtn->setClickedCallback(onCloneTrack, this);
  1171. mLoadTrackBtn = getChild<LLButton>("load_track");
  1172. mLoadTrackBtn->setClickedCallback(onLoadTrack, this);
  1173. mClearTrackBtn = getChild<LLButton>("clear_track");
  1174. mClearTrackBtn->setClickedCallback(onClearTrack, this);
  1175. mAddFrameBtn = getChild<LLButton>("add_frame");
  1176. mAddFrameBtn->setClickedCallback(onAddFrame, this);
  1177. mLoadFrameBtn = getChild<LLButton>("load_frame");
  1178. mLoadFrameBtn->setClickedCallback(onLoadFrame, this);
  1179. mDeleteFrameBtn = getChild<LLButton>("delete_frame");
  1180. mDeleteFrameBtn->setClickedCallback(onRemoveFrame, this);
  1181. mPlayBtn = getChild<LLButton>("play_btn");
  1182. mPlayBtn->setClickedCallback(onPlay, this);
  1183. mStopBtn = getChild<LLButton>("stop_btn");
  1184. mStopBtn->setClickedCallback(onStop, this);
  1185. mForwardBtn = getChild<LLButton>("forward_btn");
  1186. mForwardBtn->setClickedCallback(onForward, this);
  1187. mBackwardBtn = getChild<LLButton>("backward_btn");
  1188. mBackwardBtn->setClickedCallback(onBackward, this);
  1189. mTimeSlider = getChild<LLMultiSliderCtrl>("time_slider");
  1190. mTimeSlider->addSlider(0);
  1191. mTimeSlider->setCommitCallback(onTimeSliderCallback);
  1192. mTimeSlider->setCallbackUserData(this);
  1193. mFramesSlider = getChild<LLMultiSliderCtrl>("frames_slider");
  1194. mFramesSlider->setCommitCallback(onFrameSliderCallback);
  1195. mFramesSlider->setCallbackUserData(this);
  1196. #if 0 // *TODO: implement double-click callback support in LLMultiSliderCtrl
  1197. mFramesSlider->setDoubleClickCallback(onFrameSliderDoubleClick);
  1198. #endif
  1199. mFramesSlider->setSliderMouseDownCallback(onFrameSliderMouseDown);
  1200. mFramesSlider->setSliderMouseUpCallback(onFrameSliderMouseUp);
  1201. mEditLockedText = getChild<LLTextBox>("lock_edit");
  1202. mCurrentTimeText = getChild<LLTextBox>("current_time");
  1203. mWaterLabel = getString("water_label");
  1204. mSkyLabel = getString("sky_label");
  1205. selectTrack(LLSettingsDay::TRACK_GROUND_LEVEL, true);
  1206. refresh();
  1207. return true;
  1208. }
  1209. //virtual
  1210. void LLPanelEnvSettingsDay::setEnabled(bool enabled)
  1211. {
  1212. mWaterTrackBtn->setEnabled(enabled);
  1213. mSky1TrackBtn->setEnabled(enabled);
  1214. mSky2TrackBtn->setEnabled(enabled);
  1215. mSky3TrackBtn->setEnabled(enabled);
  1216. mSky4TrackBtn->setEnabled(enabled);
  1217. mTimeSlider->setEnabled(enabled);
  1218. mFramesSlider->setEnabled(enabled);
  1219. mCloneTrackBtn->setEnabled(enabled);
  1220. mClearTrackBtn->setEnabled(enabled);
  1221. mAddFrameBtn->setEnabled(enabled);
  1222. mDeleteFrameBtn->setEnabled(enabled);
  1223. mLoadTrackBtn->setEnabled(enabled);
  1224. mLoadFrameBtn->setEnabled(enabled);
  1225. bool got_frames = !mSliderKeyMap.empty();
  1226. mPlayBtn->setEnabled(enabled && got_frames);
  1227. mStopBtn->setEnabled(enabled && got_frames);
  1228. mForwardBtn->setEnabled(enabled && got_frames);
  1229. mBackwardBtn->setEnabled(enabled && got_frames);
  1230. mEditLockedText->setEnabled(enabled);
  1231. mCurrentTimeText->setEnabled(enabled);
  1232. bool show_sky = mCurrentTrack != LLSettingsDay::TRACK_WATER;
  1233. mWaterPanel->setVisible(enabled && !show_sky);
  1234. mSkyPanel->setVisible(enabled && show_sky);
  1235. LLPanel::setEnabled(enabled);
  1236. }
  1237. //virtual
  1238. bool LLPanelEnvSettingsDay::isDirty() const
  1239. {
  1240. // Propagate dirty state from panels as well...
  1241. return mIsDirty || mWaterPanel->isDirty() || mSkyPanel->isDirty();
  1242. }
  1243. //virtual
  1244. void LLPanelEnvSettingsDay::setDirty(bool dirty)
  1245. {
  1246. mIsDirty = dirty;
  1247. // Propagate dirty state to panels as well...
  1248. mWaterPanel->setDirty(dirty);
  1249. mSkyPanel->setDirty(dirty);
  1250. }
  1251. //virtual
  1252. void LLPanelEnvSettingsDay::draw()
  1253. {
  1254. // *HACK: to work around a race condition on asset loading at panel
  1255. // creation (and initial refresh) time, in order to get the water and sky
  1256. // settings refreshed properly...
  1257. if (mOnOpenRefreshTime > 0.f && gFrameTimeSeconds > mOnOpenRefreshTime)
  1258. {
  1259. mOnOpenRefreshTime = 0.f;
  1260. selectTrack(LLSettingsDay::TRACK_GROUND_LEVEL, true);
  1261. }
  1262. LLPanel::draw();
  1263. }
  1264. //virtual
  1265. void LLPanelEnvSettingsDay::refresh()
  1266. {
  1267. if (!mDaySettings || !canEdit())
  1268. {
  1269. setEnabled(false);
  1270. return;
  1271. }
  1272. setEnabled(true);
  1273. mPlayBtn->setVisible(!mIsPlaying);
  1274. mStopBtn->setVisible(mIsPlaying);
  1275. bool show_sky = mCurrentTrack != LLSettingsDay::TRACK_WATER;
  1276. bool can_manipulate = !mIsPlaying && canEdit();
  1277. mLoadTrackBtn->setEnabled(can_manipulate);
  1278. mLoadFrameBtn->setEnabled(can_manipulate);
  1279. mLoadFrameBtn->setLabelArg("[FRAME]", show_sky ? mSkyLabel : mWaterLabel);
  1280. mAddFrameBtn->setEnabled(can_manipulate && isAddingFrameAllowed());
  1281. mAddFrameBtn->setLabelArg("[FRAME]", show_sky ? mSkyLabel : mWaterLabel);
  1282. mDeleteFrameBtn->setEnabled(can_manipulate && isRemovingFrameAllowed());
  1283. mDeleteFrameBtn->setLabelArg("[FRAME]",
  1284. show_sky ? mSkyLabel : mWaterLabel);
  1285. bool can_clone = false;
  1286. bool can_clear = false;
  1287. if (can_manipulate)
  1288. {
  1289. if (show_sky)
  1290. {
  1291. for (S32 i = 1; i < LLSettingsDay::TRACK_MAX; ++i)
  1292. {
  1293. if (i != mCurrentTrack &&
  1294. !mDaySettings->getCycleTrack(i).empty())
  1295. {
  1296. can_clone = true;
  1297. break;
  1298. }
  1299. }
  1300. }
  1301. if (mCurrentTrack > 1)
  1302. {
  1303. can_clear = !mDaySettings->getCycleTrack(mCurrentTrack).empty();
  1304. }
  1305. else
  1306. {
  1307. can_clear = mDaySettings->getCycleTrack(mCurrentTrack).size() > 1;
  1308. }
  1309. }
  1310. mCloneTrackBtn->setEnabled(can_clone);
  1311. mClearTrackBtn->setEnabled(can_clear);
  1312. bool env_available = gAgent.hasExtendedEnvironment();
  1313. for (S32 i = 0; i < LLSettingsDay::TRACK_MAX; ++i)
  1314. {
  1315. LLButton* button = mTrackButtons[i];
  1316. button->setEnabled(env_available);
  1317. button->setToggleState(i == mCurrentTrack);
  1318. }
  1319. mWaterPanel->refresh();
  1320. mSkyPanel->refresh();
  1321. LLPanel::refresh();
  1322. }
  1323. //virtual
  1324. void LLPanelEnvSettingsDay::setFileLoadingAvailable(bool available)
  1325. {
  1326. bool enabled = available && !mIsPlaying && canEdit() && getEnabled();
  1327. mLoadTrackBtn->setEnabled(enabled);
  1328. mLoadFrameBtn->setEnabled(enabled);
  1329. }
  1330. //virtual
  1331. void LLPanelEnvSettingsDay::setSettings(const LLSettingsBase::ptr_t& settings,
  1332. bool reset_dirty)
  1333. {
  1334. setDay(std::static_pointer_cast<LLSettingsDay>(settings), reset_dirty);
  1335. }
  1336. void LLPanelEnvSettingsDay::setDay(const LLSettingsDay::ptr_t& settings,
  1337. bool reset_dirty)
  1338. {
  1339. if (!settings)
  1340. {
  1341. mDaySettings = settings;
  1342. return;
  1343. }
  1344. mDaySettings = settings->buildDeepCloneAndUncompress();
  1345. if (mDaySettings->isTrackEmpty(LLSettingsDay::TRACK_WATER))
  1346. {
  1347. llwarns << "No water frame found, generating replacement." << llendl;
  1348. mDaySettings->setWaterAtKeyframe(LLEnvSettingsWater::buildDefaultWater(),
  1349. 0.5f);
  1350. }
  1351. if (mDaySettings->isTrackEmpty(LLSettingsDay::TRACK_GROUND_LEVEL))
  1352. {
  1353. llwarns << "No sky frame found, generating replacement." << llendl;
  1354. mDaySettings->setSkyAtKeyframe(LLEnvSettingsSky::buildDefaultSky(),
  1355. 0.5f,
  1356. LLSettingsDay::TRACK_GROUND_LEVEL);
  1357. }
  1358. updateEditEnvironment();
  1359. gEnvironment.setSelectedEnvironment(LLEnvironment::ENV_EDIT,
  1360. LLEnvironment::TRANSITION_INSTANT);
  1361. gEnvironment.updateEnvironment(LLEnvironment::TRANSITION_INSTANT);
  1362. updatePanels();
  1363. if (reset_dirty)
  1364. {
  1365. setDirty(false);
  1366. mWaterPanel->setDirty(false);
  1367. mSkyPanel->setDirty(false);
  1368. }
  1369. // *HACK: to work around a race condition on asset loading at panel
  1370. // creation (and initial refresh) time, in order to get the water and sky
  1371. // settings refreshed properly...
  1372. if (mOnOpenRefreshTime != 0.f)
  1373. {
  1374. mOnOpenRefreshTime = gFrameTimeSeconds + 1.f;
  1375. }
  1376. }
  1377. void LLPanelEnvSettingsDay::synchronizePanels()
  1378. {
  1379. if (!mDaySettings)
  1380. {
  1381. return;
  1382. }
  1383. bool can_edit = false;
  1384. LLSettingsBase::ptr_t waterp = mScratchWater;
  1385. LLSettingsBase::ptr_t skyp = mScratchSky;
  1386. std::string cur_slider = mFramesSlider->getCurSlider();
  1387. if (!cur_slider.empty())
  1388. {
  1389. keymap_t::iterator it = mSliderKeyMap.find(cur_slider);
  1390. if (it != mSliderKeyMap.end())
  1391. {
  1392. if (mCurrentTrack == LLSettingsDay::TRACK_WATER)
  1393. {
  1394. waterp = it->second.mSettings;
  1395. }
  1396. else
  1397. {
  1398. skyp = it->second.mSettings;
  1399. }
  1400. can_edit = !mIsPlaying;
  1401. }
  1402. }
  1403. mEditLockedText->setVisible(!can_edit);
  1404. mCurrentTimeText->setVisible(can_edit);
  1405. // Set can edit status first, then set settings
  1406. bool can_actually_edit = can_edit && canEdit();
  1407. mWaterPanel->setCanEdit(can_actually_edit);
  1408. mSkyPanel->setCanEdit(can_actually_edit);
  1409. mWaterPanel->setSettings(waterp, false);
  1410. mSkyPanel->setSettings(skyp, false);
  1411. gEnvironment.setEnvironment(LLEnvironment::ENV_EDIT, mSkyPanel->getSky(),
  1412. mWaterPanel->getWater());
  1413. gEnvironment.updateEnvironment(LLEnvironment::TRANSITION_INSTANT);
  1414. }
  1415. void LLPanelEnvSettingsDay::updatePanels()
  1416. {
  1417. reblendSettings();
  1418. synchronizePanels();
  1419. updateTimeText();
  1420. refresh();
  1421. }
  1422. //virtual
  1423. LLSettingsBase::ptr_t LLPanelEnvSettingsDay::getSettingsClone()
  1424. {
  1425. LLSettingsBase::ptr_t clone;
  1426. if (mDaySettings)
  1427. {
  1428. clone = mDaySettings->buildClone();
  1429. }
  1430. return clone;
  1431. }
  1432. //virtual
  1433. bool LLPanelEnvSettingsDay::hasLocalTextures(LLSD& args)
  1434. {
  1435. if (!mDaySettings)
  1436. {
  1437. return false;
  1438. }
  1439. LLSettingsDay::ptr_t dayclone = mDaySettings->buildClone();
  1440. if (!dayclone)
  1441. {
  1442. return false;
  1443. }
  1444. // Brute-force local texture scan
  1445. std::string field;
  1446. F32 percent = 0.f;
  1447. for (S32 i = 0; i < LLSettingsDay::TRACK_MAX; ++i)
  1448. {
  1449. S32 frame = 0;
  1450. LLSettingsDay::cycle_track_t& track = dayclone->getCycleTrack(i);
  1451. for (LLSettingsDay::cycle_track_it_t it = track.begin(),
  1452. end = track.end();
  1453. it != end; ++it)
  1454. {
  1455. ++frame;
  1456. if (i == LLSettingsDay::TRACK_WATER)
  1457. {
  1458. LLSettingsWater::ptr_t waterp =
  1459. std::static_pointer_cast<LLSettingsWater>(it->second);
  1460. if (LLLocalBitmap::isLocal(waterp->getNormalMapID()))
  1461. {
  1462. field = mWaterPanel->getString("normalmap");
  1463. percent = it->first;
  1464. break;
  1465. }
  1466. if (LLLocalBitmap::isLocal(waterp->getTransparentTextureID()))
  1467. {
  1468. field = mWaterPanel->getString("transparent");
  1469. percent = it->first;
  1470. break;
  1471. }
  1472. }
  1473. else
  1474. {
  1475. LLSettingsSky::ptr_t skyp =
  1476. std::static_pointer_cast<LLSettingsSky>(it->second);
  1477. if (LLLocalBitmap::isLocal(skyp->getSunTextureId()))
  1478. {
  1479. field = mSkyPanel->getString("sun");
  1480. percent = it->first;
  1481. break;
  1482. }
  1483. if (LLLocalBitmap::isLocal(skyp->getMoonTextureId()))
  1484. {
  1485. field = mSkyPanel->getString("moon");
  1486. percent = it->first;
  1487. break;
  1488. }
  1489. if (LLLocalBitmap::isLocal(skyp->getCloudNoiseTextureId()))
  1490. {
  1491. field = mSkyPanel->getString("cloudnoise");
  1492. percent = it->first;
  1493. break;
  1494. }
  1495. if (LLLocalBitmap::isLocal(skyp->getBloomTextureId()))
  1496. {
  1497. field = mSkyPanel->getString("bloom");
  1498. percent = it->first;
  1499. break;
  1500. }
  1501. }
  1502. }
  1503. if (!field.empty())
  1504. {
  1505. args["TRACK"] = mTrackButtons[i]->getCurrentLabel();
  1506. args["FRAME"] = LLSD::Integer(percent * 100.f); // %
  1507. args["FIELD"] = field;
  1508. args["FRAMENO"] = frame;
  1509. return true;
  1510. }
  1511. }
  1512. return false;
  1513. }
  1514. //virtual
  1515. void LLPanelEnvSettingsDay::updateEditEnvironment()
  1516. {
  1517. if (!mDaySettings)
  1518. {
  1519. return;
  1520. }
  1521. S32 skytrack = mCurrentTrack ? mCurrentTrack : 1;
  1522. mSkyBlender = std::make_shared<LLTrackBlenderLoopingManual>(mScratchSky,
  1523. mDaySettings,
  1524. skytrack);
  1525. mWaterBlender =
  1526. std::make_shared<LLTrackBlenderLoopingManual>(mScratchWater,
  1527. mDaySettings,
  1528. LLSettingsDay::TRACK_WATER);
  1529. if (gAgent.hasExtendedEnvironment())
  1530. {
  1531. selectTrack(LLSettingsDay::TRACK_MAX, true);
  1532. }
  1533. else
  1534. {
  1535. selectTrack(LLSettingsDay::TRACK_GROUND_LEVEL, true);
  1536. }
  1537. reblendSettings();
  1538. gEnvironment.setEnvironment(LLEnvironment::ENV_EDIT, mSkyPanel->getSky(),
  1539. mWaterPanel->getWater());
  1540. gEnvironment.updateEnvironment(LLEnvironment::TRANSITION_FAST);
  1541. }
  1542. void LLPanelEnvSettingsDay::reblendSettings()
  1543. {
  1544. F32 position = mTimeSlider->getCurSliderValue();
  1545. if (mSkyBlender)
  1546. {
  1547. if (mCurrentTrack != LLSettingsDay::TRACK_WATER &&
  1548. mSkyBlender->getTrack() != mCurrentTrack)
  1549. {
  1550. mSkyBlender->switchTrack(mCurrentTrack, position);
  1551. }
  1552. else
  1553. {
  1554. mSkyBlender->setPosition(position);
  1555. }
  1556. }
  1557. if (mWaterBlender)
  1558. {
  1559. mWaterBlender->setPosition(position);
  1560. }
  1561. }
  1562. //virtual
  1563. void LLPanelEnvSettingsDay::updateLocal()
  1564. {
  1565. if (mDaySettings)
  1566. {
  1567. gEnvironment.setEnvironment(LLEnvironment::ENV_LOCAL, mDaySettings);
  1568. }
  1569. }
  1570. //virtual
  1571. void LLPanelEnvSettingsDay::updateParcel(S32 parcel_id)
  1572. {
  1573. if (mDaySettings)
  1574. {
  1575. gEnvironment.updateParcel(parcel_id, mDaySettings, -1, -1);
  1576. }
  1577. }
  1578. //virtual
  1579. void LLPanelEnvSettingsDay::updateRegion()
  1580. {
  1581. if (mDaySettings)
  1582. {
  1583. gEnvironment.updateRegion(mDaySettings, -1, -1);
  1584. }
  1585. }
  1586. bool LLPanelEnvSettingsDay::isAddingFrameAllowed()
  1587. {
  1588. if (!mDaySettings || !mFramesSlider->getCurSlider().empty())
  1589. {
  1590. return false;
  1591. }
  1592. F32 frame = mTimeSlider->getCurSliderValue();
  1593. if ((mDaySettings->getSettingsNearKeyframe(frame, mCurrentTrack,
  1594. LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second)
  1595. {
  1596. return false;
  1597. }
  1598. return mFramesSlider->canAddSliders();
  1599. }
  1600. bool LLPanelEnvSettingsDay::isRemovingFrameAllowed()
  1601. {
  1602. if (!mDaySettings || mFramesSlider->getCurSlider().empty())
  1603. {
  1604. return false;
  1605. }
  1606. if (mCurrentTrack <= LLSettingsDay::TRACK_GROUND_LEVEL)
  1607. {
  1608. return mSliderKeyMap.size() > 1;
  1609. }
  1610. else
  1611. {
  1612. return mSliderKeyMap.size() != 0;
  1613. }
  1614. }
  1615. void LLPanelEnvSettingsDay::addSliderFrame(F32 frame,
  1616. const LLSettingsBase::ptr_t& setting,
  1617. bool update_ui)
  1618. {
  1619. std::string new_slider = mFramesSlider->addSlider(frame);
  1620. if (!new_slider.empty())
  1621. {
  1622. mSliderKeyMap[new_slider] = FrameData(frame, setting);
  1623. if (update_ui)
  1624. {
  1625. mTimeSlider->setCurSliderValue(frame);
  1626. updatePanels();
  1627. }
  1628. }
  1629. }
  1630. void LLPanelEnvSettingsDay::removeCurrentSliderFrame()
  1631. {
  1632. std::string slider = mFramesSlider->getCurSlider();
  1633. if (slider.empty() || !mDaySettings)
  1634. {
  1635. return;
  1636. }
  1637. mFramesSlider->deleteCurSlider();
  1638. keymap_t::iterator iter = mSliderKeyMap.find(slider);
  1639. if (iter != mSliderKeyMap.end())
  1640. {
  1641. F32 frame = iter->second.mFrame;
  1642. mDaySettings->removeTrackKeyframe(mCurrentTrack, frame);
  1643. mSliderKeyMap.erase(iter);
  1644. }
  1645. mTimeSlider->setCurSliderValue(mFramesSlider->getCurSliderValue());
  1646. updatePanels();
  1647. }
  1648. void LLPanelEnvSettingsDay::removeSliderFrame(F32 frame)
  1649. {
  1650. keymap_t::iterator it =
  1651. std::find_if(mSliderKeyMap.begin(), mSliderKeyMap.end(),
  1652. [frame](const keymap_t::value_type& value)
  1653. {
  1654. return fabsf(value.second.mFrame - frame) <
  1655. LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR;
  1656. });
  1657. if (it != mSliderKeyMap.end())
  1658. {
  1659. mFramesSlider->deleteSlider(it->first);
  1660. mSliderKeyMap.erase(it);
  1661. }
  1662. }
  1663. void LLPanelEnvSettingsDay::updateSlider()
  1664. {
  1665. // Remember our current frame if any
  1666. F32 frame = mTimeSlider->getCurSliderValue();
  1667. mFramesSlider->clear();
  1668. mSliderKeyMap.clear();
  1669. if (!mDaySettings)
  1670. {
  1671. return;
  1672. }
  1673. LLSettingsDay::cycle_track_t track =
  1674. mDaySettings->getCycleTrack(mCurrentTrack);
  1675. for (auto& track_frame : track)
  1676. {
  1677. addSliderFrame(track_frame.first, track_frame.second, false);
  1678. }
  1679. if (mSliderKeyMap.empty())
  1680. {
  1681. // Disable panels. Set can edit status first, then set settings
  1682. mWaterPanel->setCanEdit(false);
  1683. mSkyPanel->setCanEdit(false);
  1684. mWaterPanel->setWater(LLSettingsWater::ptr_t(NULL));
  1685. mSkyPanel->setSky(LLSettingsSky::ptr_t(NULL));
  1686. }
  1687. selectFrame(frame, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR);
  1688. }
  1689. void LLPanelEnvSettingsDay::updateTimeText()
  1690. {
  1691. if (!mCurrentTimeText->getVisible())
  1692. {
  1693. return;
  1694. }
  1695. if (!mCurrentTimeText->getEnabled())
  1696. {
  1697. mCurrentTimeText->setText("");
  1698. return;
  1699. }
  1700. F32 percent = mTimeSlider->getCurSliderValue();
  1701. std::string time;
  1702. if (mDayLength > 0)
  1703. {
  1704. S32 seconds = S32((F32)mDayLength * percent);
  1705. S32 hours = seconds / 3600;
  1706. S32 minutes = (seconds - 3600 * hours) / 60;
  1707. if (minutes == 60)
  1708. {
  1709. ++hours;
  1710. minutes = 0;
  1711. }
  1712. if (minutes < 10)
  1713. {
  1714. time = llformat("%d:0%d", hours, minutes);
  1715. }
  1716. else
  1717. {
  1718. time = llformat("%d:%d", hours, minutes);
  1719. }
  1720. if (hours < 10)
  1721. {
  1722. time = llformat("%d%% (0%s)", (S32)(percent * 100.f),
  1723. time.c_str());
  1724. }
  1725. else
  1726. {
  1727. time = llformat("%d%% (%s)", (S32)(percent * 100.f), time.c_str());
  1728. }
  1729. }
  1730. else
  1731. {
  1732. time = llformat("%d%%", (S32)(percent * 100.f));
  1733. }
  1734. mCurrentTimeText->setText(time);
  1735. }
  1736. void LLPanelEnvSettingsDay::selectFrame(F32 frame, F32 slop_factor)
  1737. {
  1738. mFramesSlider->resetCurSlider();
  1739. keymap_t::iterator it = mSliderKeyMap.begin();
  1740. keymap_t::iterator end = mSliderKeyMap.end();
  1741. while (it != end)
  1742. {
  1743. F32 keyframe = it->second.mFrame;
  1744. F32 delta = fabsf(keyframe - frame);
  1745. if (delta <= slop_factor)
  1746. {
  1747. keymap_t::iterator next_it = std::next(it);
  1748. if (delta != 0.f && next_it != end &&
  1749. fabsf(next_it->second.mFrame - frame) < delta)
  1750. {
  1751. mFramesSlider->setCurSlider(next_it->first);
  1752. frame = next_it->second.mFrame;
  1753. break;
  1754. }
  1755. mFramesSlider->setCurSlider(it->first);
  1756. frame = it->second.mFrame;
  1757. break;
  1758. }
  1759. ++it;
  1760. }
  1761. mTimeSlider->setCurSliderValue(frame);
  1762. updatePanels();
  1763. }
  1764. void LLPanelEnvSettingsDay::onPickerCommitTrackId(S32 track_id)
  1765. {
  1766. if (mDaySettings && mSourceSettings)
  1767. {
  1768. cloneTrack(mSourceSettings, track_id, mCurrentTrack);
  1769. reblendSettings();
  1770. synchronizePanels();
  1771. }
  1772. }
  1773. void LLPanelEnvSettingsDay::cloneTrack(const LLSettingsDay::ptr_t& src_day,
  1774. S32 src_idx, S32 dst_idx)
  1775. {
  1776. if (!mDaySettings || !src_day)
  1777. {
  1778. return;
  1779. }
  1780. if (src_idx < 0 || dst_idx < 0 || src_idx >= LLSettingsDay::TRACK_MAX ||
  1781. dst_idx >= LLSettingsDay::TRACK_MAX)
  1782. {
  1783. llwarns << "Track index out of range. Aborted. src_idx=" << src_idx
  1784. << " - dst_idx=" << dst_idx << llendl;
  1785. return;
  1786. }
  1787. if (src_idx != dst_idx &&
  1788. (src_idx == LLSettingsDay::TRACK_WATER ||
  1789. dst_idx == LLSettingsDay::TRACK_WATER))
  1790. {
  1791. // One of the tracks is a water track and the other is not
  1792. LLSD args;
  1793. args["TRACK1"] = mTrackButtons[src_idx]->getCurrentLabel();
  1794. args["TRACK2"] = mTrackButtons[dst_idx]->getCurrentLabel();
  1795. gNotifications.add("TrackLoadMismatch", args);
  1796. return;
  1797. }
  1798. // Keep a copy of the current track in case of failure.
  1799. LLSettingsDay::cycle_track_t& backup_track =
  1800. mDaySettings->getCycleTrack(dst_idx);
  1801. mDaySettings->clearCycleTrack(dst_idx); // Because source may be empty
  1802. LLSettingsDay::cycle_track_t& source_track =
  1803. src_day->getCycleTrack(src_idx);
  1804. S32 additions = 0;
  1805. for (auto& track_frame : source_track)
  1806. {
  1807. LLSettingsBase::ptr_t framep = track_frame.second;
  1808. LLSettingsBase::ptr_t clonep = framep->buildDerivedClone();
  1809. if (clonep)
  1810. {
  1811. ++additions;
  1812. mDaySettings->setSettingsAtKeyframe(clonep, track_frame.first,
  1813. dst_idx);
  1814. }
  1815. }
  1816. if (!additions)
  1817. {
  1818. // Nothing was actually added; restore the old track and issue a
  1819. // warning.
  1820. mDaySettings->replaceCycleTrack(dst_idx, backup_track);
  1821. LLSD args;
  1822. args["TRACK"] = mTrackButtons[dst_idx]->getCurrentLabel();
  1823. gNotifications.add("TrackLoadFailed", args);
  1824. }
  1825. setDirty();
  1826. updatePanels();
  1827. }
  1828. void LLPanelEnvSettingsDay::selectTrack(S32 track_index, bool force)
  1829. {
  1830. if (track_index >= 0 && track_index < LLSettingsDay::TRACK_MAX)
  1831. {
  1832. mCurrentTrack = track_index;
  1833. }
  1834. LLButton* buttonp = mTrackButtons[track_index];
  1835. if (buttonp->getToggleState() && !force)
  1836. {
  1837. return;
  1838. }
  1839. refresh();
  1840. updateSlider();
  1841. }
  1842. void LLPanelEnvSettingsDay::onAssetLoaded(const LLUUID& item_id,
  1843. LLSettingsBase::ptr_t settings,
  1844. S32 status)
  1845. {
  1846. if (!mDaySettings)
  1847. {
  1848. return;
  1849. }
  1850. if (!settings || status)
  1851. {
  1852. gNotifications.add("CantFindInvItem");
  1853. return;
  1854. }
  1855. LLViewerInventoryItem* itemp = gInventory.getItem(item_id);
  1856. // This should not happen (already cheched in loadInventoryItem()), but
  1857. // just in case...
  1858. if (!itemp || itemp->getIsBrokenLink())
  1859. {
  1860. llwarns << "Could not find inventory item for Id: " << item_id
  1861. << llendl;
  1862. return;
  1863. }
  1864. // Do not allow at all to import no-trans settings in a transfer-ok item.
  1865. // LL's code allows it by changing the settings (not the item) to no-trans,
  1866. // thus relying on the item getting saved and marked no-transfer at that
  1867. // stage, but I suspect this could be worked around or be the victim of
  1868. // race conditions (between inventory item and settings permissions)... HB
  1869. if (!itemp->getPermissions().allowTransferBy(gAgentID) &&
  1870. !mDaySettings->getFlag(LLSettingsBase::FLAG_NOTRANS))
  1871. {
  1872. gNotifications.add("SettingsMakeNoTrans");
  1873. return;
  1874. }
  1875. std::string type = settings->getSettingsType();
  1876. bool is_water = type == "water";
  1877. if (type != "daycycle")
  1878. {
  1879. if (mCurrentTrack == LLSettingsDay::TRACK_WATER)
  1880. {
  1881. if (!is_water)
  1882. {
  1883. llwarns << "Attempt to load a sky frame in the water track. Aborted."
  1884. << llendl;
  1885. return;
  1886. }
  1887. }
  1888. else if (is_water)
  1889. {
  1890. llwarns << "Attempt to load a water frame in a sky track. Aborted."
  1891. << llendl;
  1892. return;
  1893. }
  1894. if (!mFramesSlider->canAddSliders())
  1895. {
  1896. llwarns << "Attempt to add new frame when slider is full. Aborted."
  1897. << llendl;
  1898. return;
  1899. }
  1900. F32 frame = mTimeSlider->getCurSliderValue();
  1901. LLSettingsDay::cycle_track_t::value_type nearest =
  1902. mDaySettings->getSettingsNearKeyframe(frame, mCurrentTrack,
  1903. LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR);
  1904. if (nearest.first != INVALID_TRACKPOS)
  1905. {
  1906. // There is already a frame near the target location. Remove it so
  1907. // we can put the new one in its place.
  1908. mDaySettings->removeTrackKeyframe(mCurrentTrack, nearest.first);
  1909. removeSliderFrame(nearest.first);
  1910. }
  1911. // Do not forget to clone (we might reuse/load it a couple of times)
  1912. mDaySettings->setSettingsAtKeyframe(settings->buildDerivedClone(), frame,
  1913. mCurrentTrack);
  1914. addSliderFrame(frame, settings, false);
  1915. }
  1916. else if (mCurrentTrack == LLSettingsDay::TRACK_WATER)
  1917. {
  1918. // Clone the water track
  1919. LLSettingsDay::ptr_t dayp =
  1920. std::dynamic_pointer_cast<LLSettingsDay>(settings);
  1921. cloneTrack(dayp, mCurrentTrack, mCurrentTrack);
  1922. }
  1923. else
  1924. {
  1925. // We want to copy a sky track, but we first need to know which track
  1926. // among the four sky tracks we want copied...
  1927. LLSettingsDay::ptr_t dayp =
  1928. std::dynamic_pointer_cast<LLSettingsDay>(settings);
  1929. const LLEnvironment::altitude_list_t& altitudes =
  1930. gEnvironment.getRegionAltitudes();
  1931. bool use_altitudes = !altitudes.empty() &&
  1932. mEditContext >= CONTEXT_PARCEL;
  1933. LLSD args = LLSD::emptyArray();
  1934. S32 counter = 0;
  1935. S32 last_non_empty_track = 0;
  1936. for (S32 i = 1; i < LLSettingsDay::TRACK_MAX; ++i)
  1937. {
  1938. LLSD track;
  1939. track["id"] = LLSD::Integer(i);
  1940. bool populated = !dayp->isTrackEmpty(i);
  1941. track["enabled"] = populated;
  1942. if (populated)
  1943. {
  1944. ++counter;
  1945. last_non_empty_track = i;
  1946. }
  1947. if (use_altitudes)
  1948. {
  1949. track["altitude"] = altitudes[i - 1];
  1950. }
  1951. args.append(track);
  1952. }
  1953. if (!counter)
  1954. {
  1955. // This should not happen
  1956. llwarns << "Tried to copy tracks, but there are no available sources."
  1957. << llendl;
  1958. return;
  1959. }
  1960. else if (counter > 1)
  1961. {
  1962. // Let the user choose the track to clone...
  1963. mSourceSettings = dayp;
  1964. new LLFloaterTrackPicker(this, args);
  1965. return;
  1966. }
  1967. // Only one sky track available (normaly the first, but just in case
  1968. // we did remember the actual track number in last_non_empty_track).
  1969. cloneTrack(dayp, last_non_empty_track, mCurrentTrack);
  1970. }
  1971. reblendSettings();
  1972. synchronizePanels();
  1973. }
  1974. void LLPanelEnvSettingsDay::loadInventoryItem(LLUUID item_id)
  1975. {
  1976. if (!mDaySettings || item_id.isNull())
  1977. {
  1978. return;
  1979. }
  1980. // Make sure we are not trying to load a link and get the linked item Id
  1981. // in that case.
  1982. item_id = gInventory.getLinkedItemID(item_id);
  1983. LLViewerInventoryItem* itemp = gInventory.getItem(item_id);
  1984. if (!itemp || itemp->getIsBrokenLink())
  1985. {
  1986. llwarns << "Could not find inventory item for Id: " << item_id
  1987. << llendl;
  1988. return;
  1989. }
  1990. const LLUUID& asset_id = itemp->getAssetUUID();
  1991. if (asset_id.isNull())
  1992. {
  1993. llwarns << "Null asset Id for inventory item: " << item_id
  1994. << ". Not loading it." << llendl;
  1995. return;
  1996. }
  1997. LLEnvSettingsBase::getSettingsAsset(asset_id,
  1998. [this, item_id](LLUUID,
  1999. LLSettingsBase::ptr_t settings,
  2000. S32 status, LLExtStat)
  2001. {
  2002. onAssetLoaded(item_id, settings,
  2003. status);
  2004. });
  2005. }
  2006. void LLPanelEnvSettingsDay::startPlay()
  2007. {
  2008. if (!mIsPlaying)
  2009. {
  2010. mIsPlaying = true;
  2011. mFramesSlider->resetCurSlider();
  2012. mPlayTimer.reset();
  2013. mPlayTimer.start();
  2014. gIdleCallbacks.addFunction(onIdlePlay, this);
  2015. mPlayStartFrame = mTimeSlider->getCurSliderValue();
  2016. mPlayBtn->setVisible(false);
  2017. mStopBtn->setVisible(true);
  2018. }
  2019. }
  2020. void LLPanelEnvSettingsDay::stopPlay()
  2021. {
  2022. if (mIsPlaying)
  2023. {
  2024. mIsPlaying = false;
  2025. mFramesSlider->resetCurSlider();
  2026. gIdleCallbacks.deleteFunction(onIdlePlay, this);
  2027. mPlayTimer.stop();
  2028. F32 frame = mTimeSlider->getCurSliderValue();
  2029. selectFrame(frame, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR);
  2030. mPlayBtn->setVisible(true);
  2031. mStopBtn->setVisible(false);
  2032. }
  2033. }
  2034. //static
  2035. void LLPanelEnvSettingsDay::onIdlePlay(void* userdata)
  2036. {
  2037. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2038. if (self && !gDisconnected)
  2039. {
  2040. F32 prcnt_played = self->mPlayTimer.getElapsedTimeF32() /
  2041. DAY_CYCLE_PLAY_TIME_SECONDS;
  2042. F32 new_frame = fmodf(self->mPlayStartFrame + prcnt_played, 1.f);
  2043. self->mTimeSlider->setCurSliderValue(new_frame);
  2044. if (self->mSkyBlender)
  2045. {
  2046. self->mSkyBlender->setPosition(new_frame);
  2047. }
  2048. if (self->mWaterBlender)
  2049. {
  2050. self->mWaterBlender->setPosition(new_frame);
  2051. }
  2052. self->synchronizePanels();
  2053. self->refresh();
  2054. }
  2055. }
  2056. //static
  2057. void LLPanelEnvSettingsDay::onTrack0Button(void* userdata)
  2058. {
  2059. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2060. if (self)
  2061. {
  2062. self->stopPlay();
  2063. self->selectTrack(0);
  2064. }
  2065. }
  2066. //static
  2067. void LLPanelEnvSettingsDay::onTrack1Button(void* userdata)
  2068. {
  2069. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2070. if (self)
  2071. {
  2072. self->stopPlay();
  2073. self->selectTrack(1);
  2074. }
  2075. }
  2076. //static
  2077. void LLPanelEnvSettingsDay::onTrack2Button(void* userdata)
  2078. {
  2079. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2080. if (self)
  2081. {
  2082. self->stopPlay();
  2083. self->selectTrack(2);
  2084. }
  2085. }
  2086. //static
  2087. void LLPanelEnvSettingsDay::onTrack3Button(void* userdata)
  2088. {
  2089. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2090. if (self)
  2091. {
  2092. self->stopPlay();
  2093. self->selectTrack(3);
  2094. }
  2095. }
  2096. //static
  2097. void LLPanelEnvSettingsDay::onTrack4Button(void* userdata)
  2098. {
  2099. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2100. if (self)
  2101. {
  2102. self->stopPlay();
  2103. self->selectTrack(4);
  2104. }
  2105. }
  2106. //static
  2107. void LLPanelEnvSettingsDay::onCloneTrack(void* userdata)
  2108. {
  2109. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2110. if (!self || !self->mDaySettings)
  2111. {
  2112. return;
  2113. }
  2114. self->stopPlay();
  2115. const LLEnvironment::altitude_list_t& altitudes =
  2116. gEnvironment.getRegionAltitudes();
  2117. bool use_altitudes = !altitudes.empty() &&
  2118. self->mEditContext >= CONTEXT_PARCEL;
  2119. LLSD args = LLSD::emptyArray();
  2120. S32 counter = 0;
  2121. for (S32 i = 1; i < LLSettingsDay::TRACK_MAX; ++i)
  2122. {
  2123. LLSD track;
  2124. track["id"] = LLSD::Integer(i);
  2125. bool populated = i != self->mCurrentTrack &&
  2126. !self->mDaySettings->isTrackEmpty(i);
  2127. track["enabled"] = populated;
  2128. if (populated)
  2129. {
  2130. ++counter;
  2131. }
  2132. if (use_altitudes)
  2133. {
  2134. track["altitude"] = altitudes[i - 1];
  2135. }
  2136. args.append(track);
  2137. }
  2138. if (!counter)
  2139. {
  2140. // This should not happen
  2141. llwarns << "Tried to copy tracks, but there are no available sources."
  2142. << llendl;
  2143. return;
  2144. }
  2145. self->mSourceSettings = self->mDaySettings;
  2146. new LLFloaterTrackPicker(self, args);
  2147. }
  2148. static void inv_items_picker_cb(const std::vector<std::string>&,
  2149. const uuid_vec_t& ids, void* userdata, bool)
  2150. {
  2151. LLPanelEnvSettingsDay* panelp = (LLPanelEnvSettingsDay*)userdata;
  2152. if (panelp && !ids.empty())
  2153. {
  2154. panelp->loadInventoryItem(ids[0]);
  2155. }
  2156. }
  2157. //static
  2158. void LLPanelEnvSettingsDay::onLoadTrack(void* userdata)
  2159. {
  2160. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2161. if (self && self->mDaySettings)
  2162. {
  2163. self->stopPlay();
  2164. HBFloaterInvItemsPicker* pickerp =
  2165. new HBFloaterInvItemsPicker(self, inv_items_picker_cb, self);
  2166. if (pickerp)
  2167. {
  2168. pickerp->setExcludeLibrary();
  2169. pickerp->setAssetType(LLAssetType::AT_SETTINGS,
  2170. (S32)LLSettingsType::ST_DAYCYCLE);
  2171. }
  2172. }
  2173. }
  2174. //static
  2175. void LLPanelEnvSettingsDay::onClearTrack(void* userdata)
  2176. {
  2177. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2178. if (!self || !self->mDaySettings)
  2179. {
  2180. return;
  2181. }
  2182. self->stopPlay();
  2183. if (self->mCurrentTrack > 1)
  2184. {
  2185. self->mDaySettings->getCycleTrack(self->mCurrentTrack).clear();
  2186. }
  2187. else
  2188. {
  2189. LLSettingsDay::cycle_track_t& track =
  2190. self->mDaySettings->getCycleTrack(self->mCurrentTrack);
  2191. track.erase(++track.begin(), track.end());
  2192. }
  2193. self->updateEditEnvironment();
  2194. gEnvironment.setSelectedEnvironment(LLEnvironment::ENV_EDIT,
  2195. LLEnvironment::TRANSITION_INSTANT);
  2196. gEnvironment.updateEnvironment(LLEnvironment::TRANSITION_INSTANT);
  2197. self->setDirty();
  2198. self->synchronizePanels();
  2199. self->updatePanels();
  2200. }
  2201. //static
  2202. void LLPanelEnvSettingsDay::onAddFrame(void* userdata)
  2203. {
  2204. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2205. if (!self || !self->mDaySettings)
  2206. {
  2207. return;
  2208. }
  2209. self->stopPlay();
  2210. if (!self->mFramesSlider->canAddSliders())
  2211. {
  2212. // This should not happen since the button should be disabled
  2213. llwarns << "Attempt to add new frame when slider is full." << llendl;
  2214. return;
  2215. }
  2216. F32 frame = self->mTimeSlider->getCurSliderValue();
  2217. if ((self->mDaySettings->getSettingsNearKeyframe(frame,
  2218. self->mCurrentTrack,
  2219. LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second)
  2220. {
  2221. // This should not happen since the button should be disabled
  2222. llwarns << "Attempt to add new frame too close to an existing frame."
  2223. << llendl;
  2224. return;
  2225. }
  2226. LLSettingsBase::ptr_t settingsp;
  2227. if (self->mCurrentTrack == LLSettingsDay::TRACK_WATER)
  2228. {
  2229. // Scratch water should always have the current water settings.
  2230. LLSettingsWater::ptr_t waterp = self->mScratchWater->buildClone();
  2231. settingsp = waterp;
  2232. self->mDaySettings->setWaterAtKeyframe(waterp, frame);
  2233. }
  2234. else
  2235. {
  2236. // Scratch sky should always have the current sky settings.
  2237. LLSettingsSky::ptr_t skyp = self->mScratchSky->buildClone();
  2238. settingsp = skyp;
  2239. self->mDaySettings->setSkyAtKeyframe(skyp, frame, self->mCurrentTrack);
  2240. }
  2241. self->setDirty();
  2242. self->addSliderFrame(frame, settingsp);
  2243. }
  2244. //static
  2245. void LLPanelEnvSettingsDay::onLoadFrame(void* userdata)
  2246. {
  2247. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2248. if (self && self->mDaySettings)
  2249. {
  2250. self->stopPlay();
  2251. HBFloaterInvItemsPicker* pickerp =
  2252. new HBFloaterInvItemsPicker(self, inv_items_picker_cb, self);
  2253. if (pickerp)
  2254. {
  2255. S32 type;
  2256. if (self->mCurrentTrack == LLSettingsDay::TRACK_WATER)
  2257. {
  2258. type = LLSettingsType::ST_WATER;
  2259. }
  2260. else
  2261. {
  2262. type = LLSettingsType::ST_SKY;
  2263. }
  2264. pickerp->setExcludeLibrary();
  2265. pickerp->setAssetType(LLAssetType::AT_SETTINGS, type);
  2266. }
  2267. }
  2268. }
  2269. //static
  2270. void LLPanelEnvSettingsDay::onRemoveFrame(void* userdata)
  2271. {
  2272. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2273. if (self && self->mDaySettings)
  2274. {
  2275. self->stopPlay();
  2276. std::string cur_slider = self->mFramesSlider->getCurSlider();
  2277. if (!cur_slider.empty())
  2278. {
  2279. self->setDirty();
  2280. self->removeCurrentSliderFrame();
  2281. }
  2282. }
  2283. }
  2284. //static
  2285. void LLPanelEnvSettingsDay::onTimeSliderCallback(LLUICtrl*, void* userdata)
  2286. {
  2287. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2288. if (self && self->mDaySettings)
  2289. {
  2290. self->stopPlay();
  2291. self->selectFrame(self->mTimeSlider->getCurSliderValue(),
  2292. LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR);
  2293. }
  2294. }
  2295. //static
  2296. void LLPanelEnvSettingsDay::onFrameSliderCallback(LLUICtrl*, void* userdata)
  2297. {
  2298. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2299. if (!self || !self->mDaySettings)
  2300. {
  2301. return;
  2302. }
  2303. std::string cur_slider = self->mFramesSlider->getCurSlider();
  2304. if (cur_slider.empty())
  2305. {
  2306. return;
  2307. }
  2308. F32 frame = self->mFramesSlider->getCurSliderValue();
  2309. keymap_t::iterator it = self->mSliderKeyMap.find(cur_slider);
  2310. if (it == self->mSliderKeyMap.end())
  2311. {
  2312. llwarns << "Cannot find current slider value in slider map !"
  2313. << llendl;
  2314. return;
  2315. }
  2316. // *TODO: implement SHIFT-copy feature ?
  2317. if (self->canEdit() &&
  2318. self->mDaySettings->moveTrackKeyframe(self->mCurrentTrack,
  2319. it->second.mFrame, frame))
  2320. {
  2321. it->second.mFrame = frame;
  2322. }
  2323. else
  2324. {
  2325. self->mFramesSlider->setCurSliderValue(it->second.mFrame);
  2326. }
  2327. }
  2328. //static
  2329. void LLPanelEnvSettingsDay::onFrameSliderMouseDown(S32 x, S32 y,
  2330. void* userdata)
  2331. {
  2332. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2333. if (!self || !self->mDaySettings)
  2334. {
  2335. return;
  2336. }
  2337. self->stopPlay();
  2338. F32 frame = self->mFramesSlider->getSliderValueFromPos(x, y);
  2339. self->mCurrentFrame = frame;
  2340. std::string cur_slider = self->mFramesSlider->getCurSlider();
  2341. // *TODO: implement SHIFT-copy feature ?
  2342. if (!cur_slider.empty())
  2343. {
  2344. F32 cur_frame = self->mFramesSlider->getSliderValue(cur_slider);
  2345. if (fabsf(cur_frame - frame) > LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)
  2346. {
  2347. self->mFramesSlider->resetCurSlider();
  2348. }
  2349. }
  2350. self->mTimeSlider->setCurSliderValue(frame);
  2351. self->updatePanels();
  2352. gEnvironment.updateEnvironment(LLEnvironment::TRANSITION_INSTANT);
  2353. }
  2354. //static
  2355. void LLPanelEnvSettingsDay::onFrameSliderMouseUp(S32 x, S32 y, void* userdata)
  2356. {
  2357. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2358. if (self && self->mDaySettings)
  2359. {
  2360. F32 frame = self->mFramesSlider->getSliderValueFromPos(x, y);
  2361. self->mTimeSlider->setCurSliderValue(frame);
  2362. self->selectFrame(frame, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR);
  2363. // Set dirty only if we actually changed the current frame position
  2364. // since last onFrameSliderMouseDown() event
  2365. if (fabsf(frame - self->mCurrentFrame) >=
  2366. 0.75f * self->mFramesSlider->getIncrement())
  2367. {
  2368. self->setDirty();
  2369. }
  2370. }
  2371. }
  2372. //static
  2373. void LLPanelEnvSettingsDay::onPlay(void* userdata)
  2374. {
  2375. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2376. if (self)
  2377. {
  2378. self->startPlay();
  2379. }
  2380. }
  2381. //static
  2382. void LLPanelEnvSettingsDay::onStop(void* userdata)
  2383. {
  2384. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2385. if (self)
  2386. {
  2387. self->stopPlay();
  2388. }
  2389. }
  2390. //static
  2391. void LLPanelEnvSettingsDay::onForward(void* userdata)
  2392. {
  2393. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2394. if (!self || !self->mDaySettings || self->mSliderKeyMap.empty())
  2395. {
  2396. return;
  2397. }
  2398. F32 inc_frame = self->mTimeSlider->getCurSliderValue() +
  2399. self->mTimeSlider->getIncrement() * 0.5f;
  2400. F32 frame = self->mDaySettings->getUpperBoundFrame(self->mCurrentTrack,
  2401. inc_frame);
  2402. self->selectFrame(frame, 0.f);
  2403. self->stopPlay();
  2404. }
  2405. //static
  2406. void LLPanelEnvSettingsDay::onBackward(void* userdata)
  2407. {
  2408. LLPanelEnvSettingsDay* self = (LLPanelEnvSettingsDay*)userdata;
  2409. if (!self || !self->mDaySettings || self->mSliderKeyMap.empty())
  2410. {
  2411. return;
  2412. }
  2413. F32 dec_frame = self->mTimeSlider->getCurSliderValue() -
  2414. self->mTimeSlider->getIncrement() * 0.5f;
  2415. F32 frame = self->mDaySettings->getLowerBoundFrame(self->mCurrentTrack,
  2416. dec_frame);
  2417. self->selectFrame(frame, 0.f);
  2418. self->stopPlay();
  2419. }