diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-12-08 00:43:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-12-08 00:43:21 +0300 |
commit | c075c0daa245819d0a07fea6695f233fd329e397 (patch) | |
tree | 051f09fc1a5cf2ca256c50c9b77f246bb56b7b43 /src/gui/popupmenu.cpp | |
parent | 1ba2a5d3f3687976cefd8b12cd3d001f754b55e3 (diff) | |
download | manaplus-c075c0daa245819d0a07fea6695f233fd329e397.tar.gz manaplus-c075c0daa245819d0a07fea6695f233fd329e397.tar.bz2 manaplus-c075c0daa245819d0a07fea6695f233fd329e397.tar.xz manaplus-c075c0daa245819d0a07fea6695f233fd329e397.zip |
Add to combined menu also floor items.
Diffstat (limited to 'src/gui/popupmenu.cpp')
-rw-r--r-- | src/gui/popupmenu.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index e49d5c451..15afc7600 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -350,22 +350,36 @@ void PopupMenu::showPopup(int x, int y, Being *being) showPopup(x, y); } -void PopupMenu::showPopup(int x, int y, std::vector<Being*> &beings) +void PopupMenu::showPopup(int x, int y, std::vector<ActorSprite*> &beings) { mX = x; mY = y; mBrowserBox->clearRows(); - mBrowserBox->addRow("Players"); - std::vector<Being*>::const_iterator it, it_end; + mBrowserBox->addRow(_("Players")); + std::vector<ActorSprite*>::const_iterator it, it_end; for (it = beings.begin(), it_end = beings.end(); it != it_end; ++it) { - Being *being = *it; - if (!being->getName().empty()) + Being *being = dynamic_cast<Being*>(*it); + ActorSprite *actor = *it; + if (being && !being->getName().empty()) { mBrowserBox->addRow(strprintf("@@player_%u|%s >@@", being->getId(), (being->getName() + being->getGenderSignWithSpace()).c_str())); } + else if(actor->getType() == ActorSprite::FLOOR_ITEM) + { + FloorItem *floorItem = static_cast<FloorItem*>(actor); + const ItemInfo &info = floorItem->getInfo(); + std::string name; + + if (serverVersion > 0) + name = info.getName(floorItem->getColor()); + else + name = info.getName(); + mBrowserBox->addRow(strprintf("@@flooritem_%u|%s >@@", + actor->getId(), name.c_str())); + } } mBrowserBox->addRow("##3---"); mBrowserBox->addRow("cancel", _("Cancel")); @@ -1685,6 +1699,22 @@ void PopupMenu::handleLink(const std::string &link, } } } + else if (!link.compare(0, 10, "flooritem_")) + { + if (actorSpriteManager) + { + int id = atoi(link.substr(10).c_str()); + if (id) + { + mFloorItem = actorSpriteManager->findItem(id); + if (mFloorItem) + { + showPopup(getX(), getY(), mFloorItem); + return; + } + } + } + } else if (!link.compare(0, 12, "hide button_")) { if (windowMenu) |