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") const BAG_SIDE_CARD = preload("res://scene/bag_side_card.tscn") const SKILL_CONFIG_CARD_DOWN = preload("res://scene/skill_config_card_down.tscn") const SKILL_CONFIG_CARD_UP = preload("res://scene/skill_config_card_up.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 var now_character_use_equip_page:int=0 @onready var equipment_group=[%ornaments_equipment1, %ornaments_equipment2, %ornaments_equipment3,%ornaments_equipment4,%hand_equipment1,%hand_equipment2, %head_equipment, %body_equipment] #面板关闭信号 signal close var now_selected_mes:StartConfigMes func init_from_data(): for i in equipment_group.size(): equipment_group[i].index=i for i in %special_container.get_children(): i.queue_free() for i in %ability_container.get_children(): i.queue_free() %character.texture=Database.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 is_in_game: fight_attribute=CharacterTool.cacul_fight_attribute(data) 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":fight_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 void: ##向背包中添加物品 #Global.add_item_to_bag(Global.get_item_data("item_01")) #Global.add_item_to_bag(Global.get_item_data("item_02")) #Global.add_item_to_bag(Global.get_item_data("item_03")) #Global.add_item_to_bag(Global.get_item_data("item_04")) #Global.add_item_to_bag(Global.get_item_data("item_05")) #Global.add_item_to_bag(Global.get_item_data("item_01")) #Global.add_item_to_bag(Global.get_item_data("item_02")) #Global.add_item_to_bag(Global.get_item_data("item_03")) #Global.add_item_to_bag(Global.get_item_data("item_04")) #Global.add_item_to_bag(Global.get_item_data("item_05")) #Global.add_item_to_bag(Global.get_item_data("item_01")) #Global.add_item_to_bag(Global.get_item_data("item_02")) #Global.add_item_to_bag(Global.get_item_data("item_03")) #Global.add_item_to_bag(Global.get_item_data("item_04")) #Global.add_item_to_bag(Global.get_item_data("item_05")) #Global.add_item_to_bag(Global.get_item_data("item_01")) #Global.add_item_to_bag(Global.get_item_data("item_02")) #Global.add_item_to_bag(Global.get_item_data("item_03")) #Global.add_item_to_bag(Global.get_item_data("item_04")) #Global.add_item_to_bag(Global.get_item_data("item_05")) #Global.add_item_to_bag(Global.get_item_data("item_01")) #Global.add_item_to_bag(Global.get_item_data("item_02")) #Global.add_item_to_bag(Global.get_item_data("item_03")) #Global.add_item_to_bag(Global.get_item_data("item_04")) #Global.add_item_to_bag(Global.get_item_data("item_05")) if is_in_game: $VBoxContainer/TextureRect/HBoxContainer/Button6.hide() $VBoxContainer/TextureRect/HBoxContainer/Button4.show() $VBoxContainer/TextureRect/HBoxContainer/Button5.show() else: $VBoxContainer/TextureRect/HBoxContainer/Button6.show() $VBoxContainer/TextureRect/HBoxContainer/Button4.hide() $VBoxContainer/TextureRect/HBoxContainer/Button5.hide() pass for i in equipment_group: i.fresh.connect(fresh) Global.set_now_character("test_character_01") data=Global.get_now_character_data() init_from_data() connect_button() func _on_back_button_pressed() -> void: self.hide() close.emit() pass # Replace with function body. #切换装备页按钮按下时 func _on_bag_tab_button_pressed(n: int) -> void: Global.change_character_equip_now_use(n-1) data=Global.get_now_character_data() init_from_data() pass # Replace with function body. func fresh(): data=Global.get_now_character_data() init_from_data() pass