@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 small_mode : bool = false @export var down_arrow : bool = false @export var info : CardInfo = CardInfo.new("Default Card Name") @export_tool_button("Update", "Callable") var update_action = update func _ready(): update() func update(): %CardTitle.text = info.title %CardUpperPart.self_modulate = info.bg_color %CardTypeIcon.texture = info.type_icon %EntityTexture.texture = info.texture %ImportantStatIcon.texture = info.important_stat_icon %ImportantStatText.text = info.important_stat_text %ArrowDown.visible = down_arrow self_modulate = Color.TRANSPARENT if small_mode else Color.WHITE %CardUpperPart.self_modulate.a = 0.7 if small_mode else 1.0 update_card_stats() update_card_sections() func update_card_stats(): for stat in %CardStatsContainer.get_children(): stat.queue_free() for stat_info in info.stats: if stat_info: var new_stat : CardStat = CARD_STAT_SCENE.instantiate() as CardStat new_stat.info = stat_info %CardStatsContainer.add_child(new_stat) %CardStats.visible = len(info.stats) != 0 && small_mode == false func update_card_sections(): for stat in %CardSectionsContainer.get_children(): stat.queue_free() for sections_info in info.sections: if sections_info: var new_section : CardSection = CARD_SECTION_SCENE.instantiate() as CardSection new_section.info = sections_info %CardSectionsContainer.add_child(new_section) %CardSections.visible = len(%CardSectionsContainer.get_children()) != 0 && small_mode == false