コード例 #1
0
 public void ResetOptions()
 {
     Audio      = new AudioSettings();
     Graphics   = new GraphicsSettings();
     Controls   = new ControlsSettings();
     RubiksCube = new RubiksCubeSettings();
 }
コード例 #2
0
        public void Initialize(GraphicsDeviceManager graphics)
        {
            graphicsDevice = graphics;
            string filePath = Constants.SETTINGS_FILE;

            Audio      = new AudioSettings();
            Graphics   = new GraphicsSettings();
            Controls   = new ControlsSettings();
            RubiksCube = new RubiksCubeSettings();


            if (File.Exists(filePath))
            {
                StreamReader stream = new StreamReader(filePath, true);
                try
                {
                    LoadOptions(stream);
                }
                catch
                {
                    System.Windows.Forms.MessageBox.Show(
                        $"Error occured while loading from file '{filePath}', reseting file.",
                        "Error",
                        System.Windows.Forms.MessageBoxButtons.OK,
                        System.Windows.Forms.MessageBoxIcon.Error);
                    ResetOptions();
                }
                finally
                {
                    stream.Close();
                    stream.Dispose();
                }
            }
            Save();
            ApplyChanges();
        }