Rename SFXPlayer to SoundPlayer

Now that music playback is handled by this singleton the old name is insufficient
This commit is contained in:
Luke Hubmayer-Werner 2021-01-28 22:47:19 +10:30
parent 445a814654
commit 437d361796
4 changed files with 16 additions and 16 deletions

View File

@ -30,7 +30,7 @@ Rules="*res://singletons/Rules.gd"
FileLoader="*res://singletons/FileLoader.gd" FileLoader="*res://singletons/FileLoader.gd"
Library="*res://singletons/Library.gd" Library="*res://singletons/Library.gd"
GameTheme="*res://singletons/GameTheme.gd" GameTheme="*res://singletons/GameTheme.gd"
SFXPlayer="*res://singletons/SFXPlayer.gd" SoundPlayer="*res://singletons/SoundPlayer.gd"
[debug] [debug]
@ -59,6 +59,7 @@ singletons_disabled=[ ]
[rendering] [rendering]
vram_compression/import_etc=true vram_compression/import_etc=true
environment/default_clear_color=Color( 0.11, 0.11, 0.11, 1 )
quality/filters/msaa=1 quality/filters/msaa=1
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"
quality/subsampling/x=1.0 quality/subsampling/x=1.0

View File

@ -193,7 +193,7 @@ func _draw_song_select(center: Vector2) -> Array:
var subsize = size * scales.value(abs(s_delta)) var subsize = size * scales.value(abs(s_delta))
var gx = center.x - (subsize + spacer_x) * s_delta var gx = center.x - (subsize + spacer_x) * s_delta
var songslist = Library.genre_songs[g].keys() var songslist = Library.genre_songs[g].keys()
var genre_str = '%s (%d)'%[genres.keys()[g], len(songslist)] var genre_str = '%s (%d songs)'%[genres.keys()[g], len(songslist)]
draw_string_centered(GenreFont, Vector2(center.x, gy), genre_str, Color.lightblue) draw_string_centered(GenreFont, Vector2(center.x, gy), genre_str, Color.lightblue)
var s = len(songslist) var s = len(songslist)
var key = songslist[self.selected_song_idx % s] var key = songslist[self.selected_song_idx % s]
@ -462,46 +462,46 @@ func set_menu_mode(mode):
func touch_select_song(touchdict): func touch_select_song(touchdict):
if (self.selected_genre == touchdict.genre_idx) and (self.selected_song_idx == touchdict.song_idx): if (self.selected_genre == touchdict.genre_idx) and (self.selected_song_idx == touchdict.song_idx):
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0)
# var songslist = genres[genres.keys()[selected_genre]] # var songslist = genres[genres.keys()[selected_genre]]
# selected_song_key = songslist[self.target_song_idx % len(songslist)] # selected_song_key = songslist[self.target_song_idx % len(songslist)]
set_menu_mode(MenuMode.CHART_SELECT) set_menu_mode(MenuMode.CHART_SELECT)
else: else:
self.selected_genre = touchdict.genre_idx self.selected_genre = touchdict.genre_idx
self.target_song_idx = touchdict.song_idx self.target_song_idx = touchdict.song_idx
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_interact, -4.5) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_interact, -4.5)
load_preview() load_preview()
func touch_select_chart(touchdict): func touch_select_chart(touchdict):
if touchdict.chart_idx == selected_difficulty: if touchdict.chart_idx == selected_difficulty:
if touchdict.enabled: if touchdict.enabled:
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0)
set_menu_mode(MenuMode.GAMEPLAY) set_menu_mode(MenuMode.GAMEPLAY)
else: else:
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_error, 0.0) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_error, 0.0)
elif touchdict.chart_idx < 0: elif touchdict.chart_idx < 0:
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_interact, -3.0, 0.7) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_interact, -3.0, 0.7)
set_menu_mode(MenuMode.SONG_SELECT) set_menu_mode(MenuMode.SONG_SELECT)
else: else:
self.selected_difficulty = touchdict.chart_idx self.selected_difficulty = touchdict.chart_idx
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_interact, -4.5) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_interact, -4.5)
func touch_gameplay(touchdict): func touch_gameplay(touchdict):
if touchdict.has('action'): if touchdict.has('action'):
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0)
if touchdict.action == 'stop': if touchdict.action == 'stop':
NoteHandler.stop() NoteHandler.stop()
func touch_score_screen(touchdict): func touch_score_screen(touchdict):
if touchdict.has('next_menu'): if touchdict.has('next_menu'):
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0)
set_menu_mode(touchdict.next_menu) set_menu_mode(touchdict.next_menu)
ScoreText.score = '' ScoreText.score = ''
ScoreText.score_sub = '' ScoreText.score_sub = ''
# TODO: time this to coincide with the menu going fully offscreen # TODO: time this to coincide with the menu going fully offscreen
ScoreText.update() ScoreText.update()
elif touchdict.has('action'): elif touchdict.has('action'):
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, snd_interact, 0.0)
if touchdict.action == 'save': if touchdict.action == 'save':
save_score() save_score()

