Commit d6959f17 authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

More cleanup to graphics preset system. Make largely independent of preference floater

parent a15ede76
...@@ -1100,8 +1100,6 @@ void LLFloaterPreference::setHardwareDefaults() ...@@ -1100,8 +1100,6 @@ void LLFloaterPreference::setHardwareDefaults()
LLAvatarComplexityControls::setIndirectControls(); LLAvatarComplexityControls::setIndirectControls();
refreshEnabledGraphics(); refreshEnabledGraphics();
gSavedSettings.setString("PresetGraphicActive", "");
LLPresetsManager::getInstance()->triggerChangeSignal();
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
...@@ -2894,11 +2892,7 @@ void LLPanelPreferenceGraphics::setPresetText() ...@@ -2894,11 +2892,7 @@ void LLPanelPreferenceGraphics::setPresetText()
if (hasDirtyChilds() && !preset_graphic_active.empty()) if (hasDirtyChilds() && !preset_graphic_active.empty())
{ {
gSavedSettings.setString("PresetGraphicActive", "");
preset_graphic_active.clear(); preset_graphic_active.clear();
// This doesn't seem to cause an infinite recursion. This trigger is needed to cause the pulldown
// panel to update.
LLPresetsManager::getInstance()->triggerChangeSignal();
} }
if (!preset_graphic_active.empty()) if (!preset_graphic_active.empty())
......
...@@ -44,14 +44,25 @@ ...@@ -44,14 +44,25 @@
LLPresetsManager::LLPresetsManager() LLPresetsManager::LLPresetsManager()
{ {
// Start watching camera controls as soon as the preset // Connect preset signals
// manager gets initialized startWatching(PRESETS_GRAPHIC);
startWatching(PRESETS_CAMERA); startWatching(PRESETS_CAMERA);
} }
LLPresetsManager::~LLPresetsManager() LLPresetsManager::~LLPresetsManager()
{ {
mCameraChangedSignal.disconnect(); for (auto& signal : mGraphicsChangedSignals)
{
signal.disconnect();
}
mGraphicsChangedSignals.clear();
for (auto& signal : mCameraChangedSignals)
{
signal.disconnect();
}
mCameraChangedSignals.clear();
} }
void LLPresetsManager::triggerChangeCameraSignal() void LLPresetsManager::triggerChangeCameraSignal()
...@@ -120,7 +131,43 @@ void LLPresetsManager::startWatching(const std::string& subdirectory) ...@@ -120,7 +131,43 @@ void LLPresetsManager::startWatching(const std::string& subdirectory)
} }
else else
{ {
mCameraChangedSignal = cntrl_ptr->getCommitSignal()->connect(boost::bind(&settingChanged)); mCameraChangedSignals.push_back(cntrl_ptr->getCommitSignal()->connect(boost::bind(&LLPresetsManager::cameraSettingChanged, this)));
}
}
}
}
else if (PRESETS_GRAPHIC == subdirectory)
{
std::vector<std::string> name_list;
getGraphicsControlNames(name_list);
for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
{
std::string ctrl_name = *it;
if (gSavedSettings.controlExists(ctrl_name))
{
LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name);
if (cntrl_ptr.isNull())
{
LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name
<< "'" << LL_ENDL;
}
else
{
mGraphicsChangedSignals.push_back(cntrl_ptr->getCommitSignal()->connect(boost::bind(&LLPresetsManager::graphicsSettingChanged, this)));
}
}
else if (gSavedPerAccountSettings.controlExists(ctrl_name))
{
LLPointer<LLControlVariable> cntrl_ptr = gSavedPerAccountSettings.getControl(ctrl_name);
if (cntrl_ptr.isNull())
{
LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name
<< "'" << LL_ENDL;
}
else
{
mGraphicsChangedSignals.push_back(cntrl_ptr->getCommitSignal()->connect(boost::bind(&LLPresetsManager::graphicsSettingChanged, this)));
} }
} }
} }
...@@ -219,26 +266,36 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& subdirectory, p ...@@ -219,26 +266,36 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& subdirectory, p
presets = mPresetNames; presets = mPresetNames;
} }
bool LLPresetsManager::mCameraDirty = false; bool LLPresetsManager::sCameraDirty = false;
bool LLPresetsManager::mIgnoreChangedSignal = false;
void LLPresetsManager::setCameraDirty(bool dirty) void LLPresetsManager::setCameraDirty(bool dirty)
{ {
mCameraDirty = dirty; sCameraDirty = dirty;
} }
bool LLPresetsManager::isCameraDirty() bool LLPresetsManager::isCameraDirty()
{ {
return mCameraDirty; return sCameraDirty;
}
void LLPresetsManager::graphicsSettingChanged()
{
static LLCachedControl<std::string> graphic_preset_active(gSavedSettings, "PresetGraphicActive", "");
if (!graphic_preset_active().empty() && !mIgnoreChangedSignal)
{
gSavedSettings.setString("PresetGraphicActive", "");
// Hack call because this is a static routine
LLPresetsManager::getInstance()->triggerChangeSignal();
}
} }
void LLPresetsManager::settingChanged() void LLPresetsManager::cameraSettingChanged()
{ {
setCameraDirty(true); setCameraDirty(true);
static LLCachedControl<std::string> preset_camera_active(gSavedSettings, "PresetCameraActive", ""); static LLCachedControl<std::string> preset_camera_active(gSavedSettings, "PresetCameraActive", "");
std::string preset_name = preset_camera_active; if (!preset_camera_active().empty() && !mIgnoreChangedSignal)
if (!preset_name.empty() && !mIgnoreChangedSignal)
{ {
gSavedSettings.setString("PresetCameraActive", ""); gSavedSettings.setString("PresetCameraActive", "");
...@@ -360,8 +417,10 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n ...@@ -360,8 +417,10 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap(); paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0) if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
{ {
mIgnoreChangedSignal = true;
// use the recommended setting as an initial one (MAINT-6435) // use the recommended setting as an initial one (MAINT-6435)
gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger()); gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger());
mIgnoreChangedSignal = false;
} }
// Add dynamic controls to default preset // Add dynamic controls to default preset
......
...@@ -99,12 +99,15 @@ class LLPresetsManager final : public LLSingleton<LLPresetsManager> ...@@ -99,12 +99,15 @@ class LLPresetsManager final : public LLSingleton<LLPresetsManager>
void getGraphicsControlNames(std::vector<std::string>& names); void getGraphicsControlNames(std::vector<std::string>& names);
void getCameraControlNames(std::vector<std::string>& names); void getCameraControlNames(std::vector<std::string>& names);
static void settingChanged(); void graphicsSettingChanged();
void cameraSettingChanged();
boost::signals2::connection mCameraChangedSignal; std::vector<boost::signals2::connection> mGraphicsChangedSignals;
std::vector<boost::signals2::connection> mCameraChangedSignals;
static bool mCameraDirty; bool mIgnoreChangedSignal = false;
static bool mIgnoreChangedSignal;
static bool sCameraDirty;
}; };
#endif // LL_PRESETSMANAGER_H #endif // LL_PRESETSMANAGER_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment