Rework input system

This commit is contained in:
2024-01-07 15:20:39 +01:00
parent 5f4bb3316c
commit 03dc3774e7
4 changed files with 70 additions and 151 deletions

View File

@@ -300,14 +300,13 @@ void update(float dt, void *userData) {
bzUISetCaptureMouse(UI, !io->WantCaptureMouse);
bzUISetCaptureKeyboard(UI, !io->WantCaptureKeyboard);
input->canUseMouse = !io->WantCaptureMouse && !bzUICapturedMouse(UI);
input->canUseKeyboard = !io->WantCaptureKeyboard && !bzUICapturedKeyboard(UI);
updateInputState(input, game->camera, dt);
switch (game->screen) {
case SCREEN_GAME:
updatePlayerInput();
if (IsKeyReleased(input->mapping.backBtn)) {
game->screen = SCREEN_PAUSE_MENU;
}
break;
case SCREEN_PAUSE_MENU:
if (IsKeyReleased(input->mapping.backBtn)) {
@@ -709,7 +708,8 @@ void imguiRender(float dt, void *userData) {
if (igCollapsingHeader_TreeNodeFlags("Selection", 0)) {
switch (input->state) {
case INPUT_SELECTED_UNITS:
case INPUT_SELECTED_OBJECT: {
case INPUT_SELECTED_OBJECT:
case INPUT_SELECTED_BUILDING: {
ecs_defer_begin(ECS);
ecs_iter_t it = ecs_query_iter(ECS, input->queries.selected);
while (ecs_iter_next(&it)) {