GetDefaultSettings() public static method

public static GetDefaultSettings ( ) : Settings
return Settings
Example #1
0
        /// <summary>
        /// Opens the settings file and loads the values
        /// </summary>
        public static void LoadSettings(Game game)
        {
            try
            {
                Settings settings;
                //If config does not exist, create it and write the default settings
                if (!File.Exists(configFile))
                {
                    SaveAndApplyDefault(game);
                    return;
                }
                string json = File.ReadAllText(configFile);
                //If config is empty, regenerate it
                if (string.IsNullOrWhiteSpace(json))
                {
                    SaveAndApplyDefault(game);
                    return;
                }
                settings = JsonConvert.DeserializeObject <Settings>(json);
                ApplySettings(settings, game);
            }
            catch (Exception ex)
            {
#if DEBUG
                throw ex;
#else
                System.Windows.Forms.MessageBox.Show(ex.Message + "\nTry deleting your config file!", game.Window.Title + " Configuration Error");
                //Default fallback settings
                ApplySettings(Settings.GetDefaultSettings(), game);
#endif
            }
        }
Example #2
0
 private static void SaveAndApplyDefault(Game game)
 {
     SaveSettings(Settings.GetDefaultSettings());
     ApplySettings(Settings.GetDefaultSettings(), game);
 }