ChocolateBird/widgets/PartyMenuCharacter.gd

43 lines
1.9 KiB
GDScript3
Raw Normal View History

2023-08-04 01:05:19 +09:30
extends ReferenceRect
onready var rect_frontrow := Rect2($ref0/ref_frontrow.rect_position, $ref0/ref_frontrow.rect_size)
onready var rect_backrow := Rect2($ref0/ref_backrow.rect_position, $ref0/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
$ref0/lbl_name.text = data.character_names_decoded[character]
$ref0/lbl_lv_cur.text = '%d' % c.level
$ref1/lbl_job.text = StringLoader.tables.job_names[job]
$ref1/lbl_abp_lv_cur.text = '%d-' % c.current_job_level
$ref1/lbl_abp_progress.text = '%d/' % c.current_job_abp
$ref1/lbl_abp_next.text = '%d' % c.current_job_abp # Revisit
$ref1/lbl_hp_cur.text = '%d/' % c.hp_current
$ref1/lbl_hp_max.text = '%d' % c.hp_max
$ref1/lbl_mp_cur.text = '%d/' % c.mp_current
$ref1/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
$ref0/PC.position = row_rects[c.is_back_row].position
$ref0/PC.material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[cj_idx])
$ref0/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)