public bool Load(string filepath = "") { if (!String.IsNullOrEmpty(filepath)) { FilePath = filepath; } // Load config file if (File.Exists(Defines.ConfigFile)) { configTable = Toml.ReadFile(Defines.ConfigFile).ToDictionary(); if (configTable.ContainsKey(Defines.KeyConfig)) { InputMonitor.SetKeys((Dictionary <string, object>)configTable[Defines.KeyConfig]); } if (configTable.ContainsKey(Defines.TouchConfig)) { TouchSettings.SetConfig((Dictionary <string, object>)configTable[Defines.TouchConfig]); } if (configTable.ContainsKey(Defines.GameConfig)) { GameSettingsScreen.SetConfig((Dictionary <string, object>)configTable[Defines.GameConfig]); } } else { // Build defaults } return(true); }
public void Update() { configTable = new Dictionary <string, object>() { { Defines.KeyConfig, InputMonitor.GetConfig() }, { Defines.TouchConfig, TouchSettings.GetConfig() }, { Defines.GameConfig, GameSettingsScreen.GetConfig() } }; }
public void Save(string filepath = "") { if (!String.IsNullOrEmpty(filepath)) { FilePath = filepath; } var data = new Dictionary <string, object>() { { Defines.KeyConfig, InputMonitor.GetConfig() }, { Defines.TouchConfig, TouchSettings.GetConfig() }, { Defines.GameConfig, GameSettingsScreen.GetConfig() } }; Toml.WriteFile(data, Defines.ConfigFile); // Should this go here? I don't see why we would save if we didn't want to apply it immediately UpdateGlobals(); }