Fix popups appearing at 0,0 (#8221)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -111,8 +111,7 @@ namespace Content.Client.Chat.UI
|
||||
_verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds);
|
||||
}
|
||||
|
||||
if (!_entityManager.TryGetComponent<TransformComponent>(_senderEntity, out var xform)
|
||||
|| !xform.Coordinates.IsValid(_entityManager))
|
||||
if (!_entityManager.TryGetComponent<TransformComponent>(_senderEntity, out var xform) || xform.MapID != _eyeManager.CurrentMap)
|
||||
{
|
||||
Modulate = Color.White.WithAlpha(0);
|
||||
return;
|
||||
@@ -129,7 +128,6 @@ namespace Content.Client.Chat.UI
|
||||
Modulate = Color.White;
|
||||
}
|
||||
|
||||
|
||||
var worldPos = xform.WorldPosition;
|
||||
var scale = _eyeManager.MainViewport.GetRenderScale();
|
||||
var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale);
|
||||
|
||||
@@ -43,7 +43,10 @@ namespace Content.Client.Popups
|
||||
|
||||
public void PopupCoordinates(string message, EntityCoordinates coordinates)
|
||||
{
|
||||
PopupMessage(message, _eyeManager.CoordinatesToScreen(coordinates));
|
||||
var mapCoords = coordinates.ToMap(EntityManager);
|
||||
if (_eyeManager.CurrentMap != mapCoords.MapId)
|
||||
return;
|
||||
PopupMessage(message, _eyeManager.MapToScreen(mapCoords));
|
||||
}
|
||||
|
||||
public void PopupEntity(string message, EntityUid uid)
|
||||
@@ -52,6 +55,9 @@ namespace Content.Client.Popups
|
||||
return;
|
||||
|
||||
var transform = EntityManager.GetComponent<TransformComponent>(uid);
|
||||
if (_eyeManager.CurrentMap != transform.MapID)
|
||||
return; // TODO: entity may be outside of PVS, but enter PVS at a later time. So the pop-up should still get tracked?
|
||||
|
||||
PopupMessage(message, _eyeManager.CoordinatesToScreen(transform.Coordinates), uid);
|
||||
}
|
||||
|
||||
@@ -217,12 +223,13 @@ namespace Content.Client.Popups
|
||||
screenCoords = _eyeManager.CoordinatesToScreen(xform.Coordinates);
|
||||
else
|
||||
{
|
||||
// Entity has probably been deleted.
|
||||
Visible = false;
|
||||
TotalTime += PopupLifetime;
|
||||
if (Entity != null && _entityManager.Deleted(Entity))
|
||||
TotalTime += PopupLifetime;
|
||||
return;
|
||||
}
|
||||
|
||||
Visible = true;
|
||||
var position = screenCoords.Position / UIScale - DesiredSize / 2;
|
||||
LayoutContainer.SetPosition(this, position - (0, 20 * (TotalTime * TotalTime + TotalTime)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user