Update TextNotificationsManager to use Ui.Send

This commit is contained in:
tomas
2022-07-12 17:46:20 +02:00
committed by Gustas
parent b0329aad35
commit 5f4ed5f16b
6 changed files with 25 additions and 55 deletions

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System.Collections.Generic;
using OpenRA.Primitives;
using OpenRA.Widgets;
@@ -20,6 +21,8 @@ namespace OpenRA
static readonly string SystemMessageLabel;
public static long ChatDisabledUntil { get; internal set; }
static readonly List<TextNotification> NotificationsCache = new List<TextNotification>();
public static IReadOnlyList<TextNotification> Notifications => NotificationsCache;
static TextNotificationsManager()
{
@@ -69,7 +72,12 @@ namespace OpenRA
static void AddTextNotification(TextNotificationPool pool, int clientId, string prefix, string text, Color? prefixColor = null, Color? textColor = null)
{
if (IsPoolEnabled(pool))
Game.OrderManager.AddTextNotification(new TextNotification(pool, clientId, prefix, text, prefixColor, textColor));
{
var textNotification = new TextNotification(pool, clientId, prefix, text, prefixColor, textColor);
NotificationsCache.Add(textNotification);
Ui.Send(textNotification);
}
}
static bool IsPoolEnabled(TextNotificationPool pool)
@@ -82,5 +90,10 @@ namespace OpenRA
(pool == TextNotificationPool.Transients && filters.HasFlag(TextNotificationPoolFilters.Transients)) ||
(pool == TextNotificationPool.Feedback && filters.HasFlag(TextNotificationPoolFilters.Feedback));
}
public static void Clear()
{
NotificationsCache.Clear();
}
}
}