From 04b49b45a65994f0179c93f586154367c583939d Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Fri, 22 Oct 2021 10:10:33 +0200 Subject: [PATCH] Fix held item overlay UIScale calculation. Now correctly bases UI scale off viewport control and doesn't break if scale is automatic. --- Content.Client/Hands/ShowHandItemOverlay.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Content.Client/Hands/ShowHandItemOverlay.cs b/Content.Client/Hands/ShowHandItemOverlay.cs index 46cfb13ceb..2b6aab2fc1 100644 --- a/Content.Client/Hands/ShowHandItemOverlay.cs +++ b/Content.Client/Hands/ShowHandItemOverlay.cs @@ -1,7 +1,7 @@ using Content.Shared.CCVar; using Robust.Client.Graphics; using Robust.Client.Input; -using Robust.Shared; +using Robust.Client.UserInterface; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.GameObjects; @@ -51,9 +51,11 @@ namespace Content.Client.Hands var screen = args.ScreenHandle; var halfSize = _renderBackbuffer.Size / 2; + var uiScale = (args.ViewportControl as Control)?.UIScale ?? 1f; + screen.RenderInRenderTarget(_renderBackbuffer, () => { - screen.DrawEntity(handEntity, halfSize, new Vector2(1f, 1f) * _cfg.GetCVar(CVars.DisplayUIScale), Direction.South); + screen.DrawEntity(handEntity, halfSize, new Vector2(1f, 1f) * uiScale, Direction.South); }, Color.Transparent); var offset = _cfg.GetCVar(CCVars.HudHeldItemOffset);