From 437d361796f9621fec151109f6647ad4ab0a2c93 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Thu, 28 Jan 2021 22:47:19 +1030 Subject: [PATCH] Rename SFXPlayer to SoundPlayer Now that music playback is handled by this singleton the old name is insufficient --- project.godot | 3 ++- scripts/Menu.gd | 20 ++++++++++---------- scripts/NoteHandler.gd | 8 ++++---- singletons/{SFXPlayer.gd => SoundPlayer.gd} | 1 - 4 files changed, 16 insertions(+), 16 deletions(-) rename singletons/{SFXPlayer.gd => SoundPlayer.gd} (93%) diff --git a/project.godot b/project.godot index 512b0ba..2fc0116 100644 --- a/project.godot +++ b/project.godot @@ -30,7 +30,7 @@ Rules="*res://singletons/Rules.gd" FileLoader="*res://singletons/FileLoader.gd" Library="*res://singletons/Library.gd" GameTheme="*res://singletons/GameTheme.gd" -SFXPlayer="*res://singletons/SFXPlayer.gd" +SoundPlayer="*res://singletons/SoundPlayer.gd" [debug] @@ -59,6 +59,7 @@ singletons_disabled=[ ] [rendering] vram_compression/import_etc=true +environment/default_clear_color=Color( 0.11, 0.11, 0.11, 1 ) quality/filters/msaa=1 environment/default_environment="res://default_env.tres" quality/subsampling/x=1.0 diff --git a/scripts/Menu.gd b/scripts/Menu.gd index c62b63e..846c255 100644 --- a/scripts/Menu.gd +++ b/scripts/Menu.gd @@ -193,7 +193,7 @@ func _draw_song_select(center: Vector2) -> Array: var subsize = size * scales.value(abs(s_delta)) var gx = center.x - (subsize + spacer_x) * s_delta 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) var s = len(songslist) var key = songslist[self.selected_song_idx % s] @@ -462,46 +462,46 @@ func set_menu_mode(mode): func touch_select_song(touchdict): 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]] # selected_song_key = songslist[self.target_song_idx % len(songslist)] set_menu_mode(MenuMode.CHART_SELECT) else: self.selected_genre = touchdict.genre_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() func touch_select_chart(touchdict): if touchdict.chart_idx == selected_difficulty: 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) 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: - 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) else: 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): 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': NoteHandler.stop() func touch_score_screen(touchdict): 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) ScoreText.score = '' ScoreText.score_sub = '' # TODO: time this to coincide with the menu going fully offscreen ScoreText.update() 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': save_score() diff --git a/scripts/NoteHandler.gd b/scripts/NoteHandler.gd index f8a5ef5..3daa800 100644 --- a/scripts/NoteHandler.gd +++ b/scripts/NoteHandler.gd @@ -8,7 +8,7 @@ var running := false var song_key = '' export var VideoPlayerPath := @'../../video' -onready var MusicPlayer := SFXPlayer.music_player +onready var MusicPlayer := SoundPlayer.music_player onready var VideoPlayer := get_node(VideoPlayerPath) onready var Painter = $Painter @@ -203,12 +203,12 @@ func make_slide_trail_mesh(note) -> ArrayMesh: #---------------------------------------------------------------------------------------------------------------------------------------------- func make_judgement_column(judgement, column: int): 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): # Positional judgement text not yet implemented, will do if touches are ever added #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): @@ -497,7 +497,7 @@ func stop(): next_note_to_load = 10000000 # Hacky but whatever 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: # Usually we only update the gametime once per process loop, but for input callbacks it's good to have msec precision diff --git a/singletons/SFXPlayer.gd b/singletons/SoundPlayer.gd similarity index 93% rename from singletons/SFXPlayer.gd rename to singletons/SoundPlayer.gd index 54baf5c..4b448d3 100644 --- a/singletons/SFXPlayer.gd +++ b/singletons/SoundPlayer.gd @@ -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") -# This singleton and API will need renaming later to reflect the new purposes var music_player := AudioStreamPlayer.new() func _ready() -> void: add_child(music_player)