public OptionsMenuScreen() : base("Game Options") { options = new Options(); #if PC options.ChangeSetting(Options.Setting.Fullscreen, DarkHavocGame.GameOptions.IsFullscreen); #endif options.ChangeSetting(Options.Setting.Music, DarkHavocGame.GameOptions.IsMusic); options.ChangeSetting(Options.Setting.Sound, DarkHavocGame.GameOptions.IsSound); #if PC fullscreen = new MenuEntry(string.Empty); #endif music = new MenuEntry(string.Empty); sound = new MenuEntry(string.Empty); save = new MenuEntry("Save"); back = new MenuEntry("Back"); #if PC fullscreen.Selected += new EventHandler<PlayerIndexEventArgs>(fullscreen_Selected); #endif music.Selected += new EventHandler<PlayerIndexEventArgs>(music_Selected); sound.Selected += new EventHandler<PlayerIndexEventArgs>(sound_Selected); save.Selected += new EventHandler<PlayerIndexEventArgs>(save_Selected); back.Selected += OnCancel; SetMenuText(); #if PC MenuEntries.Add(fullscreen); #endif MenuEntries.Add(music); MenuEntries.Add(sound); MenuEntries.Add(save); MenuEntries.Add(back); }
/// <summary> /// Instantiates new object of DarkHavocGame. /// </summary> public DarkHavocGame() { #if MONOMAC // Set the Window Background Color to Black, since it defaults to gray. Window.Window.BackgroundColor = NSColor.Black; #endif // Create new Options in case it has been deleted or we're starting for the first time. GameOptions = new Options(); Debug.WriteLine("[Dark Havoc] Running on " + GameOptions.UserOS); #if MONOMAC NSDictionary systemVersionDictionary = new NSDictionary(@"/System/Library/CoreServices/SystemVersion.plist"); NSString versionString = (NSString)systemVersionDictionary.ObjectForKey((NSString)@"ProductVersion"); Debug.WriteLine("[Dark Havoc] Running on Mac OS X Version: " + versionString.ToString()); #endif string location = ""; #if !MONOMAC location = "./"; #else location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library/Application Support/Dark Havoc/"); if (!Directory.Exists(location)) Directory.CreateDirectory(location); #endif AppDataLocation = location; // Does the options file exist? if (File.Exists(location + "Settings.josho")) Options.DeserializeToObject(location, out GameOptions); // If so then deserialize it! else { #if WINDOWS MessageBox.Show("Thanks for playing Dark Havoc!\n\nIf you run into any issues, please don't hesitate to contact me!", "Dark Havoc - First Run", MessageBoxButtons.OK, MessageBoxIcon.Information); #elif MONOMAC NSAlert dialogue = new NSAlert(); dialogue.InformativeText = "Thanks for playing Dark Havoc!\n\nIf you run into any issues, please don't hesitate to contact me!"; dialogue.MessageText = "First Run"; dialogue.RunModal(); #endif Options.SerializeToFile(location, GameOptions); // Since we instantiated a default Options, just recreate it. } // Set the window title to Dark Havoc! :) this.Window.Title = "Dark Havoc"; // Set the content root directory to the Resources folder. #if WINDOWS Content.RootDirectory = "Resources"; #elif MONOMAC Content.RootDirectory = "Content"; #endif // Create new instance of GraphicsDeviceManager with the pointer to this game class. graphics = new GraphicsDeviceManager(this); // Hide the mouse until we need it. this.IsMouseVisible = false; #if WINDOWS // This is where we handle MonoGame WinGL being slow at creating the window. windowCreationBackgroundWorker = new BackgroundWorker(); windowCreationBackgroundWorker.DoWork += new DoWorkEventHandler(windowCreationBackgroundWorker_DoWork); windowCreationBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(windowCreationBackgroundWorker_RunWorkerCompleted); #endif }
public static bool CheckDifferences(Options options1, Options options2) { #if PC if (options1.fullscreen == options2.fullscreen && options1.music == options2.music && options1.sound == options2.sound) return true; else return false; #else if (options1.music == options2.music && options1.sound == options2.sound) return true; else return false; #endif }
public static void SerializeToFile(string location, Options options) { BinaryFormatter bf = new BinaryFormatter(); FileStream fs = new FileStream(location + "Settings.josho", FileMode.Create); bf.Serialize(fs, options); fs.Close(); fs.Dispose(); }
public static void DeserializeToObject(string location, out Options options) { BinaryFormatter bf = new BinaryFormatter(); FileStream fs = new FileStream(location + "Settings.josho", FileMode.Open); options = (Options)bf.Deserialize(fs); fs.Close(); fs.Dispose(); }