(657674526) Reallow changing resolution in fullscreen/borderless. TODO: test, disable in borderless because it seems to do nothing?

This commit is contained in:
Joonas Rikkonen
2019-06-04 15:30:32 +03:00
parent 88c4c9a248
commit 93e4767fb8
17 changed files with 82 additions and 91 deletions
+33 -3
View File
@@ -236,8 +236,6 @@ namespace Barotrauma
GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth;
GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight;
GraphicsDeviceManager.ApplyChanges();
}
public void ResetViewPort()
@@ -255,7 +253,7 @@ namespace Barotrauma
{
base.Initialize();
ApplyGraphicsSettings();
RequestGraphicsSettings();
ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true };
@@ -294,6 +292,38 @@ namespace Barotrauma
#endif
loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "", canLoadInSeparateThread);
#if WINDOWS
var gameForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(Window.Handle);
gameForm.Activated += new EventHandler(HandleFocus);
gameForm.Deactivate += new EventHandler(HandleDefocus);
if (WindowActive) { HandleFocus(null, null); }
#endif
}
#if WINDOWS
private void HandleFocus(object sender, EventArgs e)
{
CoroutineManager.StopCoroutines("FocusCoroutine");
CoroutineManager.StartCoroutine(FocusCoroutine(),"FocusCoroutine");
}
private IEnumerable<object> FocusCoroutine()
{
yield return new WaitForSeconds(0.01f);
ApplyGraphicsSettings();
yield return CoroutineStatus.Success;
}
private void HandleDefocus(object sender, EventArgs e)
{
CoroutineManager.StopCoroutines("FocusCoroutine");
GraphicsDeviceManager.IsFullScreen = false;
GraphicsDeviceManager.ApplyChanges();
}
#endif
loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "", canLoadInSeparateThread);
}
private void InitUserStats()