diff options
Diffstat (limited to 'linden/indra/llxml/llcontrol.cpp')
-rw-r--r-- | linden/indra/llxml/llcontrol.cpp | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp index 8c74127..09719a5 100644 --- a/linden/indra/llxml/llcontrol.cpp +++ b/linden/indra/llxml/llcontrol.cpp | |||
@@ -50,44 +50,53 @@ | |||
50 | #include "llsdserialize.h" | 50 | #include "llsdserialize.h" |
51 | 51 | ||
52 | #if LL_RELEASE_FOR_DOWNLOAD | 52 | #if LL_RELEASE_FOR_DOWNLOAD |
53 | #define CONTROL_ERRS llwarns | 53 | #define CONTROL_ERRS LL_WARNS("ControlErrors") |
54 | #else | 54 | #else |
55 | #define CONTROL_ERRS llerrs | 55 | #define CONTROL_ERRS LL_ERRS("ControlErrors") |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | //this defines the current version of the settings file | 58 | //this defines the current version of the settings file |
59 | const S32 CURRENT_VERSION = 101; | 59 | const S32 CURRENT_VERSION = 101; |
60 | 60 | ||
61 | BOOL LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) | 61 | bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) |
62 | { | 62 | { |
63 | bool result = false; | ||
63 | switch (mType) | 64 | switch (mType) |
64 | { | 65 | { |
65 | case TYPE_U32: | 66 | case TYPE_U32: |
66 | case TYPE_S32: | 67 | case TYPE_S32: |
67 | return a.asInteger() == b.asInteger(); | 68 | result = a.asInteger() == b.asInteger(); |
69 | break; | ||
68 | case TYPE_BOOLEAN: | 70 | case TYPE_BOOLEAN: |
69 | return a.asBoolean() == b.asBoolean(); | 71 | result = a.asBoolean() == b.asBoolean(); |
72 | break; | ||
70 | case TYPE_F32: | 73 | case TYPE_F32: |
71 | return a.asReal() == b.asReal(); | 74 | result = a.asReal() == b.asReal(); |
75 | break; | ||
72 | case TYPE_VEC3: | 76 | case TYPE_VEC3: |
73 | case TYPE_VEC3D: | 77 | case TYPE_VEC3D: |
74 | return LLVector3d(a) == LLVector3d(b); | 78 | result = LLVector3d(a) == LLVector3d(b); |
79 | break; | ||
75 | case TYPE_RECT: | 80 | case TYPE_RECT: |
76 | return LLRect(a) == LLRect(b); | 81 | result = LLRect(a) == LLRect(b); |
82 | break; | ||
77 | case TYPE_COL4: | 83 | case TYPE_COL4: |
78 | return LLColor4(a) == LLColor4(b); | 84 | result = LLColor4(a) == LLColor4(b); |
85 | break; | ||
79 | case TYPE_COL3: | 86 | case TYPE_COL3: |
80 | return LLColor3(a) == LLColor3(b); | 87 | result = LLColor3(a) == LLColor3(b); |
88 | break; | ||
81 | case TYPE_COL4U: | 89 | case TYPE_COL4U: |
82 | return LLColor4U(a) == LLColor4U(b); | 90 | result = LLColor4U(a) == LLColor4U(b); |
91 | break; | ||
83 | case TYPE_STRING: | 92 | case TYPE_STRING: |
84 | return a.asString() == b.asString(); | 93 | result = a.asString() == b.asString(); |
94 | break; | ||
85 | default: | 95 | default: |
86 | // no-op | ||
87 | break; | 96 | break; |
88 | } | 97 | } |
89 | 98 | ||
90 | return FALSE; | 99 | return result; |
91 | } | 100 | } |
92 | 101 | ||
93 | LLControlVariable::LLControlVariable(const LLString& name, eControlType type, | 102 | LLControlVariable::LLControlVariable(const LLString& name, eControlType type, |
@@ -114,14 +123,34 @@ LLControlVariable::~LLControlVariable() | |||
114 | 123 | ||
115 | void LLControlVariable::setValue(const LLSD& value, bool saved_value) | 124 | void LLControlVariable::setValue(const LLSD& value, bool saved_value) |
116 | { | 125 | { |
117 | bool value_changed = llsd_compare(getValue(), value) == FALSE; | 126 | // *FIX:MEP - The following is needed to make the LLSD::ImplString |
127 | // work with boolean controls... | ||
128 | LLSD storable_value; | ||
129 | if(TYPE_BOOLEAN == type() && value.isString()) | ||
130 | { | ||
131 | BOOL temp; | ||
132 | if(LLString::convertToBOOL(value.asString(), temp)) | ||
133 | { | ||
134 | storable_value = temp; | ||
135 | } | ||
136 | else | ||
137 | { | ||
138 | storable_value = FALSE; | ||
139 | } | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | storable_value = value; | ||
144 | } | ||
145 | |||
146 | bool value_changed = llsd_compare(getValue(), storable_value) == FALSE; | ||
118 | if(saved_value) | 147 | if(saved_value) |
119 | { | 148 | { |
120 | // If we're going to save this value, return to default but don't fire | 149 | // If we're going to save this value, return to default but don't fire |
121 | resetToDefault(false); | 150 | resetToDefault(false); |
122 | if (llsd_compare(mValues.back(), value) == FALSE) | 151 | if (llsd_compare(mValues.back(), storable_value) == FALSE) |
123 | { | 152 | { |
124 | mValues.push_back(value); | 153 | mValues.push_back(storable_value); |
125 | } | 154 | } |
126 | } | 155 | } |
127 | else | 156 | else |
@@ -129,7 +158,7 @@ void LLControlVariable::setValue(const LLSD& value, bool saved_value) | |||
129 | // This is a unsaved value. Its needs to reside at | 158 | // This is a unsaved value. Its needs to reside at |
130 | // mValues[2] (or greater). It must not affect | 159 | // mValues[2] (or greater). It must not affect |
131 | // the result of getSaveValue() | 160 | // the result of getSaveValue() |
132 | if (llsd_compare(mValues.back(), value) == FALSE) | 161 | if (llsd_compare(mValues.back(), storable_value) == FALSE) |
133 | { | 162 | { |
134 | while(mValues.size() > 2) | 163 | while(mValues.size() > 2) |
135 | { | 164 | { |
@@ -144,13 +173,14 @@ void LLControlVariable::setValue(const LLSD& value, bool saved_value) | |||
144 | } | 173 | } |
145 | 174 | ||
146 | // Add the 'un-save' value. | 175 | // Add the 'un-save' value. |
147 | mValues.push_back(value); | 176 | mValues.push_back(storable_value); |
148 | } | 177 | } |
149 | } | 178 | } |
150 | 179 | ||
180 | |||
151 | if(value_changed) | 181 | if(value_changed) |
152 | { | 182 | { |
153 | mSignal(value); | 183 | mSignal(storable_value); |
154 | } | 184 | } |
155 | } | 185 | } |
156 | 186 | ||
@@ -1147,3 +1177,4 @@ void main() | |||
1147 | #endif | 1177 | #endif |
1148 | 1178 | ||
1149 | 1179 | ||
1180 | |||