diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/popupmenu.cpp | 40 | ||||
-rw-r--r-- | src/gui/popupmenu.h | 4 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 2 |
3 files changed, 39 insertions, 7 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) diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 6dc9a953a..2db565ab7 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -26,6 +26,8 @@ #include "gui/widgets/linkhandler.h" #include "gui/widgets/popup.h" +#include "actorsprite.h" + #include <guichan/actionlistener.hpp> #include "localconsts.h" @@ -102,7 +104,7 @@ class PopupMenu : public Popup, public LinkHandler /** * Shows the beings related popup menu at the specified mouse coords. */ - void showPopup(int x, int y, std::vector<Being*> &beings); + void showPopup(int x, int y, std::vector<ActorSprite*> &beings); void showPlayerPopup(int x, int y, std::string nick); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 3086a027f..b6c55f2c4 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -432,7 +432,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { if (actorSpriteManager) { - std::vector<Being*> beings; + std::vector<ActorSprite*> beings; const int x = getMouseX() + static_cast<int>(mPixelViewX); const int y = getMouseY() + static_cast<int>(mPixelViewY); actorSpriteManager->findBeingsByPixel(beings, x, y, true); |