aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-09-16 06:15:37 -0700
committerMcCabe Maxsted2009-09-16 07:00:53 -0700
commit5de9994da14352081ac802404ef018265487e758 (patch)
tree3c22e10728e7fa32dfb0b2f906287e735540d820 /linden/indra/newview
parentDon't track avatars when focus lost (diff)
downloadmeta-impy-5de9994da14352081ac802404ef018265487e758.zip
meta-impy-5de9994da14352081ac802404ef018265487e758.tar.gz
meta-impy-5de9994da14352081ac802404ef018265487e758.tar.bz2
meta-impy-5de9994da14352081ac802404ef018265487e758.tar.xz
More cleanup
Diffstat (limited to 'linden/indra/newview')
-rw-r--r--linden/indra/newview/llfloatermap.cpp79
-rw-r--r--linden/indra/newview/llfloatermap.h1
2 files changed, 27 insertions, 53 deletions
diff --git a/linden/indra/newview/llfloatermap.cpp b/linden/indra/newview/llfloatermap.cpp
index 1ec2020..e70f4f1 100644
--- a/linden/indra/newview/llfloatermap.cpp
+++ b/linden/indra/newview/llfloatermap.cpp
@@ -70,7 +70,6 @@ LLFloaterMap::LLFloaterMap(const LLSD& key)
70 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE); 70 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE);
71 71
72 mSelectedAvatar.setNull(); 72 mSelectedAvatar.setNull();
73 mAvatars.clear();
74} 73}
75 74
76 75
@@ -195,7 +194,7 @@ void LLFloaterMap::updateRadar()
195 194
196void LLFloaterMap::populateRadar() 195void LLFloaterMap::populateRadar()
197{ 196{
198 if (!mUpdate) 197 if (!mUpdate || !LLFloaterMap::getInstance()->getVisible())
199 { 198 {
200 return; 199 return;
201 } 200 }
@@ -218,8 +217,10 @@ void LLFloaterMap::populateRadar()
218 std::vector<LLVector3d> positions; 217 std::vector<LLVector3d> positions;
219 LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, current_pos, gSavedSettings.getF32("NearMeRange")); 218 LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, current_pos, gSavedSettings.getF32("NearMeRange"));
220 219
221 // Add avatars to the list. If they're already there, update positions 220 LLSD element;
222 std::pair<std::map<LLUUID, LLVector3d>::iterator, bool> ret; 221
222 mRadarList->deleteAllItems();
223
223 for (U32 i=0; i<avatar_ids.size(); i++) 224 for (U32 i=0; i<avatar_ids.size(); i++)
224 { 225 {
225 if (avatar_ids[i] == gAgent.getID() || 226 if (avatar_ids[i] == gAgent.getID() ||
@@ -228,50 +229,25 @@ void LLFloaterMap::populateRadar()
228 continue; 229 continue;
229 } 230 }
230 231
231 ret = mAvatars.insert(std::pair<LLUUID, LLVector3d>(avatar_ids[i], positions[i])); 232 // Add to list only if we get their name
232 if (ret.second == false) 233 std::string fullname = getSelectedName(avatar_ids[i]);
234 if (!fullname.empty() && fullname != " ")
233 { 235 {
234 mAvatars[avatar_ids[i]] = positions[i]; 236 std::string mute_text = LLMuteList::getInstance()->isMuted(avatar_ids[i]) ? getString("muted") : "";
235 } 237 element["id"] = avatar_ids[i];
236 } 238 element["columns"][0]["column"] = "avatar_name";
237 239 element["columns"][0]["type"] = "text";
238 LLSD element; 240 element["columns"][0]["value"] = fullname + " " + mute_text;
239 241 element["columns"][1]["column"] = "avatar_distance";
240 mRadarList->deleteAllItems(); 242 element["columns"][1]["type"] = "text";
241 243
242 // if an avatar's not in range anymore, kill it. Otherwise, populate radar 244 LLVector3d temp = positions[i] - current_pos;
243 std::map<LLUUID, LLVector3d>::iterator mIt; 245 F32 distance = (F32)temp.magVec();
244 std::vector<LLUUID>::iterator result; 246 char dist[32];
245 for (mIt = mAvatars.begin(); mIt != mAvatars.end(); ) 247 snprintf(dist, sizeof(dist), "%.1f", distance);
246 { 248 element["columns"][1]["value"] = strcat(dist,"m");
247 result = find(avatar_ids.begin(), avatar_ids.end(), mIt->first); 249
248 if (result == avatar_ids.end()) 250 mRadarList->addElement(element, ADD_BOTTOM);
249 {
250 mAvatars.erase(mIt++);
251 }
252 else
253 {
254 // Add to list only if we get their name
255 std::string fullname = getSelectedName(mIt->first);
256 if (!fullname.empty() && fullname != " ")
257 {
258 std::string mute_text = LLMuteList::getInstance()->isMuted(mIt->first) ? getString("muted") : "";
259 element["id"] = mIt->first;
260 element["columns"][0]["column"] = "avatar_name";
261 element["columns"][0]["type"] = "text";
262 element["columns"][0]["value"] = fullname + " " + mute_text;
263 element["columns"][1]["column"] = "avatar_distance";
264 element["columns"][1]["type"] = "text";
265
266 F64 distance = dist_vec(current_pos, mIt->second);
267 std::stringstream dist_formatted;
268 dist_formatted.str("");
269 dist_formatted << (double)((int)((distance + 0.05)*10.0))/10.0 << "m";
270 element["columns"][1]["value"] = dist_formatted.str();
271
272 mRadarList->addElement(element, ADD_BOTTOM);
273 }
274 ++mIt;
275 } 251 }
276 } 252 }
277 253
@@ -285,28 +261,27 @@ void LLFloaterMap::populateRadar()
285 // set count 261 // set count
286 std::stringstream avatar_count; 262 std::stringstream avatar_count;
287 avatar_count.str(""); 263 avatar_count.str("");
288 if (mAvatars.empty()) 264 if (avatar_ids.empty())
289 { 265 {
290 mRadarList->addCommentText(getString("no_one_near"), ADD_TOP); 266 mRadarList->addCommentText(getString("no_one_near"), ADD_TOP);
291 avatar_count << "0"; 267 avatar_count << "0";
292 } 268 }
293 else 269 else
294 { 270 {
295 avatar_count << (int)mAvatars.size(); 271 avatar_count << (int)avatar_ids.size();
296 } 272 }
297 childSetText("lblAvatarCount", avatar_count.str()); 273 childSetText("lblAvatarCount", avatar_count.str());
298 274
299 toggleButtons(); 275 toggleButtons();
300 276
301 //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl; 277 //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl;
302} 278}
303 279
304void LLFloaterMap::toggleButtons() 280void LLFloaterMap::toggleButtons()
305{ 281{
306 BOOL enabled = FALSE; 282 BOOL enabled = FALSE;
307 BOOL unmute_enabled = FALSE; 283 BOOL unmute_enabled = FALSE;
308 LLPanel* panelp = getChild<LLPanel>("RadarPanel"); 284 if (childHasFocus("RadarPanel"))
309 if (panelp->hasFocus())
310 { 285 {
311 enabled = mSelectedAvatar.notNull() ? visibleItemsSelected() : FALSE; 286 enabled = mSelectedAvatar.notNull() ? visibleItemsSelected() : FALSE;
312 unmute_enabled = mSelectedAvatar.notNull() ? LLMuteList::getInstance()->isMuted(mSelectedAvatar) : FALSE; 287 unmute_enabled = mSelectedAvatar.notNull() ? LLMuteList::getInstance()->isMuted(mSelectedAvatar) : FALSE;
diff --git a/linden/indra/newview/llfloatermap.h b/linden/indra/newview/llfloatermap.h
index 09fce01..fae6184 100644
--- a/linden/indra/newview/llfloatermap.h
+++ b/linden/indra/newview/llfloatermap.h
@@ -67,7 +67,6 @@ private:
67 LLNetMap* mPanelMap; 67 LLNetMap* mPanelMap;
68 LLScrollListCtrl* mRadarList; 68 LLScrollListCtrl* mRadarList;
69 LLUUID mSelectedAvatar; 69 LLUUID mSelectedAvatar;
70 std::map<LLUUID, LLVector3d> mAvatars;
71 bool mUpdate; 70 bool mUpdate;
72 71
73 static void onList(LLUICtrl* ctrl, void* user_data); 72 static void onList(LLUICtrl* ctrl, void* user_data);