public static bool IsValidPlayWindowResolution(ResolutionConfig resolution) { foreach (ResolutionConfig res in PlayWindowResolutionsList) if (resolution.Width == res.Width && resolution.Height == res.Height) return true; return false; }
public static bool IsValidFullScreenResolution(ResolutionConfig resolution) { foreach (ResolutionConfig res in FullScreenResolutionsList) if (resolution.Width == res.Width && resolution.Height == res.Height) return true; return false; }
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); } } }
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; }
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); } } }
private void SetGraphicsDeviceWidthHeight(ResolutionConfig resolution) { GraphicsDeviceManager.PreferredBackBufferWidth = resolution.Width; GraphicsDeviceManager.PreferredBackBufferHeight = resolution.Height; GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Settings.Game.IsVSyncEnabled; GraphicsDeviceManager.ApplyChanges(); }
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); }
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); } } }
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); }