summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterenvironmentsettings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterenvironmentsettings.cpp')
-rw-r--r--indra/newview/llfloaterenvironmentsettings.cpp197
1 files changed, 107 insertions, 90 deletions
diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp
index 4dbc8cdee0..b7bf6918fe 100644
--- a/indra/newview/llfloaterenvironmentsettings.cpp
+++ b/indra/newview/llfloaterenvironmentsettings.cpp
@@ -1,25 +1,25 @@
-/**
+/**
* @file llfloaterenvironmentsettings.cpp
* @brief LLFloaterEnvironmentSettings class definition
*
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -31,11 +31,8 @@
#include "llcombobox.h"
#include "llradiogroup.h"
-#include "lldaycyclemanager.h"
-#include "llenvmanager.h"
-#include "llwaterparammanager.h"
-#include "llwlparamset.h"
-#include "llwlparammanager.h"
+#include "llenvironment.h"
+
LLFloaterEnvironmentSettings::LLFloaterEnvironmentSettings(const LLSD &key)
: LLFloater(key)
@@ -66,16 +63,13 @@ BOOL LLFloaterEnvironmentSettings::postBuild()
mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLFloaterEnvironmentSettings::onSelectDayCyclePreset, this));
childSetCommitCallback("ok_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnOK, this), NULL);
- getChild<LLUICtrl>("ok_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance()));
childSetCommitCallback("cancel_btn", boost::bind(&LLFloaterEnvironmentSettings::onBtnCancel, this), NULL);
- getChild<LLUICtrl>("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance()));
setCloseCallback(boost::bind(&LLFloaterEnvironmentSettings::cancel, this));
- LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::refresh, this));
- LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this));
- LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this));
- LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this));
+ LLEnvironment::instance().setSkyListChange(boost::bind(&LLFloaterEnvironmentSettings::populateSkyPresetsList, this));
+ LLEnvironment::instance().setWaterListChange(boost::bind(&LLFloaterEnvironmentSettings::populateWaterPresetsList, this));
+ LLEnvironment::instance().setDayCycleListChange(boost::bind(&LLFloaterEnvironmentSettings::populateDayCyclePresetsList, this));
return TRUE;
}
@@ -86,6 +80,14 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key)
refresh();
}
+//virtual
+void LLFloaterEnvironmentSettings::onClose(bool app_quitting)
+{
+ if (!app_quitting)
+ LLEnvironment::instance().updateEnvironment();
+}
+
+
void LLFloaterEnvironmentSettings::onSwitchRegionSettings()
{
getChild<LLView>("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0);
@@ -120,6 +122,42 @@ void LLFloaterEnvironmentSettings::onSelectDayCyclePreset()
void LLFloaterEnvironmentSettings::onBtnOK()
{
+ bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
+
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ if (use_region_settings)
+ {
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_PARCEL);
+ }
+ else
+ {
+ bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
+
+ if (!use_fixed_sky)
+ {
+
+ std::string day_cycle = mDayCyclePresetCombo->getValue().asString();
+ LLSettingsDay::ptr_t day = LLEnvironment::instance().findDayCycleByName(day_cycle);
+ if (day)
+ {
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, day, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
+ }
+ }
+ else
+ {
+ std::string water_preset = mWaterPresetCombo->getValue().asString();
+ std::string sky_preset = mSkyPresetCombo->getValue().asString();
+
+ LLSettingsSky::ptr_t sky = LLEnvironment::instance().findSkyByName(sky_preset);
+ LLSettingsWater::ptr_t water = LLEnvironment::instance().findWaterByName(water_preset);
+
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::fixedEnvironment_t(sky, water));
+ }
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
+ }
+
+#if 0
// Save and apply new user preferences.
bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
@@ -135,7 +173,8 @@ void LLFloaterEnvironmentSettings::onBtnOK()
use_region_settings);
// *TODO: This triggers applying user preferences again, which is suboptimal.
- closeFloater();
+#endif
+ closeFloater();
}
void LLFloaterEnvironmentSettings::onBtnCancel()
@@ -145,10 +184,14 @@ void LLFloaterEnvironmentSettings::onBtnCancel()
void LLFloaterEnvironmentSettings::refresh()
{
- LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance();
+ LLEnvironment::fixedEnvironment_t fixed = LLEnvironment::instance().getEnvironmentFixed(LLEnvironment::ENV_EDIT);
- bool use_region_settings = env_mgr.getUseRegionSettings();
- bool use_fixed_sky = env_mgr.getUseFixedSky();
+ LLSettingsDay::ptr_t day = LLEnvironment::instance().getEnvironmentDay(LLEnvironment::ENV_EDIT);
+ LLSettingsSky::ptr_t sky = fixed.first;
+ LLSettingsWater::ptr_t water = fixed.second;
+
+ bool use_region_settings = true;
+ bool use_fixed_sky = !day;
// Set up radio buttons according to user preferences.
mRegionSettingsRadioGroup->setSelectedIndex(use_region_settings ? 0 : 1);
@@ -165,9 +208,18 @@ void LLFloaterEnvironmentSettings::refresh()
mDayCyclePresetCombo->setEnabled(!use_fixed_sky);
// Select the current presets in combo boxes.
- mWaterPresetCombo->selectByValue(env_mgr.getWaterPresetName());
- mSkyPresetCombo->selectByValue(env_mgr.getSkyPresetName());
- mDayCyclePresetCombo->selectByValue(env_mgr.getDayCycleName());
+ if (water)
+ mWaterPresetCombo->selectByValue(water->getName());
+ else
+ mWaterPresetCombo->selectByValue(LLSD());
+ if (sky)
+ mSkyPresetCombo->selectByValue(sky->getName());
+ else
+ mSkyPresetCombo->selectByValue(LLSD());
+ if (day)
+ mDayCyclePresetCombo->selectByValue(day->getName());
+ else
+ mDayCyclePresetCombo->selectByValue(LLSD());
}
void LLFloaterEnvironmentSettings::apply()
@@ -175,108 +227,73 @@ void LLFloaterEnvironmentSettings::apply()
// Update environment with the user choice.
bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
- std::string water_preset = mWaterPresetCombo->getValue().asString();
- std::string sky_preset = mSkyPresetCombo->getValue().asString();
+ std::string water_preset = mWaterPresetCombo->getValue().asString();
+ std::string sky_preset = mSkyPresetCombo->getValue().asString();
std::string day_cycle = mDayCyclePresetCombo->getValue().asString();
- LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance();
if (use_region_settings)
{
- env_mgr.useRegionSettings();
+ //env_mgr.useRegionSettings();
}
else
{
if (use_fixed_sky)
{
- env_mgr.useSkyPreset(sky_preset);
- }
+ LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(sky_preset);
+ if (psky)
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ }
else
{
- env_mgr.useDayCycle(day_cycle, LLEnvKey::SCOPE_LOCAL);
- }
-
- env_mgr.useWaterPreset(water_preset);
+ LLSettingsDay::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle);
+ if (pday)
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, pday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
+ }
+
+ LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset);
+ if (pwater)
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, pwater);
}
}
void LLFloaterEnvironmentSettings::cancel()
{
// Revert environment to user preferences.
- LLEnvManagerNew::instance().usePrefs();
+// LLEnvManagerNew::instance().usePrefs();
}
void LLFloaterEnvironmentSettings::populateWaterPresetsList()
{
- mWaterPresetCombo->removeall();
-
- std::list<std::string> user_presets, system_presets;
- LLWaterParamManager::instance().getPresetNames(user_presets, system_presets);
+ mWaterPresetCombo->removeall();
- // Add user presets first.
- for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it)
- {
- mWaterPresetCombo->add(*it);
- }
-
- if (user_presets.size() > 0)
- {
- mWaterPresetCombo->addSeparator();
- }
+ LLEnvironment::list_name_id_t list = LLEnvironment::instance().getWaterList();
- // Add system presets.
- for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it)
- {
- mWaterPresetCombo->add(*it);
- }
+ for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it)
+ {
+ mWaterPresetCombo->add((*it).first, LLSD::String((*it).first)); //
+ }
}
void LLFloaterEnvironmentSettings::populateSkyPresetsList()
{
mSkyPresetCombo->removeall();
- LLWLParamManager::preset_name_list_t region_presets; // unused as we don't list region presets here
- LLWLParamManager::preset_name_list_t user_presets, sys_presets;
- LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets);
-
- // Add user presets.
- for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it)
- {
- mSkyPresetCombo->add(*it);
- }
-
- if (!user_presets.empty())
- {
- mSkyPresetCombo->addSeparator();
- }
+ LLEnvironment::list_name_id_t list = LLEnvironment::instance().getSkyList();
- // Add system presets.
- for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it)
- {
- mSkyPresetCombo->add(*it);
- }
+ for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it)
+ {
+ mSkyPresetCombo->add((*it).first, LLSD::String((*it).first));
+ }
}
void LLFloaterEnvironmentSettings::populateDayCyclePresetsList()
{
mDayCyclePresetCombo->removeall();
- LLDayCycleManager::preset_name_list_t user_days, sys_days;
- LLDayCycleManager::instance().getPresetNames(user_days, sys_days);
+ LLEnvironment::list_name_id_t list = LLEnvironment::instance().getDayCycleList();
- // Add user days.
- for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it)
- {
- mDayCyclePresetCombo->add(*it);
- }
-
- if (user_days.size() > 0)
- {
- mDayCyclePresetCombo->addSeparator();
- }
-
- // Add system days.
- for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it)
- {
- mDayCyclePresetCombo->add(*it);
- }
+ for (LLEnvironment::list_name_id_t::iterator it = list.begin(); it != list.end(); ++it)
+ {
+ mDayCyclePresetCombo->add((*it).first, LLSD::String((*it).first));
+ }
}