Cache chat conversations in the lobby and in-game
This preserves the chat content from the lobby and makes it available in-game, and also makes all chat content available to the end-game dialog.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Primitives;
|
||||
|
||||
@@ -44,6 +45,9 @@ namespace OpenRA.Network
|
||||
|
||||
List<Order> localOrders = new List<Order>();
|
||||
|
||||
List<ChatLine> chatCache = new List<ChatLine>();
|
||||
public readonly ReadOnlyList<ChatLine> ChatCache;
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
if (GameStarted) return;
|
||||
@@ -60,6 +64,8 @@ namespace OpenRA.Network
|
||||
Password = password;
|
||||
Connection = conn;
|
||||
syncReport = new SyncReport(this);
|
||||
ChatCache = new ReadOnlyList<ChatLine>(chatCache);
|
||||
AddChatLine += CacheChatLine;
|
||||
}
|
||||
|
||||
public void IssueOrders(Order[] orders)
|
||||
@@ -73,6 +79,12 @@ namespace OpenRA.Network
|
||||
localOrders.Add(order);
|
||||
}
|
||||
|
||||
public Action<Color, string, string> AddChatLine = (c, n, s) => { };
|
||||
void CacheChatLine(Color color, string name, string text)
|
||||
{
|
||||
chatCache.Add(new ChatLine(color, name, text));
|
||||
}
|
||||
|
||||
public void TickImmediate()
|
||||
{
|
||||
var immediateOrders = localOrders.Where( o => o.IsImmediate ).ToList();
|
||||
@@ -203,4 +215,18 @@ namespace OpenRA.Network
|
||||
Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public class ChatLine
|
||||
{
|
||||
public readonly Color Color;
|
||||
public readonly string Name;
|
||||
public readonly string Text;
|
||||
|
||||
public ChatLine(Color c, string n, string t)
|
||||
{
|
||||
Color = c;
|
||||
Name = n;
|
||||
Text = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user