From 720b445bf4eea777d1fac9bac4c23aae59062826 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 5 Sep 2015 17:05:55 +0300 Subject: Add shop badge to beings. --- data/graphics/badges/CMakeLists.txt | 2 ++ data/graphics/badges/Makefile.am | 2 ++ data/graphics/badges/shop.png | Bin 0 -> 301 bytes data/graphics/badges/shop.xml | 15 +++++++++++++++ src/being/being.cpp | 24 +++++++++++++++++++++++- src/being/being.h | 2 ++ src/defaults.cpp | 1 + 7 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 data/graphics/badges/shop.png create mode 100644 data/graphics/badges/shop.xml diff --git a/data/graphics/badges/CMakeLists.txt b/data/graphics/badges/CMakeLists.txt index d8fad83de..22110ba93 100644 --- a/data/graphics/badges/CMakeLists.txt +++ b/data/graphics/badges/CMakeLists.txt @@ -1,6 +1,8 @@ SET(FILES gm.png gm.xml + shop.png + shop.xml team1.png team1.xml team2.png diff --git a/data/graphics/badges/Makefile.am b/data/graphics/badges/Makefile.am index d6f5e41df..4e8b57e04 100644 --- a/data/graphics/badges/Makefile.am +++ b/data/graphics/badges/Makefile.am @@ -3,6 +3,8 @@ badgesdir = $(pkgdatadir)/data/graphics/badges badges_DATA = \ gm.png \ gm.xml \ + shop.png \ + shop.xml \ team1.png \ team1.xml \ team2.png \ diff --git a/data/graphics/badges/shop.png b/data/graphics/badges/shop.png new file mode 100644 index 000000000..ffc71179c Binary files /dev/null and b/data/graphics/badges/shop.png differ diff --git a/data/graphics/badges/shop.xml b/data/graphics/badges/shop.xml new file mode 100644 index 000000000..4189056eb --- /dev/null +++ b/data/graphics/badges/shop.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/src/being/being.cpp b/src/being/being.cpp index 902811206..1980436d5 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2100,7 +2100,7 @@ std::string Being::getGenderSign() const } if (mShowPlayersStatus) { - if (mShop) + if (mShop && !mShowBadges) str.append("$"); if (mAway) { @@ -2517,6 +2517,7 @@ bool Being::updateFromCache() mInactive = false; } + showShopBadge(mShop); updateAwayEffect(); if (mType == ActorType::Player || mTeamId) updateColors(); @@ -3368,6 +3369,7 @@ void Being::setState(const uint8_t state) mAway = away; mInactive = inactive; updateAwayEffect(); + showShopBadge(mShop); if (needUpdate) { @@ -3880,6 +3882,7 @@ void Being::showBadges(const bool show) showGmBadge(show); showPartyBadge(show); showNameBadge(show); + showShopBadge(show); } void Being::showPartyBadge(const bool show) @@ -3897,6 +3900,7 @@ void Being::showPartyBadge(const bool show) updateBadgesCount(); } + void Being::setPartyName(const std::string &name) { if (mPartyName != name) @@ -3906,6 +3910,21 @@ void Being::setPartyName(const std::string &name) } } +void Being::showShopBadge(const bool show) +{ + delete2(mBadges[BadgeIndex::Shop]); + if (show && mShop && mShowBadges) + { + const std::string badge = paths.getStringValue("shopbadge"); + if (!badge.empty()) + { + mBadges[BadgeIndex::Shop] = AnimatedSprite::load( + paths.getStringValue("badges") + badge); + } + } + updateBadgesCount(); +} + void Being::updateBadgesCount() { mBadgesCount = 0; @@ -3928,6 +3947,7 @@ void Being::setSellBoard(const std::string &text) mShop = !text.empty() || !mBuyBoard.empty(); mSellBoard = text; updateName(); + showShopBadge(mShop); } void Being::setBuyBoard(const std::string &text) @@ -3935,6 +3955,7 @@ void Being::setBuyBoard(const std::string &text) mShop = !text.empty() || !mSellBoard.empty(); mBuyBoard = text; updateName(); + showShopBadge(mShop); } #endif @@ -3942,6 +3963,7 @@ void Being::enableShop(const bool b) { mShop = b; updateName(); + showShopBadge(mShop); } bool Being::isBuyShopEnabled() const diff --git a/src/being/being.h b/src/being/being.h index 7defdc9e9..656eb21fb 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -942,6 +942,8 @@ class Being notfinal : public ActorSprite, void showNameBadge(const bool show); + void showShopBadge(const bool show); + void showBadges(const bool show); uint16_t getTeamId() const diff --git a/src/defaults.cpp b/src/defaults.cpp index 2745d6f29..2d3b24410 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -607,6 +607,7 @@ DefaultsData* getPathsDefaults() AddDEF("team2badge", "team2.xml"); AddDEF("team3badge", "team3.xml"); AddDEF("gmbadge", "gm.xml"); + AddDEF("shopbadge", "shop.xml"); return configData; } -- cgit v1.2.3-70-g09d2