Add an option to disable chat in replays

This commit is contained in:
Gustas
2022-06-16 16:37:14 +03:00
committed by teinarss
parent 8a98ad51fd
commit a03e794140
9 changed files with 51 additions and 15 deletions

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Network
if (orderManager.LocalClient != null && client != orderManager.LocalClient && client.Team > 0 && client.Team == orderManager.LocalClient.Team)
suffix += " (Ally)";
TextNotificationsManager.AddChatLine(client.Name + suffix, message, client.Color);
TextNotificationsManager.AddChatLine(clientId, client.Name + suffix, message, client.Color);
break;
}
@@ -95,7 +95,7 @@ namespace OpenRA.Network
{
var prefix = order.ExtraData == uint.MaxValue ? "[Spectators] " : "[Team] ";
if (orderManager.LocalClient != null && client.Team == orderManager.LocalClient.Team)
TextNotificationsManager.AddChatLine(prefix + client.Name, message, client.Color);
TextNotificationsManager.AddChatLine(clientId, prefix + client.Name, message, client.Color);
break;
}
@@ -109,7 +109,7 @@ namespace OpenRA.Network
{
// Validate before adding the line
if (client.IsObserver || (player != null && player.WinState != WinState.Undefined))
TextNotificationsManager.AddChatLine("[Spectators] " + client.Name, message, client.Color);
TextNotificationsManager.AddChatLine(clientId, "[Spectators] " + client.Name, message, client.Color);
break;
}
@@ -119,7 +119,7 @@ namespace OpenRA.Network
&& world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined;
if (valid && (isSameTeam || world.IsReplay))
TextNotificationsManager.AddChatLine("[Team" + (world.IsReplay ? " " + order.ExtraData : "") + "] " + client.Name, message, client.Color);
TextNotificationsManager.AddChatLine(clientId, "[Team" + (world.IsReplay ? " " + order.ExtraData : "") + "] " + client.Name, message, client.Color);
break;
}

View File

@@ -251,6 +251,8 @@ namespace OpenRA
public bool UseClassicMouseStyle = false;
public bool UseAlternateScrollButton = false;
public bool HideReplayChat = false;
public StatusBarsType StatusBars = StatusBarsType.Standard;
public TargetLinesType TargetLines = TargetLinesType.Manual;
public bool UsePlayerStanceColors = false;

View File

@@ -20,14 +20,16 @@ namespace OpenRA
{
public readonly TextNotificationPool Pool;
public readonly string Prefix;
public readonly int ClientId;
public readonly string Text;
public readonly Color? PrefixColor;
public readonly Color? TextColor;
public readonly DateTime Time;
public TextNotification(TextNotificationPool pool, string prefix, string text, Color? prefixColor, Color? textColor)
public TextNotification(TextNotificationPool pool, int clientId, string prefix, string text, Color? prefixColor, Color? textColor)
{
Pool = pool;
ClientId = clientId;
Prefix = prefix;
Text = text;
PrefixColor = prefixColor;

View File

@@ -16,6 +16,7 @@ namespace OpenRA
{
public static class TextNotificationsManager
{
public static readonly int SystemClientId = -1;
static readonly string SystemMessageLabel;
public static long ChatDisabledUntil { get; internal set; }
@@ -32,17 +33,17 @@ namespace OpenRA
return;
if (player == null || player == player.World.LocalPlayer)
AddTextNotification(TextNotificationPool.Transients, SystemMessageLabel, text);
AddTextNotification(TextNotificationPool.Transients, SystemClientId, SystemMessageLabel, text);
}
public static void AddFeedbackLine(string text)
{
AddTextNotification(TextNotificationPool.Feedback, SystemMessageLabel, text);
AddTextNotification(TextNotificationPool.Feedback, SystemClientId, SystemMessageLabel, text);
}
public static void AddMissionLine(string prefix, string text, Color? prefixColor = null)
{
AddTextNotification(TextNotificationPool.Mission, prefix, text, prefixColor);
AddTextNotification(TextNotificationPool.Mission, SystemClientId, prefix, text, prefixColor);
}
public static void AddSystemLine(string text)
@@ -52,12 +53,12 @@ namespace OpenRA
public static void AddSystemLine(string prefix, string text)
{
AddTextNotification(TextNotificationPool.System, prefix, text);
AddTextNotification(TextNotificationPool.System, SystemClientId, prefix, text);
}
public static void AddChatLine(string prefix, string text, Color? prefixColor = null, Color? textColor = null)
public static void AddChatLine(int clientId, string prefix, string text, Color? prefixColor = null, Color? textColor = null)
{
AddTextNotification(TextNotificationPool.Chat, prefix, text, prefixColor, textColor);
AddTextNotification(TextNotificationPool.Chat, clientId, prefix, text, prefixColor, textColor);
}
public static void Debug(string s, params object[] args)
@@ -65,10 +66,10 @@ namespace OpenRA
AddSystemLine("Debug", string.Format(s, args));
}
static void AddTextNotification(TextNotificationPool pool, string prefix, string text, Color? prefixColor = null, Color? textColor = null)
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, prefix, text, prefixColor, textColor));
Game.OrderManager.AddTextNotification(new TextNotification(pool, clientId, prefix, text, prefixColor, textColor));
}
static bool IsPoolEnabled(TextNotificationPool pool)