diff options
Diffstat (limited to 'Stages/Wintermaul/HUD.gd')
-rw-r--r-- | Stages/Wintermaul/HUD.gd | 151 |
1 files changed, 76 insertions, 75 deletions
diff --git a/Stages/Wintermaul/HUD.gd b/Stages/Wintermaul/HUD.gd index 1349bda..6063b18 100644 --- a/Stages/Wintermaul/HUD.gd +++ b/Stages/Wintermaul/HUD.gd @@ -41,94 +41,93 @@ func _ready(): %TowerConfigurationsContainer.visible = false ) - # TODO: fix multi select + # multi select %SelectionContainer.visible = false %SelectionData.get_child(0).queue_free() %MultiSelectionContainer.visible = false Client.placed_tower.connect(func(tower: Tower): - 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) - var texture = AtlasTexture.new() - texture.atlas = preload("res://core_outdoor.png") - texture.region = Rect2(400, 432, 32, 48) - multi_select_hud_data.texture = texture - - if not tower.selection_group_id in selection_groups: - selection_groups[tower.selection_group_id] = [] - selection_groups[tower.selection_group_id].append(tower) - multi_select_hud_data.add_to_group(tower.selection_group_id) - - # TODO: build groups from current component configurations matches. md5 of property values? - # TODO: do in tower.gd at select? - # TODO: probably do here at the selected signal and add to groups var at top - - if Tower.selected_towers.size() == 1: - %SelectionContainer.visible = true - %MultiSelectionContainer.visible = false + if tower.owner_id == multiplayer.get_unique_id(): + tower.selected.connect(func(): + var hud_data = tower.get_hud() - redraw_select(hud_data) - %MultiSelectionList.add_child(multi_select_hud_data) - elif Tower.selected_towers.size() > 1: - %MultiSelectionContainer.visible = true + 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) + var texture = AtlasTexture.new() + texture.atlas = preload("res://core_outdoor.png") + texture.region = Rect2(400, 432, 32, 48) + multi_select_hud_data.texture = texture - %MultiSelectionList.add_child(multi_select_hud_data) + if not tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id] = [] + selection_groups[tower.selection_group_id].append(tower) + multi_select_hud_data.add_to_group(tower.selection_group_id) - redraw_multiselect("", selected_group) - ) - - tower.deselected.connect(func(): - if Tower.selected_towers.size() == 0: - %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() - elif Tower.selected_towers.size() > 1: - # only remove deselected tower from list - var node = %MultiSelectionList.get_node_or_null(NodePath(tower.name)) - if node: # when double click selecting in quick succession not found error - node.queue_free() + if Tower.selected_towers.size() == 1: + %SelectionContainer.visible = true + %MultiSelectionContainer.visible = false + + redraw_select(hud_data) + %MultiSelectionList.add_child(multi_select_hud_data) + elif Tower.selected_towers.size() > 1: + %MultiSelectionContainer.visible = true + + %MultiSelectionList.add_child(multi_select_hud_data) + + redraw_multiselect("", selected_group) + ) - if tower.selection_group_id in selection_groups: - selection_groups[tower.selection_group_id].erase(tower) - if selection_groups[tower.selection_group_id].is_empty(): - selection_groups.erase(tower.selection_group_id) - ) - - tower.selection_group_id_changed.connect(func(previous_id: String): - if not tower.selection_group_id in selection_groups: - selection_groups[tower.selection_group_id] = [] - selection_groups[tower.selection_group_id].append(tower) - %MultiSelectionList.get_node(NodePath(tower.name)).add_to_group(tower.selection_group_id) + tower.deselected.connect(func(): + if Tower.selected_towers.size() == 0: + %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() + elif Tower.selected_towers.size() > 1: + # only remove deselected tower from list + var node = %MultiSelectionList.get_node_or_null(NodePath(tower.name)) + if node: # when double click selecting in quick succession not found error + node.queue_free() + + if tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id].erase(tower) + if selection_groups[tower.selection_group_id].is_empty(): + selection_groups.erase(tower.selection_group_id) + ) - selection_groups[previous_id].erase(tower) - if selection_groups[previous_id].is_empty(): - selection_groups.erase(previous_id) - if previous_id == selected_group: - selected_group = tower.selection_group_id - %MultiSelectionList.get_node(NodePath(tower.name)).remove_from_group(previous_id) + tower.selection_group_id_changed.connect(func(previous_id: String): + if not tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id] = [] + selection_groups[tower.selection_group_id].append(tower) + %MultiSelectionList.get_node(NodePath(tower.name)).add_to_group(tower.selection_group_id) + + selection_groups[previous_id].erase(tower) + if selection_groups[previous_id].is_empty(): + selection_groups.erase(previous_id) + if previous_id == selected_group: + selected_group = tower.selection_group_id + %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()) + ) - 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) - ) + tower.attack_value_changed.connect(func(value: int): + attack_value_changed.emit(value) + ) ) Client.multi_select_finished.connect(func(): - selected_group = get_ordered_group_keys()[0] + var keys = get_ordered_group_keys() + if keys.size() > 0: + selected_group = keys[0] ) @@ -164,8 +163,10 @@ 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 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 func get_ordered_group_keys() -> Array: |