Remove FluentBundle.Arguments helper method.

This commit is contained in:
Paul Chote
2024-10-02 22:40:05 +01:00
committed by Gustas
parent b29b685058
commit d6285affec
71 changed files with 273 additions and 283 deletions

View File

@@ -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<string, object> titleArguments = null,
Dictionary<string, object> textArguments = null,
object[] titleArguments = null,
object[] textArguments = null,
Action onConfirm = null,
string confirmText = null,
Action onCancel = null,

View File

@@ -238,7 +238,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (frameText != null)
{
var soundLength = new CachedTransform<double, string>(p =>
FluentProvider.GetString(LengthInSeconds, FluentBundle.Arguments("length", Math.Round(p, 3))));
FluentProvider.GetString(LengthInSeconds, "length", Math.Round(p, 3)));
frameText.GetText = () =>
{

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var panel = widget;
panel.Get<ButtonWidget>("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); };
var connectingDesc = FluentProvider.GetString(ConnectingToEndpoint, FluentBundle.Arguments("endpoint", endpoint));
var connectingDesc = FluentProvider.GetString(ConnectingToEndpoint, "endpoint", endpoint);
widget.Get<LabelWidget>("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<LabelWidget>("CONNECTING_DESC").GetText = () => connectingDescText;
var connectionError = widget.Get<LabelWidget>("CONNECTION_ERROR");

View File

@@ -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()

View File

@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var tooltip = a.TraitInfos<EditorOnlyTooltipInfo>().FirstOrDefault(ti => ti.EnabledByDefault) as TooltipInfoBase
?? a.TraitInfos<TooltipInfo>().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<string>() { a.Name };
if (tooltip != null)

View File

@@ -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

View File

@@ -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<LabelWidget>("TEAM").GetText = () => team;
var teamRating = teamHeader.Get<LabelWidget>("TEAM_SCORE");

View File

@@ -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<int, string>(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<int, string>(p =>
FluentProvider.GetString(Complete, FluentBundle.Arguments("percentage", p)));
FluentProvider.GetString(Complete, "percentage", p));
if (timer is LabelWithTooltipWidget timerTooltip)
{
var connection = orderManager.Connection as ReplayConnection;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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<LabelWithTooltipWidget>("CASH");
cashLabel.GetTooltipText = () => siloUsageTooltip;
}

View File

@@ -194,7 +194,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return true;
};
chatAvailableIn = new CachedTransform<int, string>(x => FluentProvider.GetString(ChatAvailability, FluentBundle.Arguments("seconds", x)));
chatAvailableIn = new CachedTransform<int, string>(x => FluentProvider.GetString(ChatAvailability, "seconds", x));
if (!isMenuChat)
{

View File

@@ -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);

View File

@@ -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 = () =>

View File

@@ -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 = () =>

View File

@@ -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)

View File

@@ -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);

View File

