2023-08-02 22:11:35 +09:30
|
|
|
extends Control
|
2023-07-28 00:17:03 +09:30
|
|
|
|
2024-07-08 16:11:22 +09:30
|
|
|
var PC := preload('res://PC.gd')
|
|
|
|
var PC_scene := preload('res://PC.tscn')
|
|
|
|
var PCs := []
|
|
|
|
var num_animations: int = len(PC.Battle_Anim)
|
|
|
|
|
|
|
|
func initialize() -> void:
|
|
|
|
# Clean up any existing
|
|
|
|
for scn in PCs:
|
|
|
|
remove_child(scn)
|
|
|
|
PCs = []
|
|
|
|
|
|
|
|
# Make new sprites
|
2023-07-28 00:17:03 +09:30
|
|
|
var strips = len(SpriteLoader.strip_textures) # * 4 / 5
|
|
|
|
#var strip_divide = strips * 2 / 5
|
|
|
|
var strip_divide = strips * 1 / 5
|
2024-07-08 16:11:22 +09:30
|
|
|
var anim_id = $btn_anim_choice.get_selected_id()
|
2023-07-28 00:17:03 +09:30
|
|
|
for i in strips:
|
2024-07-08 16:11:22 +09:30
|
|
|
PCs.append(PC_scene.instance())
|
2023-07-28 00:17:03 +09:30
|
|
|
#PCs[-1].set_position(Vector2((i%strip_divide)*16, (i/strip_divide)*24*11))
|
2023-08-02 22:11:35 +09:30
|
|
|
PCs[-1].set_position(Vector2((i%strip_divide)*17, (i/strip_divide)*32))
|
2023-07-28 00:17:03 +09:30
|
|
|
PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[i])
|
|
|
|
PCs[-1].texture = SpriteLoader.strip_textures[i]
|
2024-07-08 16:11:22 +09:30
|
|
|
PCs[-1].animation = anim_id
|
2023-07-28 00:17:03 +09:30
|
|
|
|
|
|
|
add_child(PCs[-1])
|
|
|
|
# PCs.append(PC.instance())
|
|
|
|
# PCs[-1].set_position(Vector2(0, 2*24*11))
|
|
|
|
# PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[45])
|
|
|
|
# PCs[-1].texture = SpriteLoader.weapon_textures['Fist']
|
|
|
|
# add_child(PCs[-1])
|
|
|
|
|
2024-07-08 16:11:22 +09:30
|
|
|
func _ready() -> void:
|
|
|
|
initialize()
|
|
|
|
RomLoader.connect('rom_loaded', self, 'initialize') # Attempt to reload sprites if a new ROM is hot loaded
|
|
|
|
|
2023-07-28 00:17:03 +09:30
|
|
|
func _on_OptionButton_item_selected(ID):
|
|
|
|
for pc in PCs:
|
|
|
|
pc.animation = ID
|
2024-07-08 16:11:22 +09:30
|
|
|
|
|
|
|
func _on_btn_next_pressed():
|
|
|
|
var id = $btn_anim_choice.get_selected_id()
|
|
|
|
if id < num_animations-1:
|
|
|
|
$btn_anim_choice.select(id+1)
|
|
|
|
_on_OptionButton_item_selected(id+1)
|
|
|
|
|
|
|
|
func _on_btn_prev_pressed():
|
|
|
|
var id = $btn_anim_choice.get_selected_id()
|
|
|
|
if id > 0:
|
|
|
|
$btn_anim_choice.select(id-1)
|
|
|
|
_on_OptionButton_item_selected(id-1)
|