summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-11 02:37:15 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-11 02:37:15 +0300
commit3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab (patch)
treece02f79d991f526ca8f78d58564cdcaa5db53d67 /src
parent9ac735047746b9455a896b6fe82da36ea4b13ceb (diff)
downloadmv-3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab.tar.gz
mv-3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab.tar.bz2
mv-3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab.tar.xz
mv-3f93a5c9fbe8f4d42d5cb25364b3bf16b59963ab.zip
Extend undress chat command for undress item by id.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp37
-rw-r--r--src/gui/popups/popupmenu.cpp6
2 files changed, 28 insertions, 15 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index eaf0da026..78ebe6406 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -104,8 +104,9 @@
#include "utils/chatutils.h"
#include "utils/delete2.h"
#include "utils/gettext.h"
-#include "utils/timer.h"
#include "utils/mathutils.h"
+#include "utils/parameters.h"
+#include "utils/timer.h"
#ifdef ANDROID
#ifndef USE_SDL2
@@ -1166,27 +1167,43 @@ impHandler(undress)
return false;
const std::string args = event.args;
-
+ StringVect pars;
+ if (!splitParameters(pars, args, " ,", '\"'))
+ return false;
Being *target = nullptr;
- if (!args.empty())
+ const size_t sz = pars.size();
+ if (sz == 0)
{
- if (args[0] == ':')
+ if (!target)
+ target = localPlayer->getTarget();
+ }
+ else
+ {
+ if (pars[0][0] == ':')
{
target = actorManager->findBeing(fromInt(atoi(
- args.substr(1).c_str()), BeingId));
+ pars[0].substr(1).c_str()), BeingId));
if (target && target->getType() == ActorType::Monster)
target = nullptr;
}
else
{
- target = actorManager->findNearestByName(event.args);
+ target = actorManager->findNearestByName(args);
}
}
- if (!target)
- target = localPlayer->getTarget();
- if (target && beingHandler)
- beingHandler->undress(target);
+ if (sz == 2)
+ {
+ const int itemId = atoi(pars[1].c_str());
+ if (target)
+ target->undressItemById(itemId);
+ }
+ else
+ {
+ if (target && beingHandler)
+ beingHandler->undress(target);
+ }
+
return true;
}
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index ce8795b4f..4218a1101 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1238,10 +1238,6 @@ void PopupMenu::handleLink(const std::string &link,
dialog->setActionEventId("ok");
dialog->addActionListener(&mPlayerListener);
}
- else if (link == "undress item" && being && mItemId)
- {
- being->undressItemById(mItemId);
- }
else if (link == "guild-pos" && !mName.empty())
{
showChangePos(getX(), getY());
@@ -2103,7 +2099,7 @@ void PopupMenu::showUndressPopup(const int x, const int y,
// TRANSLATORS: popup menu item
// TRANSLATORS: undress item from player
- mBrowserBox->addRow("undress item", _("Undress"));
+ mBrowserBox->addRow("/undress :'BEINGID' 'ITEMID'", _("Undress"));
// TRANSLATORS: popup menu item
// TRANSLATORS: add item name to chat
mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat"));