From f33277115375d7051dd08f467cf7623b200974a3 Mon Sep 17 00:00:00 2001 From: gamer147 Date: Fri, 10 Apr 2026 14:10:25 -0400 Subject: [PATCH] Needs fine-tuning polish but looks good. --- prefabs/combat_ui.tscn | 8 ++++---- scripts/ui/chip_bar.gd | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/prefabs/combat_ui.tscn b/prefabs/combat_ui.tscn index 71e73d0..3c08082 100644 --- a/prefabs/combat_ui.tscn +++ b/prefabs/combat_ui.tscn @@ -334,9 +334,9 @@ value = 12 [node name="UnitHealth" type="HBoxContainer" parent="UIBase/UnitPanel" unique_id=53239936] layout_mode = 0 -offset_left = -102.0 +offset_left = -127.0 offset_top = 103.0 -offset_right = 225.0 +offset_right = 253.0 offset_bottom = 131.0 alignment = 2 @@ -366,7 +366,7 @@ number_sprite_height = 15 layout_mode = 0 offset_left = 1.0 offset_top = 133.0 -offset_right = 225.0 +offset_right = 249.0 offset_bottom = 151.0 [node name="SPChipBar" parent="UIBase/UnitPanel/UnitSP" unique_id=374103132 instance=ExtResource("6_gqe5k")] @@ -395,7 +395,7 @@ number_sprite_height = 15 layout_mode = 0 offset_left = 1.0 offset_top = 160.0 -offset_right = 225.0 +offset_right = 249.0 offset_bottom = 178.0 [node name="FSChipBar" parent="UIBase/UnitPanel/UnitFS" unique_id=1380843979 instance=ExtResource("6_gqe5k")] diff --git a/scripts/ui/chip_bar.gd b/scripts/ui/chip_bar.gd index f1deee7..ba13b57 100644 --- a/scripts/ui/chip_bar.gd +++ b/scripts/ui/chip_bar.gd @@ -34,21 +34,23 @@ func _refresh() -> void: for child in _container.get_children(): child.queue_free() - if filled_chip_texture and max_chips_per_row > 0: - var chip_width := filled_chip_texture.get_width() - _container.custom_minimum_size.x = chip_width * max_chips_per_row - - if max_chips_per_row <= 0: + if max_chips_per_row <= 0 or not filled_chip_texture: return + var chip_width := filled_chip_texture.get_width() + var effective_per_row := max_chips_per_row + if chip_width > 0 and _container.size.x > 0: + effective_per_row = mini(effective_per_row, int(_container.size.x / chip_width)) + var filled_remaining := value var chips_laid_out := 0 while chips_laid_out < max_value: var row := HBoxContainer.new() row.alignment = BoxContainer.ALIGNMENT_END + row.size_flags_horizontal = Control.SIZE_EXPAND_FILL row.add_theme_constant_override("separation", 0) - var chips_in_row := mini(max_chips_per_row, max_value - chips_laid_out) + var chips_in_row := mini(effective_per_row, max_value - chips_laid_out) var filled_in_row := mini(filled_remaining, chips_in_row) var empty_in_row := chips_in_row - filled_in_row