View File

@ -8,7 +8,7 @@ var running := false
var song_key = '' var song_key = ''
export var VideoPlayerPath := @'../../video' export var VideoPlayerPath := @'../../video'
onready var MusicPlayer := SFXPlayer.music_player onready var MusicPlayer := SoundPlayer.music_player
onready var VideoPlayer := get_node(VideoPlayerPath) onready var VideoPlayer := get_node(VideoPlayerPath)
onready var Painter = $Painter onready var Painter = $Painter
@ -203,12 +203,12 @@ func make_slide_trail_mesh(note) -> ArrayMesh:
#---------------------------------------------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------------------------------------------
func make_judgement_column(judgement, column: int): func make_judgement_column(judgement, column: int):
active_judgement_texts.append({col=column, judgement=judgement, time=t}) active_judgement_texts.append({col=column, judgement=judgement, time=t})
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, GameTheme.snd_judgement[judgement], GameTheme.db_judgement[judgement], GameTheme.pitch_judgement[judgement]) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, GameTheme.snd_judgement[judgement], GameTheme.db_judgement[judgement], GameTheme.pitch_judgement[judgement])
func make_judgement_pos(judgement, pos: Vector2): func make_judgement_pos(judgement, pos: Vector2):
# Positional judgement text not yet implemented, will do if touches are ever added # Positional judgement text not yet implemented, will do if touches are ever added
#active_judgement_texts.append({judgement=judgement, time=t}) #active_judgement_texts.append({judgement=judgement, time=t})
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, GameTheme.snd_judgement[judgement], GameTheme.db_judgement[judgement], GameTheme.pitch_judgement[judgement]) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, GameTheme.snd_judgement[judgement], GameTheme.db_judgement[judgement], GameTheme.pitch_judgement[judgement])
func activate_note(note, judgement): func activate_note(note, judgement):
@ -497,7 +497,7 @@ func stop():
next_note_to_load = 10000000 # Hacky but whatever next_note_to_load = 10000000 # Hacky but whatever
func intro_click(): func intro_click():
SFXPlayer.play(SFXPlayer.Type.NON_POSITIONAL, self, GameTheme.snd_count_in) SoundPlayer.play(SoundPlayer.Type.NON_POSITIONAL, self, GameTheme.snd_count_in)
func get_realtime_precise() -> float: func get_realtime_precise() -> float:
# Usually we only update the gametime once per process loop, but for input callbacks it's good to have msec precision # Usually we only update the gametime once per process loop, but for input callbacks it's good to have msec precision

View File

@ -38,7 +38,6 @@ func play(type: int, parent: Node, stream: AudioStream, volume_db: float = 0.0,
audio_stream_player.connect("finished", audio_stream_player, "queue_free") audio_stream_player.connect("finished", audio_stream_player, "queue_free")
# This singleton and API will need renaming later to reflect the new purposes
var music_player := AudioStreamPlayer.new() var music_player := AudioStreamPlayer.new()
func _ready() -> void: func _ready() -> void:
add_child(music_player) add_child(music_player)