From b3b9167c48549d93845f001d07b77c404014d408 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 4 Jun 2019 15:31:27 +0300 Subject: [PATCH] (034bb920b) Fixed selecting display resolution when using borderless on Linux --- Barotrauma/BarotraumaClient/Source/GameMain.cs | 15 +++++++-------- .../BarotraumaClient/Source/GameSettings.cs | 6 +++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index 9a37a1f96..fe28df09d 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -92,6 +92,9 @@ namespace Barotrauma public static GameSettings Config; + public static int DisplayWidth { get; private set; } + public static int DisplayHeight { get; private set; } + private CoroutineHandle loadingCoroutine; private bool hasLoaded; @@ -223,11 +226,6 @@ namespace Barotrauma GraphicsWidth = Config.GraphicsWidth; GraphicsHeight = Config.GraphicsHeight; - if (Config.WindowMode == WindowMode.BorderlessWindowed) - { - GraphicsWidth = GraphicsDevice.DisplayMode.Width; - GraphicsHeight = GraphicsDevice.DisplayMode.Height; - } GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.Reach; GraphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color; @@ -269,6 +267,9 @@ namespace Barotrauma { base.Initialize(); + DisplayWidth = GraphicsDevice.DisplayMode.Width; + DisplayHeight = GraphicsDevice.DisplayMode.Height; + RequestGraphicsSettings(); ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true }; @@ -330,6 +331,7 @@ namespace Barotrauma ApplyGraphicsSettings(); yield return CoroutineStatus.Success; } +#endif private void HandleDefocus(object sender, EventArgs e) { @@ -346,9 +348,6 @@ namespace Barotrauma } #endif - loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "", canLoadInSeparateThread); - } - private void InitUserStats() { if (GameSettings.ShowUserStatisticsPrompt) diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index 8b9ae6b9f..cea6be3d5 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -199,7 +199,7 @@ namespace Barotrauma // In a bundled .app you just disable HiDPI in the info.plist // but that's probably not gonna happen. - if (mode.Width > GameMain.Instance.GraphicsDevice.DisplayMode.Width || mode.Height > GameMain.Instance.GraphicsDevice.DisplayMode.Height) { continue; } + if (mode.Width > GameMain.DisplayWidth || mode.Height > GameMain.DisplayHeight) { continue; } #endif supportedDisplayModes.Add(mode); } @@ -247,8 +247,8 @@ namespace Barotrauma if (GameMain.Config.WindowMode == WindowMode.BorderlessWindowed) { resolutionDD.SelectItem(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.First( - m => m.Width == GameMain.Instance.GraphicsDevice.DisplayMode.Width && - m.Height == GameMain.Instance.GraphicsDevice.DisplayMode.Height)); + m => m.Width == GameMain.DisplayWidth && + m.Height == GameMain.DisplayHeight)); resolutionDD.ButtonEnabled = false; } else