aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llxml
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llxml')
-rw-r--r--linden/indra/llxml/llcontrol.cpp15
-rw-r--r--linden/indra/llxml/llcontrol.h80
2 files changed, 95 insertions, 0 deletions
diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp
index 88eb2c3..452167e 100644
--- a/linden/indra/llxml/llcontrol.cpp
+++ b/linden/indra/llxml/llcontrol.cpp
@@ -1099,6 +1099,15 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
1099 } 1099 }
1100*/ 1100*/
1101 1101
1102// [RLVa:KB] - Checked: 2010-06-20 (RLVa-1.1.2a) | Added: RLVa-1.1.2a
1103 // HACK-RLVa: bad code but it's just a temporary measure to provide a smooth changeover from the old to the new rebranded settings
1104 if ( (name.length() >= 14) && (0 == name.find("RestrainedLife")) )
1105 {
1106 // Transparently convert the old settings name to the new one while preserving the user override
1107 name = "RestrainedLove" + name.substr(14);
1108 }
1109// [/RLVa:KB]
1110
1102 // If the control exists just set the value from the input file. 1111 // If the control exists just set the value from the input file.
1103 LLControlVariable* existing_control = getControl(name); 1112 LLControlVariable* existing_control = getControl(name);
1104 if(existing_control) 1113 if(existing_control)
@@ -1217,6 +1226,12 @@ void LLControlGroup::resetWarnings()
1217 } 1226 }
1218} 1227}
1219 1228
1229template <> void jc_rebind::rebind_callback<S32>(const LLSD &data, S32 *reciever){ *reciever = data.asInteger(); }
1230template <> void jc_rebind::rebind_callback<F32>(const LLSD &data, F32 *reciever){ *reciever = data.asReal(); }
1231template <> void jc_rebind::rebind_callback<U32>(const LLSD &data, U32 *reciever){ *reciever = data.asInteger(); }
1232template <> void jc_rebind::rebind_callback<std::string>(const LLSD &data, std::string *reciever){ *reciever = data.asString(); }
1233template <> void jc_rebind::rebind_callback<LLColor4>(const LLSD &data, LLColor4 *reciever){ *reciever = LLColor4(LLColor4U(data)); }
1234
1220//============================================================================ 1235//============================================================================
1221 1236
1222#ifdef TEST_HARNESS 1237#ifdef TEST_HARNESS
diff --git a/linden/indra/llxml/llcontrol.h b/linden/indra/llxml/llcontrol.h
index ba0a1c7..316de5c 100644
--- a/linden/indra/llxml/llcontrol.h
+++ b/linden/indra/llxml/llcontrol.h
@@ -242,4 +242,84 @@ public:
242 void resetWarnings(); 242 void resetWarnings();
243}; 243};
244 244
245///////////////////////
246namespace jc_you_suck
247{
248class jc_rebind
249{
250 template <typename REC> static void rebind_callback(const LLSD &data, REC *reciever){ *reciever = data; }
251
252 typedef boost::signal<void(const LLSD&)> signal_t;
253
254public:
255
256//#define binder_debug
257
258 template <typename RBTYPE> static RBTYPE* rebind_llcontrol(std::string name, LLControlGroup* controlgroup, bool init)
259 {
260 static std::map<LLControlGroup*, std::map<std::string, void*> > references;
261
262#ifdef binder_debug
263 llinfos << "rebind_llcontrol" << llendl;
264#endif
265
266 RBTYPE* type = NULL;
267 if(controlgroup)
268 {
269 if(references.find(controlgroup) == references.end())
270 {
271#ifdef binder_debug
272 llinfos << "was no map for a group, adding" << llendl;
273#endif
274 references[controlgroup] = std::map<std::string, void*>();
275 }
276
277 if(references[controlgroup].find(name) != references[controlgroup].end())
278 {
279#ifdef binder_debug
280 llinfos << "pulling type from map for " << name << llendl;
281#endif
282 type = (RBTYPE*)(references[controlgroup][name]);
283 if(type == NULL)llerrs << "bad type stored" << llendl;
284 }else
285 {
286#ifdef binder_debug
287 llinfos << "creating type in map for " << name << llendl;
288#endif
289 type = new RBTYPE();
290 references[controlgroup][name] = (void*)type;
291 LLControlVariable* control = controlgroup->getControl(name);
292 if(control)
293 {
294#ifdef binder_debug
295 llinfos << "control there " << name << llendl;
296#endif
297 signal_t* signal = control->getSignal();
298 if(signal)
299 {
300#ifdef binder_debug
301 llinfos << "signal there" << name << llendl;
302#endif
303 signal->connect(boost::bind(&jc_rebind::rebind_callback<RBTYPE>, _1, type));
304 if(init)jc_rebind::rebind_callback<RBTYPE>(control->getValue(),type);
305 }else llerrs << "no signal!" << llendl;
306 }else llerrs << "no control for " << name << "!" << llendl;
307 }
308 }
309 return type;
310 }
311};
312
313template <> void jc_rebind::rebind_callback<S32>(const LLSD &data, S32 *reciever);
314template <> void jc_rebind::rebind_callback<F32>(const LLSD &data, F32 *reciever);
315template <> void jc_rebind::rebind_callback<U32>(const LLSD &data, U32 *reciever);
316template <> void jc_rebind::rebind_callback<std::string>(const LLSD &data, std::string *reciever);
317template <> void jc_rebind::rebind_callback<LLColor4>(const LLSD &data, LLColor4 *reciever);
318
319}
320using namespace jc_you_suck;
321#define rebind_llcontrol jc_rebind::rebind_llcontrol
322
323///////////////////////
324
245#endif 325#endif