diff options
author | elektrahesse | 2010-10-10 14:30:55 +0200 |
---|---|---|
committer | elektrahesse | 2010-10-10 14:30:55 +0200 |
commit | 2aa41c152923f2bb9e3fc00a354a4868f36856db (patch) | |
tree | 8f62b9c1e7a41538da6a7b2ef14968c57fa8d4a8 /linden/indra | |
parent | Merge branch 'weekly' of git://github.com/mccabe/imprudence into weekly (diff) | |
download | meta-impy-2aa41c152923f2bb9e3fc00a354a4868f36856db.zip meta-impy-2aa41c152923f2bb9e3fc00a354a4868f36856db.tar.gz meta-impy-2aa41c152923f2bb9e3fc00a354a4868f36856db.tar.bz2 meta-impy-2aa41c152923f2bb9e3fc00a354a4868f36856db.tar.xz |
Missing files for new RLV
Diffstat (limited to 'linden/indra')
-rw-r--r-- | linden/indra/newview/rlvcommon.cpp | 399 | ||||
-rw-r--r-- | linden/indra/newview/rlvcommon.h | 199 |
2 files changed, 598 insertions, 0 deletions
diff --git a/linden/indra/newview/rlvcommon.cpp b/linden/indra/newview/rlvcommon.cpp new file mode 100644 index 0000000..3f494bc --- /dev/null +++ b/linden/indra/newview/rlvcommon.cpp | |||
@@ -0,0 +1,399 @@ | |||
1 | /** | ||
2 | * | ||
3 | * Copyright (c) 2009-2010, Kitty Barnett | ||
4 | * | ||
5 | * The source code in this file is provided to you under the terms of the | ||
6 | * GNU General Public License, version 2.0, but WITHOUT ANY WARRANTY; | ||
7 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
8 | * PARTICULAR PURPOSE. Terms of the GPL can be found in doc/GPL-license.txt | ||
9 | * in this distribution, or online at http://www.gnu.org/licenses/gpl-2.0.txt | ||
10 | * | ||
11 | * By copying, modifying or distributing this software, you acknowledge that | ||
12 | * you have read and understood your obligations described above, and agree to | ||
13 | * abide by those obligations. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include "llviewerprecompiledheaders.h" | ||
18 | #include "llagent.h" | ||
19 | #include "llappviewer.h" | ||
20 | #include "lluictrlfactory.h" | ||
21 | #include "llversionviewer.h" | ||
22 | #include "llviewermenu.h" | ||
23 | #include "llvoavatar.h" | ||
24 | |||
25 | #include "rlvcommon.h" | ||
26 | #include "rlvhandler.h" | ||
27 | |||
28 | // ============================================================================ | ||
29 | // RlvNotifications | ||
30 | // | ||
31 | |||
32 | #ifdef RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
33 | // Checked: 2009-12-05 (RLVa-1.1.0h) | Added: RLVa-1.1.0h | ||
34 | void RlvNotifications::notifyBehaviour(ERlvBehaviour eBhvr, ERlvParamType eType) | ||
35 | { | ||
36 | const std::string& strMsg = RlvStrings::getBehaviourNotificationString(eBhvr, eType); | ||
37 | if (!strMsg.empty()) | ||
38 | { | ||
39 | LLSD argsNotify; | ||
40 | argsNotify["MESSAGE"] = strMsg; | ||
41 | LLNotifications::instance().add("SystemMessageTip", argsNotify); | ||
42 | } | ||
43 | } | ||
44 | #endif // RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
45 | |||
46 | // Checked: 2009-11-11 (RLVa-1.1.0a) | Added: RLVa-1.1.0a | ||
47 | void RlvNotifications::notifyBlockedViewXXX(const char* pstrAssetType) | ||
48 | { | ||
49 | LLStringUtil::format_map_t argsMsg; std::string strMsg = RlvStrings::getString(RLV_STRING_BLOCKED_VIEWXXX); | ||
50 | argsMsg["[TYPE]"] = pstrAssetType; | ||
51 | LLStringUtil::format(strMsg, argsMsg); | ||
52 | |||
53 | LLSD argsNotify; | ||
54 | argsNotify["MESSAGE"] = strMsg; | ||
55 | LLNotifications::instance().add("SystemMessageTip", argsNotify); | ||
56 | } | ||
57 | |||
58 | // Checked: 2009-11-13 (RLVa-1.1.0b) | Modified: RLVa-1.1.0b | ||
59 | void RlvNotifications::warnGiveToRLV() | ||
60 | { | ||
61 | if ( (gSavedSettings.getWarning(RLV_SETTING_FIRSTUSE_GIVETORLV)) && (RlvSettings::getForbidGiveToRLV()) ) | ||
62 | LLNotifications::instance().add(RLV_SETTING_FIRSTUSE_GIVETORLV, LLSD(), LLSD(), &RlvNotifications::onGiveToRLVConfirmation); | ||
63 | } | ||
64 | |||
65 | // Checked: 2009-11-13 (RLVa-1.1.0b) | Modified: RLVa-1.1.0b | ||
66 | void RlvNotifications::onGiveToRLVConfirmation(const LLSD& notification, const LLSD& response) | ||
67 | { | ||
68 | gSavedSettings.setWarning(RLV_SETTING_FIRSTUSE_GIVETORLV, FALSE); | ||
69 | |||
70 | S32 idxOption = LLNotification::getSelectedOption(notification, response); | ||
71 | if ( (0 == idxOption) || (1 == idxOption) ) | ||
72 | gSavedSettings.setBOOL(RLV_SETTING_FORBIDGIVETORLV, (idxOption == 1)); | ||
73 | } | ||
74 | |||
75 | // ========================================================================= | ||
76 | // RlvSettings | ||
77 | // | ||
78 | |||
79 | #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS | ||
80 | BOOL RlvSettings::fCompositeFolders = FALSE; | ||
81 | #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS | ||
82 | BOOL RlvSettings::fLegacyNaming = TRUE; | ||
83 | BOOL RlvSettings::fNoSetEnv = FALSE; | ||
84 | BOOL RlvSettings::fShowNameTags = FALSE; | ||
85 | |||
86 | // Checked: 2009-12-18 (RLVa-1.1.0k) | Modified: RLVa-1.1.0i | ||
87 | void RlvSettings::initClass() | ||
88 | { | ||
89 | static bool fInitialized = false; | ||
90 | if (!fInitialized) | ||
91 | { | ||
92 | #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS | ||
93 | fCompositeFolders = rlvGetSettingBOOL(RLV_SETTING_ENABLECOMPOSITES, FALSE); | ||
94 | if (gSavedSettings.controlExists(RLV_SETTING_ENABLECOMPOSITES)) | ||
95 | gSavedSettings.getControl(RLV_SETTING_ENABLECOMPOSITES)->getSignal()->connect(boost::bind(&onChangedSettingBOOL, _1, &fCompositeFolders)); | ||
96 | #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS | ||
97 | |||
98 | fLegacyNaming = rlvGetSettingBOOL(RLV_SETTING_ENABLELEGACYNAMING, TRUE); | ||
99 | if (gSavedSettings.controlExists(RLV_SETTING_ENABLELEGACYNAMING)) | ||
100 | gSavedSettings.getControl(RLV_SETTING_ENABLELEGACYNAMING)->getSignal()->connect(boost::bind(&onChangedSettingBOOL, _1, &fLegacyNaming)); | ||
101 | |||
102 | fNoSetEnv = rlvGetSettingBOOL(RLV_SETTING_NOSETENV, FALSE); | ||
103 | |||
104 | fShowNameTags = rlvGetSettingBOOL(RLV_SETTING_SHOWNAMETAGS, FALSE); | ||
105 | if (gSavedSettings.controlExists(RLV_SETTING_SHOWNAMETAGS)) | ||
106 | gSavedSettings.getControl(RLV_SETTING_SHOWNAMETAGS)->getSignal()->connect(boost::bind(&onChangedSettingBOOL, _1, &fShowNameTags)); | ||
107 | |||
108 | fInitialized = true; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | BOOL RlvSettings::getEnableWear() | ||
113 | { | ||
114 | return | ||
115 | (rlvGetSettingBOOL(RLV_SETTING_ENABLEWEAR, TRUE)) && // "Enable Wear" is toggled on and... | ||
116 | (!gRlvHandler.hasBehaviour(RLV_BHVR_DEFAULTWEAR)) && // not restricted and... | ||
117 | (!gRlvHandler.hasBehaviour(RLV_BHVR_ADDATTACH)); // we have attach points we can attach to [see RlvHandler::onAddRemAttach()] | ||
118 | } | ||
119 | |||
120 | #ifndef RLV_WORKAROUND_REZMULTIPLEATTACH | ||
121 | BOOL RlvSettings::getEnableSharedWear() | ||
122 | { | ||
123 | // NOTE-RLVa: it's not proper but some code relies on the fact that getEnableSharedWear() returns FALSE if any attach point is locked | ||
124 | return | ||
125 | (rlvGetSettingBOOL(RLV_SETTING_ENABLESHAREDWEAR, FALSE)) && // "Enable Shared Wear" is toggled on and... | ||
126 | (!gRlvHandler.hasLockedAttachment(RLV_LOCK_ANY)); // no attachment point is non-attachable or non-detachable | ||
127 | } | ||
128 | #endif // RLV_WORKAROUND_REZMULTIPLEATTACH | ||
129 | |||
130 | #ifdef RLV_EXTENSION_STARTLOCATION | ||
131 | // Checked: 2009-07-08 (RLVa-1.0.0e) | Modified: RLVa-0.2.1d | ||
132 | void RlvSettings::updateLoginLastLocation() | ||
133 | { | ||
134 | if (gSavedPerAccountSettings.controlExists(RLV_SETTING_LOGINLASTLOCATION)) | ||
135 | { | ||
136 | BOOL fValue = (gRlvHandler.hasBehaviour(RLV_BHVR_TPLOC)) || | ||
137 | ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) && | ||
138 | (gAgent.getAvatarObject()) && (!gAgent.getAvatarObject()->mIsSitting) ); | ||
139 | if (gSavedPerAccountSettings.getBOOL(RLV_SETTING_LOGINLASTLOCATION) != fValue) | ||
140 | { | ||
141 | gSavedPerAccountSettings.setBOOL(RLV_SETTING_LOGINLASTLOCATION, fValue); | ||
142 | gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE); | ||
143 | } | ||
144 | } | ||
145 | } | ||
146 | #endif // RLV_EXTENSION_STARTLOCATION | ||
147 | |||
148 | // Checked: 2009-12-18 (RLVa-1.1.0k) | Added: RLVa-1.1.0i | ||
149 | bool RlvSettings::onChangedSettingBOOL(const LLSD& newvalue, BOOL* pfSetting) | ||
150 | { | ||
151 | if (pfSetting) | ||
152 | *pfSetting = newvalue.asBoolean(); | ||
153 | return true; | ||
154 | } | ||
155 | |||
156 | // ============================================================================ | ||
157 | // RlvStrings | ||
158 | // | ||
159 | |||
160 | std::vector<std::string> RlvStrings::m_Anonyms; | ||
161 | std::map<std::string, std::string> RlvStrings::m_StringMap; | ||
162 | #ifdef RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
163 | std::map<ERlvBehaviour, std::string> RlvStrings::m_BhvrAddMap; | ||
164 | std::map<ERlvBehaviour, std::string> RlvStrings::m_BhvrRemMap; | ||
165 | #endif // RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
166 | |||
167 | // Checked: 2009-12-05 (RLVa-1.1.0h) | Added: RLVa-1.1.0h | ||
168 | void RlvStrings::initClass() | ||
169 | { | ||
170 | static bool fInitialized = false; | ||
171 | if (!fInitialized) | ||
172 | { | ||
173 | LLXMLNodePtr xmlRoot; | ||
174 | if ( (!LLUICtrlFactory::getLayeredXMLNode("rlva_strings.xml", xmlRoot)) || (xmlRoot.isNull()) || (!xmlRoot->hasName("rlva_strings")) ) | ||
175 | { | ||
176 | llerrs << "Problem reading RLVa string XML file" << llendl; | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | for (LLXMLNode* pNode = xmlRoot->getFirstChild(); pNode != NULL; pNode = pNode->getNextSibling()) | ||
181 | { | ||
182 | if (pNode->hasName("strings")) | ||
183 | { | ||
184 | std::string strName; | ||
185 | for (LLXMLNode* pStringNode = pNode->getFirstChild(); pStringNode != NULL; pStringNode = pStringNode->getNextSibling()) | ||
186 | { | ||
187 | if ( (!pStringNode->hasName("string")) || (!pStringNode->getAttributeString("name", strName)) ) | ||
188 | continue; | ||
189 | m_StringMap[strName] = pStringNode->getTextContents(); | ||
190 | } | ||
191 | } | ||
192 | else if (pNode->hasName("anonyms")) | ||
193 | { | ||
194 | for (LLXMLNode* pAnonymNode = pNode->getFirstChild(); pAnonymNode != NULL; pAnonymNode = pAnonymNode->getNextSibling()) | ||
195 | { | ||
196 | if (!pAnonymNode->hasName("anonym")) | ||
197 | continue; | ||
198 | m_Anonyms.push_back(pAnonymNode->getTextContents()); | ||
199 | } | ||
200 | } | ||
201 | #ifdef RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
202 | else if (pNode->hasName("behaviour-notifications")) | ||
203 | { | ||
204 | std::string strBhvr, strType; ERlvBehaviour eBhvr; | ||
205 | for (LLXMLNode* pNotifyNode = pNode->getFirstChild(); pNotifyNode != NULL; pNotifyNode = pNotifyNode->getNextSibling()) | ||
206 | { | ||
207 | if ( (!pNotifyNode->hasName("notification")) || (!pNotifyNode->getAttributeString("type", strType)) || | ||
208 | (!pNotifyNode->getAttributeString("behaviour", strBhvr)) || | ||
209 | ((eBhvr = RlvCommand::getBehaviourFromString(strBhvr)) == RLV_BHVR_UNKNOWN) ) | ||
210 | { | ||
211 | continue; | ||
212 | } | ||
213 | if ("add" == strType) | ||
214 | m_BhvrAddMap.insert(std::pair<ERlvBehaviour, std::string>(eBhvr, pNotifyNode->getTextContents())); | ||
215 | else if ("rem" == strType) | ||
216 | m_BhvrRemMap.insert(std::pair<ERlvBehaviour, std::string>(eBhvr, pNotifyNode->getTextContents())); | ||
217 | } | ||
218 | } | ||
219 | #endif // RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
220 | } | ||
221 | |||
222 | if ( (m_StringMap.empty()) || (m_Anonyms.empty()) ) | ||
223 | { | ||
224 | llerrs << "Problem parsing RLVa string XML file" << llendl; | ||
225 | return; | ||
226 | } | ||
227 | |||
228 | fInitialized = true; | ||
229 | } | ||
230 | } | ||
231 | |||
232 | // Checked: 2009-11-11 (RLVa-1.1.0a) | Modified: RLVa-1.1.0a | ||
233 | const std::string& RlvStrings::getAnonym(const std::string& strName) | ||
234 | { | ||
235 | const char* pszName = strName.c_str(); U32 nHash = 0; | ||
236 | |||
237 | // Test with 11,264 SL names showed a 3.33% - 3.82% occurance for each so we *should* get a very even spread | ||
238 | for (int idx = 0, cnt = strName.length(); idx < cnt; idx++) | ||
239 | nHash += pszName[idx]; | ||
240 | |||
241 | return m_Anonyms[nHash % m_Anonyms.size()]; | ||
242 | } | ||
243 | |||
244 | #ifdef RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
245 | // Checked: 2009-12-05 (RLVa-1.1.0h) | Added: RLVa-1.1.0h | ||
246 | const std::string& RlvStrings::getBehaviourNotificationString(ERlvBehaviour eBhvr, ERlvParamType eType) | ||
247 | { | ||
248 | if (RLV_TYPE_ADD == eType) | ||
249 | { | ||
250 | std::map<ERlvBehaviour, std::string>::const_iterator itString = m_BhvrAddMap.find(eBhvr); | ||
251 | return (itString != m_BhvrAddMap.end()) ? itString->second : LLStringUtil::null; | ||
252 | } | ||
253 | else if (RLV_TYPE_REMOVE == eType) | ||
254 | { | ||
255 | std::map<ERlvBehaviour, std::string>::const_iterator itString = m_BhvrRemMap.find(eBhvr); | ||
256 | return (itString != m_BhvrRemMap.end()) ? itString->second : LLStringUtil::null; | ||
257 | } | ||
258 | return LLStringUtil::null; | ||
259 | } | ||
260 | #endif // RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
261 | |||
262 | // Checked: 2009-11-11 (RLVa-1.1.0a) | Added: RLVa-1.1.0a | ||
263 | const std::string& RlvStrings::getString(const std::string& strStringName) | ||
264 | { | ||
265 | static const std::string strMissing = "(Missing RLVa string)"; | ||
266 | std::map<std::string, std::string>::const_iterator itString = m_StringMap.find(strStringName); | ||
267 | return (itString != m_StringMap.end()) ? itString->second : strMissing; | ||
268 | } | ||
269 | |||
270 | // Checked: 2009-11-25 (RLVa-1.1.0f) | Added: RLVa-1.1.0f | ||
271 | const char* RlvStrings::getStringFromReturnCode(ERlvCmdRet eRet) | ||
272 | { | ||
273 | // TODO-RLVa: [2009-11-25] clean this up along with the calling code in process_chat_from_simulator() once we're happy with the output | ||
274 | switch (eRet) | ||
275 | { | ||
276 | case RLV_RET_SUCCESS_UNSET: | ||
277 | return "unset"; | ||
278 | case RLV_RET_SUCCESS_DUPLICATE: | ||
279 | return "duplicate"; | ||
280 | case RLV_RET_FAILED_SYNTAX: | ||
281 | return "syntax error"; | ||
282 | case RLV_RET_FAILED_OPTION: | ||
283 | return "invalid option"; | ||
284 | case RLV_RET_FAILED_PARAM: | ||
285 | return "invalid param"; | ||
286 | case RLV_RET_FAILED_LOCK: | ||
287 | return "locked command"; | ||
288 | case RLV_RET_FAILED_DISABLED: | ||
289 | return "disabled command"; | ||
290 | case RLV_RET_FAILED_UNKNOWN: | ||
291 | return "unknown command"; | ||
292 | case RLV_RET_FAILED_NOSHAREDROOT: | ||
293 | return "missing #RLV"; | ||
294 | // The following are identified by the chat verb | ||
295 | case RLV_RET_RETAINED: | ||
296 | case RLV_RET_SUCCESS: | ||
297 | case RLV_RET_FAILED: | ||
298 | break; | ||
299 | // The following shouldn't occur | ||
300 | case RLV_RET_UNKNOWN: | ||
301 | default: | ||
302 | RLV_ASSERT(false); | ||
303 | break; | ||
304 | }; | ||
305 | return NULL; | ||
306 | } | ||
307 | |||
308 | // Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b | ||
309 | std::string RlvStrings::getVersion(bool fLegacy /*=false*/) | ||
310 | { | ||
311 | return llformat("%s viewer v%d.%d.%d (%s %d.%d.%d.%d - RLVa %d.%d.%d)", | ||
312 | ( (!fLegacy) ? "RestrainedLove" : "RestrainedLife" ), | ||
313 | RLV_VERSION_MAJOR, RLV_VERSION_MINOR, RLV_VERSION_PATCH, | ||
314 | LLAppViewer::instance()->getSecondLifeTitle().c_str(), LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BUILD, | ||
315 | RLVa_VERSION_MAJOR, RLVa_VERSION_MINOR, RLVa_VERSION_PATCH); | ||
316 | } | ||
317 | |||
318 | // Checked: 2010-04-18 (RLVa-1.2.0e) | Added: RLVa-1.2.0e | ||
319 | std::string RlvStrings::getVersionAbout() | ||
320 | { | ||
321 | return llformat("RLV v%d.%d.%d / RLVa v%d.%d.%d%c" , | ||
322 | RLV_VERSION_MAJOR, RLV_VERSION_MINOR, RLV_VERSION_PATCH, | ||
323 | RLVa_VERSION_MAJOR, RLVa_VERSION_MINOR, RLVa_VERSION_PATCH, 'a' + RLVa_VERSION_BUILD); | ||
324 | } | ||
325 | |||
326 | // Checked: 2009-11-11 (RLVa-1.1.0a) | Modified: RLVa-1.1.0a | ||
327 | std::string RlvStrings::getVersionNum() | ||
328 | { | ||
329 | return llformat("%d%02d%02d%02d", RLV_VERSION_MAJOR, RLV_VERSION_MINOR, RLV_VERSION_PATCH, RLV_VERSION_BUILD); | ||
330 | } | ||
331 | |||
332 | // ============================================================================ | ||
333 | // Generic menu enablers | ||
334 | // | ||
335 | |||
336 | bool RlvEnableIfNot::handleEvent(LLPointer<LLEvent>, const LLSD& userdata) | ||
337 | { | ||
338 | bool fEnable = true; | ||
339 | if (rlv_handler_t::isEnabled()) | ||
340 | { | ||
341 | ERlvBehaviour eBhvr = RlvCommand::getBehaviourFromString(userdata["data"].asString()); | ||
342 | fEnable = (eBhvr != RLV_BHVR_UNKNOWN) ? !gRlvHandler.hasBehaviour(eBhvr) : true; | ||
343 | } | ||
344 | gMenuHolder->findControl(userdata["control"].asString())->setValue(fEnable); | ||
345 | return true; | ||
346 | } | ||
347 | |||
348 | // ============================================================================ | ||
349 | // Selection functors | ||
350 | // | ||
351 | |||
352 | // Checked: 2009-07-06 (RLVa-1.0.0c) | Modified: RLVa-0.2.0f | ||
353 | bool RlvSelectHasLockedAttach::apply(LLSelectNode* pNode) | ||
354 | { | ||
355 | return (pNode->getObject()) ? gRlvHandler.isLockedAttachment(pNode->getObject(), m_eLock) : false; | ||
356 | } | ||
357 | |||
358 | // Checked: 2009-07-05 (RLVa-1.0.0b) | Modified: RLVa-0.2.0f | ||
359 | bool RlvSelectIsOwnedByOrGroupOwned::apply(LLSelectNode* pNode) | ||
360 | { | ||
361 | return (pNode->mPermissions->isGroupOwned()) || (pNode->mPermissions->getOwner() == m_idAgent); | ||
362 | } | ||
363 | |||
364 | // Checked: 2009-05-31 (RLVa-0.2.0f) | Modified: RLVa-0.2.0f | ||
365 | bool RlvSelectIsSittingOn::apply(LLSelectNode* pNode) | ||
366 | { | ||
367 | return (pNode->getObject()) && (pNode->getObject()->getRootEdit() == m_pObject); | ||
368 | } | ||
369 | |||
370 | // ============================================================================ | ||
371 | // Various public helper functions | ||
372 | // | ||
373 | |||
374 | // Checked: 2009-10-10 (RLVa-1.0.5a) | Modified: RLVa-1.0.5a | ||
375 | BOOL rlvAttachToEnabler(void* pParam) | ||
376 | { | ||
377 | // Visually disable an option on the "Attach to (HUD)" submenu if: | ||
378 | // - the attachment point is locked non-detachable with an object attached | ||
379 | // - the attachment point is locked non-attachable | ||
380 | return (pParam != NULL) && | ||
381 | (!gRlvHandler.isLockedAttachment(((LLViewerJointAttachment*)pParam)->getObject(), RLV_LOCK_REMOVE)) && | ||
382 | (!gRlvHandler.isLockedAttachment((LLViewerJointAttachment*)pParam, RLV_LOCK_ADD)); | ||
383 | } | ||
384 | |||
385 | // Checked: 2009-10-04 (RLVa-1.0.4b) | Modified: RLVa-1.0.4b | ||
386 | BOOL rlvEnableWearEnabler(void* pParam) | ||
387 | { | ||
388 | // Visually disable the "Enable Wear" option when restricted from toggling it | ||
389 | return (!gRlvHandler.hasBehaviour(RLV_BHVR_DEFAULTWEAR)); | ||
390 | } | ||
391 | |||
392 | // Checked: 2009-11-15 (RLVa-1.1.0c) | Added: RLVa-1.1.0c | ||
393 | BOOL rlvEnableSharedWearEnabler(void* pParam) | ||
394 | { | ||
395 | // Visually disable the "Enable Shared Wear" option when at least one attachment is non-detachable | ||
396 | return (!gRlvHandler.hasLockedAttachment(RLV_LOCK_REMOVE)); | ||
397 | } | ||
398 | |||
399 | // ============================================================================ | ||
diff --git a/linden/indra/newview/rlvcommon.h b/linden/indra/newview/rlvcommon.h new file mode 100644 index 0000000..315b97a --- /dev/null +++ b/linden/indra/newview/rlvcommon.h | |||
@@ -0,0 +1,199 @@ | |||
1 | /** | ||
2 | * | ||
3 | * Copyright (c) 2009-2010, Kitty Barnett | ||
4 | * | ||
5 | * The source code in this file is provided to you under the terms of the | ||
6 | * GNU General Public License, version 2.0, but WITHOUT ANY WARRANTY; | ||
7 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
8 | * PARTICULAR PURPOSE. Terms of the GPL can be found in doc/GPL-license.txt | ||
9 | * in this distribution, or online at http://www.gnu.org/licenses/gpl-2.0.txt | ||
10 | * | ||
11 | * By copying, modifying or distributing this software, you acknowledge that | ||
12 | * you have read and understood your obligations described above, and agree to | ||
13 | * abide by those obligations. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #ifndef RLV_COMMON_H | ||
18 | #define RLV_COMMON_H | ||
19 | |||
20 | #include "llmemberlistener.h" | ||
21 | #include "llselectmgr.h" | ||
22 | #include "llviewercontrol.h" | ||
23 | #include "rlvdefines.h" | ||
24 | |||
25 | // ============================================================================ | ||
26 | // Forward declarations | ||
27 | // | ||
28 | |||
29 | class RlvCommand; | ||
30 | |||
31 | // ============================================================================ | ||
32 | // RlvNotifications | ||
33 | // | ||
34 | |||
35 | class RlvNotifications | ||
36 | { | ||
37 | public: | ||
38 | static void notifyBehaviour(ERlvBehaviour eBhvr, ERlvParamType eType); | ||
39 | static void notifyBlockedViewNote() { notifyBlockedViewXXX(LLAssetType::lookup(LLAssetType::AT_NOTECARD)); } | ||
40 | static void notifyBlockedViewScript() { notifyBlockedViewXXX(LLAssetType::lookup(LLAssetType::AT_SCRIPT)); } | ||
41 | static void notifyBlockedViewTexture() { notifyBlockedViewXXX(LLAssetType::lookup(LLAssetType::AT_TEXTURE)); } | ||
42 | |||
43 | static void warnGiveToRLV(); | ||
44 | protected: | ||
45 | static void notifyBlockedViewXXX(const char* pstrAssetType); | ||
46 | |||
47 | static void onGiveToRLVConfirmation(const LLSD& notification, const LLSD& response); | ||
48 | }; | ||
49 | |||
50 | // ============================================================================ | ||
51 | // RlvSettings | ||
52 | // | ||
53 | |||
54 | inline BOOL rlvGetSettingBOOL(const std::string& strSetting, BOOL fDefault) | ||
55 | { | ||
56 | return (gSavedSettings.controlExists(strSetting)) ? gSavedSettings.getBOOL(strSetting) : fDefault; | ||
57 | } | ||
58 | inline BOOL rlvGetPerUserSettingsBOOL(const std::string& strSetting, BOOL fDefault) | ||
59 | { | ||
60 | return (gSavedPerAccountSettings.controlExists(strSetting)) ? gSavedPerAccountSettings.getBOOL(strSetting) : fDefault; | ||
61 | } | ||
62 | |||
63 | class RlvSettings | ||
64 | { | ||
65 | public: | ||
66 | static BOOL getDebug() { return rlvGetSettingBOOL(RLV_SETTING_DEBUG, FALSE); } | ||
67 | static BOOL getForbidGiveToRLV() { return rlvGetSettingBOOL(RLV_SETTING_FORBIDGIVETORLV, TRUE); } | ||
68 | static BOOL getNoSetEnv() { return fNoSetEnv; } | ||
69 | |||
70 | #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS | ||
71 | static BOOL getEnableComposites() { return fCompositeFolders; } | ||
72 | #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS | ||
73 | static BOOL getEnableLegacyNaming() { return fLegacyNaming; } | ||
74 | static BOOL getEnableWear(); | ||
75 | static BOOL getEnableSharedWear(); | ||
76 | static BOOL getHideLockedLayers() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDLAYER, FALSE); } | ||
77 | static BOOL getHideLockedAttach() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDATTACH, FALSE); } | ||
78 | static BOOL getHideLockedInventory() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDINVENTORY, FALSE); } | ||
79 | static BOOL getSharedInvAutoRename() { return rlvGetSettingBOOL(RLV_SETTING_SHAREDINVAUTORENAME, TRUE); } | ||
80 | static BOOL getShowNameTags() { return fShowNameTags; } | ||
81 | |||
82 | #ifdef RLV_EXTENSION_STARTLOCATION | ||
83 | static BOOL getLoginLastLocation() { return rlvGetPerUserSettingsBOOL(RLV_SETTING_LOGINLASTLOCATION, TRUE); } | ||
84 | static void updateLoginLastLocation(); | ||
85 | #endif // RLV_EXTENSION_STARTLOCATION | ||
86 | |||
87 | static void initClass(); | ||
88 | protected: | ||
89 | static bool onChangedSettingBOOL(const LLSD& newvalue, BOOL* pfSetting); | ||
90 | |||
91 | #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS | ||
92 | static BOOL fCompositeFolders; | ||
93 | #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS | ||
94 | static BOOL fLegacyNaming; | ||
95 | static BOOL fNoSetEnv; | ||
96 | static BOOL fShowNameTags; | ||
97 | }; | ||
98 | |||
99 | #ifdef RLV_WORKAROUND_REZMULTIPLEATTACH | ||
100 | inline BOOL RlvSettings::getEnableSharedWear() | ||
101 | { | ||
102 | return FALSE; | ||
103 | } | ||
104 | #endif // RLV_WORKAROUND_REZMULTIPLEATTACH | ||
105 | |||
106 | // ============================================================================ | ||
107 | // RlvStrings | ||
108 | // | ||
109 | |||
110 | class RlvStrings | ||
111 | { | ||
112 | public: | ||
113 | static void initClass(); | ||
114 | |||
115 | static const std::string& getAnonym(const std::string& strName); // @shownames | ||
116 | static const std::string& getBehaviourNotificationString(ERlvBehaviour eBhvr, ERlvParamType eType); | ||
117 | static const std::string& getString(const std::string& strStringName); | ||
118 | static const char* getStringFromReturnCode(ERlvCmdRet eRet); | ||
119 | static std::string getVersion(bool fLegacy = false); // @version | ||
120 | static std::string getVersionAbout(); // Shown in Help / About | ||
121 | static std::string getVersionNum(); // @versionnum | ||
122 | |||
123 | protected: | ||
124 | static std::vector<std::string> m_Anonyms; | ||
125 | static std::map<std::string, std::string> m_StringMap; | ||
126 | #ifdef RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
127 | static std::map<ERlvBehaviour, std::string> m_BhvrAddMap; | ||
128 | static std::map<ERlvBehaviour, std::string> m_BhvrRemMap; | ||
129 | #endif // RLV_EXTENSION_NOTIFY_BEHAVIOUR | ||
130 | }; | ||
131 | |||
132 | // ============================================================================ | ||
133 | // Extensibility classes | ||
134 | // | ||
135 | |||
136 | class RlvBehaviourObserver | ||
137 | { | ||
138 | public: | ||
139 | virtual ~RlvBehaviourObserver() {} | ||
140 | virtual void changed(const RlvCommand& rlvCmd, bool fInternal) = 0; | ||
141 | }; | ||
142 | |||
143 | class RlvCommandHandler | ||
144 | { | ||
145 | public: | ||
146 | virtual ~RlvCommandHandler() {} | ||
147 | virtual bool onAddRemCommand(const LLUUID& idObj, const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) { return false; } | ||
148 | virtual bool onClearCommand(const LLUUID& idObj, const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) { return false; } | ||
149 | virtual bool onReplyCommand(const LLUUID& idObj, const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) { return false; } | ||
150 | virtual bool onForceCommand(const LLUUID& idObj, const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet) { return false; } | ||
151 | }; | ||
152 | typedef bool (RlvCommandHandler::*rlvCommandHandler)(const LLUUID& idObj, const RlvCommand& rlvCmd, ERlvCmdRet& cmdRet); | ||
153 | |||
154 | // ============================================================================ | ||
155 | // Generic menu enablers | ||
156 | // | ||
157 | |||
158 | class RlvEnableIfNot : public LLMemberListener<LLView> | ||
159 | { | ||
160 | bool handleEvent(LLPointer<LLEvent>, const LLSD&); | ||
161 | }; | ||
162 | |||
163 | // ============================================================================ | ||
164 | // Selection functors | ||
165 | // | ||
166 | |||
167 | struct RlvSelectHasLockedAttach : public LLSelectedNodeFunctor | ||
168 | { | ||
169 | RlvSelectHasLockedAttach(ERlvLockMask eLock) : m_eLock(eLock) {} | ||
170 | virtual bool apply(LLSelectNode* pNode); | ||
171 | protected: | ||
172 | ERlvLockMask m_eLock; | ||
173 | }; | ||
174 | |||
175 | struct RlvSelectIsOwnedByOrGroupOwned : public LLSelectedNodeFunctor | ||
176 | { | ||
177 | RlvSelectIsOwnedByOrGroupOwned(const LLUUID& uuid) : m_idAgent(uuid) {} | ||
178 | virtual bool apply(LLSelectNode* pNode); | ||
179 | LLUUID m_idAgent; | ||
180 | }; | ||
181 | |||
182 | struct RlvSelectIsSittingOn : public LLSelectedNodeFunctor | ||
183 | { | ||
184 | RlvSelectIsSittingOn(LLXform* pObject) : m_pObject(pObject) {} | ||
185 | virtual bool apply(LLSelectNode* pNode); | ||
186 | LLXform* m_pObject; | ||
187 | }; | ||
188 | |||
189 | // ============================================================================ | ||
190 | // Various public helper functions | ||
191 | // | ||
192 | |||
193 | BOOL rlvAttachToEnabler(void* pParam); | ||
194 | BOOL rlvEnableWearEnabler(void* pParam); | ||
195 | BOOL rlvEnableSharedWearEnabler(void* pParam); | ||
196 | |||
197 | // ============================================================================ | ||
198 | |||
199 | #endif // RLV_COMMON_H | ||