diff options
Diffstat (limited to 'indra/newview/llfloaterregioninfo.cpp')
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 242 |
1 files changed, 181 insertions, 61 deletions
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 6a5b577396..ee3d00206f 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -1124,7 +1124,7 @@ F32 LLPanelRegionTerrainInfo::getSunHour() // virtual bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) { - LLEnvManager::instance().maybeClearEditingScope(LLEnvKey::SCOPE_REGION, false, false); + //LLEnvManager::instance().maybeClearEditingScope(LLEnvKey::SCOPE_REGION, false, false); BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); @@ -2088,7 +2088,7 @@ void LLFloaterRegionInfo::onClose(bool app_quitting) { if(!app_quitting) { - LLEnvManager::getInstance()->maybeClearEditingScope(true, false); + //LLEnvManager::getInstance()->maybeClearEditingScope(true, false); LLPanelRegionTerrainInfo::onFloaterClose(app_quitting); } } @@ -3198,10 +3198,15 @@ BOOL LLPanelEnvironmentInfo::postBuild() mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDayCycle, this)); mWaterPresetCombo = getChild<LLComboBox>("water_settings_preset_combo"); + mWaterPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectWaterPreset, this)); + mSkyPresetCombo = getChild<LLComboBox>("sky_settings_preset_combo"); + mSkyPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectSkyPreset, this)); + mDayCyclePresetCombo = getChild<LLComboBox>("dayc_settings_preset_combo"); + mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); - childSetCommitCallback("save_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnSave, this), NULL); + childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); @@ -3218,6 +3223,17 @@ void LLPanelEnvironmentInfo::onOpen(const LLSD& key) } // virtual +void LLPanelEnvironmentInfo::handleVisibilityChange(BOOL new_visibility) +{ + // If hiding (user switched to another tab or closed the floater), + // display user's preferred environment. + if (!new_visibility) + { + LLEnvManagerNew::instance().usePrefs(); + } +} + +// virtual bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) { LL_DEBUGS("Windlight") << "Region updated, enabling/disabling controls" << LL_ENDL; @@ -3257,14 +3273,18 @@ void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) mSkyPresetCombo->setEnabled(enabled); mDayCyclePresetCombo->setEnabled(enabled); - getChildView("save_btn")->setEnabled(enabled); + getChildView("apply_btn")->setEnabled(enabled); getChildView("cancel_btn")->setEnabled(enabled); if (enabled) { // Enable/disable some controls based on currently selected radio buttons. - LLPanelEnvironmentInfo::onSwitchRegionSettings(); - LLPanelEnvironmentInfo::onSwitchDayCycle(); + bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); + + bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + mSkyPresetCombo->setEnabled(is_fixed_sky); + mDayCyclePresetCombo->setEnabled(!is_fixed_sky); } } @@ -3367,9 +3387,97 @@ void LLPanelEnvironmentInfo::populateDayCyclesList() // Current day cycle is already selected. } +bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params) +{ + LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); + + if (water_key.scope == LLEnvKey::SCOPE_REGION) + { + water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams(); + } + else + { + LLWaterParamSet param_set; + if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) + { + llwarns << "Error getting water preset: " << water_key.name << llendl; + return false; + } + + water_params = param_set.getAll(); + } + + return true; +} + +bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& preset_name) +{ + std::string preset_key(mSkyPresetCombo->getValue().asString()); + LLWLParamKey preset(preset_key); + + // Get the preset sky params. + LLWLParamSet param_set; + if (!LLWLParamManager::instance().getParamSet(preset, param_set)) + { + llwarns << "Error getting sky params: " << preset.toLLSD() << llendl; + return false; + } + + sky_params = param_set.getAll(); + preset_name = preset.name; + return true; +} + +bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope) +{ + std::string preset_key(mDayCyclePresetCombo->getValue().asString()); + LLWLParamKey dc(preset_key); + LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; + + if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle + { + const LLEnvironmentSettings& cur_region_settings = LLEnvManagerNew::instance().getRegionSettings(); + day_cycle = cur_region_settings.getWLDayCycle(); + sky_map = cur_region_settings.getSkyMap(); + } + else // a local day cycle + { + if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) + { + llwarns << "Error getting day cycle " << dc.name << llendl; + return false; + } + + // Create sky map from the day cycle. + { + std::map<LLWLParamKey, LLWLParamSet> refs; + LLWLDayCycle tmp_day; + + tmp_day.loadDayCycle(day_cycle, dc.scope); + tmp_day.getSkyRefs(refs); + + sky_map = LLWLParamManager::createSkyMap(refs); + } + } + + scope = dc.scope; + + return true; +} void LLPanelEnvironmentInfo::onSwitchRegionSettings() { - getChild<LLView>("user_environment_settings")->setEnabled(mRegionSettingsRadioGroup->getSelectedIndex() != 0); + bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); + + if (use_defaults) + { + LLEnvManagerNew::instance().useDefaults(); + } + else + { + onSelectWaterPreset(); + onSwitchDayCycle(); + } } void LLPanelEnvironmentInfo::onSwitchDayCycle() @@ -3378,13 +3486,52 @@ void LLPanelEnvironmentInfo::onSwitchDayCycle() mSkyPresetCombo->setEnabled(is_fixed_sky); mDayCyclePresetCombo->setEnabled(!is_fixed_sky); + + if (is_fixed_sky) + { + onSelectSkyPreset(); + } + else + { + onSelectDayCycle(); + } +} + +void LLPanelEnvironmentInfo::onSelectWaterPreset() +{ + LLSD water_params; + + if (getSelectedWaterParams(water_params)) + { + LLEnvManagerNew::instance().useWaterParams(water_params); + } } -void LLPanelEnvironmentInfo::onBtnSave() +void LLPanelEnvironmentInfo::onSelectSkyPreset() { - LL_DEBUGS("Windlight") << "About to save region settings" << LL_ENDL; + LLSD params; + std::string dummy; + + if (getSelectedSkyParams(params, dummy)) + { + LLEnvManagerNew::instance().useSkyParams(params); + } +} + +void LLPanelEnvironmentInfo::onSelectDayCycle() +{ + LLSD day_cycle; + LLSD sky_map; // unused + short scope; - const LLEnvironmentSettings& old_region_settings = LLEnvManagerNew::instance().getRegionSettings(); + if (getSelectedDayCycleParams(day_cycle, sky_map, scope)) + { + LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); + } +} + +void LLPanelEnvironmentInfo::onBtnApply() +{ const bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; const bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; @@ -3402,79 +3549,44 @@ void LLPanelEnvironmentInfo::onBtnSave() if (use_fixed_sky) { LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL; - std::string preset_key(mSkyPresetCombo->getValue().asString()); - LLWLParamKey preset(preset_key); - // Get the preset sky params. - LLWLParamSet params; - if (!LLWLParamManager::instance().getParamSet(preset, params)) + // Get selected sky params. + LLSD params; + std::string preset_name; + if (!getSelectedSkyParams(params, preset_name)) { - llwarns << "Error getting sky params: " << preset.toLLSD() << llendl; return; } // Create a day cycle consisting of a single sky preset. LLSD key(LLSD::emptyArray()); key.append(-1.0f); // indicate that user preference is actually fixed sky, not a day cycle - key.append(preset.name); + key.append(preset_name); day_cycle.append(key); // Create a sky map consisting of only the sky preset. std::map<LLWLParamKey, LLWLParamSet> refs; - refs[preset] = params; + LLWLParamSet param_set; + param_set.setAll(params); + refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here sky_map = LLWLParamManager::createSkyMap(refs); } else // use day cycle { - std::string preset_key(mDayCyclePresetCombo->getValue().asString()); - LLWLParamKey dc(preset_key); - LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; + LL_DEBUGS("Windlight") << "Use day cycle" << LL_ENDL; - if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle - { - day_cycle = old_region_settings.getWLDayCycle(); - sky_map = old_region_settings.getSkyMap(); - } - else // a local day cycle + short scope; // unused + if (!getSelectedDayCycleParams(day_cycle, sky_map, scope)) { - if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) - { - llwarns << "Error getting day cycle " << dc.name << llendl; - return; - } - - // Create sky map from the day cycle. - { - std::map<LLWLParamKey, LLWLParamSet> refs; - LLWLDayCycle tmp_day; - - tmp_day.loadDayCycle(day_cycle, dc.scope); - tmp_day.getSkyRefs(refs); - - sky_map = LLWLParamManager::createSkyMap(refs); - } - - LL_DEBUGS("Windlight") << "day_cycle: " << day_cycle << LL_ENDL; - LL_DEBUGS("Windlight") << "sky_map: " << sky_map << LL_ENDL; + return; } } // Get water params. - LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); - if (water_key.scope == LLEnvKey::SCOPE_REGION) - { - water_params = old_region_settings.getWaterParams(); - } - else + if (!getSelectedWaterParams(water_params)) { - LLWaterParamSet param_set; - if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) - { - llwarns << "Error getting water preset: " << water_key.name << llendl; - return; - } - - water_params = param_set.getAll(); + // *TODO: show a notification? + return; } } @@ -3492,8 +3604,16 @@ void LLPanelEnvironmentInfo::onBtnSave() void LLPanelEnvironmentInfo::onBtnCancel() { - // Reload current region settings. + // Reload last saved region settings. refresh(); + + // Apply them. + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + const LLEnvironmentSettings& cur_settings = env_mgr.getRegionSettings(); + const LLSD& region_day_cycle = cur_settings.getWLDayCycle(); + const LLSD& region_water = cur_settings.getWaterParams(); + env_mgr.useWaterParams(region_water); + env_mgr.useDayCycleParams(region_day_cycle, LLEnvKey::SCOPE_REGION); } void LLPanelEnvironmentInfo::onRegionSettingschange() |