diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llchatbar.cpp | 81 |
1 files changed, 52 insertions, 29 deletions
diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index b47e468..d1834a6 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp | |||
@@ -45,6 +45,7 @@ | |||
45 | #include "llagent.h" | 45 | #include "llagent.h" |
46 | #include "llbutton.h" | 46 | #include "llbutton.h" |
47 | #include "llcombobox.h" | 47 | #include "llcombobox.h" |
48 | #include "llcommandhandler.h" // secondlife:///app/chat/ support | ||
48 | #include "llviewercontrol.h" | 49 | #include "llviewercontrol.h" |
49 | #include "llfloaterchat.h" | 50 | #include "llfloaterchat.h" |
50 | #include "llgesturemgr.h" | 51 | #include "llgesturemgr.h" |
@@ -64,7 +65,7 @@ | |||
64 | #include "llmultigesture.h" | 65 | #include "llmultigesture.h" |
65 | #include "llui.h" | 66 | #include "llui.h" |
66 | #include "llviewermenu.h" | 67 | #include "llviewermenu.h" |
67 | #include "llvieweruictrlfactory.h" | 68 | #include "lluictrlfactory.h" |
68 | 69 | ||
69 | 70 | ||
70 | // | 71 | // |
@@ -76,6 +77,7 @@ LLChatBar *gChatBar = NULL; | |||
76 | 77 | ||
77 | // legacy calllback glue | 78 | // legacy calllback glue |
78 | void toggleChatHistory(void* user_data); | 79 | void toggleChatHistory(void* user_data); |
80 | void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); | ||
79 | 81 | ||
80 | 82 | ||
81 | class LLChatBarGestureObserver : public LLGestureManagerObserver | 83 | class LLChatBarGestureObserver : public LLGestureManagerObserver |
@@ -123,7 +125,7 @@ BOOL LLChatBar::postBuild() | |||
123 | childSetCommitCallback("Say", onClickSay, this); | 125 | childSetCommitCallback("Say", onClickSay, this); |
124 | 126 | ||
125 | // attempt to bind to an existing combo box named gesture | 127 | // attempt to bind to an existing combo box named gesture |
126 | setGestureCombo(LLUICtrlFactory::getComboBoxByName(this, "Gesture")); | 128 | setGestureCombo(getChild<LLComboBox>( "Gesture")); |
127 | 129 | ||
128 | LLButton * sayp = getChild<LLButton>("Say"); | 130 | LLButton * sayp = getChild<LLButton>("Say"); |
129 | if(sayp) | 131 | if(sayp) |
@@ -131,7 +133,7 @@ BOOL LLChatBar::postBuild() | |||
131 | setDefaultBtn(sayp); | 133 | setDefaultBtn(sayp); |
132 | } | 134 | } |
133 | 135 | ||
134 | mInputEditor = LLUICtrlFactory::getLineEditorByName(this, "Chat Editor"); | 136 | mInputEditor = getChild<LLLineEditor>("Chat Editor"); |
135 | if (mInputEditor) | 137 | if (mInputEditor) |
136 | { | 138 | { |
137 | mInputEditor->setCallbackUserData(this); | 139 | mInputEditor->setCallbackUserData(this); |
@@ -157,36 +159,34 @@ BOOL LLChatBar::postBuild() | |||
157 | //----------------------------------------------------------------------- | 159 | //----------------------------------------------------------------------- |
158 | 160 | ||
159 | // virtual | 161 | // virtual |
160 | BOOL LLChatBar::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) | 162 | BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) |
161 | { | 163 | { |
162 | BOOL handled = FALSE; | 164 | BOOL handled = FALSE; |
163 | 165 | ||
164 | if( getVisible() && getEnabled() && !called_from_parent) | 166 | // ALT-RETURN is reserved for windowed/fullscreen toggle |
167 | if( KEY_RETURN == key ) | ||
165 | { | 168 | { |
166 | // ALT-RETURN is reserved for windowed/fullscreen toggle | 169 | if (mask == MASK_CONTROL) |
167 | if( KEY_RETURN == key ) | ||
168 | { | 170 | { |
169 | if (mask == MASK_CONTROL) | 171 | // shout |
170 | { | 172 | sendChat(CHAT_TYPE_SHOUT); |
171 | // shout | 173 | handled = TRUE; |
172 | sendChat(CHAT_TYPE_SHOUT); | ||
173 | handled = TRUE; | ||
174 | } | ||
175 | else if (mask == MASK_NONE) | ||
176 | { | ||
177 | // say | ||
178 | sendChat( CHAT_TYPE_NORMAL ); | ||
179 | handled = TRUE; | ||
180 | } | ||
181 | } | 174 | } |
182 | // only do this in main chatbar | 175 | else if (mask == MASK_NONE) |
183 | else if ( KEY_ESCAPE == key && gChatBar == this) | ||
184 | { | 176 | { |
185 | stopChat(); | 177 | // say |
186 | 178 | sendChat( CHAT_TYPE_NORMAL ); | |
187 | handled = TRUE; | 179 | handled = TRUE; |
188 | } | 180 | } |
189 | } | 181 | } |
182 | // only do this in main chatbar | ||
183 | else if ( KEY_ESCAPE == key && gChatBar == this) | ||
184 | { | ||
185 | stopChat(); | ||
186 | |||
187 | handled = TRUE; | ||
188 | } | ||
189 | |||
190 | return handled; | 190 | return handled; |
191 | } | 191 | } |
192 | 192 | ||
@@ -429,10 +429,8 @@ void LLChatBar::sendChat( EChatType type ) | |||
429 | //----------------------------------------------------------------------- | 429 | //----------------------------------------------------------------------- |
430 | 430 | ||
431 | // static | 431 | // static |
432 | void LLChatBar::startChat(void* userdata) | 432 | void LLChatBar::startChat(const char* line) |
433 | { | 433 | { |
434 | const char* line = (const char*)userdata; | ||
435 | |||
436 | gChatBar->setVisible(TRUE); | 434 | gChatBar->setVisible(TRUE); |
437 | gChatBar->setKeyboardFocus(TRUE); | 435 | gChatBar->setKeyboardFocus(TRUE); |
438 | gSavedSettings.setBOOL("ChatVisible", TRUE); | 436 | gSavedSettings.setBOOL("ChatVisible", TRUE); |
@@ -572,8 +570,6 @@ void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, | |||
572 | 570 | ||
573 | void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) | 571 | void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) |
574 | { | 572 | { |
575 | LLMessageSystem* msg = gMessageSystem; | ||
576 | |||
577 | // Look for "/20 foo" channel chats. | 573 | // Look for "/20 foo" channel chats. |
578 | S32 channel = 0; | 574 | S32 channel = 0; |
579 | LLWString out_text = stripChannelNumber(wtext, &channel); | 575 | LLWString out_text = stripChannelNumber(wtext, &channel); |
@@ -618,6 +614,12 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL | |||
618 | } | 614 | } |
619 | } | 615 | } |
620 | 616 | ||
617 | send_chat_from_viewer(utf8_out_text, type, channel); | ||
618 | } | ||
619 | |||
620 | void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) | ||
621 | { | ||
622 | LLMessageSystem* msg = gMessageSystem; | ||
621 | msg->newMessageFast(_PREHASH_ChatFromViewer); | 623 | msg->newMessageFast(_PREHASH_ChatFromViewer); |
622 | msg->nextBlockFast(_PREHASH_AgentData); | 624 | msg->nextBlockFast(_PREHASH_AgentData); |
623 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | 625 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); |
@@ -629,7 +631,7 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL | |||
629 | 631 | ||
630 | gAgent.sendReliableMessage(); | 632 | gAgent.sendReliableMessage(); |
631 | 633 | ||
632 | gViewerStats->incStat(LLViewerStats::ST_CHAT_COUNT); | 634 | LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); |
633 | } | 635 | } |
634 | 636 | ||
635 | 637 | ||
@@ -672,3 +674,24 @@ void toggleChatHistory(void* user_data) | |||
672 | { | 674 | { |
673 | LLFloaterChat::toggleInstance(LLSD()); | 675 | LLFloaterChat::toggleInstance(LLSD()); |
674 | } | 676 | } |
677 | |||
678 | |||
679 | class LLChatHandler : public LLCommandHandler | ||
680 | { | ||
681 | public: | ||
682 | // not allowed from outside the app | ||
683 | LLChatHandler() : LLCommandHandler("chat", false) { } | ||
684 | |||
685 | // Your code here | ||
686 | bool handle(const LLSD& tokens, const LLSD& queryMap) | ||
687 | { | ||
688 | if (tokens.size() < 2) return false; | ||
689 | S32 channel = tokens[0].asInteger(); | ||
690 | std::string mesg = tokens[1].asString(); | ||
691 | send_chat_from_viewer(mesg, CHAT_TYPE_NORMAL, channel); | ||
692 | return true; | ||
693 | } | ||
694 | }; | ||
695 | |||
696 | // Creating the object registers with the dispatcher. | ||
697 | LLChatHandler gChatHandler; | ||