diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 30dafbf8fa..6537c595da 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -137,7 +137,6 @@ set(viewer_SOURCE_FILES llcapabilitylistener.cpp llcaphttpsender.cpp llchannelmanager.cpp - llchatbar.cpp llchathistory.cpp llchatitemscontainerctrl.cpp llchatmsgbox.cpp @@ -737,7 +736,6 @@ set(viewer_HEADER_FILES llcapabilityprovider.h llcaphttpsender.h llchannelmanager.h - llchatbar.h llchathistory.h llchatitemscontainerctrl.h llchatmsgbox.h diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index 0419fb4c76..d92ba505a3 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -35,7 +35,6 @@ #include "llcalc.h" -#include "llchatbar.h" #include "llagent.h" #include "stdtypes.h" #include "llviewerregion.h" diff --git a/indra/newview/chatbar_as_cmdline.h b/indra/newview/chatbar_as_cmdline.h index 6c646aeb1d..b475202dc3 100644 --- a/indra/newview/chatbar_as_cmdline.h +++ b/indra/newview/chatbar_as_cmdline.h @@ -31,6 +31,6 @@ #include "llviewerprecompiledheaders.h" -#include "llchatbar.h" +#include "llchat.h" bool cmd_line_chat(std::string revised_text, EChatType type, bool from_gesture = false); diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp deleted file mode 100644 index 604a87473b..0000000000 --- a/indra/newview/llchatbar.cpp +++ /dev/null @@ -1,848 +0,0 @@ -/** - * @file llchatbar.cpp - * @brief LLChatBar class implementation - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llchatbar.h" - -#include "imageids.h" -#include "llfontgl.h" -#include "llrect.h" -#include "llerror.h" -#include "llparcel.h" -#include "llstring.h" -#include "message.h" -#include "llfocusmgr.h" - -#include "llagent.h" -#include "llbutton.h" -#include "llcombobox.h" -#include "llcommandhandler.h" // secondlife:///app/chat/ support -#include "llviewercontrol.h" -#include "llgesturemgr.h" -#include "llkeyboard.h" -#include "lllineeditor.h" -#include "llstatusbar.h" -#include "lltextbox.h" -#include "lluiconstants.h" -#include "llviewergesture.h" // for triggering gestures -#include "llviewermenu.h" // for deleting object with DEL key -#include "llviewerstats.h" -#include "llviewerwindow.h" -#include "llframetimer.h" -#include "llresmgr.h" -#include "llworld.h" -#include "llinventorymodel.h" -#include "llmultigesture.h" -#include "llui.h" -#include "llviewermenu.h" -#include "lluictrlfactory.h" -// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) -#include "rlvhandler.h" -// [/RLVa:KB] - -// ## Zi: for chat channel spinner, typing animation -#include "llnearbychat.h" -#include "llspinctrl.h" -// ## Zi: for chat channel spinner, typing animation - -// -// Globals -// -const F32 AGENT_TYPING_TIMEOUT = 5.f; // seconds - -LLChatBar *gChatBar = NULL; - -class LLChatBarGestureObserver : public LLGestureManagerObserver -{ -public: - LLChatBarGestureObserver(LLChatBar* chat_barp) : mChatBar(chat_barp){} - virtual ~LLChatBarGestureObserver() {} - virtual void changed() { mChatBar->refreshGestures(); } -private: - LLChatBar* mChatBar; -}; - - -//extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); -// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-0.2.2a -extern void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel); -// [/RLVa:KB] - -// -// Functions -// - -LLChatBar::LLChatBar() -: LLPanel(), - mInputEditor(NULL), - mGestureLabelTimer(), - mLastSpecialChatChannel(0), - mIsBuilt(FALSE), - mGestureCombo(NULL), - mObserver(NULL) -{ - //setIsChrome(TRUE); -} - - -LLChatBar::~LLChatBar() -{ - LLGestureMgr::instance().removeObserver(mObserver); - delete mObserver; - mObserver = NULL; - // LLView destructor cleans up children -} - -BOOL LLChatBar::postBuild() -{ - getChild("Say")->setCommitCallback(boost::bind(&LLChatBar::onClickSay, this, _1)); - - // * NOTE: mantipov: getChild with default parameters returns dummy widget. - // Seems this class will be completle removed - // attempt to bind to an existing combo box named gesture - setGestureCombo(findChild( "Gesture")); - - mInputEditor = getChild("Chat Editor"); - mInputEditor->setKeystrokeCallback(&onInputEditorKeystroke, this); - mInputEditor->setFocusLostCallback(boost::bind(&LLChatBar::onInputEditorFocusLost)); - mInputEditor->setFocusReceivedCallback(boost::bind(&LLChatBar::onInputEditorGainFocus)); - mInputEditor->setCommitOnFocusLost( FALSE ); - mInputEditor->setRevertOnEsc( FALSE ); - mInputEditor->setIgnoreTab(TRUE); - mInputEditor->setPassDelete(TRUE); - mInputEditor->setReplaceNewlinesWithSpaces(FALSE); - - mInputEditor->setMaxTextLength(DB_CHAT_MSG_STR_LEN); - mInputEditor->setEnableLineHistory(TRUE); - - mIsBuilt = TRUE; - - FSPlayChatAnimation = gSavedSettings.getBOOL("FSPlayChatAnimation"); - gSavedSettings.getControl("FSPlayChatAnimation")->getSignal()->connect(boost::bind(&LLChatBar::updateFSPlayChatAnimation, this, _2)); - - return TRUE; -} - -//----------------------------------------------------------------------- -// Overrides -//----------------------------------------------------------------------- - -// virtual -BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) -{ - BOOL handled = FALSE; - - if( KEY_RETURN == key ) - { - if (mask == MASK_CONTROL) - { - // shout - sendChat(CHAT_TYPE_SHOUT); - handled = TRUE; - } - else if (mask == MASK_SHIFT) - { - // whisper - sendChat(CHAT_TYPE_WHISPER); - handled = TRUE; - } - else if (mask == MASK_ALT) - { - // OOC - sendChat(CHAT_TYPE_OOC); - handled = TRUE; - } - else if (mask == MASK_NONE) - { - // say - sendChat( CHAT_TYPE_NORMAL ); - handled = TRUE; - } - } - // only do this in main chatbar - else if ( KEY_ESCAPE == key && gChatBar == this) - { - stopChat(); - - handled = TRUE; - } - - return handled; -} - -void LLChatBar::refresh() -{ - // HACK: Leave the name of the gesture in place for a few seconds. - const F32 SHOW_GESTURE_NAME_TIME = 2.f; - if (mGestureLabelTimer.getStarted() && mGestureLabelTimer.getElapsedTimeF32() > SHOW_GESTURE_NAME_TIME) - { - LLCtrlListInterface* gestures = mGestureCombo ? mGestureCombo->getListInterface() : NULL; - if (gestures) gestures->selectFirstItem(); - mGestureLabelTimer.stop(); - } - - if ((gAgent.getTypingTime() > AGENT_TYPING_TIMEOUT) && (gAgent.getRenderState() & AGENT_STATE_TYPING)) - { - gAgent.stopTyping(); - } - - getChildView("Say")->setEnabled(mInputEditor->getText().size() > 0); - -} - -void LLChatBar::refreshGestures() -{ - if (mGestureCombo) - { - //store current selection so we can maintain it - std::string cur_gesture = mGestureCombo->getValue().asString(); - mGestureCombo->selectFirstItem(); - std::string label = mGestureCombo->getValue().asString();; - // clear - mGestureCombo->clearRows(); - - // collect list of unique gestures - std::map unique; - LLGestureMgr::item_map_t::const_iterator it; - const LLGestureMgr::item_map_t& active_gestures = LLGestureMgr::instance().getActiveGestures(); - for (it = active_gestures.begin(); it != active_gestures.end(); ++it) - { - LLMultiGesture* gesture = (*it).second; - if (gesture) - { - if (!gesture->mTrigger.empty()) - { - unique[gesture->mTrigger] = TRUE; - } - } - } - - // add unique gestures - std::map ::iterator it2; - for (it2 = unique.begin(); it2 != unique.end(); ++it2) - { - mGestureCombo->addSimpleElement((*it2).first); - } - - mGestureCombo->sortByName(); - // Insert label after sorting, at top, with separator below it - mGestureCombo->addSeparator(ADD_TOP); - mGestureCombo->addSimpleElement(getString("gesture_label"), ADD_TOP); - - if (!cur_gesture.empty()) - { - mGestureCombo->selectByValue(LLSD(cur_gesture)); - } - else - { - mGestureCombo->selectFirstItem(); - } - } -} - -// Move the cursor to the correct input field. -void LLChatBar::setKeyboardFocus(BOOL focus) -{ - if (focus) - { - if (mInputEditor) - { - mInputEditor->setFocus(TRUE); - mInputEditor->selectAll(); - } - } - else if (gFocusMgr.childHasKeyboardFocus(this)) - { - if (mInputEditor) - { - mInputEditor->deselect(); - } - setFocus(FALSE); - } -} - - -// Ignore arrow keys in chat bar -void LLChatBar::setIgnoreArrowKeys(BOOL b) -{ - if (mInputEditor) - { - mInputEditor->setIgnoreArrowKeys(b); - } -} - -BOOL LLChatBar::inputEditorHasFocus() -{ - return mInputEditor && mInputEditor->hasFocus(); -} - -std::string LLChatBar::getCurrentChat() -{ - return mInputEditor ? mInputEditor->getText() : LLStringUtil::null; -} - -void LLChatBar::setGestureCombo(LLComboBox* combo) -{ - mGestureCombo = combo; - if (mGestureCombo) - { - mGestureCombo->setCommitCallback(boost::bind(&LLChatBar::onCommitGesture, this, _1)); - - // now register observer since we have a place to put the results - mObserver = new LLChatBarGestureObserver(this); - LLGestureMgr::instance().addObserver(mObserver); - - // refresh list from current active gestures - refreshGestures(); - } -} - -//----------------------------------------------------------------------- -// Internal functions -//----------------------------------------------------------------------- - -// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20. -// Otherwise returns input and channel 0. -LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel) -{ - if (mesg[0] == '/' - && mesg[1] == '/') - { - // This is a "repeat channel send" - *channel = mLastSpecialChatChannel; - return mesg.substr(2, mesg.length() - 2); - } - else if (mesg[0] == '/' - && mesg[1] - && LLStringOps::isDigit(mesg[1])) - { - // This a special "/20" speak on a channel - S32 pos = 0; - - // Copy the channel number into a string - LLWString channel_string; - llwchar c; - do - { - c = mesg[pos+1]; - channel_string.push_back(c); - pos++; - } - while(c && pos < 64 && LLStringOps::isDigit(c)); - - // Move the pointer forward to the first non-whitespace char - // Check isspace before looping, so we can handle "/33foo" - // as well as "/33 foo" - while(c && iswspace(c)) - { - c = mesg[pos+1]; - pos++; - } - - mLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10); - *channel = mLastSpecialChatChannel; - return mesg.substr(pos, mesg.length() - pos); - } - else - { - // This is normal chat. - *channel = 0; - return mesg; - } -} - -void LLChatBar::updateFSPlayChatAnimation(const LLSD &data) -{ - FSPlayChatAnimation = data.asBoolean(); -} - -void LLChatBar::sendChat( EChatType type ) -{ - if (mInputEditor) - { - LLWString text = mInputEditor->getConvertedText(); - if (!text.empty()) - { - if(type == CHAT_TYPE_OOC) - { - std::string tempText = mInputEditor->getText(); - tempText = gSavedSettings.getString("FSOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("FSOOCPostfix"); - mInputEditor->setText(tempText); - text = utf8str_to_wstring(tempText); - } - - // store sent line in history, duplicates will get filtered - if (mInputEditor) mInputEditor->updateHistory(); - // Check if this is destined for another channel - S32 channel = 0; - stripChannelNumber(text, &channel); - - std::string utf8text = wstring_to_utf8str(text); - // Try to trigger a gesture, if not chat to a script. - std::string utf8_revised_text; - if (0 == channel) - { -//-TT Patch MU_OOC from Satomi Ahn - if (gSavedSettings.getBOOL("AutoCloseOOC")) - { - // Try to find any unclosed OOC chat (i.e. an opening - // double parenthesis without a matching closing double - // parenthesis. - if (utf8text.find("(( ") != -1 && utf8text.find("))") == -1) - { - // add the missing closing double parenthesis. - utf8text += " ))"; - } - else if (utf8text.find("((") != -1 && utf8text.find("))") == -1) - { - if (utf8text.at(utf8text.length() - 1) == ')') - { - // cosmetic: add a space first to avoid a closing triple parenthesis - utf8text += " "; - } - // add the missing closing double parenthesis. - utf8text += "))"; - } - else if (utf8text.find("[[ ") != -1 && utf8text.find("]]") == -1) - { - // add the missing closing double parenthesis. - utf8text += " ]]"; - } - else if (utf8text.find("[[") != -1 && utf8text.find("]]") == -1) - { - if (utf8text.at(utf8text.length() - 1) == ']') - { - // cosmetic: add a space first to avoid a closing triple parenthesis - utf8text += " "; - } - // add the missing closing double parenthesis. - utf8text += "]]"; - } - } - - // Convert MU*s style poses into IRC emotes here. - if (gSavedSettings.getBOOL("AllowMUpose") && utf8text.find(":") == 0 && utf8text.length() > 3) - { - if (utf8text.find(":'") == 0) - { - utf8text.replace(0, 1, "/me"); - } - else if (isalpha(utf8text.at(1))) // Do not prevent smileys and such. - { - utf8text.replace(0, 1, "/me "); - } - } -//-TT Patch MU_OOC from Satomi Ahn - - // discard returned "found" boolean - LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text); - } - else - { - utf8_revised_text = utf8text; - } - - utf8_revised_text = utf8str_trim(utf8_revised_text); - - EChatType nType; - if(type == CHAT_TYPE_OOC) - nType = CHAT_TYPE_NORMAL; - else - nType = type; - - if (!utf8_revised_text.empty()) - { - // Chat with animation - sendChatFromViewer(utf8_revised_text, nType, FSPlayChatAnimation); - } - } - } - - getChild("Chat Editor")->setValue(LLStringUtil::null); - - gAgent.stopTyping(); - - // If the user wants to stop chatting on hitting return, lose focus - // and go out of chat mode. - if (gChatBar == this && (gSavedSettings.getBOOL("CloseChatOnReturn") || gSavedSettings.getBOOL("AutohideChatBar"))) - { - stopChat(); - } -} - - -//----------------------------------------------------------------------- -// Static functions -//----------------------------------------------------------------------- - -// static -void LLChatBar::startChat(const char* line) -{ - //TODO* remove DUMMY chat - //if(gBottomTray && gBottomTray->getChatBox()) - //{ - // gBottomTray->setVisible(TRUE); - // gBottomTray->getChatBox()->setFocus(TRUE); - //} - - // *TODO Vadim: Why was this code commented out? - -// gChatBar->setVisible(TRUE); -// gChatBar->setKeyboardFocus(TRUE); -// gSavedSettings.setBOOL("ChatVisible", TRUE); -// -// if (line && gChatBar->mInputEditor) -// { -// std::string line_string(line); -// gChatBar->mInputEditor->setText(line_string); -// } -// // always move cursor to end so users don't obliterate chat when accidentally hitting WASD -// gChatBar->mInputEditor->setCursorToEnd(); -} - - -// Exit "chat mode" and do the appropriate focus changes -// static -void LLChatBar::stopChat() -{ - //TODO* remove DUMMY chat - //if(gBottomTray && gBottomTray->getChatBox()) - ///{ - // gBottomTray->getChatBox()->setFocus(FALSE); - //} - - // *TODO Vadim: Why was this code commented out? - -// // In simple UI mode, we never release focus from the chat bar -// gChatBar->setKeyboardFocus(FALSE); -// -// // If we typed a movement key and pressed return during the -// // same frame, the keyboard handlers will see the key as having -// // gone down this frame and try to move the avatar. -// gKeyboard->resetKeys(); -// gKeyboard->resetMaskKeys(); -// -// // stop typing animation -// gAgent.stopTyping(); -// -// // hide chat bar so it doesn't grab focus back -// gChatBar->setVisible(FALSE); -// gSavedSettings.setBOOL("ChatVisible", FALSE); -} - -// static -void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata ) -{ - LLChatBar* self = (LLChatBar *)userdata; - - LLWString raw_text; - if (self->mInputEditor) raw_text = self->mInputEditor->getWText(); - - // Can't trim the end, because that will cause autocompletion - // to eat trailing spaces that might be part of a gesture. - LLWStringUtil::trimHead(raw_text); - - S32 length = raw_text.length(); - - // Get the currently selected channel from the channel spinner in the nearby chat bar, if present and used. - // NOTE: Parts of the gAgent.startTyping() code are duplicated in 3 places: - // - llnearbychatbar.cpp - // - llchatbar.cpp - // - llnearbychat.cpp - // So be sure to look in all three places if changes are needed. This needs to be addressed at some point. - // -Zi - S32 channel=0; - if (gSavedSettings.getBOOL("FSNearbyChatbar") && - gSavedSettings.getBOOL("FSShowChatChannel")) - { - channel = (S32)(LLNearbyChat::getInstance()->getChild("ChatChannel")->get()); - } - // -Zi - -// if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences -// [RLVa:KB] - Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.0.0d - // RELEASE-RLVa: [SL-2.0.0] This entire class appears to be dead/non-functional? - if ( (length > 0) && (raw_text[0] != '/') && (!gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT)) ) -// [/RLVa:KB] - { - // only start typing animation if we are chatting without / on channel 0 -Zi - if(channel==0) - gAgent.startTyping(); - } - else - { - gAgent.stopTyping(); - } - - /* Doesn't work -- can't tell the difference between a backspace - that killed the selection vs. backspace at the end of line. - if (length > 1 - && text[0] == '/' - && key == KEY_BACKSPACE) - { - // the selection will already be deleted, but we need to trim - // off the character before - std::string new_text = raw_text.substr(0, length-1); - self->mInputEditor->setText( new_text ); - self->mInputEditor->setCursorToEnd(); - length = length - 1; - } - */ - - KEY key = gKeyboard->currentKey(); - - // Ignore "special" keys, like backspace, arrows, etc. - if (length > 1 - && raw_text[0] == '/' - && key < KEY_SPECIAL) - { - // we're starting a gesture, attempt to autocomplete - - std::string utf8_trigger = wstring_to_utf8str(raw_text); - std::string utf8_out_str(utf8_trigger); - - if (LLGestureMgr::instance().matchPrefix(utf8_trigger, &utf8_out_str)) - { - if (self->mInputEditor) - { - std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size()); - self->mInputEditor->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part - S32 outlength = self->mInputEditor->getLength(); // in characters - - // Select to end of line, starting from the character - // after the last one the user typed. - self->mInputEditor->setSelection(length, outlength); - } - } - - //llinfos << "GESTUREDEBUG " << trigger - // << " len " << length - // << " outlen " << out_str.getLength() - // << llendl; - } -} - -// static -void LLChatBar::onInputEditorFocusLost() -{ - // stop typing animation - gAgent.stopTyping(); -} - -// static -void LLChatBar::onInputEditorGainFocus() -{ - //LLFloaterChat::setHistoryCursorAndScrollToEnd(); -} - -void LLChatBar::onClickSay( LLUICtrl* ctrl ) -{ - std::string cmd = ctrl->getValue().asString(); - e_chat_type chat_type = CHAT_TYPE_NORMAL; - if (cmd == "shout") - { - chat_type = CHAT_TYPE_SHOUT; - } - else if (cmd == "whisper") - { - chat_type = CHAT_TYPE_WHISPER; - } - sendChat(chat_type); -} - -void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate) -{ - sendChatFromViewer(utf8str_to_wstring(utf8text), type, animate); -} - -void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) -{ - // as soon as we say something, we no longer care about teaching the user - // how to chat - gWarningSettings.setBOOL("FirstOtherChatBeforeUser", FALSE); - - // Look for "/20 foo" channel chats. - S32 channel = 0; - LLWString out_text = stripChannelNumber(wtext, &channel); - std::string utf8_out_text = wstring_to_utf8str(out_text); - if (!utf8_out_text.empty()) - { - utf8_out_text = utf8str_truncate(utf8_out_text, MAX_MSG_STR_LEN); - } - - 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 - // RELEASE-RLVa: [SL-2.0.0] This entire class appears to be dead/non-functional? - 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) - { - lldebugs << "You whisper " << utf8_text << llendl; - gAgent.sendAnimationRequest(ANIM_AGENT_WHISPER, ANIM_REQUEST_START); - } - else if (type == CHAT_TYPE_NORMAL) - { - lldebugs << "You say " << utf8_text << llendl; - gAgent.sendAnimationRequest(ANIM_AGENT_TALK, ANIM_REQUEST_START); - } - else if (type == CHAT_TYPE_SHOUT) - { - lldebugs << "You shout " << utf8_text << llendl; - gAgent.sendAnimationRequest(ANIM_AGENT_SHOUT, ANIM_REQUEST_START); - } - else - { - llinfos << "send_chat_from_viewer() - invalid volume" << llendl; - return; - } - } - else - { - if (type != CHAT_TYPE_START && type != CHAT_TYPE_STOP) - { - lldebugs << "Channel chat: " << utf8_text << llendl; - } - } - - send_chat_from_viewer(utf8_out_text, type, channel); -} -/* -void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) -{ - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_ChatFromViewer); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_ChatData); - msg->addStringFast(_PREHASH_Message, utf8_out_text); - msg->addU8Fast(_PREHASH_Type, type); - msg->addS32("Channel", channel); - - gAgent.sendReliableMessage(); - - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); -} -*/ - -void LLChatBar::onCommitGesture(LLUICtrl* ctrl) -{ - LLCtrlListInterface* gestures = mGestureCombo ? mGestureCombo->getListInterface() : NULL; - if (gestures) - { - S32 index = gestures->getFirstSelectedIndex(); - if (index == 0) - { - return; - } - const std::string& trigger = gestures->getSelectedValue().asString(); - - // pretend the user chatted the trigger string, to invoke - // substitution and logging. - std::string text(trigger); - std::string revised_text; - LLGestureMgr::instance().triggerAndReviseString(text, &revised_text); - - revised_text = utf8str_trim(revised_text); - if (!revised_text.empty()) - { - // Don't play nodding animation - sendChatFromViewer(revised_text, CHAT_TYPE_NORMAL, FALSE); - } - } - mGestureLabelTimer.start(); - if (mGestureCombo != NULL) - { - // free focus back to chat bar - mGestureCombo->setFocus(FALSE); - } -} - - -/* Cruft - global gChatHandler declared below has been commented out, - so this class is never used. See similar code in llnearbychatbar.cpp -class LLChatHandler : public LLCommandHandler -{ -public: - // not allowed from outside the app - LLChatHandler() : LLCommandHandler("chat", UNTRUSTED_BLOCK) { } - - // Your code here - bool handle(const LLSD& tokens, const LLSD& query_map, - LLMediaCtrl* web) - { - bool retval = false; - // Need at least 2 tokens to have a valid message. - if (tokens.size() < 2) - { - retval = false; - } - else - { - S32 channel = tokens[0].asInteger(); - // VWR-19499 Restrict function to chat channels greater than 0. - if ((channel > 0) && (channel < CHAT_CHANNEL_DEBUG)) - { - retval = true; - // Say mesg on channel - std::string mesg = tokens[1].asString(); - send_chat_from_viewer(mesg, CHAT_TYPE_NORMAL, channel); - } - else - { - retval = false; - // Tell us this is an unsupported SLurl. - } - } - return retval; - } -}; - -// Creating the object registers with the dispatcher. -//LLChatHandler gChatHandler; -cruft */ diff --git a/indra/newview/llchatbar.h b/indra/newview/llchatbar.h deleted file mode 100644 index aee58a2e4a..0000000000 --- a/indra/newview/llchatbar.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @file llchatbar.h - * @brief LLChatBar class definition - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLCHATBAR_H -#define LL_LLCHATBAR_H - -#include "llpanel.h" -#include "llframetimer.h" -#include "llchat.h" - -class LLLineEditor; -class LLMessageSystem; -class LLUICtrl; -class LLUUID; -class LLFrameTimer; -class LLChatBarGestureObserver; -class LLComboBox; - - -class LLChatBar -: public LLPanel -{ -public: - // constructor for inline chat-bars (e.g. hosted in chat history window) - LLChatBar(); - ~LLChatBar(); - virtual BOOL postBuild(); - - virtual BOOL handleKeyHere(KEY key, MASK mask); - - void refresh(); - void refreshGestures(); - - // Move cursor into chat input field. - void setKeyboardFocus(BOOL b); - - // Ignore arrow keys for chat bar - void setIgnoreArrowKeys(BOOL b); - - BOOL inputEditorHasFocus(); - std::string getCurrentChat(); - - // since chat bar logic is reused for chat history - // gesture combo box might not be a direct child - void setGestureCombo(LLComboBox* combo); - - // Send a chat (after stripping /20foo channel chats). - // "Animate" means the nodding animation for regular text. - void sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate); - void sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate); - - // If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20. - // Otherwise returns input and channel 0. - LLWString stripChannelNumber(const LLWString &mesg, S32* channel); - - // callbacks - void onClickSay(LLUICtrl* ctrl); - - static void onTabClick( void* userdata ); - static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata); - static void onInputEditorFocusLost(); - static void onInputEditorGainFocus(); - - void onCommitGesture(LLUICtrl* ctrl); - - static void startChat(const char* line); - static void stopChat(); - - void updateFSPlayChatAnimation(const LLSD &data); - -protected: - void sendChat(EChatType type); - void updateChat(); - -protected: - LLLineEditor* mInputEditor; - - LLFrameTimer mGestureLabelTimer; - - // Which non-zero channel did we last chat on? - S32 mLastSpecialChatChannel; - - BOOL mIsBuilt; - LLComboBox* mGestureCombo; - - LLChatBarGestureObserver* mObserver; - - BOOL FSPlayChatAnimation; -}; - -extern LLChatBar *gChatBar; - -#endif