summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-12 13:40:11 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-12 13:40:11 +0300
commit91160e197b1a1f85f21cfad874e80fa286d9294f (patch)
tree69fe35efe151cac178ed45eb46600aee6c2b4fc9
parent99b516c9b20e696ddf3897bff9bc6686debf0f5a (diff)
downloadmanaplus-91160e197b1a1f85f21cfad874e80fa286d9294f.tar.gz
manaplus-91160e197b1a1f85f21cfad874e80fa286d9294f.tar.bz2
manaplus-91160e197b1a1f85f21cfad874e80fa286d9294f.tar.xz
manaplus-91160e197b1a1f85f21cfad874e80fa286d9294f.zip
Add chat command for use item by id.
New chat command: /use ITEMID Alias: /useitem ITEMID
-rw-r--r--src/actions/actions.cpp28
-rw-r--r--src/actions/actions.h1
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h9
4 files changed, 39 insertions, 0 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 93e160750..4cd863dc9 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -26,7 +26,9 @@
#include "emoteshortcut.h"
#include "game.h"
#include "graphicsmanager.h"
+#include "inventory.h"
#include "itemshortcut.h"
+#include "spellmanager.h"
#include "actions/actiondef.h"
@@ -53,6 +55,7 @@
#include "gui/windows/setupwindow.h"
#include "gui/windows/shopwindow.h"
#include "gui/windows/shortcutwindow.h"
+#include "gui/windows/skilldialog.h"
#include "gui/widgets/tabs/chat/chattab.h"
@@ -76,6 +79,7 @@
#include "resources/iteminfo.h"
#include "resources/resourcemanager.h"
+#include "resources/skillconsts.h"
#include "resources/db/itemdb.h"
@@ -1287,4 +1291,28 @@ impHandler0(mercenaryFire)
return true;
}
+impHandler(useItem)
+{
+ const int itemId = atoi(event.args.c_str());
+
+ if (itemId < SPELL_MIN_ID)
+ {
+ const Inventory *const inv = PlayerInfo::getInventory();
+ if (inv)
+ {
+ // +++ ignoring item color for now
+ const Item *const item = inv->findItem(itemId, 1);
+ PlayerInfo::useEquipItem(item, true);
+ }
+ }
+ else if (itemId < SKILL_MIN_ID && spellManager)
+ {
+ spellManager->useItem(itemId);
+ }
+ else if (skillDialog)
+ {
+ skillDialog->useItem(itemId);
+ }
+}
+
} // namespace Actions
diff --git a/src/actions/actions.h b/src/actions/actions.h
index c614f61c7..642026d76 100644
--- a/src/actions/actions.h
+++ b/src/actions/actions.h
@@ -92,6 +92,7 @@ namespace Actions
decHandler(uploadLog);
decHandler(catchPet);
decHandler(mercenaryFire);
+ decHandler(useItem);
} // namespace Actions
#undef decHandler
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index e2fcae031..c020b3b5b 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -495,6 +495,7 @@ namespace InputAction
WHISPER2,
GUILD,
NUKE,
+ USE,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 1ae660fb0..f51f5f6f5 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -4198,6 +4198,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputCondition::INGAME,
"nuke",
true},
+ {"keyUse",
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ Input::GRP_DEFAULT,
+ &Actions::useItem,
+ InputAction::NO_VALUE, 50,
+ InputCondition::INGAME,
+ "use|useitem",
+ true},
};
#endif // INPUT_INPUTACTIONMAP_H