summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-03-04 22:03:14 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-03-04 23:10:24 +0100
commitb60e6d82d6e843f9e65c81555ec281d237c3ce41 (patch)
tree9f358ae0e37badc5289c7ab3518fed2fd56f6d68
parenteefe244e276634d59d5e6b89217f5747bb2afd97 (diff)
downloadmana-b60e6d82d6e843f9e65c81555ec281d237c3ce41.tar.gz
mana-b60e6d82d6e843f9e65c81555ec281d237c3ce41.tar.bz2
mana-b60e6d82d6e843f9e65c81555ec281d237c3ce41.tar.xz
mana-b60e6d82d6e843f9e65c81555ec281d237c3ce41.zip
Show gender near player names.
Configuring in Setup / Players / Show gender. Reviewed-by: Jared Adams <jaxad0127@gmail.com> Signed-off-by: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
-rw-r--r--src/being.cpp16
-rw-r--r--src/beingmanager.cpp13
-rw-r--r--src/beingmanager.h2
-rw-r--r--src/gui/setup_players.cpp23
-rw-r--r--src/gui/setup_players.h3
5 files changed, 55 insertions, 2 deletions
diff --git a/src/being.cpp b/src/being.cpp
index d78f38ab..54aa5e8a 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -1032,7 +1032,21 @@ void Being::showName()
mDispName = 0;
std::string mDisplayName(mName);
- if (getType() == MONSTER)
+ if (getType() == PLAYER)
+ {
+ if (config.getValue("showgender", false))
+ {
+ Player* player = static_cast<Player*>(this);
+ if (player)
+ {
+ if (player->getGender() == GENDER_FEMALE)
+ mDisplayName += " \u2640";
+ else
+ mDisplayName += " \u2642";
+ }
+ }
+ }
+ else if (getType() == MONSTER)
{
if (config.getValue("showMonstersTakedDamage", false))
{
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 4a2f1106..c7ed9d86 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -276,3 +276,16 @@ void BeingManager::getPlayerNames(std::vector<std::string> &names,
++i;
}
}
+
+void BeingManager::updatePlayerNames()
+{
+ Beings::iterator i = mBeings.begin();
+
+ while (i != mBeings.end())
+ {
+ Being *being = (*i);
+ if (being->getType() == Being::PLAYER && being->getName() != "")
+ being->updateName();
+ ++i;
+ }
+}
diff --git a/src/beingmanager.h b/src/beingmanager.h
index 83c7da44..d81db668 100644
--- a/src/beingmanager.h
+++ b/src/beingmanager.h
@@ -123,6 +123,8 @@ class BeingManager
void getPlayerNames(std::vector<std::string> &names,
bool npcNames);
+ void updatePlayerNames();
+
protected:
Beings mBeings;
Map *mMap;
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index fba4228e..159eab78 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -21,6 +21,7 @@
#include "gui/setup_players.h"
+#include "beingmanager.h"
#include "configuration.h"
#include "log.h"
@@ -214,6 +215,7 @@ public:
#define ACTION_TABLE "table"
#define ACTION_STRATEGY "strategy"
#define ACTION_WHISPER_TAB "whisper tab"
+#define ACTION_SHOW_GENDER "show gender"
Setup_Players::Setup_Players():
mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
@@ -227,7 +229,9 @@ Setup_Players::Setup_Players():
player_relations.getDefault() & PlayerRelation::WHISPER)),
mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
mWhisperTab(config.getValue("whispertab", false)),
- mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), mWhisperTab))
+ mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), mWhisperTab)),
+ mShowGender(config.getValue("showgender", false)),
+ mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender))
{
setName(_("Players"));
@@ -274,6 +278,9 @@ Setup_Players::Setup_Players():
mWhisperTabCheckBox->setActionEventId(ACTION_WHISPER_TAB);
mWhisperTabCheckBox->addActionListener(this);
+ mShowGenderCheckBox->setActionEventId(ACTION_SHOW_GENDER);
+ mShowGenderCheckBox->addActionListener(this);
+
reset();
// Do the layout
@@ -283,6 +290,7 @@ Setup_Players::Setup_Players():
place(0, 0, mPlayerTitleTable, 4);
place(0, 1, mPlayerScrollArea, 4, 4).setPadding(2);
place(0, 5, mDeleteButton);
+ place(0, 6, mShowGenderCheckBox, 2).setPadding(2);
place(2, 5, ignore_action_label);
place(2, 6, mIgnoreActionChoicesBox, 2).setPadding(2);
place(2, 7, mDefaultTrading);
@@ -334,12 +342,21 @@ void Setup_Players::apply()
| (mDefaultWhisper->isSelected() ?
PlayerRelation::WHISPER : 0));
config.setValue("whispertab", mWhisperTab);
+
+ bool showGender = config.getValue("showgender", false);
+
+ config.setValue("showgender", mShowGender);
+
+ if (beingManager && mShowGender != showGender)
+ beingManager->updatePlayerNames();
}
void Setup_Players::cancel()
{
mWhisperTab = config.getValue("whispertab", false);
mWhisperTabCheckBox->setSelected(mWhisperTab);
+ mShowGender = config.getValue("showgender", false);
+ mShowGenderCheckBox->setSelected(mShowGender);
}
void Setup_Players::action(const gcn::ActionEvent &event)
@@ -383,6 +400,10 @@ void Setup_Players::action(const gcn::ActionEvent &event)
{
mWhisperTab = mWhisperTabCheckBox->isSelected();
}
+ else if (event.getId() == ACTION_SHOW_GENDER)
+ {
+ mShowGender = mShowGenderCheckBox->isSelected();
+ }
}
void Setup_Players::updatedPlayer(const std::string &name)
diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h
index 0dc8ab73..5337b213 100644
--- a/src/gui/setup_players.h
+++ b/src/gui/setup_players.h
@@ -67,6 +67,9 @@ private:
bool mWhisperTab;
gcn::CheckBox *mWhisperTabCheckBox;
+
+ bool mShowGender;
+ gcn::CheckBox *mShowGenderCheckBox;
};
#endif