Skip to content

Commit

Permalink
Fix some window UIScale bugs (#5499)
Browse files Browse the repository at this point in the history
* Fix some window UIScale bugs

* Use CalculateAutoScale()
  • Loading branch information
wixoaGit authored Oct 18, 2024
1 parent c65c4ba commit 008babe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Robust.Client/Graphics/Clyde/Clyde.Windowing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ public IClydeWindow CreateWindow(WindowCreateParameters parameters)
if (isMain)
_mainWindow = reg;

reg.IsVisible = parameters.Visible;

_windows.Add(reg);
_windowHandles.Add(reg.Handle);

Expand Down
5 changes: 3 additions & 2 deletions Robust.Client/UserInterface/Controls/OSWindow.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -192,7 +193,7 @@ private void OnWindowDestroyed(WindowDestroyedEventArgs obj)

private void OnWindowResized(WindowResizedEventArgs obj)
{
SetSize = obj.NewSize;
SetSize = obj.NewSize / UIScale;
}

private void RealClosed()
Expand Down
6 changes: 4 additions & 2 deletions Robust.Client/UserInterface/UserInterfaceManager.Roots.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

Expand Down

0 comments on commit 008babe

Please sign in to comment.