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:
@@ -24,7 +24,6 @@ namespace Content.Client
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
|
||||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||||
[Dependency] private readonly IClientNetManager _netManager = default!;
|
[Dependency] private readonly IClientNetManager _netManager = default!;
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
@@ -106,13 +105,14 @@ namespace Content.Client
|
|||||||
_userInterfaceManager.PopupRoot.AddChild(label);
|
_userInterfaceManager.PopupRoot.AddChild(label);
|
||||||
var minimumSize = label.CombinedMinimumSize;
|
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);
|
_aliveLabels.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PopupMessage(string message)
|
public void PopupMessage(string message)
|
||||||
{
|
{
|
||||||
PopupMessage(new ScreenCoordinates(_inputManager.MouseScreenPosition), message);
|
PopupMessage(new ScreenCoordinates(_userInterfaceManager.MousePositionScaled), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FrameUpdate(FrameEventArgs eventArgs)
|
public void FrameUpdate(FrameEventArgs eventArgs)
|
||||||
@@ -150,7 +150,7 @@ namespace Content.Client
|
|||||||
|
|
||||||
var position = Entity == null
|
var position = Entity == null
|
||||||
? InitialPos
|
? 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)));
|
LayoutContainer.SetPosition(this, position - (0, 20 * (TimeLeft * TimeLeft + TimeLeft)));
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
|
|||||||
var box = new UIBox2i(
|
var box = new UIBox2i(
|
||||||
leftOffset,
|
leftOffset,
|
||||||
-2 + 2 * DoAfterBarScale,
|
-2 + 2 * DoAfterBarScale,
|
||||||
leftOffset + (int) (XPixelDiff * Ratio),
|
leftOffset + (int) (XPixelDiff * Ratio * UIScale),
|
||||||
-2);
|
-2);
|
||||||
handle.DrawRect(box, color);
|
handle.DrawRect(box, color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,8 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Set position ready for 2nd+ frames.
|
// Set position ready for 2nd+ frames.
|
||||||
_playerPosition = _eyeManager.CoordinatesToScreen(AttachedEntity.Transform.Coordinates);
|
var screenCoordinates = _eyeManager.CoordinatesToScreen(AttachedEntity.Transform.Coordinates);
|
||||||
|
_playerPosition = new ScreenCoordinates(screenCoordinates.X / UIScale, screenCoordinates.Y / UIScale);
|
||||||
LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f));
|
LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f));
|
||||||
|
|
||||||
if (FirstDraw)
|
if (FirstDraw)
|
||||||
|
|||||||
Reference in New Issue
Block a user