From f2dfac8b2281abf7e853e17dc917eff5cc873c56 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 12 Nov 2015 12:01:34 +0100 Subject: [PATCH] Maintenance: Consolidate sendChatFromViewer() methods into FSNearbyChat::sendChatFromViewer() --- indra/newview/fsfloaternearbychat.cpp | 71 ++------------------------- indra/newview/fsfloaternearbychat.h | 12 ++--- indra/newview/fsnearbychathub.cpp | 6 +++ indra/newview/fsnearbychathub.h | 3 +- 4 files changed, 16 insertions(+), 76 deletions(-) diff --git a/indra/newview/fsfloaternearbychat.cpp b/indra/newview/fsfloaternearbychat.cpp index 7e0b74510e..796200cefb 100644 --- a/indra/newview/fsfloaternearbychat.cpp +++ b/indra/newview/fsfloaternearbychat.cpp @@ -846,82 +846,19 @@ void FSFloaterNearbyChat::onChatTypeChanged() void FSFloaterNearbyChat::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate) { - sendChatFromViewer(utf8str_to_wstring(utf8text), type, animate); -} - -void FSFloaterNearbyChat::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) -{ + LLWString wtext = utf8string_to_wstring(utf8text); S32 channel = 0; bool is_set = false; LLWString out_text = FSNearbyChat::stripChannelNumber(wtext, &channel, &sLastSpecialChatChannel, &is_set); - // If "/" is not specified, see if a channel has been set in - // the spinner. + // If "/" is not specified, see if a channel has been set in the spinner. if (!is_set && gSavedSettings.getBOOL("FSNearbyChatbar") && gSavedSettings.getBOOL("FSShowChatChannel")) { - // [FS communication UI] - //channel = (S32)(LLFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); - // [FS communication UI] } - std::string utf8_out_text = wstring_to_utf8str(out_text); - std::string utf8_text = wstring_to_utf8str(wtext); - - utf8_text = utf8str_trim(utf8_text); - if (!utf8_text.empty()) - { - utf8_text = utf8str_truncate(utf8_text, MAX_STRING - 1); - } - - // [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b - if ( (0 == channel) && (rlv_handler_t::isEnabled()) ) - { - // Adjust the (public) chat "volume" on chat and gestures (also takes care of playing the proper animation) - if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) ) - type = CHAT_TYPE_WHISPER; - else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) ) - type = CHAT_TYPE_NORMAL; - else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) ) - type = CHAT_TYPE_NORMAL; - - animate &= !gRlvHandler.hasBehaviour( (!RlvUtil::isEmote(utf8_text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE ); - } - // [/RLVa:KB] - - // Don't animate for chats people can't hear (chat to scripts) - if (animate && (channel == 0)) - { - if (type == CHAT_TYPE_WHISPER) - { - LL_DEBUGS("FSFloaterNearbyChat") << "You whisper " << utf8_text << LL_ENDL; - gAgent.sendAnimationRequest(ANIM_AGENT_WHISPER, ANIM_REQUEST_START); - } - else if (type == CHAT_TYPE_NORMAL) - { - LL_DEBUGS("FSFloaterNearbyChat") << "You say " << utf8_text << LL_ENDL; - gAgent.sendAnimationRequest(ANIM_AGENT_TALK, ANIM_REQUEST_START); - } - else if (type == CHAT_TYPE_SHOUT) - { - LL_DEBUGS("FSFloaterNearbyChat") << "You shout " << utf8_text << LL_ENDL; - gAgent.sendAnimationRequest(ANIM_AGENT_SHOUT, ANIM_REQUEST_START); - } - else - { - LL_INFOS("FSFloaterNearbyChat") << "send_chat_from_viewer() - invalid volume" << LL_ENDL; - return; - } - } - else - { - if (type != CHAT_TYPE_START && type != CHAT_TYPE_STOP) - { - LL_DEBUGS("FSFloaterNearbyChat") << "Channel chat: " << utf8_text << LL_ENDL; - } - } - - send_chat_from_viewer(utf8_out_text, type, channel); + + FSNearbyChat::sendChatFromViewer(wtext, out_text, type, animate, channel); } // Exit "chat mode" and do the appropriate focus changes diff --git a/indra/newview/fsfloaternearbychat.h b/indra/newview/fsfloaternearbychat.h index bd4590ec43..61568670d0 100644 --- a/indra/newview/fsfloaternearbychat.h +++ b/indra/newview/fsfloaternearbychat.h @@ -71,11 +71,11 @@ public: static FSFloaterNearbyChat* findInstance(); static FSFloaterNearbyChat* getInstance(); - + void removeScreenChat(); - + static bool isChatMultiTab(); - + BOOL getVisible(); void onHistoryButtonClicked(); @@ -92,12 +92,9 @@ public: S32 getMessageArchiveLength() {return mMessageArchive.size();} virtual BOOL handleKeyHere( KEY key, MASK mask ); - + static void startChat(const char* line); static void stopChat(); - - static void sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate); - static void sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate); void updateUnreadMessageNotification(S32 unread_messages, bool muted_history); void updateShowMutedChatHistory(const LLSD &data); @@ -108,6 +105,7 @@ protected: void onChatBoxFocusReceived(); void sendChat( EChatType type ); + void sendChatFromViewer(const std::string& utf8text, EChatType type, BOOL animate); void onChatBoxCommit(); void onChatTypeChanged(); diff --git a/indra/newview/fsnearbychathub.cpp b/indra/newview/fsnearbychathub.cpp index 52966e7b05..5cf3776050 100644 --- a/indra/newview/fsnearbychathub.cpp +++ b/indra/newview/fsnearbychathub.cpp @@ -247,6 +247,12 @@ void FSNearbyChat::sendChatFromViewer(const LLWString& wtext, EChatType type, BO { channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); } + + sendChatFromViewer(wtext, out_text, type, animate, channel); +} + +void FSNearbyChat::sendChatFromViewer(const LLWString& wtext, const LLWString& out_text, EChatType type, BOOL animate, S32 channel) +{ std::string utf8_out_text = wstring_to_utf8str(out_text); std::string utf8_text = wstring_to_utf8str(wtext); diff --git a/indra/newview/fsnearbychathub.h b/indra/newview/fsnearbychathub.h index 9a55f2bccd..a371f03281 100644 --- a/indra/newview/fsnearbychathub.h +++ b/indra/newview/fsnearbychathub.h @@ -34,8 +34,6 @@ class FSNearbyChatControl; class LLUICtrl; -void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel); - class FSNearbyChat : public LLSingleton { friend class LLSingleton; @@ -62,6 +60,7 @@ public: static EChatType processChatTypeTriggers(EChatType type, std::string &str); void sendChatFromViewer(const std::string& utf8text, EChatType type, BOOL animate); void sendChatFromViewer(const LLWString& wtext, EChatType type, BOOL animate); + static void sendChatFromViewer(const LLWString& wtext, const LLWString& out_text, EChatType type, BOOL animate, S32 channel); void setFocusedInputEditor(FSNearbyChatControl* inputEditor, BOOL focus);