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);
|
_verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_entityManager.TryGetComponent<TransformComponent>(_senderEntity, out var xform)
|
if (!_entityManager.TryGetComponent<TransformComponent>(_senderEntity, out var xform) || xform.MapID != _eyeManager.CurrentMap)
|
||||||
|| !xform.Coordinates.IsValid(_entityManager))
|
|
||||||
{
|
{
|
||||||
Modulate = Color.White.WithAlpha(0);
|
Modulate = Color.White.WithAlpha(0);
|
||||||
return;
|
return;
|
||||||
@@ -129,7 +128,6 @@ namespace Content.Client.Chat.UI
|
|||||||
Modulate = Color.White;
|
Modulate = Color.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var worldPos = xform.WorldPosition;
|
var worldPos = xform.WorldPosition;
|
||||||
var scale = _eyeManager.MainViewport.GetRenderScale();
|
var scale = _eyeManager.MainViewport.GetRenderScale();
|
||||||
var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale);
|
var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale);
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ namespace Content.Client.Popups
|
|||||||
|
|
||||||
public void PopupCoordinates(string message, EntityCoordinates coordinates)
|
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)
|
public void PopupEntity(string message, EntityUid uid)
|
||||||
@@ -52,6 +55,9 @@ namespace Content.Client.Popups
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var transform = EntityManager.GetComponent<TransformComponent>(uid);
|
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);
|
PopupMessage(message, _eyeManager.CoordinatesToScreen(transform.Coordinates), uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,12 +223,13 @@ namespace Content.Client.Popups
|
|||||||
screenCoords = _eyeManager.CoordinatesToScreen(xform.Coordinates);
|
screenCoords = _eyeManager.CoordinatesToScreen(xform.Coordinates);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Entity has probably been deleted.
|
|
||||||
Visible = false;
|
Visible = false;
|
||||||
TotalTime += PopupLifetime;
|
if (Entity != null && _entityManager.Deleted(Entity))
|
||||||
|
TotalTime += PopupLifetime;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Visible = true;
|
||||||
var position = screenCoords.Position / UIScale - DesiredSize / 2;
|
var position = screenCoords.Position / UIScale - DesiredSize / 2;
|
||||||
LayoutContainer.SetPosition(this, position - (0, 20 * (TotalTime * TotalTime + TotalTime)));
|
LayoutContainer.SetPosition(this, position - (0, 20 * (TotalTime * TotalTime + TotalTime)));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user