Merge branch 'master' of git://github.com/Shyotl/SingularityViewer

This commit is contained in:
Lirusaito
2012-12-28 01:21:28 -05:00
2 changed files with 50 additions and 37 deletions

View File

@@ -161,7 +161,10 @@ LLAvatarListEntry::LLAvatarListEntry(const LLUUID& id, const std::string &name,
mIsInList(false), mAge(-1), mAgeAlert(false), mTime(time(NULL)) mIsInList(false), mAge(-1), mAgeAlert(false), mTime(time(NULL))
{ {
if (mID.notNull()) if (mID.notNull())
{
LLAvatarPropertiesProcessor::getInstance()->addObserver(mID, this); LLAvatarPropertiesProcessor::getInstance()->addObserver(mID, this);
LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(mID);
}
} }
LLAvatarListEntry::~LLAvatarListEntry() LLAvatarListEntry::~LLAvatarListEntry()
@@ -175,6 +178,7 @@ void LLAvatarListEntry::processProperties(void* data, EAvatarProcessorType type)
{ {
if(type == APT_PROPERTIES) if(type == APT_PROPERTIES)
{ {
LLAvatarPropertiesProcessor::getInstance()->removeObserver(mID, this);
const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>(data); const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>(data);
if (pAvatarData && (pAvatarData->avatar_id != LLUUID::null)) if (pAvatarData && (pAvatarData->avatar_id != LLUUID::null))
{ {
@@ -608,10 +612,9 @@ void LLFloaterAvatarList::updateAvatarList()
else else
{ {
// Avatar not there yet, add it // Avatar not there yet, add it
LLAvatarListEntry entry(avid, name, position);
if(announce && avatarp->getRegion() == gAgent.getRegion()) if(announce && avatarp->getRegion() == gAgent.getRegion())
announce_keys.push(avid); announce_keys.push(avid);
mAvatars.push_back(entry); mAvatars.push_back(LLAvatarListEntryPtr(new LLAvatarListEntry(avid, name, position)));
} }
} }
else else
@@ -640,10 +643,9 @@ void LLFloaterAvatarList::updateAvatarList()
} }
else else
{ {
LLAvatarListEntry entry(avid, name, position);
if(announce && gAgent.getRegion()->pointInRegionGlobal(position)) if(announce && gAgent.getRegion()->pointInRegionGlobal(position))
announce_keys.push(avid); announce_keys.push(avid);
mAvatars.push_back(entry); mAvatars.push_back(LLAvatarListEntryPtr(new LLAvatarListEntry(avid, name, position)));
} }
} }
} }
@@ -707,10 +709,19 @@ void LLFloaterAvatarList::expireAvatarList()
// llinfos << "radar: expiring" << llendl; // llinfos << "radar: expiring" << llendl;
for(av_list_t::iterator it = mAvatars.begin(); it != mAvatars.end();) for(av_list_t::iterator it = mAvatars.begin(); it != mAvatars.end();)
{ {
if(!it->isDead()) LLAvatarListEntry* entry = it->get();
(it++)->getAlive(); if(!entry->isDead())
{
entry->getAlive();
++it;
}
else else
{ {
if(mAvatars.back() == *it)
{
mAvatars.pop_back();
return;
}
*it = mAvatars.back(); *it = mAvatars.back();
mAvatars.pop_back(); mAvatars.pop_back();
if(mAvatars.empty()) if(mAvatars.empty())
@@ -771,17 +782,17 @@ void LLFloaterAvatarList::refreshAvatarList()
std::string av_name; std::string av_name;
// Skip if avatar hasn't been around // Skip if avatar hasn't been around
if (entry.isDead()) if (entry->isDead())
{ {
continue; continue;
} }
entry.setInList(); entry->setInList();
av_id = entry.getID(); av_id = entry->getID();
av_name = entry.getName().c_str(); av_name = entry->getName().c_str();
LLVector3d position = entry.getPosition(); LLVector3d position = entry->getPosition();
BOOL UnknownAltitude = false; BOOL UnknownAltitude = false;
LLVector3d delta = position - mypos; LLVector3d delta = position - mypos;
@@ -814,14 +825,13 @@ void LLFloaterAvatarList::refreshAvatarList()
} }
//Request properties here, so we'll have them later on when we need them //Request properties here, so we'll have them later on when we need them
LLAvatarPropertiesProcessor::getInstance()->addObserver(entry.mID, &entry);
LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(entry.mID);
element["id"] = av_id; element["id"] = av_id;
element["columns"][LIST_MARK]["column"] = "marked"; element["columns"][LIST_MARK]["column"] = "marked";
element["columns"][LIST_MARK]["type"] = "text"; element["columns"][LIST_MARK]["type"] = "text";
if (entry.isMarked()) if (entry->isMarked())
{ {
element["columns"][LIST_MARK]["value"] = "X"; element["columns"][LIST_MARK]["value"] = "X";
element["columns"][LIST_MARK]["color"] = LLColor4::blue.getValue(); element["columns"][LIST_MARK]["color"] = LLColor4::blue.getValue();
@@ -835,7 +845,7 @@ void LLFloaterAvatarList::refreshAvatarList()
element["columns"][LIST_AVATAR_NAME]["column"] = "avatar_name"; element["columns"][LIST_AVATAR_NAME]["column"] = "avatar_name";
element["columns"][LIST_AVATAR_NAME]["type"] = "text"; element["columns"][LIST_AVATAR_NAME]["type"] = "text";
element["columns"][LIST_AVATAR_NAME]["value"] = av_name; element["columns"][LIST_AVATAR_NAME]["value"] = av_name;
if (entry.isFocused()) if (entry->isFocused())
{ {
element["columns"][LIST_AVATAR_NAME]["font-style"] = "BOLD"; element["columns"][LIST_AVATAR_NAME]["font-style"] = "BOLD";
} }
@@ -843,7 +853,7 @@ void LLFloaterAvatarList::refreshAvatarList()
//<edit> custom colors for certain types of avatars! //<edit> custom colors for certain types of avatars!
//Changed a bit so people can modify them in settings. And since they're colors, again it's possibly account-based. Starting to think I need a function just to determine that. - HgB //Changed a bit so people can modify them in settings. And since they're colors, again it's possibly account-based. Starting to think I need a function just to determine that. - HgB
//element["columns"][LIST_AVATAR_NAME]["color"] = gColors.getColor( "MapAvatar" ).getValue(); //element["columns"][LIST_AVATAR_NAME]["color"] = gColors.getColor( "MapAvatar" ).getValue();
LLViewerRegion* parent_estate = LLWorld::getInstance()->getRegionFromPosGlobal(entry.getPosition()); LLViewerRegion* parent_estate = LLWorld::getInstance()->getRegionFromPosGlobal(entry->getPosition());
LLUUID estate_owner = LLUUID::null; LLUUID estate_owner = LLUUID::null;
if(parent_estate && parent_estate->isAlive()) if(parent_estate && parent_estate->isAlive())
{ {
@@ -895,7 +905,7 @@ void LLFloaterAvatarList::refreshAvatarList()
if (UnknownAltitude) if (UnknownAltitude)
{ {
strcpy(temp, "?"); strcpy(temp, "?");
if (entry.isDrawn()) if (entry->isDrawn())
{ {
color = sRadarTextDrawDist; color = sRadarTextDrawDist;
} }
@@ -916,7 +926,7 @@ void LLFloaterAvatarList::refreshAvatarList()
} }
else else
{ {
if (entry.isDrawn()) if (entry->isDrawn())
{ {
color = sRadarTextDrawDist; color = sRadarTextDrawDist;
} }
@@ -975,7 +985,7 @@ void LLFloaterAvatarList::refreshAvatarList()
std::string activity_icon = ""; std::string activity_icon = "";
std::string activity_tip = ""; std::string activity_tip = "";
switch(entry.getActivity()) switch(entry->getActivity())
{ {
case LLAvatarListEntry::ACTIVITY_MOVING: case LLAvatarListEntry::ACTIVITY_MOVING:
{ {
@@ -1030,17 +1040,17 @@ void LLFloaterAvatarList::refreshAvatarList()
element["columns"][LIST_AGE]["column"] = "age"; element["columns"][LIST_AGE]["column"] = "age";
element["columns"][LIST_AGE]["type"] = "text"; element["columns"][LIST_AGE]["type"] = "text";
color = sDefaultListText; color = sDefaultListText;
std::string age = boost::lexical_cast<std::string>(entry.mAge); std::string age = boost::lexical_cast<std::string>(entry->mAge);
if (entry.mAge > -1) if (entry->mAge > -1)
{ {
static LLCachedControl<U32> sAvatarAgeAlertDays(gSavedSettings, "AvatarAgeAlertDays"); static LLCachedControl<U32> sAvatarAgeAlertDays(gSavedSettings, "AvatarAgeAlertDays");
if ((U32)entry.mAge < sAvatarAgeAlertDays) if ((U32)entry->mAge < sAvatarAgeAlertDays)
{ {
color = sRadarTextYoung; color = sRadarTextYoung;
if (!entry.mAgeAlert) //Only announce age once per entry. if (!entry->mAgeAlert) //Only announce age once per entry.
{ {
entry.mAgeAlert = true; entry->mAgeAlert = true;
chat_avatar_status(entry.getName().c_str(), av_id, ALERT_TYPE_AGE, true); chat_avatar_status(entry->getName().c_str(), av_id, ALERT_TYPE_AGE, true);
} }
} }
} }
@@ -1051,7 +1061,7 @@ void LLFloaterAvatarList::refreshAvatarList()
element["columns"][LIST_AGE]["value"] = age; element["columns"][LIST_AGE]["value"] = age;
element["columns"][LIST_AGE]["color"] = color.getValue(); element["columns"][LIST_AGE]["color"] = color.getValue();
int dur = difftime(time(NULL), entry.getTime()); int dur = difftime(time(NULL), entry->getTime());
int hours = dur / 3600; int hours = dur / 3600;
int mins = (dur % 3600) / 60; int mins = (dur % 3600) / 60;
int secs = (dur % 3600) % 60; int secs = (dur % 3600) % 60;
@@ -1225,7 +1235,7 @@ LLAvatarListEntry * LLFloaterAvatarList::getAvatarEntry(LLUUID avatar)
av_list_t::iterator iter = std::find_if(mAvatars.begin(),mAvatars.end(),LLAvatarListEntry::uuidMatch(avatar)); av_list_t::iterator iter = std::find_if(mAvatars.begin(),mAvatars.end(),LLAvatarListEntry::uuidMatch(avatar));
if(iter != mAvatars.end()) if(iter != mAvatars.end())
return &(*iter); return iter->get();
else else
return NULL; return NULL;
} }
@@ -1297,7 +1307,7 @@ void LLFloaterAvatarList::removeFocusFromAll()
{ {
BOOST_FOREACH(av_list_t::value_type& entry, mAvatars) BOOST_FOREACH(av_list_t::value_type& entry, mAvatars)
{ {
entry.setFocus(FALSE); entry->setFocus(FALSE);
} }
} }
@@ -1309,7 +1319,7 @@ void LLFloaterAvatarList::setFocusAvatar(const LLUUID& id)
if(!gAgentCamera.lookAtObject(id, false)) if(!gAgentCamera.lookAtObject(id, false))
return; return;
removeFocusFromAll(); removeFocusFromAll();
iter->setFocus(TRUE); (*iter)->setFocus(TRUE);
} }
} }
@@ -1317,22 +1327,22 @@ template<typename T>
void decrement_focus_target(T begin, T end, BOOL marked_only) void decrement_focus_target(T begin, T end, BOOL marked_only)
{ {
T iter = begin; T iter = begin;
while(iter != end && !iter->isFocused()) ++iter; while(iter != end && !(*iter)->isFocused()) ++iter;
if(iter == end) if(iter == end)
return; return;
T prev_iter = iter; T prev_iter = iter;
while(prev_iter != begin) while(prev_iter != begin)
{ {
LLAvatarListEntry& entry = *(--prev_iter); const LLAvatarListEntry& entry = *((--prev_iter)->get());
if(entry.isInList() && (entry.isMarked() || !marked_only) && gAgentCamera.lookAtObject(entry.getID(), false)) if(entry.isInList() && (entry.isMarked() || !marked_only) && gAgentCamera.lookAtObject(entry.getID(), false))
{ {
iter->setFocus(FALSE); (*iter)->setFocus(FALSE);
prev_iter->setFocus(TRUE); (*prev_iter)->setFocus(TRUE);
gAgentCamera.lookAtObject(prev_iter->getID(), false); gAgentCamera.lookAtObject((*prev_iter)->getID(), false);
return; return;
} }
} }
gAgentCamera.lookAtObject(iter->getID(), false); gAgentCamera.lookAtObject((*iter)->getID(), false);
} }
void LLFloaterAvatarList::focusOnPrev(BOOL marked_only) void LLFloaterAvatarList::focusOnPrev(BOOL marked_only)

View File

@@ -22,6 +22,8 @@
#include <map> #include <map>
#include <set> #include <set>
#include <boost/shared_ptr.hpp>
class LLFloaterAvatarList; class LLFloaterAvatarList;
/** /**
@@ -130,7 +132,7 @@ enum ACTIVITY_TYPE
struct uuidMatch struct uuidMatch
{ {
uuidMatch(const LLUUID& id) : mID(id) {} uuidMatch(const LLUUID& id) : mID(id) {}
bool operator()(const LLAvatarListEntry& l) { return l.getID() == mID; } bool operator()(const boost::shared_ptr<LLAvatarListEntry>& l) { return l->getID() == mID; }
LLUUID mID; LLUUID mID;
}; };
@@ -243,7 +245,8 @@ public:
static void sound_trigger_hook(LLMessageSystem* msg,void **); static void sound_trigger_hook(LLMessageSystem* msg,void **);
void sendKeys(); void sendKeys();
typedef std::vector<LLAvatarListEntry> av_list_t; typedef boost::shared_ptr<LLAvatarListEntry> LLAvatarListEntryPtr;
typedef std::vector< LLAvatarListEntryPtr > av_list_t;
private: private:
// when a line editor loses keyboard focus, it is committed. // when a line editor loses keyboard focus, it is committed.