Fixes notify messages causing an exception in UI update.

Fixes #539
This commit is contained in:
Pieter-Jan Briers
2020-01-22 23:59:30 +01:00
parent 83b2e59910
commit 5a5e8f0e31

View File

@@ -71,12 +71,20 @@ namespace Content.Client
public void FrameUpdate(FrameEventArgs eventArgs)
{
_aliveLabels.ForEach(l =>
{
if (l.TimeLeft > 3f)
{
l.Dispose();
}
});
_aliveLabels.RemoveAll(l => l.Disposed);
}
private class PopupLabel : Label
{
private float _timeLeft;
public float TimeLeft { get; private set; }
public Vector2 InitialPos { get; set; }
public PopupLabel()
@@ -88,15 +96,11 @@ namespace Content.Client
protected override void Update(FrameEventArgs eventArgs)
{
_timeLeft += eventArgs.DeltaSeconds;
LayoutContainer.SetPosition(this, InitialPos - (0, 20 * (_timeLeft * _timeLeft + _timeLeft)));
if (_timeLeft > 0.5f)
TimeLeft += eventArgs.DeltaSeconds;
LayoutContainer.SetPosition(this, InitialPos - (0, 20 * (TimeLeft * TimeLeft + TimeLeft)));
if (TimeLeft > 0.5f)
{
Modulate = Color.White.WithAlpha(1f - 0.2f * (float)Math.Pow(_timeLeft - 0.5f, 3f));
if (_timeLeft > 3f)
{
Dispose();
}
Modulate = Color.White.WithAlpha(1f - 0.2f * (float)Math.Pow(TimeLeft - 0.5f, 3f));
}
}
}