Split chat lines into pools
- Add a common class for passing around chat lines - Add wrapper methods for adding chat lines - Combine repeated chat lines in the display widget
This commit is contained in:
committed by
Paul Chote
parent
0a02bd524a
commit
6af354ff99
@@ -46,9 +46,9 @@ namespace OpenRA.Network
|
||||
readonly List<Order> localOrders = new List<Order>();
|
||||
readonly List<Order> localImmediateOrders = new List<Order>();
|
||||
|
||||
readonly List<ChatLine> chatCache = new List<ChatLine>();
|
||||
readonly List<TextNotification> notificationsCache = new List<TextNotification>();
|
||||
|
||||
public IReadOnlyList<ChatLine> ChatCache => chatCache;
|
||||
public IReadOnlyList<TextNotification> NotificationsCache => notificationsCache;
|
||||
|
||||
bool disposed;
|
||||
bool generateSyncReport = false;
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
Connection = conn;
|
||||
syncReport = new SyncReport(this);
|
||||
AddChatLine += CacheChatLine;
|
||||
AddTextNotification += CacheTextNotification;
|
||||
}
|
||||
|
||||
public void IssueOrders(Order[] orders)
|
||||
@@ -111,10 +111,10 @@ namespace OpenRA.Network
|
||||
localOrders.Add(order);
|
||||
}
|
||||
|
||||
public Action<string, Color, string, Color> AddChatLine = (n, nc, s, tc) => { };
|
||||
void CacheChatLine(string name, Color nameColor, string text, Color textColor)
|
||||
public Action<TextNotification> AddTextNotification = (notification) => { };
|
||||
void CacheTextNotification(TextNotification notification)
|
||||
{
|
||||
chatCache.Add(new ChatLine(name, nameColor, text, textColor));
|
||||
notificationsCache.Add(notification);
|
||||
}
|
||||
|
||||
public void TickImmediate()
|
||||
@@ -242,20 +242,4 @@ namespace OpenRA.Network
|
||||
Connection?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public class ChatLine
|
||||
{
|
||||
public readonly Color Color;
|
||||
public readonly string Name;
|
||||
public readonly string Text;
|
||||
public readonly Color TextColor;
|
||||
|
||||
public ChatLine(string name, Color nameColor, string text, Color textColor)
|
||||
{
|
||||
Color = nameColor;
|
||||
Name = name;
|
||||
Text = text;
|
||||
TextColor = textColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user