mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-19 19:44:46 +00:00
Merge branch 'main' into 'develop'
🐛 Fix default settings not being applied See merge request open-fpsz/open-fpsz!65
This commit is contained in:
commit
dd84c965c9
|
|
@ -2,24 +2,25 @@ class_name Settings extends Node
|
|||
|
||||
var _config_file : ConfigFile = ConfigFile.new()
|
||||
|
||||
var fov : int
|
||||
var mouse_sensitivity : float
|
||||
var inverted_y_axis : bool
|
||||
var fullscreen : bool
|
||||
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")
|
||||
return
|
||||
|
||||
fov = _config_file.get_value("gameplay", "fov", 90)
|
||||
mouse_sensitivity = _config_file.get_value("gameplay", "mouse_sensitivity", 0.6)
|
||||
inverted_y_axis = _config_file.get_value("gameplay", "inverted_y_axis", false)
|
||||
fullscreen = _config_file.get_value("graphics", "fullscreen", false)
|
||||
_update_screen()
|
||||
save_to_file()
|
||||
|
||||
func save_to_file() -> void:
|
||||
_config_file.set_value("gameplay", "fov", fov)
|
||||
|
|
|
|||
Loading…
Reference in a new issue