From 87e2755c31a972f8839b408e5cf78d4665533927 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:15:47 +1100 Subject: [PATCH] Fix shuttle IFF drawing (#25821) Didn't account for UI scale properly I love transforms. --- Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs b/Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs index 18122415f5..00ee6890b2 100644 --- a/Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs +++ b/Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs @@ -212,18 +212,20 @@ public sealed partial class ShuttleNavControl : BaseShuttleControl var distance = gridCentre.Length(); var labelText = Loc.GetString("shuttle-console-iff-label", ("name", labelName), ("distance", $"{distance:0.0}")); - var labelDimensions = handle.GetDimensions(Font, labelText, UIScale); + + // yes 1.0 scale is intended here. + var labelDimensions = handle.GetDimensions(Font, labelText, 1f); // y-offset the control to always render below the grid (vertically) - var yOffset = Math.Max(gridBounds.Height, gridBounds.Width) * MinimapScale / 1.8f / UIScale; + var yOffset = Math.Max(gridBounds.Height, gridBounds.Width) * MinimapScale / 1.8f; // The actual position in the UI. We offset the matrix position to render it off by half its width // plus by the offset. - var uiPosition = ScalePosition(gridCentre) / UIScale - new Vector2(labelDimensions.X / 2f, -yOffset); + var uiPosition = ScalePosition(gridCentre)- new Vector2(labelDimensions.X / 2f, -yOffset); // Look this is uggo so feel free to cleanup. We just need to clamp the UI position to within the viewport. - uiPosition = new Vector2(Math.Clamp(uiPosition.X, 0f, Width - labelDimensions.X), - Math.Clamp(uiPosition.Y, 0f, Height - labelDimensions.Y)); + uiPosition = new Vector2(Math.Clamp(uiPosition.X, 0f, PixelWidth - labelDimensions.X ), + Math.Clamp(uiPosition.Y, 0f, PixelHeight - labelDimensions.Y)); handle.DrawString(Font, uiPosition, labelText, color); } -- 2.51.2