aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview
diff options
context:
space:
mode:
authorJacek Antonelli2009-10-30 03:18:35 -0500
committerJacek Antonelli2009-10-30 03:50:28 -0500
commit44cc489c43e83f23838d4e3ea30482ddf0299e6c (patch)
tree26a98227af7d477052e19d54aefec77bcfc93a2f /linden/indra/newview
parentMinimap radar can now be toggled. (diff)
downloadmeta-impy-44cc489c43e83f23838d4e3ea30482ddf0299e6c.zip
meta-impy-44cc489c43e83f23838d4e3ea30482ddf0299e6c.tar.gz
meta-impy-44cc489c43e83f23838d4e3ea30482ddf0299e6c.tar.bz2
meta-impy-44cc489c43e83f23838d4e3ea30482ddf0299e6c.tar.xz
Cleaned up PanelRadar class a bit.
More privacy, better method names, generally cleaner.
Diffstat (limited to 'linden/indra/newview')
-rw-r--r--linden/indra/newview/llviewermessage.cpp7
-rw-r--r--linden/indra/newview/panelradar.cpp135
-rw-r--r--linden/indra/newview/panelradar.h34
3 files changed, 72 insertions, 104 deletions
diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp
index a6c7497..b47b6b0 100644
--- a/linden/indra/newview/llviewermessage.cpp
+++ b/linden/indra/newview/llviewermessage.cpp
@@ -2558,7 +2558,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
2558 2558
2559 if (LLFloaterMap::getInstance()) 2559 if (LLFloaterMap::getInstance())
2560 { 2560 {
2561 LLFloaterMap::getInstance()->getRadar()->updateTypingList(from_id, false); 2561 LLFloaterMap::getInstance()->getRadar()->addToTypingList(from_id);
2562 } 2562 }
2563 2563
2564 return; 2564 return;
@@ -2575,10 +2575,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
2575 2575
2576 if (LLFloaterMap::getInstance()) 2576 if (LLFloaterMap::getInstance())
2577 { 2577 {
2578 if (LLFloaterMap::getInstance()->getRadar()->isTyping(from_id)) 2578 LLFloaterMap::getInstance()->getRadar()->removeFromTypingList(from_id);
2579 {
2580 LLFloaterMap::getInstance()->getRadar()->updateTypingList(from_id, true);
2581 }
2582 } 2579 }
2583 2580
2584 return; 2581 return;
diff --git a/linden/indra/newview/panelradar.cpp b/linden/indra/newview/panelradar.cpp
index 487767d..e85af44 100644
--- a/linden/indra/newview/panelradar.cpp
+++ b/linden/indra/newview/panelradar.cpp
@@ -64,17 +64,16 @@ PanelRadar::PanelRadar()
64 64
65 mChatAvatars.clear(); 65 mChatAvatars.clear();
66 mTypingAvatars.clear(); 66 mTypingAvatars.clear();
67 mSimAvatars.clear();
67} 68}
68 69
69 70
70BOOL PanelRadar::postBuild() 71BOOL PanelRadar::postBuild()
71{ 72{
72 mRadarList = getChild<LLScrollListCtrl>("RadarList"); 73 mRadarList = getChild<LLScrollListCtrl>("RadarList");
73 childSetCommitCallback("RadarList", onList, this); 74 childSetCommitCallback("RadarList", onUseRadarList, this);
74 mRadarList->setDoubleClickCallback(onClickIM); 75 mRadarList->setDoubleClickCallback(onClickIM);
75 76
76 childSetFocusChangedCallback("near_me_range", onRangeChange, this);
77
78 childSetAction("im_btn", onClickIM, this); 77 childSetAction("im_btn", onClickIM, this);
79 childSetAction("profile_btn", onClickProfile, this); 78 childSetAction("profile_btn", onClickProfile, this);
80 childSetAction("offer_teleport_btn", onClickOfferTeleport, this); 79 childSetAction("offer_teleport_btn", onClickOfferTeleport, this);
@@ -107,19 +106,15 @@ bool PanelRadar::isImpDev(LLUUID agent_id)
107 // We use strings here as avatar keys change across grids. 106 // We use strings here as avatar keys change across grids.
108 // Feel free to add/remove yourself. 107 // Feel free to add/remove yourself.
109 std::string agent_name = getSelectedName(agent_id); 108 std::string agent_name = getSelectedName(agent_id);
110 if (agent_name == "McCabe Maxsted" || 109 return (agent_name == "McCabe Maxsted" ||
111 agent_name == "Jacek Antonelli" || 110 agent_name == "Jacek Antonelli" ||
112 agent_name == "Armin Weatherwax") 111 agent_name == "Armin Weatherwax");
113 {
114 return true;
115 }
116 return false;
117} 112}
118 113
119 114
120void PanelRadar::populateRadar() 115void PanelRadar::populateRadar()
121{ 116{
122 if (!mUpdate || !getVisible()) 117 if (!getVisible())
123 { 118 {
124 return; 119 return;
125 } 120 }
@@ -221,7 +216,7 @@ void PanelRadar::populateRadar()
221 216
222 if (notify_sim) 217 if (notify_sim)
223 { 218 {
224 if (!isInChatList(avatar_ids[i]) && !getInSimAvList(avatar_ids[i])) 219 if (!isInChatList(avatar_ids[i]) && !isInSimAvList(avatar_ids[i]))
225 { 220 {
226 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]); 221 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
227 if (av_obj != NULL && av_obj->isAvatar()) 222 if (av_obj != NULL && av_obj->isAvatar())
@@ -284,7 +279,7 @@ void PanelRadar::populateRadar()
284 279
285 childSetText("lblAvatarCount", avatar_count.str()); 280 childSetText("lblAvatarCount", avatar_count.str());
286 281
287 toggleButtons(); 282 updateButtonStates();
288 283
289 //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl; 284 //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl;
290} 285}
@@ -311,11 +306,7 @@ void PanelRadar::updateChatList(std::vector<LLUUID> agent_ids)
311 306
312bool PanelRadar::isInChatList(LLUUID agent_id) 307bool PanelRadar::isInChatList(LLUUID agent_id)
313{ 308{
314 if (mChatAvatars.count(agent_id) > 0) 309 return (mChatAvatars.count(agent_id) > 0);
315 {
316 return true;
317 }
318 return false;
319} 310}
320 311
321 312
@@ -343,27 +334,19 @@ void PanelRadar::removeFromChatList(LLUUID agent_id)
343 334
344bool PanelRadar::isTyping(LLUUID agent_id) 335bool PanelRadar::isTyping(LLUUID agent_id)
345{ 336{
346 if (mTypingAvatars.count(agent_id) > 0) 337 return (mTypingAvatars.count(agent_id) > 0);
347 {
348 return true;
349 }
350 return false;
351} 338}
352 339
353 340
354void PanelRadar::updateTypingList(LLUUID agent_id, bool remove) 341void PanelRadar::addToTypingList(LLUUID agent_id)
355{ 342{
356 if (remove) 343 mTypingAvatars.insert(agent_id);
357 { 344}
358 if (isTyping(agent_id)) 345
359 { 346
360 mTypingAvatars.erase(agent_id); 347void PanelRadar::removeFromTypingList(LLUUID agent_id)
361 } 348{
362 } 349 mTypingAvatars.erase(agent_id);
363 else
364 {
365 mTypingAvatars.insert(agent_id);
366 }
367} 350}
368 351
369 352
@@ -401,7 +384,7 @@ void PanelRadar::addToSimAvList(LLUUID agent_id, std::string distance)
401} 384}
402 385
403 386
404bool PanelRadar::getInSimAvList(LLUUID agent_id) 387bool PanelRadar::isInSimAvList(LLUUID agent_id)
405{ 388{
406 if (mSimAvatars.count(agent_id) > 0) 389 if (mSimAvatars.count(agent_id) > 0)
407 { 390 {
@@ -411,17 +394,17 @@ bool PanelRadar::getInSimAvList(LLUUID agent_id)
411} 394}
412 395
413 396
414void PanelRadar::toggleButtons() 397void PanelRadar::updateButtonStates()
415{ 398{
416 BOOL enable = FALSE; 399 bool enable = false;
417 BOOL enable_unmute = FALSE; 400 bool enable_unmute = false;
418 BOOL enable_track = FALSE; 401 bool enable_track = false;
419 BOOL enable_estate = FALSE; 402 bool enable_estate = false;
420 BOOL enable_friend = FALSE; 403 bool enable_friend = false;
421 if (childHasFocus("RadarPanel")) 404 if (hasFocus())
422 { 405 {
423 enable = mSelectedAvatar.notNull() ? visibleItemsSelected() : FALSE; 406 enable = mSelectedAvatar.notNull() ? visibleItemsSelected() : false;
424 enable_unmute = mSelectedAvatar.notNull() ? LLMuteList::getInstance()->isMuted(mSelectedAvatar) : FALSE; 407 enable_unmute = mSelectedAvatar.notNull() ? LLMuteList::getInstance()->isMuted(mSelectedAvatar) : false;
425 enable_track = gAgent.isGodlike() || is_agent_mappable(mSelectedAvatar); 408 enable_track = gAgent.isGodlike() || is_agent_mappable(mSelectedAvatar);
426 enable_estate = isKickable(mSelectedAvatar); 409 enable_estate = isKickable(mSelectedAvatar);
427 enable_friend = !is_agent_friend(mSelectedAvatar); 410 enable_friend = !is_agent_friend(mSelectedAvatar);
@@ -462,12 +445,12 @@ void PanelRadar::toggleButtons()
462 { 445 {
463 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) 446 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
464 { 447 {
465 childSetEnabled("im_btn", FALSE); 448 childSetEnabled("im_btn", false);
466 childSetEnabled("profile_btn", FALSE); 449 childSetEnabled("profile_btn", false);
467 childSetEnabled("invite_btn", FALSE); 450 childSetEnabled("invite_btn", false);
468 childSetEnabled("add_btn", FALSE); 451 childSetEnabled("add_btn", false);
469 childSetEnabled("mute_btn", FALSE); 452 childSetEnabled("mute_btn", false);
470 childSetEnabled("unmute_btn", FALSE); 453 childSetEnabled("unmute_btn", false);
471 } 454 }
472 455
473 // Even though the avie is in the same sim (so they already know 456 // Even though the avie is in the same sim (so they already know
@@ -487,7 +470,7 @@ void PanelRadar::toggleButtons()
487} 470}
488 471
489 472
490BOOL PanelRadar::isKickable(const LLUUID &agent_id) 473bool PanelRadar::isKickable(const LLUUID &agent_id)
491{ 474{
492 if (agent_id.notNull()) 475 if (agent_id.notNull())
493 { 476 {
@@ -505,7 +488,7 @@ BOOL PanelRadar::isKickable(const LLUUID &agent_id)
505 LLParcel* parcel = LLViewerParcelMgr::getInstance()->selectParcelAt(pos_global)->getParcel(); 488 LLParcel* parcel = LLViewerParcelMgr::getInstance()->selectParcelAt(pos_global)->getParcel();
506 LLViewerParcelMgr::getInstance()->deselectLand(); 489 LLViewerParcelMgr::getInstance()->deselectLand();
507 490
508 BOOL new_value = (region != NULL); 491 bool new_value = (region != NULL);
509 492
510 if (new_value) 493 if (new_value)
511 { 494 {
@@ -520,49 +503,45 @@ BOOL PanelRadar::isKickable(const LLUUID &agent_id)
520 } 503 }
521 } 504 }
522 } 505 }
523 return FALSE; 506 return false;
524} 507}
525 508
526 509
527// static 510// static
528void PanelRadar::onList(LLUICtrl* ctrl, void* user_data) 511void PanelRadar::onUseRadarList(LLUICtrl* ctrl, void* user_data)
529{ 512{
530 PanelRadar* self = (PanelRadar*)user_data; 513 PanelRadar* self = (PanelRadar*)user_data;
531 if (self) 514 if (self)
532 { 515 {
533 self->toggleButtons(); 516 self->updateButtonStates();
534 } 517 }
535} 518}
536 519
537 520
538BOOL PanelRadar::visibleItemsSelected() const 521bool PanelRadar::visibleItemsSelected() const
539{ 522{
540 if (mRadarList->getFirstSelectedIndex() >= 0) 523 return (mRadarList->getFirstSelectedIndex() >= 0);
541 {
542 return TRUE;
543 }
544 return FALSE;
545} 524}
546 525
547 526
548// static 527LLUUID PanelRadar::getSelected()
549void PanelRadar::onRangeChange(LLFocusableElement* focus, void* user_data)
550{ 528{
551 PanelRadar* self = (PanelRadar*)user_data; 529 return mSelectedAvatar;
552 if (self)
553 {
554 self->mUpdate = !(self->childHasFocus("near_me_range"));
555 }
556} 530}
557 531
558 532
559LLUUID PanelRadar::getSelected() 533//static
534std::string PanelRadar::getSelectedName(const LLUUID &agent_id)
560{ 535{
561 return mSelectedAvatar; 536 std::string agent_name;
537 if(gCacheName->getFullName(agent_id, agent_name) && agent_name != " ")
538 {
539 return agent_name;
540 }
541 return LLStringUtil::null;
562} 542}
563 543
564 544
565
566// 545//
567// Avatar tab 546// Avatar tab
568// 547//
@@ -678,18 +657,6 @@ void PanelRadar::onClickAddFriend(void* user_data)
678// 657//
679 658
680//static 659//static
681std::string PanelRadar::getSelectedName(const LLUUID &agent_id)
682{
683 std::string agent_name;
684 if(gCacheName->getFullName(agent_id, agent_name) && agent_name != " ")
685 {
686 return agent_name;
687 }
688 return LLStringUtil::null;
689}
690
691
692//static
693void PanelRadar::callbackFreeze(S32 option, void *user_data) 660void PanelRadar::callbackFreeze(S32 option, void *user_data)
694{ 661{
695 PanelRadar *self = (PanelRadar*)user_data; 662 PanelRadar *self = (PanelRadar*)user_data;
diff --git a/linden/indra/newview/panelradar.h b/linden/indra/newview/panelradar.h
index ca253dd..0152f26 100644
--- a/linden/indra/newview/panelradar.h
+++ b/linden/indra/newview/panelradar.h
@@ -42,15 +42,18 @@ public:
42 42
43 BOOL postBuild(); 43 BOOL postBuild();
44 44
45 // returns true if agent_id belongs to a developer listed in llfloatermap.cpp 45 // returns true if agent_id belongs to an Imprudence developer
46 static bool isImpDev(LLUUID agent_id); 46 static bool isImpDev(LLUUID agent_id);
47 47
48 LLUUID getSelected(); 48 LLUUID getSelected();
49 bool isTyping(LLUUID agent_id);
50 void updateTypingList(LLUUID agent_id, bool remove);
51 49
52 LLScrollListCtrl* mRadarList; 50 void addToTypingList(LLUUID agent_id);
53 LLUUID mSelectedAvatar; 51 void removeFromTypingList(LLUUID agent_id);
52
53 void updateButtonStates();
54 void populateRadar();
55
56private:
54 57
55 // TODO: move all this info into its own object. It's stupid 58 // TODO: move all this info into its own object. It's stupid
56 // and bug-prone to keep it all in separate containers, but 59 // and bug-prone to keep it all in separate containers, but
@@ -58,28 +61,29 @@ public:
58 std::set<LLUUID> mChatAvatars; 61 std::set<LLUUID> mChatAvatars;
59 std::set<LLUUID> mTypingAvatars; 62 std::set<LLUUID> mTypingAvatars;
60 std::set<LLUUID> mSimAvatars; 63 std::set<LLUUID> mSimAvatars;
61 bool mUpdate; 64
62 65 LLScrollListCtrl* mRadarList;
63 static void onList(LLUICtrl* ctrl, void* user_data); 66 LLUUID mSelectedAvatar;
64 static void onRangeChange(LLFocusableElement* focus, void* user_data);
65 BOOL visibleItemsSelected() const;
66 BOOL isKickable(const LLUUID &agent_id);
67 void toggleButtons();
68 void populateRadar();
69 67
70 void updateChatList(std::vector<LLUUID> agent_ids); 68 void updateChatList(std::vector<LLUUID> agent_ids);
71 bool isInChatList(LLUUID agent_id); 69 bool isInChatList(LLUUID agent_id);
72 void addToChatList(LLUUID agent_id, std::string distance); 70 void addToChatList(LLUUID agent_id, std::string distance);
73 void removeFromChatList(LLUUID agent_id); 71 void removeFromChatList(LLUUID agent_id);
74 72
75 bool getInSimAvList(LLUUID agent_id); 73 bool isInSimAvList(LLUUID agent_id);
76 void addToSimAvList(LLUUID agent_id, std::string distance); 74 void addToSimAvList(LLUUID agent_id, std::string distance);
77 void updateSimAvList(std::vector<LLUUID> agent_ids); 75 void updateSimAvList(std::vector<LLUUID> agent_ids);
78 76
79private: 77 bool isTyping(LLUUID agent_id);
78
79 bool visibleItemsSelected() const;
80 bool isKickable(const LLUUID &agent_id);
80 81
81 static std::string getSelectedName(const LLUUID &agent_id); 82 static std::string getSelectedName(const LLUUID &agent_id);
82 83
84 static void onUseRadarList(LLUICtrl* ctrl, void* user_data);
85 static void onRangeChange(LLFocusableElement* focus, void* user_data);
86
83 static void onClickProfile(void* user_data); 87 static void onClickProfile(void* user_data);
84 static void onClickIM(void* user_data); 88 static void onClickIM(void* user_data);
85 static void onClickAddFriend(void* user_data); 89 static void onClickAddFriend(void* user_data);