aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/rlvfloaterbehaviour.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-09-04 01:56:20 -0500
committerJacek Antonelli2009-09-04 03:39:51 -0500
commit89a510de10c48ebcf82b98a962e4bf66477dcc93 (patch)
treed30f79f433badffe36a67fc155e70a0e29dd2dc4 /linden/indra/newview/rlvfloaterbehaviour.cpp
parentBackported 1.23 fix for animation joint assertion crash. (diff)
downloadmeta-impy-89a510de10c48ebcf82b98a962e4bf66477dcc93.zip
meta-impy-89a510de10c48ebcf82b98a962e4bf66477dcc93.tar.gz
meta-impy-89a510de10c48ebcf82b98a962e4bf66477dcc93.tar.bz2
meta-impy-89a510de10c48ebcf82b98a962e4bf66477dcc93.tar.xz
Applied Kitty Barnett's RLVa 1.0.1h (Restrained Life) patch.
Made a few non-functional changes to help it apply.
Diffstat (limited to 'linden/indra/newview/rlvfloaterbehaviour.cpp')
-rw-r--r--linden/indra/newview/rlvfloaterbehaviour.cpp152
1 files changed, 152 insertions, 0 deletions
diff --git a/linden/indra/newview/rlvfloaterbehaviour.cpp b/linden/indra/newview/rlvfloaterbehaviour.cpp
new file mode 100644
index 0000000..39fcf12
--- /dev/null
+++ b/linden/indra/newview/rlvfloaterbehaviour.cpp
@@ -0,0 +1,152 @@
1#include "llviewerprecompiledheaders.h"
2
3#include "llagent.h"
4#include "llcachename.h"
5#include "llscrolllistctrl.h"
6#include "lluictrlfactory.h"
7#include "llviewerinventory.h"
8#include "llviewerobjectlist.h"
9#include "llvoavatar.h"
10
11#include "rlvfloaterbehaviour.h"
12
13// ============================================================================
14
15RlvFloaterBehaviour::RlvFloaterBehaviour(const LLSD& key)
16 : LLFloater(std::string("rlvBehaviours"))
17{
18 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_rlv_behaviour.xml");
19}
20
21
22void RlvFloaterBehaviour::show(void*)
23{
24 RlvFloaterBehaviour::showInstance();
25}
26
27void RlvFloaterBehaviour::refreshAll()
28{
29 LLVOAvatar* pAvatar = gAgent.getAvatarObject();
30 LLCtrlListInterface* pList = childGetListInterface("behaviour_list");
31 const rlv_object_map_t* pRlvObjects = gRlvHandler.getObjectMap();
32 if ( (!pAvatar) || (!pList) || (!pRlvObjects) )
33 return;
34
35 pList->operateOnAll(LLCtrlListInterface::OP_DELETE);
36
37 for (rlv_object_map_t::const_iterator itObj = pRlvObjects->begin(), endObj = pRlvObjects->end(); itObj != endObj; ++itObj)
38 {
39 std::string strName = itObj->first.asString();
40
41 LLViewerInventoryItem* pItem = NULL;
42 LLViewerObject* pObj = gObjectList.findObject(itObj->first);
43 if (pObj)
44 {
45 LLViewerJointAttachment* pAttachPt =
46 get_if_there(pAvatar->mAttachmentPoints, gRlvHandler.getAttachPointIndex(pObj), (LLViewerJointAttachment*)NULL);
47 if (pAttachPt)
48 {
49 pItem = gInventory.getItem(pAttachPt->getItemID());
50 }
51 }
52
53 if (pItem)
54 strName = pItem->getName();
55
56 const rlv_command_list_t* pCommands = itObj->second.getCommandList();
57 for (rlv_command_list_t::const_iterator itCmd = pCommands->begin(), endCmd = pCommands->end(); itCmd != endCmd; ++itCmd)
58 {
59 std::string strBhvr = itCmd->asString(); LLUUID uuid(itCmd->getOption());
60 if (uuid.notNull())
61 {
62 std::string strLookup;
63 if ( (gCacheName->getFullName(uuid, strLookup)) || (gCacheName->getGroupName(uuid, strLookup)) )
64 {
65 if (strLookup.find("???") == std::string::npos)
66 strBhvr.assign(itCmd->getBehaviour()).append(":").append(strLookup);
67 }
68 else if (m_PendingLookup.end() == std::find(m_PendingLookup.begin(), m_PendingLookup.end(), uuid))
69 {
70 gCacheName->get(uuid, FALSE, onAvatarNameLookup, this);
71 m_PendingLookup.push_back(uuid);
72 }
73 }
74
75 LLSD element;
76
77 // Restriction column
78 element["columns"][0]["column"] = "behaviour";
79 element["columns"][0]["value"] = strBhvr;
80 element["columns"][0]["font"] = "SANSSERIF";
81 element["columns"][0]["font-style"] = "NORMAL";
82
83 // Object Name column
84 element["columns"][1]["column"] = "name";
85 element["columns"][1]["value"] = strName;
86 element["columns"][1]["font"] = "SANSSERIF";
87 element["columns"][1]["font-style"] = "NORMAL";
88
89 pList->addElement(element, ADD_BOTTOM);
90 }
91 }
92}
93
94// ============================================================================
95/*
96 * LLFloater overrides
97 */
98
99BOOL RlvFloaterBehaviour::canClose()
100{
101 return !LLApp::isExiting();
102}
103
104void RlvFloaterBehaviour::onOpen()
105{
106 gRlvHandler.addBehaviourObserver(this);
107
108 refreshAll();
109}
110
111void RlvFloaterBehaviour::onClose(bool fQuitting)
112{
113 LLFloater::setVisible(FALSE);
114
115 gRlvHandler.removeBehaviourObserver(this);
116
117 for (std::list<LLUUID>::const_iterator itLookup = m_PendingLookup.begin(); itLookup != m_PendingLookup.end(); ++itLookup)
118 {
119 gCacheName->cancelCallback(*itLookup, onAvatarNameLookup, this);
120 }
121 m_PendingLookup.clear();
122}
123
124BOOL RlvFloaterBehaviour::postBuild()
125{
126 return TRUE;
127}
128
129// ============================================================================
130/*
131 * RlvBehaviourObserver overrides
132 */
133
134void RlvFloaterBehaviour::changed(const RlvCommand& /*rlvCmd*/, bool /*fInternal*/)
135{
136 refreshAll();
137}
138
139// ============================================================================
140
141void RlvFloaterBehaviour::onAvatarNameLookup(const LLUUID& uuid, const std::string& strFirst, const std::string& strLast, BOOL fGroup, void* pParam)
142{
143 RlvFloaterBehaviour* pSelf = (RlvFloaterBehaviour*)pParam;
144
145 std::list<LLUUID>::iterator itLookup = std::find(pSelf->m_PendingLookup.begin(), pSelf->m_PendingLookup.end(), uuid);
146 if (itLookup != pSelf->m_PendingLookup.end())
147 pSelf->m_PendingLookup.erase(itLookup);
148
149 pSelf->refreshAll();
150}
151
152// ============================================================================