Reassign debug keys, backspace on textfield added
This commit is contained in:
parent
8aa23b7cfc
commit
cb857cfaa6
@ -428,6 +428,13 @@ INTERNAL void parseInput(GameState *state, const f32 dt)
|
|||||||
f (t) = (a/2)*t^2 + v*t + p, where p is a constant, old position
|
f (t) = (a/2)*t^2 + v*t + p, where p is a constant, old position
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef DENGINE_DEBUG
|
||||||
|
DEBUG_PUSH_STRING("== Controls ==");
|
||||||
|
DEBUG_PUSH_STRING(" [: Spawn a mob");
|
||||||
|
DEBUG_PUSH_STRING("<TAB>: Switch UI element");
|
||||||
|
DEBUG_PUSH_STRING("<ESC>: Close program");
|
||||||
|
#endif
|
||||||
|
|
||||||
World *const world = &state->world[state->currWorldIndex];
|
World *const world = &state->world[state->currWorldIndex];
|
||||||
Entity *hero = &world->entities[entity_getIndex(world, world->heroId)];
|
Entity *hero = &world->entities[entity_getIndex(world, world->heroId)];
|
||||||
v2 ddPos = V2(0, 0);
|
v2 ddPos = V2(0, 0);
|
||||||
@ -504,11 +511,27 @@ INTERNAL void parseInput(GameState *state, const f32 dt)
|
|||||||
state->uiState.keyEntered = keycode_enter;
|
state->uiState.keyEntered = keycode_enter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getKeyStatus(&keys[keycode_tab], readkeytype_delayedRepeat, 0.25f,
|
||||||
|
dt))
|
||||||
|
{
|
||||||
|
state->uiState.keyEntered = keycode_tab;
|
||||||
|
}
|
||||||
|
|
||||||
if (getKeyStatus(&keys[keycode_space], readkeytype_delayedRepeat, 0.25f,
|
if (getKeyStatus(&keys[keycode_space], readkeytype_delayedRepeat, 0.25f,
|
||||||
dt))
|
dt))
|
||||||
{
|
{
|
||||||
state->uiState.keyEntered = keycode_space;
|
state->uiState.keyChar = keycode_space;
|
||||||
DEBUG_LOG("push space");
|
}
|
||||||
|
|
||||||
|
if (getKeyStatus(&keys[keycode_backspace], readkeytype_delayedRepeat,
|
||||||
|
0.1f, dt))
|
||||||
|
{
|
||||||
|
state->uiState.keyEntered = keycode_backspace;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getKeyStatus(&keys[keycode_left_square_bracket],
|
||||||
|
readkeytype_delayedRepeat, 0.25f, dt))
|
||||||
|
{
|
||||||
|
|
||||||
Renderer *renderer = &state->renderer;
|
Renderer *renderer = &state->renderer;
|
||||||
f32 yPos = CAST(f32)(rand() % CAST(i32)renderer->size.h);
|
f32 yPos = CAST(f32)(rand() % CAST(i32)renderer->size.h);
|
||||||
@ -1030,7 +1053,7 @@ INTERNAL i32 button(UiState *uiState, AssetManager *assetManager,
|
|||||||
{
|
{
|
||||||
switch (uiState->keyEntered)
|
switch (uiState->keyEntered)
|
||||||
{
|
{
|
||||||
case keycode_space:
|
case keycode_tab:
|
||||||
// Set focus to nothing and let next widget get focus
|
// Set focus to nothing and let next widget get focus
|
||||||
uiState->kbdItem = 0;
|
uiState->kbdItem = 0;
|
||||||
if (uiState->keyMod == keycode_leftShift)
|
if (uiState->keyMod == keycode_leftShift)
|
||||||
@ -1113,7 +1136,7 @@ INTERNAL i32 scrollBar(UiState *uiState, AssetManager *assetManager,
|
|||||||
{
|
{
|
||||||
switch (uiState->keyEntered)
|
switch (uiState->keyEntered)
|
||||||
{
|
{
|
||||||
case keycode_space:
|
case keycode_tab:
|
||||||
uiState->kbdItem = 0;
|
uiState->kbdItem = 0;
|
||||||
if (uiState->keyMod == keycode_leftShift)
|
if (uiState->keyMod == keycode_leftShift)
|
||||||
uiState->kbdItem = uiState->lastWidget;
|
uiState->kbdItem = uiState->lastWidget;
|
||||||
@ -1221,7 +1244,7 @@ INTERNAL i32 textField(UiState *const uiState, MemoryArena *arena,
|
|||||||
{
|
{
|
||||||
switch (uiState->keyEntered)
|
switch (uiState->keyEntered)
|
||||||
{
|
{
|
||||||
case keycode_space:
|
case keycode_tab:
|
||||||
uiState->kbdItem = 0;
|
uiState->kbdItem = 0;
|
||||||
if (uiState->keyMod == keycode_leftShift)
|
if (uiState->keyMod == keycode_leftShift)
|
||||||
uiState->kbdItem = uiState->lastWidget;
|
uiState->kbdItem = uiState->lastWidget;
|
||||||
@ -1232,8 +1255,7 @@ INTERNAL i32 textField(UiState *const uiState, MemoryArena *arena,
|
|||||||
case keycode_backspace:
|
case keycode_backspace:
|
||||||
if (strLen > 0)
|
if (strLen > 0)
|
||||||
{
|
{
|
||||||
strLen--;
|
string[--strLen] = 0;
|
||||||
string[strLen] = 0;
|
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1538,7 +1560,7 @@ void worldTraveller_gameUpdateAndRender(GameState *state, f32 dt)
|
|||||||
else if (state->uiState.activeItem == 0)
|
else if (state->uiState.activeItem == 0)
|
||||||
state->uiState.activeItem = -1;
|
state->uiState.activeItem = -1;
|
||||||
|
|
||||||
if (state->uiState.keyEntered == keycode_space) state->uiState.kbdItem = 0;
|
if (state->uiState.keyEntered == keycode_tab) state->uiState.kbdItem = 0;
|
||||||
state->uiState.keyEntered = keycode_null;
|
state->uiState.keyEntered = keycode_null;
|
||||||
state->uiState.keyChar = keycode_null;
|
state->uiState.keyChar = keycode_null;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
INTERNAL inline void processKey(KeyState *state, int action)
|
INTERNAL inline void processKey(KeyState *state, int action)
|
||||||
{
|
{
|
||||||
// TODO(doyle): Handle GLFW_REPEAT, and probably remove this function
|
|
||||||
if (action == GLFW_PRESS || action == GLFW_RELEASE)
|
if (action == GLFW_PRESS || action == GLFW_RELEASE)
|
||||||
{
|
{
|
||||||
state->newHalfTransitionCount++;
|
state->newHalfTransitionCount++;
|
||||||
@ -47,6 +46,9 @@ INTERNAL void keyCallback(GLFWwindow *window, int key, int scancode, int action,
|
|||||||
case GLFW_KEY_BACKSPACE:
|
case GLFW_KEY_BACKSPACE:
|
||||||
processKey(&game->input.keys[keycode_backspace], action);
|
processKey(&game->input.keys[keycode_backspace], action);
|
||||||
break;
|
break;
|
||||||
|
case GLFW_KEY_TAB:
|
||||||
|
processKey(&game->input.keys[keycode_tab], action);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (key >= ' ' && key <= '~')
|
if (key >= ' ' && key <= '~')
|
||||||
{
|
{
|
||||||
|
@ -114,6 +114,7 @@ enum KeyCode
|
|||||||
keycode_mouseLeft,
|
keycode_mouseLeft,
|
||||||
keycode_enter,
|
keycode_enter,
|
||||||
keycode_backspace,
|
keycode_backspace,
|
||||||
|
keycode_tab,
|
||||||
keycode_count,
|
keycode_count,
|
||||||
keycode_null,
|
keycode_null,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user