Move Text handling to its own class

This commit is contained in:
teinarss
2021-06-03 19:33:32 +02:00
committed by reaperrr
parent 2a26ddc622
commit 82115c6bf7
25 changed files with 97 additions and 74 deletions

View File

@@ -212,8 +212,8 @@ namespace OpenRA
Log.Write("debug", e.ToString());
// HACK: this can hopefully go away in the future
Game.Debug("Ignoring malformed order that would have crashed the game");
Game.Debug("Please file a bug report and include the replay from this match");
TextNotificationsManager.Debug("Ignoring malformed order that would have crashed the game");
TextNotificationsManager.Debug("Please file a bug report and include the replay from this match");
return null;
}

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Network
{
// Server message
case "Message":
Game.AddSystemLine(order.TargetString);
TextNotificationsManager.AddSystemLine(order.TargetString);
break;
// Reports that the target player disconnected
@@ -70,7 +70,7 @@ namespace OpenRA.Network
if (orderManager.LocalClient != null && client != orderManager.LocalClient && client.Team > 0 && client.Team == orderManager.LocalClient.Team)
suffix += " (Ally)";
Game.AddChatLine(client.Name + suffix, client.Color, message);
TextNotificationsManager.AddChatLine(client.Name + suffix, client.Color, message);
break;
}
@@ -79,7 +79,7 @@ namespace OpenRA.Network
{
var prefix = order.ExtraData == uint.MaxValue ? "[Spectators] " : "[Team] ";
if (orderManager.LocalClient != null && client.Team == orderManager.LocalClient.Team)
Game.AddChatLine(prefix + client.Name, client.Color, message);
TextNotificationsManager.AddChatLine(prefix + client.Name, client.Color, message);
break;
}
@@ -93,7 +93,7 @@ namespace OpenRA.Network
{
// Validate before adding the line
if (client.IsObserver || (player != null && player.WinState != WinState.Undefined))
Game.AddChatLine("[Spectators] " + client.Name, client.Color, message);
TextNotificationsManager.AddChatLine("[Spectators] " + client.Name, client.Color, message);
break;
}
@@ -103,7 +103,7 @@ namespace OpenRA.Network
&& world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined;
if (valid && (isSameTeam || world.IsReplay))
Game.AddChatLine("[Team" + (world.IsReplay ? " " + order.ExtraData : "") + "] " + client.Name, client.Color, message);
TextNotificationsManager.AddChatLine("[Team" + (world.IsReplay ? " " + order.ExtraData : "") + "] " + client.Name, client.Color, message);
break;
}
@@ -133,7 +133,7 @@ namespace OpenRA.Network
FieldLoader.GetValue<int>("SaveSyncFrame", saveSyncFrame.Value.Value);
}
else
Game.AddSystemLine("The game has started.");
TextNotificationsManager.AddSystemLine("The game has started.");
Game.StartGame(orderManager.LobbyInfo.GlobalSettings.Map, WorldType.Regular);
break;
@@ -151,7 +151,7 @@ namespace OpenRA.Network
case "GameSaved":
if (!orderManager.World.IsReplay)
Game.AddSystemLine("Game saved");
TextNotificationsManager.AddSystemLine("Game saved");
foreach (var nsr in orderManager.World.WorldActor.TraitsImplementing<INotifyGameSaved>())
nsr.GameSaved(orderManager.World);
@@ -171,7 +171,7 @@ namespace OpenRA.Network
if (orderManager.World.Paused != pause && world != null && world.LobbyInfo.NonBotClients.Count() > 1)
{
var pausetext = $"The game is {(pause ? "paused" : "un-paused")} by {client.Name}";
Game.AddSystemLine(pausetext);
TextNotificationsManager.AddSystemLine(pausetext);
}
orderManager.World.Paused = pause;