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
+5 -3
View File
@@ -32,7 +32,9 @@ var _pre_battery_pref: bool = true
# -- Lifecycle ----------------------------------------------------------------
func _ready() -> void:
assert(PlatformInfo != null, "PlatformInfo must load before HardwareDetector")
load_ai_pref()
_pre_battery_pref = GameState.ai_enhanced_dialogue_enabled
PlatformInfo.power_profile_changed.connect(_on_power_profile_changed)
@@ -75,11 +77,11 @@ func read_benchmark_cache() -> Variant:
var cache_path: String = PlatformInfo.benchmark_cache_path
if not FileAccess.file_exists(cache_path):
return null
var f := FileAccess.open(cache_path, FileAccess.READ)
if f == null:
var text: String = FileAccess.get_file_as_string(cache_path)
if text.is_empty():
return null
var json := JSON.new()
if json.parse(f.get_as_text()) != OK:
if json.parse(text) != OK:
return null
var data: Variant = json.get_data()
if not data is Dictionary or not data.has("tps"):