aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project.godot1
-rw-r--r--scenes/gui/gui_turret_detail.tscn141
-rw-r--r--scripts/gui_turret_detail.gd56
3 files changed, 64 insertions, 134 deletions
diff --git a/project.godot b/project.godot
index 58b4747..7c3047a 100644
--- a/project.godot
+++ b/project.godot
@@ -185,4 +185,3 @@ quality/shadows/filter_mode=2
quality/subsurface_scattering/quality=2
quality/filters/msaa=4
quality/filters/use_fxaa=true
-environment/default_environment="res://default_env.tres"
diff --git a/scenes/gui/gui_turret_detail.tscn b/scenes/gui/gui_turret_detail.tscn
index 1b4aa5c..9d8093c 100644
--- a/scenes/gui/gui_turret_detail.tscn
+++ b/scenes/gui/gui_turret_detail.tscn
@@ -1,148 +1,69 @@
-[gd_scene load_steps=5 format=2]
+[gd_scene load_steps=4 format=2]
[ext_resource path="res://scripts/gui_turret_detail.gd" type="Script" id=1]
[ext_resource path="res://themes/DarkTheme/Dark.theme" type="Theme" id=2]
-[ext_resource path="res://scenes/gui/gui_turret_values.tscn" type="PackedScene" id=3]
[sub_resource type="StyleBoxFlat" id=1]
-bg_color = Color( 0.6, 0.6, 0.6, 0 )
+bg_color = Color( 0, 0, 0, 0.392157 )
+border_width_left = 1
+border_width_top = 1
border_width_right = 1
-shadow_offset = Vector2( 1, 1 )
+border_width_bottom = 1
-[node name="gui_turret_detail" type="Panel"]
-margin_top = -125.0
-margin_right = 200.0
-margin_bottom = 125.0
+[node name="gui_turret_detail" type="PanelContainer"]
+margin_right = 64.0
+margin_bottom = 29.0
grow_vertical = 2
-rect_min_size = Vector2( 200, 250 )
size_flags_horizontal = 9
theme = ExtResource( 2 )
-script = ExtResource( 1 )
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="name_label" type="Label" parent="."]
-anchor_right = 1.0
-text = "turret: "
-valign = 1
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="border" type="Panel" parent="."]
-anchor_right = 1.0
-anchor_bottom = 1.0
-mouse_filter = 2
custom_styles/panel = SubResource( 1 )
+script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
-[node name="hbox_global" type="HBoxContainer" parent="."]
-anchor_bottom = 1.0
-margin_top = 25.0
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="hbox_labels" type="VBoxContainer" parent="hbox_global"]
-margin_right = 150.0
-margin_bottom = 225.0
-rect_min_size = Vector2( 150, 0 )
-custom_constants/separation = 0
-__meta__ = {
-"_edit_use_anchors_": false
-}
+[node name="vbox" type="VBoxContainer" parent="."]
+margin_left = 1.0
+margin_top = 1.0
+margin_right = 63.0
+margin_bottom = 28.0
-[node name="damage" type="Label" parent="hbox_global/hbox_labels"]
+[node name="name_label" type="Label" parent="vbox"]
margin_top = -1.0
-margin_right = 150.0
+margin_right = 62.4
margin_bottom = 23.4
-text = "damage"
-valign = 1
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="range" type="Label" parent="hbox_global/hbox_labels"]
-margin_top = 23.0
-margin_right = 150.0
-margin_bottom = 47.4
-text = "range"
-valign = 1
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="turn speed" type="Label" parent="hbox_global/hbox_labels"]
-margin_top = 47.0
-margin_right = 150.0
-margin_bottom = 71.4
-text = "turn speed"
-valign = 1
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="cooldown" type="Label" parent="hbox_global/hbox_labels"]
-margin_top = 71.0
-margin_right = 150.0
-margin_bottom = 95.4
-text = "cooldown"
-valign = 1
-__meta__ = {
-"_edit_use_anchors_": false
-}
-
-[node name="projectile" type="Label" parent="hbox_global/hbox_labels"]
-margin_top = 95.0
-margin_right = 150.0
-margin_bottom = 119.4
-text = "projectile"
+text = "turret: "
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
-[node name="spread" type="Label" parent="hbox_global/hbox_labels"]
-margin_top = 119.0
-margin_right = 150.0
-margin_bottom = 143.4
-text = "spread"
-valign = 1
+[node name="hbox_global" type="HBoxContainer" parent="vbox"]
+margin_top = 27.0
+margin_right = 62.0
+margin_bottom = 27.0
__meta__ = {
"_edit_use_anchors_": false
}
-[node name="projectile speed" type="Label" parent="hbox_global/hbox_labels"]
-margin_top = 143.0
-margin_right = 150.0
-margin_bottom = 167.4
-text = "projectile speed"
-valign = 1
+[node name="hbox_labels" type="VBoxContainer" parent="vbox/hbox_global"]
+custom_constants/separation = 0
__meta__ = {
"_edit_use_anchors_": false
}
-[node name="projectiles per shot" type="Label" parent="hbox_global/hbox_labels"]
-margin_top = 167.0
-margin_right = 150.0
-margin_bottom = 191.4
-text = "projectiles per shot"
-valign = 1
+[node name="hbox_values" type="VBoxContainer" parent="vbox/hbox_global"]
+margin_left = 3.0
+margin_right = 3.0
+custom_constants/separation = 0
__meta__ = {
"_edit_use_anchors_": false
}
-[node name="modules" type="Label" parent="hbox_global/hbox_labels"]
-margin_top = 191.0
-margin_right = 150.0
-margin_bottom = 215.4
-text = "max modules"
-valign = 1
+[node name="hbox_upgs" type="VBoxContainer" parent="vbox/hbox_global"]
+margin_left = 6.0
+margin_right = 6.0
+custom_constants/separation = 0
__meta__ = {
"_edit_use_anchors_": false
}
-
-[node name="hbox_values" parent="hbox_global" instance=ExtResource( 3 )]
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