]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Scale text in admin player overlay (#31503)
authoreoineoineoin <github@eoinrul.es>
Tue, 27 Aug 2024 14:43:47 +0000 (15:43 +0100)
committerGitHub <noreply@github.com>
Tue, 27 Aug 2024 14:43:47 +0000 (16:43 +0200)
* Scale text in admin player overlay

Fixes #30040

* Feedback from PR - get UI scale through root window

---------

Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es>
Content.Client/Administration/AdminNameOverlay.cs
Content.Client/Administration/Systems/AdminSystem.Overlay.cs

index 6a1881a2276073e5006189a12112fee30c26919c..e2db7a8d6b4cbc8c7637eb819be6123d8688dd8a 100644 (file)
@@ -2,10 +2,10 @@ using System.Numerics;
 using Content.Client.Administration.Systems;
 using Robust.Client.Graphics;
 using Robust.Client.ResourceManagement;
+using Robust.Client.UserInterface;
+using Robust.Shared;
 using Robust.Shared.Enums;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
-using Robust.Shared.Maths;
+using Robust.Shared.Configuration;
 
 namespace Content.Client.Administration;
 
@@ -15,14 +15,16 @@ internal sealed class AdminNameOverlay : Overlay
     private readonly IEntityManager _entityManager;
     private readonly IEyeManager _eyeManager;
     private readonly EntityLookupSystem _entityLookup;
+    private readonly IUserInterfaceManager _userInterfaceManager;
     private readonly Font _font;
 
-    public AdminNameOverlay(AdminSystem system, IEntityManager entityManager, IEyeManager eyeManager, IResourceCache resourceCache, EntityLookupSystem entityLookup)
+    public AdminNameOverlay(AdminSystem system, IEntityManager entityManager, IEyeManager eyeManager, IResourceCache resourceCache, EntityLookupSystem entityLookup, IUserInterfaceManager userInterfaceManager)
     {
         _system = system;
         _entityManager = entityManager;
         _eyeManager = eyeManager;
         _entityLookup = entityLookup;
+        _userInterfaceManager = userInterfaceManager;
         ZIndex = 200;
         _font = new VectorFont(resourceCache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
     }
@@ -57,16 +59,18 @@ internal sealed class AdminNameOverlay : Overlay
                 continue;
             }
 
-            var lineoffset = new Vector2(0f, 11f);
+            var uiScale = _userInterfaceManager.RootControl.UIScale;
+            var lineoffset = new Vector2(0f, 11f) * uiScale;
             var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center +
                                                               new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec(
                                                                   aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f);
             if (playerInfo.Antag)
             {
-                args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), "ANTAG", Color.OrangeRed);
+                args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), "ANTAG", uiScale, Color.OrangeRed);
+;
             }
-            args.ScreenHandle.DrawString(_font, screenCoordinates+lineoffset, playerInfo.Username, playerInfo.Connected ? Color.Yellow : Color.White);
-            args.ScreenHandle.DrawString(_font, screenCoordinates, playerInfo.CharacterName, playerInfo.Connected ? Color.Aquamarine : Color.White);
+            args.ScreenHandle.DrawString(_font, screenCoordinates+lineoffset, playerInfo.Username, uiScale, playerInfo.Connected ? Color.Yellow : Color.White);
+            args.ScreenHandle.DrawString(_font, screenCoordinates, playerInfo.CharacterName, uiScale, playerInfo.Connected ? Color.Aquamarine : Color.White);
         }
     }
 }
index 3502faf9e8e83eac971f10d0729c9000dc9ed3f1..ba6ce40ca0b796c32f71dde73d078b493df0bc70 100644 (file)
@@ -1,6 +1,8 @@
 using Content.Client.Administration.Managers;
 using Robust.Client.Graphics;
 using Robust.Client.ResourceManagement;
+using Robust.Client.UserInterface;
+using Robust.Shared.Configuration;
 
 namespace Content.Client.Administration.Systems
 {
@@ -11,6 +13,7 @@ namespace Content.Client.Administration.Systems
         [Dependency] private readonly IClientAdminManager _adminManager = default!;
         [Dependency] private readonly IEyeManager _eyeManager = default!;
         [Dependency] private readonly EntityLookupSystem _entityLookup = default!;
+        [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
 
         private AdminNameOverlay _adminNameOverlay = default!;
 
@@ -19,7 +22,7 @@ namespace Content.Client.Administration.Systems
 
         private void InitializeOverlay()
         {
-            _adminNameOverlay = new AdminNameOverlay(this, EntityManager, _eyeManager, _resourceCache, _entityLookup);
+            _adminNameOverlay = new AdminNameOverlay(this, EntityManager, _eyeManager, _resourceCache, _entityLookup, _userInterfaceManager);
             _adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
         }