Пример #1
0
        public bool Handle(IEvent evt)
        {
            if (evt is StepGameUpdateEvent)
            {
                Update(CVars.Get <float>("debug_game_step_period"));
            }

            if (evt is GameShutdownEvent)
            {
                Exit();
            }

            if (evt is ReloadDisplayOptionsEvent)
            {
                ReloadDisplayOptions();
            }

            return(false);
        }
Пример #2
0
        private void ReloadDisplayOptions()
        {
            bool applyChanges = false;

            DisplayModeCollection displayModes = Graphics.GraphicsDevice.Adapter.SupportedDisplayModes;

            // Windowed/Borderless/Fullscreen
            if (CVars.Get <bool>("display_fullscreen"))
            {
                if (!Graphics.IsFullScreen)
                {
                    if (CVars.Get <int>("display_fullscreen_width") < 0 || CVars.Get <int>("display_fullscreen_height") < 0)
                    {
                        CVars.Get <int>("display_fullscreen_width")  = Graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width;
                        CVars.Get <int>("display_fullscreen_height") = Graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height;
                        CVars.Save();
                    }

                    Graphics.PreferredBackBufferWidth  = CVars.Get <int>("display_fullscreen_width");
                    Graphics.PreferredBackBufferHeight = CVars.Get <int>("display_fullscreen_height");

                    Graphics.IsFullScreen       = true;
                    Graphics.HardwareModeSwitch = true;
                    applyChanges = true;
                }

                CVars.Get <bool>("display_borderless") = false;
                CVars.Get <bool>("display_windowed")   = false;
                CVars.Save();
            }
            else if (CVars.Get <bool>("display_borderless"))
            {
                if (!Graphics.IsFullScreen)
                {
                    Graphics.IsFullScreen       = true;
                    Graphics.HardwareModeSwitch = false;
                    applyChanges = true;
                }

                CVars.Get <bool>("display_windowed") = false;
                CVars.Save();
            }
            else
            {
                if (Graphics.IsFullScreen)
                {
                    Graphics.IsFullScreen = false;
                }
                Graphics.HardwareModeSwitch = false;
                applyChanges = true;

                CVars.Get <bool>("display_windowed") = true;
                CVars.Save();
            }

            // V-sync
            if (Graphics.SynchronizeWithVerticalRetrace
                != CVars.Get <bool>("display_vsync"))
            {
                Graphics.SynchronizeWithVerticalRetrace = CVars.Get <bool>("display_vsync");
                applyChanges = true;
            }

            if (applyChanges)
            {
                Graphics.ApplyChanges();
            }
        }