From 008babebc67db0a7daa196a7a3630aea682ae8f8 Mon Sep 17 00:00:00 2001 From: wixoa Date: Fri, 18 Oct 2024 18:08:16 -0400 Subject: [PATCH] Fix some window UIScale bugs (#5499) * Fix some window UIScale bugs * Use CalculateAutoScale() --- Robust.Client/Graphics/Clyde/Clyde.Windowing.cs | 2 ++ Robust.Client/UserInterface/Controls/OSWindow.cs | 5 +++-- Robust.Client/UserInterface/UserInterfaceManager.Roots.cs | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Robust.Client/Graphics/Clyde/Clyde.Windowing.cs b/Robust.Client/Graphics/Clyde/Clyde.Windowing.cs index 31776f53af5..b824dcd1a3f 100644 --- a/Robust.Client/Graphics/Clyde/Clyde.Windowing.cs +++ b/Robust.Client/Graphics/Clyde/Clyde.Windowing.cs @@ -343,6 +343,8 @@ public IClydeWindow CreateWindow(WindowCreateParameters parameters) if (isMain) _mainWindow = reg; + reg.IsVisible = parameters.Visible; + _windows.Add(reg); _windowHandles.Add(reg.Handle); diff --git a/Robust.Client/UserInterface/Controls/OSWindow.cs b/Robust.Client/UserInterface/Controls/OSWindow.cs index 63d7e6e1083..a35e7fa4713 100644 --- a/Robust.Client/UserInterface/Controls/OSWindow.cs +++ b/Robust.Client/UserInterface/Controls/OSWindow.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel; -using System.Numerics; using Robust.Client.Graphics; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.IoC; @@ -138,6 +137,8 @@ public IClydeWindow Create() _root = UserInterfaceManager.CreateWindowRoot(ClydeWindow); _root.AddChild(this); + // Resize the window by our UIScale + ClydeWindow.Size = new((int)(ClydeWindow.Size.X * UIScale), (int)(ClydeWindow.Size.Y * UIScale)); return ClydeWindow; } @@ -192,7 +193,7 @@ private void OnWindowDestroyed(WindowDestroyedEventArgs obj) private void OnWindowResized(WindowResizedEventArgs obj) { - SetSize = obj.NewSize; + SetSize = obj.NewSize / UIScale; } private void RealClosed() diff --git a/Robust.Client/UserInterface/UserInterfaceManager.Roots.cs b/Robust.Client/UserInterface/UserInterfaceManager.Roots.cs index e159a728c9b..c1a48829634 100644 --- a/Robust.Client/UserInterface/UserInterfaceManager.Roots.cs +++ b/Robust.Client/UserInterface/UserInterfaceManager.Roots.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Robust.Client.Graphics; using Robust.Client.UserInterface.Controls; +using Robust.Shared; using Robust.Shared.Map; using Robust.Shared.Utility; @@ -28,10 +29,11 @@ public WindowRoot CreateWindowRoot(IClydeWindow window) { MouseFilter = Control.MouseFilterMode.Ignore, HorizontalAlignment = Control.HAlignment.Stretch, - VerticalAlignment = Control.VAlignment.Stretch, - UIScaleSet = window.ContentScale.X + VerticalAlignment = Control.VAlignment.Stretch }; + newRoot.UIScaleSet = CalculateAutoScale(newRoot); + _roots.Add(newRoot); _windowsToRoot.Add(window.Id, newRoot);