diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-11 00:22:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-11 00:22:44 +0300 |
commit | 48d66daa641c58d68a4150b1f6bf958dfb8ecb13 (patch) | |
tree | 8db421d088f95f5e007e82840e4b87ae99aed128 /src | |
parent | 926a702799f919bbe75f3e8adcac30129749a963 (diff) | |
download | manaplus-48d66daa641c58d68a4150b1f6bf958dfb8ecb13.tar.gz manaplus-48d66daa641c58d68a4150b1f6bf958dfb8ecb13.tar.bz2 manaplus-48d66daa641c58d68a4150b1f6bf958dfb8ecb13.tar.xz manaplus-48d66daa641c58d68a4150b1f6bf958dfb8ecb13.zip |
Handle custom commands in npc menu.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index b636d1d7c..4e85109ca 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -390,7 +390,7 @@ bool PopupMenu::addBeingMenu() FOR_EACH (std::vector<BeingMenuItem>::const_iterator, it, menu) { const BeingMenuItem &item = *it; - mBrowserBox->addRow("@" + item.command, item.name.c_str()); + mBrowserBox->addRow("/" + item.command, item.name.c_str()); } return true; } @@ -2024,6 +2024,25 @@ void PopupMenu::handleLink(const std::string &link, if (id >= 0) inputManager.executeAction(id); } + else if(!link.empty() && link[0] == '/') + { + std::string cmd = link.substr(1); + replaceAll(cmd, "'NAME'", mNick); + replaceAll(cmd, "'X'", toString(mX)); + replaceAll(cmd, "'Y'", toString(mY)); + replaceAll(cmd, "'BEINGID'", toString(mBeingId)); + replaceAll(cmd, "'FLOORID'", toString(mFloorItemId)); + replaceAll(cmd, "'ITEMID'", toString(mItemId)); + replaceAll(cmd, "'ITEMCOLOR'", toString(mItemColor)); + replaceAll(cmd, "'BEINGTYPEID'", toString(mType)); + replaceAll(cmd, "'PLAYER'", localPlayer->getName()); + + const size_t pos = cmd.find(' '); + const std::string type(cmd, 0, pos); + std::string args(cmd, pos == std::string::npos ? cmd.size() : pos + 1); + args = trim(args); + inputManager.executeChatCommand(type, args, mTab); + } // Unknown actions else if (link != "cancel") { |