summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/llfolderviewmodel.h10
-rw-r--r--indra/newview/llconversationmodel.cpp28
-rwxr-xr-xindra/newview/llconversationmodel.h7
-rwxr-xr-xindra/newview/llimfloatercontainer.cpp42
-rw-r--r--indra/newview/llimfloatercontainer.h1
-rw-r--r--indra/newview/llparticipantlist.cpp2
6 files changed, 82 insertions, 8 deletions
diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h
index c99fa07c8b..c6030c9b71 100644
--- a/indra/llui/llfolderviewmodel.h
+++ b/indra/llui/llfolderviewmodel.h
@@ -254,6 +254,16 @@ public:
virtual void addChild(LLFolderViewModelItem* child)
{
+ // Avoid duplicates: bail out if that child is already present in the list
+ // Note: this happens when models are created before views
+ child_list_t::const_iterator iter;
+ for (iter = mChildren.begin(); iter != mChildren.end(); iter++)
+ {
+ if (child == *iter)
+ {
+ return;
+ }
+ }
mChildren.push_back(child);
child->setParent(this);
dirtyFilter();
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp
index e090d1647f..a94d82bf7c 100644
--- a/indra/newview/llconversationmodel.cpp
+++ b/indra/newview/llconversationmodel.cpp
@@ -181,6 +181,16 @@ void LLConversationItemSession::setTimeNow(const LLUUID& participant_id)
}
}
+void LLConversationItemSession::setDistance(const LLUUID& participant_id, F64 dist)
+{
+ LLConversationItemParticipant* participant = findParticipant(participant_id);
+ if (participant)
+ {
+ participant->setDistance(dist);
+ mNeedsRefresh = true;
+ }
+}
+
// The time of activity of a session is the time of the most recent activity, session and participants included
const bool LLConversationItemSession::getTime(F64& time) const
{
@@ -207,7 +217,7 @@ const bool LLConversationItemSession::getTime(F64& time) const
void LLConversationItemSession::dumpDebugData()
{
- llinfos << "Merov debug : session, uuid = " << mUUID << ", name = " << mName << ", is loaded = " << mIsLoaded << llendl;
+ llinfos << "Merov debug : session " << this << ", uuid = " << mUUID << ", name = " << mName << ", is loaded = " << mIsLoaded << llendl;
LLConversationItemParticipant* participant = NULL;
child_list_t::iterator iter;
for (iter = mChildren.begin(); iter != mChildren.end(); iter++)
@@ -224,13 +234,17 @@ void LLConversationItemSession::dumpDebugData()
LLConversationItemParticipant::LLConversationItemParticipant(std::string display_name, const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) :
LLConversationItem(display_name,uuid,root_view_model),
mIsMuted(false),
- mIsModerator(false)
+ mIsModerator(false),
+ mDistToAgent(-1.0)
{
mConvType = CONV_PARTICIPANT;
}
LLConversationItemParticipant::LLConversationItemParticipant(const LLUUID& uuid, LLFolderViewModelInterface& root_view_model) :
- LLConversationItem(uuid,root_view_model)
+ LLConversationItem(uuid,root_view_model),
+ mIsMuted(false),
+ mIsModerator(false),
+ mDistToAgent(-1.0)
{
mConvType = CONV_PARTICIPANT;
}
@@ -248,7 +262,7 @@ void LLConversationItemParticipant::onAvatarNameCache(const LLAvatarName& av_nam
void LLConversationItemParticipant::dumpDebugData()
{
- llinfos << "Merov debug : participant, uuid = " << mUUID << ", name = " << mName << ", muted = " << mIsMuted << ", moderator = " << mIsModerator << llendl;
+ llinfos << "Merov debug : participant " << this << ", uuid = " << mUUID << ", name = " << mName << ", muted = " << mIsMuted << ", moderator = " << mIsModerator << llendl;
}
//
@@ -284,13 +298,13 @@ bool LLConversationSort::operator()(const LLConversationItem* const& a, const LL
}
else if (sort_order == LLConversationFilter::SO_DISTANCE)
{
- F32 dist_a = 0.0;
- F32 dist_b = 0.0;
+ F64 dist_a = 0.0;
+ F64 dist_b = 0.0;
bool has_dist_a = a->getDistanceToAgent(dist_a);
bool has_dist_b = b->getDistanceToAgent(dist_b);
if (has_dist_a && has_dist_b)
{
- return (dist_a > dist_b);
+ return (dist_a < dist_b);
}
else if (has_dist_a || has_dist_b)
{
diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h
index e67aeb9aca..18c5dd1ce1 100755
--- a/indra/newview/llconversationmodel.h
+++ b/indra/newview/llconversationmodel.h
@@ -107,7 +107,7 @@ public:
// Methods used in sorting (see LLConversationSort::operator())
EConversationType const getType() const { return mConvType; }
virtual const bool getTime(F64& time) const { time = mLastActiveTime; return (time > 0.1); }
- virtual const bool getDistanceToAgent(F32& distance) const { return false; }
+ virtual const bool getDistanceToAgent(F64& distance) const { return false; }
// This method will be called to determine if a drop can be
// performed, and will set drop to TRUE if a drop is
@@ -151,6 +151,7 @@ public:
void setParticipantIsMuted(const LLUUID& participant_id, bool is_muted);
void setParticipantIsModerator(const LLUUID& participant_id, bool is_moderator);
void setTimeNow(const LLUUID& participant_id);
+ void setDistance(const LLUUID& participant_id, F64 dist);
bool isLoaded() { return mIsLoaded; }
@@ -174,14 +175,18 @@ public:
void setIsMuted(bool is_muted) { mIsMuted = is_muted; mNeedsRefresh = true; }
void setIsModerator(bool is_moderator) { mIsModerator = is_moderator; mNeedsRefresh = true; }
void setTimeNow() { mLastActiveTime = LLFrameTimer::getElapsedSeconds(); mNeedsRefresh = true; }
+ void setDistance(F64 dist) { mDistToAgent = dist; mNeedsRefresh = true; }
void onAvatarNameCache(const LLAvatarName& av_name);
+ virtual const bool getDistanceToAgent(F64& dist) const { dist = mDistToAgent; return (dist >= 0.0); }
+
void dumpDebugData();
private:
bool mIsMuted; // default is false
bool mIsModerator; // default is false
+ F64 mDistToAgent; // Distance to the agent. A negative (meaningless) value means the distance has not been set.
};
// We don't want to ever filter conversations but we need to declare that class to create a conversation view model.
diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp
index 3c21794d28..14d40d4685 100755
--- a/indra/newview/llimfloatercontainer.cpp
+++ b/indra/newview/llimfloatercontainer.cpp
@@ -47,6 +47,7 @@
#include "llviewercontrol.h"
#include "llconversationview.h"
#include "llcallbacklist.h"
+#include "llworld.h"
//
// LLIMFloaterContainer
@@ -333,6 +334,14 @@ void LLIMFloaterContainer::setMinimized(BOOL b)
void LLIMFloaterContainer::idle(void* user_data)
{
LLIMFloaterContainer* self = static_cast<LLIMFloaterContainer*>(user_data);
+
+ // Update the distance to agent in the nearby chat session if required
+ // Note: it makes no sense of course to update the distance in other session
+ if (self->mConversationViewModel.getSorter().getSortOrderParticipants() == LLConversationFilter::SO_DISTANCE)
+ {
+ self->setNearbyDistances();
+ }
+
self->mConversationsRoot->update();
}
@@ -385,6 +394,8 @@ void LLIMFloaterContainer::draw()
}
// Reset the need for refresh
session_model->resetRefresh();
+ mConversationViewModel.requestSortAll();
+ mConversationsRoot->arrangeAll();
// Next participant
current_participant_model++;
}
@@ -725,6 +736,37 @@ void LLIMFloaterContainer::setTimeNow(const LLUUID& session_id, const LLUUID& pa
}
}
+void LLIMFloaterContainer::setNearbyDistances()
+{
+ // Get the nearby chat session: that's the one with uuid nul in mConversationsItems
+ conversations_items_map::iterator item_it = mConversationsItems.find(LLUUID());
+ if (item_it != mConversationsItems.end())
+ {
+ LLConversationItemSession* item = dynamic_cast<LLConversationItemSession*>(item_it->second);
+ if (item)
+ {
+ // Get the positions of the nearby avatars and their ids
+ std::vector<LLVector3d> positions;
+ uuid_vec_t avatar_ids;
+ LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgent.getPositionGlobal(), gSavedSettings.getF32("NearMeRange"));
+ // Get the position of the agent
+ const LLVector3d& me_pos = gAgent.getPositionGlobal();
+ // For each nearby avatar, compute and update the distance
+ int avatar_count = positions.size();
+ for (int i = 0; i < avatar_count; i++)
+ {
+ F64 dist = dist_vec_squared(positions[i], me_pos);
+ item->setDistance(avatar_ids[i],dist);
+ }
+ // Also does it for the agent itself
+ item->setDistance(gAgent.getID(),0.0f);
+ // Request resort
+ mConversationViewModel.requestSortAll();
+ mConversationsRoot->arrangeAll();
+ }
+ }
+}
+
void LLIMFloaterContainer::addConversationListItem(const LLUUID& uuid)
{
bool is_nearby_chat = uuid.isNull();
diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h
index 4546029e93..e8d185297c 100644
--- a/indra/newview/llimfloatercontainer.h
+++ b/indra/newview/llimfloatercontainer.h
@@ -125,6 +125,7 @@ public:
void removeConversationListItem(const LLUUID& uuid, bool change_focus = true);
void addConversationListItem(const LLUUID& uuid);
void setTimeNow(const LLUUID& session_id, const LLUUID& participant_id);
+ void setNearbyDistances();
private:
LLConversationViewSession* createConversationItemWidget(LLConversationItem* item);
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index 09f2716773..90226e7fba 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -678,8 +678,10 @@ void LLParticipantList::sort()
void LLParticipantList::addAvatarIDExceptAgent(const LLUUID& avatar_id)
{
+ // Do not add if already in there or excluded for some reason
if (mExcludeAgent && gAgent.getID() == avatar_id) return;
if (mAvatarList && mAvatarList->contains(avatar_id)) return;
+ if (findParticipant(avatar_id)) return;
bool is_avatar = LLVoiceClient::getInstance()->isParticipantAvatar(avatar_id);