158 lines
5.4 KiB
GDScript
158 lines
5.4 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
|
|
|
|
@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
|
|
|
|
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)
|
|
if data.has("character"):
|
|
var character_data=data["character"]
|
|
%character_name.text=character_data["name"]
|
|
var star_arr=%star_container.get_children()
|
|
var star_num:int=character_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"]:
|
|
var new_label=Label.new()
|
|
new_label.text=i["name"]+":"+str(i["value"])
|
|
%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"]:
|
|
var new_label=Label.new()
|
|
new_label.text=i["name"]+":"+str(i["value"])
|
|
%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)
|
|
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)
|
|
pass
|
|
func connect_button():
|
|
for i in button_group.size():
|
|
button_group[i].pressed.connect(selected.bind(i))
|
|
|
|
#当第几个皮肤卡片被点击时
|
|
func skin_card_click(skin_index:int):
|
|
|
|
|
|
|
|
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:
|
|
data=Global.get_character_data("test_character_01")
|
|
init_from_data()
|
|
connect_button()
|
|
|
|
|
|
func _on_back_button_pressed() -> void:
|
|
self.hide()
|
|
pass # Replace with function body.
|