UI Scaling Fixes for do_after and PopupMessage (#2737)

* Fixes do_after bar placement when using UI scaling

* Add Scaled Screen Position debug overlay to DebugCoordsPanel
Fix PopupMessage being in the wrong location when using UI scaling

* Fix warning
This commit is contained in:
R. Neuser
2020-12-12 22:24:16 -06:00
committed by GitHub
parent 450e30fbda
commit 4ea18f2449
3 changed files with 7 additions and 6 deletions

View File

@@ -24,7 +24,6 @@ namespace Content.Client
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
@@ -106,13 +105,14 @@ namespace Content.Client
_userInterfaceManager.PopupRoot.AddChild(label);
var minimumSize = label.CombinedMinimumSize;
LayoutContainer.SetPosition(label, label.InitialPos = coordinates.Position - minimumSize / 2);
label.InitialPos = (coordinates.Position / _userInterfaceManager.UIScale) - minimumSize / 2;
LayoutContainer.SetPosition(label, label.InitialPos);
_aliveLabels.Add(label);
}
public void PopupMessage(string message)
{
PopupMessage(new ScreenCoordinates(_inputManager.MouseScreenPosition), message);
PopupMessage(new ScreenCoordinates(_userInterfaceManager.MousePositionScaled), message);
}
public void FrameUpdate(FrameEventArgs eventArgs)
@@ -150,7 +150,7 @@ namespace Content.Client
var position = Entity == null
? InitialPos
: _eyeManager.CoordinatesToScreen(Entity.Transform.Coordinates).Position - CombinedMinimumSize / 2;
: (_eyeManager.CoordinatesToScreen(Entity.Transform.Coordinates).Position / UIScale) - CombinedMinimumSize / 2;
LayoutContainer.SetPosition(this, position - (0, 20 * (TimeLeft * TimeLeft + TimeLeft)));