summaryrefslogtreecommitdiff
path: root/Stages/Wintermaul/HUD.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-03 14:10:07 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-03 14:10:07 +0100
commit84365b6f901a9c0251a9f724a8d9f81a3787e97d (patch)
tree401e2bf99e6573d1d069f5044e7448067cdfb384 /Stages/Wintermaul/HUD.gd
parenta43499efa6c228cea3633f9661f3ff09127bd82d (diff)
next commit
Diffstat (limited to 'Stages/Wintermaul/HUD.gd')
-rw-r--r--Stages/Wintermaul/HUD.gd46
1 files changed, 22 insertions, 24 deletions
diff --git a/Stages/Wintermaul/HUD.gd b/Stages/Wintermaul/HUD.gd
index 6063b18..8457ab2 100644
--- a/Stages/Wintermaul/HUD.gd
+++ b/Stages/Wintermaul/HUD.gd
@@ -7,9 +7,7 @@ var selected_group := "":
set(value):
redraw_multiselect(selected_group, value)
selected_group = value
- redraw_select(selection_groups[selected_group][0].get_hud())
-
-signal attack_value_changed(value: int)
+ redraw_select(selection_groups[selected_group][0])
@onready var time: Label = %Time
@onready var money: Label = %Money
@@ -43,19 +41,19 @@ func _ready():
# multi select
%SelectionContainer.visible = false
- %SelectionData.get_child(0).queue_free()
%MultiSelectionContainer.visible = false
Client.placed_tower.connect(func(tower: Tower):
if tower.owner_id == multiplayer.get_unique_id():
tower.selected.connect(func():
- var hud_data = tower.get_hud()
-
var multi_select_hud_data = TextureRect.new()
multi_select_hud_data.name = tower.name
multi_select_hud_data.modulate = Color(0.5, 0.5, 0.5)
+ multi_select_hud_data.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
+ multi_select_hud_data.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
+ multi_select_hud_data.custom_minimum_size = Vector2(32, 64)
var texture = AtlasTexture.new()
- texture.atlas = preload("res://core_outdoor.png")
- texture.region = Rect2(400, 432, 32, 48)
+ texture.atlas = preload("res://Towers/Assets/spritesheet.png")
+ texture.region = Rect2(5, 1, 62, 95)
multi_select_hud_data.texture = texture
if not tower.selection_group_id in selection_groups:
@@ -67,14 +65,16 @@ func _ready():
%SelectionContainer.visible = true
%MultiSelectionContainer.visible = false
- redraw_select(hud_data)
%MultiSelectionList.add_child(multi_select_hud_data)
+ selected_group = tower.selection_group_id
elif Tower.selected_towers.size() > 1:
%MultiSelectionContainer.visible = true
%MultiSelectionList.add_child(multi_select_hud_data)
redraw_multiselect("", selected_group)
+
+ redraw_select(tower)
)
tower.deselected.connect(func():
@@ -82,14 +82,15 @@ func _ready():
%SelectionContainer.visible = false
%MultiSelectionContainer.visible = false
- for child in %SelectionData.get_children():
- child.queue_free()
for child in %MultiSelectionList.get_children():
child.queue_free()
elif Tower.selected_towers.size() == 1:
%MultiSelectionContainer.visible = false
%SelectionContainer.visible = true
- %MultiSelectionList.get_node(NodePath(tower.name)).queue_free()
+
+ var node = %MultiSelectionList.get_node_or_null(NodePath(tower.name))
+ if node:
+ node.queue_free()
elif Tower.selected_towers.size() > 1:
# only remove deselected tower from list
var node = %MultiSelectionList.get_node_or_null(NodePath(tower.name))
@@ -116,11 +117,7 @@ func _ready():
%MultiSelectionList.get_node(NodePath(tower.name)).remove_from_group(previous_id)
if tower.name == selection_groups[tower.selection_group_id][0].name:
- redraw_select(tower.get_hud())
- )
-
- tower.attack_value_changed.connect(func(value: int):
- attack_value_changed.emit(value)
+ redraw_select(tower)
)
)
@@ -144,11 +141,8 @@ func _input(event: InputEvent):
selected_group = keys[(current_idx + 1) % keys.size()]
-func redraw_select(hud_data: Control):
- for node in %SelectionData.get_children():
- node.queue_free()
-
- %SelectionData.add_child(hud_data)
+func redraw_select(tower: Tower):
+ %TowerData.current_tower = tower
func redraw_multiselect(previous_group: String, new_group: String):
@@ -163,10 +157,14 @@ func redraw_multiselect(previous_group: String, new_group: String):
for node in get_tree().get_nodes_in_group(previous_group):
node.modulate = Color(0.5, 0.5, 0.5)
- Client.current_stage.get_node("%Towers/" + node.name).is_highlighted = false
+ var tower = Client.current_stage.get_node_or_null("%Towers/" + node.name)
+ if tower:
+ tower.is_highlighted = false
for node in get_tree().get_nodes_in_group(new_group):
node.modulate = Color(1.0, 1.0, 1.0)
- Client.current_stage.get_node("%Towers/" + node.name).is_highlighted = true
+ var tower = Client.current_stage.get_node_or_null("%Towers/" + node.name)
+ if tower:
+ tower.is_highlighted = true
func get_ordered_group_keys() -> Array: