summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llchathistory.cpp28
-rw-r--r--indra/newview/llfloaterimnearbychathandler.cpp2
-rw-r--r--indra/newview/llfloaterimnearbychatlistener.cpp12
-rw-r--r--indra/newview/llfloaterimnearbychatlistener.h4
-rw-r--r--indra/newview/llviewerchat.cpp2
-rw-r--r--indra/newview/scripts/lua/test_LLChat.lua8
6 files changed, 28 insertions, 28 deletions
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 54b0c171f1..7ee0f3dd7a 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -665,6 +665,7 @@ public:
mSessionID = chat.mSessionID;
mSourceType = chat.mSourceType;
mIsFromScript = is_script;
+ mPrefix = mIsFromScript ? LLTrans::getString("ScriptBy") : "";
// To be able to report a message, we need a copy of it's text
// and it's easier to store text directly than trying to get
@@ -734,7 +735,7 @@ public:
username_end == (chat.mFromName.length() - 1))
{
mFrom = chat.mFromName.substr(0, username_start);
- user_name->setValue(mIsFromScript ? LLTrans::getString("ScriptBy") + mFrom : mFrom);
+ user_name->setValue(mPrefix + mFrom);
if (gSavedSettings.getBOOL("NameTagShowUsernames"))
{
@@ -789,7 +790,7 @@ public:
icon->setValue(LLSD("Command_Destinations_Icon"));
break;
case CHAT_SOURCE_UNKNOWN:
- icon->setValue(mIsFromScript ? LLSD("Inv_Script") : LLSD(chat.mFromID));
+ icon->setValue(mIsFromScript ? LLSD("Inv_Script") : LLSD("Unknown_Icon"));
}
// In case the message came from an object, save the object info
@@ -1031,14 +1032,7 @@ private:
mFrom = av_name.getDisplayName();
LLTextBox* user_name = getChild<LLTextBox>("user_name");
- if(mIsFromScript)
- {
- user_name->setValue(LLSD(LLTrans::getString("ScriptBy") + av_name.getDisplayName()));
- }
- else
- {
- user_name->setValue(LLSD(av_name.getDisplayName()));
- }
+ user_name->setValue(LLSD(mPrefix + av_name.getDisplayName()));
user_name->setToolTip( av_name.getUserName() );
if (gSavedSettings.getBOOL("NameTagShowUsernames") &&
@@ -1081,6 +1075,7 @@ protected:
bool mNeedsTimeBox;
bool mIsFromScript;
+ std::string mPrefix;
private:
boost::signals2::connection mAvatarNameCacheConnection;
@@ -1270,8 +1265,11 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
name_params.color(name_color);
name_params.readonly_color(name_color);
- bool is_lua = (chat.mText.substr(0, LUA_PREFIX.size()) == LUA_PREFIX);
- std::string prefix = chat.mText.substr(is_lua ? LUA_PREFIX.size() : 0, 4);
+ bool is_lua = LLStringUtil::startsWith(chat.mText, LUA_PREFIX);
+
+ std::string message = remove_LUA_PREFIX(chat.mText, is_lua);
+ std::string prefix = message.substr(0, 4);
+
//IRC styled /me messages.
bool irc_me = prefix == "/me " || prefix == "/me'";
@@ -1347,6 +1345,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
// names showing
if (args["show_names_for_p2p_conv"].asBoolean() && utf8str_trim(chat.mFromName).size())
{
+ std::string script_prefix = is_lua ? LLTrans::getString("ScriptBy") : "";
// Don't hotlink any messages from the system (e.g. "Second Life:"), so just add those in plain text.
if (chat.mSourceType == CHAT_SOURCE_OBJECT && chat.mFromID.notNull())
{
@@ -1371,7 +1370,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
link_params.overwriteFrom(LLStyleMap::instance().lookupAgent(chat.mFromID));
// Add link to avatar's inspector and delimiter to message.
- mEditor->appendText(std::string(link_params.link_href) + delimiter,
+ mEditor->appendText(script_prefix + std::string(link_params.link_href) + delimiter,
prependNewLineState, link_params);
prependNewLineState = false;
}
@@ -1384,7 +1383,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
}
else
{
- mEditor->appendText("<nolink>" + chat.mFromName + "</nolink>" + delimiter,
+ mEditor->appendText(script_prefix + "<nolink>" + chat.mFromName + "</nolink>" + delimiter,
prependNewLineState, body_message_params);
prependNewLineState = false;
}
@@ -1505,7 +1504,6 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
// usual messages showing
else if (!teleport_separator)
{
- std::string message = is_lua ? chat.mText.substr(LUA_PREFIX.size()) : chat.mText;
message = irc_me ? message.substr(3) : message;
//MESSAGE TEXT PROCESSING
diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp
index 91d9cd56cf..0c7cd3aec4 100644
--- a/indra/newview/llfloaterimnearbychathandler.cpp
+++ b/indra/newview/llfloaterimnearbychathandler.cpp
@@ -613,7 +613,7 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg,
}
else
{
- toast_msg = chat_msg.mIsScript ? chat_msg.mText.substr(LUA_PREFIX.size()) : chat_msg.mText;
+ toast_msg = remove_LUA_PREFIX(chat_msg.mText, chat_msg.mIsScript);
}
bool chat_overlaps = false;
diff --git a/indra/newview/llfloaterimnearbychatlistener.cpp b/indra/newview/llfloaterimnearbychatlistener.cpp
index e8fb510111..e1be6f7281 100644
--- a/indra/newview/llfloaterimnearbychatlistener.cpp
+++ b/indra/newview/llfloaterimnearbychatlistener.cpp
@@ -39,7 +39,8 @@ static const F32 CHAT_THROTTLE_PERIOD = 1.f;
LLFloaterIMNearbyChatListener::LLFloaterIMNearbyChatListener()
: LLEventAPI("LLChatBar",
- "LLChatBar listener to (e.g.) sendChat, etc.")
+ "LLChatBar listener to (e.g.) sendChat, etc."),
+ mLastThrottleTime(0)
{
add("sendChat",
"Send chat to the simulator:\n"
@@ -51,17 +52,16 @@ LLFloaterIMNearbyChatListener::LLFloaterIMNearbyChatListener()
// "sendChat" command
-void LLFloaterIMNearbyChatListener::sendChat(LLSD const & chat_data) const
+void LLFloaterIMNearbyChatListener::sendChat(LLSD const & chat_data)
{
- static F64 last_throttle_time = 0.0;
F64 cur_time = LLTimer::getElapsedSeconds();
- if (cur_time < last_throttle_time + CHAT_THROTTLE_PERIOD)
+ if (cur_time < mLastThrottleTime + CHAT_THROTTLE_PERIOD)
{
LL_DEBUGS("LLFloaterIMNearbyChatListener") << "'sendChat' was throttled" << LL_ENDL;
return;
}
- last_throttle_time = cur_time;
+ mLastThrottleTime = cur_time;
// Extract the data
std::string chat_text = LUA_PREFIX + chat_data["message"].asString();
@@ -105,6 +105,6 @@ void LLFloaterIMNearbyChatListener::sendChat(LLSD const & chat_data) const
}
// Send it as if it was typed in
- LLFloaterIMNearbyChat::sendChatFromViewer(chat_to_send, type_o_chat, ((BOOL) (channel == 0)) && gSavedSettings.getBOOL("PlayChatAnim"));
+ LLFloaterIMNearbyChat::sendChatFromViewer(chat_to_send, type_o_chat, ((channel == 0)) && gSavedSettings.getBOOL("PlayChatAnim"));
}
diff --git a/indra/newview/llfloaterimnearbychatlistener.h b/indra/newview/llfloaterimnearbychatlistener.h
index 0df0341d36..2d7c851f2c 100644
--- a/indra/newview/llfloaterimnearbychatlistener.h
+++ b/indra/newview/llfloaterimnearbychatlistener.h
@@ -41,7 +41,9 @@ public:
LLFloaterIMNearbyChatListener();
private:
- void sendChat(LLSD const & chat_data) const;
+ void sendChat(LLSD const & chat_data);
+
+ F64 mLastThrottleTime;
};
#endif // LL_LLFLOATERIMNEARBYCHATLISTENER_H
diff --git a/indra/newview/llviewerchat.cpp b/indra/newview/llviewerchat.cpp
index 70c426740b..ce29ceac1a 100644
--- a/indra/newview/llviewerchat.cpp
+++ b/indra/newview/llviewerchat.cpp
@@ -217,7 +217,7 @@ S32 LLViewerChat::getChatFontSize()
//static
void LLViewerChat::formatChatMsg(const LLChat& chat, std::string& formated_msg)
{
- std::string tmpmsg = chat.mIsScript ? chat.mText.substr(LUA_PREFIX.size()) : chat.mText;
+ std::string tmpmsg = remove_LUA_PREFIX(chat.mText, chat.mIsScript);
if(chat.mChatStyle == CHAT_STYLE_IRC)
{
formated_msg = chat.mFromName + tmpmsg.substr(3);
diff --git a/indra/newview/scripts/lua/test_LLChat.lua b/indra/newview/scripts/lua/test_LLChat.lua
index 95bd218baa..883b82fafb 100644
--- a/indra/newview/scripts/lua/test_LLChat.lua
+++ b/indra/newview/scripts/lua/test_LLChat.lua
@@ -2,15 +2,15 @@ LLChat = require 'LLChat'
function generateRandomWord(length)
local alphabet = "abcdefghijklmnopqrstuvwxyz"
- local word = ""
+ local wordTable = {}
for i = 1, length do
local randomIndex = math.random(1, #alphabet)
- word = word .. alphabet:sub(randomIndex, randomIndex)
+ table.insert(wordTable, alphabet:sub(randomIndex, randomIndex))
end
- return word
+ return table.concat(wordTable)
end
-local msg = ""
+local msg = "AI says:"
math.randomseed(os.time())
for i = 1, math.random(1, 10) do
msg = msg .. " ".. generateRandomWord(math.random(1, 8))