Annotation of /trunk/linden/indra/newview/llfloaterwater.cpp
Parent Directory
|
Revision Log
Revision 58 -
(view)
(download)
Original Path: linden_release/linden/indra/newview/llfloaterwater.cpp
| 1 : | mjm | 57 | /** |
| 2 : | * @file llfloaterwater.cpp | ||
| 3 : | * @brief LLFloaterWater 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 "llfloaterwater.h" | ||
| 35 : | |||
| 36 : | #include "pipeline.h" | ||
| 37 : | #include "llsky.h" | ||
| 38 : | |||
| 39 : | #include "llsliderctrl.h" | ||
| 40 : | #include "llspinctrl.h" | ||
| 41 : | #include "llcolorswatch.h" | ||
| 42 : | #include "llcheckboxctrl.h" | ||
| 43 : | #include "lltexturectrl.h" | ||
| 44 : | #include "lluictrlfactory.h" | ||
| 45 : | #include "llviewercamera.h" | ||
| 46 : | #include "llcombobox.h" | ||
| 47 : | #include "lllineeditor.h" | ||
| 48 : | #include "llfloaterdaycycle.h" | ||
| 49 : | #include "llboost.h" | ||
| 50 : | #include "llmultisliderctrl.h" | ||
| 51 : | |||
| 52 : | #include "v4math.h" | ||
| 53 : | #include "llviewerdisplay.h" | ||
| 54 : | #include "llviewercontrol.h" | ||
| 55 : | #include "llviewerwindow.h" | ||
| 56 : | #include "llsavedsettingsglue.h" | ||
| 57 : | |||
| 58 : | #include "llwaterparamset.h" | ||
| 59 : | #include "llwaterparammanager.h" | ||
| 60 : | #include "llpostprocess.h" | ||
| 61 : | |||
| 62 : | #undef max | ||
| 63 : | |||
| 64 : | LLFloaterWater* LLFloaterWater::sWaterMenu = NULL; | ||
| 65 : | |||
| 66 : | std::set<std::string> LLFloaterWater::sDefaultPresets; | ||
| 67 : | |||
| 68 : | LLFloaterWater::LLFloaterWater() : LLFloater(std::string("water floater")) | ||
| 69 : | { | ||
| 70 : | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_water.xml"); | ||
| 71 : | |||
| 72 : | // add the combo boxes | ||
| 73 : | LLComboBox* comboBox = getChild<LLComboBox>("WaterPresetsCombo"); | ||
| 74 : | |||
| 75 : | if(comboBox != NULL) { | ||
| 76 : | |||
| 77 : | std::map<std::string, LLWaterParamSet>::iterator mIt = | ||
| 78 : | LLWaterParamManager::instance()->mParamList.begin(); | ||
| 79 : | for(; mIt != LLWaterParamManager::instance()->mParamList.end(); mIt++) | ||
| 80 : | { | ||
| 81 : | comboBox->add(mIt->first); | ||
| 82 : | } | ||
| 83 : | |||
| 84 : | // set defaults on combo boxes | ||
| 85 : | comboBox->selectByValue(LLSD("Default")); | ||
| 86 : | } | ||
| 87 : | |||
| 88 : | std::string def_water = getString("WLDefaultWaterNames"); | ||
| 89 : | |||
| 90 : | // no editing or deleting of the blank string | ||
| 91 : | sDefaultPresets.insert(""); | ||
| 92 : | boost_tokenizer tokens(def_water, boost::char_separator<char>(":")); | ||
| 93 : | for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) | ||
| 94 : | { | ||
| 95 : | std::string tok(*token_iter); | ||
| 96 : | sDefaultPresets.insert(tok); | ||
| 97 : | } | ||
| 98 : | |||
| 99 : | // load it up | ||
| 100 : | initCallbacks(); | ||
| 101 : | } | ||
| 102 : | |||
| 103 : | LLFloaterWater::~LLFloaterWater() | ||
| 104 : | { | ||
| 105 : | } | ||
| 106 : | |||
| 107 : | void LLFloaterWater::initCallbacks(void) { | ||
| 108 : | |||
| 109 : | // help buttons | ||
| 110 : | initHelpBtn("WaterFogColorHelp", "HelpWaterFogColor"); | ||
| 111 : | initHelpBtn("WaterFogDensityHelp", "HelpWaterFogDensity"); | ||
| 112 : | initHelpBtn("WaterUnderWaterFogModHelp", "HelpUnderWaterFogMod"); | ||
| 113 : | initHelpBtn("WaterGlowHelp", "HelpWaterGlow"); | ||
| 114 : | initHelpBtn("WaterNormalScaleHelp", "HelpWaterNormalScale"); | ||
| 115 : | initHelpBtn("WaterFresnelScaleHelp", "HelpWaterFresnelScale"); | ||
| 116 : | initHelpBtn("WaterFresnelOffsetHelp", "HelpWaterFresnelOffset"); | ||
| 117 : | |||
| 118 : | initHelpBtn("WaterBlurMultiplierHelp", "HelpWaterBlurMultiplier"); | ||
| 119 : | initHelpBtn("WaterScaleBelowHelp", "HelpWaterScaleBelow"); | ||
| 120 : | initHelpBtn("WaterScaleAboveHelp", "HelpWaterScaleAbove"); | ||
| 121 : | |||
| 122 : | initHelpBtn("WaterNormalMapHelp", "HelpWaterNormalMap"); | ||
| 123 : | initHelpBtn("WaterWave1Help", "HelpWaterWave1"); | ||
| 124 : | initHelpBtn("WaterWave2Help", "HelpWaterWave2"); | ||
| 125 : | |||
| 126 : | LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); | ||
| 127 : | |||
| 128 : | childSetCommitCallback("WaterFogColor", onWaterFogColorMoved, ¶m_mgr->mFogColor); | ||
| 129 : | |||
| 130 : | // | ||
| 131 : | childSetCommitCallback("WaterGlow", onColorControlAMoved, ¶m_mgr->mFogColor); | ||
| 132 : | |||
| 133 : | // fog density | ||
| 134 : | childSetCommitCallback("WaterFogDensity", onExpFloatControlMoved, ¶m_mgr->mFogDensity); | ||
| 135 : | childSetCommitCallback("WaterUnderWaterFogMod", onFloatControlMoved, ¶m_mgr->mUnderWaterFogMod); | ||
| 136 : | |||
| 137 : | // blue density | ||
| 138 : | childSetCommitCallback("WaterNormalScaleX", onVector3ControlXMoved, ¶m_mgr->mNormalScale); | ||
| 139 : | childSetCommitCallback("WaterNormalScaleY", onVector3ControlYMoved, ¶m_mgr->mNormalScale); | ||
| 140 : | childSetCommitCallback("WaterNormalScaleZ", onVector3ControlZMoved, ¶m_mgr->mNormalScale); | ||
| 141 : | |||
| 142 : | // fresnel | ||
| 143 : | childSetCommitCallback("WaterFresnelScale", onFloatControlMoved, ¶m_mgr->mFresnelScale); | ||
| 144 : | childSetCommitCallback("WaterFresnelOffset", onFloatControlMoved, ¶m_mgr->mFresnelOffset); | ||
| 145 : | |||
| 146 : | // scale above/below | ||
| 147 : | childSetCommitCallback("WaterScaleAbove", onFloatControlMoved, ¶m_mgr->mScaleAbove); | ||
| 148 : | childSetCommitCallback("WaterScaleBelow", onFloatControlMoved, ¶m_mgr->mScaleBelow); | ||
| 149 : | |||
| 150 : | // blur mult | ||
| 151 : | childSetCommitCallback("WaterBlurMult", onFloatControlMoved, ¶m_mgr->mBlurMultiplier); | ||
| 152 : | |||
| 153 : | // Load/save | ||
| 154 : | LLComboBox* comboBox = getChild<LLComboBox>("WaterPresetsCombo"); | ||
| 155 : | |||
| 156 : | //childSetAction("WaterLoadPreset", onLoadPreset, comboBox); | ||
| 157 : | childSetAction("WaterNewPreset", onNewPreset, comboBox); | ||
| 158 : | childSetAction("WaterSavePreset", onSavePreset, comboBox); | ||
| 159 : | childSetAction("WaterDeletePreset", onDeletePreset, comboBox); | ||
| 160 : | |||
| 161 : | // wave direction | ||
| 162 : | childSetCommitCallback("WaterWave1DirX", onVector2ControlXMoved, ¶m_mgr->mWave1Dir); | ||
| 163 : | childSetCommitCallback("WaterWave1DirY", onVector2ControlYMoved, ¶m_mgr->mWave1Dir); | ||
| 164 : | childSetCommitCallback("WaterWave2DirX", onVector2ControlXMoved, ¶m_mgr->mWave2Dir); | ||
| 165 : | childSetCommitCallback("WaterWave2DirY", onVector2ControlYMoved, ¶m_mgr->mWave2Dir); | ||
| 166 : | |||
| 167 : | comboBox->setCommitCallback(onChangePresetName); | ||
| 168 : | |||
| 169 : | LLTextureCtrl* textCtrl = getChild<LLTextureCtrl>("WaterNormalMap"); | ||
| 170 : | textCtrl->setDefaultImageAssetID(DEFAULT_WATER_NORMAL); | ||
| 171 : | childSetCommitCallback("WaterNormalMap", onNormalMapPicked, NULL); | ||
| 172 : | } | ||
| 173 : | |||
| 174 : | void LLFloaterWater::onClickHelp(void* data) | ||
| 175 : | { | ||
| 176 : | LLFloaterWater* self = LLFloaterWater::instance(); | ||
| 177 : | |||
| 178 : | const std::string* xml_alert = (std::string*)data; | ||
| 179 : | LLAlertDialog* dialogp = gViewerWindow->alertXml(*xml_alert); | ||
| 180 : | if (dialogp) | ||
| 181 : | { | ||
| 182 : | LLFloater* root_floater = gFloaterView->getParentFloater(self); | ||
| 183 : | if (root_floater) | ||
| 184 : | { | ||
| 185 : | root_floater->addDependentFloater(dialogp); | ||
| 186 : | } | ||
| 187 : | } | ||
| 188 : | } | ||
| 189 : | |||
| 190 : | void LLFloaterWater::initHelpBtn(const std::string& name, const std::string& xml_alert) | ||
| 191 : | { | ||
| 192 : | childSetAction(name, onClickHelp, new std::string(xml_alert)); | ||
| 193 : | } | ||
| 194 : | |||
| 195 : | void LLFloaterWater::newPromptCallback(S32 option, const std::string& text, void* userData) | ||
| 196 : | { | ||
| 197 : | if(text == "") | ||
| 198 : | { | ||
| 199 : | return; | ||
| 200 : | } | ||
| 201 : | |||
| 202 : | if(option == 0) { | ||
| 203 : | LLComboBox* comboBox = sWaterMenu->getChild<LLComboBox>( "WaterPresetsCombo"); | ||
| 204 : | |||
| 205 : | LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); | ||
| 206 : | |||
| 207 : | // add the current parameters to the list | ||
| 208 : | // see if it's there first | ||
| 209 : | std::map<std::string, LLWaterParamSet>::iterator mIt = | ||
| 210 : | param_mgr->mParamList.find(text); | ||
| 211 : | |||
| 212 : | // if not there, add a new one | ||
| 213 : | if(mIt == param_mgr->mParamList.end()) | ||
| 214 : | { | ||
| 215 : | param_mgr->addParamSet(text, param_mgr->mCurParams); | ||
| 216 : | comboBox->add(text); | ||
| 217 : | comboBox->sortByName(); | ||
| 218 : | |||
| 219 : | comboBox->setSelectedByValue(text, true); | ||
| 220 : | |||
| 221 : | param_mgr->savePreset(text); | ||
| 222 : | |||
| 223 : | // otherwise, send a message to the user | ||
| 224 : | } | ||
| 225 : | else | ||
| 226 : | { | ||
| 227 : | gViewerWindow->alertXml("ExistsWaterPresetAlert"); | ||
| 228 : | } | ||
| 229 : | } | ||
| 230 : | } | ||
| 231 : | |||
| 232 : | void LLFloaterWater::syncMenu() | ||
| 233 : | { | ||
| 234 : | bool err; | ||
| 235 : | |||
| 236 : | LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); | ||
| 237 : | |||
| 238 : | LLWaterParamSet & current_params = param_mgr->mCurParams; | ||
| 239 : | |||
| 240 : | // blue horizon | ||
| 241 : | param_mgr->mFogColor = current_params.getVector4(param_mgr->mFogColor.mName, err); | ||
| 242 : | |||
| 243 : | LLColor4 col = param_mgr->getFogColor(); | ||
| 244 : | childSetValue("WaterGlow", col.mV[3]); | ||
| 245 : | col.mV[3] = 1.0f; | ||
| 246 : | LLColorSwatchCtrl* colCtrl = sWaterMenu->getChild<LLColorSwatchCtrl>("WaterFogColor"); | ||
| 247 : | |||
| 248 : | colCtrl->set(col); | ||
| 249 : | |||
| 250 : | // fog and wavelets | ||
| 251 : | param_mgr->mFogDensity.mExp = | ||
| 252 : | log(current_params.getFloat(param_mgr->mFogDensity.mName, err)) / | ||
| 253 : | log(param_mgr->mFogDensity.mBase); | ||
| 254 : | param_mgr->setDensitySliderValue(param_mgr->mFogDensity.mExp); | ||
| 255 : | childSetValue("WaterFogDensity", param_mgr->mFogDensity.mExp); | ||
| 256 : | |||
| 257 : | param_mgr->mUnderWaterFogMod.mX = | ||
| 258 : | current_params.getFloat(param_mgr->mUnderWaterFogMod.mName, err); | ||
| 259 : | childSetValue("WaterUnderWaterFogMod", param_mgr->mUnderWaterFogMod.mX); | ||
| 260 : | |||
| 261 : | param_mgr->mNormalScale = current_params.getVector3(param_mgr->mNormalScale.mName, err); | ||
| 262 : | childSetValue("WaterNormalScaleX", param_mgr->mNormalScale.mX); | ||
| 263 : | childSetValue("WaterNormalScaleY", param_mgr->mNormalScale.mY); | ||
| 264 : | childSetValue("WaterNormalScaleZ", param_mgr->mNormalScale.mZ); | ||
| 265 : | |||
| 266 : | // Fresnel | ||
| 267 : | param_mgr->mFresnelScale.mX = current_params.getFloat(param_mgr->mFresnelScale.mName, err); | ||
| 268 : | childSetValue("WaterFresnelScale", param_mgr->mFresnelScale.mX); | ||
| 269 : | param_mgr->mFresnelOffset.mX = current_params.getFloat(param_mgr->mFresnelOffset.mName, err); | ||
| 270 : | childSetValue("WaterFresnelOffset", param_mgr->mFresnelOffset.mX); | ||
| 271 : | |||
| 272 : | // Scale Above/Below | ||
| 273 : | param_mgr->mScaleAbove.mX = current_params.getFloat(param_mgr->mScaleAbove.mName, err); | ||
| 274 : | childSetValue("WaterScaleAbove", param_mgr->mScaleAbove.mX); | ||
| 275 : | param_mgr->mScaleBelow.mX = current_params.getFloat(param_mgr->mScaleBelow.mName, err); | ||
| 276 : | childSetValue("WaterScaleBelow", param_mgr->mScaleBelow.mX); | ||
| 277 : | |||
| 278 : | // blur mult | ||
| 279 : | param_mgr->mBlurMultiplier.mX = current_params.getFloat(param_mgr->mBlurMultiplier.mName, err); | ||
| 280 : | childSetValue("WaterBlurMult", param_mgr->mBlurMultiplier.mX); | ||
| 281 : | |||
| 282 : | // wave directions | ||
| 283 : | param_mgr->mWave1Dir = current_params.getVector2(param_mgr->mWave1Dir.mName, err); | ||
| 284 : | childSetValue("WaterWave1DirX", param_mgr->mWave1Dir.mX); | ||
| 285 : | childSetValue("WaterWave1DirY", param_mgr->mWave1Dir.mY); | ||
| 286 : | |||
| 287 : | param_mgr->mWave2Dir = current_params.getVector2(param_mgr->mWave2Dir.mName, err); | ||
| 288 : | childSetValue("WaterWave2DirX", param_mgr->mWave2Dir.mX); | ||
| 289 : | childSetValue("WaterWave2DirY", param_mgr->mWave2Dir.mY); | ||
| 290 : | |||
| 291 : | LLTextureCtrl* textCtrl = sWaterMenu->getChild<LLTextureCtrl>("WaterNormalMap"); | ||
| 292 : | textCtrl->setImageAssetID(param_mgr->getNormalMapID()); | ||
| 293 : | } | ||
| 294 : | |||
| 295 : | |||
| 296 : | // static | ||
| 297 : | LLFloaterWater* LLFloaterWater::instance() | ||
| 298 : | { | ||
| 299 : | if (!sWaterMenu) | ||
| 300 : | { | ||
| 301 : | sWaterMenu = new LLFloaterWater(); | ||
| 302 : | sWaterMenu->open(); | ||
| 303 : | sWaterMenu->setFocus(TRUE); | ||
| 304 : | } | ||
| 305 : | return sWaterMenu; | ||
| 306 : | } | ||
| 307 : | void LLFloaterWater::show() | ||
| 308 : | { | ||
| 309 : | LLFloaterWater* water = instance(); | ||
| 310 : | water->syncMenu(); | ||
| 311 : | |||
| 312 : | // comment in if you want the menu to rebuild each time | ||
| 313 : | //LLUICtrlFactory::getInstance()->buildFloater(water, "floater_water.xml"); | ||
| 314 : | //water->initCallbacks(); | ||
| 315 : | |||
| 316 : | water->open(); | ||
| 317 : | } | ||
| 318 : | |||
| 319 : | bool LLFloaterWater::isOpen() | ||
| 320 : | { | ||
| 321 : | if (sWaterMenu != NULL) { | ||
| 322 : | return true; | ||
| 323 : | } | ||
| 324 : | return false; | ||
| 325 : | } | ||
| 326 : | |||
| 327 : | // virtual | ||
| 328 : | void LLFloaterWater::onClose(bool app_quitting) | ||
| 329 : | { | ||
| 330 : | if (sWaterMenu) | ||
| 331 : | { | ||
| 332 : | sWaterMenu->setVisible(FALSE); | ||
| 333 : | } | ||
| 334 : | } | ||
| 335 : | |||
| 336 : | // vector control callbacks | ||
| 337 : | void LLFloaterWater::onVector3ControlXMoved(LLUICtrl* ctrl, void* userData) | ||
| 338 : | { | ||
| 339 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 340 : | WaterVector3Control * vectorControl = static_cast<WaterVector3Control *>(userData); | ||
| 341 : | |||
| 342 : | vectorControl->mX = sldrCtrl->getValueF32(); | ||
| 343 : | |||
| 344 : | vectorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 345 : | |||
| 346 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 347 : | } | ||
| 348 : | |||
| 349 : | // vector control callbacks | ||
| 350 : | void LLFloaterWater::onVector3ControlYMoved(LLUICtrl* ctrl, void* userData) | ||
| 351 : | { | ||
| 352 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 353 : | WaterVector3Control * vectorControl = static_cast<WaterVector3Control *>(userData); | ||
| 354 : | |||
| 355 : | vectorControl->mY = sldrCtrl->getValueF32(); | ||
| 356 : | |||
| 357 : | vectorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 358 : | |||
| 359 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 360 : | } | ||
| 361 : | |||
| 362 : | // vector control callbacks | ||
| 363 : | void LLFloaterWater::onVector3ControlZMoved(LLUICtrl* ctrl, void* userData) | ||
| 364 : | { | ||
| 365 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 366 : | WaterVector3Control * vectorControl = static_cast<WaterVector3Control *>(userData); | ||
| 367 : | |||
| 368 : | vectorControl->mZ = sldrCtrl->getValueF32(); | ||
| 369 : | |||
| 370 : | vectorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 371 : | |||
| 372 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 373 : | } | ||
| 374 : | |||
| 375 : | |||
| 376 : | // vector control callbacks | ||
| 377 : | void LLFloaterWater::onVector2ControlXMoved(LLUICtrl* ctrl, void* userData) | ||
| 378 : | { | ||
| 379 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 380 : | WaterVector2Control * vectorControl = static_cast<WaterVector2Control *>(userData); | ||
| 381 : | |||
| 382 : | vectorControl->mX = sldrCtrl->getValueF32(); | ||
| 383 : | |||
| 384 : | vectorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 385 : | |||
| 386 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 387 : | } | ||
| 388 : | |||
| 389 : | // vector control callbacks | ||
| 390 : | void LLFloaterWater::onVector2ControlYMoved(LLUICtrl* ctrl, void* userData) | ||
| 391 : | { | ||
| 392 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 393 : | WaterVector2Control * vectorControl = static_cast<WaterVector2Control *>(userData); | ||
| 394 : | |||
| 395 : | vectorControl->mY = sldrCtrl->getValueF32(); | ||
| 396 : | |||
| 397 : | vectorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 398 : | |||
| 399 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 400 : | } | ||
| 401 : | |||
| 402 : | // color control callbacks | ||
| 403 : | void LLFloaterWater::onColorControlRMoved(LLUICtrl* ctrl, void* userData) | ||
| 404 : | { | ||
| 405 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 406 : | WaterColorControl * colorControl = static_cast<WaterColorControl *>(userData); | ||
| 407 : | |||
| 408 : | colorControl->mR = sldrCtrl->getValueF32(); | ||
| 409 : | |||
| 410 : | // move i if it's the max | ||
| 411 : | if(colorControl->mR >= colorControl->mG | ||
| 412 : | && colorControl->mR >= colorControl->mB | ||
| 413 : | && colorControl->mHasSliderName) | ||
| 414 : | { | ||
| 415 : | colorControl->mI = colorControl->mR; | ||
| 416 : | std::string name = colorControl->mSliderName; | ||
| 417 : | name.append("I"); | ||
| 418 : | |||
| 419 : | sWaterMenu->childSetValue(name, colorControl->mR); | ||
| 420 : | } | ||
| 421 : | |||
| 422 : | colorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 423 : | |||
| 424 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 425 : | } | ||
| 426 : | |||
| 427 : | void LLFloaterWater::onColorControlGMoved(LLUICtrl* ctrl, void* userData) | ||
| 428 : | { | ||
| 429 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 430 : | WaterColorControl * colorControl = static_cast<WaterColorControl *>(userData); | ||
| 431 : | |||
| 432 : | colorControl->mG = sldrCtrl->getValueF32(); | ||
| 433 : | |||
| 434 : | // move i if it's the max | ||
| 435 : | if(colorControl->mG >= colorControl->mR | ||
| 436 : | && colorControl->mG >= colorControl->mB | ||
| 437 : | && colorControl->mHasSliderName) | ||
| 438 : | { | ||
| 439 : | colorControl->mI = colorControl->mG; | ||
| 440 : | std::string name = colorControl->mSliderName; | ||
| 441 : | name.append("I"); | ||
| 442 : | |||
| 443 : | sWaterMenu->childSetValue(name, colorControl->mG); | ||
| 444 : | |||
| 445 : | } | ||
| 446 : | |||
| 447 : | colorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 448 : | |||
| 449 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 450 : | } | ||
| 451 : | |||
| 452 : | void LLFloaterWater::onColorControlBMoved(LLUICtrl* ctrl, void* userData) | ||
| 453 : | { | ||
| 454 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 455 : | WaterColorControl * colorControl = static_cast<WaterColorControl *>(userData); | ||
| 456 : | |||
| 457 : | colorControl->mB = sldrCtrl->getValueF32(); | ||
| 458 : | |||
| 459 : | // move i if it's the max | ||
| 460 : | if(colorControl->mB >= colorControl->mR | ||
| 461 : | && colorControl->mB >= colorControl->mG | ||
| 462 : | && colorControl->mHasSliderName) | ||
| 463 : | { | ||
| 464 : | colorControl->mI = colorControl->mB; | ||
| 465 : | std::string name = colorControl->mSliderName; | ||
| 466 : | name.append("I"); | ||
| 467 : | |||
| 468 : | sWaterMenu->childSetValue(name, colorControl->mB); | ||
| 469 : | } | ||
| 470 : | |||
| 471 : | colorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 472 : | |||
| 473 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 474 : | } | ||
| 475 : | |||
| 476 : | void LLFloaterWater::onColorControlAMoved(LLUICtrl* ctrl, void* userData) | ||
| 477 : | { | ||
| 478 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 479 : | WaterColorControl * colorControl = static_cast<WaterColorControl *>(userData); | ||
| 480 : | |||
| 481 : | colorControl->mA = sldrCtrl->getValueF32(); | ||
| 482 : | |||
| 483 : | colorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 484 : | |||
| 485 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 486 : | } | ||
| 487 : | |||
| 488 : | |||
| 489 : | void LLFloaterWater::onColorControlIMoved(LLUICtrl* ctrl, void* userData) | ||
| 490 : | { | ||
| 491 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 492 : | WaterColorControl * colorControl = static_cast<WaterColorControl *>(userData); | ||
| 493 : | |||
| 494 : | colorControl->mI = sldrCtrl->getValueF32(); | ||
| 495 : | |||
| 496 : | // only for sliders where we pass a name | ||
| 497 : | if(colorControl->mHasSliderName) | ||
| 498 : | { | ||
| 499 : | // set it to the top | ||
| 500 : | F32 maxVal = std::max(std::max(colorControl->mR, colorControl->mG), colorControl->mB); | ||
| 501 : | F32 iVal; | ||
| 502 : | |||
| 503 : | iVal = colorControl->mI; | ||
| 504 : | |||
| 505 : | // get the names of the other sliders | ||
| 506 : | std::string rName = colorControl->mSliderName; | ||
| 507 : | rName.append("R"); | ||
| 508 : | std::string gName = colorControl->mSliderName; | ||
| 509 : | gName.append("G"); | ||
| 510 : | std::string bName = colorControl->mSliderName; | ||
| 511 : | bName.append("B"); | ||
| 512 : | |||
| 513 : | // handle if at 0 | ||
| 514 : | if(iVal == 0) | ||
| 515 : | { | ||
| 516 : | colorControl->mR = 0; | ||
| 517 : | colorControl->mG = 0; | ||
| 518 : | colorControl->mB = 0; | ||
| 519 : | |||
| 520 : | // if all at the start | ||
| 521 : | // set them all to the intensity | ||
| 522 : | } | ||
| 523 : | else if (maxVal == 0) | ||
| 524 : | { | ||
| 525 : | colorControl->mR = iVal; | ||
| 526 : | colorControl->mG = iVal; | ||
| 527 : | colorControl->mB = iVal; | ||
| 528 : | } | ||
| 529 : | else | ||
| 530 : | { | ||
| 531 : | // add delta amounts to each | ||
| 532 : | F32 delta = (iVal - maxVal) / maxVal; | ||
| 533 : | colorControl->mR *= (1.0f + delta); | ||
| 534 : | colorControl->mG *= (1.0f + delta); | ||
| 535 : | colorControl->mB *= (1.0f + delta); | ||
| 536 : | } | ||
| 537 : | |||
| 538 : | // set the sliders to the new vals | ||
| 539 : | sWaterMenu->childSetValue(rName, colorControl->mR); | ||
| 540 : | sWaterMenu->childSetValue(gName, colorControl->mG); | ||
| 541 : | sWaterMenu->childSetValue(bName, colorControl->mB); | ||
| 542 : | } | ||
| 543 : | |||
| 544 : | // now update the current parameters and send them to shaders | ||
| 545 : | colorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 546 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 547 : | } | ||
| 548 : | |||
| 549 : | void LLFloaterWater::onExpFloatControlMoved(LLUICtrl* ctrl, void* userData) | ||
| 550 : | { | ||
| 551 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 552 : | WaterExpFloatControl * expFloatControl = static_cast<WaterExpFloatControl *>(userData); | ||
| 553 : | |||
| 554 : | F32 val = sldrCtrl->getValueF32(); | ||
| 555 : | expFloatControl->mExp = val; | ||
| 556 : | LLWaterParamManager::instance()->setDensitySliderValue(val); | ||
| 557 : | |||
| 558 : | expFloatControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 559 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 560 : | } | ||
| 561 : | |||
| 562 : | void LLFloaterWater::onFloatControlMoved(LLUICtrl* ctrl, void* userData) | ||
| 563 : | { | ||
| 564 : | LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl); | ||
| 565 : | WaterFloatControl * floatControl = static_cast<WaterFloatControl *>(userData); | ||
| 566 : | |||
| 567 : | floatControl->mX = sldrCtrl->getValueF32() / floatControl->mMult; | ||
| 568 : | |||
| 569 : | floatControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 570 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 571 : | } | ||
| 572 : | void LLFloaterWater::onWaterFogColorMoved(LLUICtrl* ctrl, void* userData) | ||
| 573 : | { | ||
| 574 : | LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl); | ||
| 575 : | WaterColorControl * colorControl = static_cast<WaterColorControl *>(userData); | ||
| 576 : | *colorControl = swatch->get(); | ||
| 577 : | |||
| 578 : | colorControl->update(LLWaterParamManager::instance()->mCurParams); | ||
| 579 : | LLWaterParamManager::instance()->propagateParameters(); | ||
| 580 : | } | ||
| 581 : | |||
| 582 : | void LLFloaterWater::onBoolToggle(LLUICtrl* ctrl, void* userData) | ||
| 583 : | { | ||
| 584 : | LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl); | ||
| 585 : | |||
| 586 : | bool value = cbCtrl->get(); | ||
| 587 : | (*(static_cast<BOOL *>(userData))) = value; | ||
| 588 : | } | ||
| 589 : | |||
| 590 : | void LLFloaterWater::onNormalMapPicked(LLUICtrl* ctrl, void* userData) | ||
| 591 : | { | ||
| 592 : | LLTextureCtrl* textCtrl = static_cast<LLTextureCtrl*>(ctrl); | ||
| 593 : | LLUUID textID = textCtrl->getImageAssetID(); | ||
| 594 : | LLWaterParamManager::instance()->setNormalMapID(textID); | ||
| 595 : | } | ||
| 596 : | |||
| 597 : | void LLFloaterWater::onNewPreset(void* userData) | ||
| 598 : | { | ||
| 599 : | gViewerWindow->alertXmlEditText("NewWaterPreset", LLStringUtil::format_map_t(), | ||
| 600 : | NULL, NULL, newPromptCallback, NULL); | ||
| 601 : | } | ||
| 602 : | |||
| 603 : | void LLFloaterWater::onSavePreset(void* userData) | ||
| 604 : | { | ||
| 605 : | // get the name | ||
| 606 : | LLComboBox* comboBox = sWaterMenu->getChild<LLComboBox>("WaterPresetsCombo"); | ||
| 607 : | |||
| 608 : | // don't save the empty name | ||
| 609 : | if(comboBox->getSelectedItemLabel() == "") | ||
| 610 : | { | ||
| 611 : | return; | ||
| 612 : | } | ||
| 613 : | |||
| 614 : | LLWaterParamManager::instance()->mCurParams.mName = | ||
| 615 : | comboBox->getSelectedItemLabel(); | ||
| 616 : | |||
| 617 : | // check to see if it's a default and shouldn't be overwritten | ||
| 618 : | std::set<std::string>::iterator sIt = sDefaultPresets.find( | ||
| 619 : | comboBox->getSelectedItemLabel()); | ||
| 620 : | if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("WaterEditPresets")) | ||
| 621 : | { | ||
| 622 : | gViewerWindow->alertXml("WLNoEditDefault"); | ||
| 623 : | return; | ||
| 624 : | } | ||
| 625 : | |||
| 626 : | gViewerWindow->alertXml("WLSavePresetAlert", saveAlertCallback, sWaterMenu); | ||
| 627 : | } | ||
| 628 : | |||
| 629 : | void LLFloaterWater::saveAlertCallback(S32 option, void* userdata) | ||
| 630 : | { | ||
| 631 : | // if they choose save, do it. Otherwise, don't do anything | ||
| 632 : | if(option == 0) | ||
| 633 : | { | ||
| 634 : | LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); | ||
| 635 : | |||
| 636 : | param_mgr->setParamSet( | ||
| 637 : | param_mgr->mCurParams.mName, | ||
| 638 : | param_mgr->mCurParams); | ||
| 639 : | |||
| 640 : | // comment this back in to save to file | ||
| 641 : | param_mgr->savePreset(param_mgr->mCurParams.mName); | ||
| 642 : | } | ||
| 643 : | |||
| 644 : | } | ||
| 645 : | |||
| 646 : | void LLFloaterWater::onDeletePreset(void* userData) | ||
| 647 : | { | ||
| 648 : | LLComboBox* combo_box = sWaterMenu->getChild<LLComboBox>("WaterPresetsCombo"); | ||
| 649 : | |||
| 650 : | if(combo_box->getSelectedValue().asString() == "") | ||
| 651 : | { | ||
| 652 : | return; | ||
| 653 : | } | ||
| 654 : | |||
| 655 : | LLStringUtil::format_map_t args; | ||
| 656 : | args["[SKY]"] = combo_box->getSelectedValue().asString(); | ||
| 657 : | gViewerWindow->alertXml("WLDeletePresetAlert", args, deleteAlertCallback, sWaterMenu); | ||
| 658 : | } | ||
| 659 : | |||
| 660 : | void LLFloaterWater::deleteAlertCallback(S32 option, void* userdata) | ||
| 661 : | { | ||
| 662 : | // if they choose delete, do it. Otherwise, don't do anything | ||
| 663 : | if(option == 0) | ||
| 664 : | { | ||
| 665 : | LLComboBox* combo_box = sWaterMenu->getChild<LLComboBox>("WaterPresetsCombo"); | ||
| 666 : | LLFloaterDayCycle* day_cycle = NULL; | ||
| 667 : | LLComboBox* key_combo = NULL; | ||
| 668 : | LLMultiSliderCtrl* mult_sldr = NULL; | ||
| 669 : | |||
| 670 : | if(LLFloaterDayCycle::isOpen()) | ||
| 671 : | { | ||
| 672 : | day_cycle = LLFloaterDayCycle::instance(); | ||
| 673 : | key_combo = day_cycle->getChild<LLComboBox>("WaterKeyPresets"); | ||
| 674 : | mult_sldr = day_cycle->getChild<LLMultiSliderCtrl>("WaterDayCycleKeys"); | ||
| 675 : | } | ||
| 676 : | |||
| 677 : | std::string name = combo_box->getSelectedValue().asString(); | ||
| 678 : | |||
| 679 : | // check to see if it's a default and shouldn't be deleted | ||
| 680 : | std::set<std::string>::iterator sIt = sDefaultPresets.find(name); | ||
| 681 : | if(sIt != sDefaultPresets.end()) | ||
| 682 : | { | ||
| 683 : | gViewerWindow->alertXml("WaterNoEditDefault"); | ||
| 684 : | return; | ||
| 685 : | } | ||
| 686 : | |||
| 687 : | LLWaterParamManager::instance()->removeParamSet(name, true); | ||
| 688 : | |||
| 689 : | // remove and choose another | ||
| 690 : | S32 new_index = combo_box->getCurrentIndex(); | ||
| 691 : | |||
| 692 : | combo_box->remove(name); | ||
| 693 : | |||
| 694 : | if(key_combo != NULL) | ||
| 695 : | { | ||
| 696 : | key_combo->remove(name); | ||
| 697 : | |||
| 698 : | // remove from slider, as well | ||
| 699 : | day_cycle->deletePreset(name); | ||
| 700 : | } | ||
| 701 : | |||
| 702 : | // pick the previously selected index after delete | ||
| 703 : | if(new_index > 0) | ||
| 704 : | { | ||
| 705 : | new_index--; | ||
| 706 : | } | ||
| 707 : | |||
| 708 : | if(combo_box->getItemCount() > 0) | ||
| 709 : | { | ||
| 710 : | combo_box->setCurrentByIndex(new_index); | ||
| 711 : | } | ||
| 712 : | } | ||
| 713 : | } | ||
| 714 : | |||
| 715 : | |||
| 716 : | void LLFloaterWater::onChangePresetName(LLUICtrl* ctrl, void * userData) | ||
| 717 : | { | ||
| 718 : | LLComboBox * combo_box = static_cast<LLComboBox*>(ctrl); | ||
| 719 : | |||
| 720 : | if(combo_box->getSimple() == "") | ||
| 721 : | { | ||
| 722 : | return; | ||
| 723 : | } | ||
| 724 : | |||
| 725 : | LLWaterParamManager::instance()->loadPreset( | ||
| 726 : | combo_box->getSelectedValue().asString()); | ||
| 727 : | sWaterMenu->syncMenu(); | ||
| 728 : | } | ||
| 729 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

