]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Don't draw handitem offscreen (#16193)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 7 May 2023 03:37:05 +0000 (13:37 +1000)
committerGitHub <noreply@github.com>
Sun, 7 May 2023 03:37:05 +0000 (13:37 +1000)
Content.Client/Hands/ShowHandItemOverlay.cs

index 9b478333c8cd8e923b9a3c2582f924ceda1dc3d9..81a59cc475b7d38e59cda78852a188616c24e729 100644 (file)
@@ -6,6 +6,7 @@ using Robust.Client.Input;
 using Robust.Client.UserInterface;
 using Robust.Shared.Configuration;
 using Robust.Shared.Enums;
+using Robust.Shared.Map;
 
 namespace Content.Client.Hands
 {
@@ -44,18 +45,28 @@ namespace Content.Client.Hands
             _renderBackbuffer.Dispose();
         }
 
-        protected override void Draw(in OverlayDrawArgs args)
+        protected override bool BeforeDraw(in OverlayDrawArgs args)
         {
             if (!_cfg.GetCVar(CCVars.HudHeldItemShow))
+                return false;
+
+            return base.BeforeDraw(in args);
+        }
+
+        protected override void Draw(in OverlayDrawArgs args)
+        {
+            var mousePos = _inputManager.MouseScreenPosition;
+
+            // Offscreen
+            if (mousePos.Window == WindowId.Invalid)
                 return;
 
             var screen = args.ScreenHandle;
             var offset = _cfg.GetCVar(CCVars.HudHeldItemOffset);
-            var mousePos = _inputManager.MouseScreenPosition.Position;
 
             if (IconOverride != null)
             {
-                screen.DrawTexture(IconOverride, mousePos - IconOverride.Size / 2 + offset, Color.White.WithAlpha(0.75f));
+                screen.DrawTexture(IconOverride, mousePos.Position - IconOverride.Size / 2 + offset, Color.White.WithAlpha(0.75f));
                 return;
             }
 
@@ -73,7 +84,7 @@ namespace Content.Client.Hands
                 screen.DrawEntity(handEntity.Value, halfSize, new Vector2(1f, 1f) * uiScale, Angle.Zero, Angle.Zero, Direction.South, sprite);
             }, Color.Transparent);
 
-            screen.DrawTexture(_renderBackbuffer.Texture, mousePos - halfSize + offset, Color.White.WithAlpha(0.75f));
+            screen.DrawTexture(_renderBackbuffer.Texture, mousePos.Position - halfSize + offset, Color.White.WithAlpha(0.75f));
         }
     }
 }