FIRE-2436: Change behavior of chat console: Chat console will now always show the chat for sessions that are currently not shown by a visible floater

master
Ansariel 2015-11-11 13:55:23 +01:00
parent c546da1400
commit 9036ed275a
8 changed files with 154 additions and 45 deletions

View File

@ -63,7 +63,8 @@ LLConsole::LLConsole(const LLConsole::Params& p)
mFont(p.font),
mConsoleWidth(0),
mConsoleHeight(0),
mParseUrls(p.parse_urls) // <FS:Ansariel> If lines should be parsed for URLs
mParseUrls(p.parse_urls), // <FS:Ansariel> If lines should be parsed for URLs
mSessionSupport(p.session_support) // <FS:Ansariel> Session support
{
if (p.font_size_index.isProvided())
{
@ -174,6 +175,11 @@ void LLConsole::draw()
return;
}
// <FS:Ansariel> Session support
if (!mSessionSupport)
{
// This is done in update() if session support is enabled
// </FS:Ansariel>
U32 num_lines=0;
paragraph_t::reverse_iterator paragraph_it;
@ -196,6 +202,9 @@ void LLConsole::draw()
paragraph_num--;
paragraph_it++;
}
// <FS:Ansariel> Session support
}
// </FS:Ansariel>
if (mParagraphs.empty())
{
@ -267,6 +276,7 @@ void LLConsole::draw()
// y_pos += padding_vertical;
//}
paragraph_t::reverse_iterator paragraph_it;
static LLCachedControl<F32> 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()
}
// <FS:Ansariel> 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.
// <FS:Ansariel> Added styleflags parameter for style customization
// <FS:Ansariel> 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)
// </FS:Ansariel>
: mParagraphText(str), mAddTime(add_time), mMaxWidth(-1)
{
// <FS:Ansariel> 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();
// </FS:Ansariel>
}
}
// 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)
// <FS:Ansariel> Session support
if (!mSessionSupport)
{
// </FS:Ansariel>
while ((S32)mParagraphs.size() > llmax((S32)0, (S32)(mMaxLines)))
{
mParagraphs.pop_front();
}
// <FS:Ansariel> 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<LLUUID, S32> 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);
}
// </FS:Ansariel>
}
// <FS:Ansariel> Session support
void LLConsole::addSession(const LLUUID& session_id)
{
mCurrentSessions.insert(session_id);
}
void LLConsole::removeSession(const LLUUID& session_id)
{
mCurrentSessions.erase(session_id);
}
// </FS:Ansariel>

View File

@ -52,13 +52,15 @@ public:
Optional<S32> font_size_index;
Optional<bool> parse_urls; // <FS:Ansariel> If lines should be parsed for URLs
Optional<std::string> background_image; // <FS:Ansariel> Configurable background for different console types
Optional<bool> session_support; // <FS:Ansariel> 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), // <FS:Ansariel> If lines should be parsed for URLs
background_image("background_image", "Console_Background") // <FS:Ansariel> Configurable background for different console types
background_image("background_image", "Console_Background"), // <FS:Ansariel> Configurable background for different console types
session_support("session_support", false) // <FS:Ansariel> Session support
{
changeDefault(mouse_opaque, false);
}
@ -120,7 +122,7 @@ public:
public:
// <FS:Ansariel> 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);
// </FS:Ansariel>
void makeParagraphColorSegments ( const LLColor4 &color);
// <FS:Ansariel> 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; // <FS:Ansariel> Session support
// <FS:Ansariel> Parse SLURLs
LLUUID mID;
@ -160,12 +163,15 @@ public:
/*virtual*/ void draw();
// <FS:Ansariel> 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<LLColor4> mLineColors;
std::deque<LLFontGL::StyleFlags> mLineStyle;
std::deque<LLUUID> mSessionIDs;
protected:
/*virtual*/ void removeExtraLines();
@ -183,6 +189,10 @@ private:
S32 mConsoleHeight;
bool mParseUrls; // <FS:Ansariel> If lines should be parsed for URLs
LLUIImagePtr mBackgroundImage; // <FS:Ansariel> Configurable background for different console types
// <FS:Ansariel> Session support
std::set<LLUUID> mCurrentSessions;
bool mSessionSupport;
// </FS:Ansariel>
};
extern LLConsole* gConsole;

View File

@ -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);
}

View File

@ -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);
};

View File

@ -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);
}
}

View File

@ -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);
// <Ansariel> Support for chat console
static LLCachedControl<bool> 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());
}
}
// </Ansariel> 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 )

View File

@ -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());
}
}
}

View File

@ -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); // <FS:Ansariel> Enable URL parsing for the chat console
cp.background_image("Rounded_Square"); // <FS:Ansariel> Configurable background for different console types
cp.session_support(true); // <FS:Ansariel> Session support
// <FS:AO>, 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"));