Update TextNotificationsManager to use Ui.Send
This commit is contained in:
@@ -83,6 +83,9 @@ namespace OpenRA
|
||||
|
||||
static void JoinInner(OrderManager om)
|
||||
{
|
||||
// Refresh TextNotificationsManager before the game starts.
|
||||
TextNotificationsManager.Clear();
|
||||
|
||||
// HACK: The shellmap World and OrderManager are owned by the main menu's WorldRenderer instead of Game.
|
||||
// This allows us to switch Game.OrderManager from the shellmap to the new network connection when joining
|
||||
// a lobby, while keeping the OrderManager that runs the shellmap intact.
|
||||
|
||||
@@ -51,10 +51,6 @@ namespace OpenRA.Network
|
||||
readonly List<ClientOrder> processClientOrders = new List<ClientOrder>();
|
||||
readonly List<int> processClientsToRemove = new List<int>();
|
||||
|
||||
readonly List<TextNotification> notificationsCache = new List<TextNotification>();
|
||||
|
||||
public IReadOnlyList<TextNotification> NotificationsCache => notificationsCache;
|
||||
|
||||
bool disposed;
|
||||
bool generateSyncReport = false;
|
||||
int sentOrdersFrame = 0;
|
||||
@@ -108,7 +104,6 @@ namespace OpenRA.Network
|
||||
{
|
||||
Connection = conn;
|
||||
syncReport = new SyncReport(this);
|
||||
AddTextNotification += CacheTextNotification;
|
||||
|
||||
LastTickTime = new TickTime(() => SuggestedTimestep, Game.RunTime);
|
||||
}
|
||||
@@ -127,12 +122,6 @@ namespace OpenRA.Network
|
||||
localOrders.Add(order);
|
||||
}
|
||||
|
||||
public Action<TextNotification> AddTextNotification = (notification) => { };
|
||||
void CacheTextNotification(TextNotification notification)
|
||||
{
|
||||
notificationsCache.Add(notification);
|
||||
}
|
||||
|
||||
void SendImmediateOrders()
|
||||
{
|
||||
if (localImmediateOrders.Count != 0 && GameSaveLastFrame < NetFrameNumber)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user