summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-26 21:40:24 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-27 02:22:56 +0300
commit3a19b08078d42837126cc585d2a9b6f5f61b2c2b (patch)
tree400122420df75e178cb7d52cfd2f67cd12d394a8
parent4a6e5d83cd39dfde59d273b9be79cd76c685a8e9 (diff)
downloadplus-3a19b08078d42837126cc585d2a9b6f5f61b2c2b.tar.gz
plus-3a19b08078d42837126cc585d2a9b6f5f61b2c2b.tar.bz2
plus-3a19b08078d42837126cc585d2a9b6f5f61b2c2b.tar.xz
plus-3a19b08078d42837126cc585d2a9b6f5f61b2c2b.zip
Add quick shortcuts for add selected item to each craft inventory slot.
Add craft tab with shortcuts in input tab.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/actions/actions.cpp14
-rw-r--r--src/actions/actions.h1
-rw-r--r--src/dyetool/actions/actions.cpp1
-rw-r--r--src/enums/input/inputaction.h9
-rw-r--r--src/gui/setupinputpages.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp6
-rw-r--r--src/gui/windows/inventorywindow.cpp32
-rw-r--r--src/gui/windows/inventorywindow.h4
-rw-r--r--src/gui/windows/npcdialog.h40
-rw-r--r--src/input/inputactionmap.h99
-rw-r--r--src/input/pages/craft.cpp89
-rw-r--r--src/input/pages/craft.h28
14 files changed, 313 insertions, 18 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e5398adb9..c11074d71 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -462,6 +462,8 @@ SET(SRCS
input/pages/basic.h
input/pages/chat.cpp
input/pages/chat.h
+ input/pages/craft.cpp
+ input/pages/craft.h
input/pages/emotes.cpp
input/pages/emotes.h
input/pages/gui.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 4e723484d..61ac91935 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1078,6 +1078,8 @@ manaplus_SOURCES += main.cpp \
input/pages/basic.h \
input/pages/chat.cpp \
input/pages/chat.h \
+ input/pages/craft.cpp \
+ input/pages/craft.h \
input/pages/emotes.cpp \
input/pages/emotes.h \
input/pages/gui.cpp \
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index df4f23779..eb6404d37 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -1674,4 +1674,18 @@ impHandler0(testInfo)
return false;
}
+impHandler(craftKey)
+{
+#ifdef EATHENA_SUPPORT
+ const int slot = (event.action - InputAction::CRAFT_1);
+ if (slot >= 0 && slot < 9)
+ {
+ if (inventoryWindow)
+ inventoryWindow->moveItemToCraft(slot);
+ return true;
+ }
+#endif
+ return false;
+}
+
} // namespace Actions
diff --git a/src/actions/actions.h b/src/actions/actions.h
index cb382ddef..712017bd0 100644
--- a/src/actions/actions.h
+++ b/src/actions/actions.h
@@ -109,6 +109,7 @@ namespace Actions
decHandler(kick);
decHandler(clearDrop);
decHandler(testInfo);
+ decHandler(craftKey);
} // namespace Actions
#undef decHandler
diff --git a/src/dyetool/actions/actions.cpp b/src/dyetool/actions/actions.cpp
index c7fb2d7f8..35c9d8d45 100644
--- a/src/dyetool/actions/actions.cpp
+++ b/src/dyetool/actions/actions.cpp
@@ -106,5 +106,6 @@ impHandlerVoid(unprotectItem)
impHandlerVoid(kick)
impHandlerVoid(clearDrop)
impHandlerVoid(testInfo)
+impHandlerVoid(craftKey)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 2c3827840..1b004f93b 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -607,6 +607,15 @@ enumStart(InputAction)
SLIDE,
SELECT_SKILL_LEVEL,
SKILL,
+ CRAFT_1,
+ CRAFT_2,
+ CRAFT_3,
+ CRAFT_4,
+ CRAFT_5,
+ CRAFT_6,
+ CRAFT_7,
+ CRAFT_8,
+ CRAFT_9,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/gui/setupinputpages.cpp b/src/gui/setupinputpages.cpp
index 6f93c635e..32efcecdb 100644
--- a/src/gui/setupinputpages.cpp
+++ b/src/gui/setupinputpages.cpp
@@ -27,6 +27,7 @@
#include "input/pages/basic.h"
#include "input/pages/chat.h"
+#include "input/pages/craft.h"
#include "input/pages/emotes.h"
#include "input/pages/gui.h"
#include "input/pages/move.h"
@@ -48,6 +49,8 @@ const char *const pages[] =
// TRANSLATORS: input tab sub tab name
N_("Windows"),
// TRANSLATORS: input tab sub tab name
+ N_("Craft"),
+ // TRANSLATORS: input tab sub tab name
N_("Emotes"),
// TRANSLATORS: input tab sub tab name
N_("Outfits"),
@@ -66,6 +69,7 @@ SetupActionData *const setupActionData[] =
setupActionDataMove,
setupActionDataShortcuts,
setupActionDataWindows,
+ setupActionDataCraft,
setupActionDataEmotes,
setupActionDataOutfits,
setupActionDataChat,
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index 4872821f7..50187cffd 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -29,6 +29,7 @@
#include "input/inputmanager.h"
#include "input/keyboardconfig.h"
+#include "input/pages/craft.h"
#include "input/pages/emotes.h"
#include "input/pages/move.h"
#include "input/pages/outfits.h"
@@ -381,6 +382,11 @@ void Setup_Input::fixTranslations()
InputAction::EMOTE_48,
"Emote Shortcut %d");
+ fixTranslation(setupActionDataCraft,
+ InputAction::CRAFT_1,
+ InputAction::CRAFT_9,
+ "Craft shortcut %d");
+
fixTranslation(setupActionDataOutfits,
InputAction::OUTFIT_1,
InputAction::OUTFIT_48,
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index eac1b692d..76dfef268 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -41,6 +41,7 @@
#include "gui/windows/confirmdialog.h"
#include "gui/windows/itemamountwindow.h"
+#include "gui/windows/npcdialog.h"
#include "gui/windows/setupwindow.h"
#include "gui/windows/tradewindow.h"
@@ -59,6 +60,8 @@
#include "listeners/insertcardlistener.h"
+#include "net/npchandler.h"
+
#include "resources/iteminfo.h"
#include "resources/item/item.h"
@@ -1056,4 +1059,33 @@ void InventoryWindow::combineItems(const int index1,
insertCardListener.cardIndex = item1->getInvIndex();
confirmDlg->addActionListener(&insertCardListener);
}
+
+void InventoryWindow::moveItemToCraft(const int craftSlot)
+{
+ if (!npcHandler)
+ return;
+
+ Item *const item = mItems->getSelectedItem();
+ if (!item)
+ return;
+
+ NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
+ if (dialog &&
+ dialog->getInputState() == NpcDialog::NPC_INPUT_ITEM_CRAFT)
+ {
+ if (item->getQuantity() > 1
+ && !inputManager.isActionActive(InputAction::STOP_ATTACK))
+ {
+ ItemAmountWindow::showWindow(ItemAmountWindow::CraftAdd,
+ npcHandler->getCurrentNpcDialog(),
+ item,
+ 0,
+ craftSlot);
+ }
+ else
+ {
+ dialog->addCraftItem(item, 1, craftSlot);
+ }
+ }
+}
#endif
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index 6c02e4304..930ce9e72 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -156,9 +156,13 @@ class InventoryWindow final : public Window,
const int oldVal,
const int newVal) override final;
+#ifdef EATHENA_SUPPORT
void combineItems(const int index1,
const int index2);
+ void moveItemToCraft(const int craftSlot);
+#endif
+
static bool isAnyInputFocused();
static InventoryWindow *getFirstVisible();
diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h
index 29f728c91..524ae7bd8 100644
--- a/src/gui/windows/npcdialog.h
+++ b/src/gui/windows/npcdialog.h
@@ -77,6 +77,25 @@ class NpcDialog final : public Window,
void postInit() override final;
+ enum NpcInputState
+ {
+ NPC_INPUT_NONE = 0,
+ NPC_INPUT_LIST,
+ NPC_INPUT_STRING,
+ NPC_INPUT_INTEGER,
+ NPC_INPUT_ITEM,
+ NPC_INPUT_ITEM_INDEX,
+ NPC_INPUT_ITEM_CRAFT
+ };
+
+ enum NpcActionState
+ {
+ NPC_ACTION_WAIT = 0,
+ NPC_ACTION_NEXT,
+ NPC_ACTION_INPUT,
+ NPC_ACTION_CLOSE
+ };
+
/**
* Called when receiving actions from the widgets.
*/
@@ -228,6 +247,9 @@ class NpcDialog final : public Window,
const int amount,
const int slot);
+ NpcInputState getInputState()
+ { return mInputState; }
+
static void copyToClipboard(const BeingId npcId,
const int x, const int y);
@@ -303,24 +325,6 @@ class NpcDialog final : public Window,
ItemContainer *mItemContainer A_NONNULLPOINTER;
ScrollArea *mItemScrollArea A_NONNULLPOINTER;
- enum NpcInputState
- {
- NPC_INPUT_NONE = 0,
- NPC_INPUT_LIST,
- NPC_INPUT_STRING,
- NPC_INPUT_INTEGER,
- NPC_INPUT_ITEM,
- NPC_INPUT_ITEM_INDEX,
- NPC_INPUT_ITEM_CRAFT
- };
-
- enum NpcActionState
- {
- NPC_ACTION_WAIT = 0,
- NPC_ACTION_NEXT,
- NPC_ACTION_INPUT,
- NPC_ACTION_CLOSE
- };
NpcInputState mInputState;
NpcActionState mActionState;
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index b187b63b0..f76e8cb53 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5086,6 +5086,105 @@ static const InputActionData inputActionData
"skill|useskill",
UseArgs_true,
Protected_false},
+ {"keyCraftShortcut1",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
+ {"keyCraftShortcut2",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
+ {"keyCraftShortcut3",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
+ {"keyCraftShortcut4",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
+ {"keyCraftShortcut5",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
+ {"keyCraftShortcut6",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
+ {"keyCraftShortcut7",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
+ {"keyCraftShortcut8",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
+ {"keyCraftShortcut9",
+ emptyKey,
+ emptyKey,
+ Input::GRP_DEFAULT,
+ &Actions::craftKey,
+ InputAction::NO_VALUE, 100,
+ InputCondition::NOMODAL | InputCondition::NOAWAY
+ | InputCondition::NONPCINPUT,
+ "",
+ UseArgs_false,
+ Protected_true},
};
#undef defaultAction
diff --git a/src/input/pages/craft.cpp b/src/input/pages/craft.cpp
new file mode 100644
index 000000000..5b5bf0466
--- /dev/null
+++ b/src/input/pages/craft.cpp
@@ -0,0 +1,89 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2016 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/setupactiondata.h"
+
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+SetupActionData setupActionDataCraft[] =
+{
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 1),
+ InputAction::CRAFT_1,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 2),
+ InputAction::CRAFT_2,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 3),
+ InputAction::CRAFT_3,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 4),
+ InputAction::CRAFT_4,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 5),
+ InputAction::CRAFT_5,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 6),
+ InputAction::CRAFT_6,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 7),
+ InputAction::CRAFT_7,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 8),
+ InputAction::CRAFT_8,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ strprintf(N_("Craft shortcut %d"), 9),
+ InputAction::CRAFT_9,
+ "",
+ },
+ {
+ "",
+ InputAction::NO_VALUE,
+ ""
+ },
+};
diff --git a/src/input/pages/craft.h b/src/input/pages/craft.h
new file mode 100644
index 000000000..ef797f7a5
--- /dev/null
+++ b/src/input/pages/craft.h
@@ -0,0 +1,28 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2016 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INPUT_PAGES_CRAFT_H
+#define INPUT_PAGES_CRAFT_H
+
+#include "gui/setupactiondata.h"
+
+extern SetupActionData setupActionDataCraft[];
+
+#endif // INPUT_PAGES_CRAFT_H