GetDefaultSettings() 공개 정적인 메소드

public static GetDefaultSettings ( ) : Settings
리턴 Settings
예제 #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
            }
        }
예제 #2
0
 private static void SaveAndApplyDefault(Game game)
 {
     SaveSettings(Settings.GetDefaultSettings());
     ApplySettings(Settings.GetDefaultSettings(), game);
 }