aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llxml/llcontrol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llxml/llcontrol.cpp')
-rw-r--r--linden/indra/llxml/llcontrol.cpp56
1 files changed, 44 insertions, 12 deletions
diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp
index 81c3e78..d9ed45a 100644
--- a/linden/indra/llxml/llcontrol.cpp
+++ b/linden/indra/llxml/llcontrol.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -101,11 +102,12 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b)
101 102
102LLControlVariable::LLControlVariable(const std::string& name, eControlType type, 103LLControlVariable::LLControlVariable(const std::string& name, eControlType type,
103 LLSD initial, const std::string& comment, 104 LLSD initial, const std::string& comment,
104 bool persist) 105 bool persist, bool hidefromsettingseditor)
105 : mName(name), 106 : mName(name),
106 mComment(comment), 107 mComment(comment),
107 mType(type), 108 mType(type),
108 mPersist(persist) 109 mPersist(persist),
110 mHideFromSettingsEditor(hidefromsettingseditor)
109{ 111{
110 if (mPersist && mComment.empty()) 112 if (mPersist && mComment.empty())
111 { 113 {
@@ -212,6 +214,11 @@ void LLControlVariable::setPersist(bool state)
212 mPersist = state; 214 mPersist = state;
213} 215}
214 216
217void LLControlVariable::setHiddenFromSettingsEditor(bool hide)
218{
219 mHideFromSettingsEditor = hide;
220}
221
215void LLControlVariable::setComment(const std::string& comment) 222void LLControlVariable::setComment(const std::string& comment)
216{ 223{
217 mComment = comment; 224 mComment = comment;
@@ -295,17 +302,27 @@ std::string LLControlGroup::typeEnumToString(eControlType typeenum)
295 return mTypeString[typeenum]; 302 return mTypeString[typeenum];
296} 303}
297 304
298BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist) 305BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist, BOOL hidefromsettingseditor)
299{ 306{
300 if(mNameTable.find(name) != mNameTable.end()) 307 LLControlVariable* existing_control = getControl(name);
301 { 308 if (existing_control)
302 llwarns << "LLControlGroup::declareControl: Control named " << name << " already exists." << llendl; 309 {
303 mNameTable[name]->setValue(initial_val); 310 if (persist && existing_control->isType(type))
304 return TRUE; 311 {
312 // Sometimes we need to declare a control *after* it has been loaded from a settings file.
313 LLSD cur_value = existing_control->getValue(); // get the current value
314 existing_control->setDefaultValue(initial_val); // set the default to the declared value
315 existing_control->setValue(cur_value); // now set to the loaded value
316 }
317 else
318 {
319 llwarns << "Control named " << name << " already exists, ignoring new declaration." << llendl;
320 }
321 return TRUE;
305 } 322 }
306 323
307 // if not, create the control and add it to the name table 324 // if not, create the control and add it to the name table
308 LLControlVariable* control = new LLControlVariable(name, type, initial_val, comment, persist); 325 LLControlVariable* control = new LLControlVariable(name, type, initial_val, comment, persist, hidefromsettingseditor);
309 mNameTable[name] = control; 326 mNameTable[name] = control;
310 return TRUE; 327 return TRUE;
311} 328}
@@ -1042,7 +1059,8 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
1042 } 1059 }
1043 1060
1044 U32 validitems = 0; 1061 U32 validitems = 0;
1045 bool persist = false; 1062 bool persist = true;
1063 bool hidefromsettingseditor = false;
1046 for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr) 1064 for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr)
1047 { 1065 {
1048 name = (*itr).first; 1066 name = (*itr).first;
@@ -1053,6 +1071,18 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
1053 persist = control_map["Persist"].asInteger(); 1071 persist = control_map["Persist"].asInteger();
1054 } 1072 }
1055 1073
1074 // Sometimes we want to use the settings system to provide cheap persistence, but we
1075 // don't want the settings themselves to be easily manipulated in the UI because
1076 // doing so can cause support problems. So we have this option:
1077 if(control_map.has("HideFromEditor"))
1078 {
1079 hidefromsettingseditor = control_map["HideFromEditor"].asInteger();
1080 }
1081 else
1082 {
1083 hidefromsettingseditor = false;
1084 }
1085
1056 // If the control exists just set the value from the input file. 1086 // If the control exists just set the value from the input file.
1057 LLControlVariable* existing_control = getControl(name); 1087 LLControlVariable* existing_control = getControl(name);
1058 if(existing_control) 1088 if(existing_control)
@@ -1066,6 +1096,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
1066 { 1096 {
1067 existing_control->setDefaultValue(control_map["Value"]); 1097 existing_control->setDefaultValue(control_map["Value"]);
1068 existing_control->setPersist(persist); 1098 existing_control->setPersist(persist);
1099 existing_control->setHiddenFromSettingsEditor(hidefromsettingseditor);
1069 existing_control->setComment(control_map["Comment"].asString()); 1100 existing_control->setComment(control_map["Comment"].asString());
1070 } 1101 }
1071 else 1102 else
@@ -1089,7 +1120,8 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
1089 typeStringToEnum(control_map["Type"].asString()), 1120 typeStringToEnum(control_map["Type"].asString()),
1090 control_map["Value"], 1121 control_map["Value"],
1091 control_map["Comment"].asString(), 1122 control_map["Comment"].asString(),
1092 persist 1123 persist,
1124 hidefromsettingseditor
1093 ); 1125 );
1094 } 1126 }
1095 1127