From 24b26d71ee01211aa796b8061b66ec06a133e4ce Mon Sep 17 00:00:00 2001 From: Dave Simmons Date: Fri, 20 Mar 2009 20:00:47 +0000 Subject: svn merge -r113004:115000 svn+ssh://svn.lindenlab.com/svn/linden/branches/server/server-1.26 Merge latest 1.26 into trunk --- indra/llxml/CMakeLists.txt | 1 + indra/llxml/llcontrol.cpp | 53 ++++++++++++++++++++++++++++++-------- indra/llxml/llcontrol.h | 13 +++++++--- indra/llxml/llcontrolgroupreader.h | 51 ++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 15 deletions(-) create mode 100644 indra/llxml/llcontrolgroupreader.h (limited to 'indra/llxml') diff --git a/indra/llxml/CMakeLists.txt b/indra/llxml/CMakeLists.txt index 9febd9775d..487c5b9a8a 100644 --- a/indra/llxml/CMakeLists.txt +++ b/indra/llxml/CMakeLists.txt @@ -23,6 +23,7 @@ set(llxml_HEADER_FILES CMakeLists.txt llcontrol.h + llcontrolgroupreader.h llxmlnode.h llxmlparser.h llxmltree.h diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 9bf1d122bc..d9ed45ab9d 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -102,11 +102,12 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) LLControlVariable::LLControlVariable(const std::string& name, eControlType type, LLSD initial, const std::string& comment, - bool persist) + bool persist, bool hidefromsettingseditor) : mName(name), mComment(comment), mType(type), - mPersist(persist) + mPersist(persist), + mHideFromSettingsEditor(hidefromsettingseditor) { if (mPersist && mComment.empty()) { @@ -213,6 +214,11 @@ void LLControlVariable::setPersist(bool state) mPersist = state; } +void LLControlVariable::setHiddenFromSettingsEditor(bool hide) +{ + mHideFromSettingsEditor = hide; +} + void LLControlVariable::setComment(const std::string& comment) { mComment = comment; @@ -296,17 +302,27 @@ std::string LLControlGroup::typeEnumToString(eControlType typeenum) return mTypeString[typeenum]; } -BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist) +BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist, BOOL hidefromsettingseditor) { - if(mNameTable.find(name) != mNameTable.end()) - { - llwarns << "LLControlGroup::declareControl: Control named " << name << " already exists." << llendl; - mNameTable[name]->setValue(initial_val); - return TRUE; + LLControlVariable* existing_control = getControl(name); + if (existing_control) + { + if (persist && existing_control->isType(type)) + { + // Sometimes we need to declare a control *after* it has been loaded from a settings file. + LLSD cur_value = existing_control->getValue(); // get the current value + existing_control->setDefaultValue(initial_val); // set the default to the declared value + existing_control->setValue(cur_value); // now set to the loaded value + } + else + { + llwarns << "Control named " << name << " already exists, ignoring new declaration." << llendl; + } + return TRUE; } // if not, create the control and add it to the name table - LLControlVariable* control = new LLControlVariable(name, type, initial_val, comment, persist); + LLControlVariable* control = new LLControlVariable(name, type, initial_val, comment, persist, hidefromsettingseditor); mNameTable[name] = control; return TRUE; } @@ -1043,7 +1059,8 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v } U32 validitems = 0; - bool persist = false; + bool persist = true; + bool hidefromsettingseditor = false; for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr) { name = (*itr).first; @@ -1054,6 +1071,18 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v persist = control_map["Persist"].asInteger(); } + // Sometimes we want to use the settings system to provide cheap persistence, but we + // don't want the settings themselves to be easily manipulated in the UI because + // doing so can cause support problems. So we have this option: + if(control_map.has("HideFromEditor")) + { + hidefromsettingseditor = control_map["HideFromEditor"].asInteger(); + } + else + { + hidefromsettingseditor = false; + } + // If the control exists just set the value from the input file. LLControlVariable* existing_control = getControl(name); if(existing_control) @@ -1067,6 +1096,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v { existing_control->setDefaultValue(control_map["Value"]); existing_control->setPersist(persist); + existing_control->setHiddenFromSettingsEditor(hidefromsettingseditor); existing_control->setComment(control_map["Comment"].asString()); } else @@ -1090,7 +1120,8 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v typeStringToEnum(control_map["Type"].asString()), control_map["Value"], control_map["Comment"].asString(), - persist + persist, + hidefromsettingseditor ); } diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 3be781ef78..ba0a1c7cbf 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -39,6 +39,8 @@ #include "llstring.h" #include "llrect.h" +#include "llcontrolgroupreader.h" + #include // *NOTE: boost::visit_each<> generates warning 4675 on .net 2003 @@ -93,7 +95,8 @@ private: std::string mName; std::string mComment; eControlType mType; - bool mPersist; + bool mPersist; + bool mHideFromSettingsEditor; std::vector mValues; signal_t mSignal; @@ -101,7 +104,7 @@ private: public: LLControlVariable(const std::string& name, eControlType type, LLSD initial, const std::string& comment, - bool persist = true); + bool persist = true, bool hidefromsettingseditor = false); virtual ~LLControlVariable(); @@ -118,6 +121,7 @@ public: bool isDefault() { return (mValues.size() == 1); } bool isSaveValueDefault(); bool isPersisted() { return mPersist; } + bool isHiddenFromSettingsEditor() { return mHideFromSettingsEditor; } LLSD get() const { return getValue(); } LLSD getValue() const { return mValues.back(); } LLSD getDefault() const { return mValues.front(); } @@ -127,6 +131,7 @@ public: void setValue(const LLSD& value, bool saved_value = TRUE); void setDefaultValue(const LLSD& value); void setPersist(bool state); + void setHiddenFromSettingsEditor(bool hide); void setComment(const std::string& comment); void firePropertyChanged() @@ -140,7 +145,7 @@ private: }; //const U32 STRING_CACHE_SIZE = 10000; -class LLControlGroup +class LLControlGroup : public LLControlGroupReader { protected: typedef std::map > ctrl_name_table_t; @@ -164,7 +169,7 @@ public: }; void applyToAll(ApplyFunctor* func); - BOOL declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist); + BOOL declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist, BOOL hidefromsettingseditor = FALSE); BOOL declareU32(const std::string& name, U32 initial_val, const std::string& comment, BOOL persist = TRUE); BOOL declareS32(const std::string& name, S32 initial_val, const std::string& comment, BOOL persist = TRUE); BOOL declareF32(const std::string& name, F32 initial_val, const std::string& comment, BOOL persist = TRUE); diff --git a/indra/llxml/llcontrolgroupreader.h b/indra/llxml/llcontrolgroupreader.h new file mode 100644 index 0000000000..960b19036e --- /dev/null +++ b/indra/llxml/llcontrolgroupreader.h @@ -0,0 +1,51 @@ +/** + * @file llcontrolgroupreader.h + * @brief Interface providing readonly access to LLControlGroup (intended for unit testing) + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * Copyright (c) 2001-2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#ifndef LL_LLCONTROLGROUPREADER_H +#define LL_LLCONTROLGROUPREADER_H + +#include "stdtypes.h" +#include + +// Many of the types below are commented out because for the purposes of the early testing we're doing, +// we don't need them and we don't want to pull in all the machinery to support them. +// But the model is here for future unit test extensions. + +class LLControlGroupReader +{ +public: + LLControlGroupReader() {} + virtual ~LLControlGroupReader() {} + + virtual std::string getString(const std::string& name) = 0; + //virtual LLWString getWString(const std::string& name) = 0; + virtual std::string getText(const std::string& name) = 0; + //virtual LLVector3 getVector3(const std::string& name) = 0; + //virtual LLVector3d getVector3d(const std::string& name) = 0; + //virtual LLRect getRect(const std::string& name) = 0; + virtual BOOL getBOOL(const std::string& name) = 0; + virtual S32 getS32(const std::string& name) = 0; + virtual F32 getF32(const std::string& name) = 0; + virtual U32 getU32(const std::string& name) = 0; + //virtual LLSD getLLSD(const std::string& name) = 0; + + //virtual LLColor4 getColor(const std::string& name) = 0; + //virtual LLColor4U getColor4U(const std::string& name) = 0; + //virtual LLColor4 getColor4(const std::string& name) = 0; + //virtual LLColor3 getColor3(const std::string& name) = 0; +}; + +#endif /* LL_LLCONTROLGROUPREADER_H */ + + + + + + + -- cgit v1.2.3