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:
@@ -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;
|
||||
|
||||
@@ -90,7 +90,12 @@ namespace Barotrauma
|
||||
|
||||
displayModeDD.SelectItem(GameMain.Config.WindowMode);
|
||||
|
||||
displayModeDD.OnSelected = (guiComponent, obj) => { GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData; return true; };
|
||||
displayModeDD.OnSelected = (guiComponent, obj) =>
|
||||
{
|
||||
UnsavedSettings = true;
|
||||
GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData;
|
||||
return true;
|
||||
};
|
||||
|
||||
y += 70;
|
||||
|
||||
@@ -130,7 +135,6 @@ namespace Barotrauma
|
||||
foreach (ContentPackage contentPackage in ContentPackage.list)
|
||||
{
|
||||
contentPackageDD.AddItem(contentPackage.Name, contentPackage);
|
||||
|
||||
if (SelectedContentPackage == contentPackage) contentPackageDD.SelectItem(contentPackage);
|
||||
}
|
||||
|
||||
@@ -237,6 +241,11 @@ namespace Barotrauma
|
||||
Save("config.xml");
|
||||
|
||||
settingsFrame.Flash(Color.Green);
|
||||
|
||||
if (GameMain.WindowMode != GameMain.Config.WindowMode)
|
||||
{
|
||||
GameMain.Instance.SetWindowMode(GameMain.Config.WindowMode);
|
||||
}
|
||||
|
||||
if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user