everything_has_a_price_jam/gui/currency_inspector_panel.gd
2026-09-26 23:54:33 -06:00

42 lines
1.1 KiB
GDScript

extends Control
var currency: Currency = null
func _ready() -> void:
UserContext.currency_inspect.connect(currency_inspect)
UserContext.member_inspect.connect(member_inspect)
UserContext.modal_command_change.connect(modal_command_change)
update()
func modal_command_change(_c: Command):
visible = false
func member_inspect(_m: CurrencyMemberSprite):
visible = false
func currency_inspect(c: Currency):
currency = c
update()
func update():
if currency == null:
visible = false
return
visible = true
%InspectedCurrency.text = currency.name
%CurrencyDescription.text = currency.description
for child in %ProductionsList.get_children():
child.queue_free()
%word.visible = currency.production.size() > 0
for production in currency.production:
var display := preload("res://gui/production_display.tscn").instantiate()
display.production = production
%ProductionsList.add_child(display)
if currency.thumbnail != null:
%CurrrencyImage.visible = true
%CurrrencyImage.texture = currency.thumbnail
else:
%CurrrencyImage.visible = false
func _on_close_button_pressed() -> void:
visible = false