llfloaterwindlight.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:30k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llfloaterwindlight.cpp
  3.  * @brief LLFloaterWindLight class definition
  4.  *
  5.  * $LicenseInfo:firstyear=2007&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2007-2010, 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
  21.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22.  * 
  23.  * By copying, modifying or distributing this software, you acknowledge
  24.  * that you have read and understood your obligations described above,
  25.  * and agree to abide by those obligations.
  26.  * 
  27.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29.  * COMPLETENESS OR PERFORMANCE.
  30.  * $/LicenseInfo$
  31.  */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llfloaterwindlight.h"
  34. #include "pipeline.h"
  35. #include "llsky.h"
  36. #include "llfloaterreg.h"
  37. #include "llsliderctrl.h"
  38. #include "llmultislider.h"
  39. #include "llmultisliderctrl.h"
  40. #include "llnotificationsutil.h"
  41. #include "llspinctrl.h"
  42. #include "llcheckboxctrl.h"
  43. #include "lluictrlfactory.h"
  44. #include "llviewercamera.h"
  45. #include "llcombobox.h"
  46. #include "lllineeditor.h"
  47. #include "llfloaterdaycycle.h"
  48. #include "llboost.h"
  49. #include "v4math.h"
  50. #include "llviewerdisplay.h"
  51. #include "llviewercontrol.h"
  52. #include "llviewerwindow.h"
  53. #include "llsavedsettingsglue.h"
  54. #include "llwlparamset.h"
  55. #include "llwlparammanager.h"
  56. #include "llpostprocess.h"
  57. #include "lltabcontainer.h"
  58. #undef max
  59. std::set<std::string> LLFloaterWindLight::sDefaultPresets;
  60. static const F32 WL_SUN_AMBIENT_SLIDER_SCALE = 3.0f;
  61. LLFloaterWindLight::LLFloaterWindLight(const LLSD& key)
  62.   : LLFloater(key)
  63. {
  64. //LLUICtrlFactory::getInstance()->buildFloater(this, "floater_windlight_options.xml");
  65. }
  66. LLFloaterWindLight::~LLFloaterWindLight()
  67. {
  68. }
  69. BOOL LLFloaterWindLight::postBuild()
  70. {
  71. // add the list of presets
  72. std::string def_days = getString("WLDefaultSkyNames");
  73. // no editing or deleting of the blank string
  74. sDefaultPresets.insert("");
  75. boost_tokenizer tokens(def_days, boost::char_separator<char>(":"));
  76. for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter)
  77. {
  78. std::string tok(*token_iter);
  79. sDefaultPresets.insert(tok);
  80. }
  81. // add the combo boxes
  82. LLComboBox* comboBox = getChild<LLComboBox>("WLPresetsCombo");
  83. if(comboBox != NULL) {
  84. std::map<std::string, LLWLParamSet>::iterator mIt = 
  85. LLWLParamManager::instance()->mParamList.begin();
  86. for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) 
  87. {
  88. comboBox->add(mIt->first);
  89. }
  90. // entry for when we're in estate time
  91. comboBox->add(LLStringUtil::null);
  92. // set defaults on combo boxes
  93. comboBox->selectByValue(LLSD("Default"));
  94. }
  95. // load it up
  96. initCallbacks();
  97. syncMenu();
  98. return TRUE;
  99. }
  100. void LLFloaterWindLight::initCallbacks(void) {
  101. LLWLParamManager * param_mgr = LLWLParamManager::instance();
  102. // blue horizon
  103. getChild<LLUICtrl>("WLBlueHorizonR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mBlueHorizon));
  104. getChild<LLUICtrl>("WLBlueHorizonG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, &param_mgr->mBlueHorizon));
  105. getChild<LLUICtrl>("WLBlueHorizonB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, &param_mgr->mBlueHorizon));
  106. getChild<LLUICtrl>("WLBlueHorizonI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, &param_mgr->mBlueHorizon));
  107. // haze density, horizon, mult, and altitude
  108. getChild<LLUICtrl>("WLHazeDensity")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mHazeDensity));
  109. getChild<LLUICtrl>("WLHazeHorizon")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mHazeHorizon));
  110. getChild<LLUICtrl>("WLDensityMult")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, &param_mgr->mDensityMult));
  111. getChild<LLUICtrl>("WLMaxAltitude")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, &param_mgr->mMaxAlt));
  112. // blue density
  113. getChild<LLUICtrl>("WLBlueDensityR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mBlueDensity));
  114. getChild<LLUICtrl>("WLBlueDensityG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, &param_mgr->mBlueDensity));
  115. getChild<LLUICtrl>("WLBlueDensityB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, &param_mgr->mBlueDensity));
  116. getChild<LLUICtrl>("WLBlueDensityI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, &param_mgr->mBlueDensity));
  117. // Lighting
  118. // sunlight
  119. getChild<LLUICtrl>("WLSunlightR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mSunlight));
  120. getChild<LLUICtrl>("WLSunlightG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, &param_mgr->mSunlight));
  121. getChild<LLUICtrl>("WLSunlightB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, &param_mgr->mSunlight));
  122. getChild<LLUICtrl>("WLSunlightI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, &param_mgr->mSunlight));
  123. // glow
  124. getChild<LLUICtrl>("WLGlowR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onGlowRMoved, this, _1, &param_mgr->mGlow));
  125. getChild<LLUICtrl>("WLGlowB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onGlowBMoved, this, _1, &param_mgr->mGlow));
  126. // ambient
  127. getChild<LLUICtrl>("WLAmbientR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mAmbient));
  128. getChild<LLUICtrl>("WLAmbientG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, &param_mgr->mAmbient));
  129. getChild<LLUICtrl>("WLAmbientB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, &param_mgr->mAmbient));
  130. getChild<LLUICtrl>("WLAmbientI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, &param_mgr->mAmbient));
  131. // time of day
  132. getChild<LLUICtrl>("WLSunAngle")->setCommitCallback(boost::bind(&LLFloaterWindLight::onSunMoved, this, _1, &param_mgr->mLightnorm));
  133. getChild<LLUICtrl>("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterWindLight::onSunMoved, this, _1, &param_mgr->mLightnorm));
  134. // Clouds
  135. // Cloud Color
  136. getChild<LLUICtrl>("WLCloudColorR")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mCloudColor));
  137. getChild<LLUICtrl>("WLCloudColorG")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, &param_mgr->mCloudColor));
  138. getChild<LLUICtrl>("WLCloudColorB")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, &param_mgr->mCloudColor));
  139. getChild<LLUICtrl>("WLCloudColorI")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlIMoved, this, _1, &param_mgr->mCloudColor));
  140. // Cloud
  141. getChild<LLUICtrl>("WLCloudX")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mCloudMain));
  142. getChild<LLUICtrl>("WLCloudY")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, &param_mgr->mCloudMain));
  143. getChild<LLUICtrl>("WLCloudDensity")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, &param_mgr->mCloudMain));
  144. // Cloud Detail
  145. getChild<LLUICtrl>("WLCloudDetailX")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlRMoved, this, _1, &param_mgr->mCloudDetail));
  146. getChild<LLUICtrl>("WLCloudDetailY")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlGMoved, this, _1, &param_mgr->mCloudDetail));
  147. getChild<LLUICtrl>("WLCloudDetailDensity")->setCommitCallback(boost::bind(&LLFloaterWindLight::onColorControlBMoved, this, _1, &param_mgr->mCloudDetail));
  148. // Cloud extras
  149. getChild<LLUICtrl>("WLCloudCoverage")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, &param_mgr->mCloudCoverage));
  150. getChild<LLUICtrl>("WLCloudScale")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, &param_mgr->mCloudScale));
  151. getChild<LLUICtrl>("WLCloudLockX")->setCommitCallback(boost::bind(&LLFloaterWindLight::onCloudScrollXToggled, this, _1));
  152. getChild<LLUICtrl>("WLCloudLockY")->setCommitCallback(boost::bind(&LLFloaterWindLight::onCloudScrollYToggled, this, _1));
  153. getChild<LLUICtrl>("WLCloudScrollX")->setCommitCallback(boost::bind(&LLFloaterWindLight::onCloudScrollXMoved, this, _1));
  154. getChild<LLUICtrl>("WLCloudScrollY")->setCommitCallback(boost::bind(&LLFloaterWindLight::onCloudScrollYMoved, this, _1));
  155. getChild<LLUICtrl>("WLDistanceMult")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, &param_mgr->mDistanceMult));
  156. getChild<LLUICtrl>("DrawClassicClouds")->setCommitCallback(boost::bind(LLSavedSettingsGlue::setBOOL, _1, "SkyUseClassicClouds"));
  157. // WL Top
  158. getChild<LLUICtrl>("WLDayCycleMenuButton")->setCommitCallback(boost::bind(&LLFloaterWindLight::onOpenDayCycle, this));
  159. // Load/save
  160. LLComboBox* comboBox = getChild<LLComboBox>("WLPresetsCombo");
  161. //childSetAction("WLLoadPreset", onLoadPreset, comboBox);
  162. getChild<LLUICtrl>("WLNewPreset")->setCommitCallback(boost::bind(&LLFloaterWindLight::onNewPreset, this));
  163. getChild<LLUICtrl>("WLSavePreset")->setCommitCallback(boost::bind(&LLFloaterWindLight::onSavePreset, this));
  164. getChild<LLUICtrl>("WLDeletePreset")->setCommitCallback(boost::bind(&LLFloaterWindLight::onDeletePreset, this));
  165. comboBox->setCommitCallback(boost::bind(&LLFloaterWindLight::onChangePresetName, this, _1));
  166. // Dome
  167. getChild<LLUICtrl>("WLGamma")->setCommitCallback(boost::bind(&LLFloaterWindLight::onFloatControlMoved, this, _1, &param_mgr->mWLGamma));
  168. getChild<LLUICtrl>("WLStarAlpha")->setCommitCallback(boost::bind(&LLFloaterWindLight::onStarAlphaMoved, this, _1));
  169. }
  170. bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& response)
  171. {
  172. std::string text = response["message"].asString();
  173. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  174. if(text == "")
  175. {
  176. return false;
  177. }
  178. if(option == 0) {
  179. LLComboBox* comboBox = getChild<LLComboBox>("WLPresetsCombo");
  180. LLFloaterDayCycle* day_cycle = LLFloaterReg::findTypedInstance<LLFloaterDayCycle>("env_day_cycle");
  181. LLComboBox* keyCombo = NULL;
  182. if(day_cycle) 
  183. {
  184. keyCombo = day_cycle->getChild<LLComboBox>("WLKeyPresets");
  185. }
  186. // add the current parameters to the list
  187. // see if it's there first
  188. std::map<std::string, LLWLParamSet>::iterator mIt = 
  189. LLWLParamManager::instance()->mParamList.find(text);
  190. // if not there, add a new one
  191. if(mIt == LLWLParamManager::instance()->mParamList.end()) 
  192. {
  193. LLWLParamManager::instance()->addParamSet(text, 
  194. LLWLParamManager::instance()->mCurParams);
  195. comboBox->add(text);
  196. comboBox->sortByName();
  197. // add a blank to the bottom
  198. comboBox->selectFirstItem();
  199. if(comboBox->getSimple() == "")
  200. {
  201. comboBox->remove(0);
  202. }
  203. comboBox->add(LLStringUtil::null);
  204. comboBox->setSelectedByValue(text, true);
  205. if(keyCombo) 
  206. {
  207. keyCombo->add(text);
  208. keyCombo->sortByName();
  209. }
  210. LLWLParamManager::instance()->savePreset(text);
  211. // otherwise, send a message to the user
  212. else 
  213. {
  214. LLNotificationsUtil::add("ExistsSkyPresetAlert");
  215. }
  216. }
  217. return false;
  218. }
  219. void LLFloaterWindLight::syncMenu()
  220. {
  221. bool err;
  222. LLWLParamManager * param_mgr = LLWLParamManager::instance();
  223. LLWLParamSet& currentParams = param_mgr->mCurParams;
  224. //std::map<std::string, LLVector4> & currentParams = param_mgr->mCurParams.mParamValues;
  225. // blue horizon
  226. param_mgr->mBlueHorizon = currentParams.getVector(param_mgr->mBlueHorizon.mName, err);
  227. childSetValue("WLBlueHorizonR", param_mgr->mBlueHorizon.r / 2.0);
  228. childSetValue("WLBlueHorizonG", param_mgr->mBlueHorizon.g / 2.0);
  229. childSetValue("WLBlueHorizonB", param_mgr->mBlueHorizon.b / 2.0);
  230. childSetValue("WLBlueHorizonI", 
  231. std::max(param_mgr->mBlueHorizon.r / 2.0, 
  232. std::max(param_mgr->mBlueHorizon.g / 2.0, 
  233. param_mgr->mBlueHorizon.b / 2.0)));
  234. // haze density, horizon, mult, and altitude
  235. param_mgr->mHazeDensity = currentParams.getVector(param_mgr->mHazeDensity.mName, err);
  236. childSetValue("WLHazeDensity", param_mgr->mHazeDensity.r);
  237. param_mgr->mHazeHorizon = currentParams.getVector(param_mgr->mHazeHorizon.mName, err);
  238. childSetValue("WLHazeHorizon", param_mgr->mHazeHorizon.r);
  239. param_mgr->mDensityMult = currentParams.getVector(param_mgr->mDensityMult.mName, err);
  240. childSetValue("WLDensityMult", param_mgr->mDensityMult.x * 
  241. param_mgr->mDensityMult.mult);
  242. param_mgr->mMaxAlt = currentParams.getVector(param_mgr->mMaxAlt.mName, err);
  243. childSetValue("WLMaxAltitude", param_mgr->mMaxAlt.x);
  244. // blue density
  245. param_mgr->mBlueDensity = currentParams.getVector(param_mgr->mBlueDensity.mName, err);
  246. childSetValue("WLBlueDensityR", param_mgr->mBlueDensity.r / 2.0);
  247. childSetValue("WLBlueDensityG", param_mgr->mBlueDensity.g / 2.0);
  248. childSetValue("WLBlueDensityB", param_mgr->mBlueDensity.b / 2.0);
  249. childSetValue("WLBlueDensityI", 
  250. std::max(param_mgr->mBlueDensity.r / 2.0, 
  251. std::max(param_mgr->mBlueDensity.g / 2.0, param_mgr->mBlueDensity.b / 2.0)));
  252. // Lighting
  253. // sunlight
  254. param_mgr->mSunlight = currentParams.getVector(param_mgr->mSunlight.mName, err);
  255. childSetValue("WLSunlightR", param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE);
  256. childSetValue("WLSunlightG", param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE);
  257. childSetValue("WLSunlightB", param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE);
  258. childSetValue("WLSunlightI", 
  259. std::max(param_mgr->mSunlight.r / WL_SUN_AMBIENT_SLIDER_SCALE, 
  260. std::max(param_mgr->mSunlight.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mSunlight.b / WL_SUN_AMBIENT_SLIDER_SCALE)));
  261. // glow
  262. param_mgr->mGlow = currentParams.getVector(param_mgr->mGlow.mName, err);
  263. childSetValue("WLGlowR", 2 - param_mgr->mGlow.r / 20.0f);
  264. childSetValue("WLGlowB", -param_mgr->mGlow.b / 5.0f);
  265. // ambient
  266. param_mgr->mAmbient = currentParams.getVector(param_mgr->mAmbient.mName, err);
  267. childSetValue("WLAmbientR", param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE);
  268. childSetValue("WLAmbientG", param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE);
  269. childSetValue("WLAmbientB", param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE);
  270. childSetValue("WLAmbientI", 
  271. std::max(param_mgr->mAmbient.r / WL_SUN_AMBIENT_SLIDER_SCALE, 
  272. std::max(param_mgr->mAmbient.g / WL_SUN_AMBIENT_SLIDER_SCALE, param_mgr->mAmbient.b / WL_SUN_AMBIENT_SLIDER_SCALE)));
  273. childSetValue("WLSunAngle", param_mgr->mCurParams.getFloat("sun_angle",err) / F_TWO_PI);
  274. childSetValue("WLEastAngle", param_mgr->mCurParams.getFloat("east_angle",err) / F_TWO_PI);
  275. // Clouds
  276. // Cloud Color
  277. param_mgr->mCloudColor = currentParams.getVector(param_mgr->mCloudColor.mName, err);
  278. childSetValue("WLCloudColorR", param_mgr->mCloudColor.r);
  279. childSetValue("WLCloudColorG", param_mgr->mCloudColor.g);
  280. childSetValue("WLCloudColorB", param_mgr->mCloudColor.b);
  281. childSetValue("WLCloudColorI", 
  282. std::max(param_mgr->mCloudColor.r, 
  283. std::max(param_mgr->mCloudColor.g, param_mgr->mCloudColor.b)));
  284. // Cloud
  285. param_mgr->mCloudMain = currentParams.getVector(param_mgr->mCloudMain.mName, err);
  286. childSetValue("WLCloudX", param_mgr->mCloudMain.r);
  287. childSetValue("WLCloudY", param_mgr->mCloudMain.g);
  288. childSetValue("WLCloudDensity", param_mgr->mCloudMain.b);
  289. // Cloud Detail
  290. param_mgr->mCloudDetail = currentParams.getVector(param_mgr->mCloudDetail.mName, err);
  291. childSetValue("WLCloudDetailX", param_mgr->mCloudDetail.r);
  292. childSetValue("WLCloudDetailY", param_mgr->mCloudDetail.g);
  293. childSetValue("WLCloudDetailDensity", param_mgr->mCloudDetail.b);
  294. // Cloud extras
  295. param_mgr->mCloudCoverage = currentParams.getVector(param_mgr->mCloudCoverage.mName, err);
  296. param_mgr->mCloudScale = currentParams.getVector(param_mgr->mCloudScale.mName, err);
  297. childSetValue("WLCloudCoverage", param_mgr->mCloudCoverage.x);
  298. childSetValue("WLCloudScale", param_mgr->mCloudScale.x);
  299. // cloud scrolling
  300. bool lockX = !param_mgr->mCurParams.getEnableCloudScrollX();
  301. bool lockY = !param_mgr->mCurParams.getEnableCloudScrollY();
  302. childSetValue("WLCloudLockX", lockX);
  303. childSetValue("WLCloudLockY", lockY);
  304. childSetValue("DrawClassicClouds", gSavedSettings.getBOOL("SkyUseClassicClouds"));
  305. // disable if locked, enable if not
  306. if(lockX) 
  307. {
  308. childDisable("WLCloudScrollX");
  309. } else {
  310. childEnable("WLCloudScrollX");
  311. }
  312. if(lockY)
  313. {
  314. childDisable("WLCloudScrollY");
  315. } else {
  316. childEnable("WLCloudScrollY");
  317. }
  318. // *HACK cloud scrolling is off my an additive of 10
  319. childSetValue("WLCloudScrollX", param_mgr->mCurParams.getCloudScrollX() - 10.0f);
  320. childSetValue("WLCloudScrollY", param_mgr->mCurParams.getCloudScrollY() - 10.0f);
  321. param_mgr->mDistanceMult = currentParams.getVector(param_mgr->mDistanceMult.mName, err);
  322. childSetValue("WLDistanceMult", param_mgr->mDistanceMult.x);
  323. // Tweak extras
  324. param_mgr->mWLGamma = currentParams.getVector(param_mgr->mWLGamma.mName, err);
  325. childSetValue("WLGamma", param_mgr->mWLGamma.x);
  326. childSetValue("WLStarAlpha", param_mgr->mCurParams.getStarBrightness());
  327. LLTabContainer* tab = getChild<LLTabContainer>("WindLight Tabs");
  328. LLPanel* panel = getChild<LLPanel>("Scattering");
  329. tab->enableTabButton(tab->getIndexForPanel(panel), gSavedSettings.getBOOL("RenderDeferredGI"));
  330. }
  331. // color control callbacks
  332. void LLFloaterWindLight::onColorControlRMoved(LLUICtrl* ctrl, WLColorControl* colorControl)
  333. {
  334. deactivateAnimator();
  335. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  336. colorControl->r = sldrCtrl->getValueF32();
  337. if(colorControl->isSunOrAmbientColor) {
  338. colorControl->r *= 3;
  339. }
  340. if(colorControl->isBlueHorizonOrDensity) {
  341. colorControl->r *= 2;
  342. }
  343. // move i if it's the max
  344. if(colorControl->r >= colorControl->g && colorControl->r >= colorControl->b 
  345. && colorControl->hasSliderName) {
  346. colorControl->i = colorControl->r;
  347. std::string name = colorControl->mSliderName;
  348. name.append("I");
  349. if(colorControl->isSunOrAmbientColor) {
  350. childSetValue(name, colorControl->r / 3);
  351. } else if(colorControl->isBlueHorizonOrDensity) {
  352. childSetValue(name, colorControl->r / 2);
  353. } else {
  354. childSetValue(name, colorControl->r);
  355. }
  356. }
  357. colorControl->update(LLWLParamManager::instance()->mCurParams);
  358. LLWLParamManager::instance()->propagateParameters();
  359. }
  360. void LLFloaterWindLight::onColorControlGMoved(LLUICtrl* ctrl, WLColorControl* colorControl)
  361. {
  362. deactivateAnimator();
  363. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  364. colorControl->g = sldrCtrl->getValueF32();
  365. if(colorControl->isSunOrAmbientColor) {
  366. colorControl->g *= 3;
  367. }
  368. if(colorControl->isBlueHorizonOrDensity) {
  369. colorControl->g *= 2;
  370. }
  371. // move i if it's the max
  372. if(colorControl->g >= colorControl->r && colorControl->g >= colorControl->b
  373. && colorControl->hasSliderName) {
  374. colorControl->i = colorControl->g;
  375. std::string name = colorControl->mSliderName;
  376. name.append("I");
  377. if(colorControl->isSunOrAmbientColor) {
  378. childSetValue(name, colorControl->g / 3);
  379. } else if(colorControl->isBlueHorizonOrDensity) {
  380. childSetValue(name, colorControl->g / 2);
  381. } else {
  382. childSetValue(name, colorControl->g);
  383. }
  384. }
  385. colorControl->update(LLWLParamManager::instance()->mCurParams);
  386. LLWLParamManager::instance()->propagateParameters();
  387. }
  388. void LLFloaterWindLight::onColorControlBMoved(LLUICtrl* ctrl, WLColorControl* colorControl)
  389. {
  390. deactivateAnimator();
  391. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  392. colorControl->b = sldrCtrl->getValueF32();
  393. if(colorControl->isSunOrAmbientColor) {
  394. colorControl->b *= 3;
  395. }
  396. if(colorControl->isBlueHorizonOrDensity) {
  397. colorControl->b *= 2;
  398. }
  399. // move i if it's the max
  400. if(colorControl->b >= colorControl->r && colorControl->b >= colorControl->g
  401. && colorControl->hasSliderName) {
  402. colorControl->i = colorControl->b;
  403. std::string name = colorControl->mSliderName;
  404. name.append("I");
  405. if(colorControl->isSunOrAmbientColor) {
  406. childSetValue(name, colorControl->b / 3);
  407. } else if(colorControl->isBlueHorizonOrDensity) {
  408. childSetValue(name, colorControl->b / 2);
  409. } else {
  410. childSetValue(name, colorControl->b);
  411. }
  412. }
  413. colorControl->update(LLWLParamManager::instance()->mCurParams);
  414. LLWLParamManager::instance()->propagateParameters();
  415. }
  416. void LLFloaterWindLight::onColorControlIMoved(LLUICtrl* ctrl, WLColorControl* colorControl)
  417. {
  418. deactivateAnimator();
  419. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  420. colorControl->i = sldrCtrl->getValueF32();
  421. // only for sliders where we pass a name
  422. if(colorControl->hasSliderName) {
  423. // set it to the top
  424. F32 maxVal = std::max(std::max(colorControl->r, colorControl->g), colorControl->b);
  425. F32 iVal;
  426. if(colorControl->isSunOrAmbientColor)
  427. {
  428. iVal = colorControl->i * 3;
  429. else if(colorControl->isBlueHorizonOrDensity)
  430. {
  431. iVal = colorControl->i * 2;
  432. else 
  433. {
  434. iVal = colorControl->i;
  435. }
  436. // get the names of the other sliders
  437. std::string rName = colorControl->mSliderName;
  438. rName.append("R");
  439. std::string gName = colorControl->mSliderName;
  440. gName.append("G");
  441. std::string bName = colorControl->mSliderName;
  442. bName.append("B");
  443. // handle if at 0
  444. if(iVal == 0) {
  445. colorControl->r = 0;
  446. colorControl->g = 0;
  447. colorControl->b = 0;
  448. // if all at the start
  449. // set them all to the intensity
  450. } else if (maxVal == 0) {
  451. colorControl->r = iVal;
  452. colorControl->g = iVal;
  453. colorControl->b = iVal;
  454. } else {
  455. // add delta amounts to each
  456. F32 delta = (iVal - maxVal) / maxVal;
  457. colorControl->r *= (1.0f + delta);
  458. colorControl->g *= (1.0f + delta);
  459. colorControl->b *= (1.0f + delta);
  460. }
  461. // divide sun color vals by three
  462. if(colorControl->isSunOrAmbientColor) 
  463. {
  464. childSetValue(rName, colorControl->r/3);
  465. childSetValue(gName, colorControl->g/3);
  466. childSetValue(bName, colorControl->b/3);
  467. else if(colorControl->isBlueHorizonOrDensity) 
  468. {
  469. childSetValue(rName, colorControl->r/2);
  470. childSetValue(gName, colorControl->g/2);
  471. childSetValue(bName, colorControl->b/2);
  472. else 
  473. {
  474. // set the sliders to the new vals
  475. childSetValue(rName, colorControl->r);
  476. childSetValue(gName, colorControl->g);
  477. childSetValue(bName, colorControl->b);
  478. }
  479. }
  480. // now update the current parameters and send them to shaders
  481. colorControl->update(LLWLParamManager::instance()->mCurParams);
  482. LLWLParamManager::instance()->propagateParameters();
  483. }
  484. /// GLOW SPECIFIC CODE
  485. void LLFloaterWindLight::onGlowRMoved(LLUICtrl* ctrl, WLColorControl* colorControl)
  486. {
  487. deactivateAnimator();
  488. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  489. // scaled by 20
  490. colorControl->r = (2 - sldrCtrl->getValueF32()) * 20;
  491. colorControl->update(LLWLParamManager::instance()->mCurParams);
  492. LLWLParamManager::instance()->propagateParameters();
  493. }
  494. /// NOTE that we want NEGATIVE (-) B
  495. void LLFloaterWindLight::onGlowBMoved(LLUICtrl* ctrl, WLColorControl* colorControl)
  496. {
  497. deactivateAnimator();
  498. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  499. /// NOTE that we want NEGATIVE (-) B and NOT by 20 as 20 is too big
  500. colorControl->b = -sldrCtrl->getValueF32() * 5;
  501. colorControl->update(LLWLParamManager::instance()->mCurParams);
  502. LLWLParamManager::instance()->propagateParameters();
  503. }
  504. void LLFloaterWindLight::onFloatControlMoved(LLUICtrl* ctrl, WLFloatControl* floatControl)
  505. {
  506. deactivateAnimator();
  507. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  508. floatControl->x = sldrCtrl->getValueF32() / floatControl->mult;
  509. floatControl->update(LLWLParamManager::instance()->mCurParams);
  510. LLWLParamManager::instance()->propagateParameters();
  511. }
  512. // Lighting callbacks
  513. // time of day
  514. void LLFloaterWindLight::onSunMoved(LLUICtrl* ctrl, WLColorControl* colorControl)
  515. {
  516. deactivateAnimator();
  517. LLSliderCtrl* sunSldr = getChild<LLSliderCtrl>("WLSunAngle");
  518. LLSliderCtrl* eastSldr = getChild<LLSliderCtrl>("WLEastAngle");
  519. // get the two angles
  520. LLWLParamManager * param_mgr = LLWLParamManager::instance();
  521. param_mgr->mCurParams.setSunAngle(F_TWO_PI * sunSldr->getValueF32());
  522. param_mgr->mCurParams.setEastAngle(F_TWO_PI * eastSldr->getValueF32());
  523. // set the sun vector
  524. colorControl->r = -sin(param_mgr->mCurParams.getEastAngle()) * 
  525. cos(param_mgr->mCurParams.getSunAngle());
  526. colorControl->g = sin(param_mgr->mCurParams.getSunAngle());
  527. colorControl->b = cos(param_mgr->mCurParams.getEastAngle()) * 
  528. cos(param_mgr->mCurParams.getSunAngle());
  529. colorControl->i = 1.f;
  530. colorControl->update(param_mgr->mCurParams);
  531. param_mgr->propagateParameters();
  532. }
  533. void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl)
  534. {
  535. deactivateAnimator();
  536. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  537. LLWLParamManager::instance()->mCurParams.setStarBrightness(sldrCtrl->getValueF32());
  538. }
  539. void LLFloaterWindLight::onNewPreset()
  540. {
  541. LLNotificationsUtil::add("NewSkyPreset", LLSD(), LLSD(), boost::bind(&LLFloaterWindLight::newPromptCallback, this, _1, _2));
  542. }
  543. void LLFloaterWindLight::onSavePreset()
  544. {
  545. // get the name
  546. LLComboBox* comboBox = getChild<LLComboBox>( 
  547. "WLPresetsCombo");
  548. // don't save the empty name
  549. if(comboBox->getSelectedItemLabel() == "")
  550. {
  551. return;
  552. }
  553. // check to see if it's a default and shouldn't be overwritten
  554. std::set<std::string>::iterator sIt = sDefaultPresets.find(
  555. comboBox->getSelectedItemLabel());
  556. if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets")) 
  557. {
  558. LLNotificationsUtil::add("WLNoEditDefault");
  559. return;
  560. }
  561. LLWLParamManager::instance()->mCurParams.mName = 
  562. comboBox->getSelectedItemLabel();
  563. LLNotificationsUtil::add("WLSavePresetAlert", LLSD(), LLSD(), boost::bind(&LLFloaterWindLight::saveAlertCallback, this, _1, _2));
  564. }
  565. bool LLFloaterWindLight::saveAlertCallback(const LLSD& notification, const LLSD& response)
  566. {
  567. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  568. // if they choose save, do it.  Otherwise, don't do anything
  569. if(option == 0) 
  570. {
  571. LLWLParamManager * param_mgr = LLWLParamManager::instance();
  572. param_mgr->setParamSet(param_mgr->mCurParams.mName, param_mgr->mCurParams);
  573. // comment this back in to save to file
  574. param_mgr->savePreset(param_mgr->mCurParams.mName);
  575. }
  576. return false;
  577. }
  578. void LLFloaterWindLight::onDeletePreset()
  579. {
  580. LLComboBox* combo_box = getChild<LLComboBox>( 
  581. "WLPresetsCombo");
  582. if(combo_box->getSelectedValue().asString() == "")
  583. {
  584. return;
  585. }
  586. LLSD args;
  587. args["SKY"] = combo_box->getSelectedValue().asString();
  588. LLNotificationsUtil::add("WLDeletePresetAlert", args, LLSD(), 
  589. boost::bind(&LLFloaterWindLight::deleteAlertCallback, this, _1, _2));
  590. }
  591. bool LLFloaterWindLight::deleteAlertCallback(const LLSD& notification, const LLSD& response)
  592. {
  593. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  594. // if they choose delete, do it.  Otherwise, don't do anything
  595. if(option == 0) 
  596. {
  597. LLComboBox* combo_box = getChild<LLComboBox>("WLPresetsCombo");
  598. LLFloaterDayCycle* day_cycle = LLFloaterReg::findTypedInstance<LLFloaterDayCycle>("env_day_cycle");
  599. LLComboBox* key_combo = NULL;
  600. if (day_cycle) 
  601. {
  602. key_combo = day_cycle->getChild<LLComboBox>("WLKeyPresets");
  603. }
  604. std::string name(combo_box->getSelectedValue().asString());
  605. // check to see if it's a default and shouldn't be deleted
  606. std::set<std::string>::iterator sIt = sDefaultPresets.find(name);
  607. if(sIt != sDefaultPresets.end()) 
  608. {
  609. LLNotificationsUtil::add("WLNoEditDefault");
  610. return false;
  611. }
  612. LLWLParamManager::instance()->removeParamSet(name, true);
  613. // remove and choose another
  614. S32 new_index = combo_box->getCurrentIndex();
  615. combo_box->remove(name);
  616. if(key_combo != NULL) 
  617. {
  618. key_combo->remove(name);
  619. // remove from slider, as well
  620. day_cycle->deletePreset(name);
  621. }
  622. // pick the previously selected index after delete
  623. if(new_index > 0) 
  624. {
  625. new_index--;
  626. }
  627. if(combo_box->getItemCount() > 0) 
  628. {
  629. combo_box->setCurrentByIndex(new_index);
  630. }
  631. }
  632. return false;
  633. }
  634. void LLFloaterWindLight::onChangePresetName(LLUICtrl* ctrl)
  635. {
  636. deactivateAnimator();
  637. std::string data = ctrl->getValue().asString();
  638. if(!data.empty())
  639. {
  640. LLWLParamManager::instance()->loadPreset( data);
  641. syncMenu();
  642. }
  643. }
  644. void LLFloaterWindLight::onOpenDayCycle()
  645. {
  646. LLFloaterReg::showInstance("env_day_cycle");
  647. }
  648. // Clouds
  649. void LLFloaterWindLight::onCloudScrollXMoved(LLUICtrl* ctrl)
  650. {
  651. deactivateAnimator();
  652. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  653. // *HACK  all cloud scrolling is off by an additive of 10. 
  654. LLWLParamManager::instance()->mCurParams.setCloudScrollX(sldrCtrl->getValueF32() + 10.0f);
  655. }
  656. void LLFloaterWindLight::onCloudScrollYMoved(LLUICtrl* ctrl)
  657. {
  658. deactivateAnimator();
  659. LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
  660. // *HACK  all cloud scrolling is off by an additive of 10. 
  661. LLWLParamManager::instance()->mCurParams.setCloudScrollY(sldrCtrl->getValueF32() + 10.0f);
  662. }
  663. void LLFloaterWindLight::onCloudScrollXToggled(LLUICtrl* ctrl)
  664. {
  665. deactivateAnimator();
  666. LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
  667. bool lock = cbCtrl->get();
  668. LLWLParamManager::instance()->mCurParams.setEnableCloudScrollX(!lock);
  669. LLSliderCtrl* sldr = getChild<LLSliderCtrl>( 
  670. "WLCloudScrollX");
  671. if(cbCtrl->get()) 
  672. {
  673. sldr->setEnabled(false);
  674. else 
  675. {
  676. sldr->setEnabled(true);
  677. }
  678. }
  679. void LLFloaterWindLight::onCloudScrollYToggled(LLUICtrl* ctrl)
  680. {
  681. deactivateAnimator();
  682. LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
  683. bool lock = cbCtrl->get();
  684. LLWLParamManager::instance()->mCurParams.setEnableCloudScrollY(!lock);
  685. LLSliderCtrl* sldr = getChild<LLSliderCtrl>( 
  686. "WLCloudScrollY");
  687. if(cbCtrl->get()) 
  688. {
  689. sldr->setEnabled(false);
  690. else 
  691. {
  692. sldr->setEnabled(true);
  693. }
  694. }
  695. void LLFloaterWindLight::deactivateAnimator()
  696. {
  697. LLWLParamManager::instance()->mAnimator.mIsRunning = false;
  698. LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
  699. }