[BGM] Make the debug menus play appropriate music :)
This commit is contained in:
parent
79fee675ac
commit
bb3c850c95
9
main.gd
9
main.gd
|
@ -54,16 +54,21 @@ func push_menu(menu_type):
|
||||||
return
|
return
|
||||||
remove_child(menus[active_menu_stack[-1]])
|
remove_child(menus[active_menu_stack[-1]])
|
||||||
active_menu_stack.append(menu_type)
|
active_menu_stack.append(menu_type)
|
||||||
add_child(menus[menu_type])
|
self._present_menu(menus[menu_type])
|
||||||
|
|
||||||
func pop_menu():
|
func pop_menu():
|
||||||
if len(active_menu_stack) > 0:
|
if len(active_menu_stack) > 0:
|
||||||
remove_child(menus[active_menu_stack.pop_back()])
|
remove_child(menus[active_menu_stack.pop_back()])
|
||||||
if len(active_menu_stack) > 0:
|
if len(active_menu_stack) > 0:
|
||||||
add_child(menus[active_menu_stack[-1]])
|
self._present_menu(menus[active_menu_stack[-1]])
|
||||||
else:
|
else:
|
||||||
push_menu(Menu.LOADER)
|
push_menu(Menu.LOADER)
|
||||||
|
|
||||||
|
func _present_menu(menu) -> void:
|
||||||
|
add_child(menu)
|
||||||
|
if menu.has_method('_on_menu_presented'):
|
||||||
|
menu._on_menu_presented()
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event is InputEventKey and event.pressed:
|
if event is InputEventKey and event.pressed:
|
||||||
match event.scancode:
|
match event.scancode:
|
||||||
|
|
|
@ -45,20 +45,25 @@ func stop() -> void:
|
||||||
self.queued_awaiting_render_bgm = ''
|
self.queued_awaiting_render_bgm = ''
|
||||||
self.current_bgm = ''
|
self.current_bgm = ''
|
||||||
|
|
||||||
func play_bgm(key: String) -> void:
|
func play_bgm(key: String, target_time: float = -1.0) -> void:
|
||||||
print('@%dms - Playing %s' % [get_ms(), key])
|
print('@%dms - Playing %s' % [get_ms(), key])
|
||||||
|
_evict_pcm_cache()
|
||||||
var bgm_id := int(key.substr(3, 2))
|
var bgm_id := int(key.substr(3, 2))
|
||||||
if not (bgm_id in audio_renderer.cached_midis):
|
if not (bgm_id in audio_renderer.cached_midis):
|
||||||
self.queue_prerender_bgm(bgm_id)
|
self.queue_prerender_bgm(bgm_id)
|
||||||
# TODO: crossfade
|
# TODO: crossfade
|
||||||
var target_time := 0.0
|
|
||||||
if self.music_player_1.playing and self.current_bgm.substr(0, 5) == key.substr(0, 5):
|
if self.music_player_1.playing and self.current_bgm.substr(0, 5) == key.substr(0, 5):
|
||||||
# Try live transition
|
# Try live transition
|
||||||
var tempo_thou := int(key.substr(6))
|
var tempo_thou := int(key.substr(6))
|
||||||
var old_tempo_thou := int(self.current_bgm.substr(6))
|
var old_tempo_thou := int(self.current_bgm.substr(6))
|
||||||
var old_playback_pos: float = self.music_player_1.get_playback_position()
|
var old_playback_pos: float = self.music_player_1.get_playback_position()
|
||||||
target_time = old_playback_pos * old_tempo_thou / tempo_thou
|
if target_time < 0.0: # Negative (default) time means automatic continuation
|
||||||
print('Old temposcale %d, New temposcale %d, Old pos %.2f, New pos %.2f' % [old_tempo_thou, tempo_thou, old_playback_pos, target_time])
|
if old_tempo_thou == tempo_thou:
|
||||||
|
return # Don't even need to refresh LRU since it can only be most recent anyway
|
||||||
|
target_time = old_playback_pos * old_tempo_thou / tempo_thou
|
||||||
|
print('Old temposcale %d, New temposcale %d, Old pos %.2f, New pos %.2f' % [old_tempo_thou, tempo_thou, old_playback_pos, target_time])
|
||||||
|
if target_time < 0.0:
|
||||||
|
target_time = 0.0
|
||||||
if key in self.cached_bgms:
|
if key in self.cached_bgms:
|
||||||
self.music_player_1.stream = self.cached_bgms[key]
|
self.music_player_1.stream = self.cached_bgms[key]
|
||||||
self.music_player_1.play(target_time)
|
self.music_player_1.play(target_time)
|
||||||
|
|
|
@ -14,5 +14,8 @@ func _ready() -> void:
|
||||||
btn.connect('pressed', self, '_on_btn_pressed', [key])
|
btn.connect('pressed', self, '_on_btn_pressed', [key])
|
||||||
buttons.add_child(btn)
|
buttons.add_child(btn)
|
||||||
|
|
||||||
|
func _on_menu_presented() -> void: # Called by main.gd when a menu is presented in front of the rest
|
||||||
|
MusicManager.play_bgm('BGM08-1000') # Prelude
|
||||||
|
|
||||||
func _on_btn_pressed(menu) -> void:
|
func _on_btn_pressed(menu) -> void:
|
||||||
emit_signal('button_pressed', menu)
|
emit_signal('button_pressed', menu)
|
||||||
|
|
|
@ -5,6 +5,7 @@ var worldmap_shader_mat := preload('res://worldmap_palette_mat.tres')
|
||||||
onready var minimap := $tr_minimap
|
onready var minimap := $tr_minimap
|
||||||
|
|
||||||
var current_map_id := 0
|
var current_map_id := 0
|
||||||
|
const MAP_BGM_KEYS := ['BGM35-1000', 'BGM39-1000', 'BGM63-1000', 'BGM30-1000', 'BGM30-1000']
|
||||||
var map_images := [null, null, null, null, null]
|
var map_images := [null, null, null, null, null]
|
||||||
var map_textures := [null, null, null, null, null]
|
var map_textures := [null, null, null, null, null]
|
||||||
var map_regional_replacement_amounts := [0, 0, 0, 0, 0]
|
var map_regional_replacement_amounts := [0, 0, 0, 0, 0]
|
||||||
|
@ -36,6 +37,7 @@ func _set_map(id: int) -> void:
|
||||||
print_debug('Invalid map ID %d' % id)
|
print_debug('Invalid map ID %d' % id)
|
||||||
return
|
return
|
||||||
self.current_map_id = id
|
self.current_map_id = id
|
||||||
|
MusicManager.play_bgm(MAP_BGM_KEYS[self.current_map_id])
|
||||||
var tileset = map_tilesets[id]
|
var tileset = map_tilesets[id]
|
||||||
self.current_texture = self.map_textures[self.current_map_id]
|
self.current_texture = self.map_textures[self.current_map_id]
|
||||||
self.material.set_shader_param('palette', SpriteLoader.worldmap_palette_textures[tileset])
|
self.material.set_shader_param('palette', SpriteLoader.worldmap_palette_textures[tileset])
|
||||||
|
@ -99,8 +101,12 @@ func _ready() -> void:
|
||||||
minimap.modulate.a8 = 192
|
minimap.modulate.a8 = 192
|
||||||
minimap.rect_scale = Vector2.ONE * 0.125
|
minimap.rect_scale = Vector2.ONE * 0.125
|
||||||
minimap.rect_position = Vector2(8, 168)
|
minimap.rect_position = Vector2(8, 168)
|
||||||
|
self.pos = Vector2(156, 150)
|
||||||
_set_map(0)
|
_set_map(0)
|
||||||
|
|
||||||
|
func _on_menu_presented() -> void:
|
||||||
|
MusicManager.play_bgm(MAP_BGM_KEYS[self.current_map_id], 0.0)
|
||||||
|
|
||||||
func handle_movement_input(delta: float, quantize:=8.0) -> void:
|
func handle_movement_input(delta: float, quantize:=8.0) -> void:
|
||||||
delta = round(delta*quantize)/quantize
|
delta = round(delta*quantize)/quantize
|
||||||
if Input.is_physical_key_pressed(KEY_RIGHT):
|
if Input.is_physical_key_pressed(KEY_RIGHT):
|
||||||
|
|
|
@ -13,6 +13,10 @@ func _ready() -> void:
|
||||||
background.material = battle_bg_mat
|
background.material = battle_bg_mat
|
||||||
set_bg(1)
|
set_bg(1)
|
||||||
|
|
||||||
|
const RANDOM_BGMS_PLAYLIST = [34, 43, 1, 9, 64]
|
||||||
|
func _on_menu_presented() -> void:
|
||||||
|
MusicManager.play_bgm('BGM%02d-1000'%RANDOM_BGMS_PLAYLIST.pick_random(), 0)
|
||||||
|
|
||||||
func set_bg(index: int) -> void:
|
func set_bg(index: int) -> void:
|
||||||
self.bg = SpriteLoader.battle_backgrounds[index]
|
self.bg = SpriteLoader.battle_backgrounds[index]
|
||||||
self.pal_l = len(self.bg.palette_texs)
|
self.pal_l = len(self.bg.palette_texs)
|
||||||
|
|
|
@ -150,6 +150,11 @@ func _upload_file(filename: String, file_type: String, data): # data is Javascr
|
||||||
func _files_dropped(filenames: PoolStringArray, screen_idx: int) -> void:
|
func _files_dropped(filenames: PoolStringArray, screen_idx: int) -> void:
|
||||||
print('Files Dropped signal: screen=%d, files='%screen_idx, filenames)
|
print('Files Dropped signal: screen=%d, files='%screen_idx, filenames)
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
|
var dir := Directory.new()
|
||||||
|
dir.open('user://')
|
||||||
|
var new_filename = 'user://' + filename.rsplit('/', true, 1)[1]
|
||||||
|
var err = dir.copy(filename, new_filename)
|
||||||
|
print('Attempted to copy %s to %s - error code %s' % [filename, new_filename, globals.ERROR_CODE_STRINGS[err]])
|
||||||
var ext: String = filename.rsplit('.', true, 1)[1]
|
var ext: String = filename.rsplit('.', true, 1)[1]
|
||||||
if ext in ALLOWED_EXTS:
|
if ext in ALLOWED_EXTS:
|
||||||
var file := File.new()
|
var file := File.new()
|
||||||
|
@ -168,6 +173,7 @@ func _files_dropped(filenames: PoolStringArray, screen_idx: int) -> void:
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if OS.get_name() != 'HTML5' or !OS.has_feature('JavaScript'):
|
if OS.get_name() != 'HTML5' or !OS.has_feature('JavaScript'):
|
||||||
return
|
return
|
||||||
|
print('is_userfs_persistent() == %s'%OS.is_userfs_persistent())
|
||||||
init_labels()
|
init_labels()
|
||||||
update_view()
|
update_view()
|
||||||
btn_load.connect('pressed', self, 'activate_current_entry')
|
btn_load.connect('pressed', self, 'activate_current_entry')
|
||||||
|
|
Loading…
Reference in New Issue