summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorJonathan Yap <jhwelch@gmail.com>2014-11-27 16:20:39 -0500
committerJonathan Yap <jhwelch@gmail.com>2014-11-27 16:20:39 -0500
commitf30e518f1774cc3c1b4641e97c26afa496fb85e5 (patch)
treea46d770586a32854df9a1305e503c346136737b4 /indra/newview
parentf71247ea542805819b82640759e1f44fd0599e7f (diff)
STORM-2082 Get writing out and loading presets working
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llfloaterpreference.cpp50
-rwxr-xr-xindra/newview/llfloaterpreference.h8
-rw-r--r--indra/newview/llpresetsmanager.cpp96
-rw-r--r--indra/newview/llpresetsmanager.h9
-rwxr-xr-xindra/newview/skins/default/xui/en/panel_preferences_graphics1.xml5
5 files changed, 137 insertions, 31 deletions
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 39f37f4e50..e8590fc9dc 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -109,6 +109,7 @@
#include "lllogininstance.h" // to check if logged in yet
#include "llsdserialize.h"
#include "llpresetsmanager.h"
+#include "llviewercontrol.h"
const F32 MAX_USER_FAR_CLIP = 512.f;
const F32 MIN_USER_FAR_CLIP = 64.f;
@@ -742,7 +743,13 @@ void LLFloaterPreference::onOpen(const LLSD& key)
saveSettings();
// Make sure there is a default preference file
-
+ std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, PRESETS_DIR, PRESETS_GRAPHIC_DIR, "default.xml");
+ if (!gDirUtilp->fileExists(default_file))
+ {
+ LL_WARNS() << "No " << default_file << " found -- creating one" << LL_ENDL;
+ // Write current graphic settings to default.xml
+ LLPresetsManager::getInstance()->savePreset("Default");
+ }
}
void LLFloaterPreference::onVertexShaderEnable()
@@ -1873,6 +1880,7 @@ LLPanelPreference::LLPanelPreference()
{
mCommitCallbackRegistrar.add("Pref.setControlFalse", boost::bind(&LLPanelPreference::setControlFalse,this, _2));
mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1));
+ mCommitCallbackRegistrar.add("Pref.Preset", boost::bind(&LLPanelPreference::onChangePreset, this));
}
//virtual
@@ -2070,6 +2078,19 @@ void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl)
}
}
+void LLPanelPreference::onChangePreset()
+{
+ LLComboBox* combo = getChild<LLComboBox>("graphic_preset_combo");
+ std::string name = combo->getSimple();
+
+ LLPresetsManager::getInstance()->loadPreset(name);
+ LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+ if (instance)
+ {
+ instance->refreshEnabledGraphics();
+ }
+}
+
class LLPanelPreferencePrivacy : public LLPanelPreference
{
public:
@@ -2113,28 +2134,43 @@ static LLPanelInjector<LLPanelPreferencePrivacy> t_pref_privacy("panel_preferenc
BOOL LLPanelPreferenceGraphics::postBuild()
{
- LLComboBox* graphic_preset = getChild<LLComboBox>("graphic_preset_combo");
- graphic_preset->setLabel(getString("graphic_preset_combo_label"));
+ LLComboBox* combo = getChild<LLComboBox>("graphic_preset_combo");
+ combo->setLabel(getString("graphic_preset_combo_label"));
+
+ setPresetNamesInCombobox();
+
+ LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this));
+
+ return LLPanelPreference::postBuild();
+}
+
+void LLPanelPreferenceGraphics::onPresetsListChange()
+{
+ setPresetNamesInCombobox();
+}
+
+void LLPanelPreferenceGraphics::setPresetNamesInCombobox()
+{
+ LLComboBox* combo = getChild<LLComboBox>("graphic_preset_combo");
+ combo->clearRows();
std::string presets_dir = LLPresetsManager::getGraphicPresetsDir();
if (!presets_dir.empty())
{
- LLPresetsManager::getInstance()->loadPresetsFromDir(presets_dir);
+ LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir);
std::list<std::string> preset_names;
LLPresetsManager::getInstance()->getPresetNames(preset_names);
for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
{
const std::string& name = *it;
- graphic_preset->add(name, LLSD().with(0, name));
+ combo->add(name, LLSD().with(0, name));
}
}
else {
LL_WARNS() << "Could not obtain graphic presets path" << LL_ENDL;
}
-
- return LLPanelPreference::postBuild();
}
void LLPanelPreferenceGraphics::draw()
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index 1b42444c9e..66442a0b51 100755
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -220,7 +220,9 @@ public:
// This function squirrels away the current values of the controls so that
// cancel() can restore them.
virtual void saveSettings();
-
+
+ void onChangePreset();
+
class Updater;
protected:
@@ -248,11 +250,13 @@ public:
void cancel();
void saveSettings();
void setHardwareDefaults();
+ void setPresetNamesInCombobox();
static const std::string getPresetsPath();
+
protected:
bool hasDirtyChilds();
void resetDirtyChilds();
-
+ void onPresetsListChange();
};
class LLFloaterPreferenceProxy : public LLFloater
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index d97e9312e2..8fd9024fef 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -26,17 +26,15 @@
#include "llviewerprecompiledheaders.h"
+#include <boost/assign/list_of.hpp>
+
#include "llpresetsmanager.h"
#include "lldiriterator.h"
-#include "lluictrlfactory.h"
#include "llsdserialize.h"
+#include "lluictrlfactory.h"
#include "llviewercontrol.h"
-static const std::string PRESETS_DIR = "presets";
-static const std::string GRAPHIC_DIR = "graphic";
-static const std::string CAMERA_DIR = "camera";
-
LLPresetsManager::LLPresetsManager()
{
}
@@ -66,7 +64,7 @@ std::string LLPresetsManager::getUserDir(const std::string& subdirectory)
std::string LLPresetsManager::getGraphicPresetsDir()
{
- return getUserDir(GRAPHIC_DIR);
+ return getUserDir(PRESETS_GRAPHIC_DIR);
}
void LLPresetsManager::getPresetNames(preset_name_list_t& presets) const
@@ -75,43 +73,103 @@ void LLPresetsManager::getPresetNames(preset_name_list_t& presets) const
}
-void LLPresetsManager::loadPresetsFromDir(const std::string& dir)
+void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir)
{
LL_INFOS("AppInit") << "Loading presets from " << dir << LL_ENDL;
mPresetNames.clear();
LLDirIterator dir_iter(dir, "*.xml");
- while (1)
+ bool found = true;
+ while (found)
{
std::string file;
- if (!dir_iter.next(file))
+ found = dir_iter.next(file);
+
+ if (found)
{
- break; // no more files
+ std::string path = gDirUtilp->add(dir, file);
+ std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true));
+ mPresetNames.push_back(name);
}
-
- std::string path = gDirUtilp->add(dir, file);
- std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true));
- mPresetNames.push_back(name);
}
}
-void LLPresetsManager::savePreset(const std::string & name)
+void LLPresetsManager::savePreset(const std::string& name)
{
llassert(!name.empty());
+ // 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");
+
// make an empty llsd
LLSD paramsData(LLSD::emptyMap());
- std::string pathName(getUserDir(GRAPHIC_DIR) + LLURI::escape(name) + ".xml");
-// Get all graphic settings
-// paramsData = mParamList[name].getAll();
+ for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
+ {
+ std::string ctrl_name = *it;
+ LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
+ std::string comment = ctrl->getComment();
+ std::string type = gSavedSettings.typeEnumToString(ctrl->type());
+ LLSD value = ctrl->getValue();
+
+ paramsData[ctrl_name]["Comment"] = comment;
+ paramsData[ctrl_name]["Persist"] = 1;
+ paramsData[ctrl_name]["Type"] = type;
+ paramsData[ctrl_name]["Value"] = value;
+ }
+
+ std::string pathName(getUserDir(PRESETS_GRAPHIC_DIR) + "\\" + LLURI::escape(name) + ".xml");
// write to file
llofstream presetsXML(pathName);
LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
presetsXML.close();
+
+ // signal interested parties
+ mPresetListChangeSignal();
+}
+
+void LLPresetsManager::loadPreset(const std::string& name)
+{
+ std::string pathName(getUserDir(PRESETS_GRAPHIC_DIR) + "\\" + LLURI::escape(name) + ".xml");
+
+ gSavedSettings.loadFromFile(pathName, false, true);
}
bool LLPresetsManager::removeParamSet(const std::string& name, bool delete_from_disk)
@@ -129,7 +187,7 @@ bool LLPresetsManager::removeParamSet(const std::string& name, bool delete_from_
// remove from file system if requested
if (delete_from_disk)
{
- if (gDirUtilp->deleteFilesInDir(getUserDir(GRAPHIC_DIR), LLURI::escape(name) + ".xml") < 1)
+ if (gDirUtilp->deleteFilesInDir(getUserDir(PRESETS_GRAPHIC_DIR), LLURI::escape(name) + ".xml") < 1)
{
LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL;
}
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index b9a79a7736..5bf85b835a 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -30,6 +30,10 @@
#include <list>
#include <map>
+static const std::string PRESETS_DIR = "presets";
+static const std::string PRESETS_GRAPHIC_DIR = "graphic";
+static const std::string PRESETS_CAMERA_DIR = "camera";
+
class LLPresetsManager : public LLSingleton<LLPresetsManager>
{
public:
@@ -37,12 +41,13 @@ public:
typedef boost::signals2::signal<void()> preset_list_signal_t;
void getPresetNames(preset_name_list_t& presets) const;
- void loadPresetsFromDir(const std::string& dir);
+ void loadPresetNamesFromDir(const std::string& dir);
void savePreset(const std::string & name);
+ void loadPreset(const std::string & name);
static std::string getGraphicPresetsDir();
bool removeParamSet(const std::string& name, bool delete_from_disk);
- /// Emitted when a preset gets added or deleted.
+ /// Emitted when a preset gets loaded or deleted.
boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb);
preset_name_list_t mPresetNames;
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 371a5fd48e..2cbba946d4 100755
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -30,7 +30,10 @@
max_chars="100"
name="graphic_preset_combo"
top_delta="0"
- width="150"/>
+ width="150">
+ <combo_box.commit_callback
+ function="Pref.Preset" />
+ </combo_box>
<button
follows="top|left"
height="23"