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

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common
public static void BotDebug(string s, params object[] args)
{
if (Game.Settings.Debug.BotDebug)
Game.Debug(s, args);
TextNotificationsManager.Debug(s, args);
}
}
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Commands
if (command.Value != null)
command.Value.InvokeCommand(name.ToLowerInvariant(), message.Substring(1 + name.Length).Trim());
else
Game.Debug("{0} is not a valid command.", name);
TextNotificationsManager.Debug("{0} is not a valid command.", name);
return false;
}

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Commands
if (!developerMode.Enabled)
{
Game.Debug("Cheats are disabled.");
TextNotificationsManager.Debug("Cheats are disabled.");
return;
}

View File

@@ -42,14 +42,14 @@ namespace OpenRA.Mods.Common.Commands
public void InvokeCommand(string name, string arg)
{
Game.Debug("Here are the available commands:");
TextNotificationsManager.Debug("Here are the available commands:");
foreach (var key in console.Commands.Keys)
{
if (!helpDescriptions.TryGetValue(key, out var description))
description = "no description available.";
Game.Debug("{0}: {1}", key, description);
TextNotificationsManager.Debug("{0}: {1}", key, description);
}
}

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Scripting
if (value.TryGetClrValue(out int facing))
{
facingInit.Initialize(WAngle.FromFacing(facing));
Game.Debug("Initializing Facing with integers is deprecated. Use Angle instead.");
TextNotificationsManager.Debug("Initializing Facing with integers is deprecated. Use Angle instead.");
return facingInit;
}
}

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Scripting.Global
void Deprecated()
{
Game.Debug("The Facing table is deprecated. Use Angle instead.");
TextNotificationsManager.Debug("The Facing table is deprecated. Use Angle instead.");
}
public int North { get { Deprecated(); return 0; } }

View File

@@ -194,7 +194,7 @@ namespace OpenRA.Mods.Common.Scripting
return;
var c = color.HasValue ? color.Value : Color.White;
Game.AddChatLine(prefix, c, text);
TextNotificationsManager.AddChatLine(prefix, c, text);
}
[Desc("Display a system message to the player. If 'prefix' is nil the default system prefix is used.")]
@@ -204,9 +204,9 @@ namespace OpenRA.Mods.Common.Scripting
return;
if (string.IsNullOrEmpty(prefix))
Game.AddSystemLine(text);
TextNotificationsManager.AddSystemLine(text);
else
Game.AddSystemLine(prefix, text);
TextNotificationsManager.AddSystemLine(prefix, text);
}
[Desc("Displays a debug message to the player, if \"Show Map Debug Messages\" is checked in the settings.")]
@@ -215,7 +215,7 @@ namespace OpenRA.Mods.Common.Scripting
if (string.IsNullOrEmpty(text) || !Game.Settings.Debug.LuaDebug)
return;
Game.Debug(text);
TextNotificationsManager.Debug(text);
}
[Desc("Display a text message at the specified location.")]

View File

