diff --git a/src/battle/ai.c b/src/battle/ai.c index 5f43ccf..50247b0 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -685,7 +685,7 @@ static void moveToItem(void) { if (self->target->alive == ALIVE_ALIVE) { - faceTarget(self->target); + faceTarget(self->target); applyFighterThrust(); return; } diff --git a/src/battle/battle.c b/src/battle/battle.c index 4bdec3e..1c845a8 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -257,7 +257,7 @@ static void drawMenu(void) static void handleKeyboard(void) { - if (app.keyboard[SDL_SCANCODE_ESCAPE]) + if (app.keyboard[SDL_SCANCODE_ESCAPE] && !app.awaitingWidgetInput) { switch (show) { diff --git a/src/challenges/challengeHome.c b/src/challenges/challengeHome.c index 6bf77c0..03156df 100644 --- a/src/challenges/challengeHome.c +++ b/src/challenges/challengeHome.c @@ -413,7 +413,7 @@ static void quit(void) static void handleKeyboard(void) { - if (app.keyboard[SDL_SCANCODE_ESCAPE]) + if (app.keyboard[SDL_SCANCODE_ESCAPE] && !app.awaitingWidgetInput) { switch (show) { diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index d80a291..00452d7 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -588,7 +588,7 @@ static void fallenOK(void) static void handleKeyboard(void) { - if (app.keyboard[SDL_SCANCODE_ESCAPE]) + if (app.keyboard[SDL_SCANCODE_ESCAPE] && !app.awaitingWidgetInput) { switch (show) { diff --git a/src/galaxy/stats.c b/src/galaxy/stats.c index 952c8c5..490f4df 100644 --- a/src/galaxy/stats.c +++ b/src/galaxy/stats.c @@ -140,6 +140,9 @@ void drawStats(void) drawText(SCREEN_WIDTH / 2, 110, 16, TA_CENTER, colors.lightGrey, _("Page %d / %d"), page + 1, (int)maxPages); + SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255); + SDL_RenderDrawLine(app.renderer, r.x, 150, r.x + r.w, 150); + y = 170; startIndex = (page * STATS_PER_PAGE); @@ -171,7 +174,7 @@ void drawStats(void) drawText(r.x + 20, 565, 18, TA_LEFT, colors.white, statDescription[STAT_TIME]); drawText(r.x + r.w - 20, 565, 18, TA_RIGHT, colors.white, timeToString(game.stats[STAT_TIME], 1)); - drawWidgets("stats"); + drawWidgets("stats"); } static void nextPage(void) diff --git a/src/game/title.c b/src/game/title.c index 4e6b64f..acfd599 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -198,16 +198,10 @@ static void drawFighters(void) static void handleKeyboard(void) { - switch (show) + if (app.keyboard[SDL_SCANCODE_ESCAPE] && !app.awaitingWidgetInput) { - case SHOW_STATS: - returnFromOptions(); - memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS); - playSound(SND_GUI_CLOSE); - break; - - case SHOW_OPTIONS: - break; + returnFromOptions(); + playSound(SND_GUI_CLOSE); } } diff --git a/src/structs.h b/src/structs.h index 824e760..cc6dff3 100644 --- a/src/structs.h +++ b/src/structs.h @@ -423,6 +423,7 @@ typedef struct { SDL_Window *window; Delegate delegate; ModalDialog modalDialog; + int awaitingWidgetInput; int lastKeyPressed; int lastButtonPressed; int keyControls[CONTROL_MAX]; diff --git a/src/system/controls.c b/src/system/controls.c index f25198c..1120e37 100644 --- a/src/system/controls.c +++ b/src/system/controls.c @@ -151,7 +151,7 @@ void drawControls(void) for (i = 0 ; i < CONTROL_MAX ; i++) { - drawText(r.x, r.y, 20, TA_LEFT, colors.white, controlName[i]); + drawText(r.x, r.y + 2, 20, TA_LEFT, colors.white, controlName[i]); controlWidget[i]->rect.x = r.x + 175; controlWidget[i]->rect.y = r.y; diff --git a/src/system/input.c b/src/system/input.c index b1f531c..0406457 100644 --- a/src/system/input.c +++ b/src/system/input.c @@ -104,17 +104,9 @@ void drawMouse(void) void clearInput(void) { SDL_Event event; - int i; - - for (i = 0 ; i < MAX_KEYBOARD_KEYS ; i++) - { - app.keyboard[i] = 0; - } - - for (i = 0 ; i < MAX_MOUSE_BUTTONS ; i++) - { - app.mouse.button[i] = 0; - } + + memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS); + memset(app.mouse.button, 0, sizeof(int) * MAX_MOUSE_BUTTONS); while (SDL_PollEvent(&event)) { diff --git a/src/system/widgets.c b/src/system/widgets.c index 4baaeed..fb37e66 100644 --- a/src/system/widgets.c +++ b/src/system/widgets.c @@ -35,7 +35,6 @@ static Widget *selectedWidget; static SDL_Texture *optionsLeft; static SDL_Texture *optionsRight; static int drawingWidgets; -static int waitingForInput; void initWidgets(void) { @@ -50,7 +49,7 @@ void initWidgets(void) loadWidgets(); - waitingForInput = drawingWidgets = 0; + app.awaitingWidgetInput = drawingWidgets = 0; } void doWidgets(void) @@ -61,7 +60,7 @@ void doWidgets(void) handleKeyboard(); - if (waitingForInput) + if (app.awaitingWidgetInput) { handleControlWidgets(); } @@ -104,7 +103,7 @@ void drawWidgets(const char *group) { if ((app.modalDialog.type == MD_NONE || (app.modalDialog.type != MD_NONE && w->isModal)) && w->visible && strcmp(w->group, group) == 0) { - if (!mouseOver && !waitingForInput) + if (!mouseOver && !app.awaitingWidgetInput) { mouseOver = (w->type != WT_SELECT && w->enabled && collision(w->rect.x, w->rect.y, w->rect.w, w->rect.h, app.mouse.x, app.mouse.y, 1, 1)); @@ -157,7 +156,7 @@ void drawWidgets(const char *group) case WT_CONTROL_CONFIG: SDL_RenderDrawRect(app.renderer, &w->rect); - if (!waitingForInput || (waitingForInput && w != selectedWidget)) + if (!app.awaitingWidgetInput || (app.awaitingWidgetInput && w != selectedWidget)) { if (strlen(w->options[0]) && strlen(w->options[1])) { @@ -259,9 +258,9 @@ static void handleMouse(void) break; case WT_CONTROL_CONFIG: - if (!waitingForInput) + if (!app.awaitingWidgetInput) { - waitingForInput = 1; + app.awaitingWidgetInput = 1; app.lastKeyPressed = app.lastButtonPressed = -1; } app.mouse.button[SDL_BUTTON_LEFT] = 0; @@ -302,11 +301,11 @@ static void handleControlWidgets(void) { clearControlConfig(selectedWidget->name); - waitingForInput = 0; + app.awaitingWidgetInput = 0; } else if (app.lastKeyPressed == SDL_SCANCODE_ESCAPE) { - waitingForInput = 0; + app.awaitingWidgetInput = 0; } else { @@ -314,18 +313,18 @@ static void handleControlWidgets(void) { updateControlKey(selectedWidget->name); - waitingForInput = 0; + app.awaitingWidgetInput = 0; } if (app.lastButtonPressed != -1) { updateControlButton(selectedWidget->name); - waitingForInput = 0; + app.awaitingWidgetInput = 0; } } - if (!waitingForInput) + if (!app.awaitingWidgetInput) { clearInput(); }