57 lines
2.1 KiB
GDScript3
57 lines
2.1 KiB
GDScript3
|
extends PanelContainer
|
||
|
const PC := preload('res://PC.tscn')
|
||
|
var PCs = []
|
||
|
|
||
|
var dummy_data := {
|
||
|
'characters': [
|
||
|
{'character_id': 0},
|
||
|
{'character_id': 1},
|
||
|
{'character_id': 2},
|
||
|
{'character_id': 3},
|
||
|
],
|
||
|
'game_time_frames': randi() % 0x01000000,
|
||
|
'character_names': ['Butz', 'Lenna', 'Galuf', 'Faris', 'Krile'],
|
||
|
'config': {'menu_color_r': randi()%32, 'menu_color_g': randi()%32, 'menu_color_b': randi()%32}
|
||
|
}
|
||
|
|
||
|
func _init_dummy():
|
||
|
for i in 4:
|
||
|
var c = dummy_data.characters[i]
|
||
|
c.level = 1 + (randi()%99)
|
||
|
c.current_job_id = randi()%22
|
||
|
c.hp_max = (50*c.level) + (randi()%(100 + 50*c.level))
|
||
|
c.hp_current = 1 + (randi()%c.hp_max)
|
||
|
dummy_data.characters.shuffle()
|
||
|
|
||
|
func set_data(data: Dictionary):
|
||
|
self.material.set_shader_param('MenuBGColour', Color(data.config.menu_color_r/31.0, data.config.menu_color_g/31.0, data.config.menu_color_b/31.0))
|
||
|
for i in 4:
|
||
|
var char_id: int = data.characters[i].character_id
|
||
|
var job_id: int = data.characters[i].current_job_id
|
||
|
var sprite_id := (char_id * 22) + job_id
|
||
|
PCs[i].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[sprite_id])
|
||
|
PCs[i].texture = SpriteLoader.strip_textures[sprite_id]
|
||
|
$HBoxContainer/right_labels/HBoxContainer/lbl_level_num.text = '%d' % data.characters[0].level
|
||
|
var game_seconds = data.game_time_frames / 60
|
||
|
var game_minutes = game_seconds / 60
|
||
|
var game_hours = game_minutes / 60
|
||
|
$HBoxContainer/left_labels/lbl_gametime.text = '%d:%02d' % [game_hours, game_minutes % 60]
|
||
|
$HBoxContainer/left_labels/lbl_name.text = data.character_names[data.characters[0].character_id]
|
||
|
$HBoxContainer/right_labels/lbl_hp.text = '%d/%4d' % [data.characters[0].hp_current, data.characters[0].hp_max]
|
||
|
|
||
|
# Called when the node enters the scene tree for the first time.
|
||
|
func _ready() -> void:
|
||
|
_init_dummy()
|
||
|
self.material = self.material.duplicate()
|
||
|
for i in 4:
|
||
|
var pc = PC.instance()
|
||
|
pc.set_position(Vector2(i*24, 8))
|
||
|
$HBoxContainer/PCs.add_child(pc)
|
||
|
PCs.append(pc)
|
||
|
set_data(dummy_data)
|
||
|
|
||
|
|
||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
#func _process(delta: float) -> void:
|
||
|
# pass
|