The popups, the volume slider, the player name field and the main window get a class_name, so the main window and the quiz hold them by their real type instead of Control. The classes already use the names the files will get.
226 lines
7.9 KiB
GDScript
226 lines
7.9 KiB
GDScript
class_name SettingsPopup
|
|
extends PopupWindow
|
|
|
|
@onready
|
|
var settings_panel: Panel = %SettingsPanel
|
|
|
|
@onready
|
|
var stop_after_current_button: CheckButton = %StopAfterCurrentCheckButton
|
|
|
|
@onready
|
|
var hide_next_track_button: CheckButton = %HideNextTrackCheckButton
|
|
|
|
@onready
|
|
var add_to_database_button: CheckButton = %AddToDatabaseCheckButton
|
|
|
|
@onready
|
|
var low_played_button: CheckButton = %LowPlayedCheckButton
|
|
|
|
@onready
|
|
var hide_beginning_button: CheckButton = %HideBeginningCheckButton
|
|
|
|
@onready
|
|
var hide_length_button: CheckButton = %HideLengthCheckButton
|
|
|
|
@onready
|
|
var hide_ticks_button: CheckButton = %HideTicksCheckButton
|
|
|
|
@onready
|
|
var score_label: Label = %ScoreLabel
|
|
|
|
@onready
|
|
var lower_winning_score_button: Button = %LowerButton
|
|
|
|
@onready
|
|
var increase_winning_score_button: Button = %IncreaseButton
|
|
|
|
@onready
|
|
var cache_label: Label = %CacheLabel
|
|
|
|
@onready
|
|
var lower_cache_button: Button = %LowerCacheButton
|
|
|
|
@onready
|
|
var increase_cache_button: Button = %IncreaseCacheButton
|
|
|
|
@onready
|
|
var inspiration_speed_label: Label = %InspirationListSpeedLabel
|
|
|
|
@onready
|
|
var lower_inspiration_speed_button: Button = %LowerInspirationSpeedButton
|
|
|
|
@onready
|
|
var increase_inspiration_speed_button: Button = %IncreaseInspirationSpeedButton
|
|
|
|
@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 select_server_button: OptionButton = %SelectServerButton
|
|
|
|
@onready
|
|
var fullscreen_button: CheckButton = %FullscreenButton
|
|
|
|
@onready
|
|
var local_button: CheckButton = %LocalButton
|
|
|
|
signal server_changed
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
fullscreen_button.button_pressed = Settings.fullscreen
|
|
select_server_button.selected = Settings.selected_server
|
|
|
|
stop_after_current_button.pressed.connect(stop_after_current)
|
|
hide_next_track_button.pressed.connect(hide_next_track)
|
|
add_to_database_button.pressed.connect(add_to_database)
|
|
low_played_button.pressed.connect(low_played)
|
|
hide_beginning_button.pressed.connect(hide_beginning)
|
|
hide_length_button.pressed.connect(hide_length)
|
|
hide_ticks_button.pressed.connect(hide_ticks)
|
|
lower_winning_score_button.pressed.connect(lower_winning_score)
|
|
increase_winning_score_button.pressed.connect(increase_winning_score)
|
|
lower_cache_button.pressed.connect(lower_cache)
|
|
increase_cache_button.pressed.connect(increase_cache)
|
|
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)
|
|
fullscreen_button.pressed.connect(fullscreen)
|
|
local_button.pressed.connect(local_play)
|
|
|
|
stop_after_current_button.button_pressed = Settings.stop_after_current
|
|
hide_next_track_button.button_pressed = Settings.hide_next_track
|
|
add_to_database_button.button_pressed = Settings.add_to_stats
|
|
low_played_button.button_pressed = Settings.use_low_played_mode
|
|
hide_beginning_button.button_pressed = Settings.hide_beginning
|
|
hide_length_button.button_pressed = Settings.hide_length
|
|
hide_ticks_button.button_pressed = Settings.hide_ticks
|
|
score_label.text = str(Settings.winning_score)
|
|
cache_label.text = str(Playlist.number_of_tracks_to_preload)
|
|
inspiration_speed_label.text = str(Settings.inspiration_list_speed)
|
|
hide_for_seconds_label.text = str(Settings.hide_for_seconds)
|
|
fullscreen_button.button_pressed = Settings.fullscreen
|
|
update_hide_for_seconds_enabled()
|
|
select_server_button.select(Settings.selected_server)
|
|
select_server_button.item_selected.connect(select_server)
|
|
visibility_changed.connect(_on_visibility_changed)
|
|
# Alt+Enter switches fullscreen from the main window, which resizes the window
|
|
get_window().size_changed.connect(_update_fullscreen_button)
|
|
|
|
# Settings can change outside this window, e.g. winning turns statistics off
|
|
func _on_visibility_changed() -> void:
|
|
if visible:
|
|
add_to_database_button.button_pressed = Settings.add_to_stats
|
|
_update_fullscreen_button()
|
|
|
|
func _update_fullscreen_button() -> void:
|
|
fullscreen_button.set_pressed_no_signal(Settings.fullscreen)
|
|
|
|
func fullscreen() -> void:
|
|
Settings.fullscreen = !Settings.fullscreen
|
|
if Settings.fullscreen == true:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
|
if Settings.fullscreen == false:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
|
|
|
func local_play() -> void:
|
|
Settings.play_local = !Settings.play_local
|
|
|
|
func stop_after_current() -> void:
|
|
Settings.stop_after_current = !Settings.stop_after_current
|
|
|
|
func hide_next_track() -> void:
|
|
Settings.hide_next_track = !Settings.hide_next_track
|
|
|
|
func add_to_database() -> void:
|
|
Settings.add_to_stats = !Settings.add_to_stats
|
|
|
|
func low_played() -> void:
|
|
Settings.use_low_played_mode = !Settings.use_low_played_mode
|
|
|
|
func hide_beginning() -> void:
|
|
Settings.hide_beginning = !Settings.hide_beginning
|
|
update_hide_for_seconds_enabled()
|
|
|
|
func update_hide_for_seconds_enabled() -> void:
|
|
var enabled: bool = Settings.hide_beginning
|
|
%HideForSecondsHBoxContainer.visible = enabled
|
|
|
|
func hide_length() -> void:
|
|
Settings.hide_length = !Settings.hide_length
|
|
|
|
func hide_ticks() -> void:
|
|
Settings.hide_ticks = !Settings.hide_ticks
|
|
|
|
func lower_winning_score() -> void:
|
|
Settings.winning_score = max(Settings.winning_score - 1, 1)
|
|
score_label.text = str(Settings.winning_score)
|
|
|
|
func increase_winning_score() -> void:
|
|
Settings.winning_score += 1
|
|
score_label.text = str(Settings.winning_score)
|
|
|
|
func set_winning_score(new_score: int) -> void:
|
|
Settings.winning_score = new_score
|
|
score_label.text = str(Settings.winning_score)
|
|
|
|
func lower_cache() -> void:
|
|
Playlist.number_of_tracks_to_preload -= 1
|
|
if Playlist.number_of_tracks_to_preload < 1:
|
|
Playlist.number_of_tracks_to_preload = 1
|
|
cache_label.text = str(Playlist.number_of_tracks_to_preload)
|
|
|
|
func increase_cache() -> void:
|
|
Playlist.number_of_tracks_to_preload += 1
|
|
cache_label.text = str(Playlist.number_of_tracks_to_preload)
|
|
|
|
func lower_inspiration_speed() -> void:
|
|
Settings.inspiration_list_speed -= 1
|
|
if Settings.inspiration_list_speed < 1:
|
|
Settings.inspiration_list_speed = 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 -= 1.0
|
|
if Settings.hide_for_seconds < 0:
|
|
Settings.hide_for_seconds = 0
|
|
hide_for_seconds_label.text = str(Settings.hide_for_seconds)
|
|
|
|
func increase_hide_for_seconds() -> void:
|
|
Settings.hide_for_seconds += 1.0
|
|
if Settings.hide_for_seconds > 10.0:
|
|
Settings.hide_for_seconds = 10.0
|
|
hide_for_seconds_label.text = str(Settings.hide_for_seconds)
|
|
|
|
func select_server(new_server: int) -> void:
|
|
GameLog.debug("select_server")
|
|
Settings.default_path = select_server_button.get_item_text(new_server)
|
|
Settings.selected_server = new_server
|
|
GameLog.debug("Settings.default_path: " + Settings.default_path)
|
|
GameLog.debug("Settings.selected_server: " + str(Settings.selected_server))
|
|
GameLog.debug("new_server: " + str(new_server))
|
|
GameLog.debug("select_server_button.get_item_text(new_server): " + select_server_button.get_item_text(new_server))
|
|
server_changed.emit()
|
|
|
|
func set_selected_server(new_server: int) -> void:
|
|
GameLog.debug("set_selected_server")
|
|
select_server_button.select(new_server)
|
|
Settings.default_path = select_server_button.get_item_text(new_server)
|
|
Settings.selected_server = new_server
|
|
GameLog.debug("Settings.default_path: " + Settings.default_path)
|
|
GameLog.debug("Settings.selected_server: " + str(Settings.selected_server))
|
|
GameLog.debug("new_server: " + str(new_server))
|
|
GameLog.debug("select_server_button.get_item_text(new_server): " + select_server_button.get_item_text(new_server))
|
|
server_changed.emit()
|