]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Use new engine APIs for setting the scroll target of views (#35401)
authorpathetic meowmeow <uhhadd@gmail.com>
Sun, 23 Feb 2025 17:47:13 +0000 (12:47 -0500)
committerGitHub <noreply@github.com>
Sun, 23 Feb 2025 17:47:13 +0000 (18:47 +0100)
Content.Client/Atmos/Consoles/AtmosAlertsComputerWindow.xaml.cs
Content.Client/Atmos/Consoles/AtmosMonitoringConsoleWindow.xaml.cs
Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs
Content.Client/Power/PowerMonitoringWindow.xaml.Widgets.cs

index 81c9a409a3b4032b37f49c02bd359e78489c0f04..1268433cabf4adb38a183aa02b7b8b2886552ca4 100644 (file)
@@ -512,39 +512,15 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
         if (scroll == null)
             return;
 
-        if (!TryGetVerticalScrollbar(scroll, out var vScrollbar))
-            return;
-
         if (!TryGetNextScrollPosition(out float? nextScrollPosition))
             return;
 
-        vScrollbar.ValueTarget = nextScrollPosition.Value;
+        scroll.VScrollTarget = nextScrollPosition.Value;
 
-        if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
+        if (MathHelper.CloseToPercent(scroll.VScroll, scroll.VScrollTarget))
             _autoScrollActive = false;
     }
 
-    private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
-    {
-        vScrollBar = null;
-
-        foreach (var child in scroll.Children)
-        {
-            if (child is not VScrollBar)
-                continue;
-
-            var castChild = child as VScrollBar;
-
-            if (castChild != null)
-            {
-                vScrollBar = castChild;
-                return true;
-            }
-        }
-
-        return false;
-    }
-
     private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
     {
         nextScrollPosition = null;
index 515f91790f493e57d93ff0c6c12a1abb0e175817..e25c3af9e9076bd0dba2545988f7d17493f7ec5d 100644 (file)
@@ -350,35 +350,15 @@ public sealed partial class AtmosMonitoringConsoleWindow : FancyWindow
         if (scroll == null)
             return;
 
-        if (!TryGetVerticalScrollbar(scroll, out var vScrollbar))
-            return;
-
         if (!TryGetNextScrollPosition(out float? nextScrollPosition))
             return;
 
-        vScrollbar.ValueTarget = nextScrollPosition.Value;
+        scroll.VScrollTarget = nextScrollPosition.Value;
 
-        if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
+        if (MathHelper.CloseToPercent(scroll.VScroll, scroll.VScrollTarget))
             _autoScrollActive = false;
     }
 
-    private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
-    {
-        vScrollBar = null;
-
-        foreach (var control in scroll.Children)
-        {
-            if (control is not VScrollBar)
-                continue;
-
-            vScrollBar = (VScrollBar)control;
-
-            return true;
-        }
-
-        return false;
-    }
-
     private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
     {
         nextScrollPosition = null;
index ac23e8216b2353965685e631fae32d6c2e13b00c..18c54cd231df57e5f7561ef6259545e61f942ec0 100644 (file)
@@ -372,14 +372,11 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
         if (!_tryToScrollToListFocus)
             return;
 
-        if (!TryGetVerticalScrollbar(SensorScroller, out var vScrollbar))
-            return;
-
         if (TryGetNextScrollPosition(out float? nextScrollPosition))
         {
-            vScrollbar.ValueTarget = nextScrollPosition.Value;
+            SensorScroller.VScrollTarget = nextScrollPosition.Value;
 
-            if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
+            if (MathHelper.CloseToPercent(SensorScroller.VScroll, SensorScroller.VScrollTarget))
             {
                 _tryToScrollToListFocus = false;
                 return;
@@ -387,22 +384,6 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
         }
     }
 
-    private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
-    {
-        vScrollBar = null;
-
-        foreach (var child in scroll.Children)
-        {
-            if (child is not VScrollBar)
-                continue;
-
-            vScrollBar = (VScrollBar) child;
-            return true;
-        }
-
-        return false;
-    }
-
     private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
     {
         nextScrollPosition = 0;
index 87b252e9d509f6755cb36b85e1166e5191c746c4..d3671e265ac3bc34cf381d4af2245e7f8b39072a 100644 (file)
@@ -269,27 +269,6 @@ public sealed partial class PowerMonitoringWindow
         return false;
     }
 
-    private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
-    {
-        vScrollBar = null;
-
-        foreach (var child in scroll.Children)
-        {
-            if (child is not VScrollBar)
-                continue;
-
-            var castChild = child as VScrollBar;
-
-            if (castChild != null)
-            {
-                vScrollBar = castChild;
-                return true;
-            }
-        }
-
-        return false;
-    }
-
     private void AutoScrollToFocus()
     {
         if (!_autoScrollActive)
@@ -299,15 +278,12 @@ public sealed partial class PowerMonitoringWindow
         if (scroll == null)
             return;
 
-        if (!TryGetVerticalScrollbar(scroll, out var vScrollbar))
-            return;
-
         if (!TryGetNextScrollPosition(out float? nextScrollPosition))
             return;
 
-        vScrollbar.ValueTarget = nextScrollPosition.Value;
+        scroll.VScrollTarget = nextScrollPosition.Value;
 
-        if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
+        if (MathHelper.CloseToPercent(scroll.VScroll, scroll.VScrollTarget))
             _autoScrollActive = false;
     }