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

53 lines
1.4 KiB
GDScript

extends VBoxContainer
signal changed
var has_unsaved_changes: bool = false
signal leave_stage
var has_stage:bool = false:
set(stage):
has_stage = stage
if is_node_ready() and has_stage:
%ExpandButton.grab_focus()
@export var is_in_beginning: bool = false
var current_music_decay:float = 0
@onready var expand_button: Button = %ExpandButton
@onready var content_note_box: CheckBox = %ContentNoteButton
@onready var allow_skip_button: CheckBox = %AllowSkipButton
func _ready() -> void:
if is_in_beginning:
%SaveButton.hide()
else:
%SaveButton.text = "menu_save_exit"
update_ui_from_state()
content_note_box.pressed.connect(func(value): State.show_content_notes = value)
content_note_box.pressed.connect(changed.emit)
allow_skip_button.pressed.connect(func(value): State.allow_skipping = value)
allow_skip_button.pressed.connect(changed.emit)
%SaveButton.pressed.connect(_on_exit_button_pressed)
%ExpandButton.pressed.connect(
func():
%Reveal.play("reveal")
%ExpandButton.disabled = true
)
func update_ui_from_state():
content_note_box.button_pressed = State.show_content_notes
allow_skip_button.button_pressed = State.allow_skipping
func _on_exit_button_pressed() -> void:
State.save_settings()
has_unsaved_changes = false
leave_stage.emit()
State.leave_stage(self)
func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and has_stage:
State.leave_stage(self)