From 89a510de10c48ebcf82b98a962e4bf66477dcc93 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 4 Sep 2009 01:56:20 -0500 Subject: Applied Kitty Barnett's RLVa 1.0.1h (Restrained Life) patch. Made a few non-functional changes to help it apply. --- linden/indra/newview/rlvfloaterbehaviour.cpp | 152 +++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 linden/indra/newview/rlvfloaterbehaviour.cpp (limited to 'linden/indra/newview/rlvfloaterbehaviour.cpp') 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 @@ +#include "llviewerprecompiledheaders.h" + +#include "llagent.h" +#include "llcachename.h" +#include "llscrolllistctrl.h" +#include "lluictrlfactory.h" +#include "llviewerinventory.h" +#include "llviewerobjectlist.h" +#include "llvoavatar.h" + +#include "rlvfloaterbehaviour.h" + +// ============================================================================ + +RlvFloaterBehaviour::RlvFloaterBehaviour(const LLSD& key) + : LLFloater(std::string("rlvBehaviours")) +{ + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_rlv_behaviour.xml"); +} + + +void RlvFloaterBehaviour::show(void*) +{ + RlvFloaterBehaviour::showInstance(); +} + +void RlvFloaterBehaviour::refreshAll() +{ + LLVOAvatar* pAvatar = gAgent.getAvatarObject(); + LLCtrlListInterface* pList = childGetListInterface("behaviour_list"); + const rlv_object_map_t* pRlvObjects = gRlvHandler.getObjectMap(); + if ( (!pAvatar) || (!pList) || (!pRlvObjects) ) + return; + + pList->operateOnAll(LLCtrlListInterface::OP_DELETE); + + for (rlv_object_map_t::const_iterator itObj = pRlvObjects->begin(), endObj = pRlvObjects->end(); itObj != endObj; ++itObj) + { + std::string strName = itObj->first.asString(); + + LLViewerInventoryItem* pItem = NULL; + LLViewerObject* pObj = gObjectList.findObject(itObj->first); + if (pObj) + { + LLViewerJointAttachment* pAttachPt = + get_if_there(pAvatar->mAttachmentPoints, gRlvHandler.getAttachPointIndex(pObj), (LLViewerJointAttachment*)NULL); + if (pAttachPt) + { + pItem = gInventory.getItem(pAttachPt->getItemID()); + } + } + + if (pItem) + strName = pItem->getName(); + + const rlv_command_list_t* pCommands = itObj->second.getCommandList(); + for (rlv_command_list_t::const_iterator itCmd = pCommands->begin(), endCmd = pCommands->end(); itCmd != endCmd; ++itCmd) + { + std::string strBhvr = itCmd->asString(); LLUUID uuid(itCmd->getOption()); + if (uuid.notNull()) + { + std::string strLookup; + if ( (gCacheName->getFullName(uuid, strLookup)) || (gCacheName->getGroupName(uuid, strLookup)) ) + { + if (strLookup.find("???") == std::string::npos) + strBhvr.assign(itCmd->getBehaviour()).append(":").append(strLookup); + } + else if (m_PendingLookup.end() == std::find(m_PendingLookup.begin(), m_PendingLookup.end(), uuid)) + { + gCacheName->get(uuid, FALSE, onAvatarNameLookup, this); + m_PendingLookup.push_back(uuid); + } + } + + LLSD element; + + // Restriction column + element["columns"][0]["column"] = "behaviour"; + element["columns"][0]["value"] = strBhvr; + element["columns"][0]["font"] = "SANSSERIF"; + element["columns"][0]["font-style"] = "NORMAL"; + + // Object Name column + element["columns"][1]["column"] = "name"; + element["columns"][1]["value"] = strName; + element["columns"][1]["font"] = "SANSSERIF"; + element["columns"][1]["font-style"] = "NORMAL"; + + pList->addElement(element, ADD_BOTTOM); + } + } +} + +// ============================================================================ +/* + * LLFloater overrides + */ + +BOOL RlvFloaterBehaviour::canClose() +{ + return !LLApp::isExiting(); +} + +void RlvFloaterBehaviour::onOpen() +{ + gRlvHandler.addBehaviourObserver(this); + + refreshAll(); +} + +void RlvFloaterBehaviour::onClose(bool fQuitting) +{ + LLFloater::setVisible(FALSE); + + gRlvHandler.removeBehaviourObserver(this); + + for (std::list::const_iterator itLookup = m_PendingLookup.begin(); itLookup != m_PendingLookup.end(); ++itLookup) + { + gCacheName->cancelCallback(*itLookup, onAvatarNameLookup, this); + } + m_PendingLookup.clear(); +} + +BOOL RlvFloaterBehaviour::postBuild() +{ + return TRUE; +} + +// ============================================================================ +/* + * RlvBehaviourObserver overrides + */ + +void RlvFloaterBehaviour::changed(const RlvCommand& /*rlvCmd*/, bool /*fInternal*/) +{ + refreshAll(); +} + +// ============================================================================ + +void RlvFloaterBehaviour::onAvatarNameLookup(const LLUUID& uuid, const std::string& strFirst, const std::string& strLast, BOOL fGroup, void* pParam) +{ + RlvFloaterBehaviour* pSelf = (RlvFloaterBehaviour*)pParam; + + std::list::iterator itLookup = std::find(pSelf->m_PendingLookup.begin(), pSelf->m_PendingLookup.end(), uuid); + if (itLookup != pSelf->m_PendingLookup.end()) + pSelf->m_PendingLookup.erase(itLookup); + + pSelf->refreshAll(); +} + +// ============================================================================ -- cgit v1.1