@tool extends Control class_name CharacterCard signal select() @export var displayName: String = "Unknown Character" @export var avatar: Texture2D = null @export_multiline var description: String = "" @export var fields: Array[FieldStore.Entity] = [] @export var fieldValues: Array[float] = [] @export var clickToRebuild: bool = false @export var borderOpacity: float = 0 @onready var panel: PanelContainer = $%panel @onready var avatarTexture: TextureRect = $%avatarTexture @onready var nameLebel: Label = $%nameLabel @onready var descriptionLabel: Label = $%descriptionLabel @onready var fieldsBox: Control = $%fields @onready var animator: AnimationPlayer = $%animator var watcher: Watcher = Watcher.new(false) @onready var panelStyleBox: StyleBoxFlat = panel.get_theme_stylebox("panel").duplicate() func _ready(): panel.add_theme_stylebox_override("panel", panelStyleBox) watcher.changed.connect(rebuildInfo) gui_input.connect( func(event): if event is InputEventMouseButton: if !(event.pressed && event.button_index == MouseButton.MOUSE_BUTTON_LEFT): return if animator.is_playing(): return select.emit() ) rebuildInfo() func _process(_delta): watcher.setState(clickToRebuild) panelStyleBox.border_width_top = int(10 * borderOpacity) panelStyleBox.border_width_bottom = int(10 * borderOpacity) func rebuildInfo(): avatarTexture.texture = avatar nameLebel.text = displayName descriptionLabel.text = description for child in fieldsBox.get_children(): fieldsBox.remove_child(child) for index in len(fields): var field = fields[index] var value = fieldValues[index] var fieldShow = ComponentManager.getUIComponent("FieldShow").instantiate() as FieldShow fieldShow.field = field fieldShow.showAdvantage = true fieldShow.value = value fieldsBox.add_child(fieldShow)