extends SceneTree
## GATE — keymap step 4: F1 = the keys that work RIGHT NOW, and the context strip
## (docs/keymap-blender-279.md §4a).
##
## 1. build mode: F1 lists build / editor keys (S Scale) and NOT play keys (Jump)
## 2. faces selected (face_sel): the UV keys appear
## 3. "show every context": the play keys come back, marked not active
## 4. typing in the search does not collapse the list (the snapshot)
## 5. a mapped row names its Blender command (Scale -> transform.resize)
## 6. the strip: names build mode; reads FLYING while RMB is held; names the tool
##
## Run: HYPERTPS_DAEMON_TCP=127.0.0.1:1 "$HYPER_TPS_GODOT" --headless --path . --script res://scenes/test/gate_help_contexts.gd
var ok := true
var checks := 0
var _frame := 0
var _km: Node
var _gm: Node
var _help: Node
var _hud: Node
func _p(cond: bool, what: String, note: Variant = "") -> void:
checks += 1
if not cond:
ok = false
print(" %-62s %s %s" % [what, "OK" if cond else "**FAIL**", str(note).left(140)])
func _body() -> String:
return String(_help.text())
func _process(_d: float) -> bool:
_frame += 1
match _frame:
3:
_km = root.get_node("/root/Keymap")
_gm = root.get_node("/root/GameMode")
_help = root.get_node("/root/HelpOverlay")
_hud = root.get_node("/root/BuildHud")
_gm.set_mode("build")
_km.push_context("builder") # the level map pushes it; no map here
print("-- 1. build mode --")
_help.show_help()
var b := _body()
_p(b.contains("Scale the selection"), "F1 lists the editor keys (S scale)")
_p(not b.contains("Jump"), "and NOT the play keys (no Jump)")
_p(b.contains("BUILD MODE") and b.contains("EDITOR TOOLS"), "grouped under plain names", b.left(120))
_help.hide_help()
print("\n-- 2. faces selected --")
_km.push_context("face_sel")
_help.show_help()
_p(_body().contains("Rotate texture"), "with faces selected the UV keys appear")
_help.hide_help()
_km.pop_context("face_sel")
_help.show_help()
_p(not _body().contains("Rotate texture"), "and go again when nothing is selected")
print("\n-- 3. show every context --")
_help.call("set_show_all", true)
b = _body()
_p(b.contains("Jump") and b.contains("not active"), "show every context: play keys, marked not active")
_help.call("set_show_all", false)
print("\n-- 4. the snapshot --")
_help.set_query("scale")
_p(_body().contains("Scale the selection"), "typing in the search keeps the build keys (snapshot)",
_km.active_contexts())
_help.set_query("")
print("\n-- 5. Blender names --")
_p(_body().contains("transform.resize"), "a mapped row names its Blender command")
_help.hide_help()
print("\n-- 6. the strip --")
6:
var s: String = String(_hud.call("context_strip"))
_p(s.contains("BUILD"), "the strip names build mode", s)
_gm.set("_temp_look", true)
9:
var s2: String = String(_hud.call("context_strip"))
_p(s2.contains("FLYING"), "RMB held: the strip reads FLYING", s2)
_gm.set("_temp_look", false)
var stack := OperatorStack.new()
root.add_child(stack)
var op := LevelOperator.new()
root.add_child(op)
stack.activate(op)
_hud.call("set_operator", op.op_name())
12:
var s3: String = String(_hud.call("context_strip"))
_p(s3.contains("tool"), "a tool up: the strip says so", s3)
_gm.set_mode("play")
if checks < 11:
_p(false, "only %d checks ran" % checks)
print("\nGATE help_contexts: %s (%d checks)" % ["PASS" if ok else "FAIL", checks])
quit(0 if ok else 1)
return true
return false