Files
MusicPlayer/music_list_panel.gd
T
Sansan a0428e3475 Follow the GDScript style guide in every script
- 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.
2026-10-06 11:53:26 +02:00

27 lines
917 B
GDScript

class_name MusicListPanel
extends PanelContainer
## The list of songs in the playlist, one row per song.
## Emitted when the row of song number [param song_no] is clicked.
signal song_clicked(song_no: int)
var _song_list_object: PackedScene = preload("res://SongRow.tscn")
@onready var _rows: VBoxContainer = %MusicList
## Shows the songs in the playlist again, so it shows their latest state.
func refresh() -> void:
Settings.delete_children(_rows)
for s: SongObject in Playlist.get_playlist():
var new_song_list_object: SongRow = _song_list_object.instantiate()
new_song_list_object.song_object = s
new_song_list_object.gui_input.connect(_on_row_input.bind(s.song_number))
_rows.add_child(new_song_list_object)
func _on_row_input(event: InputEvent, song_no: int) -> void:
if event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT:
song_clicked.emit(song_no)