more work on the ui theme and changing the hud

This commit is contained in:
2025-11-05 08:28:07 +11:00
parent 2f4159ebbe
commit f257a5df68
187 changed files with 806 additions and 799 deletions

View File

@@ -0,0 +1,8 @@
class_name PricePanel
extends PanelContainer
@export var label: Label
func set_price(price: int) -> void:
label.text = "$" + str(price)

View File

@@ -0,0 +1 @@
uid://bs73eocafngiu

View File

@@ -0,0 +1,24 @@
[gd_scene load_steps=3 format=3 uid="uid://dekexkjl37dvh"]
[ext_resource type="Script" uid="uid://bs73eocafngiu" path="res://UI/Menus/MixingMenu/price_panel.gd" id="1_sn84y"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_517dt"]
bg_color = Color(0.2702219, 0.27022195, 0.27022177, 0.09019608)
corner_detail = 1
[node name="Control" type="PanelContainer" node_paths=PackedStringArray("label")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_517dt")
script = ExtResource("1_sn84y")
label = NodePath("Label")
[node name="Label" type="Label" parent="."]
layout_mode = 2
text = "$15"
horizontal_alignment = 1
vertical_alignment = 1

View File

@@ -0,0 +1,258 @@
class_name TrackEditor
extends Control
signal cards_remixed(cards_consumed: Array[Card], cards_created: Array[Card], amount_spent: int)
@export var drag_feature: FeatureUI
@export var sample_library: VBoxContainer
@export var feature_scene: PackedScene
@export var tower_parts: HBoxContainer
@export var weapon_parts: HBoxContainer
@export var drop_down: OptionButton
@export var card_desc: CardDescriptionUI
@export var price_panel_scene: PackedScene
@export var price_label: Label
@export var money_label: Label
@export var confirm_button: Button
@export var switch_button: Button
const FEATURE_SLOTS: int = 6
const PRICE_STR: String = "LABEL_REMIX_PRICE"
const MONEY_STR: String = "LABEL_REMIX_CURRENCY"
const SIDE_A_STR: String = "BUTTON_VIEW_TOWER"
const SIDE_B_STR: String = "BUTTON_VIEW_WEAPON"
var hero: Hero
var dragging: bool = false
var hovered_feature: Feature
var hovered_drop_slot: int = -2
var hovered_drop_track: int = 0
var tower_feature_uis: Array[FeatureUI]
var weapon_feature_uis: Array[FeatureUI]
var features_list: Array[Feature]
var tower_slots: Array[MarginContainer]
var weapon_slots: Array[MarginContainer]
var tower_prices: Array[PricePanel]
var weapon_prices: Array[PricePanel]
var cards: Array[Card]
var card_selected: Card
var temp_card: Card
var cost: int = 0
var check_button_pressed: bool = false
func _ready() -> void:
#populate_sample_library()
#populate_feature_slots()
card_desc.hide_features()
tower_parts.mouse_entered.connect(set_hovered_drop_slot.bind(-1, 0))
weapon_parts.mouse_entered.connect(set_hovered_drop_slot.bind(-1, 1))
tower_parts.mouse_exited.connect(unset_hovered_drop_slot)
weapon_parts.mouse_exited.connect(unset_hovered_drop_slot)
price_label.text = tr(PRICE_STR) + str(cost)
func set_money(money: int) -> void:
money_label.text = tr(MONEY_STR) + str(money)
func press_check_button(value: bool) -> void:
check_button_pressed = value
if check_button_pressed:
switch_button.text = tr(SIDE_B_STR)
else:
switch_button.text = tr(SIDE_A_STR)
card_desc.set_card(temp_card, check_button_pressed)
func _process(_delta: float) -> void:
drag_feature.position = get_viewport().get_mouse_position()
if Input.is_action_just_pressed("Pause"):
_on_cancel_button_pressed()
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.pressed == true and event.button_index == 1:
if hovered_feature != null:
attach_feat_to_mouse(hovered_feature)
if event.pressed == false and event.button_index == 1:
detach_feat_from_mouse()
func select_card(option: int) -> void:
for feature_ui: FeatureUI in tower_feature_uis:
feature_ui.queue_free()
tower_feature_uis = []
for feature_ui: FeatureUI in weapon_feature_uis:
feature_ui.queue_free()
weapon_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, check_button_pressed)
for feature: Feature in temp_card.tower_stats.features:
add_feature(feature, 0, false)
for feature: Feature in temp_card.weapon_stats.features:
add_feature(feature, 1, 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 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.show_title()
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)
func populate_feature_slots() -> void:
for x: int in FEATURE_SLOTS:
var vbox: MarginContainer = MarginContainer.new()
vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
vbox.mouse_filter = Control.MOUSE_FILTER_STOP
vbox.mouse_entered.connect(set_hovered_drop_slot.bind(tower_slots.size(), 0))
vbox.mouse_exited.connect(unset_hovered_drop_slot)
tower_parts.add_child(vbox)
tower_slots.append(vbox)
if x != 0:
var panel: PricePanel = price_panel_scene.instantiate() as PricePanel
panel.set_price(Data.slot_prices[x - 1])
vbox.add_child(panel)
tower_prices.append(panel)
for x: int in FEATURE_SLOTS:
var vbox: MarginContainer = MarginContainer.new()
vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
vbox.mouse_filter = Control.MOUSE_FILTER_STOP
vbox.mouse_entered.connect(set_hovered_drop_slot.bind(weapon_slots.size(), 1))
vbox.mouse_exited.connect(unset_hovered_drop_slot)
weapon_parts.add_child(vbox)
weapon_slots.append(vbox)
if x != 0:
var panel: PricePanel = price_panel_scene.instantiate() as PricePanel
panel.set_price(Data.slot_prices[x - 1])
vbox.add_child(panel)
weapon_prices.append(panel)
func add_feature(feature: Feature, track: int, modify_resource: bool = true) -> void:
if hovered_drop_slot == 0:
return
if track == 0:
if hovered_drop_slot > 0 and hovered_drop_slot < tower_feature_uis.size():
change_feature(tower_feature_uis[hovered_drop_slot], feature, 0)
elif tower_feature_uis.size() < FEATURE_SLOTS:
var feature_visual: FeatureUI = feature_scene.instantiate()
feature_visual.set_feature(feature)
tower_slots[tower_feature_uis.size()].add_child(feature_visual)
tower_feature_uis.append(feature_visual)
if modify_resource:
temp_card.tower_stats.features.append(feature)
tower_prices[tower_feature_uis.size() - 2].visible = false
cost += Data.slot_prices[tower_feature_uis.size() - 2]
price_label.text = tr(PRICE_STR) + str(cost)
card_desc.set_card(temp_card, check_button_pressed)
if cost > hero.currency:
confirm_button.disabled = true
elif track == 1:
if hovered_drop_slot > 0 and hovered_drop_slot < weapon_feature_uis.size():
change_feature(weapon_feature_uis[hovered_drop_slot], feature, 1)
elif weapon_feature_uis.size() < FEATURE_SLOTS:
var feature_visual: FeatureUI = feature_scene.instantiate()
feature_visual.set_feature(feature)
weapon_slots[weapon_feature_uis.size()].add_child(feature_visual)
weapon_feature_uis.append(feature_visual)
if modify_resource:
temp_card.weapon_stats.features.append(feature)
weapon_prices[weapon_feature_uis.size() - 2].visible = false
cost += Data.slot_prices[weapon_feature_uis.size() - 2]
price_label.text = tr(PRICE_STR) + str(cost)
card_desc.set_card(temp_card, check_button_pressed)
if cost > hero.currency:
confirm_button.disabled = true
func change_feature(existing_feature: FeatureUI, new_feature: Feature, track: int) -> void:
existing_feature.set_feature(new_feature)
if track == 0:
var i: int = tower_feature_uis.find(existing_feature)
temp_card.tower_stats.features[i] = new_feature
elif track == 1:
var i: int = weapon_feature_uis.find(existing_feature)
temp_card.weapon_stats.features[i] = new_feature
card_desc.set_card(temp_card, check_button_pressed)
func attach_feat_to_mouse(feature: Feature) -> void:
drag_feature.set_feature(feature)
drag_feature.visible = true
dragging = true
func detach_feat_from_mouse() -> void:
drag_feature.visible = false
if hovered_drop_slot >= -1 and dragging == true:
add_feature(drag_feature.feature, hovered_drop_track)
dragging = false
func set_hovered_feature(feature: Feature) -> void:
hovered_feature = feature
func unset_hovered_feature() -> void:
hovered_feature = null
func set_hovered_drop_slot(slot: int = -2, track: int = 0) -> void:
hovered_drop_slot = slot
hovered_drop_track = track
func unset_hovered_drop_slot() -> void:
hovered_drop_slot = -2
hovered_drop_track = -1
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, 0)
queue_free()
func _on_confirm_button_pressed() -> void:
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, cost)
queue_free()

