diff options
Diffstat (limited to 'indra/newview/llfloaterpreference.cpp')
-rw-r--r-- | indra/newview/llfloaterpreference.cpp | 161 |
1 files changed, 106 insertions, 55 deletions
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 64961fc99c..927124f333 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -702,7 +702,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 @@ -821,7 +821,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); @@ -830,16 +831,23 @@ 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"); - collectSearchableItems(); - if (!mFilterEdit->getText().empty()) + if (load_camera_btn && save_camera_btn && delete_camera_btn) { - mFilterEdit->setText(LLStringExplicit("")); - onUpdateFilterTerm(true); + load_camera_btn->setEnabled(started); + save_camera_btn->setEnabled(started); + delete_camera_btn->setEnabled(started); } } @@ -2021,45 +2029,6 @@ void LLFloaterPreference::updateMaxComplexity() getChild<LLTextBox>("IndirectMaxComplexityText")); } -bool LLFloaterPreference::loadFromFilename(const std::string& filename, std::map<std::string, std::string> &label_map) -{ - LLXMLNodePtr root; - - if (!LLXMLNode::parseFile(filename, root, NULL)) - { - LL_WARNS() << "Unable to parse file " << filename << LL_ENDL; - return false; - } - - if (!root->hasName("labels")) - { - LL_WARNS() << filename << " is not a valid definition file" << LL_ENDL; - return false; - } - - LabelTable params; - LLXUIParser parser; - parser.readXUI(root, params, filename); - - if (params.validateBlock()) - { - for (LLInitParam::ParamIterator<LabelDef>::const_iterator it = params.labels.begin(); - it != params.labels.end(); - ++it) - { - LabelDef label_entry = *it; - label_map[label_entry.name] = label_entry.value; - } - } - else - { - LL_WARNS() << filename << " failed to load" << LL_ENDL; - return false; - } - - return true; -} - void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity() { // Called when the IndirectMaxComplexity control changes @@ -2293,6 +2262,11 @@ void LLFloaterPreference::changed() } +void LLFloaterPreference::saveCameraPreset(std::string& preset) +{ + mSavedCameraPreset = preset; +} + void LLFloaterPreference::saveGraphicsPreset(std::string& preset) { mSavedGraphicsPreset = preset; @@ -2609,18 +2583,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); } @@ -2668,6 +2648,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() { @@ -2679,7 +2735,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(); } @@ -2700,11 +2756,6 @@ void LLPanelPreferenceGraphics::onPresetsListChange() { instance->saveSettings(); //make cancel work correctly after changing the preset } - else - { - std::string dummy; - instance->saveGraphicsPreset(dummy); - } } void LLPanelPreferenceGraphics::setPresetText() |