diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-01 16:29:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-02 00:13:44 +0300 |
commit | 2464d9d85019711583ef830c2fdeae8a6772cb53 (patch) | |
tree | fd007695db4d5c4a06376c27421a3c5a61e129a3 | |
parent | b6a0e05498b2b1a64d9b407fb2416dbaa0faf407 (diff) | |
download | manaverse-2464d9d85019711583ef830c2fdeae8a6772cb53.tar.gz manaverse-2464d9d85019711583ef830c2fdeae8a6772cb53.tar.bz2 manaverse-2464d9d85019711583ef830c2fdeae8a6772cb53.tar.xz manaverse-2464d9d85019711583ef830c2fdeae8a6772cb53.zip |
Show shop name on players.
-rw-r--r-- | src/being/being.cpp | 6 | ||||
-rw-r--r-- | src/being/being.h | 6 | ||||
-rw-r--r-- | src/gui/popups/beingpopup.cpp | 39 | ||||
-rw-r--r-- | src/gui/popups/beingpopup.h | 1 | ||||
-rw-r--r-- | src/net/eathena/vendinghandler.cpp | 13 |
5 files changed, 56 insertions, 9 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index c1ccf3c90..06012f708 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(), + mBoard(), mPets(), mOwner(nullptr), mSpecialParticle(nullptr), @@ -3526,3 +3527,8 @@ void Being::setChat(ChatObject *const obj) delete mChat; mChat = obj; } + +void Being::setBoard(const std::string &text) +{ + mBoard = text; +} diff --git a/src/being/being.h b/src/being/being.h index 361277f27..0f6a81413 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -914,6 +914,11 @@ class Being notfinal : public ActorSprite, void setAreaSize(const int areaSize) { mAreaSize = areaSize; } + void setBoard(const std::string &text); + + std::string getBoard() const A_WARN_UNUSED + { return mBoard; } + protected: /** * Updates name's location. @@ -1029,6 +1034,7 @@ class Being notfinal : public ActorSprite, int *mSpriteHide; int *mSpriteDraw; std::string mComment; + std::string mBoard; std::vector<Being*> mPets; Being *mOwner; Particle *mSpecialParticle; diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 918e39f41..7a3194a36 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -43,7 +43,8 @@ BeingPopup::BeingPopup() : mBeingParty(new Label(this, "A")), mBeingGuild(new Label(this, "A")), mBeingRank(new Label(this, "A")), - mBeingComment(new Label(this, "A")) + mBeingComment(new Label(this, "A")), + mBeingBoard(new Label(this, "A")) { // Being Name mBeingName->setFont(boldFont); @@ -57,7 +58,8 @@ BeingPopup::BeingPopup() : // Being's party mBeingGuild->setPosition(0, 2 * fontHeight); mBeingRank->setPosition(0, 3 * fontHeight); - mBeingComment->setPosition(0, 4 * fontHeight); + mBeingBoard->setPosition(0, 4 * fontHeight); + mBeingComment->setPosition(0, 5 * fontHeight); mBeingParty->setForegroundColorAll(getThemeColor(Theme::POPUP), getThemeColor(Theme::POPUP_OUTLINE)); @@ -65,6 +67,8 @@ BeingPopup::BeingPopup() : getThemeColor(Theme::POPUP_OUTLINE)); mBeingRank->setForegroundColorAll(getThemeColor(Theme::POPUP), getThemeColor(Theme::POPUP_OUTLINE)); + mBeingBoard->setForegroundColorAll(getThemeColor(Theme::POPUP), + getThemeColor(Theme::POPUP_OUTLINE)); mBeingComment->setForegroundColorAll(getThemeColor(Theme::POPUP), getThemeColor(Theme::POPUP_OUTLINE)); } @@ -80,6 +84,7 @@ void BeingPopup::postInit() add(mBeingGuild); add(mBeingRank); add(mBeingComment); + add(mBeingBoard); } void BeingPopup::show(const int x, const int y, Being *const b) @@ -93,7 +98,8 @@ void BeingPopup::show(const int x, const int y, Being *const b) Label *label1 = mBeingParty; Label *label2 = mBeingGuild; Label *label3 = mBeingRank; - Label *label4 = mBeingComment; + Label *label4 = mBeingBoard; + Label *label5 = mBeingComment; b->updateComment(); @@ -128,6 +134,7 @@ void BeingPopup::show(const int x, const int y, Being *const b) label2->setCaption(""); label3->setCaption(""); label4->setCaption(""); + label5->setCaption(""); if (!(b->getPartyName().empty())) { @@ -138,6 +145,7 @@ void BeingPopup::show(const int x, const int y, Being *const b) } else { + label5 = label4; label4 = label3; label3 = label2; label2 = label1; @@ -153,6 +161,7 @@ void BeingPopup::show(const int x, const int y, Being *const b) } else { + label5 = label4; label4 = label3; label3 = label2; label2 = nullptr; @@ -166,22 +175,36 @@ void BeingPopup::show(const int x, const int y, Being *const b) } else { + label5 = label4; label4 = label3; label3 = nullptr; } - if (!b->getComment().empty()) + if (!b->getBoard().empty()) { // TRANSLATORS: being popup label - label4->setCaption(strprintf(_("Comment: %s"), - b->getComment().c_str())); + label4->setCaption(strprintf(_("Shop: %s"), + b->getBoard().c_str())); label4->adjustSize(); } else { + label5 = label4; label4 = nullptr; } + if (!b->getComment().empty()) + { + // TRANSLATORS: being popup label + label5->setCaption(strprintf(_("Comment: %s"), + b->getComment().c_str())); + label5->adjustSize(); + } + else + { + label5 = nullptr; + } + int minWidth = mBeingName->getWidth(); if (label1 && label1->getWidth() > minWidth) minWidth = label1->getWidth(); @@ -191,6 +214,8 @@ void BeingPopup::show(const int x, const int y, Being *const b) minWidth = label3->getWidth(); if (label4 && label4->getWidth() > minWidth) minWidth = label4->getWidth(); + if (label5 && label5->getWidth() > minWidth) + minWidth = label5->getWidth(); const int height1 = getFont()->getHeight(); int height = height1; @@ -202,6 +227,8 @@ void BeingPopup::show(const int x, const int y, Being *const b) height += height1; if (label4) height += height1; + if (label5) + height += height1; setContentSize(minWidth, height); position(x, y); diff --git a/src/gui/popups/beingpopup.h b/src/gui/popups/beingpopup.h index fcc8bc7e4..8f43719ae 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 *mBeingBoard; }; extern BeingPopup *beingPopup; diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp index 54f1b74c1..ec765d559 100644 --- a/src/net/eathena/vendinghandler.cpp +++ b/src/net/eathena/vendinghandler.cpp @@ -20,6 +20,7 @@ #include "net/eathena/vendinghandler.h" +#include "actormanager.h" #include "shopitem.h" #include "being/being.h" @@ -99,13 +100,19 @@ void VendingHandler::processOpenReq(Net::MessageIn &msg) void VendingHandler::processShowBoard(Net::MessageIn &msg) { - msg.readInt32("owner id"); - msg.readString(80, "shop name"); + const int id = msg.readInt32("owner id"); + const std::string shopName = msg.readString(80, "shop name"); + Being *const dstBeing = actorManager->findBeing(id); + if (dstBeing) + dstBeing->setBoard(shopName); } void VendingHandler::processHideBoard(Net::MessageIn &msg) { - msg.readInt32("owner id"); + const int id = msg.readInt32("owner id"); + Being *const dstBeing = actorManager->findBeing(id); + if (dstBeing) + dstBeing->setBoard(std::string()); } void VendingHandler::processItemsList(Net::MessageIn &msg) |