bugged-racing/menu/settings_menu.gd

89 lines
3.2 KiB
GDScript
Raw Permalink Normal View History

2021-11-17 22:23:12 +00:00
extends Panel
onready var master_bus := AudioServer.get_bus_index("Master")
onready var sound_bus := AudioServer.get_bus_index("Sound")
onready var music_bus := AudioServer.get_bus_index("Music")
2021-11-18 23:36:05 +00:00
# gdlint: ignore=max-line-length
2021-11-17 22:23:12 +00:00
onready var master_slider: HSlider = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/MasterSlider
2021-11-18 23:36:05 +00:00
# gdlint: ignore=max-line-length
2021-11-17 22:23:12 +00:00
onready var sound_slider: HSlider = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/SoundEffectsSlider
2021-11-18 23:36:05 +00:00
# gdlint: ignore=max-line-length
2021-11-17 22:23:12 +00:00
onready var music_slider: HSlider = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/MusicSlider
2021-11-18 23:36:05 +00:00
# gdlint: ignore=max-line-length
2021-11-17 22:23:12 +00:00
onready var auto_clutch_cb: CheckBox = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/AutoClutchCheckBox
2021-11-18 23:36:05 +00:00
# gdlint: ignore=max-line-length
2021-11-17 22:23:12 +00:00
onready var automatic_transmission_cb: CheckBox = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/AutomaticTransmissionCheckBox
2021-11-18 23:36:05 +00:00
# gdlint: ignore=max-line-length
2021-11-18 19:05:35 +00:00
onready var fullscreen_cb: CheckBox = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/FullscreenCheckBox
2021-11-18 23:36:05 +00:00
# gdlint: ignore=max-line-length
2021-11-18 19:05:35 +00:00
onready var borderless_cb: CheckBox = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/BorderlessCheckBox
2021-11-17 22:23:12 +00:00
2021-11-18 23:36:05 +00:00
2021-11-17 22:23:12 +00:00
func _ready() -> void:
2021-11-22 19:22:32 +00:00
auto_clutch_cb.grab_focus()
2021-11-17 22:23:12 +00:00
master_slider.value = db2linear(AudioServer.get_bus_volume_db(master_bus))
sound_slider.value = db2linear(AudioServer.get_bus_volume_db(sound_bus))
music_slider.value = db2linear(AudioServer.get_bus_volume_db(music_bus))
auto_clutch_cb.pressed = GlobalSettings.auto_clutch
automatic_transmission_cb.pressed = GlobalSettings.automatic_transmission
2021-11-18 19:05:35 +00:00
fullscreen_cb.pressed = false
borderless_cb.pressed = false
if OS.is_window_fullscreen():
_set_fullscreen(true)
if OS.get_borderless_window():
_set_borderless(true)
2021-11-17 22:23:12 +00:00
func _on_autoclutch_toggled(new_state: bool) -> void:
GlobalSettings.auto_clutch = new_state
2021-11-18 19:05:35 +00:00
func _on_fullscreen_toggled(new_state: bool) -> void:
_set_borderless(false)
_set_fullscreen(new_state)
func _on_borderless_toggled(new_state: bool) -> void:
_set_fullscreen(false)
_set_borderless(new_state)
2021-11-17 22:23:12 +00:00
func _on_automatictransmission_toggled(new_state: bool) -> void:
GlobalSettings.automatic_transmission = new_state
auto_clutch_cb.disabled = new_state == true
func _on_BackButton_pressed() -> void:
2021-11-18 19:48:47 +00:00
get_tree().change_scene("res://menu/main_menu.tscn")
2021-11-17 22:23:12 +00:00
func _on_MasterSlider_value_changed(new_value: float) -> void:
AudioServer.set_bus_volume_db(master_bus, linear2db(new_value))
func _on_SoundEffectsSlider_value_changed(new_value: float) -> void:
AudioServer.set_bus_volume_db(sound_bus, linear2db(new_value))
func _on_MusicSlider_value_changed(new_value: float) -> void:
AudioServer.set_bus_volume_db(music_bus, linear2db(new_value))
2021-11-18 19:05:35 +00:00
func _set_fullscreen(new_state: bool) -> void:
OS.set_window_fullscreen(new_state)
OS.set_window_maximized(new_state)
if new_state == true:
borderless_cb.disabled = true
else:
borderless_cb.disabled = false
func _set_borderless(new_state: bool) -> void:
OS.set_borderless_window(new_state)
OS.set_window_maximized(new_state)
if new_state == true:
fullscreen_cb.disabled = true
else:
fullscreen_cb.disabled = false