diff options
Diffstat (limited to 'linden/indra/newview/rlvhelper.h')
-rw-r--r-- | linden/indra/newview/rlvhelper.h | 206 |
1 files changed, 127 insertions, 79 deletions
diff --git a/linden/indra/newview/rlvhelper.h b/linden/indra/newview/rlvhelper.h index 25d8174..1204146 100644 --- a/linden/indra/newview/rlvhelper.h +++ b/linden/indra/newview/rlvhelper.h | |||
@@ -1,13 +1,15 @@ | |||
1 | #ifndef RLV_HELPER_H | 1 | #ifndef RLV_HELPER_H |
2 | #define RLV_HELPER_H | 2 | #define RLV_HELPER_H |
3 | 3 | ||
4 | #include "llagent.h" | ||
4 | #include "llboost.h" | 5 | #include "llboost.h" |
6 | #include "llgesturemgr.h" | ||
5 | #include "llinventorymodel.h" | 7 | #include "llinventorymodel.h" |
6 | #include "llselectmgr.h" | 8 | #include "llviewerinventory.h" |
7 | #include "llviewercontrol.h" | 9 | #include "llvoavatar.h" |
8 | #include "llviewerobjectlist.h" | ||
9 | #include "llwlparamset.h" | 10 | #include "llwlparamset.h" |
10 | #include "rlvdefines.h" | 11 | #include "rlvdefines.h" |
12 | #include "rlvcommon.h" | ||
11 | 13 | ||
12 | #ifdef LL_WINDOWS | 14 | #ifdef LL_WINDOWS |
13 | #pragma warning (push) | 15 | #pragma warning (push) |
@@ -40,7 +42,7 @@ public: | |||
40 | bool isStrict() const { return m_fStrict; } | 42 | bool isStrict() const { return m_fStrict; } |
41 | bool isValid() const { return m_fValid; } | 43 | bool isValid() const { return m_fValid; } |
42 | 44 | ||
43 | static ERlvBehaviour getBehaviourFromString(const std::string& strBhvr); | 45 | static ERlvBehaviour getBehaviourFromString(const std::string& strBhvr, bool* pfStrict = NULL); |
44 | static const std::string& getStringFromBehaviour(ERlvBehaviour eBhvr); | 46 | static const std::string& getStringFromBehaviour(ERlvBehaviour eBhvr); |
45 | static bool hasStrictVariant(ERlvBehaviour eBhvr); | 47 | static bool hasStrictVariant(ERlvBehaviour eBhvr); |
46 | 48 | ||
@@ -122,8 +124,9 @@ public: | |||
122 | * Member functions | 124 | * Member functions |
123 | */ | 125 | */ |
124 | public: | 126 | public: |
125 | static void forceAttach(const LLUUID& idItem, S32 idxAttachPt); | 127 | // NOTE: the following two do *not* respect attachment locks so use with care |
126 | static void forceDetach(LLViewerJointAttachment* pAttachPt); | 128 | static void attach(const LLUUID& idItem, S32 idxAttachPt); |
129 | static void detach(LLViewerJointAttachment* pAttachPt); | ||
127 | protected: | 130 | protected: |
128 | void startTimer() { if (!m_pTimer) m_pTimer = new RlvAttachmentManagerTimer(this); } | 131 | void startTimer() { if (!m_pTimer) m_pTimer = new RlvAttachmentManagerTimer(this); } |
129 | 132 | ||
@@ -212,8 +215,12 @@ public: | |||
212 | std::string strFolderName = pFolder->getName(); | 215 | std::string strFolderName = pFolder->getName(); |
213 | LLStringUtil::toLower(strFolderName); | 216 | LLStringUtil::toLower(strFolderName); |
214 | 217 | ||
215 | if ( (strFolderName.empty()) || (RLV_FOLDER_PREFIX_HIDDEN == strFolderName[0]) ) | 218 | // NOTE: hidden or "give to #RLV" folders can never be a match |
219 | if ( (strFolderName.empty()) || | ||
220 | (RLV_FOLDER_PREFIX_HIDDEN == strFolderName[0]) || (RLV_FOLDER_PREFIX_PUTINV == strFolderName[0]) ) | ||
221 | { | ||
216 | return false; | 222 | return false; |
223 | } | ||
217 | 224 | ||
218 | for (std::list<std::string>::const_iterator itCrit = m_Criteria.begin(); itCrit != m_Criteria.end(); ++itCrit) | 225 | for (std::list<std::string>::const_iterator itCrit = m_Criteria.begin(); itCrit != m_Criteria.end(); ++itCrit) |
219 | if (std::string::npos == strFolderName.find(*itCrit)) // Return false on the first mismatch | 226 | if (std::string::npos == strFolderName.find(*itCrit)) // Return false on the first mismatch |
@@ -257,17 +264,97 @@ protected: | |||
257 | }; | 264 | }; |
258 | 265 | ||
259 | // ============================================================================ | 266 | // ============================================================================ |
267 | // RlvForceWear | ||
268 | // | ||
269 | |||
270 | class RlvForceWear | ||
271 | { | ||
272 | public: | ||
273 | // Folders | ||
274 | enum eWearAction { ACTION_ATTACH, ACTION_DETACH }; | ||
275 | enum eWearFlags { FLAG_NONE = 0x00, FLAG_MATCHALL = 0x01, FLAG_DEFAULT = FLAG_NONE }; | ||
276 | void forceFolder(const LLViewerInventoryCategory* pFolder, eWearAction eAction, eWearFlags eFlags); | ||
277 | |||
278 | // Attachments | ||
279 | static bool isForceDetachable(LLViewerJointAttachment* pAttachPt, bool fCheckComposite = true, LLViewerObject* pExceptObj = NULL); | ||
280 | void forceDetach(LLViewerJointAttachment* ptAttachPt); | ||
281 | |||
282 | // Wearables | ||
283 | static bool isForceRemovable(EWearableType wtType, bool fCheckComposite = true, const LLUUID& idExcept = LLUUID::null); | ||
284 | void forceRemove(EWearableType wtType); | ||
285 | |||
286 | // General purpose | ||
287 | static bool isWearableItem(const LLInventoryItem* pItem); | ||
288 | static bool isWearingItem(const LLInventoryItem* pItem); | ||
289 | |||
290 | public: | ||
291 | void done() { processRem(); processAdd(); } | ||
292 | protected: | ||
293 | void processAdd(); | ||
294 | void processRem(); | ||
295 | static void onWearableArrived(LLWearable* pWearable, void* pParam); | ||
296 | |||
297 | protected: | ||
298 | LLInventoryModel::item_array_t m_addAttachments, m_addWearables, m_addGestures, m_remGestures; | ||
299 | std::list<LLViewerJointAttachment*> m_remAttachments; | ||
300 | std::list<EWearableType> m_remWearables; | ||
301 | }; | ||
302 | |||
303 | // ============================================================================ | ||
304 | // RlvBehaviourNotifyObserver | ||
305 | // | ||
306 | |||
307 | class RlvBehaviourNotifyObserver : public RlvBehaviourObserver | ||
308 | { | ||
309 | public: | ||
310 | virtual ~RlvBehaviourNotifyObserver() { } | ||
311 | virtual void changed(const RlvCommand& rlvCmd, bool fInternal); | ||
312 | |||
313 | void addNotify(const LLUUID& idObj, S32 nChannel, const std::string& strFilter) | ||
314 | { | ||
315 | m_Notifications.insert(std::pair<LLUUID, notifyData>(idObj, notifyData(nChannel, strFilter))); | ||
316 | } | ||
317 | void clearNotify(const LLUUID& idObj) | ||
318 | { | ||
319 | m_Notifications.erase(idObj); | ||
320 | } | ||
321 | bool hasNotify() | ||
322 | { | ||
323 | return (m_Notifications.size() != 0); | ||
324 | } | ||
325 | void removeNotify(const LLUUID& idObj, S32 nChannel, const std::string& strFilter) | ||
326 | { | ||
327 | for (std::multimap<LLUUID, notifyData>::iterator itNotify = m_Notifications.lower_bound(idObj), | ||
328 | endNotify = m_Notifications.upper_bound(idObj); itNotify != endNotify; ++itNotify) | ||
329 | { | ||
330 | if ( (itNotify->second.nChannel == nChannel) && (itNotify->second.strFilter == strFilter) ) | ||
331 | { | ||
332 | m_Notifications.erase(itNotify); | ||
333 | break; | ||
334 | } | ||
335 | } | ||
336 | } | ||
337 | protected: | ||
338 | struct notifyData | ||
339 | { | ||
340 | S32 nChannel; | ||
341 | std::string strFilter; | ||
342 | notifyData(S32 channel, const std::string& filter) : nChannel(channel), strFilter(filter) {} | ||
343 | }; | ||
344 | std::multimap<LLUUID, notifyData> m_Notifications; | ||
345 | }; | ||
346 | |||
347 | // ============================================================================ | ||
260 | // RlvRetainedCommand | 348 | // RlvRetainedCommand |
261 | // | 349 | // |
262 | 350 | ||
263 | struct RlvRetainedCommand | 351 | struct RlvRetainedCommand |
264 | { | 352 | { |
265 | public: | 353 | public: |
266 | std::string strObject; | ||
267 | LLUUID idObject; | 354 | LLUUID idObject; |
268 | std::string strCmd; | 355 | RlvCommand rlvCmd; |
269 | 356 | ||
270 | RlvRetainedCommand(const std::string obj, const LLUUID& uuid, const std::string& cmd) : strObject(obj), idObject(uuid), strCmd(cmd) {} | 357 | RlvRetainedCommand(const LLUUID& uuid, const RlvCommand& cmd) : idObject(uuid), rlvCmd(cmd) {} |
271 | private: | 358 | private: |
272 | RlvRetainedCommand(); | 359 | RlvRetainedCommand(); |
273 | }; | 360 | }; |
@@ -309,43 +396,6 @@ private: | |||
309 | }; | 396 | }; |
310 | 397 | ||
311 | // ============================================================================ | 398 | // ============================================================================ |
312 | // RlvSettings | ||
313 | // | ||
314 | |||
315 | inline BOOL rlvGetSettingBOOL(const std::string& strSetting, BOOL fDefault) | ||
316 | { | ||
317 | return (gSavedSettings.controlExists(strSetting)) ? gSavedSettings.getBOOL(strSetting) : fDefault; | ||
318 | } | ||
319 | inline BOOL rlvGetPerUserSettingsBOOL(const std::string& strSetting, BOOL fDefault) | ||
320 | { | ||
321 | return (gSavedPerAccountSettings.controlExists(strSetting)) ? gSavedPerAccountSettings.getBOOL(strSetting) : fDefault; | ||
322 | } | ||
323 | |||
324 | class RlvSettings | ||
325 | { | ||
326 | public: | ||
327 | static BOOL getDebug() { return rlvGetSettingBOOL(RLV_SETTING_DEBUG, FALSE); } | ||
328 | static BOOL getForbidGiveToRLV() { return rlvGetSettingBOOL(RLV_SETTING_FORBIDGIVETORLV, TRUE); } | ||
329 | |||
330 | static BOOL getEnableWear(); | ||
331 | static BOOL getHideLockedLayers() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDLAYER, FALSE); } | ||
332 | static BOOL getHideLockedAttach() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDATTACH, FALSE); } | ||
333 | static BOOL getHideLockedInventory() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDINVENTORY, FALSE); } | ||
334 | static BOOL getShowNameTags() { return fShowNameTags; } | ||
335 | |||
336 | #ifdef RLV_EXTENSION_STARTLOCATION | ||
337 | static BOOL getLoginLastLocation() { return rlvGetPerUserSettingsBOOL(RLV_SETTING_LOGINLASTLOCATION, TRUE); } | ||
338 | static void updateLoginLastLocation(); | ||
339 | #endif // RLV_EXTENSION_STARTLOCATION | ||
340 | |||
341 | static BOOL fShowNameTags; | ||
342 | }; | ||
343 | |||
344 | // ============================================================================ | ||
345 | // State keeping classes/structure | ||
346 | // | ||
347 | |||
348 | // ============================================================================ | ||
349 | // Various helper classes/timers/functors | 399 | // Various helper classes/timers/functors |
350 | // | 400 | // |
351 | 401 | ||
@@ -367,39 +417,21 @@ public: | |||
367 | void fetchItem(const LLUUID& idItem); | 417 | void fetchItem(const LLUUID& idItem); |
368 | }; | 418 | }; |
369 | 419 | ||
370 | struct RlvSelectHasLockedAttach : public LLSelectedNodeFunctor | 420 | class RlvGiveToRLVAgentOffer : public LLInventoryFetchDescendentsObserver |
371 | { | ||
372 | RlvSelectHasLockedAttach(ERlvLockMask eLock) : m_eLock(eLock) {} | ||
373 | virtual bool apply(LLSelectNode* pNode); | ||
374 | protected: | ||
375 | ERlvLockMask m_eLock; | ||
376 | }; | ||
377 | |||
378 | struct RlvSelectIsOwnedByOrGroupOwned : public LLSelectedNodeFunctor | ||
379 | { | 421 | { |
380 | RlvSelectIsOwnedByOrGroupOwned(const LLUUID& uuid) : m_idAgent(uuid) {} | 422 | public: |
381 | virtual bool apply(LLSelectNode* pNode); | 423 | RlvGiveToRLVAgentOffer() {} |
382 | LLUUID m_idAgent; | 424 | virtual void done(); |
383 | }; | ||
384 | |||
385 | struct RlvSelectIsSittingOn : public LLSelectedNodeFunctor | ||
386 | { | ||
387 | RlvSelectIsSittingOn(LLXform* pObject) : m_pObject(pObject) {} | ||
388 | virtual bool apply(LLSelectNode* pNode); | ||
389 | LLXform* m_pObject; | ||
390 | }; | 425 | }; |
391 | 426 | ||
392 | // ============================================================================ | 427 | // ============================================================================ |
393 | // Various helper functions | 428 | // Various helper functions |
394 | // | 429 | // |
395 | 430 | ||
396 | BOOL rlvAttachToEnabler(void* pParam); | ||
397 | bool rlvCanDeleteOrReturn(); | 431 | bool rlvCanDeleteOrReturn(); |
398 | BOOL rlvEnableWearEnabler(void* pParam); | ||
399 | S32 rlvGetDirectDescendentsCount(const LLInventoryCategory* pFolder, LLAssetType::EType type); | 432 | S32 rlvGetDirectDescendentsCount(const LLInventoryCategory* pFolder, LLAssetType::EType type); |
400 | bool rlvIsEmote(const std::string& strUTF8Text); | 433 | bool rlvIsEmote(const std::string& strUTF8Text); |
401 | bool rlvIsValidReplyChannel(S32 nChannel); | 434 | bool rlvIsValidReplyChannel(S32 nChannel); |
402 | bool rlvIsWearingItem(const LLInventoryItem* pItem); | ||
403 | 435 | ||
404 | void rlvSendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession = LLUUID::null); | 436 | void rlvSendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession = LLUUID::null); |
405 | bool rlvSendChatReply(const std::string& strChannel, const std::string& strReply); | 437 | bool rlvSendChatReply(const std::string& strChannel, const std::string& strReply); |
@@ -439,16 +471,6 @@ inline bool RlvCommand::operator ==(const RlvCommand& rhs) const | |||
439 | ( (RLV_TYPE_UNKNOWN != m_eParamType) ? (m_eParamType == rhs.m_eParamType) : (m_strParam == rhs.m_strParam) ); | 471 | ( (RLV_TYPE_UNKNOWN != m_eParamType) ? (m_eParamType == rhs.m_eParamType) : (m_strParam == rhs.m_strParam) ); |
440 | } | 472 | } |
441 | 473 | ||
442 | inline void RlvCurrentlyWorn::fetchItem(const LLUUID& idItem) | ||
443 | { | ||
444 | if (idItem.notNull()) | ||
445 | { | ||
446 | LLInventoryFetchObserver::item_ref_t idItems; | ||
447 | idItems.push_back(idItem); | ||
448 | fetchItems(idItems); | ||
449 | } | ||
450 | } | ||
451 | |||
452 | inline bool RlvCommand::hasStrictVariant(ERlvBehaviour eBhvr) | 474 | inline bool RlvCommand::hasStrictVariant(ERlvBehaviour eBhvr) |
453 | { | 475 | { |
454 | switch (eBhvr) | 476 | switch (eBhvr) |
@@ -465,6 +487,32 @@ inline bool RlvCommand::hasStrictVariant(ERlvBehaviour eBhvr) | |||
465 | } | 487 | } |
466 | } | 488 | } |
467 | 489 | ||
490 | inline void RlvCurrentlyWorn::fetchItem(const LLUUID& idItem) | ||
491 | { | ||
492 | if (idItem.notNull()) | ||
493 | { | ||
494 | LLInventoryFetchObserver::item_ref_t idItems; | ||
495 | idItems.push_back(idItem); | ||
496 | fetchItems(idItems); | ||
497 | } | ||
498 | } | ||
499 | |||
500 | // Checked: 2009-12-18 (RLVa-1.1.0k) | Added: RLVa-1.1.0i | ||
501 | inline bool RlvForceWear::isWearableItem(const LLInventoryItem* pItem) | ||
502 | { | ||
503 | return (LLAssetType::AT_OBJECT == pItem->getType()) || (LLAssetType::AT_GESTURE == pItem->getType()) || | ||
504 | (LLAssetType::AT_BODYPART == pItem->getType()) || (LLAssetType::AT_CLOTHING == pItem->getType()); | ||
505 | } | ||
506 | |||
507 | // Checked: 2009-12-18 (RLVa-1.1.0k) | Modified: RLVa-1.1.0i | ||
508 | inline bool RlvForceWear::isWearingItem(const LLInventoryItem* pItem) | ||
509 | { | ||
510 | return | ||
511 | ((LLAssetType::AT_OBJECT == pItem->getType()) && (gAgent.getAvatarObject()->isWearingAttachment(pItem->getUUID()))) || | ||
512 | ((LLAssetType::AT_GESTURE == pItem->getType()) && (gGestureManager.isGestureActive(pItem->getUUID()))) || | ||
513 | (gAgent.isWearingItem(pItem->getUUID())); | ||
514 | } | ||
515 | |||
468 | // ============================================================================ | 516 | // ============================================================================ |
469 | // Inlined helper functions | 517 | // Inlined helper functions |
470 | // | 518 | // |