Split settings into a quiz card and an application Settings popup
- A Quiz settings button under the player bar opens a small card above it with the quiz settings, including Auto repeat, which moves there from under the player bar. The card does not dim the quiz, so it can be changed during a song, and grows to fit its rows. - A Settings button in the top bar opens the application settings: server, fullscreen and songs to download ahead. Quick sync is gone, as the server no longer has it, and the server list is in Settings. - Labels use sentence case, and seconds to hide show as whole numbers. - Debug builds switch to the local server and a low winning score in the Settings autoload, before any scene asks the server for anything. The DEBUG label moves to the top bar, so it shows on every tab. - Search moves from the top bar back to the quiz toolbar, as the Statistics tab has its own search.
This commit is contained in:
1 parent
8d21b0617d
commit
b510aa47f2
34 files changed
+3074
-2525
No files matched your search
@@ -0,0 +1,130 @@
|
||||
class_name QuizSettingsCard
|
||||
extends BasePopup
|
||||
## The quiz settings, in a small card that opens above the Quiz settings button by the
|
||||
## music player: how songs are played and hidden, statistics, the winning score and the
|
||||
## inspiration list. It does not dim the quiz, so it can be changed during a song.
|
||||
##
|
||||
## The card's bottom edge is where the card is placed, just above the player bar, and
|
||||
## it grows upward to fit its rows.
|
||||
##
|
||||
## The application settings, such as the server, are in [SettingsPopup].
|
||||
|
||||
## The most seconds of a song's beginning that can be hidden.
|
||||
const MAX_HIDE_SECONDS: float = 10.0
|
||||
## Space between the rows and the card's edges.
|
||||
const PADDING: Vector2 = Vector2(16, 12)
|
||||
|
||||
@onready var card_panel: Panel = %CardPanel
|
||||
@onready var rows: VBoxContainer = %VBox
|
||||
@onready var auto_repeat_button: CheckButton = %AutoRepeatCheckButton
|
||||
@onready var stop_after_current_button: CheckButton = %StopAfterCurrentCheckButton
|
||||
@onready var hide_next_track_button: CheckButton = %HideNextTrackCheckButton
|
||||
@onready var hide_beginning_button: CheckButton = %HideBeginningCheckButton
|
||||
@onready var hide_for_seconds_row: HBoxContainer = %HideForSecondsRow
|
||||
@onready var hide_for_seconds_label: Label = %HideForSecondsLabel
|
||||
@onready var lower_hide_for_seconds_button: Button = %LowerHideForSecondsButton
|
||||
@onready var increase_hide_for_seconds_button: Button = %IncreaseHideForSecondsButton
|
||||
@onready var hide_length_button: CheckButton = %HideLengthCheckButton
|
||||
@onready var hide_ticks_button: CheckButton = %HideTicksCheckButton
|
||||
@onready var low_played_button: CheckButton = %LowPlayedCheckButton
|
||||
@onready var add_to_database_button: CheckButton = %AddToDatabaseCheckButton
|
||||
@onready var score_label: Label = %ScoreLabel
|
||||
@onready var lower_winning_score_button: Button = %LowerButton
|
||||
@onready var increase_winning_score_button: Button = %IncreaseButton
|
||||
@onready var inspiration_speed_label: Label = %InspirationListSpeedLabel
|
||||
@onready var lower_inspiration_speed_button: Button = %LowerInspirationSpeedButton
|
||||
@onready var increase_inspiration_speed_button: Button = %IncreaseInspirationSpeedButton
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
auto_repeat_button.toggled.connect(func(on: bool) -> void: Settings.auto_repeat_song = on)
|
||||
stop_after_current_button.toggled.connect(
|
||||
func(on: bool) -> void: Settings.stop_after_current = on)
|
||||
hide_next_track_button.toggled.connect(
|
||||
func(on: bool) -> void: Settings.hide_next_track = on)
|
||||
hide_beginning_button.toggled.connect(_on_hide_beginning_toggled)
|
||||
hide_length_button.toggled.connect(func(on: bool) -> void: Settings.hide_length = on)
|
||||
hide_ticks_button.toggled.connect(func(on: bool) -> void: Settings.hide_ticks = on)
|
||||
low_played_button.toggled.connect(
|
||||
func(on: bool) -> void: Settings.use_low_played_mode = on)
|
||||
add_to_database_button.toggled.connect(func(on: bool) -> void: Settings.add_to_stats = on)
|
||||
lower_winning_score_button.pressed.connect(lower_winning_score)
|
||||
increase_winning_score_button.pressed.connect(increase_winning_score)
|
||||
lower_inspiration_speed_button.pressed.connect(lower_inspiration_speed)
|
||||
increase_inspiration_speed_button.pressed.connect(increase_inspiration_speed)
|
||||
lower_hide_for_seconds_button.pressed.connect(lower_hide_for_seconds)
|
||||
increase_hide_for_seconds_button.pressed.connect(increase_hide_for_seconds)
|
||||
visibility_changed.connect(_on_visibility_changed)
|
||||
show_settings()
|
||||
|
||||
|
||||
## Shows the current settings. Some change outside this card, e.g. winning turns
|
||||
## statistics off, so this runs every time the card opens.
|
||||
func show_settings() -> void:
|
||||
auto_repeat_button.set_pressed_no_signal(Settings.auto_repeat_song)
|
||||
stop_after_current_button.set_pressed_no_signal(Settings.stop_after_current)
|
||||
hide_next_track_button.set_pressed_no_signal(Settings.hide_next_track)
|
||||
hide_beginning_button.set_pressed_no_signal(Settings.hide_beginning)
|
||||
hide_length_button.set_pressed_no_signal(Settings.hide_length)
|
||||
hide_ticks_button.set_pressed_no_signal(Settings.hide_ticks)
|
||||
low_played_button.set_pressed_no_signal(Settings.use_low_played_mode)
|
||||
add_to_database_button.set_pressed_no_signal(Settings.add_to_stats)
|
||||
hide_for_seconds_row.visible = Settings.hide_beginning
|
||||
hide_for_seconds_label.text = "%d" % Settings.hide_for_seconds
|
||||
score_label.text = str(Settings.winning_score)
|
||||
inspiration_speed_label.text = str(Settings.inspiration_list_speed)
|
||||
_fit_to_rows()
|
||||
|
||||
|
||||
func lower_winning_score() -> void:
|
||||
set_winning_score(Settings.winning_score - 1)
|
||||
|
||||
|
||||
func increase_winning_score() -> void:
|
||||
set_winning_score(Settings.winning_score + 1)
|
||||
|
||||
|
||||
## Sets the winning score, never below 1.
|
||||
func set_winning_score(new_score: int) -> void:
|
||||
Settings.winning_score = maxi(new_score, 1)
|
||||
score_label.text = str(Settings.winning_score)
|
||||
|
||||
|
||||
func lower_inspiration_speed() -> void:
|
||||
Settings.inspiration_list_speed = maxi(Settings.inspiration_list_speed - 1, 1)
|
||||
inspiration_speed_label.text = str(Settings.inspiration_list_speed)
|
||||
|
||||
|
||||
func increase_inspiration_speed() -> void:
|
||||
Settings.inspiration_list_speed += 1
|
||||
inspiration_speed_label.text = str(Settings.inspiration_list_speed)
|
||||
|
||||
|
||||
func lower_hide_for_seconds() -> void:
|
||||
Settings.hide_for_seconds = maxf(Settings.hide_for_seconds - 1.0, 0.0)
|
||||
hide_for_seconds_label.text = "%d" % Settings.hide_for_seconds
|
||||
|
||||
|
||||
func increase_hide_for_seconds() -> void:
|
||||
Settings.hide_for_seconds = minf(Settings.hide_for_seconds + 1.0, MAX_HIDE_SECONDS)
|
||||
hide_for_seconds_label.text = "%d" % Settings.hide_for_seconds
|
||||
|
||||
|
||||
func _on_hide_beginning_toggled(on: bool) -> void:
|
||||
Settings.hide_beginning = on
|
||||
hide_for_seconds_row.visible = on
|
||||
_fit_to_rows()
|
||||
|
||||
|
||||
# Grows or shrinks the card upward, keeping its bottom edge in place
|
||||
func _fit_to_rows() -> void:
|
||||
var height: float = rows.get_combined_minimum_size().y + PADDING.y * 2
|
||||
card_panel.position.y = -height
|
||||
card_panel.size.y = height
|
||||
rows.position = PADDING
|
||||
rows.size = Vector2(card_panel.size.x - PADDING.x * 2, height - PADDING.y * 2)
|
||||
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
if visible:
|
||||
show_settings()
|
||||
Reference in new issue
Block a user