00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llfloaterwindlight.h"
00035
00036 #include "pipeline.h"
00037 #include "llsky.h"
00038
00039 #include "llsliderctrl.h"
00040 #include "llmultislider.h"
00041 #include "llmultisliderctrl.h"
00042 #include "llspinctrl.h"
00043 #include "llcheckboxctrl.h"
00044 #include "lluictrlfactory.h"
00045 #include "llviewercamera.h"
00046 #include "llcombobox.h"
00047 #include "lllineeditor.h"
00048 #include "llfloaterdaycycle.h"
00049 #include "llboost.h"
00050
00051 #include "v4math.h"
00052 #include "llviewerdisplay.h"
00053 #include "llviewercontrol.h"
00054 #include "llviewerwindow.h"
00055 #include "llsavedsettingsglue.h"
00056
00057 #include "llwlparamset.h"
00058 #include "llwlparammanager.h"
00059 #include "llpostprocess.h"
00060
00061 #undef max
00062
00063 LLFloaterWindLight* LLFloaterWindLight::sWindLight = NULL;
00064
00065 std::set<std::string> LLFloaterWindLight::sDefaultPresets;
00066
00067 static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f;
00068
00069 LLFloaterWindLight::LLFloaterWindLight() : LLFloater("windlight floater")
00070 {
00071 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_windlight_options.xml");
00072
00073
00074 LLComboBox* comboBox = getChild<LLComboBox>("WLPresetsCombo");
00075
00076 if(comboBox != NULL) {
00077
00078 std::map<std::string, LLWLParamSet>::iterator mIt =
00079 LLWLParamManager::instance()->mParamList.begin();
00080 for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++)
00081 {
00082 comboBox->add(mIt->first);
00083 }
00084
00085
00086 comboBox->add("");
00087
00088
00089 comboBox->selectByValue(LLSD("Default"));
00090 }
00091
00092
00093 LLString def_days = getString("WLDefaultSkyNames");
00094
00095
00096 sDefaultPresets.insert("");
00097 boost_tokenizer tokens(def_days, boost::char_separator<char>(":"));
00098 for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter)
00099 {
00100 LLString tok(*token_iter);
00101 sDefaultPresets.insert(tok);
00102 }
00103
00104
00105 initCallbacks();
00106 }
00107
00108 LLFloaterWindLight::~LLFloaterWindLight()
00109 {
00110 }
00111
00112 void LLFloaterWindLight::initCallbacks(void) {
00113
00114
00115 initHelpBtn("WLBlueHorizonHelp", "HelpBlueHorizon");
00116 initHelpBtn("WLHazeHorizonHelp", "HelpHazeHorizon");
00117 initHelpBtn("WLBlueDensityHelp", "HelpBlueDensity");
00118 initHelpBtn("WLHazeDensityHelp", "HelpHazeDensity");
00119
00120 initHelpBtn("WLDensityMultHelp", "HelpDensityMult");
00121 initHelpBtn("WLDistanceMultHelp", "HelpDistanceMult");
00122 initHelpBtn("WLMaxAltitudeHelp", "HelpMaxAltitude");
00123
00124 initHelpBtn("WLSunlightColorHelp", "HelpSunlightColor");
00125 initHelpBtn("WLAmbientHelp", "HelpSunAmbient");
00126 initHelpBtn("WLSunGlowHelp", "HelpSunGlow");
00127 initHelpBtn("WLTimeOfDayHelp", "HelpTimeOfDay");
00128 initHelpBtn("WLEastAngleHelp", "HelpEastAngle");
00129
00130 initHelpBtn("WLSceneGammaHelp", "HelpSceneGamma");
00131 initHelpBtn("WLStarBrightnessHelp", "HelpStarBrightness");
00132
00133 initHelpBtn("WLCloudColorHelp", "HelpCloudColor");
00134 initHelpBtn("WLCloudDetailHelp", "HelpCloudDetail");
00135 initHelpBtn("WLCloudDensityHelp", "HelpCloudDensity");
00136 initHelpBtn("WLCloudCoverageHelp", "HelpCloudCoverage");
00137
00138 initHelpBtn("WLCloudScaleHelp", "HelpCloudScale");
00139 initHelpBtn("WLCloudScrollXHelp", "HelpCloudScrollX");
00140 initHelpBtn("WLCloudScrollYHelp", "HelpCloudScrollY");
00141
00142 initHelpBtn("WLClassicCloudsHelp", "HelpClassicClouds");
00143
00144 LLWLParamManager * param_mgr = LLWLParamManager::instance();
00145
00146
00147 childSetCommitCallback("WLBlueHorizonR", onColorControlRMoved, ¶m_mgr->mBlueHorizon);
00148 childSetCommitCallback("WLBlueHorizonG", onColorControlGMoved, ¶m_mgr->mBlueHorizon);
00149 childSetCommitCallback("WLBlueHorizonB", onColorControlBMoved, ¶m_mgr->mBlueHorizon);
00150 childSetCommitCallback("WLBlueHorizonI", onColorControlIMoved, ¶m_mgr->mBlueHorizon);
00151
00152
00153 childSetCommitCallback("WLHazeDensity", onColorControlRMoved, ¶m_mgr->mHazeDensity);
00154 childSetCommitCallback("WLHazeHorizon", onColorControlRMoved, ¶m_mgr->mHazeHorizon);
00155 childSetCommitCallback("WLDensityMult", onFloatControlMoved, ¶m_mgr->mDensityMult);
00156 childSetCommitCallback("WLMaxAltitude", onFloatControlMoved, ¶m_mgr->mMaxAlt);
00157
00158
00159 childSetCommitCallback("WLBlueDensityR", onColorControlRMoved, ¶m_mgr->mBlueDensity);
00160 childSetCommitCallback("WLBlueDensityG", onColorControlGMoved, ¶m_mgr->mBlueDensity);
00161 childSetCommitCallback("WLBlueDensityB", onColorControlBMoved, ¶m_mgr->mBlueDensity);
00162 childSetCommitCallback("WLBlueDensityI", onColorControlIMoved, ¶m_mgr->mBlueDensity);
00163
00164
00165
00166
00167 childSetCommitCallback("WLSunlightR", onColorControlRMoved, ¶m_mgr->mSunlight);
00168 childSetCommitCallback("WLSunlightG", onColorControlGMoved, ¶m_mgr->mSunlight);
00169 childSetCommitCallback("WLSunlightB", onColorControlBMoved, ¶m_mgr->mSunlight);
00170 childSetCommitCallback("WLSunlightI", onColorControlIMoved, ¶m_mgr->mSunlight);
00171
00172
00173 childSetCommitCallback("WLGlowR", onGlowRMoved, ¶m_mgr->mGlow);
00174 childSetCommitCallback("WLGlowB", onGlowBMoved, ¶m_mgr->mGlow);
00175
00176
00177 childSetCommitCallback("WLAmbientR", onColorControlRMoved, ¶m_mgr->mAmbient);
00178 childSetCommitCallback("WLAmbientG", onColorControlGMoved, ¶m_mgr->mAmbient);
00179 childSetCommitCallback("WLAmbientB", onColorControlBMoved, ¶m_mgr->mAmbient);
00180 childSetCommitCallback("WLAmbientI", onColorControlIMoved, ¶m_mgr->mAmbient);
00181
00182
00183 childSetCommitCallback("WLSunAngle", onSunMoved, ¶m_mgr->mLightnorm);
00184 childSetCommitCallback("WLEastAngle", onSunMoved, ¶m_mgr->mLightnorm);
00185
00186
00187
00188
00189 childSetCommitCallback("WLCloudColorR", onColorControlRMoved, ¶m_mgr->mCloudColor);
00190 childSetCommitCallback("WLCloudColorG", onColorControlGMoved, ¶m_mgr->mCloudColor);
00191 childSetCommitCallback("WLCloudColorB", onColorControlBMoved, ¶m_mgr->mCloudColor);
00192 childSetCommitCallback("WLCloudColorI", onColorControlIMoved, ¶m_mgr->mCloudColor);
00193
00194
00195 childSetCommitCallback("WLCloudX", onColorControlRMoved, ¶m_mgr->mCloudMain);
00196 childSetCommitCallback("WLCloudY", onColorControlGMoved, ¶m_mgr->mCloudMain);
00197 childSetCommitCallback("WLCloudDensity", onColorControlBMoved, ¶m_mgr->mCloudMain);
00198
00199
00200 childSetCommitCallback("WLCloudDetailX", onColorControlRMoved, ¶m_mgr->mCloudDetail);
00201 childSetCommitCallback("WLCloudDetailY", onColorControlGMoved, ¶m_mgr->mCloudDetail);
00202 childSetCommitCallback("WLCloudDetailDensity", onColorControlBMoved, ¶m_mgr->mCloudDetail);
00203
00204
00205 childSetCommitCallback("WLCloudCoverage", onFloatControlMoved, ¶m_mgr->mCloudCoverage);
00206 childSetCommitCallback("WLCloudScale", onFloatControlMoved, ¶m_mgr->mCloudScale);
00207 childSetCommitCallback("WLCloudLockX", onCloudScrollXToggled, NULL);
00208 childSetCommitCallback("WLCloudLockY", onCloudScrollYToggled, NULL);
00209 childSetCommitCallback("WLCloudScrollX", onCloudScrollXMoved, NULL);
00210 childSetCommitCallback("WLCloudScrollY", onCloudScrollYMoved, NULL);
00211 childSetCommitCallback("WLDistanceMult", onFloatControlMoved, ¶m_mgr->mDistanceMult);
00212 childSetCommitCallback("DrawClassicClouds", LLSavedSettingsGlue::setBOOL, (void*)"SkyUseClassicClouds");
00213
00214
00215 childSetAction("WLDayCycleMenuButton", onOpenDayCycle, NULL);
00216
00217 LLComboBox* comboBox = getChild<LLComboBox>("WLPresetsCombo");
00218
00219
00220 childSetAction("WLNewPreset", onNewPreset, comboBox);
00221 childSetAction("WLSavePreset", onSavePreset, comboBox);
00222 childSetAction("WLDeletePreset", onDeletePreset, comboBox);
00223
00224 comboBox->setCommitCallback(onChangePresetName);
00225
00226
00227
00228 childSetCommitCallback("WLGamma", onFloatControlMoved, ¶m_mgr->mWLGamma);
00229 childSetCommitCallback("WLStarAlpha", onStarAlphaMoved, NULL);
00230 }
00231
00232 void LLFloaterWindLight::onClickHelp(void* data)
00233 {
00234 LLFloaterWindLight* self = LLFloaterWindLight::instance();
00235
00236 const char* xml_alert = (const char*) data;
00237 LLAlertDialog* dialogp = gViewerWindow->alertXml(xml_alert);
00238 if (dialogp)
00239 {
00240 LLFloater* root_floater = gFloaterView->getParentFloater(self);
00241 if (root_floater)
00242 {
00243 root_floater->addDependentFloater(dialogp);
00244 }
00245 }
00246
00247 }
00248
00249 void LLFloaterWindLight::initHelpBtn(const char* name, const char* xml_alert)
00250 {
00251 childSetAction(name, onClickHelp, (void*)xml_alert);
00252 }
00253
00254 void LLFloaterWindLight::newPromptCallback(S32 option, const LLString& text, void* userData)
00255 {
00256 if(text == "")
00257 {
00258 return;
00259 }
00260
00261 if(option == 0) {
00262 LLComboBox* comboBox = sWindLight->getChild<LLComboBox>(
00263 "WLPresetsCombo");
00264
00265 LLFloaterDayCycle* sDayCycle = NULL;
00266 LLComboBox* keyCombo = NULL;
00267 if(LLFloaterDayCycle::isOpen())
00268 {
00269 sDayCycle = LLFloaterDayCycle::instance();
00270 keyCombo = sDayCycle->getChild<LLComboBox>(
00271 "WLKeyPresets");
00272 }
00273
00274
00275
00276 std::map<std::string, LLWLParamSet>::iterator mIt =
00277 LLWLParamManager::instance()->mParamList.find(text.c_str());
00278
00279
00280 if(mIt == LLWLParamManager::instance()->mParamList.end())
00281 {
00282 LLWLParamManager::instance()->addParamSet(text.c_str(),
00283 LLWLParamManager::instance()->mCurParams);
00284 comboBox->add(text);
00285 comboBox->sortByName();
00286
00287
00288 comboBox->selectFirstItem();
00289 if(comboBox->getSimple() == "")
00290 {
00291 comboBox->remove(0);
00292 }
00293 comboBox->add("");
00294
00295 comboBox->setSelectedByValue(text, true);
00296 if(LLFloaterDayCycle::isOpen())
00297 {
00298 keyCombo->add(text);
00299 keyCombo->sortByName();
00300 }
00301 LLWLParamManager::instance()->savePreset(text);
00302
00303
00304 }
00305 else
00306 {
00307 gViewerWindow->alertXml("ExistsSkyPresetAlert");
00308 }
00309 }
00310 }
00311
00312 void LLFloaterWindLight::syncMenu()
00313 {
00314 bool err;
00315
00316 LLWLParamManager * param_mgr = LLWLParamManager::instance();
00317
00318 LLWLParamSet& currentParams = param_mgr->mCurParams;
00319
00320
00321
00322 param_mgr->mBlueHorizon = currentParams.getVector(param_mgr->mBlueHorizon.name, err);
00323 childSetValue("WLBlueHorizonR", param_mgr->mBlueHorizon.r / 2.0);
00324 childSetValue("WLBlueHorizonG", param_mgr->mBlueHorizon.g / 2.0);
00325 childSetValue("WLBlueHorizonB", param_mgr->mBlueHorizon.b / 2.0);
00326 childSetValue("WLBlueHorizonI",
00327 std::max(param_mgr->mBlueHorizon.r / 2.0,
00328 std::max(param_mgr->mBlueHorizon.g / 2.0,
00329 param_mgr->mBlueHorizon.b / 2.0)));
00330
00331
00332 param_mgr->mHazeDensity = currentParams.getVector(param_mgr->mHazeDensity.name, err);
00333 childSetValue("WLHazeDensity", param_mgr->mHazeDensity.r);
00334 param_mgr->mHazeHorizon = currentParams.getVector(param_mgr->mHazeHorizon.name, err);
00335 childSetValue("WLHazeHorizon", param_mgr->mHazeHorizon.r);
00336 param_mgr->mDensityMult = currentParams.getVector(param_mgr->mDensityMult.name, err);
00337 childSetValue("WLDensityMult", param_mgr->mDensityMult.x *
00338 param_mgr->mDensityMult.mult);
00339 param_mgr->mMaxAlt = currentParams.getVector(param_mgr->mMaxAlt.name, err);
00340 childSetValue("WLMaxAltitude", param_mgr->mMaxAlt.x);
00341
00342
00343 param_mgr->mBlueDensity = currentParams.getVector(param_mgr->mBlueDensity.name, err);
00344 childSetValue("WLBlueDensityR", param_mgr->mBlueDensity.r / 2.0);
00345 childSetValue("WLBlueDensityG", param_mgr->mBlueDensity.g / 2.0);
00346 childSetValue("WLBlueDensityB", param_mgr->mBlueDensity.b / 2.0);
00347 childSetValue("WLBlueDensityI",
00348 std::max(param_mgr->mBlueDensity.r / 2.0,
00349 std::max(param_mgr->mBlueDensity.g / 2.0, param_mgr->mBlueDensity.b / 2.0)));
00350
00351
00352
00353
00354 param_mgr->mSunlight = currentParams.getVector(param_mgr->mSunlight.name, err);
00355 childSetValue("WLSunlightR", param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE);
00356 childSetValue("WLSunlightG", param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE);
00357 childSetValue("WLSunlightB", param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE);
00358 childSetValue("WLSunlightI",
00359 std::max(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE,
00360 std::max(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE)));
00361
00362
00363 param_mgr->mGlow = currentParams.getVector(param_mgr->mGlow.name, err);
00364 childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f);
00365 childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f);
00366
00367
00368 param_mgr->mAmbient = currentParams.getVector(param_mgr->mAmbient.name, err);
00369 childSetValue("WLAmbientR", param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE);
00370 childSetValue("WLAmbientG", param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE);
00371 childSetValue("WLAmbientB", param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE);
00372 childSetValue("WLAmbientI",
00373 std::max(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE,
00374 std::max(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE)));
00375
00376 childSetValue("WLSunAngle", param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI);
00377 childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI);
00378
00379
00380
00381
00382 param_mgr->mCloudColor = currentParams.getVector(param_mgr->mCloudColor.name, err);
00383 childSetValue("WLCloudColorR", param_mgr->mCloudColor.r);
00384 childSetValue("WLCloudColorG", param_mgr->mCloudColor.g);
00385 childSetValue("WLCloudColorB", param_mgr->mCloudColor.b);
00386 childSetValue("WLCloudColorI",
00387 std::max(param_mgr->mCloudColor.r,
00388 std::max(param_mgr->mCloudColor.g, param_mgr->mCloudColor.b)));
00389
00390
00391 param_mgr->mCloudMain = currentParams.getVector(param_mgr->mCloudMain.name, err);
00392 childSetValue("WLCloudX", param_mgr->mCloudMain.r);
00393 childSetValue("WLCloudY", param_mgr->mCloudMain.g);
00394 childSetValue("WLCloudDensity", param_mgr->mCloudMain.b);
00395
00396
00397 param_mgr->mCloudDetail = currentParams.getVector(param_mgr->mCloudDetail.name, err);
00398 childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r);
00399 childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g);
00400 childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b);
00401
00402
00403 param_mgr->mCloudCoverage = currentParams.getVector(param_mgr->mCloudCoverage.name, err);
00404 param_mgr->mCloudScale = currentParams.getVector(param_mgr->mCloudScale.name, err);
00405 childSetValue("WLCloudCoverage", param_mgr->mCloudCoverage.x);
00406 childSetValue("WLCloudScale", param_mgr->mCloudScale.x);
00407
00408
00409 bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX();
00410 bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY();
00411 childSetValue("WLCloudLockX", lockX);
00412 childSetValue("WLCloudLockY", lockY);
00413 childSetValue("DrawClassicClouds", gSavedSettings.getBOOL("SkyUseClassicClouds"));
00414
00415
00416 if(lockX)
00417 {
00418 childDisable("WLCloudScrollX");
00419 } else {
00420 childEnable("WLCloudScrollX");
00421 }
00422 if(lockY)
00423 {
00424 childDisable("WLCloudScrollY");
00425 } else {
00426 childEnable("WLCloudScrollY");
00427 }
00428
00429
00430 childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f);
00431 childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f);
00432
00433 param_mgr->mDistanceMult = currentParams.getVector(param_mgr->mDistanceMult.name, err);
00434 childSetValue("WLDistanceMult", param_mgr->mDistanceMult.x);
00435
00436
00437
00438 param_mgr->mWLGamma = currentParams.getVector(param_mgr->mWLGamma.name, err);
00439 childSetValue("WLGamma", param_mgr->mWLGamma.x);
00440
00441 childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness());
00442 }
00443
00444
00445
00446 LLFloaterWindLight* LLFloaterWindLight::instance()
00447 {
00448 if (!sWindLight)
00449 {
00450 sWindLight = new LLFloaterWindLight();
00451 sWindLight->open();
00452 sWindLight->setFocus(TRUE);
00453 }
00454 return sWindLight;
00455 }
00456 void LLFloaterWindLight::show()
00457 {
00458 LLFloaterWindLight* windLight = instance();
00459 windLight->syncMenu();
00460
00461
00462
00463
00464
00465 windLight->open();
00466 }
00467
00468 bool LLFloaterWindLight::isOpen()
00469 {
00470 if (sWindLight != NULL) {
00471 return true;
00472 }
00473 return false;
00474 }
00475
00476
00477 void LLFloaterWindLight::onClose(bool app_quitting)
00478 {
00479 if (sWindLight)
00480 {
00481 sWindLight->setVisible(FALSE);
00482 }
00483 }
00484
00485
00486 void LLFloaterWindLight::onColorControlRMoved(LLUICtrl* ctrl, void* userData)
00487 {
00488 deactivateAnimator();
00489
00490 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00491 WLColorControl * colorControl = static_cast<WLColorControl *>(userData);
00492
00493 colorControl->r = sldrCtrl->getValueF32();
00494 if(colorControl->isSunOrAmbientColor) {
00495 colorControl->r *= 3;
00496 }
00497 if(colorControl->isBlueHorizonOrDensity) {
00498 colorControl->r *= 2;
00499 }
00500
00501
00502 if(colorControl->r >= colorControl->g && colorControl->r >= colorControl->b
00503 && colorControl->hasSliderName) {
00504 colorControl->i = colorControl->r;
00505 std::string name = colorControl->mSliderName;
00506 name.append("I");
00507
00508 if(colorControl->isSunOrAmbientColor) {
00509 sWindLight->childSetValue(name, colorControl->r / 3);
00510 } else if(colorControl->isBlueHorizonOrDensity) {
00511 sWindLight->childSetValue(name, colorControl->r / 2);
00512 } else {
00513 sWindLight->childSetValue(name, colorControl->r);
00514 }
00515 }
00516
00517 colorControl->update(LLWLParamManager::instance()->mCurParams);
00518
00519 LLWLParamManager::instance()->propagateParameters();
00520 }
00521
00522 void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, void* userData)
00523 {
00524 deactivateAnimator();
00525
00526 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00527 WLColorControl * colorControl = static_cast<WLColorControl *>(userData);
00528
00529 colorControl->g = sldrCtrl->getValueF32();
00530 if(colorControl->isSunOrAmbientColor) {
00531 colorControl->g *= 3;
00532 }
00533 if(colorControl->isBlueHorizonOrDensity) {
00534 colorControl->g *= 2;
00535 }
00536
00537
00538 if(colorControl->g >= colorControl->r && colorControl->g >= colorControl->b
00539 && colorControl->hasSliderName) {
00540 colorControl->i = colorControl->g;
00541 std::string name = colorControl->mSliderName;
00542 name.append("I");
00543
00544 if(colorControl->isSunOrAmbientColor) {
00545 sWindLight->childSetValue(name, colorControl->g / 3);
00546 } else if(colorControl->isBlueHorizonOrDensity) {
00547 sWindLight->childSetValue(name, colorControl->g / 2);
00548 } else {
00549 sWindLight->childSetValue(name, colorControl->g);
00550 }
00551 }
00552
00553 colorControl->update(LLWLParamManager::instance()->mCurParams);
00554
00555 LLWLParamManager::instance()->propagateParameters();
00556 }
00557
00558 void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, void* userData)
00559 {
00560 deactivateAnimator();
00561
00562 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00563 WLColorControl * colorControl = static_cast<WLColorControl *>(userData);
00564
00565 colorControl->b = sldrCtrl->getValueF32();
00566 if(colorControl->isSunOrAmbientColor) {
00567 colorControl->b *= 3;
00568 }
00569 if(colorControl->isBlueHorizonOrDensity) {
00570 colorControl->b *= 2;
00571 }
00572
00573
00574 if(colorControl->b >= colorControl->r && colorControl->b >= colorControl->g
00575 && colorControl->hasSliderName) {
00576 colorControl->i = colorControl->b;
00577 std::string name = colorControl->mSliderName;
00578 name.append("I");
00579
00580 if(colorControl->isSunOrAmbientColor) {
00581 sWindLight->childSetValue(name, colorControl->b / 3);
00582 } else if(colorControl->isBlueHorizonOrDensity) {
00583 sWindLight->childSetValue(name, colorControl->b / 2);
00584 } else {
00585 sWindLight->childSetValue(name, colorControl->b);
00586 }
00587 }
00588
00589 colorControl->update(LLWLParamManager::instance()->mCurParams);
00590
00591 LLWLParamManager::instance()->propagateParameters();
00592 }
00593
00594 void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, void* userData)
00595 {
00596 deactivateAnimator();
00597
00598 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00599 WLColorControl * colorControl = static_cast<WLColorControl *>(userData);
00600
00601 colorControl->i = sldrCtrl->getValueF32();
00602
00603
00604 if(colorControl->hasSliderName) {
00605
00606
00607 F32 maxVal = std::max(std::max(colorControl->r, colorControl->g), colorControl->b);
00608 F32 iVal;
00609
00610 if(colorControl->isSunOrAmbientColor)
00611 {
00612 iVal = colorControl->i * 3;
00613 }
00614 else if(colorControl->isBlueHorizonOrDensity)
00615 {
00616 iVal = colorControl->i * 2;
00617 }
00618 else
00619 {
00620 iVal = colorControl->i;
00621 }
00622
00623
00624 std::string rName = colorControl->mSliderName;
00625 rName.append("R");
00626 std::string gName = colorControl->mSliderName;
00627 gName.append("G");
00628 std::string bName = colorControl->mSliderName;
00629 bName.append("B");
00630
00631
00632 if(iVal == 0) {
00633 colorControl->r = 0;
00634 colorControl->g = 0;
00635 colorControl->b = 0;
00636
00637
00638
00639 } else if (maxVal == 0) {
00640 colorControl->r = iVal;
00641 colorControl->g = iVal;
00642 colorControl->b = iVal;
00643
00644 } else {
00645
00646
00647 F32 delta = (iVal - maxVal) / maxVal;
00648 colorControl->r *= (1.0f + delta);
00649 colorControl->g *= (1.0f + delta);
00650 colorControl->b *= (1.0f + delta);
00651 }
00652
00653
00654 if(colorControl->isSunOrAmbientColor)
00655 {
00656 sWindLight->childSetValue(rName.c_str(), colorControl->r/3);
00657 sWindLight->childSetValue(gName.c_str(), colorControl->g/3);
00658 sWindLight->childSetValue(bName.c_str(), colorControl->b/3);
00659
00660 }
00661 else if(colorControl->isBlueHorizonOrDensity)
00662 {
00663 sWindLight->childSetValue(rName.c_str(), colorControl->r/2);
00664 sWindLight->childSetValue(gName.c_str(), colorControl->g/2);
00665 sWindLight->childSetValue(bName.c_str(), colorControl->b/2);
00666
00667 }
00668 else
00669 {
00670
00671 sWindLight->childSetValue(rName.c_str(), colorControl->r);
00672 sWindLight->childSetValue(gName.c_str(), colorControl->g);
00673 sWindLight->childSetValue(bName.c_str(), colorControl->b);
00674 }
00675 }
00676
00677
00678 colorControl->update(LLWLParamManager::instance()->mCurParams);
00679 LLWLParamManager::instance()->propagateParameters();
00680 }
00681
00683 void LLFloaterWindLight::onGlowRMoved(LLUICtrl* ctrl, void* userData)
00684 {
00685 deactivateAnimator();
00686
00687 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00688 WLColorControl * colorControl = static_cast<WLColorControl *>(userData);
00689
00690
00691 colorControl->r = (2 - sldrCtrl->getValueF32()) * 20;
00692
00693 colorControl->update(LLWLParamManager::instance()->mCurParams);
00694 LLWLParamManager::instance()->propagateParameters();
00695 }
00696
00698 void LLFloaterWindLight::onGlowBMoved(LLUICtrl* ctrl, void* userData)
00699 {
00700 deactivateAnimator();
00701
00702 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00703 WLColorControl * colorControl = static_cast<WLColorControl *>(userData);
00704
00706 colorControl->b = -sldrCtrl->getValueF32() * 5;
00707
00708 colorControl->update(LLWLParamManager::instance()->mCurParams);
00709 LLWLParamManager::instance()->propagateParameters();
00710 }
00711
00712 void LLFloaterWindLight::onFloatControlMoved(LLUICtrl* ctrl, void* userData)
00713 {
00714 deactivateAnimator();
00715
00716 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00717 WLFloatControl * floatControl = static_cast<WLFloatControl *>(userData);
00718
00719 floatControl->x = sldrCtrl->getValueF32() / floatControl->mult;
00720
00721 floatControl->update(LLWLParamManager::instance()->mCurParams);
00722 LLWLParamManager::instance()->propagateParameters();
00723 }
00724
00725 void LLFloaterWindLight::onBoolToggle(LLUICtrl* ctrl, void* userData)
00726 {
00727 deactivateAnimator();
00728
00729 LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
00730
00731 bool value = cbCtrl->get();
00732 (*(static_cast<BOOL *>(userData))) = value;
00733 }
00734
00735
00736
00737
00738
00739 void LLFloaterWindLight::onSunMoved(LLUICtrl* ctrl, void* userData)
00740 {
00741 deactivateAnimator();
00742
00743 LLSliderCtrl* sunSldr = sWindLight->getChild<LLSliderCtrl>("WLSunAngle");
00744 LLSliderCtrl* eastSldr = sWindLight->getChild<LLSliderCtrl>("WLEastAngle");
00745
00746 WLColorControl * colorControl = static_cast<WLColorControl *>(userData);
00747
00748
00749 LLWLParamManager * param_mgr = LLWLParamManager::instance();
00750
00751 param_mgr->mCurParams.setSunAngle(F_TWO_PI * sunSldr->getValueF32());
00752 param_mgr->mCurParams.setEastAngle(F_TWO_PI * eastSldr->getValueF32());
00753
00754
00755 colorControl->r = -sin(param_mgr->mCurParams.getEastAngle()) *
00756 cos(param_mgr->mCurParams.getSunAngle());
00757 colorControl->g = sin(param_mgr->mCurParams.getSunAngle());
00758 colorControl->b = cos(param_mgr->mCurParams.getEastAngle()) *
00759 cos(param_mgr->mCurParams.getSunAngle());
00760 colorControl->i = 1.f;
00761
00762 colorControl->update(param_mgr->mCurParams);
00763 param_mgr->propagateParameters();
00764 }
00765
00766 void LLFloaterWindLight::onFloatTweakMoved(LLUICtrl* ctrl, void* userData)
00767 {
00768 deactivateAnimator();
00769
00770 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00771 F32 * tweak = static_cast<F32 *>(userData);
00772
00773 (*tweak) = sldrCtrl->getValueF32();
00774 LLWLParamManager::instance()->propagateParameters();
00775 }
00776
00777 void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl, void* userData)
00778 {
00779 deactivateAnimator();
00780
00781 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00782
00783 LLWLParamManager::instance()->mCurParams.setStarBrightness(sldrCtrl->getValueF32());
00784 }
00785
00786 void LLFloaterWindLight::onNewPreset(void* userData)
00787 {
00788 gViewerWindow->alertXmlEditText("NewSkyPreset", LLString::format_map_t(),
00789 NULL, NULL, newPromptCallback, NULL);
00790 }
00791
00792 void LLFloaterWindLight::onSavePreset(void* userData)
00793 {
00794
00795 LLComboBox* comboBox = sWindLight->getChild<LLComboBox>(
00796 "WLPresetsCombo");
00797
00798
00799 if(comboBox->getSelectedItemLabel() == "")
00800 {
00801 return;
00802 }
00803
00804
00805 std::set<std::string>::iterator sIt = sDefaultPresets.find(
00806 comboBox->getSelectedItemLabel().c_str());
00807 if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets"))
00808 {
00809 gViewerWindow->alertXml("WLNoEditDefault");
00810 return;
00811 }
00812
00813 LLWLParamManager::instance()->mCurParams.mName =
00814 comboBox->getSelectedItemLabel();
00815
00816 gViewerWindow->alertXml("WLSavePresetAlert", saveAlertCallback, sWindLight);
00817 }
00818
00819 void LLFloaterWindLight::saveAlertCallback(S32 option, void* userdata)
00820 {
00821
00822 if(option == 0)
00823 {
00824 LLWLParamManager * param_mgr = LLWLParamManager::instance();
00825
00826 param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams);
00827
00828
00829 param_mgr->savePreset(param_mgr->mCurParams.mName);
00830 }
00831
00832 }
00833
00834 void LLFloaterWindLight::onDeletePreset(void* userData)
00835 {
00836 LLComboBox* combo_box = sWindLight->getChild<LLComboBox>(
00837 "WLPresetsCombo");
00838
00839 if(combo_box->getSelectedValue().asString() == "")
00840 {
00841 return;
00842 }
00843
00844 LLString::format_map_t args;
00845 args["[SKY]"] = combo_box->getSelectedValue().asString();
00846 gViewerWindow->alertXml("WLDeletePresetAlert", args, deleteAlertCallback, sWindLight);
00847 }
00848
00849 void LLFloaterWindLight::deleteAlertCallback(S32 option, void* userdata)
00850 {
00851
00852 if(option == 0)
00853 {
00854 LLComboBox* combo_box = sWindLight->getChild<LLComboBox>(
00855 "WLPresetsCombo");
00856 LLFloaterDayCycle* day_cycle = NULL;
00857 LLComboBox* key_combo = NULL;
00858 LLMultiSliderCtrl* mult_sldr = NULL;
00859
00860 if(LLFloaterDayCycle::isOpen())
00861 {
00862 day_cycle = LLFloaterDayCycle::instance();
00863 key_combo = day_cycle->getChild<LLComboBox>(
00864 "WLKeyPresets");
00865 mult_sldr = day_cycle->getChild<LLMultiSliderCtrl>("WLDayCycleKeys");
00866 }
00867
00868 LLString name(combo_box->getSelectedValue().asString());
00869
00870
00871 std::set<std::string>::iterator sIt = sDefaultPresets.find(name.c_str());
00872 if(sIt != sDefaultPresets.end())
00873 {
00874 gViewerWindow->alertXml("WLNoEditDefault");
00875 return;
00876 }
00877
00878 LLWLParamManager::instance()->removeParamSet(name, true);
00879
00880
00881 S32 new_index = combo_box->getCurrentIndex();
00882
00883 combo_box->remove(name);
00884 if(key_combo != NULL)
00885 {
00886 key_combo->remove(name);
00887
00888
00889 day_cycle->deletePreset(name);
00890 }
00891
00892
00893 if(new_index > 0)
00894 {
00895 new_index--;
00896 }
00897
00898 if(combo_box->getItemCount() > 0)
00899 {
00900 combo_box->setCurrentByIndex(new_index);
00901 }
00902 }
00903 }
00904
00905
00906 void LLFloaterWindLight::onChangePresetName(LLUICtrl* ctrl, void * userData)
00907 {
00908 deactivateAnimator();
00909
00910 LLComboBox * combo_box = static_cast<LLComboBox*>(ctrl);
00911
00912 if(combo_box->getSimple() == "")
00913 {
00914 return;
00915 }
00916
00917 LLWLParamManager::instance()->loadPreset(
00918 combo_box->getSelectedValue().asString());
00919 sWindLight->syncMenu();
00920 }
00921
00922 void LLFloaterWindLight::onOpenDayCycle(void* userData)
00923 {
00924 LLFloaterDayCycle::show();
00925 }
00926
00927
00928 void LLFloaterWindLight::onCloudScrollXMoved(LLUICtrl* ctrl, void* userData)
00929 {
00930 deactivateAnimator();
00931
00932 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00933
00934 LLWLParamManager::instance()->mCurParams.setCloudScrollX(sldrCtrl->getValueF32() + 10.0f);
00935 }
00936
00937 void LLFloaterWindLight::onCloudScrollYMoved(LLUICtrl* ctrl, void* userData)
00938 {
00939 deactivateAnimator();
00940
00941 LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
00942
00943
00944 LLWLParamManager::instance()->mCurParams.setCloudScrollY(sldrCtrl->getValueF32() + 10.0f);
00945 }
00946
00947 void LLFloaterWindLight::onCloudScrollXToggled(LLUICtrl* ctrl, void* userData)
00948 {
00949 deactivateAnimator();
00950
00951 LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
00952
00953 bool lock = cbCtrl->get();
00954 LLWLParamManager::instance()->mCurParams.setEnableCloudScrollX(!lock);
00955
00956 LLSliderCtrl* sldr = sWindLight->getChild<LLSliderCtrl>(
00957 "WLCloudScrollX");
00958
00959 if(cbCtrl->get())
00960 {
00961 sldr->setEnabled(false);
00962 }
00963 else
00964 {
00965 sldr->setEnabled(true);
00966 }
00967
00968 }
00969
00970 void LLFloaterWindLight::onCloudScrollYToggled(LLUICtrl* ctrl, void* userData)
00971 {
00972 deactivateAnimator();
00973
00974 LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
00975 bool lock = cbCtrl->get();
00976 LLWLParamManager::instance()->mCurParams.setEnableCloudScrollY(!lock);
00977
00978 LLSliderCtrl* sldr = sWindLight->getChild<LLSliderCtrl>(
00979 "WLCloudScrollY");
00980
00981 if(cbCtrl->get())
00982 {
00983 sldr->setEnabled(false);
00984 }
00985 else
00986 {
00987 sldr->setEnabled(true);
00988 }
00989 }
00990
00991 void LLFloaterWindLight::deactivateAnimator()
00992 {
00993 LLWLParamManager::instance()->mAnimator.mIsRunning = false;
00994 LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
00995 }