Replace F extension with string interpolation
This commit is contained in:
@@ -149,9 +149,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (frameText != null)
|
||||
{
|
||||
frameText.GetText = () =>
|
||||
isVideoLoaded ?
|
||||
"{0} / {1}".F(player.Video.CurrentFrame + 1, player.Video.Frames) :
|
||||
"{0} / {1}".F(currentFrame, currentSprites.Length - 1);
|
||||
isVideoLoaded ? $"{player.Video.CurrentFrame + 1} / {player.Video.Frames}"
|
||||
: $"{currentFrame} / {currentSprites.Length - 1}";
|
||||
}
|
||||
|
||||
var playButton = panel.GetOrNull<ButtonWidget>("BUTTON_PLAY");
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var hotkey = widget.Get<LabelWidget>("HOTKEY");
|
||||
hotkey.Visible = true;
|
||||
|
||||
var hotkeyLabel = "({0})".F(key.DisplayString());
|
||||
var hotkeyLabel = $"({key.DisplayString()})";
|
||||
hotkey.GetText = () => hotkeyLabel;
|
||||
hotkey.Bounds.X = labelWidth + 2 * label.Bounds.X;
|
||||
|
||||
|
||||
@@ -103,13 +103,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
if (logicArgs.TryGetValue("PaletteColumns", out var yaml))
|
||||
if (!int.TryParse(yaml.Value, out paletteCols))
|
||||
throw new YamlException("Invalid value for PaletteColumns: {0}".F(yaml.Value));
|
||||
throw new YamlException($"Invalid value for PaletteColumns: {yaml.Value}");
|
||||
if (logicArgs.TryGetValue("PalettePresetRows", out yaml))
|
||||
if (!int.TryParse(yaml.Value, out palettePresetRows))
|
||||
throw new YamlException("Invalid value for PalettePresetRows: {0}".F(yaml.Value));
|
||||
throw new YamlException($"Invalid value for PalettePresetRows: {yaml.Value}");
|
||||
if (logicArgs.TryGetValue("PaletteCustomRows", out yaml))
|
||||
if (!int.TryParse(yaml.Value, out paletteCustomRows))
|
||||
throw new YamlException("Invalid value for PaletteCustomRows: {0}".F(yaml.Value));
|
||||
throw new YamlException($"Invalid value for PaletteCustomRows: {yaml.Value}");
|
||||
|
||||
for (var j = 0; j < palettePresetRows; j++)
|
||||
{
|
||||
|
||||
@@ -59,8 +59,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var panel = widget;
|
||||
panel.Get<ButtonWidget>("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); };
|
||||
|
||||
widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||
"Connecting to {0}...".F(endpoint);
|
||||
widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () => $"Connecting to {endpoint}...";
|
||||
}
|
||||
|
||||
public static void Connect(ConnectionTarget endpoint, string password, Action onConnect, Action onAbort)
|
||||
@@ -102,8 +101,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
onRetry(password);
|
||||
};
|
||||
|
||||
widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () =>
|
||||
"Could not connect to {0}".F(orderManager.Endpoint);
|
||||
widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () => $"Could not connect to {orderManager.Endpoint}";
|
||||
|
||||
var connectionError = widget.Get<LabelWidget>("CONNECTION_ERROR");
|
||||
connectionError.GetText = () => orderManager.ServerError ?? orderManager.Connection.ErrorMessage ?? "Unknown error";
|
||||
@@ -163,7 +161,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
switchButton.OnClick = () =>
|
||||
{
|
||||
var launchCommand = "Launch.URI={0}".F(new UriBuilder("tcp", orderManager.Connection.EndPoint.Address.ToString(), orderManager.Connection.EndPoint.Port));
|
||||
var launchCommand = $"Launch.URI={new UriBuilder("tcp", orderManager.Connection.EndPoint.Address.ToString(), orderManager.Connection.EndPoint.Port)}";
|
||||
Game.SwitchToExternalMod(orderManager.ServerExternalMod, new[] { launchCommand }, () =>
|
||||
{
|
||||
orderManager.ServerError = "Failed to switch mod.";
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var port = Exts.WithDefault(1234, () => Exts.ParseIntegerInvariant(portField.Text));
|
||||
|
||||
Game.Settings.Player.LastServer = "{0}:{1}".F(ipField.Text, port);
|
||||
Game.Settings.Player.LastServer = $"{ipField.Text}:{port}";
|
||||
Game.Settings.Save();
|
||||
|
||||
ConnectionLogic.Connect(new ConnectionTarget(ipField.Text, port), "", () => { Ui.CloseWindow(); openLobby(); }, DoNothing);
|
||||
|
||||
@@ -461,7 +461,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
actorId = actor.ID;
|
||||
this.actor = actor;
|
||||
this.handles = handles;
|
||||
Text = "Edited {0} ({1})".F(actor.Info.Name, actor.ID);
|
||||
Text = $"Edited {actor.Info.Name} ({actor.ID})";
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
|
||||
@@ -66,8 +66,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var cell = worldRenderer.Viewport.ViewToWorld(Viewport.LastMousePos);
|
||||
var map = worldRenderer.World.Map;
|
||||
return map.Height.Contains(cell) ?
|
||||
"{0},{1} ({2})".F(cell, map.Height[cell], map.Tiles[cell].Type) : "";
|
||||
return map.Height.Contains(cell) ? $"{cell},{map.Height[cell]} ({map.Tiles[cell].Type})" : "";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -76,7 +75,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var reslayer = worldRenderer.World.WorldActor.TraitsImplementing<EditorResourceLayer>().FirstOrDefault();
|
||||
if (reslayer != null)
|
||||
cashLabel.GetText = () => "$ {0}".F(reslayer.NetWorth);
|
||||
cashLabel.GetText = () => $"$ {reslayer.NetWorth}";
|
||||
}
|
||||
|
||||
var undoButton = widget.GetOrNull<ButtonWidget>("UNDO_BUTTON");
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (!File.Exists(Path.Combine(baseSavePath, defaultSaveFilename + ".orasav")))
|
||||
break;
|
||||
|
||||
defaultSaveFilename = world.Map.Title + " ({0})".F(++filenameAttempt);
|
||||
defaultSaveFilename = world.Map.Title + $" ({++filenameAttempt})";
|
||||
}
|
||||
|
||||
var saveButton = panel.Get<ButtonWidget>("SAVE_BUTTON");
|
||||
@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Delete selected game save?",
|
||||
text: "Delete '{0}'?".F(Path.GetFileNameWithoutExtension(selectedSave)),
|
||||
text: $"Delete '{Path.GetFileNameWithoutExtension(selectedSave)}'?",
|
||||
onConfirm: () =>
|
||||
{
|
||||
Delete(selectedSave);
|
||||
@@ -155,7 +155,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Delete all game saves?",
|
||||
text: "Delete {0} game saves?".F(games.Count),
|
||||
text: $"Delete {games.Count} game saves?",
|
||||
onConfirm: () =>
|
||||
{
|
||||
foreach (var s in games.ToList())
|
||||
@@ -295,7 +295,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var orders = new List<Order>()
|
||||
{
|
||||
Order.FromTargetString("LoadGameSave", Path.GetFileName(selectedSave), true),
|
||||
Order.Command("state {0}".F(Session.ClientState.Ready))
|
||||
Order.Command($"state {Session.ClientState.Ready}")
|
||||
};
|
||||
|
||||
Game.CreateAndStartLocalServer(map.Uid, orders);
|
||||
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Overwrite save game?",
|
||||
text: "Overwrite {0}?".F(saveTextField.Text),
|
||||
text: $"Overwrite {saveTextField.Text}?",
|
||||
onConfirm: inner,
|
||||
confirmText: "Overwrite",
|
||||
onCancel: () => { });
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
||||
var cell = worldRenderer.Viewport.ViewToWorld(Viewport.LastMousePos);
|
||||
var map = worldRenderer.World.Map;
|
||||
var wpos = map.CenterOfCell(cell);
|
||||
return map.Height.Contains(cell) ? "({0},{1}) ({2})".F(cell, map.Height[cell], wpos) : "";
|
||||
return map.Height.Contains(cell) ? $"({cell},{map.Height[cell]}) ({wpos})" : "";
|
||||
});
|
||||
|
||||
labelWidget.GetText = () => cellPosText.Update(Viewport.LastMousePos);
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (teams.Count() > 1)
|
||||
{
|
||||
var teamHeader = ScrollItemWidget.Setup(teamTemplate, () => true, () => { });
|
||||
teamHeader.Get<LabelWidget>("TEAM").GetText = () => t.Key == 0 ? "No Team" : "Team {0}".F(t.Key);
|
||||
teamHeader.Get<LabelWidget>("TEAM").GetText = () => t.Key == 0 ? "No Team" : $"Team {t.Key}";
|
||||
var teamRating = teamHeader.Get<LabelWidget>("TEAM_SCORE");
|
||||
var scoreCache = new CachedTransform<int, string>(s => s.ToString());
|
||||
var teamMemberScores = t.Select(tt => tt.PlayerStatistics).Where(s => s != null).ToArray().Select(s => s.Experience);
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (player == null || player.RelationshipWith(pp) == PlayerRelationship.Ally || player.WinState != WinState.Undefined)
|
||||
{
|
||||
flag.GetImageName = () => pp.Faction.InternalName;
|
||||
var factionName = pp.Faction.Name != pp.DisplayFaction.Name ? "{0} ({1})".F(pp.DisplayFaction.Name, pp.Faction.Name) : pp.Faction.Name;
|
||||
var factionName = pp.Faction.Name != pp.DisplayFaction.Name ? $"{pp.DisplayFaction.Name} ({pp.Faction.Name})" : pp.Faction.Name;
|
||||
item.Get<LabelWidget>("FACTION").GetText = () => factionName;
|
||||
}
|
||||
else
|
||||
@@ -149,11 +149,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
hideMenu(true);
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Kick {0}?".F(client.Name),
|
||||
title: $"Kick {client.Name}?",
|
||||
text: "They will not be able to rejoin this game.",
|
||||
onConfirm: () =>
|
||||
{
|
||||
orderManager.IssueOrder(Order.Command("kick {0} {1}".F(client.Index, false)));
|
||||
orderManager.IssueOrder(Order.Command($"kick {client.Index} {false}"));
|
||||
hideMenu(false);
|
||||
},
|
||||
onCancel: () => hideMenu(false),
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (world.ReplayTimestep == 1)
|
||||
return "Max Speed";
|
||||
|
||||
return "{0}% Speed".F(world.Timestep * 100 / world.ReplayTimestep);
|
||||
return $"{world.Timestep * 100 / world.ReplayTimestep}% Speed";
|
||||
};
|
||||
|
||||
if (timer != null)
|
||||
@@ -64,9 +64,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var connection = orderManager.Connection as ReplayConnection;
|
||||
if (connection != null && connection.FinalGameTick != 0)
|
||||
timerTooltip.GetTooltipText = () => "{0}% complete".F(world.WorldTick * 100 / connection.FinalGameTick);
|
||||
timerTooltip.GetTooltipText = () => $"{world.WorldTick * 100 / connection.FinalGameTick}% complete";
|
||||
else if (connection != null && connection.TickCount != 0)
|
||||
timerTooltip.GetTooltipText = () => "{0}% complete".F(orderManager.NetFrameNumber * 100 / connection.TickCount);
|
||||
timerTooltip.GetTooltipText = () => $"{orderManager.NetFrameNumber * 100 / connection.TickCount}% complete";
|
||||
else
|
||||
timerTooltip.GetTooltipText = null;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
displayLabel = cashLabel.F(displayResources);
|
||||
|
||||
cash.GetText = () => displayLabel;
|
||||
cash.GetTooltipText = () => "Silo Usage: {0}/{1}".F(playerResources.Resources, playerResources.ResourceCapacity);
|
||||
cash.GetTooltipText = () => $"Silo Usage: {playerResources.Resources}/{playerResources.ResourceCapacity}";
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var noTeams = teams.Count() == 1;
|
||||
foreach (var t in teams)
|
||||
{
|
||||
var label = noTeams ? "Players" : t.Key == 0 ? "No Team" : "Team {0}".F(t.Key);
|
||||
var label = noTeams ? "Players" : t.Key == 0 ? "No Team" : $"Team {t.Key}";
|
||||
groups.Add(label, t);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
if (hotkeyLabel.Visible)
|
||||
{
|
||||
var hotkeyText = "({0})".F(hotkey.DisplayString());
|
||||
var hotkeyText = $"({hotkey.DisplayString()})";
|
||||
|
||||
hotkeyWidth = font.Measure(hotkeyText).X + 2 * nameLabel.Bounds.X;
|
||||
hotkeyLabel.Text = hotkeyText;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var remaining = WidgetUtils.FormatTime(sp.RemainingTicks, world.Timestep);
|
||||
var total = WidgetUtils.FormatTime(sp.Info.ChargeInterval, world.Timestep);
|
||||
timeLabel.Text = "{0} / {1}".F(remaining, total);
|
||||
timeLabel.Text = $"{remaining} / {total}";
|
||||
}
|
||||
else
|
||||
timeLabel.Text = customLabel;
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
hotkeyLabel.Visible = hotkey.IsValid();
|
||||
if (hotkeyLabel.Visible)
|
||||
{
|
||||
var hotkeyText = "({0})".F(hotkey.DisplayString());
|
||||
var hotkeyText = $"({hotkey.DisplayString()})";
|
||||
|
||||
hotkeyWidth = hotkeyFont.Measure(hotkeyText).X + 2 * nameLabel.Bounds.X;
|
||||
hotkeyLabel.Text = hotkeyText;
|
||||
|
||||
@@ -49,7 +49,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 = "Downloading {0}".F(download.Title);
|
||||
var text = $"Downloading {download.Title}";
|
||||
panel.Get<LabelWidget>("TITLE").Text = text;
|
||||
|
||||
ShowDownloadDialog();
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
dataReceived = read / (float)(1L << (mag * 10));
|
||||
dataSuffix = SizeSuffixes[mag];
|
||||
|
||||
getStatusText = () => "Downloading from {2} {0:0.00} {1}".F(dataReceived, dataSuffix, downloadHost ?? "unknown host");
|
||||
getStatusText = () => $"Downloading from {downloadHost ?? "unknown host"} {dataReceived:0.00} {dataSuffix}";
|
||||
progressBar.Indeterminate = true;
|
||||
}
|
||||
else
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
dataReceived = read / (float)(1L << (mag * 10));
|
||||
dataSuffix = SizeSuffixes[mag];
|
||||
|
||||
getStatusText = () => "Downloading from {4} {1:0.00}/{2:0.00} {3} ({0}%)".F(progressPercentage, dataReceived, dataTotal, dataSuffix, downloadHost ?? "unknown host");
|
||||
getStatusText = () => $"Downloading from {downloadHost ?? "unknown host"} {dataReceived:0.00}/{dataTotal:0.00} {dataSuffix} ({progressPercentage}%)";
|
||||
progressBar.Indeterminate = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
continue;
|
||||
}
|
||||
|
||||
Log.Write("install", "Copying {0} -> {1}".F(sourcePath, targetPath));
|
||||
Log.Write("install", $"Copying {sourcePath} -> {targetPath}");
|
||||
extracted.Add(targetPath);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (length < ShowPercentageThreshold)
|
||||
message = "Copying " + displayFilename;
|
||||
else
|
||||
onProgress = b => message = "Copying " + displayFilename + " ({0}%)".F(100 * b / length);
|
||||
onProgress = b => message = $"Copying {displayFilename} ({100 * b / length}%)";
|
||||
|
||||
CopyStream(source, target, length, onProgress);
|
||||
}
|
||||
@@ -362,11 +362,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (length < ShowPercentageThreshold)
|
||||
updateMessage("Extracting " + displayFilename);
|
||||
else
|
||||
onProgress = b => updateMessage("Extracting " + displayFilename + " ({0}%)".F(100 * b / length));
|
||||
onProgress = b => updateMessage($"Extracting {displayFilename} ({100 * b / length}%)");
|
||||
|
||||
using (var target = File.OpenWrite(targetPath))
|
||||
{
|
||||
Log.Write("install", "Extracting {0} -> {1}".F(sourcePath, targetPath));
|
||||
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
||||
if (type == ExtractionType.Blast)
|
||||
Blast.Decompress(source, target, (read, _) => onProgress?.Invoke(read));
|
||||
else
|
||||
@@ -398,9 +398,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
|
||||
using (var target = File.OpenWrite(targetPath))
|
||||
{
|
||||
Log.Write("install", "Extracting {0} -> {1}".F(sourcePath, targetPath));
|
||||
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
||||
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
||||
Action<int> onProgress = percent => updateMessage("Extracting {0} ({1}%)".F(displayFilename, percent));
|
||||
Action<int> onProgress = percent => updateMessage($"Extracting {displayFilename} ({percent}%)");
|
||||
reader.ExtractFile(node.Value.Value, target, onProgress);
|
||||
}
|
||||
}
|
||||
@@ -447,9 +447,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
|
||||
using (var target = File.OpenWrite(targetPath))
|
||||
{
|
||||
Log.Write("install", "Extracting {0} -> {1}".F(sourcePath, targetPath));
|
||||
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
||||
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
||||
Action<int> onProgress = percent => updateMessage("Extracting {0} ({1}%)".F(displayFilename, percent));
|
||||
Action<int> onProgress = percent => updateMessage($"Extracting {displayFilename} ({percent}%)");
|
||||
reader.ExtractFile(node.Value.Value, target, onProgress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var download = downloadYaml.FirstOrDefault(n => n.Key == content.QuickDownload);
|
||||
if (download == null)
|
||||
throw new InvalidOperationException("Mod QuickDownload `{0}` definition not found.".F(content.QuickDownload));
|
||||
throw new InvalidOperationException($"Mod QuickDownload `{content.QuickDownload}` definition not found.");
|
||||
|
||||
Ui.OpenWindow("PACKAGE_DOWNLOAD_PANEL", new WidgetArgs
|
||||
{
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
battlefieldCameraDropDown.GetText = () => battlefieldCameraLabel.Update(ds.ViewportDistance);
|
||||
|
||||
var uiScaleDropdown = widget.Get<DropDownButtonWidget>("UI_SCALE_DROPDOWN");
|
||||
var uiScaleLabel = new CachedTransform<float, string>(s => "{0}%".F((int)(100 * s)));
|
||||
var uiScaleLabel = new CachedTransform<float, string>(s => $"{(int)(100 * s)}%");
|
||||
uiScaleDropdown.OnMouseDown = _ => DisplaySettingsLogic.ShowUIScaleDropdown(uiScaleDropdown, ds);
|
||||
uiScaleDropdown.GetText = () => uiScaleLabel.Update(ds.UIScale);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
[ObjectCreator.UseCtor]
|
||||
public KickClientLogic(Widget widget, string clientName, Action<bool> okPressed, Action cancelPressed)
|
||||
{
|
||||
widget.Get<LabelWidget>("TITLE").GetText = () => "Kick {0}?".F(clientName);
|
||||
widget.Get<LabelWidget>("TITLE").GetText = () => $"Kick {clientName}?";
|
||||
|
||||
var tempBan = false;
|
||||
var preventRejoiningCheckbox = widget.Get<CheckboxWidget>("PREVENT_REJOINING_CHECKBOX");
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
[ObjectCreator.UseCtor]
|
||||
public KickSpectatorsLogic(Widget widget, string clientCount, Action okPressed, Action cancelPressed)
|
||||
{
|
||||
widget.Get<LabelWidget>("TEXT").GetText = () => "Are you sure you want to kick {0} spectators?".F(clientCount);
|
||||
widget.Get<LabelWidget>("TEXT").GetText = () => $"Are you sure you want to kick {clientCount} spectators?";
|
||||
|
||||
widget.Get<ButtonWidget>("OK_BUTTON").OnClick = () =>
|
||||
{
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var bot = botTypes.Random(Game.CosmeticRandom);
|
||||
var c = orderManager.LobbyInfo.ClientInSlot(slot.Key);
|
||||
if (slot.Value.AllowBots == true && (c == null || c.Bot != null))
|
||||
orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot.Key, botController.Index, bot)));
|
||||
orderManager.IssueOrder(Order.Command($"slot_bot {slot.Key} {botController.Index} {bot}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -261,9 +261,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var teamOptions = Enumerable.Range(2, teamCount - 1).Reverse().Select(d => new DropDownOption
|
||||
{
|
||||
Title = "{0} Teams".F(d),
|
||||
Title = $"{d} Teams",
|
||||
IsSelected = () => false,
|
||||
OnClick = () => orderManager.IssueOrder(Order.Command("assignteams {0}".F(d.ToString())))
|
||||
OnClick = () => orderManager.IssueOrder(Order.Command($"assignteams {d.ToString()}"))
|
||||
}).ToList();
|
||||
|
||||
if (orderManager.LobbyInfo.Slots.Any(s => s.Value.AllowBots))
|
||||
@@ -518,7 +518,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (map.Status == MapStatus.Available)
|
||||
{
|
||||
// Tell the server that we have the map
|
||||
orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady)));
|
||||
orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}"));
|
||||
|
||||
if (addBotOnMapLoad)
|
||||
{
|
||||
@@ -526,7 +526,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var bot = map.PlayerActorInfo.TraitInfos<IBotInfo>().Select(t => t.Type).FirstOrDefault();
|
||||
var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
|
||||
if (slot != null && bot != null)
|
||||
orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot, botController.Index, bot)));
|
||||
orderManager.IssueOrder(Order.Command($"slot_bot {slot} {botController.Index} {bot}"));
|
||||
|
||||
addBotOnMapLoad = false;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
checkbox.IsChecked = () => optionValue.Update(orderManager.LobbyInfo.GlobalSettings).IsEnabled;
|
||||
checkbox.IsDisabled = () => configurationDisabled() || optionValue.Update(orderManager.LobbyInfo.GlobalSettings).IsLocked;
|
||||
checkbox.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"option {0} {1}".F(option.Id, !optionValue.Update(orderManager.LobbyInfo.GlobalSettings).IsEnabled)));
|
||||
$"option {option.Id} {!optionValue.Update(orderManager.LobbyInfo.GlobalSettings).IsEnabled}"));
|
||||
}
|
||||
|
||||
foreach (var option in allOptions.Where(o => !(o is LobbyBooleanOption)))
|
||||
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Func<KeyValuePair<string, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (c, template) =>
|
||||
{
|
||||
Func<bool> isSelected = () => optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Value == c.Key;
|
||||
Action onClick = () => orderManager.IssueOrder(Order.Command("option {0} {1}".F(option.Id, c.Key)));
|
||||
Action onClick = () => orderManager.IssueOrder(Order.Command($"option {option.Id} {c.Key}"));
|
||||
|
||||
var item = ScrollItemWidget.Setup(template, isSelected, onClick);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => c.Value;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
|
||||
bots.Add(new SlotDropDownOption(b.Name,
|
||||
"slot_bot {0} {1} {2}".F(slot.PlayerReference, botController.Index, b.Type),
|
||||
$"slot_bot {slot.PlayerReference} {botController.Index} {b.Type}",
|
||||
() => client != null && client.Bot == b.Type));
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public static void ShowPlayerActionDropDown(DropDownButtonWidget dropdown, Session.Slot slot,
|
||||
Session.Client c, OrderManager orderManager, Widget lobby, Action before, Action after)
|
||||
{
|
||||
Action<bool> okPressed = tempBan => { orderManager.IssueOrder(Order.Command("kick {0} {1}".F(c.Index, tempBan))); after(); };
|
||||
Action<bool> okPressed = tempBan => { orderManager.IssueOrder(Order.Command($"kick {c.Index} {tempBan}")); after(); };
|
||||
var onClick = new Action(() =>
|
||||
{
|
||||
before();
|
||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
options.Add(new DropDownOption
|
||||
{
|
||||
Title = "Transfer Admin",
|
||||
OnClick = () => orderManager.IssueOrder(Order.Command("make_admin {0}".F(c.Index)))
|
||||
OnClick = () => orderManager.IssueOrder(Order.Command($"make_admin {c.Index}"))
|
||||
});
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
options.Add(new DropDownOption
|
||||
{
|
||||
Title = "Move to Spectator",
|
||||
OnClick = () => orderManager.IssueOrder(Order.Command("make_spectator {0}".F(c.Index)))
|
||||
OnClick = () => orderManager.IssueOrder(Order.Command($"make_spectator {c.Index}"))
|
||||
});
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => client.Team == ii,
|
||||
() => orderManager.IssueOrder(Order.Command("team {0} {1}".F(client.Index, ii))));
|
||||
() => orderManager.IssueOrder(Order.Command($"team {client.Index} {ii}")));
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString();
|
||||
return item;
|
||||
};
|
||||
@@ -153,9 +153,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => client.Handicap == ii,
|
||||
() => orderManager.IssueOrder(Order.Command("handicap {0} {1}".F(client.Index, ii))));
|
||||
() => orderManager.IssueOrder(Order.Command($"handicap {client.Index} {ii}")));
|
||||
|
||||
var label = "{0}%".F(ii);
|
||||
var label = $"{ii}%";
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||
return item;
|
||||
};
|
||||
@@ -199,7 +199,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => client.Faction == factionId,
|
||||
() => orderManager.IssueOrder(Order.Command("faction {0} {1}".F(client.Index, factionId))));
|
||||
() => orderManager.IssueOrder(Order.Command($"faction {client.Index} {factionId}")));
|
||||
var faction = factions[factionId];
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => faction.Name;
|
||||
var flag = item.Get<ImageWidget>("FLAG");
|
||||
@@ -231,7 +231,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
color.RemovePanel();
|
||||
orderManager.IssueOrder(Order.Command("color {0} {1}".F(client.Index, preview.Color)));
|
||||
orderManager.IssueOrder(Order.Command($"color {client.Index} {preview.Color}"));
|
||||
};
|
||||
|
||||
Action<Color> onChange = c => preview.Color = c;
|
||||
@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var selectedSpawn = DetermineSelectedSpawnPoint(mapPreview, preview, mi);
|
||||
if (Game.IsHost || orderManager.LobbyInfo.Clients.FirstOrDefault(cc => cc.SpawnPoint == selectedSpawn) == orderManager.LocalClient)
|
||||
orderManager.IssueOrder(Order.Command("clear_spawn {0}".F(selectedSpawn)));
|
||||
orderManager.IssueOrder(Order.Command($"clear_spawn {selectedSpawn}"));
|
||||
}
|
||||
|
||||
static int DetermineSelectedSpawnPoint(MapPreviewWidget mapPreview, MapPreview preview, MouseInput mi)
|
||||
@@ -289,7 +289,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var owned = orderManager.LobbyInfo.Clients.Any(c => c.SpawnPoint == selectedSpawnPoint) || orderManager.LobbyInfo.DisabledSpawnPoints.Contains(selectedSpawnPoint);
|
||||
if (selectedSpawnPoint == 0 || !owned)
|
||||
orderManager.IssueOrder(Order.Command("spawn {0} {1}".F((playerToMove ?? orderManager.LocalClient).Index, selectedSpawnPoint)));
|
||||
orderManager.IssueOrder(Order.Command($"spawn {(playerToMove ?? orderManager.LocalClient).Index} {selectedSpawnPoint}"));
|
||||
}
|
||||
|
||||
public static List<int> AvailableSpawnPoints(int spawnPoints, Session lobbyInfo)
|
||||
@@ -492,11 +492,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
Action okPressed = () =>
|
||||
{
|
||||
orderManager.IssueOrder(Order.Command("allow_spectators {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowSpectators)));
|
||||
orderManager.IssueOrder(Order.Command($"allow_spectators {!orderManager.LobbyInfo.GlobalSettings.AllowSpectators}"));
|
||||
orderManager.IssueOrders(
|
||||
orderManager.LobbyInfo.Clients.Where(
|
||||
c => c.IsObserver && !c.IsAdmin).Select(
|
||||
client => Order.Command("kick {0} {1}".F(client.Index, client.Name))).ToArray());
|
||||
client => Order.Command($"kick {client.Index} {client.Name}")).ToArray());
|
||||
|
||||
after();
|
||||
};
|
||||
@@ -510,14 +510,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
Game.LoadWidget(null, "KICK_SPECTATORS_DIALOG", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs
|
||||
{
|
||||
{ "clientCount", "{0}".F(spectatorCount) },
|
||||
{ "clientCount", $"{spectatorCount}" },
|
||||
{ "okPressed", okPressed },
|
||||
{ "cancelPressed", after }
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
orderManager.IssueOrder(Order.Command("allow_spectators {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowSpectators)));
|
||||
orderManager.IssueOrder(Order.Command($"allow_spectators {!orderManager.LobbyInfo.GlobalSettings.AllowSpectators}"));
|
||||
after();
|
||||
}
|
||||
};
|
||||
@@ -588,7 +588,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
dropdown.IsDisabled = () => s.LockTeam || orderManager.LocalClient.IsReady;
|
||||
dropdown.OnMouseDown = _ => ShowHandicapDropDown(dropdown, c, orderManager);
|
||||
|
||||
var handicapLabel = new CachedTransform<int, string>(h => "{0}%".F(h));
|
||||
var handicapLabel = new CachedTransform<int, string>(h => $"{h}%");
|
||||
dropdown.GetText = () => handicapLabel.Update(c.Handicap);
|
||||
|
||||
HideChildWidget(parent, "HANDICAP");
|
||||
@@ -599,7 +599,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var team = parent.Get<LabelWidget>("HANDICAP");
|
||||
team.IsVisible = () => true;
|
||||
|
||||
var handicapLabel = new CachedTransform<int, string>(h => "{0}%".F(h));
|
||||
var handicapLabel = new CachedTransform<int, string>(h => $"{h}%");
|
||||
team.GetText = () => handicapLabel.Update(c.Handicap);
|
||||
HideChildWidget(parent, "HANDICAP_DROPDOWN");
|
||||
}
|
||||
@@ -638,7 +638,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
status.IsDisabled = () => c.Bot != null || map.Status != MapStatus.Available || !isEnabled;
|
||||
|
||||
var state = orderManager.LocalClient.IsReady ? Session.ClientState.NotReady : Session.ClientState.Ready;
|
||||
status.OnClick = () => orderManager.IssueOrder(Order.Command("state {0}".F(state)));
|
||||
status.OnClick = () => orderManager.IssueOrder(Order.Command($"state {state}"));
|
||||
}
|
||||
|
||||
public static void SetupReadyWidget(Widget parent, Session.Slot s, Session.Client c)
|
||||
@@ -662,7 +662,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var font = Game.Renderer.Fonts[nameLabel.Font];
|
||||
var nameSize = font.Measure(nameText);
|
||||
|
||||
timeLabel.GetText = () => "{0:D2}:{1:D2}".F(time.Hour, time.Minute);
|
||||
timeLabel.GetText = () => $"{time.Hour:D2}:{time.Minute:D2}";
|
||||
|
||||
nameLabel.GetColor = () => nameColor;
|
||||
nameLabel.GetText = () => nameText;
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
getMap().Map.Install(mapRepository, () =>
|
||||
{
|
||||
if (orderManager != null)
|
||||
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady))));
|
||||
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}")));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -138,9 +138,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
// Server does not provide the total file length
|
||||
if (map.DownloadPercentage == 0)
|
||||
return "Downloading {0} kB".F(map.DownloadBytes / 1024);
|
||||
return $"Downloading {map.DownloadBytes / 1024} kB";
|
||||
|
||||
return "Downloading {0} kB ({1}%)".F(map.DownloadBytes / 1024, map.DownloadPercentage);
|
||||
return $"Downloading {map.DownloadBytes / 1024} kB ({map.DownloadPercentage}%)";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
map.Install(mapRepository, () =>
|
||||
{
|
||||
if (orderManager != null)
|
||||
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady))));
|
||||
Game.RunAfterTick(() => orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}")));
|
||||
});
|
||||
}
|
||||
else if (map.Status == MapStatus.Unavailable)
|
||||
@@ -226,7 +226,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var font = Game.Renderer.Fonts[authorLabel.Font];
|
||||
var author = new CachedTransform<MapPreview, string>(
|
||||
m => WidgetUtils.TruncateText("Created by {0}".F(m.Author), authorLabel.Bounds.Width, font));
|
||||
m => WidgetUtils.TruncateText($"Created by {m.Author}", authorLabel.Bounds.Width, font));
|
||||
authorLabel.GetText = () => author.Update(getMap().Map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
flag.IsVisible = () => playerFaction != null;
|
||||
flag.GetImageCollection = () => "flags";
|
||||
flag.GetImageName = () => playerFaction;
|
||||
team.GetText = () => "Team {0}".F(playerTeam);
|
||||
team.GetText = () => $"Team {playerTeam}";
|
||||
team.IsVisible = () => playerTeam > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
Game.RunAfterTick(() => // run on the main thread
|
||||
{
|
||||
SetNewsStatus("Failed to retrieve news: {0}".F(e));
|
||||
SetNewsStatus($"Failed to retrieve news: {e}");
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -388,7 +388,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SetNewsStatus("Failed to parse news: {0}".F(ex.Message));
|
||||
SetNewsStatus($"Failed to parse news: {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
// 'all game types' extra item
|
||||
categories.Insert(0, (null as string, tabMaps[tab].Count()));
|
||||
|
||||
Func<(string Category, int Count), string> showItem = x => "{0} ({1})".F(x.Category ?? "All Maps", x.Count);
|
||||
Func<(string Category, int Count), string> showItem = x => $"{x.Category ?? "All Maps"} ({x.Count})";
|
||||
|
||||
Func<(string Category, int Count), ScrollItemWidget, ScrollItemWidget> setupItem = (ii, template) =>
|
||||
{
|
||||
@@ -272,7 +272,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (type != null)
|
||||
details = type + " ";
|
||||
|
||||
details += "({0} players)".F(preview.PlayerCount);
|
||||
details += $"({preview.PlayerCount} players)";
|
||||
detailsWidget.GetText = () => details;
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (authorWidget != null)
|
||||
{
|
||||
var font = Game.Renderer.Fonts[authorWidget.Font];
|
||||
var author = WidgetUtils.TruncateText("Created by {0}".F(preview.Author), authorWidget.Bounds.Width, font);
|
||||
var author = WidgetUtils.TruncateText($"Created by {preview.Author}", authorWidget.Bounds.Width, font);
|
||||
authorWidget.GetText = () => author;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Delete map",
|
||||
text: "Delete the map '{0}'?".F(modData.MapCache[map].Title),
|
||||
text: $"Delete the map '{modData.MapCache[map].Title}'?",
|
||||
onConfirm: () =>
|
||||
{
|
||||
var newUid = DeleteMap(map);
|
||||
|
||||
@@ -372,10 +372,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var orders = new List<Order>();
|
||||
if (difficulty != null)
|
||||
orders.Add(Order.Command("option difficulty {0}".F(difficulty)));
|
||||
orders.Add(Order.Command($"option difficulty {difficulty}"));
|
||||
|
||||
orders.Add(Order.Command("option gamespeed {0}".F(gameSpeed)));
|
||||
orders.Add(Order.Command("state {0}".F(Session.ClientState.Ready)));
|
||||
orders.Add(Order.Command($"option gamespeed {gameSpeed}"));
|
||||
orders.Add(Order.Command($"state {Session.ClientState.Ready}"));
|
||||
|
||||
var missionData = selectedMap.WorldActorInfo.TraitInfoOrDefault<MissionDataInfo>();
|
||||
if (missionData != null && missionData.StartVideo != null && modData.DefaultFileSystem.Exists(missionData.StartVideo))
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var totalMinutes = currentSong.Length / 60;
|
||||
var totalSeconds = currentSong.Length % 60;
|
||||
|
||||
return "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F(minutes, seconds, totalMinutes, totalSeconds);
|
||||
return $"{minutes:D2}:{seconds:D2} / {totalMinutes:D2}:{totalSeconds:D2}";
|
||||
};
|
||||
|
||||
var musicTitle = panel.GetOrNull<LabelWidget>("TITLE_LABEL");
|
||||
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
static string SongLengthLabel(MusicInfo song)
|
||||
{
|
||||
return "{0:D1}:{1:D2}".F(song.Length / 60, song.Length % 60);
|
||||
return $"{song.Length / 60:D1}:{song.Length % 60:D2}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
fpsReferenceFrame = Game.RenderFrame;
|
||||
}
|
||||
|
||||
return "FPS: {0}\nTick {1} @ {2:F1} ms\nRender {3} @ {4:F1} ms\nBatches: {5}".F(
|
||||
fps, Game.LocalTick, PerfHistory.Items["tick_time"].Average(Game.Settings.Debug.Samples),
|
||||
Game.RenderFrame, PerfHistory.Items["render"].Average(Game.Settings.Debug.Samples),
|
||||
PerfHistory.Items["batches"].LastValue);
|
||||
return $"FPS: {fps}\nTick {Game.LocalTick} @ {PerfHistory.Items["tick_time"].Average(Game.Settings.Debug.Samples):F1} ms\nRender {Game.RenderFrame} @ {PerfHistory.Items["render"].Average(Game.Settings.Debug.Samples):F1} ms\nBatches: {PerfHistory.Items["batches"].LastValue}";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
});
|
||||
|
||||
var replayDuration = new CachedTransform<ReplayMetadata, string>(r =>
|
||||
"Duration: {0}".F(WidgetUtils.FormatTimeSeconds((int)selectedReplay.GameInfo.Duration.TotalSeconds)));
|
||||
$"Duration: {WidgetUtils.FormatTimeSeconds((int)selectedReplay.GameInfo.Duration.TotalSeconds)}");
|
||||
panel.Get<LabelWidget>("DURATION").GetText = () => replayDuration.Update(selectedReplay);
|
||||
|
||||
SetupFilters();
|
||||
@@ -424,7 +424,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Delete selected replay?",
|
||||
text: "Delete replay '{0}'?".F(Path.GetFileNameWithoutExtension(r.FilePath)),
|
||||
text: $"Delete replay '{Path.GetFileNameWithoutExtension(r.FilePath)}'?",
|
||||
onConfirm: () =>
|
||||
{
|
||||
DeleteReplay(r);
|
||||
@@ -461,7 +461,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Delete all selected replays?",
|
||||
text: "Delete {0} replays?".F(list.Count),
|
||||
text: $"Delete {list.Count} replays?",
|
||||
onConfirm: () =>
|
||||
{
|
||||
list.ForEach(DeleteReplay);
|
||||
@@ -635,7 +635,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var noTeams = players.Count() == 1;
|
||||
foreach (var p in players)
|
||||
{
|
||||
var label = noTeams ? "Players" : p.Key == 0 ? "No Team" : "Team {0}".F(p.Key);
|
||||
var label = noTeams ? "Players" : p.Key == 0 ? "No Team" : $"Team {p.Key}";
|
||||
teams.Add(label, p);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
static bool IncompatibleReplayDialog(string type, string name, Action onCancel)
|
||||
{
|
||||
var error = "It was recorded with an " + type;
|
||||
error += string.IsNullOrEmpty(name) ? "." : ":\n{0}".F(name);
|
||||
error += string.IsNullOrEmpty(name) ? "." : $":\n{name}";
|
||||
|
||||
ConfirmationDialogs.ButtonPrompt("Incompatible Replay", error, onCancel: onCancel);
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var font = Game.Renderer.Fonts[authorLabel.Font];
|
||||
var author = new CachedTransform<MapPreview, string>(
|
||||
m => WidgetUtils.TruncateText("Created by {0}".F(m.Author), authorLabel.Bounds.Width, font));
|
||||
m => WidgetUtils.TruncateText($"Created by {m.Author}", authorLabel.Bounds.Width, font));
|
||||
authorLabel.GetText = () => author.Update(preview);
|
||||
}
|
||||
}
|
||||
@@ -203,13 +203,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
catch (System.Net.Sockets.SocketException e)
|
||||
{
|
||||
var message = "Could not listen on port {0}.".F(Game.Settings.Server.ListenPort);
|
||||
var message = $"Could not listen on port {Game.Settings.Server.ListenPort}.";
|
||||
|
||||
// AddressAlreadyInUse (WSAEADDRINUSE)
|
||||
if (e.ErrorCode == 10048)
|
||||
message += "\nCheck if the port is already being used.";
|
||||
else
|
||||
message += "\nError is: \"{0}\" ({1})".F(e.Message, e.ErrorCode);
|
||||
message += $"\nError is: \"{e.Message}\" ({e.ErrorCode})";
|
||||
|
||||
ConfirmationDialogs.ButtonPrompt("Server Creation Failed", message, onCancel: () => { }, cancelText: "Back");
|
||||
}
|
||||
|
||||
@@ -313,10 +313,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
string PlayersLabel(GameServer game)
|
||||
{
|
||||
return "{0}{1}{2}".F(
|
||||
"{0} Player{1}".F(game.Players > 0 ? game.Players.ToString() : "No", game.Players != 1 ? "s" : ""),
|
||||
game.Bots > 0 ? ", {0} Bot{1}".F(game.Bots, game.Bots != 1 ? "s" : "") : "",
|
||||
game.Spectators > 0 ? ", {0} Spectator{1}".F(game.Spectators, game.Spectators != 1 ? "s" : "") : "");
|
||||
return $"{(game.Players > 0 ? game.Players.ToString() : "No")} Player{(game.Players != 1 ? "s" : "")}{(game.Bots > 0 ? $", {game.Bots} Bot{(game.Bots != 1 ? "s" : "")}" : "")}{(game.Spectators > 0 ? $", {game.Spectators} Spectator{(game.Spectators != 1 ? "s" : "")}" : "")}";
|
||||
}
|
||||
|
||||
public void RefreshServerList()
|
||||
@@ -466,7 +463,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var noTeams = players.Count() == 1;
|
||||
foreach (var p in players)
|
||||
{
|
||||
var label = noTeams ? "Players" : p.Key == 0 ? "No Team" : "Team {0}".F(p.Key);
|
||||
var label = noTeams ? "Players" : p.Key == 0 ? "No Team" : $"Team {p.Key}";
|
||||
teams.Add(label, p);
|
||||
}
|
||||
|
||||
@@ -634,8 +631,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var players = item.GetOrNull<LabelWithTooltipWidget>("PLAYERS");
|
||||
if (players != null)
|
||||
{
|
||||
var label = "{0} / {1}".F(game.Players + game.Bots, game.MaxPlayers + game.Bots)
|
||||
+ (game.Spectators > 0 ? " + {0}".F(game.Spectators) : "");
|
||||
var label = $"{game.Players + game.Bots} / {game.MaxPlayers + game.Bots}"
|
||||
+ (game.Spectators > 0 ? $" + {game.Spectators}" : "");
|
||||
|
||||
var color = canJoin ? players.TextColor : incompatibleGameColor;
|
||||
players.GetText = () => label;
|
||||
@@ -647,7 +644,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (game.Clients.Length > 10)
|
||||
displayClients = displayClients
|
||||
.Take(9)
|
||||
.Append("+ {0} other players".F(game.Clients.Length - 9));
|
||||
.Append($"+ {game.Clients.Length - 9} other players");
|
||||
|
||||
var tooltip = displayClients.JoinWith("\n");
|
||||
players.GetTooltipText = () => tooltip;
|
||||
@@ -699,7 +696,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (game.PlayTime > 0)
|
||||
{
|
||||
var totalMinutes = Math.Ceiling(game.PlayTime / 60.0);
|
||||
label += " for {0} minute{1}".F(totalMinutes, totalMinutes > 1 ? "s" : "");
|
||||
label += $" for {totalMinutes} minute{(totalMinutes > 1 ? "s" : "")}";
|
||||
}
|
||||
|
||||
return label;
|
||||
|
||||
@@ -79,7 +79,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 => "Display {0}".F(i + 1));
|
||||
var displaySelectionLabel = new CachedTransform<int, string>(i => $"Display {i + 1}");
|
||||
displaySelectionDropDown.GetText = () => displaySelectionLabel.Update(ds.VideoDisplay);
|
||||
displaySelectionDropDown.IsDisabled = () => Game.Renderer.DisplayCount < 2;
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
};
|
||||
|
||||
var uiScaleDropdown = panel.Get<DropDownButtonWidget>("UI_SCALE_DROPDOWN");
|
||||
var uiScaleLabel = new CachedTransform<float, string>(s => "{0}%".F((int)(100 * s)));
|
||||
var uiScaleLabel = new CachedTransform<float, string>(s => $"{(int)(100 * s)}%");
|
||||
uiScaleDropdown.OnMouseDown = _ => ShowUIScaleDropdown(uiScaleDropdown, ds);
|
||||
uiScaleDropdown.GetText = () => uiScaleLabel.Update(ds.UIScale);
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var frameLimitCheckbox = panel.Get<CheckboxWidget>("FRAME_LIMIT_CHECKBOX");
|
||||
var frameLimitOrigLabel = frameLimitCheckbox.Text;
|
||||
var frameLimitLabel = new CachedTransform<int, string>(fps => frameLimitOrigLabel + " ({0} FPS)".F(fps));
|
||||
var frameLimitLabel = new CachedTransform<int, string>(fps => frameLimitOrigLabel + $" ({fps} FPS)");
|
||||
frameLimitCheckbox.GetText = () => frameLimitLabel.Update(ds.MaxFramerate);
|
||||
|
||||
// Player profile
|
||||
@@ -285,7 +285,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
() => s.VideoDisplay == o,
|
||||
() => s.VideoDisplay = o);
|
||||
|
||||
var label = "Display {0}".F(o + 1);
|
||||
var label = $"Display {o + 1}";
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||
return item;
|
||||
};
|
||||
@@ -421,7 +421,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
});
|
||||
});
|
||||
|
||||
var label = "{0}%".F((int)(100 * o));
|
||||
var label = $"{(int)(100 * o)}%";
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => label;
|
||||
return item;
|
||||
};
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
};
|
||||
|
||||
ConfirmationDialogs.ButtonPrompt(
|
||||
title: "Reset \"{0}\"".F(panels[activePanel]),
|
||||
title: $"Reset \"{panels[activePanel]}\"",
|
||||
text: "Are you sure you want to reset\nall settings in this panel?",
|
||||
onConfirm: reset,
|
||||
onCancel: () => { },
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var field = group.GetType().GetField(pref);
|
||||
if (field == null)
|
||||
throw new InvalidOperationException("{0} does not contain a preference type {1}".F(group.GetType().Name, pref));
|
||||
throw new InvalidOperationException($"{group.GetType().Name} does not contain a preference type {pref}");
|
||||
|
||||
var cb = parent.Get<CheckboxWidget>(id);
|
||||
cb.IsChecked = () => (bool)field.GetValue(group);
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var field = group.GetType().GetField(pref);
|
||||
if (field == null)
|
||||
throw new InvalidOperationException("{0} does not contain a preference type {1}".F(group.GetType().Name, pref));
|
||||
throw new InvalidOperationException($"{group.GetType().Name} does not contain a preference type {pref}");
|
||||
|
||||
var ss = parent.Get<SliderWidget>(id);
|
||||
ss.Value = (float)field.GetValue(group);
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var field = group.GetType().GetField(pref);
|
||||
if (field == null)
|
||||
throw new InvalidOperationException("{0} does not contain a preference type {1}".F(group.GetType().Name, pref));
|
||||
throw new InvalidOperationException($"{group.GetType().Name} does not contain a preference type {pref}");
|
||||
|
||||
var ss = parent.Get<SliderWidget>(id);
|
||||
ss.Value = (float)(int)field.GetValue(group);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ "x64process", ("Process is 64 bit", Environment.Is64BitProcess.ToString()) },
|
||||
{ "runtime", (".NET Runtime", Platform.RuntimeVersion) },
|
||||
{ "gl", ("OpenGL Version", Game.Renderer.GLVersion) },
|
||||
{ "windowsize", ("Window Size", "{0}x{1}".F(Game.Renderer.NativeResolution.Width, Game.Renderer.NativeResolution.Height)) },
|
||||
{ "windowsize", ("Window Size", $"{Game.Renderer.NativeResolution.Width}x{Game.Renderer.NativeResolution.Height}") },
|
||||
{ "windowscale", ("Window Scale", Game.Renderer.NativeWindowScale.ToString("F2", CultureInfo.InvariantCulture)) },
|
||||
{ "uiscale", ("UI Scale", Game.Settings.Graphics.UIScale.ToString("F2", CultureInfo.InvariantCulture)) },
|
||||
{ "lang", ("System Language", lang) }
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (!Game.Settings.Debug.SendSystemInformation)
|
||||
return "";
|
||||
|
||||
return "&sysinfoversion={0}&".F(SystemInformationVersion)
|
||||
return $"&sysinfoversion={SystemInformationVersion}&"
|
||||
+ GetSystemInformation()
|
||||
.Select(kv => kv.Key + "=" + Uri.EscapeUriString(kv.Value.Value))
|
||||
.JoinWith("&");
|
||||
|
||||
Reference in New Issue
Block a user