frame-of-mind/src/ui/menu_main/gameplay_settings.gd

44 lines
1.4 KiB
GDScript3
Raw Normal View History

extends VBoxContainer
signal changed
2024-10-07 09:16:18 +00:00
signal leave_stage
var has_stage:bool = false:
set(stage):
has_stage = stage
2024-10-07 09:16:18 +00:00
if is_node_ready() and has_stage:
2025-10-07 22:33:15 +00:00
y_switch_gamepad.grab_focus()
var current_music_decay:float = 0
2025-10-07 22:33:15 +00:00
@onready var y_switch_gamepad: CheckBox = %InvertYGamepad
@onready var y_switch_mouse: CheckBox = %InvertYMouse
@onready var input_sensitivity_slider: HSlider = %InputSensitivitySlider
2025-10-07 22:33:15 +00:00
@onready var fov_slider: HSlider = %FOVSlider
@onready var stream_overlay_picker: OptionButton = %StreamOverlayPicker
func _ready() -> void:
update_ui_from_state()
2025-10-07 22:33:15 +00:00
y_switch_gamepad.toggled.connect(func(value): State.inverty_y_axis = value)
y_switch_mouse.toggled.connect(func(value): State.inverty_y_mouse = value)
input_sensitivity_slider.value_changed.connect(func(value): State.input_sensitivity = value)
stream_overlay_picker.item_selected.connect(func(value): State.stream_overlay = value)
2025-10-07 22:33:15 +00:00
fov_slider.value_changed.connect(func(value): State.input_sensitivity = value)
2025-12-10 17:52:09 +00:00
%SaveButton.pressed.connect(_on_exit_button_pressed)
func update_ui_from_state():
2025-10-07 22:33:15 +00:00
y_switch_gamepad.button_pressed = State.inverty_y_axis
input_sensitivity_slider.value = State.input_sensitivity
stream_overlay_picker.select(State.stream_overlay_position)
2025-12-10 17:52:09 +00:00
func _on_exit_button_pressed() -> void:
2024-10-07 09:16:18 +00:00
leave_stage.emit()
State.save_settings()
State.leave_stage(self)
func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and has_stage:
State.leave_stage(self)