From fb63d42ec18e0b926cb3441f4e402f1039785949 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 28 Jun 2026 10:29:44 +0900 Subject: [PATCH] Remove popupmenu_opened flag With the blocking modal_run(), the game's main loop is frozen while a menu is open, so the flag's input-suppression and VM-pause checks are unreachable. Quit requested during a modal is now handled by closing the modal and letting it propagate through the main loop. --- modules/NIGHTDLL/NIGHTDLL.c | 3 +-- modules/NIGHTDLL/nt_event.c | 15 --------------- modules/NIGHTDLL/nt_event.h | 1 - modules/NIGHTDLL/nt_scenario.c | 22 ++++++++++------------ modules/SACT/sprite_event.c | 5 ----- modules/SACT/sprite_tevent.c | 6 ------ src/modal.c | 5 +---- src/nact.c | 2 +- src/nact.h | 1 - 9 files changed, 13 insertions(+), 47 deletions(-) diff --git a/modules/NIGHTDLL/NIGHTDLL.c b/modules/NIGHTDLL/NIGHTDLL.c index 435fa7c..3883ff6 100644 --- a/modules/NIGHTDLL/NIGHTDLL.c +++ b/modules/NIGHTDLL/NIGHTDLL.c @@ -56,8 +56,7 @@ static void InitGame() { /* 1 */ nact->msgout = ntmsg_add; nact->ags.eventcb = ntev_callback; - nact->callback = ntev_main; - + nt_gr_init(); ntmsg_init(); nt_sstr_init(); diff --git a/modules/NIGHTDLL/nt_event.c b/modules/NIGHTDLL/nt_event.c index 03a6152..48fb3be 100644 --- a/modules/NIGHTDLL/nt_event.c +++ b/modules/NIGHTDLL/nt_event.c @@ -53,11 +53,6 @@ static void cb_waitkey_selection(agsevent_t *e) { } void ntev_callback(agsevent_t *e) { - // menu open中は無視 - if (nact->popupmenu_opened) { - return; - } - if (e->type == AGSEVENT_KEY_PRESS && e->code == KEY_CTRL) { night.waitskiplv = 2; night.waitkey = e->code; @@ -90,15 +85,5 @@ void ntev_callback(agsevent_t *e) { default: return; } - -} -/* - system35のメインループからで呼ばれるコールバック -*/ -void ntev_main() { - // デフォルトのコールバックのうち、ここで必要なものだけ処理。 - if (nact->popupmenu_opened) { - if (nact->is_quit) sys_exit(0); - } } diff --git a/modules/NIGHTDLL/nt_event.h b/modules/NIGHTDLL/nt_event.h index da4b558..ee9328a 100644 --- a/modules/NIGHTDLL/nt_event.h +++ b/modules/NIGHTDLL/nt_event.h @@ -2,7 +2,6 @@ #define __NT_EVENT_H__ extern void ntev_callback(agsevent_t *e); -extern void ntev_main(); #endif /* __NT_EVENT_H__ */ diff --git a/modules/NIGHTDLL/nt_scenario.c b/modules/NIGHTDLL/nt_scenario.c index e05e87f..725f893 100644 --- a/modules/NIGHTDLL/nt_scenario.c +++ b/modules/NIGHTDLL/nt_scenario.c @@ -55,19 +55,17 @@ static void ntmain(struct _scoadr inadr) { while (!nact->is_quit && !is_yield_requested()) { scheduler_on_command(); //SACT_DEBUG("%d:%x", sl_getPage(), sl_getIndex()); - if (!nact->popupmenu_opened) { - exec_command(); - if (sl_getPage() == inadr.page && - sl_getIndex() == inadr.index) { - // ~E%05dからの戻り - if (nact->fnc_return_value == 0) { - return; - } else { - scono = nact->fnc_return_value; - } - curadr = scene2adr(scono); - sl_callFar2(curadr.page -1, curadr.index); + exec_command(); + if (sl_getPage() == inadr.page && + sl_getIndex() == inadr.index) { + // ~E%05dからの戻り + if (nact->fnc_return_value == 0) { + return; + } else { + scono = nact->fnc_return_value; } + curadr = scene2adr(scono); + sl_callFar2(curadr.page -1, curadr.index); } nact->callback(); } diff --git a/modules/SACT/sprite_event.c b/modules/SACT/sprite_event.c index 5003adf..187847f 100644 --- a/modules/SACT/sprite_event.c +++ b/modules/SACT/sprite_event.c @@ -426,11 +426,6 @@ static void cb_waitkey_backlog(agsevent_t *e) { X|SDL のイベントディスパッチャからくる最初の場所 */ void spev_callback(agsevent_t *e) { - // menu open中は無視 - if (nact->popupmenu_opened) { - return; - } - if (sact.waittype != KEYWAIT_BACKLOG) { if (e->type == AGSEVENT_KEY_PRESS && e->code == KEY_CTRL) { sact.waitskiplv = 2; diff --git a/modules/SACT/sprite_tevent.c b/modules/SACT/sprite_tevent.c index 4da4703..46fba4d 100644 --- a/modules/SACT/sprite_tevent.c +++ b/modules/SACT/sprite_tevent.c @@ -117,10 +117,4 @@ void spev_main() { e.type = AGSEVENT_TIMER; tevent_callback(&e); - - // デフォルトのコールバックのうち、ここで必要なものだけ - // 処理。(VAコマンドcallbackはなし) - if (nact->popupmenu_opened) { - if (nact->is_quit) sys_exit(0); - } } diff --git a/src/modal.c b/src/modal.c index d369f38..6651f64 100644 --- a/src/modal.c +++ b/src/modal.c @@ -241,12 +241,10 @@ void modal_run(modal *m) { assert(!event_custom_handler); event_custom_handler = modal_event_trampoline; - nact->popupmenu_opened = true; - mu_Id prev_hash = 0; bool open = true; - while (open) { + while (open && !nact->is_quit) { event_get_key(); // pump SDL events -> trampoline -> m->handler -> microui mu_begin(ctx); @@ -263,7 +261,6 @@ void modal_run(modal *m) { sys_wait_vsync(); // -> gfx_updateScreen() -> menu_render_overlay() } - nact->popupmenu_opened = false; event_custom_handler = NULL; current_modal = NULL; free(ctx); diff --git a/src/nact.c b/src/nact.c index a50d54c..e624037 100644 --- a/src/nact.c +++ b/src/nact.c @@ -119,7 +119,7 @@ void nact_main() { exec_command(); scheduler_on_command(); - if (is_yield_requested() || nact->popupmenu_opened || dbg_trapped()) { + if (is_yield_requested() || dbg_trapped()) { nact->callback(); // Async in emscripten sys_getInputInfo(); scheduler_yield(); diff --git a/src/nact.h b/src/nact.h index 93cdb55..8230ced 100644 --- a/src/nact.h +++ b/src/nact.h @@ -72,7 +72,6 @@ typedef struct { void (*callback)(void); /* main の callback */ bool is_va_animation; /* VA command working */ bool is_cursor_animation; /* animation cursor working */ - bool popupmenu_opened; /* popup menu が 開いているか */ CharacterEncoding encoding; char *game_title_utf8;