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/GlobalSettings.gd
2023-04-09 17:30:52 +05:30

43 lines
1.5 KiB
GDScript

extends Node
@export var master_bus_index : int = 0
@export var music_bus_index : int = 1
@export var sfx_bus_index : int = 2
# Video Global Settings
func set_display_mode(value: int) -> void:
Save.game_data.display_mode = value
Save.save_data()
if value == 0: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
elif value == 1: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
elif value == 2: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MAXIMIZED)
elif value == 3: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)
elif value == 4: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN)
else: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
pass
func toggle_vsync(value : bool) -> void:
Save.game_data.vsync_on = value
Save.save_data()
if value: DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
else: DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
pass
# Audio Global Settings
func update_master_volume(vol : int) -> void:
Save.game_data.master_volume = vol
Save.save_data()
AudioServer.set_bus_volume_db(master_bus_index, vol)
pass
func update_music_volume(vol : int) -> void:
Save.game_data.music_volume = vol
Save.save_data()
AudioServer.set_bus_volume_db(music_bus_index, vol)
pass
func update_sfx_volume(vol : int) -> void:
Save.game_data.sfx_volume = vol
Save.save_data()
AudioServer.set_bus_volume_db(sfx_bus_index, vol)
pass