From 0494dc8d324c0fc63c8899e31e8ba45c7085afd3 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Mon, 14 Jan 2013 06:30:50 -0500 Subject: [PATCH] Fix Issue 432: Radar Keeps Popping Up and side issue `I got still the window "An object owned by you ..."` Unified key message sending to function send_keys_message() Switched a few getBOOLs to CachedControls Added RadarChatKeysStopAsking, and RadarChatKeysRequest as a three button notification so the user can decide to permanently say no. Corrected RadarChatKeys description to be more accurate. If we want to know if the radar is open, we check instanceExists, not getInstance. Also enabled using the announce button when RadarChatKeys is false to announce keys, for manual updates. --- indra/newview/app_settings/settings.xml | 13 +- indra/newview/chatbar_as_cmdline.cpp | 6 +- indra/newview/llfloateravatarlist.cpp | 130 ++++++++---------- .../skins/default/xui/en-us/notifications.xml | 14 ++ 4 files changed, 86 insertions(+), 77 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 5ac2fa00a..97e1651c9 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -6743,7 +6743,18 @@ This should be as low as possible, but too low may break functionality RadarChatKeys Comment - Enable private chat alerts for avatars entering the region + Enable alerting scripts about avatars detected by the radar + Persist + 1 + Type + Boolean + Value + 0 + + RadarChatKeysStopAsking + + Comment + Do not ask if RadarChatKeys should be enabled when a script requests for the radar's keys. Persist 1 Type diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index 7dcd34a59..6d19d693c 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -461,7 +461,7 @@ bool cmd_line_chat(std::string revised_text, EChatType type) return true; } -//case insensative search for avatar in draw distance +//case insensitive search for avatar in draw distance //TODO: make this use the avatar list floaters list so we have EVERYONE // even if they are out of draw distance. LLUUID cmdline_partial_name2key(std::string partial_name) @@ -471,7 +471,7 @@ LLUUID cmdline_partial_name2key(std::string partial_name) LLStringUtil::toLower(partial_name); LLWorld::getInstance()->getAvatars(&avatars); typedef std::vector::const_iterator av_iter; - bool has_avatarlist = (LLFloaterAvatarList::getInstance() ? true : false); + bool has_avatarlist = LLFloaterAvatarList::instanceExists(); if(has_avatarlist) LLFloaterAvatarList::getInstance()->updateAvatarList(); for(av_iter i = avatars.begin(); i != avatars.end(); ++i) @@ -511,7 +511,7 @@ void cmdline_tp2name(std::string target) cmdline_printchat("Avatar not found."); return; } - LLFloaterAvatarList* avlist = LLFloaterAvatarList::getInstance(); + LLFloaterAvatarList* avlist = LLFloaterAvatarList::instanceExists() ? LLFloaterAvatarList::getInstance() : NULL; LLVOAvatar* avatarp = gObjectList.findAvatar(avkey); if(avatarp) { diff --git a/indra/newview/llfloateravatarlist.cpp b/indra/newview/llfloateravatarlist.cpp index 0c6e71773..5a191551b 100644 --- a/indra/newview/llfloateravatarlist.cpp +++ b/indra/newview/llfloateravatarlist.cpp @@ -84,6 +84,8 @@ typedef enum e_radar_alert_type ALERT_TYPE_AGE = 16, } ERadarAlertType; +namespace +{ void chat_avatar_status(std::string name, LLUUID key, ERadarAlertType type, bool entering) { if(gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) return; //RLVa:LF Don't announce people are around when blind, that cheats the system. @@ -94,7 +96,6 @@ void chat_avatar_status(std::string name, LLUUID key, ERadarAlertType type, bool static LLCachedControl radar_alert_shout_range(gSavedSettings, "RadarAlertShoutRange"); static LLCachedControl radar_alert_chat_range(gSavedSettings, "RadarAlertChatRange"); static LLCachedControl radar_alert_age(gSavedSettings, "RadarAlertAge"); - static LLCachedControl radar_chat_keys(gSavedSettings, "RadarChatKeys"); LLFloaterAvatarList* self = LLFloaterAvatarList::getInstance(); LLStringUtil::format_map_t args; @@ -153,6 +154,21 @@ void chat_avatar_status(std::string name, LLUUID key, ERadarAlertType type, bool } } + void send_keys_message(const int transact_num, const int num_ids, const std::string ids) + { + gMessageSystem->newMessage("ScriptDialogReply"); + gMessageSystem->nextBlock("AgentData"); + gMessageSystem->addUUID("AgentID", gAgent.getID()); + gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); + gMessageSystem->nextBlock("Data"); + gMessageSystem->addUUID("ObjectID", gAgent.getID()); + gMessageSystem->addS32("ChatChannel", -777777777); + gMessageSystem->addS32("ButtonIndex", 1); + gMessageSystem->addString("ButtonLabel", llformat("%d,%d", transact_num, num_ids) + ids); + gAgent.sendReliableMessage(); + } +} //namespace + LLAvatarListEntry::LLAvatarListEntry(const LLUUID& id, const std::string &name, const LLVector3d &position) : mID(id), mName(name), mPosition(position), mDrawPosition(), mMarked(false), mFocused(false), mUpdateTimer(), mFrame(gFrameCount), mInSimFrame(U32_MAX), mInDrawFrame(U32_MAX), @@ -567,7 +583,7 @@ void LLFloaterAvatarList::updateAvatarList() size_t i; size_t count = avatar_ids.size(); - bool announce = gSavedSettings.getBOOL("RadarChatKeys"); + static LLCachedControl announce(gSavedSettings, "RadarChatKeys"); std::queue announce_keys; for (i = 0; i < count; ++i) @@ -659,8 +675,9 @@ void LLFloaterAvatarList::updateAvatarList() } } //let us send the keys in a more timely fashion - if(announce && !announce_keys.empty()) + if (announce && !announce_keys.empty()) { + // NOTE: This fragment is repeated in sendKey std::ostringstream ids; int transact_num = (int)gFrameCount; int num_ids = 0; @@ -672,37 +689,17 @@ void LLFloaterAvatarList::updateAvatarList() ids << "," << id.asString(); ++num_ids; - if(ids.tellp() > 200) + if (ids.tellp() > 200) { - gMessageSystem->newMessage("ScriptDialogReply"); - gMessageSystem->nextBlock("AgentData"); - gMessageSystem->addUUID("AgentID", gAgent.getID()); - gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); - gMessageSystem->nextBlock("Data"); - gMessageSystem->addUUID("ObjectID", gAgent.getID()); - gMessageSystem->addS32("ChatChannel", -777777777); - gMessageSystem->addS32("ButtonIndex", 1); - gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); - gAgent.sendReliableMessage(); + send_keys_message(transact_num, num_ids, ids.str()); num_ids = 0; ids.seekp(0); ids.str(""); } } - if(num_ids > 0) - { - gMessageSystem->newMessage("ScriptDialogReply"); - gMessageSystem->nextBlock("AgentData"); - gMessageSystem->addUUID("AgentID", gAgent.getID()); - gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); - gMessageSystem->nextBlock("Data"); - gMessageSystem->addUUID("ObjectID", gAgent.getID()); - gMessageSystem->addS32("ChatChannel", -777777777); - gMessageSystem->addS32("ButtonIndex", 1); - gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); - gAgent.sendReliableMessage(); - } + if (num_ids > 0) + send_keys_message(transact_num, num_ids, ids.str()); } } @@ -1396,19 +1393,17 @@ void LLFloaterAvatarList::onClickGetKey() void LLFloaterAvatarList::sendKeys() { + // This would break for send_keys_btn callback, check this beforehand, if it matters. + //static LLCachedControl radar_chat_keys(gSavedSettings, "RadarChatKeys"); + //if (radar_chat_keys) return; + LLViewerRegion* regionp = gAgent.getRegion(); - if(!regionp)return;//ALWAYS VALIDATE DATA - std::ostringstream ids; + if (!regionp) return;//ALWAYS VALIDATE DATA + static int last_transact_num = 0; int transact_num = (int)gFrameCount; - int num_ids = 0; - if(!gSavedSettings.getBOOL("RadarChatKeys")) - { - return; - } - - if(transact_num > last_transact_num) + if (transact_num > last_transact_num) { last_transact_num = transact_num; } @@ -1419,7 +1414,9 @@ void LLFloaterAvatarList::sendKeys() return; } - if (!regionp) return; // caused crash if logged out/connection lost + std::ostringstream ids; + int num_ids = 0; + for (int i = 0; i < regionp->mMapAvatarIDs.count(); i++) { const LLUUID &id = regionp->mMapAvatarIDs.get(i); @@ -1428,67 +1425,54 @@ void LLFloaterAvatarList::sendKeys() ++num_ids; - if(ids.tellp() > 200) + if (ids.tellp() > 200) { - gMessageSystem->newMessage("ScriptDialogReply"); - gMessageSystem->nextBlock("AgentData"); - gMessageSystem->addUUID("AgentID", gAgent.getID()); - gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); - gMessageSystem->nextBlock("Data"); - gMessageSystem->addUUID("ObjectID", gAgent.getID()); - gMessageSystem->addS32("ChatChannel", -777777777); - gMessageSystem->addS32("ButtonIndex", 1); - gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); - gAgent.sendReliableMessage(); + send_keys_message(transact_num, num_ids, ids.str()); num_ids = 0; ids.seekp(0); ids.str(""); } } - if(num_ids > 0) - { - gMessageSystem->newMessage("ScriptDialogReply"); - gMessageSystem->nextBlock("AgentData"); - gMessageSystem->addUUID("AgentID", gAgent.getID()); - gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); - gMessageSystem->nextBlock("Data"); - gMessageSystem->addUUID("ObjectID", gAgent.getID()); - gMessageSystem->addS32("ChatChannel", -777777777); - gMessageSystem->addS32("ButtonIndex", 1); - gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); - gAgent.sendReliableMessage(); - } + if (num_ids > 0) + send_keys_message(transact_num, num_ids, ids.str()); } //static void LLFloaterAvatarList::sound_trigger_hook(LLMessageSystem* msg,void **) { + if (!LLFloaterAvatarList::instanceExists()) return; // Don't bother if we're closed. + LLUUID sound_id,owner_id; msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_SoundID, sound_id); msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_OwnerID, owner_id); - if(owner_id == gAgent.getID() && sound_id == LLUUID("76c78607-93f9-f55a-5238-e19b1a181389")) + if (owner_id == gAgent.getID() && sound_id == LLUUID("76c78607-93f9-f55a-5238-e19b1a181389")) { - //let's ask if they want to turn it on. - if(gSavedSettings.getBOOL("RadarChatKeys")) - { + static LLCachedControl on("RadarChatKeys"); + static LLCachedControl do_not_ask("RadarChatKeysStopAsking"); + if (on) LLFloaterAvatarList::getInstance()->sendKeys(); - }else - { - LLSD args; - args["MESSAGE"] = "An object owned by you has request the keys from your radar.\nWould you like to enable announcing keys to objects in the sim?"; - LLNotificationsUtil::add("GenericAlertYesCancel", args, LLSD(), onConfirmRadarChatKeys); - } + else if (!do_not_ask) // Let's ask if they want to turn it on, but not pester them. + LLNotificationsUtil::add("RadarChatKeysRequest", LLSD(), LLSD(), onConfirmRadarChatKeys); } } // static bool LLFloaterAvatarList::onConfirmRadarChatKeys(const LLSD& notification, const LLSD& response ) { S32 option = LLNotification::getSelectedOption(notification, response); - if(option == 0) // yes + if (option == 1) // no { - gSavedSettings.setBOOL("RadarChatKeys",TRUE); + return false; + } + else if (option == 0) // yes + { + gSavedSettings.setBOOL("RadarChatKeys", true); LLFloaterAvatarList::getInstance()->sendKeys(); } + else if (option == 2) // No, and stop asking!! + { + gSavedSettings.setBOOL("RadarChatKeysStopAsking", true); + } + return false; } diff --git a/indra/newview/skins/default/xui/en-us/notifications.xml b/indra/newview/skins/default/xui/en-us/notifications.xml index e976ed2ee..dea60a043 100644 --- a/indra/newview/skins/default/xui/en-us/notifications.xml +++ b/indra/newview/skins/default/xui/en-us/notifications.xml @@ -7591,4 +7591,18 @@ AntiSpam: Blocked [SOURCE] for spamming [TYPE]s [AMOUNT] times in [TIME] seconds AntiSpam: Blocked newline flood from [SOURCE] (over [AMOUNT] newlines). + + +An object owned by you has requested keys from your radar. +Would you like to enable announcing keys to objects in the sim? + + +