summaryrefslogtreecommitdiff
path: root/stage/hud.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-01-30 13:19:56 +0100
committerDaniel Weipert <git@mail.dweipert.de>2025-01-30 13:19:56 +0100
commita210c39b5d2be1e7e5c52568d40ba6a29f34b4bb (patch)
tree1425761be2edb336499970a7cb2d8a2c45da9a31 /stage/hud.gd
initial commit
Diffstat (limited to 'stage/hud.gd')
-rw-r--r--stage/hud.gd42
1 files changed, 42 insertions, 0 deletions
diff --git a/stage/hud.gd b/stage/hud.gd
new file mode 100644
index 0000000..8a0b146
--- /dev/null
+++ b/stage/hud.gd
@@ -0,0 +1,42 @@
+extends CanvasLayer
+
+
+@onready var grid_selector: GridSelector = get_tree().get_first_node_in_group("grid_selector")
+
+
+func _ready() -> void:
+ visible = false
+
+ grid_selector.selected.connect(func(_node: Node2D):
+ grid_selector.process_mode = Node.PROCESS_MODE_DISABLED
+ visible = true
+ $PanelContainer/VBoxContainer/Button.grab_focus()
+ )
+
+ grid_selector.move_mode_exited.connect(func():
+ grid_selector.current_state = grid_selector.get_node("StateSelect")
+ grid_selector.process_mode = Node.PROCESS_MODE_DISABLED
+ visible = true
+ $PanelContainer/VBoxContainer/Button.grab_focus()
+ )
+
+
+func _input(event: InputEvent) -> void:
+ if not visible:
+ return
+
+ if event.is_action_pressed("left_click"):
+ for button: Button in $PanelContainer/VBoxContainer.get_children():
+ if button.has_focus():
+ button.pressed.emit()
+ break
+
+ elif event.is_action_pressed("right_click"):
+ visible = false
+ grid_selector.process_mode = Node.PROCESS_MODE_INHERIT
+
+
+func _on_button_pressed() -> void:
+ grid_selector.process_mode = Node.PROCESS_MODE_INHERIT
+ grid_selector.current_state = grid_selector.get_node("StateMoveMode")
+ visible = false