From c099e6d09bb7253c790fa94c0b6e5897954bc180 Mon Sep 17 00:00:00 2001 From: Pavlos Touboulidis Date: Sat, 26 Apr 2014 03:18:46 +0300 Subject: [PATCH] Fix overlay chat lines expiration It wasn't working right when the widget was hidden because it wasn't receiving any Ticks. Instead of counting, we're now using Game.LocalTick as the tick source. --- OpenRA.Game/Widgets/ChatDisplayWidget.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Widgets/ChatDisplayWidget.cs b/OpenRA.Game/Widgets/ChatDisplayWidget.cs index e7bd0ee837..33f5892f56 100644 --- a/OpenRA.Game/Widgets/ChatDisplayWidget.cs +++ b/OpenRA.Game/Widgets/ChatDisplayWidget.cs @@ -22,7 +22,6 @@ namespace OpenRA.Widgets public string Notification = ""; const int logLength = 9; - uint totalTicks; List recentLines = new List(); public override Rectangle EventBounds { get { return Rectangle.Empty; } } @@ -68,7 +67,7 @@ namespace OpenRA.Widgets public void AddLine(Color c, string from, string text) { - recentLines.Add(new ChatLine(from, text, totalTicks + (uint)RemoveTime, c)); + recentLines.Add(new ChatLine(from, text, Game.LocalTick + RemoveTime, c)); if (Notification != null) Sound.Play(Notification); @@ -85,13 +84,11 @@ namespace OpenRA.Widgets public override void Tick() { - totalTicks++; - if (RemoveTime == 0) return; // This takes advantage of the fact that recentLines is ordered by expiration, from sooner to later - while (recentLines.Count > 0 && totalTicks >= recentLines[0].Expiration) + while (recentLines.Count > 0 && Game.LocalTick >= recentLines[0].Expiration) recentLines.RemoveAt(0); } } @@ -100,9 +97,9 @@ namespace OpenRA.Widgets { public readonly Color Color; public readonly string Owner, Text; - public readonly uint Expiration; + public readonly int Expiration; - public ChatLine(string owner, string text, uint expiration, Color color) + public ChatLine(string owner, string text, int expiration, Color color) { Owner = owner; Text = text;