From 906dea62dc3f797770f3a7a879bb996d24e2e83b Mon Sep 17 00:00:00 2001 From: ziree Date: Fri, 27 Jan 2012 23:29:53 +0100 Subject: [PATCH] Nearby chat working, toolbar layouts mostly behaving. --- indra/llui/lltoolbar.cpp | 2 - indra/newview/CMakeLists.txt | 13 +- indra/newview/app_settings/commands.xml | 4 +- indra/newview/app_settings/toolbars.xml | 2 +- indra/newview/chatbar_as_cmdline.cpp | 7 +- indra/newview/fslslbridge.cpp | 2 +- indra/newview/fspanelprefs.cpp | 1 - indra/newview/llagent.cpp | 21 +- indra/newview/llcallingcard.cpp | 7 +- indra/newview/llchatitemscontainerctrl.cpp | 14 +- indra/newview/llfirstuse.cpp | 5 +- indra/newview/llfloaternearbychat.cpp | 648 +++++++++ indra/newview/llfloaternearbychat.h | 121 ++ indra/newview/llfloaterpreference.cpp | 9 +- .../newview/llfloatertranslationsettings.cpp | 7 +- indra/newview/llgesturemgr.cpp | 16 +- indra/newview/llimfloatercontainer.cpp | 40 +- indra/newview/llimhandler.cpp | 7 +- indra/newview/llimview.cpp | 14 +- indra/newview/llnearbychat.cpp | 826 +---------- indra/newview/llnearbychat.h | 125 +- indra/newview/llnearbychatbar.cpp | 1265 +---------------- indra/newview/llnearbychatbar.h | 170 +-- indra/newview/llnearbychatbarbase.h | 68 +- indra/newview/llnearbychatbarlistener.cpp | 22 +- indra/newview/llnearbychatbarlistener.h | 7 +- indra/newview/llnearbychatbarmulti.cpp | 153 +- indra/newview/llnearbychatbarmulti.h | 56 +- indra/newview/llnearbychatcontrol.cpp | 234 +++ indra/newview/llnearbychatcontrol.h | 53 + indra/newview/llnearbychathandler.cpp | 11 +- indra/newview/llnearbychathub.cpp | 479 +++++++ indra/newview/llnearbychathub.h | 66 + indra/newview/llnotificationhandlerutil.cpp | 7 +- indra/newview/llnotificationtiphandler.cpp | 16 +- indra/newview/llpanelpeople.cpp | 2 +- indra/newview/llstartup.cpp | 7 +- indra/newview/llviewercontrol.cpp | 8 - indra/newview/llviewerfloaterreg.cpp | 17 +- indra/newview/llviewergesture.cpp | 15 +- indra/newview/llviewerkeyboard.cpp | 25 +- indra/newview/llviewermessage.cpp | 11 +- indra/newview/llviewerwindow.cpp | 75 +- .../default/xui/en/floater_nearby_chat.xml | 4 +- .../default/xui/en/panel_toolbar_view.xml | 74 +- .../newview/skins/default/xui/en/strings.xml | 2 +- .../vintage/xui/en/panel_toolbar_view.xml | 74 + .../skins/vintage/xui/en/widgets/toolbar.xml | 6 +- 48 files changed, 1995 insertions(+), 2823 deletions(-) create mode 100644 indra/newview/llfloaternearbychat.cpp create mode 100644 indra/newview/llfloaternearbychat.h create mode 100644 indra/newview/llnearbychatcontrol.cpp create mode 100644 indra/newview/llnearbychatcontrol.h create mode 100644 indra/newview/llnearbychathub.cpp create mode 100644 indra/newview/llnearbychathub.h diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index e0e016c179..34a748d979 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -1351,7 +1351,6 @@ const std::string LLToolBarButton::getToolTip() const // Returns the current layout style for saving in XML settings LLToolBarEnums::LayoutStyle LLToolBar::getLayoutStyle() const { - llwarns << mLayoutStyle << llendl; return mLayoutStyle; } @@ -1359,7 +1358,6 @@ LLToolBarEnums::LayoutStyle LLToolBar::getLayoutStyle() const void LLToolBar::setLayoutStyle(LLToolBarEnums::LayoutStyle layout_style) { mLayoutStyle=layout_style; - llwarns << mLayoutStyle << llendl; mNeedsLayout=true; } diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 6537c595da..c2f04967fa 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -238,6 +238,7 @@ set(viewer_SOURCE_FILES llfloatermodeluploadbase.cpp llfloatermodelwizard.cpp llfloaternamedesc.cpp + llfloaternearbychat.cpp llfloaternotificationsconsole.cpp llfloaterobjectweights.cpp llfloateropenobject.cpp @@ -352,11 +353,10 @@ set(viewer_SOURCE_FILES llnameeditor.cpp llnamelistctrl.cpp llnavigationbar.cpp - llnearbychat.cpp - llnearbychatbar.cpp + llnearbychatcontrol.cpp llnearbychathandler.cpp + llnearbychathub.cpp llnearbychatbarlistener.cpp - llnearbychatbarmulti.cpp llnetmap.cpp llnotificationalerthandler.cpp llnotificationgrouphandler.cpp @@ -837,6 +837,7 @@ set(viewer_HEADER_FILES llfloatermodeluploadbase.h llfloatermodelwizard.h llfloaternamedesc.h + llfloaternearbychat.h llfloaternotificationsconsole.h llfloaterobjectweights.h llfloateropenobject.h @@ -951,12 +952,10 @@ set(viewer_HEADER_FILES llnameeditor.h llnamelistctrl.h llnavigationbar.h - llnearbychat.h - llnearbychatbar.h - llnearbychatbarbase.h + llnearbychatcontrol.h llnearbychathandler.h + llnearbychathub.h llnearbychatbarlistener.h - llnearbychatbarmulti.h llnetmap.h llnotificationhandler.h llnotificationmanager.h diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index 5fdcc80d4b..5f1103f0b5 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -50,9 +50,9 @@ label_ref="Command_Chat_Label" tooltip_ref="Command_Chat_Tooltip" execute_function="Floater.ToggleOrBringToFront" - execute_parameters="chat_bar" + execute_parameters="im_container" is_running_function="Floater.IsOpen" - is_running_parameters="chat_bar" + is_running_parameters="im_container" /> + button_layout_style="fill"> diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index d92ba505a3..58f4423ac8 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -41,7 +41,10 @@ #include "llworld.h" #include "lluuid.h" #include "llviewercontrol.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "material_codes.h" #include "llvolume.h" @@ -970,7 +973,7 @@ bool cmd_line_chat(std::string revised_text, EChatType type, bool from_gesture) else if(command == std::string(sFSCmdLineClearChat)) { - LLNearbyChat* chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); + LLFloaterNearbyChat* chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); if(chat) { chat->clearChatHistory(); diff --git a/indra/newview/fslslbridge.cpp b/indra/newview/fslslbridge.cpp index 3e2fe40e15..cde2dbfc50 100644 --- a/indra/newview/fslslbridge.cpp +++ b/indra/newview/fslslbridge.cpp @@ -47,7 +47,7 @@ #include "llfoldertype.h" #include "llhttpclient.h" #include "llassetuploadresponders.h" -#include "llnearbychatbar.h" +// #include "llnearbychatbar.h" // Dead code #include "llnotificationmanager.h" #include "llviewerobject.h" diff --git a/indra/newview/fspanelprefs.cpp b/indra/newview/fspanelprefs.cpp index d02f7640f1..71bd0f55c4 100644 --- a/indra/newview/fspanelprefs.cpp +++ b/indra/newview/fspanelprefs.cpp @@ -11,7 +11,6 @@ #include "lggbeamcolormapfloater.h" #include "llvoavatar.h" #include "llvoavatarself.h" -#include "llnearbychat.h" #include "llspinctrl.h" static LLRegisterPanelClassWrapper t_pref_fs("panel_preference_firestorm"); diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 0347674aa1..4ead94aeec 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -54,9 +54,10 @@ #include "llmorphview.h" #include "llmoveview.h" #include "llnavigationbar.h" // to show/hide navigation bar when changing mouse look state +// Remove floating chat bar //#include "llnearbychatbar.h" -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) -#include "llnearbychatbarbase.h" +#include "llnearbychathub.h" +// #include "llspeakers.h" // [/SL:KB] #include "llnotificationsutil.h" @@ -1985,10 +1986,10 @@ void LLAgent::startTyping() { sendAnimationRequest(ANIM_AGENT_TYPE, ANIM_REQUEST_START); } -// LLNearbyChatBar::getInstance()->sendChatFromViewer("", CHAT_TYPE_START, FALSE); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLNearbyChatBarBase::sendChatFromViewer("", CHAT_TYPE_START, FALSE); -// [/SL:KB] + // Remove floating chat bar + // LLNearbyChatBar::getInstance()->sendChatFromViewer("", CHAT_TYPE_START, FALSE); + LLNearbyChat::instance().sendChatFromViewer("", CHAT_TYPE_START, FALSE); + // } //----------------------------------------------------------------------------- @@ -2000,10 +2001,10 @@ void LLAgent::stopTyping() { clearRenderState(AGENT_STATE_TYPING); sendAnimationRequest(ANIM_AGENT_TYPE, ANIM_REQUEST_STOP); -// LLNearbyChatBar::getInstance()->sendChatFromViewer("", CHAT_TYPE_STOP, FALSE); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLNearbyChatBarBase::sendChatFromViewer("", CHAT_TYPE_STOP, FALSE); -// [/SL:KB] + // Remove floating chat bar + // LLNearbyChatBar::getInstance()->sendChatFromViewer("", CHAT_TYPE_STOP, FALSE); + LLNearbyChat::instance().sendChatFromViewer("", CHAT_TYPE_STOP, FALSE); + // } } diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index da6440053f..834351c64f 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -62,7 +62,10 @@ #include "llavataractions.h" #include "lggcontactsets.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "llfloaterreg.h" #include "llnotificationmanager.h" @@ -830,7 +833,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, args["type"] = LLNotificationsUI::NT_NEARBYCHAT; if (history_only) { - LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); + LLFloaterNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); nearby_chat->addMessage(chat, true, LLSD()); } else diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index be304ad27b..5e3af5d3f8 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -35,7 +35,7 @@ #include "llfloaterreg.h" #include "lllocalcliprect.h" #include "lltrans.h" -#include "llnearbychatbar.h" +// #include "llnearbychatbar.h" // Remove floating chat bar #include "llviewercontrol.h" #include "llagentdata.h" @@ -46,6 +46,8 @@ #include "rlvhandler.h" // [/RLVa:KB] +#include "llfloaternearbychat.h" // Remove floating chat bar + static const S32 msg_left_offset = 10; static const S32 msg_right_offset = 10; static const S32 msg_height_pad = 5; @@ -326,12 +328,18 @@ BOOL LLNearbyChatToastPanel::handleMouseUp (S32 x, S32 y, MASK mask) return TRUE; else { - LLNearbyChatBar::getInstance()->showHistory(); + // Remove floating chat bar + // LLNearbyChatBar::getInstance()->showHistory(); + LLFloaterNearbyChat::getInstance()->setVisible(TRUE); + // return FALSE; } } - LLNearbyChatBar::getInstance()->showHistory(); + // Remove floating chat bar + // LLNearbyChatBar::getInstance()->showHistory(); + LLFloaterNearbyChat::getInstance()->setVisible(TRUE); + // return LLPanel::handleMouseUp(x,y,mask); } diff --git a/indra/newview/llfirstuse.cpp b/indra/newview/llfirstuse.cpp index 8a3cb13770..d920cf0652 100644 --- a/indra/newview/llfirstuse.cpp +++ b/indra/newview/llfirstuse.cpp @@ -74,7 +74,10 @@ void LLFirstUse::resetFirstUse() // static void LLFirstUse::otherAvatarChatFirst(bool enable) { - firstUseNotification("FirstOtherChatBeforeUser", enable, "HintChat", LLSD(), LLSD().with("target", "chat_bar").with("direction", "top_right").with("distance", 24)); + // Remove floating chat bar + // firstUseNotification("FirstOtherChatBeforeUser", enable, "HintChat", LLSD(), LLSD().with("target", "chat_bar").with("direction", "top_right").with("distance", 24)); + firstUseNotification("FirstOtherChatBeforeUser", enable, "HintChat", LLSD(), LLSD().with("target", "nearby_chat").with("direction", "top_right").with("distance", 24)); + // } // static diff --git a/indra/newview/llfloaternearbychat.cpp b/indra/newview/llfloaternearbychat.cpp new file mode 100644 index 0000000000..4c6004064f --- /dev/null +++ b/indra/newview/llfloaternearbychat.cpp @@ -0,0 +1,648 @@ +/** + * @file llfloaternearbychat.cpp + * @brief Nearby chat history scrolling panel implementation + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2012, Zi Ree @ Second Life + * + * 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 "llfloaternearbychat.h" + +#include "llviewercontrol.h" +#include "llviewerwindow.h" +#include "llrootview.h" +//#include "llchatitemscontainerctrl.h" +#include "lliconctrl.h" +#include "llspinctrl.h" +#include "llfloatersidepanelcontainer.h" +#include "llfocusmgr.h" +#include "lllogchat.h" +#include "llresizebar.h" +#include "llresizehandle.h" +#include "llmenugl.h" +#include "llviewermenu.h"//for gMenuHolder + +#include "llnearbychathandler.h" +// #include "llnearbychatbar.h" // Remove floating chat bar +#include "llnearbychathub.h" +#include "llchannelmanager.h" + +#include "llagent.h" // gAgent +#include "llchathistory.h" +#include "llstylemap.h" + +#include "llavatarnamecache.h" + +#include "lldraghandle.h" + +// #include "llnearbychatbar.h" // Remove floating chat bar +#include "llfloaterreg.h" +#include "lltrans.h" + +// IM +#include "llbutton.h" +#include "lllayoutstack.h" + +#include "llimfloatercontainer.h" +#include "llimfloater.h" +#include "lllineeditor.h" + +//AO - includes for textentry +#include "rlvhandler.h" +#include "llcommandhandler.h" +#include "llkeyboard.h" +#include "llgesturemgr.h" +#include "llmultigesture.h" + +#include "llconsole.h" +#include "fscontactsfloater.h" + +// Moved nearby chat functionality here for now +#include "chatbar_as_cmdline.h" +#include "llanimationstates.h" // ANIM_AGENT_WHISPER, ANIM_AGENT_TALK, ANIM_AGENT_SHOUT +#include "llviewerstats.h" +// + +static const S32 RESIZE_BAR_THICKNESS = 3; + +// ## Zi // static LLRegisterPanelClassWrapper t_panel_nearby_chat("panel_nearby_chat"); + +LLFloaterNearbyChat::LLFloaterNearbyChat(const LLSD& key) + : LLDockableFloater(NULL, false, false, key) + ,mChatHistory(NULL) + ,mInputEditor(NULL) +{ +} + +LLFloaterNearbyChat::~LLFloaterNearbyChat() +{ +} + +void LLFloaterNearbyChat::updateFSUseNearbyChatConsole(const LLSD &data) +{ + FSUseNearbyChatConsole = data.asBoolean(); + + if (FSUseNearbyChatConsole) + { + LLNotificationsUI::LLScreenChannelBase* chat_channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID"))); + if(chat_channel) + { + chat_channel->removeToastsFromChannel(); + } + gConsole->setVisible(!getVisible()); + } + else + { + gConsole->setVisible(FALSE); + } +} + + +BOOL LLFloaterNearbyChat::postBuild() +{ + //menu + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + enable_registrar.add("NearbyChat.Check", boost::bind(&LLFloaterNearbyChat::onNearbyChatCheckContextMenuItem, this, _2)); + registrar.add("NearbyChat.Action", boost::bind(&LLFloaterNearbyChat::onNearbyChatContextMenuItemClicked, this, _2)); + + + LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile("menu_nearby_chat.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + if(menu) + mPopupMenuHandle = menu->getHandle(); + + gSavedSettings.declareS32("nearbychat_showicons_and_names",2,"NearByChat header settings",true); + + mInputEditor = getChild("chat_box"); + + mInputEditor->setEnabled(TRUE); + + gSavedSettings.getControl("FSNearbyChatbar")->getCommitSignal()->connect(boost::bind(&LLFloaterNearbyChat::onChatBarVisibilityChanged, this)); + gSavedSettings.getControl("FSShowChatChannel")->getCommitSignal()->connect(boost::bind(&LLFloaterNearbyChat::onChatChannelVisibilityChanged, this)); + + onChatBarVisibilityChanged(); + onChatChannelVisibilityChanged(); + + // extra icon controls -AO + LLButton* transl = getChild("translate_btn"); + transl->setVisible(true); + + childSetCommitCallback("chat_history_btn",onHistoryButtonClicked,this); + + mChatHistory = getChild("chat_history"); + + // Nicky D.; FIRE-3066: Force creation or FSFLoaterContacts here, this way it will register with LLAvatarTracker early enough. + // Otherwise it is only create if isChatMultriTab() == true and LLIMFloaterContainer::getInstance is called + LLFloater *pContacts(FSFloaterContacts::getInstance()); + + // Do something with pContacts so no overzealous optimizer optimzes our neat little call to FSFloaterContacts::getInstance() away. + if( pContacts ) + llinfos << "Constructed " << pContacts->getTitle() << llendl; + + // Nicky D.; End FIRE-3066 + + // -AO + if(isChatMultiTab()) + { + LLButton* slide_left = getChild("slide_left_btn"); + slide_left->setVisible(false); + LLButton* slide_right = getChild("slide_right_btn"); + slide_right->setVisible(false); + + + if (getDockControl() == NULL) + { + LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); + if (floater_container) + { + if (gSavedSettings.getBOOL("ChatHistoryTornOff")) + { + // first set the tear-off host to this floater + setHost(floater_container); + // clear the tear-off host right after, the "last host used" will still stick + setHost(NULL); + // reparent the floater to the main view + gFloaterView->addChild(this); + } + else + { + floater_container->addFloater(this, FALSE); + } + floater_container->setVisible(FALSE); + } + } + + FSUseNearbyChatConsole = gSavedSettings.getBOOL("FSUseNearbyChatConsole"); + gSavedSettings.getControl("FSUseNearbyChatConsole")->getSignal()->connect(boost::bind(&LLFloaterNearbyChat::updateFSUseNearbyChatConsole, this, _2)); + + // Show window title according to docking state + mDragHandle->setTitleVisible(gSavedSettings.getBOOL("ChatHistoryTornOff")); + + return LLDockableFloater::postBuild(); + } + + if(!LLDockableFloater::postBuild()) + return false; + + return true; +} + +std::string appendTime() +{ + time_t utc_time; + utc_time = time_corrected(); + std::string timeStr ="["+ LLTrans::getString("TimeHour")+"]:[" + +LLTrans::getString("TimeMin")+"]"; + if (gSavedSettings.getBOOL("FSSecondsinChatTimestamps")) + { + timeStr += ":[" + +LLTrans::getString("TimeSec")+"]"; + } + + LLSD substitution; + + substitution["datetime"] = (S32) utc_time; + LLStringUtil::format (timeStr, substitution); + + return timeStr; +} + + +void LLFloaterNearbyChat::addMessage(const LLChat& chat,bool archive,const LLSD &args) +{ + LLChat& tmp_chat = const_cast(chat); + bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory"); + bool hide_timestamps_nearby_chat = gSavedSettings.getBOOL("FSHideTimestampsNearbyChat"); + // [FIRE-1641 : SJ]: Option to hide timestamps in nearby chat - only add Timestamp when hide_timestamps_nearby_chat is not TRUE + if (!hide_timestamps_nearby_chat) + { + if(tmp_chat.mTimeStr.empty()) + tmp_chat.mTimeStr = appendTime(); + } + + + if (!chat.mMuted) + { + tmp_chat.mFromName = chat.mFromName; + LLSD chat_args = args; + chat_args["use_plain_text_chat_history"] = use_plain_text_chat_history; + chat_args["hide_timestamps_nearby_chat"] = hide_timestamps_nearby_chat; + mChatHistory->appendMessage(chat, chat_args); + } + + if(archive) + { + mMessageArchive.push_back(chat); + if(mMessageArchive.size()>200) + mMessageArchive.erase(mMessageArchive.begin()); + } + + if (args["do_not_log"].asBoolean()) + { + return; + } + + // AO: IF tab mode active, flash our tab + if(isChatMultiTab()) + { + LLMultiFloater* hostp = getHost(); + if( !isInVisibleChain() + && hostp) + { + hostp->setFloaterFlashing(this, TRUE); + } + } + + if (gSavedPerAccountSettings.getBOOL("LogNearbyChat")) + { + std::string from_name = chat.mFromName; + + if (chat.mSourceType == CHAT_SOURCE_AGENT) + { + // if the chat is coming from an agent, log the complete name + LLAvatarName av_name; + LLAvatarNameCache::get(chat.mFromID, &av_name); + + if (!av_name.mIsDisplayNameDefault) + { + from_name = av_name.getCompleteName(); + } + + // Ansariel: Handle IMs in nearby chat + if (gSavedSettings.getBOOL("FSShowIMInChatHistory") && chat.mChatType == CHAT_TYPE_IM) + { + if (gSavedSettings.getBOOL("FSLogIMInChatHistory")) + { + from_name = "IM: " + from_name; + } + else return; + } + } + + LLLogChat::saveHistory("chat", from_name, chat.mFromID, chat.mText); + } +} + +// virtual +BOOL LLFloaterNearbyChat::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash) +{ + mInputEditor->setFocus(TRUE); + onTabInto(); + if(focus_flash) + { + gFocusMgr.triggerFocusFlash(); + } + return TRUE; +} + +void LLFloaterNearbyChat::onNearbySpeakers() +{ + LLSD param; + param["people_panel_tab_name"] = "nearby_panel"; + LLFloaterSidePanelContainer::showPanel("people", "panel_people", param); +} + +// static +void LLFloaterNearbyChat::onHistoryButtonClicked(LLUICtrl* ctrl, void* userdata) +{ + gViewerWindow->getWindow()->openFile(LLLogChat::makeLogFileName("chat")); +} + +void LLFloaterNearbyChat::onNearbyChatContextMenuItemClicked(const LLSD& userdata) +{ +} + +bool LLFloaterNearbyChat::onNearbyChatCheckContextMenuItem(const LLSD& userdata) +{ + std::string str = userdata.asString(); + if(str == "nearby_people") + onNearbySpeakers(); + return false; +} + +void LLFloaterNearbyChat::onChatBarVisibilityChanged() +{ + getChild("chat_bar_visibility_panel")->setVisible(gSavedSettings.getBOOL("FSNearbyChatbar")); +} + +void LLFloaterNearbyChat::onChatChannelVisibilityChanged() +{ + getChild("channel_spinner_visibility_panel")->setVisible(gSavedSettings.getBOOL("FSShowChatChannel")); +} + +void LLFloaterNearbyChat::openFloater(const LLSD& key) +{ + // We override this to put nearbychat in the IM floater. -AO + if(isChatMultiTab()) + { + LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); + // only show the floater container if we are actually attached -Zi + if (floater_container && !gSavedSettings.getBOOL("ChatHistoryTornOff")) + { + floater_container->showFloater(this, LLTabContainer::START); + } + setVisible(TRUE); + LLFloater::openFloater(key); + } +} + +void LLFloaterNearbyChat::removeScreenChat() +{ + LLNotificationsUI::LLScreenChannelBase* chat_channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID"))); + if(chat_channel) + { + chat_channel->removeToastsFromChannel(); + } +} + +void LLFloaterNearbyChat::setVisible(BOOL visible) +{ + if(visible) + { + removeScreenChat(); + } + LLDockableFloater::setVisible(visible); + + // Support for chat console + static LLCachedControl chatHistoryTornOff(gSavedSettings, "ChatHistoryTornOff"); + if (FSUseNearbyChatConsole) + { + LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); + if (floater_container && !chatHistoryTornOff && !floater_container->getVisible()) + { + // In case the nearby chat is docked into the IM floater and the + // IM floater is invisible, always show the console. + gConsole->setVisible(TRUE); + } + else + { + // In case the nearby chat is undocked OR docked and the IM floater + // is visible, show console only if nearby chat is not visible. + gConsole->setVisible(!getVisible()); + } + } + // Support for chat console +} + +void LLFloaterNearbyChat::onOpen(const LLSD& key ) +{ + // We override this to put nearbychat in the IM floater. -AO + if(isChatMultiTab() && ! isVisible(this)) + { + LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); + // only show the floater container if we are actually attached -Zi + if (floater_container && !gSavedSettings.getBOOL("ChatHistoryTornOff")) + { + floater_container->showFloater(this, LLTabContainer::START); + } + setVisible(TRUE); + } + + LLDockableFloater::onOpen(key); +} + +void LLFloaterNearbyChat::setRect (const LLRect &rect) +{ + LLDockableFloater::setRect(rect); +} + +void LLFloaterNearbyChat::getAllowedRect(LLRect& rect) +{ + rect = gViewerWindow->getWorldViewRectScaled(); +} + +// exported here for "clrchat" command line -Zi +void LLFloaterNearbyChat::clearChatHistory() +{ + mChatHistory->clear(); +} + +void LLFloaterNearbyChat::updateChatHistoryStyle() +{ + clearChatHistory(); + + LLSD do_not_log; + do_not_log["do_not_log"] = true; + for(std::vector::iterator it = mMessageArchive.begin();it!=mMessageArchive.end();++it) + { + // Update the messages without re-writing them to a log file. + addMessage(*it,false, do_not_log); + } +} + +//static +void LLFloaterNearbyChat::processChatHistoryStyleUpdate(const LLSD& newvalue) +{ + LLFloaterNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); + if(nearby_chat) + nearby_chat->updateChatHistoryStyle(); +} + +bool isWordsName(const std::string& name) +{ + // checking to see if it's display name plus username in parentheses + S32 open_paren = name.find(" (", 0); + S32 close_paren = name.find(')', 0); + + if (open_paren != std::string::npos && + close_paren == name.length()-1) + { + return true; + } + else + { + //checking for a single space + S32 pos = name.find(' ', 0); + return std::string::npos != pos && name.rfind(' ', name.length()) == pos && 0 != pos && name.length()-1 != pos; + } +} + + + + + +// this probably belongs in LLNearbyChatControl +// virtual +BOOL LLFloaterNearbyChat::handleKeyHere( KEY key, MASK mask ) +{ + BOOL handled = FALSE; + EChatType type = CHAT_TYPE_NORMAL; // won't get used as such + + if( KEY_RETURN == key ) + { + llinfos << "Handling return key, mask=" << mask << llendl; + if (mask == MASK_CONTROL) + { + // shout + type = CHAT_TYPE_SHOUT; + handled = TRUE; + } + else if (mask == MASK_SHIFT) + { + // whisper + type = CHAT_TYPE_WHISPER; + handled = TRUE; + } + else if (mask == MASK_ALT) + { + // OOC + type = CHAT_TYPE_OOC; + handled = TRUE; + } + // Ansariel: For some reason we don't get an unmasked return here. + // So we use the child commit callback that invokes + // LLNearbyChat::onSendMsg() to handle this case. + //else if (mask == MASK_NONE) + //{ + // // say + // type = CHAT_TYPE_NORMAL; + // handled = TRUE; + //} + } + + if (handled == TRUE) + { + LLNearbyChat::getInstance()->sendChat(mInputEditor->getConvertedText(),type); + } + + return handled; +} + +void LLFloaterNearbyChat::loadHistory() +{ + LLSD do_not_log; + do_not_log["do_not_log"] = true; + + std::list history; + LLLogChat::loadAllHistory("chat", history); + + std::list::const_iterator it = history.begin(); + while (it != history.end()) + { + bool im_type = false; + const LLSD& msg = *it; + + std::string from = msg[IM_FROM]; + LLUUID from_id; + if (msg[IM_FROM_ID].isDefined()) + { + from_id = msg[IM_FROM_ID].asUUID(); + } + else + { + // Ansariel: Strip IM prefix so we can properly + // retrieve the UUID in case we got a + // saved IM in nearby chat history. + std::string im_prefix = "IM: "; + size_t im_prefix_found = from.find(im_prefix); + if (im_prefix_found != std::string::npos) + { + from = from.substr(im_prefix.length()); + im_type = true; + } + + std::string legacy_name = gCacheName->buildLegacyName(from); + gCacheName->getUUID(legacy_name, from_id); + } + + LLChat chat; + chat.mFromName = from; + chat.mFromID = from_id; + chat.mText = msg[IM_TEXT].asString(); + chat.mTimeStr = msg[IM_TIME].asString(); + chat.mChatStyle = CHAT_STYLE_HISTORY; + + if (im_type) chat.mChatType = CHAT_TYPE_IM; + + chat.mSourceType = CHAT_SOURCE_AGENT; + if (from_id.isNull() && SYSTEM_FROM == from) + { + chat.mSourceType = CHAT_SOURCE_SYSTEM; + + } + else if (from_id.isNull()) + { + chat.mSourceType = isWordsName(from) ? CHAT_SOURCE_UNKNOWN : CHAT_SOURCE_OBJECT; + } + + addMessage(chat, true, do_not_log); + + it++; + } +} + +//static +LLFloaterNearbyChat* LLFloaterNearbyChat::getInstance() +{ + return LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); +} + +bool LLFloaterNearbyChat::isChatMultiTab() +{ + // Restart is required in order to change chat window type. + static bool is_single_window = gSavedSettings.getS32("ChatWindow") == 1; + return is_single_window; +} + +void LLFloaterNearbyChat::setDocked(bool docked, bool pop_on_undock) +{ + if((!isChatMultiTab()) && gSavedSettings.getBOOL("ChatHistoryTornOff")) + { + mDragHandle->setTitleVisible(docked); // Show window title according to docking state + LLDockableFloater::setDocked(docked, pop_on_undock); + } +} + +// Show window title according to docking state +void LLFloaterNearbyChat::setTornOff(bool torn_off) +{ + mDragHandle->setTitleVisible(torn_off); + LLDockableFloater::setTornOff(torn_off); +} +// Show window title according to docking state + +BOOL LLFloaterNearbyChat::getVisible() +{ + if(isChatMultiTab()) + { + LLIMFloaterContainer* im_container = LLIMFloaterContainer::getInstance(); + + // Treat inactive floater as invisible. + bool is_active = im_container->getActiveFloater() == this; + + //torn off floater is always inactive + if (!is_active && getHost() != im_container) + { + return LLDockableFloater::getVisible(); + } + + // getVisible() returns TRUE when Tabbed IM window is minimized. + return is_active && !im_container->isMinimized() && im_container->getVisible(); + } + else + { + return LLDockableFloater::getVisible(); + } +} diff --git a/indra/newview/llfloaternearbychat.h b/indra/newview/llfloaternearbychat.h new file mode 100644 index 0000000000..338b805920 --- /dev/null +++ b/indra/newview/llfloaternearbychat.h @@ -0,0 +1,121 @@ + /** + * @file llfloaternearbychat.h + * @brief Nearby chat history scrolling panel implementation + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2012, Zi Ree @ Second Life + * + * 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_LLFLOATERNEARBYCHAT_H +#define LL_LLFLOATERNEARBYCHAT_H + +#include "lldockablefloater.h" +#include "llscrollbar.h" +#include "llviewerchat.h" + +class LLResizeBar; +class LLChatHistory; +// Nearby chat bar class +// class LLLineEditor; +#include "lllineeditor.h" +#include "llsingleton.h" +// + +class LLFloaterNearbyChat: public LLDockableFloater +{ +public: + LLFloaterNearbyChat(const LLSD& key); + ~LLFloaterNearbyChat(); + + BOOL postBuild (); + + /** @param archive true - to save a message to the chat history log */ + void addMessage (const LLChat& message,bool archive = true, const LLSD &args = LLSD()); + void onNearbyChatContextMenuItemClicked(const LLSD& userdata); + bool onNearbyChatCheckContextMenuItem(const LLSD& userdata); + + void onChatBarVisibilityChanged(); + void onChatChannelVisibilityChanged(); + + // This doesn't seem to apply anymore? It makes the chat and spin box colors + // appear wrong when focused and unfocused, so disable this. -Zi +#if 0 + virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); + virtual void draw(); + + // focus overrides + /*virtual*/ void onFocusLost(); + /*virtual*/ void onFocusReceived(); +#endif + + /*virtual*/ void onOpen (const LLSD& key); + + /*virtual*/ void setVisible(BOOL visible); + void openFloater(const LLSD& key); + + virtual void setRect (const LLRect &rect); + + void clearChatHistory(); + virtual void updateChatHistoryStyle(); + + static void processChatHistoryStyleUpdate(const LLSD& newvalue); + + void loadHistory(); + + static LLFloaterNearbyChat* getInstance(); + + void removeScreenChat(); + + static bool isChatMultiTab(); + + void setDocked(bool docked, bool pop_on_undock = true); + /*virtual*/ void setTornOff(bool torn_off); // Needed to show window title according to docking state + + BOOL getVisible(); + + static void onHistoryButtonClicked(LLUICtrl* ctrl, void* userdata); + + // overridden to fix the multitab focus bug -Zi + BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); + + void updateFSUseNearbyChatConsole(const LLSD &data); + +private: + void getAllowedRect (LLRect& rect); + + void onNearbySpeakers (); + + void setTyping(bool typing); + + virtual BOOL handleKeyHere( KEY key, MASK mask ); + +private: + LLHandle mPopupMenuHandle; + LLChatHistory* mChatHistory; + + std::vector mMessageArchive; + LLLineEditor* mInputEditor; + + BOOL FSUseNearbyChatConsole; +}; + +#endif diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index f71cac838e..a2cfc08d33 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -56,7 +56,10 @@ #include "llkeyboard.h" #include "llmodaldialog.h" #include "llnavigationbar.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "llnotifications.h" #include "llnotificationsutil.h" #include "llnotificationtemplate.h" @@ -477,11 +480,11 @@ BOOL LLFloaterPreference::postBuild() { gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLIMFloater::processChatHistoryStyleUpdate, _2)); - gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLNearbyChat::processChatHistoryStyleUpdate, _2)); + gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLFloaterNearbyChat::processChatHistoryStyleUpdate, _2)); gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLIMFloater::processChatHistoryStyleUpdate, _2)); - gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLNearbyChat::processChatHistoryStyleUpdate, _2)); + gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterNearbyChat::processChatHistoryStyleUpdate, _2)); gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged)); diff --git a/indra/newview/llfloatertranslationsettings.cpp b/indra/newview/llfloatertranslationsettings.cpp index 428a02e9f0..3cb929aa80 100644 --- a/indra/newview/llfloatertranslationsettings.cpp +++ b/indra/newview/llfloatertranslationsettings.cpp @@ -29,7 +29,7 @@ #include "llfloatertranslationsettings.h" // Viewer includes -#include "llnearbychatbar.h" +// #include "llnearbychatbar.h" // Remove floating chat bar #include "lltranslate.h" #include "llviewercontrol.h" // for gSavedSettings @@ -293,6 +293,9 @@ void LLFloaterTranslationSettings::onBtnOK() gSavedSettings.setString("TranslationService", getSelectedService()); gSavedSettings.setString("BingTranslateAPIKey", getEnteredBingKey()); gSavedSettings.setString("GoogleTranslateAPIKey", getEnteredGoogleKey()); - LLNearbyChatBar::getInstance()->enableTranslationCheckbox(LLTranslate::isTranslationConfigured()); + // Remove floating chat bar + // LLNearbyChatBar::getInstance()->enableTranslationCheckbox(LLTranslate::isTranslationConfigured()); + // TODO: Add code to make this happen via control callback within LLNearbyChat + // closeFloater(false); } diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 517a6d4715..6d6c7ec99b 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -51,10 +51,10 @@ #include "llviewermessage.h" #include "llvoavatarself.h" #include "llviewerstats.h" -//#include "llnearbychatbar.h" -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) -#include "llnearbychatbarbase.h" -// [/SL:KB] +// Remove floating chat bar +// #include "llnearbychatbar.h" +#include "llnearbychathub.h" +// #include "llappearancemgr.h" #include "llgesturelistener.h" @@ -1010,10 +1010,10 @@ void LLGestureMgr::runStep(LLMultiGesture* gesture, LLGestureStep* step) const BOOL animate = FALSE; -// LLNearbyChatBar::getInstance()->sendChatFromViewer(chat_text, CHAT_TYPE_NORMAL, animate); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLNearbyChatBarBase::sendChatFromViewer(chat_text, CHAT_TYPE_NORMAL, animate); -// [/SL:KB] + // Remove floating chat bar + // LLNearbyChatBar::getInstance()->sendChatFromViewer(chat_text, CHAT_TYPE_NORMAL, animate); + LLNearbyChat::getInstance()->sendChatFromViewer(chat_text, CHAT_TYPE_NORMAL, animate); + // gesture->mCurrentStep++; break; diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index 1465aef77e..db1f7540f2 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -34,8 +34,7 @@ #include "llgroupiconctrl.h" #include "llagent.h" #include "lltransientfloatermgr.h" - -#include "llnearbychat.h" +#include "llfloaternearbychat.h" #include "fscontactsfloater.h" #include "llfloater.h" #include "llviewercontrol.h" @@ -81,26 +80,23 @@ void LLIMFloaterContainer::onOpen(const LLSD& key) // But only if it hasnt been already so we can reopen it to the same tab -KC // Improved handling to leave most of the work to the LL tear-off code -Zi - // ND_MERGE - // LLPanel* floater = LLNearbyChat::getInstance(); - // if (! LLFloater::isVisible(floater) && (floater->getHost() != this)) - // { - // if (gSavedSettings.getBOOL("ChatHistoryTornOff")) - // { - // // first set the tear-off host to this floater - // floater->setHost(this); - // // clear the tear-off host right after, the "last host used" will still stick - // floater->setHost(NULL); - // // reparent to floater view - // gFloaterView->addChild(floater); - // } - // else - // { - // LLMultiFloater::showFloater(floater); - // } - // } - // /ND_MERGE - + LLFloater* floater = LLFloaterNearbyChat::getInstance(); + if (! LLFloater::isVisible(floater) && (floater->getHost() != this)) + { + if (gSavedSettings.getBOOL("ChatHistoryTornOff")) + { + // first set the tear-off host to this floater + floater->setHost(this); + // clear the tear-off host right after, the "last host used" will still stick + floater->setHost(NULL); + // reparent to floater view + gFloaterView->addChild(floater); + } + else + { + LLMultiFloater::showFloater(floater); + } + } /* if (key.isDefined()) diff --git a/indra/newview/llimhandler.cpp b/indra/newview/llimhandler.cpp index 81566da35d..d4944a6944 100644 --- a/indra/newview/llimhandler.cpp +++ b/indra/newview/llimhandler.cpp @@ -37,7 +37,10 @@ #include "llavatarnamecache.h" #include "llconsole.h" #include "llfloaterreg.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "rlvhandler.h" #include "lggcontactsets.h" @@ -203,6 +206,6 @@ void LLIMHandler::onAvatarNameLookup(const LLUUID& agent_id, const LLAvatarName& } gConsole->addConsoleLine("IM: " + senderName + delimiter + message, textColor); - LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); + LLFloaterNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); gConsole->setVisible(!nearby_chat->getVisible()); } diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 4dcd0732c2..69087518fa 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -57,7 +57,10 @@ #include "llviewerwindow.h" #include "llnotifications.h" #include "llnotificationsutil.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "llspeakers.h" //for LLIMSpeakerMgr #include "lltextbox.h" #include "lltoolbarview.h" @@ -852,7 +855,7 @@ bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from, chat.mSourceType = CHAT_SOURCE_AGENT; chat.mText = utf8_text; chat.mTimeStr = timestr; - LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); + LLFloaterNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); nearby_chat->addMessage(chat, true, LLSD()); } // @@ -2603,8 +2606,11 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& mess LLChat chat(message); chat.mSourceType = CHAT_SOURCE_SYSTEM; - LLFloater* chat_bar = LLFloaterReg::getInstance("chat_bar"); - LLNearbyChat* nearby_chat = chat_bar->findChild("nearby_chat"); + // Remove floating chat bar + // LLFloater* chat_bar = LLFloaterReg::getInstance("chat_bar"); + // LLNearbyChat* nearby_chat = chat_bar->findChild("nearby_chat"); + LLFloaterNearbyChat* nearby_chat = LLFloaterNearbyChat::getInstance(); + // if(nearby_chat) { diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index d553a82c5f..9dba386362 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -1,825 +1,5 @@ -/** - * @file LLNearbyChat.cpp - * @brief Nearby chat history scrolling panel implementation - * - * $LicenseInfo:firstyear=2009&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" +This file is not used by Firestorm. It's being kept in place to track merges. -#include "llnearbychat.h" -#include "llviewercontrol.h" -#include "llviewerwindow.h" -#include "llrootview.h" -//#include "llchatitemscontainerctrl.h" -#include "lliconctrl.h" -#include "llspinctrl.h" -#include "llfloatersidepanelcontainer.h" -#include "llfocusmgr.h" -#include "lllogchat.h" -#include "llresizebar.h" -#include "llresizehandle.h" -#include "llmenugl.h" -#include "llviewermenu.h"//for gMenuHolder - -#include "llnearbychathandler.h" -#include "llnearbychatbar.h" -#include "llchannelmanager.h" - -#include "llagent.h" // gAgent -#include "llchathistory.h" -#include "llstylemap.h" - -#include "llavatarnamecache.h" - -#include "lldraghandle.h" - -#include "llnearbychatbar.h" -#include "llfloaterreg.h" -#include "lltrans.h" - -// IM -#include "llbutton.h" -#include "lllayoutstack.h" - -#include "llimfloatercontainer.h" -#include "llimfloater.h" -#include "lllineeditor.h" - -//AO - includes for textentry -#include "rlvhandler.h" -#include "llcommandhandler.h" -#include "llkeyboard.h" -#include "llgesturemgr.h" -#include "llmultigesture.h" - -#include "llconsole.h" -#include "fscontactsfloater.h" - -static const S32 RESIZE_BAR_THICKNESS = 3; - -struct LLChatTypeTrigger { - std::string name; - EChatType type; -}; - -static LLChatTypeTrigger sChatTypeTriggers[] = { - { "/whisper" , CHAT_TYPE_WHISPER}, - { "/shout" , CHAT_TYPE_SHOUT} -}; - -// ## Zi // static LLRegisterPanelClassWrapper t_panel_nearby_chat("panel_nearby_chat"); - -LLNearbyChat::LLNearbyChat(const LLSD& key) - : LLDockableFloater(NULL, false, false, key) - ,mChatHistory(NULL) - ,mInputEditor(NULL) -{ - -} - -LLNearbyChat::~LLNearbyChat() -{ -} - -void LLNearbyChat::updateFSUseNearbyChatConsole(const LLSD &data) -{ - FSUseNearbyChatConsole = data.asBoolean(); - - if (FSUseNearbyChatConsole) - { - LLNotificationsUI::LLScreenChannelBase* chat_channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID"))); - if(chat_channel) - { - chat_channel->removeToastsFromChannel(); - } - gConsole->setVisible(!getVisible()); - } - else - { - gConsole->setVisible(FALSE); - } -} - - -BOOL LLNearbyChat::postBuild() -{ - //menu - LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; - LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; - - enable_registrar.add("NearbyChat.Check", boost::bind(&LLNearbyChat::onNearbyChatCheckContextMenuItem, this, _2)); - registrar.add("NearbyChat.Action", boost::bind(&LLNearbyChat::onNearbyChatContextMenuItemClicked, this, _2)); - - - LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile("menu_nearby_chat.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - if(menu) - mPopupMenuHandle = menu->getHandle(); - - gSavedSettings.declareS32("nearbychat_showicons_and_names",2,"NearByChat header settings",true); - - // Text Entry - relay to llnearbychatbar - mInputEditor = getChild("chat_box"); - //mInputEditor->setMaxTextLength(1023); - mInputEditor->setFocusReceivedCallback( boost::bind(onInputEditorFocusReceived, _1, this) ); - mInputEditor->setFocusLostCallback( boost::bind(onInputEditorFocusLost, _1, this) ); - mInputEditor->setKeystrokeCallback( onInputEditorKeystroke, this ); - childSetCommitCallback("chat_box", onSendMsg, this); - mInputEditor->setEnableLineHistory(TRUE); - mInputEditor->setIgnoreArrowKeys( FALSE ); - mInputEditor->setCommitOnFocusLost( FALSE ); - mInputEditor->setRevertOnEsc( FALSE ); - mInputEditor->setIgnoreTab( TRUE ); - mInputEditor->setReplaceNewlinesWithSpaces( FALSE ); - mInputEditor->setPassDelete( TRUE ); - mInputEditor->setEnabled(TRUE); - - gSavedSettings.getControl("FSNearbyChatbar")->getCommitSignal()->connect(boost::bind(&LLNearbyChat::onChatBarVisibilityChanged, this)); - gSavedSettings.getControl("FSShowChatChannel")->getCommitSignal()->connect(boost::bind(&LLNearbyChat::onChatChannelVisibilityChanged, this)); - - onChatBarVisibilityChanged(); - onChatChannelVisibilityChanged(); - - // extra icon controls -AO - LLButton* transl = getChild("translate_btn"); - transl->setVisible(true); - - childSetCommitCallback("chat_history_btn",onHistoryButtonClicked,this); - - mChatHistory = getChild("chat_history"); - - // Nicky D.; FIRE-3066: Force creation or FSFLoaterContacts here, this way it will register with LLAvatarTracker early enough. - // Otherwise it is only create if isChatMultriTab() == true and LLIMFloaterContainer::getInstance is called - LLFloater *pContacts(FSFloaterContacts::getInstance()); - - // Do something with pContacts so no overzealous optimizer optimzes our neat little call to FSFloaterContacts::getInstance() away. - if( pContacts ) - llinfos << "Constructed " << pContacts->getTitle() << llendl; - - // Nicky D.; End FIRE-3066 - - // -AO - if(isChatMultiTab()) - { - LLButton* slide_left = getChild("slide_left_btn"); - slide_left->setVisible(false); - LLButton* slide_right = getChild("slide_right_btn"); - slide_right->setVisible(false); - - - if (getDockControl() == NULL) - { - LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); - if (floater_container) - { - if (gSavedSettings.getBOOL("ChatHistoryTornOff")) - { - // first set the tear-off host to this floater - setHost(floater_container); - // clear the tear-off host right after, the "last host used" will still stick - setHost(NULL); - // reparent the floater to the main view - gFloaterView->addChild(this); - } - else - { - floater_container->addFloater(this, FALSE); - } - floater_container->setVisible(FALSE); - } - } - - FSUseNearbyChatConsole = gSavedSettings.getBOOL("FSUseNearbyChatConsole"); - gSavedSettings.getControl("FSUseNearbyChatConsole")->getSignal()->connect(boost::bind(&LLNearbyChat::updateFSUseNearbyChatConsole, this, _2)); - - // Show window title according to docking state - mDragHandle->setTitleVisible(gSavedSettings.getBOOL("ChatHistoryTornOff")); - - return LLDockableFloater::postBuild(); - } - - if(!LLDockableFloater::postBuild()) - return false; - - return true; -} - -std::string appendTime() -{ - time_t utc_time; - utc_time = time_corrected(); - std::string timeStr ="["+ LLTrans::getString("TimeHour")+"]:[" - +LLTrans::getString("TimeMin")+"]"; - if (gSavedSettings.getBOOL("FSSecondsinChatTimestamps")) - { - timeStr += ":[" - +LLTrans::getString("TimeSec")+"]"; - } - - LLSD substitution; - - substitution["datetime"] = (S32) utc_time; - LLStringUtil::format (timeStr, substitution); - - return timeStr; -} - - -void LLNearbyChat::addMessage(const LLChat& chat,bool archive,const LLSD &args) -{ - LLChat& tmp_chat = const_cast(chat); - bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory"); - bool hide_timestamps_nearby_chat = gSavedSettings.getBOOL("FSHideTimestampsNearbyChat"); - // [FIRE-1641 : SJ]: Option to hide timestamps in nearby chat - only add Timestamp when hide_timestamps_nearby_chat is not TRUE - if (!hide_timestamps_nearby_chat) - { - if(tmp_chat.mTimeStr.empty()) - tmp_chat.mTimeStr = appendTime(); - } - - - if (!chat.mMuted) - { - tmp_chat.mFromName = chat.mFromName; - LLSD chat_args = args; - chat_args["use_plain_text_chat_history"] = use_plain_text_chat_history; - chat_args["hide_timestamps_nearby_chat"] = hide_timestamps_nearby_chat; - mChatHistory->appendMessage(chat, chat_args); - } - - if(archive) - { - mMessageArchive.push_back(chat); - if(mMessageArchive.size()>200) - mMessageArchive.erase(mMessageArchive.begin()); - } - - if (args["do_not_log"].asBoolean()) - { - return; - } - - // AO: IF tab mode active, flash our tab - if(isChatMultiTab()) - { - LLMultiFloater* hostp = getHost(); - if( !isInVisibleChain() - && hostp) - { - hostp->setFloaterFlashing(this, TRUE); - } - } - - if (gSavedPerAccountSettings.getBOOL("LogNearbyChat")) - { - std::string from_name = chat.mFromName; - - if (chat.mSourceType == CHAT_SOURCE_AGENT) - { - // if the chat is coming from an agent, log the complete name - LLAvatarName av_name; - LLAvatarNameCache::get(chat.mFromID, &av_name); - - if (!av_name.mIsDisplayNameDefault) - { - from_name = av_name.getCompleteName(); - } - - // Ansariel: Handle IMs in nearby chat - if (gSavedSettings.getBOOL("FSShowIMInChatHistory") && chat.mChatType == CHAT_TYPE_IM) - { - if (gSavedSettings.getBOOL("FSLogIMInChatHistory")) - { - from_name = "IM: " + from_name; - } - else return; - } - } - - LLLogChat::saveHistory("chat", from_name, chat.mFromID, chat.mText); - } -} - -// virtual -BOOL LLNearbyChat::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash) -{ - mInputEditor->setFocus(TRUE); - onTabInto(); - if(focus_flash) - { - gFocusMgr.triggerFocusFlash(); - } - return TRUE; -} - -void LLNearbyChat::onNearbySpeakers() -{ - LLSD param; - param["people_panel_tab_name"] = "nearby_panel"; - LLFloaterSidePanelContainer::showPanel("people", "panel_people", param); -} - -// static -void LLNearbyChat::onHistoryButtonClicked(LLUICtrl* ctrl, void* userdata) -{ - gViewerWindow->getWindow()->openFile(LLLogChat::makeLogFileName("chat")); -} - -void LLNearbyChat::onNearbyChatContextMenuItemClicked(const LLSD& userdata) -{ -} - -bool LLNearbyChat::onNearbyChatCheckContextMenuItem(const LLSD& userdata) -{ - std::string str = userdata.asString(); - if(str == "nearby_people") - onNearbySpeakers(); - return false; -} - -void LLNearbyChat::onChatBarVisibilityChanged() -{ - getChild("chat_bar_visibility_panel")->setVisible(gSavedSettings.getBOOL("FSNearbyChatbar")); -} - -void LLNearbyChat::onChatChannelVisibilityChanged() -{ - getChild("channel_spinner_visibility_panel")->setVisible(gSavedSettings.getBOOL("FSShowChatChannel")); -} - -void LLNearbyChat::openFloater(const LLSD& key) -{ - // We override this to put nearbychat in the IM floater. -AO - if(isChatMultiTab()) - { - LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); - // only show the floater container if we are actually attached -Zi - if (floater_container && !gSavedSettings.getBOOL("ChatHistoryTornOff")) - { - floater_container->showFloater(this, LLTabContainer::START); - } - setVisible(TRUE); - LLFloater::openFloater(key); - } -} - -void LLNearbyChat::removeScreenChat() -{ - LLNotificationsUI::LLScreenChannelBase* chat_channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID"))); - if(chat_channel) - { - chat_channel->removeToastsFromChannel(); - } -} - -void LLNearbyChat::setVisible(BOOL visible) -{ - if(visible) - { - removeScreenChat(); - } - LLDockableFloater::setVisible(visible); - - // Support for chat console - static LLCachedControl chatHistoryTornOff(gSavedSettings, "ChatHistoryTornOff"); - if (FSUseNearbyChatConsole) - { - LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); - if (floater_container && !chatHistoryTornOff && !floater_container->getVisible()) - { - // In case the nearby chat is docked into the IM floater and the - // IM floater is invisible, always show the console. - gConsole->setVisible(TRUE); - } - else - { - // In case the nearby chat is undocked OR docked and the IM floater - // is visible, show console only if nearby chat is not visible. - gConsole->setVisible(!getVisible()); - } - } - // Support for chat console -} - -void LLNearbyChat::onOpen(const LLSD& key ) -{ - // We override this to put nearbychat in the IM floater. -AO - if(isChatMultiTab() && ! isVisible(this)) - { - LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); - // only show the floater container if we are actually attached -Zi - if (floater_container && !gSavedSettings.getBOOL("ChatHistoryTornOff")) - { - floater_container->showFloater(this, LLTabContainer::START); - } - setVisible(TRUE); - } - - LLDockableFloater::onOpen(key); -} - - - -void LLNearbyChat::setRect (const LLRect &rect) -{ - LLDockableFloater::setRect(rect); -} - -void LLNearbyChat::getAllowedRect(LLRect& rect) -{ - rect = gViewerWindow->getWorldViewRectScaled(); -} - -// exported here for "clrchat" command line -Zi -void LLNearbyChat::clearChatHistory() -{ - mChatHistory->clear(); -} - -void LLNearbyChat::updateChatHistoryStyle() -{ - clearChatHistory(); - - LLSD do_not_log; - do_not_log["do_not_log"] = true; - for(std::vector::iterator it = mMessageArchive.begin();it!=mMessageArchive.end();++it) - { - // Update the messages without re-writing them to a log file. - addMessage(*it,false, do_not_log); - } -} - -//static -void LLNearbyChat::processChatHistoryStyleUpdate(const LLSD& newvalue) -{ - LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); - if(nearby_chat) - nearby_chat->updateChatHistoryStyle(); -} - -bool isWordsName(const std::string& name) -{ - // checking to see if it's display name plus username in parentheses - S32 open_paren = name.find(" (", 0); - S32 close_paren = name.find(')', 0); - - if (open_paren != std::string::npos && - close_paren == name.length()-1) - { - return true; - } - else - { - //checking for a single space - S32 pos = name.find(' ', 0); - return std::string::npos != pos && name.rfind(' ', name.length()) == pos && 0 != pos && name.length()-1 != pos; - } -} -void LLNearbyChat::onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata ) -{ - // ND_MERGE code from FS commented out, causes endless recursion - // LLNearbyChatBar::getInstance()->onChatBoxFocusReceived(); - // -} -void LLNearbyChat::onInputEditorFocusLost(LLFocusableElement* caller, void* userdata) -{ - // ND_MERGE code from FS commented out, causes endless recursion - // LLNearbyChatBar::getInstance()->onChatBoxFocusLost(); - // -} -void LLNearbyChat::onInputEditorKeystroke(LLLineEditor* caller, void* userdata) -{ - LLNearbyChat* self = (LLNearbyChat*)userdata; - LLWString 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 - 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(); - } - - 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)) - { - 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); - } - else if (matchChatTypeTrigger(utf8_trigger, &utf8_out_str)) - { - 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 - self->mInputEditor->setCursorToEnd(); - } - } -} - -void LLNearbyChat::doSendMsg( std::string msg, EChatType type ) -{ - LLNearbyChatBar* masterBar = LLNearbyChatBar::getInstance(); - std::string masterText = masterBar->getCurrentChat(); - masterBar->setText(msg); - masterBar->sendChat(type); - mInputEditor->setText(LLStringExplicit("")); - masterBar->setText(masterText); -} - -void LLNearbyChat::onSendMsg( LLUICtrl* ctrl, void* userdata ) -{ - LLNearbyChat* self = (LLNearbyChat*)userdata; - std::string sendText = self->mInputEditor->getText(); - self->doSendMsg(sendText,CHAT_TYPE_NORMAL); -} - -// virtual -BOOL LLNearbyChat::handleKeyHere( KEY key, MASK mask ) -{ - BOOL handled = FALSE; - EChatType type = CHAT_TYPE_NORMAL; // won't get used as such - - if( KEY_RETURN == key ) - { - llinfos << "Handling return key, mask=" << mask << llendl; - if (mask == MASK_CONTROL) - { - // shout - type = CHAT_TYPE_SHOUT; - handled = TRUE; - } - else if (mask == MASK_SHIFT) - { - // whisper - type = CHAT_TYPE_WHISPER; - handled = TRUE; - } - else if (mask == MASK_ALT) - { - // OOC - type = CHAT_TYPE_OOC; - handled = TRUE; - } - // Ansariel: For some reason we don't get an unmasked return here. - // So we use the child commit callback that invokes - // LLNearbyChat::onSendMsg() to handle this case. - //else if (mask == MASK_NONE) - //{ - // // say - // type = CHAT_TYPE_NORMAL; - // handled = TRUE; - //} - } - - if (handled == TRUE) - { - doSendMsg(mInputEditor->getText(),type); - } - - return handled; -} - -BOOL LLNearbyChat::matchChatTypeTrigger(const std::string& in_str, std::string* out_str) -{ - U32 in_len = in_str.length(); - S32 cnt = sizeof(sChatTypeTriggers) / sizeof(*sChatTypeTriggers); - - for (S32 n = 0; n < cnt; n++) - { - if (in_len > sChatTypeTriggers[n].name.length()) - continue; - - std::string trigger_trunc = sChatTypeTriggers[n].name; - LLStringUtil::truncate(trigger_trunc, in_len); - - if (!LLStringUtil::compareInsensitive(in_str, trigger_trunc)) - { - *out_str = sChatTypeTriggers[n].name; - return TRUE; - } - } - - return FALSE; -} - -void LLNearbyChat::loadHistory() -{ - LLSD do_not_log; - do_not_log["do_not_log"] = true; - - std::list history; - LLLogChat::loadAllHistory("chat", history); - - std::list::const_iterator it = history.begin(); - while (it != history.end()) - { - bool im_type = false; - const LLSD& msg = *it; - - std::string from = msg[IM_FROM]; - LLUUID from_id; - if (msg[IM_FROM_ID].isDefined()) - { - from_id = msg[IM_FROM_ID].asUUID(); - } - else - { - // Ansariel: Strip IM prefix so we can properly - // retrieve the UUID in case we got a - // saved IM in nearby chat history. - std::string im_prefix = "IM: "; - size_t im_prefix_found = from.find(im_prefix); - if (im_prefix_found != std::string::npos) - { - from = from.substr(im_prefix.length()); - im_type = true; - } - - std::string legacy_name = gCacheName->buildLegacyName(from); - gCacheName->getUUID(legacy_name, from_id); - } - - LLChat chat; - chat.mFromName = from; - chat.mFromID = from_id; - chat.mText = msg[IM_TEXT].asString(); - chat.mTimeStr = msg[IM_TIME].asString(); - chat.mChatStyle = CHAT_STYLE_HISTORY; - - if (im_type) chat.mChatType = CHAT_TYPE_IM; - - chat.mSourceType = CHAT_SOURCE_AGENT; - if (from_id.isNull() && SYSTEM_FROM == from) - { - chat.mSourceType = CHAT_SOURCE_SYSTEM; - - } - else if (from_id.isNull()) - { - chat.mSourceType = isWordsName(from) ? CHAT_SOURCE_UNKNOWN : CHAT_SOURCE_OBJECT; - } - - addMessage(chat, true, do_not_log); - - it++; - } -} - -//static -LLNearbyChat* LLNearbyChat::getInstance() -{ - return LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); -} - -bool LLNearbyChat::isChatMultiTab() -{ - // Restart is required in order to change chat window type. - static bool is_single_window = gSavedSettings.getS32("ChatWindow") == 1; - return is_single_window; -} - -void LLNearbyChat::setDocked(bool docked, bool pop_on_undock) -{ - if((!isChatMultiTab()) && gSavedSettings.getBOOL("ChatHistoryTornOff")) - { - mDragHandle->setTitleVisible(docked); // Show window title according to docking state - LLDockableFloater::setDocked(docked, pop_on_undock); - } -} - -// Show window title according to docking state -void LLNearbyChat::setTornOff(bool torn_off) -{ - mDragHandle->setTitleVisible(torn_off); - LLDockableFloater::setTornOff(torn_off); -} -// Show window title according to docking state - -BOOL LLNearbyChat::getVisible() -{ - if(isChatMultiTab()) - { - LLIMFloaterContainer* im_container = LLIMFloaterContainer::getInstance(); - - // Treat inactive floater as invisible. - bool is_active = im_container->getActiveFloater() == this; - - //torn off floater is always inactive - if (!is_active && getHost() != im_container) - { - return LLDockableFloater::getVisible(); - } - - // getVisible() returns TRUE when Tabbed IM window is minimized. - return is_active && !im_container->isMinimized() && im_container->getVisible(); - } - else - { - return LLDockableFloater::getVisible(); - } -} - -// This doesn't seem to apply anymore? It makes the chat and spin box colors -// appear wrong when focused and unfocused, so disable this. -Zi -#if 0 -//////////////////////////////////////////////////////////////////////////////// -// -void LLNearbyChat::onFocusReceived() -{ - setBackgroundOpaque(true); - LLPanel::onFocusReceived(); -} - -//////////////////////////////////////////////////////////////////////////////// -// -void LLNearbyChat::onFocusLost() -{ - setBackgroundOpaque(false); - LLPanel::onFocusLost(); -} - -BOOL LLNearbyChat::handleMouseDown(S32 x, S32 y, MASK mask) -{ - //fix for EXT-6625 - //highlight NearbyChat history whenever mouseclick happen in NearbyChat - //setting focus to eidtor will force onFocusLost() call that in its turn will change - //background opaque. This all happenn since NearByChat is "chrome" and didn't process focus change. - - if(mChatHistory) - mChatHistory->setFocus(TRUE); - return LLDockableFloater::handleMouseDown(x, y, mask); -} - -void LLNearbyChat::draw() -{ - // *HACK: Update transparency type depending on whether our children have focus. - // This is needed because this floater is chrome and thus cannot accept focus, so - // the transparency type setting code from LLFloater::setFocus() isn't reached. - if (getTransparencyType() != TT_DEFAULT) - { - setTransparencyType(hasFocus() ? TT_ACTIVE : TT_INACTIVE); - } - - LLDockableFloater::draw(); -} -#endif +*/ diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h index 2ba8c8c2ba..9dba386362 100644 --- a/indra/newview/llnearbychat.h +++ b/indra/newview/llnearbychat.h @@ -1,124 +1,5 @@ - /** - * @file llnearbychat.h - * @brief nearby chat history scrolling panel implementation - * - * $LicenseInfo:firstyear=2004&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_LLNEARBYCHAT_H_ -#define LL_LLNEARBYCHAT_H_ +This file is not used by Firestorm. It's being kept in place to track merges. -#include "lldockablefloater.h" -#include "llscrollbar.h" -#include "llviewerchat.h" - -class LLResizeBar; -class LLChatHistory; -class LLLineEditor; - -class LLNearbyChat: public LLDockableFloater -{ -public: - LLNearbyChat(const LLSD& key); - ~LLNearbyChat(); - - BOOL postBuild (); - - /** @param archive true - to save a message to the chat history log */ - void addMessage (const LLChat& message,bool archive = true, const LLSD &args = LLSD()); - void onNearbyChatContextMenuItemClicked(const LLSD& userdata); - bool onNearbyChatCheckContextMenuItem(const LLSD& userdata); - - void onChatBarVisibilityChanged(); - void onChatChannelVisibilityChanged(); - - // This doesn't seem to apply anymore? It makes the chat and spin box colors - // appear wrong when focused and unfocused, so disable this. -Zi -#if 0 - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - virtual void draw(); - - // focus overrides - /*virtual*/ void onFocusLost(); - /*virtual*/ void onFocusReceived(); -#endif - - /*virtual*/ void onOpen (const LLSD& key); - - /*virtual*/ void setVisible(BOOL visible); - void openFloater(const LLSD& key); - - virtual void setRect (const LLRect &rect); - - void clearChatHistory(); - virtual void updateChatHistoryStyle(); - - static void processChatHistoryStyleUpdate(const LLSD& newvalue); - - void loadHistory(); - - static LLNearbyChat* getInstance(); - - void removeScreenChat(); - - static bool isChatMultiTab(); - - void setDocked(bool docked, bool pop_on_undock = true); - /*virtual*/ void setTornOff(bool torn_off); // Needed to show window title according to docking state - - BOOL getVisible(); - void doSendMsg( std::string msg, EChatType type); - static void onSendMsg( LLUICtrl*, void*); - void sendMsg(); - - static void onHistoryButtonClicked(LLUICtrl* ctrl, void* userdata); - - // overridden to fix the multitab focus bug -Zi - BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); - - void updateFSUseNearbyChatConsole(const LLSD &data); - -private: - void getAllowedRect (LLRect& rect); - - void onNearbySpeakers (); - - void setTyping(bool typing); - static void onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata ); - static void onInputEditorFocusLost(LLFocusableElement* caller, void* userdata); - static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata); - static BOOL matchChatTypeTrigger(const std::string& in_str, std::string* out_str); - - virtual BOOL handleKeyHere( KEY key, MASK mask ); - -private: - LLHandle mPopupMenuHandle; - LLChatHistory* mChatHistory; - - std::vector mMessageArchive; - LLLineEditor* mInputEditor; - - BOOL FSUseNearbyChatConsole; - -}; - -#endif +*/ diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp index 861d9d5692..9dba386362 100644 --- a/indra/newview/llnearbychatbar.cpp +++ b/indra/newview/llnearbychatbar.cpp @@ -1,1264 +1,5 @@ -/** - * @file llnearbychatbar.cpp - * @brief LLNearbyChatBar 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" +This file is not used by Firestorm. It's being kept in place to track merges. -#include "message.h" - -#include "llappviewer.h" -#include "llfloaterreg.h" -#include "lltrans.h" - -#include "llfirstuse.h" -#include "llnearbychatbar.h" -#include "llagent.h" -#include "llgesturemgr.h" -#include "llmultigesture.h" -#include "llkeyboard.h" -#include "llanimationstates.h" -#include "llviewerstats.h" -#include "llcommandhandler.h" -#include "llviewercontrol.h" -#include "llnavigationbar.h" -#include "llwindow.h" -#include "llspinctrl.h" -#include "llnearbychat.h" -#include "llviewerwindow.h" -#include "llrootview.h" -#include "llviewerchat.h" -#include "llnearbychat.h" -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) -#include "llevents.h" -#include "llimfloater.h" -#include "llimfloatercontainer.h" -#include "llmultifloater.h" -#include "llnearbychatbarmulti.h" -#include "lltranslate.h" -// [/SL:KB] - -#include "llresizehandle.h" - -// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) -#include "rlvhandler.h" -// [/RLVa:KB] -#include "chatbar_as_cmdline.h" -#include "llviewerchat.h" - -//S32 LLNearbyChatBar::sLastSpecialChatChannel = 0; -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a -S32 LLNearbyChatBarBase::sLastSpecialChatChannel = 0; -// [/SL:KB] - -const S32 EXPANDED_HEIGHT = 300; -//const S32 COLLAPSED_HEIGHT = 60; -const S32 EXPANDED_MIN_HEIGHT = 150; -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-11-12 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -S32 COLLAPSED_HEIGHT = 60; -// [/SL:KB] - -// legacy callback glue -//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 -void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel); -// [/RLVa:KB] - -struct LLChatTypeTrigger { - std::string name; - EChatType type; -}; - -static LLChatTypeTrigger sChatTypeTriggers[] = { - { "/whisper" , CHAT_TYPE_WHISPER}, - { "/shout" , CHAT_TYPE_SHOUT} -}; - -// -LLNearbyChatBarBase::LLNearbyChatBarBase() -{ - FSPlayChatAnimation = gSavedSettings.getBOOL("FSPlayChatAnimation"); - gSavedSettings.getControl("FSPlayChatAnimation")->getSignal()->connect(boost::bind(&LLNearbyChatBarBase::updateFSPlayChatAnimation, this, _2)); -} -// - -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -LLNearbyChatBarSingle::LLNearbyChatBarSingle() - : LLPanel() - , mChatBox(NULL) - , mOutputMonitor(NULL) - , mSpeakerMgr(LLLocalSpeakerMgr::getInstance()) -{ -} -// [/SL:KB] - -LLNearbyChatBar::LLNearbyChatBar(const LLSD& key) -: LLFloater(key), -// mChatBox(NULL) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - mNearbyChatContainer(NULL), -// ## Zi: from old FS ## // mNearbyChat(NULL), - mChatBarImpl(NULL) -// [/SL:KB] -{ -// mSpeakerMgr = LLLocalSpeakerMgr::getInstance(); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Modified: Catznip-3.2.0a - mFactoryMap["panel_chat_bar_single"] = LLCallbackMap(createChatBarSingle, NULL); - mFactoryMap["panel_chat_bar_multi"] = LLCallbackMap(createChatBarMulti, NULL); -// [/SL:KB] -} - -//virtual -//BOOL LLNearbyChatBar::postBuild() -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -BOOL LLNearbyChatBarSingle::postBuild() -// [/SL:KB] -{ - mChatBox = getChild("chat_box"); - -// mChatBox->setCommitCallback(boost::bind(&LLNearbyChatBar::onChatBoxCommit, this)); -// mChatBox->setKeystrokeCallback(&onChatBoxKeystroke, this); -// mChatBox->setFocusLostCallback(boost::bind(&onChatBoxFocusLost, _1, this)); -// mChatBox->setFocusReceivedCallback(boost::bind(&LLNearbyChatBar::onChatBoxFocusReceived, this)); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Modified: Catznip-3.2.0a - mChatBox->setCommitCallback(boost::bind(&LLNearbyChatBarSingle::onChatBoxCommit, this)); - mChatBox->setKeystrokeCallback(boost::bind(&LLNearbyChatBarSingle::onChatBoxKeystroke, this), NULL); - mChatBox->setFocusLostCallback(boost::bind(&LLNearbyChatBarSingle::onChatBoxFocusLost, this)); - mChatBox->setFocusReceivedCallback(boost::bind(&LLNearbyChatBarSingle::onChatBoxFocusReceived, this)); -// [/SL:KB] - - mChatBox->setIgnoreArrowKeys( FALSE ); - mChatBox->setCommitOnFocusLost( FALSE ); - mChatBox->setRevertOnEsc( FALSE ); - mChatBox->setIgnoreTab(TRUE); - mChatBox->setPassDelete(TRUE); - mChatBox->setReplaceNewlinesWithSpaces(FALSE); - mChatBox->setEnableLineHistory(TRUE); - mChatBox->setFont(LLViewerChat::getChatFont()); - -// mNearbyChat = getChildView("nearby_chat"); -// LLUICtrl* show_btn = getChild("show_nearby_chat"); -// show_btn->setCommitCallback(boost::bind(&LLNearbyChatBar::onToggleNearbyChatPanel, this)); - - mOutputMonitor = getChild("chat_zone_indicator"); - mOutputMonitor->setVisible(FALSE); - - // Register for font change notifications -// LLViewerChat::setFontChangedCallback(boost::bind(&LLNearbyChatBar::onChatFontChange, this, _1)); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLViewerChat::setFontChangedCallback(boost::bind(&LLNearbyChatBarSingle::onChatFontChange, this, _1)); - - return TRUE; -} -// [/SL:KB] - -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -BOOL LLNearbyChatBar::postBuild() -{ - mNearbyChatContainer = findChild("panel_nearby_chat"); -// ## Zi: from old FS ## // mNearbyChat = findChild("nearby_chat"); - - mChatBarImpl = (hasChild("panel_chat_bar_multi", TRUE)) ? findChild("panel_chat_bar_multi", TRUE) : findChild("panel_chat_bar_single", TRUE); - - LLUICtrl* show_btn = getChild("show_nearby_chat"); - show_btn->setCommitCallback(boost::bind(&LLNearbyChatBar::onToggleNearbyChatPanel, this)); - - // The collpased height differs between single-line and multi-line so dynamically calculate it from the default sizes - COLLAPSED_HEIGHT = getRect().getHeight() - mNearbyChatContainer->getRect().getHeight(); -// [/SL:KB] - - mExpandedHeight = COLLAPSED_HEIGHT + EXPANDED_HEIGHT; - enableResizeCtrls(true, true, false); - -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Modified: Catznip-3.2.0a - // Initalize certain parameters depending on default vs embedded state - bool fTabbedNearbyChat = isTabbedNearbyChat(); -// setCanClose(!fTabbedNearbyChat); -// setCanMinimize(fTabbedNearbyChat); - setCanTearOff(fTabbedNearbyChat); - - if (fTabbedNearbyChat) - { - LLIMFloaterContainer* pConvFloater = LLIMFloaterContainer::getInstance(); - if (pConvFloater) - { - if (!mNearbyChatContainer->getVisible()) - onToggleNearbyChatPanel(); - pConvFloater->addFloater(this, TRUE, LLTabContainer::START); - - LLEventPump& pumpNearbyChat = LLEventPumps::instance().obtain("LLChat"); - pumpNearbyChat.listen("nearby_chat_bar", boost::bind(&LLNearbyChatBar::onNewNearbyChatMsg, this, _1)); - } - - onTearOff(LLSD(isTornOff())); - setTearOffCallback(boost::bind(&LLNearbyChatBar::onTearOff, this, _2)); - } -// [/SL:KB] - - gSavedSettings.declareBOOL("nearbychat_history_visibility", mNearbyChatContainer->getVisible(), "Visibility state of nearby chat history", TRUE); - mNearbyChatContainer->setVisible(gSavedSettings.getBOOL("nearbychat_history_visibility")); - - return TRUE; -} - -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-11-12 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -bool LLNearbyChatBar::onNewNearbyChatMsg(const LLSD& sdEvent) -{ - if ( (!isTornOff()) && (!isInVisibleChain()) ) - { - LLIMFloaterContainer* pConvFloater = LLIMFloaterContainer::getInstance(); - if (pConvFloater) - { - if (pConvFloater->isFloaterFlashing(this)) - pConvFloater->setFloaterFlashing(this, FALSE); - pConvFloater->setFloaterFlashing(this, TRUE); - } - } - return false; -} - -void LLNearbyChatBar::onTearOff(const LLSD& sdData) -{ - LLUICtrl* pTogglePanel = findChild("panel_nearby_chat_toggle"); - if (sdData.asBoolean()) // Tearing off - { - pTogglePanel->setVisible(TRUE); - } - else // Attaching - { - showHistory(); - pTogglePanel->setVisible(FALSE); - } - - // Don't allow closing the nearby chat floater while it's attached - setCanClose(sdData.asBoolean()); -} -// [/SL:KB] - -bool LLNearbyChatBar::applyRectControl() -{ -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - if (isTabbedNearbyChat()) - { - return true; - } -// [/SL:KB] - - bool rect_controlled = LLFloater::applyRectControl(); - -// LLView* nearby_chat = getChildView("nearby_chat"); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-11-12 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLView* nearby_chat = mNearbyChatContainer; -// [/SL:KB] - if (!nearby_chat->getVisible()) - { - reshape(getRect().getWidth(), getMinHeight()); - enableResizeCtrls(true, true, false); - } - else - { - enableResizeCtrls(true); - setResizeLimits(getMinWidth(), EXPANDED_MIN_HEIGHT); - } -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - mNearbyChatContainer->setVisible(mExpandedHeight > COLLAPSED_HEIGHT); -// [/SL:KB] - - return rect_controlled; -} - -//void LLNearbyChatBar::onChatFontChange(LLFontGL* fontp) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -void LLNearbyChatBarSingle::onChatFontChange(LLFontGL* fontp) -// [/SL:KB] -{ - // Update things with the new font whohoo - if (mChatBox) - { - mChatBox->setFont(fontp); - } -} - -//static -LLNearbyChatBar* LLNearbyChatBar::getInstance() -{ - return LLFloaterReg::getTypedInstance("chat_bar"); -} - -void LLNearbyChatBar::showHistory() -{ - openFloater(); - -// if (!getChildView("nearby_chat")->getVisible()) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-11-12 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - if (!mNearbyChatContainer->getVisible()) -// [/SL:KB] - { - onToggleNearbyChatPanel(); - } -} - -void LLNearbyChatBar::enableTranslationCheckbox(BOOL enable) -{ - getChild("translate_chat_checkbox")->setEnabled(enable); -} - -//void LLNearbyChatBar::draw() -//{ -// displaySpeakingIndicator(); -// LLFloater::draw(); -//} -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -void LLNearbyChatBarSingle::draw() -{ - displaySpeakingIndicator(); - LLPanel::draw(); -} -// [/SL:KB] - -//std::string LLNearbyChatBar::getCurrentChat() -//{ -// return mChatBox ? mChatBox->getText() : LLStringUtil::null; -//} - -// virtual -BOOL LLNearbyChatBar::handleKeyHere( KEY key, MASK mask ) -{ - BOOL handled = FALSE; - - if( KEY_RETURN == key ) - { - if (mask == MASK_CONTROL) - { - // shout -// sendChat(CHAT_TYPE_SHOUT); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Modified: Catznip-3.2.0a - mChatBarImpl->sendChat(CHAT_TYPE_SHOUT); -// [/SL:KB] - handled = TRUE; - } - else if (mask == MASK_SHIFT) - { - // whisper - mChatBarImpl->sendChat(CHAT_TYPE_WHISPER); - handled = TRUE; - } - else if (mask == MASK_ALT) - { - // OOC - mChatBarImpl->sendChat(CHAT_TYPE_OOC); - handled = TRUE; - } - else if (mask == MASK_NONE) - { - // say - mChatBarImpl->sendChat( CHAT_TYPE_NORMAL ); - handled = TRUE; - } - } - - return handled; -} - -//BOOL LLNearbyChatBar::matchChatTypeTrigger(const std::string& in_str, std::string* out_str) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a -BOOL LLNearbyChatBarBase::matchChatTypeTrigger(const std::string& in_str, std::string* out_str) -// [/SL:KB] -{ - U32 in_len = in_str.length(); - S32 cnt = sizeof(sChatTypeTriggers) / sizeof(*sChatTypeTriggers); - - for (S32 n = 0; n < cnt; n++) - { - if (in_len > sChatTypeTriggers[n].name.length()) - continue; - - std::string trigger_trunc = sChatTypeTriggers[n].name; - LLStringUtil::truncate(trigger_trunc, in_len); - - if (!LLStringUtil::compareInsensitive(in_str, trigger_trunc)) - { - *out_str = sChatTypeTriggers[n].name; - return TRUE; - } - } - - return FALSE; -} - -//void LLNearbyChatBar::onChatBoxKeystroke(LLLineEditor* caller, void* userdata) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -void LLNearbyChatBarBase::onChatBoxKeystroke() -// [/SL:KB] -{ - LLFirstUse::otherAvatarChatFirst(false); - -// LLNearbyChatBar* self = (LLNearbyChatBar *)userdata; -// -// LLWString raw_text = self->mChatBox->getWText(); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLLineEditor* pLineEditor = dynamic_cast(getChatBoxCtrl()); - LLTextEditor* pTextEditor = dynamic_cast(getChatBoxCtrl()); - - LLWString raw_text = (pLineEditor) ? pLineEditor->getWText() : pTextEditor->getWText(); -// [/SL:KB] - - // 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 - 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)) - { - std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size()); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - if (pLineEditor) - { - pLineEditor->setText(utf8_trigger + rest_of_match); - pLineEditor->setSelection(length, pLineEditor->getLength()); - } - else - { - pTextEditor->setText(utf8_trigger + rest_of_match); - pTextEditor->setSelection(length, pTextEditor->getLength()); - } -// [/SL:KB] -// self->mChatBox->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part -// S32 outlength = self->mChatBox->getLength(); // in characters -// -// // Select to end of line, starting from the character -// // after the last one the user typed. -// self->mChatBox->setSelection(length, outlength); - } - else if (matchChatTypeTrigger(utf8_trigger, &utf8_out_str)) - { - std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size()); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - if (pLineEditor) - { - pLineEditor->setText(utf8_trigger + rest_of_match + " "); - pLineEditor->setCursorToEnd(); - } - else - { - pTextEditor->setText(utf8_trigger + rest_of_match + " "); - pTextEditor->endOfDoc(); - } -// [/SL:KB] -// self->mChatBox->setText(utf8_trigger + rest_of_match + " "); // keep original capitalization for user-entered part -// self->mChatBox->setCursorToEnd(); - } - - //llinfos << "GESTUREDEBUG " << trigger - // << " len " << length - // << " outlen " << out_str.getLength() - // << llendl; - } -} - -// static -//void LLNearbyChatBar::onChatBoxFocusLost(LLFocusableElement* caller, void* userdata) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a -void LLNearbyChatBarBase::onChatBoxFocusLost() -// [/SL:KB] -{ - // stop typing animation - gAgent.stopTyping(); -} - -//void LLNearbyChatBar::onChatBoxFocusReceived() -//{ -// mChatBox->setEnabled(!gDisconnected); -//} -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a -void LLNearbyChatBarBase::onChatBoxFocusReceived() -{ - getChatBoxCtrl()->setEnabled(!gDisconnected); -} -// [/SL:KB] - -//EChatType LLNearbyChatBar::processChatTypeTriggers(EChatType type, std::string &str) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a -EChatType LLNearbyChatBarBase::processChatTypeTriggers(EChatType type, std::string &str) -// [/SL:KB] -{ - U32 length = str.length(); - S32 cnt = sizeof(sChatTypeTriggers) / sizeof(*sChatTypeTriggers); - - for (S32 n = 0; n < cnt; n++) - { - if (length >= sChatTypeTriggers[n].name.length()) - { - std::string trigger = str.substr(0, sChatTypeTriggers[n].name.length()); - - if (!LLStringUtil::compareInsensitive(trigger, sChatTypeTriggers[n].name)) - { - U32 trigger_length = sChatTypeTriggers[n].name.length(); - - // It's to remove space after trigger name - if (length > trigger_length && str[trigger_length] == ' ') - trigger_length++; - - str = str.substr(trigger_length, length); - - if (CHAT_TYPE_NORMAL == type) - return sChatTypeTriggers[n].type; - else - break; - } - } - } - - return type; -} - -void LLNearbyChatBarBase::updateFSPlayChatAnimation(const LLSD &data) -{ - FSPlayChatAnimation = data.asBoolean(); -} - -void LLNearbyChatBarBase::sendChat(EChatType type) -// [/SL:KB] -{ -// if (mChatBox) -// { -// LLWString text = mChatBox->getConvertedText(); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Modified: Catznip-3.2.0a - LLLineEditor* pLineEditor = dynamic_cast(getChatBoxCtrl()); - LLTextEditor* pTextEditor = dynamic_cast(getChatBoxCtrl()); - if ( (pLineEditor) || (pTextEditor) ) - { - LLWString text = getChatBoxText(); - LLWStringUtil::trim(text); -// [/SL:KB] - if (!text.empty()) - { - if(type == CHAT_TYPE_OOC) - { - std::string tempText = wstring_to_utf8str( text ); - tempText = gSavedSettings.getString("FSOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("FSOOCPostfix"); - text = utf8str_to_wstring(tempText); - setChatBoxText(LLStringExplicit(tempText)); - } - - // store sent line in history, duplicates will get filtered -// mChatBox->updateHistory(); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a - // The multi-line chat bar history is updated in LLNearbyChatBarMulti::onChatBoxCommit() - if (pLineEditor) - pLineEditor->updateHistory(); -// [/SL:KB] - // Check if this is destined for another channel - S32 channel = 0; - stripChannelNumber(text, &channel); - // If "/" is not specified, see if a channel has been set in - // the spinner. - if (gSavedSettings.getBOOL("FSNearbyChatbar") && - gSavedSettings.getBOOL("FSShowChatChannel") && - (channel == 0)) - { - channel = (S32)(LLNearbyChat::getInstance()->getChild("ChatChannel")->get()); - } - - 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 Satomi Ahn - Patch MU_OOC - 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 Satomi Ahn - Patch MU_OOC - // 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; - - type = processChatTypeTriggers(nType, utf8_revised_text); - - if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type)) - { - // Chat with animation - sendChatFromViewer(utf8_revised_text, type, FSPlayChatAnimation); - } - } - -// mChatBox->setText(LLStringExplicit("")); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a - setChatBoxText(LLStringExplicit("")); -// [/SL:KB] - } - - gAgent.stopTyping(); - - // If the user wants to stop chatting on hitting return, lose focus - // and go out of chat mode. - if (gSavedSettings.getBOOL("CloseChatOnReturn") || gSavedSettings.getBOOL("AutohideChatBar")) - { -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Modified: Catznip-3.2.0a - getChatBoxCtrl()->setFocus(FALSE); -// [/SL:KB] -// stopChat(); - } -} - - -void LLNearbyChatBar::onToggleNearbyChatPanel() -{ -// LLView* nearby_chat = getChildView("nearby_chat"); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLView* nearby_chat = mNearbyChatContainer; -// [/SL:KB] - - if (nearby_chat->getVisible()) - { - if (!isMinimized()) - { - mExpandedHeight = getRect().getHeight(); - } - setResizeLimits(getMinWidth(), COLLAPSED_HEIGHT); - nearby_chat->setVisible(FALSE); - reshape(getRect().getWidth(), COLLAPSED_HEIGHT); - enableResizeCtrls(true, true, false); - storeRectControl(); - } - else - { - nearby_chat->setVisible(TRUE); - setResizeLimits(getMinWidth(), EXPANDED_MIN_HEIGHT); - reshape(getRect().getWidth(), mExpandedHeight); - enableResizeCtrls(true); - storeRectControl(); - } - - gSavedSettings.setBOOL("nearbychat_history_visibility", mNearbyChatContainer->getVisible()); -} - -//void LLNearbyChatBar::setMinimized(BOOL b) -//{ -// LLNearbyChat* nearby_chat = getChild("nearby_chat"); -// // when unminimizing with nearby chat visible, go ahead and kill off screen chats -// if (!b && nearby_chat->getVisible()) -// { -// nearby_chat->removeScreenChat(); -// } -// LLFloater::setMinimized(b); -//} -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-11-17 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -BOOL LLNearbyChatBar::canClose() -{ - if (getHost()) - return false; - return LLFloater::canClose(); -} - -void LLNearbyChatBar::onOpen(const LLSD& sdKey) -{ - // When open the floater with nearby chat visible, go ahead and kill off screen chats - if (mNearbyChatContainer->getVisible()) - { -// ## Zi: from old FS ## // mNearbyChat->removeScreenChat(); - } - enableTranslationCheckbox(LLTranslate::isTranslationConfigured()); // Translation stuffs -} -// [/SL:KB] - -//void LLNearbyChatBar::onChatBoxCommit() -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -void LLNearbyChatBarSingle::onChatBoxCommit() -// [/SL:KB] -{ - if (mChatBox->getText().length() > 0) - { - sendChat(CHAT_TYPE_NORMAL); - } -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-12-02 (Catznip-3.2.0d) | Added: Catznip-3.2.0d - else if (gSavedSettings.getBOOL("CloseChatOnEmptyReturn")) - { - // Close if we're the child of a floater - LLFloater* pFloater = getParentByType(); - if (pFloater) - pFloater->closeFloater(); - } -// [/SL:KB] - - gAgent.stopTyping(); -} - -void LLNearbyChatBar::setText(const LLStringExplicit &new_text) -{ - mChatBarImpl->setChatBoxText(new_text); -} - -//void LLNearbyChatBar::displaySpeakingIndicator() -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -void LLNearbyChatBarSingle::displaySpeakingIndicator() -// [/SL:KB] -{ - LLSpeakerMgr::speaker_list_t speaker_list; - LLUUID id; - - id.setNull(); - mSpeakerMgr->update(TRUE); - mSpeakerMgr->getSpeakerList(&speaker_list, FALSE); - - for (LLSpeakerMgr::speaker_list_t::iterator i = speaker_list.begin(); i != speaker_list.end(); ++i) - { - LLPointer s = *i; - if (s->mSpeechVolume > 0 || s->mStatus == LLSpeaker::STATUS_SPEAKING) - { - id = s->mID; - break; - } - } - - if (!id.isNull()) - { - mOutputMonitor->setVisible(TRUE); - mOutputMonitor->setSpeakerId(id); - } - else - { - mOutputMonitor->setVisible(FALSE); - } -} - -//void LLNearbyChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a -void LLNearbyChatBarBase::sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate) -// [/SL:KB] -{ - sendChatFromViewer(utf8str_to_wstring(utf8text), type, animate); -} - -//void LLNearbyChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a -void LLNearbyChatBarBase::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) -// [/SL:KB] -{ - // Look for "/20 foo" channel chats. - S32 channel = 0; - LLWString out_text = stripChannelNumber(wtext, &channel); - // If "/" is not specified, see if a channel has been set in - // the spinner. - if (gSavedSettings.getBOOL("FSNearbyChatbar") && - gSavedSettings.getBOOL("FSShowChatChannel") && - (channel == 0)) - { - channel = (S32)(LLNearbyChat::getInstance()->getChild("ChatChannel")->get()); - } - 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) - { - 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); -} - -// static -//void LLNearbyChatBar::startChat(const char* line) -//{ -// LLNearbyChatBar* cb = LLNearbyChatBar::getInstance(); -// -// if (!cb ) -// return; -// -// cb->setVisible(TRUE); -// cb->setFocus(TRUE); -// cb->mChatBox->setFocus(TRUE); -// -// if (line) -// { -// std::string line_string(line); -// cb->mChatBox->setText(line_string); -// } -// -// cb->mChatBox->setCursorToEnd(); -//} -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -void LLNearbyChatBar::startChat(const char* line) -{ - LLNearbyChatBar* pSelf = getInstance(); - if (!pSelf) - return; - - pSelf->openFloater(LLSD()); - pSelf->setFocus(TRUE); - pSelf->mChatBarImpl->getChatBoxCtrl()->setFocus(TRUE); - - if (line) - { - LLStringExplicit line_string(line); - pSelf->mChatBarImpl->setChatBoxText(line_string); - } - - pSelf->mChatBarImpl->setChatBoxCursorToEnd(); -} -// [/SL:KB] - -// Exit "chat mode" and do the appropriate focus changes -// static -//void LLNearbyChatBar::stopChat() -//{ -// LLNearbyChatBar* cb = LLNearbyChatBar::getInstance(); -// -// if (!cb) -// return; -// -// cb->mChatBox->setFocus(FALSE); -// -// // stop typing animation -// gAgent.stopTyping(); -//} -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Modified: Catznip-3.2.0a -void LLNearbyChatBar::stopChat() -{ - LLNearbyChatBar* pSelf = getInstance(); - if (!pSelf) - return; - - // cb->setChatBarVisible(FALSE); ND_MERGE - pSelf->getChatBarImpl()->getChatBoxCtrl()->setFocus(FALSE); - - // stop typing animation - gAgent.stopTyping(); -} -// [/SL:KB] - -// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20. -// Otherwise returns input and channel 0. -//LLWString LLNearbyChatBar::stripChannelNumber(const LLWString &mesg, S32* channel) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) | Added: Catznip-2.8.0a -LLWString LLNearbyChatBarBase::stripChannelNumber(const LLWString &mesg, S32* channel) -// [/SL:KB] -{ - if (mesg[0] == '/' - && mesg[1] == '/') - { - // This is a "repeat channel send" - *channel = sLastSpecialChatChannel; - return mesg.substr(2, mesg.length() - 2); - } - else if (mesg[0] == '/' - && mesg[1] - && ( LLStringOps::isDigit(mesg[1]) - || (mesg[1] == '-' - && LLStringOps::isDigit(mesg[2])))) - { - // This a special "/20" speak on a channel - S32 pos = 0; - if(mesg[1] == '-') - pos++; - // 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++; - } - - sLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10); - if(mesg[1] == '-') - sLastSpecialChatChannel = -sLastSpecialChatChannel; - *channel = sLastSpecialChatChannel; - return mesg.substr(pos, mesg.length() - pos); - } - else - { - // This is normal chat. - *channel = 0; - return mesg; - } -} - -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Modified: Catznip-3.2.0a -void* LLNearbyChatBar::createChatBarSingle(void*) -{ - return new LLNearbyChatBarSingle(); -} - -void* LLNearbyChatBar::createChatBarMulti(void*) -{ - return new LLNearbyChatBarMulti(); -} - -const std::string& LLNearbyChatBar::getFloaterXMLFile() -{ - static std::string strFile; - switch (gSavedSettings.getS32("NearbyChatFloaterBarType")) - { - case 2: // Multi-line - strFile = "floater_chat_bar_multi.xml"; - break; - case 0: // None (default) - case 1: // Single-line - default: - strFile = "floater_chat_bar.xml"; - break; - } - return strFile; -} - -bool LLNearbyChatBar::isTabbedNearbyChat() -{ - return (LLIMFloater::isChatMultiTab()) && (gSavedSettings.getBOOL("NearbyChatFloaterWindow")); -} - -void LLNearbyChatBar::processFloaterTypeChanged() -{ -// // We only need to do anything if an instance of the nearby chat floater already exists -// LLNearbyChat* pNearbyChat = LLFloaterReg::findTypedInstance("nearby_chat", LLSD()); -// if (pNearbyChat) -// { -// bool fVisible = pNearbyChat->getVisible(); -// std::vector msgArchive = pNearbyChat->mMessageArchive; -// -// // NOTE: * LLFloater::closeFloater() won't call LLFloater::destroy() since the nearby chat floater is single instaced -// // * we can't call LLFloater::destroy() since it will call LLMortician::die() which defers destruction until a later time -// // => we'll have created a new instance and the delayed destructor calling LLFloaterReg::removeInstance() will make all future -// // LLFloaterReg::getTypedInstance() calls return NULL so we need to destruct manually [see LLFloaterReg::destroyInstance()] -// pNearbyChat->closeFloater(); -// LLFloaterReg::destroyInstance("nearby_chat", LLSD()); -// -// if ((pNearbyChat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD())) != NULL) -// { -// pNearbyChat->mMessageArchive = msgArchive; -// pNearbyChat->updateChatHistoryStyle(); -// if (fVisible) -// pNearbyChat->openFloater(LLSD()); -// } -// } -} -// [/SL:KB] - -//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 -void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel) -// [/RLVa:KB] -{ -// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a - // Only process chat messages (ie not CHAT_TYPE_START, CHAT_TYPE_STOP, etc) - if ( (rlv_handler_t::isEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) ) - { - if (0 == channel) - { - // (We already did this before, but LLChatHandler::handle() calls this directly) - 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; - - // Redirect chat if needed - if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE)) ) && - (gRlvHandler.redirectChatOrEmote(utf8_out_text)) ) ) - { - return; - } - - // Filter public chat if sendchat restricted - if (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) - gRlvHandler.filterChat(utf8_out_text, true); - } - else - { - // Don't allow chat on a non-public channel if sendchannel restricted (unless the channel is an exception) - if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNEL)) && (!gRlvHandler.isException(RLV_BHVR_SENDCHANNEL, channel)) ) - return; - - // Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers) - if (CHAT_CHANNEL_DEBUG == channel) - { - bool fIsEmote = RlvUtil::isEmote(utf8_out_text); - if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) || - ((!fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT))) || - ((fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE))) ) - { - return; - } - } - } - } -// [/RLVa:KB] - - LLMessageSystem* msg = gMessageSystem; - if(channel >= 0) - { - 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); - } - else - { - msg->newMessage("ScriptDialogReply"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - msg->nextBlock("Data"); - msg->addUUID("ObjectID", gAgent.getID()); - msg->addS32("ChatChannel", channel); - msg->addS32("ButtonIndex", 0); - msg->addString("ButtonLabel", utf8_out_text); - } - - gAgent.sendReliableMessage(); - - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); -} - -class LLChatCommandHandler : public LLCommandHandler -{ -public: - // not allowed from outside the app - LLChatCommandHandler() : 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; - // Send unescaped message, see EXT-6353. - std::string unescaped_mesg (LLURI::unescape(tokens[1].asString())); - send_chat_from_viewer(unescaped_mesg, CHAT_TYPE_NORMAL, channel); - } - else - { - retval = false; - // Tell us this is an unsupported SLurl. - } - } - return retval; - } -}; - -// Creating the object registers with the dispatcher. -LLChatCommandHandler gChatHandler; - -std::string LLNearbyChatBar::getCurrentChat() -{ - LLLineEditor* pLE(0); - if( mChatBarImpl ) - pLE = dynamic_cast< LLLineEditor* >( mChatBarImpl->getChatBoxCtrl() ); - - if( !pLE ) - return LLStringUtil::null; - - return pLE->getText(); -} +*/ diff --git a/indra/newview/llnearbychatbar.h b/indra/newview/llnearbychatbar.h index 7402bf496d..9dba386362 100644 --- a/indra/newview/llnearbychatbar.h +++ b/indra/newview/llnearbychatbar.h @@ -1,169 +1,5 @@ -/** - * @file llnearbychatbar.h - * @brief LLNearbyChatBar 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_LLNEARBYCHATBAR_H -#define LL_LLNEARBYCHATBAR_H +This file is not used by Firestorm. It's being kept in place to track merges. -#include "llfloater.h" -#include "llcombobox.h" -#include "llgesturemgr.h" -#include "llchat.h" -#include "llvoiceclient.h" -#include "lloutputmonitorctrl.h" -#include "llspeakers.h" -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-20 (Catznip-3.2.0a) -#include "llnearbychatbarbase.h" - -class LLNearbyChat; -// [/SL:KB] - -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -class LLNearbyChatBarSingle - : public LLPanel - , public LLNearbyChatBarBase -{ -public: - LLNearbyChatBarSingle(); - /*virtual*/ ~LLNearbyChatBarSingle() {} - -public: - /*virtual*/ void draw(); - /*virtual*/ BOOL postBuild(); -protected: - void displaySpeakingIndicator(); - void onChatBoxCommit(); - void onChatFontChange(LLFontGL* fontp); - - // LLNearbyChatBarBase overrides -public: - /*virtual*/ LLUICtrl* getChatBoxCtrl() { return mChatBox; } - /*virtual*/ LLWString getChatBoxText() { return mChatBox->getConvertedText(); } - /*virtual*/ void setChatBoxText(const LLStringExplicit& text) { mChatBox->setText(text); } - /*virtual*/ void setChatBoxCursorToEnd() { mChatBox->setCursorToEnd(); } - -protected: - LLLineEditor* mChatBox; - LLOutputMonitorCtrl* mOutputMonitor; - LLLocalSpeakerMgr* mSpeakerMgr; -}; -// [/SL:KB] - -class LLNearbyChatBar : public LLFloater -{ -public: - // constructor for inline chat-bars (e.g. hosted in chat history window) - LLNearbyChatBar(const LLSD& key); - ~LLNearbyChatBar() {} - - virtual BOOL postBuild(); - - static LLNearbyChatBar* getInstance(); - -// LLLineEditor* getChatBox() { return mChatBox; } -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLNearbyChatBarBase* getChatBarImpl() const { return mChatBarImpl; } -// [/SL:KB] - -// virtual void draw(); - - std::string getCurrentChat(); - 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); - - // , moved to public so we can relay from other textentries. - void onChatBoxFocusLost() - { mChatBarImpl->onChatBoxFocusLost(); } - void onChatBoxFocusReceived() - { mChatBarImpl->onChatBoxFocusReceived(); } - - void onChatBoxCommit(); - // - void setText(const LLStringExplicit &new_text); - - void showHistory(); - void enableTranslationCheckbox(BOOL enable); -// /*virtual*/void setMinimized(BOOL b); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-11-17 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - /*virtual*/ BOOL canClose(); - /*virtual*/ void onOpen(const LLSD& sdKey); -// [/SL:KB] - - void sendChat( EChatType type ) - { mChatBarImpl->sendChat( type ); } - -protected: -// static BOOL matchChatTypeTrigger(const std::string& in_str, std::string* out_str); -// static void onChatBoxKeystroke(LLLineEditor* caller, void* userdata); -// static void onChatBoxFocusLost(LLFocusableElement* caller, void* userdata); -// void onChatBoxFocusReceived(); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-11-12 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - bool onNewNearbyChatMsg(const LLSD& sdEvent); - void onTearOff(const LLSD& sdData); -// [/SL:KB] - - //void onChatBoxCommit(); // moved to public -// void onChatFontChange(LLFontGL* fontp); - - /* virtual */ bool applyRectControl(); - - void onToggleNearbyChatPanel(); - -// static LLWString stripChannelNumber(const LLWString &mesg, S32* channel); -// EChatType processChatTypeTriggers(EChatType type, std::string &str); - -// void displaySpeakingIndicator(); - -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -public: - static const std::string& getFloaterXMLFile(); - static bool isTabbedNearbyChat(); - static void processFloaterTypeChanged(); -protected: - static void* createChatBarSingle(void*); - static void* createChatBarMulti(void*); -// [/SL:KB] - -// // Which non-zero channel did we last chat on? -// static S32 sLastSpecialChatChannel; -// -// LLLineEditor* mChatBox; -// LLOutputMonitorCtrl* mOutputMonitor; -// LLLocalSpeakerMgr* mSpeakerMgr; -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLPanel* mNearbyChatContainer; // "panel_nearby_chat" is the parent panel containing "nearby_chat" - LLNearbyChat* mNearbyChat; // "nearby_chat" - LLNearbyChatBarBase* mChatBarImpl; -// [/SL:KB] - - S32 mExpandedHeight; -}; - -#endif +*/ diff --git a/indra/newview/llnearbychatbarbase.h b/indra/newview/llnearbychatbarbase.h index 1030c9b18d..9dba386362 100644 --- a/indra/newview/llnearbychatbarbase.h +++ b/indra/newview/llnearbychatbarbase.h @@ -1,67 +1,5 @@ -/** - * - * Copyright (c) 2011, Kitty Barnett - * - * The source code in this file is provided to you under the terms of the - * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt - * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt - * - * By copying, modifying or distributing this software, you acknowledge that - * you have read and understood your obligations described above, and agree to - * abide by those obligations. - * - */ -#ifndef LL_LLNEARBYCHATBARBASE_H -#define LL_LLNEARBYCHATBARBASE_H +/* -#include "llchat.h" -#include "lluictrl.h" +This file is not used by Firestorm. It's being kept in place to track merges. -class LLNearbyChatBarBase -{ -public: - LLNearbyChatBarBase(); - - static LLNearbyChatBarBase* findInstance(); - - static void sendChatFromViewer(const std::string &utf8text, EChatType type, BOOL animate); - static void sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate); - -public: - void sendChat(EChatType type); - - virtual LLUICtrl* getChatBoxCtrl() = 0; - virtual LLWString getChatBoxText() = 0; - virtual void setChatBoxText(const LLStringExplicit& text) = 0; - virtual void setChatBoxCursorToEnd() = 0; - - // moved from nearbychatbar - BOOL playChatAnimations() const - { return FSPlayChatAnimation; } - // - - //protected: // need this for nearbychatbar - void onChatBoxFocusLost(); - void onChatBoxFocusReceived(); - -protected: - void onChatBoxKeystroke(); - - static BOOL matchChatTypeTrigger(const std::string& in_str, std::string* out_str); - static EChatType processChatTypeTriggers(EChatType type, std::string &str); - static LLWString stripChannelNumber(const LLWString &mesg, S32* channel); - -protected: - // Which non-zero channel did we last chat on? - static S32 sLastSpecialChatChannel; - -private: - // moved from nearbychatbar - void updateFSPlayChatAnimation(const LLSD &data); - BOOL FSPlayChatAnimation; - // -}; - -#endif // LL_LLNEARBYCHATBARBASE_H +*/ diff --git a/indra/newview/llnearbychatbarlistener.cpp b/indra/newview/llnearbychatbarlistener.cpp index 7271962197..892a0b7e3c 100644 --- a/indra/newview/llnearbychatbarlistener.cpp +++ b/indra/newview/llnearbychatbarlistener.cpp @@ -29,22 +29,24 @@ #include "llviewerprecompiledheaders.h" #include "llnearbychatbarlistener.h" -#include "llnearbychatbar.h" +// Remove floating chat bar +// #include "llnearbychatbar.h" +#include "llnearbychathub.h" +// #include "llagent.h" #include "llchat.h" - -//LLNearbyChatBarListener::LLNearbyChatBarListener(LLNearbyChatBar & chatbar) +// Remove floating chat bar +// LLNearbyChatBarListener::LLNearbyChatBarListener(LLNearbyChatBar & chatbar) // : LLEventAPI("LLChatBar", // "LLChatBar listener to (e.g.) sendChat, etc."), // mChatbar(chatbar) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a -LLNearbyChatBarListener::LLNearbyChatBarListener(LLNearbyChatBar& chatbar) +LLNearbyChatBarListener::LLNearbyChatBarListener() : LLEventAPI("LLChatBar", "LLChatBar listener to (e.g.) sendChat, etc.") -// [/SL:KB] +// { add("sendChat", "Send chat to the simulator:\n" @@ -100,9 +102,9 @@ void LLNearbyChatBarListener::sendChat(LLSD const & chat_data) const } // Send it as if it was typed in -// mChatbar.sendChatFromViewer(chat_to_send, type_o_chat, (BOOL)(channel == 0)); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLNearbyChatBarBase::sendChatFromViewer(chat_to_send, type_o_chat, (BOOL)(channel == 0)); -// [/SL:KB] + // Remove floating chat bar + // mChatbar.sendChatFromViewer(chat_to_send, type_o_chat, (BOOL)(channel == 0)); + LLNearbyChat::getInstance()->sendChatFromViewer(chat_to_send, type_o_chat, (BOOL)(channel == 0)); + // } diff --git a/indra/newview/llnearbychatbarlistener.h b/indra/newview/llnearbychatbarlistener.h index 2fd0649a8b..7e61f0298a 100644 --- a/indra/newview/llnearbychatbarlistener.h +++ b/indra/newview/llnearbychatbarlistener.h @@ -33,12 +33,15 @@ #include "lleventapi.h" class LLSD; -class LLNearbyChatBar; +// class LLNearbyChatBar; // Remove floating chat bar class LLNearbyChatBarListener : public LLEventAPI { public: - LLNearbyChatBarListener(LLNearbyChatBar & chatbar); + // Remove floating chat bar + // LLNearbyChatBarListener(LLNearbyChatBar & chatbar); + LLNearbyChatBarListener(); + // private: void sendChat(LLSD const & chat_data) const; diff --git a/indra/newview/llnearbychatbarmulti.cpp b/indra/newview/llnearbychatbarmulti.cpp index 687c74730e..9dba386362 100644 --- a/indra/newview/llnearbychatbarmulti.cpp +++ b/indra/newview/llnearbychatbarmulti.cpp @@ -1,152 +1,5 @@ -/** - * - * Copyright (c) 2011, Kitty Barnett - * - * The source code in this file is provided to you under the terms of the - * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt - * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt - * - * By copying, modifying or distributing this software, you acknowledge that - * you have read and understood your obligations described above, and agree to - * abide by those obligations. - * - */ -#include "llviewerprecompiledheaders.h" +/* -#include "llagent.h" -#include "llfirstuse.h" -#include "llfloater.h" -#include "llgesturemgr.h" -#include "llkeyboard.h" -#include "llnearbychatbarmulti.h" -#include "llviewercontrol.h" +This file is not used by Firestorm. It's being kept in place to track merges. -LLNearbyChatBarMulti::LLNearbyChatBarMulti() -{ - // Initialize current history line iterator - mCurrentHistoryLine = mLineHistory.begin(); -} - -BOOL LLNearbyChatBarMulti::postBuild() -{ - m_pChatEditor = findChild("chat_editor"); - - m_pChatEditor->setCommitCallback(boost::bind(&LLNearbyChatBarMulti::onChatBoxCommit, this, CHAT_TYPE_NORMAL)); - m_pChatEditor->setKeystrokeCallback(boost::bind(&LLNearbyChatBarMulti::onChatBoxKeystroke, this)); - m_pChatEditor->setFocusLostCallback(boost::bind(&LLNearbyChatBarMulti::onChatBoxFocusLost, this)); - m_pChatEditor->setFocusReceivedCallback(boost::bind(&LLNearbyChatBarMulti::onChatBoxFocusReceived, this)); - - m_pChatEditor->setCommitOnFocusLost(FALSE); - - return TRUE; -} - -// virtual -BOOL LLNearbyChatBarMulti::handleKeyHere(KEY key, MASK mask) -{ - BOOL handled = FALSE; - if (KEY_RETURN == key) - { - if (MASK_CONTROL == mask) - { - onChatBoxCommit(CHAT_TYPE_SHOUT); - handled = TRUE; - } - else if (MASK_SHIFT == mask) - { - onChatBoxCommit(CHAT_TYPE_WHISPER); - handled = TRUE; - } - } - else if ( (KEY_UP == key) && (MASK_CONTROL == mask) ) - { - if (mCurrentHistoryLine > mLineHistory.begin()) - { - m_pChatEditor->setText(*(--mCurrentHistoryLine)); - m_pChatEditor->endOfDoc(); - } - else - { - LLUI::reportBadKeystroke(); - } - handled = TRUE; - } - else if ( (KEY_DOWN == key) && (MASK_CONTROL == mask) ) - { - if ( (!mLineHistory.empty()) && (mCurrentHistoryLine < mLineHistory.end() - 1) ) - { - m_pChatEditor->setText(*(++mCurrentHistoryLine)); - m_pChatEditor->endOfDoc(); - } - else - { - LLUI::reportBadKeystroke(); - } - handled = TRUE; - } - return handled; -} - -void LLNearbyChatBarMulti::onChatBoxCommit(EChatType eChatType) -{ - if (m_pChatEditor->getLength() > 0) - { - if (!mLineHistory.empty()) - { - // When not empty, last line of history should always be blank. - if (mLineHistory.back().empty()) - { - // discard the empty line - mLineHistory.pop_back(); - } - else - { - LL_WARNS("") << "Last line of history was not blank." << LL_ENDL; - } - } - - // Add text to history, ignoring duplicates - if ( (mLineHistory.empty()) || (m_pChatEditor->getText() != mLineHistory.back()) ) - { - mLineHistory.push_back(m_pChatEditor->getText()); - } - - // Restore the blank line and set mCurrentHistoryLine to point at it - mLineHistory.push_back(""); - mCurrentHistoryLine = mLineHistory.end() - 1; - - // Send the chat - LLNearbyChatBarBase::sendChat(eChatType); - } - else if (gSavedSettings.getBOOL("CloseChatOnEmptyReturn")) - { - // Close if we're the child of a floater - LLFloater* pFloater = getParentByType(); - if (pFloater) - pFloater->closeFloater(); - } - - gAgent.stopTyping(); -} - -LLWString LLNearbyChatBarMulti::getChatBoxText() -{ - return m_pChatEditor->getWText(); -} - -void LLNearbyChatBarMulti::setChatBoxText(const LLStringExplicit& text) -{ - m_pChatEditor->setText(text); - - // Set current history line to end of history. - if (mLineHistory.empty()) - { - mCurrentHistoryLine = mLineHistory.end(); - } - else - { - mCurrentHistoryLine = mLineHistory.end() - 1; - } -} +*/ diff --git a/indra/newview/llnearbychatbarmulti.h b/indra/newview/llnearbychatbarmulti.h index fea7276915..9dba386362 100644 --- a/indra/newview/llnearbychatbarmulti.h +++ b/indra/newview/llnearbychatbarmulti.h @@ -1,55 +1,5 @@ -/** - * - * Copyright (c) 2011, Kitty Barnett - * - * The source code in this file is provided to you under the terms of the - * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt - * in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt - * - * By copying, modifying or distributing this software, you acknowledge that - * you have read and understood your obligations described above, and agree to - * abide by those obligations. - * - */ -#ifndef LL_LLNEARBYCHATBARMULTI_H -#define LL_LLNEARBYCHATBARMULTI_H +/* -#include "lllayoutstack.h" -#include "llnearbychatbarbase.h" -#include "lltexteditor.h" +This file is not used by Firestorm. It's being kept in place to track merges. -class LLNearbyChatBarMulti - : public LLPanel - , public LLNearbyChatBarBase -{ -public: - LLNearbyChatBarMulti(); - /*virtual*/ ~LLNearbyChatBarMulti() {} - - virtual BOOL postBuild(); - - /*virtual*/ LLUICtrl* getChatBoxCtrl() { return m_pChatEditor; } - /*virtual*/ LLWString getChatBoxText(); - /*virtual*/ void setChatBoxText(const LLStringExplicit& text); - /*virtual*/ void setChatBoxCursorToEnd() { m_pChatEditor->endOfDoc(); } -protected: - void onChatBoxCommit(EChatType eChatType); - - /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); - - /* - * Member variables - */ -protected: - // Controls - LLTextEditor* m_pChatEditor; - - // Line history support - typedef std::vector line_history_t; - line_history_t mLineHistory; - line_history_t::iterator mCurrentHistoryLine; -}; - -#endif // LL_LLNEARBYCHATBARMULTI_H +*/ diff --git a/indra/newview/llnearbychatcontrol.cpp b/indra/newview/llnearbychatcontrol.cpp new file mode 100644 index 0000000000..7496bce5ed --- /dev/null +++ b/indra/newview/llnearbychatcontrol.cpp @@ -0,0 +1,234 @@ +/** + * @file llnearbychatcontrol.cpp + * @brief Nearby chat input control implementation + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2012, Zi Ree @ Second Life + * + * 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 "llnearbychatcontrol.h" +#include "llnearbychathub.h" +#include "llfloaternearbychat.h" +// #include "llviewercontrol.h" +// #include "llviewerwindow.h" +// #include "llrootview.h" +//#include "llchatitemscontainerctrl.h" +// #include "lliconctrl.h" +#include "llspinctrl.h" +// #include "llfloatersidepanelcontainer.h" +// #include "llfocusmgr.h" +// #include "lllogchat.h" +// #include "llresizebar.h" +// #include "llresizehandle.h" +#include "llmenugl.h" +#include "llviewermenu.h"//for gMenuHolder + +// #include "llnearbychathandler.h" +// #include "llnearbychatbar.h" // Remove floating chat bar +// #include "llchannelmanager.h" + +#include "llagent.h" // gAgent +// #include "llchathistory.h" +// #include "llstylemap.h" + +// #include "llavatarnamecache.h" + +// #include "lldraghandle.h" + +// #include "llnearbychatbar.h" // Remove floating chat bar +// #include "llfloaterreg.h" +// #include "lltrans.h" + +// IM +// #include "llbutton.h" +// #include "lllayoutstack.h" + +// #include "llimfloatercontainer.h" +// #include "llimfloater.h" +#include "lllineeditor.h" + +//AO - includes for textentry +#include "rlvhandler.h" +#include "llcommandhandler.h" +#include "llkeyboard.h" +#include "llgesturemgr.h" +#include "llmultigesture.h" + +// #include "llconsole.h" +// #include "fscontactsfloater.h" + +// Moved nearby chat functionality here for now +// #include "chatbar_as_cmdline.h" +// #include "llanimationstates.h" // ANIM_AGENT_WHISPER, ANIM_AGENT_TALK, ANIM_AGENT_SHOUT +// #include "llviewerstats.h" +// + +static LLDefaultChildRegistry::Register r("nearby_chat_control"); + +struct LLChatTypeTrigger { + std::string name; + EChatType type; +}; + +static LLChatTypeTrigger sChatTypeTriggers[] = { + { "/whisper" , CHAT_TYPE_WHISPER}, + { "/shout" , CHAT_TYPE_SHOUT} +}; + +LLNearbyChatControl::LLNearbyChatControl(const LLNearbyChatControl::Params& p) : + LLLineEditor(p) +{ + setKeystrokeCallback(onKeystroke,this); + LLNearbyChat::getInstance()->registerChatBar(this); + + setEnableLineHistory(TRUE); + setIgnoreArrowKeys( FALSE ); + setCommitOnFocusLost( FALSE ); + setRevertOnEsc( FALSE ); + setIgnoreTab( TRUE ); + setReplaceNewlinesWithSpaces( FALSE ); + setPassDelete( TRUE ); +} + +LLNearbyChatControl::~LLNearbyChatControl() +{ +} + +void LLNearbyChatControl::onCommit() +{ + LLNearbyChat::getInstance()->sendChat(getConvertedText(),CHAT_TYPE_NORMAL); + setText(LLStringExplicit("")); + + if(gSavedSettings.getBOOL("CloseChatOnReturn")) + { + setFocus(FALSE); + } + + if(gSavedSettings.getBOOL("AutohideChatBar") && getName()=="default_chat_bar") + { + setVisible(FALSE); + getParent()->setVisible(FALSE); + } + + LLUICtrl::onCommit(); +} + +void LLNearbyChatControl::onKeystroke(LLLineEditor* caller,void* userdata) +{ + LLWString raw_text = caller->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)(LLFloaterNearbyChat::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 + 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(); + } + + 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)) + { + std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size()); + caller->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part + S32 outlength = caller->getLength(); // in characters + + // Select to end of line, starting from the character + // after the last one the user typed. + caller->setSelection(length, outlength); + } + else if (matchChatTypeTrigger(utf8_trigger, &utf8_out_str)) + { + std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size()); + caller->setText(utf8_trigger + rest_of_match + " "); // keep original capitalization for user-entered part + caller->setCursorToEnd(); + } + } +} + +BOOL LLNearbyChatControl::matchChatTypeTrigger(const std::string& in_str, std::string* out_str) +{ + U32 in_len = in_str.length(); + S32 cnt = sizeof(sChatTypeTriggers) / sizeof(*sChatTypeTriggers); + + for (S32 n = 0; n < cnt; n++) + { + if (in_len > sChatTypeTriggers[n].name.length()) + continue; + + std::string trigger_trunc = sChatTypeTriggers[n].name; + LLStringUtil::truncate(trigger_trunc, in_len); + + if (!LLStringUtil::compareInsensitive(in_str, trigger_trunc)) + { + *out_str = sChatTypeTriggers[n].name; + return TRUE; + } + } + + return FALSE; +} + +// send our focus status to the LLNearbyChat hub +void LLNearbyChatControl::setFocus(BOOL focus) +{ + LLNearbyChat::instance().setFocusedInputEditor(this,focus); + LLLineEditor::setFocus(focus); +} diff --git a/indra/newview/llnearbychatcontrol.h b/indra/newview/llnearbychatcontrol.h new file mode 100644 index 0000000000..ccd7428b41 --- /dev/null +++ b/indra/newview/llnearbychatcontrol.h @@ -0,0 +1,53 @@ + /** + * @file llnearbychatcontrol.h + * @brief Nearby chat input control implementation + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2012, Zi Ree @ Second Life + * + * 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_LLNEARBYCHATCONTROL_H +#define LL_LLNEARBYCHATCONTROL_H + +#include "lllineeditor.h" + +class LLNearbyChatControl : public LLLineEditor +{ +public: + struct Params : public LLInitParam::Block {}; + + LLNearbyChatControl(const Params& p); + ~LLNearbyChatControl(); + + virtual void setFocus(BOOL focus); + + static BOOL matchChatTypeTrigger(const std::string& in_str, std::string* out_str); + +private: + // Typing in progress, expand gestures etc. + static void onKeystroke(LLLineEditor* caller,void* userdata); + + // Chat data entered to be sent to nearby chat + void onCommit(); +}; + +#endif diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 038e203f48..952574c3f2 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -34,14 +34,17 @@ #include "llfirstuse.h" #include "llfloaterscriptdebug.h" #include "llhints.h" -#include "llnearbychat.h" +// #include "llnearbychat.h" // Remove floating chat bar #include "llrecentpeople.h" #include "llviewercontrol.h" #include "llfloaterreg.h"//for LLFloaterReg::getTypedInstance #include "llviewerwindow.h"//for screen channel position -#include "llnearbychatbar.h" +// Remove floating chat bar +// #include "llnearbychatbar.h" +#include "llfloaternearbychat.h" +// #include "llrootview.h" #include "lllayoutstack.h" @@ -555,7 +558,7 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, // ## Zi - Post merge fixup ## // LLFloater* chat_bar = LLFloaterReg::getInstance("chat_bar"); // ## Zi - Post merge fixup ## // LLNearbyChat* nearby_chat = chat_bar->findChild("nearby_chat"); - LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); // ## Zi - Post merge fixup ## + LLFloaterNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); // ## Zi - Post merge fixup ## // Build notification data LLSD notification; @@ -823,7 +826,7 @@ void LLNearbyChatHandler::onAvatarNameLookup(const LLUUID& agent_id, const LLAva LLColor4 chatcolor; LLViewerChat::getChatColor(chat_msg, chatcolor); gConsole->addConsoleLine(consoleChat, chatcolor); - LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); + LLFloaterNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); if( nearby_chat ) gConsole->setVisible(!nearby_chat->getVisible()); } diff --git a/indra/newview/llnearbychathub.cpp b/indra/newview/llnearbychathub.cpp new file mode 100644 index 0000000000..021edef03f --- /dev/null +++ b/indra/newview/llnearbychathub.cpp @@ -0,0 +1,479 @@ +/** + * @file llnearbychat.cpp + * @brief @brief Nearby chat central class for handling multiple chat input controls + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2012, Zi Ree @ Second Life + * + * 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 "llnearbychathub.h" +#include "llnearbychatcontrol.h" +#include "llfloaternearbychat.h" + +#include "llviewercontrol.h" +#include "llviewerwindow.h" +#include "llrootview.h" +#include "llspinctrl.h" +#include "llfocusmgr.h" +#include "lllogchat.h" +#include "llmenugl.h" +#include "llviewermenu.h"//for gMenuHolder + +#include "llnearbychathandler.h" +#include "llchannelmanager.h" + +#include "llagent.h" // gAgent + +//AO - includes for textentry +#include "rlvhandler.h" +#include "llcommandhandler.h" +#include "llkeyboard.h" +#include "llgesturemgr.h" +#include "llmultigesture.h" + +#include "llconsole.h" + +// Moved nearby chat functionality here +#include "chatbar_as_cmdline.h" +#include "llanimationstates.h" // ANIM_AGENT_WHISPER, ANIM_AGENT_TALK, ANIM_AGENT_SHOUT +#include "llviewerstats.h" +// + +struct LLChatTypeTrigger { + std::string name; + EChatType type; +}; + +static LLChatTypeTrigger sChatTypeTriggers[] = { + { "/whisper" , CHAT_TYPE_WHISPER}, + { "/shout" , CHAT_TYPE_SHOUT} +}; + +S32 LLNearbyChat::sLastSpecialChatChannel = 0; + +LLNearbyChat::LLNearbyChat() : + mDefaultChatBar(NULL), + mFocusedInputEditor(NULL) +{ +} + +LLNearbyChat::~LLNearbyChat() +{ +} + +//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 +void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel) +// [/RLVa:KB] +{ +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a + // Only process chat messages (ie not CHAT_TYPE_START, CHAT_TYPE_STOP, etc) + if ( (rlv_handler_t::isEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) ) + { + if (0 == channel) + { + // (We already did this before, but LLChatHandler::handle() calls this directly) + 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; + + // Redirect chat if needed + if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE)) ) && + (gRlvHandler.redirectChatOrEmote(utf8_out_text)) ) ) + { + return; + } + + // Filter public chat if sendchat restricted + if (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) + gRlvHandler.filterChat(utf8_out_text, true); + } + else + { + // Don't allow chat on a non-public channel if sendchannel restricted (unless the channel is an exception) + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNEL)) && (!gRlvHandler.isException(RLV_BHVR_SENDCHANNEL, channel)) ) + return; + + // Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers) + if (CHAT_CHANNEL_DEBUG == channel) + { + bool fIsEmote = RlvUtil::isEmote(utf8_out_text); + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) || + ((!fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT))) || + ((fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE))) ) + { + return; + } + } + } + } +// [/RLVa:KB] + + LLMessageSystem* msg = gMessageSystem; + if(channel >= 0) + { + 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); + } + else + { + msg->newMessage("ScriptDialogReply"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID()); + msg->addUUID("SessionID", gAgent.getSessionID()); + msg->nextBlock("Data"); + msg->addUUID("ObjectID", gAgent.getID()); + msg->addS32("ChatChannel", channel); + msg->addS32("ButtonIndex", 0); + msg->addString("ButtonLabel", utf8_out_text); + } + + gAgent.sendReliableMessage(); + + LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); +} + +void LLNearbyChat::sendChatFromViewer(const std::string& utf8text, EChatType type, BOOL animate) +{ + sendChatFromViewer(utf8str_to_wstring(utf8text), type, animate); +} + +void LLNearbyChat::sendChatFromViewer(const LLWString& wtext, EChatType type, BOOL animate) +{ + // Look for "/20 foo" channel chats. + S32 channel = 0; + LLWString out_text = stripChannelNumber(wtext, &channel); + // If "/" is not specified, see if a channel has been set in + // the spinner. + if (gSavedSettings.getBOOL("FSNearbyChatbar") && + gSavedSettings.getBOOL("FSShowChatChannel") && + (channel == 0)) + { + channel = (S32)(LLFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); + } + 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) + { + 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); +} + +EChatType LLNearbyChat::processChatTypeTriggers(EChatType type, std::string &str) +{ + U32 length = str.length(); + S32 cnt = sizeof(sChatTypeTriggers) / sizeof(*sChatTypeTriggers); + + for (S32 n = 0; n < cnt; n++) + { + if (length >= sChatTypeTriggers[n].name.length()) + { + std::string trigger = str.substr(0, sChatTypeTriggers[n].name.length()); + + if (!LLStringUtil::compareInsensitive(trigger, sChatTypeTriggers[n].name)) + { + U32 trigger_length = sChatTypeTriggers[n].name.length(); + + // It's to remove space after trigger name + if (length > trigger_length && str[trigger_length] == ' ') + trigger_length++; + + str = str.substr(trigger_length, length); + + if (CHAT_TYPE_NORMAL == type) + return sChatTypeTriggers[n].type; + else + break; + } + } + } + + return type; +} + +// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20. +// Otherwise returns input and channel 0. +LLWString LLNearbyChat::stripChannelNumber(const LLWString &mesg, S32* channel) +{ + if (mesg[0] == '/' + && mesg[1] == '/') + { + // This is a "repeat channel send" + *channel = sLastSpecialChatChannel; + return mesg.substr(2, mesg.length() - 2); + } + else if (mesg[0] == '/' + && mesg[1] + && ( LLStringOps::isDigit(mesg[1]) + || (mesg[1] == '-' + && LLStringOps::isDigit(mesg[2])))) + { + // This a special "/20" speak on a channel + S32 pos = 0; + if(mesg[1] == '-') + pos++; + // 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++; + } + + sLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10); + if(mesg[1] == '-') + sLastSpecialChatChannel = -sLastSpecialChatChannel; + *channel = sLastSpecialChatChannel; + return mesg.substr(pos, mesg.length() - pos); + } + else + { + // This is normal chat. + *channel = 0; + return mesg; + } +} + +void LLNearbyChat::sendChat(LLWString text,EChatType type) +{ + LLWStringUtil::trim(text); + + if (!text.empty()) + { + if(type == CHAT_TYPE_OOC) + { + std::string tempText = wstring_to_utf8str( text ); + tempText = gSavedSettings.getString("FSOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("FSOOCPostfix"); + text = utf8str_to_wstring(tempText); + } + + // Check if this is destined for another channel + S32 channel = 0; + stripChannelNumber(text, &channel); + // If "/" is not specified, see if a channel has been set in + // the spinner. + if (gSavedSettings.getBOOL("FSNearbyChatbar") && + gSavedSettings.getBOOL("FSShowChatChannel") && + (channel == 0)) + { + channel = (S32)(LLFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); + } + + 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 Satomi Ahn - Patch MU_OOC + 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 Satomi Ahn - Patch MU_OOC + // 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; + + type = processChatTypeTriggers(nType, utf8_revised_text); + + if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type)) + { + // Chat with animation + sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("FSPlayChatAnimation")); + } + } + + gAgent.stopTyping(); +} + +// all chat bars call this function and we keep the first or one that's seen as the default +void LLNearbyChat::registerChatBar(LLNearbyChatControl* chatBar) +{ + // TODO: make this a Param option "is_default" + if(!mDefaultChatBar || chatBar->getName()=="default_chat_bar") + { + mDefaultChatBar=chatBar; + } +} + +// unhide the default nearby chat bar on request (pressing Enter or a letter key) +void LLNearbyChat::showDefaultChatBar(BOOL visible) const +{ + if(!mDefaultChatBar) + return; + + mDefaultChatBar->getParent()->setVisible(visible); + mDefaultChatBar->setVisible(visible); + mDefaultChatBar->setFocus(visible); +} + +// We want to know which nearby chat editor (if any) currently has focus +void LLNearbyChat::setFocusedInputEditor(LLNearbyChatControl* inputEditor,BOOL focus) +{ + if(focus) + mFocusedInputEditor=inputEditor; + + // only remove focus if the request came from the previously active input editor + // to avoid races + else if(mFocusedInputEditor==inputEditor) + mFocusedInputEditor=NULL; +} + +// for the "arrow key moves avatar when chat is empty" hack in llviewerwindow.cpp +BOOL LLNearbyChat::chatIsEmpty() const +{ + if(mFocusedInputEditor) + return mFocusedInputEditor->getText().empty(); + + return TRUE; +} diff --git a/indra/newview/llnearbychathub.h b/indra/newview/llnearbychathub.h new file mode 100644 index 0000000000..54f5f6a63e --- /dev/null +++ b/indra/newview/llnearbychathub.h @@ -0,0 +1,66 @@ + /** + * @file llnearbychat.h + * @brief Nearby chat central class for handling multiple chat input controls + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2012, Zi Ree @ Second Life + * + * 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_LLNEARBYCHAT_H +#define LL_LLNEARBYCHAT_H + +#include "llsingleton.h" +#include "llviewerchat.h" + +class LLNearbyChatControl; + +class LLNearbyChat : public LLSingleton +{ + friend class LLSingleton; + +private: + LLNearbyChat(); + ~LLNearbyChat(); + + void sendMsg(); + + static S32 sLastSpecialChatChannel; + LLNearbyChatControl* mDefaultChatBar; + +public: + void registerChatBar(LLNearbyChatControl* chatBar); + void showDefaultChatBar(BOOL visible) const; + + void sendChat(LLWString text,EChatType type); + LLWString stripChannelNumber(const LLWString &mesg, S32* channel); + 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); + + void setFocusedInputEditor(LLNearbyChatControl* inputEditor,BOOL focus); + + BOOL chatIsEmpty() const; + + LLNearbyChatControl* mFocusedInputEditor; +}; + +#endif diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 1fdff826f7..a2e0d359f7 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -36,7 +36,10 @@ #include "llagent.h" #include "llimfloater.h" #include "llimview.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "llnotificationhandler.h" #include "llnotifications.h" // [SL:KB] - Patch: Chat-Logs | Checked: 2010-11-18 (Catznip-2.4.0c) | Added: Catznip-2.4.0c @@ -464,7 +467,7 @@ void LLHandlerUtil::logGroupNoticeToIMGroup( // static void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChatSourceType type) { - LLNearbyChat* nearby_chat = LLNearbyChat::getInstance(); + LLFloaterNearbyChat* nearby_chat = LLFloaterNearbyChat::getInstance(); if(nearby_chat) { LLChat chat_msg(notification->getMessage()); diff --git a/indra/newview/llnotificationtiphandler.cpp b/indra/newview/llnotificationtiphandler.cpp index d98f6c1eaa..0ed368443e 100644 --- a/indra/newview/llnotificationtiphandler.cpp +++ b/indra/newview/llnotificationtiphandler.cpp @@ -28,8 +28,11 @@ #include "llviewerprecompiledheaders.h" // must be first include #include "llfloaterreg.h" -#include "llnearbychat.h" -#include "llnearbychatbar.h" +// Remove floating chat bar +// #include "llnearbychat.h" +// #include "llnearbychatbar.h" +#include "llfloaternearbychat.h" +// #include "llnotificationhandler.h" #include "llnotifications.h" #include "lltoastnotifypanel.h" @@ -94,9 +97,12 @@ bool LLTipHandler::processNotification(const LLSD& notify) LLHandlerUtil::logToNearbyChat(notification, CHAT_SOURCE_SYSTEM); // don't show toast if Nearby Chat is opened - LLNearbyChat* nearby_chat = LLNearbyChat::getInstance(); - LLNearbyChatBar* nearby_chat_bar = LLNearbyChatBar::getInstance(); - if (!nearby_chat_bar->isMinimized() && nearby_chat_bar->getVisible() && nearby_chat->getVisible()) + LLFloaterNearbyChat* nearby_chat = LLFloaterNearbyChat::getInstance(); + // Remove floating chat bar + // LLNearbyChatBar* nearby_chat_bar = LLNearbyChatBar::getInstance(); + // if (!nearby_chat_bar->isMinimized() && nearby_chat_bar->getVisible() && nearby_chat->getVisible()) + if (nearby_chat->getVisible()) + // { return false; } diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index ea2420415a..1d5ed5e05c 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -77,7 +77,7 @@ #include #include "llnotificationmanager.h" #include "lllayoutstack.h" -#include "llnearbychatbar.h" +// #include "llnearbychatbar.h" // Remove floating chat bar #include #include #include "llcontrol.h" diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index c1e37c8794..43352ae5bc 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -63,7 +63,10 @@ #include "llmemorystream.h" #include "llmessageconfig.h" #include "llmoveview.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "llnotifications.h" #include "llnotificationsutil.h" #include "llteleporthistory.h" @@ -1568,7 +1571,7 @@ bool idle_startup() //so I just moved nearby history loading a few states further if (gSavedPerAccountSettings.getBOOL("LogShowHistory")) { - LLNearbyChat* nearby_chat = LLNearbyChat::getInstance(); + LLFloaterNearbyChat* nearby_chat = LLFloaterNearbyChat::getInstance(); if (nearby_chat) nearby_chat->loadHistory(); } display_startup(); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 04f1d49915..5a890353e5 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -67,9 +67,6 @@ #include "llvowlsky.h" #include "llrender.h" #include "llnavigationbar.h" -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-09-24 (Catznip-3.2.0a) -#include "llnearbychatbar.h" -// [/SL:KB] #include "llfloatertools.h" #include "llpaneloutfitsinventory.h" #include "llpanellogin.h" @@ -808,11 +805,6 @@ void settings_setup_listeners() gSavedSettings.getControl("_NACL_AntiSpamTime")->getSignal()->connect(boost::bind(&handleNaclAntiSpamTimeChanged, _2)); gSavedSettings.getControl("_NACL_AntiSpamAmount")->getSignal()->connect(boost::bind(&handleNaclAntiSpamAmountChanged, _2)); // NaCl End - -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-09-24 (Catznip-3.2.0a) | Added: Catznip-3.0.0a - gSavedSettings.getControl("NearbyChatFloaterBarType")->getSignal()->connect(boost::bind(&LLNearbyChatBar::processFloaterTypeChanged)); - gSavedSettings.getControl("NearbyChatFloaterWindow")->getSignal()->connect(boost::bind(&LLNearbyChatBar::processFloaterTypeChanged)); -// [/SL:KB] } #if TEST_CACHED_CONTROL diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 29b8a77b52..5d8679c74a 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -119,7 +119,10 @@ #include "llinspectremoteobject.h" #include "llinspecttoast.h" #include "llmoveview.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "llpanelblockedlist.h" #include "llpanelclassified.h" #include "llpreviewanim.h" @@ -132,7 +135,7 @@ #include "llscriptfloater.h" #include "llfloatermodelpreview.h" #include "llcommandhandler.h" -#include "llnearbychatbar.h" +// #include "llnearbychatbar.h" // Remove floating chat bar // *NOTE: Please add files in alphabetical order to keep merges easy. // ND: And for FS please put yours after this line, for easier merges too @@ -213,12 +216,10 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - - LLFloaterReg::add("nearby_chat", "floater_nearby_chat.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); -// LLFloaterReg::add("chat_bar", "floater_chat_bar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-08-24 (Catznip-3.2.0a) | Added: Catznip-2.8.0a - LLFloaterReg::addWithFileCallback("chat_bar", &LLNearbyChatBar::getFloaterXMLFile, (LLFloaterBuildFunc)&LLFloaterReg::build); -// [/SL:KB] + // Remove floating chat bar + // LLFloaterReg::add("chat_bar", "floater_chat_bar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("nearby_chat", "floater_nearby_chat.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + // LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewergesture.cpp b/indra/newview/llviewergesture.cpp index 345a45b5a4..94b31ba408 100644 --- a/indra/newview/llviewergesture.cpp +++ b/indra/newview/llviewergesture.cpp @@ -40,10 +40,10 @@ #include "llviewermessage.h" // send_guid_sound_trigger #include "llviewernetwork.h" #include "llagent.h" -//#include "llnearbychatbar.h" -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) -#include "llnearbychatbarbase.h" -// [/SL:KB] +// Remove floating chat bar +// #include "llnearbychatbar.h" +#include "llnearbychathub.h" +// // Globals LLViewerGestureList gGestureList; @@ -133,10 +133,9 @@ void LLViewerGesture::doTrigger( BOOL send_chat ) { // Don't play nodding animation, since that might not blend // with the gesture animation. -// LLNearbyChatBar::getInstance()->sendChatFromViewer(mOutputString, CHAT_TYPE_NORMAL, FALSE); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLNearbyChatBarBase::sendChatFromViewer(mOutputString, CHAT_TYPE_NORMAL, FALSE); -// [/SL:KB] + // Remove floating chat bar + // LLNearbyChatBar::getInstance()->sendChatFromViewer(mOutputString, CHAT_TYPE_NORMAL, FALSE); + LLNearbyChat::getInstance()->sendChatFromViewer(mOutputString, CHAT_TYPE_NORMAL, FALSE); } } diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index 6b5f9bcbf6..a6cc6aac7e 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -31,7 +31,11 @@ #include "llmath.h" #include "llagent.h" #include "llagentcamera.h" -#include "llnearbychatbar.h" +// Remove floating chat bar +// #include "llnearbychatbar.h" +#include "llnearbychathub.h" +#include "lllineeditor.h" +// #include "llviewercontrol.h" #include "llfocusmgr.h" #include "llmorphview.h" @@ -545,7 +549,10 @@ void stop_moving( EKeystate s ) void start_chat( EKeystate s ) { // start chat - LLNearbyChatBar::startChat(NULL); + // Remove floating chat bar + // LLNearbyChatBar::startChat(NULL); + LLNearbyChat::getInstance()->showDefaultChatBar(TRUE); + // } void start_gesture( EKeystate s ) @@ -570,19 +577,19 @@ void start_gesture( EKeystate s ) if (KEYSTATE_UP == s && ! (focus_ctrlp && focus_ctrlp->acceptsTextInput())) { -// if (LLNearbyChatBar::getInstance()->getCurrentChat().empty()) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - if (LLNearbyChatBar::getInstance()->getChatBarImpl()->getChatBoxText().empty()) -// [/SL:KB] + // Remove floating chat bar + // TODO: This needs the new bottom chat bar to work at all +/* if (LLNearbyChat::getInstance()->getCurrentChat().empty()) { // No existing chat in chat editor, insert '/' - LLNearbyChatBar::startChat("/"); + LLNearbyChat::startChat("/"); } else { // Don't overwrite existing text in chat editor - LLNearbyChatBar::startChat(NULL); - } + LLNearbyChat::startChat(NULL); + }*/ + // } } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 9d7ea16902..90c4bd78bc 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -67,7 +67,10 @@ #include "llinventoryfunctions.h" #include "llinventoryobserver.h" #include "llinventorypanel.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llfloaternearbychat.h" +// #include "llnotifications.h" #include "llnotificationsutil.h" #include "llpanelgrouplandmoney.h" @@ -2340,7 +2343,7 @@ void god_message_name_cb(const LLAvatarName& av_name, LLChat chat, std::string m // Treat like a system message and put in chat history. chat.mText = av_name.getCompleteName() + ": " + message; - LLNearbyChat* nearby_chat = LLNearbyChat::getInstance(); + LLFloaterNearbyChat* nearby_chat = LLFloaterNearbyChat::getInstance(); if(nearby_chat) { nearby_chat->addMessage(chat); @@ -3089,7 +3092,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // Note: lie to Nearby Chat, pretending that this is NOT an IM, because // IMs from obejcts don't open IM sessions. - LLNearbyChat* nearby_chat = LLNearbyChat::getInstance(); + // Can anyone elaborate on this and add to the comment what this + // code is supposed to do exactly? + LLFloaterNearbyChat* nearby_chat = LLFloaterNearbyChat::getInstance(); if(SYSTEM_FROM != name && nearby_chat) { chat.mOwnerID = from_id; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index e61f3a0468..6a2314a74d 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -189,7 +189,7 @@ #include "llviewerjoystick.h" #include "llviewernetwork.h" #include "llpostprocess.h" -#include "llnearbychatbar.h" +// #include "llnearbychatbar.h" // Remove floating chat bar #include "llagentui.h" #include "llwearablelist.h" @@ -199,7 +199,10 @@ #include "llfloaternotificationsconsole.h" -#include "llnearbychat.h" +// Remove floating chat bar +// #include "llnearbychat.h" +#include "llnearbychathub.h" +// #include "llwindowlistener.h" #include "llviewerwindowlistener.h" #include "llpaneltopinfobar.h" @@ -2508,28 +2511,23 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // Traverses up the hierarchy if( keyboard_focus ) { - LLNearbyChatBar* nearby_chat = LLFloaterReg::findTypedInstance("chat_bar"); + // Remove floating chat bar + // LLNearbyChatBar* nearby_chat = LLFloaterReg::findTypedInstance("chat_bar"); -// if (nearby_chat) -// { -// LLLineEditor* chat_editor = nearby_chat->getChatBox(); -// -// // arrow keys move avatar while chatting hack -// if (chat_editor && chat_editor->hasFocus()) -// { -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLNearbyChatBarBase* pChatBarImpl = (nearby_chat) ? nearby_chat->getChatBarImpl() : NULL; - if ( (pChatBarImpl) && (pChatBarImpl->getChatBoxCtrl()) && (pChatBarImpl->getChatBoxCtrl()->hasFocus()) ) - { -// [/SL:KB] - // If text field is empty, there's no point in trying to move - // cursor with arrow keys, so allow movement -// if (chat_editor->getText().empty() -// || gSavedSettings.getBOOL("ArrowKeysAlwaysMove")) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - if (pChatBarImpl->getChatBoxText().empty() + // if (nearby_chat) + // { + // LLLineEditor* chat_editor = nearby_chat->getChatBox(); + + + // arrow keys move avatar while chatting hack + // if (chat_editor && chat_editor->hasFocus()) + // { + // // If text field is empty, there's no point in trying to move + // // cursor with arrow keys, so allow movement + // if (chat_editor->getText().empty() + if(LLNearbyChat::instance().chatIsEmpty() + // || gSavedSettings.getBOOL("ArrowKeysAlwaysMove")) -// [/SL:KB] { // let Control-Up and Control-Down through for chat line history, if (!(key == KEY_UP && mask == MASK_CONTROL) @@ -2551,8 +2549,10 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) break; } } - } -// } + // Remove floating chat bar + // } + // } + // } if (keyboard_focus->handleKey(key, mask, FALSE)) { @@ -2581,23 +2581,22 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // If "Pressing letter keys starts local chat" option is selected, we are not in mouselook, // no view has keyboard focus, this is a printable character key (and no modifier key is // pressed except shift), then give focus to nearby chat (STORM-560) + if ( gSavedSettings.getS32("LetterKeysFocusChatBar") && !gAgentCamera.cameraMouselook() && !keyboard_focus && key < 0x80 && (mask == MASK_NONE || mask == MASK_SHIFT) ) { -// LLLineEditor* chat_editor = LLFloaterReg::getTypedInstance("chat_bar")->getChatBox(); -// if (chat_editor) -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - LLNearbyChatBar* nearby_chat = LLFloaterReg::getTypedInstance("chat_bar"); - if (nearby_chat) -// [/SL:KB] - { - // passing NULL here, character will be added later when it is handled by character handler. -// LLNearbyChatBar::getInstance()->startChat(NULL); -// [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-10-26 (Catznip-3.2.0a) | Added: Catznip-3.2.0a - nearby_chat->startChat(NULL); -// [/SL:KB] - return TRUE; - } + // Remove floating chat bar + // LLLineEditor* chat_editor = LLFloaterReg::getTypedInstance("chat_bar")->getChatBox(); + + // if (chat_editor) + // { + // // passing NULL here, character will be added later when it is handled by character handler. + // LLNearbyChatBar::getInstance()->startChat(NULL); + // return TRUE; + // } + LLNearbyChat::getInstance()->showDefaultChatBar(TRUE); + return TRUE; + // } // give menus a chance to handle unmodified accelerator keys diff --git a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml index c32efc4b55..a8af0effb0 100644 --- a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml +++ b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml @@ -127,7 +127,7 @@ user_resize="false" width="300"> - + tab_group="3" /> + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 66a8b04de1..27a7e7cf29 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3724,7 +3724,7 @@ Try enclosing path to the editor with double quotes. Appearance Avatar Build - Chat + Conversations Compass Destinations Gestures diff --git a/indra/newview/skins/vintage/xui/en/panel_toolbar_view.xml b/indra/newview/skins/vintage/xui/en/panel_toolbar_view.xml index 9728cea197..3e61ffe5e4 100644 --- a/indra/newview/skins/vintage/xui/en/panel_toolbar_view.xml +++ b/indra/newview/skins/vintage/xui/en/panel_toolbar_view.xml @@ -10,6 +10,7 @@ mouse_opaque="false" tab_stop="false" visible="true"> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/vintage/xui/en/widgets/toolbar.xml b/indra/newview/skins/vintage/xui/en/widgets/toolbar.xml index 72c31931bd..921f5aa50f 100644 --- a/indra/newview/skins/vintage/xui/en/widgets/toolbar.xml +++ b/indra/newview/skins/vintage/xui/en/widgets/toolbar.xml @@ -43,9 +43,9 @@ image_selected="PushButton_Selected_Press" image_disabled_selected="PushButton_Selected_Disabled" image_disabled="PushButton_Disabled" - desired_height="24" - button_width.min="24" - button_width.max="24" + desired_height="20" + button_width.min="20" + button_width.max="20" follows="left|top" label="" halign="left"