ps1 filter variables, crowds
This commit is contained in:
+35
-3
@@ -172,6 +172,18 @@ func _input(event: InputEvent) -> void:
|
||||
if not _is_open:
|
||||
return
|
||||
|
||||
# Ctrl+C clears the input line, Ctrl+L clears the log — familiar shell reflexes.
|
||||
if ke.ctrl_pressed:
|
||||
match ke.keycode:
|
||||
KEY_C:
|
||||
_clear_input()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
KEY_L:
|
||||
_log.clear()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
|
||||
match ke.keycode:
|
||||
KEY_TAB:
|
||||
_accept_completion()
|
||||
@@ -187,6 +199,20 @@ func _input(event: InputEvent) -> void:
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
# Focus can be stolen a frame or more after we re-grab it (submit, arrows, the tree
|
||||
# unpausing), so a one-shot deferred grab loses the race. Enforce it every frame
|
||||
# while the console is open — cheap, and it never lets the command line go dark.
|
||||
func _process(_delta: float) -> void:
|
||||
if _is_open and not _input_field.has_focus():
|
||||
# Diagnostic: name whatever currently holds focus before we snatch it back, so
|
||||
# a persistent thief (a HUD button, a menu control) shows up in the log instead
|
||||
# of us guessing. Remove once the culprit is identified.
|
||||
var owner: Control = get_viewport().gui_get_focus_owner()
|
||||
var who: String = String(owner.name) if owner != null else "<nothing>"
|
||||
_log_warn("focus stolen by %s — reclaiming" % who)
|
||||
_input_field.grab_focus()
|
||||
|
||||
|
||||
func _toggle() -> void:
|
||||
_is_open = not _is_open
|
||||
get_tree().paused = _is_open
|
||||
@@ -381,6 +407,15 @@ func _history_step(dir: int) -> void:
|
||||
_set_input(_pending_line if _history_idx == -1 else _history[_history_idx])
|
||||
|
||||
|
||||
# Wipe the live line (Ctrl+C) without submitting — also drops any suggestion popup
|
||||
# and resets history browsing so the next ↑ starts fresh.
|
||||
func _clear_input() -> void:
|
||||
_input_field.clear()
|
||||
_history_idx = -1
|
||||
_pending_line = ""
|
||||
_clear_suggestions()
|
||||
|
||||
|
||||
func _set_input(text: String) -> void:
|
||||
_input_field.text = text
|
||||
_input_field.caret_column = text.length()
|
||||
@@ -400,9 +435,6 @@ func _on_submitted(raw: String) -> void:
|
||||
_input_field.clear()
|
||||
_clear_suggestions()
|
||||
_execute(raw)
|
||||
# Defer: the LineEdit finishes handling the Enter keypress after this signal
|
||||
# returns, so a synchronous grab_focus() gets clobbered. Re-grab next idle.
|
||||
_input_field.grab_focus.call_deferred()
|
||||
|
||||
|
||||
func _execute(cmd: String) -> void:
|
||||
|
||||
Reference in New Issue
Block a user