extends Control @onready var data: Data = $/root/Root/Data @onready var titleScreen: Control = $/root/Root/MainMenu/TitleScreen @onready var fpsMonitor: RichTextLabel = $/root/Root/FPSMonitor @onready var mainBus: int = AudioServer.get_bus_index("Master") @onready var musicBus: int = AudioServer.get_bus_index("Music") @onready var effectsBus: int = AudioServer.get_bus_index("Effects") @onready var animationPlayer: AnimationPlayer = $/root/Root/MainMenu/AnimationPlayer @onready var masterSlide: HSlider = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/MasterSlide @onready var musicSlide: HSlider = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/MusicSlide @onready var effectsSlide: HSlider = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/EffectsSlide @onready var difficulty: OptionButton = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/OptionButton @onready var windowModeLabel: RichTextLabel = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/WindowMode @onready var windowMode: OptionButton = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/OptionButton2 @onready var vsync: OptionButton = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/OptionButton3 @onready var maxFPS: OptionButton = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/OptionButton4 @onready var fpsMonitorBox: CheckBox = $/root/Root/MainMenu/Settings/NinePatchRect/ScrollContainer/GridContainer/CheckBox func _ready(): difficulty.selected = int(data.difficulty) var volumeMaster: float = db_to_linear(AudioServer.get_bus_volume_db(mainBus)) var volumeMusic: float = db_to_linear(AudioServer.get_bus_volume_db(musicBus)) var volumeEffects: float = db_to_linear(AudioServer.get_bus_volume_db(effectsBus)) effectsSlide.value = volumeEffects musicSlide.value = volumeMusic masterSlide.value = volumeMaster if (data.forWeb): windowMode.disabled = true windowModeLabel.modulate = Color("dfdfdf80") else: match DisplayServer.window_get_mode(): DisplayServer.WINDOW_MODE_WINDOWED: windowMode.selected = 0 DisplayServer.WINDOW_MODE_FULLSCREEN: windowMode.selected = 1 DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN: windowMode.selected = 2 match DisplayServer.window_get_vsync_mode(): DisplayServer.VSYNC_DISABLED: vsync.selected = 0 DisplayServer.VSYNC_ENABLED: vsync.selected = 1 DisplayServer.VSYNC_ADAPTIVE: vsync.selected = 2 DisplayServer.VSYNC_MAILBOX: vsync.selected = 3 match Engine.max_fps: 24: maxFPS.selected = 0 30: maxFPS.selected = 1 60: maxFPS.selected = 2 90: maxFPS.selected = 3 120: maxFPS.selected = 4 144: maxFPS.selected = 5 240: maxFPS.selected = 6 0: maxFPS.selected = 7 fpsMonitorBox.button_pressed = fpsMonitor.visible func home(): animationPlayer.play_backwards("settingsTransition") func changeDifficulty(i: int): data.difficulty = i as Data.Difficulty func changeVolMaster(i: float): AudioServer.set_bus_volume_db(mainBus, linear_to_db(i)) func changeVolMusic(i: float): AudioServer.set_bus_volume_db(musicBus, linear_to_db(i)) func changeVolEffects(i: float): AudioServer.set_bus_volume_db(effectsBus, linear_to_db(i)) func windowModeChanged(index: int): match index: 0: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) 1: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN) 2: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN) func vsyncChanged(index: int): match index: 0: DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED) 1: DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED) 2: DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ADAPTIVE) 3: DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_MAILBOX) func toggleFPSMonitor(toggled_on: bool): $/root/Root/FPSMonitor.visible = toggled_on func fpsChanged(index: int): match index: 0: Engine.max_fps = 24 1: Engine.max_fps = 30 2: Engine.max_fps = 60 3: Engine.max_fps = 90 4: Engine.max_fps = 120 5: Engine.max_fps = 144 6: Engine.max_fps = 240 7: Engine.max_fps = 0