From 3e4d417b4f6ac715779c25557a455fa9f17e78a9 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 24 Aug 2025 12:00:29 +0200 Subject: [PATCH] #1: Fixed bug with inspiration list and search list not updating on sync and server changed --- MainWindow.gd | 26 ++++++++++++++++++++++---- MainWindow.tscn | 14 +++++++++++++- SearchWindow.gd | 2 ++ Settings.gd | 8 ++++---- SettingsWindow.gd | 6 ++++++ SettingsWindow.tscn | 14 ++++++++------ 6 files changed, 55 insertions(+), 15 deletions(-) diff --git a/MainWindow.gd b/MainWindow.gd index 37f53a5..35d5057 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -63,6 +63,9 @@ var settings_button: Button = $SettingsButton @onready var settings_popup: PopupPanel = $SettingsPopupPanel +@onready +var settings_window: BoxContainer = $SettingsPopupPanel/SettingsWindow + @onready var statistics_button: Button = $StatisticsButton @@ -129,6 +132,9 @@ var auto_repeat_song_button: CheckButton = $RepeatSongCheckButton @onready var music_player_container: PanelContainer = $MusicPlayer +@onready +var debug_label: Label = $DebugLabel + var player := preload("res://Player.tscn") var song_list_object := preload("res://song_list_object.tscn") @@ -142,6 +148,7 @@ func _ready() -> void: var is_mac: bool = OS.has_feature("macos") if is_debug: print("is_debug") + debug_label.visible = true ##Settings.default_path = "http://localhost:8080" ##Settings.selected_server = 3 Settings.default_path = "http://localhost:8080" @@ -164,6 +171,7 @@ func _ready() -> void: new_player_name_field.connect("enter_key_pressed", add_player) music_player_container.connect("play_next_song", fetch_song.bind(false)) music_player_container.connect("update_song_list", update_song_list) + settings_window.connect("server_changed", server_updated) add_players_button.pressed.connect(add_players) add_player_button.pressed.connect(add_player) @@ -199,6 +207,17 @@ func _input(event: InputEvent) -> void: if Settings.fullscreen == false: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) +func server_updated() -> void: + print("server_updated") + update_from_server() + reset_playlist() + reset_points() + +func update_from_server() -> void: + print("update_from_server") + search_view.get_list_of_games() + get_suggestion_list() + func repeat_song() -> void: Settings.auto_repeat_song = !Settings.auto_repeat_song @@ -349,8 +368,7 @@ func sync_games() -> void: sync_popup.visible = true print("games_synced") reset_playlist() - get_suggestion_list() - search_view.get_list_of_games() + update_from_server() var new_games_synced: Callable = func new_games_synced(synced) -> void: sync_button.disabled = false @@ -358,8 +376,7 @@ func sync_games() -> void: print("games_synced") print("synced: ", synced) reset_playlist() - get_suggestion_list() - search_view.get_list_of_games() + update_from_server() if Settings.quick_sync == true: Settings.make_request2("/sync/new", new_games_synced, true) @@ -371,6 +388,7 @@ func get_suggestion_list() -> void: var populate_list: Callable = func populate_list(array) -> void: if typeof(array) == TYPE_ARRAY: games = [] + Settings.delete_children(inspiration_list) games.append_array(array) for game: String in games: var inspiration_label: Label = Label.new() diff --git a/MainWindow.tscn b/MainWindow.tscn index 8723127..83514ee 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -477,7 +477,7 @@ size = Vector2i(268, 233) offset_left = 4.0 offset_top = 4.0 offset_right = 264.0 -offset_bottom = 354.0 +offset_bottom = 229.0 [node name="WinnerPopupPanel" type="PopupPanel" parent="."] initial_position = 2 @@ -513,4 +513,16 @@ focus_mode = 0 action_mode = 0 text = "Auto repeat" +[node name="DebugLabel" type="Label" parent="."] +layout_mode = 0 +offset_left = 974.0 +offset_top = 904.0 +offset_right = 1014.0 +offset_bottom = 927.0 +scale = Vector2(3, 3) +text = "DEBUG" +horizontal_alignment = 1 +vertical_alignment = 1 +autowrap_mode = 2 + [connection signal="dir_selected" from="FileDialog" to="." method="_on_file_dialog_dir_selected"] diff --git a/SearchWindow.gd b/SearchWindow.gd index d216f5c..454376a 100644 --- a/SearchWindow.gd +++ b/SearchWindow.gd @@ -99,9 +99,11 @@ func compile_regex(search_term: String) -> RegEx: return regex func get_list_of_games() -> void: + print("get_list_of_games") var handle_games = func handle_games(array): if typeof(array) == TYPE_ARRAY: games = [] + Settings.delete_children(search_list) games.append_array(array) for game in games: var label := Label.new() diff --git a/Settings.gd b/Settings.gd index d84d344..c457e25 100644 --- a/Settings.gd +++ b/Settings.gd @@ -23,9 +23,11 @@ var latest_played_song: int = 0 var currently_playing_song: int = -1 var edit_players: bool = false -var version: String = "1.5.0" +var version: String = "1.6.0" var whats_new: String = "Changelog: +1.6.0: + #1: Fixed bug with inspiration list not reloding after sync 1.5.0: Made big changes to players and the song list and how the local song list works 0.9.0-Beta: Fixed settings and updated the player view 0.8.0-Beta: Fixed reset buttons and some other small things @@ -34,10 +36,8 @@ var whats_new: String = "Changelog: 0.7-Beta: Can now hop between songs" var whats_left: String = "Things left to do: -Fix graphics in lists Fix layout -Fix for local play -Change some buttons to icons" +Fix for local play" var shortcuts: String = "Shortcuts: Alt + S = Search diff --git a/SettingsWindow.gd b/SettingsWindow.gd index 145122c..10e7581 100644 --- a/SettingsWindow.gd +++ b/SettingsWindow.gd @@ -33,8 +33,13 @@ var quick_sync_button := $QuickSyncButton @onready var local_button := $LocalButton +signal server_changed + # Called when the node enters the scene tree for the first time. func _ready(): + fullscreen_button.button_pressed = Settings.fullscreen + select_server_button.selected = Settings.selected_server + stop_after_current_button.pressed.connect(stop_after_current) hide_next_track_button.pressed.connect(hide_next_track) add_to_database_button.pressed.connect(add_to_database) @@ -96,3 +101,4 @@ func select_server(new_server: int) -> void: print("Settings.selected_server: " + str(Settings.selected_server)) print("new_server: " + str(new_server)) print("select_server_button.get_item_text(new_server): " + select_server_button.get_item_text(new_server)) + server_changed.emit() diff --git a/SettingsWindow.tscn b/SettingsWindow.tscn index ce1996b..c2d805c 100644 --- a/SettingsWindow.tscn +++ b/SettingsWindow.tscn @@ -77,15 +77,17 @@ text = "+1" [node name="SelectServerButton" type="OptionButton" parent="."] layout_mode = 2 selected = 0 -item_count = 4 +item_count = 5 popup/item_0/text = "https://music.sanplex.tech" popup/item_0/id = 1 popup/item_1/text = "https://tmusic.sanplex.tech" -popup/item_1/id = 1 -popup/item_2/text = "http://192.168.86.100:8085" -popup/item_2/id = 2 -popup/item_3/text = "http://localhost:8080" -popup/item_3/id = 3 +popup/item_1/id = 2 +popup/item_2/text = "https://rmusic.sanplex.tech" +popup/item_2/id = 3 +popup/item_3/text = "https://old-music.sanplex.tech" +popup/item_3/id = 4 +popup/item_4/text = "http://localhost:8080" +popup/item_4/id = 5 [node name="FullscreenButton" type="CheckButton" parent="."] layout_mode = 2