コード例 #1
0
ファイル: MySerializer.cs プロジェクト: Shnagenburg/ClimbGame
        /// <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;
        }
コード例 #2
0
ファイル: MySerializer.cs プロジェクト: Shnagenburg/ClimbGame
        /// <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);
        }
コード例 #3
0
ファイル: MySerializer.cs プロジェクト: Shnagenburg/ClimbGame
 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();
 }