diff options
Diffstat (limited to 'linden/indra/newview/rlvextensions.cpp')
-rw-r--r-- | linden/indra/newview/rlvextensions.cpp | 497 |
1 files changed, 497 insertions, 0 deletions
diff --git a/linden/indra/newview/rlvextensions.cpp b/linden/indra/newview/rlvextensions.cpp new file mode 100644 index 0000000..f31c62e --- /dev/null +++ b/linden/indra/newview/rlvextensions.cpp | |||
@@ -0,0 +1,497 @@ | |||
1 | #include "llviewerprecompiledheaders.h" | ||
2 | #include "llagent.h" | ||
3 | #include "llfloaterwindlight.h" | ||
4 | #include "llviewercontrol.h" | ||
5 | #include "llviewerwindow.h" | ||
6 | #include "llvoavatar.h" | ||
7 | #include "llwlparammanager.h" | ||
8 | |||
9 | #include "rlvextensions.h" | ||
10 | #include "rlvhandler.h" | ||
11 | |||
12 | // ============================================================================ | ||
13 | |||
14 | std::map<std::string, S16> RlvExtGetSet::m_DbgAllowed; | ||
15 | std::map<std::string, std::string> RlvExtGetSet::m_PseudoDebug; | ||
16 | |||
17 | // Checked: 2009-06-03 (RLVa-0.2.0h) | Modified: RLVa-0.2.0h | ||
18 | RlvExtGetSet::RlvExtGetSet() | ||
19 | { | ||
20 | if (!m_DbgAllowed.size()) // m_DbgAllowed is static and should only be initialized once | ||
21 | { | ||
22 | m_DbgAllowed.insert(std::pair<std::string, S16>("AvatarSex", DBG_READ | DBG_WRITE | DBG_PSEUDO)); | ||
23 | m_DbgAllowed.insert(std::pair<std::string, S16>("RenderResolutionDivisor", DBG_READ | DBG_WRITE)); | ||
24 | #ifdef RLV_EXTENSION_CMD_GETSETDEBUG_EX | ||
25 | m_DbgAllowed.insert(std::pair<std::string, S16>(RLV_SETTING_FORBIDGIVETORLV, DBG_READ)); | ||
26 | m_DbgAllowed.insert(std::pair<std::string, S16>(RLV_SETTING_NOSETENV, DBG_READ)); | ||
27 | m_DbgAllowed.insert(std::pair<std::string, S16>("WindLightUseAtmosShaders", DBG_READ)); | ||
28 | #endif // RLV_EXTENSION_CMD_GETSETDEBUG_EX | ||
29 | |||
30 | // Cache persistance of every setting | ||
31 | LLControlVariable* pSetting; | ||
32 | for (std::map<std::string, S16>::iterator itDbg = m_DbgAllowed.begin(); itDbg != m_DbgAllowed.end(); ++itDbg) | ||
33 | { | ||
34 | if ( ((pSetting = gSavedSettings.getControl(itDbg->first)) != NULL) && (pSetting->isPersisted()) ) | ||
35 | itDbg->second |= DBG_PERSIST; | ||
36 | } | ||
37 | } | ||
38 | } | ||
39 | |||
40 | // Checked: 2009-05-17 (RLVa-0.2.0a) | ||
41 | BOOL RlvExtGetSet::onForceCommand(const RlvEvent& rlvEvent) | ||
42 | { | ||
43 | return processCommand(rlvEvent.getSenderID(), rlvEvent.getCommand()); | ||
44 | } | ||
45 | |||
46 | // Checked: 2009-05-17 (RLVa-0.2.0a) | ||
47 | BOOL RlvExtGetSet::onReplyCommand(const EventType& rlvEvent) | ||
48 | { | ||
49 | return processCommand(rlvEvent.getSenderID(), rlvEvent.getCommand()); | ||
50 | } | ||
51 | |||
52 | // Checked: 2009-06-18 (RLVa-0.2.1d) | Modified: RLVa-0.2.1d | ||
53 | BOOL RlvExtGetSet::processCommand(const LLUUID& idObj, const RlvCommand& rlvCmd) | ||
54 | { | ||
55 | std::string strBehaviour = rlvCmd.getBehaviour(), strGetSet, strSetting; | ||
56 | int idxSetting = strBehaviour.find('_'); | ||
57 | if ( (strBehaviour.length() >= 6) && (-1 != idxSetting) && ((int)strBehaviour.length() > idxSetting + 1) ) | ||
58 | { | ||
59 | strSetting = strBehaviour.substr(idxSetting + 1); | ||
60 | strBehaviour.erase(idxSetting); // Get rid of "_<setting>" | ||
61 | |||
62 | strGetSet = strBehaviour.substr(0, 3); | ||
63 | strBehaviour.erase(0, 3); // Get rid of get/set | ||
64 | |||
65 | if ("debug" == strBehaviour) | ||
66 | { | ||
67 | if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) ) | ||
68 | { | ||
69 | rlvSendChatReply(rlvCmd.getParam(), onGetDebug(strSetting)); | ||
70 | return TRUE; | ||
71 | } | ||
72 | else if ( ("set" == strGetSet) && (RLV_TYPE_FORCE == rlvCmd.getParamType()) ) | ||
73 | { | ||
74 | if (!gRlvHandler.hasBehaviourExcept(RLV_BHVR_SETDEBUG, idObj)) | ||
75 | onSetDebug(strSetting, rlvCmd.getOption()); | ||
76 | return TRUE; | ||
77 | } | ||
78 | } | ||
79 | else if ("env" == strBehaviour) | ||
80 | { | ||
81 | if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) ) | ||
82 | { | ||
83 | rlvSendChatReply(rlvCmd.getParam(), onGetEnv(strSetting)); | ||
84 | return TRUE; | ||
85 | } | ||
86 | else if ( ("set" == strGetSet) && (RLV_TYPE_FORCE == rlvCmd.getParamType()) ) | ||
87 | { | ||
88 | if (!gRlvHandler.hasBehaviourExcept(RLV_BHVR_SETENV, idObj)) | ||
89 | onSetEnv(strSetting, rlvCmd.getOption()); | ||
90 | return TRUE; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | else if ("setrot" == rlvCmd.getBehaviour()) | ||
95 | { | ||
96 | // NOTE: if <option> is invalid (or missing) altogether then RLV-1.17 will rotate to 0.0 (which is actually PI / 4) | ||
97 | F32 nAngle = 0.0f; | ||
98 | if (LLStringUtil::convertToF32(rlvCmd.getOption(), nAngle)) | ||
99 | { | ||
100 | nAngle += RLV_SETROT_OFFSET; | ||
101 | |||
102 | gAgent.startCameraAnimation(); | ||
103 | |||
104 | LLVector3 at(LLVector3::x_axis); | ||
105 | at.rotVec(nAngle, LLVector3::z_axis); | ||
106 | at.normalize(); | ||
107 | gAgent.resetAxes(at); | ||
108 | |||
109 | return TRUE; | ||
110 | } | ||
111 | } | ||
112 | return FALSE; | ||
113 | } | ||
114 | |||
115 | // Checked: 2009-06-03 (RLVa-0.2.0h) | Modified: RLVa-0.2.0h | ||
116 | bool RlvExtGetSet::findDebugSetting(std::string& strSetting, S16& flags) | ||
117 | { | ||
118 | LLStringUtil::toLower(strSetting); // Convenience for non-RLV calls | ||
119 | |||
120 | std::string strTemp; | ||
121 | for (std::map<std::string, S16>::const_iterator itSetting = m_DbgAllowed.begin(); itSetting != m_DbgAllowed.end(); ++itSetting) | ||
122 | { | ||
123 | strTemp = itSetting->first; | ||
124 | LLStringUtil::toLower(strTemp); | ||
125 | |||
126 | if (strSetting == strTemp) | ||
127 | { | ||
128 | strSetting = itSetting->first; | ||
129 | flags = itSetting->second; | ||
130 | return true; | ||
131 | } | ||
132 | } | ||
133 | return false; | ||
134 | } | ||
135 | |||
136 | // Checked: 2009-06-03 (RLVa-0.2.0h) | Added: RLVa-0.2.0h | ||
137 | S16 RlvExtGetSet::getDebugSettingFlags(const std::string& strSetting) | ||
138 | { | ||
139 | std::map<std::string, S16>::const_iterator itSetting = m_DbgAllowed.find(strSetting); | ||
140 | return (itSetting != m_DbgAllowed.end()) ? itSetting->second : 0; | ||
141 | } | ||
142 | |||
143 | // Checked: 2009-06-03 (RLVa-0.2.0h) | Modified: RLVa-0.2.0h | ||
144 | std::string RlvExtGetSet::onGetDebug(std::string strSetting) | ||
145 | { | ||
146 | S16 dbgFlags; | ||
147 | if ( (findDebugSetting(strSetting, dbgFlags)) && ((dbgFlags & DBG_READ) == DBG_READ) ) | ||
148 | { | ||
149 | if ((dbgFlags & DBG_PSEUDO) == 0) | ||
150 | { | ||
151 | LLControlVariable* pSetting = gSavedSettings.getControl(strSetting); | ||
152 | if (pSetting) | ||
153 | { | ||
154 | switch (pSetting->type()) | ||
155 | { | ||
156 | case TYPE_U32: | ||
157 | return llformat("%u", gSavedSettings.getU32(strSetting)); | ||
158 | case TYPE_S32: | ||
159 | return llformat("%d", gSavedSettings.getS32(strSetting)); | ||
160 | case TYPE_BOOLEAN: | ||
161 | return llformat("%d", gSavedSettings.getBOOL(strSetting)); | ||
162 | default: | ||
163 | RLV_ERRS << "Unexpected debug setting type" << LL_ENDL; | ||
164 | break; | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | else | ||
169 | { | ||
170 | return onGetPseudoDebug(strSetting); | ||
171 | } | ||
172 | } | ||
173 | return std::string(); | ||
174 | } | ||
175 | |||
176 | // Checked: 2009-10-03 (RLVa-1.0.4e) | Added: RLVa-1.0.4e | ||
177 | std::string RlvExtGetSet::onGetPseudoDebug(const std::string& strSetting) | ||
178 | { | ||
179 | // Skip sanity checking because it's all done in RlvExtGetSet::onGetDebug() already | ||
180 | if ("AvatarSex" == strSetting) | ||
181 | { | ||
182 | std::map<std::string, std::string>::const_iterator itPseudo = m_PseudoDebug.find(strSetting); | ||
183 | if (itPseudo != m_PseudoDebug.end()) | ||
184 | { | ||
185 | return itPseudo->second; | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | if (gAgent.getAvatarObject()) | ||
190 | return llformat("%d", (gAgent.getAvatarObject()->getSex() == SEX_MALE)); // [See LLFloaterCustomize::LLFloaterCustomize()] | ||
191 | } | ||
192 | } | ||
193 | return std::string(); | ||
194 | } | ||
195 | |||
196 | // Checked: 2009-10-10 (RLVa-1.0.4e) | Modified: RLVa-1.0.4e | ||
197 | void RlvExtGetSet::onSetDebug(std::string strSetting, const std::string& strValue) | ||
198 | { | ||
199 | S16 dbgFlags; | ||
200 | if ( (findDebugSetting(strSetting, dbgFlags)) && ((dbgFlags & DBG_WRITE) == DBG_WRITE) ) | ||
201 | { | ||
202 | if ((dbgFlags & DBG_PSEUDO) == 0) | ||
203 | { | ||
204 | LLControlVariable* pSetting = gSavedSettings.getControl(strSetting); | ||
205 | if (pSetting) | ||
206 | { | ||
207 | U32 u32Value; S32 s32Value; BOOL fValue; | ||
208 | switch (pSetting->type()) | ||
209 | { | ||
210 | case TYPE_U32: | ||
211 | if (LLStringUtil::convertToU32(strValue, u32Value)) | ||
212 | gSavedSettings.setU32(strSetting, u32Value); | ||
213 | break; | ||
214 | case TYPE_S32: | ||
215 | if (LLStringUtil::convertToS32(strValue, s32Value)) | ||
216 | gSavedSettings.setS32(strSetting, s32Value); | ||
217 | break; | ||
218 | case TYPE_BOOLEAN: | ||
219 | if (LLStringUtil::convertToBOOL(strValue, fValue)) | ||
220 | gSavedSettings.setBOOL(strSetting, fValue); | ||
221 | break; | ||
222 | default: | ||
223 | RLV_ERRS << "Unexpected debug setting type" << LL_ENDL; | ||
224 | break; | ||
225 | } | ||
226 | |||
227 | // Default settings should persist if they were marked that way, but non-default settings should never persist | ||
228 | pSetting->setPersist( (pSetting->isDefault()) ? ((dbgFlags & DBG_PERSIST) == DBG_PERSIST) : false ); | ||
229 | } | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | onSetPseudoDebug(strSetting, strValue); | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | |||
238 | // Checked: 2009-10-10 (RLVa-1.0.4e) | Modified: RLVa-1.0.4e | ||
239 | void RlvExtGetSet::onSetPseudoDebug(const std::string& strSetting, const std::string& strValue) | ||
240 | { | ||
241 | if ("AvatarSex" == strSetting) | ||
242 | { | ||
243 | BOOL fValue; | ||
244 | if (LLStringUtil::convertToBOOL(strValue, fValue)) | ||
245 | m_PseudoDebug[strSetting] = strValue; | ||
246 | } | ||
247 | } | ||
248 | |||
249 | // Checked: 2009-09-16 (RLVa-1.0.3c) | Modified: RLVa-1.0.3c | ||
250 | std::string RlvExtGetSet::onGetEnv(std::string strSetting) | ||
251 | { | ||
252 | // HACK: - create a LLFloaterWindLight instance if there isn't one already | ||
253 | // - isOpen() is actually instanceExists() | ||
254 | // - creating an instance results in showing the floater which is why we need to ->close() it | ||
255 | if (!LLFloaterWindLight::isOpen()) | ||
256 | { | ||
257 | LLFloaterWindLight::instance()->close(); | ||
258 | LLFloaterWindLight::instance()->syncMenu(); | ||
259 | } | ||
260 | |||
261 | LLWLParamManager* pWLParams = LLWLParamManager::instance(); | ||
262 | |||
263 | F32 nValue = 0.0f; | ||
264 | if ("daytime" == strSetting) | ||
265 | { | ||
266 | nValue = (pWLParams->mAnimator.mIsRunning && pWLParams->mAnimator.mUseLindenTime) ? -1.0f : pWLParams->mAnimator.getDayTime(); | ||
267 | } | ||
268 | else if ("preset" == strSetting) | ||
269 | { | ||
270 | return (pWLParams->mAnimator.mIsRunning && pWLParams->mAnimator.mUseLindenTime) ? std::string() : pWLParams->mCurParams.mName; | ||
271 | } | ||
272 | else if ("cloudcoverage" == strSetting) nValue = pWLParams->mCloudCoverage; | ||
273 | else if ("cloudscale" == strSetting) nValue = pWLParams->mCloudScale; | ||
274 | else if ("cloudscrollx" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollX() - 10.0f; | ||
275 | else if ("cloudscrolly" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollY() - 10.0f; | ||
276 | else if ("densitymultiplier" == strSetting) nValue = pWLParams->mDensityMult.x * pWLParams->mDensityMult.mult; | ||
277 | else if ("distancemultiplier" == strSetting) nValue = pWLParams->mDistanceMult; | ||
278 | else if ("eastangle" == strSetting) nValue = pWLParams->mCurParams.getEastAngle() / F_TWO_PI; | ||
279 | else if ("hazedensity" == strSetting) nValue = pWLParams->mHazeDensity.r; | ||
280 | else if ("hazehorizon" == strSetting) nValue = pWLParams->mHazeHorizon.r; | ||
281 | else if ("maxaltitude" == strSetting) nValue = pWLParams->mMaxAlt; | ||
282 | else if ("scenegamma" == strSetting) nValue = pWLParams->mWLGamma; | ||
283 | else if ("starbrightness" == strSetting) nValue = pWLParams->mCurParams.getStarBrightness(); | ||
284 | else if ("sunglowfocus" == strSetting) nValue = -pWLParams->mGlow.b / 5.0f; | ||
285 | else if ("sunglowsize" == strSetting) nValue = 2 - pWLParams->mGlow.r / 20.0f; | ||
286 | else if ("sunmoonposition" == strSetting) nValue = pWLParams->mCurParams.getSunAngle() / F_TWO_PI; | ||
287 | else | ||
288 | { | ||
289 | char ch = strSetting[strSetting.length() - 1]; | ||
290 | // HACK-RLVa: not entirely proper (creates new synonyms) | ||
291 | if ('x' == ch) ch = 'r'; | ||
292 | else if ('y' == ch) ch = 'g'; | ||
293 | else if ('d' == ch) ch = 'b'; | ||
294 | |||
295 | if ( ('r' == ch) || ('g' == ch) || ('b' == ch) || ('i' == ch) ) | ||
296 | { | ||
297 | WLColorControl* pColour = NULL; | ||
298 | strSetting.erase(strSetting.length() - 1, 1); | ||
299 | |||
300 | if ("ambient" == strSetting) pColour = &pWLParams->mAmbient; | ||
301 | else if ("bluedensity" == strSetting) pColour = &pWLParams->mBlueDensity; | ||
302 | else if ("bluehorizon" == strSetting) pColour = &pWLParams->mBlueHorizon; | ||
303 | else if ("sunmooncolor" == strSetting) pColour = &pWLParams->mSunlight; | ||
304 | else if ("cloudcolor" == strSetting) pColour = &pWLParams->mCloudColor; | ||
305 | else if ("cloud" == strSetting) pColour = &pWLParams->mCloudMain; | ||
306 | else if ("clouddetail" == strSetting) pColour = &pWLParams->mCloudDetail; | ||
307 | |||
308 | if (pColour) | ||
309 | { | ||
310 | if ('r' == ch) nValue = pColour->r; | ||
311 | else if ('g' == ch) nValue = pColour->g; | ||
312 | else if ('b' == ch) nValue = pColour->b; | ||
313 | else if (('i' == ch) && (pColour->hasSliderName)) nValue = llmax(pColour->r, pColour->g, pColour->b); | ||
314 | |||
315 | if (pColour->isBlueHorizonOrDensity) nValue /= 2.0f; | ||
316 | else if (pColour->isSunOrAmbientColor) nValue /= 3.0f; | ||
317 | } | ||
318 | } | ||
319 | } | ||
320 | |||
321 | return llformat("%f", nValue); | ||
322 | } | ||
323 | |||
324 | // Checked: 2009-09-16 (RLVa-1.0.3c) | Modified: RLVa-1.0.3c | ||
325 | void RlvExtGetSet::onSetEnv(std::string strSetting, const std::string& strValue) | ||
326 | { | ||
327 | // HACK: see RlvExtGetSet::onGetEnv | ||
328 | if (!LLFloaterWindLight::isOpen()) | ||
329 | { | ||
330 | LLFloaterWindLight::instance()->close(); | ||
331 | LLFloaterWindLight::instance()->syncMenu(); | ||
332 | } | ||
333 | |||
334 | LLWLParamManager* pWLParams = LLWLParamManager::instance(); | ||
335 | WLFloatControl* pFloat = NULL; | ||
336 | WLColorControl* pColour = NULL; | ||
337 | |||
338 | F32 nValue = 0.0f; | ||
339 | // Sanity check - make sure strValue specifies a number for all settings except "preset" | ||
340 | if ( (rlv_handler_t::fNoSetEnv) || ( (!LLStringUtil::convertToF32(strValue, nValue)) && ("preset" != strSetting) )) | ||
341 | return; | ||
342 | |||
343 | // Not quite correct, but RLV-1.16.0 will halt the default daytime cycle on invalid commands so we need to as well | ||
344 | pWLParams->mAnimator.mIsRunning = false; | ||
345 | pWLParams->mAnimator.mUseLindenTime = false; | ||
346 | |||
347 | // See LLWorldEnvSettings::handleEvent() | ||
348 | if ("daytime" == strSetting) | ||
349 | { | ||
350 | if (0.0f <= nValue) | ||
351 | { | ||
352 | pWLParams->mAnimator.setDayTime(llmin(nValue, 1.0f)); | ||
353 | pWLParams->mAnimator.update(pWLParams->mCurParams); | ||
354 | } | ||
355 | else | ||
356 | { | ||
357 | pWLParams->mAnimator.mIsRunning = true; | ||
358 | pWLParams->mAnimator.mUseLindenTime = true; | ||
359 | } | ||
360 | return; | ||
361 | } | ||
362 | // See LLFloaterWindLight::onChangePresetName() | ||
363 | else if ("preset" == strSetting) | ||
364 | { | ||
365 | pWLParams->loadPreset(strValue, true); | ||
366 | return; | ||
367 | } | ||
368 | // See LLFloaterWindLight::onStarAlphaMoved | ||
369 | else if ("starbrightness" == strSetting) | ||
370 | { | ||
371 | pWLParams->mCurParams.setStarBrightness(nValue); | ||
372 | return; | ||
373 | } | ||
374 | // See LLFloaterWindLight::onGlowRMoved() / LLFloaterWindLight::onGlowBMoved() | ||
375 | else if ( ("sunglowfocus" == strSetting) || ("sunglowsize" == strSetting) ) | ||
376 | { | ||
377 | WLColorControl *pColour = &pWLParams->mGlow; | ||
378 | if ("sunglowfocus" == strSetting) | ||
379 | pColour->b = -nValue * 5; | ||
380 | else | ||
381 | pColour->r = (2 - nValue) * 20; | ||
382 | |||
383 | pColour->update(pWLParams->mCurParams); | ||
384 | pWLParams->propagateParameters(); | ||
385 | return; | ||
386 | } | ||
387 | // See LLFloaterWindLight::onSunMoved() | ||
388 | else if ( ("eastangle" == strSetting) || ("sunmoonposition" == strSetting) ) | ||
389 | { | ||
390 | if ("eastangle" == strSetting) | ||
391 | pWLParams->mCurParams.setEastAngle(F_TWO_PI * nValue); | ||
392 | else | ||
393 | pWLParams->mCurParams.setSunAngle(F_TWO_PI * nValue); | ||
394 | |||
395 | // TODO-RLVa: it looks like propagateParameters() will actually take care of this for us, making this redundant? | ||
396 | WLColorControl* pColour = &pWLParams->mLightnorm; | ||
397 | pColour->r = -sin(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle()); | ||
398 | pColour->g = sin(pWLParams->mCurParams.getSunAngle()); | ||
399 | pColour->b = cos(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle()); | ||
400 | pColour->i = 1.f; | ||
401 | |||
402 | pColour->update(pWLParams->mCurParams); | ||
403 | pWLParams->propagateParameters(); | ||
404 | return; | ||
405 | } | ||
406 | // See LLFloaterWindLight::onCloudScrollXMoved() / LLFloaterWindLight::onCloudScrollYMoved() | ||
407 | else if ("cloudscrollx" == strSetting) | ||
408 | { | ||
409 | pWLParams->mCurParams.setCloudScrollX(nValue + 10.0f); | ||
410 | return; | ||
411 | } | ||
412 | else if ("cloudscrolly" == strSetting) | ||
413 | { | ||
414 | pWLParams->mCurParams.setCloudScrollY(nValue + 10.0f); | ||
415 | return; | ||
416 | } | ||
417 | // See LLFloaterWindLight::onFloatControlMoved() | ||
418 | else if ("cloudcoverage" == strSetting) pFloat = &pWLParams->mCloudCoverage; | ||
419 | else if ("cloudscale" == strSetting) pFloat = &pWLParams->mCloudScale; | ||
420 | else if ("densitymultiplier" == strSetting) pFloat = &pWLParams->mDensityMult; | ||
421 | else if ("distancemultiplier" == strSetting) pFloat = &pWLParams->mDistanceMult; | ||
422 | else if ("maxaltitude" == strSetting) pFloat = &pWLParams->mMaxAlt; | ||
423 | else if ("scenegamma" == strSetting) pFloat = &pWLParams->mWLGamma; | ||
424 | // See LLFloaterWindLight::onColorControlRMoved() | ||
425 | else if ("hazedensity" == strSetting) pColour = &pWLParams->mHazeDensity; | ||
426 | else if ("hazehorizon" == strSetting) pColour = &pWLParams->mHazeHorizon; | ||
427 | |||
428 | if (pFloat) | ||
429 | { | ||
430 | pFloat->x = nValue / pFloat->mult; | ||
431 | pFloat->update(pWLParams->mCurParams); | ||
432 | pWLParams->propagateParameters(); | ||
433 | return; | ||
434 | } | ||
435 | else if (pColour) | ||
436 | { | ||
437 | pColour->r = nValue; | ||
438 | pColour->update(pWLParams->mCurParams); | ||
439 | pWLParams->propagateParameters(); | ||
440 | return; | ||
441 | } | ||
442 | |||
443 | // RGBI settings | ||
444 | char ch = strSetting[strSetting.length() - 1]; | ||
445 | if ('x' == ch) ch = 'r'; | ||
446 | else if ('y' == ch) ch = 'g'; | ||
447 | else if ('d' == ch) ch = 'b'; | ||
448 | |||
449 | if ( ('r' == ch) || ('g' == ch) || ('b' == ch) || ('i' == ch) ) | ||
450 | { | ||
451 | strSetting.erase(strSetting.length() - 1, 1); | ||
452 | |||
453 | if ("ambient" == strSetting) pColour = &pWLParams->mAmbient; | ||
454 | else if ("bluedensity" == strSetting) pColour = &pWLParams->mBlueDensity; | ||
455 | else if ("bluehorizon" == strSetting) pColour = &pWLParams->mBlueHorizon; | ||
456 | else if ("sunmooncolor" == strSetting) pColour = &pWLParams->mSunlight; | ||
457 | else if ("cloudcolor" == strSetting) pColour = &pWLParams->mCloudColor; | ||
458 | else if ("cloud" == strSetting) pColour = &pWLParams->mCloudMain; | ||
459 | else if ("clouddetail" == strSetting) pColour = &pWLParams->mCloudDetail; | ||
460 | |||
461 | if (pColour) | ||
462 | { | ||
463 | if (pColour->isBlueHorizonOrDensity) nValue *= 2.0f; | ||
464 | else if (pColour->isSunOrAmbientColor) nValue *= 3.0f; | ||
465 | |||
466 | if ('i' == ch) // (See: LLFloaterWindLight::onColorControlIMoved) | ||
467 | { | ||
468 | if (!pColour->hasSliderName) | ||
469 | return; | ||
470 | |||
471 | F32 curMax = llmax(pColour->r, pColour->g, pColour->b); | ||
472 | if ( (0.0f == nValue) || (0.0f == curMax) ) | ||
473 | pColour->r = pColour->g = pColour->b = pColour->i = nValue; | ||
474 | else | ||
475 | { | ||
476 | F32 nDelta = (nValue - curMax) / curMax; | ||
477 | pColour->r *= (1.0f + nDelta); | ||
478 | pColour->g *= (1.0f + nDelta); | ||
479 | pColour->b *= (1.0f + nDelta); | ||
480 | pColour->i = nValue; | ||
481 | } | ||
482 | } | ||
483 | else // (See: LLFloaterWindLight::onColorControlRMoved) | ||
484 | { | ||
485 | F32* pnValue = ('r' == ch) ? &pColour->r : ('g' == ch) ? &pColour->g : ('b' == ch) ? &pColour->b : NULL; | ||
486 | if (pnValue) | ||
487 | *pnValue = nValue; | ||
488 | pColour->i = llmax(pColour->r, pColour->g, pColour->b); | ||
489 | } | ||
490 | |||
491 | pColour->update(pWLParams->mCurParams); | ||
492 | pWLParams->propagateParameters(); | ||
493 | } | ||
494 | } | ||
495 | } | ||
496 | |||
497 | // ============================================================================ | ||