summaryrefslogtreecommitdiff
path: root/indra/newview/llnearbychat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llnearbychat.cpp')
-rw-r--r--indra/newview/llnearbychat.cpp290
1 files changed, 176 insertions, 114 deletions
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index bbab9944f3..c8d5d782b7 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -54,14 +54,22 @@
#include "llstylemap.h"
#include "lldraghandle.h"
-#include "lltrans.h"
+
#include "llbottomtray.h"
#include "llnearbychatbar.h"
+#include "llfloaterreg.h"
+#include "lltrans.h"
static const S32 RESIZE_BAR_THICKNESS = 3;
+const static std::string IM_TIME("time");
+const static std::string IM_TEXT("message");
+const static std::string IM_FROM("from");
+const static std::string IM_FROM_ID("from_id");
+
+
LLNearbyChat::LLNearbyChat(const LLSD& key)
- : LLDockableFloater(NULL, key)
+ : LLDockableFloater(NULL, false, false, key)
,mChatHistory(NULL)
{
@@ -89,93 +97,58 @@ BOOL LLNearbyChat::postBuild()
mChatHistory = getChild<LLChatHistory>("chat_history");
- setCanResize(true);
-
if(!LLDockableFloater::postBuild())
return false;
if (getDockControl() == NULL)
{
setDockControl(new LLDockControl(
- LLBottomTray::getInstance()->getNearbyChatBar(), this,
- getDockTongue(), LLDockControl::LEFT, boost::bind(&LLNearbyChat::getAllowedRect, this, _1)));
+ LLBottomTray::getInstance()->getNearbyChatBar(), this,
+ getDockTongue(), LLDockControl::TOP, boost::bind(&LLNearbyChat::getAllowedRect, this, _1)));
}
+ setIsChrome(true);
+ //chrome="true" hides floater caption
+ if (mDragHandle)
+ mDragHandle->setTitleVisible(TRUE);
+
return true;
}
-LLColor4 nearbychat_get_text_color(const LLChat& chat)
+void LLNearbyChat::applySavedVariables()
{
- LLColor4 text_color;
+ if (mRectControl.size() > 1)
+ {
+ const LLRect& rect = LLUI::sSettingGroups["floater"]->getRect(mRectControl);
+ if(!rect.isEmpty() && rect.isValid())
+ {
+ reshape(rect.getWidth(), rect.getHeight());
+ setRect(rect);
+ }
+ }
- if(chat.mMuted)
+
+ if(!LLUI::sSettingGroups["floater"]->controlExists(mDocStateControl))
{
- text_color.setVec(0.8f, 0.8f, 0.8f, 1.f);
+ setDocked(true);
}
else
{
- switch(chat.mSourceType)
+ if (mDocStateControl.size() > 1)
{
- case CHAT_SOURCE_SYSTEM:
- text_color = LLUIColorTable::instance().getColor("SystemChatColor");
- break;
- case CHAT_SOURCE_AGENT:
- if (chat.mFromID.isNull())
- {
- text_color = LLUIColorTable::instance().getColor("SystemChatColor");
- }
- else
- {
- if(gAgentID == chat.mFromID)
- {
- text_color = LLUIColorTable::instance().getColor("UserChatColor");
- }
- else
- {
- text_color = LLUIColorTable::instance().getColor("AgentChatColor");
- }
- }
- break;
- case CHAT_SOURCE_OBJECT:
- if (chat.mChatType == CHAT_TYPE_DEBUG_MSG)
- {
- text_color = LLUIColorTable::instance().getColor("ScriptErrorColor");
- }
- else if ( chat.mChatType == CHAT_TYPE_OWNER )
- {
- text_color = LLUIColorTable::instance().getColor("llOwnerSayChatColor");
- }
- else
- {
- text_color = LLUIColorTable::instance().getColor("ObjectChatColor");
- }
- break;
- default:
- text_color.setToWhite();
- }
-
- if (!chat.mPosAgent.isExactlyZero())
- {
- LLVector3 pos_agent = gAgent.getPositionAgent();
- F32 distance = dist_vec(pos_agent, chat.mPosAgent);
- if (distance > gAgent.getNearChatRadius())
- {
- // diminish far-off chat
- text_color.mV[VALPHA] = 0.8f;
- }
+ bool dockState = LLUI::sSettingGroups["floater"]->getBOOL(mDocStateControl);
+ setDocked(dockState);
}
}
-
- return text_color;
}
-std::string formatCurrentTime()
+std::string appendTime()
{
time_t utc_time;
utc_time = time_corrected();
std::string timeStr ="["+ LLTrans::getString("TimeHour")+"]:["
- +LLTrans::getString("TimeMin")+"] ";
+ +LLTrans::getString("TimeMin")+"]";
LLSD substitution;
@@ -186,55 +159,58 @@ std::string formatCurrentTime()
}
-void LLNearbyChat::add_timestamped_line(const LLChat& chat, const LLColor4& color)
+void LLNearbyChat::addMessage(const LLChat& chat,bool archive,const LLSD &args)
{
- S32 font_size = gSavedSettings.getS32("ChatFontSize");
-
- const LLFontGL* fontp = NULL;
- switch(font_size)
- {
- case 0:
- fontp = LLFontGL::getFontSansSerifSmall();
- break;
- default:
- case 1:
- fontp = LLFontGL::getFontSansSerif();
- break;
- case 2:
- fontp = LLFontGL::getFontSansSerifBig();
- break;
- }
-
- LLStyle::Params style_params;
- style_params.color(color);
- style_params.font(fontp);
- LLUUID uuid = chat.mFromID;
- std::string from = chat.mFromName;
- std::string time = formatCurrentTime();
- std::string message = chat.mText;
- mChatHistory->appendWidgetMessage(uuid, from, time, message, style_params);
-}
-
-void LLNearbyChat::addMessage(const LLChat& chat)
-{
- LLColor4 color = nearbychat_get_text_color(chat);
-
-
if (chat.mChatType == CHAT_TYPE_DEBUG_MSG)
{
- LLFloaterScriptDebug::addScriptLine(chat.mText,
- chat.mFromName,
- color,
- chat.mFromID);
- if (!gSavedSettings.getBOOL("ScriptErrorsAsChat"))
+ if(gSavedSettings.getBOOL("ShowScriptErrors") == FALSE)
+ return;
+ if (gSavedSettings.getS32("ShowScriptErrorsLocation")== 1)// show error in window //("ScriptErrorsAsChat"))
{
+
+ LLColor4 txt_color;
+
+ LLViewerChat::getChatColor(chat,txt_color);
+
+ LLFloaterScriptDebug::addScriptLine(chat.mText,
+ chat.mFromName,
+ txt_color,
+ chat.mFromID);
return;
}
}
+
+ LLChat& tmp_chat = const_cast<LLChat&>(chat);
+
+ if(tmp_chat.mTimeStr.empty())
+ tmp_chat.mTimeStr = appendTime();
+
+ bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory");
- // could flash the chat button in the status bar here. JC
if (!chat.mMuted)
- add_timestamped_line(chat, color);
+ {
+ tmp_chat.mFromName = chat.mFromName;
+ LLSD chat_args = args;
+ chat_args["use_plain_text_chat_history"] = use_plain_text_chat_history;
+ mChatHistory->appendMessage(chat, chat_args);
+ }
+
+ if(archive)
+ {
+ mMessageArchive.push_back(chat);
+ if(mMessageArchive.size()>200)
+ mMessageArchive.erase(mMessageArchive.begin());
+ }
+
+ if (args["do_not_log"].asBoolean())
+ {
+ return;
+ }
+
+ if (gSavedPerAccountSettings.getBOOL("LogChat"))
+ {
+ LLLogChat::saveHistory("chat", chat.mFromName, chat.mFromID, chat.mText);
+ }
}
void LLNearbyChat::onNearbySpeakers()
@@ -256,20 +232,23 @@ bool LLNearbyChat::onNearbyChatCheckContextMenuItem(const LLSD& userdata)
return false;
}
-void LLNearbyChat::onOpen(const LLSD& key )
+void LLNearbyChat::setVisible(BOOL visible)
{
- LLNotificationsUI::LLScreenChannelBase* chat_channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID")));
- if(chat_channel)
+ if(visible)
{
- chat_channel->removeToastsFromChannel();
+ LLNotificationsUI::LLScreenChannelBase* chat_channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID")));
+ if(chat_channel)
+ {
+ chat_channel->removeToastsFromChannel();
+ }
}
+
+ LLDockableFloater::setVisible(visible);
}
-void LLNearbyChat::setDocked (bool docked, bool pop_on_undock)
+void LLNearbyChat::onOpen(const LLSD& key )
{
- LLDockableFloater::setDocked(docked, pop_on_undock);
-
- setCanResize(!docked);
+ LLDockableFloater::onOpen(key);
}
void LLNearbyChat::setRect (const LLRect &rect)
@@ -279,13 +258,96 @@ void LLNearbyChat::setRect (const LLRect &rect)
void LLNearbyChat::getAllowedRect(LLRect& rect)
{
- rect = gViewerWindow->getWorldViewRect();
+ rect = gViewerWindow->getWorldViewRectScaled();
}
-void LLNearbyChat::setVisible (BOOL visible)
+
+void LLNearbyChat::updateChatHistoryStyle()
{
- LLDockableFloater::setVisible(visible);
+ mChatHistory->clear();
+ for(std::vector<LLChat>::iterator it = mMessageArchive.begin();it!=mMessageArchive.end();++it)
+ {
+ addMessage(*it,false);
+ }
+}
+
+//static
+void LLNearbyChat::processChatHistoryStyleUpdate(const LLSD& newvalue)
+{
+ LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
+ if(nearby_chat)
+ nearby_chat->updateChatHistoryStyle();
+}
+
+bool isTwoWordsName(const std::string& name)
+{
+ //checking for a single space
+ S32 pos = name.find(' ', 0);
+ return std::string::npos != pos && name.rfind(' ', name.length()) == pos && 0 != pos && name.length()-1 != pos;
}
-void LLNearbyChat::toggleWindow()
+
+void LLNearbyChat::loadHistory()
+{
+ LLSD do_not_log;
+ do_not_log["do_not_log"] = true;
+
+ std::list<LLSD> history;
+ LLLogChat::loadAllHistory("chat", history);
+
+ std::list<LLSD>::const_iterator it = history.begin();
+ while (it != history.end())
+ {
+ const LLSD& msg = *it;
+
+ std::string from = msg[IM_FROM];
+ LLUUID from_id = LLUUID::null;
+ if (msg[IM_FROM_ID].isUndefined())
+ {
+ gCacheName->getUUID(from, from_id);
+ }
+
+ LLChat chat;
+ chat.mFromName = from;
+ chat.mFromID = from_id;
+ chat.mText = msg[IM_TEXT].asString();
+ chat.mTimeStr = msg[IM_TIME].asString();
+ chat.mChatStyle = CHAT_STYLE_HISTORY;
+
+ chat.mSourceType = CHAT_SOURCE_AGENT;
+ if (from_id.isNull() && SYSTEM_FROM == from)
+ {
+ chat.mSourceType = CHAT_SOURCE_SYSTEM;
+
+ }
+ else if (from_id.isNull())
+ {
+ chat.mSourceType = isTwoWordsName(from) ? CHAT_SOURCE_UNKNOWN : CHAT_SOURCE_OBJECT;
+ }
+
+ addMessage(chat, true, do_not_log);
+
+ it++;
+ }
+}
+
+//static
+LLNearbyChat* LLNearbyChat::getInstance()
+{
+ return LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void LLNearbyChat::onFocusReceived()
+{
+ setBackgroundOpaque(true);
+ LLPanel::onFocusReceived();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void LLNearbyChat::onFocusLost()
{
+ setBackgroundOpaque(false);
+ LLPanel::onFocusLost();
}