From 473d62c5907d0ba5f423424f12f2fb511e776436 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Mon, 15 Jul 2024 02:31:36 +0930 Subject: [PATCH] Improve some debug menu layouts --- main.gd | 2 ++ test/audio_system.gd | 25 ++++++++++---- test/audio_system.tscn | 70 +++++++++++++++++++++++---------------- test/battle_sprites.gd | 6 +++- test/battle_sprites.tscn | 7 ++++ test/worldmap_blocks.gd | 5 ++- test/worldmap_blocks.tscn | 8 +++++ 7 files changed, 85 insertions(+), 38 deletions(-) diff --git a/main.gd b/main.gd index db25a38..dcfabe1 100644 --- a/main.gd +++ b/main.gd @@ -11,6 +11,8 @@ func instantiate_menu_list(menu_list) -> void: for key in menu_list: packed_menus[key] = load(globals.MENUS[key][0]) menus[key] = packed_menus[key].instance() + if menus[key].has_signal('exit'): + menus[key].connect('exit', self, 'pop_menu') var is_rom_loaded := false func _on_rom_loaded() -> void: diff --git a/test/audio_system.gd b/test/audio_system.gd index 1927f48..4008726 100644 --- a/test/audio_system.gd +++ b/test/audio_system.gd @@ -1,5 +1,6 @@ extends Node2D #warning-ignore-all:return_value_discarded +signal exit const MusicPlayer := preload('res://scripts/MusicPlayer.gd') var MusicLoader := preload('res://scripts/loaders/snes/music_ff5.gd').new() onready var bgm_titles := Common.load_glyph_table('res://data/5/bgm_titles.txt') @@ -19,22 +20,28 @@ var bgm_tracksets := {} func _create_sfx_buttons(): var disable_btn := !SoundLoader.has_loaded_audio_samples + var btn_width := 48 + var btn_height := 22 + var btns_per_row := 8 + var inst_pos_offset: Vector2 = $inst_buttons.rect_position for i in SoundLoader.INST_NUM: var btn = Button.new() - btn.text = 'Inst #%02X' % i + btn.text = 'Inst #%02d' % i btn.align = Button.ALIGN_CENTER - btn.set_position(Vector2((i%7)*50, (i/7)*24)) - btn.rect_min_size.x = 48 + btn.set_position(Vector2((i%btns_per_row)*btn_width, (i/btns_per_row)*btn_height) + inst_pos_offset) + btn.rect_min_size.x = btn_width add_child(btn) btn.connect('pressed', SoundLoader, 'play_sample', [i]) inst_buttons.append(btn) btn.disabled = disable_btn + btns_per_row = int($sfx_buttons.rect_size.x/btn_width) + var sfx_pos_offset: Vector2 = $sfx_buttons.rect_position for i in SoundLoader.SFX_NUM: var btn = Button.new() - btn.text = 'SFX #%02X' % i + btn.text = 'SFX #%02d' % i btn.align = Button.ALIGN_CENTER - btn.set_position(Vector2((i%4)*50, 130 + (i/4)*24)) - btn.rect_min_size.x = 48 + btn.set_position(Vector2((i%btns_per_row)*btn_width, (i/btns_per_row)*btn_height) + sfx_pos_offset) + btn.rect_min_size.x = btn_width add_child(btn) btn.connect('pressed', SoundLoader, 'play_sfx', [i]) sfx_buttons.append(btn) @@ -145,11 +152,14 @@ func _update_bgm_label(id = 0) -> void: $lbl_bgm_title.text = '' -# Called when the node enters the scene tree for the first time. +func _exit() -> void: + self.emit_signal('exit') + func _ready() -> void: self._create_sfx_buttons() self._create_bgm_playback() $btn_stop.connect('pressed', self, '_stop_all') + $btn_exit.connect('pressed', self, '_exit') for i in len(RomLoader.snes_data.bgm_song_pointers): var pointer = RomLoader.snes_data.bgm_song_pointers[i] # print('BGM 0x%02X (%02d) at 0x%06X' % [i, i, pointer]) @@ -187,6 +197,7 @@ func queue_prerender_bgm(bgm_id: int) -> void: func render_all_bgm(bgms_to_render: int = 70) -> void: + $btn_render.set_disabled(true) self.initialize_instrument_texture() for bgm_id in bgms_to_render: self.queue_prerender_bgm(bgm_id) diff --git a/test/audio_system.tscn b/test/audio_system.tscn index ac65bff..77476a2 100644 --- a/test/audio_system.tscn +++ b/test/audio_system.tscn @@ -6,8 +6,8 @@ [sub_resource type="ShaderMaterial" id=2] shader = ExtResource( 4 ) -shader_param/INT_TEX_WIDTH = 4096 -shader_param/TEX_SIZE = Vector2( 4096, 4096 ) +shader_param/INT_OUTPUT_WIDTH = 4096 +shader_param/OUTPUT_FRAMEBUFFER_SIZE = Vector2( 4096, 4096 ) shader_param/instrument_samples_size = Vector2( 2048, 128 ) shader_param/reference_note = 71.0 shader_param/output_mixrate = 32000.0 @@ -32,54 +32,66 @@ margin_bottom = 40.0 script = ExtResource( 3 ) [node name="inst_buttons" type="ReferenceRect" parent="."] -margin_right = 348.0 +margin_right = 384.0 margin_bottom = 118.0 [node name="sfx_buttons" type="ReferenceRect" parent="."] -margin_top = 130.0 -margin_right = 198.0 -margin_bottom = 176.0 +margin_left = 192.0 +margin_top = 96.0 +margin_right = 384.0 +margin_bottom = 142.0 [node name="sb_bgm" type="SpinBox" parent="."] -margin_top = 188.0 +margin_top = 138.0 margin_right = 38.0 -margin_bottom = 212.0 +margin_bottom = 162.0 rect_min_size = Vector2( 38, 0 ) max_value = 69.0 align = 2 [node name="btn_bgm_live" type="Button" parent="."] -margin_left = 40.0 -margin_top = 188.0 -margin_right = 126.0 -margin_bottom = 212.0 +margin_top = 216.0 +margin_right = 86.0 +margin_bottom = 240.0 text = "Play BGM live" [node name="btn_bgm_prerendered" type="Button" parent="."] -margin_left = 132.0 -margin_top = 188.0 -margin_right = 272.0 -margin_bottom = 212.0 +margin_top = 164.0 +margin_right = 140.0 +margin_bottom = 188.0 text = "Play BGM prerendered" [node name="btn_render" type="Button" parent="."] -margin_left = 278.0 -margin_top = 188.0 -margin_right = 374.0 -margin_bottom = 212.0 +margin_top = 190.0 +margin_right = 96.0 +margin_bottom = 214.0 text = "Render All BGM" [node name="btn_stop" type="Button" parent="."] -margin_left = 320.0 -margin_top = 216.0 -margin_right = 374.0 -margin_bottom = 240.0 -text = "Stop All" +margin_left = 278.0 +margin_top = 164.0 +margin_right = 384.0 +margin_bottom = 188.0 +text = "Stop All Playback" [node name="lbl_bgm_title" type="Label" parent="."] -margin_left = 2.0 -margin_top = 220.0 -margin_right = 42.0 -margin_bottom = 234.0 +margin_left = 42.0 +margin_top = 143.0 +margin_right = 82.0 +margin_bottom = 157.0 + +[node name="lbl_bgm" type="Label" parent="."] +margin_left = 3.0 +margin_top = 123.0 +margin_right = 84.0 +margin_bottom = 137.0 +text = "BGM Playback" [node name="audio_player" type="AudioStreamPlayer" parent="."] + +[node name="btn_exit" type="Button" parent="."] +margin_left = 245.0 +margin_top = 218.0 +margin_right = 384.0 +margin_bottom = 240.0 +text = "Return to Debug Menu" diff --git a/test/battle_sprites.gd b/test/battle_sprites.gd index 93d389c..46b2c81 100644 --- a/test/battle_sprites.gd +++ b/test/battle_sprites.gd @@ -1,5 +1,5 @@ extends Control - +signal exit var PC := preload('res://PC.gd') var PC_scene := preload('res://PC.tscn') var PCs := [] @@ -32,7 +32,11 @@ func initialize() -> void: # PCs[-1].texture = SpriteLoader.weapon_textures['Fist'] # add_child(PCs[-1]) +func _exit() -> void: + emit_signal('exit') + func _ready() -> void: + $btn_exit.connect('pressed', self, '_exit') initialize() RomLoader.connect('rom_loaded', self, 'initialize') # Attempt to reload sprites if a new ROM is hot loaded diff --git a/test/battle_sprites.tscn b/test/battle_sprites.tscn index b0fa76c..2930e2a 100644 --- a/test/battle_sprites.tscn +++ b/test/battle_sprites.tscn @@ -47,6 +47,13 @@ margin_bottom = 218.0 shortcut = SubResource( 2 ) text = "Nex[t]" +[node name="btn_exit" type="Button" parent="."] +margin_left = 245.0 +margin_top = 218.0 +margin_right = 384.0 +margin_bottom = 240.0 +text = "Return to Debug Menu" + [connection signal="item_selected" from="btn_anim_choice" to="." method="_on_OptionButton_item_selected"] [connection signal="pressed" from="btn_prev" to="." method="_on_btn_prev_pressed"] [connection signal="pressed" from="btn_next" to="." method="_on_btn_next_pressed"] diff --git a/test/worldmap_blocks.gd b/test/worldmap_blocks.gd index b7cc958..03e70d9 100644 --- a/test/worldmap_blocks.gd +++ b/test/worldmap_blocks.gd @@ -1,4 +1,5 @@ extends Node2D +signal exit var tileset_tex := TextureRect.new() var worldmaps := [] var block_images := [] @@ -17,9 +18,11 @@ func bin2str(bin: int) -> String: string += '.' #'0' return string - +func _exit() -> void: + emit_signal('exit') func _ready() -> void: + $btn_exit.connect('pressed', self, '_exit') var blockmap = PoolByteArray() for i in 0xC0: blockmap.append(i) diff --git a/test/worldmap_blocks.tscn b/test/worldmap_blocks.tscn index 3f0d343..897d4b2 100644 --- a/test/worldmap_blocks.tscn +++ b/test/worldmap_blocks.tscn @@ -28,3 +28,11 @@ margin_right = 330.0 margin_bottom = 22.0 rect_min_size = Vector2( 30, 0 ) max_value = 2.0 + +[node name="btn_exit" type="Button" parent="."] +margin_left = 304.0 +margin_top = 204.0 +margin_right = 384.0 +margin_bottom = 240.0 +text = "Return to +Debug Menu"