diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llfloaterwindlight.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llfloaterwindlight.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterwindlight.cpp | 998 |
1 files changed, 998 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterwindlight.cpp b/linden/indra/newview/llfloaterwindlight.cpp new file mode 100644 index 0000000..2321f5d --- /dev/null +++ b/linden/indra/newview/llfloaterwindlight.cpp | |||
@@ -0,0 +1,998 @@ | |||
1 | /** | ||
2 | * @file llfloaterwindlight.cpp | ||
3 | * @brief LLFloaterWindLight class definition | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2007-2008, Linden Research, Inc. | ||
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 http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | |||
34 | #include "llfloaterwindlight.h" | ||
35 | |||
36 | #include "pipeline.h" | ||
37 | #include "llsky.h" | ||
38 | |||
39 | #include "llsliderctrl.h" | ||
40 | #include "llmultislider.h" | ||
41 | #include "llmultisliderctrl.h" | ||
42 | #include "llspinctrl.h" | ||
43 | #include "llcheckboxctrl.h" | ||
44 | #include "llvieweruictrlfactory.h" | ||
45 | #include "llviewercamera.h" | ||
46 | #include "llcombobox.h" | ||
47 | #include "lllineeditor.h" | ||
48 | #include "llfloaterdaycycle.h" | ||
49 | #include "llboost.h" | ||
50 | |||
51 | #include "v4math.h" | ||
52 | #include "llviewerdisplay.h" | ||
53 | #include "llviewercontrol.h" | ||
54 | #include "llviewerwindow.h" | ||
55 | #include "llsavedsettingsglue.h" | ||
56 | |||
57 | #include "llwlparamset.h" | ||
58 | #include "llwlparammanager.h" | ||
59 | #include "llpostprocess.h" | ||
60 | |||
61 | #undef max | ||
62 | |||
63 | LLFloaterWindLight* LLFloaterWindLight::sWindLight = NULL; | ||
64 | |||
65 | std::set<std::string> LLFloaterWindLight::sDefaultPresets; | ||
66 | |||
67 | static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f; | ||
68 | |||
69 | LLFloaterWindLight::LLFloaterWindLight() : LLFloater("windlight floater") | ||
70 | { | ||
71 | gUICtrlFactory->buildFloater(this, "floater_windlight_options.xml"); | ||
72 | |||
73 | // add the combo boxes | ||
74 | LLComboBox* comboBox = LLUICtrlFactory::getComboBoxByName(this, "WLPresetsCombo"); | ||
75 | |||
76 | if(comboBox != NULL) { | ||
77 | |||
78 | std::map<std::string, LLWLParamSet>::iterator mIt = | ||
79 | LLWLParamManager::instance()->mParamList.begin(); | ||
80 | for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) | ||
81 | { | ||
82 | comboBox->add(mIt->first); | ||
83 | } | ||
84 | |||
85 | // entry for when we're in estate time | ||
86 | comboBox->add(""); | ||
87 | |||
88 | // set defaults on combo boxes | ||
89 | comboBox->selectByValue(LLSD("Default")); | ||
90 | } | ||
91 | |||
92 | // add the list of presets | ||
93 | LLString def_days = getString("WLDefaultSkyNames"); | ||
94 | |||
95 | // no editing or deleting of the blank string | ||
96 | sDefaultPresets.insert(""); | ||
97 | boost_tokenizer tokens(def_days, boost::char_separator<char>(":")); | ||
98 | for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) | ||
99 | { | ||
100 | LLString tok(*token_iter); | ||
101 | sDefaultPresets.insert(tok); | ||
102 | } | ||
103 | |||
104 | // load it up | ||
105 | initCallbacks(); | ||
106 | } | ||
107 | |||
108 | LLFloaterWindLight::~LLFloaterWindLight() | ||
109 | { | ||
110 | } | ||
111 | |||
112 | void LLFloaterWindLight::initCallbacks(void) { | ||
113 | |||
114 | // help buttons | ||
115 | initHelpBtn("WLBlueHorizonHelp", "HelpBlueHorizon"); | ||
116 | initHelpBtn("WLHazeHorizonHelp", "HelpHazeHorizon"); | ||
117 | initHelpBtn("WLBlueDensityHelp", "HelpBlueDensity"); | ||
118 | initHelpBtn("WLHazeDensityHelp", "HelpHazeDensity"); | ||
119 | |||
120 | initHelpBtn("WLDensityMultHelp", "HelpDensityMult"); | ||
121 | initHelpBtn("WLDistanceMultHelp", "HelpDistanceMult"); | ||
122 | initHelpBtn("WLMaxAltitudeHelp", "HelpMaxAltitude"); | ||
123 | |||
124 | initHelpBtn("WLSunlightColorHelp", "HelpSunlightColor"); | ||
125 | initHelpBtn("WLAmbientHelp", "HelpSunAmbient"); | ||
126 | initHelpBtn("WLSunGlowHelp", "HelpSunGlow"); | ||
127 | initHelpBtn("WLTimeOfDayHelp", "HelpTimeOfDay"); | ||
128 | initHelpBtn("WLEastAngleHelp", "HelpEastAngle"); | ||
129 | |||
130 | initHelpBtn("WLSceneGammaHelp", "HelpSceneGamma"); | ||
131 | initHelpBtn("WLStarBrightnessHelp", "HelpStarBrightness"); | ||
132 | |||
133 | initHelpBtn("WLCloudColorHelp", "HelpCloudColor"); | ||
134 | initHelpBtn("WLCloudDetailHelp", "HelpCloudDetail"); | ||
135 | initHelpBtn("WLCloudDensityHelp", "HelpCloudDensity"); | ||
136 | initHelpBtn("WLCloudCoverageHelp", "HelpCloudCoverage"); | ||
137 | |||
138 | initHelpBtn("WLCloudScaleHelp", "HelpCloudScale"); | ||
139 | initHelpBtn("WLCloudScrollXHelp", "HelpCloudScrollX"); | ||
140 | initHelpBtn("WLCloudScrollYHelp", "HelpCloudScrollY"); | ||
141 | |||
142 | initHelpBtn("WLClassicCloudsHelp", "HelpClassicClouds"); | ||
143 | |||
144 | LLWLParamManager * param_mgr = LLWLParamManager::instance(); | ||
145 | |||
146 | // blue horizon | ||
147 | childSetCommitCallback("WLBlueHorizonR", onColorControlRMoved, ¶m_mgr->mBlueHorizon); | ||
148 | childSetCommitCallback("WLBlueHorizonG", onColorControlGMoved, ¶m_mgr->mBlueHorizon); | ||
149 | childSetCommitCallback("WLBlueHorizonB", onColorControlBMoved, ¶m_mgr->mBlueHorizon); | ||
150 | childSetCommitCallback("WLBlueHorizonI", onColorControlIMoved, ¶m_mgr->mBlueHorizon); | ||
151 | |||
152 | // haze density, horizon, mult, and altitude | ||
153 | childSetCommitCallback("WLHazeDensity", onColorControlRMoved, ¶m_mgr->mHazeDensity); | ||
154 | childSetCommitCallback("WLHazeHorizon", onColorControlRMoved, ¶m_mgr->mHazeHorizon); | ||
155 | childSetCommitCallback("WLDensityMult", onFloatControlMoved, ¶m_mgr->mDensityMult); | ||
156 | childSetCommitCallback("WLMaxAltitude", onFloatControlMoved, ¶m_mgr->mMaxAlt); | ||
157 | |||
158 | // blue density | ||
159 | childSetCommitCallback("WLBlueDensityR", onColorControlRMoved, ¶m_mgr->mBlueDensity); | ||
160 | childSetCommitCallback("WLBlueDensityG", onColorControlGMoved, ¶m_mgr->mBlueDensity); | ||
161 | childSetCommitCallback("WLBlueDensityB", onColorControlBMoved, ¶m_mgr->mBlueDensity); | ||
162 | childSetCommitCallback("WLBlueDensityI", onColorControlIMoved, ¶m_mgr->mBlueDensity); | ||
163 | |||
164 | // Lighting | ||
165 | |||
166 | // sunlight | ||
167 | childSetCommitCallback("WLSunlightR", onColorControlRMoved, ¶m_mgr->mSunlight); | ||
168 | childSetCommitCallback("WLSunlightG", onColorControlGMoved, ¶m_mgr->mSunlight); | ||
169 | childSetCommitCallback("WLSunlightB", onColorControlBMoved, ¶m_mgr->mSunlight); | ||
170 | childSetCommitCallback("WLSunlightI", onColorControlIMoved, ¶m_mgr->mSunlight); | ||
171 | |||
172 | // glow | ||
173 | childSetCommitCallback("WLGlowR", onGlowRMoved, ¶m_mgr->mGlow); | ||
174 | childSetCommitCallback("WLGlowB", onGlowBMoved, ¶m_mgr->mGlow); | ||
175 | |||
176 | // ambient | ||
177 | childSetCommitCallback("WLAmbientR", onColorControlRMoved, ¶m_mgr->mAmbient); | ||
178 | childSetCommitCallback("WLAmbientG", onColorControlGMoved, ¶m_mgr->mAmbient); | ||
179 | childSetCommitCallback("WLAmbientB", onColorControlBMoved, ¶m_mgr->mAmbient); | ||
180 | childSetCommitCallback("WLAmbientI", onColorControlIMoved, ¶m_mgr->mAmbient); | ||
181 | |||
182 | // time of day | ||
183 | childSetCommitCallback("WLSunAngle", onSunMoved, ¶m_mgr->mLightnorm); | ||
184 | childSetCommitCallback("WLEastAngle", onSunMoved, ¶m_mgr->mLightnorm); | ||
185 | |||
186 | // Clouds | ||
187 | |||
188 | // Cloud Color | ||
189 | childSetCommitCallback("WLCloudColorR", onColorControlRMoved, ¶m_mgr->mCloudColor); | ||
190 | childSetCommitCallback("WLCloudColorG", onColorControlGMoved, ¶m_mgr->mCloudColor); | ||
191 | childSetCommitCallback("WLCloudColorB", onColorControlBMoved, ¶m_mgr->mCloudColor); | ||
192 | childSetCommitCallback("WLCloudColorI", onColorControlIMoved, ¶m_mgr->mCloudColor); | ||
193 | |||
194 | // Cloud | ||
195 | childSetCommitCallback("WLCloudX", onColorControlRMoved, ¶m_mgr->mCloudMain); | ||
196 | childSetCommitCallback("WLCloudY", onColorControlGMoved, ¶m_mgr->mCloudMain); | ||
197 | childSetCommitCallback("WLCloudDensity", onColorControlBMoved, ¶m_mgr->mCloudMain); | ||
198 | |||
199 | // Cloud Detail | ||
200 | childSetCommitCallback("WLCloudDetailX", onColorControlRMoved, ¶m_mgr->mCloudDetail); | ||
201 | childSetCommitCallback("WLCloudDetailY", onColorControlGMoved, ¶m_mgr->mCloudDetail); | ||
202 | childSetCommitCallback("WLCloudDetailDensity", onColorControlBMoved, ¶m_mgr->mCloudDetail); | ||
203 | |||
204 | // Cloud extras | ||
205 | childSetCommitCallback("WLCloudCoverage", onFloatControlMoved, ¶m_mgr->mCloudCoverage); | ||
206 | childSetCommitCallback("WLCloudScale", onFloatControlMoved, ¶m_mgr->mCloudScale); | ||
207 | childSetCommitCallback("WLCloudLockX", onCloudScrollXToggled, NULL); | ||
208 | childSetCommitCallback("WLCloudLockY", onCloudScrollYToggled, NULL); | ||
209 | childSetCommitCallback("WLCloudScrollX", onCloudScrollXMoved, NULL); | ||
210 | childSetCommitCallback("WLCloudScrollY", onCloudScrollYMoved, NULL); | ||
211 | childSetCommitCallback("WLDistanceMult", onFloatControlMoved, ¶m_mgr->mDistanceMult); | ||
212 | childSetCommitCallback("DrawClassicClouds", LLSavedSettingsGlue::setBOOL, (void*)"SkyUseClassicClouds"); | ||
213 | |||
214 | // WL Top | ||
215 | childSetAction("WLDayCycleMenuButton", onOpenDayCycle, NULL); | ||
216 | // Load/save | ||
217 | LLComboBox* comboBox = LLUICtrlFactory::getComboBoxByName(this, "WLPresetsCombo"); | ||
218 | |||
219 | //childSetAction("WLLoadPreset", onLoadPreset, comboBox); | ||
220 | childSetAction("WLNewPreset", onNewPreset, comboBox); | ||
221 | childSetAction("WLSavePreset", onSavePreset, comboBox); | ||
222 | childSetAction("WLDeletePreset", onDeletePreset, comboBox); | ||
223 | |||
224 | comboBox->setCommitCallback(onChangePresetName); | ||
225 | |||
226 | |||
227 | // Dome | ||
228 | childSetCommitCallback("WLGamma", onFloatControlMoved, ¶m_mgr->mWLGamma); | ||
229 | childSetCommitCallback("WLStarAlpha", onStarAlphaMoved, NULL); | ||
230 | } | ||
231 | |||
232 | void LLFloaterWindLight::onClickHelp(void* data) | ||
233 | { | ||
234 | LLFloaterWindLight* self = LLFloaterWindLight::instance(); | ||
235 | |||
236 | const char* xml_alert = (const char*) data; | ||
237 | LLAlertDialog* dialogp = gViewerWindow->alertXml(xml_alert); | ||
238 | if (dialogp) | ||
239 | { | ||
240 | LLFloater* root_floater = gFloaterView->getParentFloater(self); | ||
241 | if (root_floater) | ||
242 | { | ||
243 | root_floater->addDependentFloater(dialogp); | ||
244 | } | ||
245 | } | ||
246 | |||
247 | } | ||
248 | |||
249 | void LLFloaterWindLight::initHelpBtn(const char* name, const char* xml_alert) | ||
250 | { | ||
251 | childSetAction(name, onClickHelp, (void*)xml_alert); | ||
252 | } | ||
253 | |||
254 | void LLFloaterWindLight::newPromptCallback(S32 option, const LLString& text, void* userData) | ||
255 | { | ||
256 | if(text == "") | ||
257 | { | ||
258 | return; | ||
259 | } | ||
260 | |||
261 | if(option == 0) { | ||
262 | LLComboBox* comboBox = LLUICtrlFactory::getComboBoxByName(sWindLight, | ||
263 | "WLPresetsCombo"); | ||
264 | |||
265 | LLFloaterDayCycle* sDayCycle = NULL; | ||
266 | LLComboBox* keyCombo = NULL; | ||
267 | if(LLFloaterDayCycle::isOpen()) | ||
268 | { | ||
269 | sDayCycle = LLFloaterDayCycle::instance(); | ||
270 | keyCombo = LLUICtrlFactory::getComboBoxByName(sDayCycle, | ||
271 | "WLKeyPresets"); | ||
272 | } | ||
273 | |||
274 | // add the current parameters to the list | ||
275 | // see if it's there first | ||
276 | std::map<std::string, LLWLParamSet>::iterator mIt = | ||
277 | LLWLParamManager::instance()->mParamList.find(text.c_str()); | ||
278 | |||
279 | // if not there, add a new one | ||
280 | if(mIt == LLWLParamManager::instance()->mParamList.end()) | ||
281 | { | ||
282 | LLWLParamManager::instance()->addParamSet(text.c_str(), | ||
283 | LLWLParamManager::instance()->mCurParams); | ||
284 | comboBox->add(text); | ||
285 | comboBox->sortByName(); | ||
286 | |||
287 | // add a blank to the bottom | ||
288 | comboBox->selectFirstItem(); | ||
289 | if(comboBox->getSimple() == "") | ||
290 | { | ||
291 | comboBox->remove(0); | ||
292 | } | ||
293 | comboBox->add(""); | ||
294 | |||
295 | comboBox->setSelectedByValue(text, true); | ||
296 | if(LLFloaterDayCycle::isOpen()) | ||
297 | { | ||
298 | keyCombo->add(text); | ||
299 | keyCombo->sortByName(); | ||
300 | } | ||
301 | LLWLParamManager::instance()->savePreset(text); | ||
302 | |||
303 | // otherwise, send a message to the user | ||
304 | } | ||
305 | else | ||
306 | { | ||
307 | gViewerWindow->alertXml("ExistsSkyPresetAlert"); | ||
308 | } | ||
309 | } | ||
310 | } | ||
311 | |||
312 | void LLFloaterWindLight::syncMenu() | ||
313 | { | ||
314 | bool err; | ||
315 | |||
316 | LLWLParamManager * param_mgr = LLWLParamManager::instance(); | ||
317 | |||
318 | LLWLParamSet& currentParams = param_mgr->mCurParams; | ||
319 | //std::map<std::string, LLVector4> & currentParams = param_mgr->mCurParams.mParamValues; | ||
320 | |||
321 | // blue horizon | ||
322 | param_mgr->mBlueHorizon = currentParams.getVector(param_mgr->mBlueHorizon.name, err); | ||
323 | childSetValue("WLBlueHorizonR", param_mgr->mBlueHorizon.r / 2.0); | ||
324 | childSetValue("WLBlueHorizonG", param_mgr->mBlueHorizon.g / 2.0); | ||
325 | childSetValue("WLBlueHorizonB", param_mgr->mBlueHorizon.b / 2.0); | ||
326 | childSetValue("WLBlueHorizonI", | ||
327 | std::max(param_mgr->mBlueHorizon.r / 2.0, | ||
328 | std::max(param_mgr->mBlueHorizon.g / 2.0, | ||
329 | param_mgr->mBlueHorizon.b / 2.0))); | ||
330 | |||
331 | // haze density, horizon, mult, and altitude | ||
332 | param_mgr->mHazeDensity = currentParams.getVector(param_mgr->mHazeDensity.name, err); | ||
333 | childSetValue("WLHazeDensity", param_mgr->mHazeDensity.r); | ||
334 | param_mgr->mHazeHorizon = currentParams.getVector(param_mgr->mHazeHorizon.name, err); | ||
335 | childSetValue("WLHazeHorizon", param_mgr->mHazeHorizon.r); | ||
336 | param_mgr->mDensityMult = currentParams.getVector(param_mgr->mDensityMult.name, err); | ||
337 | childSetValue("WLDensityMult", param_mgr->mDensityMult.x * | ||
338 | param_mgr->mDensityMult.mult); | ||
339 | param_mgr->mMaxAlt = currentParams.getVector(param_mgr->mMaxAlt.name, err); | ||
340 | childSetValue("WLMaxAltitude", param_mgr->mMaxAlt.x); | ||
341 | |||
342 | // blue density | ||
343 | param_mgr->mBlueDensity = currentParams.getVector(param_mgr->mBlueDensity.name, err); | ||
344 | childSetValue("WLBlueDensityR", param_mgr->mBlueDensity.r / 2.0); | ||
345 | childSetValue("WLBlueDensityG", param_mgr->mBlueDensity.g / 2.0); | ||
346 | childSetValue("WLBlueDensityB", param_mgr->mBlueDensity.b / 2.0); | ||
347 | childSetValue("WLBlueDensityI", | ||
348 | std::max(param_mgr->mBlueDensity.r / 2.0, | ||
349 | std::max(param_mgr->mBlueDensity.g / 2.0, param_mgr->mBlueDensity.b / 2.0))); | ||
350 | |||
351 | // Lighting | ||
352 | |||
353 | // sunlight | ||
354 | param_mgr->mSunlight = currentParams.getVector(param_mgr->mSunlight.name, err); | ||
355 | childSetValue("WLSunlightR", param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE); | ||
356 | childSetValue("WLSunlightG", param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE); | ||
357 | childSetValue("WLSunlightB", param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE); | ||
358 | childSetValue("WLSunlightI", | ||
359 | std::max(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE, | ||
360 | std::max(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE))); | ||
361 | |||
362 | // glow | ||
363 | param_mgr->mGlow = currentParams.getVector(param_mgr->mGlow.name, err); | ||
364 | childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f); | ||
365 | childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f); | ||
366 | |||
367 | // ambient | ||
368 | param_mgr->mAmbient = currentParams.getVector(param_mgr->mAmbient.name, err); | ||
369 | childSetValue("WLAmbientR", param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE); | ||
370 | childSetValue("WLAmbientG", param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE); | ||
371 | childSetValue("WLAmbientB", param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE); | ||
372 | childSetValue("WLAmbientI", | ||
373 | std::max(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE, | ||
374 | std::max(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE))); | ||
375 | |||
376 | childSetValue("WLSunAngle", param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI); | ||
377 | childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI); | ||
378 | |||
379 | // Clouds | ||
380 | |||
381 | // Cloud Color | ||
382 | param_mgr->mCloudColor = currentParams.getVector(param_mgr->mCloudColor.name, err); | ||
383 | childSetValue("WLCloudColorR", param_mgr->mCloudColor.r); | ||
384 | childSetValue("WLCloudColorG", param_mgr->mCloudColor.g); | ||
385 | childSetValue("WLCloudColorB", param_mgr->mCloudColor.b); | ||
386 | childSetValue("WLCloudColorI", | ||
387 | std::max(param_mgr->mCloudColor.r, | ||
388 | std::max(param_mgr->mCloudColor.g, param_mgr->mCloudColor.b))); | ||
389 | |||
390 | // Cloud | ||
391 | param_mgr->mCloudMain = currentParams.getVector(param_mgr->mCloudMain.name, err); | ||
392 | childSetValue("WLCloudX", param_mgr->mCloudMain.r); | ||
393 | childSetValue("WLCloudY", param_mgr->mCloudMain.g); | ||
394 | childSetValue("WLCloudDensity", param_mgr->mCloudMain.b); | ||
395 | |||
396 | // Cloud Detail | ||
397 | param_mgr->mCloudDetail = currentParams.getVector(param_mgr->mCloudDetail.name, err); | ||
398 | childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r); | ||
399 | childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g); | ||
400 | childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b); | ||
401 | |||
402 | // Cloud extras | ||
403 | param_mgr->mCloudCoverage = currentParams.getVector(param_mgr->mCloudCoverage.name, err); | ||
404 | param_mgr->mCloudScale = currentParams.getVector(param_mgr->mCloudScale.name, err); | ||
405 | childSetValue("WLCloudCoverage", param_mgr->mCloudCoverage.x); | ||
406 | childSetValue("WLCloudScale", param_mgr->mCloudScale.x); | ||
407 | |||
408 | // cloud scrolling | ||
409 | bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX(); | ||
410 | bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY(); | ||
411 | childSetValue("WLCloudLockX", lockX); | ||
412 | childSetValue("WLCloudLockY", lockY); | ||
413 | childSetValue("DrawClassicClouds", gSavedSettings.getBOOL("SkyUseClassicClouds")); | ||
414 | |||
415 | // disable if locked, enable if not | ||
416 | if(lockX) | ||
417 | { | ||
418 | childDisable("WLCloudScrollX"); | ||
419 | } else { | ||
420 | childEnable("WLCloudScrollX"); | ||
421 | } | ||
422 | if(lockY) | ||
423 | { | ||
424 | childDisable("WLCloudScrollY"); | ||
425 | } else { | ||
426 | childEnable("WLCloudScrollY"); | ||
427 | } | ||
428 | |||
429 | // *HACK cloud scrolling is off my an additive of 10 | ||
430 | childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f); | ||
431 | childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f); | ||
432 | |||
433 | param_mgr->mDistanceMult = currentParams.getVector(param_mgr->mDistanceMult.name, err); | ||
434 | childSetValue("WLDistanceMult", param_mgr->mDistanceMult.x); | ||
435 | |||
436 | // Tweak extras | ||
437 | |||
438 | param_mgr->mWLGamma = currentParams.getVector(param_mgr->mWLGamma.name, err); | ||
439 | childSetValue("WLGamma", param_mgr->mWLGamma.x); | ||
440 | |||
441 | childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness()); | ||
442 | } | ||
443 | |||
444 | |||
445 | // static | ||
446 | LLFloaterWindLight* LLFloaterWindLight::instance() | ||
447 | { | ||
448 | if (!sWindLight) | ||
449 | { | ||
450 | sWindLight = new LLFloaterWindLight(); | ||
451 | sWindLight->open(); | ||
452 | sWindLight->setFocus(TRUE); | ||
453 | } | ||
454 | return sWindLight; | ||
455 | } | ||
456 | void LLFloaterWindLight::show() | ||
457 | { | ||
458 | LLFloaterWindLight* windLight = instance(); | ||
459 | windLight->syncMenu(); | ||
460 | |||
461 | // comment in if you want the menu to rebuild each time | ||
462 | //gUICtrlFactory->buildFloater(windLight, "floater_windlight_options.xml"); | ||
463 | //windLight->initCallbacks(); | ||
464 | |||
465 | windLight->open(); | ||
466 | } | ||
467 | |||
468 | bool LLFloaterWindLight::isOpen() | ||
469 | { | ||
470 | if (sWindLight != NULL) { | ||
471 | return true; | ||
472 | } | ||
473 | return false; | ||
474 | } | ||
475 | |||
476 | // virtual | ||
477 | void LLFloaterWindLight::onClose(bool app_quitting) | ||
478 | { | ||
479 | if (sWindLight) | ||
480 | { | ||
481 | sWindLight->setVisible(FALSE); | ||
482 | } | ||
483 | } | ||
484 | |||
485 | // color control callbacks | ||
486 | void LLFloaterWindLight::onColorControlRMoved(LLUICtrl* ctrl, void* userData) | ||
487 | { | ||
488 | deactivateAnimator(); | ||
489 | |||
490 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
491 | WLColorControl * colorControl = static_cast<WLColorControl *>(userData); | ||
492 | |||
493 | colorControl->r = sldrCtrl->getValueF32(); | ||
494 | if(colorControl->isSunOrAmbientColor) { | ||
495 | colorControl->r *= 3; | ||
496 | } | ||
497 | if(colorControl->isBlueHorizonOrDensity) { | ||
498 | colorControl->r *= 2; | ||
499 | } | ||
500 | |||
501 | // move i if it's the max | ||
502 | if(colorControl->r >= colorControl->g && colorControl->r >= colorControl->b | ||
503 | && colorControl->hasSliderName) { | ||
504 | colorControl->i = colorControl->r; | ||
505 | std::string name = colorControl->mSliderName; | ||
506 | name.append("I"); | ||
507 | |||
508 | if(colorControl->isSunOrAmbientColor) { | ||
509 | sWindLight->childSetValue(name, colorControl->r / 3); | ||
510 | } else if(colorControl->isBlueHorizonOrDensity) { | ||
511 | sWindLight->childSetValue(name, colorControl->r / 2); | ||
512 | } else { | ||
513 | sWindLight->childSetValue(name, colorControl->r); | ||
514 | } | ||
515 | } | ||
516 | |||
517 | colorControl->update(LLWLParamManager::instance()->mCurParams); | ||
518 | |||
519 | LLWLParamManager::instance()->propagateParameters(); | ||
520 | } | ||
521 | |||
522 | void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, void* userData) | ||
523 | { | ||
524 | deactivateAnimator(); | ||
525 | |||
526 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
527 | WLColorControl * colorControl = static_cast<WLColorControl *>(userData); | ||
528 | |||
529 | colorControl->g = sldrCtrl->getValueF32(); | ||
530 | if(colorControl->isSunOrAmbientColor) { | ||
531 | colorControl->g *= 3; | ||
532 | } | ||
533 | if(colorControl->isBlueHorizonOrDensity) { | ||
534 | colorControl->g *= 2; | ||
535 | } | ||
536 | |||
537 | // move i if it's the max | ||
538 | if(colorControl->g >= colorControl->r && colorControl->g >= colorControl->b | ||
539 | && colorControl->hasSliderName) { | ||
540 | colorControl->i = colorControl->g; | ||
541 | std::string name = colorControl->mSliderName; | ||
542 | name.append("I"); | ||
543 | |||
544 | if(colorControl->isSunOrAmbientColor) { | ||
545 | sWindLight->childSetValue(name, colorControl->g / 3); | ||
546 | } else if(colorControl->isBlueHorizonOrDensity) { | ||
547 | sWindLight->childSetValue(name, colorControl->g / 2); | ||
548 | } else { | ||
549 | sWindLight->childSetValue(name, colorControl->g); | ||
550 | } | ||
551 | } | ||
552 | |||
553 | colorControl->update(LLWLParamManager::instance()->mCurParams); | ||
554 | |||
555 | LLWLParamManager::instance()->propagateParameters(); | ||
556 | } | ||
557 | |||
558 | void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, void* userData) | ||
559 | { | ||
560 | deactivateAnimator(); | ||
561 | |||
562 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
563 | WLColorControl * colorControl = static_cast<WLColorControl *>(userData); | ||
564 | |||
565 | colorControl->b = sldrCtrl->getValueF32(); | ||
566 | if(colorControl->isSunOrAmbientColor) { | ||
567 | colorControl->b *= 3; | ||
568 | } | ||
569 | if(colorControl->isBlueHorizonOrDensity) { | ||
570 | colorControl->b *= 2; | ||
571 | } | ||
572 | |||
573 | // move i if it's the max | ||
574 | if(colorControl->b >= colorControl->r && colorControl->b >= colorControl->g | ||
575 | && colorControl->hasSliderName) { | ||
576 | colorControl->i = colorControl->b; | ||
577 | std::string name = colorControl->mSliderName; | ||
578 | name.append("I"); | ||
579 | |||
580 | if(colorControl->isSunOrAmbientColor) { | ||
581 | sWindLight->childSetValue(name, colorControl->b / 3); | ||
582 | } else if(colorControl->isBlueHorizonOrDensity) { | ||
583 | sWindLight->childSetValue(name, colorControl->b / 2); | ||
584 | } else { | ||
585 | sWindLight->childSetValue(name, colorControl->b); | ||
586 | } | ||
587 | } | ||
588 | |||
589 | colorControl->update(LLWLParamManager::instance()->mCurParams); | ||
590 | |||
591 | LLWLParamManager::instance()->propagateParameters(); | ||
592 | } | ||
593 | |||
594 | void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, void* userData) | ||
595 | { | ||
596 | deactivateAnimator(); | ||
597 | |||
598 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
599 | WLColorControl * colorControl = static_cast<WLColorControl *>(userData); | ||
600 | |||
601 | colorControl->i = sldrCtrl->getValueF32(); | ||
602 | |||
603 | // only for sliders where we pass a name | ||
604 | if(colorControl->hasSliderName) { | ||
605 | |||
606 | // set it to the top | ||
607 | F32 maxVal = std::max(std::max(colorControl->r, colorControl->g), colorControl->b); | ||
608 | F32 iVal; | ||
609 | |||
610 | if(colorControl->isSunOrAmbientColor) | ||
611 | { | ||
612 | iVal = colorControl->i * 3; | ||
613 | } | ||
614 | else if(colorControl->isBlueHorizonOrDensity) | ||
615 | { | ||
616 | iVal = colorControl->i * 2; | ||
617 | } | ||
618 | else | ||
619 | { | ||
620 | iVal = colorControl->i; | ||
621 | } | ||
622 | |||
623 | // get the names of the other sliders | ||
624 | std::string rName = colorControl->mSliderName; | ||
625 | rName.append("R"); | ||
626 | std::string gName = colorControl->mSliderName; | ||
627 | gName.append("G"); | ||
628 | std::string bName = colorControl->mSliderName; | ||
629 | bName.append("B"); | ||
630 | |||
631 | // handle if at 0 | ||
632 | if(iVal == 0) { | ||
633 | colorControl->r = 0; | ||
634 | colorControl->g = 0; | ||
635 | colorControl->b = 0; | ||
636 | |||
637 | // if all at the start | ||
638 | // set them all to the intensity | ||
639 | } else if (maxVal == 0) { | ||
640 | colorControl->r = iVal; | ||
641 | colorControl->g = iVal; | ||
642 | colorControl->b = iVal; | ||
643 | |||
644 | } else { | ||
645 | |||
646 | // add delta amounts to each | ||
647 | F32 delta = (iVal - maxVal) / maxVal; | ||
648 | colorControl->r *= (1.0f + delta); | ||
649 | colorControl->g *= (1.0f + delta); | ||
650 | colorControl->b *= (1.0f + delta); | ||
651 | } | ||
652 | |||
653 | // divide sun color vals by three | ||
654 | if(colorControl->isSunOrAmbientColor) | ||
655 | { | ||
656 | sWindLight->childSetValue(rName.c_str(), colorControl->r/3); | ||
657 | sWindLight->childSetValue(gName.c_str(), colorControl->g/3); | ||
658 | sWindLight->childSetValue(bName.c_str(), colorControl->b/3); | ||
659 | |||
660 | } | ||
661 | else if(colorControl->isBlueHorizonOrDensity) | ||
662 | { | ||
663 | sWindLight->childSetValue(rName.c_str(), colorControl->r/2); | ||
664 | sWindLight->childSetValue(gName.c_str(), colorControl->g/2); | ||
665 | sWindLight->childSetValue(bName.c_str(), colorControl->b/2); | ||
666 | |||
667 | } | ||
668 | else | ||
669 | { | ||
670 | // set the sliders to the new vals | ||
671 | sWindLight->childSetValue(rName.c_str(), colorControl->r); | ||
672 | sWindLight->childSetValue(gName.c_str(), colorControl->g); | ||
673 | sWindLight->childSetValue(bName.c_str(), colorControl->b); | ||
674 | } | ||
675 | } | ||
676 | |||
677 | // now update the current parameters and send them to shaders | ||
678 | colorControl->update(LLWLParamManager::instance()->mCurParams); | ||
679 | LLWLParamManager::instance()->propagateParameters(); | ||
680 | } | ||
681 | |||
682 | /// GLOW SPECIFIC CODE | ||
683 | void LLFloaterWindLight::onGlowRMoved(LLUICtrl* ctrl, void* userData) | ||
684 | { | ||
685 | deactivateAnimator(); | ||
686 | |||
687 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
688 | WLColorControl * colorControl = static_cast<WLColorControl *>(userData); | ||
689 | |||
690 | // scaled by 20 | ||
691 | colorControl->r = (2 - sldrCtrl->getValueF32()) * 20; | ||
692 | |||
693 | colorControl->update(LLWLParamManager::instance()->mCurParams); | ||
694 | LLWLParamManager::instance()->propagateParameters(); | ||
695 | } | ||
696 | |||
697 | /// \NOTE that we want NEGATIVE (-) B | ||
698 | void LLFloaterWindLight::onGlowBMoved(LLUICtrl* ctrl, void* userData) | ||
699 | { | ||
700 | deactivateAnimator(); | ||
701 | |||
702 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
703 | WLColorControl * colorControl = static_cast<WLColorControl *>(userData); | ||
704 | |||
705 | /// \NOTE that we want NEGATIVE (-) B and NOT by 20 as 20 is too big | ||
706 | colorControl->b = -sldrCtrl->getValueF32() * 5; | ||
707 | |||
708 | colorControl->update(LLWLParamManager::instance()->mCurParams); | ||
709 | LLWLParamManager::instance()->propagateParameters(); | ||
710 | } | ||
711 | |||
712 | void LLFloaterWindLight::onFloatControlMoved(LLUICtrl* ctrl, void* userData) | ||
713 | { | ||
714 | deactivateAnimator(); | ||
715 | |||
716 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
717 | WLFloatControl * floatControl = static_cast<WLFloatControl *>(userData); | ||
718 | |||
719 | floatControl->x = sldrCtrl->getValueF32() / floatControl->mult; | ||
720 | |||
721 | floatControl->update(LLWLParamManager::instance()->mCurParams); | ||
722 | LLWLParamManager::instance()->propagateParameters(); | ||
723 | } | ||
724 | |||
725 | void LLFloaterWindLight::onBoolToggle(LLUICtrl* ctrl, void* userData) | ||
726 | { | ||
727 | deactivateAnimator(); | ||
728 | |||
729 | LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl); | ||
730 | |||
731 | bool value = cbCtrl->get(); | ||
732 | (*(static_cast<BOOL *>(userData))) = value; | ||
733 | } | ||
734 | |||
735 | |||
736 | // Lighting callbacks | ||
737 | |||
738 | // time of day | ||
739 | void LLFloaterWindLight::onSunMoved(LLUICtrl* ctrl, void* userData) | ||
740 | { | ||
741 | deactivateAnimator(); | ||
742 | |||
743 | LLSliderCtrl* sunSldr = LLUICtrlFactory::getSliderByName(sWindLight, | ||
744 | "WLSunAngle"); | ||
745 | LLSliderCtrl* eastSldr = LLUICtrlFactory::getSliderByName(sWindLight, | ||
746 | "WLEastAngle"); | ||
747 | |||
748 | WLColorControl * colorControl = static_cast<WLColorControl *>(userData); | ||
749 | |||
750 | // get the two angles | ||
751 | LLWLParamManager * param_mgr = LLWLParamManager::instance(); | ||
752 | |||
753 | param_mgr->mCurParams.setSunAngle(F_TWO_PI * sunSldr->getValueF32()); | ||
754 | param_mgr->mCurParams.setEastAngle(F_TWO_PI * eastSldr->getValueF32()); | ||
755 | |||
756 | // set the sun vector | ||
757 | colorControl->r = -sin(param_mgr->mCurParams.getEastAngle()) * | ||
758 | cos(param_mgr->mCurParams.getSunAngle()); | ||
759 | colorControl->g = sin(param_mgr->mCurParams.getSunAngle()); | ||
760 | colorControl->b = cos(param_mgr->mCurParams.getEastAngle()) * | ||
761 | cos(param_mgr->mCurParams.getSunAngle()); | ||
762 | colorControl->i = 1.f; | ||
763 | |||
764 | colorControl->update(param_mgr->mCurParams); | ||
765 | param_mgr->propagateParameters(); | ||
766 | } | ||
767 | |||
768 | void LLFloaterWindLight::onFloatTweakMoved(LLUICtrl* ctrl, void* userData) | ||
769 | { | ||
770 | deactivateAnimator(); | ||
771 | |||
772 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
773 | F32 * tweak = static_cast<F32 *>(userData); | ||
774 | |||
775 | (*tweak) = sldrCtrl->getValueF32(); | ||
776 | LLWLParamManager::instance()->propagateParameters(); | ||
777 | } | ||
778 | |||
779 | void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl, void* userData) | ||
780 | { | ||
781 | deactivateAnimator(); | ||
782 | |||
783 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
784 | |||
785 | LLWLParamManager::instance()->mCurParams.setStarBrightness(sldrCtrl->getValueF32()); | ||
786 | } | ||
787 | |||
788 | void LLFloaterWindLight::onNewPreset(void* userData) | ||
789 | { | ||
790 | gViewerWindow->alertXmlEditText("NewSkyPreset", LLString::format_map_t(), | ||
791 | NULL, NULL, newPromptCallback, NULL); | ||
792 | } | ||
793 | |||
794 | void LLFloaterWindLight::onSavePreset(void* userData) | ||
795 | { | ||
796 | // get the name | ||
797 | LLComboBox* comboBox = LLUICtrlFactory::getComboBoxByName(sWindLight, | ||
798 | "WLPresetsCombo"); | ||
799 | |||
800 | // don't save the empty name | ||
801 | if(comboBox->getSelectedItemLabel() == "") | ||
802 | { | ||
803 | return; | ||
804 | } | ||
805 | |||
806 | // check to see if it's a default and shouldn't be overwritten | ||
807 | std::set<std::string>::iterator sIt = sDefaultPresets.find( | ||
808 | comboBox->getSelectedItemLabel().c_str()); | ||
809 | if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets")) | ||
810 | { | ||
811 | gViewerWindow->alertXml("WLNoEditDefault"); | ||
812 | return; | ||
813 | } | ||
814 | |||
815 | LLWLParamManager::instance()->mCurParams.mName = | ||
816 | comboBox->getSelectedItemLabel(); | ||
817 | |||
818 | gViewerWindow->alertXml("WLSavePresetAlert", saveAlertCallback, sWindLight); | ||
819 | } | ||
820 | |||
821 | void LLFloaterWindLight::saveAlertCallback(S32 option, void* userdata) | ||
822 | { | ||
823 | // if they choose save, do it. Otherwise, don't do anything | ||
824 | if(option == 0) | ||
825 | { | ||
826 | LLWLParamManager * param_mgr = LLWLParamManager::instance(); | ||
827 | |||
828 | param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams); | ||
829 | |||
830 | // comment this back in to save to file | ||
831 | param_mgr->savePreset(param_mgr->mCurParams.mName); | ||
832 | } | ||
833 | |||
834 | } | ||
835 | |||
836 | void LLFloaterWindLight::onDeletePreset(void* userData) | ||
837 | { | ||
838 | LLComboBox* combo_box = LLUICtrlFactory::getComboBoxByName(sWindLight, | ||
839 | "WLPresetsCombo"); | ||
840 | |||
841 | if(combo_box->getSelectedValue().asString() == "") | ||
842 | { | ||
843 | return; | ||
844 | } | ||
845 | |||
846 | LLString::format_map_t args; | ||
847 | args["[SKY]"] = combo_box->getSelectedValue().asString(); | ||
848 | gViewerWindow->alertXml("WLDeletePresetAlert", args, deleteAlertCallback, sWindLight); | ||
849 | } | ||
850 | |||
851 | void LLFloaterWindLight::deleteAlertCallback(S32 option, void* userdata) | ||
852 | { | ||
853 | // if they choose delete, do it. Otherwise, don't do anything | ||
854 | if(option == 0) | ||
855 | { | ||
856 | LLComboBox* combo_box = LLUICtrlFactory::getComboBoxByName(sWindLight, | ||
857 | "WLPresetsCombo"); | ||
858 | LLFloaterDayCycle* day_cycle = NULL; | ||
859 | LLComboBox* key_combo = NULL; | ||
860 | LLMultiSliderCtrl* mult_sldr = NULL; | ||
861 | |||
862 | if(LLFloaterDayCycle::isOpen()) | ||
863 | { | ||
864 | day_cycle = LLFloaterDayCycle::instance(); | ||
865 | key_combo = LLUICtrlFactory::getComboBoxByName(day_cycle, | ||
866 | "WLKeyPresets"); | ||
867 | mult_sldr = LLUICtrlFactory::getMultiSliderByName(day_cycle, | ||
868 | "WLDayCycleKeys"); | ||
869 | } | ||
870 | |||
871 | LLString name(combo_box->getSelectedValue().asString()); | ||
872 | |||
873 | // check to see if it's a default and shouldn't be deleted | ||
874 | std::set<std::string>::iterator sIt = sDefaultPresets.find(name.c_str()); | ||
875 | if(sIt != sDefaultPresets.end()) | ||
876 | { | ||
877 | gViewerWindow->alertXml("WLNoEditDefault"); | ||
878 | return; | ||
879 | } | ||
880 | |||
881 | LLWLParamManager::instance()->removeParamSet(name, true); | ||
882 | |||
883 | // remove and choose another | ||
884 | S32 new_index = combo_box->getCurrentIndex(); | ||
885 | |||
886 | combo_box->remove(name); | ||
887 | if(key_combo != NULL) | ||
888 | { | ||
889 | key_combo->remove(name); | ||
890 | |||
891 | // remove from slider, as well | ||
892 | day_cycle->deletePreset(name); | ||
893 | } | ||
894 | |||
895 | // pick the previously selected index after delete | ||
896 | if(new_index > 0) | ||
897 | { | ||
898 | new_index--; | ||
899 | } | ||
900 | |||
901 | if(combo_box->getItemCount() > 0) | ||
902 | { | ||
903 | combo_box->setCurrentByIndex(new_index); | ||
904 | } | ||
905 | } | ||
906 | } | ||
907 | |||
908 | |||
909 | void LLFloaterWindLight::onChangePresetName(LLUICtrl* ctrl, void * userData) | ||
910 | { | ||
911 | deactivateAnimator(); | ||
912 | |||
913 | LLComboBox * combo_box = static_cast<LLComboBox*>(ctrl); | ||
914 | |||
915 | if(combo_box->getSimple() == "") | ||
916 | { | ||
917 | return; | ||
918 | } | ||
919 | |||
920 | LLWLParamManager::instance()->loadPreset( | ||
921 | combo_box->getSelectedValue().asString()); | ||
922 | sWindLight->syncMenu(); | ||
923 | } | ||
924 | |||
925 | void LLFloaterWindLight::onOpenDayCycle(void* userData) | ||
926 | { | ||
927 | LLFloaterDayCycle::show(); | ||
928 | } | ||
929 | |||
930 | // Clouds | ||
931 | void LLFloaterWindLight::onCloudScrollXMoved(LLUICtrl* ctrl, void* userData) | ||
932 | { | ||
933 | deactivateAnimator(); | ||
934 | |||
935 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
936 | // *HACK all cloud scrolling is off by an additive of 10. | ||
937 | LLWLParamManager::instance()->mCurParams.setCloudScrollX(sldrCtrl->getValueF32() + 10.0f); | ||
938 | } | ||
939 | |||
940 | void LLFloaterWindLight::onCloudScrollYMoved(LLUICtrl* ctrl, void* userData) | ||
941 | { | ||
942 | deactivateAnimator(); | ||
943 | |||
944 | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
945 | |||
946 | // *HACK all cloud scrolling is off by an additive of 10. | ||
947 | LLWLParamManager::instance()->mCurParams.setCloudScrollY(sldrCtrl->getValueF32() + 10.0f); | ||
948 | } | ||
949 | |||
950 | void LLFloaterWindLight::onCloudScrollXToggled(LLUICtrl* ctrl, void* userData) | ||
951 | { | ||
952 | deactivateAnimator(); | ||
953 | |||
954 | LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl); | ||
955 | |||
956 | bool lock = cbCtrl->get(); | ||
957 | LLWLParamManager::instance()->mCurParams.setEnableCloudScrollX(!lock); | ||
958 | |||
959 | LLSliderCtrl* sldr = LLUICtrlFactory::getSliderByName(sWindLight, | ||
960 | "WLCloudScrollX"); | ||
961 | |||
962 | if(cbCtrl->get()) | ||
963 | { | ||
964 | sldr->setEnabled(false); | ||
965 | } | ||
966 | else | ||
967 | { | ||
968 | sldr->setEnabled(true); | ||
969 | } | ||
970 | |||
971 | } | ||
972 | |||
973 | void LLFloaterWindLight::onCloudScrollYToggled(LLUICtrl* ctrl, void* userData) | ||
974 | { | ||
975 | deactivateAnimator(); | ||
976 | |||
977 | LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl); | ||
978 | bool lock = cbCtrl->get(); | ||
979 | LLWLParamManager::instance()->mCurParams.setEnableCloudScrollY(!lock); | ||
980 | |||
981 | LLSliderCtrl* sldr = LLUICtrlFactory::getSliderByName(sWindLight, | ||
982 | "WLCloudScrollY"); | ||
983 | |||
984 | if(cbCtrl->get()) | ||
985 | { | ||
986 | sldr->setEnabled(false); | ||
987 | } | ||
988 | else | ||
989 | { | ||
990 | sldr->setEnabled(true); | ||
991 | } | ||
992 | } | ||
993 | |||
994 | void LLFloaterWindLight::deactivateAnimator() | ||
995 | { | ||
996 | LLWLParamManager::instance()->mAnimator.mIsRunning = false; | ||
997 | LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; | ||
998 | } | ||