Fix held item overlay UIScale calculation.

Now correctly bases UI scale off viewport control and doesn't break if scale is automatic.
This commit is contained in:
Pieter-Jan Briers
2021-10-22 10:10:33 +02:00
parent 85f2fcb86b
commit 04b49b45a6

View File

@@ -1,7 +1,7 @@
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Input; using Robust.Client.Input;
using Robust.Shared; using Robust.Client.UserInterface;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -51,9 +51,11 @@ namespace Content.Client.Hands
var screen = args.ScreenHandle; var screen = args.ScreenHandle;
var halfSize = _renderBackbuffer.Size / 2; var halfSize = _renderBackbuffer.Size / 2;
var uiScale = (args.ViewportControl as Control)?.UIScale ?? 1f;
screen.RenderInRenderTarget(_renderBackbuffer, () => 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); }, Color.Transparent);
var offset = _cfg.GetCVar(CCVars.HudHeldItemOffset); var offset = _cfg.GetCVar(CCVars.HudHeldItemOffset);