Add currency panel

This commit is contained in:
2026-04-24 00:55:00 +02:00
parent 4e6d7e41ed
commit b8a5e153c1
5 changed files with 161 additions and 89 deletions

View File

@@ -0,0 +1,35 @@
## Dynamically displays all currencies from the LevelGameState catalogue as CurrencyTile widgets.
class_name CurrencyPanel
extends PanelContainer
const CURRENCY_TILE_SCENE: PackedScene = preload("res://currency_tile.tscn")
@onready var _tiles_container: VBoxContainer = $CurrencyTiles
var _game_state: LevelGameState
func _ready() -> void:
_game_state = find_parent("LevelGameState")
if _game_state == null:
push_error("CurrencyPanel: No LevelGameState found in parent hierarchy")
return
_build_currency_tiles()
_game_state.ready.connect(_on_game_state_ready)
func _build_currency_tiles() -> void:
for child in _tiles_container.get_children():
child.queue_free()
if _game_state.currency_catalogue == null:
return
for currency in _game_state.currency_catalogue.currencies:
if currency == null:
continue
var tile: CurrencyTile = CURRENCY_TILE_SCENE.instantiate()
tile.currency = currency
tile.game_state = _game_state
_tiles_container.add_child(tile)
func _on_game_state_ready() -> void:
pass

View File

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