From b4d35c8d24d1095cdb67864b6576ef280b76c646 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 9 Sep 2009 02:31:31 -0700 Subject: Created my own version of Emerald's chat channel tool --- linden/indra/newview/app_settings/settings.xml | 11 ++++++ linden/indra/newview/llchatbar.cpp | 43 ++++++++++++++++++++-- linden/indra/newview/llchatbar.h | 5 +++ linden/indra/newview/llfloaterchat.cpp | 31 +++++++++++++++- linden/indra/newview/llfloaterchat.h | 2 + linden/indra/newview/llprefschat.cpp | 23 +++++++++++- linden/indra/newview/llprefsim.cpp | 2 +- .../default/xui/en-us/floater_chat_history.xml | 6 ++- .../skins/default/xui/en-us/panel_chat_bar.xml | 10 +++-- .../default/xui/en-us/panel_preferences_chat.xml | 16 +++++--- 10 files changed, 132 insertions(+), 17 deletions(-) (limited to 'linden') diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index a6a18e6..56d65f4 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -1105,6 +1105,17 @@ Value 0.5 + ChatChannelSelect + + Comment + Toggle custom channel controls in the chat bar + Persist + 1 + Type + Boolean + Value + 0 + ChatFontSize Comment diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 59aa572..0178420 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -53,6 +53,7 @@ #include "llkeyboard.h" #include "lllineeditor.h" #include "llstatusbar.h" +#include "llspinctrl.h" #include "lltextbox.h" #include "lluiconstants.h" #include "llviewergesture.h" // for triggering gestures @@ -98,6 +99,7 @@ private: LLChatBar::LLChatBar() : LLPanel(LLStringUtil::null, LLRect(), BORDER_NO), + mChannelControl(FALSE), mInputEditor(NULL), mGestureLabelTimer(), mLastSpecialChatChannel(0), @@ -151,6 +153,8 @@ BOOL LLChatBar::postBuild() mInputEditor->setEnableLineHistory(TRUE); } + toggleChannelControl(); + mIsBuilt = TRUE; return TRUE; @@ -210,6 +214,7 @@ void LLChatBar::refresh() childSetValue("History", LLFloaterChat::instanceVisible(LLSD())); + childSetValue("channel_control",( 1.f * ((S32)(getChild("channel_control")->get()))) ); childSetEnabled("Say", mInputEditor->getText().size() > 0); childSetEnabled("Shout", mInputEditor->getText().size() > 0); @@ -370,8 +375,11 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel) } else { - // This is normal chat. - *channel = 0; + if (!mChannelControl) + { + // This is normal chat. + *channel = 0; + } return mesg; } } @@ -387,7 +395,8 @@ void LLChatBar::sendChat( EChatType type ) // store sent line in history, duplicates will get filtered if (mInputEditor) mInputEditor->updateHistory(); // Check if this is destined for another channel - S32 channel = 0; + S32 channel = mChannelControl ? (S32)(getChild("channel_control")->get()) : 0; + stripChannelNumber(text, &channel); std::string utf8text = wstring_to_utf8str(text); @@ -425,6 +434,31 @@ void LLChatBar::sendChat( EChatType type ) } } +void LLChatBar::toggleChannelControl() +{ + LLRect input_rect = mInputEditor->getRect(); + S32 chan_width = getChild("channel_control")->getRect().getWidth(); + BOOL visible = gSavedSettings.getBOOL("ChatChannelSelect"); + BOOL control = getChild("channel_control")->getVisible(); + + if (visible && !control) + { + input_rect.setLeftTopAndSize(input_rect.mLeft+chan_width, input_rect.mTop, + input_rect.getWidth()-chan_width, input_rect.getHeight()); + } + else if (!visible && control) + { + input_rect.setLeftTopAndSize(input_rect.mLeft-chan_width, input_rect.mTop, + input_rect.getWidth()+chan_width, input_rect.getHeight()); + + } + mInputEditor->setRect(input_rect); + + childSetVisible("channel_control", visible); + childSetEnabled("channel_control", visible); + mChannelControl = visible; +} + //----------------------------------------------------------------------- // Static functions @@ -575,7 +609,8 @@ void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) { // Look for "/20 foo" channel chats. - S32 channel = 0; + S32 channel = mChannelControl ? (S32)(getChild("channel_control")->get()) : 0; + //S32 channel = (S32)(getChild("ChatChannel")->get()); LLWString out_text = stripChannelNumber(wtext, &channel); std::string utf8_out_text = wstring_to_utf8str(out_text); std::string utf8_text = wstring_to_utf8str(wtext); diff --git a/linden/indra/newview/llchatbar.h b/linden/indra/newview/llchatbar.h index 72c797a..53ac233 100644 --- a/linden/indra/newview/llchatbar.h +++ b/linden/indra/newview/llchatbar.h @@ -93,6 +93,8 @@ public: static void startChat(const char* line); static void stopChat(); + void toggleChannelControl(); + protected: void sendChat(EChatType type); void updateChat(); @@ -109,6 +111,9 @@ protected: LLComboBox* mGestureCombo; LLChatBarGestureObserver* mObserver; + +private: + BOOL mChannelControl; }; extern LLChatBar *gChatBar; diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index 5117b8d..f624ec3 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp @@ -56,10 +56,11 @@ #include "llfloaterchatterbox.h" #include "llfloatermute.h" #include "llkeyboard.h" -//#include "lllineeditor.h" +#include "lllineeditor.h" #include "llmutelist.h" //#include "llresizehandle.h" #include "llchatbar.h" +#include "llspinctrl.h" #include "llstatusbar.h" #include "llviewertexteditor.h" #include "llviewergesture.h" // for triggering gestures @@ -223,6 +224,34 @@ void log_chat_text(const LLChat& chat) LLLogChat::saveHistory(std::string("chat"),histstr); } + +// static +void LLFloaterChat::toggleHistoryChannelControl() +{ + LLFloaterChat* chat_floater = LLFloaterChat::getInstance(LLSD()); + BOOL visible = gSavedSettings.getBOOL("ChatChannelSelect"); + BOOL control = chat_floater->getChild("channel_control")->getVisible(); + + LLLineEditor* input = chat_floater->getChild("Chat Editor"); + LLRect input_rect = input->getRect(); + S32 chan_width = chat_floater->getChild("channel_control")->getRect().getWidth(); + + if (visible && !control) + { + input_rect.setLeftTopAndSize(input_rect.mLeft+chan_width+4, input_rect.mTop, + input_rect.getWidth()-chan_width, input_rect.getHeight()); + } + else if (!visible && control) + { + input_rect.setLeftTopAndSize(input_rect.mLeft-chan_width-4, input_rect.mTop, + input_rect.getWidth()+chan_width, input_rect.getHeight()); + } + input->setRect(input_rect); + + chat_floater->childSetVisible("channel_control", visible); + chat_floater->childSetEnabled("channel_control", visible); +} + // static void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) { diff --git a/linden/indra/newview/llfloaterchat.h b/linden/indra/newview/llfloaterchat.h index 923fd9a..203a158 100644 --- a/linden/indra/newview/llfloaterchat.h +++ b/linden/indra/newview/llfloaterchat.h @@ -82,6 +82,8 @@ public: static void* createSpeakersPanel(void* data); static void* createChatPanel(void* data); + static void toggleHistoryChannelControl(); + // visibility policy for LLUISingleton static bool visible(LLFloater* instance, const LLSD& key); static void show(LLFloater* instance, const LLSD& key); diff --git a/linden/indra/newview/llprefschat.cpp b/linden/indra/newview/llprefschat.cpp index 4453751..82ae07c 100644 --- a/linden/indra/newview/llprefschat.cpp +++ b/linden/indra/newview/llprefschat.cpp @@ -32,6 +32,8 @@ #include "llviewerprecompiledheaders.h" +#include "llchatbar.h" +#include "llfloaterchat.h" #include "llprefschat.h" #include "lltexteditor.h" #include "llviewercontrol.h" @@ -45,10 +47,13 @@ class LLPrefsChatImpl : public LLPanel public: LLPrefsChatImpl(); /*virtual*/ ~LLPrefsChatImpl(){}; + /*virtual*/ BOOL postBuild(); void apply(); void cancel(); + static void onCheckToggleChannel(LLUICtrl* ctrl, void* user_data); + protected: S32 mChatSize; F32 mChatPersist; @@ -73,7 +78,6 @@ protected: F32 mBubbleOpacity; }; - LLPrefsChatImpl::LLPrefsChatImpl() : LLPanel(std::string("Chat Panel")) { @@ -128,6 +132,13 @@ LLPrefsChatImpl::LLPrefsChatImpl() mBubbleOpacity = gSavedSettings.getF32("ChatBubbleOpacity"); } +BOOL LLPrefsChatImpl::postBuild() +{ + childSetCommitCallback("toggle_channel_control",onCheckToggleChannel, this); + + return TRUE; +} + void LLPrefsChatImpl::cancel() { gSavedSettings.setS32("ChatFontSize", mChatSize); @@ -183,6 +194,16 @@ void LLPrefsChatImpl::apply() gSavedSettings.setF32("ChatBubbleOpacity", childGetValue("bubble_chat_opacity").asReal()); } +// static +void LLPrefsChatImpl::onCheckToggleChannel(LLUICtrl* ctrl, void* user_data) +{ + if (gChatBar) + { + gChatBar->toggleChannelControl(); + LLFloaterChat::toggleHistoryChannelControl(); + } +} + //--------------------------------------------------------------------------- LLPrefsChat::LLPrefsChat() diff --git a/linden/indra/newview/llprefsim.cpp b/linden/indra/newview/llprefsim.cpp index 39619b7..6115074 100644 --- a/linden/indra/newview/llprefsim.cpp +++ b/linden/indra/newview/llprefsim.cpp @@ -58,7 +58,7 @@ public: void cancel(); void setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email); void enableHistory(); - + static void onClickLogPath(void* user_data); static void onCommitLogging(LLUICtrl* ctrl, void* user_data); diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_chat_history.xml b/linden/indra/newview/skins/default/xui/en-us/floater_chat_history.xml index 100c455..dd66a83 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_chat_history.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_chat_history.xml @@ -59,10 +59,14 @@ Gestures + + - + diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_chat.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_chat.xml index 24753d1..0704666 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_chat.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_chat.xml @@ -131,30 +131,34 @@ follows="left|top" font="SansSerifSmall" height="16" initial_value="false" label="Close chat bar after hitting return" left="148" mouse_opaque="true" name="close_chat_on_return_check" radio_style="false" width="237" /> - - - + Bubble Chat: - -