From 388df8000a62921bfd0f0dc6039a4c1e24d9f3f5 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Wed, 4 Mar 2026 22:31:52 +0100 Subject: [PATCH] =?UTF-8?q?fix(client):=20debug=20console=20review=20fixes?= =?UTF-8?q?=20=E2=80=94=20D-088=20pause,=20settings=20state,=20response=20?= =?UTF-8?q?guard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add D-088 Overlay pause/unpause signals to DebugConsole, wire in main.gd so sim does not advance while typing debug commands - Settings dialog reads live DebugConsole.is_enabled() instead of ConfigFile directly, preventing checkbox/state divergence - append_response respects disabled state — no auto-open when user disabled console via settings - tp command warns on invalid z value instead of silently defaulting to 0 Co-Authored-By: Claude Opus 4.6 --- client/scripts/main.gd | 5 +++++ client/ui/debug_console.gd | 18 +++++++++++++++--- client/ui/settings_dialog.gd | 13 +++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/client/scripts/main.gd b/client/scripts/main.gd index 8bcd7cbcd..624eb8533 100644 --- a/client/scripts/main.gd +++ b/client/scripts/main.gd @@ -129,6 +129,11 @@ func _ready() -> void: if settings_dialog and debug_console: settings_dialog.debug_console_toggled.connect(debug_console.set_enabled) + # #581 D-088: Wire debug console pause/unpause — sim must not advance during debug input + if debug_console: + debug_console.pause_requested.connect(_on_dialogue_pause_requested) + debug_console.unpause_requested.connect(_on_dialogue_unpause_requested) + func _process(delta: float) -> void: # Main game loop: poll snapshot, apply state, flush input diff --git a/client/ui/debug_console.gd b/client/ui/debug_console.gd index 90d15275d..e2b673064 100644 --- a/client/ui/debug_console.gd +++ b/client/ui/debug_console.gd @@ -5,6 +5,10 @@ extends Control ## Semi-transparent panel anchored to bottom ~40% of screen. ## Dispatches DebugCommandKind variants to server via SimBridge. ## Settings-toggled; enabled state persisted in user://settings.cfg. +## D-088: triggers Overlay pause while open — sim must not advance during debug input. + +signal pause_requested # D-088: pause sim while console is open +signal unpause_requested # D-088: unpause sim when console closes const PREFS_PATH := "user://settings.cfg" const PREFS_SECTION := "debug" @@ -134,6 +138,7 @@ func _open_console() -> void: _input_line.clear() _input_line.grab_focus() _history_idx = -1 + pause_requested.emit() # D-088: pause sim while typing debug commands func _close() -> void: @@ -141,6 +146,7 @@ func _close() -> void: visible = false mouse_filter = Control.MOUSE_FILTER_IGNORE _input_line.release_focus() + unpause_requested.emit() # D-088: resume sim when console closes func is_open() -> bool: @@ -187,7 +193,12 @@ func _dispatch(line: String) -> void: _append_text("usage: tp [z] or tp ", ERROR_COLOR) return if parts.size() >= 3 and parts[1].is_valid_int() and parts[2].is_valid_int(): - var z := int(parts[3]) if parts.size() >= 4 and parts[3].is_valid_int() else 0 + var z := 0 + if parts.size() >= 4: + if parts[3].is_valid_int(): + z = int(parts[3]) + else: + _append_text("tp: invalid z '%s' — defaulting to 0" % parts[3], ERROR_COLOR) _send_debug({"TeleportToPosition": {"x": int(parts[1]), "y": int(parts[2]), "z": z}}) else: var loc := " ".join(PackedStringArray(parts.slice(1))) @@ -226,13 +237,14 @@ func _send_debug(kind: Variant) -> void: # -- Response display -- -## Append a server debug response to the output log. Auto-opens console if closed. +## Append a server debug response to the output log. Auto-opens console if closed +## (only if console is enabled — respect user's settings toggle). func append_response(response: Dictionary) -> void: var success: bool = response.get("success", false) var text: String = response.get("text", "") var color := SUCCESS_COLOR if success else ERROR_COLOR _append_text(text, color) - if not _open: + if not _open and _enabled: _open_console() diff --git a/client/ui/settings_dialog.gd b/client/ui/settings_dialog.gd index 55b94dc66..51f1fe2cb 100644 --- a/client/ui/settings_dialog.gd +++ b/client/ui/settings_dialog.gd @@ -124,10 +124,15 @@ func _build_ui() -> void: debug_hbox.add_child(debug_label) var debug_check := CheckButton.new() - var cfg := ConfigFile.new() - debug_check.button_pressed = true # default: enabled - if cfg.load(DebugConsole.PREFS_PATH) == OK: - debug_check.button_pressed = cfg.get_value(DebugConsole.PREFS_SECTION, DebugConsole.PREFS_KEY_ENABLED, true) + # Query live DebugConsole node if available; fall back to prefs file + var console_node := get_node_or_null("/root/Main/ModalLayer/DebugConsole") + if console_node and console_node.has_method("is_enabled"): + debug_check.button_pressed = console_node.is_enabled() + else: + var cfg := ConfigFile.new() + debug_check.button_pressed = true + if cfg.load(DebugConsole.PREFS_PATH) == OK: + debug_check.button_pressed = cfg.get_value(DebugConsole.PREFS_SECTION, DebugConsole.PREFS_KEY_ENABLED, true) debug_check.toggled.connect(func(enabled: bool) -> void: debug_console_toggled.emit(enabled) )