From d365a8881d1d1653566ad51a405bb472bce4dc0a Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 19 Mar 2013 14:53:46 +0100 Subject: [PATCH] Centralized calls to retrieve LLPanelPeople in getPeoplePanel() in FSCommon --- indra/newview/chatbar_as_cmdline.cpp | 8 ++++---- indra/newview/fscommon.cpp | 12 ++++++++++++ indra/newview/fscommon.h | 2 ++ indra/newview/fslslbridgerequest.cpp | 14 ++++++-------- indra/newview/fsslurlcommand.cpp | 5 +++-- indra/newview/llnetmap.cpp | 10 +++++----- indra/newview/llpanelpeoplemenus.cpp | 17 ++++++++++++----- indra/newview/llviewermessage.cpp | 10 ++++++---- 8 files changed, 50 insertions(+), 28 deletions(-) diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index 7cea21d588..fe3bf385dc 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -1163,11 +1163,11 @@ LLUUID cmdline_partial_name2key(std::string partial_name) std::string av_name; LLStringUtil::toLower(partial_name); - LLPanel* panel_people = LLFloaterSidePanelContainer::getPanel("people", "panel_people"); + LLPanelPeople* panel_people = getPeoplePanel(); if (panel_people) { std::vector items; - LLAvatarList* nearbyList = ((LLPanelPeople*)panel_people)->getNearbyList(); + LLAvatarList* nearbyList = panel_people->getNearbyList(); nearbyList->getItems(items); for (std::vector::const_iterator itItem = items.begin(); itItem != items.end(); ++itItem) @@ -1189,10 +1189,10 @@ LLUUID cmdline_partial_name2key(std::string partial_name) void cmdline_tp2name(std::string target) { LLUUID avkey = cmdline_partial_name2key(target); - LLPanel* panel_people = LLFloaterSidePanelContainer::getPanel("people", "panel_people"); + LLPanelPeople* panel_people = getPeoplePanel(); if (avkey.notNull() && panel_people) { - LLAvatarListItem* avatar_list_item = ((LLPanelPeople*)panel_people)->getNearbyList()->getAvatarListItem(avkey); + LLAvatarListItem* avatar_list_item = panel_people->getNearbyList()->getAvatarListItem(avkey); if (avatar_list_item) { LLVector3d pos = avatar_list_item->getPosition(); diff --git a/indra/newview/fscommon.cpp b/indra/newview/fscommon.cpp index b38eac6630..46d29129fc 100644 --- a/indra/newview/fscommon.cpp +++ b/indra/newview/fscommon.cpp @@ -28,7 +28,10 @@ #include "llviewerprecompiledheaders.h" #include "fscommon.h" + +#include "llfloatersidepanelcontainer.h" #include "llnotificationmanager.h" +#include "llpanel.h" #include #include @@ -111,6 +114,15 @@ std::string applyMuPose(const std::string& message) return utf8_text; } +LLPanelPeople* getPeoplePanel() +{ + LLPanel* panel_people = LLFloaterSidePanelContainer::getPanel("people", "panel_people"); + if (panel_people) + { + return dynamic_cast(panel_people); + } + return NULL; +} S32 FSCommon::secondsSinceEpochFromString(const std::string& format, const std::string& str) { diff --git a/indra/newview/fscommon.h b/indra/newview/fscommon.h index 5cdb528ad6..5a892eee38 100644 --- a/indra/newview/fscommon.h +++ b/indra/newview/fscommon.h @@ -29,10 +29,12 @@ #define FS_COMMON_H #include "llchat.h" +#include "llpanelpeople.h" void reportToNearbyChat(const std::string& message); std::string applyAutoCloseOoc(const std::string& message); std::string applyMuPose(const std::string& message); +LLPanelPeople* getPeoplePanel(); namespace FSCommon { diff --git a/indra/newview/fslslbridgerequest.cpp b/indra/newview/fslslbridgerequest.cpp index f85f3ea657..a4dd322593 100644 --- a/indra/newview/fslslbridgerequest.cpp +++ b/indra/newview/fslslbridgerequest.cpp @@ -26,17 +26,16 @@ */ #include "llviewerprecompiledheaders.h" + #include "fslslbridgerequest.h" + +#include "fscommon.h" #include "fslslbridge.h" -#include "llagent.h" // for gAgent -#include "llhttpclient.h" #include #include // for radar -#include "llpanel.h" #include "llpanelpeople.h" #include "llavatarlist.h" #include "llavatarlistitem.h" -#include "llfloatersidepanelcontainer.h" #ifdef LL_STANDALONE #include @@ -63,13 +62,13 @@ void FSLSLBridgeRequestManager::processBridgeCall(const LLSD& content) { std::string strContent = content.asString(); llinfos << "Got info: " << strContent << llendl; - } FSLSLBridgeRequestResponder::FSLSLBridgeRequestResponder() { //FSLSLBridgeRequestManager::instance().initSingleton(); } + //If we get back a normal response, handle it here void FSLSLBridgeRequestResponder::result(const LLSD& content) { @@ -88,17 +87,16 @@ void FSLSLBridgeRequestResponder::error(U32 status, const std::string& reason) << status << ": " << reason << ")" << llendl; } - // AO: The below handler is used to parse return data from the bridge, requesting bulk ZOffset updates. FSLSLBridgeRequestRadarPosResponder::FSLSLBridgeRequestRadarPosResponder() { } void FSLSLBridgeRequestRadarPosResponder::result(const LLSD& content) { - LLPanel* panel_people = LLFloaterSidePanelContainer::getPanel("people", "panel_people"); + LLPanelPeople* panel_people = getPeoplePanel(); if (panel_people) { - LLAvatarList* nearbyList = ((LLPanelPeople*)panel_people)->getNearbyList(); + LLAvatarList* nearbyList = panel_people->getNearbyList(); std::string strContent = content.asString(); //llinfos << "Got info: " << strContent << llendl; diff --git a/indra/newview/fsslurlcommand.cpp b/indra/newview/fsslurlcommand.cpp index cb19204c66..855193dec8 100644 --- a/indra/newview/fsslurlcommand.cpp +++ b/indra/newview/fsslurlcommand.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "fsslurlcommand.h" +#include "fscommon.h" #include "llagent.h" #include "llavataractions.h" #include "llavatarlist.h" @@ -39,7 +40,7 @@ LLAvatarListItem* getAvatarListItem(const LLUUID& avatar_id) { - LLPanelPeople* panel_people = dynamic_cast(LLFloaterSidePanelContainer::getPanel("people", "panel_people")); + LLPanelPeople* panel_people = getPeoplePanel(); if (panel_people) { return panel_people->getNearbyList()->getAvatarListItem(avatar_id); @@ -117,7 +118,7 @@ public: { if (gAgentID != target_id) { - LLPanelPeople* panel_people = dynamic_cast(LLFloaterSidePanelContainer::getPanel("people", "panel_people")); + LLPanelPeople* panel_people = getPeoplePanel(); LLAvatarListItem* avatar_list_item = getAvatarListItem(target_id); if (avatar_list_item && panel_people) { diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 0c5b033b40..5687440684 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -840,11 +840,11 @@ BOOL LLNetMap::handleToolTipAgent(const LLUUID& avatar_id) // aka radar when above 1020m. if (isHigher1020mBug) { - LLPanel* panel_people = LLFloaterSidePanelContainer::getPanel("people", "panel_people"); - if (panel_people != NULL) + LLPanelPeople* panel_people = getPeoplePanel(); + if (panel_people) { - LLAvatarListItem* avatar_list_item = ((LLPanelPeople*)panel_people)->getNearbyList()->getAvatarListItem(avatar_id); - if (avatar_list_item != NULL) + LLAvatarListItem* avatar_list_item = panel_people->getNearbyList()->getAvatarListItem(avatar_id); + if (avatar_list_item) { F32 radar_distance = avatar_list_item->getRange(); @@ -1304,7 +1304,7 @@ void LLNetMap::startTracking() { if (mClosestAgentAtLastRightClick.notNull()) { - LLPanelPeople* panel_people = (LLPanelPeople*)LLFloaterSidePanelContainer::getPanel("people", "panel_people"); + LLPanelPeople* panel_people = getPeoplePanel(); if (panel_people != NULL) { panel_people->startTracking(mClosestAgentAtLastRightClick); diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp index 7a598ed67a..e633d43f7a 100644 --- a/indra/newview/llpanelpeoplemenus.cpp +++ b/indra/newview/llpanelpeoplemenus.cpp @@ -38,9 +38,10 @@ #include "llavataractions.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llviewermenu.h" // for gMenuHolder -#include "llfloatersidepanelcontainer.h" #include "llpanelpeople.h" +#include "fscommon.h" + namespace LLPanelPeopleMenus { @@ -242,15 +243,21 @@ void NearbyMenu::teleportToAvatar() // AO: wrapper for functionality managed by LLPanelPeople, because it manages the nearby avatar list. // Will only work for avatars within radar range. { - LLPanelPeople* peoplePanel = dynamic_cast(LLFloaterSidePanelContainer::getPanel("people", "panel_people")); - peoplePanel->teleportToAvatar(mUUIDs.front()); + LLPanelPeople* peoplePanel = getPeoplePanel(); + if (peoplePanel) + { + peoplePanel->teleportToAvatar(mUUIDs.front()); + } } // Ansariel: Avatar tracking feature void NearbyMenu::onTrackAvatarMenuItemClick() { - LLPanelPeople* peoplePanel = dynamic_cast(LLFloaterSidePanelContainer::getPanel("people", "panel_people")); - peoplePanel->startTracking(mUUIDs.front()); + LLPanelPeople* peoplePanel = getPeoplePanel(); + if (peoplePanel) + { + peoplePanel->startTracking(mUUIDs.front()); + } } } // namespace LLPanelPeopleMenus diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 0ae64c551d..e60527cd92 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -5542,10 +5542,12 @@ void process_sound_trigger(LLMessageSystem *msg, void **) // AO: Hack for legacy radar script interface compatibility. Interpret certain // sound assets as a request for a full radar update to a channel if ((owner_id == gAgent.getID()) && (sound_id.asString() == gSavedSettings.getString("RadarLegacyChannelAlertRefreshUUID"))) - { - LLPanelPeople* pPeoplePanel = dynamic_cast(LLFloaterSidePanelContainer::getPanel("people", "panel_people")); - if (pPeoplePanel) - pPeoplePanel->requestRadarChannelAlertSync(); + { + LLPanelPeople* pPeoplePanel = getPeoplePanel(); + if (pPeoplePanel) + { + pPeoplePanel->requestRadarChannelAlertSync(); + } return; }