Implemented spawn points correctly. Added saving & loading (currently only implemented with the spawn_index). You can now set spawn indicies in the DynamicAreaLoader to automatically load when the game is set to that value (on ready). Added configuration warnings to DynamicAreaLoader & PlayerSpawnPoint Added some generic translation (pot) files. Added AudioManager autoload to play, stop, fade audio streams (and set the bus directly). Added SceneFader autoload. Added SaveManager autoload. Added OptionsMenu with currently only volume sliders and a fullscreen toggle button. Added PauseMenu
72 lines
1.7 KiB
GDScript
72 lines
1.7 KiB
GDScript
extends Node
|
|
|
|
const SETTINGS_PATH: String = "user://settings.cfg"
|
|
|
|
var settings: Dictionary[String, Dictionary] = {
|
|
&"game": {
|
|
&"has_compiled_shaders": false,
|
|
},
|
|
&"audio": {
|
|
&"Master": 1.0,
|
|
&"SFX": 1.0,
|
|
&"Music": 1.0,
|
|
&"Ambient": 1.0,
|
|
},
|
|
&"video": {
|
|
&"fullscreen": true
|
|
}
|
|
}
|
|
|
|
|
|
func _ready() -> void:
|
|
load_settings()
|
|
|
|
|
|
func load_settings() -> void:
|
|
if not FileAccess.file_exists(SETTINGS_PATH):
|
|
save_settings()
|
|
return
|
|
|
|
var config := ConfigFile.new()
|
|
config.load(SETTINGS_PATH)
|
|
|
|
for section: String in settings.keys():
|
|
for key: String in settings[section].keys():
|
|
var default: Variant = get_setting(section, key)
|
|
set_setting(section, key, config.get_value(section, key, default), false)
|
|
|
|
|
|
func save_settings() -> void:
|
|
var config := ConfigFile.new()
|
|
|
|
for section: String in settings.keys():
|
|
for key: String in settings[section].keys():
|
|
config.set_value(section, key, settings[section][key])
|
|
|
|
config.save(SETTINGS_PATH)
|
|
|
|
|
|
func set_setting(section: String, key: String, value: Variant, do_save: bool = true) -> void:
|
|
settings[section][key] = value
|
|
|
|
if do_save:
|
|
save_settings()
|
|
|
|
|
|
func get_setting(section: String, key: String) -> Variant:
|
|
return settings[section][key]
|
|
|
|
|
|
func adjust_volume(bus: StringName, volume: float) -> void:
|
|
set_setting(&"audio", bus, volume, false)
|
|
return
|
|
|
|
var fmod_bus: FmodBus = FmodServer.get_bus(str("res://components/fmod/Build/Desktop/", bus, ".bank"))
|
|
if is_instance_valid(fmod_bus):
|
|
fmod_bus.volume = volume
|
|
|
|
|
|
func set_fullscreen(fullscreened: bool) -> void:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN if fullscreened else DisplayServer.WINDOW_MODE_WINDOWED)
|
|
set_setting(&"video", &"fullscreen", fullscreened)
|