diff options
Diffstat (limited to 'linden/indra/newview/llfloaterchat.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterchat.cpp | 213 |
1 files changed, 97 insertions, 116 deletions
diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index dd79afd..2621161 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "llviewerprecompiledheaders.h" | 34 | #include "llviewerprecompiledheaders.h" |
35 | 35 | ||
36 | #include "llfloaterchat.h" | 36 | #include "llfloaterchat.h" |
37 | #include "llfloateractivespeakers.h" | ||
37 | #include "llfloaterscriptdebug.h" | 38 | #include "llfloaterscriptdebug.h" |
38 | 39 | ||
39 | #include "llchat.h" | 40 | #include "llchat.h" |
@@ -49,11 +50,13 @@ | |||
49 | #include "llcheckboxctrl.h" | 50 | #include "llcheckboxctrl.h" |
50 | #include "llcombobox.h" | 51 | #include "llcombobox.h" |
51 | #include "llconsole.h" | 52 | #include "llconsole.h" |
53 | #include "llfloaterchatterbox.h" | ||
52 | #include "llfloatermute.h" | 54 | #include "llfloatermute.h" |
53 | #include "llkeyboard.h" | 55 | #include "llkeyboard.h" |
54 | //#include "lllineeditor.h" | 56 | //#include "lllineeditor.h" |
55 | #include "llmutelist.h" | 57 | #include "llmutelist.h" |
56 | //#include "llresizehandle.h" | 58 | //#include "llresizehandle.h" |
59 | #include "llchatbar.h" | ||
57 | #include "llstatusbar.h" | 60 | #include "llstatusbar.h" |
58 | #include "llviewertexteditor.h" | 61 | #include "llviewertexteditor.h" |
59 | #include "llviewergesture.h" // for triggering gestures | 62 | #include "llviewergesture.h" // for triggering gestures |
@@ -70,7 +73,6 @@ | |||
70 | // | 73 | // |
71 | // Constants | 74 | // Constants |
72 | // | 75 | // |
73 | const char FLOATER_TITLE[] = "Chat History"; | ||
74 | const F32 INSTANT_MSG_SIZE = 8.0f; | 76 | const F32 INSTANT_MSG_SIZE = 8.0f; |
75 | const F32 CHAT_MSG_SIZE = 8.0f; | 77 | const F32 CHAT_MSG_SIZE = 8.0f; |
76 | const LLColor4 INSTANT_MSG_COLOR(1, 1, 1, 1); | 78 | const LLColor4 INSTANT_MSG_COLOR(1, 1, 1, 1); |
@@ -80,25 +82,25 @@ const S32 MAX_CHATTER_COUNT = 16; | |||
80 | // | 82 | // |
81 | // Global statics | 83 | // Global statics |
82 | // | 84 | // |
83 | LLFloaterChat* gFloaterChat = NULL; | ||
84 | |||
85 | LLColor4 get_text_color(const LLChat& chat); | 85 | LLColor4 get_text_color(const LLChat& chat); |
86 | 86 | ||
87 | // | 87 | // |
88 | // Member Functions | 88 | // Member Functions |
89 | // | 89 | // |
90 | LLFloaterChat::LLFloaterChat() | 90 | LLFloaterChat::LLFloaterChat(const LLSD& seed) |
91 | : LLFloater("chat floater", "FloaterChatRect", FLOATER_TITLE, | 91 | : LLFloater("chat floater", "FloaterChatRect", "", |
92 | RESIZE_YES, 440, 100, DRAG_ON_TOP, MINIMIZE_NO, CLOSE_YES) | 92 | RESIZE_YES, 440, 100, DRAG_ON_TOP, MINIMIZE_NO, CLOSE_YES), |
93 | mPanel(NULL) | ||
93 | { | 94 | { |
94 | 95 | mFactoryMap["chat_panel"] = LLCallbackMap(createChatPanel, NULL); | |
95 | gUICtrlFactory->buildFloater(this,"floater_chat_history.xml"); | 96 | mFactoryMap["active_speakers_panel"] = LLCallbackMap(createSpeakersPanel, NULL); |
97 | // do not automatically open singleton floaters (as result of getInstance()) | ||
98 | BOOL no_open = FALSE; | ||
99 | gUICtrlFactory->buildFloater(this,"floater_chat_history.xml",&getFactoryMap(),no_open); | ||
96 | 100 | ||
97 | childSetAction("Mute resident",onClickMute,this); | ||
98 | childSetAction("Chat", onClickChat, this); | ||
99 | childSetCommitCallback("chatter combobox",onCommitUserSelect,this); | ||
100 | childSetCommitCallback("show mutes",onClickToggleShowMute,this); //show mutes | 101 | childSetCommitCallback("show mutes",onClickToggleShowMute,this); //show mutes |
101 | childSetVisible("Chat History Editor with mute",FALSE); | 102 | childSetVisible("Chat History Editor with mute",FALSE); |
103 | childSetAction("toggle_active_speakers_btn", onClickToggleActiveSpeakers, this); | ||
102 | setDefaultBtn("Chat"); | 104 | setDefaultBtn("Chat"); |
103 | } | 105 | } |
104 | 106 | ||
@@ -112,33 +114,53 @@ void LLFloaterChat::setVisible(BOOL visible) | |||
112 | LLFloater::setVisible( visible ); | 114 | LLFloater::setVisible( visible ); |
113 | 115 | ||
114 | gSavedSettings.setBOOL("ShowChatHistory", visible); | 116 | gSavedSettings.setBOOL("ShowChatHistory", visible); |
117 | } | ||
115 | 118 | ||
116 | // Hide the chat overlay when our history is visible. | 119 | void LLFloaterChat::draw() |
117 | gConsole->setVisible( !visible ); | 120 | { |
121 | // enable say and shout only when text available | ||
122 | |||
123 | childSetValue("toggle_active_speakers_btn", childIsVisible("active_speakers_panel")); | ||
124 | |||
125 | LLChatBar* chat_barp = (LLChatBar*)getChildByName("chat_panel", TRUE); | ||
126 | if (chat_barp) | ||
127 | { | ||
128 | chat_barp->refresh(); | ||
129 | } | ||
130 | |||
131 | mPanel->refreshSpeakers(); | ||
132 | LLFloater::draw(); | ||
118 | } | 133 | } |
119 | 134 | ||
135 | BOOL LLFloaterChat::postBuild() | ||
136 | { | ||
137 | mPanel = (LLPanelActiveSpeakers*)LLUICtrlFactory::getPanelByName(this, "active_speakers_panel"); | ||
138 | |||
139 | LLChatBar* chat_barp = (LLChatBar*)getChildByName("chat_panel", TRUE); | ||
140 | if (chat_barp) | ||
141 | { | ||
142 | chat_barp->setGestureCombo(LLUICtrlFactory::getComboBoxByName(this, "Gesture")); | ||
143 | } | ||
144 | return TRUE; | ||
145 | } | ||
120 | 146 | ||
121 | // public virtual | 147 | // public virtual |
122 | void LLFloaterChat::onClose(bool app_quitting) | 148 | void LLFloaterChat::onClose(bool app_quitting) |
123 | { | 149 | { |
124 | LLFloater::setVisible( FALSE ); | ||
125 | |||
126 | if (!app_quitting) | 150 | if (!app_quitting) |
127 | { | 151 | { |
128 | gSavedSettings.setBOOL("ShowChatHistory", FALSE); | 152 | gSavedSettings.setBOOL("ShowChatHistory", FALSE); |
129 | } | 153 | } |
130 | 154 | setVisible(FALSE); | |
131 | // Hide the chat overlay when our history is visible. | ||
132 | gConsole->setVisible( TRUE ); | ||
133 | } | 155 | } |
134 | 156 | ||
135 | 157 | void LLFloaterChat::onVisibilityChange(BOOL new_visibility) | |
136 | // public | ||
137 | void LLFloaterChat::show() | ||
138 | { | 158 | { |
139 | open(); /*Flawfinder: ignore*/ | 159 | // Hide the chat overlay when our history is visible. |
160 | gConsole->setVisible( !new_visibility ); | ||
140 | } | 161 | } |
141 | 162 | ||
163 | |||
142 | void add_timestamped_line(LLViewerTextEditor* edit, const LLString& line, const LLColor4& color) | 164 | void add_timestamped_line(LLViewerTextEditor* edit, const LLString& line, const LLColor4& color) |
143 | { | 165 | { |
144 | bool prepend_newline = true; | 166 | bool prepend_newline = true; |
@@ -162,7 +184,7 @@ void log_chat_text(const LLChat& chat) | |||
162 | } | 184 | } |
163 | // static | 185 | // static |
164 | void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) | 186 | void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) |
165 | { | 187 | { |
166 | if ( gSavedPerAccountSettings.getBOOL("LogChat") && log_to_file) | 188 | if ( gSavedPerAccountSettings.getBOOL("LogChat") && log_to_file) |
167 | { | 189 | { |
168 | log_chat_text(chat); | 190 | log_chat_text(chat); |
@@ -185,10 +207,9 @@ void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) | |||
185 | } | 207 | } |
186 | 208 | ||
187 | // could flash the chat button in the status bar here. JC | 209 | // could flash the chat button in the status bar here. JC |
188 | if (!gFloaterChat) return; | 210 | LLFloaterChat* chat_floater = LLFloaterChat::getInstance(LLSD()); |
189 | 211 | LLViewerTextEditor* history_editor = (LLViewerTextEditor*)chat_floater->getChildByName("Chat History Editor", TRUE); | |
190 | LLViewerTextEditor* history_editor = (LLViewerTextEditor*)gFloaterChat->getChildByName("Chat History Editor"); | 212 | LLViewerTextEditor* history_editor_with_mute = (LLViewerTextEditor*)chat_floater->getChildByName("Chat History Editor with mute", TRUE); |
191 | LLViewerTextEditor* history_editor_with_mute = (LLViewerTextEditor*)gFloaterChat->getChildByName("Chat History Editor with mute"); | ||
192 | 213 | ||
193 | history_editor->setParseHTML(TRUE); | 214 | history_editor->setParseHTML(TRUE); |
194 | history_editor_with_mute->setParseHTML(TRUE); | 215 | history_editor_with_mute->setParseHTML(TRUE); |
@@ -204,77 +225,24 @@ void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) | |||
204 | LLColor4 muted_color = lerp(color, LLColor4::grey, 0.5f); | 225 | LLColor4 muted_color = lerp(color, LLColor4::grey, 0.5f); |
205 | add_timestamped_line(history_editor_with_mute, chat.mText, color); | 226 | add_timestamped_line(history_editor_with_mute, chat.mText, color); |
206 | } | 227 | } |
207 | 228 | ||
208 | if (!chat.mMuted | 229 | // add objects as transient speakers that can be muted |
209 | && chat.mSourceType != CHAT_SOURCE_SYSTEM | 230 | if (chat.mSourceType == CHAT_SOURCE_OBJECT) |
210 | && chat.mFromID.notNull() | ||
211 | && chat.mFromID != gAgent.getID()) | ||
212 | { | 231 | { |
213 | 232 | chat_floater->mPanel->setSpeaker(chat.mFromID, chat.mFromName, LLSpeaker::STATUS_NOT_IN_CHANNEL, LLSpeaker::SPEAKER_OBJECT); | |
214 | LLComboBox* chatter_combo = LLUICtrlFactory::getComboBoxByName(gFloaterChat,"chatter combobox"); | ||
215 | |||
216 | if(!chatter_combo) | ||
217 | { | ||
218 | return; | ||
219 | } | ||
220 | |||
221 | if (!chatter_combo->setCurrentByID(chat.mFromID)) | ||
222 | { | ||
223 | // if we have too many items... | ||
224 | if (chatter_combo->getItemCount() >= MAX_CHATTER_COUNT) | ||
225 | { | ||
226 | chatter_combo->remove(0); | ||
227 | } | ||
228 | |||
229 | LLMute mute(chat.mFromID, chat.mFromName); | ||
230 | if (chat.mSourceType == CHAT_SOURCE_OBJECT) | ||
231 | { | ||
232 | mute.mType = LLMute::OBJECT; | ||
233 | } | ||
234 | else if (chat.mSourceType == CHAT_SOURCE_AGENT) | ||
235 | { | ||
236 | mute.mType = LLMute::AGENT; | ||
237 | } | ||
238 | LLString item = mute.getDisplayName(); | ||
239 | chatter_combo->add(item, chat.mFromID); | ||
240 | chatter_combo->setCurrentByIndex(chatter_combo->getItemCount() - 1); | ||
241 | gFloaterChat->childSetEnabled("Mute resident",TRUE); | ||
242 | } | ||
243 | } | 233 | } |
244 | } | 234 | } |
245 | 235 | ||
246 | // static | 236 | // static |
247 | void LLFloaterChat::setHistoryCursorAndScrollToEnd() | 237 | void LLFloaterChat::setHistoryCursorAndScrollToEnd() |
248 | { | 238 | { |
249 | if (gFloaterChat) | 239 | LLViewerTextEditor* history_editor = (LLViewerTextEditor*)LLFloaterChat::getInstance(LLSD())->getChildByName("Chat History Editor", TRUE); |
250 | { | 240 | LLViewerTextEditor* history_editor_with_mute = (LLViewerTextEditor*)LLFloaterChat::getInstance(LLSD())->getChildByName("Chat History Editor with mute", TRUE); |
251 | LLViewerTextEditor* history_editor = (LLViewerTextEditor*)gFloaterChat->getChildByName("Chat History Editor"); | 241 | |
252 | LLViewerTextEditor* history_editor_with_mute = (LLViewerTextEditor*)gFloaterChat->getChildByName("Chat History Editor with mute"); | 242 | history_editor->setCursorAndScrollToEnd(); |
253 | 243 | history_editor_with_mute->setCursorAndScrollToEnd(); | |
254 | history_editor->setCursorAndScrollToEnd(); | ||
255 | history_editor_with_mute->setCursorAndScrollToEnd(); | ||
256 | } | ||
257 | } | ||
258 | |||
259 | |||
260 | // static | ||
261 | void LLFloaterChat::toggle(void*) | ||
262 | { | ||
263 | if (gFloaterChat->getVisible()) | ||
264 | { | ||
265 | gFloaterChat->close(); | ||
266 | } | ||
267 | else | ||
268 | { | ||
269 | gFloaterChat->show(); | ||
270 | } | ||
271 | } | 244 | } |
272 | 245 | ||
273 | // static | ||
274 | BOOL LLFloaterChat::visible(void*) | ||
275 | { | ||
276 | return (gFloaterChat && gFloaterChat->getVisible()); | ||
277 | } | ||
278 | 246 | ||
279 | //static | 247 | //static |
280 | void LLFloaterChat::onClickMute(void *data) | 248 | void LLFloaterChat::onClickMute(void *data) |
@@ -299,30 +267,6 @@ void LLFloaterChat::onClickMute(void *data) | |||
299 | } | 267 | } |
300 | 268 | ||
301 | //static | 269 | //static |
302 | void LLFloaterChat::onClickChat(void*) | ||
303 | { | ||
304 | // we need this function as a level of indirection because otherwise startChat would | ||
305 | // cast the data pointer to a character string, and dump garbage in the chat | ||
306 | LLChatBar::startChat(NULL); | ||
307 | } | ||
308 | |||
309 | //static | ||
310 | void LLFloaterChat::onCommitUserSelect(LLUICtrl* caller, void* data) | ||
311 | { | ||
312 | LLFloaterChat* floater = (LLFloaterChat*)data; | ||
313 | LLComboBox* combo = (LLComboBox*)caller; | ||
314 | |||
315 | if (combo->getCurrentIndex() == -1) | ||
316 | { | ||
317 | floater->childSetEnabled("Mute resident",FALSE); | ||
318 | } | ||
319 | else | ||
320 | { | ||
321 | floater->childSetEnabled("Mute resident",TRUE); | ||
322 | } | ||
323 | } | ||
324 | |||
325 | //static | ||
326 | void LLFloaterChat::onClickToggleShowMute(LLUICtrl* caller, void *data) | 270 | void LLFloaterChat::onClickToggleShowMute(LLUICtrl* caller, void *data) |
327 | { | 271 | { |
328 | LLFloaterChat* floater = (LLFloaterChat*)data; | 272 | LLFloaterChat* floater = (LLFloaterChat*)data; |
@@ -330,8 +274,8 @@ void LLFloaterChat::onClickToggleShowMute(LLUICtrl* caller, void *data) | |||
330 | 274 | ||
331 | //LLCheckBoxCtrl* | 275 | //LLCheckBoxCtrl* |
332 | BOOL show_mute = LLUICtrlFactory::getCheckBoxByName(floater,"show mutes")->get(); | 276 | BOOL show_mute = LLUICtrlFactory::getCheckBoxByName(floater,"show mutes")->get(); |
333 | LLViewerTextEditor* history_editor = (LLViewerTextEditor*)floater->getChildByName("Chat History Editor"); | 277 | LLViewerTextEditor* history_editor = (LLViewerTextEditor*)floater->getChildByName("Chat History Editor", TRUE); |
334 | LLViewerTextEditor* history_editor_with_mute = (LLViewerTextEditor*)floater->getChildByName("Chat History Editor with mute"); | 278 | LLViewerTextEditor* history_editor_with_mute = (LLViewerTextEditor*)floater->getChildByName("Chat History Editor with mute", TRUE); |
335 | 279 | ||
336 | if (!history_editor || !history_editor_with_mute) | 280 | if (!history_editor || !history_editor_with_mute) |
337 | return; | 281 | return; |
@@ -447,7 +391,7 @@ LLColor4 get_text_color(const LLChat& chat) | |||
447 | //static | 391 | //static |
448 | void LLFloaterChat::loadHistory() | 392 | void LLFloaterChat::loadHistory() |
449 | { | 393 | { |
450 | LLLogChat::loadHistory("chat", &chatFromLogFile, (void *)gFloaterChat); | 394 | LLLogChat::loadHistory("chat", &chatFromLogFile, (void *)LLFloaterChat::getInstance(LLSD())); |
451 | } | 395 | } |
452 | 396 | ||
453 | //static | 397 | //static |
@@ -458,3 +402,40 @@ void LLFloaterChat::chatFromLogFile(LLString line, void* userdata) | |||
458 | chat.mText = line; | 402 | chat.mText = line; |
459 | addChatHistory(chat, FALSE); | 403 | addChatHistory(chat, FALSE); |
460 | } | 404 | } |
405 | |||
406 | //static | ||
407 | void* LLFloaterChat::createSpeakersPanel(void* data) | ||
408 | { | ||
409 | return new LLPanelActiveSpeakers(gLocalSpeakerMgr, TRUE); | ||
410 | } | ||
411 | |||
412 | //static | ||
413 | void* LLFloaterChat::createChatPanel(void* data) | ||
414 | { | ||
415 | LLChatBar* chatp = new LLChatBar("floating_chat_bar"); | ||
416 | return chatp; | ||
417 | } | ||
418 | |||
419 | //static | ||
420 | void LLFloaterChat::hideInstance(const LLSD& id) | ||
421 | { | ||
422 | LLFloaterChat* floaterp = LLFloaterChat::getInstance(LLSD()); | ||
423 | // don't do anything when hosted in the chatterbox | ||
424 | if(floaterp->getHost()) | ||
425 | { | ||
426 | LLFloaterChatterBox::hideInstance(LLSD()); | ||
427 | } | ||
428 | else | ||
429 | { | ||
430 | LLUISingleton<LLFloaterChat>::hideInstance(id); | ||
431 | } | ||
432 | } | ||
433 | |||
434 | // static | ||
435 | void LLFloaterChat::onClickToggleActiveSpeakers(void* userdata) | ||
436 | { | ||
437 | LLFloaterChat* self = (LLFloaterChat*)userdata; | ||
438 | |||
439 | self->childSetVisible("active_speakers_panel", !self->childIsVisible("active_speakers_panel")); | ||
440 | } | ||
441 | |||