stick-the-quick/ui/OptionsMenu/OptionsMenu.gd

121 lines
4.3 KiB
GDScript3
Raw Permalink Normal View History

class_name OptionsMenu extends AbstractConfigMenu
@onready var _actual_menu := (
$'OuterMargin/Content/ActualMenu'
)
@onready var _content := _actual_menu.get_node(
^'ContentScrollContainer/ContentInnerMargin/Content'
)
@onready var fullscreen := _content.get_node(
^'FullscreenToggle'
) as CheckButton
@onready var master_volume := _content.get_node(
^'MasterVolumeSlider'
) as HSlider
@onready var music_volume := _content.get_node(
^'MusicVolumeSlider'
) as HSlider
@onready var sound_volume := _content.get_node(
^'SoundVolumeSlider'
) as HSlider
@onready var mouselook := _content.get_node(
^'MouselookToggle'
) as CheckButton
@onready var mouse_sensitivity := _content.get_node(
^'MouseSensitivitySlider'
) as HSlider
@onready var mouse_wheel_sensitivity := _content.get_node(
^'MouseWheelSensitivitySlider'
) as HSlider
@onready var invert_mouselook := _content.get_node(
^'InvertMouselookToggle'
) as CheckButton
@onready var invert_mouse_wheel := _content.get_node(
^'InvertMouseWheelToggle'
) as CheckButton
@onready var right_stick_sensitivity := _content.get_node(
^'RightStickSensitivitySlider'
) as HSlider
@onready var invert_right_stick := _content.get_node(
^'InvertRightStickToggle'
) as CheckButton
@onready var _button_input_bindings := _actual_menu.get_node(
^'Nav/InputBindings'
) as Button
@onready var _button_debug_menu := _actual_menu.get_node(
^'Nav/DebugMenu'
)
func _connect_signals() -> void:
fullscreen.toggled.connect(_hot_update_options)
master_volume.value_changed.connect(_hot_update_options)
music_volume.value_changed.connect(_hot_update_options)
sound_volume.value_changed.connect(_hot_update_options)
mouselook.toggled.connect(_hot_update_options)
mouse_sensitivity.value_changed.connect(_hot_update_options)
mouse_wheel_sensitivity.value_changed.connect(_hot_update_options)
invert_mouselook.toggled.connect(_hot_update_options)
invert_mouse_wheel.toggled.connect(_hot_update_options)
right_stick_sensitivity.value_changed.connect(_hot_update_options)
invert_right_stick.toggled.connect(_hot_update_options)
_button_input_bindings.pressed.connect(_input_bindings)
if OS.is_debug_build():
_button_debug_menu.pressed.connect(_debug_menu)
else:
_button_debug_menu.queue_free()
func _pull_settings() -> void:
fullscreen.set_pressed_no_signal(Options.fullscreen)
master_volume.set_value_no_signal(Options.master_volume)
music_volume.set_value_no_signal(Options.music_volume)
sound_volume.set_value_no_signal(Options.sound_volume)
mouselook.set_pressed_no_signal(Options.mouselook)
mouse_sensitivity.set_value_no_signal(Options.mouse_sensitivity)
mouse_wheel_sensitivity.set_value_no_signal(
Options.mouse_wheel_sensitivity
)
invert_mouselook.set_pressed_no_signal(Options.invert_mouselook)
invert_mouse_wheel.set_pressed_no_signal(Options.invert_mouse_wheel)
right_stick_sensitivity.set_value_no_signal(
Options.right_stick_sensitivity
)
invert_right_stick.set_pressed_no_signal(Options.invert_right_stick)
_hot_update_options()
_button_apply.disabled = true
func _push_settings() -> void:
Options.save_file()
func _restore_defaults() -> void:
Options.reset_non_input_map_options()
_pull_settings()
_button_apply.disabled = false
func _revert_changes() -> void:
Options.load_file()
_pull_settings()
func _hot_update_options(_dont_care = null) -> void:
Options.fullscreen = fullscreen.button_pressed
Options.master_volume = master_volume.value
Options.music_volume = music_volume.value
Options.sound_volume = sound_volume.value
Options.mouselook = mouselook.button_pressed
Options.mouse_sensitivity = mouse_sensitivity.value
Options.mouse_wheel_sensitivity = mouse_wheel_sensitivity.value
Options.invert_mouselook = invert_mouselook.button_pressed
Options.invert_mouse_wheel = invert_mouse_wheel.button_pressed
Options.right_stick_sensitivity = right_stick_sensitivity.value
Options.invert_right_stick = invert_right_stick.button_pressed
mouse_sensitivity.editable = mouselook.button_pressed
mouse_wheel_sensitivity.editable = mouselook.button_pressed
invert_mouselook.disabled = not mouselook.button_pressed
invert_mouse_wheel.disabled = not mouselook.button_pressed
_button_apply.disabled = false
func _input_bindings() -> void:
await UI.Call(load('res://ui/OptionsMenu/InputMapMenu.tscn'))
func _debug_menu() -> void:
await UI.Call(load('res://ui/DebugMenu/DebugMenu.tscn'))