summaryrefslogtreecommitdiff
path: root/scripts/ui.gd
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-05-24 18:50:01 -0400
committerbd <bdunahu@operationnull.com>2025-05-24 18:50:01 -0400
commit2190d18d8d58f867927126829e7c0d7ef6fac372 (patch)
tree1dd88af4374a9105ef2c723c43a68a0fd67e390f /scripts/ui.gd
parentc38a303aad3c3c0d8114524e664da6ad721e21c4 (diff)
Add UI panel which displays actions/upgrades
Diffstat (limited to 'scripts/ui.gd')
-rw-r--r--scripts/ui.gd34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/ui.gd b/scripts/ui.gd
new file mode 100644
index 0000000..031236b
--- /dev/null
+++ b/scripts/ui.gd
@@ -0,0 +1,34 @@
+extends PanelContainer
+
+@onready var morale : Label = $MarginContainer/HBoxContainer/VBoxContainer/Life
+@onready var life : Label = $MarginContainer/HBoxContainer/VBoxContainer/Morale
+@onready var options_container : HBoxContainer = $MarginContainer/HBoxContainer/HBoxContainer
+
+var ui_option = preload("res://scenes/ui_option.tscn")
+
+func _ready():
+ var player = get_node("../Player")
+ player.connect("curr_tile", Callable(self, "_update_options"))
+
+ GameData.connect("morale_changed", Callable(self, "_update_morale"))
+ GameData.connect("life_changed", Callable(self, "_update_life"))
+ _update_morale()
+ _update_life()
+
+func _update_morale() -> void:
+ morale.text = "Morale:" + str(GameData.get_morale())
+
+func _update_life() -> void:
+ life.text = "Life:" + str(GameData.get_life())
+
+func _update_options(data):
+ for i in options_container.get_children():
+ i.queue_free()
+
+ if data != null:
+ for i in data:
+ var option = ui_option.instantiate()
+ option.desc = i["desc"]
+ option.cost = i["cost"]
+ option.sprite_atlas = i["sprite_panel"]
+ options_container.add_child(option)