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.
This commit is contained in:
Lirusaito
2013-01-14 06:30:50 -05:00
parent 00fb7804da
commit 0494dc8d32
4 changed files with 86 additions and 77 deletions

View File

@@ -6743,7 +6743,18 @@ This should be as low as possible, but too low may break functionality</string>
<key>RadarChatKeys</key>
<map>
<key>Comment</key>
<string>Enable private chat alerts for avatars entering the region</string>
<string>Enable alerting scripts about avatars detected by the radar</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>RadarChatKeysStopAsking</key>
<map>
<key>Comment</key>
<string>Do not ask if RadarChatKeys should be enabled when a script requests for the radar's keys.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>

View File

@@ -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<LLUUID>::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)
{

View File

@@ -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<bool> radar_alert_shout_range(gSavedSettings, "RadarAlertShoutRange");
static LLCachedControl<bool> radar_alert_chat_range(gSavedSettings, "RadarAlertChatRange");
static LLCachedControl<bool> radar_alert_age(gSavedSettings, "RadarAlertAge");
static LLCachedControl<bool> 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<bool> announce(gSavedSettings, "RadarChatKeys");
std::queue<LLUUID> 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<bool> 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<bool> on("RadarChatKeys");
static LLCachedControl<bool> 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;
}

View File

@@ -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).
</notification>
<notification
icon="alertmodal.tga"
name="RadarChatKeysRequest"
type="alertmodal">
An object owned by you has requested keys from your radar.
Would you like to enable announcing keys to objects in the sim?
<usetemplate
name="yesnocancelbuttons"
yestext="Yes"
notext="No"
canceltext="No, don't ask again!"/>
</notification>
</notifications>