- Types on every parameter, return value and variable, and snake_case names (the player name limit is the constant MAX_NAME_LENGTH). - Spelling fixes: *_triggered, character_selected, separator, caught_errors. The server's catched_errors key stays as the server sends it. - Signals are connected with signal.connect() instead of by name. - Code is ordered signals, constants, exported vars, vars, @onready vars, functions, with @onready on one line and two blank lines between functions. - Every script starts with a ## description. Template comments, old LOC notes and commented-out code are gone, apart from the local play code. - Lines are at most 100 characters, apart from the local play path. - The screenshot tour turns off the blinking text cursor so pictures match.
38 lines
1.3 KiB
GDScript
38 lines
1.3 KiB
GDScript
class_name SongRow
|
|
extends PanelContainer
|
|
## One song in the music list: its number, soundtrack and title, and a marker for
|
|
## each player who got a point for it.
|
|
|
|
var song_object: SongObject
|
|
|
|
@onready var song_list_label: Label = %SongListLabel
|
|
@onready var song_list_players: HBoxContainer = %SongListPlayers
|
|
|
|
|
|
func _ready() -> void:
|
|
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)
|