This repository has been archived on 2024-07-02. You can view files and clone it, but cannot push or open issues or pull requests.
HoppyEaster/Scripts/SettingsMenu.gd
2023-04-09 18:34:49 +05:30

63 lines
1.9 KiB
GDScript

extends Node
# Video Settings UI References
@export var display_options_button : OptionButton
@export var vsync_toggle : CheckButton
@export var resolutions_options_button : OptionButton
# Audio Settings UI References
@export var master_volume_slider : Slider
@export var music_volume_slider : Slider
@export var sfx_volume_slider : Slider
# Engine Callbacks
func _ready():
add_resolution_items()
display_options_button.select(Save.game_data.display_mode)
GlobalSettings.set_display_mode(Save.game_data.display_mode)
vsync_toggle.set_pressed_no_signal(Save.game_data.vsync_on)
GlobalSettings.toggle_vsync(Save.game_data.vsync_on)
resolutions_options_button.select(Save.game_data.current_resolution_index)
GlobalSettings.set_resolution(Save.game_data.current_resolution_index)
master_volume_slider.value = Save.game_data.master_volume
GlobalSettings.update_master_volume(Save.game_data.master_volume)
music_volume_slider.value = Save.game_data.music_volume
GlobalSettings.update_music_volume(Save.game_data.music_volume)
sfx_volume_slider.value = Save.game_data.sfx_volume
GlobalSettings.update_sfx_volume(Save.game_data.sfx_volume)
pass
func add_resolution_items():
for key in GlobalSettings.resolutions_dictionary.keys():
resolutions_options_button.add_item(key)
# Other Buttons
func _on_back_pressed():
queue_free()
pass
# Video Settings
func _on_display_mode_options_item_selected(index):
GlobalSettings.set_display_mode(index)
pass
func _on_vsync_button_toggled(button_pressed):
GlobalSettings.toggle_vsync(button_pressed)
pass
func _on_resolutions_options_item_selected(index):
GlobalSettings.set_resolution(index)
pass
# Audio Settings
func _on_master_volume_slider_value_changed(value):
GlobalSettings.update_master_volume(value)
pass
func _on_music_vol_slider_value_changed(value):
GlobalSettings.update_music_volume(value)
pass
func _on_sfx_vol_slider_value_changed(value):
GlobalSettings.update_sfx_volume(value)
pass