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

@ -189,7 +189,7 @@ void menu_update(menu_t *menu) {
}
// 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() {