mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-19 19:44:46 +00:00
38 lines
1.3 KiB
GDScript
38 lines
1.3 KiB
GDScript
class_name Settings extends Node
|
|
|
|
var _config_file : ConfigFile = ConfigFile.new()
|
|
|
|
var fov : int = 90
|
|
var mouse_sensitivity : float = 0.6
|
|
var inverted_y_axis : bool = false
|
|
var fullscreen : bool = false
|
|
|
|
const SETTINGS_FILE_PATH : String = "user://settings.cfg"
|
|
|
|
func _ready() -> void:
|
|
var error : Error = _config_file.load(SETTINGS_FILE_PATH)
|
|
|
|
fov = _config_file.get_value("gameplay", "fov", fov)
|
|
mouse_sensitivity = _config_file.get_value("gameplay", "mouse_sensitivity", mouse_sensitivity)
|
|
inverted_y_axis = _config_file.get_value("gameplay", "inverted_y_axis", inverted_y_axis)
|
|
fullscreen = _config_file.get_value("graphics", "fullscreen", fullscreen)
|
|
_update_screen()
|
|
|
|
if error != OK:
|
|
print("Settings not found, using defaults")
|
|
save_to_file()
|
|
|
|
func save_to_file() -> void:
|
|
_config_file.set_value("gameplay", "fov", fov)
|
|
_config_file.set_value("gameplay", "mouse_sensitivity", mouse_sensitivity)
|
|
_config_file.set_value("gameplay", "inverted_y_axis", inverted_y_axis)
|
|
_config_file.set_value("graphics", "fullscreen", fullscreen)
|
|
_update_screen()
|
|
_config_file.save(SETTINGS_FILE_PATH)
|
|
|
|
func _update_screen() -> void:
|
|
if fullscreen:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
|
else:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|