Example #1
0
 public static void ResetGameSettings()
 {
     try
     {
         Directory.CreateDirectory(DevConstants.FileIOConstants.GameSettings.SettingsDirectory);
         if (!File.Exists(DevConstants.FileIOConstants.GameSettings.DefaultGameSettings))
         {
             FileIOSystem.CreateDefaultSettingsFile();
         }
         File.Copy(DevConstants.FileIOConstants.GameSettings.DefaultGameSettings, DevConstants.FileIOConstants.GameSettings.CurrentSettings, true);
     }
     catch
     {
         FileIOSystem.CreateDefaultSettingsFile();
         FileIOSystem.ResetGameSettings();
     }
 }
Example #2
0
 public static void LoadGameSettings(ref GameSettings gameSettings)
 {
     try
     {
         Directory.CreateDirectory(DevConstants.FileIOConstants.GameSettings.SettingsDirectory);
         if (!File.Exists(DevConstants.FileIOConstants.GameSettings.CurrentSettings))
         {
             FileIOSystem.ResetGameSettings();
             gameSettings.HasChanges = true;
         }
         using (StreamReader fs = File.OpenText(DevConstants.FileIOConstants.GameSettings.CurrentSettings))
         {
             JsonSerializer js = new JsonSerializer();
             gameSettings = (GameSettings)js.Deserialize(fs, typeof(GameSettings));
         }
     }
     catch
     {
         FileIOSystem.ResetGameSettings();
         FileIOSystem.LoadGameSettings(ref gameSettings);
     }
 }