From ab608a29a138cd5db47fad949f1f3993d21af153 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Jan 2016 16:07:28 +0300 Subject: Add context menu for moving items to craft. --- src/gui/popups/popupmenu.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ src/gui/popups/popupmenu.h | 4 ++++ 2 files changed, 46 insertions(+) (limited to 'src') diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index b1b33155c..d1e23b558 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -72,6 +72,7 @@ #ifdef EATHENA_SUPPORT #include "net/homunculushandler.h" #include "net/mercenaryhandler.h" +#include "net/npchandler.h" #endif #include "net/pethandler.h" #include "net/serverfeatures.h" @@ -1473,6 +1474,11 @@ void PopupMenu::handleLink(const std::string &link, { homunculusHandler->fire(); } + else if (link == "craftmenu") + { + showCraftPopup(); + return; + } #endif else if (link == "pet feed") { @@ -1733,6 +1739,20 @@ void PopupMenu::showPopup(Window *const parent, } mBrowserBox->addRow("##3---"); } +#ifdef EATHENA_SUPPORT + if (npcHandler) + { + NpcDialog *const dialog = npcHandler->getCurrentNpcDialog(); + if (dialog && + dialog->getInputState() == NpcDialog::NPC_INPUT_ITEM_CRAFT) + { + mBrowserBox->addRow("craftmenu", + // TRANSLATORS: popup menu item + // TRANSLATORS: sub menu for craft + _("Move to craft...")); + } + } +#endif addUseDrop(item, isProtected); break; @@ -2787,6 +2807,28 @@ void PopupMenu::showGMPopup() showPopup(getX(), getY()); } +#ifdef EATHENA_SUPPORT +void PopupMenu::showCraftPopup() +{ + mBrowserBox->clearRows(); + + for (int f = 0; f < 9; f ++) + { + const std::string cmd = strprintf("/craft %d", f); + mBrowserBox->addRow(cmd, + // TRANSLATORS: popup menu item + // TRANSLATORS: move current item to craft slot + strprintf(_("Move to craft %d"), f + 1).c_str()); + } + + // TRANSLATORS: popup menu item + // TRANSLATORS: close menu + mBrowserBox->addRow("cancel", _("Cancel")); + + showPopup(mX, mY); +} +#endif + void PopupMenu::moveUp() { mBrowserBox->moveSelectionUp(); diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 798a4359a..ca6d58ee6 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -158,6 +158,10 @@ class PopupMenu final : public Popup, public LinkHandler void showSkillPopup(const SkillInfo *const info); +#ifdef EATHENA_SUPPORT + void showCraftPopup(); +#endif + /** * Handles link action. */ -- cgit v1.2.3-70-g09d2