From d6285affec4e886ac8f8aa260f805a5fc79c1d16 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 2 Oct 2024 22:40:05 +0100 Subject: [PATCH] Remove FluentBundle.Arguments helper method. --- OpenRA.Game/FluentBundle.cs | 59 ++++++++----------- OpenRA.Game/FluentProvider.cs | 7 +-- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/GameInformation.cs | 3 +- OpenRA.Game/Map/MapPreview.cs | 2 +- OpenRA.Game/Network/FluentMessage.cs | 37 ++++++++---- OpenRA.Game/Network/OrderManager.cs | 2 +- OpenRA.Game/Network/UnitOrders.cs | 2 +- OpenRA.Game/Player.cs | 4 +- OpenRA.Game/Server/PlayerMessageTracker.cs | 8 +-- OpenRA.Game/Server/Server.cs | 24 ++++---- OpenRA.Game/Server/VoteKickTracker.cs | 12 ++-- OpenRA.Game/TextNotificationsManager.cs | 16 ++--- .../Installer/ExtractMixSourceAction.cs | 10 ++-- OpenRA.Mods.Common/Commands/ChatCommands.cs | 2 +- .../EditorBrushes/EditorActorBrush.cs | 3 +- .../EditorBrushes/EditorCopyPasteBrush.cs | 2 +- .../EditorBrushes/EditorDefaultBrush.cs | 22 ++++--- .../EditorBrushes/EditorMarkerLayerBrush.cs | 8 +-- .../EditorBrushes/EditorResourceBrush.cs | 2 +- .../EditorBrushes/EditorTileBrush.cs | 4 +- .../SourceActions/CopySourceAction.cs | 11 ++-- .../SourceActions/ExtractBlastSourceAction.cs | 11 ++-- .../SourceActions/ExtractIscabSourceAction.cs | 2 +- .../SourceActions/ExtractMscabSourceAction.cs | 6 +- .../SourceActions/ExtractRawSourceAction.cs | 9 +-- .../SourceActions/ExtractZipSourceAction.cs | 6 +- .../ServerTraits/LobbyCommands.cs | 42 ++++++------- .../ServerTraits/PlayerPinger.cs | 11 +--- .../Player/ConquestVictoryConditions.cs | 4 +- .../Traits/Player/DeveloperMode.cs | 6 +- .../Player/StrategicVictoryConditions.cs | 4 +- .../Traits/World/TimeLimitManager.cs | 2 +- .../Widgets/ConfirmationDialogs.cs | 5 +- .../Widgets/Logic/AssetBrowserLogic.cs | 2 +- .../Widgets/Logic/ConnectionLogic.cs | 4 +- .../Widgets/Logic/Editor/ActorEditLogic.cs | 4 +- .../Logic/Editor/ActorSelectorLogic.cs | 2 +- .../Widgets/Logic/GameSaveBrowserLogic.cs | 12 ++-- .../Logic/Ingame/GameInfoStatsLogic.cs | 12 ++-- .../Widgets/Logic/Ingame/GameTimerLogic.cs | 4 +- .../Hotkeys/SelectAllUnitsHotkeyLogic.cs | 4 +- .../Hotkeys/SelectUnitsByTypeHotkeyLogic.cs | 4 +- .../Logic/Ingame/IngameCashCounterLogic.cs | 2 +- .../Widgets/Logic/Ingame/IngameChatLogic.cs | 2 +- .../Widgets/Logic/Ingame/IngameMenuLogic.cs | 2 +- .../Logic/Ingame/IngamePowerBarLogic.cs | 4 +- .../Logic/Ingame/IngamePowerCounterLogic.cs | 8 +-- .../Logic/Ingame/IngameSiloBarLogic.cs | 8 +-- .../Ingame/ObserverShroudSelectorLogic.cs | 2 +- .../Logic/Ingame/ObserverStatsLogic.cs | 2 +- .../Logic/Ingame/ProductionTooltipLogic.cs | 2 +- .../Installation/DownloadPackageLogic.cs | 15 +++-- .../Installation/InstallFromSourceLogic.cs | 4 +- .../Widgets/Logic/Lobby/KickClientLogic.cs | 2 +- .../Logic/Lobby/KickSpectatorsLogic.cs | 2 +- .../Widgets/Logic/Lobby/LobbyLogic.cs | 4 +- .../Widgets/Logic/Lobby/MapPreviewLogic.cs | 6 +- .../Logic/Lobby/SpawnSelectorTooltipLogic.cs | 2 +- .../Widgets/Logic/MainMenuLogic.cs | 8 +-- .../Widgets/Logic/MapChooserLogic.cs | 12 ++-- .../Widgets/Logic/PlayerProfileLogic.cs | 2 +- .../Widgets/Logic/ReplayBrowserLogic.cs | 10 ++-- .../Widgets/Logic/ReplayUtils.cs | 17 +++--- .../Widgets/Logic/ServerCreationLogic.cs | 5 +- .../Widgets/Logic/ServerListLogic.cs | 14 ++--- .../Logic/Settings/DisplaySettingsLogic.cs | 4 +- .../Logic/Settings/HotkeysSettingsLogic.cs | 8 +-- .../Widgets/Logic/Settings/SettingsLogic.cs | 2 +- .../Widgets/SupportPowerTimerWidget.cs | 5 +- OpenRA.Test/OpenRA.Game/FluentTest.cs | 4 +- 71 files changed, 273 insertions(+), 283 deletions(-) diff --git a/OpenRA.Game/FluentBundle.cs b/OpenRA.Game/FluentBundle.cs index 35e7e51023..cf60d1276a 100644 --- a/OpenRA.Game/FluentBundle.cs +++ b/OpenRA.Game/FluentBundle.cs @@ -112,15 +112,15 @@ namespace OpenRA } } - public string GetString(string key, IDictionary arguments = null) + public string GetString(string key, object[] args = null) { - if (!TryGetString(key, out var message, arguments)) + if (!TryGetString(key, out var message, args)) message = key; return message; } - public bool TryGetString(string key, out string value, IDictionary arguments = null) + public bool TryGetString(string key, out string value, object[] args = null) { if (key == null) throw new ArgumentNullException(nameof(key)); @@ -133,12 +133,29 @@ namespace OpenRA return false; } - var fluentArguments = new Dictionary(); - if (arguments != null) - foreach (var (k, v) in arguments) - fluentArguments.Add(k, v.ToFluentType()); + Dictionary fluentArgs = null; + if (args != null) + { + if (args.Length % 2 != 0) + throw new ArgumentException("Expected a comma separated list of name, value arguments " + + "but the number of arguments is not a multiple of two", nameof(args)); - var result = bundle.TryGetAttrMessage(key, fluentArguments, out var errors, out value); + fluentArgs = new Dictionary(); + for (var i = 0; i < args.Length; i += 2) + { + var argKey = args[i] as string; + if (string.IsNullOrEmpty(argKey)) + throw new ArgumentException($"Expected the argument at index {i} to be a non-empty string", nameof(args)); + + var argValue = args[i + 1]; + if (argValue == null) + throw new ArgumentNullException(nameof(args), $"Expected the argument at index {i + 1} to be a non-null value"); + + fluentArgs.Add(argKey, argValue.ToFluentType()); + } + } + + var result = bundle.TryGetAttrMessage(key, fluentArgs, out var errors, out value); foreach (var error in errors) Log.Write("debug", $"FluentBundle of {key}: {error}"); @@ -157,31 +174,5 @@ namespace OpenRA { return bundle.HasAttrMessage(key); } - - // Adapted from Fluent.Net.SimpleExample.TranslationService by Mark Weaver - public static Dictionary Arguments(string name, object value, params object[] args) - { - if (args.Length % 2 != 0) - throw new ArgumentException("Expected a comma separated list of name, value arguments" - + " but the number of arguments is not a multiple of two", nameof(args)); - - var argumentDictionary = new Dictionary { { name, value } }; - - for (var i = 0; i < args.Length; i += 2) - { - name = args[i] as string; - if (string.IsNullOrEmpty(name)) - throw new ArgumentException($"Expected the argument at index {i} to be a non-empty string", - nameof(args)); - - value = args[i + 1]; - if (value == null) - throw new ArgumentNullException(nameof(args), $"Expected the argument at index {i + 1} to be a non-null value"); - - argumentDictionary.Add(name, value); - } - - return argumentDictionary; - } } } diff --git a/OpenRA.Game/FluentProvider.cs b/OpenRA.Game/FluentProvider.cs index 669abb092c..eee653a026 100644 --- a/OpenRA.Game/FluentProvider.cs +++ b/OpenRA.Game/FluentProvider.cs @@ -9,7 +9,6 @@ */ #endregion -using System.Collections.Generic; using OpenRA.FileSystem; namespace OpenRA @@ -32,7 +31,7 @@ namespace OpenRA } } - public static string GetString(string key, IDictionary args = null) + public static string GetString(string key, params object[] args) { lock (SyncObject) { @@ -48,7 +47,7 @@ namespace OpenRA } } - public static bool TryGetString(string key, out string message, IDictionary args = null) + public static bool TryGetString(string key, out string message, params object[] args) { lock (SyncObject) { @@ -65,7 +64,7 @@ namespace OpenRA } /// Should only be used by . - internal static bool TryGetModString(string key, out string message, IDictionary args = null) + internal static bool TryGetModString(string key, out string message, params object[] args) { lock (SyncObject) { diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index aa21187ac2..d61023407f 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -595,7 +595,7 @@ namespace OpenRA Log.Write("debug", "Taking screenshot " + path); Renderer.SaveScreenshot(path); - TextNotificationsManager.Debug(FluentProvider.GetString(SavedScreenshot, FluentBundle.Arguments("filename", filename))); + TextNotificationsManager.Debug(FluentProvider.GetString(SavedScreenshot, "filename", filename)); } } diff --git a/OpenRA.Game/GameInformation.cs b/OpenRA.Game/GameInformation.cs index 8d7e1988c8..c8e9448ae0 100644 --- a/OpenRA.Game/GameInformation.cs +++ b/OpenRA.Game/GameInformation.cs @@ -153,9 +153,8 @@ namespace OpenRA { var number = Players.Where(p => p.BotType == player.BotType).ToList().IndexOf(player) + 1; return FluentProvider.GetString(EnumeratedBotName, - FluentBundle.Arguments( "name", FluentProvider.GetString(player.Name), - "number", number)); + "number", number); } return player.Name; diff --git a/OpenRA.Game/Map/MapPreview.cs b/OpenRA.Game/Map/MapPreview.cs index 4b1a9afb1d..141309b174 100644 --- a/OpenRA.Game/Map/MapPreview.cs +++ b/OpenRA.Game/Map/MapPreview.cs @@ -227,7 +227,7 @@ namespace OpenRA /// Functionality mirrors , except instead of using /// loaded 's fluent bundle as backup, we use this 's. /// - public string GetLocalisedString(string key, IDictionary args = null) + public string GetLocalisedString(string key, object[] args = null) { // PERF: instead of loading mod level strings per each MapPreview, reuse the already loaded one in FluentProvider. if (FluentProvider.TryGetModString(key, out var message, args)) diff --git a/OpenRA.Game/Network/FluentMessage.cs b/OpenRA.Game/Network/FluentMessage.cs index ad3a29b984..27cfbc92a2 100644 --- a/OpenRA.Game/Network/FluentMessage.cs +++ b/OpenRA.Game/Network/FluentMessage.cs @@ -9,8 +9,8 @@ */ #endregion +using System; using System.Collections.Generic; -using System.Linq; using Linguini.Shared.Types.Bundle; namespace OpenRA.Network @@ -55,30 +55,31 @@ namespace OpenRA.Network public readonly string Key = string.Empty; [FieldLoader.LoadUsing(nameof(LoadArguments))] - public readonly Dictionary Arguments; + public readonly object[] Arguments; static object LoadArguments(MiniYaml yaml) { - var arguments = new Dictionary(); + var arguments = new List(); var argumentsNode = yaml.NodeWithKeyOrDefault("Arguments"); if (argumentsNode != null) { foreach (var argumentNode in argumentsNode.Value.Nodes) { var argument = FieldLoader.Load(argumentNode.Value); + arguments.Add(argument.Key); if (argument.Type == FluentArgument.FluentArgumentType.Number) { if (!double.TryParse(argument.Value, out var number)) Log.Write("debug", $"Failed to parse {argument.Value}"); - arguments.Add(argument.Key, number); + arguments.Add(number); } else - arguments.Add(argument.Key, argument.Value); + arguments.Add(argument.Value); } } - return arguments; + return arguments.ToArray(); } public FluentMessage(MiniYaml yaml) @@ -87,21 +88,31 @@ namespace OpenRA.Network FieldLoader.Load(this, yaml); } - public static string Serialize(string key, Dictionary arguments = null) + public static string Serialize(string key, object[] args) { var root = new List { new("Protocol", ProtocolVersion.ToStringInvariant()), - new("Key", key) + new("Key", key), }; - if (arguments != null) + if (args != null) { - var argumentsNode = new MiniYaml("", arguments - .Select(a => new FluentArgument(a.Key, a.Value)) - .Select((argument, i) => new MiniYamlNode("Argument@" + i, FieldSaver.Save(argument)))); + var nodes = new List(); + for (var i = 0; i < args.Length; i += 2) + { + var argKey = args[i] as string; + if (string.IsNullOrEmpty(argKey)) + throw new ArgumentException($"Expected the argument at index {i} to be a non-empty string", nameof(args)); - root.Add(new MiniYamlNode("Arguments", argumentsNode)); + var argValue = args[i + 1]; + if (argValue == null) + throw new ArgumentNullException(nameof(args), $"Expected the argument at index {i + 1} to be a non-null value"); + + nodes.Add(new MiniYamlNode($"Argument@{i / 2}", FieldSaver.Save(new FluentArgument(argKey, argValue)))); + } + + root.Add(new MiniYamlNode("Arguments", new MiniYaml("", nodes))); } return new MiniYaml("", root) diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index f00bf330ae..f955d7804c 100644 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -91,7 +91,7 @@ namespace OpenRA.Network World.OutOfSync(); IsOutOfSync = true; - TextNotificationsManager.AddSystemLine(DesyncCompareLogs, FluentBundle.Arguments("frame", frame)); + TextNotificationsManager.AddSystemLine(DesyncCompareLogs, "frame", frame); } public void StartGame() diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 11482eab70..2df8b81627 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -231,7 +231,7 @@ namespace OpenRA.Network break; if (orderManager.World.Paused != pause && world != null && world.LobbyInfo.NonBotClients.Count() > 1) - TextNotificationsManager.AddSystemLine(pause ? GamePaused : GameUnpaused, FluentBundle.Arguments("player", client.Name)); + TextNotificationsManager.AddSystemLine(pause ? GamePaused : GameUnpaused, "player", client.Name); orderManager.World.Paused = pause; orderManager.World.PredictedPaused = pause; diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index c2bf3d3ea9..b74a584704 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -239,8 +239,8 @@ namespace OpenRA var botInfo = botInfos.First(b => b.Type == BotType); var botsOfSameType = World.Players.Where(c => c.BotType == BotType).ToArray(); return FluentProvider.GetString(EnumeratedBotName, - FluentBundle.Arguments("name", FluentProvider.GetString(botInfo.Name), - "number", botsOfSameType.IndexOf(this) + 1)); + "name", FluentProvider.GetString(botInfo.Name), + "number", botsOfSameType.IndexOf(this) + 1); } return PlayerName; diff --git a/OpenRA.Game/Server/PlayerMessageTracker.cs b/OpenRA.Game/Server/PlayerMessageTracker.cs index 1b36044576..ad779bb7b1 100644 --- a/OpenRA.Game/Server/PlayerMessageTracker.cs +++ b/OpenRA.Game/Server/PlayerMessageTracker.cs @@ -22,12 +22,12 @@ namespace OpenRA.Server readonly Dictionary> messageTracker = new(); readonly Server server; readonly Action dispatchOrdersToClient; - readonly Action> sendLocalizedMessageTo; + readonly Action sendLocalizedMessageTo; public PlayerMessageTracker( Server server, Action dispatchOrdersToClient, - Action> sendLocalizedMessageTo) + Action sendLocalizedMessageTo) { this.server = server; this.dispatchOrdersToClient = dispatchOrdersToClient; @@ -56,7 +56,7 @@ namespace OpenRA.Server if (!isAdmin && time < settings.FloodLimitJoinCooldown) { var remaining = CalculateRemaining(settings.FloodLimitJoinCooldown); - sendLocalizedMessageTo(conn, ChatTemporaryDisabled, FluentBundle.Arguments("remaining", remaining)); + sendLocalizedMessageTo(conn, ChatTemporaryDisabled, new object[] { "remaining", remaining }); return true; } @@ -64,7 +64,7 @@ namespace OpenRA.Server if (tracker.Count >= settings.FloodLimitMessageCount) { var remaining = CalculateRemaining(tracker[0] + settings.FloodLimitInterval); - sendLocalizedMessageTo(conn, ChatTemporaryDisabled, FluentBundle.Arguments("remaining", remaining)); + sendLocalizedMessageTo(conn, ChatTemporaryDisabled, new object[] { "remaining", remaining }); return true; } diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 3a6969711a..ebe187f9f6 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -580,7 +580,7 @@ namespace OpenRA.Server Log.Write("server", $"{client.Name} ({newConn.EndPoint}) has joined the game."); - SendLocalizedMessage(Joined, FluentBundle.Arguments("player", client.Name)); + SendLocalizedMessage(Joined, "player", client.Name); if (Type == ServerType.Dedicated) { @@ -952,18 +952,18 @@ namespace OpenRA.Server WriteLineWithTimeStamp(text); } - public void SendLocalizedMessage(string key, Dictionary arguments = null) + public void SendLocalizedMessage(string key, params object[] args) { - var text = FluentMessage.Serialize(key, arguments); + var text = FluentMessage.Serialize(key, args); DispatchServerOrdersToClients(Order.FromTargetString("FluentMessage", text, true)); if (Type == ServerType.Dedicated) - WriteLineWithTimeStamp(FluentProvider.GetString(key, arguments)); + WriteLineWithTimeStamp(FluentProvider.GetString(key, args)); } - public void SendLocalizedMessageTo(Connection conn, string key, Dictionary arguments = null) + public void SendLocalizedMessageTo(Connection conn, string key, object[] args = null) { - var text = FluentMessage.Serialize(key, arguments); + var text = FluentMessage.Serialize(key, args); DispatchOrdersToClient(conn, 0, 0, Order.FromTargetString("FluentMessage", text, true).Serialize()); } @@ -998,7 +998,7 @@ namespace OpenRA.Server if (!InterpretCommand(o.TargetString, conn)) { Log.Write("server", $"Unknown server command: {o.TargetString}"); - SendLocalizedMessageTo(conn, UnknownServerCommand, FluentBundle.Arguments("command", o.TargetString)); + SendLocalizedMessageTo(conn, UnknownServerCommand, new object[] { "command", o.TargetString }); } break; @@ -1180,14 +1180,14 @@ namespace OpenRA.Server if (State == ServerState.GameStarted) { if (dropClient.IsObserver) - SendLocalizedMessage(ObserverDisconnected, FluentBundle.Arguments("player", dropClient.Name)); + SendLocalizedMessage(ObserverDisconnected, "player", dropClient.Name); else if (dropClient.Team > 0) - SendLocalizedMessage(PlayerTeamDisconnected, FluentBundle.Arguments("player", dropClient.Name, "team", dropClient.Team)); + SendLocalizedMessage(PlayerTeamDisconnected, "player", dropClient.Name, "team", dropClient.Team); else - SendLocalizedMessage(PlayerDisconnected, FluentBundle.Arguments("player", dropClient.Name)); + SendLocalizedMessage(PlayerDisconnected, "player", dropClient.Name); } else - SendLocalizedMessage(LobbyDisconnected, FluentBundle.Arguments("player", dropClient.Name)); + SendLocalizedMessage(LobbyDisconnected, "player", dropClient.Name); LobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex); @@ -1204,7 +1204,7 @@ namespace OpenRA.Server if (nextAdmin != null) { nextAdmin.IsAdmin = true; - SendLocalizedMessage(NewAdmin, FluentBundle.Arguments("player", nextAdmin.Name)); + SendLocalizedMessage(NewAdmin, "player", nextAdmin.Name); } } diff --git a/OpenRA.Game/Server/VoteKickTracker.cs b/OpenRA.Game/Server/VoteKickTracker.cs index 27f418a55c..526d04daa6 100644 --- a/OpenRA.Game/Server/VoteKickTracker.cs +++ b/OpenRA.Game/Server/VoteKickTracker.cs @@ -107,7 +107,7 @@ namespace OpenRA.Server if (!kickee.IsObserver && !server.HasClientWonOrLost(kickee)) { // Vote kick cannot be the sole deciding factor for a game. - server.SendLocalizedMessageTo(conn, InsufficientVotes, FluentBundle.Arguments("kickee", kickee.Name)); + server.SendLocalizedMessageTo(conn, InsufficientVotes, new object[] { "kickee", kickee.Name }); EndKickVote(); return false; } @@ -135,7 +135,7 @@ namespace OpenRA.Server Log.Write("server", $"Vote kick started on {kickeeID}."); voteKickTimer = Stopwatch.StartNew(); - server.SendLocalizedMessage(VoteKickStarted, FluentBundle.Arguments("kicker", kicker.Name, "kickee", kickee.Name)); + server.SendLocalizedMessage(VoteKickStarted, "kicker", kicker.Name, "kickee", kickee.Name); server.DispatchServerOrdersToClients(new Order("StartKickVote", null, false) { ExtraData = (uint)kickeeID }.Serialize()); this.kickee = (kickee, kickeeConn); voteKickerStarter = (kicker, conn); @@ -145,7 +145,7 @@ namespace OpenRA.Server voteTracker[conn.PlayerIndex] = vote; else { - server.SendLocalizedMessageTo(conn, AlreadyVoted, null); + server.SendLocalizedMessageTo(conn, AlreadyVoted); return false; } @@ -168,9 +168,9 @@ namespace OpenRA.Server } var votesNeeded = eligiblePlayers / 2 + 1; - server.SendLocalizedMessage(VoteKickProgress, FluentBundle.Arguments( + server.SendLocalizedMessage(VoteKickProgress, "kickee", kickee.Name, - "percentage", votesFor * 100 / eligiblePlayers)); + "percentage", votesFor * 100 / eligiblePlayers); // If a player or players during a vote lose or disconnect, it is possible that a downvote will // kick a client. Guard against that situation. @@ -210,7 +210,7 @@ namespace OpenRA.Server return; if (sendMessage) - server.SendLocalizedMessage(VoteKickEnded, FluentBundle.Arguments("kickee", kickee.Client.Name)); + server.SendLocalizedMessage(VoteKickEnded, "kickee", kickee.Client.Name); server.DispatchServerOrdersToClients(new Order("EndKickVote", null, false) { ExtraData = (uint)kickee.Client.Index }.Serialize()); diff --git a/OpenRA.Game/TextNotificationsManager.cs b/OpenRA.Game/TextNotificationsManager.cs index 469a5ab6e4..c6422f2e7c 100644 --- a/OpenRA.Game/TextNotificationsManager.cs +++ b/OpenRA.Game/TextNotificationsManager.cs @@ -41,9 +41,9 @@ namespace OpenRA AddTextNotification(TextNotificationPool.Transients, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text)); } - public static void AddFeedbackLine(string text, Dictionary arguments = null) + public static void AddFeedbackLine(string text, params object[] args) { - AddTextNotification(TextNotificationPool.Feedback, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, arguments)); + AddTextNotification(TextNotificationPool.Feedback, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, args)); } public static void AddMissionLine(string prefix, string text, Color? prefixColor = null) @@ -51,19 +51,19 @@ namespace OpenRA AddTextNotification(TextNotificationPool.Mission, SystemClientId, prefix, text, prefixColor); } - public static void AddPlayerJoinedLine(string text, Dictionary arguments = null) + public static void AddPlayerJoinedLine(string text, params object[] args) { - AddTextNotification(TextNotificationPool.Join, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, arguments)); + AddTextNotification(TextNotificationPool.Join, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, args)); } - public static void AddPlayerLeftLine(string text, Dictionary arguments = null) + public static void AddPlayerLeftLine(string text, params object[] args) { - AddTextNotification(TextNotificationPool.Leave, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, arguments)); + AddTextNotification(TextNotificationPool.Leave, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, args)); } - public static void AddSystemLine(string text, Dictionary arguments = null) + public static void AddSystemLine(string text, params object[] args) { - AddSystemLine(SystemMessageLabel, FluentProvider.GetString(text, arguments)); + AddSystemLine(SystemMessageLabel, FluentProvider.GetString(text, args)); } public static void AddSystemLine(string prefix, string text) diff --git a/OpenRA.Mods.Cnc/Installer/ExtractMixSourceAction.cs b/OpenRA.Mods.Cnc/Installer/ExtractMixSourceAction.cs index 494bc6bff9..5cbed64b77 100644 --- a/OpenRA.Mods.Cnc/Installer/ExtractMixSourceAction.cs +++ b/OpenRA.Mods.Cnc/Installer/ExtractMixSourceAction.cs @@ -51,13 +51,11 @@ namespace OpenRA.Mods.Cnc.Installer Action onProgress = null; if (stream.Length < InstallFromSourceLogic.ShowPercentageThreshold) - updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.Extracing, - FluentBundle.Arguments("filename", displayFilename))); + updateMessage(FluentProvider.GetString(InstallFromSourceLogic.Extracting, "filename", displayFilename)); else - onProgress = b => updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.ExtractingProgress, - FluentBundle.Arguments("filename", displayFilename, "progress", 100 * b / stream.Length))); + onProgress = b => updateMessage(FluentProvider.GetString(InstallFromSourceLogic.ExtractingProgress, + "filename", displayFilename, + "progress", 100 * b / stream.Length)); using (var target = File.OpenWrite(targetPath)) { diff --git a/OpenRA.Mods.Common/Commands/ChatCommands.cs b/OpenRA.Mods.Common/Commands/ChatCommands.cs index fcef570f8b..31c6dba0e0 100644 --- a/OpenRA.Mods.Common/Commands/ChatCommands.cs +++ b/OpenRA.Mods.Common/Commands/ChatCommands.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Commands if (Commands.TryGetValue(name, out var command)) command.InvokeCommand(name, message[(1 + name.Length)..].Trim()); else - TextNotificationsManager.Debug(FluentProvider.GetString(InvalidCommand, FluentBundle.Arguments("name", name))); + TextNotificationsManager.Debug(FluentProvider.GetString(InvalidCommand, "name", name)); return false; } diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs index 61d6b747ef..284d78229a 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs @@ -168,7 +168,8 @@ namespace OpenRA.Mods.Common.Widgets { editorActorPreview = editorLayer.Add(actor); Text = FluentProvider.GetString(AddedActor, - FluentBundle.Arguments("name", editorActorPreview.Info.Name, "id", editorActorPreview.ID)); + "name", editorActorPreview.Info.Name, + "id", editorActorPreview.ID); } public void Undo() diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorCopyPasteBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorCopyPasteBrush.cs index fc59e65595..cfa0040d80 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorCopyPasteBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorCopyPasteBrush.cs @@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Widgets undoClipboard = CopySelectionContents(); - Text = FluentProvider.GetString(CopiedTiles, FluentBundle.Arguments("amount", clipboard.Tiles.Count)); + Text = FluentProvider.GetString(CopiedTiles, "amount", clipboard.Tiles.Count); } /// diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs index 604a3a1a25..59b1fd166b 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs @@ -308,13 +308,13 @@ namespace OpenRA.Mods.Common.Widgets }; if (selection.Area != null) - Text = FluentProvider.GetString(SelectedArea, FluentBundle.Arguments( - "x", selection.Area.TopLeft.X, - "y", selection.Area.TopLeft.Y, - "width", selection.Area.BottomRight.X - selection.Area.TopLeft.X, - "height", selection.Area.BottomRight.Y - selection.Area.TopLeft.Y)); + Text = FluentProvider.GetString(SelectedArea, + "x", selection.Area.TopLeft.X, + "y", selection.Area.TopLeft.Y, + "width", selection.Area.BottomRight.X - selection.Area.TopLeft.X, + "height", selection.Area.BottomRight.Y - selection.Area.TopLeft.Y); else if (selection.Actor != null) - Text = FluentProvider.GetString(SelectedActor, FluentBundle.Arguments("id", selection.Actor.ID)); + Text = FluentProvider.GetString(SelectedActor, "id", selection.Actor.ID); else Text = FluentProvider.GetString(ClearedSelection); } @@ -360,8 +360,7 @@ namespace OpenRA.Mods.Common.Widgets Actor = defaultBrush.Selection.Actor }; - Text = FluentProvider.GetString(RemovedActor, - FluentBundle.Arguments("name", actor.Info.Name, "id", actor.ID)); + Text = FluentProvider.GetString(RemovedActor, "name", actor.Info.Name, "id", actor.ID); } public void Execute() @@ -397,8 +396,7 @@ namespace OpenRA.Mods.Common.Widgets this.editorActorLayer = editorActorLayer; this.actor = actor; - Text = FluentProvider.GetString(RemovedActor, - FluentBundle.Arguments("name", actor.Info.Name, "id", actor.ID)); + Text = FluentProvider.GetString(RemovedActor, "name", actor.Info.Name, "id", actor.ID); } public void Execute() @@ -466,7 +464,7 @@ namespace OpenRA.Mods.Common.Widgets to = worldRenderer.Viewport.ViewToWorld(pixelTo + pixelOffset) + cellOffset; layer.MoveActor(actor, to); - Text = FluentProvider.GetString(MovedActor, FluentBundle.Arguments("id", actor.ID, "x1", from.X, "y1", from.Y, "x2", to.X, "y2", to.Y)); + Text = FluentProvider.GetString(MovedActor, "id", actor.ID, "x1", from.X, "y1", from.Y, "x2", to.X, "y2", to.Y); } } @@ -487,7 +485,7 @@ namespace OpenRA.Mods.Common.Widgets this.resourceLayer = resourceLayer; this.cell = cell; - Text = FluentProvider.GetString(RemovedResource, FluentBundle.Arguments("type", resourceType)); + Text = FluentProvider.GetString(RemovedResource, "type", resourceType); } public void Execute() diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs index 989bf036fd..3826b183e6 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs @@ -150,9 +150,9 @@ namespace OpenRA.Mods.Common.Widgets } if (type != null) - Text = FluentProvider.GetString(AddedMarkerTiles, FluentBundle.Arguments("amount", paintTiles.Count, "type", type)); + Text = FluentProvider.GetString(AddedMarkerTiles, "amount", paintTiles.Count, "type", type); else - Text = FluentProvider.GetString(RemovedMarkerTiles, FluentBundle.Arguments("amount", paintTiles.Count)); + Text = FluentProvider.GetString(RemovedMarkerTiles, "amount", paintTiles.Count); } } @@ -176,7 +176,7 @@ namespace OpenRA.Mods.Common.Widgets tiles = new HashSet(markerLayerOverlay.Tiles[tile]); - Text = FluentProvider.GetString(ClearedSelectedMarkerTiles, FluentBundle.Arguments("amount", tiles.Count, "type", tile)); + Text = FluentProvider.GetString(ClearedSelectedMarkerTiles, "amount", tiles.Count, "type", tile); } public void Execute() @@ -213,7 +213,7 @@ namespace OpenRA.Mods.Common.Widgets var allTilesCount = tiles.Values.Select(x => x.Count).Sum(); - Text = FluentProvider.GetString(ClearedAllMarkerTiles, FluentBundle.Arguments("amount", allTilesCount)); + Text = FluentProvider.GetString(ClearedAllMarkerTiles, "amount", allTilesCount); } public void Execute() diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs index e910c82cc2..5e21239c18 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs @@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Widgets resourceLayer.ClearResources(resourceCell.Cell); resourceLayer.AddResource(resourceCell.NewResourceType, resourceCell.Cell, resourceLayer.GetMaxDensity(resourceCell.NewResourceType)); cellResources.Add(resourceCell); - Text = FluentProvider.GetString(AddedResource, FluentBundle.Arguments("amount", cellResources.Count, "type", resourceType)); + Text = FluentProvider.GetString(AddedResource, "amount", cellResources.Count, "type", resourceType); } } } diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs index 4bda68e356..9ac43904a2 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs @@ -192,7 +192,7 @@ namespace OpenRA.Mods.Common.Widgets var terrainInfo = (ITemplatedTerrainInfo)map.Rules.TerrainInfo; terrainTemplate = terrainInfo.Templates[template]; - Text = FluentProvider.GetString(AddedTile, FluentBundle.Arguments("id", terrainTemplate.Id)); + Text = FluentProvider.GetString(AddedTile, "id", terrainTemplate.Id); } public void Execute() @@ -264,7 +264,7 @@ namespace OpenRA.Mods.Common.Widgets var terrainInfo = (ITemplatedTerrainInfo)map.Rules.TerrainInfo; terrainTemplate = terrainInfo.Templates[template]; - Text = FluentProvider.GetString(FilledTile, FluentBundle.Arguments("id", terrainTemplate.Id)); + Text = FluentProvider.GetString(FilledTile, "id", terrainTemplate.Id); } public void Execute() diff --git a/OpenRA.Mods.Common/Installer/SourceActions/CopySourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/CopySourceAction.cs index 59e22b1647..98b06b6e43 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/CopySourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/CopySourceAction.cs @@ -44,13 +44,12 @@ namespace OpenRA.Mods.Common.Installer Action onProgress = null; if (length < InstallFromSourceLogic.ShowPercentageThreshold) - updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.CopyingFilename, - FluentBundle.Arguments("filename", displayFilename))); + updateMessage(FluentProvider.GetString(InstallFromSourceLogic.CopyingFilename, + "filename", displayFilename)); else - onProgress = b => updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.CopyingFilenameProgress, - FluentBundle.Arguments("filename", displayFilename, "progress", 100 * b / length))); + onProgress = b => updateMessage(FluentProvider.GetString(InstallFromSourceLogic.CopyingFilenameProgress, + "filename", displayFilename, + "progress", 100 * b / length)); InstallerUtils.CopyStream(source, target, length, onProgress); } diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractBlastSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractBlastSourceAction.cs index 5246631269..252d4521d0 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractBlastSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractBlastSourceAction.cs @@ -68,13 +68,12 @@ namespace OpenRA.Mods.Common.Installer Action onProgress = null; if (length < InstallFromSourceLogic.ShowPercentageThreshold) - updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.Extracing, - FluentBundle.Arguments("filename", displayFilename))); + updateMessage(FluentProvider.GetString(InstallFromSourceLogic.Extracting, + "filename", displayFilename)); else - onProgress = b => updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.ExtractingProgress, - FluentBundle.Arguments("filename", displayFilename, "progress", 100 * b / length))); + onProgress = b => updateMessage(FluentProvider.GetString(InstallFromSourceLogic.ExtractingProgress, + "filename", displayFilename, + "progress", 100 * b / length)); using (var target = File.OpenWrite(targetPath)) { diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractIscabSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractIscabSourceAction.cs index a48c356fc1..004f98015d 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractIscabSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractIscabSourceAction.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Installer var displayFilename = Path.GetFileName(Path.GetFileName(targetPath)); void OnProgress(int percent) => updateMessage(FluentProvider.GetString( InstallFromSourceLogic.ExtractingProgress, - FluentBundle.Arguments("filename", displayFilename, "progress", percent))); + "filename", displayFilename, "progress", percent)); reader.ExtractFile(node.Value.Value, target, OnProgress); } } diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractMscabSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractMscabSourceAction.cs index 5840a88af9..6bc940fe79 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractMscabSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractMscabSourceAction.cs @@ -46,9 +46,9 @@ namespace OpenRA.Mods.Common.Installer { Log.Write("install", $"Extracting {sourcePath} -> {targetPath}"); var displayFilename = Path.GetFileName(Path.GetFileName(targetPath)); - void OnProgress(int percent) => updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.ExtractingProgress, - FluentBundle.Arguments("filename", displayFilename, "progress", percent))); + void OnProgress(int percent) => updateMessage(FluentProvider.GetString(InstallFromSourceLogic.ExtractingProgress, + "filename", displayFilename, + "progress", percent)); reader.ExtractFile(node.Value.Value, target, OnProgress); } } diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractRawSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractRawSourceAction.cs index 2fe4a5d44a..e4b14a00a5 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractRawSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractRawSourceAction.cs @@ -61,11 +61,12 @@ namespace OpenRA.Mods.Common.Installer Action onProgress = null; if (length < InstallFromSourceLogic.ShowPercentageThreshold) - updateMessage(FluentProvider.GetString(InstallFromSourceLogic.Extracing, FluentBundle.Arguments("filename", displayFilename))); + updateMessage(FluentProvider.GetString(InstallFromSourceLogic.Extracting, + "filename", displayFilename)); else - onProgress = b => updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.ExtractingProgress, - FluentBundle.Arguments("filename", displayFilename, "progress", 100 * b / length))); + onProgress = b => updateMessage(FluentProvider.GetString(InstallFromSourceLogic.ExtractingProgress, + "filename", displayFilename, + "progress", 100 * b / length)); using (var target = File.OpenWrite(targetPath)) { diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractZipSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractZipSourceAction.cs index f6c481d95d..3d700185d2 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractZipSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractZipSourceAction.cs @@ -49,9 +49,9 @@ namespace OpenRA.Mods.Common.Installer using (var targetStream = File.OpenWrite(targetPath)) sourceStream.CopyTo(targetStream); - updateMessage(FluentProvider.GetString( - InstallFromSourceLogic.ExtractingProgress, - FluentBundle.Arguments("filename", displayFilename, "progress", 100))); + updateMessage(FluentProvider.GetString(InstallFromSourceLogic.ExtractingProgress, + "filename", displayFilename, + "progress", 100)); extracted.Add(targetPath); } diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index a12623795c..41680faaed 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -224,7 +224,7 @@ namespace OpenRA.Mods.Common.Server if (server.State == ServerState.GameStarted) { - server.SendLocalizedMessageTo(conn, StateUnchangedGameStarted, FluentBundle.Arguments("command", command)); + server.SendLocalizedMessageTo(conn, StateUnchangedGameStarted, new object[] { "command", command }); return false; } else if (client.State == Session.ClientState.Ready && !(command.StartsWith("state", StringComparison.Ordinal) || command == "startgame")) @@ -303,7 +303,7 @@ namespace OpenRA.Mods.Common.Server { if (!Enum.TryParse(s, false, out var state)) { - server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "state")); + server.SendLocalizedMessageTo(conn, MalformedCommand, new object[] { "command", "state" }); return true; } @@ -399,7 +399,7 @@ namespace OpenRA.Mods.Common.Server return true; } - server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "allow_spectate")); + server.SendLocalizedMessageTo(conn, MalformedCommand, new object[] { "command", "allow_spectate" }); return true; } @@ -488,7 +488,7 @@ namespace OpenRA.Mods.Common.Server var parts = s.Split(' '); if (parts.Length < 3) { - server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "slot_bot")); + server.SendLocalizedMessageTo(conn, MalformedCommand, new object[] { "command", "slot_bot" }); return true; } @@ -652,7 +652,7 @@ namespace OpenRA.Mods.Common.Server server.SyncLobbyInfo(); - server.SendLocalizedMessage(ChangedMap, FluentBundle.Arguments("player", client.Name, "map", server.Map.Title)); + server.SendLocalizedMessage(ChangedMap, "player", client.Name, "map", server.Map.Title); if ((server.LobbyInfo.GlobalSettings.MapStatus & Session.MapStatus.UnsafeCustomRules) != 0) server.SendLocalizedMessage(CustomRules); @@ -722,7 +722,7 @@ namespace OpenRA.Mods.Common.Server if (option.IsLocked) { - server.SendLocalizedMessageTo(conn, OptionLocked, FluentBundle.Arguments("option", option.Name)); + server.SendLocalizedMessageTo(conn, OptionLocked, new object[] { "option", option.Name }); return true; } @@ -739,7 +739,7 @@ namespace OpenRA.Mods.Common.Server oo.Value = oo.PreferredValue = split[1]; server.SyncLobbyGlobalSettings(); - server.SendLocalizedMessage(ValueChanged, FluentBundle.Arguments("player", client.Name, "name", option.Name, "value", option.Label(split[1]))); + server.SendLocalizedMessage(ValueChanged, "player", client.Name, "name", option.Name, "value", option.Label(split[1])); foreach (var c in server.LobbyInfo.Clients) c.State = Session.ClientState.NotReady; @@ -768,10 +768,10 @@ namespace OpenRA.Mods.Common.Server foreach (var o in allOptions) { if (o.DefaultValue != server.LobbyInfo.GlobalSettings.LobbyOptions[o.Id].Value) - server.SendLocalizedMessage(ValueChanged, FluentBundle.Arguments( + server.SendLocalizedMessage(ValueChanged, "player", client.Name, "name", o.Name, - "value", o.Label(o.DefaultValue))); + "value", o.Label(o.DefaultValue)); options[o.Id] = new Session.LobbyOptionState { @@ -805,7 +805,7 @@ namespace OpenRA.Mods.Common.Server if (!Exts.TryParseInt32Invariant(raw, out var teamCount)) { - server.SendLocalizedMessageTo(conn, NumberTeams, FluentBundle.Arguments("raw", raw)); + server.SendLocalizedMessageTo(conn, NumberTeams, new object[] { "raw", raw }); return true; } @@ -850,7 +850,7 @@ namespace OpenRA.Mods.Common.Server var split = s.Split(' '); if (split.Length < 2) { - server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "kick")); + server.SendLocalizedMessageTo(conn, MalformedCommand, new object[] { "command", "kick" }); return true; } @@ -877,14 +877,14 @@ namespace OpenRA.Mods.Common.Server } Log.Write("server", $"Kicking client {kickClientID}."); - server.SendLocalizedMessage(AdminKicked, FluentBundle.Arguments("admin", client.Name, "player", kickClient.Name)); + server.SendLocalizedMessage(AdminKicked, "admin", client.Name, "player", kickClient.Name); server.SendOrderTo(kickConn, "ServerError", YouWereKicked); server.DropClient(kickConn); if (bool.TryParse(split[1], out var tempBan) && tempBan) { Log.Write("server", $"Temporarily banning client {kickClientID} ({kickClient.IPAddress})."); - server.SendLocalizedMessage(TempBan, FluentBundle.Arguments("admin", client.Name, "player", kickClient.Name)); + server.SendLocalizedMessage(TempBan, "admin", client.Name, "player", kickClient.Name); server.TempBans.Add(kickClient.IPAddress); } @@ -902,7 +902,7 @@ namespace OpenRA.Mods.Common.Server var split = s.Split(' '); if (split.Length != 2) { - server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "vote_kick")); + server.SendLocalizedMessageTo(conn, MalformedCommand, new object[] { "command", "vote_kick" }); return true; } @@ -930,14 +930,14 @@ namespace OpenRA.Mods.Common.Server if (!bool.TryParse(split[1], out var vote)) { - server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "vote_kick")); + server.SendLocalizedMessageTo(conn, MalformedCommand, new object[] { "command", "vote_kick" }); return true; } if (server.VoteKickTracker.VoteKick(conn, client, kickConn, kickClient, kickClientID, vote)) { Log.Write("server", $"Kicking client {kickClientID}."); - server.SendLocalizedMessage(Kicked, FluentBundle.Arguments("player", kickClient.Name)); + server.SendLocalizedMessage(Kicked, "player", kickClient.Name); server.SendOrderTo(kickConn, "ServerError", YouWereKicked); server.DropClient(kickConn); @@ -980,7 +980,7 @@ namespace OpenRA.Mods.Common.Server foreach (var b in bots) b.BotControllerClientIndex = newAdminId; - server.SendLocalizedMessage(NewAdmin, FluentBundle.Arguments("player", newAdminClient.Name)); + server.SendLocalizedMessage(NewAdmin, "player", newAdminClient.Name); Log.Write("server", $"{newAdminClient.Name} is now the admin."); server.SyncLobbyClients(); @@ -1014,7 +1014,7 @@ namespace OpenRA.Mods.Common.Server targetClient.Handicap = 0; targetClient.Color = Color.White; targetClient.State = Session.ClientState.NotReady; - server.SendLocalizedMessage(MoveSpectators, FluentBundle.Arguments("admin", client.Name, "player", targetClient.Name)); + server.SendLocalizedMessage(MoveSpectators, "admin", client.Name, "player", targetClient.Name); Log.Write("server", $"{client.Name} moved {targetClient.Name} to spectators."); server.SyncLobbyClients(); CheckAutoStart(server); @@ -1032,7 +1032,7 @@ namespace OpenRA.Mods.Common.Server return true; Log.Write("server", $"Player@{conn.EndPoint} is now known as {sanitizedName}."); - server.SendLocalizedMessage(Nick, FluentBundle.Arguments("player", client.Name, "name", sanitizedName)); + server.SendLocalizedMessage(Nick, "player", client.Name, "name", sanitizedName); client.Name = sanitizedName; server.SyncLobbyClients(); @@ -1062,8 +1062,8 @@ namespace OpenRA.Mods.Common.Server var faction = parts[1]; if (!factions.Contains(faction)) { - server.SendLocalizedMessageTo(conn, InvalidFactionSelected, FluentBundle.Arguments("faction", faction)); - server.SendLocalizedMessageTo(conn, SupportedFactions, FluentBundle.Arguments("factions", factions.JoinWith(", "))); + server.SendLocalizedMessageTo(conn, InvalidFactionSelected, new object[] { "faction", faction }); + server.SendLocalizedMessageTo(conn, SupportedFactions, new object[] { "factions", factions.JoinWith(", ") }); return true; } diff --git a/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs b/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs index f0b360749a..d877c60f1f 100644 --- a/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs +++ b/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs @@ -9,7 +9,6 @@ */ #endregion -using System.Collections.Generic; using System.Linq; using OpenRA.Server; using S = OpenRA.Server.Server; @@ -69,13 +68,13 @@ namespace OpenRA.Mods.Common.Server { if (!c.TimeoutMessageShown && c.TimeSinceLastResponse > PingInterval * 2) { - server.SendLocalizedMessage(ConnectionProblems, FluentBundle.Arguments("player", client.Name)); + server.SendLocalizedMessage(ConnectionProblems, "player", client.Name); c.TimeoutMessageShown = true; } } else { - server.SendLocalizedMessage(Timeout, FluentBundle.Arguments("player", client.Name)); + server.SendLocalizedMessage(Timeout, "player", client.Name); server.DropClient(c); } } @@ -94,11 +93,7 @@ namespace OpenRA.Mods.Common.Server if (client != null) { var timeout = (ConnTimeout - c.TimeSinceLastResponse) / 1000; - server.SendLocalizedMessage(TimeoutIn, new Dictionary() - { - { "player", client.Name }, - { "timeout", timeout } - }); + server.SendLocalizedMessage(TimeoutIn, "player", client.Name, "timeout", timeout); } } } diff --git a/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs b/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs index d80538610c..d26a000a44 100644 --- a/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs +++ b/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs @@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Traits if (info.SuppressNotifications) return; - TextNotificationsManager.AddSystemLine(PlayerIsDefeated, FluentBundle.Arguments("player", player.ResolvedPlayerName)); + TextNotificationsManager.AddSystemLine(PlayerIsDefeated, "player", player.ResolvedPlayerName); Game.RunAfterDelay(info.NotificationDelay, () => { if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) @@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Traits if (info.SuppressNotifications) return; - TextNotificationsManager.AddSystemLine(PlayerIsVictorious, FluentBundle.Arguments("player", player.ResolvedPlayerName)); + TextNotificationsManager.AddSystemLine(PlayerIsVictorious, "player", player.ResolvedPlayerName); Game.RunAfterDelay(info.NotificationDelay, () => { if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) diff --git a/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs b/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs index 16e249c630..35fab62eb1 100644 --- a/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs @@ -275,8 +275,10 @@ namespace OpenRA.Mods.Common.Traits return; } - var arguments = FluentBundle.Arguments("cheat", order.OrderString, "player", self.Owner.ResolvedPlayerName, "suffix", debugSuffix); - TextNotificationsManager.Debug(FluentProvider.GetString(CheatUsed, arguments)); + TextNotificationsManager.Debug(FluentProvider.GetString(CheatUsed, + "cheat", order.OrderString, + "player", self.Owner.ResolvedPlayerName, + "suffix", debugSuffix)); } bool IUnlocksRenderPlayer.RenderPlayerUnlocked => Enabled; diff --git a/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs b/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs index 9e7eb2bc2e..d8d55a5281 100644 --- a/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs +++ b/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs @@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits if (info.SuppressNotifications) return; - TextNotificationsManager.AddSystemLine(PlayerIsDefeated, FluentBundle.Arguments("player", player.ResolvedPlayerName)); + TextNotificationsManager.AddSystemLine(PlayerIsDefeated, "player", player.ResolvedPlayerName); Game.RunAfterDelay(info.NotificationDelay, () => { if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) @@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Traits if (info.SuppressNotifications) return; - TextNotificationsManager.AddSystemLine(PlayerIsVictorious, FluentBundle.Arguments("player", player.ResolvedPlayerName)); + TextNotificationsManager.AddSystemLine(PlayerIsVictorious, "player", player.ResolvedPlayerName); Game.RunAfterDelay(info.NotificationDelay, () => { if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) diff --git a/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs b/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs index 98c1190513..5c000f81ab 100644 --- a/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs +++ b/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs @@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits if (m == 0) return FluentProvider.GetString(NoTimeLimit); else - return FluentProvider.GetString(TimeLimitOption, FluentBundle.Arguments("minutes", m)); + return FluentProvider.GetString(TimeLimitOption, "minutes", m); }); yield return new LobbyOption(map, "timelimit", TimeLimitLabel, TimeLimitDescription, TimeLimitDropdownVisible, TimeLimitDisplayOrder, diff --git a/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs b/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs index 71ede68678..e64748e0d2 100644 --- a/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs +++ b/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs @@ -10,7 +10,6 @@ #endregion using System; -using System.Collections.Generic; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets @@ -21,8 +20,8 @@ namespace OpenRA.Mods.Common.Widgets ModData modData, string title, string text, - Dictionary titleArguments = null, - Dictionary textArguments = null, + object[] titleArguments = null, + object[] textArguments = null, Action onConfirm = null, string confirmText = null, Action onCancel = null, diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index 407d0df07c..0bb50f141e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -238,7 +238,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (frameText != null) { var soundLength = new CachedTransform(p => - FluentProvider.GetString(LengthInSeconds, FluentBundle.Arguments("length", Math.Round(p, 3)))); + FluentProvider.GetString(LengthInSeconds, "length", Math.Round(p, 3))); frameText.GetText = () => { diff --git a/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs index 3689c8c580..79e083b846 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var panel = widget; panel.Get("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); }; - var connectingDesc = FluentProvider.GetString(ConnectingToEndpoint, FluentBundle.Arguments("endpoint", endpoint)); + var connectingDesc = FluentProvider.GetString(ConnectingToEndpoint, "endpoint", endpoint); widget.Get("CONNECTING_DESC").GetText = () => connectingDesc; } @@ -130,7 +130,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic onRetry(pass); }; - var connectingDescText = FluentProvider.GetString(CouldNotConnectToTarget, FluentBundle.Arguments("target", connection.Target)); + var connectingDescText = FluentProvider.GetString(CouldNotConnectToTarget, "target", connection.Target); widget.Get("CONNECTING_DESC").GetText = () => connectingDescText; var connectionError = widget.Get("CONNECTION_ERROR"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs index 78aa9443ec..832cf652ef 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs @@ -454,7 +454,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { Actor = actor; this.handles = handles; - Text = FluentProvider.GetString(EditedActor, FluentBundle.Arguments("name", actor.Info.Name, "id", actor.ID)); + Text = FluentProvider.GetString(EditedActor, "name", actor.Info.Name, "id", actor.ID); } public void Execute() @@ -466,7 +466,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var after = Actor; if (before != after) - Text = FluentProvider.GetString(EditedActorId, FluentBundle.Arguments("name", after.Info.Name, "old-id", before.ID, "new-id", after.ID)); + Text = FluentProvider.GetString(EditedActorId, "name", after.Info.Name, "old-id", before.ID, "new-id", after.ID); } public void Do() diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs index cd6caa4077..a4d784c89f 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var tooltip = a.TraitInfos().FirstOrDefault(ti => ti.EnabledByDefault) as TooltipInfoBase ?? a.TraitInfos().FirstOrDefault(ti => ti.EnabledByDefault); - var actorType = FluentProvider.GetString(ActorTypeTooltip, FluentBundle.Arguments("actorType", a.Name)); + var actorType = FluentProvider.GetString(ActorTypeTooltip, "actorType", a.Name); var searchTerms = new List() { a.Name }; if (tooltip != null) diff --git a/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs index b79a9ed12b..f95c6dfe07 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs @@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic const string OverwriteSavePrompt = "dialog-overwrite-save.prompt"; [FluentReference] - const string OverwriteSaveAccpet = "dialog-overwrite-save.confirm"; + const string OverwriteSaveAccept = "dialog-overwrite-save.confirm"; readonly Widget panel; readonly ScrollPanelWidget gameList; @@ -173,7 +173,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteSaveTitle, text: DeleteSavePrompt, - textArguments: FluentBundle.Arguments("save", Path.GetFileNameWithoutExtension(selectedSave)), + textArguments: new object[] { "save", Path.GetFileNameWithoutExtension(selectedSave) }, onConfirm: () => { Delete(selectedSave); @@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteAllSavesTitle, text: DeleteAllSavesPrompt, - textArguments: FluentBundle.Arguments("count", games.Count), + textArguments: new object[] { "count", games.Count }, onConfirm: () => { foreach (var s in games.ToList()) @@ -293,7 +293,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (Exception ex) { - TextNotificationsManager.Debug(FluentProvider.GetString(SaveDeletionFailed, FluentBundle.Arguments("savePath", savePath))); + TextNotificationsManager.Debug(FluentProvider.GetString(SaveDeletionFailed, "savePath", savePath)); Log.Write("debug", ex.ToString()); return; } @@ -373,9 +373,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: OverwriteSaveTitle, text: OverwriteSavePrompt, - textArguments: FluentBundle.Arguments("file", saveTextField.Text), + textArguments: new object[] { "file", saveTextField.Text }, onConfirm: Inner, - confirmText: OverwriteSaveAccpet, + confirmText: OverwriteSaveAccept, onCancel: () => { }); } else diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs index ff6c8e221e..89892583fc 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs @@ -160,8 +160,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: VoteKickTitle, text: botsCount > 0 ? VoteKickPromptBreakBots : VoteKickPrompt, - titleArguments: FluentBundle.Arguments("player", client.Name), - textArguments: FluentBundle.Arguments("bots", botsCount), + titleArguments: new object[] { "player", client.Name }, + textArguments: new object[] { "bots", botsCount }, onConfirm: () => { orderManager.IssueOrder(Order.Command($"vote_kick {client.Index} {true}")); @@ -176,8 +176,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: VoteKickTitle, text: botsCount > 0 ? VoteKickPromptBreakBots : VoteKickPrompt, - titleArguments: FluentBundle.Arguments("player", client.Name), - textArguments: FluentBundle.Arguments("bots", botsCount), + titleArguments: new object[] { "player", client.Name }, + textArguments: new object[] { "bots", botsCount }, onConfirm: () => { orderManager.IssueOrder(Order.Command($"vote_kick {client.Index} {true}")); @@ -201,7 +201,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: KickTitle, text: KickPrompt, - titleArguments: FluentBundle.Arguments("player", client.Name), + titleArguments: new object[] { "player", client.Name }, onConfirm: () => { orderManager.IssueOrder(Order.Command($"kick {client.Index} {false}")); @@ -227,7 +227,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var teamHeader = ScrollItemWidget.Setup(teamTemplate, () => false, () => { }); var team = t.Key > 0 - ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", t.Key)) + ? FluentProvider.GetString(TeamNumber, "team", t.Key) : FluentProvider.GetString(NoTeam); teamHeader.Get("TEAM").GetText = () => team; var teamRating = teamHeader.Get("TEAM_SCORE"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs index 487b553356..de3952b5a6 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var pausedText = FluentProvider.GetString(GameTimerLogic.Paused); var maxSpeedText = FluentProvider.GetString(MaxSpeed); var speedText = new CachedTransform(p => - FluentProvider.GetString(Speed, FluentBundle.Arguments("percentage", p))); + FluentProvider.GetString(Speed, "percentage", p)); if (timer != null) { @@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var timerText = new CachedTransform(p => - FluentProvider.GetString(Complete, FluentBundle.Arguments("percentage", p))); + FluentProvider.GetString(Complete, "percentage", p)); if (timer is LabelWithTooltipWidget timerTooltip) { var connection = orderManager.Connection as ReplayConnection; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectAllUnitsHotkeyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectAllUnitsHotkeyLogic.cs index c2a5e50c8f..82419345e8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectAllUnitsHotkeyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectAllUnitsHotkeyLogic.cs @@ -54,12 +54,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame // Check if selecting actors on the screen has selected new units if (newSelection.Count > selection.Actors.Count) - TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, FluentBundle.Arguments("units", newSelection.Count)); + TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, "units", newSelection.Count); else { // Select actors in the world that have highest selection priority newSelection = SelectionUtils.SelectActorsInWorld(world, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); - TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, FluentBundle.Arguments("units", newSelection.Count)); + TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, "units", newSelection.Count); } selection.Combine(world, newSelection, false, false); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectUnitsByTypeHotkeyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectUnitsByTypeHotkeyLogic.cs index 6a1a3976a1..e22d798b7d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectUnitsByTypeHotkeyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectUnitsByTypeHotkeyLogic.cs @@ -79,12 +79,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame // Check if selecting actors on the screen has selected new units if (newSelection.Count > selection.Actors.Count) - TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, FluentBundle.Arguments("units", newSelection.Count)); + TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, "units", newSelection.Count); else { // Select actors in the world that have the same selection class as one of the already selected actors newSelection = SelectionUtils.SelectActorsInWorld(world, selectedClasses, eligiblePlayers).ToList(); - TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, FluentBundle.Arguments("units", newSelection.Count)); + TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, "units", newSelection.Count); } selection.Combine(world, newSelection, true, false); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs index 9810a1c11e..a6b803bedb 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic displayResources = playerResources.GetCashAndResources(); siloUsageTooltipCache = new CachedTransform<(int Resources, int Capacity), string>(x => - FluentProvider.GetString(SiloUsage, FluentBundle.Arguments("usage", x.Resources, "capacity", x.Capacity))); + FluentProvider.GetString(SiloUsage, "usage", x.Resources, "capacity", x.Capacity)); cashLabel = widget.Get("CASH"); cashLabel.GetTooltipText = () => siloUsageTooltip; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index 6aa169c6cc..26a060b5d7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -194,7 +194,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic return true; }; - chatAvailableIn = new CachedTransform(x => FluentProvider.GetString(ChatAvailability, FluentBundle.Arguments("seconds", x))); + chatAvailableIn = new CachedTransform(x => FluentProvider.GetString(ChatAvailability, "seconds", x)); if (!isMenuChat) { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs index 57a64ae611..d27c541404 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs @@ -494,7 +494,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: ErrorMaxPlayerTitle, text: ErrorMaxPlayerPrompt, - textArguments: FluentBundle.Arguments("players", playerCount, "max", MapPlayers.MaximumPlayerCount), + textArguments: new object[] { "players", playerCount, "max", MapPlayers.MaximumPlayerCount }, onConfirm: ShowMenu, confirmText: ErrorMaxPlayerAccept); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerBarLogic.cs index 03388961e4..c6c9474a09 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerBarLogic.cs @@ -39,9 +39,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic FluentProvider.GetString(Infinite) : powerManager.PowerProvided.ToString(NumberFormatInfo.CurrentInfo); - return FluentProvider.GetString( - PowerUsage, - FluentBundle.Arguments("usage", usage.Current, "capacity", capacity)); + return FluentProvider.GetString(PowerUsage, "usage", usage.Current, "capacity", capacity); }); powerBar.GetBarColor = () => diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs index 5a6271b0cd..3537217066 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs @@ -41,11 +41,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var tooltipTextCached = new CachedTransform<(int, int?), string>(((int Usage, int? Capacity) args) => { var capacity = args.Capacity == null ? unlimitedCapacity : args.Capacity.Value.ToString(NumberFormatInfo.CurrentInfo); - return FluentProvider.GetString( - PowerUsage, - FluentBundle.Arguments( - "usage", args.Usage.ToString(NumberFormatInfo.CurrentInfo), - "capacity", capacity)); + return FluentProvider.GetString(PowerUsage, + "usage", args.Usage.ToString(NumberFormatInfo.CurrentInfo), + "capacity", capacity); }); power.GetTooltipText = () => diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameSiloBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameSiloBarLogic.cs index 348a58550d..1d10177124 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameSiloBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameSiloBarLogic.cs @@ -28,12 +28,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic siloBar.GetProvided = () => playerResources.ResourceCapacity; siloBar.GetUsed = () => playerResources.Resources; - siloBar.TooltipTextCached = new CachedTransform<(float Current, float Capacity), string>(usage => - { - return FluentProvider.GetString( - SiloUsage, - FluentBundle.Arguments("usage", usage.Current, "capacity", usage.Capacity)); - }); + siloBar.TooltipTextCached = new CachedTransform<(float Current, float Capacity), string>( + usage => FluentProvider.GetString(SiloUsage, "usage", usage.Current, "capacity", usage.Capacity)); siloBar.GetBarColor = () => { if (playerResources.Resources == playerResources.ResourceCapacity) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs index da8eebf81d..a6c393b7f1 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs @@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { totalPlayers += t.Count(); var label = noTeams ? FluentProvider.GetString(Players) : t.Key > 0 - ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", t.Key)) + ? FluentProvider.GetString(TeamNumber, "team", t.Key) : FluentProvider.GetString(NoTeam); groups.Add(label, t); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs index d9361c2096..16cdce6a53 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs @@ -286,7 +286,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic tt.IgnoreMouseOver = true; var teamLabel = tt.Get("TEAM"); - var teamText = team.Key > 0 ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", team.Key)) + var teamText = team.Key > 0 ? FluentProvider.GetString(TeamNumber, "team", team.Key) : FluentProvider.GetString(NoTeam); teamLabel.GetText = () => teamText; tt.Bounds.Width = teamLabel.Bounds.Width = Game.Renderer.Fonts[tt.Font].Measure(teamText).X; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs index dbc120e988..bce9d65dae 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs @@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var requiresSize = int2.Zero; if (prereqs.Count > 0) { - var requiresText = FluentProvider.GetString(Requires, FluentBundle.Arguments("prequisites", prereqs.JoinWith(", "))); + var requiresText = FluentProvider.GetString(Requires, "prequisites", prereqs.JoinWith(", ")); requiresLabel.GetText = () => requiresText; requiresSize = requiresFont.Measure(requiresText); requiresLabel.Visible = true; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs index e9c5ef6aa0..4a332535f7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs @@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var status = new CachedTransform(s => WidgetUtils.TruncateText(s, statusLabel.Bounds.Width, statusFont)); statusLabel.GetText = () => status.Update(getStatusText()); - var text = FluentProvider.GetString(Downloading, FluentBundle.Arguments("title", download.Title)); + var text = FluentProvider.GetString(Downloading, "title", download.Title); panel.Get("TITLE").GetText = () => text; ShowDownloadDialog(); @@ -117,7 +117,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic dataSuffix = SizeSuffixes[mag]; getStatusText = () => FluentProvider.GetString(DownloadingFrom, - FluentBundle.Arguments("host", host, "received", $"{dataReceived:0.00}", "suffix", dataSuffix)); + "host", host, + "received", $"{dataReceived:0.00}", + "suffix", dataSuffix); progressBar.Indeterminate = true; } else @@ -128,8 +130,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic dataSuffix = SizeSuffixes[mag]; getStatusText = () => FluentProvider.GetString(DownloadingFromProgress, - FluentBundle.Arguments("host", host, "received", $"{dataReceived:0.00}", "total", $"{dataTotal:0.00}", - "suffix", dataSuffix, "progress", progressPercentage)); + "host", host, + "received", $"{dataReceived:0.00}", + "total", $"{dataTotal:0.00}", + "suffix", dataSuffix, + "progress", progressPercentage); progressBar.Indeterminate = false; } @@ -232,7 +237,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic continue; } - OnExtractProgress(FluentProvider.GetString(ExtractingEntry, FluentBundle.Arguments("entry", kv.Value))); + OnExtractProgress(FluentProvider.GetString(ExtractingEntry, "entry", kv.Value)); Log.Write("install", "Extracting " + kv.Value); var targetPath = Platform.ResolvePath(kv.Key); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromSourceLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromSourceLogic.cs index d2f2799f6e..ade0814e0c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromSourceLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromSourceLogic.cs @@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic const string CheckInstallLog = "label-check-install-log"; [FluentReference("filename")] - public const string Extracing = "label-extracting-filename"; + public const string Extracting = "label-extracting-filename"; [FluentReference("filename", "progress")] public const string ExtractingProgress = "label-extracting-filename-progress"; @@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { foreach (var kv in sources) { - message = FluentProvider.GetString(SearchingSourceFor, FluentBundle.Arguments("title", kv.Value.Title)); + message = FluentProvider.GetString(SearchingSourceFor, "title", kv.Value.Title); var sourceResolver = kv.Value.ObjectCreator.CreateObject($"{kv.Value.Type.Value}SourceResolver"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickClientLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickClientLogic.cs index d9f22962dd..2f3fe901f4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickClientLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickClientLogic.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ObjectCreator.UseCtor] public KickClientLogic(Widget widget, string clientName, Action okPressed, Action cancelPressed) { - var kickMessage = FluentProvider.GetString(KickClient, FluentBundle.Arguments("player", clientName)); + var kickMessage = FluentProvider.GetString(KickClient, "player", clientName); widget.Get("TITLE").GetText = () => kickMessage; var tempBan = false; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickSpectatorsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickSpectatorsLogic.cs index fec59045b7..f6326c83a0 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickSpectatorsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickSpectatorsLogic.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ObjectCreator.UseCtor] public KickSpectatorsLogic(Widget widget, int clientCount, Action okPressed, Action cancelPressed) { - var kickMessage = FluentProvider.GetString(KickSpectators, FluentBundle.Arguments("count", clientCount)); + var kickMessage = FluentProvider.GetString(KickSpectators, "count", clientCount); widget.Get("TEXT").GetText = () => kickMessage; widget.Get("OK_BUTTON").OnClick = () => diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index af59695673..59a67f518e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -323,7 +323,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var teamOptions = Enumerable.Range(2, teamCount - 1).Reverse().Select(d => new DropDownOption { - Title = FluentProvider.GetString(NumberTeams, FluentBundle.Arguments("count", d)), + Title = FluentProvider.GetString(NumberTeams, "count", d), IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command($"assignteams {d}")) }).ToList(); @@ -539,7 +539,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic chatTextField.OnEscKey = _ => chatTextField.YieldKeyboardFocus(); - chatAvailableIn = new CachedTransform(x => FluentProvider.GetString(ChatAvailability, FluentBundle.Arguments("seconds", x))); + chatAvailableIn = new CachedTransform(x => FluentProvider.GetString(ChatAvailability, "seconds", x)); chatDisabled = FluentProvider.GetString(ChatDisabled); lobbyChatPanel = lobby.Get("CHAT_DISPLAY"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs index d4943a1ab0..d5007e470c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs @@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var authorCache = new CachedTransform( - text => FluentProvider.GetString(CreatedBy, FluentBundle.Arguments("author", text))); + text => FluentProvider.GetString(CreatedBy, "author", text)); Widget SetupAuthorAndMapType(Widget parent) { @@ -169,9 +169,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Server does not provide the total file length. if (map.DownloadPercentage == 0) - return FluentProvider.GetString(Downloading, FluentBundle.Arguments("size", map.DownloadBytes / 1024)); + return FluentProvider.GetString(Downloading, "size", map.DownloadBytes / 1024); - return FluentProvider.GetString(DownloadingPercentage, FluentBundle.Arguments("size", map.DownloadBytes / 1024, "progress", map.DownloadPercentage)); + return FluentProvider.GetString(DownloadingPercentage, "size", map.DownloadBytes / 1024, "progress", map.DownloadPercentage); }; return parent; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/SpawnSelectorTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/SpawnSelectorTooltipLogic.cs index 2f127c45eb..15ee162db7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/SpawnSelectorTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/SpawnSelectorTooltipLogic.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var labelText = ""; string playerFaction = null; var playerTeam = -1; - teamMessage = new CachedTransform(t => FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", t))); + teamMessage = new CachedTransform(t => FluentProvider.GetString(TeamNumber, "team", t)); var disabledSpawn = FluentProvider.GetString(DisabledSpawn); var availableSpawn = FluentProvider.GetString(AvailableSpawn); diff --git a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs index 19dcc3f991..6c26a82cb8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs @@ -346,7 +346,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic catch (Exception e) { Game.RunAfterTick(() => // run on the main thread - SetNewsStatus(FluentProvider.GetString(NewsRetrivalFailed, FluentBundle.Arguments("message", e.Message)))); + SetNewsStatus(FluentProvider.GetString(NewsRetrivalFailed, "message", e.Message))); } }); } @@ -417,7 +417,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (Exception ex) { - SetNewsStatus(FluentProvider.GetString(NewsParsingFailed, FluentBundle.Arguments("message", ex.Message))); + SetNewsStatus(FluentProvider.GetString(NewsParsingFailed, "message", ex.Message)); } return null; @@ -438,9 +438,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic titleLabel.GetText = () => item.Title; var authorDateTimeLabel = newsItem.Get("AUTHOR_DATETIME"); - var authorDateTime = FluentProvider.GetString(AuthorDateTime, FluentBundle.Arguments( + var authorDateTime = FluentProvider.GetString(AuthorDateTime, "author", item.Author, - "datetime", item.DateTime.ToLocalTime().ToString(CultureInfo.CurrentCulture))); + "datetime", item.DateTime.ToLocalTime().ToString(CultureInfo.CurrentCulture)); authorDateTimeLabel.GetText = () => authorDateTime; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs index 59750890ea..aecb264818 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs @@ -205,9 +205,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var remoteMapText = new CachedTransform<(int Searching, int Unavailable), string>(counts => { if (counts.Searching > 0) - return FluentProvider.GetString(MapSearchingCount, FluentBundle.Arguments("count", counts.Searching)); + return FluentProvider.GetString(MapSearchingCount, "count", counts.Searching); - return FluentProvider.GetString(MapUnavailableCount, FluentBundle.Arguments("count", counts.Unavailable)); + return FluentProvider.GetString(MapUnavailableCount, "count", counts.Unavailable); }); remoteMapLabel.IsVisible = () => remoteMapPool != null && (remoteSearching > 0 || remoteUnavailable > 0); @@ -458,13 +458,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (type != null) details = type + " "; - details += FluentProvider.GetString(Players, FluentBundle.Arguments("players", preview.PlayerCount)); + details += FluentProvider.GetString(Players, "players", preview.PlayerCount); detailsWidget.GetText = () => details; } var authorWidget = item.GetOrNull("AUTHOR"); if (authorWidget != null && !string.IsNullOrEmpty(preview.Author)) - WidgetUtils.TruncateLabelToTooltip(authorWidget, FluentProvider.GetString(CreatedBy, FluentBundle.Arguments("author", preview.Author))); + WidgetUtils.TruncateLabelToTooltip(authorWidget, FluentProvider.GetString(CreatedBy, "author", preview.Author)); var sizeWidget = item.GetOrNull("SIZE"); if (sizeWidget != null) @@ -502,7 +502,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (Exception ex) { - TextNotificationsManager.Debug(FluentProvider.GetString(MapDeletionFailed, FluentBundle.Arguments("map", map))); + TextNotificationsManager.Debug(FluentProvider.GetString(MapDeletionFailed, "map", map)); Log.Write("debug", ex.ToString()); } @@ -514,7 +514,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteMapTitle, text: DeleteMapPrompt, - textArguments: FluentBundle.Arguments("title", modData.MapCache[map].Title), + textArguments: new object[] { "title", modData.MapCache[map].Title }, onConfirm: () => { var newUid = DeleteMap(map); diff --git a/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs index 1b6636b014..c7fb4451fe 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs @@ -365,7 +365,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var nameFont = Game.Renderer.Fonts[nameLabel.Font]; var controller = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.Index == client.BotControllerClientIndex); if (controller != null) - nameLabel.GetText = () => FluentProvider.GetString(BotManagedBy, FluentBundle.Arguments("name", controller.Name)); + nameLabel.GetText = () => FluentProvider.GetString(BotManagedBy, "name", controller.Name); widget.Bounds.Width = nameFont.Measure(nameLabel.GetText()).X + 2 * nameLabel.Bounds.Left; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs index 730d44cbd4..383eb7323e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs @@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }); var replayDuration = new CachedTransform(r => - FluentProvider.GetString(Duration, FluentBundle.Arguments("time", WidgetUtils.FormatTimeSeconds((int)selectedReplay.GameInfo.Duration.TotalSeconds)))); + FluentProvider.GetString(Duration, "time", WidgetUtils.FormatTimeSeconds((int)selectedReplay.GameInfo.Duration.TotalSeconds))); panel.Get("DURATION").GetText = () => replayDuration.Update(selectedReplay); SetupFilters(); @@ -507,7 +507,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteReplayTitle, text: DeleteReplayPrompt, - textArguments: FluentBundle.Arguments("replay", Path.GetFileNameWithoutExtension(r.FilePath)), + textArguments: new object[] { "replay", Path.GetFileNameWithoutExtension(r.FilePath) }, onConfirm: () => { DeleteReplay(r); @@ -545,7 +545,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteAllReplaysTitle, text: DeleteAllReplaysPrompt, - textArguments: FluentBundle.Arguments("count", list.Count), + textArguments: new object[] { "count", list.Count }, onConfirm: () => { foreach (var replayMetadata in list) @@ -584,7 +584,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (Exception ex) { - TextNotificationsManager.Debug(FluentProvider.GetString(ReplayDeletionFailed, FluentBundle.Arguments("file", replay.FilePath))); + TextNotificationsManager.Debug(FluentProvider.GetString(ReplayDeletionFailed, "file", replay.FilePath)); Log.Write("debug", ex.ToString()); return; } @@ -725,7 +725,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic foreach (var p in players) { var label = noTeams ? FluentProvider.GetString(Players) : p.Key > 0 - ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", p.Key)) + ? FluentProvider.GetString(TeamNumber, "team", p.Key) : FluentProvider.GetString(NoTeam); teams.Add(label, p); diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs index ae1e879360..74fabe43ef 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs @@ -10,7 +10,6 @@ #endregion using System; -using System.Collections.Generic; using OpenRA.FileFormats; namespace OpenRA.Mods.Common.Widgets.Logic @@ -48,32 +47,32 @@ namespace OpenRA.Mods.Common.Widgets.Logic onCancel ??= DoNothing; if (replayMeta == null) - return IncompatibleReplayDialog(IncompatibleReplayPrompt, null, modData, onCancel); + return IncompatibleReplayDialog(modData, onCancel, IncompatibleReplayPrompt); var version = replayMeta.GameInfo.Version; if (version == null) - return IncompatibleReplayDialog(UnknownVersion, null, modData, onCancel); + return IncompatibleReplayDialog(modData, onCancel, UnknownVersion); var mod = replayMeta.GameInfo.Mod; if (mod == null) - return IncompatibleReplayDialog(UnknownMod, null, modData, onCancel); + return IncompatibleReplayDialog(modData, onCancel, UnknownMod); if (!Game.Mods.ContainsKey(mod)) - return IncompatibleReplayDialog(UnvailableMod, FluentBundle.Arguments("mod", mod), modData, onCancel); + return IncompatibleReplayDialog(modData, onCancel, UnvailableMod, "mod", mod); if (Game.Mods[mod].Metadata.Version != version) - return IncompatibleReplayDialog(IncompatibleVersion, FluentBundle.Arguments("version", version), modData, onCancel); + return IncompatibleReplayDialog(modData, onCancel, IncompatibleVersion, "version", version); if (replayMeta.GameInfo.MapPreview.Status != MapStatus.Available) - return IncompatibleReplayDialog(UnvailableMap, FluentBundle.Arguments("map", replayMeta.GameInfo.MapUid), modData, onCancel); + return IncompatibleReplayDialog(modData, onCancel, UnvailableMap, "map", replayMeta.GameInfo.MapUid); return true; } - static bool IncompatibleReplayDialog(string text, Dictionary textArguments, ModData modData, Action onCancel) + static bool IncompatibleReplayDialog(ModData modData, Action onCancel, string text, params object[] args) { ConfirmationDialogs.ButtonPrompt( - modData, IncompatibleReplayTitle, text, textArguments: textArguments, onCancel: onCancel, cancelText: IncompatibleReplayAccept); + modData, IncompatibleReplayTitle, text, textArguments: args, onCancel: onCancel, cancelText: IncompatibleReplayAccept); return false; } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs index 23573de3ad..5f6e75a488 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs @@ -239,14 +239,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (System.Net.Sockets.SocketException e) { - var message = FluentProvider.GetString(ServerCreationFailedPrompt, FluentBundle.Arguments("port", Game.Settings.Server.ListenPort)); + var message = FluentProvider.GetString(ServerCreationFailedPrompt, "port", Game.Settings.Server.ListenPort); // AddressAlreadyInUse (WSAEADDRINUSE) if (e.ErrorCode == 10048) message += "\n" + FluentProvider.GetString(ServerCreationFailedPortUsed); else - message += "\n" + FluentProvider.GetString(ServerCreationFailedError, - FluentBundle.Arguments("message", e.Message, "code", e.ErrorCode)); + message += "\n" + FluentProvider.GetString(ServerCreationFailedError, "message", e.Message, "code", e.ErrorCode); ConfirmationDialogs.ButtonPrompt(modData, ServerCreationFailedTitle, message, onCancel: () => { }, cancelText: ServerCreationFailedCancel); diff --git a/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs index c853e9c748..4719d30a51 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs @@ -164,11 +164,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic mapStatusSearching = FluentProvider.GetString(MapStatusSearching); mapClassificationUnknown = FluentProvider.GetString(MapClassificationUnknown); - players = new CachedTransform(i => FluentProvider.GetString(PlayersLabel, FluentBundle.Arguments("players", i))); - bots = new CachedTransform(i => FluentProvider.GetString(BotsLabel, FluentBundle.Arguments("bots", i))); - spectators = new CachedTransform(i => FluentProvider.GetString(SpectatorsLabel, FluentBundle.Arguments("spectators", i))); + players = new CachedTransform(i => FluentProvider.GetString(PlayersLabel, "players", i)); + bots = new CachedTransform(i => FluentProvider.GetString(BotsLabel, "bots", i)); + spectators = new CachedTransform(i => FluentProvider.GetString(SpectatorsLabel, "spectators", i)); - minutes = new CachedTransform(i => FluentProvider.GetString(InProgress, FluentBundle.Arguments("minutes", i))); + minutes = new CachedTransform(i => FluentProvider.GetString(InProgress, "minutes", i)); passwordProtected = FluentProvider.GetString(PasswordProtected); waitingForPlayers = FluentProvider.GetString(WaitingForPlayers); serverShuttingDown = FluentProvider.GetString(ServerShuttingDown); @@ -318,7 +318,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var playersLabel = widget.GetOrNull("PLAYER_COUNT"); if (playersLabel != null) { - var playersText = new CachedTransform(p => FluentProvider.GetString(PlayersOnline, FluentBundle.Arguments("players", p))); + var playersText = new CachedTransform(p => FluentProvider.GetString(PlayersOnline, "players", p)); playersLabel.IsVisible = () => playerCount != 0; playersLabel.GetText = () => playersText.Update(playerCount); } @@ -582,7 +582,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic foreach (var p in players) { var label = noTeams ? FluentProvider.GetString(Players) : p.Key > 0 - ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", p.Key)) + ? FluentProvider.GetString(TeamNumber, "team", p.Key) : FluentProvider.GetString(NoTeam); teams.Add(label, p); } @@ -765,7 +765,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (game.Clients.Length > 10) displayClients = displayClients .Take(9) - .Append(FluentProvider.GetString(OtherPlayers, FluentBundle.Arguments("players", game.Clients.Length - 9))); + .Append(FluentProvider.GetString(OtherPlayers, "players", game.Clients.Length - 9)); var tooltip = displayClients.JoinWith("\n"); players.GetTooltipText = () => tooltip; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs index 2b637ba7a2..3f60f7e50e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs @@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var displaySelectionDropDown = panel.Get("DISPLAY_SELECTION_DROPDOWN"); displaySelectionDropDown.OnMouseDown = _ => ShowDisplaySelectionDropdown(displaySelectionDropDown, ds); - var displaySelectionLabel = new CachedTransform(i => FluentProvider.GetString(Display, FluentBundle.Arguments("number", i + 1))); + var displaySelectionLabel = new CachedTransform(i => FluentProvider.GetString(Display, "number", i + 1)); displaySelectionDropDown.GetText = () => displaySelectionLabel.Update(ds.VideoDisplay); displaySelectionDropDown.IsDisabled = () => Game.Renderer.DisplayCount < 2; @@ -242,7 +242,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var frameLimitGamespeedCheckbox = panel.Get("FRAME_LIMIT_GAMESPEED_CHECKBOX"); var frameLimitCheckbox = panel.Get("FRAME_LIMIT_CHECKBOX"); - var frameLimitLabel = new CachedTransform(fps => FluentProvider.GetString(FrameLimiter, FluentBundle.Arguments("fps", fps))); + var frameLimitLabel = new CachedTransform(fps => FluentProvider.GetString(FrameLimiter, "fps", fps)); frameLimitCheckbox.GetText = () => frameLimitLabel.Update(ds.MaxFramerate); frameLimitCheckbox.IsDisabled = () => ds.CapFramerateToGameFps; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs index 61268c9ac9..a0838955b0 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs @@ -229,16 +229,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic duplicateNotice.IsVisible = () => !isHotkeyValid; var duplicateNoticeText = new CachedTransform(hd => hd != null ? - FluentProvider.GetString(DuplicateNotice, FluentBundle.Arguments("key", hd.Description, - "context", hd.Contexts.First(c => selectedHotkeyDefinition.Contexts.Contains(c)))) : - ""); + FluentProvider.GetString(DuplicateNotice, + "key", hd.Description, + "context", hd.Contexts.First(c => selectedHotkeyDefinition.Contexts.Contains(c))) : ""); duplicateNotice.GetText = () => duplicateNoticeText.Update(duplicateHotkeyDefinition); var originalNotice = panel.Get("ORIGINAL_NOTICE"); originalNotice.TextColor = ChromeMetrics.Get("NoticeInfoColor"); originalNotice.IsVisible = () => isHotkeyValid && !isHotkeyDefault; var originalNoticeText = new CachedTransform(hd => - FluentProvider.GetString(OriginalNotice, FluentBundle.Arguments("key", hd?.Default.DisplayString()))); + FluentProvider.GetString(OriginalNotice, "key", hd?.Default.DisplayString())); originalNotice.GetText = () => originalNoticeText.Update(selectedHotkeyDefinition); var readonlyNotice = panel.Get("READONLY_NOTICE"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs index af500f51e8..f1f8d6e5f1 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs @@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: ResetTitle, text: ResetPrompt, - titleArguments: FluentBundle.Arguments("panel", panels[activePanel]), + titleArguments: new object[] { "panel", panels[activePanel] }, onConfirm: Reset, confirmText: ResetAccept, onCancel: () => { }, diff --git a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs index 026d7d90bc..99c4e0ac58 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs @@ -59,7 +59,10 @@ namespace OpenRA.Mods.Common.Widgets { var self = p.Instances[0].Self; var time = WidgetUtils.FormatTime(p.RemainingTicks, false, self.World.Timestep); - var text = FluentProvider.GetString(Format, FluentBundle.Arguments("player", self.Owner.ResolvedPlayerName, "support-power", p.Name, "time", time)); + var text = FluentProvider.GetString(Format, + "player", self.Owner.ResolvedPlayerName, + "support-power", p.Name, + "time", time); var color = !p.Ready || Game.LocalTick % 50 < 25 ? self.OwnerColor() : Color.White; diff --git a/OpenRA.Test/OpenRA.Game/FluentTest.cs b/OpenRA.Test/OpenRA.Game/FluentTest.cs index 4119c58626..55517cfd22 100644 --- a/OpenRA.Test/OpenRA.Game/FluentTest.cs +++ b/OpenRA.Test/OpenRA.Game/FluentTest.cs @@ -28,9 +28,9 @@ label-players = {$player -> public void TestOne() { var bundle = new FluentBundle("en", pluralForms, e => Console.WriteLine(e.Message)); - var label = bundle.GetString("label-players", FluentBundle.Arguments("player", 1)); + var label = bundle.GetString("label-players", new object[] { "player", 1 }); Assert.That("One player", Is.EqualTo(label)); - label = bundle.GetString("label-players", FluentBundle.Arguments("player", 2)); + label = bundle.GetString("label-players", new object[] { "player", 2 }); Assert.That("2 players", Is.EqualTo(label)); } }