forked from datawhale/whale-town
创建新工程
This commit is contained in:
58
quick_customization_test.gd
Normal file
58
quick_customization_test.gd
Normal file
@@ -0,0 +1,58 @@
|
||||
extends Node
|
||||
## 快速角色自定义测试
|
||||
## 直接测试自定义界面功能
|
||||
|
||||
func _ready():
|
||||
print("=== 快速角色自定义测试 ===")
|
||||
print("按空格键打开角色自定义界面")
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.keycode == KEY_SPACE:
|
||||
_open_customization()
|
||||
|
||||
func _open_customization():
|
||||
print("打开角色自定义界面...")
|
||||
|
||||
# 创建自定义界面
|
||||
var CharacterCustomizationClass = preload("res://scripts/CharacterCustomization.gd")
|
||||
var customization_ui = CharacterCustomizationClass.new()
|
||||
|
||||
# 添加到场景树
|
||||
get_tree().root.add_child(customization_ui)
|
||||
|
||||
# 创建测试数据
|
||||
var test_data = CharacterData.create("测试角色", "test")
|
||||
|
||||
# 设置默认外观
|
||||
var appearance = {
|
||||
"body_color": "#4A90E2",
|
||||
"head_color": "#F5E6D3",
|
||||
"hair_color": "#8B4513",
|
||||
"clothing_color": "#2ECC71"
|
||||
}
|
||||
CharacterData.set_appearance(test_data, appearance)
|
||||
|
||||
# 设置默认个性
|
||||
test_data[CharacterData.FIELD_PERSONALITY] = {
|
||||
"traits": ["friendly", "creative"],
|
||||
"bio": "这是一个测试角色",
|
||||
"favorite_activity": "exploring"
|
||||
}
|
||||
|
||||
# 加载数据
|
||||
customization_ui.load_character_data(test_data)
|
||||
|
||||
# 连接信号
|
||||
customization_ui.customization_saved.connect(_on_saved)
|
||||
customization_ui.customization_cancelled.connect(_on_cancelled)
|
||||
|
||||
print("✓ 自定义界面已打开")
|
||||
|
||||
func _on_saved(data: Dictionary):
|
||||
print("✓ 自定义已保存")
|
||||
print("外观数据:", data.get(CharacterData.FIELD_APPEARANCE, {}))
|
||||
print("个性数据:", data.get(CharacterData.FIELD_PERSONALITY, {}))
|
||||
|
||||
func _on_cancelled():
|
||||
print("✓ 自定义已取消")
|
||||
Reference in New Issue
Block a user