fix(menu): main-menu Quit now closes the GUI instead of revealing the game
App.run ended its menu loop on Quit and just returned. The console exits then,
but in the GUI run() is on a daemon worker while the Swing JFrame stays
displayable on the EDT, keeping the JVM alive — and the dismissed menu overlay
just revealed the running game underneath ("back into the game"). EXIT_ON_CLOSE
only fires for the native window X, not a programmatic quit.
Add a GameIO.shutdown() teardown hook (default no-op) and call it after the menu
loop ends. SwingIO overrides it to stop music, dispose the window, and exit the
JVM, mirroring EXIT_ON_CLOSE; console keeps the no-op. Extract an injectable
App.run overload and add AppQuitTest asserting the Quit path invokes shutdown().
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -64,8 +64,11 @@ public final class App {
|
||||
|
||||
/** Runs the menu shell on the given IO until the player quits. */
|
||||
public static void run(GameIO io) {
|
||||
SaveService saves = new SaveService();
|
||||
SettingsStore settingsStore = new SettingsStore();
|
||||
run(io, new SaveService(), new SettingsStore());
|
||||
}
|
||||
|
||||
/** Runs the menu shell with injectable persistence (for testing). */
|
||||
static void run(GameIO io, SaveService saves, SettingsStore settingsStore) {
|
||||
Settings settings = settingsStore.load();
|
||||
SettingsMenu.apply(settings, io);
|
||||
|
||||
@@ -88,6 +91,7 @@ public final class App {
|
||||
}
|
||||
}
|
||||
io.write("Farewell.");
|
||||
io.shutdown(); // GUI: close the window and exit; console: no-op
|
||||
}
|
||||
|
||||
/** Loads a fresh world and binds it to a newly named session. */
|
||||
|
||||
Reference in New Issue
Block a user