summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-10 04:32:18 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-10 04:32:18 +0300
commit1fa706c6669db9a2d060d100cf591fd505012a9d (patch)
treedee79462d680321e05c6a688146d2116f83bb3f6 /src
parent2291f18b6366312916903de6cfe973379ebd536d (diff)
downloadmanaplus-s20170510.tar.gz
manaplus-s20170510.tar.bz2
manaplus-s20170510.tar.xz
manaplus-s20170510.zip
Add chat command for show player items.s20170510
Diffstat (limited to 'src')
-rw-r--r--src/actions/windows.cpp38
-rw-r--r--src/actions/windows.h1
-rw-r--r--src/dyetool/actions/windows.cpp1
-rw-r--r--src/enums/input/inputaction.h1
-rw-r--r--src/gui/popups/popupmenu.cpp18
-rw-r--r--src/input/inputactionmap.h6
6 files changed, 48 insertions, 17 deletions
diff --git a/src/actions/windows.cpp b/src/actions/windows.cpp
index 2e6c8d78c..bb7de28df 100644
--- a/src/actions/windows.cpp
+++ b/src/actions/windows.cpp
@@ -20,6 +20,8 @@
#include "actions/windows.h"
+#include "actormanager.h"
+
#include "actions/actiondef.h"
#include "being/localplayer.h"
@@ -320,4 +322,40 @@ impHandler0(mailWindowShow)
return true;
}
+impHandler(showItems)
+{
+ const std::string args = event.args;
+ if (args.empty())
+ return false;
+
+ Being *being = nullptr;
+ if (args[0] == ':')
+ {
+ being = actorManager->findBeing(fromInt(atoi(
+ args.substr(1).c_str()), BeingId));
+ if (being && being->getType() == ActorType::Monster)
+ being = nullptr;
+ }
+ else
+ {
+ being = actorManager->findBeingByName(args, ActorType::Player);
+ }
+ if (!being)
+ return true;
+ if (being == localPlayer)
+ {
+ if (equipmentWindow && !equipmentWindow->isWindowVisible())
+ equipmentWindow->setVisible(Visible_true);
+ }
+ else
+ {
+ if (beingEquipmentWindow)
+ {
+ beingEquipmentWindow->setBeing(being);
+ beingEquipmentWindow->setVisible(Visible_true);
+ }
+ }
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/windows.h b/src/actions/windows.h
index 8026b9a6f..3820ee9fe 100644
--- a/src/actions/windows.h
+++ b/src/actions/windows.h
@@ -54,6 +54,7 @@ namespace Actions
decHandler(cartWindowShow);
decHandler(quickWindowShow);
decHandler(mailWindowShow);
+ decHandler(showItems);
} // namespace Actions
#undef decHandler
diff --git a/src/dyetool/actions/windows.cpp b/src/dyetool/actions/windows.cpp
index f55930de0..635a64f9f 100644
--- a/src/dyetool/actions/windows.cpp
+++ b/src/dyetool/actions/windows.cpp
@@ -54,5 +54,6 @@ impHandlerVoid(cartWindowShow)
impHandlerVoid(updaterWindowShow)
impHandlerVoid(quickWindowShow)
impHandlerVoid(mailWindowShow)
+impHandlerVoid(showItems)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index dfff6b401..2be35e654 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -692,6 +692,7 @@ enumStart(InputAction)
MOVE_ATTACK_DOWN,
MOVE_PRIORITY_ATTACK_UP,
MOVE_PRIORITY_ATTACK_DOWN,
+ SHOW_ITEMS,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 47ef604be..f99332f00 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1239,22 +1239,6 @@ void PopupMenu::handleLink(const std::string &link,
dialog->setActionEventId("ok");
dialog->addActionListener(&mPlayerListener);
}
- else if (link == "items" && being)
- {
- if (being == localPlayer)
- {
- if (equipmentWindow && !equipmentWindow->isWindowVisible())
- equipmentWindow->setVisible(Visible_true);
- }
- else
- {
- if (beingEquipmentWindow)
- {
- beingEquipmentWindow->setBeing(being);
- beingEquipmentWindow->setVisible(Visible_true);
- }
- }
- }
else if (link == "undress item" && being && mItemId)
{
being->undressItemById(mItemId);
@@ -2651,7 +2635,7 @@ void PopupMenu::addChat(const Being *const being)
void PopupMenu::addPlayerMisc()
{
// TRANSLATORS: popup menu item
- mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("/showitems :'BEINGID'", _("Show Items"));
// TRANSLATORS: popup menu item
// TRANSLATORS: undress player
mBrowserBox->addRow("/undress :'BEINGID'", _("Undress"));
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index a2507f884..908a0d4b5 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5642,6 +5642,12 @@ static const InputActionData inputActionData
"attackmoveprioritydown|movepriorityattackdown",
UseArgs_true,
Protected_true},
+ {"keyShowItems",
+ defaultAction(&Actions::showItems),
+ InputCondition::INGAME,
+ "showitems|items|itemsshow",
+ UseArgs_true,
+ Protected_true},
};
#undef defaultAction