Example #1
0
 public static bool IsValidPlayWindowResolution(ResolutionConfig resolution)
 {
     foreach (ResolutionConfig res in PlayWindowResolutionsList)
         if (resolution.Width == res.Width && resolution.Height == res.Height)
             return true;
     return false;
 }
Example #2
0
 public static bool IsValidFullScreenResolution(ResolutionConfig resolution)
 {
     foreach (ResolutionConfig res in FullScreenResolutionsList)
         if (resolution.Width == res.Width && resolution.Height == res.Height)
             return true;
     return false;
 }
Example #3
0
        public static void SetScreenSize(GameWindow window)
        {
            Microsoft.Xna.Framework.Rectangle game;
            System.Drawing.Rectangle screen;

            if (window != null)
            {
                game = window.ClientBounds;
                screen = Screen.GetWorkingArea(new System.Drawing.Rectangle(game.X, game.Y, game.Width, game.Height));
            }
            else
            {
                screen = Screen.GetWorkingArea(new System.Drawing.Point(0, 0));
            }

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if (mode.Format != SurfaceFormat.Color)
                    continue;
                ResolutionConfig res = new ResolutionConfig(mode.Width, mode.Height);
                if (!FullScreenResolutionsList.Contains(res))
                {
                    FullScreenResolutionsList.Add(res);
                }
            }

            foreach (ResolutionConfig res in FullScreenResolutionsList)
            {
                if (!PlayWindowResolutionsList.Contains(res) && res.Width <= screen.Width && res.Height <= screen.Height)
                {
                    PlayWindowResolutionsList.Add(res);
                }
            }
        }
Example #4
0
 public WorldSettings()
 {
     FullScreenResolution = new ResolutionConfig(1024, 768);
     WindowResolution = new ResolutionConfig(1024, 768);
     PlayWindowGumpResolution = new ResolutionConfig(1024, 768);
     m_PlayWindowPixelDoubling = false;
     IsMaximized = false;
     Mouse = new MouseConfig();
     AlwaysRun = false;
     MenuBarDisabled = false;
 }
Example #5
0
 public WorldSettings()
 {
     FullScreenResolution      = new ResolutionConfig(1024, 768);
     WindowResolution          = new ResolutionConfig(1024, 768);
     PlayWindowGumpResolution  = new ResolutionConfig(1024, 768);
     m_PlayWindowPixelDoubling = false;
     IsMaximized     = false;
     Mouse           = new MouseConfig();
     AlwaysRun       = false;
     MenuBarDisabled = false;
 }
Example #6
0
        static Resolutions()
        {
            FullScreenResolutionsList = new List<ResolutionConfig>();
            PlayWindowResolutionsList = new List<ResolutionConfig>();

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if (mode.Format != SurfaceFormat.Color)
                    continue;
                ResolutionConfig res = new ResolutionConfig(mode.Width, mode.Height);
                if (!FullScreenResolutionsList.Contains(res))
                {
                    FullScreenResolutionsList.Add(res);
                }
            }

            foreach (ResolutionConfig res in FullScreenResolutionsList)
            {
                if (!PlayWindowResolutionsList.Contains(res) && res.Width < 2048 && res.Height < 2048)
                {
                    PlayWindowResolutionsList.Add(res);
                }
            }
        }
Example #7
0
 private void SetGraphicsDeviceWidthHeight(ResolutionConfig resolution)
 {
     GraphicsDeviceManager.PreferredBackBufferWidth = resolution.Width;
     GraphicsDeviceManager.PreferredBackBufferHeight = resolution.Height;
     GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Settings.Game.IsVSyncEnabled;
     GraphicsDeviceManager.ApplyChanges();
 }
Example #8
0
 private void OnWindowSizeChanged(object sender, EventArgs e)
 {
     GameWindow window = (sender as GameWindow);
     ResolutionConfig resolution = new ResolutionConfig(window.ClientBounds.Width, window.ClientBounds.Height);
     // this only occurs when the world is active. Make sure that we don't reduce the window size
     // smaller than the world gump size.
     if (resolution.Width < Settings.World.PlayWindowGumpResolution.Width)
         resolution.Width = Settings.World.PlayWindowGumpResolution.Width;
     if (resolution.Height < Settings.World.PlayWindowGumpResolution.Height)
         resolution.Height = Settings.World.PlayWindowGumpResolution.Height;
     SetGraphicsDeviceWidthHeight(resolution);
 }
Example #9
0
        public void BuildResolutionsLists()
        {
            if (m_FullScreenResolutionsList != null)
                m_FullScreenResolutionsList.Clear();
            else
                m_FullScreenResolutionsList = new List<ResolutionConfig>();

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                ResolutionConfig res = new ResolutionConfig(mode.Width, mode.Height);
                if (!m_FullScreenResolutionsList.Contains(res))
                {
                    m_FullScreenResolutionsList.Add(res);
                }
            }

            if (m_PlayWindowResolutionsList != null)
                m_PlayWindowResolutionsList.Clear();
            else
                m_PlayWindowResolutionsList = new List<ResolutionConfig>();

            foreach (ResolutionConfig res in m_FullScreenResolutionsList)
            {
                if (!m_PlayWindowResolutionsList.Contains(res) && res.Width < 2048 && res.Height < 2048)
                {
                    m_PlayWindowResolutionsList.Add(res);
                }
            }
        }
Example #10
0
 private void CheckWindowSize(int minWidth, int minHeight)
 {
     GameWindow window = this.Window; // (sender as GameWindow);
     ResolutionConfig resolution = new ResolutionConfig(window.ClientBounds.Width, window.ClientBounds.Height);
     // this only occurs when the world is active. Make sure that we don't reduce the window size
     // smaller than the world gump size.
     if (resolution.Width < minWidth)
         resolution.Width = minWidth;
     if (resolution.Height < minHeight)
         resolution.Height = minHeight;
     if (resolution.Width != window.ClientBounds.Width || resolution.Height != window.ClientBounds.Height)
         SetGraphicsDeviceWidthHeight(resolution);
 }