From 1bd4836e7c36f3c1ee4a821c39f78ca1397e3291 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 20 Aug 2024 21:33:20 +0800 Subject: Arrival, distance & leaving notifs in local chat https://megapahit.com/show_bug.cgi?id=49 The LLVOAvatar class doesn't seem to have a display name getter. --- indra/newview/llvoavatar.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index d7382eaac6..62884ecb3c 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -70,6 +70,7 @@ #include "llmeshrepository.h" #include "llmutelist.h" #include "llmoveview.h" +#include "llnotificationmanager.h" #include "llnotificationsutil.h" #include "llphysicsshapebuilderutil.h" #include "llquantize.h" @@ -811,6 +812,7 @@ void LLVOAvatar::debugAvatarRezTime(std::string notification_name, std::string c //------------------------------------------------------------------------ LLVOAvatar::~LLVOAvatar() { + LLNotificationsUI::LLNotificationManager::instance().onChat(LLChat{llformat("%s left.", getFullname().c_str())}, LLSD{}); if (!mFullyLoaded) { debugAvatarRezTime("AvatarRezLeftCloudNotification","left after ruth seconds as cloud"); @@ -2462,6 +2464,20 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys, { mDebugExistenceTimer.reset(); debugAvatarRezTime("AvatarRezArrivedNotification","avatar arrived"); + uuid_vec_t uuids; + std::vector positions; + LLWorld::getInstance()->getAvatars(&uuids, &positions, gAgent.getPositionGlobal(), gSavedSettings.getF32("MPVNearMeRange")); + auto pos_it = positions.begin(); + auto id_it = uuids.begin(); + for (;pos_it != positions.end() && id_it != uuids.end(); ++pos_it, ++id_it) + { + if (*id_it == getID() && !isSelf()) + { + LLNotificationsUI::LLNotificationManager::instance() + .onChat(LLChat{llformat("%s arrived (%.1f m).", getFullname().c_str(), dist_vec(*pos_it, gAgent.getPositionGlobal()))}, LLSD{}); + break; + } + } } if(retval & LLViewerObject::INVALID_UPDATE) -- cgit v1.2.3 From 06bfcd7e75a2659ba4eb2dd79e89b8476a3c33cf Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Wed, 21 Aug 2024 12:27:18 +0800 Subject: Arrival time in nearby tab (draft) The period got updated to something more frequent (from 5 to 1 second). I copied from newview/llpanelpeople.cpp and updateLastInteractionTime. The values are still not accurate, and have a delayed start. The presentation could use something like std's strftime, but I started from what worked first, which was using LL's formatSeconds. The alignments really need some tidying up too. --- indra/newview/llavatarlist.cpp | 33 +++++++++++++++++++--- indra/newview/llavatarlist.h | 3 ++ indra/newview/llavatarlistitem.cpp | 22 ++++++++++++++- indra/newview/llavatarlistitem.h | 4 +++ .../default/xui/en/panel_avatar_list_item.xml | 11 ++++++++ .../newview/skins/default/xui/en/panel_people.xml | 1 + 6 files changed, 69 insertions(+), 5 deletions(-) diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index 5624961e35..bc1c915ab6 100644 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -53,7 +53,7 @@ static LLDefaultChildRegistry::Register 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. @@ -121,6 +121,7 @@ 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) @@ -135,6 +136,7 @@ LLAvatarList::LLAvatarList(const Params& 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) @@ -151,7 +153,7 @@ LLAvatarList::LLAvatarList(const Params& p) // Set default sort order. setComparator(&NAME_COMPARATOR); - if (mShowLastInteractionTime || mAvatarDistance) + if (mShowLastInteractionTime || mAvatarDistance || mAvatarArrivalTime) { mLITUpdateTimer = new LLTimer(); mLITUpdateTimer->setTimerExpirySec(0); // zero to force initial update @@ -200,8 +202,12 @@ void LLAvatarList::draw() if (mDirty) refresh(); - if ((mShowLastInteractionTime || mAvatarDistance) && mLITUpdateTimer->hasExpired()) + if ((mShowLastInteractionTime || mAvatarDistance || mAvatarArrivalTime) && mLITUpdateTimer->hasExpired()) { + if (mAvatarArrivalTime) + { + updateAvatarArrivalTime(); + } if (mAvatarDistance) { updateAvatarDistance(); @@ -433,6 +439,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->showAvatarArrivalTime(mAvatarArrivalTime); item->showAvatarDistance(mAvatarDistance); item->showLastInteractionTime(mShowLastInteractionTime); @@ -540,7 +547,25 @@ void LLAvatarList::computeDifference( LLCommonUtils::computeDifference(vnew_unsorted, vcur, vadded, vremoved); } -void LLAvatarList::updateAvatarDistance() +void LLAvatarList::updateAvatarArrivalTime() +{ + std::vector items; + getItems(items); + auto uuids = getIDs(); + std::vector 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(*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 items; getItems(items); diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h index 5593985fff..207ff700c5 100644 --- a/indra/newview/llavatarlist.h +++ b/indra/newview/llavatarlist.h @@ -50,6 +50,7 @@ public: struct Params : public LLInitParam::Block { Optional ignore_online_status, // show all items as online + show_avatar_arrival_time, show_avatar_distance, show_last_interaction_time, // show most recent interaction time. *HACK: move this to a derived class show_info_btn, @@ -111,6 +112,7 @@ protected: const uuid_vec_t& vnew, uuid_vec_t& vadded, uuid_vec_t& vremoved); + void updateAvatarArrivalTime(); void updateAvatarDistance(); void updateLastInteractionTimes(); void rebuildNames(); @@ -120,6 +122,7 @@ protected: private: bool mIgnoreOnlineStatus; + bool mAvatarArrivalTime; bool mAvatarDistance; bool mShowLastInteractionTime; bool mDirty; diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp index dd0e2d83d3..a840afa967 100644 --- a/indra/newview/llavatarlistitem.cpp +++ b/indra/newview/llavatarlistitem.cpp @@ -65,6 +65,7 @@ LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/) LLFriendObserver(), mAvatarIcon(NULL), mAvatarName(NULL), + mAvatarArrivalTime(NULL), mAvatarDistance(NULL), mLastInteractionTime(NULL), mIconPermissionOnline(NULL), @@ -108,6 +109,7 @@ BOOL LLAvatarListItem::postBuild() { mAvatarIcon = getChild("avatar_icon"); mAvatarName = getChild("avatar_name"); + mAvatarArrivalTime = getChild("avatar_arrival_time"); mAvatarDistance = getChild("avatar_distance"); mLastInteractionTime = getChild("last_interaction"); @@ -303,6 +305,17 @@ void LLAvatarListItem::setAvatarId(const LLUUID& id, const LLUUID& session_id, b } } +void LLAvatarListItem::showAvatarArrivalTime(bool show) +{ + mAvatarArrivalTime->setVisible(show); + updateChildren(); +} + +void LLAvatarListItem::setAvatarArrivalTime(F32 arrival_time) +{ + mAvatarArrivalTime->setValue(formatSeconds(arrival_time)); +} + void LLAvatarListItem::showAvatarDistance(bool show) { mAvatarDistance->setVisible(show); @@ -552,7 +565,10 @@ void LLAvatarListItem::initChildrenWidths(LLAvatarListItem* avatar_item) S32 last_interaction_time_width = avatar_item->mIconPermissionEditTheirs->getRect().mLeft - avatar_item->mLastInteractionTime->getRect().mLeft; // avatar distance textbox width + padding - S32 avatar_distance_width = avatar_item->mAvatarDistance->getRect().mLeft - avatar_item->mAvatarName->getRect().mLeft; + S32 avatar_distance_width = avatar_item->mAvatarDistance->getRect().mLeft - avatar_item->mAvatarArrivalTime->getRect().mLeft; + + // avatar arrival time textbox width + padding + S32 avatar_arrival_time = avatar_item->mAvatarArrivalTime->getRect().mLeft - avatar_item->mAvatarName->getRect().mLeft; // avatar icon width + padding S32 icon_width = avatar_item->mAvatarName->getRect().mLeft - avatar_item->mAvatarIcon->getRect().mLeft; @@ -562,6 +578,7 @@ void LLAvatarListItem::initChildrenWidths(LLAvatarListItem* avatar_item) S32 index = ALIC_COUNT; sChildrenWidths[--index] = icon_width; sChildrenWidths[--index] = 0; // for avatar name we don't need its width, it will be calculated as "left available space" + sChildrenWidths[--index] = avatar_arrival_time; sChildrenWidths[--index] = avatar_distance_width; sChildrenWidths[--index] = last_interaction_time_width; sChildrenWidths[--index] = permission_edit_theirs_width; @@ -683,6 +700,9 @@ LLView* LLAvatarListItem::getItemChildView(EAvatarListItemChildIndex child_view_ case ALIC_NAME: child_view = mAvatarName; break; + case ALIC_ARRIVAL_TIME: + child_view = mAvatarArrivalTime; + break; case ALIC_DISTANCE: child_view = mAvatarDistance; break; diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h index ac356ab3b1..4b24410d82 100644 --- a/indra/newview/llavatarlistitem.h +++ b/indra/newview/llavatarlistitem.h @@ -98,6 +98,7 @@ public: void setHighlight(const std::string& highlight); void setState(EItemState item_style); void setAvatarId(const LLUUID& id, const LLUUID& session_id, bool ignore_status_changes = false, bool is_resident = true); + void setAvatarArrivalTime(F32 arrival_time); void setAvatarDistance(F32 distance); void setLastInteractionTime(U32 secs_since); //Show/hide profile/info btn, translating speaker indicator and avatar name coordinates accordingly @@ -105,6 +106,7 @@ public: void setShowInfoBtn(bool show); void showSpeakingIndicator(bool show); void setShowPermissions(bool show) { mShowPermissions = show; }; + void showAvatarArrivalTime(bool show); void showAvatarDistance(bool show); void showLastInteractionTime(bool show); void setAvatarIconVisible(bool visible); @@ -161,6 +163,7 @@ private: ALIC_PERMISSION_EDIT_THEIRS, ALIC_INTERACTION_TIME, ALIC_DISTANCE, + ALIC_ARRIVAL_TIME, ALIC_NAME, ALIC_ICON, ALIC_COUNT, @@ -202,6 +205,7 @@ private: LLView* getItemChildView(EAvatarListItemChildIndex child_index); LLTextBox* mAvatarName; + LLTextBox* mAvatarArrivalTime; LLTextBox* mAvatarDistance; LLTextBox* mLastInteractionTime; LLStyle::Params mAvatarNameStyle; diff --git a/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml b/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml index 122b5ae508..cfca246321 100644 --- a/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml +++ b/indra/newview/skins/default/xui/en/panel_avatar_list_item.xml @@ -65,6 +65,17 @@ use_ellipses="true" value="(loading)" width="180" /> + -- cgit v1.2.3