ChocolateBird/widgets/PartyMenuCharacter.gd

43 lines
2.0 KiB
GDScript3
Raw Permalink Normal View History

2023-08-04 01:05:19 +09:30
extends ReferenceRect
2023-09-21 15:26:10 +09:30
onready var rect_frontrow := Rect2($'%ref_frontrow'.rect_position, $'%ref_frontrow'.rect_size)
onready var rect_backrow := Rect2($'%ref_backrow'.rect_position, $'%ref_backrow'.rect_size)
onready var row_rects := [rect_frontrow, rect_backrow]
onready var ls = [$ref_commands/l1, $ref_commands/l2, $ref_commands/l3, $ref_commands/l4]
onready var ts = [$ref_commands/t1, $ref_commands/t2, $ref_commands/t3, $ref_commands/t4]
var t1s = [] # Ability icon shadows
func update_labels(data: Dictionary, i: int):
var c = data.characters[i]
var character = c.character_id
var job = c.current_job_id
var cj_idx = character*22 + job
2023-09-21 15:26:10 +09:30
$'%lbl_name'.text = data.character_names_decoded[character]
$'%lbl_lv_cur'.text = '%d' % c.level
$'%lbl_job'.text = StringLoader.tables.job_names[job]
$'%lbl_abp_lv_cur'.text = '%d-' % c.current_job_level
$'%lbl_abp_progress'.text = '' if job == 21 else ('%d/' % c.current_job_abp)
$'%lbl_abp_next'.text = '' if job == 21 else ('%d' % RomLoader.snes_data.job_levels[job][c.current_job_level].ABP)
$'%lbl_hp_cur'.text = '%d/' % c.hp_current
$'%lbl_hp_max'.text = '%d' % c.hp_max
$'%lbl_mp_cur'.text = '%d/' % c.mp_current
$'%lbl_mp_max'.text = '%d' % c.mp_max
for i in 4:
ls[i].text = StringLoader.get_ability_name(c.equipped_abilities[i])
ts[i].texture = ThemeManager.get_ability_icon(c.equipped_abilities[i])
t1s[i].texture = ts[i].texture
2023-08-04 01:05:19 +09:30
# Draw character battle sprite in either ref_frontrow or ref_backrow
2023-09-21 15:26:10 +09:30
$'%PC'.position = row_rects[c.is_back_row].position
$'%PC'.material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[cj_idx])
$'%PC'.texture = SpriteLoader.strip_textures[cj_idx]
# Think about status icons
2023-08-04 01:05:19 +09:30
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
for t in ts:
t1s.append(t.duplicate(0))
t1s[-1].rect_position += Vector2(1, 1)
t1s[-1].modulate = Color(0, 0, 0, 0.5)
$ref_commands.add_child(t1s[-1])
$ref_commands.move_child(t1s[-1], 0)