Added workaround to tabbing out breaking fullscreen
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using GameAnalyticsSDK.Net;
|
using GameAnalyticsSDK.Net;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -74,6 +75,7 @@ namespace Barotrauma
|
|||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
private static bool FullscreenOnTabIn;
|
||||||
|
|
||||||
public static WindowMode WindowMode
|
public static WindowMode WindowMode
|
||||||
{
|
{
|
||||||
@@ -231,8 +233,37 @@ namespace Barotrauma
|
|||||||
TitleScreen = new LoadingScreen(GraphicsDevice);
|
TitleScreen = new LoadingScreen(GraphicsDevice);
|
||||||
|
|
||||||
loadingCoroutine = CoroutineManager.StartCoroutine(Load());
|
loadingCoroutine = CoroutineManager.StartCoroutine(Load());
|
||||||
|
|
||||||
|
var myForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(Window.Handle);
|
||||||
|
myForm.Deactivate += new EventHandler(HandleDefocus);
|
||||||
|
myForm.Activated += new EventHandler(HandleFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleDefocus(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (GraphicsDeviceManager.IsFullScreen && GraphicsDeviceManager.HardwareModeSwitch)
|
||||||
|
{
|
||||||
|
GraphicsDeviceManager.IsFullScreen = false;
|
||||||
|
GraphicsDeviceManager.ApplyChanges();
|
||||||
|
FullscreenOnTabIn = true;
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleFocus(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (FullscreenOnTabIn)
|
||||||
|
{
|
||||||
|
GraphicsDeviceManager.HardwareModeSwitch = true;
|
||||||
|
GraphicsDeviceManager.IsFullScreen = true;
|
||||||
|
GraphicsDeviceManager.ApplyChanges();
|
||||||
|
FullscreenOnTabIn = false;
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void InitUserStats()
|
private void InitUserStats()
|
||||||
{
|
{
|
||||||
if (GameSettings.ShowUserStatisticsPrompt)
|
if (GameSettings.ShowUserStatisticsPrompt)
|
||||||
|
|||||||
Reference in New Issue
Block a user