summaryrefslogtreecommitdiff
path: root/indra/newview/llavatarlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llavatarlist.cpp')
-rw-r--r--indra/newview/llavatarlist.cpp65
1 files changed, 62 insertions, 3 deletions
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 8f858fe4e1..52cd86951d 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -36,6 +36,7 @@
#include "lltextutil.h"
// newview
+#include "llagent.h"
#include "llagentdata.h" // for comparator
#include "llavatariconctrl.h"
#include "llavatarnamecache.h"
@@ -47,11 +48,12 @@
#include "llvoiceclient.h"
#include "llviewercontrol.h" // for gSavedSettings
#include "lltooldraganddrop.h"
+#include "llworld.h"
static LLDefaultChildRegistry::Register<LLAvatarList> r("avatar_list");
// Last interaction time update period.
-static const F32 LIT_UPDATE_PERIOD = 5;
+static const F32 LIT_UPDATE_PERIOD = 1;
// Maximum number of avatars that can be added to a list in one pass.
// Used to limit time spent for avatar list update per frame.
@@ -119,6 +121,8 @@ static const LLFlatListView::ItemReverseComparator REVERSE_NAME_COMPARATOR(NAME_
LLAvatarList::Params::Params()
: ignore_online_status("ignore_online_status", false)
+, show_avatar_arrival_time("show_avatar_arrival_time", false)
+, show_avatar_distance("show_avatar_distance", false)
, show_last_interaction_time("show_last_interaction_time", false)
, show_info_btn("show_info_btn", true)
, show_profile_btn("show_profile_btn", true)
@@ -131,6 +135,8 @@ LLAvatarList::LLAvatarList(const Params& p)
: LLFlatListViewEx(p)
, mIgnoreOnlineStatus(p.ignore_online_status)
, mShowLastInteractionTime(p.show_last_interaction_time)
+, mAvatarDistance(p.show_avatar_distance)
+, mAvatarArrivalTime(p.show_avatar_arrival_time)
, mContextMenu(NULL)
, mDirty(true) // to force initial update
, mNeedUpdateNames(false)
@@ -147,7 +153,7 @@ LLAvatarList::LLAvatarList(const Params& p)
// Set default sort order.
setComparator(&NAME_COMPARATOR);
- if (mShowLastInteractionTime)
+ if (mShowLastInteractionTime || mAvatarDistance || mAvatarArrivalTime)
{
mLITUpdateTimer = new LLTimer();
mLITUpdateTimer->setTimerExpirySec(0); // zero to force initial update
@@ -196,9 +202,20 @@ void LLAvatarList::draw()
if (mDirty)
refresh();
- if (mShowLastInteractionTime && mLITUpdateTimer->hasExpired())
+ if ((mShowLastInteractionTime || mAvatarDistance || mAvatarArrivalTime) && mLITUpdateTimer->hasExpired())
{
+ if (mAvatarArrivalTime)
+ {
+ updateAvatarArrivalTime();
+ }
+ if (mAvatarDistance)
+ {
+ updateAvatarDistance();
+ }
+ if (mShowLastInteractionTime)
+ {
updateLastInteractionTimes();
+ }
mLITUpdateTimer->setTimerExpirySec(LIT_UPDATE_PERIOD); // restart the timer
}
}
@@ -422,6 +439,8 @@ void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, bool is
// This sets the name as a side effect
item->setAvatarId(id, mSessionID, mIgnoreOnlineStatus);
item->setOnline(mIgnoreOnlineStatus ? true : is_online);
+ item->showAvatarArrivalTime(mAvatarArrivalTime);
+ item->showAvatarDistance(mAvatarDistance);
item->showLastInteractionTime(mShowLastInteractionTime);
item->setAvatarIconVisible(mShowIcons);
@@ -528,6 +547,46 @@ void LLAvatarList::computeDifference(
LLCommonUtils::computeDifference(vnew_unsorted, vcur, vadded, vremoved);
}
+void LLAvatarList::updateAvatarArrivalTime()
+{
+ std::vector<LLPanel*> items;
+ getItems(items);
+ auto uuids = getIDs();
+ std::vector<LLVector3d> positions;
+ auto me_pos = gAgent.getPositionGlobal();
+ LLWorld::getInstance()->getAvatars(&uuids, &positions, me_pos, gSavedSettings.getF32("MPVNearMeRange"));
+ LLRecentPeople::instance().updateAvatarsArrivalTime(uuids);
+ for (auto it = items.begin(); it != items.end(); it++)
+ {
+ auto item = static_cast<LLAvatarListItem*>(*it);
+ auto secs_since = LLDate::now().secondsSinceEpoch() - LLRecentPeople::instance().getArrivalTimeByID(item->getAvatarId());
+ if (secs_since >= 0)
+ item->setAvatarArrivalTime(secs_since);
+ }
+}
+
+ void LLAvatarList::updateAvatarDistance()
+{
+ std::vector<LLPanel*> items;
+ getItems(items);
+ auto uuids = getIDs();
+ std::vector<LLVector3d> positions;
+ auto me_pos = gAgent.getPositionGlobal();
+ LLWorld::getInstance()->getAvatars(&uuids, &positions, me_pos, gSavedSettings.getF32("MPVNearMeRange"));
+ std::map <LLUUID, LLVector3d> avatarsPositions;
+ auto pos_it = positions.begin();
+ auto id_it = uuids.begin();
+ for (;pos_it != positions.end() && id_it != uuids.end(); ++pos_it, ++id_it)
+ {
+ avatarsPositions[*id_it] = *pos_it;
+ }
+ for (auto it = items.begin(); it != items.end(); it++)
+ {
+ auto item = static_cast<LLAvatarListItem*>(*it);
+ item->setAvatarDistance(dist_vec(avatarsPositions[item->getAvatarId()], me_pos));
+ }
+}
+
// Refresh shown time of our last interaction with all listed avatars.
void LLAvatarList::updateLastInteractionTimes()
{