Needs fine-tuning polish but looks good.

This commit is contained in:
gamer147
2026-04-10 14:10:25 -04:00
parent 2d74e15006
commit f332771153
2 changed files with 12 additions and 10 deletions

View File

@@ -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")]

View File

@@ -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