diff --git a/src/main.cpp b/src/main.cpp index 116bc6a..0444100 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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()) {