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()
51 lines
1.9 KiB
GDScript
51 lines
1.9 KiB
GDScript
class_name SongListObject
|
|
extends PanelContainer
|
|
|
|
@onready
|
|
var song_list_label: Label = $HBoxContainer/SongListLabel
|
|
|
|
@onready
|
|
var song_list_players: HBoxContainer = $HBoxContainer/SongListPlayers
|
|
|
|
var song_object: SongObject
|
|
|
|
#Color(0.18, 0.18, 0.18)
|
|
#Color(0.302, 0.302, 0.302)
|
|
#Color(0.259, 0.259, 0.259)
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
#if song_object != null && song_object.song_number % 2 == 0:
|
|
# var new_stylebox_normal = self.get_theme_stylebox("panel").duplicate()
|
|
# new_stylebox_normal.bg_color = Color(0.18, 0.18, 0.18)
|
|
# self.add_theme_stylebox_override("panel", new_stylebox_normal)
|
|
# song_list_label.add_theme_stylebox_override("normal", new_stylebox_normal)
|
|
#else:
|
|
# var new_stylebox_normal = self.get_theme_stylebox("panel").duplicate()
|
|
# new_stylebox_normal.bg_color = Color(0.18, 0.18, 0.18)
|
|
# self.add_theme_stylebox_override("panel", new_stylebox_normal)
|
|
# song_list_label.add_theme_stylebox_override("normal", new_stylebox_normal)
|
|
set_label()
|
|
update_players()
|
|
|
|
func set_label() -> void:
|
|
if song_object != null:
|
|
var size_to_change: int = song_object.players_given_point.size() * 50
|
|
song_list_label.custom_minimum_size = Vector2(1000 - size_to_change, 28)
|
|
if song_object.is_playing:
|
|
song_list_label.add_theme_color_override("font_color", Color(1, 0.5, 0))
|
|
song_list_label.text = song_object.get_song_info()
|
|
|
|
func update_players() -> void:
|
|
Settings.delete_children(song_list_players)
|
|
if song_object != null:
|
|
# Show players in the same order as the player list
|
|
for player: PlayerObject in Settings.player_array:
|
|
if song_object.players_given_point.has(player.id):
|
|
var texture: TextureRect = TextureRect.new()
|
|
texture.texture = player.character
|
|
texture.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
|
|
texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
texture.custom_minimum_size = Vector2(50, 25)
|
|
song_list_players.add_child(texture)
|