summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterenvsettings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterenvsettings.cpp')
-rw-r--r--indra/newview/llfloaterenvsettings.cpp183
1 files changed, 48 insertions, 135 deletions
diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp
index 661c3988c0..2fffa6eece 100644
--- a/indra/newview/llfloaterenvsettings.cpp
+++ b/indra/newview/llfloaterenvsettings.cpp
@@ -34,6 +34,7 @@
#include "llfloaterenvsettings.h"
+#include "llfloaterreg.h"
#include "llfloaterwindlight.h"
#include "llfloaterwater.h"
#include "lluictrlfactory.h"
@@ -52,59 +53,53 @@
#include <sstream>
-LLFloaterEnvSettings* LLFloaterEnvSettings::sEnvSettings = NULL;
-
-LLFloaterEnvSettings::LLFloaterEnvSettings() : LLFloater(std::string("Environment Settings Floater"))
+LLFloaterEnvSettings::LLFloaterEnvSettings(const LLSD& key)
+ : LLFloater(key)
{
- LLUICtrlFactory::getInstance()->buildFloater(this, "floater_env_settings.xml");
-
- // load it up
- initCallbacks();
+ //LLUICtrlFactory::getInstance()->buildFloater(this, "floater_env_settings.xml");
}
-
+// virtual
LLFloaterEnvSettings::~LLFloaterEnvSettings()
{
}
-
-void LLFloaterEnvSettings::onClickHelp(void* data)
-{
- LLFloaterEnvSettings* self = (LLFloaterEnvSettings*)data;
- LLNotifications::instance().add(self->contextualNotification("EnvSettingsHelpButton"));
+// virtual
+BOOL LLFloaterEnvSettings::postBuild()
+{
+ // load it up
+ initCallbacks();
+ syncMenu();
+ return TRUE;
}
void LLFloaterEnvSettings::initCallbacks(void)
{
// our three sliders
- childSetCommitCallback("EnvTimeSlider", onChangeDayTime, NULL);
- childSetCommitCallback("EnvCloudSlider", onChangeCloudCoverage, NULL);
- childSetCommitCallback("EnvWaterFogSlider", onChangeWaterFogDensity,
- &LLWaterParamManager::instance()->mFogDensity);
+ getChild<LLUICtrl>("EnvTimeSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeDayTime, this, _1));
+ getChild<LLUICtrl>("EnvCloudSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeCloudCoverage, this, _1));
+ getChild<LLUICtrl>("EnvWaterFogSlider")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeWaterFogDensity, this, _1, &LLWaterParamManager::instance()->mFogDensity));
// color picker
- childSetCommitCallback("EnvWaterColor", onChangeWaterColor,
- &LLWaterParamManager::instance()->mFogColor);
+ getChild<LLUICtrl>("EnvWaterColor")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onChangeWaterColor, this, _1, &LLWaterParamManager::instance()->mFogColor));
// WL Top
- childSetAction("EnvAdvancedSkyButton", onOpenAdvancedSky, NULL);
- childSetAction("EnvAdvancedWaterButton", onOpenAdvancedWater, NULL);
- childSetAction("EnvUseEstateTimeButton", onUseEstateTime, NULL);
- childSetAction("EnvSettingsHelpButton", onClickHelp, this);
+ getChild<LLUICtrl>("EnvAdvancedSkyButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onOpenAdvancedSky, this));
+ getChild<LLUICtrl>("EnvAdvancedWaterButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onOpenAdvancedWater, this));
+ getChild<LLUICtrl>("EnvUseEstateTimeButton")->setCommitCallback(boost::bind(&LLFloaterEnvSettings::onUseEstateTime, this));
}
-
// menu maintenance functions
void LLFloaterEnvSettings::syncMenu()
{
LLSliderCtrl* sldr;
- sldr = sEnvSettings->getChild<LLSliderCtrl>("EnvTimeSlider");
+ sldr = getChild<LLSliderCtrl>("EnvTimeSlider");
// sync the clock
F32 val = (F32)LLWLParamManager::instance()->mAnimator.getDayTime();
std::string timeStr = timeToString(val);
LLTextBox* textBox;
- textBox = sEnvSettings->getChild<LLTextBox>("EnvTimeText");
+ textBox = getChild<LLTextBox>("EnvTimeText");
textBox->setValue(timeStr);
@@ -123,7 +118,7 @@ void LLFloaterEnvSettings::syncMenu()
LLWaterParamManager * param_mgr = LLWaterParamManager::instance();
// sync water params
LLColor4 col = param_mgr->getFogColor();
- LLColorSwatchCtrl* colCtrl = sEnvSettings->getChild<LLColorSwatchCtrl>("EnvWaterColor");
+ LLColorSwatchCtrl* colCtrl = getChild<LLColorSwatchCtrl>("EnvWaterColor");
col.mV[3] = 1.0f;
colCtrl->set(col);
@@ -167,53 +162,9 @@ void LLFloaterEnvSettings::syncMenu()
}
}
-
-// static instance of it
-LLFloaterEnvSettings* LLFloaterEnvSettings::instance()
+void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl)
{
- if (!sEnvSettings)
- {
- sEnvSettings = new LLFloaterEnvSettings();
- sEnvSettings->open();
- sEnvSettings->setFocus(TRUE);
- }
- return sEnvSettings;
-}
-void LLFloaterEnvSettings::show()
-{
- LLFloaterEnvSettings* envSettings = instance();
- envSettings->syncMenu();
-
- // comment in if you want the menu to rebuild each time
- //LLUICtrlFactory::getInstance()->buildFloater(envSettings, "floater_env_settings.xml");
- //envSettings->initCallbacks();
-
- envSettings->open();
-}
-
-bool LLFloaterEnvSettings::isOpen()
-{
- if (sEnvSettings != NULL)
- {
- return true;
- }
- return false;
-}
-
-// virtual
-void LLFloaterEnvSettings::onClose(bool app_quitting)
-{
- if (sEnvSettings)
- {
- sEnvSettings->setVisible(FALSE);
- }
-}
-
-
-void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl, void* userData)
-{
- LLSliderCtrl* sldr;
- sldr = sEnvSettings->getChild<LLSliderCtrl>("EnvTimeSlider");
+ LLSliderCtrl* sldr = static_cast<LLSliderCtrl*>(ctrl);
// deactivate animator
LLWLParamManager::instance()->mAnimator.mIsRunning = false;
@@ -230,10 +181,9 @@ void LLFloaterEnvSettings::onChangeDayTime(LLUICtrl* ctrl, void* userData)
LLWLParamManager::instance()->mCurParams);
}
-void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl, void* userData)
+void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl)
{
- LLSliderCtrl* sldr;
- sldr = sEnvSettings->getChild<LLSliderCtrl>("EnvCloudSlider");
+ LLSliderCtrl* sldr = static_cast<LLSliderCtrl*>(ctrl);
// deactivate animator
//LLWLParamManager::instance()->mAnimator.mIsRunning = false;
@@ -243,17 +193,10 @@ void LLFloaterEnvSettings::onChangeCloudCoverage(LLUICtrl* ctrl, void* userData)
LLWLParamManager::instance()->mCurParams.set("cloud_shadow", val);
}
-void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, void* userData)
+void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl)
{
LLSliderCtrl* sldr;
- sldr = sEnvSettings->getChild<LLSliderCtrl>("EnvWaterFogSlider");
-
- if(NULL == userData)
- {
- return;
- }
-
- WaterExpFloatControl * expFloatControl = static_cast<WaterExpFloatControl *>(userData);
+ sldr = getChild<LLSliderCtrl>("EnvWaterFogSlider");
F32 val = sldr->getValueF32();
expFloatControl->mExp = val;
@@ -263,10 +206,9 @@ void LLFloaterEnvSettings::onChangeWaterFogDensity(LLUICtrl* ctrl, void* userDat
LLWaterParamManager::instance()->propagateParameters();
}
-void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, void* userData)
+void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, WaterColorControl* colorControl)
{
LLColorSwatchCtrl* swatch = static_cast<LLColorSwatchCtrl*>(ctrl);
- WaterColorControl * colorControl = static_cast<WaterColorControl *>(userData);
*colorControl = swatch->get();
colorControl->update(LLWaterParamManager::instance()->mCurParams);
@@ -274,23 +216,22 @@ void LLFloaterEnvSettings::onChangeWaterColor(LLUICtrl* ctrl, void* userData)
}
-void LLFloaterEnvSettings::onOpenAdvancedSky(void* userData)
+void LLFloaterEnvSettings::onOpenAdvancedSky()
{
- LLFloaterWindLight::show();
+ LLFloaterReg::showInstance("env_windlight");
}
-void LLFloaterEnvSettings::onOpenAdvancedWater(void* userData)
+void LLFloaterEnvSettings::onOpenAdvancedWater()
{
- LLFloaterWater::show();
+ LLFloaterReg::showInstance("env_water");
}
-void LLFloaterEnvSettings::onUseEstateTime(void* userData)
+void LLFloaterEnvSettings::onUseEstateTime()
{
- if(LLFloaterWindLight::isOpen())
+ LLFloaterWindLight* wl = LLFloaterReg::findTypedInstance<LLFloaterWindLight>("env_windlight");
+ if(wl)
{
- // select the blank value in
- LLFloaterWindLight* wl = LLFloaterWindLight::instance();
LLComboBox* box = wl->getChild<LLComboBox>("WLPresetsCombo");
box->selectByValue("");
}
@@ -303,7 +244,6 @@ std::string LLFloaterEnvSettings::timeToString(F32 curTime)
{
S32 hours;
S32 min;
- bool isPM = false;
// get hours and minutes
hours = (S32) (24.0 * curTime);
@@ -317,46 +257,19 @@ std::string LLFloaterEnvSettings::timeToString(F32 curTime)
min = 0;
}
- // set for PM
- if(hours >= 12 && hours < 24)
- {
- isPM = true;
- }
+ std::string newTime = getString("timeStr");
+ struct tm * timeT;
+ time_t secT = time(0);
+ timeT = gmtime (&secT);
- // convert to non-military notation
- if(hours >= 24)
- {
- hours = 12;
- }
- else if(hours > 12)
- {
- hours -= 12;
- }
- else if(hours == 0)
- {
- hours = 12;
- }
+ timeT->tm_hour = hours;
+ timeT->tm_min = min;
+ secT = mktime (timeT);
+ secT -= LLStringOps::getLocalTimeOffset ();
- // make the string
- std::stringstream newTime;
- newTime << hours << ":";
-
- // double 0
- if(min < 10)
- {
- newTime << 0;
- }
-
- // finish it
- newTime << min << " ";
- if(isPM)
- {
- newTime << "PM";
- }
- else
- {
- newTime << "AM";
- }
+ LLSD substitution;
+ substitution["datetime"] = (S32) secT;
- return newTime.str();
+ LLStringUtil::format (newTime, substitution);
+ return newTime;
}