Beispiel #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Applying graphics settings

            #if WINDOWS
            // ini settings file
            FAZEngine.IniFile settingsIni = new FAZEngine.IniFile(@".\configs\settings.ini");

            // fullscreen
            graphics.IsFullScreen = bool.Parse(settingsIni.IniReadValue("Options", "Fullscreen"));

            // resolution settings
            int sWidth = 0, sHeight = 0;
            if (int.TryParse(settingsIni.IniReadValue("Resolution", "Width"), out sWidth) &&
                int.TryParse(settingsIni.IniReadValue("Resolution", "Height"), out sHeight))
            {
                GlobalHelper.WindowWidth = sWidth;
                GlobalHelper.WindowHeight = sHeight;
            }
            else
            {
                GlobalHelper.WindowWidth = graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width;
                GlobalHelper.WindowHeight = graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height;
            }

            // use gamepad settings
            GlobalHelper.UseGamePad = bool.Parse(settingsIni.IniReadValue("Options", "UseGamePad"));
            IsMouseVisible = !GlobalHelper.UseGamePad;
            #else
            // START UP SETTINGS FOR XBOX
            GlobalHelper.UseGamePad = true;
            GlobalHelper.WindowWidth = GraphicsDevice.DisplayMode.Width;
            GlobalHelper.WindowHeight = GraphicsDevice.DisplayMode.Height;
            // if it's in 4:3 but "widescreen" at the same time, just use a fake 16:9 resolution
            if (GraphicsDevice.DisplayMode.AspectRatio == (float)4 / 3 && GraphicsDevice.Adapter.IsWideScreen)
            {
                GlobalHelper.WindowWidth = 1280;
                GlobalHelper.WindowHeight = 720;
            }
            #endif
            // msaa settings is done when preparing
            graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);

            graphics.PreferredBackBufferWidth = GlobalHelper.WindowWidth;
            graphics.PreferredBackBufferHeight = GlobalHelper.WindowHeight;
            //graphics.PreferMultiSampling = true;
            //GraphicsDevice.PresentationParameters.MultiSampleCount = 8;
            //graphics.SynchronizeWithVerticalRetrace = true;
            graphics.ApplyChanges();

            // After loading graphics settings, load audio engine manager
            audioEM = new AudioEM(this);

            base.Initialize();
        }
 protected override void OnCancel(PlayerIndex playerIndex)
 {
     // save settings to ini file
     #if WINDOWS
     FAZEngine.IniFile settingFile = new FAZEngine.IniFile(@".\configs\settings.ini");
     settingFile.IniWriteValue("Options", "Fullscreen", fullscreen.ToString());
     settingFile.IniWriteValue("Options", "MSAA", msaa.ToString());
     settingFile.IniWriteValue("Options", "UseGamePad", GlobalHelper.UseGamePad.ToString());
     #endif
     base.OnCancel(playerIndex);
 }
Beispiel #3
0
 void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
 {
     #if WINDOWS
     FAZEngine.IniFile settingsIni = new FAZEngine.IniFile(@".\configs\settings.ini");
     e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = int.Parse(settingsIni.IniReadValue("Options", "MSAA"));
     #else
     e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = 8;
     #endif
 }