fix(gui): require explicit dashboard autostart

This commit is contained in:
simoleo89
2026-06-14 19:00:22 +02:00
parent c6e43c6d55
commit 1a03b8f3a9
2 changed files with 14 additions and 3 deletions
@@ -159,6 +159,7 @@ public final class Emulator {
Emulator.config.register("camera.render.delay", "5");
Emulator.config.register("hotel.timezone", java.time.ZoneId.systemDefault().getId());
Emulator.config.register("gui.enabled", "0");
Emulator.config.register("gui.autostart.enabled", "0");
String hotelTimezoneId = Emulator.getConfig().getValue("hotel.timezone", java.time.ZoneId.systemDefault().getId());
System.out.println(startupCard(hotelTimezoneId));
Emulator.texts.register("camera.permission", "You don't have permission to use the camera!");
@@ -198,7 +199,7 @@ public final class Emulator {
Emulator.isReady = true;
Emulator.timeStarted = getIntUnixTimestamp();
if (Emulator.getConfig().getBoolean("gui.enabled", false)) {
if (shouldLaunchGui()) {
EmulatorDashboard.launch();
}
@@ -388,6 +389,10 @@ public final class Emulator {
}
}
static boolean shouldLaunchGui() {
return Emulator.getConfig() != null && Emulator.getConfig().getBoolean("gui.autostart.enabled", false);
}
private static String fit(String value, int width) {
String safe = value == null ? "" : value;
if (safe.length() > width) {
@@ -76,7 +76,13 @@ class EmulatorStartupConsoleTest {
assertTrue(source.contains("register(\"gui.enabled\", \"0\")"),
"gui.enabled must be registered disabled by default so it does not log missing config errors or start the UI unexpectedly");
assertTrue(source.indexOf("register(\"gui.enabled\", \"0\")") < source.indexOf("getBoolean(\"gui.enabled\", false)"),
"gui.enabled must be registered before it is read");
assertTrue(source.contains("register(\"gui.autostart.enabled\", \"0\")"),
"GUI autostart must use a new disabled-by-default key so old gui.enabled=1 settings do not launch the current UI");
assertTrue(source.indexOf("register(\"gui.autostart.enabled\", \"0\")") < source.indexOf("shouldLaunchGui()"),
"GUI autostart must be registered before the launch decision");
assertFalse(source.contains("getBoolean(\"gui.enabled\", true)"),
"GUI must not use a true fallback");
assertFalse(source.contains("getBoolean(\"gui.enabled\", false)"),
"legacy gui.enabled must not control startup anymore");
}
}