challenge-editor/scene/character_bag.gd
2024-09-26 17:54:02 +08:00

65 lines
1.8 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()
select(-1,-1)
pass
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)
pass
pass
func _on_back_btn_pressed() -> void:
get_parent().change_open(false)
pass # Replace with function body.
func refresh():
data=Global.get_all_character()
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.