Exemple #1
0
        /// <summary>
        /// Load
        /// </summary>
        public static void Load()
        {
            _needSave = false;
            FileStream file = FileHelper.LoadGameContentFile(
                SettingsFilename);

            if (file == null)
            {
                _needSave = true;
                return;
            }

            // If the file is empty, just create a new file with the default
            // settings.
            if (file.Length == 0)
            {
                throw new Exception("Not yet finished.");
            }
            else
            {
                // Load everything into this class with the help of
                // the xmlserializer
                GameSettings loadedGameSettings =
                    (GameSettings)new XmlSerializer(typeof(GameSettings)).Deserialize(file);
                file.Close();

                if (loadedGameSettings != null)
                    _defaultInstance = loadedGameSettings;
            }
        }
Exemple #2
0
 public static void Initialize()
 {
     _defaultInstance = new GameSettings();
     Load();
 }