aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/MusicConductor
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-12-24 19:23:18 +0100
committer GitHub <noreply@github.com>2023-12-24 19:23:18 +0100
commitd26c990d9a5596a3ef3b32ba1cb0f99950cd6d34 (patch)
tree1b99c935438692bb2ebadeac412b990c82089b65 /game/src/Game/MusicConductor
parent50b0b935b0bf0724f40b5140aca85d1830a8b1b3 (diff)
parentb6413251a866c76538869b84ed1c9b9852f7c507 (diff)
Merge pull request #178 from Spartan322/add-menu-type-hints
Diffstat (limited to 'game/src/Game/MusicConductor')
-rw-r--r--game/src/Game/MusicConductor/MusicConductor.gd10
-rw-r--r--game/src/Game/MusicConductor/MusicPlayer.gd20
-rw-r--r--game/src/Game/MusicConductor/SongInfo.gd2
3 files changed, 16 insertions, 16 deletions
diff --git a/game/src/Game/MusicConductor/MusicConductor.gd b/game/src/Game/MusicConductor/MusicConductor.gd
index f298db6..abfc52f 100644
--- a/game/src/Game/MusicConductor/MusicConductor.gd
+++ b/game/src/Game/MusicConductor/MusicConductor.gd
@@ -13,7 +13,7 @@ signal song_scrubbed(percentage : float, seconds : float)
@export var _audio_stream_player : AudioStreamPlayer
-var _selected_track = 0
+var _selected_track := 0
var _available_songs : Array[SongInfo] = []
var _auto_play_next_song : bool = true
@@ -76,9 +76,9 @@ func select_previous_song() -> void:
# REQUIREMENTS
# * SND-2, SND-3
-func _ready():
- var dir = DirAccess.open(music_directory)
- for fname in dir.get_files():
+func _ready() -> void:
+ var dir := DirAccess.open(music_directory)
+ for fname : String in dir.get_files():
if fname.ends_with(".import"):
fname = fname.get_basename()
if fname.get_basename() == first_song_name:
@@ -91,7 +91,7 @@ func set_startup_music(play : bool) -> void:
_has_startup_happened = true
set_paused(not play)
-func _on_audio_stream_player_finished():
+func _on_audio_stream_player_finished() -> void:
song_finished.emit(_selected_track)
if _auto_play_next_song:
select_next_song()
diff --git a/game/src/Game/MusicConductor/MusicPlayer.gd b/game/src/Game/MusicConductor/MusicPlayer.gd
index e83ab9b..949f423 100644
--- a/game/src/Game/MusicConductor/MusicPlayer.gd
+++ b/game/src/Game/MusicConductor/MusicPlayer.gd
@@ -9,7 +9,7 @@ extends Control
var _is_user_dragging_progress_slider : bool = false
-func _ready():
+func _ready() -> void:
for songName in MusicConductor.get_all_song_names():
_song_selector_button.add_item(songName, _song_selector_button.item_count)
_on_song_set(MusicConductor.get_current_song_index())
@@ -22,35 +22,35 @@ func _on_song_set(track_id : int) -> void:
_song_selector_button.selected = track_id
_update_play_pause_button()
-func _process(_delta):
+func _process(_delta : float) -> void:
if !_is_user_dragging_progress_slider:
_progress_slider.value = MusicConductor.get_current_song_progress_percentage()
-func _update_play_pause_button(_arg1 = null, _arg2 = null):
+func _update_play_pause_button(_arg1 : Variant = null, _arg2 : Variant = null) -> void:
_play_pause_button.text = "◼" if MusicConductor.is_paused() else "▶"
-func _on_play_pause_button_pressed():
+func _on_play_pause_button_pressed() -> void:
MusicConductor.toggle_play_pause()
# REQUIREMENTS
# * UIFUN-93
-func _on_next_song_button_pressed():
+func _on_next_song_button_pressed() -> void:
MusicConductor.select_next_song()
# REQUIREMENTS
# * UIFUN-94
-func _on_previous_song_button_pressed():
+func _on_previous_song_button_pressed() -> void:
MusicConductor.select_previous_song()
# REQUIREMENTS
# * UIFUN-95
-func _on_option_button_item_selected(index):
+func _on_option_button_item_selected(index : int) -> void:
MusicConductor.start_song_by_index(index)
-func _on_progress_slider_drag_started():
+func _on_progress_slider_drag_started() -> void:
_is_user_dragging_progress_slider = true
-func _on_progress_slider_drag_ended(_value_changed):
+func _on_progress_slider_drag_ended(_value_changed : bool) -> void:
MusicConductor.scrub_song_by_percentage(_progress_slider.value)
_is_user_dragging_progress_slider = false
@@ -65,5 +65,5 @@ func _set_music_player_visible(is_player_visible : bool) -> void:
# REQUIREMENTS
# * UIFUN-91
-func _on_music_ui_visibility_button_pressed():
+func _on_music_ui_visibility_button_pressed() -> void:
_set_music_player_visible(not MusicConductor.is_music_player_visible)
diff --git a/game/src/Game/MusicConductor/SongInfo.gd b/game/src/Game/MusicConductor/SongInfo.gd
index 1ee9adc..abcf120 100644
--- a/game/src/Game/MusicConductor/SongInfo.gd
+++ b/game/src/Game/MusicConductor/SongInfo.gd
@@ -5,7 +5,7 @@ var song_path : String = ""
var song_name : String = ""
var song_stream : Resource
-func _init(dirname:String, fname:String):
+func _init(dirname:String, fname:String) -> void:
song_path = dirname.path_join(fname)
song_name = fname.get_basename().replace("_", " ")
song_stream = load(song_path)