aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-12-18 23:34:52 +0100
committerparamat <mat.gregory@virginmedia.com>2017-07-30 18:24:45 +0100
commit640ba7727629392211ed3c2bd116e938883a6f90 (patch)
treecc50d7cbce56771fa5f2a88bc48616d8014b0232
parentd504831ee2adf59421e82202e350f82701bd3cd0 (diff)
downloadminetest-640ba7727629392211ed3c2bd116e938883a6f90.tar.gz
minetest-640ba7727629392211ed3c2bd116e938883a6f90.tar.bz2
minetest-640ba7727629392211ed3c2bd116e938883a6f90.zip
Make direct item selection keys freely bindable
-rw-r--r--builtin/settingtypes.txt92
-rw-r--r--src/client/keys.h25
-rw-r--r--src/defaultsettings.cpp33
-rw-r--r--src/game.cpp20
-rw-r--r--src/keycode.cpp4
-rw-r--r--src/keycode.h1
6 files changed, 158 insertions, 17 deletions
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 383caac13..93520aa5e 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -233,6 +233,98 @@ keymap_drop (Drop item key) key KEY_KEY_Q
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_zoom (View zoom key) key KEY_KEY_Z
+# Key for selecting the first hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot1 (Hotbar slot 1 key) key KEY_KEY_1
+
+# Key for selecting the second hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot2 (Hotbar slot 2 key) key KEY_KEY_2
+
+# Key for selecting the third hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot3 (Hotbar slot 3 key) key KEY_KEY_3
+
+# Key for selecting the fourth hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot4 (Hotbar slot 4 key) key KEY_KEY_4
+
+# Key for selecting the fifth hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot5 (Hotbar slot 5 key) key KEY_KEY_5
+
+# Key for selecting the sixth hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot6 (Hotbar slot 6 key) key KEY_KEY_6
+
+# Key for selecting the seventh hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot7 (Hotbar slot 7 key) key KEY_KEY_7
+
+# Key for selecting the eighth hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot8 (Hotbar slot 8 key) key KEY_KEY_8
+
+# Key for selecting the ninth hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot9 (Hotbar slot 9 key) key KEY_KEY_9
+
+# Key for selecting the tenth hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot10 (Hotbar slot 10 key) key KEY_KEY_0
+
+# Key for selecting the 11th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot11 (Hotbar slot 11 key) key
+
+# Key for selecting the 12th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot12 (Hotbar slot 12 key) key
+
+# Key for selecting the 13th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot13 (Hotbar slot 13 key) key
+
+# Key for selecting the 14th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot14 (Hotbar slot 14 key) key
+
+# Key for selecting the 15th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot15 (Hotbar slot 15 key) key
+
+# Key for selecting the 16th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot16 (Hotbar slot 16 key) key
+
+# Key for selecting the 17th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot17 (Hotbar slot 17 key) key
+
+# Key for selecting the 18th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot18 (Hotbar slot 18 key) key
+
+# Key for selecting the 19th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot19 (Hotbar slot 19 key) key
+
+# Key for selecting the 20th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot20 (Hotbar slot 20 key) key
+
+# Key for selecting the 21th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot21 (Hotbar slot 21 key) key
+
+# Key for selecting the 22th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot22 (Hotbar slot 22 key) key
+
+# Key for selecting the 23th hotbar slot.
+# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
+keymap_slot23 (Hotbar slot 23 key) key
+
# Key for toggling the display of the HUD.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_toggle_hud (HUD toggle key) key KEY_F1
diff --git a/src/client/keys.h b/src/client/keys.h
index 886ae8791..d10c96240 100644
--- a/src/client/keys.h
+++ b/src/client/keys.h
@@ -76,6 +76,31 @@ public:
DEBUG_STACKS,
+ // hotbar
+ SLOT_1,
+ SLOT_2,
+ SLOT_3,
+ SLOT_4,
+ SLOT_5,
+ SLOT_6,
+ SLOT_7,
+ SLOT_8,
+ SLOT_9,
+ SLOT_10,
+ SLOT_11,
+ SLOT_12,
+ SLOT_13,
+ SLOT_14,
+ SLOT_15,
+ SLOT_16,
+ SLOT_17,
+ SLOT_18,
+ SLOT_19,
+ SLOT_20,
+ SLOT_21,
+ SLOT_22,
+ SLOT_23,
+
// joystick specific keys
MOUSE_L,
MOUSE_R,
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 9785b5f5b..797beb3d7 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -101,6 +101,39 @@ void set_default_settings(Settings *settings)
settings->setDefault("keymap_screenshot", "KEY_F12");
settings->setDefault("keymap_increase_viewing_range_min", "+");
settings->setDefault("keymap_decrease_viewing_range_min", "-");
+ settings->setDefault("keymap_slot1", "KEY_KEY_1");
+ settings->setDefault("keymap_slot2", "KEY_KEY_2");
+ settings->setDefault("keymap_slot3", "KEY_KEY_3");
+ settings->setDefault("keymap_slot4", "KEY_KEY_4");
+ settings->setDefault("keymap_slot5", "KEY_KEY_5");
+ settings->setDefault("keymap_slot6", "KEY_KEY_6");
+ settings->setDefault("keymap_slot7", "KEY_KEY_7");
+ settings->setDefault("keymap_slot8", "KEY_KEY_8");
+ settings->setDefault("keymap_slot9", "KEY_KEY_9");
+ settings->setDefault("keymap_slot10", "KEY_KEY_0");
+ settings->setDefault("keymap_slot11", "");
+ settings->setDefault("keymap_slot12", "");
+ settings->setDefault("keymap_slot13", "");
+ settings->setDefault("keymap_slot14", "");
+ settings->setDefault("keymap_slot15", "");
+ settings->setDefault("keymap_slot16", "");
+ settings->setDefault("keymap_slot17", "");
+ settings->setDefault("keymap_slot18", "");
+ settings->setDefault("keymap_slot19", "");
+ settings->setDefault("keymap_slot20", "");
+ settings->setDefault("keymap_slot21", "");
+ settings->setDefault("keymap_slot22", "");
+ settings->setDefault("keymap_slot23", "");
+ settings->setDefault("enable_build_where_you_stand", "false" );
+ settings->setDefault("3d_mode", "none");
+ settings->setDefault("3d_paralax_strength", "0.025");
+ settings->setDefault("aux1_descends", "false");
+ settings->setDefault("doubletap_jump", "false");
+ settings->setDefault("always_fly_fast", "true");
+ settings->setDefault("directional_colored_fog", "true");
+ settings->setDefault("tooltip_show_delay", "400");
+ settings->setDefault("zoom_fov", "15");
+
// Some (temporary) keys for debugging
settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P");
settings->setDefault("keymap_quicktune_prev", "KEY_HOME");
diff --git a/src/game.cpp b/src/game.cpp
index ba4840203..0088bc95d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1107,6 +1107,11 @@ void KeyCache::populate()
key[KeyType::DEBUG_STACKS] = getKeySetting("keymap_print_debug_stacks");
+ for (int i = 0; i < 23; i++) {
+ std::string slot_key_name = "keymap_slot" + std::to_string(i + 1);
+ key[KeyType::SLOT_1 + i] = getKeySetting(slot_key_name.c_str());
+ }
+
if (handler) {
// First clear all keys, then re-add the ones we listen for
handler->dontListenForKeys();
@@ -1115,9 +1120,6 @@ void KeyCache::populate()
}
handler->listenForKey(EscapeKey);
handler->listenForKey(CancelKey);
- for (size_t i = 0; i < 10; i++) {
- handler->listenForKey(NumberKey[i]);
- }
}
}
@@ -2639,16 +2641,10 @@ void Game::processItemSelection(u16 *new_playeritem)
*new_playeritem = *new_playeritem > 0 ? *new_playeritem - 1 : max_item;
// else dir == 0
- /* Item selection using keyboard
+ /* Item selection using hotbar slot keys
*/
- for (u16 i = 0; i < 10; i++) {
- static const KeyPress *item_keys[10] = {
- NumberKey + 1, NumberKey + 2, NumberKey + 3, NumberKey + 4,
- NumberKey + 5, NumberKey + 6, NumberKey + 7, NumberKey + 8,
- NumberKey + 9, NumberKey + 0,
- };
-
- if (input->wasKeyDown(*item_keys[i])) {
+ for (u16 i = 0; i < 23; i++) {
+ if (wasKeyDown((GameKeyType) (KeyType::SLOT_1 + i))) {
if (i < PLAYER_INVENTORY_SIZE && i < player->hud_hotbar_itemcount) {
*new_playeritem = i;
infostream << "Selected item: " << new_playeritem << std::endl;
diff --git a/src/keycode.cpp b/src/keycode.cpp
index 344ac7c83..3551c385a 100644
--- a/src/keycode.cpp
+++ b/src/keycode.cpp
@@ -351,10 +351,6 @@ const char *KeyPress::name() const
const KeyPress EscapeKey("KEY_ESCAPE");
const KeyPress CancelKey("KEY_CANCEL");
-const KeyPress NumberKey[] = {
- KeyPress("0"), KeyPress("1"), KeyPress("2"), KeyPress("3"), KeyPress("4"),
- KeyPress("5"), KeyPress("6"), KeyPress("7"), KeyPress("8"), KeyPress("9")
-};
/*
Key config
diff --git a/src/keycode.h b/src/keycode.h
index f0012d5eb..b413d0396 100644
--- a/src/keycode.h
+++ b/src/keycode.h
@@ -57,7 +57,6 @@ protected:
extern const KeyPress EscapeKey;
extern const KeyPress CancelKey;
-extern const KeyPress NumberKey[10];
// Key configuration getter
KeyPress getKeySetting(const char *settingname);