summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-01 21:49:35 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-01 21:49:35 +0300
commitec552e6430ac86b1234c9a7798bf4e028a3c78c0 (patch)
tree10cd93cf86dca5ce2074b362dc7e4db1c0e2b03d /src
parent170aae70566003a30ab1f6f936364484f6a0a097 (diff)
downloadmanaverse-ec552e6430ac86b1234c9a7798bf4e028a3c78c0.tar.gz
manaverse-ec552e6430ac86b1234c9a7798bf4e028a3c78c0.tar.bz2
manaverse-ec552e6430ac86b1234c9a7798bf4e028a3c78c0.tar.xz
manaverse-ec552e6430ac86b1234c9a7798bf4e028a3c78c0.zip
Set secure font in chat tab name if need.
Diffstat (limited to 'src')
-rw-r--r--src/gui/chatwindow.cpp3
-rw-r--r--src/gui/widgets/tab.cpp8
-rw-r--r--src/gui/widgets/tab.h6
-rw-r--r--src/playerrelations.cpp40
-rw-r--r--src/playerrelations.h5
5 files changed, 53 insertions, 9 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 1712a3f16..a575b7054 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -34,6 +34,7 @@
#include "spellshortcut.h"
#include "sound.h"
+#include "gui/gui.h"
#include "gui/setup.h"
#include "gui/sdlinput.h"
#include "gui/theme.h"
@@ -1004,6 +1005,8 @@ ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo)
else
{
ret = new WhisperTab(nick);
+ if (gui && !player_relations.isGoodName(nick))
+ ret->setLabelFont(gui->getSecureFont());
mWhispers[tempNick] = ret;
if (config.getBoolValue("showChatHistory"))
ret->loadFromLogFile(nick);
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 7287d6a8e..37a32480d 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -229,3 +229,11 @@ void Tab::widgetMoved(const gcn::Event &event _UNUSED_)
{
mRedraw = true;
}
+
+void Tab::setLabelFont(gcn::Font *font)
+{
+ if (!mLabel)
+ return;
+
+ mLabel->setFont(font);
+}
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index f9f1fa4da..5847bd505 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -23,6 +23,7 @@
#ifndef TAB_H
#define TAB_H
+#include <guichan/widgets/label.hpp>
#include <guichan/widgets/tab.hpp>
#include <guichan/widgetlistener.hpp>
@@ -67,6 +68,11 @@ class Tab : public gcn::Tab, public gcn::WidgetListener
void widgetMoved(const gcn::Event &event);
+ void setLabelFont(gcn::Font *font);
+
+ gcn::Label *getLabel()
+ { return mLabel; }
+
protected:
friend class TabbedArea;
virtual void setCurrent()
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 87318ff43..7ff410064 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -494,6 +494,20 @@ PlayerRelationsManager::getPlayerIgnoreStrategies()
return &mIgnoreStrategies;
}
+bool PlayerRelationsManager::isGoodName(std::string name)
+{
+ bool status(false);
+
+ const int size = name.size();
+
+ if (size < 3 || mRelations[name])
+ return true;
+
+ status = checkName(name);
+
+ return status;
+}
+
bool PlayerRelationsManager::isGoodName(Being *being)
{
bool status(false);
@@ -505,21 +519,29 @@ bool PlayerRelationsManager::isGoodName(Being *being)
const std::string name = being->getName();
const int size = name.size();
- std::string check = config.getStringValue("unsecureChars");
if (size < 3 || mRelations[name])
return true;
- else if (name.substr(0, 1) == " " || name.substr(size - 1, 1) == " ")
- status = false;
- else if (check.empty())
- status = true;
- else if (name.find_first_of(check) != std::string::npos)
- status = false;
- else
- status = true;
+
+ status = checkName(name);
being->setGoodStatus(status ? 1 : 0);
return status;
}
+bool PlayerRelationsManager::checkName(const std::string &name) const
+{
+ const int size = name.size();
+ std::string check = config.getStringValue("unsecureChars");
+
+ if (name.substr(0, 1) == " " || name.substr(size - 1, 1) == " ")
+ return false;
+ else if (check.empty())
+ return true;
+ else if (name.find_first_of(check) != std::string::npos)
+ return false;
+ else
+ return true;
+}
+
PlayerRelationsManager player_relations;
diff --git a/src/playerrelations.h b/src/playerrelations.h
index b4ef6dd45..613a27d01 100644
--- a/src/playerrelations.h
+++ b/src/playerrelations.h
@@ -219,6 +219,8 @@ class PlayerRelationsManager
bool isGoodName(Being *being);
+ bool isGoodName(std::string name);
+
/**
* Change the `ignore persist' flag.
*
@@ -233,6 +235,7 @@ class PlayerRelationsManager
void removeListener(PlayerRelationsListener *listener)
{ mListeners.remove(listener); }
+
private:
void signalUpdate(const std::string &name);
@@ -240,6 +243,8 @@ class PlayerRelationsManager
// ignored data upon reloading
unsigned int mDefaultPermissions;
+ bool checkName(const std::string &name) const;
+
PlayerIgnoreStrategy *mIgnoreStrategy;
std::map<std::string, PlayerRelation *> mRelations;
std::list<PlayerRelationsListener *> mListeners;