diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index e2e0efee10..a5fb5387a1 100755 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -63,7 +63,8 @@ LLConsole::LLConsole(const LLConsole::Params& p) mFont(p.font), mConsoleWidth(0), mConsoleHeight(0), - mParseUrls(p.parse_urls) // If lines should be parsed for URLs + mParseUrls(p.parse_urls), // If lines should be parsed for URLs + mSessionSupport(p.session_support) // Session support { if (p.font_size_index.isProvided()) { @@ -174,6 +175,11 @@ void LLConsole::draw() return; } + // Session support + if (!mSessionSupport) + { + // This is done in update() if session support is enabled + // U32 num_lines=0; paragraph_t::reverse_iterator paragraph_it; @@ -196,6 +202,9 @@ void LLConsole::draw() paragraph_num--; paragraph_it++; } + // Session support + } + // if (mParagraphs.empty()) { @@ -267,6 +276,7 @@ void LLConsole::draw() // y_pos += padding_vertical; //} + paragraph_t::reverse_iterator paragraph_it; static LLCachedControl consoleBackgroundOpacity(*LLUI::sSettingGroups["config"], "ConsoleBackgroundOpacity"); static LLUIColor cbcolor = LLUIColorTable::instance().getColor("ConsoleBackground"); LLColor4 color = cbcolor.get(); @@ -280,17 +290,49 @@ void LLConsole::draw() static const F32 padding_vert = 5; S32 total_width = 0; S32 total_height = 0; + S32 lines_drawn = 0; paragraph_t::reverse_iterator paragraphs_end = mParagraphs.rend(); for (paragraph_it = mParagraphs.rbegin(); paragraph_it != paragraphs_end; ++paragraph_it) { + if (mSessionSupport) + { + // Skip paragraph if visible in floater and make sure we don't + // exceed the maximum number of lines we want to display + if (mCurrentSessions.find((*paragraph_it).mSessionID) != mCurrentSessions.end()) + { + continue; + } + lines_drawn += (*paragraph_it).mLines.size(); + if (lines_drawn > mMaxLines) + { + break; + } + } + total_height += llfloor( (*paragraph_it).mLines.size() * line_height + padding_vert); total_width = llmax(total_width, llfloor( (*paragraph_it).mMaxWidth + padding_horizontal)); } mBackgroundImage->drawSolid(-14, (S32)(y_pos + line_height / 2), total_width, total_height + (line_height - padding_vert) / 2, color); + lines_drawn = 0; for (paragraph_it = mParagraphs.rbegin(); paragraph_it != paragraphs_end; ++paragraph_it) { + if (mSessionSupport) + { + // Skip paragraph if visible in floater and make sure we don't + // exceed the maximum number of lines we want to display + if (mCurrentSessions.find((*paragraph_it).mSessionID) != mCurrentSessions.end()) + { + continue; + } + lines_drawn += (*paragraph_it).mLines.size(); + if (lines_drawn > mMaxLines) + { + break; + } + } + F32 y_off=0; F32 alpha; S32 target_width = llfloor( (*paragraph_it).mMaxWidth + padding_horizontal); @@ -339,9 +381,26 @@ void LLConsole::draw() } else { + S32 lines_drawn = 0; + paragraph_t::reverse_iterator paragraphs_end = mParagraphs.rend(); for(paragraph_it = mParagraphs.rbegin(); paragraph_it != paragraphs_end; paragraph_it++) { + if (mSessionSupport) + { + // Skip paragraph if visible in floater and make sure we don't + // exceed the maximum number of lines we want to display + if (mCurrentSessions.find((*paragraph_it).mSessionID) != mCurrentSessions.end()) + { + continue; + } + lines_drawn += (*paragraph_it).mLines.size(); + if (lines_drawn > mMaxLines) + { + break; + } + } + S32 target_height = llfloor( (*paragraph_it).mLines.size() * line_height + padding_vertical); S32 target_width = llfloor( (*paragraph_it).mMaxWidth + padding_horizontal); @@ -397,20 +456,23 @@ void LLConsole::draw() } // Chat console -void LLConsole::addConsoleLine(const std::string& utf8line, const LLColor4 &color, LLFontGL::StyleFlags styleflags) +void LLConsole::addConsoleLine(const std::string& utf8line, const LLColor4 &color, const LLUUID& session_id, LLFontGL::StyleFlags styleflags) { LLWString wline = utf8str_to_wstring(utf8line); - addConsoleLine(wline, color, styleflags); + addConsoleLine(wline, color, session_id, styleflags); } -void LLConsole::addConsoleLine(const LLWString& wline, const LLColor4 &color, LLFontGL::StyleFlags styleflags) +void LLConsole::addConsoleLine(const LLWString& wline, const LLColor4 &color, const LLUUID& session_id, LLFontGL::StyleFlags styleflags) { if (wline.empty()) { return; } - removeExtraLines(); + if (!mSessionSupport) + { + removeExtraLines(); + } mMutex.lock(); mLines.push_back(wline); @@ -418,6 +480,7 @@ void LLConsole::addConsoleLine(const LLWString& wline, const LLColor4 &color, LL mAddTimes.push_back(mTimer.getElapsedTimeF32()); mLineColors.push_back(color); mLineStyle.push_back(styleflags); + mSessionIDs.push_back(session_id); mMutex.unlock(); } @@ -430,6 +493,7 @@ void LLConsole::clear() mLineLengths.clear(); mLineColors.clear(); mLineStyle.clear(); + mSessionIDs.clear(); mMutex.unlock(); mTimer.reset(); @@ -580,11 +644,12 @@ void LLConsole::Paragraph::updateLines(F32 screen_width, const LLFontGL* font, L } //Pass in the string and the default color for this block of text. -// Added styleflags parameter for style customization +// Added styleflags parameter for style customization and session support //LLConsole::Paragraph::Paragraph (LLWString str, const LLColor4 &color, F32 add_time, const LLFontGL* font, F32 screen_width) -LLConsole::Paragraph::Paragraph (LLWString str, const LLColor4 &color, F32 add_time, const LLFontGL* font, F32 screen_width, LLFontGL::StyleFlags styleflags, bool parse_urls, LLConsole* console) +//: mParagraphText(str), mAddTime(add_time), mMaxWidth(-1) +LLConsole::Paragraph::Paragraph (LLWString str, const LLColor4 &color, F32 add_time, const LLFontGL* font, F32 screen_width, LLFontGL::StyleFlags styleflags, const LLUUID& session_id, bool parse_urls, LLConsole* console) +: mParagraphText(str), mAddTime(add_time), mMaxWidth(-1), mSessionID(session_id) // -: mParagraphText(str), mAddTime(add_time), mMaxWidth(-1) { // Parse SLURLs mSourceText = str; @@ -664,6 +729,7 @@ void LLConsole::updateClass() } } +static LLTrace::BlockTimerStatHandle FTM_CONSOLE_UPDATE_PARAGRAPHS("Update Console Paragraphs"); void LLConsole::update() { { @@ -687,6 +753,7 @@ void LLConsole::update() mFont, (F32)getRect().getWidth(), (!mLineStyle.empty() ? mLineStyle.front() : LLFontGL::NORMAL), + (!mSessionIDs.empty() ? mSessionIDs.front(): LLUUID::null), mParseUrls, this)); mLines.pop_front(); @@ -694,14 +761,55 @@ void LLConsole::update() mLineColors.pop_front(); if (!mLineStyle.empty()) mLineStyle.pop_front(); + if (!mSessionIDs.empty()) + mSessionIDs.pop_front(); // } } // remove old paragraphs which can't possibly be visible any more. ::draw() will do something similar but more conservative - we do this here because ::draw() isn't guaranteed to ever be called! (i.e. the console isn't visible) + // Session support + if (!mSessionSupport) + { + // while ((S32)mParagraphs.size() > llmax((S32)0, (S32)(mMaxLines))) { mParagraphs.pop_front(); } + // Session support + } + else + { + LL_RECORD_BLOCK_TIME(FTM_CONSOLE_UPDATE_PARAGRAPHS); + + // skip lines added more than mLinePersistTime ago + F32 skip_time = mTimer.getElapsedTimeF32() - mLinePersistTime; + + paragraph_t temp_para; + std::map session_map; + for (paragraph_t::reverse_iterator it = mParagraphs.rbegin(); it != mParagraphs.rend(); ++it) + { + Paragraph& para = *it; + session_map[para.mSessionID] += (S32)para.mLines.size(); + if (session_map[para.mSessionID] <= mMaxLines && // max lines on a per session basis + !((mLinePersistTime > 0.f) && (para.mAddTime - skip_time) / (mLinePersistTime - mFadeTime) <= 0.f)) // not expired yet + { + temp_para.push_front(para); + } + } + mParagraphs.swap(temp_para); + } + // } +// Session support +void LLConsole::addSession(const LLUUID& session_id) +{ + mCurrentSessions.insert(session_id); +} + +void LLConsole::removeSession(const LLUUID& session_id) +{ + mCurrentSessions.erase(session_id); +} +// diff --git a/indra/llui/llconsole.h b/indra/llui/llconsole.h index a16f849186..86f1ac87c3 100755 --- a/indra/llui/llconsole.h +++ b/indra/llui/llconsole.h @@ -52,13 +52,15 @@ public: Optional font_size_index; Optional parse_urls; // If lines should be parsed for URLs Optional background_image; // Configurable background for different console types + Optional session_support; // Session support Params() : max_lines("max_lines", LLUI::sSettingGroups["config"]->getS32("ConsoleMaxLines")), persist_time("persist_time", 0.f), // forever font_size_index("font_size_index"), parse_urls("parse_urls", false), // If lines should be parsed for URLs - background_image("background_image", "Console_Background") // Configurable background for different console types + background_image("background_image", "Console_Background"), // Configurable background for different console types + session_support("session_support", false) // Session support { changeDefault(mouse_opaque, false); } @@ -120,7 +122,7 @@ public: public: // Added styleflags parameter for style customization //Paragraph (LLWString str, const LLColor4 &color, F32 add_time, const LLFontGL* font, F32 screen_width); - Paragraph (LLWString str, const LLColor4 &color, F32 add_time, const LLFontGL* font, F32 screen_width, LLFontGL::StyleFlags styleflags, bool parse_urls, LLConsole* console); + Paragraph (LLWString str, const LLColor4 &color, F32 add_time, const LLFontGL* font, F32 screen_width, LLFontGL::StyleFlags styleflags, const LLUUID& session_id, bool parse_urls, LLConsole* console); // void makeParagraphColorSegments ( const LLColor4 &color); // Added styleflags parameter for style customization @@ -133,6 +135,7 @@ public: F32 mAddTime; //Time this paragraph was added to the display. F32 mMaxWidth; //Width of the widest line of text in this paragraph. lines_t mLines; + LLUUID mSessionID; // Session support // Parse SLURLs LLUUID mID; @@ -160,12 +163,15 @@ public: /*virtual*/ void draw(); // Chat console - void addConsoleLine(const std::string& utf8line, const LLColor4 &color, LLFontGL::StyleFlags styleflags = LLFontGL::NORMAL); - void addConsoleLine(const LLWString& wline, const LLColor4 &color, LLFontGL::StyleFlags styleflags = LLFontGL::NORMAL); + void addConsoleLine(const std::string& utf8line, const LLColor4 &color, const LLUUID& session_id = LLUUID::null, LLFontGL::StyleFlags styleflags = LLFontGL::NORMAL); + void addConsoleLine(const LLWString& wline, const LLColor4 &color, const LLUUID& session_id = LLUUID::null, LLFontGL::StyleFlags styleflags = LLFontGL::NORMAL); void clear(); - + void addSession(const LLUUID& session_id); + void removeSession(const LLUUID& session_id); + std::deque mLineColors; std::deque mLineStyle; + std::deque mSessionIDs; protected: /*virtual*/ void removeExtraLines(); @@ -183,6 +189,10 @@ private: S32 mConsoleHeight; bool mParseUrls; // If lines should be parsed for URLs LLUIImagePtr mBackgroundImage; // Configurable background for different console types + // Session support + std::set mCurrentSessions; + bool mSessionSupport; + // }; extern LLConsole* gConsole; diff --git a/indra/newview/fsconsoleutils.cpp b/indra/newview/fsconsoleutils.cpp index a5a7a131bc..dbda6fbfe9 100644 --- a/indra/newview/fsconsoleutils.cpp +++ b/indra/newview/fsconsoleutils.cpp @@ -103,7 +103,6 @@ bool FSConsoleUtils::ProcessChatMessage(const LLChat& chat_msg, const LLSD &args LLColor4 chatcolor; LLViewerChat::getChatColor(chat_msg, chatcolor); gConsole->addConsoleLine(consoleChat, chatcolor); - gConsole->setVisible(!isNearbyChatVisible()); } else { @@ -126,7 +125,6 @@ bool FSConsoleUtils::ProcessChatMessage(const LLChat& chat_msg, const LLSD &args LLColor4 chatcolor; LLViewerChat::getChatColor(chat_msg, chatcolor); gConsole->addConsoleLine(consoleChat, chatcolor); - gConsole->setVisible(!isNearbyChatVisible()); } return true; @@ -173,7 +171,6 @@ void FSConsoleUtils::onProcessChatAvatarNameLookup(const LLUUID& agent_id, const LLColor4 chatcolor; LLViewerChat::getChatColor(chat_msg, chatcolor); gConsole->addConsoleLine(consoleChat, chatcolor); - gConsole->setVisible(!isNearbyChatVisible()); } //static @@ -214,13 +211,13 @@ bool FSConsoleUtils::ProcessInstantMessage(const LLUUID& session_id, const LLUUI } } - LLAvatarNameCache::get(from_id, boost::bind(&FSConsoleUtils::onProccessInstantMessageNameLookup, _1, _2, message, group)); + LLAvatarNameCache::get(from_id, boost::bind(&FSConsoleUtils::onProccessInstantMessageNameLookup, _1, _2, message, group, session_id)); return true; } //static -void FSConsoleUtils::onProccessInstantMessageNameLookup(const LLUUID& agent_id, const LLAvatarName& av_name, const std::string& message_str, const std::string& group) +void FSConsoleUtils::onProccessInstantMessageNameLookup(const LLUUID& agent_id, const LLAvatarName& av_name, const std::string& message_str, const std::string& group, const LLUUID& session_id) { const bool is_group = !group.empty(); @@ -254,6 +251,5 @@ void FSConsoleUtils::onProccessInstantMessageNameLookup(const LLUUID& agent_id, LLColor4 textColor; LLViewerChat::getChatColor(chat, textColor, LLSD().with("is_local", false).with("for_console", true)); - gConsole->addConsoleLine("IM: " + senderName + delimiter + message, textColor); - gConsole->setVisible(!isNearbyChatVisible()); + gConsole->addConsoleLine("IM: " + senderName + delimiter + message, textColor, session_id); } diff --git a/indra/newview/fsconsoleutils.h b/indra/newview/fsconsoleutils.h index 03e74a34b2..80e1fd0a61 100644 --- a/indra/newview/fsconsoleutils.h +++ b/indra/newview/fsconsoleutils.h @@ -41,7 +41,7 @@ public: protected: static BOOL isNearbyChatVisible(); static void onProcessChatAvatarNameLookup(const LLUUID& agent_id, const LLAvatarName& av_name, const LLChat& chat_msg); - static void onProccessInstantMessageNameLookup(const LLUUID& agent_id, const LLAvatarName& av_name, const std::string& message_str, const std::string& group); + static void onProccessInstantMessageNameLookup(const LLUUID& agent_id, const LLAvatarName& av_name, const std::string& message_str, const std::string& group, const LLUUID& session_id); }; diff --git a/indra/newview/fsfloaterim.cpp b/indra/newview/fsfloaterim.cpp index 6c12cd4304..f737ca9a30 100644 --- a/indra/newview/fsfloaterim.cpp +++ b/indra/newview/fsfloaterim.cpp @@ -48,6 +48,7 @@ #include "llcheckboxctrl.h" #include "llchiclet.h" #include "llchicletbar.h" +#include "llconsole.h" #include "llfloaterabout.h" // for sysinfo button -Zi #include "llfloateravatarpicker.h" #include "llfloaterreg.h" @@ -1202,6 +1203,11 @@ void FSFloaterIM::setVisible(BOOL visible) if (visible && isInVisibleChain()) { sIMFloaterShowedSignal(mSessionID); + gConsole->addSession(mSessionID); + } + else + { + gConsole->removeSession(mSessionID); } } diff --git a/indra/newview/fsfloaternearbychat.cpp b/indra/newview/fsfloaternearbychat.cpp index 93b7fb1a13..2329e9c5bf 100644 --- a/indra/newview/fsfloaternearbychat.cpp +++ b/indra/newview/fsfloaternearbychat.cpp @@ -118,7 +118,7 @@ void FSFloaterNearbyChat::updateFSUseNearbyChatConsole(const LLSD &data) if (FSUseNearbyChatConsole) { removeScreenChat(); - gConsole->setVisible(!getVisible()); + gConsole->setVisible(TRUE); } else { @@ -386,26 +386,6 @@ void FSFloaterNearbyChat::setVisible(BOOL visible) } LLFloater::setVisible(visible); - // Support for chat console - static LLCachedControl chatHistoryTornOff(gSavedSettings, "ChatHistoryTornOff"); - if (FSUseNearbyChatConsole) - { - FSFloaterIMContainer* floater_container = FSFloaterIMContainer::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 - BOOL is_minimized = visible && isChatMultiTab() ? FSFloaterIMContainer::getInstance()->isMinimized() : !visible; @@ -423,6 +403,15 @@ void FSFloaterNearbyChat::setVisible(BOOL visible) mInputEditor->setFocus(TRUE); } } + + if (visible && isInVisibleChain()) + { + gConsole->addSession(LLUUID::null); + } + else + { + gConsole->removeSession(LLUUID::null); + } } void FSFloaterNearbyChat::onOpen(const LLSD& key ) diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 45301c4dd0..2c976a57f1 100755 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -269,7 +269,6 @@ void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChat LLColor4 chatcolor; LLViewerChat::getChatColor(chat_msg, chatcolor); gConsole->addConsoleLine(chat_msg.mText, chatcolor); - gConsole->setVisible(!nearby_chat->getVisible()); } } } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 80ea22b93d..4c57592bf5 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1957,8 +1957,9 @@ void LLViewerWindow::initBase() cp.name("console"); cp.max_lines(gSavedSettings.getS32("ConsoleBufferSize")); cp.rect(getChatConsoleRect()); - cp.parse_urls(true); // Ansariel: Enable URL parsing for the chat console - cp.background_image("Rounded_Square"); // Ansariel: Configurable background for different console types + cp.parse_urls(true); // Enable URL parsing for the chat console + cp.background_image("Rounded_Square"); // Configurable background for different console types + cp.session_support(true); // Session support // , have console respect/reuse NearbyToastLifeTime for the length popup chat messages are displayed. //cp.persist_time(gSavedSettings.getF32("ChatPersistTime")); cp.persist_time((F32)gSavedSettings.getS32("NearbyToastLifeTime"));