198 lines
6.6 KiB
GDScript
198 lines
6.6 KiB
GDScript
extends Control
|
|
const ABILITY_BUTTON = preload("res://scene/ability_button.tscn")
|
|
const ATTRIBUTE = preload("res://scene/attribute.tscn")
|
|
const SELECTED = preload("res://res/ui/ui_005_basic_message/selected.tres")
|
|
const BASIC_MES_SKIN_CARD = preload("res://scene/basic_mes_skin_card.tscn")
|
|
const START_CONFIG_MES = preload("res://scene/start_config_mes.tscn")
|
|
var data:Dictionary
|
|
##当前是在游戏外编辑还是在游戏内编辑
|
|
@export var is_in_game:bool=false
|
|
@onready var button_group:Array[Button]=[$VBoxContainer/TextureRect/HBoxContainer/Button, $VBoxContainer/TextureRect/HBoxContainer/Button2, $VBoxContainer/TextureRect/HBoxContainer/Button3, $VBoxContainer/TextureRect/HBoxContainer/Button4, $VBoxContainer/TextureRect/HBoxContainer/Button5, $VBoxContainer/TextureRect/HBoxContainer/Button6]
|
|
@onready var now_selected_button:Button=$VBoxContainer/TextureRect/HBoxContainer/Button
|
|
#面板关闭信号
|
|
signal close
|
|
var now_selected_mes:StartConfigMes
|
|
func init_from_data():
|
|
|
|
for i in %special_container.get_children():
|
|
i.queue_free()
|
|
for i in %ability_container.get_children():
|
|
i.queue_free()
|
|
%character.texture=Global.get_texture(CharacterTool.get_skin_now_use_data(data)["character"])
|
|
var basic_data=data["basic_mes"]
|
|
match int(basic_data["type"]):
|
|
0:
|
|
%category.text="历史"
|
|
1:
|
|
%category.text="奇幻"
|
|
2:
|
|
%category.text="现实"
|
|
3:
|
|
%category.text="末世"
|
|
%place.text=basic_data["place"]
|
|
#缺少性别
|
|
%race.text=basic_data["race"]
|
|
%birthday.text=basic_data["birthday"]
|
|
%introduction.text=basic_data["introduction"]
|
|
|
|
var basic_attribute:Dictionary=data["basic_attribute"]
|
|
var fight_attribute:Dictionary={}
|
|
if data.has("fight_attribute"):
|
|
fight_attribute=data["fight_attribute"]
|
|
for i in %basic_attribute.get_children():
|
|
i.queue_free()
|
|
for i in %fight_attribute.get_children():
|
|
i.queue_free()
|
|
for i in basic_attribute.keys():
|
|
var new_attribute=ATTRIBUTE.instantiate()
|
|
new_attribute.data={
|
|
"name":CharacterTool.get_name_by_attribute_key(i),
|
|
"value":basic_attribute[i]
|
|
}
|
|
%basic_attribute.add_child(new_attribute)
|
|
for i in fight_attribute.keys():
|
|
var new_attribute=ATTRIBUTE.instantiate()
|
|
new_attribute.data={
|
|
"name":CharacterTool.get_name_by_attribute_key(i),
|
|
"value":basic_attribute[i]
|
|
}
|
|
%fight_attribute.add_child(new_attribute)
|
|
pass
|
|
if data.has("special"):
|
|
var special_data=data["special"]
|
|
for i in special_data:
|
|
var new_button=ABILITY_BUTTON.instantiate()
|
|
new_button.show_mes=i["introduction"]
|
|
new_button.text=i["name"]
|
|
%special_container.add_child(new_button)
|
|
if data.has("ability"):
|
|
var ability_data=data["ability"]
|
|
for i in ability_data:
|
|
var new_button=ABILITY_BUTTON.instantiate()
|
|
new_button.show_mes=i["introduction"]
|
|
new_button.text=i["name"]
|
|
%ability_container.add_child(new_button)
|
|
%character_name.text=data["name"]
|
|
var star_arr=%star_container.get_children()
|
|
var star_num:int=data["star"]
|
|
for i in star_arr.size():
|
|
if i<star_num:
|
|
star_arr[i].show()
|
|
else:
|
|
star_arr[i].hide()
|
|
#关系
|
|
if data.has("favor"):
|
|
for i in %favor.get_children():
|
|
i.queue_free()
|
|
for i in data["favor"].keys():
|
|
var new_label=Label.new()
|
|
new_label.text=i+":"+str(data["favor"][i])
|
|
%favor.add_child(new_label)
|
|
new_label.add_theme_font_size_override("font_size",26)
|
|
#声望
|
|
if data.has("reputation"):
|
|
for i in %reputation.get_children():
|
|
i.queue_free()
|
|
for i in data["reputation"].keys():
|
|
var new_label=Label.new()
|
|
new_label.text=i+":"+str(data["reputation"][i])
|
|
%reputation.add_child(new_label)
|
|
new_label.add_theme_font_size_override("font_size",26)
|
|
for i in %start_config_mes_add_pos.get_children():
|
|
i.queue_free()
|
|
##加载开局
|
|
var start_config_arr:Array=data["start"]
|
|
var start_now_use:int=data["start_now_use"]
|
|
var unclocked_start:Array=data["unclocked_start"]
|
|
for i in start_config_arr.size():
|
|
var new_start:StartConfigMes=START_CONFIG_MES.instantiate()
|
|
%start_config_mes_add_pos.add_child(new_start)
|
|
new_start.index=i
|
|
if i==start_now_use:
|
|
new_start.state=1
|
|
now_selected_mes=new_start
|
|
elif float(i) in unclocked_start:
|
|
new_start.state=0
|
|
else:
|
|
new_start.state=-1
|
|
new_start.set_data(start_config_arr[i])
|
|
new_start.click.connect(start_config_mes_click)
|
|
for i in %skin_card_add_pos.get_children():
|
|
i.queue_free()
|
|
var skin_data_arr:Array=data["skin"]
|
|
var skin_now_use:int=data["skin_now_use"]
|
|
var unlocked_skin=data["unlocked_skin"]
|
|
for i in skin_data_arr.size():
|
|
var new_skin_card:BasicMesSkinCard=BASIC_MES_SKIN_CARD.instantiate()
|
|
%skin_card_add_pos.add_child(new_skin_card)
|
|
new_skin_card.index=i
|
|
if i==skin_now_use:
|
|
new_skin_card.state=1
|
|
now_selected_skin_card=new_skin_card
|
|
elif float(i) in unlocked_skin:
|
|
new_skin_card.state=0
|
|
else:
|
|
new_skin_card.state=-1
|
|
new_skin_card.set_data(skin_data_arr[i])
|
|
new_skin_card.click.connect(skin_card_click)
|
|
|
|
pass
|
|
|
|
func start_config_mes_click(mes:StartConfigMes,ind:int):
|
|
now_selected_mes.state=0
|
|
mes.state=1
|
|
now_selected_mes=mes
|
|
#添加开局选择修饰
|
|
Global.add_character_embellich_data(data["id"],"start",ind)
|
|
data=Global.get_character_data(data["id"])
|
|
init_from_data()
|
|
pass
|
|
var now_selected_skin_card:BasicMesSkinCard
|
|
func connect_button():
|
|
for i in button_group.size():
|
|
button_group[i].pressed.connect(selected.bind(i))
|
|
|
|
#当第几个皮肤卡片被点击时
|
|
func skin_card_click(skin:BasicMesSkinCard,skin_index:int):
|
|
#添加皮肤修饰器
|
|
Global.add_character_embellich_data(data["id"],"skin",skin_index)
|
|
%character.texture=Global.get_texture(data["skin"][skin_index]["character"])
|
|
now_selected_skin_card.state=0
|
|
skin.state=1
|
|
now_selected_skin_card=skin
|
|
|
|
|
|
pass
|
|
|
|
func selected(ind:int):
|
|
if now_selected_button!=null:
|
|
var new_st=StyleBoxEmpty.new()
|
|
now_selected_button.add_theme_stylebox_override("normal",new_st)
|
|
now_selected_button.add_theme_stylebox_override("pressed",new_st)
|
|
now_selected_button.add_theme_stylebox_override("hover",new_st)
|
|
now_selected_button.add_theme_stylebox_override("hover_pressed",new_st)
|
|
now_selected_button=button_group[ind]
|
|
now_selected_button.add_theme_stylebox_override("normal",SELECTED)
|
|
now_selected_button.add_theme_stylebox_override("pressed",SELECTED)
|
|
now_selected_button.add_theme_stylebox_override("hover",SELECTED)
|
|
now_selected_button.add_theme_stylebox_override("hover_pressed",SELECTED)
|
|
%TabContainer.set_current_tab(ind)
|
|
pass
|
|
|
|
func _ready() -> void:
|
|
if is_in_game:
|
|
$VBoxContainer/TextureRect/HBoxContainer/Button6.hide()
|
|
else:
|
|
$VBoxContainer/TextureRect/HBoxContainer/Button6.show()
|
|
|
|
pass
|
|
data=Global.get_character_data("test_character_01")
|
|
init_from_data()
|
|
connect_button()
|
|
|
|
|
|
func _on_back_button_pressed() -> void:
|
|
self.hide()
|
|
close.emit()
|
|
pass # Replace with function body.
|