extends SceneTree
## GATE — T opens chat in PLAY, never in the editor (user 2026-10-18: "t still brings up
## chat menu in editor which is very wrong"). The chat overlay checked the raw KEY_T, so
## no keymap context could suppress it — and it ignored modifiers, so the editor's Ctrl+T
## (show / hide the tools column) opened chat too.
## K1 play mode: T toggles the chat panel, T again toggles it back
## K2 build mode (F4): T does not toggle it
## K3 play mode: Ctrl+T does not toggle it (that chord is not chat)
##
## RUN: CI=true HYPERTPS_DAEMON_TCP=127.0.0.1:1 "$GODOT" --headless --path . --script res://scenes/test/gate_chat_key.gd
var _frame := 0
var _chat: Node = null
var _step := 0
var _s0 := false
var fails := 0
var checks := 0
func _p(c: bool, m: String, got: Variant = "") -> void:
checks += 1
if not c:
fails += 1
print(" %-60s %s %s" % [m, "OK" if c else "**FAIL**", str(got)])
func _press(code: Key, ctrl := false) -> void:
for pressed: bool in [true, false]:
var e := InputEventKey.new()
e.keycode = code
e.physical_keycode = code
e.ctrl_pressed = ctrl
e.unicode = 0 if ctrl else 116
e.pressed = pressed
root.push_input(e)
func _open() -> bool:
return bool(_chat.get("_chat_visible"))
func _process(_d: float) -> bool:
_frame += 1
if _frame == 1:
root.size = Vector2i(1920, 1080)
_chat = (load("res://packs/keet_chat/chat_overlay.tscn") as PackedScene).instantiate()
root.add_child(_chat)
root.get_node("/root/GameMode").set_mode("play")
return false
if _frame < 10 or _frame % 3 != 0:
return false
# The panel starts SHOWN (chat_overlay.gd `_chat_visible := true`), so each check is
# relative: T flips it, and where T must do nothing the state does not change.
match _step:
0:
_s0 = _open()
_press(KEY_T)
1:
_p(_open() != _s0, "K1 play mode: T toggles chat", [_s0, _open()])
_press(KEY_T)
2:
_p(_open() == _s0, "K1 ... T again toggles it back", [_s0, _open()])
root.get_node("/root/GameMode").set_mode("build")
3:
_press(KEY_T)
4:
_p(_open() == _s0, "K2 build mode: T does NOT toggle chat", [_s0, _open()])
root.get_node("/root/GameMode").set_mode("play")
5:
_press(KEY_T, true)
6:
_p(_open() == _s0, "K3 play mode: Ctrl+T does NOT toggle chat", [_s0, _open()])
_:
if checks < 4:
print(" **FAIL** only %d checks ran" % checks)
fails += 1
print("\nGATE chat_key: %s (%d checks, %d failed)" % ["PASS" if fails == 0 else "FAIL", checks, fails])
quit(0 if fails == 0 else 1)
return true
_step += 1
return false