Needs fine-tuning polish but looks good.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user