mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
feat: 添加角色选择系统及相关功能
新增角色卡片组件和角色选择逻辑 实现角色卡片动画效果和交互功能 添加初始角色数据配置 修改启动面板以支持角色选择 更新主题样式和UI布局
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
@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)
|
||||
Reference in New Issue
Block a user