diff options
author | Jonathan Yap <jhwelch@gmail.com> | 2014-11-30 11:24:22 -0500 |
---|---|---|
committer | Jonathan Yap <jhwelch@gmail.com> | 2014-11-30 11:24:22 -0500 |
commit | 563e22e81c6bf14bca6370b098a257f94f4f843f (patch) | |
tree | 4835333aa4dadfbc1ce37224ed40f6b2a12bc56b /indra/newview | |
parent | 34a79a6ece28fbc560bde907142ecaadf95e910f (diff) |
STORM-2082 Make code more generic to handle the future camera presets.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterdeleteprefpreset.cpp | 9 | ||||
-rw-r--r-- | indra/newview/llfloaterdeleteprefpreset.h | 2 | ||||
-rwxr-xr-x | indra/newview/llfloaterpreference.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llpresetsmanager.cpp | 122 | ||||
-rw-r--r-- | indra/newview/llpresetsmanager.h | 12 |
5 files changed, 75 insertions, 76 deletions
diff --git a/indra/newview/llfloaterdeleteprefpreset.cpp b/indra/newview/llfloaterdeleteprefpreset.cpp index 5dc51c4223..bef5b4e3bf 100644 --- a/indra/newview/llfloaterdeleteprefpreset.cpp +++ b/indra/newview/llfloaterdeleteprefpreset.cpp @@ -49,14 +49,14 @@ BOOL LLFloaterDeletePrefPreset::postBuild() void LLFloaterDeletePrefPreset::onOpen(const LLSD& key) { - std::string param = key.asString(); - std::string floater_title = getString(std::string("title_") + param); + std::string mSubdirectory = key.asString(); + std::string floater_title = getString(std::string("title_") + mSubdirectory); setTitle(floater_title); LLComboBox* combo = getChild<LLComboBox>("preset_combo"); - LLPresetsManager::getInstance()->setPresetNamesInComboBox(combo); + LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo); } void LLFloaterDeletePrefPreset::onBtnDelete() @@ -64,6 +64,7 @@ void LLFloaterDeletePrefPreset::onBtnDelete() LLComboBox* combo = getChild<LLComboBox>("preset_combo"); std::string name = combo->getSimple(); + // Ignore return status LLPresetsManager::getInstance()->deletePreset(name); } @@ -71,7 +72,7 @@ void LLFloaterDeletePrefPreset::onPresetsListChange() { LLComboBox* combo = getChild<LLComboBox>("preset_combo"); - LLPresetsManager::getInstance()->setPresetNamesInComboBox(combo); + LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo); } void LLFloaterDeletePrefPreset::onBtnCancel() diff --git a/indra/newview/llfloaterdeleteprefpreset.h b/indra/newview/llfloaterdeleteprefpreset.h index fc531ca1b7..356bc1a437 100644 --- a/indra/newview/llfloaterdeleteprefpreset.h +++ b/indra/newview/llfloaterdeleteprefpreset.h @@ -46,6 +46,8 @@ public: private: void onPresetsListChange(); + + std::string mSubdirectory; }; #endif // LL_LLFLOATERDELETEPREFPRESET_H diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 6b798f6549..508d82522e 100755 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -749,7 +749,9 @@ void LLFloaterPreference::onOpen(const LLSD& key) { LL_WARNS() << "No " << default_file << " found -- creating one" << LL_ENDL; // Write current graphic settings to default.xml - LLPresetsManager::getInstance()->savePreset("Default"); + // If this name is to be localized additional code will be needed to delete the old default + // when changing languages. + LLPresetsManager::getInstance()->savePreset(PRESETS_GRAPHIC, "Default"); } } @@ -2160,7 +2162,7 @@ void LLPanelPreferenceGraphics::setPresetNamesInComboBox() { LLComboBox* combo = getChild<LLComboBox>("graphic_preset_combo"); - LLPresetsManager::getInstance()->setPresetNamesInComboBox(combo); + LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_GRAPHIC, combo); } void LLPanelPreferenceGraphics::draw() diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 6b0023d97a..6e00a90ae5 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -45,7 +45,8 @@ LLPresetsManager::~LLPresetsManager() { } -std::string LLPresetsManager::getUserDir(const std::string& subdirectory) +//std::string LLPresetsManager::getUserDir(const std::string& subdirectory) +std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory) { std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, PRESETS_DIR); std::string full_path; @@ -64,22 +65,7 @@ std::string LLPresetsManager::getUserDir(const std::string& subdirectory) return full_path; } -std::string LLPresetsManager::getCameraPresetsDir() -{ - return getUserDir(PRESETS_CAMERA); -} - -std::string LLPresetsManager::getGraphicPresetsDir() -{ - return getUserDir(PRESETS_GRAPHIC); -} - -void LLPresetsManager::getPresetNames(preset_name_list_t& presets) const -{ - presets = mPresetNames; -} - -void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir) +void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets) { LL_INFOS("AppInit") << "Loading presets from " << dir << LL_ENDL; @@ -106,48 +92,61 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir) } } } + + presets = mPresetNames; } -void LLPresetsManager::savePreset(const std::string& name) +void LLPresetsManager::savePreset(const std::string& subdirectory, const std::string& name) { llassert(!name.empty()); + std::vector<std::string> name_list; // This ugliness is the current list of all the control variables in the graphics and hardware - // preferences floaters. Additions or subtractions to the floaters must also be reflected here. - std::vector<std::string> name_list = boost::assign::list_of - ("RenderQualityPerformance") - ("RenderFarClip") - ("RenderMaxPartCount") - ("RenderGlowResolutionPow") - ("RenderTerrainDetail") - ("RenderAvatarLODFactor") - ("RenderAvatarMaxVisible") - ("RenderUseImpostors") - ("RenderTerrainLODFactor") - ("RenderTreeLODFactor") - ("RenderVolumeLODFactor") - ("RenderFlexTimeFactor") - ("RenderTransparentWater") - ("RenderObjectBump") - ("RenderLocalLights") - ("VertexShaderEnable") - ("RenderAvatarVP") - ("RenderAvatarCloth") - ("RenderReflectionDetail") - ("WindLightUseAtmosShaders") - ("WLSkyDetail") - ("RenderDeferred") - ("RenderDeferredSSAO") - ("RenderDepthOfField") - ("RenderShadowDetail") - - ("RenderAnisotropic") - ("RenderFSAASamples") - ("RenderGamma") - ("RenderVBOEnable") - ("RenderCompressTextures") - ("TextureMemory") - ("RenderFogRatio"); + // preferences floaters or the settings for camera views. + // Additions or subtractions to the control variables in the floaters must also be reflected here. + if(PRESETS_GRAPHIC == subdirectory) + { + name_list = boost::assign::list_of + ("RenderQualityPerformance") + ("RenderFarClip") + ("RenderMaxPartCount") + ("RenderGlowResolutionPow") + ("RenderTerrainDetail") + ("RenderAvatarLODFactor") + ("RenderAvatarMaxVisible") + ("RenderUseImpostors") + ("RenderTerrainLODFactor") + ("RenderTreeLODFactor") + ("RenderVolumeLODFactor") + ("RenderFlexTimeFactor") + ("RenderTransparentWater") + ("RenderObjectBump") + ("RenderLocalLights") + ("VertexShaderEnable") + ("RenderAvatarVP") + ("RenderAvatarCloth") + ("RenderReflectionDetail") + ("WindLightUseAtmosShaders") + ("WLSkyDetail") + ("RenderDeferred") + ("RenderDeferredSSAO") + ("RenderDepthOfField") + ("RenderShadowDetail") + + ("RenderAnisotropic") + ("RenderFSAASamples") + ("RenderGamma") + ("RenderVBOEnable") + ("RenderCompressTextures") + ("TextureMemory") + ("RenderFogRatio"); + } + + if(PRESETS_CAMERA == subdirectory) + { + name_list = boost::assign::list_of + ("Placeholder"); + } // make an empty llsd LLSD paramsData(LLSD::emptyMap()); @@ -166,7 +165,7 @@ void LLPresetsManager::savePreset(const std::string& name) paramsData[ctrl_name]["Value"] = value; } - std::string pathName(getUserDir(PRESETS_GRAPHIC) + "\\" + LLURI::escape(name) + ".xml"); + std::string pathName(getPresetsDir(subdirectory) + "\\" + LLURI::escape(name) + ".xml"); // write to file llofstream presetsXML(pathName); @@ -178,17 +177,16 @@ void LLPresetsManager::savePreset(const std::string& name) mPresetListChangeSignal(); } -void LLPresetsManager::setPresetNamesInComboBox(LLComboBox* combo) +void LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo) { combo->clearRows(); - std::string presets_dir = getGraphicPresetsDir(); + std::string presets_dir = getPresetsDir(subdirectory); if (!presets_dir.empty()) { - loadPresetNamesFromDir(presets_dir); std::list<std::string> preset_names; - getPresetNames(preset_names); + loadPresetNamesFromDir(presets_dir, preset_names); combo->setLabel(LLTrans::getString("preset_combo_label")); @@ -206,9 +204,9 @@ void LLPresetsManager::setPresetNamesInComboBox(LLComboBox* combo) void LLPresetsManager::loadPreset(const std::string& name) { - std::string pathName(getUserDir(PRESETS_GRAPHIC) + "\\" + LLURI::escape(name) + ".xml"); + std::string full_path(getPresetsDir(PRESETS_GRAPHIC) + "\\" + LLURI::escape(name) + ".xml"); - gSavedSettings.loadFromFile(pathName, false, true); + gSavedSettings.loadFromFile(full_path, false, true); } bool LLPresetsManager::deletePreset(const std::string& name) @@ -221,10 +219,10 @@ bool LLPresetsManager::deletePreset(const std::string& name) return false; } - // (*TODO Should the name be escaped here? - if (gDirUtilp->deleteFilesInDir(getUserDir(PRESETS_GRAPHIC), name + ".xml") < 1) + if (gDirUtilp->deleteFilesInDir(getPresetsDir(PRESETS_GRAPHIC), LLURI::escape(name) + ".xml") < 1) { LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL; + return false; } else { diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h index 128c5850f2..3a2542bda0 100644 --- a/indra/newview/llpresetsmanager.h +++ b/indra/newview/llpresetsmanager.h @@ -42,13 +42,11 @@ public: typedef std::list<std::string> preset_name_list_t; typedef boost::signals2::signal<void()> preset_list_signal_t; - void setPresetNamesInComboBox(LLComboBox* combo); - void getPresetNames(preset_name_list_t& presets) const; - void loadPresetNamesFromDir(const std::string& dir); - void savePreset(const std::string & name); + static std::string getPresetsDir(const std::string& subdirectory); + void setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo); + void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets); + void savePreset(const std::string& subdirectory, const std::string & name); void loadPreset(const std::string & name); - static std::string getCameraPresetsDir(); - static std::string getGraphicPresetsDir(); bool deletePreset(const std::string& name); /// Emitted when a preset gets loaded or deleted. @@ -60,8 +58,6 @@ public: LLPresetsManager(); ~LLPresetsManager(); - static std::string getUserDir(const std::string& subdirectory); - preset_list_signal_t mPresetListChangeSignal; }; |