Exemplo n.º 1
0
        /// <summary>
        /// Load config.cfg. Returns true if the file was found, false otherwise
        /// </summary>
        /// <returns></returns>
        public static bool LoadConfig()
        {
            MyConfig objectToSerialize = new MyConfig();

            objectToSerialize = MySerializer.DeSerializeObject("config.cfg");

            // If the file wasn't found.
            if (objectToSerialize == null)
            {
                CUtil.Config = new MyConfig();
                return false;
            }

            CUtil.Config = objectToSerialize;
            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Write the MyConfig object to the config.cfg file.
        /// </summary>
        public static void SaveConfig()
        {
            //save the config to a file
            MyConfig objectToSerialize = new MyConfig();
            objectToSerialize.Highscores = CUtil.Config.Highscores;

            objectToSerialize.ScreenWidth = CUtil.ResolutionWidth;
            objectToSerialize.ScreenHeight = CUtil.ResolutionHeight;

            objectToSerialize.FullScreenWidth = CUtil.FullScreenResolution.X;
            objectToSerialize.FullScreenHeight = CUtil.FullScreenResolution.Y;

            objectToSerialize.IsFullscreen = CUtil.Graphics.IsFullScreen;
            objectToSerialize.IsLetterbox = CUtil.IsLetterBoxed;

            objectToSerialize.IsSFXOn = Options.IsSFXOn;

            objectToSerialize.MusicSelection = Options.CurrentMusicSelection;
            objectToSerialize.HeroSelection = Options.CurrentHeroSelection;

            MySerializer.SerializeObject("config.cfg", objectToSerialize);
        }
Exemplo n.º 3
0
 public static void SerializeObject(string filename, MyConfig objectToSerialize)
 {
     Stream stream = File.Open(filename, FileMode.Create);
     BinaryFormatter bFormatter = new BinaryFormatter();
     bFormatter.Serialize(stream, objectToSerialize);
     stream.Close();
 }