From b5f977a6b3757aa785346d20a8f7b29858506d42 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sun, 4 Oct 2009 09:12:16 -0700 Subject: Mini-map radar now notifies when someone enters chat range, and how far away they are --- linden/indra/newview/app_settings/settings.xml | 11 +++ linden/indra/newview/llfloatermap.cpp | 89 ++++++++++++++++++++-- linden/indra/newview/llfloatermap.h | 14 +++- linden/indra/newview/llpanelgeneral.cpp | 2 + .../skins/default/xui/en-us/floater_mini_map.xml | 3 + .../xui/en-us/panel_preferences_general.xml | 5 ++ 6 files changed, 112 insertions(+), 12 deletions(-) (limited to 'linden') diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 84baa99..8a13b85 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -5044,6 +5044,17 @@ Value 1 + MiniMapNotify + + Comment + Notify when avatars enter chat range + Persist + 1 + Type + Boolean + Value + 1 + MiniMapPrimMaxRadius Comment diff --git a/linden/indra/newview/llfloatermap.cpp b/linden/indra/newview/llfloatermap.cpp index c60f07f..9992d9c 100644 --- a/linden/indra/newview/llfloatermap.cpp +++ b/linden/indra/newview/llfloatermap.cpp @@ -43,8 +43,10 @@ #include "lluictrlfactory.h" // radar +#include "llchat.h" #include "llfirstuse.h" #include "llfloateravatarinfo.h" +#include "llfloaterchat.h" #include "llfloaterfriends.h" #include "llfloatergroupinvite.h" #include "llfloatergroups.h" @@ -69,13 +71,15 @@ LLFloaterMap::LLFloaterMap(const LLSD& key) : LLFloater(std::string("minimap")), mPanelMap(NULL), - mUpdate(TRUE) + mUpdate(TRUE), + mSelectedAvatar(LLUUID::null) + { LLCallbackMap::map_t factory_map; factory_map["mini_mapview"] = LLCallbackMap(createPanelMiniMap, this); LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE); - mSelectedAvatar.setNull(); + mChatAvatars.clear(); } @@ -262,6 +266,33 @@ void LLFloaterMap::populateRadar() } // [/RLVa:KB] + // check if they're in chat range and notify user + LLVector3d temp = positions[i] - current_pos; + F32 distance = llround((F32)temp.magVec(), 0.1f); + std::stringstream dist; + dist.str(""); + dist << distance; + + if (gSavedSettings.getBOOL("MiniMapNotify")) + { + if (distance <= 20.0f) + { + if (!getInChatList(avatar_ids[i])) + { + addToChatList(avatar_ids[i], dist.str()); + } + } + else + { + if (getInChatList(avatar_ids[i])) + { + removeFromChatList(avatar_ids[i]); + } + } + + updateChatList(avatar_ids); + } + std::string mute_text = LLMuteList::getInstance()->isMuted(avatar_ids[i]) ? getString("muted") : ""; element["id"] = avatar_ids[i]; element["columns"][0]["column"] = "avatar_name"; @@ -269,12 +300,7 @@ void LLFloaterMap::populateRadar() element["columns"][0]["value"] = fullname + " " + mute_text; element["columns"][1]["column"] = "avatar_distance"; element["columns"][1]["type"] = "text"; - - LLVector3d temp = positions[i] - current_pos; - F32 distance = (F32)temp.magVec(); - char dist[32]; - snprintf(dist, sizeof(dist), "%.1f", distance); - element["columns"][1]["value"] = strcat(dist,"m"); + element["columns"][1]["value"] = dist.str()+"m"; mRadarList->addElement(element, ADD_BOTTOM); } @@ -306,6 +332,53 @@ void LLFloaterMap::populateRadar() //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl; } +void LLFloaterMap::updateChatList(std::vector agent_ids) +{ + std::set::iterator it; + std::vector::iterator result; + for (it = mChatAvatars.begin(); it != mChatAvatars.end(); ) + { + result = find(agent_ids.begin(), agent_ids.end(), *it); + if (result == agent_ids.end()) + { + mChatAvatars.erase(it++); + } + else + { + it++; + } + } +} + +bool LLFloaterMap::getInChatList(LLUUID agent_id) +{ + if (mChatAvatars.count(agent_id) > 0) + { + return true; + } + return false; +} + +void LLFloaterMap::addToChatList(LLUUID agent_id, std::string distance) +{ + mChatAvatars.insert(agent_id); + LLChat chat; + + LLUIString notify = getString("entering_chat_range"); + notify.setArg("[NAME]", getSelectedName(agent_id)); + notify.setArg("[DISTANCE]", distance); + + chat.mText = notify; + chat.mSourceType = CHAT_SOURCE_SYSTEM; + LLFloaterChat::addChat(chat, FALSE, FALSE); +} + +void LLFloaterMap::removeFromChatList(LLUUID agent_id) +{ + // Do we want to add a notice? + mChatAvatars.erase(agent_id); +} + void LLFloaterMap::toggleButtons() { BOOL enable = FALSE; diff --git a/linden/indra/newview/llfloatermap.h b/linden/indra/newview/llfloatermap.h index 349b0e6..deb972b 100644 --- a/linden/indra/newview/llfloatermap.h +++ b/linden/indra/newview/llfloatermap.h @@ -66,10 +66,11 @@ public: private: LLFloaterMap(const LLSD& key = LLSD()); - LLNetMap* mPanelMap; - LLScrollListCtrl* mRadarList; - LLUUID mSelectedAvatar; - bool mUpdate; + LLNetMap* mPanelMap; + LLScrollListCtrl* mRadarList; + LLUUID mSelectedAvatar; + std::set mChatAvatars; + bool mUpdate; static void onList(LLUICtrl* ctrl, void* user_data); static void onRangeChange(LLFocusableElement* focus, void* user_data); @@ -78,6 +79,11 @@ private: void toggleButtons(); void populateRadar(); + void updateChatList(std::vector agent_ids); + bool getInChatList(LLUUID agent_id); + void addToChatList(LLUUID agent_id, std::string distance); + void removeFromChatList(LLUUID agent_id); + static void onClickProfile(void* user_data); static void onClickIM(void* user_data); static void onClickAddFriend(void* user_data); diff --git a/linden/indra/newview/llpanelgeneral.cpp b/linden/indra/newview/llpanelgeneral.cpp index e416401..4cf4091 100644 --- a/linden/indra/newview/llpanelgeneral.cpp +++ b/linden/indra/newview/llpanelgeneral.cpp @@ -60,6 +60,7 @@ BOOL LLPanelGeneral::postBuild() childSetValue("small_avatar_names_checkbox", gSavedSettings.getBOOL("SmallAvatarNames")); childSetValue("show_my_title_checkbox", gSavedSettings.getBOOL("RenderHideGroupTitle")); childSetValue("afk_timeout_spinner", gSavedSettings.getF32("AFKTimeout")); + childSetValue("mini_map_notify", gSavedSettings.getBOOL("MiniMapNotify")); childSetValue("notify_money_change_checkbox", gSavedSettings.getBOOL("NotifyMoneyChange")); childSetValue("use_system_color_picker_checkbox", gSavedSettings.getBOOL("UseDefaultColorPicker")); childSetValue("show_search_panel", gSavedSettings.getBOOL("ShowSearchBar")); @@ -97,6 +98,7 @@ void LLPanelGeneral::apply() gSavedSettings.setBOOL("SmallAvatarNames", childGetValue("small_avatar_names_checkbox")); gSavedSettings.setBOOL("RenderHideGroupTitle", childGetValue("show_my_title_checkbox")); gSavedSettings.setF32("AFKTimeout", childGetValue("afk_timeout_spinner").asReal()); + gSavedSettings.setBOOL("MiniMapNotify", childGetValue("mini_map_notify")); gSavedSettings.setBOOL("NotifyMoneyChange", childGetValue("notify_money_change_checkbox")); gSavedSettings.setBOOL("UseDefaultColorPicker", childGetValue("use_system_color_picker_checkbox")); gSavedSettings.setBOOL("ShowSearchBar", childGetValue("show_search_panel")); diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_mini_map.xml b/linden/indra/newview/skins/default/xui/en-us/floater_mini_map.xml index 3ae02e7..2cb46b7 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_mini_map.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_mini_map.xml @@ -95,4 +95,7 @@ (muted) + + [NAME] has entered chat range ([DISTANCE]m) + diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_general.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_general.xml index bb1c5ee..56bdb28 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_general.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_general.xml @@ -77,6 +77,11 @@ follows="left|top" height="16" increment="1" initial_val="300" label="Away Timeout:" label_width="141" left="10" max_val="600" min_val="30" mouse_opaque="true" name="afk_timeout_spinner" width="202" /> +