From 1494026aac1d133f46900f3de9ae3312c83edd73 Mon Sep 17 00:00:00 2001 From: Lexi Quinn Date: Mon, 20 Oct 2025 20:29:52 +1100 Subject: [PATCH] swapped out old remix menu for new one --- PCs/hero.gd | 8 +-- Scripts/Resources/card_text.gd | 12 ++++- card_description_ui.gd | 7 ++- remix_table.gd | 12 +++-- remix_table.tscn | 5 +- track_editor.gd | 91 +++++++++++++++++++++++++++------- track_editor.tscn | 46 +++++------------ 7 files changed, 118 insertions(+), 63 deletions(-) diff --git a/PCs/hero.gd b/PCs/hero.gd index 6b24059..bc1a362 100644 --- a/PCs/hero.gd +++ b/PCs/hero.gd @@ -356,15 +356,15 @@ func update_selected_box() -> void: func equip_weapon(slot: int = 0) -> void: + if weapons[slot] != null: + unequip_weapon(slot) + if !game_manager.card_gameplay or hand.size == 1: + return if hand.size == 0: return var energy_cost: int = selected_card.cost if game_manager.card_gameplay and energy < energy_cost: return - if weapons[slot] != null: - unequip_weapon(slot) - if !game_manager.card_gameplay: - return if hand.size > 0: if game_manager.card_gameplay: energy -= energy_cost diff --git a/Scripts/Resources/card_text.gd b/Scripts/Resources/card_text.gd index e2a8868..21b88d5 100644 --- a/Scripts/Resources/card_text.gd +++ b/Scripts/Resources/card_text.gd @@ -18,15 +18,23 @@ func set_attribute(attribute: String, value: float) -> void: attributes[attribute] = value -func tower_features_applied() -> CardText: +func get_duplicate() -> CardText: var card_text: CardText = self.duplicate() + card_text.target_type = target_type.duplicate() + card_text.attributes = attributes.duplicate() + card_text.features = features.duplicate() + return card_text + + +func tower_features_applied() -> CardText: + var card_text: CardText = get_duplicate() for feature: Feature in features: feature.attach_to_tower(card_text) return card_text func weapon_features_applied() -> CardText: - var card_text: CardText = self.duplicate() + var card_text: CardText = get_duplicate() for feature: Feature in features: feature.attach_to_weapon(card_text) return card_text diff --git a/card_description_ui.gd b/card_description_ui.gd index ba385cf..b07d9fa 100644 --- a/card_description_ui.gd +++ b/card_description_ui.gd @@ -28,6 +28,11 @@ func set_card(new_card: Card, side: bool) -> void: populate_targets() +func hide_features() -> void: + $FeaturesLabel.visible = false + $FeaturesVBox.visible = false + + func populate_features() -> void: for child: Node in feature_list.get_children(): child.queue_free() @@ -55,6 +60,6 @@ func populate_targets() -> void: func process_card_text(card_text: CardText) -> String: var processed_string: String = tr(card_text.text) for key: String in card_text.attributes: - processed_string = processed_string.replace(key, "[color=red]" + str(card_text.attributes[key]) + "[color=white]") + processed_string = processed_string.replace(key, "[color=red]" + str(snapped(card_text.attributes[key], 0.01)) + "[color=white]") processed_string = processed_string.replace("%", "") return processed_string diff --git a/remix_table.gd b/remix_table.gd index da540c7..d7b7cb8 100644 --- a/remix_table.gd +++ b/remix_table.gd @@ -2,17 +2,22 @@ class_name RemixTable extends StaticBody3D @export var remix_menu_scene: PackedScene +@export var button: InteractButton var reply_player: Hero +func _ready() -> void: + button.hover_text = tr("PROMPT_REMIX_INTERACT") -func _on_static_body_3d_button_interacted(value: int, callback: Hero) -> void: - if callback.hand.size >= 2: + +func _on_static_body_3d_button_interacted(_value: int, callback: Hero) -> void: + if callback.hand.size >= 1: reply_player = callback - var menu: RemixMenu = remix_menu_scene.instantiate() as RemixMenu + var menu: TrackEditor = remix_menu_scene.instantiate() as TrackEditor var card_array: Array[Card] = [] for card: Card in callback.hand.contents: card_array.append(card) + menu.populate_feature_slots() menu.add_option(card_array) menu.cards_remixed.connect(output) reply_player.pause() @@ -22,6 +27,7 @@ func _on_static_body_3d_button_interacted(value: int, callback: Hero) -> void: func output(cards_to_remove: Array[Card], cards_to_add: Array[Card]) -> void: for card: Card in cards_to_remove: reply_player.hand.contents.erase(card) + reply_player.check_removal() for card: Card in cards_to_add: reply_player.add_card(card) reply_player.unpause() diff --git a/remix_table.tscn b/remix_table.tscn index 01542f3..ae037d8 100644 --- a/remix_table.tscn +++ b/remix_table.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=6 format=3 uid="uid://c6isprnkaliqr"] [ext_resource type="Script" uid="uid://bpvmvx10q4ayd" path="res://remix_table.gd" id="1_q8doq"] -[ext_resource type="PackedScene" uid="uid://cqdft7j5pwg4b" path="res://remix_menu.tscn" id="2_ibyhf"] +[ext_resource type="PackedScene" uid="uid://bajli4d3nqwll" path="res://track_editor.tscn" id="2_ibyhf"] [ext_resource type="Script" uid="uid://dkfswql8ui0bt" path="res://Scripts/interact_button.gd" id="2_mjah6"] [sub_resource type="BoxShape3D" id="BoxShape3D_ibyhf"] @@ -9,9 +9,10 @@ [sub_resource type="BoxShape3D" id="BoxShape3D_78x4u"] size = Vector3(0.5, 0.5, 0.5) -[node name="Node3D" type="StaticBody3D"] +[node name="RemixTable" type="StaticBody3D" node_paths=PackedStringArray("button")] script = ExtResource("1_q8doq") remix_menu_scene = ExtResource("2_ibyhf") +button = NodePath("StaticBody3D") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("BoxShape3D_ibyhf") diff --git a/track_editor.gd b/track_editor.gd index aced394..55fdfa1 100644 --- a/track_editor.gd +++ b/track_editor.gd @@ -1,24 +1,32 @@ class_name TrackEditor extends Control +signal cards_remixed(cards_consumed: Array[Card], cards_created: Array[Card]) + @export var drag_feature: FeatureUI @export var sample_library: VBoxContainer @export var feature_scene: PackedScene -@export var features_list: Array[Feature] @export var parts: HBoxContainer +@export var drop_down: OptionButton +@export var card_desc: CardDescriptionUI + +const FEATURE_SLOTS: int = 6 var dragging: bool = false var hovered_feature: Feature var hovered_drop_slot: int = -2 var feature_uis: Array[FeatureUI] +var features_list: Array[Feature] var slots: Array[VBoxContainer] - -const FEATURE_SLOTS: int = 6 +var cards: Array[Card] +var card_selected: Card +var temp_card: Card func _ready() -> void: - populate_sample_library() - populate_feature_slots() + #populate_sample_library() + #populate_feature_slots() + card_desc.hide_features() parts.mouse_entered.connect(set_hovered_drop_slot.bind(-1)) parts.mouse_exited.connect(unset_hovered_drop_slot) @@ -36,18 +44,51 @@ func _input(event: InputEvent) -> void: detach_feat_from_mouse() +func select_card(option: int) -> void: + for feature_ui: FeatureUI in feature_uis: + feature_ui.queue_free() + feature_uis = [] + card_selected = cards[option] + temp_card = card_selected.duplicate() + temp_card.tower_stats = temp_card.tower_stats.get_duplicate() + temp_card.weapon_stats = temp_card.weapon_stats.get_duplicate() + card_desc.set_card(temp_card, true) + for feature: Feature in temp_card.tower_stats.features: + add_feature(feature, false) + + +func add_option(card_options: Array[Card]) -> void: + cards = card_options + for card: Card in cards: + drop_down.add_item(tr(card.display_name)) + drop_down.select(0) + select_card(0) + populate_sample_library() + + func populate_sample_library() -> void: - for x: int in 3: - var hbox: HBoxContainer = HBoxContainer.new() - hbox.size_flags_vertical = Control.SIZE_EXPAND_FILL - for y: int in 3: - var feat: FeatureUI = feature_scene.instantiate() as FeatureUI - feat.set_feature(features_list[x]) - feat.mouse_filter = Control.MOUSE_FILTER_PASS - feat.size_flags_horizontal = Control.SIZE_EXPAND_FILL - feat.mouse_entered.connect(set_hovered_feature.bind(feat.feature)) - hbox.add_child(feat) - sample_library.add_child(hbox) + for card: Card in cards: + for feature: Feature in card.tower_stats.features: + if !features_list.has(feature): + features_list.append(feature) + for feature: Feature in card.weapon_stats.features: + if !features_list.has(feature): + features_list.append(feature) + var i: int = 0 + var hbox: HBoxContainer + for feature: Feature in features_list: + if i == 0: + hbox = HBoxContainer.new() + sample_library.add_child(hbox) + var feat: FeatureUI = feature_scene.instantiate() as FeatureUI + feat.set_feature(feature) + feat.mouse_filter = Control.MOUSE_FILTER_PASS + feat.size_flags_horizontal = Control.SIZE_EXPAND_FILL + feat.mouse_entered.connect(set_hovered_feature.bind(feat.feature)) + hbox.add_child(feat) + i += 1 + if i == 3: + i = 0 sample_library.mouse_exited.connect(unset_hovered_feature) @@ -73,7 +114,7 @@ func populate_feature_slots() -> void: slots.append(vbox) -func add_feature(feature: Feature) -> void: +func add_feature(feature: Feature, modify_resource: bool = true) -> void: if hovered_drop_slot >= 0 and hovered_drop_slot < feature_uis.size(): change_feature(feature_uis[hovered_drop_slot], feature) elif feature_uis.size() < FEATURE_SLOTS: @@ -81,10 +122,16 @@ func add_feature(feature: Feature) -> void: feature_visual.set_feature(feature) slots[feature_uis.size()].add_child(feature_visual) feature_uis.append(feature_visual) + if modify_resource: + temp_card.tower_stats.features.append(feature) + card_desc.set_card(temp_card, true) func change_feature(existing_feature: FeatureUI, new_feature: Feature) -> void: existing_feature.set_feature(new_feature) + var i: int = feature_uis.find(existing_feature) + temp_card.tower_stats.features[i] = new_feature + card_desc.set_card(temp_card, true) func attach_feat_to_mouse(feature: Feature) -> void: @@ -117,8 +164,16 @@ func unset_hovered_drop_slot() -> void: func _on_cancel_button_pressed() -> void: + var cards_to_remove: Array[Card] = [] + var cards_to_add: Array[Card] = [] + cards_remixed.emit(cards_to_remove, cards_to_add) queue_free() func _on_confirm_button_pressed() -> void: - pass # Replace with function body. + var cards_to_remove: Array[Card] = [] + var cards_to_add: Array[Card] = [] + cards_to_remove.append(card_selected) + cards_to_add.append(temp_card) + cards_remixed.emit(cards_to_remove, cards_to_add) + queue_free() diff --git a/track_editor.tscn b/track_editor.tscn index f5634ad..c75ee0a 100644 --- a/track_editor.tscn +++ b/track_editor.tscn @@ -1,13 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://bajli4d3nqwll"] +[gd_scene load_steps=4 format=3 uid="uid://bajli4d3nqwll"] [ext_resource type="PackedScene" uid="uid://c8xdsg6gtwvh3" path="res://feature_ui.tscn" id="1_y6tpq"] [ext_resource type="Script" uid="uid://mrv5vrlxfc13" path="res://track_editor.gd" id="1_yrnbk"] -[ext_resource type="Script" uid="uid://bsuinotkvh7eu" path="res://Scripts/Resources/feature.gd" id="3_dya4i"] -[ext_resource type="Resource" uid="uid://nh7g23b3rnvr" path="res://Scripts/Features/Radar/radar_feature.tres" id="4_4gmyw"] -[ext_resource type="Resource" uid="uid://dfup264h2pun7" path="res://Scripts/Features/HeavyRounds/heavy_rounds_feature.tres" id="5_dxngn"] -[ext_resource type="Resource" uid="uid://bij61ul87ka0r" path="res://Scripts/Features/ExtendedBarrel/extended_barrel_feature.tres" id="6_1rakx"] +[ext_resource type="PackedScene" uid="uid://cmlpmr78tmo6p" path="res://card_description_ui.tscn" id="3_q6wwl"] -[node name="Control" type="Control" node_paths=PackedStringArray("drag_feature", "sample_library", "parts")] +[node name="Control" type="Control" node_paths=PackedStringArray("drag_feature", "sample_library", "parts", "drop_down", "card_desc")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -16,10 +13,11 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_yrnbk") drag_feature = NodePath("FeatureUI") -sample_library = NodePath("PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/SamplePanel/SampleLibrary") +sample_library = NodePath("PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/SamplePanel/ScrollContainer/SampleLibrary") feature_scene = ExtResource("1_y6tpq") -features_list = Array[ExtResource("3_dya4i")]([ExtResource("4_4gmyw"), ExtResource("5_dxngn"), ExtResource("6_1rakx")]) parts = NodePath("PanelContainer/VBoxContainer/VBoxContainer/SourceCartridge/Parts") +drop_down = NodePath("PanelContainer/VBoxContainer/VBoxContainer/SourceCartridge/CassetteSelector/OptionButton") +card_desc = NodePath("PanelContainer/VBoxContainer/InfoPanel/DescriptionVBox") [node name="PanelContainer" type="PanelContainer" parent="."] layout_mode = 1 @@ -78,31 +76,8 @@ layout_mode = 2 size_flags_vertical = 3 size_flags_stretch_ratio = 5.0 -[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/InfoPanel"] +[node name="DescriptionVBox" parent="PanelContainer/VBoxContainer/InfoPanel" instance=ExtResource("3_q6wwl")] layout_mode = 2 -size_flags_horizontal = 3 - -[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer"] -layout_mode = 2 -text = "LABEL_CARD_DESCRIPTION" -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="RichTextLabel" type="RichTextLabel" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 -bbcode_enabled = true -text = "a long ass example description of a card that goes into honestly way too much detail but at least if we can support a lot of text at a good size then we dont have to worry about really complicated cards fucking up our UI later in developement if we end up needing to explain a lot" - -[node name="Label2" type="Label" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer"] -layout_mode = 2 -text = "LABEL_TARGET_LIST" -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 [node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/InfoPanel"] layout_mode = 2 @@ -123,7 +98,11 @@ text = "TITLE_SAMPLES" horizontal_alignment = 1 vertical_alignment = 1 -[node name="SampleLibrary" type="VBoxContainer" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/SamplePanel"] +[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/SamplePanel"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="SampleLibrary" type="VBoxContainer" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/SamplePanel/ScrollContainer"] layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 @@ -150,5 +129,6 @@ grow_horizontal = 1 grow_vertical = 1 mouse_filter = 2 +[connection signal="item_selected" from="PanelContainer/VBoxContainer/VBoxContainer/SourceCartridge/CassetteSelector/OptionButton" to="." method="select_card"] [connection signal="pressed" from="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/Controls/CancelButton" to="." method="_on_cancel_button_pressed"] [connection signal="pressed" from="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/Controls/ConfirmButton" to="." method="_on_confirm_button_pressed"]