From 0c881af6fbeef5022f9c48b993b1d2a2f0df026e Mon Sep 17 00:00:00 2001 From: Melon Bread Date: Tue, 26 Apr 2022 18:26:12 -0400 Subject: [PATCH] Added inital logic for loading game settings --- src/Save/save_settings.gd | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Save/save_settings.gd diff --git a/src/Save/save_settings.gd b/src/Save/save_settings.gd new file mode 100644 index 0000000..7202e0b --- /dev/null +++ b/src/Save/save_settings.gd @@ -0,0 +1,30 @@ +extends Node + +const SETTINGS_FILE = "GameSettings.save" + +var game_data: = {} + +func _ready() -> void: + load_data() + +func load_data(): + var file: = File.new() + + if not file.file_exists(SETTINGS_FILE): + game_data = { + "fullscreen": false, + "vsync": false, + "particle_effects": true, + "master_vol": -10 + } + save_data() + + file.open(SETTINGS_FILE, File.READ) + game_data = file.get_var() + file.close() + +func save_data(): + var file: = File.new() + file.open(SETTINGS_FILE, File.WRITE) + file.store_var(game_data) + file.close()