diff options
Diffstat (limited to 'indra/newview/llfloaterpreference.cpp')
-rw-r--r-- | indra/newview/llfloaterpreference.cpp | 116 |
1 files changed, 109 insertions, 7 deletions
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 4ce35643b1..83e54c6465 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -661,7 +661,7 @@ void LLFloaterPreference::cancel() // hide spellchecker settings folder LLFloaterReg::hideInstance("prefs_spellchecker"); - // hide advancede floater + // hide advanced graphics floater LLFloaterReg::hideInstance("prefs_graphics_advanced"); // reverts any changes to current skin @@ -780,7 +780,8 @@ void LLFloaterPreference::onOpen(const LLSD& key) saveSettings(); // Make sure there is a default preference file - LLPresetsManager::getInstance()->createMissingDefault(); + LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA); + LLPresetsManager::getInstance()->createMissingDefault(PRESETS_GRAPHIC); bool started = (LLStartUp::getStartupState() == STATE_STARTED); @@ -789,10 +790,24 @@ void LLFloaterPreference::onOpen(const LLSD& key) LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton"); LLButton* exceptions_btn = findChild<LLButton>("RenderExceptionsButton"); - load_btn->setEnabled(started); - save_btn->setEnabled(started); - delete_btn->setEnabled(started); - exceptions_btn->setEnabled(started); + if (load_btn && save_btn && delete_btn && exceptions_btn) + { + load_btn->setEnabled(started); + save_btn->setEnabled(started); + delete_btn->setEnabled(started); + exceptions_btn->setEnabled(started); + } + + LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton"); + LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton"); + LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton"); + + if (load_camera_btn && save_camera_btn && delete_camera_btn) + { + load_camera_btn->setEnabled(started); + save_camera_btn->setEnabled(started); + delete_camera_btn->setEnabled(started); + } } void LLFloaterPreference::onVertexShaderEnable() @@ -2206,6 +2221,11 @@ void LLFloaterPreference::changed() } +void LLFloaterPreference::saveCameraPreset(std::string& preset) +{ + mSavedCameraPreset = preset; +} + void LLFloaterPreference::saveGraphicsPreset(std::string& preset) { mSavedGraphicsPreset = preset; @@ -2493,18 +2513,24 @@ void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl) void LLPanelPreference::deletePreset(const LLSD& user_data) { std::string subdirectory = user_data.asString(); + LLFloaterReg::hideInstance("load_pref_preset", subdirectory); + LLFloaterReg::hideInstance("save_pref_preset", subdirectory); LLFloaterReg::showInstance("delete_pref_preset", subdirectory); } void LLPanelPreference::savePreset(const LLSD& user_data) { std::string subdirectory = user_data.asString(); + LLFloaterReg::hideInstance("delete_pref_preset", subdirectory); + LLFloaterReg::hideInstance("load_pref_preset", subdirectory); LLFloaterReg::showInstance("save_pref_preset", subdirectory); } void LLPanelPreference::loadPreset(const LLSD& user_data) { std::string subdirectory = user_data.asString(); + LLFloaterReg::hideInstance("delete_pref_preset", subdirectory); + LLFloaterReg::hideInstance("save_pref_preset", subdirectory); LLFloaterReg::showInstance("load_pref_preset", subdirectory); } @@ -2552,6 +2578,82 @@ private: static LLPanelInjector<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics"); static LLPanelInjector<LLPanelPreferencePrivacy> t_pref_privacy("panel_preference_privacy"); +static LLPanelInjector<LLPanelPreferenceView> t_pref_view("panel_preference_view"); + +BOOL LLPanelPreferenceView::postBuild() +{ + setPresetText(); + + LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); + if (presetsMgr) + { + presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this)); + presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok + } + + return LLPanelPreference::postBuild(); +} + +void LLPanelPreferenceView::onPresetsListChangeCamera() +{ + LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); + if (presetsMgr) + { + presetsMgr->setCameraDirty(false); + } + + setPresetText(); + + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance && !gSavedSettings.getString("PresetCameraActive").empty()) + { + instance->saveSettings(); //make cancel work correctly after changing the preset + } +} + +void LLPanelPreferenceView::draw() +{ + setPresetText(); + LLPanelPreference::draw(); +} + +void LLPanelPreferenceView::setPresetText() +{ + LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text"); + + std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive"); + + if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText()) + { + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); + if (instance) + { + instance->saveCameraPreset(preset_camera_active); + } + } + + LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); + if (presetsMgr) + { + if (presetsMgr->isCameraDirty() && !preset_camera_active.empty()) + { + preset_camera_active.clear(); + } + } + + if (!preset_camera_active.empty()) + { + if (preset_camera_active == PRESETS_DEFAULT) + { + preset_camera_active = LLTrans::getString(PRESETS_DEFAULT); + } + preset_text->setText(preset_camera_active); + } + else + { + preset_text->setText(LLTrans::getString("none_paren_cap")); + } +} BOOL LLPanelPreferenceGraphics::postBuild() { @@ -2563,7 +2665,7 @@ BOOL LLPanelPreferenceGraphics::postBuild() LLPresetsManager* presetsMgr = LLPresetsManager::getInstance(); presetsMgr->setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this)); - presetsMgr->createMissingDefault(); // a no-op after the first time, but that's ok + presetsMgr->createMissingDefault(PRESETS_GRAPHIC); // a no-op after the first time, but that's ok return LLPanelPreference::postBuild(); } |