Allow numbers on the keyboard to change what hotbar slot is selected
This commit is contained in:
@@ -427,6 +427,12 @@ int gameLoop (
|
||||
&player.inventory.offhand
|
||||
);
|
||||
}
|
||||
|
||||
if (!gamePopup && inputs->numPressed != 0 && inputs->numPressed != 10) {
|
||||
player.inventory.hotbarSelect = inputs->numPressed - 1;
|
||||
|
||||
inputs->numPressed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef small
|
||||
|
||||
@@ -137,6 +137,10 @@ int handleEvent (Inputs *inputs, const u_int8_t *keyboard, SDL_Event event) {
|
||||
inputs->keyboard_F = keyboard[SDL_SCANCODE_F];
|
||||
|
||||
inputs->keySym = event.key.keysym.sym;
|
||||
|
||||
if (event.key.keysym.scancode >= SDL_SCANCODE_1 && event.key.keysym.scancode <= SDL_SCANCODE_0) {
|
||||
inputs->numPressed = event.key.keysym.scancode - SDL_SCANCODE_1 + 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ typedef struct {
|
||||
|
||||
int keyTyped;
|
||||
int keySym;
|
||||
|
||||
int numPressed;
|
||||
} Inputs;
|
||||
|
||||
int controlLoop(Inputs *inputs, const u_int8_t *keyboard);
|
||||
|
||||
Reference in New Issue
Block a user