Buttons get 12 px of side padding. The top bar buttons, the quiz toolbar and Show answer/Next are laid out in rows with 12 px gaps and are all 36 px tall, and the ±1 buttons use a compact StepButton style. "Randomize new track" is now "Next song". Player rows show the name and the score apart, alternate like the other lists and highlight the character under the mouse. The name field is a LineEdit with a 10-letter limit; blank and duplicate names are refused, and a full list says "Up to 7 players". Remove buttons update when editing is switched instead of every frame, and the spacer panels are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
1.6 KiB
GDScript
56 lines
1.6 KiB
GDScript
class_name SongControls
|
|
extends Control
|
|
## The buttons for the song that is playing: show the answer, and go to the next song.
|
|
|
|
signal show_answer_pressed
|
|
signal next_pressed
|
|
## Emitted when Next is pressed at the end of a prepared quiz, where it reads
|
|
## "Show winner".
|
|
signal show_winner_pressed
|
|
|
|
const NEXT_TEXT: String = "Next song"
|
|
const SHOW_WINNER_TEXT: String = "Show winner"
|
|
|
|
## True while Next reads "Show winner", after the last song of a prepared quiz.
|
|
var shows_winner: bool = false
|
|
|
|
@onready var show_answer_button: Button = $ShowAnswerButton
|
|
@onready var next_button: Button = $NextButton
|
|
|
|
|
|
func _ready() -> void:
|
|
show_answer_button.pressed.connect(show_answer_pressed.emit)
|
|
next_button.pressed.connect(_on_next_button_pressed)
|
|
|
|
|
|
## Enables Next while there is a downloaded song to play next.
|
|
func set_next_enabled(enabled: bool) -> void:
|
|
_set_shows_winner(false)
|
|
next_button.disabled = !enabled
|
|
|
|
|
|
## Turns Next into "Show winner", for when the last song of a prepared quiz has played.
|
|
func show_winner_button() -> void:
|
|
_set_shows_winner(true)
|
|
next_button.disabled = false
|
|
|
|
|
|
## Disables both buttons, e.g. while the server syncs the song list. Unlocking enables
|
|
## Show answer again; Next comes back when the next song has been downloaded.
|
|
func set_locked(locked: bool) -> void:
|
|
show_answer_button.disabled = locked
|
|
if locked:
|
|
next_button.disabled = true
|
|
|
|
|
|
func _set_shows_winner(on: bool) -> void:
|
|
shows_winner = on
|
|
next_button.text = SHOW_WINNER_TEXT if on else NEXT_TEXT
|
|
|
|
|
|
func _on_next_button_pressed() -> void:
|
|
if shows_winner:
|
|
show_winner_pressed.emit()
|
|
else:
|
|
next_pressed.emit()
|