@@ -286,7 +286,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
tt.IgnoreMouseOver = true;
var teamLabel = tt.Get<LabelWidget>("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;

View File

@@ -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;

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var status = new CachedTransform<string, string>(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<LabelWidget>("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));

View File

@@ -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<ISourceResolver>($"{kv.Value.Type.Value}SourceResolver");

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[ObjectCreator.UseCtor]
public KickClientLogic(Widget widget, string clientName, Action<bool> okPressed, Action cancelPressed)
{
var kickMessage = FluentProvider.GetString(KickClient, FluentBundle.Arguments("player", clientName));
var kickMessage = FluentProvider.GetString(KickClient, "player", clientName);
widget.Get<LabelWidget>("TITLE").GetText = () => kickMessage;
var tempBan = false;

View File

@@ -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<LabelWidget>("TEXT").GetText = () => kickMessage;
widget.Get<ButtonWidget>("OK_BUTTON").OnClick = () =>

View File

@@ -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<int, string>(x => FluentProvider.GetString(ChatAvailability, FluentBundle.Arguments("seconds", x)));
chatAvailableIn = new CachedTransform<int, string>(x => FluentProvider.GetString(ChatAvailability, "seconds", x));
chatDisabled = FluentProvider.GetString(ChatDisabled);
lobbyChatPanel = lobby.Get<ScrollPanelWidget>("CHAT_DISPLAY");

View File

@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
var authorCache = new CachedTransform<string, string>(
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;

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var labelText = "";
string playerFaction = null;
var playerTeam = -1;
teamMessage = new CachedTransform<int, string>(t => FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", t)));
teamMessage = new CachedTransform<int, string>(t => FluentProvider.GetString(TeamNumber, "team", t));
var disabledSpawn = FluentProvider.GetString(DisabledSpawn);
var availableSpawn = FluentProvider.GetString(AvailableSpawn);

View File

@@ -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<LabelWidget>("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;

View File

@@ -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<LabelWithTooltipWidget>("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<LabelWidget>("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);

View File

@@ -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;
}

View File

@@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
});
var replayDuration = new CachedTransform<ReplayMetadata, string>(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<LabelWidget>("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);

View File

@@ -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<string, object> 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;
}
}

View File

@@ -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);

View File

@@ -164,11 +164,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
mapStatusSearching = FluentProvider.GetString(MapStatusSearching);
mapClassificationUnknown = FluentProvider.GetString(MapClassificationUnknown);
players = new CachedTransform<int, string>(i => FluentProvider.GetString(PlayersLabel, FluentBundle.Arguments("players", i)));
bots = new CachedTransform<int, string>(i => FluentProvider.GetString(BotsLabel, FluentBundle.Arguments("bots", i)));
spectators = new CachedTransform<int, string>(i => FluentProvider.GetString(SpectatorsLabel, FluentBundle.Arguments("spectators", i)));
players = new CachedTransform<int, string>(i => FluentProvider.GetString(PlayersLabel, "players", i));
bots = new CachedTransform<int, string>(i => FluentProvider.GetString(BotsLabel, "bots", i));
spectators = new CachedTransform<int, string>(i => FluentProvider.GetString(SpectatorsLabel, "spectators", i));
minutes = new CachedTransform<double, string>(i => FluentProvider.GetString(InProgress, FluentBundle.Arguments("minutes", i)));
minutes = new CachedTransform<double, string>(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<LabelWidget>("PLAYER_COUNT");
if (playersLabel != null)
{
var playersText = new CachedTransform<int, string>(p => FluentProvider.GetString(PlayersOnline, FluentBundle.Arguments("players", p)));
var playersText = new CachedTransform<int, string>(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;

View File

@@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var displaySelectionDropDown = panel.Get<DropDownButtonWidget>("DISPLAY_SELECTION_DROPDOWN");
displaySelectionDropDown.OnMouseDown = _ => ShowDisplaySelectionDropdown(displaySelectionDropDown, ds);
var displaySelectionLabel = new CachedTransform<int, string>(i => FluentProvider.GetString(Display, FluentBundle.Arguments("number", i + 1)));
var displaySelectionLabel = new CachedTransform<int, string>(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<CheckboxWidget>("FRAME_LIMIT_GAMESPEED_CHECKBOX");
var frameLimitCheckbox = panel.Get<CheckboxWidget>("FRAME_LIMIT_CHECKBOX");
var frameLimitLabel = new CachedTransform<int, string>(fps => FluentProvider.GetString(FrameLimiter, FluentBundle.Arguments("fps", fps)));
var frameLimitLabel = new CachedTransform<int, string>(fps => FluentProvider.GetString(FrameLimiter, "fps", fps));
frameLimitCheckbox.GetText = () => frameLimitLabel.Update(ds.MaxFramerate);
frameLimitCheckbox.IsDisabled = () => ds.CapFramerateToGameFps;

View File

@@ -229,16 +229,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
duplicateNotice.IsVisible = () => !isHotkeyValid;
var duplicateNoticeText = new CachedTransform<HotkeyDefinition, string>(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<LabelWidget>("ORIGINAL_NOTICE");
originalNotice.TextColor = ChromeMetrics.Get<Color>("NoticeInfoColor");
originalNotice.IsVisible = () => isHotkeyValid && !isHotkeyDefault;
var originalNoticeText = new CachedTransform<HotkeyDefinition, string>(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<LabelWidget>("READONLY_NOTICE");

View File

@@ -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: () => { },

View File

@@ -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;