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
@@ -69,7 +69,7 @@ var popup_backdrop: PopupBackdrop
|
||||
func _ready() -> void:
|
||||
popup_backdrop = PopupBackdrop.add_to(self, _popups())
|
||||
if OS.has_feature("debug"):
|
||||
print("is_debug")
|
||||
GameLog.debug("is_debug")
|
||||
debug_label.visible = true
|
||||
Settings.is_debug = true
|
||||
settings_window.set_winning_score(5)
|
||||
@@ -103,19 +103,19 @@ func _ready() -> void:
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.alt_pressed && event.keycode == KEY_UP:
|
||||
print("Alt + UP pressed")
|
||||
GameLog.debug("Alt + UP pressed")
|
||||
music_player_container.change_volume(0.05)
|
||||
if event.alt_pressed && event.keycode == KEY_DOWN:
|
||||
print("Alt + DOWN pressed")
|
||||
GameLog.debug("Alt + DOWN pressed")
|
||||
music_player_container.change_volume(-0.05)
|
||||
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()
|
||||
elif event.alt_pressed && event.keycode == KEY_LEFT:
|
||||
print("Alt + LEFT pressed")
|
||||
GameLog.debug("Alt + LEFT pressed")
|
||||
music_player_container.seek(-5)
|
||||
if event.alt_pressed && event.keycode == KEY_RIGHT:
|
||||
print("Alt + RIGHT pressed")
|
||||
GameLog.debug("Alt + RIGHT pressed")
|
||||
music_player_container.seek(5)
|
||||
|
||||
|
||||
@@ -135,27 +135,27 @@ func on_sync_finished() -> void:
|
||||
|
||||
## Reloads the soundtracks, playlist and characters from the server.
|
||||
func refresh_from_server() -> void:
|
||||
print("refresh_from_server")
|
||||
GameLog.debug("refresh_from_server")
|
||||
inspiration_list.load_from_server()
|
||||
reset_playlist()
|
||||
new_character_select.load_characters()
|
||||
|
||||
|
||||
func _on_server_changed() -> void:
|
||||
print("_on_server_changed")
|
||||
GameLog.debug("_on_server_changed")
|
||||
refresh_from_server()
|
||||
reset_points()
|
||||
server_changed.emit()
|
||||
|
||||
|
||||
func show_answer_pressed() -> void:
|
||||
print("show_answer_pressed")
|
||||
GameLog.debug("show_answer_pressed")
|
||||
Playlist.song_is_answered()
|
||||
update_song_list()
|
||||
|
||||
|
||||
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:
|
||||
Playlist.set_latest_played_song()
|
||||
Playlist.first_song_played = true
|
||||
@@ -183,7 +183,7 @@ func _on_song_added() -> void:
|
||||
|
||||
|
||||
func update_song_list() -> void:
|
||||
print("update_song_list")
|
||||
GameLog.debug("update_song_list")
|
||||
if Playlist.currently_playing_song >= 0:
|
||||
now_playing.show_song(Playlist.get_current_soundtrack_title(),
|
||||
Playlist.get_current_song_title())
|
||||
@@ -191,10 +191,10 @@ func update_song_list() -> 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 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 sound: AudioStream = AudioStreamMP3.new()
|
||||
sound.data = body
|
||||
@@ -202,12 +202,12 @@ func song_object_clicked(song_no: int) -> void:
|
||||
music_player_container.play_song_object(song_no)
|
||||
MusicServerClient.fetch_song(song_no, song_downloaded)
|
||||
else:
|
||||
print("song already downloaded")
|
||||
GameLog.debug("song already downloaded")
|
||||
music_player_container.play_song_object(song_no)
|
||||
|
||||
|
||||
func reset_playlist() -> void:
|
||||
print("reset_playlist")
|
||||
GameLog.debug("reset_playlist")
|
||||
var playlist_reset_done: Callable = func playlist_reset_done() -> void:
|
||||
Playlist.reset_playlist()
|
||||
song_loader.load_song_list()
|
||||
@@ -216,7 +216,7 @@ func reset_playlist() -> void:
|
||||
|
||||
|
||||
func reset_points() -> void:
|
||||
print("reset_points")
|
||||
GameLog.debug("reset_points")
|
||||
for player_objects: PlayerObject in Settings.player_array:
|
||||
player_objects.reset_points()
|
||||
players_panel.reload()
|
||||
@@ -227,7 +227,7 @@ func reset_points() -> void:
|
||||
|
||||
|
||||
func show_settings() -> void:
|
||||
print("show_settings")
|
||||
GameLog.debug("show_settings")
|
||||
settings_window.open()
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ func _on_player_added(new_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")
|
||||
if Playlist.currently_playing_song >= 0:
|
||||
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:
|
||||
print("_on_point_taken")
|
||||
GameLog.debug("_on_point_taken")
|
||||
event_logged.emit(player_object.player_name + " lost a point")
|
||||
music_player_container.play_sound_effect(preload("res://sounds/itemequip.wav"))
|
||||
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:
|
||||
print("_on_player_won")
|
||||
GameLog.debug("_on_player_won")
|
||||
winner_window.show_winner(player_object)
|
||||
music_player_container.play_song(preload("res://sounds/winning.mp3"))
|
||||
# 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:
|
||||
print("_on_player_change_character_clicked")
|
||||
GameLog.debug("_on_player_change_character_clicked")
|
||||
current_player = new_player
|
||||
print("Change character for: " + player_name)
|
||||
GameLog.debug("Change character for: " + player_name)
|
||||
new_character_select.show_grid(player_name)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ func open() -> void:
|
||||
|
||||
|
||||
func _on_file_dialog_dir_selected(path: String) -> void:
|
||||
print(path)
|
||||
GameLog.debug(path)
|
||||
dir_contents(path)
|
||||
|
||||
|
||||
@@ -311,13 +311,13 @@ func dir_contents(path: String) -> void:
|
||||
var soundtracks: Array = []
|
||||
while file_name != "":
|
||||
if dir.current_is_dir():
|
||||
#print("Found directory: " + file_name)
|
||||
#GameLog.debug("Found directory: " + file_name)
|
||||
soundtracks.append(file_name)
|
||||
else:
|
||||
#print("Found file: " + file_name)
|
||||
#GameLog.debug("Found file: " + file_name)
|
||||
if file_name.ends_with(".mp3"):
|
||||
songs.append(path + "/" + file_name)
|
||||
file_name = dir.get_next()
|
||||
inspiration_list.show_soundtracks(soundtracks)
|
||||
else:
|
||||
print("An error occurred when trying to access the path.")
|
||||
GameLog.warning("An error occurred when trying to access the path.")
|
||||
Reference in new issue
Block a user