1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00
Files
Dog-Lynx-And-HCN/scripts/Structs/Character.gd
T
fallingshrimp 4d1f68cac1 feat(角色卡片): 添加新角色卡片资源并优化显示逻辑
添加猞猁、牧羊犬和氰化氢的角色卡片资源
优化卡片选中状态的动画显示逻辑
调整卡片样式和主题配置
移除冗余的panel节点引用
2026-05-04 20:32:07 +08:00

54 lines
1.7 KiB
GDScript

@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 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 = get_theme_stylebox("panel").duplicate()
func _ready():
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)