Allow for A_MENU_START to select in menu; add A_MENU_QUIT to go back

This commit is contained in:
Dominic Szablewski 2023-08-15 23:37:05 +02:00
parent 24b6efd3ea
commit 0ded93de55
2 changed files with 14 additions and 11 deletions

View file

@ -182,14 +182,14 @@ void menu_update(menu_t *menu) {
if (entry->type == MENU_ENTRY_TOGGLE) {
vec2i_t toggle_pos = items_pos;
toggle_pos.x += page->block_width - ui_text_width(entry->options[entry->data], UI_SIZE_8);
ui_draw_text(entry->options[entry->data], ui_scaled_pos(page->items_anchor, toggle_pos), UI_SIZE_8, text_color);
ui_draw_text(entry->options[entry->data], ui_scaled_pos(page->items_anchor, toggle_pos), UI_SIZE_8, text_color);
}
items_pos.y += 12;
}
}
// Handle back buttons
if (input_pressed(A_MENU_BACK)) {
if (input_pressed(A_MENU_BACK) || input_pressed(A_MENU_QUIT)) {
if (menu->index != 0) {
menu_pop(menu);
sfx_play(SFX_MENU_SELECT);
@ -216,7 +216,7 @@ void menu_update(menu_t *menu) {
entry->select_func(menu, entry->data);
}
}
else if (input_pressed(A_MENU_RIGHT) || input_pressed(A_MENU_SELECT)) {
else if (input_pressed(A_MENU_RIGHT) || input_pressed(A_MENU_SELECT) || input_pressed(A_MENU_START)) {
sfx_play(SFX_MENU_SELECT);
entry->data = (entry->data + 1) % entry->options_len;
if (entry->select_func) {
@ -227,7 +227,7 @@ void menu_update(menu_t *menu) {
// Handle buttons
else {
if (input_pressed(A_MENU_SELECT)) {
if (input_pressed(A_MENU_SELECT) || input_pressed(A_MENU_START)) {
if (entry->select_func) {
sfx_play(SFX_MENU_SELECT);
if (entry->type == MENU_ENTRY_TOGGLE) {

View file

@ -68,7 +68,15 @@ void race_init() {
}
void race_update() {
if (!is_paused) {
if (is_paused) {
if (!active_menu) {
active_menu = pause_menu_init();
}
if (input_pressed(A_MENU_QUIT)) {
race_unpause();
}
}
else {
ships_update();
droid_update(&g.droid, &g.ships[g.pilot]);
camera_update(&g.camera, &g.ships[g.pilot], &g.droid);
@ -88,14 +96,10 @@ void race_update() {
game_set_scene(GAME_SCENE_TITLE);
}
}
else if (active_menu == NULL && input_pressed(A_MENU_START)) {
else if (active_menu == NULL && (input_pressed(A_MENU_START) || input_pressed(A_MENU_QUIT))) {
race_pause();
}
}
else if (input_pressed(A_MENU_START)) {
race_unpause();
}
// Draw 3D
@ -259,7 +263,6 @@ void race_release_control() {
void race_pause() {
sfx_pause();
is_paused = true;
active_menu = pause_menu_init();
}
void race_unpause() {