View File

@@ -0,0 +1 @@
uid://mrv5vrlxfc13

View File

@@ -0,0 +1,241 @@
[gd_scene load_steps=7 format=3 uid="uid://bajli4d3nqwll"]
[ext_resource type="PackedScene" uid="uid://c8xdsg6gtwvh3" path="res://UI/FeatureUI/feature_ui.tscn" id="1_y6tpq"]
[ext_resource type="Script" uid="uid://mrv5vrlxfc13" path="res://UI/Menus/MixingMenu/track_editor.gd" id="1_yrnbk"]
[ext_resource type="PackedScene" uid="uid://dekexkjl37dvh" path="res://UI/Menus/MixingMenu/price_panel.tscn" id="3_48m6c"]
[ext_resource type="PackedScene" uid="uid://cmlpmr78tmo6p" path="res://UI/card_description_ui.tscn" id="3_q6wwl"]
[ext_resource type="Texture2D" uid="uid://cll2vlvf1h454" path="res://UI/Themes/Scale1/track_one_patch.png" id="4_dya4i"]
[ext_resource type="Texture2D" uid="uid://cvhkk22pxxuqj" path="res://UI/Themes/Scale1/track_two_patch.png" id="5_4gmyw"]
[node name="TrackEditor" type="Control" node_paths=PackedStringArray("drag_feature", "sample_library", "tower_parts", "weapon_parts", "drop_down", "card_desc", "price_label", "money_label", "confirm_button", "switch_button")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_yrnbk")
drag_feature = NodePath("FeatureUI")
sample_library = NodePath("PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/SamplePanel/ScrollContainer/SampleLibrary")
feature_scene = ExtResource("1_y6tpq")
tower_parts = NodePath("PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs/Tower/MarginContainer/TowerParts")
weapon_parts = NodePath("PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs/Weapon/MarginContainer/WeaponParts")
drop_down = NodePath("PanelContainer/VBoxContainer/Tracks/SourceCartridge/CassetteSelector/OptionButton")
card_desc = NodePath("PanelContainer/VBoxContainer/InfoPanel/VBoxContainer/DescriptionVBox")
price_panel_scene = ExtResource("3_48m6c")
price_label = NodePath("PanelContainer/VBoxContainer/Tracks/SourceCartridge/MarginContainer/VBoxContainer/PriceLabel")
money_label = NodePath("PanelContainer/VBoxContainer/Tracks/SourceCartridge/MarginContainer/VBoxContainer/MoneyLabel")
confirm_button = NodePath("PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/Controls/ConfirmButton")
switch_button = NodePath("PanelContainer/VBoxContainer/InfoPanel/VBoxContainer/Button")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.02
anchor_top = 0.02
anchor_right = 0.98
anchor_bottom = 0.98
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
text = "TITLE_REMIX"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Tracks" type="VBoxContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="SourceCartridge" type="HBoxContainer" parent="PanelContainer/VBoxContainer/Tracks"]
layout_mode = 2
[node name="MarginContainer2" type="MarginContainer" parent="PanelContainer/VBoxContainer/Tracks/SourceCartridge"]
layout_mode = 2
size_flags_horizontal = 3
[node name="CassetteSelector" type="VBoxContainer" parent="PanelContainer/VBoxContainer/Tracks/SourceCartridge"]
layout_mode = 2
size_flags_horizontal = 3
[node name="OptionButton" type="OptionButton" parent="PanelContainer/VBoxContainer/Tracks/SourceCartridge/CassetteSelector"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 1
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/Tracks/SourceCartridge"]
layout_mode = 2
size_flags_horizontal = 3
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/Tracks/SourceCartridge/MarginContainer"]
layout_mode = 2
[node name="MoneyLabel" type="Label" parent="PanelContainer/VBoxContainer/Tracks/SourceCartridge/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 1
text = "Coins: $0"
horizontal_alignment = 1
vertical_alignment = 1
[node name="PriceLabel" type="Label" parent="PanelContainer/VBoxContainer/Tracks/SourceCartridge/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 1
text = "Price: $0"
horizontal_alignment = 1
vertical_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/Tracks"]
layout_mode = 2
[node name="Labels" type="VBoxContainer" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer"]
layout_mode = 2
[node name="Tower" type="Label" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/Labels"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 7
text = "LABEL_TOWER_TRACK"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Weapon" type="Label" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/Labels"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 7
text = "LABEL_WEAPON_TRACK"
horizontal_alignment = 1
vertical_alignment = 1
[node name="TrackUIs" type="VBoxContainer" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Tower" type="MarginContainer" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 4.0
[node name="NinePatchRect" type="NinePatchRect" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs/Tower"]
layout_mode = 2
texture = ExtResource("5_4gmyw")
patch_margin_left = 1
patch_margin_top = 1
patch_margin_right = 1
patch_margin_bottom = 1
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs/Tower"]
layout_mode = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TowerParts" type="HBoxContainer" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs/Tower/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Weapon" type="MarginContainer" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 4.0
[node name="NinePatchRect" type="NinePatchRect" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs/Weapon"]
layout_mode = 2
texture = ExtResource("4_dya4i")
patch_margin_left = 1
patch_margin_top = 1
patch_margin_right = 1
patch_margin_bottom = 1
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs/Weapon"]
layout_mode = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="WeaponParts" type="HBoxContainer" parent="PanelContainer/VBoxContainer/Tracks/HBoxContainer/TrackUIs/Weapon/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="InfoPanel" type="HBoxContainer" parent="PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
size_flags_stretch_ratio = 2.0
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/InfoPanel"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Button" type="Button" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
theme_type_variation = &"SideCheckButton"
toggle_mode = true
text = "Side A"
[node name="DescriptionVBox" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer" instance=ExtResource("3_q6wwl")]
layout_mode = 2
size_flags_vertical = 3
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/InfoPanel"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.1
[node name="VBoxContainer2" type="VBoxContainer" parent="PanelContainer/VBoxContainer/InfoPanel"]
layout_mode = 2
size_flags_horizontal = 3
[node name="SamplePanel" type="VBoxContainer" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2"]
layout_mode = 2
size_flags_vertical = 3
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/SamplePanel"]
layout_mode = 2
text = "TITLE_SAMPLES"
horizontal_alignment = 1
vertical_alignment = 1
[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
[node name="Controls" type="HBoxContainer" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2"]
layout_mode = 2
alignment = 2
[node name="CancelButton" type="Button" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/Controls"]
layout_mode = 2
text = "BUTTON_CANCEL"
[node name="ConfirmButton" type="Button" parent="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer2/Controls"]
layout_mode = 2
text = "BUTTON_CONFIRM_REMIX"
[node name="FeatureUI" parent="." instance=ExtResource("1_y6tpq")]
visible = false
layout_mode = 0
anchors_preset = 0
anchor_right = 0.0
anchor_bottom = 0.0
grow_horizontal = 1
grow_vertical = 1
mouse_filter = 2
[connection signal="item_selected" from="PanelContainer/VBoxContainer/Tracks/SourceCartridge/CassetteSelector/OptionButton" to="." method="select_card"]
[connection signal="toggled" from="PanelContainer/VBoxContainer/InfoPanel/VBoxContainer/Button" to="." method="press_check_button"]
[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"]