diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-14 00:06:52 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-14 00:06:52 +0100 |
commit | 90af765b430e3a75daa9b2b4d0343ae58ad5c33d (patch) | |
tree | 024e803ce9b7476ed310fc156b54eb5ebced3c4f /scripts/gui_turret_detail.gd | |
parent | 7cb4290601010459b09376396c7833ec391c25bf (diff) |
secret work
Diffstat (limited to 'scripts/gui_turret_detail.gd')
-rw-r--r-- | scripts/gui_turret_detail.gd | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/scripts/gui_turret_detail.gd b/scripts/gui_turret_detail.gd new file mode 100644 index 0000000..df89c14 --- /dev/null +++ b/scripts/gui_turret_detail.gd @@ -0,0 +1,63 @@ +extends Panel + +var hbox_labels +var hbox_global +var _turret_values : Resource = load("res://scenes/gui/gui_turret_values.tscn") +var load_turrets : Node + +var gui : Control + +func _fetch (): + if gui == null: gui = get_parent() + if hbox_labels != null: return; + hbox_labels = $"hbox_global/hbox_labels" + hbox_global = $"hbox_global" + + var root = get_tree().root.get_child(0) + load_turrets = root.get_node("saveload").get_node("load_turrets") + if !load_turrets.loaded: yield(load_turrets, "done_loading") + + +func refresh (turret : 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", "-"), + } + + var base_values = hbox_global.get_node("hbox_values") + for k in dict: + base_values.get_node(k).text = str(dict[k]); + +func _process(delta): + _fetch() + + var info = null; + + var hovering = gui.bottom_bar.turret_picker.hovering + if gui.player.highlight != null: + info = gui.player.highlight.info + elif gui.player.sel.type == "turrets": + info = load_turrets.info[gui.player.sel.name] + elif hovering != "": + info = load_turrets.info[hovering] + elif gui.player.placer.colliding \ + and "turrets" in gui.player.placer.colliding_group: + info = gui.player.placer.colliding_node.info + + if info != null: + refresh(info) + self.visible = true + else: self.visible = false |