diff --git a/OpenRA.Game/Exts.cs b/OpenRA.Game/Exts.cs index c99c41ea9f..f9cca3b774 100644 --- a/OpenRA.Game/Exts.cs +++ b/OpenRA.Game/Exts.cs @@ -27,11 +27,6 @@ namespace OpenRA return string.Compare(str.ToUpperInvariant(), str, false) == 0; } - public static string F(this string format, params object[] args) - { - return string.Format(format, args); - } - public static T WithDefault(T def, Func f) { try { return f(); } diff --git a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs index e9cdc99367..2d94b06c0e 100644 --- a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs +++ b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs @@ -96,15 +96,11 @@ namespace OpenRA.Traits .ToArray(); if (Footprint.Length == 0) - throw new ArgumentException(("This frozen actor has no footprint.\n" + - "Actor Name: {0}\n" + - "Actor Location: {1}\n" + - "Input footprint: [{2}]\n" + - "Input footprint (after shroud.Contains): [{3}]") - .F(actor.Info.Name, - actor.Location.ToString(), - footprint.Select(p => p.ToString()).JoinWith("|"), - footprint.Select(p => shroud.Contains(p).ToString()).JoinWith("|"))); + throw new ArgumentException("This frozen actor has no footprint.\n" + + $"Actor Name: {actor.Info.Name}\n" + + $"Actor Location: {actor.Location}\n" + + $"Input footprint: [{footprint.Select(p => p.ToString()).JoinWith("|")}]\n" + + $"Input footprint (after shroud.Contains): [{footprint.Select(p => shroud.Contains(p).ToString()).JoinWith("|")}]"); CenterPosition = actor.CenterPosition; diff --git a/OpenRA.Mods.Common/Scripting/Properties/CarryallProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/CarryallProperties.cs index 7426b7608c..d7af37bfe7 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/CarryallProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/CarryallProperties.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Scripting { var carryable = target.TraitOrDefault(); if (carryable == null) - throw new LuaException("Actor '{0}' cannot carry actor '{1}'!".F(Self, target)); + throw new LuaException($"Actor '{Self}' cannot carry actor '{target}'!"); Self.QueueActivity(new PickupUnit(Self, target, carryall.Info.BeforeLoadDelay, null)); } diff --git a/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs b/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs index b87c591ea8..21b8eaeb89 100644 --- a/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs +++ b/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs @@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Traits if (countdownLabel != null) { countdown = new CachedTransform(t => - info.CountdownText.F(WidgetUtils.FormatTime(t, w.Timestep))); + string.Format(info.CountdownText, WidgetUtils.FormatTime(t, w.Timestep))); countdownLabel.GetText = () => TimeLimit > 0 ? countdown.Update(ticksRemaining) : ""; } } @@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Traits { if (ticksRemaining == m * 60 * ticksPerSecond) { - TextNotificationsManager.AddSystemLine(Notification.F(m, m > 1 ? "s" : null)); + TextNotificationsManager.AddSystemLine(string.Format(Notification, m, m > 1 ? "s" : null)); var faction = self.World.LocalPlayer?.Faction.InternalName; Game.Sound.PlayNotification(self.World.Map.Rules, self.World.LocalPlayer, "Speech", info.TimeLimitWarnings[m], faction); diff --git a/OpenRA.Mods.Common/UtilityCommands/DebugChromeRegions.cs b/OpenRA.Mods.Common/UtilityCommands/DebugChromeRegions.cs index edfe8686c3..0e9b4e0eec 100644 --- a/OpenRA.Mods.Common/UtilityCommands/DebugChromeRegions.cs +++ b/OpenRA.Mods.Common/UtilityCommands/DebugChromeRegions.cs @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.UtilityCommands } } - var output = HtmlTemplate.JoinWith("\n").F(zoom, Convert.ToBase64String(modData.ModFiles.Open(image).ReadAllBytes()), "[" + regions.JoinWith(",") + "]"); + var output = string.Format(HtmlTemplate.JoinWith("\n"), zoom, Convert.ToBase64String(modData.ModFiles.Open(image).ReadAllBytes()), "[" + regions.JoinWith(",") + "]"); var outputPath = Path.ChangeExtension(image, ".html"); File.WriteAllLines(outputPath, new[] { output }); Console.WriteLine("Saved {0}", outputPath); diff --git a/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs b/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs index 2702fa88cf..f96ba7120c 100644 --- a/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs +++ b/OpenRA.Mods.Common/Widgets/LineGraphWidget.cs @@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Widgets var scale = 200 / Math.Max(5000, (float)Math.Ceiling(maxValue / 1000) * 1000); - var widthMaxValue = labelFont.Measure(GetYAxisValueFormat().F(height / scale)).X; + var widthMaxValue = labelFont.Measure(string.Format(GetYAxisValueFormat(), height / scale)).X; var widthLongestName = labelFont.Measure(longestName).X; // y axis label @@ -164,7 +164,7 @@ namespace OpenRA.Mods.Common.Widgets }), 1, color); if (lastPoint != 0f) - labelFont.DrawTextWithShadow(GetValueFormat().F(lastPoint), graphOrigin + new float2(lastX * xStep, -lastPoint * scale - 2), + labelFont.DrawTextWithShadow(string.Format(GetValueFormat(), lastPoint), graphOrigin + new float2(lastX * xStep, -lastPoint * scale - 2), color, BackgroundColorDark, BackgroundColorLight, 1); } @@ -185,7 +185,7 @@ namespace OpenRA.Mods.Common.Widgets if (n % XAxisTicksPerLabel != 0) continue; - var xAxisText = GetXAxisValueFormat().F(n / XAxisTicksPerLabel); + var xAxisText = string.Format(GetXAxisValueFormat(), n / XAxisTicksPerLabel); var xAxisTickTextWidth = labelFont.Measure(xAxisText).X; var xLocation = x - xAxisTickTextWidth / 2; labelFont.DrawTextWithShadow(xAxisText, @@ -202,7 +202,7 @@ namespace OpenRA.Mods.Common.Widgets { var yValue = y / scale; cr.DrawLine(graphOrigin + new float2(0, -y), graphOrigin + new float2(5, -y), 1, Color.White); - var text = GetYAxisValueFormat().F(yValue); + var text = string.Format(GetYAxisValueFormat(), yValue); var textWidth = labelFont.Measure(text); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs index e91110d17e..eae08ad7da 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs @@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } siloUsageTooltip = siloUsageTooltipCache.Update((playerResources.Resources, playerResources.ResourceCapacity)); - cashLabel.Text = cashTemplate.F(displayResources); + cashLabel.Text = string.Format(cashTemplate, displayResources); } } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs index a8d312fbf5..f5f91ec1a1 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs @@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var requiresSize = int2.Zero; if (prereqs.Any()) { - requiresLabel.Text = requiresFormat.F(prereqs.JoinWith(", ")); + requiresLabel.Text = string.Format(requiresFormat, prereqs.JoinWith(", ")); requiresSize = requiresFont.Measure(requiresLabel.Text); requiresLabel.Visible = true; descLabel.Bounds.Y = descLabelY + requiresLabel.Bounds.Height; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs index ecd2edcab6..c2a0c957eb 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs @@ -425,7 +425,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic titleLabel.GetText = () => item.Title; var authorDateTimeLabel = newsItem.Get("AUTHOR_DATETIME"); - var authorDateTime = authorDateTimeLabel.Text.F(item.Author, item.DateTime.ToLocalTime()); + var authorDateTime = string.Format(authorDateTimeLabel.Text, item.Author, item.DateTime.ToLocalTime()); authorDateTimeLabel.GetText = () => authorDateTime; var contentLabel = newsItem.Get("CONTENT"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs index f9786653e1..5dfb7c7ba8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs @@ -220,14 +220,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic duplicateNotice.IsVisible = () => !isHotkeyValid; var duplicateNoticeText = new CachedTransform(hd => hd != null ? - duplicateNotice.Text.F(hd.Description, hd.Contexts.First(c => selectedHotkeyDefinition.Contexts.Contains(c))) : + string.Format(duplicateNotice.Text, hd.Description, 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 => originalNotice.Text.F(hd?.Default.DisplayString())); + var originalNoticeText = new CachedTransform(hd => string.Format(originalNotice.Text, hd?.Default.DisplayString())); originalNotice.GetText = () => originalNoticeText.Update(selectedHotkeyDefinition); var readonlyNotice = panel.Get("READONLY_NOTICE"); diff --git a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs index d93e2052c6..12549d6c2d 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets { var self = p.Instances[0].Self; var time = WidgetUtils.FormatTime(p.RemainingTicks, false, self.World.Timestep); - var text = Format.F(self.Owner.PlayerName, p.Info.Name, time); + var text = string.Format(Format, self.Owner.PlayerName, p.Info.Name, time); var playerColor = self.Owner.Color; if (Game.Settings.Game.UsePlayerStanceColors) diff --git a/OpenRA.Platforms.Default/Texture.cs b/OpenRA.Platforms.Default/Texture.cs index c6ae9adf67..26523fbd4f 100644 --- a/OpenRA.Platforms.Default/Texture.cs +++ b/OpenRA.Platforms.Default/Texture.cs @@ -96,7 +96,7 @@ namespace OpenRA.Platforms.Default { VerifyThreadAffinity(); if (!Exts.IsPowerOf2(width) || !Exts.IsPowerOf2(height)) - throw new InvalidDataException("Non-power-of-two array {0}x{1}".F(width, height)); + throw new InvalidDataException($"Non-power-of-two array {width}x{height}"); Size = new Size(width, height); unsafe