From 676c82c4e5bac3d39dd46baef3fff6d72b2e9d2e Mon Sep 17 00:00:00 2001 From: gamer147 Date: Fri, 10 Apr 2026 09:46:39 -0400 Subject: [PATCH] Weird alignments --- prefabs/chip_bar.tscn | 10 +++++++--- prefabs/combat_ui.tscn | 24 +++++++++++++++--------- scripts/battle/combat_ui.gd | 29 +++++++++++++++++++++-------- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/prefabs/chip_bar.tscn b/prefabs/chip_bar.tscn index e1aa54c..daa2866 100644 --- a/prefabs/chip_bar.tscn +++ b/prefabs/chip_bar.tscn @@ -12,8 +12,12 @@ grow_vertical = 2 script = ExtResource("1_3whrn") [node name="HFlowContainer" type="HFlowContainer" parent="." unique_id=185867767] -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 40.0 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 theme_override_constants/h_separation = 0 theme_override_constants/v_separation = 0 +alignment = 2 diff --git a/prefabs/combat_ui.tscn b/prefabs/combat_ui.tscn index 0292898..399e44c 100644 --- a/prefabs/combat_ui.tscn +++ b/prefabs/combat_ui.tscn @@ -283,7 +283,7 @@ layout_mode = 2 text = "Cancel" [node name="UnitPanel" type="Control" parent="UIBase" unique_id=1823763147] -visible = false +unique_name_in_owner = true layout_mode = 1 anchors_preset = 3 anchor_left = 1.0 @@ -333,12 +333,13 @@ value = 12 [node name="UnitHealth" type="HBoxContainer" parent="UIBase/UnitPanel" unique_id=53239936] layout_mode = 0 -offset_left = 185.0 +offset_left = 1.0 offset_top = 103.0 offset_right = 225.0 -offset_bottom = 143.0 +offset_bottom = 131.0 -[node name="ChipBar" parent="UIBase/UnitPanel/UnitHealth" unique_id=379110810 instance=ExtResource("6_gqe5k")] +[node name="HealthChipBar" parent="UIBase/UnitPanel/UnitHealth" unique_id=379110810 instance=ExtResource("6_gqe5k")] +unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 0 max_chips_per_row = 100 @@ -350,7 +351,8 @@ layout_mode = 2 size_flags_vertical = 0 texture = SubResource("AtlasTexture_manhy") -[node name="StylizedNumberDisplay" parent="UIBase/UnitPanel/UnitHealth" unique_id=1442983008 instance=ExtResource("5_55shj")] +[node name="HealthNumber" parent="UIBase/UnitPanel/UnitHealth" unique_id=1442983008 instance=ExtResource("5_55shj")] +unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 0 sprite_sheet = SubResource("AtlasTexture_ox7qj") @@ -364,7 +366,8 @@ offset_top = 133.0 offset_right = 225.0 offset_bottom = 151.0 -[node name="ChipBar" parent="UIBase/UnitPanel/UnitSP" unique_id=374103132 instance=ExtResource("6_gqe5k")] +[node name="SPChipBar" parent="UIBase/UnitPanel/UnitSP" unique_id=374103132 instance=ExtResource("6_gqe5k")] +unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 0 max_chips_per_row = 100 @@ -376,7 +379,8 @@ layout_mode = 2 size_flags_vertical = 0 texture = SubResource("AtlasTexture_vj7wc") -[node name="StylizedNumberDisplay" parent="UIBase/UnitPanel/UnitSP" unique_id=442319509 instance=ExtResource("5_55shj")] +[node name="SPNumber" parent="UIBase/UnitPanel/UnitSP" unique_id=442319509 instance=ExtResource("5_55shj")] +unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 0 sprite_sheet = SubResource("AtlasTexture_ox7qj") @@ -390,7 +394,8 @@ offset_top = 160.0 offset_right = 225.0 offset_bottom = 178.0 -[node name="ChipBar" parent="UIBase/UnitPanel/UnitFS" unique_id=1380843979 instance=ExtResource("6_gqe5k")] +[node name="FSChipBar" parent="UIBase/UnitPanel/UnitFS" unique_id=1380843979 instance=ExtResource("6_gqe5k")] +unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 0 max_chips_per_row = 100 @@ -402,7 +407,8 @@ layout_mode = 2 size_flags_vertical = 0 texture = SubResource("AtlasTexture_r8i3r") -[node name="StylizedNumberDisplay" parent="UIBase/UnitPanel/UnitFS" unique_id=1558008542 instance=ExtResource("5_55shj")] +[node name="FSNumber" parent="UIBase/UnitPanel/UnitFS" unique_id=1558008542 instance=ExtResource("5_55shj")] +unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 0 sprite_sheet = SubResource("AtlasTexture_ox7qj") diff --git a/scripts/battle/combat_ui.gd b/scripts/battle/combat_ui.gd index fb70e06..d7cd607 100644 --- a/scripts/battle/combat_ui.gd +++ b/scripts/battle/combat_ui.gd @@ -3,9 +3,13 @@ class_name CombatUI extends CanvasLayer signal fight_confirmed(proposal: CombatProposal) signal fight_cancelled -@onready var unit_panel: PanelContainer = %UnitPanel -@onready var name_label: Label = %NameLabel -@onready var hp_bar: ProgressBar = %HPBar +@onready var unit_panel: Control = %UnitPanel +@onready var health_chip_bar: ChipBar = %HealthChipBar +@onready var health_number: StylizedNumberDisplay = %HealthNumber +@onready var sp_chip_bar: ChipBar = %SPChipBar +@onready var sp_number: StylizedNumberDisplay = %SPNumber +@onready var fs_chip_bar: ChipBar = %FSChipBar +@onready var fs_number: StylizedNumberDisplay = %FSNumber @onready var background_tint: ColorRect = %BackgroundTint @onready var proposal_panel: PanelContainer = %CombatProposalPanel @@ -59,8 +63,7 @@ func _on_unit_died(deployed: DeployedUnit) -> void: func _process(_delta: float) -> void: if _selected_unit and is_instance_valid(_selected_unit): - hp_bar.max_value = _selected_unit.current_stats.max_hp - hp_bar.value = _selected_unit.current_stats.current_hp + _refresh_unit_panel() func _unhandled_input(event: InputEvent) -> void: if proposal_panel.visible and event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_RIGHT: @@ -71,14 +74,24 @@ func _unhandled_input(event: InputEvent) -> void: func _on_unit_selected_changed(deployed: DeployedUnit, selected: bool) -> void: if selected: _selected_unit = deployed - name_label.text = deployed.unit.info.name - hp_bar.max_value = deployed.current_stats.max_hp - hp_bar.value = deployed.current_stats.current_hp + _refresh_unit_panel() unit_panel.visible = true else: _selected_unit = null unit_panel.visible = false +func _refresh_unit_panel() -> void: + var stats := _selected_unit.current_stats + health_chip_bar.max_value = stats.max_hp + health_chip_bar.value = stats.current_hp + health_number.value = stats.current_hp + sp_chip_bar.max_value = stats.max_sp + sp_chip_bar.value = stats.current_sp + sp_number.value = stats.current_sp + fs_chip_bar.max_value = stats.max_fs + fs_chip_bar.value = stats.current_fs + fs_number.value = stats.current_fs + func show_proposal(proposal: CombatProposal) -> void: _current_proposal = proposal _populate_tactic_select(atk_tactic_select, proposal.attacker)