@@ -36,14 +36,14 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Activate the actor's Airstrike Power. DEPRECATED! Will be removed.")]
public void SendAirstrike(WPos target, bool randomize = true, int facing = 0)
{
Game.Debug("SendAirstrike is deprecated. Use TargetAirstrike instead.");
TextNotificationsManager.Debug("SendAirstrike is deprecated. Use TargetAirstrike instead.");
ap.SendAirstrike(Self, target, randomize ? (WAngle?)null : WAngle.FromFacing(facing));
}
[Desc("Activate the actor's Airstrike Power. DEPRECATED! Will be removed.")]
public void SendAirstrikeFrom(CPos from, CPos to)
{
Game.Debug("SendAirstrikeFrom is deprecated. Use TargetAirstrike instead.");
TextNotificationsManager.Debug("SendAirstrikeFrom is deprecated. Use TargetAirstrike instead.");
var i = Self.World.Map.CenterOfCell(from);
var j = Self.World.Map.CenterOfCell(to);

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Activate the actor's Paratroopers Power. Returns the aircraft that will drop the reinforcements. DEPRECATED! Will be removed.")]
public Actor[] ActivateParatroopers(WPos target, int facing = -1)
{
Game.Debug("SendParatroopersFrom is deprecated. Use TargetParatroopers instead.");
TextNotificationsManager.Debug("SendParatroopersFrom is deprecated. Use TargetParatroopers instead.");
var actors = pp.SendParatroopers(Self, target, facing == -1 ? (WAngle?)null : WAngle.FromFacing(facing));
return actors.Aircraft;
}

View File

@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
if (info.SuppressNotifications)
return;
Game.AddSystemLine(player.PlayerName + " is defeated.");
TextNotificationsManager.AddSystemLine(player.PlayerName + " is defeated.");
Game.RunAfterDelay(info.NotificationDelay, () =>
{
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Traits
if (info.SuppressNotifications)
return;
Game.AddSystemLine(player.PlayerName + " is victorious.");
TextNotificationsManager.AddSystemLine(player.PlayerName + " is victorious.");
Game.RunAfterDelay(info.NotificationDelay, () =>
{
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)

View File

@@ -273,7 +273,7 @@ namespace OpenRA.Mods.Common.Traits
return;
}
Game.Debug("Cheat used: {0} by {1}{2}", order.OrderString, self.Owner.PlayerName, debugSuffix);
TextNotificationsManager.Debug("Cheat used: {0} by {1}{2}", order.OrderString, self.Owner.PlayerName, debugSuffix);
}
bool IUnlocksRenderPlayer.RenderPlayerUnlocked => Enabled;

View File

@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Traits
if (info.SuppressNotifications)
return;
Game.AddSystemLine(player.PlayerName + " is defeated.");
TextNotificationsManager.AddSystemLine(player.PlayerName + " is defeated.");
Game.RunAfterDelay(info.NotificationDelay, () =>
{
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Common.Traits
if (info.SuppressNotifications)
return;
Game.AddSystemLine(player.PlayerName + " is victorious.");
TextNotificationsManager.AddSystemLine(player.PlayerName + " is victorious.");
Game.RunAfterDelay(info.NotificationDelay, () =>
{
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)

View File

@@ -158,7 +158,7 @@ namespace OpenRA.Mods.Common.Traits
{
if (ticksRemaining == m * 60 * ticksPerSecond)
{
Game.AddSystemLine(Notification.F(m, m > 1 ? "s" : null));
TextNotificationsManager.AddSystemLine(Notification.F(m, m > 1 ? "s" : null));
var faction = self.World.LocalPlayer == null ? null : self.World.LocalPlayer.Faction.InternalName;
Game.Sound.PlayNotification(self.World.Map.Rules, self.World.LocalPlayer, "Speech", info.TimeLimitWarnings[m], faction);
@@ -172,7 +172,7 @@ namespace OpenRA.Mods.Common.Traits
countdownLabel.GetText = () => null;
if (!info.SkipTimerExpiredNotification)
Game.AddSystemLine("Time limit has expired.");
TextNotificationsManager.AddSystemLine("Time limit has expired.");
}
}
}

View File

@@ -252,7 +252,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
catch (Exception ex)
{
Game.Debug("Failed to delete save file '{0}'. See the logs for details.", savePath);
TextNotificationsManager.Debug("Failed to delete save file '{0}'. See the logs for details.", savePath);
Log.Write("debug", ex.ToString());
return;
}

View File

@@ -320,7 +320,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
catch (Exception ex)
{
Game.Debug("Failed to delete map '{0}'. See the debug.log file for details.", map);
TextNotificationsManager.Debug("Failed to delete map '{0}'. See the debug.log file for details.", map);
Log.Write("debug", ex.ToString());
}

View File

@@ -29,12 +29,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (Game.Settings.Sound.Mute)
{
Game.Sound.MuteAudio();
Game.AddSystemLine("Audio muted");
TextNotificationsManager.AddSystemLine("Audio muted");
}
else
{
Game.Sound.UnmuteAudio();
Game.AddSystemLine("Audio unmuted");
TextNotificationsManager.AddSystemLine("Audio unmuted");
}
return true;

View File

@@ -499,7 +499,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
catch (Exception ex)
{
Game.Debug("Failed to delete replay file '{0}'. See the logs for details.", replay.FilePath);
TextNotificationsManager.Debug("Failed to delete replay file '{0}'. See the logs for details.", replay.FilePath);
Log.Write("debug", ex.ToString());
return;
}

View File

@@ -261,12 +261,12 @@ namespace OpenRA.Mods.Common.Widgets
// Check if selecting actors on the screen has selected new units
if (ownUnitsOnScreen.Count > World.Selection.Actors.Count())
Game.AddSystemLine("Selected across screen");
TextNotificationsManager.AddSystemLine("Selected across screen");
else
{
// Select actors in the world that have highest selection priority
ownUnitsOnScreen = SelectActorsInWorld(World, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList();
Game.AddSystemLine("Selected across map");
TextNotificationsManager.AddSystemLine("Selected across map");
}
World.Selection.Combine(World, ownUnitsOnScreen, false, false);
@@ -293,12 +293,12 @@ namespace OpenRA.Mods.Common.Widgets
// Check if selecting actors on the screen has selected new units
if (newSelection.Count > World.Selection.Actors.Count())
Game.AddSystemLine("Selected across screen");
TextNotificationsManager.AddSystemLine("Selected across screen");
else
{
// Select actors in the world that have the same selection class as one of the already selected actors
newSelection = SelectActorsInWorld(World, selectedClasses, eligiblePlayers).ToList();
Game.AddSystemLine("Selected across map");
TextNotificationsManager.AddSystemLine("Selected across map");
}
World.Selection.Combine(World, newSelection, true, false);