All pastes #1823068 Raw Edit

Mine

public diff v1 · immutable
#1823068 ·published 2010-03-04 20:27 UTC
rendered paste body
From 05f1da243cf9e7a054f8b3463930c182033f42aa Mon Sep 17 00:00:00 2001From: Andrei Karas <akaras@inbox.ru>Date: Thu, 4 Mar 2010 22:03:14 +0200Subject: [PATCH] Show gender near player names.Configuring in Setup / Players / Show gender.--- src/being.cpp             |   16 +++++++++++++++- src/beingmanager.cpp      |   13 +++++++++++++ src/beingmanager.h        |    2 ++ src/gui/setup_players.cpp |   23 ++++++++++++++++++++++- src/gui/setup_players.h   |    3 +++ 5 files changed, 55 insertions(+), 2 deletions(-)diff --git a/src/being.cpp b/src/being.cppindex d78f38a..54aa5e8 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.cppindex 4a2f110..c7ed9d8 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.hindex 83c7da4..d81db66 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.cppindex fba4228..159eab7 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.hindex 0dc8ab7..5337b21 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-- 1.7.0