From 8f5ddebf0abfbcf73f25313214b06b98f2c7889c Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Sun, 14 Dec 2014 19:17:52 -0500
Subject: STORM-2082 Remove ugly list of control names.  Instead, obtain the
 list from the View data Remove a few remants used by the old hardware floater

---
 indra/newview/llfloaterpreference.cpp | 42 +++++++++++++++++++++++++-----
 indra/newview/llfloaterpreference.h   |  2 +-
 indra/newview/llpresetsmanager.cpp    | 49 +++++++----------------------------
 3 files changed, 46 insertions(+), 47 deletions(-)

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 814e552027..9df7f82275 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -340,7 +340,6 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
 	mCommitCallbackRegistrar.add("Pref.ClickEnablePopup",		boost::bind(&LLFloaterPreference::onClickEnablePopup, this));
 	mCommitCallbackRegistrar.add("Pref.ClickDisablePopup",		boost::bind(&LLFloaterPreference::onClickDisablePopup, this));	
 	mCommitCallbackRegistrar.add("Pref.LogPath",				boost::bind(&LLFloaterPreference::onClickLogPath, this));
-	mCommitCallbackRegistrar.add("Pref.HardwareSettings",		boost::bind(&LLFloaterPreference::onOpenHardwareSettings, this));
 	mCommitCallbackRegistrar.add("Pref.HardwareDefaults",		boost::bind(&LLFloaterPreference::setHardwareDefaults, this));
 	mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",		boost::bind(&LLFloaterPreference::onVertexShaderEnable, this));
 	mCommitCallbackRegistrar.add("Pref.WindowedMod",			boost::bind(&LLFloaterPreference::onCommitWindowedMode, this));
@@ -788,6 +787,42 @@ void LLFloaterPreference::setHardwareDefaults()
 	LLPresetsManager::getInstance()->savePreset(PRESETS_GRAPHIC, PRESETS_DEFAULT);
 }
 
+void LLFloaterPreference::getControlNames(std::vector<std::string>& names)
+{
+	LLView* view = findChild<LLView>("display");
+	if (view)
+	{
+		std::list<LLView*> stack;
+		stack.push_back(view);
+		while(!stack.empty())
+		{
+			// Process view on top of the stack
+			LLView* curview = stack.front();
+			stack.pop_front();
+
+			LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+			if (ctrl)
+			{
+				LLControlVariable* control = ctrl->getControlVariable();
+				if (control)
+				{
+					std::string control_name = control->getName();
+					if (std::find(names.begin(), names.end(), control_name) == names.end())
+					{
+						names.push_back(control_name);
+					}
+				}
+			}
+
+			for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+				iter != curview->getChildList()->end(); ++iter)
+			{
+				stack.push_back(*iter);
+			}
+		}
+	}
+}
+
 //virtual
 void LLFloaterPreference::onClose(bool app_quitting)
 {
@@ -799,11 +834,6 @@ void LLFloaterPreference::onClose(bool app_quitting)
 	}
 }
 
-void LLFloaterPreference::onOpenHardwareSettings()
-{
-	LLFloater* floater = LLFloaterReg::showInstance("prefs_hardware_settings");
-	addDependentFloater(floater, FALSE);
-}
 // static 
 void LLFloaterPreference::onBtnOK()
 {
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index 12230c2877..f6b5f5229d 100755
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -93,6 +93,7 @@ public:
 	void saveAvatarProperties( void );
 	void selectPrivacyPanel();
 	void selectChatPanel();
+	void getControlNames(std::vector<std::string>& names);
 
 protected:	
 	void		onBtnOK();
@@ -110,7 +111,6 @@ protected:
 	// if the custom settings box is clicked
 	void onChangeCustom();
 	void updateMeterText(LLUICtrl* ctrl);
-	void onOpenHardwareSettings();
 	// callback for defaults
 	void setHardwareDefaults();
 	void setRecommended();
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 1c14cc6ece..05a135b19c 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -36,6 +36,8 @@
 #include "lltrans.h"
 #include "lluictrlfactory.h"
 #include "llviewercontrol.h"
+#include "llfloaterpreference.h"
+#include "llfloaterreg.h"
 
 LLPresetsManager::LLPresetsManager()
 {
@@ -137,51 +139,18 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, const std::st
 	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 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)
 	{
 		gSavedSettings.setString("PresetGraphicActive", name);
 
-		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")
-			("RenderAutoMuteRenderWeightLimit")
-
-			("RenderAnisotropic")
-			("RenderFSAASamples")
-			("RenderGamma")
-			("RenderVBOEnable")
-			("RenderCompressTextures")
-			("TextureMemory")
-			("RenderFogRatio")
-
-			("PresetGraphicActive");
+		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+		if (instance)
+		{
+			instance->getControlNames(name_list);
+			name_list.push_back("PresetGraphicActive");
 		}
+	}
 
 	if(PRESETS_CAMERA == subdirectory)
 	{
-- 
cgit v1.2.3