Skip to content

Commit

Permalink
global,mainmenu: enable Quit if quitting is allowed in kiosk mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Akaricchi committed Jun 4, 2024
1 parent 139ac03 commit fc54f3f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,20 @@ bool gamekeypressed(KeyIndex key) {

static SDL_atomic_t quitting;

static bool taisei_is_quit_forbidden(void) {
return global.is_kiosk_mode && env_get("TAISEI_KIOSK_PREVENT_QUIT", true);
}

bool taisei_is_quit_hidden(void) {
#ifdef __EMSCRIPTEN__
return true;
#else
return taisei_is_quit_forbidden();
#endif
}

void taisei_quit(void) {
if(global.is_kiosk_mode && env_get("TAISEI_KIOSK_PREVENT_QUIT", true)) {
if(taisei_is_quit_forbidden()) {
log_info("Running in kiosk mode; exit request ignored");
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void init_global(CLIAction *cli);

void taisei_quit(void);
bool taisei_quit_requested(void);
bool taisei_is_quit_hidden(void);
void taisei_commit_persistent_data(void);

// XXX: Move this somewhere?
Expand Down
9 changes: 5 additions & 4 deletions src/menu/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ MenuData* create_main_menu(void) {
add_menu_entry(m, "Replays", menu_action_enter_replayview, NULL);
add_menu_entry(m, "Media Room", menu_action_enter_media, NULL);
add_menu_entry(m, "Options", menu_action_enter_options, NULL);
#ifndef __EMSCRIPTEN__
add_menu_entry(m, "Quit", global.is_kiosk_mode ? NULL : menu_action_close, NULL)->transition = TransFadeBlack;
m->input = main_menu_input;
#endif

if(!taisei_is_quit_hidden()) {
add_menu_entry(m, "Quit", menu_action_close, NULL)->transition = TransFadeBlack;
m->input = main_menu_input;
}

stage_practice_entry = dynarray_get_ptr(&m->entries, stage_practice_idx);
spell_practice_entry = dynarray_get_ptr(&m->entries, spell_practice_idx);
Expand Down

0 comments on commit fc54f3f

Please sign in to comment.