You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB
GDScript

extends Control
@onready var mp_scene: PackedScene = preload("res://scene/ui/item/mp_item.tscn")
@onready var hp_bar: TextureProgressBar = $HpBar as TextureProgressBar
@onready var mp_sub_bar: TextureProgressBar = $MpSubBar as TextureProgressBar
@onready var mp_list: HBoxContainer = $MpList as HBoxContainer
9 months ago
#debug info
@onready var debug_info_scene: PackedScene = preload("res://scene/ui/item/debug_info_item_sub.tscn")
@onready var debug_info_list: VBoxContainer = $DebugInfoList as VBoxContainer
9 months ago
var debug_info_dict: Dictionary[String, DebugInfoItemSub] = {}
9 months ago
func _process(_delta: float) -> void:
var player: Character = Global.character_mgr.get_player()
9 months ago
if not player:
return
refresh_debug_info("break_level", str(player.get_status("break_level")))
refresh_debug_info("stance", str(player.get_status("stance")))
func refresh_debug_info(label_value: String, value: String) -> void:
if not debug_info_dict.has(label_value):
var debug_info: DebugInfoItemSub = debug_info_scene.instantiate() as DebugInfoItemSub
debug_info.init(label_value)
debug_info_list.add_child(debug_info)
debug_info_dict[label_value] = debug_info
debug_info_dict[label_value].set_value(value)
2 years ago
func on_hp_max_changed(value: float):
hp_bar.max_value = value
2 years ago
func on_hp_changed(value: float):
hp_bar.value = value
2 years ago
func on_mp_sub_max_changed(value: float):
mp_sub_bar.max_value = value
2 years ago
func on_mp_sub_changed(value: float):
mp_sub_bar.value = value
2 years ago
func on_mp_max_changed(value: int):
for child in mp_list.get_children():
child.queue_free()
for i in range(value):
var mp_item: MpItemSub = mp_scene.instantiate() as MpItemSub
mp_list.add_child(mp_item)
2 years ago
func on_mp_changed(value: int):
for i in range(mp_list.get_child_count()):
var mp_item: MpItemSub = mp_list.get_child(i) as MpItemSub
mp_item.set_active(i<value)