Log through a GameLog autoload instead of print()
GameLog.debug() prints only in debug builds, and GameLog.warning() reports problems such as unexpected server data or failed downloads.
This commit is contained in:
1 parent
5cdec5cc8f
commit
5831e1e73d
20 files changed
+137
-89
No files matched your search
+10
-10
@@ -41,7 +41,7 @@ var popup_backdrop: PopupBackdrop
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
popup_backdrop = PopupBackdrop.add_to(self, _popups())
|
popup_backdrop = PopupBackdrop.add_to(self, _popups())
|
||||||
if OS.has_feature("macos"):
|
if OS.has_feature("macos"):
|
||||||
print("is_mac")
|
GameLog.debug("is_mac")
|
||||||
top_bar.search_pressed.connect(show_search)
|
top_bar.search_pressed.connect(show_search)
|
||||||
top_bar.sync_pressed.connect(sync_soundtracks)
|
top_bar.sync_pressed.connect(sync_soundtracks)
|
||||||
top_bar.statistics_pressed.connect(get_statistics)
|
top_bar.statistics_pressed.connect(get_statistics)
|
||||||
@@ -60,7 +60,7 @@ func _ready() -> void:
|
|||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event is InputEventKey and event.pressed:
|
if event is InputEventKey and event.pressed:
|
||||||
if event.alt_pressed && event.keycode == KEY_ENTER:
|
if event.alt_pressed && event.keycode == KEY_ENTER:
|
||||||
print("Alt + Enter pressed")
|
GameLog.debug("Alt + Enter pressed")
|
||||||
Settings.fullscreen = !Settings.fullscreen
|
Settings.fullscreen = !Settings.fullscreen
|
||||||
if Settings.fullscreen == true:
|
if Settings.fullscreen == true:
|
||||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||||
@@ -77,44 +77,44 @@ func _popups() -> Array[PopupWindow]:
|
|||||||
|
|
||||||
|
|
||||||
func show_search() -> void:
|
func show_search() -> void:
|
||||||
print("show_search")
|
GameLog.debug("show_search")
|
||||||
search_view.toggle()
|
search_view.toggle()
|
||||||
|
|
||||||
|
|
||||||
func show_about() -> void:
|
func show_about() -> void:
|
||||||
print("show_about")
|
GameLog.debug("show_about")
|
||||||
about_window.open()
|
about_window.open()
|
||||||
|
|
||||||
|
|
||||||
func show_shortcuts() -> void:
|
func show_shortcuts() -> void:
|
||||||
print("show_shortcuts")
|
GameLog.debug("show_shortcuts")
|
||||||
shortcuts_window.open()
|
shortcuts_window.open()
|
||||||
|
|
||||||
|
|
||||||
func show_qr() -> void:
|
func show_qr() -> void:
|
||||||
print("show_qr")
|
GameLog.debug("show_qr")
|
||||||
qr_window.open()
|
qr_window.open()
|
||||||
|
|
||||||
|
|
||||||
func get_statistics() -> void:
|
func get_statistics() -> void:
|
||||||
print("get_statistics")
|
GameLog.debug("get_statistics")
|
||||||
statistic_popup.visible = true
|
statistic_popup.visible = true
|
||||||
statistic_label.text = "Total amount of soundtracks in the playlist: " \
|
statistic_label.text = "Total amount of soundtracks in the playlist: " \
|
||||||
+ str(search_view.soundtracks.size())
|
+ str(search_view.soundtracks.size())
|
||||||
|
|
||||||
|
|
||||||
func sync_soundtracks() -> void:
|
func sync_soundtracks() -> void:
|
||||||
print("sync_soundtracks")
|
GameLog.debug("sync_soundtracks")
|
||||||
sync_window.start_sync()
|
sync_window.start_sync()
|
||||||
|
|
||||||
|
|
||||||
func _on_sync_started() -> void:
|
func _on_sync_started() -> void:
|
||||||
print("_on_sync_started")
|
GameLog.debug("_on_sync_started")
|
||||||
top_bar.sync_button.disabled = false
|
top_bar.sync_button.disabled = false
|
||||||
quiz.lock_for_sync()
|
quiz.lock_for_sync()
|
||||||
|
|
||||||
|
|
||||||
func _on_sync_finished() -> void:
|
func _on_sync_finished() -> void:
|
||||||
print("_on_sync_finished")
|
GameLog.debug("_on_sync_finished")
|
||||||
search_view.get_list_of_soundtracks()
|
search_view.get_list_of_soundtracks()
|
||||||
quiz.on_sync_finished()
|
quiz.on_sync_finished()
|
||||||
+5
-5
@@ -91,7 +91,7 @@ func play_or_pause() -> void:
|
|||||||
audio_player.stream_paused = false
|
audio_player.stream_paused = false
|
||||||
song_finished = false
|
song_finished = false
|
||||||
audio_player.seek(playback_position)
|
audio_player.seek(playback_position)
|
||||||
print("continue")
|
GameLog.debug("continue")
|
||||||
progress_slider.max_value = round(stream.get_length())
|
progress_slider.max_value = round(stream.get_length())
|
||||||
if Settings.hide_ticks:
|
if Settings.hide_ticks:
|
||||||
progress_slider.tick_count = 0
|
progress_slider.tick_count = 0
|
||||||
@@ -184,7 +184,7 @@ func play_song(song: AudioStream) -> void:
|
|||||||
music_time_label.text = format_text(progress_slider.value, stream.get_length())
|
music_time_label.text = format_text(progress_slider.value, stream.get_length())
|
||||||
|
|
||||||
func play_song_object(song_object_no: int) -> void:
|
func play_song_object(song_object_no: int) -> void:
|
||||||
print("play_song_object")
|
GameLog.debug("play_song_object")
|
||||||
if audio_player.is_playing():
|
if audio_player.is_playing():
|
||||||
audio_player.stop()
|
audio_player.stop()
|
||||||
await get_tree().create_timer(0.5).timeout
|
await get_tree().create_timer(0.5).timeout
|
||||||
@@ -204,7 +204,7 @@ func play_song_object(song_object_no: int) -> void:
|
|||||||
Playlist.set_currently_playing_song(song_object_no)
|
Playlist.set_currently_playing_song(song_object_no)
|
||||||
Playlist.unset_is_playing()
|
Playlist.unset_is_playing()
|
||||||
if !Settings.hide_next_track:
|
if !Settings.hide_next_track:
|
||||||
print("Show answer now!!")
|
GameLog.debug("Show answer now!!")
|
||||||
Playlist.song_is_answered(song_object_no)
|
Playlist.song_is_answered(song_object_no)
|
||||||
Playlist.song_has_played(song_object_no)
|
Playlist.song_has_played(song_object_no)
|
||||||
Playlist.song_is_playing(song_object_no)
|
Playlist.song_is_playing(song_object_no)
|
||||||
@@ -229,8 +229,8 @@ func load_mp3(_path: String) -> AudioStream:
|
|||||||
func play_local_song() -> void:
|
func play_local_song() -> void:
|
||||||
if songs:
|
if songs:
|
||||||
local_path = songs[0]
|
local_path = songs[0]
|
||||||
print(local_path)
|
GameLog.debug(local_path)
|
||||||
print(FileAccess.file_exists(local_path))
|
GameLog.debug(FileAccess.file_exists(local_path))
|
||||||
play_sound(load_mp3(local_path))
|
play_sound(load_mp3(local_path))
|
||||||
|
|
||||||
func sound_test_local() -> void:
|
func sound_test_local() -> void:
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func change_character() -> void:
|
|||||||
change_character_clicked.emit()
|
change_character_clicked.emit()
|
||||||
|
|
||||||
func new_character_selected(character_texture: ImageTexture) -> void:
|
func new_character_selected(character_texture: ImageTexture) -> void:
|
||||||
print("Back in player list with new")
|
GameLog.debug("Back in player list with new")
|
||||||
player_object.character = character_texture
|
player_object.character = character_texture
|
||||||
set_player_character()
|
set_player_character()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ func _ready() -> void:
|
|||||||
var url: String = Settings.default_path + "/search"
|
var url: String = Settings.default_path + "/search"
|
||||||
qr_code_rect.data = url
|
qr_code_rect.data = url
|
||||||
url_label.text = qr_code_rect.data
|
url_label.text = qr_code_rect.data
|
||||||
print("QR code generated for: ", url)
|
GameLog.debug("QR code generated for: ", url)
|
||||||
|
|
||||||
func open() -> void:
|
func open() -> void:
|
||||||
super()
|
super()
|
||||||
|
|||||||
+3
-3
@@ -39,7 +39,7 @@ func close() -> void:
|
|||||||
super()
|
super()
|
||||||
|
|
||||||
func search() -> void:
|
func search() -> void:
|
||||||
print(search_bar.text)
|
GameLog.debug(search_bar.text)
|
||||||
var search_text: String = search_bar.text
|
var search_text: String = search_bar.text
|
||||||
|
|
||||||
if search_text == "":
|
if search_text == "":
|
||||||
@@ -153,7 +153,7 @@ func check_if_soundtrack_exists(soundtrack: String) -> bool:
|
|||||||
return soundtrack_exists
|
return soundtrack_exists
|
||||||
|
|
||||||
func get_list_of_soundtracks() -> void:
|
func get_list_of_soundtracks() -> void:
|
||||||
print("get_list_of_soundtracks")
|
GameLog.debug("get_list_of_soundtracks")
|
||||||
var handle_soundtracks: Callable = func handle_soundtracks(array) -> void:
|
var handle_soundtracks: Callable = func handle_soundtracks(array) -> void:
|
||||||
if typeof(array) == TYPE_ARRAY:
|
if typeof(array) == TYPE_ARRAY:
|
||||||
# Reuse existing labels: hide all and add to pool
|
# Reuse existing labels: hide all and add to pool
|
||||||
@@ -164,7 +164,7 @@ func get_list_of_soundtracks() -> void:
|
|||||||
for soundtrack: String in soundtracks:
|
for soundtrack: String in soundtracks:
|
||||||
add_soundtrack_reuse(soundtrack)
|
add_soundtrack_reuse(soundtrack)
|
||||||
else:
|
else:
|
||||||
print("Unexpected data")
|
GameLog.warning("Unexpected data")
|
||||||
MusicServerClient.fetch_all_soundtracks_ordered(handle_soundtracks)
|
MusicServerClient.fetch_all_soundtracks_ordered(handle_soundtracks)
|
||||||
|
|
||||||
## Replaces the searchable soundtracks and precomputes their search forms.
|
## Replaces the searchable soundtracks and precomputes their search forms.
|
||||||
|
|||||||
+10
-10
@@ -203,22 +203,22 @@ func increase_hide_for_seconds() -> void:
|
|||||||
hide_for_seconds_label.text = str(Settings.hide_for_seconds)
|
hide_for_seconds_label.text = str(Settings.hide_for_seconds)
|
||||||
|
|
||||||
func select_server(new_server: int) -> void:
|
func select_server(new_server: int) -> void:
|
||||||
print("select_server")
|
GameLog.debug("select_server")
|
||||||
Settings.default_path = select_server_button.get_item_text(new_server)
|
Settings.default_path = select_server_button.get_item_text(new_server)
|
||||||
Settings.selected_server = new_server
|
Settings.selected_server = new_server
|
||||||
print("Settings.default_path: " + Settings.default_path)
|
GameLog.debug("Settings.default_path: " + Settings.default_path)
|
||||||
print("Settings.selected_server: " + str(Settings.selected_server))
|
GameLog.debug("Settings.selected_server: " + str(Settings.selected_server))
|
||||||
print("new_server: " + str(new_server))
|
GameLog.debug("new_server: " + str(new_server))
|
||||||
print("select_server_button.get_item_text(new_server): " + select_server_button.get_item_text(new_server))
|
GameLog.debug("select_server_button.get_item_text(new_server): " + select_server_button.get_item_text(new_server))
|
||||||
server_changed.emit()
|
server_changed.emit()
|
||||||
|
|
||||||
func set_selected_server(new_server: int) -> void:
|
func set_selected_server(new_server: int) -> void:
|
||||||
print("set_selected_server")
|
GameLog.debug("set_selected_server")
|
||||||
select_server_button.select(new_server)
|
select_server_button.select(new_server)
|
||||||
Settings.default_path = select_server_button.get_item_text(new_server)
|
Settings.default_path = select_server_button.get_item_text(new_server)
|
||||||
Settings.selected_server = new_server
|
Settings.selected_server = new_server
|
||||||
print("Settings.default_path: " + Settings.default_path)
|
GameLog.debug("Settings.default_path: " + Settings.default_path)
|
||||||
print("Settings.selected_server: " + str(Settings.selected_server))
|
GameLog.debug("Settings.selected_server: " + str(Settings.selected_server))
|
||||||
print("new_server: " + str(new_server))
|
GameLog.debug("new_server: " + str(new_server))
|
||||||
print("select_server_button.get_item_text(new_server): " + select_server_button.get_item_text(new_server))
|
GameLog.debug("select_server_button.get_item_text(new_server): " + select_server_button.get_item_text(new_server))
|
||||||
server_changed.emit()
|
server_changed.emit()
|
||||||
+2
-2
@@ -42,12 +42,12 @@ func get_song_info() -> String:
|
|||||||
return "??? - ???"
|
return "??? - ???"
|
||||||
|
|
||||||
func add_point(player_id: String) -> void:
|
func add_point(player_id: String) -> void:
|
||||||
print("add_point")
|
GameLog.debug("add_point")
|
||||||
if !players_given_point.has(player_id):
|
if !players_given_point.has(player_id):
|
||||||
players_given_point.append(player_id)
|
players_given_point.append(player_id)
|
||||||
|
|
||||||
func remove_point(player_id: String) -> void:
|
func remove_point(player_id: String) -> void:
|
||||||
print("remove_point")
|
GameLog.debug("remove_point")
|
||||||
players_given_point.erase(player_id)
|
players_given_point.erase(player_id)
|
||||||
|
|
||||||
func _to_string() -> String:
|
func _to_string() -> String:
|
||||||
|
|||||||
+4
-3
@@ -22,10 +22,11 @@ func set_character_name(character_name: String) -> void:
|
|||||||
var img: Image = Image.new()
|
var img: Image = Image.new()
|
||||||
var err: Error = img.load_png_from_buffer(image)
|
var err: Error = img.load_png_from_buffer(image)
|
||||||
if err != OK:
|
if err != OK:
|
||||||
print(err)
|
GameLog.debug("Character image is not a PNG, trying JPG: ", error_string(err))
|
||||||
var err2: Error = img.load_jpg_from_buffer(image)
|
var err2: Error = img.load_jpg_from_buffer(image)
|
||||||
if err2 != OK:
|
if err2 != OK:
|
||||||
print(err2)
|
GameLog.warning("Could not load the image for ", character_name, ": ",
|
||||||
|
error_string(err2))
|
||||||
var new_image: ImageTexture = ImageTexture.new()
|
var new_image: ImageTexture = ImageTexture.new()
|
||||||
new_image.set_image(img)
|
new_image.set_image(img)
|
||||||
character_image.custom_minimum_size = Vector2(200, 100)
|
character_image.custom_minimum_size = Vector2(200, 100)
|
||||||
@@ -42,5 +43,5 @@ func _input(event: InputEvent) -> void:
|
|||||||
if event is InputEventMouseButton && event.is_pressed() && event.get_button_index() == MOUSE_BUTTON_LEFT:
|
if event is InputEventMouseButton && event.is_pressed() && event.get_button_index() == MOUSE_BUTTON_LEFT:
|
||||||
var evLocal: InputEvent = make_input_local(event)
|
var evLocal: InputEvent = make_input_local(event)
|
||||||
if Rect2(Vector2(0, 0), panel.size).has_point(evLocal.position):
|
if Rect2(Vector2(0, 0), panel.size).has_point(evLocal.position):
|
||||||
print(character_name_label.text)
|
GameLog.debug(character_name_label.text)
|
||||||
new_character_selected.emit(character_image.texture)
|
new_character_selected.emit(character_image.texture)
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
extends Node
|
||||||
|
## Writes messages about what the game is doing, for finding problems.
|
||||||
|
##
|
||||||
|
## Registered as the [code]GameLog[/code] autoload. Use [method debug] instead of
|
||||||
|
## [code]print()[/code]: the messages show in debug builds and the editor, and are left
|
||||||
|
## out of released games. Problems the player may notice go through [method warning].
|
||||||
|
|
||||||
|
|
||||||
|
## Prints [param parts] joined together, like [code]print()[/code], in debug builds only.
|
||||||
|
func debug(...parts: Array) -> void:
|
||||||
|
if OS.is_debug_build():
|
||||||
|
print(_join(parts))
|
||||||
|
|
||||||
|
|
||||||
|
## Reports a problem in the editor's debugger and the console, in every build.
|
||||||
|
func warning(...parts: Array) -> void:
|
||||||
|
push_warning(_join(parts))
|
||||||
|
|
||||||
|
|
||||||
|
func _join(parts: Array) -> String:
|
||||||
|
return "".join(parts.map(func(part: Variant) -> String: return str(part)))
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://c37mlo6svk03q
|
||||||
+2
-2
@@ -49,12 +49,12 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
## Fetches every soundtrack from the server and shows them.
|
## Fetches every soundtrack from the server and shows them.
|
||||||
func load_from_server() -> void:
|
func load_from_server() -> void:
|
||||||
print("load_from_server")
|
GameLog.debug("load_from_server")
|
||||||
var populate_list: Callable = func populate_list(array) -> void:
|
var populate_list: Callable = func populate_list(array) -> void:
|
||||||
if typeof(array) == TYPE_ARRAY:
|
if typeof(array) == TYPE_ARRAY:
|
||||||
show_soundtracks(array)
|
show_soundtracks(array)
|
||||||
else:
|
else:
|
||||||
print("Unexpected data")
|
GameLog.warning("Unexpected data")
|
||||||
MusicServerClient.fetch_all_soundtracks(populate_list)
|
MusicServerClient.fetch_all_soundtracks(populate_list)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,18 +22,18 @@ func _ready() -> void:
|
|||||||
close_timer.timeout.connect(_on_close_timeout)
|
close_timer.timeout.connect(_on_close_timeout)
|
||||||
|
|
||||||
func _on_close_timeout() -> void:
|
func _on_close_timeout() -> void:
|
||||||
print("_on_close_timeout!")
|
GameLog.debug("_on_close_timeout!")
|
||||||
Settings.character_select_open = false
|
Settings.character_select_open = false
|
||||||
close_timer.stop()
|
close_timer.stop()
|
||||||
|
|
||||||
func load_characters() -> void:
|
func load_characters() -> void:
|
||||||
print("load_characters")
|
GameLog.debug("load_characters")
|
||||||
var fetch_character_list: Callable = func fetch_character_list(list) -> void:
|
var fetch_character_list: Callable = func fetch_character_list(list) -> void:
|
||||||
print("fetch_character_list")
|
GameLog.debug("fetch_character_list")
|
||||||
Settings.delete_children(character_grid)
|
Settings.delete_children(character_grid)
|
||||||
if typeof(list) == TYPE_ARRAY:
|
if typeof(list) == TYPE_ARRAY:
|
||||||
for character_name: String in list:
|
for character_name: String in list:
|
||||||
print("character_name ", character_name)
|
GameLog.debug("character_name ", character_name)
|
||||||
var character_box: Character = character.instantiate()
|
var character_box: Character = character.instantiate()
|
||||||
character_grid.add_child(character_box)
|
character_grid.add_child(character_box)
|
||||||
character_box.custom_minimum_size = Vector2(235, 145)
|
character_box.custom_minimum_size = Vector2(235, 145)
|
||||||
@@ -43,7 +43,7 @@ func load_characters() -> void:
|
|||||||
MusicServerClient.fetch_character_list(fetch_character_list)
|
MusicServerClient.fetch_character_list(fetch_character_list)
|
||||||
|
|
||||||
func show_grid(player_name: String) -> void:
|
func show_grid(player_name: String) -> void:
|
||||||
print("show_grid")
|
GameLog.debug("show_grid")
|
||||||
title_label.text = "Select character for " + player_name
|
title_label.text = "Select character for " + player_name
|
||||||
close_timer.stop()
|
close_timer.stop()
|
||||||
open()
|
open()
|
||||||
@@ -55,7 +55,7 @@ func close() -> void:
|
|||||||
Settings.character_select_open = false
|
Settings.character_select_open = false
|
||||||
|
|
||||||
func _on_character_selected(texture: ImageTexture) -> void:
|
func _on_character_selected(texture: ImageTexture) -> void:
|
||||||
print("_on_character_selected")
|
GameLog.debug("_on_character_selected")
|
||||||
# Not close(): character_select_open stays true until close_timer fires, so the click
|
# Not close(): character_select_open stays true until close_timer fires, so the click
|
||||||
# that picked the character does not also select a song behind it
|
# that picked the character does not also select a song behind it
|
||||||
self.visible = false
|
self.visible = false
|
||||||
|
|||||||
+5
-5
@@ -41,7 +41,7 @@ func _ready() -> void:
|
|||||||
|
|
||||||
## Shows or hides the row for adding players, and the buttons for removing them.
|
## Shows or hides the row for adding players, and the buttons for removing them.
|
||||||
func add_players() -> void:
|
func add_players() -> void:
|
||||||
print("add_players")
|
GameLog.debug("add_players")
|
||||||
Settings.edit_players = !Settings.edit_players
|
Settings.edit_players = !Settings.edit_players
|
||||||
add_player_container.visible = !add_player_container.visible
|
add_player_container.visible = !add_player_container.visible
|
||||||
new_player_name_field.grab_focus()
|
new_player_name_field.grab_focus()
|
||||||
@@ -50,7 +50,7 @@ func add_players() -> void:
|
|||||||
## Adds a player with the name in the name field, unless it is empty or there are
|
## Adds a player with the name in the name field, unless it is empty or there are
|
||||||
## already as many players as there can be.
|
## already as many players as there can be.
|
||||||
func add_player() -> void:
|
func add_player() -> void:
|
||||||
print("add_player")
|
GameLog.debug("add_player")
|
||||||
if new_player_name_field.text != "" && Settings.player_array.size() < Settings.MAX_NUMBER_OF_PLAYERS:
|
if new_player_name_field.text != "" && Settings.player_array.size() < Settings.MAX_NUMBER_OF_PLAYERS:
|
||||||
var new_player_object: PlayerObject = PlayerObject.new(new_player_name_field.text)
|
var new_player_object: PlayerObject = PlayerObject.new(new_player_name_field.text)
|
||||||
new_player_name_field.text = ""
|
new_player_name_field.text = ""
|
||||||
@@ -62,11 +62,11 @@ func add_player() -> void:
|
|||||||
## Shows the players in [code]Settings.player_array[/code] again, e.g. after their
|
## Shows the players in [code]Settings.player_array[/code] again, e.g. after their
|
||||||
## points were reset.
|
## points were reset.
|
||||||
func reload() -> void:
|
func reload() -> void:
|
||||||
print("load_players")
|
GameLog.debug("load_players")
|
||||||
Settings.delete_children(players_list_container)
|
Settings.delete_children(players_list_container)
|
||||||
var counter: int = 0
|
var counter: int = 0
|
||||||
for player_object: PlayerObject in Settings.player_array:
|
for player_object: PlayerObject in Settings.player_array:
|
||||||
print(player_object.player_name)
|
GameLog.debug(player_object.player_name)
|
||||||
|
|
||||||
var new_player: Player = _player_row.instantiate()
|
var new_player: Player = _player_row.instantiate()
|
||||||
new_player.player_object = player_object
|
new_player.player_object = player_object
|
||||||
@@ -84,7 +84,7 @@ func _on_change_character_clicked(row: Player, player_name: String) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_player_removed(player_object: PlayerObject) -> void:
|
func _on_player_removed(player_object: PlayerObject) -> void:
|
||||||
print("_on_player_removed ", player_object.player_name)
|
GameLog.debug("_on_player_removed ", player_object.player_name)
|
||||||
Settings.player_array.erase(player_object)
|
Settings.player_array.erase(player_object)
|
||||||
reload()
|
reload()
|
||||||
player_removed.emit(player_object)
|
player_removed.emit(player_object)
|
||||||
+2
-2
@@ -35,10 +35,10 @@ 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
|
# Nothing is playing yet (-1); a negative index would answer the last, unplayed song
|
||||||
if song_no < 0 || song_no >= song_object_array.size():
|
if song_no < 0 || song_no >= song_object_array.size():
|
||||||
return
|
return
|
||||||
print("show_answer_pressed song_object: ", song_object_array[song_no]._to_string())
|
GameLog.debug("show_answer_pressed song_object: ", song_object_array[song_no]._to_string())
|
||||||
song_object_array[song_no].is_answered = true
|
song_object_array[song_no].is_answered = true
|
||||||
if Settings.add_to_stats:
|
if Settings.add_to_stats:
|
||||||
print("add to stats: ", song_no)
|
GameLog.debug("add to stats: ", song_no)
|
||||||
MusicServerClient.mark_song_played(song_no)
|
MusicServerClient.mark_song_played(song_no)
|
||||||
|
|
||||||
func add_to_playlist(new_song_object: SongObject) -> void:
|
func add_to_playlist(new_song_object: SongObject) -> void:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ config/icon="res://icon.svg"
|
|||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
|
GameLog="*res://game_log.gd"
|
||||||
Settings="*res://Settings.gd"
|
Settings="*res://Settings.gd"
|
||||||
Playlist="*res://playlist.gd"
|
Playlist="*res://playlist.gd"
|
||||||
MusicServerClient="*res://music_server_client.gd"
|
MusicServerClient="*res://music_server_client.gd"
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ var popup_backdrop: PopupBackdrop
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
popup_backdrop = PopupBackdrop.add_to(self, _popups())
|
popup_backdrop = PopupBackdrop.add_to(self, _popups())
|
||||||
if OS.has_feature("debug"):
|
if OS.has_feature("debug"):
|
||||||
print("is_debug")
|
GameLog.debug("is_debug")
|
||||||
debug_label.visible = true
|
debug_label.visible = true
|
||||||
Settings.is_debug = true
|
Settings.is_debug = true
|
||||||
settings_window.set_winning_score(5)
|
settings_window.set_winning_score(5)
|
||||||
@@ -103,19 +103,19 @@ func _ready() -> void:
|
|||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event is InputEventKey and event.pressed:
|
if event is InputEventKey and event.pressed:
|
||||||
if event.alt_pressed && event.keycode == KEY_UP:
|
if event.alt_pressed && event.keycode == KEY_UP:
|
||||||
print("Alt + UP pressed")
|
GameLog.debug("Alt + UP pressed")
|
||||||
music_player_container.change_volume(0.05)
|
music_player_container.change_volume(0.05)
|
||||||
if event.alt_pressed && event.keycode == KEY_DOWN:
|
if event.alt_pressed && event.keycode == KEY_DOWN:
|
||||||
print("Alt + DOWN pressed")
|
GameLog.debug("Alt + DOWN pressed")
|
||||||
music_player_container.change_volume(-0.05)
|
music_player_container.change_volume(-0.05)
|
||||||
if event.alt_pressed && event.ctrl_pressed && event.keycode == KEY_LEFT:
|
if event.alt_pressed && event.ctrl_pressed && event.keycode == KEY_LEFT:
|
||||||
print("Ctrl + Alt + LEFT pressed")
|
GameLog.debug("Ctrl + Alt + LEFT pressed")
|
||||||
music_player_container.restart()
|
music_player_container.restart()
|
||||||
elif event.alt_pressed && event.keycode == KEY_LEFT:
|
elif event.alt_pressed && event.keycode == KEY_LEFT:
|
||||||
print("Alt + LEFT pressed")
|
GameLog.debug("Alt + LEFT pressed")
|
||||||
music_player_container.seek(-5)
|
music_player_container.seek(-5)
|
||||||
if event.alt_pressed && event.keycode == KEY_RIGHT:
|
if event.alt_pressed && event.keycode == KEY_RIGHT:
|
||||||
print("Alt + RIGHT pressed")
|
GameLog.debug("Alt + RIGHT pressed")
|
||||||
music_player_container.seek(5)
|
music_player_container.seek(5)
|
||||||
|
|
||||||
|
|
||||||
@@ -135,27 +135,27 @@ func on_sync_finished() -> void:
|
|||||||
|
|
||||||
## Reloads the soundtracks, playlist and characters from the server.
|
## Reloads the soundtracks, playlist and characters from the server.
|
||||||
func refresh_from_server() -> void:
|
func refresh_from_server() -> void:
|
||||||
print("refresh_from_server")
|
GameLog.debug("refresh_from_server")
|
||||||
inspiration_list.load_from_server()
|
inspiration_list.load_from_server()
|
||||||
reset_playlist()
|
reset_playlist()
|
||||||
new_character_select.load_characters()
|
new_character_select.load_characters()
|
||||||
|
|
||||||
|
|
||||||
func _on_server_changed() -> void:
|
func _on_server_changed() -> void:
|
||||||
print("_on_server_changed")
|
GameLog.debug("_on_server_changed")
|
||||||
refresh_from_server()
|
refresh_from_server()
|
||||||
reset_points()
|
reset_points()
|
||||||
server_changed.emit()
|
server_changed.emit()
|
||||||
|
|
||||||
|
|
||||||
func show_answer_pressed() -> void:
|
func show_answer_pressed() -> void:
|
||||||
print("show_answer_pressed")
|
GameLog.debug("show_answer_pressed")
|
||||||
Playlist.song_is_answered()
|
Playlist.song_is_answered()
|
||||||
update_song_list()
|
update_song_list()
|
||||||
|
|
||||||
|
|
||||||
func play_next_song() -> void:
|
func play_next_song() -> void:
|
||||||
print("play_next_song ", Playlist.latest_played_song)
|
GameLog.debug("play_next_song ", Playlist.latest_played_song)
|
||||||
if Playlist.first_song_played:
|
if Playlist.first_song_played:
|
||||||
Playlist.set_latest_played_song()
|
Playlist.set_latest_played_song()
|
||||||
Playlist.first_song_played = true
|
Playlist.first_song_played = true
|
||||||
@@ -183,7 +183,7 @@ func _on_song_added() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func update_song_list() -> void:
|
func update_song_list() -> void:
|
||||||
print("update_song_list")
|
GameLog.debug("update_song_list")
|
||||||
if Playlist.currently_playing_song >= 0:
|
if Playlist.currently_playing_song >= 0:
|
||||||
now_playing.show_song(Playlist.get_current_soundtrack_title(),
|
now_playing.show_song(Playlist.get_current_soundtrack_title(),
|
||||||
Playlist.get_current_song_title())
|
Playlist.get_current_song_title())
|
||||||
@@ -191,10 +191,10 @@ func update_song_list() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func song_object_clicked(song_no: int) -> void:
|
func song_object_clicked(song_no: int) -> void:
|
||||||
print("Clicked Song Object: ", Playlist.song_object_array[song_no].to_string())
|
GameLog.debug("Clicked Song Object: ", Playlist.song_object_array[song_no].to_string())
|
||||||
if Settings.character_select_open == false:
|
if Settings.character_select_open == false:
|
||||||
if Playlist.get_song(song_no) == null:
|
if Playlist.get_song(song_no) == null:
|
||||||
print("has no song, need to download")
|
GameLog.debug("has no song, need to download")
|
||||||
var song_downloaded: Callable = func song_downloaded(body: PackedByteArray) -> void:
|
var song_downloaded: Callable = func song_downloaded(body: PackedByteArray) -> void:
|
||||||
var sound: AudioStream = AudioStreamMP3.new()
|
var sound: AudioStream = AudioStreamMP3.new()
|
||||||
sound.data = body
|
sound.data = body
|
||||||
@@ -202,12 +202,12 @@ func song_object_clicked(song_no: int) -> void:
|
|||||||
music_player_container.play_song_object(song_no)
|
music_player_container.play_song_object(song_no)
|
||||||
MusicServerClient.fetch_song(song_no, song_downloaded)
|
MusicServerClient.fetch_song(song_no, song_downloaded)
|
||||||
else:
|
else:
|
||||||
print("song already downloaded")
|
GameLog.debug("song already downloaded")
|
||||||
music_player_container.play_song_object(song_no)
|
music_player_container.play_song_object(song_no)
|
||||||
|
|
||||||
|
|
||||||
func reset_playlist() -> void:
|
func reset_playlist() -> void:
|
||||||
print("reset_playlist")
|
GameLog.debug("reset_playlist")
|
||||||
var playlist_reset_done: Callable = func playlist_reset_done() -> void:
|
var playlist_reset_done: Callable = func playlist_reset_done() -> void:
|
||||||
Playlist.reset_playlist()
|
Playlist.reset_playlist()
|
||||||
song_loader.load_song_list()
|
song_loader.load_song_list()
|
||||||
@@ -216,7 +216,7 @@ func reset_playlist() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func reset_points() -> void:
|
func reset_points() -> void:
|
||||||
print("reset_points")
|
GameLog.debug("reset_points")
|
||||||
for player_objects: PlayerObject in Settings.player_array:
|
for player_objects: PlayerObject in Settings.player_array:
|
||||||
player_objects.reset_points()
|
player_objects.reset_points()
|
||||||
players_panel.reload()
|
players_panel.reload()
|
||||||
@@ -227,7 +227,7 @@ func reset_points() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func show_settings() -> void:
|
func show_settings() -> void:
|
||||||
print("show_settings")
|
GameLog.debug("show_settings")
|
||||||
settings_window.open()
|
settings_window.open()
|
||||||
|
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ func _on_player_added(new_player_object: PlayerObject) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_point_given(player_object: PlayerObject) -> void:
|
func _on_point_given(player_object: PlayerObject) -> void:
|
||||||
print("_on_point_given")
|
GameLog.debug("_on_point_given")
|
||||||
event_logged.emit(player_object.player_name + " got a point")
|
event_logged.emit(player_object.player_name + " got a point")
|
||||||
if Playlist.currently_playing_song >= 0:
|
if Playlist.currently_playing_song >= 0:
|
||||||
Playlist.add_point(player_object.id)
|
Playlist.add_point(player_object.id)
|
||||||
@@ -254,7 +254,7 @@ func _on_make_point_given_sound() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_point_taken(player_object: PlayerObject) -> void:
|
func _on_point_taken(player_object: PlayerObject) -> void:
|
||||||
print("_on_point_taken")
|
GameLog.debug("_on_point_taken")
|
||||||
event_logged.emit(player_object.player_name + " lost a point")
|
event_logged.emit(player_object.player_name + " lost a point")
|
||||||
music_player_container.play_sound_effect(preload("res://sounds/itemequip.wav"))
|
music_player_container.play_sound_effect(preload("res://sounds/itemequip.wav"))
|
||||||
if Playlist.currently_playing_song >= 0:
|
if Playlist.currently_playing_song >= 0:
|
||||||
@@ -263,7 +263,7 @@ func _on_point_taken(player_object: PlayerObject) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_player_won(player_object: PlayerObject) -> void:
|
func _on_player_won(player_object: PlayerObject) -> void:
|
||||||
print("_on_player_won")
|
GameLog.debug("_on_player_won")
|
||||||
winner_window.show_winner(player_object)
|
winner_window.show_winner(player_object)
|
||||||
music_player_container.play_song(preload("res://sounds/winning.mp3"))
|
music_player_container.play_song(preload("res://sounds/winning.mp3"))
|
||||||
# Songs played after the game is won don't count towards the statistics
|
# Songs played after the game is won don't count towards the statistics
|
||||||
@@ -278,14 +278,14 @@ func _on_player_removed(player_object: PlayerObject) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_player_change_character_clicked(new_player: Player, player_name: String) -> void:
|
func _on_player_change_character_clicked(new_player: Player, player_name: String) -> void:
|
||||||
print("_on_player_change_character_clicked")
|
GameLog.debug("_on_player_change_character_clicked")
|
||||||
current_player = new_player
|
current_player = new_player
|
||||||
print("Change character for: " + player_name)
|
GameLog.debug("Change character for: " + player_name)
|
||||||
new_character_select.show_grid(player_name)
|
new_character_select.show_grid(player_name)
|
||||||
|
|
||||||
|
|
||||||
func _on_new_character_selected(character_texture: ImageTexture) -> void:
|
func _on_new_character_selected(character_texture: ImageTexture) -> void:
|
||||||
print("_on_new_character_selected")
|
GameLog.debug("_on_new_character_selected")
|
||||||
current_player.new_character_selected(character_texture)
|
current_player.new_character_selected(character_texture)
|
||||||
|
|
||||||
|
|
||||||
@@ -298,7 +298,7 @@ func open() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_file_dialog_dir_selected(path: String) -> void:
|
func _on_file_dialog_dir_selected(path: String) -> void:
|
||||||
print(path)
|
GameLog.debug(path)
|
||||||
dir_contents(path)
|
dir_contents(path)
|
||||||
|
|
||||||
|
|
||||||
@@ -311,13 +311,13 @@ func dir_contents(path: String) -> void:
|
|||||||
var soundtracks: Array = []
|
var soundtracks: Array = []
|
||||||
while file_name != "":
|
while file_name != "":
|
||||||
if dir.current_is_dir():
|
if dir.current_is_dir():
|
||||||
#print("Found directory: " + file_name)
|
#GameLog.debug("Found directory: " + file_name)
|
||||||
soundtracks.append(file_name)
|
soundtracks.append(file_name)
|
||||||
else:
|
else:
|
||||||
#print("Found file: " + file_name)
|
#GameLog.debug("Found file: " + file_name)
|
||||||
if file_name.ends_with(".mp3"):
|
if file_name.ends_with(".mp3"):
|
||||||
songs.append(path + "/" + file_name)
|
songs.append(path + "/" + file_name)
|
||||||
file_name = dir.get_next()
|
file_name = dir.get_next()
|
||||||
inspiration_list.show_soundtracks(soundtracks)
|
inspiration_list.show_soundtracks(soundtracks)
|
||||||
else:
|
else:
|
||||||
print("An error occurred when trying to access the path.")
|
GameLog.warning("An error occurred when trying to access the path.")
|
||||||
+7
-7
@@ -20,7 +20,7 @@ var retry_seconds: float = 5.0
|
|||||||
## Loads the songs already in the server playlist, then starts preloading new ones.
|
## Loads the songs already in the server playlist, then starts preloading new ones.
|
||||||
## Preloading waits for the list, because loading the list clears the playlist.
|
## Preloading waits for the list, because loading the list clears the playlist.
|
||||||
func load_song_list() -> void:
|
func load_song_list() -> void:
|
||||||
print("load_song_list")
|
GameLog.debug("load_song_list")
|
||||||
var song_list_fetched: Callable = func song_list_fetched(data) -> void:
|
var song_list_fetched: Callable = func song_list_fetched(data) -> void:
|
||||||
Playlist.clear_song_list()
|
Playlist.clear_song_list()
|
||||||
if typeof(data) == TYPE_ARRAY:
|
if typeof(data) == TYPE_ARRAY:
|
||||||
@@ -33,7 +33,7 @@ func load_song_list() -> void:
|
|||||||
new_song_object.has_played = true
|
new_song_object.has_played = true
|
||||||
Playlist.add_to_playlist(new_song_object)
|
Playlist.add_to_playlist(new_song_object)
|
||||||
elif data != null:
|
elif data != null:
|
||||||
print("Unexpected data")
|
GameLog.warning("Unexpected data")
|
||||||
Playlist.update_last_played_song()
|
Playlist.update_last_played_song()
|
||||||
song_list_loaded.emit()
|
song_list_loaded.emit()
|
||||||
fetch_song_if_idle()
|
fetch_song_if_idle()
|
||||||
@@ -42,7 +42,7 @@ func load_song_list() -> void:
|
|||||||
|
|
||||||
## Starts downloading one more song, which keeps downloading until the cache is full.
|
## Starts downloading one more song, which keeps downloading until the cache is full.
|
||||||
func fetch_song() -> void:
|
func fetch_song() -> void:
|
||||||
print("fetch_song")
|
GameLog.debug("fetch_song")
|
||||||
Playlist.is_song_downloading = true
|
Playlist.is_song_downloading = true
|
||||||
_download_random_song(SongObject.new())
|
_download_random_song(SongObject.new())
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ func fill_cache() -> void:
|
|||||||
# the server and the game keep the same songs in their playlists.
|
# the server and the game keep the same songs in their playlists.
|
||||||
func _download_random_song(new_song_object: SongObject) -> void:
|
func _download_random_song(new_song_object: SongObject) -> void:
|
||||||
var song_downloaded: Callable = func song_downloaded(body: PackedByteArray) -> void:
|
var song_downloaded: Callable = func song_downloaded(body: PackedByteArray) -> void:
|
||||||
print("song_downloaded")
|
GameLog.debug("song_downloaded")
|
||||||
var sound: AudioStream = AudioStreamMP3.new()
|
var sound: AudioStream = AudioStreamMP3.new()
|
||||||
sound.data = body
|
sound.data = body
|
||||||
new_song_object.song = sound
|
new_song_object.song = sound
|
||||||
@@ -80,11 +80,11 @@ func _add_song_to_queue(new_song_object: SongObject) -> void:
|
|||||||
|
|
||||||
func _fetch_song_info(new_song_object: SongObject) -> void:
|
func _fetch_song_info(new_song_object: SongObject) -> void:
|
||||||
var song_info_fetched: Callable = func song_info_fetched(data_received: Dictionary) -> void:
|
var song_info_fetched: Callable = func song_info_fetched(data_received: Dictionary) -> void:
|
||||||
print("song_info_fetched")
|
GameLog.debug("song_info_fetched")
|
||||||
new_song_object.song_number = data_received.SongNo
|
new_song_object.song_number = data_received.SongNo
|
||||||
new_song_object.soundtrack_title = data_received.Soundtrack
|
new_song_object.soundtrack_title = data_received.Soundtrack
|
||||||
new_song_object.song_title = data_received.Song
|
new_song_object.song_title = data_received.Song
|
||||||
print("new_song_object: ", new_song_object.to_string())
|
GameLog.debug("new_song_object: ", new_song_object.to_string())
|
||||||
Playlist.add_to_playlist(new_song_object)
|
Playlist.add_to_playlist(new_song_object)
|
||||||
if Playlist.should_preload_more_songs():
|
if Playlist.should_preload_more_songs():
|
||||||
fetch_song()
|
fetch_song()
|
||||||
@@ -96,5 +96,5 @@ func _fetch_song_info(new_song_object: SongObject) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _retry_later(step: Callable) -> void:
|
func _retry_later(step: Callable) -> void:
|
||||||
print("Song download failed, retrying in %s seconds" % retry_seconds)
|
GameLog.warning("Song download failed, retrying in %s seconds" % retry_seconds)
|
||||||
get_tree().create_timer(retry_seconds).timeout.connect(step)
|
get_tree().create_timer(retry_seconds).timeout.connect(step)
|
||||||
+5
-5
@@ -83,7 +83,7 @@ func show_section_if_has_data(data: Variant, vbox: VBoxContainer, separator: VSe
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
func start_sync() -> void:
|
func start_sync() -> void:
|
||||||
print("start_sync")
|
GameLog.debug("start_sync")
|
||||||
self.visible = true
|
self.visible = true
|
||||||
if has_synced:
|
if has_synced:
|
||||||
# Already synced, just show the results
|
# Already synced, just show the results
|
||||||
@@ -98,10 +98,10 @@ func start_sync() -> void:
|
|||||||
MusicServerClient.start_sync(sync_request_sent)
|
MusicServerClient.start_sync(sync_request_sent)
|
||||||
|
|
||||||
func _on_sync_timeout() -> void:
|
func _on_sync_timeout() -> void:
|
||||||
print("_on_sync_timeout!")
|
GameLog.debug("_on_sync_timeout!")
|
||||||
var get_progress: Callable = func get_progress(data_received: Dictionary) -> void:
|
var get_progress: Callable = func get_progress(data_received: Dictionary) -> void:
|
||||||
print("get_progress")
|
GameLog.debug("get_progress")
|
||||||
print("data_received: ", data_received)
|
GameLog.debug("data_received: ", data_received)
|
||||||
if data_received != null:
|
if data_received != null:
|
||||||
if data_received.has("progress"):
|
if data_received.has("progress"):
|
||||||
sync_progress_bar.value = int(data_received.progress)
|
sync_progress_bar.value = int(data_received.progress)
|
||||||
@@ -176,7 +176,7 @@ func on_sync_finished(data_received: Dictionary) -> void:
|
|||||||
sync_time.text = "Total time: " + data_received.total_time if data_received.has("total_time") else ""
|
sync_time.text = "Total time: " + data_received.total_time if data_received.has("total_time") else ""
|
||||||
Settings.currently_syncing = false
|
Settings.currently_syncing = false
|
||||||
sync_timer.stop()
|
sync_timer.stop()
|
||||||
print("sync finished")
|
GameLog.debug("sync finished")
|
||||||
show_sync_result()
|
show_sync_result()
|
||||||
restart_sync_button.visible = true
|
restart_sync_button.visible = true
|
||||||
sync_finished.emit()
|
sync_finished.emit()
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
extends GdUnitTestSuite
|
||||||
|
## GameLog joins its arguments like print() does.
|
||||||
|
|
||||||
|
|
||||||
|
func test_joins_parts_without_spaces_like_print() -> void:
|
||||||
|
assert_str(GameLog._join(["Song ", 3, " of ", 10.5])).is_equal("Song 3 of 10.5")
|
||||||
|
|
||||||
|
|
||||||
|
func test_joins_any_kind_of_value() -> void:
|
||||||
|
assert_str(GameLog._join([null, true, [1, 2], {"a": 1}])) \
|
||||||
|
.is_equal("<null>true[1, 2]{ \"a\": 1 }")
|
||||||
|
|
||||||
|
|
||||||
|
func test_no_parts_gives_an_empty_line() -> void:
|
||||||
|
assert_str(GameLog._join([])).is_empty()
|
||||||
|
|
||||||
|
|
||||||
|
func test_debug_takes_any_number_of_arguments() -> void:
|
||||||
|
GameLog.debug()
|
||||||
|
GameLog.debug("one")
|
||||||
|
GameLog.debug("one", 2, Vector2.ONE)
|
||||||
|
# Reaching this line means none of the calls failed
|
||||||
|
assert_bool(true).is_true()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://delnqk8yt0hes
|
||||||
Reference in new issue
Block a user