meta: quit confirmation

This commit is contained in:
Lephenixnoir 2022-07-17 17:03:08 +01:00
parent 27dd8b1d36
commit 511a53851f
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 21 additions and 3 deletions

View File

@ -112,7 +112,7 @@ static void renderGame(Game *game)
}
}
bool title_screen(void)
bool titleScreen(void)
{
int selection = 0;
@ -145,11 +145,29 @@ bool title_screen(void)
}
}
bool confirmExit(void)
{
renderClear();
renderText(1, 1, "QUIT? THE WORLD WILL BE LOST.");
renderText(1, 2, "F1: YES, QUIT");
renderText(1, 3, "F6: NO, GO BACK");
renderUpdate();
while(1) {
int opt = GETKEY_DEFAULT & ~GETKEY_MENU;
int key = getkey_opt(opt, NULL).key;
if(key == KEY_F1)
return true;
if(key == KEY_F6)
return false;
}
}
int main(void)
{
prof_init();
bool random = title_screen();
bool random = titleScreen();
srand(random ? rtc_ticks() : 0xc0ffee);
#ifdef NOONCRAFT_ENABLE_USB
@ -216,7 +234,7 @@ int main(void)
continue;
#endif
if(ev.key == KEY_MENU)
if(ev.key == KEY_MENU && confirmExit())
runMainLoop = false;
int digit = keycode_digit(ev.key);
if(digit >= 1 && digit <= 9 && !game.isBreakingBlock()) {