Sort the scripts and scenes into folders
main/ holds the main window and top bar, quiz/ the quiz and its parts, player/ the music player, popups/ every popup and what they share, data/ the songs, players, playlist and settings, server/ the MusicServer client, common/ the list row and GameLog, and themes/ the themes and style boxes.
This commit is contained in:
1 parent
a0428e3475
commit
d77b72159d
115 files changed
+94
-84
No files matched your search
@@ -0,0 +1,122 @@
|
||||
extends Node
|
||||
## The songs of the current quiz, in the order they were added, and which of them are
|
||||
## played, answered and playing.
|
||||
##
|
||||
## Registered as the [code]Playlist[/code] autoload.
|
||||
|
||||
var song_object_array: Array[SongObject] = []
|
||||
var latest_played_song: int = 0
|
||||
var currently_playing_song: int = -1
|
||||
var first_song_downloaded: bool = false
|
||||
var first_song_played: bool = false
|
||||
var number_of_tracks_to_preload: int = 1
|
||||
var is_song_downloading: bool = false
|
||||
|
||||
|
||||
func get_next_song() -> SongObject:
|
||||
return song_object_array[latest_played_song]
|
||||
|
||||
|
||||
func set_latest_played_song() -> void:
|
||||
latest_played_song += 1
|
||||
if latest_played_song > song_object_array.size() - 1:
|
||||
latest_played_song = song_object_array.size() - 1
|
||||
|
||||
|
||||
func update_last_played_song() -> void:
|
||||
latest_played_song = song_object_array.size()
|
||||
|
||||
|
||||
func get_preloaded_songs() -> int:
|
||||
var number_of_tracks_preloaded: int = 0
|
||||
for song: SongObject in song_object_array:
|
||||
if !song.has_played:
|
||||
number_of_tracks_preloaded += 1
|
||||
return number_of_tracks_preloaded
|
||||
|
||||
|
||||
func should_preload_more_songs() -> bool:
|
||||
return number_of_tracks_to_preload > get_preloaded_songs()
|
||||
|
||||
|
||||
func song_is_answered(song_no: int = currently_playing_song) -> void:
|
||||
# Nothing is playing yet (-1); a negative index would answer the last, unplayed song
|
||||
if song_no < 0 || song_no >= song_object_array.size():
|
||||
return
|
||||
GameLog.debug("show_answer_pressed song_object: ", song_object_array[song_no]._to_string())
|
||||
song_object_array[song_no].is_answered = true
|
||||
if Settings.add_to_stats:
|
||||
GameLog.debug("add to stats: ", song_no)
|
||||
MusicServerClient.mark_song_played(song_no)
|
||||
|
||||
|
||||
func add_to_playlist(new_song_object: SongObject) -> void:
|
||||
song_object_array.append(new_song_object)
|
||||
|
||||
|
||||
func get_playlist() -> Array[SongObject]:
|
||||
if Settings.is_debug:
|
||||
return song_object_array
|
||||
else:
|
||||
var temp_list: Array[SongObject] = []
|
||||
for s: SongObject in song_object_array:
|
||||
if s.has_played:
|
||||
temp_list.append(s)
|
||||
return temp_list
|
||||
|
||||
|
||||
func reset_playlist() -> void:
|
||||
currently_playing_song = -1
|
||||
latest_played_song = 0
|
||||
clear_song_list()
|
||||
|
||||
|
||||
func clear_song_list() -> void:
|
||||
song_object_array.clear()
|
||||
|
||||
|
||||
func unset_is_playing() -> void:
|
||||
for song_object: SongObject in song_object_array:
|
||||
song_object.is_playing = false
|
||||
|
||||
|
||||
func set_currently_playing_song(value: int) -> void:
|
||||
currently_playing_song = value
|
||||
|
||||
|
||||
func get_current_soundtrack_title() -> String:
|
||||
return song_object_array[currently_playing_song].get_soundtrack_title()
|
||||
|
||||
|
||||
func get_current_song_title() -> String:
|
||||
return song_object_array[currently_playing_song].get_song_title()
|
||||
|
||||
|
||||
func add_point(player_id: String) -> void:
|
||||
song_object_array[currently_playing_song].add_point(player_id)
|
||||
|
||||
|
||||
func remove_point(player_id: String) -> void:
|
||||
song_object_array[currently_playing_song].remove_point(player_id)
|
||||
|
||||
|
||||
## Removes a player's points from every song.
|
||||
func remove_player_from_list(player_id: String) -> void:
|
||||
for song_object: SongObject in song_object_array:
|
||||
song_object.remove_point(player_id)
|
||||
|
||||
|
||||
func get_song(song_no: int) -> AudioStream:
|
||||
return song_object_array[song_no].song
|
||||
|
||||
|
||||
func add_song_to_song_object(song_no: int, sound: AudioStream) -> void:
|
||||
song_object_array[song_no].song = sound
|
||||
|
||||
|
||||
func song_has_played(song_no: int = latest_played_song) -> void:
|
||||
song_object_array[song_no].has_played = true
|
||||
|
||||
|
||||
func song_is_playing(song_no: int = latest_played_song) -> void:
|
||||
song_object_array[song_no].is_playing = true
|
||||
Reference in new issue
Block a user