Added code support for keyword alerts
parent
0adb3d4148
commit
30661e0188
|
|
@ -78,6 +78,7 @@ set(viewer_SOURCE_FILES
|
|||
floatermedialists.cpp
|
||||
fscontactsfloater.cpp
|
||||
fsareasearch.cpp
|
||||
fskeywords.cpp
|
||||
llagent.cpp
|
||||
llagentaccess.cpp
|
||||
llagentcamera.cpp
|
||||
|
|
@ -640,6 +641,7 @@ set(viewer_HEADER_FILES
|
|||
floatermedialists.h
|
||||
fscontactsfloater.h
|
||||
fsareasearch.h
|
||||
fskeywords.h
|
||||
llagent.h
|
||||
llagentaccess.h
|
||||
llagentcamera.h
|
||||
|
|
|
|||
|
|
@ -298,6 +298,100 @@
|
|||
<integer>0</integer>
|
||||
</array>
|
||||
</map>
|
||||
|
||||
<key>PhoenixKeywordOn</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Turns on keyword alerts</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>PhoenixKeywordInChat</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Look for keywords in local chat</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>PhoenixKeywordInIM</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Look for keywords in IMs and group chats</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>PhoenixKeywords</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Comma seperated list of keywords</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>String</string>
|
||||
<key>Value</key>
|
||||
<string></string>
|
||||
</map>
|
||||
<key>PhoenixKeywordPlaySound</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Play a sound when a keyword is found</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>PhoenixKeywordSound</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>UUID of sound to play</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>String</string>
|
||||
<key>Value</key>
|
||||
<string></string>
|
||||
</map>
|
||||
<key>PhoenixKeywordChangeColor</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>change message color if keyword found</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>PhoenixKeywordColor</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Color of keyword detects messages</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Color4</string>
|
||||
<key>Value</key>
|
||||
<array>
|
||||
<real>1.0</real>
|
||||
<real>0.600000023842</real>
|
||||
<real>0.0</real>
|
||||
<real>1.0</real>
|
||||
</array>
|
||||
</map>
|
||||
<!-- End of Firestorm settings -->
|
||||
</map>
|
||||
</llsd>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
|
||||
#include "fskeywords.h"
|
||||
#include "llui.h"
|
||||
#include "llviewercontrol.h"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
//#include <boost/algorithm/string/find.hpp> //for boost::ifind_first
|
||||
|
||||
|
||||
FSKeywords::FSKeywords()
|
||||
{
|
||||
gSavedPerAccountSettings.getControl("PhoenixKeywords")->getSignal()->connect(boost::bind(&FSKeywords::updateKeywords, this));
|
||||
updateKeywords();
|
||||
}
|
||||
|
||||
FSKeywords::~FSKeywords()
|
||||
{
|
||||
}
|
||||
|
||||
void FSKeywords::updateKeywords()
|
||||
{
|
||||
std::string s = gSavedPerAccountSettings.getString("PhoenixKeywords");
|
||||
LLStringUtil::toLower(s);
|
||||
boost::regex re(",");
|
||||
boost::sregex_token_iterator begin(s.begin(), s.end(), re, -1), end;
|
||||
mWordList.clear();
|
||||
while(begin != end)
|
||||
{
|
||||
mWordList.push_back(*begin++);
|
||||
}
|
||||
}
|
||||
|
||||
bool FSKeywords::chatContainsKeyword(const LLChat& chat, bool is_local)
|
||||
{
|
||||
static LLCachedControl<bool> sPhoenixKeywordOn(gSavedPerAccountSettings, "PhoenixKeywordOn", false);
|
||||
static LLCachedControl<bool> sPhoenixKeywordInChat(gSavedPerAccountSettings, "PhoenixKeywordInChat", false);
|
||||
static LLCachedControl<bool> sPhoenixKeywordInIM(gSavedPerAccountSettings, "PhoenixKeywordInIM", false);
|
||||
if (!sPhoenixKeywordOn ||
|
||||
(is_local && !sPhoenixKeywordInChat) ||
|
||||
(!is_local && !sPhoenixKeywordInIM))
|
||||
return FALSE;
|
||||
|
||||
std::string source(chat.mText);
|
||||
LLStringUtil::toLower(source);
|
||||
|
||||
for(U32 i=0; i < mWordList.size(); i++)
|
||||
{
|
||||
if(source.find(mWordList[i]) != std::string::npos)
|
||||
{
|
||||
if(gSavedPerAccountSettings.getBOOL("PhoenixKeywordPlaySound"))
|
||||
LLUI::sAudioCallback(LLUUID(gSavedPerAccountSettings.getString("PhoenixKeywordSound")));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
#include "llsingleton.h"
|
||||
#include "llstring.h"
|
||||
#include "llchat.h"
|
||||
|
||||
class LLViewerRegion;
|
||||
|
||||
|
||||
class FSKeywords : public LLSingleton<FSKeywords>
|
||||
{
|
||||
public:
|
||||
FSKeywords();
|
||||
virtual ~FSKeywords();
|
||||
|
||||
void updateKeywords();
|
||||
bool chatContainsKeyword(const LLChat& chat, bool is_local);
|
||||
|
||||
private:
|
||||
std::vector<std::string> mWordList;
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -791,7 +791,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
|
|||
|
||||
LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
|
||||
LLColor4 header_name_color = LLUIColorTable::instance().getColor("ChatNameColor");
|
||||
LLViewerChat::getChatColor(chat,txt_color);
|
||||
LLViewerChat::getChatColor(chat,txt_color,false);
|
||||
LLFontGL* fontp = LLViewerChat::getChatFont();
|
||||
std::string font_name = LLFontGL::nameFromFont(fontp);
|
||||
std::string font_size = LLFontGL::sizeFromFont(fontp);
|
||||
|
|
|
|||
|
|
@ -32,11 +32,12 @@
|
|||
#include "lluicolortable.h"
|
||||
#include "llviewercontrol.h" // gSavedSettings
|
||||
#include "llinstantmessage.h" //SYSTEM_FROM
|
||||
#include "fskeywords.h"
|
||||
|
||||
// LLViewerChat
|
||||
|
||||
//static
|
||||
void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color)
|
||||
void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color, bool is_local)
|
||||
{
|
||||
if(chat.mMuted)
|
||||
{
|
||||
|
|
@ -84,6 +85,17 @@ void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color)
|
|||
r_color.setToWhite();
|
||||
}
|
||||
|
||||
//Keyword alerts -KC
|
||||
if ((gAgentID != chat.mFromID) && FSKeywords::getInstance()->chatContainsKeyword(chat, is_local))
|
||||
{
|
||||
static LLCachedControl<bool> sPhoenixKeywordChangeColor(gSavedPerAccountSettings, "PhoenixKeywordChangeColor");
|
||||
if (sPhoenixKeywordChangeColor)
|
||||
{
|
||||
static LLCachedControl<LLColor4> sPhoenixKeywordColor(gSavedPerAccountSettings, "PhoenixKeywordColor");
|
||||
r_color = sPhoenixKeywordColor;
|
||||
}
|
||||
}
|
||||
|
||||
if (!chat.mPosAgent.isExactlyZero())
|
||||
{
|
||||
LLVector3 pos_agent = gAgent.getPositionAgent();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
class LLViewerChat
|
||||
{
|
||||
public:
|
||||
static void getChatColor(const LLChat& chat, LLColor4& r_color);
|
||||
static void getChatColor(const LLChat& chat, LLColor4& r_color, bool is_local = true);
|
||||
static void getChatColor(const LLChat& chat, std::string& r_color_name, F32& r_color_alpha);
|
||||
static LLFontGL* getChatFont();
|
||||
static S32 getChatFontSize();
|
||||
|
|
|
|||
Loading…
Reference in New Issue