summaryrefslogtreecommitdiff
path: root/indra/newview/llavatarlist.cpp
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-08-17 13:23:01 +0800
committerErik Kundiman <erik@megapahit.org>2024-08-17 13:23:01 +0800
commitd15ebf5623fe15677a59a66029e9cfd00edc2942 (patch)
tree5dc79911481636a95546c2c10382cc609ba92edc /indra/newview/llavatarlist.cpp
parent90127cf36c5ca6e7c6273261830e65da2d7e9c73 (diff)
Distance in nearby tab (draft)
https://megapahit.com/show_bug.cgi?id=49 Still needs to be tidied up. For now it's aligned to the left. If you want to align it to the right, apart from modifying avatar_distance in panel_avatar_list_item.xml to look more like last_interaction, modify newview/llavatarlistitem.cpp line 555 to be something like: `S32 avatar_distance_width = avatar_item->mLastInteractionTime->getRect().mLeft - avatar_item->mAvatarDistance->getRect().mLeft;` I had tried this at first, but I couldn't make it look good and that's why I aligned it to the left. Also, these distances need to not be shown on Friends list. I'm doing that next.
Diffstat (limited to 'indra/newview/llavatarlist.cpp')
-rw-r--r--indra/newview/llavatarlist.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index e467f74f9c..57126d175f 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,6 +48,7 @@
#include "llvoiceclient.h"
#include "llviewercontrol.h" // for gSavedSettings
#include "lltooldraganddrop.h"
+#include "llworld.h"
static LLDefaultChildRegistry::Register<LLAvatarList> r("avatar_list");
@@ -131,6 +133,7 @@ LLAvatarList::LLAvatarList(const Params& p)
: LLFlatListViewEx(p)
, mIgnoreOnlineStatus(p.ignore_online_status)
, mShowLastInteractionTime(p.show_last_interaction_time)
+, mAvatarDistance(true)
, mContextMenu(NULL)
, mDirty(true) // to force initial update
, mNeedUpdateNames(false)
@@ -147,7 +150,7 @@ LLAvatarList::LLAvatarList(const Params& p)
// Set default sort order.
setComparator(&NAME_COMPARATOR);
- if (mShowLastInteractionTime)
+ if (mShowLastInteractionTime || mAvatarDistance)
{
mLITUpdateTimer = new LLTimer();
mLITUpdateTimer->setTimerExpirySec(0); // zero to force initial update
@@ -196,9 +199,16 @@ void LLAvatarList::draw()
if (mDirty)
refresh();
- if (mShowLastInteractionTime && mLITUpdateTimer->hasExpired())
+ if ((mShowLastInteractionTime || mAvatarDistance) && mLITUpdateTimer->hasExpired())
{
+ if (mAvatarDistance)
+ {
+ updateAvatarDistance();
+ }
+ if (mShowLastInteractionTime)
+ {
updateLastInteractionTimes();
+ }
mLITUpdateTimer->setTimerExpirySec(LIT_UPDATE_PERIOD); // restart the timer
}
}
@@ -422,6 +432,7 @@ 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->showAvatarDistance(true);
item->showLastInteractionTime(mShowLastInteractionTime);
item->setAvatarIconVisible(mShowIcons);
@@ -528,6 +539,28 @@ void LLAvatarList::computeDifference(
LLCommonUtils::computeDifference(vnew_unsorted, vcur, vadded, vremoved);
}
+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()
{