Annotation of /trunk/indra/newview/llfloaterchat.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llfloaterchat.cpp | ||
| 3 : | * @brief LLFloaterChat class implementation | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2002-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | /** | ||
| 34 : | * Actually the "Chat History" floater. | ||
| 35 : | * Should be llfloaterchathistory, not llfloaterchat. | ||
| 36 : | */ | ||
| 37 : | |||
| 38 : | #include "llviewerprecompiledheaders.h" | ||
| 39 : | |||
| 40 : | #include "llfloaterchat.h" | ||
| 41 : | #include "llfloateractivespeakers.h" | ||
| 42 : | #include "llfloaterscriptdebug.h" | ||
| 43 : | |||
| 44 : | #include "llchat.h" | ||
| 45 : | #include "llfontgl.h" | ||
| 46 : | #include "llrect.h" | ||
| 47 : | #include "llerror.h" | ||
| 48 : | #include "llstring.h" | ||
| 49 : | #include "message.h" | ||
| 50 : | |||
| 51 : | // project include | ||
| 52 : | #include "llagent.h" | ||
| 53 : | #include "llbutton.h" | ||
| 54 : | #include "llcheckboxctrl.h" | ||
| 55 : | #include "llcombobox.h" | ||
| 56 : | #include "llconsole.h" | ||
| 57 : | #include "llfloaterchatterbox.h" | ||
| 58 : | #include "llfloatermute.h" | ||
| 59 : | #include "llkeyboard.h" | ||
| 60 : | //#include "lllineeditor.h" | ||
| 61 : | #include "llmutelist.h" | ||
| 62 : | //#include "llresizehandle.h" | ||
| 63 : | #include "llchatbar.h" | ||
| 64 : | #include "llstatusbar.h" | ||
| 65 : | #include "llviewertexteditor.h" | ||
| 66 : | #include "llviewergesture.h" | ||
| 67 : | #include "llviewermessage.h" | ||
| 68 : | #include "llviewerwindow.h" | ||
| 69 : | #include "llviewercontrol.h" | ||
| 70 : | #include "lluictrlfactory.h" | ||
| 71 : | #include "llchatbar.h" | ||
| 72 : | #include "lllogchat.h" | ||
| 73 : | #include "lltexteditor.h" | ||
| 74 : | #include "lltextparser.h" | ||
| 75 : | #include "llfloaterhtml.h" | ||
| 76 : | #include "llweb.h" | ||
| 77 : | #include "llstylemap.h" | ||
| 78 : | |||
| 79 : | // Used for LCD display | ||
| 80 : | extern void AddNewIMToLCD(const std::string &newLine); | ||
| 81 : | extern void AddNewChatToLCD(const std::string &newLine); | ||
| 82 : | // | ||
| 83 : | // Constants | ||
| 84 : | // | ||
| 85 : | const F32 INSTANT_MSG_SIZE = 8.0f; | ||
| 86 : | const F32 CHAT_MSG_SIZE = 8.0f; | ||
| 87 : | const LLColor4 MUTED_MSG_COLOR(0.5f, 0.5f, 0.5f, 1.f); | ||
| 88 : | const S32 MAX_CHATTER_COUNT = 16; | ||
| 89 : | |||
| 90 : | // | ||
| 91 : | // Global statics | ||
| 92 : | // | ||
| 93 : | LLColor4 get_text_color(const LLChat& chat); | ||
| 94 : | |||
| 95 : | // | ||
| 96 : | // Member Functions | ||
| 97 : | // | ||
| 98 : | LLFloaterChat::LLFloaterChat(const LLSD& seed) | ||
| 99 : | : LLFloater(std::string("chat floater"), std::string("FloaterChatRect"), LLStringUtil::null, | ||
| 100 : | RESIZE_YES, 440, 100, DRAG_ON_TOP, MINIMIZE_NO, CLOSE_YES), | ||
| 101 : | mPanel(NULL) | ||
| 102 : | { | ||
| 103 : | mFactoryMap["chat_panel"] = LLCallbackMap(createChatPanel, NULL); | ||
| 104 : | mFactoryMap["active_speakers_panel"] = LLCallbackMap(createSpeakersPanel, NULL); | ||
| 105 : | // do not automatically open singleton floaters (as result of getInstance()) | ||
| 106 : | BOOL no_open = FALSE; | ||
| 107 : | if (gSavedSettings.getBOOL("UseOldChatHistory")) | ||
| 108 : | { | ||
| 109 : | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_chat_history2.xml",&getFactoryMap(),no_open); | ||
| 110 : | } | ||
| 111 : | else | ||
| 112 : | { | ||
| 113 : | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_chat_history.xml",&getFactoryMap(),no_open); | ||
| 114 : | } | ||
| 115 : | |||
| 116 : | childSetCommitCallback("show mutes",onClickToggleShowMute,this); //show mutes | ||
| 117 : | childSetVisible("Chat History Editor with mute",FALSE); | ||
| 118 : | childSetAction("toggle_active_speakers_btn", onClickToggleActiveSpeakers, this); | ||
| 119 : | setDefaultBtn("Chat"); | ||
| 120 : | } | ||
| 121 : | |||
| 122 : | LLFloaterChat::~LLFloaterChat() | ||
| 123 : | { | ||
| 124 : | // Children all cleaned up by default view destructor. | ||
| 125 : | } | ||
| 126 : | |||
| 127 : | void LLFloaterChat::setVisible(BOOL visible) | ||
| 128 : | { | ||
| 129 : | LLFloater::setVisible( visible ); | ||
| 130 : | |||
| 131 : | gSavedSettings.setBOOL("ShowChatHistory", visible); | ||
| 132 : | } | ||
| 133 : | |||
| 134 : | void LLFloaterChat::draw() | ||
| 135 : | { | ||
| 136 : | // enable say and shout only when text available | ||
| 137 : | |||
| 138 : | childSetValue("toggle_active_speakers_btn", childIsVisible("active_speakers_panel")); | ||
| 139 : | |||
| 140 : | LLChatBar* chat_barp = getChild<LLChatBar>("chat_panel", TRUE); | ||
| 141 : | if (chat_barp) | ||
| 142 : | { | ||
| 143 : | chat_barp->refresh(); | ||
| 144 : | } | ||
| 145 : | |||
| 146 : | mPanel->refreshSpeakers(); | ||
| 147 : | LLFloater::draw(); | ||
| 148 : | } | ||
| 149 : | |||
| 150 : | BOOL LLFloaterChat::postBuild() | ||
| 151 : | { | ||
| 152 : | mPanel = (LLPanelActiveSpeakers*)getChild<LLPanel>("active_speakers_panel"); | ||
| 153 : | |||
| 154 : | LLChatBar* chat_barp = getChild<LLChatBar>("chat_panel", TRUE); | ||
| 155 : | if (chat_barp) | ||
| 156 : | { | ||
| 157 : | chat_barp->setGestureCombo(getChild<LLComboBox>( "Gesture")); | ||
| 158 : | } | ||
| 159 : | return TRUE; | ||
| 160 : | } | ||
| 161 : | |||
| 162 : | // public virtual | ||
| 163 : | void LLFloaterChat::onClose(bool app_quitting) | ||
| 164 : | { | ||
| 165 : | if (!app_quitting) | ||
| 166 : | { | ||
| 167 : | gSavedSettings.setBOOL("ShowChatHistory", FALSE); | ||
| 168 : | } | ||
| 169 : | setVisible(FALSE); | ||
| 170 : | } | ||
| 171 : | |||
| 172 : | void LLFloaterChat::onVisibilityChange(BOOL new_visibility) | ||
| 173 : | { | ||
| 174 : | // Hide the chat overlay when our history is visible. | ||
| 175 : | updateConsoleVisibility(); | ||
| 176 : | |||
| 177 : | // stop chat history tab from flashing when it appears | ||
| 178 : | if (new_visibility) | ||
| 179 : | { | ||
| 180 : | LLFloaterChatterBox::getInstance()->setFloaterFlashing(this, FALSE); | ||
| 181 : | } | ||
| 182 : | |||
| 183 : | LLFloater::onVisibilityChange(new_visibility); | ||
| 184 : | } | ||
| 185 : | |||
| 186 : | void LLFloaterChat::setMinimized(BOOL minimized) | ||
| 187 : | { | ||
| 188 : | LLFloater::setMinimized(minimized); | ||
| 189 : | updateConsoleVisibility(); | ||
| 190 : | } | ||
| 191 : | |||
| 192 : | |||
| 193 : | void LLFloaterChat::updateConsoleVisibility() | ||
| 194 : | { | ||
| 195 : | // determine whether we should show console due to not being visible | ||
| 196 : | gConsole->setVisible( !isInVisibleChain() // are we not in part of UI being drawn? | ||
| 197 : | || isMinimized() // are we minimized? | ||
| 198 : | || (getHost() && getHost()->isMinimized() )); // are we hosted in a minimized floater? | ||
| 199 : | } | ||
| 200 : | |||
| 201 : | void add_timestamped_line(LLViewerTextEditor* edit, LLChat chat, const LLColor4& color) | ||
| 202 : | { | ||
| 203 : | std::string line = chat.mText; | ||
| 204 : | bool prepend_newline = true; | ||
| 205 : | if (gSavedSettings.getBOOL("ChatShowTimestamps")) | ||
| 206 : | { | ||
| 207 : | edit->appendTime(prepend_newline); | ||
| 208 : | prepend_newline = false; | ||
| 209 : | } | ||
| 210 : | |||
| 211 : | // If the msg is from an agent (not yourself though), | ||
| 212 : | // extract out the sender name and replace it with the hotlinked name. | ||
| 213 : | if (chat.mSourceType == CHAT_SOURCE_AGENT && | ||
| 214 : | chat.mFromID != LLUUID::null) | ||
| 215 : | { | ||
| 216 : | chat.mURL = llformat("secondlife:///app/agent/%s/about",chat.mFromID.asString().c_str()); | ||
| 217 : | } | ||
| 218 : | |||
| 219 : | // If the chat line has an associated url, link it up to the name. | ||
| 220 : | if (!chat.mURL.empty() | ||
| 221 : | && (line.length() > chat.mFromName.length() && line.find(chat.mFromName,0) == 0)) | ||
| 222 : | { | ||
| 223 : | //MK | ||
| 224 : | if (!gRRenabled || !gAgent.mRRInterface.mContainsShownames) | ||
| 225 : | { | ||
| 226 : | //mk | ||
| 227 : | std::string start_line = line.substr(0, chat.mFromName.length() + 1); | ||
| 228 : | line = line.substr(chat.mFromName.length() + 1); | ||
| 229 : | const LLStyleSP &sourceStyle = LLStyleMap::instance().lookup(chat.mFromID,chat.mURL); | ||
| 230 : | edit->appendStyledText(start_line, false, prepend_newline, sourceStyle); | ||
| 231 : | prepend_newline = false; | ||
| 232 : | //MK | ||
| 233 : | } | ||
| 234 : | //mk | ||
| 235 : | } | ||
| 236 : | edit->appendColoredText(line, false, prepend_newline, color); | ||
| 237 : | } | ||
| 238 : | |||
| 239 : | void log_chat_text(const LLChat& chat) | ||
| 240 : | { | ||
| 241 : | std::string histstr; | ||
| 242 : | if (gSavedPerAccountSettings.getBOOL("LogChatTimestamp")) | ||
| 243 : | histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + chat.mText; | ||
| 244 : | else | ||
| 245 : | histstr = chat.mText; | ||
| 246 : | |||
| 247 : | LLLogChat::saveHistory(std::string("chat"),histstr); | ||
| 248 : | } | ||
| 249 : | // static | ||
| 250 : | void LLFloaterChat::addChatHistory(const LLChat& chat, bool log_to_file) | ||
| 251 : | { | ||
| 252 : | if ( gSavedPerAccountSettings.getBOOL("LogChat") && log_to_file) | ||
| 253 : | { | ||
| 254 : | log_chat_text(chat); | ||
| 255 : | } | ||
| 256 : | |||
| 257 : | LLColor4 color = get_text_color(chat); | ||
| 258 : | |||
| 259 : | if (!log_to_file) color = LLColor4::grey; //Recap from log file. | ||
| 260 : | |||
| 261 : | if (chat.mChatType == CHAT_TYPE_DEBUG_MSG) | ||
| 262 : | { | ||
| 263 : | LLFloaterScriptDebug::addScriptLine(chat.mText, | ||
| 264 : | chat.mFromName, | ||
| 265 : | color, | ||
| 266 : | chat.mFromID); | ||
| 267 : | if (!gSavedSettings.getBOOL("ScriptErrorsAsChat")) | ||
| 268 : | { | ||
| 269 : | return; | ||
| 270 : | } | ||
| 271 : | } | ||
| 272 : | |||
| 273 : | // could flash the chat button in the status bar here. JC | ||
| 274 : | LLFloaterChat* chat_floater = LLFloaterChat::getInstance(LLSD()); | ||
| 275 : | LLViewerTextEditor* history_editor = chat_floater->getChild<LLViewerTextEditor>("Chat History Editor"); | ||
| 276 : | LLViewerTextEditor* history_editor_with_mute = chat_floater->getChild<LLViewerTextEditor>("Chat History Editor with mute"); | ||
| 277 : | |||
| 278 : | history_editor->setParseHTML(TRUE); | ||
| 279 : | history_editor_with_mute->setParseHTML(TRUE); | ||
| 280 : | |||
| 281 : | history_editor->setParseHighlights(TRUE); | ||
| 282 : | history_editor_with_mute->setParseHighlights(TRUE); | ||
| 283 : | |||
| 284 : | if (!chat.mMuted) | ||
| 285 : | { | ||
| 286 : | add_timestamped_line(history_editor, chat, color); | ||
| 287 : | add_timestamped_line(history_editor_with_mute, chat, color); | ||
| 288 : | } | ||
| 289 : | else | ||
| 290 : | { | ||
| 291 : | // desaturate muted chat | ||
| 292 : | LLColor4 muted_color = lerp(color, LLColor4::grey, 0.5f); | ||
| 293 : | add_timestamped_line(history_editor_with_mute, chat, color); | ||
| 294 : | } | ||
| 295 : | |||
| 296 : | // add objects as transient speakers that can be muted | ||
| 297 : | if (chat.mSourceType == CHAT_SOURCE_OBJECT) | ||
| 298 : | { | ||
| 299 : | chat_floater->mPanel->setSpeaker(chat.mFromID, chat.mFromName, LLSpeaker::STATUS_NOT_IN_CHANNEL, LLSpeaker::SPEAKER_OBJECT); | ||
| 300 : | } | ||
| 301 : | |||
| 302 : | // start tab flashing on incoming text from other users (ignoring system text, etc) | ||
| 303 : | if (!chat_floater->isInVisibleChain() && chat.mSourceType == CHAT_SOURCE_AGENT) | ||
| 304 : | { | ||
| 305 : | LLFloaterChatterBox::getInstance()->setFloaterFlashing(chat_floater, TRUE); | ||
| 306 : | } | ||
| 307 : | } | ||
| 308 : | |||
| 309 : | // static | ||
| 310 : | void LLFloaterChat::setHistoryCursorAndScrollToEnd() | ||
| 311 : | { | ||
| 312 : | LLViewerTextEditor* history_editor = LLFloaterChat::getInstance(LLSD())->getChild<LLViewerTextEditor>("Chat History Editor"); | ||
| 313 : | LLViewerTextEditor* history_editor_with_mute = LLFloaterChat::getInstance(LLSD())->getChild<LLViewerTextEditor>("Chat History Editor with mute"); | ||
| 314 : | |||
| 315 : | if (history_editor) | ||
| 316 : | { | ||
| 317 : | history_editor->setCursorAndScrollToEnd(); | ||
| 318 : | } | ||
| 319 : | if (history_editor_with_mute) | ||
| 320 : | { | ||
| 321 : | history_editor_with_mute->setCursorAndScrollToEnd(); | ||
| 322 : | } | ||
| 323 : | } | ||
| 324 : | |||
| 325 : | |||
| 326 : | //static | ||
| 327 : | void LLFloaterChat::onClickMute(void *data) | ||
| 328 : | { | ||
| 329 : | LLFloaterChat* self = (LLFloaterChat*)data; | ||
| 330 : | |||
| 331 : | LLComboBox* chatter_combo = self->getChild<LLComboBox>("chatter combobox"); | ||
| 332 : | |||
| 333 : | const std::string& name = chatter_combo->getSimple(); | ||
| 334 : | LLUUID id = chatter_combo->getCurrentID(); | ||
| 335 : | |||
| 336 : | if (name.empty()) return; | ||
| 337 : | |||
| 338 : | LLMute mute(id); | ||
| 339 : | mute.setFromDisplayName(name); | ||
| 340 : | LLMuteList::getInstance()->add(mute); | ||
| 341 : | |||
| 342 : | LLFloaterMute::showInstance(); | ||
| 343 : | } | ||
| 344 : | |||
| 345 : | //static | ||
| 346 : | void LLFloaterChat::onClickToggleShowMute(LLUICtrl* caller, void *data) | ||
| 347 : | { | ||
| 348 : | LLFloaterChat* floater = (LLFloaterChat*)data; | ||
| 349 : | |||
| 350 : | |||
| 351 : | //LLCheckBoxCtrl* | ||
| 352 : | BOOL show_mute = floater->getChild<LLCheckBoxCtrl>("show mutes")->get(); | ||
| 353 : | LLViewerTextEditor* history_editor = floater->getChild<LLViewerTextEditor>("Chat History Editor"); | ||
| 354 : | LLViewerTextEditor* history_editor_with_mute = floater->getChild<LLViewerTextEditor>("Chat History Editor with mute"); | ||
| 355 : | |||
| 356 : | if (!history_editor || !history_editor_with_mute) | ||
| 357 : | return; | ||
| 358 : | |||
| 359 : | //BOOL show_mute = floater->mShowMuteCheckBox->get(); | ||
| 360 : | if (show_mute) | ||
| 361 : | { | ||
| 362 : | history_editor->setVisible(FALSE); | ||
| 363 : | history_editor_with_mute->setVisible(TRUE); | ||
| 364 : | history_editor_with_mute->setCursorAndScrollToEnd(); | ||
| 365 : | } | ||
| 366 : | else | ||
| 367 : | { | ||
| 368 : | history_editor->setVisible(TRUE); | ||
| 369 : | history_editor_with_mute->setVisible(FALSE); | ||
| 370 : | history_editor->setCursorAndScrollToEnd(); | ||
| 371 : | } | ||
| 372 : | } | ||
| 373 : | |||
| 374 : | // Put a line of chat in all the right places | ||
| 375 : | void LLFloaterChat::addChat(const LLChat& chat, | ||
| 376 : | BOOL from_instant_message, | ||
| 377 : | BOOL local_agent) | ||
| 378 : | { | ||
| 379 : | LLColor4 text_color = get_text_color(chat); | ||
| 380 : | |||
| 381 : | BOOL invisible_script_debug_chat = | ||
| 382 : | chat.mChatType == CHAT_TYPE_DEBUG_MSG | ||
| 383 : | && !gSavedSettings.getBOOL("ScriptErrorsAsChat"); | ||
| 384 : | |||
| 385 : | #if LL_LCD_COMPILE | ||
| 386 : | // add into LCD displays | ||
| 387 : | if (!invisible_script_debug_chat) | ||
| 388 : | { | ||
| 389 : | if (!from_instant_message) | ||
| 390 : | { | ||
| 391 : | AddNewChatToLCD(chat.mText); | ||
| 392 : | } | ||
| 393 : | else | ||
| 394 : | { | ||
| 395 : | AddNewIMToLCD(chat.mText); | ||
| 396 : | } | ||
| 397 : | } | ||
| 398 : | #endif | ||
| 399 : | if (!invisible_script_debug_chat | ||
| 400 : | && !chat.mMuted | ||
| 401 : | && gConsole | ||
| 402 : | && !local_agent) | ||
| 403 : | { | ||
| 404 : | F32 size = CHAT_MSG_SIZE; | ||
| 405 : | if (chat.mSourceType == CHAT_SOURCE_SYSTEM) | ||
| 406 : | { | ||
| 407 : | text_color = gSavedSettings.getColor("SystemChatColor"); | ||
| 408 : | } | ||
| 409 : | else if(from_instant_message) | ||
| 410 : | { | ||
| 411 : | text_color = gSavedSettings.getColor("IMChatColor"); | ||
| 412 : | size = INSTANT_MSG_SIZE; | ||
| 413 : | } | ||
| 414 : | // We display anything if it's not an IM. If it's an IM, check pref... | ||
| 415 : | if ( !from_instant_message || gSavedSettings.getBOOL("IMInChatConsole") ) | ||
| 416 : | { | ||
| 417 : | gConsole->addLine(chat.mText, size, text_color); | ||
| 418 : | } | ||
| 419 : | } | ||
| 420 : | |||
| 421 : | if(from_instant_message && gSavedPerAccountSettings.getBOOL("LogChatIM")) | ||
| 422 : | log_chat_text(chat); | ||
| 423 : | |||
| 424 : | if(from_instant_message && gSavedSettings.getBOOL("IMInChatHistory")) | ||
| 425 : | addChatHistory(chat,false); | ||
| 426 : | |||
| 427 : | LLTextParser* highlight = LLTextParser::getInstance(); | ||
| 428 : | highlight->triggerAlerts(gAgent.getID(), gAgent.getPositionGlobal(), chat.mText, gViewerWindow->getWindow()); | ||
| 429 : | |||
| 430 : | if(!from_instant_message) | ||
| 431 : | addChatHistory(chat); | ||
| 432 : | } | ||
| 433 : | |||
| 434 : | LLColor4 get_text_color(const LLChat& chat) | ||
| 435 : | { | ||
| 436 : | LLColor4 text_color; | ||
| 437 : | |||
| 438 : | if(chat.mMuted) | ||
| 439 : | { | ||
| 440 : | text_color.setVec(0.8f, 0.8f, 0.8f, 1.f); | ||
| 441 : | } | ||
| 442 : | else | ||
| 443 : | { | ||
| 444 : | switch(chat.mSourceType) | ||
| 445 : | { | ||
| 446 : | case CHAT_SOURCE_SYSTEM: | ||
| 447 : | text_color = gSavedSettings.getColor4("SystemChatColor"); | ||
| 448 : | break; | ||
| 449 : | case CHAT_SOURCE_AGENT: | ||
| 450 : | if (chat.mFromID.isNull()) | ||
| 451 : | { | ||
| 452 : | text_color = gSavedSettings.getColor4("SystemChatColor"); | ||
| 453 : | } | ||
| 454 : | else | ||
| 455 : | { | ||
| 456 : | if(gAgent.getID() == chat.mFromID) | ||
| 457 : | { | ||
| 458 : | text_color = gSavedSettings.getColor4("UserChatColor"); | ||
| 459 : | } | ||
| 460 : | else | ||
| 461 : | { | ||
| 462 : | text_color = gSavedSettings.getColor4("AgentChatColor"); | ||
| 463 : | } | ||
| 464 : | } | ||
| 465 : | break; | ||
| 466 : | case CHAT_SOURCE_OBJECT: | ||
| 467 : | if (chat.mChatType == CHAT_TYPE_DEBUG_MSG) | ||
| 468 : | { | ||
| 469 : | text_color = gSavedSettings.getColor4("ScriptErrorColor"); | ||
| 470 : | } | ||
| 471 : | else if ( chat.mChatType == CHAT_TYPE_OWNER ) | ||
| 472 : | { | ||
| 473 : | text_color = gSavedSettings.getColor4("llOwnerSayChatColor"); | ||
| 474 : | } | ||
| 475 : | else | ||
| 476 : | { | ||
| 477 : | text_color = gSavedSettings.getColor4("ObjectChatColor"); | ||
| 478 : | } | ||
| 479 : | break; | ||
| 480 : | default: | ||
| 481 : | text_color.setToWhite(); | ||
| 482 : | } | ||
| 483 : | |||
| 484 : | if (!chat.mPosAgent.isExactlyZero()) | ||
| 485 : | { | ||
| 486 : | LLVector3 pos_agent = gAgent.getPositionAgent(); | ||
| 487 : | F32 distance = dist_vec(pos_agent, chat.mPosAgent); | ||
| 488 : | if (distance > gAgent.getNearChatRadius()) | ||
| 489 : | { | ||
| 490 : | // diminish far-off chat | ||
| 491 : | text_color.mV[VALPHA] = 0.8f; | ||
| 492 : | } | ||
| 493 : | } | ||
| 494 : | } | ||
| 495 : | |||
| 496 : | return text_color; | ||
| 497 : | } | ||
| 498 : | |||
| 499 : | //static | ||
| 500 : | void LLFloaterChat::loadHistory() | ||
| 501 : | { | ||
| 502 : | LLLogChat::loadHistory(std::string("chat"), &chatFromLogFile, (void *)LLFloaterChat::getInstance(LLSD())); | ||
| 503 : | } | ||
| 504 : | |||
| 505 : | //static | ||
| 506 : | void LLFloaterChat::chatFromLogFile(LLLogChat::ELogLineType type , std::string line, void* userdata) | ||
| 507 : | { | ||
| 508 : | switch (type) | ||
| 509 : | { | ||
| 510 : | case LLLogChat::LOG_EMPTY: | ||
| 511 : | case LLLogChat::LOG_END: | ||
| 512 : | // *TODO: nice message from XML file here | ||
| 513 : | break; | ||
| 514 : | case LLLogChat::LOG_LINE: | ||
| 515 : | { | ||
| 516 : | LLChat chat; | ||
| 517 : | chat.mText = line; | ||
| 518 : | addChatHistory(chat, FALSE); | ||
| 519 : | } | ||
| 520 : | break; | ||
| 521 : | default: | ||
| 522 : | // nothing | ||
| 523 : | break; | ||
| 524 : | } | ||
| 525 : | } | ||
| 526 : | |||
| 527 : | //static | ||
| 528 : | void* LLFloaterChat::createSpeakersPanel(void* data) | ||
| 529 : | { | ||
| 530 : | return new LLPanelActiveSpeakers(LLLocalSpeakerMgr::getInstance(), TRUE); | ||
| 531 : | } | ||
| 532 : | |||
| 533 : | //static | ||
| 534 : | void* LLFloaterChat::createChatPanel(void* data) | ||
| 535 : | { | ||
| 536 : | LLChatBar* chatp = new LLChatBar("floating_chat_bar"); | ||
| 537 : | return chatp; | ||
| 538 : | } | ||
| 539 : | |||
| 540 : | // static | ||
| 541 : | void LLFloaterChat::onClickToggleActiveSpeakers(void* userdata) | ||
| 542 : | { | ||
| 543 : | LLFloaterChat* self = (LLFloaterChat*)userdata; | ||
| 544 : | //MK | ||
| 545 : | if (gRRenabled && gAgent.mRRInterface.mContainsShownames) | ||
| 546 : | { | ||
| 547 : | if (!self->childIsVisible("active_speakers_panel")) return; | ||
| 548 : | } | ||
| 549 : | //mk | ||
| 550 : | self->childSetVisible("active_speakers_panel", !self->childIsVisible("active_speakers_panel")); | ||
| 551 : | } | ||
| 552 : | |||
| 553 : | //static | ||
| 554 : | bool LLFloaterChat::visible(LLFloater* instance, const LLSD& key) | ||
| 555 : | { | ||
| 556 : | return VisibilityPolicy<LLFloater>::visible(instance, key); | ||
| 557 : | } | ||
| 558 : | |||
| 559 : | //static | ||
| 560 : | void LLFloaterChat::show(LLFloater* instance, const LLSD& key) | ||
| 561 : | { | ||
| 562 : | VisibilityPolicy<LLFloater>::show(instance, key); | ||
| 563 : | } | ||
| 564 : | |||
| 565 : | //static | ||
| 566 : | void LLFloaterChat::hide(LLFloater* instance, const LLSD& key) | ||
| 567 : | { | ||
| 568 : | if(instance->getHost()) | ||
| 569 : | { | ||
| 570 : | LLFloaterChatterBox::hideInstance(); | ||
| 571 : | } | ||
| 572 : | else | ||
| 573 : | { | ||
| 574 : | VisibilityPolicy<LLFloater>::hide(instance, key); | ||
| 575 : | } | ||
| 576 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

