@tool extends PanelContainer class_name Card const CARD_STAT_SCENE : PackedScene = preload("res://gui/game/card/card_stat.tscn") const CARD_SECTION_SCENE : PackedScene = preload("res://gui/game/card/card_section.tscn") @export var down_arrow : bool = false @export var info : CardInfo = CardInfo.new("Default Card Name") @export_tool_button("Update", "Callable") var update_action = update @export_tool_button("Reset Size", "Callable") var reset_size_action = func(): reset_size() # func _ready(): # update() func update(): pass %Title.text = info.title %Subtitle.visible = info.subtitle != "" %Subtitle.text = info.subtitle %ImportantStat.visible = info.important_stat_text != "" or info.important_stat_icon != null %ImportantStatIcon.texture = info.important_stat_icon %ImportantStatText.text = info.important_stat_text %ArrowDown.visible = down_arrow update_card_stats() update_card_sections() await get_tree().create_timer(0.01).timeout reset_size() func update_card_stats(): for stat in %StatsContainer.get_children(): stat.queue_free() %StatsContainer.visible = len(info.stats) > 0 %StatsContainer.columns = max(1,len(info.stats)) for stat_info in info.stats: if stat_info: var new_stat : CardStat = CARD_STAT_SCENE.instantiate() as CardStat new_stat.info = stat_info %StatsContainer.add_child(new_stat) func update_card_sections(): for stat in %SectionContainer.get_children(): stat.queue_free() %SectionContainer.visible = len(info.sections) > 0 for sections_info in info.sections: if sections_info: var new_section : CardSection = CARD_SECTION_SCENE.instantiate() as CardSection new_section.info = sections_info %SectionContainer.add_child(new_section)