aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-02-01 14:08:13 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-02-01 14:08:13 +0100
commitef2fa8b2b8b545f52a21052713b15c3b406a3055 (patch)
treee656afca037386c8b65faab07e585405e29ac897 /scripts
parent5e7fec45672277cfa33542aefef1d746eee6d2e8 (diff)
turret detail GUI
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gui_turret_detail.gd56
1 files changed, 33 insertions, 23 deletions
diff --git a/scripts/gui_turret_detail.gd b/scripts/gui_turret_detail.gd
index ec5d9a1..2f42833 100644
--- a/scripts/gui_turret_detail.gd
+++ b/scripts/gui_turret_detail.gd
@@ -1,9 +1,8 @@
-extends Panel
+extends PanelContainer
var hbox_labels
var hbox_global
var _turret_holder : Node
-var _turret_values : Resource = load("res://scenes/gui/gui_turret_values.tscn")
var load_turrets : Node
var resources : Node
@@ -16,8 +15,8 @@ func _fetch ():
var root = get_tree().root.get_node("world")
_turret_holder = root.get_node("turrets")
- hbox_labels = $"hbox_global/hbox_labels"
- hbox_global = $"hbox_global"
+ hbox_labels = $"vbox/hbox_global/hbox_labels"
+ hbox_global = $"vbox/hbox_global"
resources = root.get_node("player").get_node("resources")
@@ -25,33 +24,44 @@ func _fetch ():
if !load_turrets.loaded: yield(load_turrets, "done_loading")
-func refresh (turret : Dictionary, upgraded : Dictionary = {}):
+func flatten (dict : Dictionary):
+ var flat = {}
+ for k in dict:
+ if dict[k] is Dictionary:
+ for kk in dict[k]:
+ flat[k+" "+kk] = dict[k][kk]
+ else: flat[k] = dict[k]
+ return flat
+
+func refresh (turret_info : Dictionary, upgraded : Dictionary = {}):
_fetch()
- if upgraded == null: rect_min_size.x = 200
- else: rect_min_size.x = 230
- get_node("name_label").text = "name: " + turret.name
-
- var dict = {
- "damage": turret.get("damage", "-"),
- "range": turret.get("range", "-"),
- "turn speed": turret.get("turn_speed", "-"),
- "cooldown": turret.get("cooldown", "-"),
- "projectile": turret.get("projectile", {}).get("type", "-"),
- "spread": turret.get("projectile", {}).get("spread", "-"),
- "projectile speed": turret.get("projectile", {}).get("speed", "-"),
- "projectiles per shot": turret.get("projectile", {}).get("amount", "-"),
- "modules": turret.get("modules_max", "-"),
- }
+ get_node("vbox").get_node("name_label").text = "name: " + turret_info.name
+ var base_labels = hbox_global.get_node("hbox_labels")
var base_values = hbox_global.get_node("hbox_values")
- for k in dict:
- base_values.get_node(k).text = str(dict[k]);
+ for child in base_labels.get_children(): child.queue_free()
+ for child in base_values.get_children(): child.queue_free()
+
+ var flat = flatten(turret_info)
+
+ var skip = ["upgrades"]
+ for k in flat:
+ if k in skip or "name" in k: continue
+
+ var val = str(flat[k])
+ var label_lab = Label.new()
+ label_lab.text = k
+ base_labels.add_child(label_lab)
+ var label_val = Label.new()
+ label_val.text = val
+ base_values.add_child(label_val)
func _process(delta):
_fetch()
var info = null;
+ var comp = {};
var hovering = null
if gui.control.state == Globals.PlayerState.PICK and \
@@ -84,6 +94,6 @@ func _process(delta):
info = gui.player.placer.colliding_node.info
if info != null:
- refresh(info)
+ refresh(info, comp)
self.visible = true
else: self.visible = false