Move server calls to MusicServerClient and give players stable ids

Server requests move out of Settings into a new MusicServerClient
autoload with one function per endpoint. It sends requests through a
swappable HttpTransport so tests can fake the server, and it frees its
HTTPRequest nodes after use.

Players now have a UUID that never changes. Their position in
Settings.player_array is only used for the Alt+<number> keybinds.
Previously the position doubled as the id, so removing a player made
points and wins land on the wrong player, and could delete another
player's point from a song.

Also fixes:
- format_time showed 59.6 seconds as "00:60"
- searches containing regex characters such as "Q*bert" broke search
- SongObject and PlayerObject were Nodes that were never freed; they
  are now RefCounted
- search matching is split out of the UI code into find_matches()
This commit is contained in:
Sansan committed 2026-10-06 08:32:55 +02:00
1 parent ab338b0696
commit 56e9fe66d3
18 files changed
+281 -162

No files matched your search

+5 -5
View File
@@ -63,12 +63,12 @@ func _process(_delta: float) -> void:
music_time_label.text = format_text(progress_slider.value, 0.0)
func format_time(time: float) -> String:
var mins: String = "%02d" % floor(time / 60)
var sec: String = "%02d" % round(fmod(time, 60))
return mins + ":" + sec
var total_seconds: int = roundi(time)
@warning_ignore("integer_division")
return "%02d:%02d" % [total_seconds / 60, total_seconds % 60]
func format_text(part: float, total: float) -> String:
if (Settings.hide_beginning && part <= Settings.hide_for_seconds) && Settings.hide_length:
if (Settings.hide_beginning && part < Settings.hide_for_seconds) && Settings.hide_length:
return "??:?? / ??:??"
elif Settings.hide_length:
return format_time(part) + " / ??:??"
@@ -209,7 +209,7 @@ func get_sound_test_song() -> void:
var sound: AudioStream = AudioStreamMP3.new()
sound.data = body
play_song(sound)
Settings.make_request2("/music/soundTest", test_sound, true)
MusicServerClient.fetch_sound_test_song(test_sound)
##### LOCAL
var local_path: String = '/Users/sebastian/ResilioSync/Sorterat_test/Metal Gear Solid 4 - Guns of the Patriots/2-16 Metal Gear Saga.mp3'