fix(ui): address PR #90 review — 8 items (W1–W4, S5–S6, A3–A4)

W1/A2: add SimBridge.CONNECTED guard before send_input in toggle handler
W2/A1: assert PlatformInfo != null in HardwareDetector._ready();
       add ordering comment in project.godot [autoload] section
W3: replace FileAccess.open() with get_file_as_string() in
    read_benchmark_cache() — auto-closes, no leak
W4/A3: add _extract_bool_setting() helper in game_state.gd that handles
       both {"Bool": true} and plain bool; push_warning on type mismatch
S5: sync _pre_battery_pref from GameState after load_ai_pref() in
    HardwareDetector._ready() — closes race if system starts on battery
S6: separate "red" TPT status into its own arm with STATUS_RED dot and
    label colour — three-colour mapping: green/yellow/red now distinct
A4: replace DebugConsole.PREFS_PATH compile-time dependency in
    _save_ai_pref() with local SETTINGS_CFG_PATH constant

S7 (battery CI guard) already applied by Hoshe in test file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 11:39:47 +01:00
co-authored by Claude Sonnet 4.6
parent 23e6890c4e
commit f51366b3f5
4 changed files with 37 additions and 16 deletions
+15 -2
View File
@@ -352,8 +352,8 @@ func apply_snapshot(snapshot: Dictionary) -> void:
continue
if entry.get("key") == "ai_dialogue.enabled":
var val: Variant = entry.get("value")
if val is Dictionary and val.has("Bool"):
ai_enhanced_dialogue_enabled = bool(val["Bool"])
if val != null:
ai_enhanced_dialogue_enabled = _extract_bool_setting("ai_dialogue.enabled", val)
else:
settings_response = null
@@ -403,3 +403,16 @@ func apply_snapshot(snapshot: Dictionary) -> void:
boundary_positions[pos] = true
elif not has_explicit_positions:
visible_positions[pos] = true
# -- Helpers ------------------------------------------------------------------
## Extract a bool from a tagged-union {"Bool": true} or plain bool value.
## Handles both serde encoding styles; emits push_warning on unrecognised format.
static func _extract_bool_setting(key: String, val: Variant) -> bool:
if val is bool:
return val
if val is Dictionary and val.has("Bool"):
return bool(val["Bool"])
push_warning("GameState: unexpected type for setting '%s': %s" % [key, str(val)])
return false