challenge-editor/scene/character_bag.gd
2024-10-04 18:08:33 +08:00

75 lines
2.1 KiB
GDScript

extends Control
const CHARACTER_BAG_CARD = preload("res://scene/character_bag_card.tscn")
const CHARACTER_BAG_SELECTED:StyleBoxTexture = preload("res://res/ui/ui_004_character_bag/character_bag_selected.tres")
@onready var btn_panel_group:Array[PanelContainer]=[$NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer, $NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer2, $NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer3, $NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer4, $NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer5]
var data:Dictionary
var now_select_index:int=-1:
set(val):
if now_select_index!=val:
select(now_select_index,val)
now_select_index=val
func _ready() -> void:
refresh()
func select(before:int,ind:int):
btn_panel_group[before+1].add_theme_stylebox_override("panel",StyleBoxEmpty.new())
btn_panel_group[ind+1].add_theme_stylebox_override("panel",CHARACTER_BAG_SELECTED)
for i in %card_add_pos.get_children():
i.queue_free()
for i in data.values():
if CharacterTool.get_character_type(i)==ind ||ind==-1:
var new_card=CHARACTER_BAG_CARD.instantiate()
new_card.data=i
%card_add_pos.add_child(new_card)
new_card.self_click.connect(character_card_click)
pass
func character_card_click(data:Dictionary):
%basic_mes.data=data
%basic_mes.init_from_data()
%animation.play("open_mes")
pass
func _on_back_btn_pressed() -> void:
get_parent().change_open(false)
pass # Replace with function body.
func refresh():
data=Database.get_all_character()
select(-1,-1)
pass
func _on_all_pressed() -> void:
now_select_index=-1
pass # Replace with function body.
func _on_history_pressed() -> void:
now_select_index=0
pass # Replace with function body.
func _on_fantasy_pressed() -> void:
now_select_index=1
pass # Replace with function body.
func _on_reality_pressed() -> void:
now_select_index=2
pass # Replace with function body.
func _on_eschatological_pressed() -> void:
now_select_index=3
pass # Replace with function body.
func _on_basic_mes_close() -> void:
refresh()
pass # Replace with function body.