Window mode can be changed mid-game, fixed "apply" button not becoming active in the settings menu when changing the window mode

This commit is contained in:
Joonas Rikkonen
2018-01-24 16:07:26 +02:00
parent 7199095c40
commit 30e624e572
2 changed files with 28 additions and 7 deletions
+17 -5
View File
@@ -74,6 +74,12 @@ namespace Barotrauma
private set;
}
public static WindowMode WindowMode
{
get;
private set;
}
public static int GraphicsWidth
{
get;
@@ -155,7 +161,7 @@ namespace Barotrauma
GraphicsDeviceManager.PreferMultiSampling = false;
GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
if (Config.WindowMode == WindowMode.Windowed)
if (Config.WindowMode == Barotrauma.WindowMode.Windowed)
{
//for whatever reason, window isn't centered automatically
//since MonoGame 3.6 (nuget package might be broken), so
@@ -164,17 +170,23 @@ namespace Barotrauma
(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - GraphicsHeight) / 2);
}
GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
GraphicsDeviceManager.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth;
GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight;
GraphicsDeviceManager.ApplyChanges();
SetWindowMode(Config.WindowMode);
defaultViewport = GraphicsDevice.Viewport;
}
public void SetWindowMode(WindowMode windowMode)
{
WindowMode = windowMode;
GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
GraphicsDeviceManager.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
GraphicsDeviceManager.ApplyChanges();
}
public void ResetViewPort()
{
GraphicsDevice.Viewport = defaultViewport;