diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-08 03:25:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-08 03:25:29 +0300 |
commit | a88d005220997d4c66d3a97ae8fd857a7dd3c307 (patch) | |
tree | cebc4b8388f33da27f24b727d2fe531e0f4acf2d | |
parent | 27c3646d10e0c5d25905d7afc7a43289159f711b (diff) | |
download | manaplus-a88d005220997d4c66d3a97ae8fd857a7dd3c307.tar.gz manaplus-a88d005220997d4c66d3a97ae8fd857a7dd3c307.tar.bz2 manaplus-a88d005220997d4c66d3a97ae8fd857a7dd3c307.tar.xz manaplus-a88d005220997d4c66d3a97ae8fd857a7dd3c307.zip |
Show players statuses near nicks.
-rw-r--r-- | src/being.cpp | 53 | ||||
-rw-r--r-- | src/being.h | 3 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/gui/setup_players.cpp | 14 | ||||
-rw-r--r-- | src/gui/setup_players.h | 5 |
5 files changed, 62 insertions, 14 deletions
diff --git a/src/being.cpp b/src/being.cpp index cbdb8af8d..25ae64211 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -185,6 +185,9 @@ bool Being::mDrawHotKeys = true; bool Being::mShowBattleEvents = false; bool Being::mShowMobHP = false; bool Being::mShowOwnHP = false; +bool Being::mShowGender = false; +bool Being::mShowLevel = false; +bool Being::mShowPlayersStatus = false; std::list<BeingCacheEntry*> beingInfoCache; @@ -1483,16 +1486,30 @@ std::string Being::getGenderSignWithSpace() const std::string Being::getGenderSign() const { - if (config.getBoolValue("showgender")) + std::string str; + if (mShowGender) { if (getGender() == GENDER_FEMALE) - return "\u2640"; + str = "\u2640"; else if (getGender() == GENDER_MALE) - return "\u2642"; - else - return ""; + str = "\u2642"; } - return ""; + if (mShowPlayersStatus && mAdvanced) + { + if (mShop) + str += "$"; + if (mAway) + { + // TRANSLATORS: this away status writed in player nick + str += _("A"); + } + else if (mInactive) + { + // TRANSLATORS: this inactive status writed in player nick + str += _("I"); + } + } + return str; } void Being::showName() @@ -1501,12 +1518,10 @@ void Being::showName() mDispName = 0; std::string mDisplayName(mName); - if (mType != MONSTER - && (config.getBoolValue("showgender") - || config.getBoolValue("showlevel"))) + if (mType != MONSTER && (mShowGender || mShowLevel)) { mDisplayName += " "; - if (config.getBoolValue("showlevel") && getLevel() != 0) + if (mShowLevel && getLevel() != 0) mDisplayName += toString(getLevel()); mDisplayName += getGenderSign(); @@ -1723,6 +1738,9 @@ void Being::reReadConfig() mShowBattleEvents = config.getBoolValue("showBattleEvents"); mShowMobHP = config.getBoolValue("showMobHP"); mShowOwnHP = config.getBoolValue("showOwnHP"); + mShowGender = config.getBoolValue("showgender"); + mShowLevel = config.getBoolValue("showlevel"); + mShowPlayersStatus = config.getBoolValue("showPlayersStatus"); mUpdateConfigTime = cur_time; } @@ -2316,9 +2334,18 @@ void Being::setEmote(Uint8 emotion, int emote_time) if ((emotion & FLAG_SPECIAL) == FLAG_SPECIAL) { mAdvanced = true; - mShop = (emotion & FLAG_SHOP); - mAway = (emotion & FLAG_AWAY); - mInactive = (emotion & FLAG_INACTIVE); + bool shop = (emotion & FLAG_SHOP); + bool away = (emotion & FLAG_AWAY); + bool inactive = (emotion & FLAG_INACTIVE); + bool needUpdate = (shop != mShop || away != mAway + || inactive != mInactive); + + mShop = shop; + mAway = away; + mInactive = inactive; + + if (needUpdate) + updateName(); // logger->log("flags: %d", emotion - FLAG_SPECIAL); } else diff --git a/src/being.h b/src/being.h index de50d8fcf..143f3eec5 100644 --- a/src/being.h +++ b/src/being.h @@ -870,6 +870,9 @@ class Being : public ActorSprite, public ConfigListener static bool mShowBattleEvents; static bool mShowMobHP; static bool mShowOwnHP; + static bool mShowGender; + static bool mShowLevel; + static bool mShowPlayersStatus; unsigned int mMoveTime; unsigned int mAttackTime; diff --git a/src/defaults.cpp b/src/defaults.cpp index 0fcf1c5d7..3f8a97340 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -207,6 +207,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "useLocalTime", false); AddDEF(configData, "enableAdvert", true); AddDEF(configData, "enableMapReduce", true); + AddDEF(configData, "showPlayersStatus", true); return configData; } diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 407eca42a..67ec053ea 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -261,6 +261,7 @@ Setup_Players::Setup_Players(): mSecureTrades(config.getBoolValue("securetrades")), mUnsecureChars(config.getStringValue("unsecureChars")), mVisibleNamesEnabled(config.getBoolValue("visiblenames")), + mShowPlayersStatus(config.getBoolValue("showPlayersStatus")), mEditDialog(0) { setName(_("Players")); @@ -337,6 +338,11 @@ Setup_Players::Setup_Players(): mVisibleNamesCheckBox->setActionEventId("visiblenames"); mVisibleNamesCheckBox->addActionListener(this); + mShowPlayersStatusCheckBox = new CheckBox(_("Show statuses"), + mShowPlayersStatus); + mShowPlayersStatusCheckBox->setActionEventId("showPlayersStatus"); + mShowPlayersStatusCheckBox->addActionListener(this); + reset(); // Do the layout @@ -357,6 +363,7 @@ Setup_Players::Setup_Players(): place(3, 8, mSecureTradesCheckBox, 3); place(3, 9, mUnsecureCharsLabel, 3); place(3, 10, mUnsecureCharsField, 2); + place(3, 11, mShowPlayersStatusCheckBox, 2); place(5, 10, mUnsecureCharsButton, 1); place(0, 9, mWhisperTabCheckBox, 3).setPadding(4); place(0, 10, mTargetDeadCheckBox, 3).setPadding(4); @@ -415,6 +422,7 @@ void Setup_Players::apply() config.setValue("securetrades", mSecureTrades); config.setValue("unsecureChars", mUnsecureCharsField->getText()); config.setValue("visiblenames", mVisibleNamesEnabled); + config.setValue("showPlayersStatus", mShowPlayersStatus); if (actorSpriteManager) actorSpriteManager->updatePlayerNames(); @@ -441,6 +449,8 @@ void Setup_Players::cancel() mUnsecureCharsField->setText(mUnsecureChars); mVisibleNamesEnabled = config.getBoolValue("visiblenames"); mVisibleNamesCheckBox->setSelected(mVisibleNamesEnabled); + mShowPlayersStatus = config.getBoolValue("showPlayersStatus"); + mShowPlayersStatusCheckBox->setSelected(mShowPlayersStatus); } void Setup_Players::action(const gcn::ActionEvent &event) @@ -526,6 +536,10 @@ void Setup_Players::action(const gcn::ActionEvent &event) { mVisibleNamesEnabled = mVisibleNamesCheckBox->isSelected(); } + else if (event.getId() == "showPlayersStatus") + { + mShowPlayersStatus = mShowPlayersStatusCheckBox->isSelected(); + } } void Setup_Players::updatedPlayer(const std::string &name A_UNUSED) diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index 83709d7bd..9f35d1600 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -99,10 +99,13 @@ private: gcn::TextField *mUnsecureCharsField; gcn::Button *mUnsecureCharsButton; std::string mUnsecureChars; - bool mVisibleNamesEnabled; + bool mVisibleNamesEnabled; gcn::CheckBox *mVisibleNamesCheckBox; + bool mShowPlayersStatus; + gcn::CheckBox *mShowPlayersStatusCheckBox; + EditDialog *mEditDialog; }; |