Skip to content

Commit

Permalink
Raise hotbar limit to 32 slots, add associated keybinding options (#7916
Browse files Browse the repository at this point in the history
)

add associated keybinding options
update docs and settingtypes
  • Loading branch information
VanessaE authored and sfan5 committed Dec 2, 2018
1 parent 42166ff commit 1b0fd19
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 11 deletions.
42 changes: 39 additions & 3 deletions builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,54 @@ keymap_slot19 (Hotbar slot 19 key) key
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot20 (Hotbar slot 20 key) key

# Key for selecting the 21th hotbar slot.
# Key for selecting the 21st 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.
# Key for selecting the 22nd 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.
# Key for selecting the 23rd hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot23 (Hotbar slot 23 key) key

# Key for selecting the 24th hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot24 (Hotbar slot 24 key) key

# Key for selecting the 25th hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot25 (Hotbar slot 25 key) key

# Key for selecting the 26th hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot26 (Hotbar slot 26 key) key

# Key for selecting the 27th hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot27 (Hotbar slot 27 key) key

# Key for selecting the 28th hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot28 (Hotbar slot 28 key) key

# Key for selecting the 29th hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot29 (Hotbar slot 29 key) key

# Key for selecting the 30th hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot30 (Hotbar slot 30 key) key

# Key for selecting the 31st hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot31 (Hotbar slot 31 key) key

# Key for selecting the 32nd hotbar slot.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_slot32 (Hotbar slot 32 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
Expand Down
2 changes: 1 addition & 1 deletion doc/lua_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5190,7 +5190,7 @@ This is basically a reference to a C++ `ServerActiveObject`
* `hud_get_flags()`: returns a table of player HUD flags with boolean values.
* See `hud_set_flags` for a list of flags that can be toggled.
* `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
* `count`: number of items, must be between `1` and `23`
* `count`: number of items, must be between `1` and `32`
* `hud_get_hotbar_itemcount`: returns number of visible items
* `hud_set_hotbar_image(texturename)`
* sets background image for hotbar
Expand Down
9 changes: 4 additions & 5 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlicht_changes/static_text.h"
#include "version.h"
#include "script/scripting_client.h"
#include "hud.h"

#if USE_SOUND
#include "client/sound_openal.h"
Expand Down Expand Up @@ -2004,12 +2005,10 @@ void Game::processItemSelection(u16 *new_playeritem)

/* Item selection using hotbar slot keys
*/
for (u16 i = 0; i < 23; i++) {
for (u16 i = 0; i <= max_item; 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;
}
*new_playeritem = i;
infostream << "Selected item: " << new_playeritem << std::endl;
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/client/inputhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/numeric.h"
#include "inputhandler.h"
#include "gui/mainmenumanager.h"
#include "hud.h"

void KeyCache::populate_nonchanging()
{
Expand Down Expand Up @@ -76,7 +77,7 @@ void KeyCache::populate()
key[KeyType::QUICKTUNE_INC] = getKeySetting("keymap_quicktune_inc");
key[KeyType::QUICKTUNE_DEC] = getKeySetting("keymap_quicktune_dec");

for (int i = 0; i < 23; i++) {
for (int i = 0; i < HUD_HOTBAR_ITEMCOUNT_MAX; i++) {
std::string slot_key_name = "keymap_slot" + std::to_string(i + 1);
key[KeyType::SLOT_1 + i] = getKeySetting(slot_key_name.c_str());
}
Expand Down
9 changes: 9 additions & 0 deletions src/client/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ class KeyType
SLOT_21,
SLOT_22,
SLOT_23,
SLOT_24,
SLOT_25,
SLOT_26,
SLOT_27,
SLOT_28,
SLOT_29,
SLOT_30,
SLOT_31,
SLOT_32,

// joystick specific keys
MOUSE_L,
Expand Down
9 changes: 9 additions & 0 deletions src/defaultsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ void set_default_settings(Settings *settings)
settings->setDefault("keymap_slot21", "");
settings->setDefault("keymap_slot22", "");
settings->setDefault("keymap_slot23", "");
settings->setDefault("keymap_slot24", "");
settings->setDefault("keymap_slot25", "");
settings->setDefault("keymap_slot26", "");
settings->setDefault("keymap_slot27", "");
settings->setDefault("keymap_slot28", "");
settings->setDefault("keymap_slot29", "");
settings->setDefault("keymap_slot30", "");
settings->setDefault("keymap_slot31", "");
settings->setDefault("keymap_slot32", "");

// Some (temporary) keys for debugging
settings->setDefault("keymap_quicktune_prev", "KEY_HOME");
Expand Down
2 changes: 1 addition & 1 deletion src/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define HUD_PARAM_HOTBAR_SELECTED_IMAGE 3

#define HUD_HOTBAR_ITEMCOUNT_DEFAULT 8
#define HUD_HOTBAR_ITEMCOUNT_MAX 23
#define HUD_HOTBAR_ITEMCOUNT_MAX 32


#define HOTBAR_IMAGE_SIZE 48
Expand Down

0 comments on commit 1b0fd19

Please sign in to comment.