diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-15 13:22:40 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-15 13:22:40 +0300 |
commit | 35dff83d93c36cd294f1899b1530da88a80b8917 (patch) | |
tree | c33b40350d3e45a201402982db7925b6c988328e /src | |
parent | 8ef332195f82d30f70435b69ba485640a19d80ed (diff) | |
download | mv-35dff83d93c36cd294f1899b1530da88a80b8917.tar.gz mv-35dff83d93c36cd294f1899b1530da88a80b8917.tar.bz2 mv-35dff83d93c36cd294f1899b1530da88a80b8917.tar.xz mv-35dff83d93c36cd294f1899b1530da88a80b8917.zip |
Allow to shop buy board name on beings.
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 10 | ||||
-rw-r--r-- | src/being/being.h | 6 | ||||
-rw-r--r-- | src/gui/popups/beingpopup.cpp | 44 | ||||
-rw-r--r-- | src/gui/popups/beingpopup.h | 1 |
4 files changed, 52 insertions, 9 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 60b87914c..97fad3c59 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -175,6 +175,7 @@ Being::Being(const int id, mSpriteHide(new int[20]), mSpriteDraw(new int[20]), mComment(), + mBuyBoard(), mSellBoard(), mPets(), mOwner(nullptr), @@ -3533,11 +3534,18 @@ void Being::setChat(ChatObject *const obj) void Being::setSellBoard(const std::string &text) { - mShop = !text.empty(); + mShop = !text.empty() || !mBuyBoard.empty(); mSellBoard = text; updateName(); } +void Being::setBuyBoard(const std::string &text) +{ + mShop = !text.empty() || !mSellBoard.empty(); + mBuyBoard = text; + updateName(); +} + void Being::enableShop(const bool b) { mShop = b; diff --git a/src/being/being.h b/src/being/being.h index e0fd0f044..a6b588919 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -918,6 +918,11 @@ class Being notfinal : public ActorSprite, std::string getSellBoard() const A_WARN_UNUSED { return mSellBoard; } + void setBuyBoard(const std::string &text); + + std::string getBuyBoard() const A_WARN_UNUSED + { return mBuyBoard; } + protected: /** * Updates name's location. @@ -1033,6 +1038,7 @@ class Being notfinal : public ActorSprite, int *mSpriteHide; int *mSpriteDraw; std::string mComment; + std::string mBuyBoard; std::string mSellBoard; std::vector<Being*> mPets; Being *mOwner; diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 2fa9368cf..f6c694059 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -44,6 +44,7 @@ BeingPopup::BeingPopup() : mBeingGuild(new Label(this, "A")), mBeingRank(new Label(this, "A")), mBeingComment(new Label(this, "A")), + mBeingBuyBoard(new Label(this, "A")), mBeingSellBoard(new Label(this, "A")) { // Being Name @@ -58,6 +59,7 @@ BeingPopup::BeingPopup() : // Being's party mBeingGuild->setPosition(0, 2 * fontHeight); mBeingRank->setPosition(0, 3 * fontHeight); + mBeingBuyBoard->setPosition(0, 4 * fontHeight); mBeingSellBoard->setPosition(0, 4 * fontHeight); mBeingComment->setPosition(0, 5 * fontHeight); @@ -67,6 +69,8 @@ BeingPopup::BeingPopup() : getThemeColor(Theme::POPUP_OUTLINE)); mBeingRank->setForegroundColorAll(getThemeColor(Theme::POPUP), getThemeColor(Theme::POPUP_OUTLINE)); + mBeingBuyBoard->setForegroundColorAll(getThemeColor(Theme::POPUP), + getThemeColor(Theme::POPUP_OUTLINE)); mBeingSellBoard->setForegroundColorAll(getThemeColor(Theme::POPUP), getThemeColor(Theme::POPUP_OUTLINE)); mBeingComment->setForegroundColorAll(getThemeColor(Theme::POPUP), @@ -84,6 +88,7 @@ void BeingPopup::postInit() add(mBeingGuild); add(mBeingRank); add(mBeingComment); + add(mBeingBuyBoard); add(mBeingSellBoard); } @@ -98,8 +103,9 @@ void BeingPopup::show(const int x, const int y, Being *const b) Label *label1 = mBeingParty; Label *label2 = mBeingGuild; Label *label3 = mBeingRank; - Label *label4 = mBeingSellBoard; - Label *label5 = mBeingComment; + Label *label4 = mBeingBuyBoard; + Label *label5 = mBeingSellBoard; + Label *label6 = mBeingComment; b->updateComment(); @@ -135,6 +141,7 @@ void BeingPopup::show(const int x, const int y, Being *const b) label3->setCaption(""); label4->setCaption(""); label5->setCaption(""); + label6->setCaption(""); if (!(b->getPartyName().empty())) { @@ -145,6 +152,7 @@ void BeingPopup::show(const int x, const int y, Being *const b) } else { + label6 = label4; label5 = label4; label4 = label3; label3 = label2; @@ -161,6 +169,7 @@ void BeingPopup::show(const int x, const int y, Being *const b) } else { + label6 = label4; label5 = label4; label4 = label3; label3 = label2; @@ -175,36 +184,51 @@ void BeingPopup::show(const int x, const int y, Being *const b) } else { + label6 = label4; label5 = label4; label4 = label3; label3 = nullptr; } - if (!b->getSellBoard().empty()) + if (!b->getBuyBoard().empty()) { // TRANSLATORS: being popup label - label4->setCaption(strprintf(_("Sell shop: %s"), - b->getSellBoard().c_str())); + label4->setCaption(strprintf(_("Buy shop: %s"), + b->getBuyBoard().c_str())); label4->adjustSize(); } else { + label6 = label4; label5 = label4; label4 = nullptr; } - if (!b->getComment().empty()) + if (!b->getSellBoard().empty()) { // TRANSLATORS: being popup label - label5->setCaption(strprintf(_("Comment: %s"), - b->getComment().c_str())); + label5->setCaption(strprintf(_("Sell shop: %s"), + b->getSellBoard().c_str())); label5->adjustSize(); } else { + label6 = label4; label5 = nullptr; } + if (!b->getComment().empty()) + { + // TRANSLATORS: being popup label + label6->setCaption(strprintf(_("Comment: %s"), + b->getComment().c_str())); + label6->adjustSize(); + } + else + { + label6 = nullptr; + } + int minWidth = mBeingName->getWidth(); if (label1 && label1->getWidth() > minWidth) minWidth = label1->getWidth(); @@ -216,6 +240,8 @@ void BeingPopup::show(const int x, const int y, Being *const b) minWidth = label4->getWidth(); if (label5 && label5->getWidth() > minWidth) minWidth = label5->getWidth(); + if (label6 && label6->getWidth() > minWidth) + minWidth = label6->getWidth(); const int height1 = getFont()->getHeight(); int height = height1; @@ -229,6 +255,8 @@ void BeingPopup::show(const int x, const int y, Being *const b) height += height1; if (label5) height += height1; + if (label6) + height += height1; setContentSize(minWidth, height); position(x, y); diff --git a/src/gui/popups/beingpopup.h b/src/gui/popups/beingpopup.h index 8ba82babb..6203b5ef7 100644 --- a/src/gui/popups/beingpopup.h +++ b/src/gui/popups/beingpopup.h @@ -62,6 +62,7 @@ class BeingPopup final : public Popup Label *mBeingGuild; Label *mBeingRank; Label *mBeingComment; + Label *mBeingBuyBoard; Label *mBeingSellBoard; }; |