Skip to content
Snippets Groups Projects
Commit 0d5edb03 authored by AndreyL ProductEngine's avatar AndreyL ProductEngine
Browse files

MAINT-6435 Deafult preset should set the same settings as the "Reset to...

MAINT-6435 Deafult preset should set the same settings as the "Reset to recommended settings" button
parent 67f8d579
Branches
Tags
No related merge requests found
...@@ -809,3 +809,62 @@ void LLFeatureManager::applyBaseMasks() ...@@ -809,3 +809,62 @@ void LLFeatureManager::applyBaseMasks()
maskFeatures("safe"); maskFeatures("safe");
} }
} }
LLSD LLFeatureManager::getRecommendedSettingsMap()
{
// Create the map and fill it with the hardware recommended settings.
// It's needed to create an initial Default graphics preset (MAINT-6435).
// The process is similar to the one LLFeatureManager::applyRecommendedSettings() does.
LLSD map(LLSD::emptyMap());
loadGPUClass();
U32 level = llmax(GPU_CLASS_0, llmin(mGPUClass, GPU_CLASS_5));
LL_INFOS("RenderInit") << "Getting the map of recommended settings for level " << level << LL_ENDL;
applyBaseMasks();
std::string features(isValidGraphicsLevel(level) ? getNameForGraphicsLevel(level) : "Low");
maskFeatures(features);
LLControlVariable* ctrl = gSavedSettings.getControl("RenderQualityPerformance"); // include the quality value for correct preset loading
map["RenderQualityPerformance"]["Value"] = (LLSD::Integer)level;
map["RenderQualityPerformance"]["Comment"] = ctrl->getComment();;
map["RenderQualityPerformance"]["Persist"] = 1;
map["RenderQualityPerformance"]["Type"] = LLControlGroup::typeEnumToString(ctrl->type());
for (feature_map_t::iterator mIt = mFeatures.begin(); mIt != mFeatures.end(); ++mIt)
{
LLControlVariable* ctrl = gSavedSettings.getControl(mIt->first);
if (ctrl == NULL)
{
LL_WARNS() << "AHHH! Control setting " << mIt->first << " does not exist!" << LL_ENDL;
continue;
}
if (ctrl->isType(TYPE_BOOLEAN))
{
map[mIt->first]["Value"] = (LLSD::Boolean)getRecommendedValue(mIt->first);
}
else if (ctrl->isType(TYPE_S32) || ctrl->isType(TYPE_U32))
{
map[mIt->first]["Value"] = (LLSD::Integer)getRecommendedValue(mIt->first);
}
else if (ctrl->isType(TYPE_F32))
{
map[mIt->first]["Value"] = (LLSD::Real)getRecommendedValue(mIt->first);
}
else
{
LL_WARNS() << "AHHH! Control variable is not a numeric type!" << LL_ENDL;
continue;
}
map[mIt->first]["Comment"] = ctrl->getComment();;
map[mIt->first]["Persist"] = 1;
map[mIt->first]["Type"] = LLControlGroup::typeEnumToString(ctrl->type());
}
return map;
}
...@@ -158,6 +158,8 @@ class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManag ...@@ -158,6 +158,8 @@ class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManag
// load the dynamic GPU/feature table from a website // load the dynamic GPU/feature table from a website
void fetchHTTPTables(); void fetchHTTPTables();
LLSD getRecommendedSettingsMap();
protected: protected:
bool loadGPUClass(); bool loadGPUClass();
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "llviewercontrol.h" #include "llviewercontrol.h"
#include "llfloaterpreference.h" #include "llfloaterpreference.h"
#include "llfloaterreg.h" #include "llfloaterreg.h"
#include "llfeaturemanager.h"
LLPresetsManager::LLPresetsManager() LLPresetsManager::LLPresetsManager()
{ {
...@@ -60,7 +61,7 @@ void LLPresetsManager::createMissingDefault() ...@@ -60,7 +61,7 @@ void LLPresetsManager::createMissingDefault()
LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL; LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL;
// Write current graphic settings as the default // Write current graphic settings as the default
savePreset(PRESETS_GRAPHIC, PRESETS_DEFAULT); savePreset(PRESETS_GRAPHIC, PRESETS_DEFAULT, true);
} }
else else
{ {
...@@ -134,7 +135,7 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam ...@@ -134,7 +135,7 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
presets = mPresetNames; presets = mPresetNames;
} }
bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name) bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
{ {
if (LLTrans::getString(PRESETS_DEFAULT) == name) if (LLTrans::getString(PRESETS_DEFAULT) == name)
{ {
...@@ -146,11 +147,10 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n ...@@ -146,11 +147,10 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
if(PRESETS_GRAPHIC == subdirectory) if(PRESETS_GRAPHIC == subdirectory)
{ {
gSavedSettings.setString("PresetGraphicActive", name);
LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
if (instance) if (instance && !createDefault)
{ {
gSavedSettings.setString("PresetGraphicActive", name);
instance->getControlNames(name_list); instance->getControlNames(name_list);
LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL; LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL;
name_list.push_back("PresetGraphicActive"); name_list.push_back("PresetGraphicActive");
...@@ -170,11 +170,23 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n ...@@ -170,11 +170,23 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL; LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL;
} }
if (name_list.size() > 1) // if the active preset name is the only thing in the list, don't save the list if (name_list.size() > 1 // if the active preset name is the only thing in the list, don't save the list
|| (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC)) // or create a default graphics preset from hw recommended settings
{ {
// make an empty llsd // make an empty llsd
LLSD paramsData(LLSD::emptyMap()); LLSD paramsData(LLSD::emptyMap());
if (createDefault)
{
paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
{
// use the recommended setting as an initial one (MAINT-6435)
gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger());
}
}
else
{
for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it) for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
{ {
std::string ctrl_name = *it; std::string ctrl_name = *it;
...@@ -188,6 +200,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n ...@@ -188,6 +200,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
paramsData[ctrl_name]["Type"] = type; paramsData[ctrl_name]["Type"] = type;
paramsData[ctrl_name]["Value"] = value; paramsData[ctrl_name]["Value"] = value;
} }
}
std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml"); std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
...@@ -203,11 +216,13 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n ...@@ -203,11 +216,13 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL; LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL;
if (!createDefault)
{
gSavedSettings.setString("PresetGraphicActive", name); gSavedSettings.setString("PresetGraphicActive", name);
// signal interested parties // signal interested parties
triggerChangeSignal(); triggerChangeSignal();
} }
}
else else
{ {
LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL; LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL;
......
...@@ -56,7 +56,7 @@ class LLPresetsManager : public LLSingleton<LLPresetsManager> ...@@ -56,7 +56,7 @@ class LLPresetsManager : public LLSingleton<LLPresetsManager>
static std::string getPresetsDir(const std::string& subdirectory); static std::string getPresetsDir(const std::string& subdirectory);
void setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option); void setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option); void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option);
bool savePreset(const std::string& subdirectory, std::string name); bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false);
void loadPreset(const std::string& subdirectory, std::string name); void loadPreset(const std::string& subdirectory, std::string name);
bool deletePreset(const std::string& subdirectory, std::string name); bool deletePreset(const std::string& subdirectory, std::string name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment