Replace F extension with string interpolation

This commit is contained in:
teinarss
2021-04-24 17:46:24 +02:00
committed by reaperrr
parent 1385aca783
commit 10676be377
300 changed files with 752 additions and 799 deletions

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
if (actorNode.ChildrenMatching("ResourceLayer").Any() && !actorNode.ChildrenMatching("ResourceRenderer").Any())
{
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key} ({actorNode.Location.Filename})");
var resourceRenderer = new MiniYamlNode("ResourceRenderer", "");
resourceRenderer.AddNode("RenderTypes", "");
actorNode.AddNode(resourceRenderer);
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
actorNode.RenameChildrenMatching("D2kResourceLayer", "ResourceLayer");
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key} ({actorNode.Location.Filename})");
var resourceRenderer = new MiniYamlNode("D2kResourceRenderer", "");
resourceRenderer.AddNode("RenderTypes", "");
actorNode.AddNode(resourceRenderer);

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
var weaponNode = madTankTrait.ChildrenMatching("MADTankThump").FirstOrDefault();
var weaponName = weaponNode != null ? weaponNode.Value.Value : "MADTankThump";
weaponsToUpdate.Add(new Tuple<string, string, string>(weaponName, traitName, "{0} ({1})".F(actorNode.Key, actorNode.Location.Filename)));
weaponsToUpdate.Add(new Tuple<string, string, string>(weaponName, traitName, $"{actorNode.Key} ({actorNode.Location.Filename})"));
madTankTrait.RemoveNodes("ThumpShakeTime");
madTankTrait.RemoveNodes("ThumpShakeIntensity");
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
var weaponName = weaponNode.Value.Value;
weaponsToUpdate.Add(new Tuple<string, string, string>(weaponName, traitName, "{0} ({1})".F(actorNode.Key, actorNode.Location.Filename)));
weaponsToUpdate.Add(new Tuple<string, string, string>(weaponName, traitName, $"{actorNode.Key} ({actorNode.Location.Filename})"));
}
yield break;
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
if (weaponsToUpdate.Any())
yield return "Add a ScreenShakeWarhead to the following weapons:\n" +
UpdateUtils.FormatMessageList(weaponsToUpdate.Select(x => "Weapon `{0}`, used by trait `{1}` on actor {2}".F(x.Item1, x.Item2, x.Item3)));
UpdateUtils.FormatMessageList(weaponsToUpdate.Select(x => $"Weapon `{x.Item1}`, used by trait `{x.Item2}` on actor {x.Item3}"));
weaponsToUpdate.Clear();
}

View File

@@ -187,7 +187,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
regionsNode.AddNode(n.Key, n.NodeValue<int[]>());
if (n.Value.Nodes.Any())
overrideLocations.Add("{0}.{1} ({2})".F(chromeProviderNode.Key, n.Key, chromeProviderNode.Location.Filename));
overrideLocations.Add($"{chromeProviderNode.Key}.{n.Key} ({chromeProviderNode.Location.Filename})");
}
chromeProviderNode.Value.Nodes.RemoveAll(n => n.Key != "Inherits");
@@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
chromeProviderNode.Value.Value = "";
if (!ExtractPanelDefinition(chromeProviderNode, regionsNode))
panelLocations.Add("{0} ({1})".F(chromeProviderNode.Key, chromeProviderNode.Location.Filename));
panelLocations.Add($"{chromeProviderNode.Key} ({chromeProviderNode.Location.Filename})");
if (regionsNode.Value.Nodes.Any())
chromeProviderNode.AddNode(regionsNode);

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
if (actorNode.RemoveNodes("WithPermanentInjury") > 0)
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key} ({actorNode.Location.Filename})");
yield break;
}

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
fallsToEarth.AddNode("MaximumSpinSpeed", "0");
fallsToEarth.RemoveNode(spinsNode);
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key} ({actorNode.Location.Filename})");
}
}

View File

@@ -58,13 +58,13 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
yield return "Some passenger types define custom cargo pips. Review the following definitions:\n" +
UpdateUtils.FormatMessageList(cargoPipLocations) +
"\nand, if required, add the following to the WithCargoPipsDecoration traits:\n" +
"CustomPipSequences:\n" + cargoCustomPips.Select(p => "\t{0}: {1}".F(p, PipReplacements[p])).JoinWith("\n");
"CustomPipSequences:\n" + cargoCustomPips.Select(p => $"\t{p}: {PipReplacements[p]}").JoinWith("\n");
if (harvesterCustomPips.Any() && harvesterPipLocations.Any())
yield return "Review the following definitions:\n" +
UpdateUtils.FormatMessageList(harvesterPipLocations) +
"\nand, if required, add the following to the WithHarvesterPipsDecoration traits:\n" +
"ResourceSequences:\n" + harvesterCustomPips.Select(kv => "\t{0}: {1}".F(kv.Key, PipReplacements[kv.Value])).JoinWith("\n");
"ResourceSequences:\n" + harvesterCustomPips.Select(kv => $"\t{kv.Key}: {PipReplacements[kv.Value]}").JoinWith("\n");
customPips = false;
locations.Clear();
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
}
addNodes.Add(ammoPips);
locations.Add("{0}: {1} ({2})".F(actorNode.Key, ammoPips.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key}: {ammoPips.Key} ({actorNode.Location.Filename})");
}
foreach (var cargo in actorNode.ChildrenMatching("Cargo"))
@@ -154,8 +154,8 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
continue;
addNodes.Add(cargoPips);
locations.Add("{0}: {1} ({2})".F(actorNode.Key, cargoPips.Key, actorNode.Location.Filename));
cargoPipLocations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key}: {cargoPips.Key} ({actorNode.Location.Filename})");
cargoPipLocations.Add($"{actorNode.Key} ({actorNode.Location.Filename})");
}
foreach (var passenger in actorNode.ChildrenMatching("Passenger"))
@@ -199,8 +199,8 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
harvesterPips.AddNode("PipCount", 7);
addNodes.Add(harvesterPips);
locations.Add("{0}: {1} ({2})".F(actorNode.Key, harvesterPips.Key, actorNode.Location.Filename));
harvesterPipLocations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key}: {harvesterPips.Key} ({actorNode.Location.Filename})");
harvesterPipLocations.Add($"{actorNode.Key} ({actorNode.Location.Filename})");
}
foreach (var resourceType in actorNode.ChildrenMatching("ResourceType"))
@@ -254,7 +254,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
storagePips.AddNode("FullSequence", PipReplacements["yellow"]);
addNodes.Add(storagePips);
locations.Add("{0}: {1} ({2})".F(actorNode.Key, storagePips.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key}: {storagePips.Key} ({actorNode.Location.Filename})");
}
foreach (var addNode in addNodes)

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
range = rangeNode.NodeValue<int>();
if (range > 3)
locations.Add("{0} ({1})".F(rangeNode.Key, rangeNode.Location.Filename));
locations.Add($"{rangeNode.Key} ({rangeNode.Location.Filename})");
power.RemoveNode(rangeNode);
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
var weaponName = weaponNode.Value.Value;
weaponsToUpdate.Add(new Tuple<string, string, string>(weaponName, traitName, "{0} ({1})".F(actorNode.Key, actorNode.Location.Filename)));
weaponsToUpdate.Add(new Tuple<string, string, string>(weaponName, traitName, $"{actorNode.Key} ({actorNode.Location.Filename})"));
nukePowerTrait.RemoveNodes("FlashType");
}
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
if (weaponsToUpdate.Any())
yield return "Add a FlashPaletteEffectWarhead to the following weapons:\n" +
UpdateUtils.FormatMessageList(weaponsToUpdate.Select(x => "Weapon `{0}`, used by trait `{1}` on actor {2}".F(x.Item1, x.Item2, x.Item3)));
UpdateUtils.FormatMessageList(weaponsToUpdate.Select(x => $"Weapon `{x.Item1}`, used by trait `{x.Item2}` on actor {x.Item3}"));
weaponsToUpdate.Clear();
}

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
var locationKey = "{0} ({1})".F(actorNode.Key, actorNode.Location.Filename);
var locationKey = $"{actorNode.Key} ({actorNode.Location.Filename})";
foreach (var trait in LegacyDecorationTraits)
{

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
if (usesClassicFacings)
{
bo.RenameKey("ClassicFacingBodyOrientation");
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key} ({actorNode.Location.Filename})");
}
}

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
if (actorNode.RemoveNodes("LaysTerrain") > 0)
yield return "'LaysTerrain' was removed from {0} ({1}) without replacement.\n".F(actorNode.Key, actorNode.Location.Filename);
yield return $"'LaysTerrain' was removed from {actorNode.Key} ({actorNode.Location.Filename}) without replacement.\n";
yield break;
}

View File

@@ -33,9 +33,10 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
var sequence = sequenceNode.Value.Value;
var facings = muzzleSplitFacings.NodeValue<int>() - 1;
var actor = actorNode.Key.ToLowerInvariant();
yield return "The Armament muzzle effect has been removed from {0} ({1}).\n".F(actor, actorNode.Location.Filename) +
"If you would like to restore the muzzle effect you must redefine `MuzzleSequence: {0}`\n".F(sequence) +
"and replace the {0}0-{1} sequence definitions with a single `{0}` sequence that uses\n".F(sequence, facings) +
yield return
$"The Armament muzzle effect has been removed from {actor} ({actorNode.Location.Filename}).\n" +
$"If you would like to restore the muzzle effect you must redefine `MuzzleSequence: {sequence}`\n" +
$"and replace the {sequence}0-{facings} sequence definitions with a single `{sequence}` sequence that uses\n" +
"the Combine syntax to assemble the different facing sprites.";
a.RemoveNode(muzzleSplitFacings);

View File

@@ -24,9 +24,9 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
foreach (var damaged in actorNode.ChildrenMatching("DamagedByTerrain", includeRemovals: false))
{
if (damaged.RemoveNodes("DamageThreshold") > 0)
yield return "'DamageThreshold' was removed from {0} ({1}) without replacement.\n".F(actorNode.Key, actorNode.Location.Filename);
yield return $"'DamageThreshold' was removed from {actorNode.Key} ({actorNode.Location.Filename}) without replacement.\n";
if (damaged.RemoveNodes("StartOnThreshold") > 0)
yield return "'StartOnThreshold' was removed from {0} ({1}) without replacement.\n".F(actorNode.Key, actorNode.Location.Filename);
yield return $"'StartOnThreshold' was removed from {actorNode.Key} ({actorNode.Location.Filename}) without replacement.\n";
}
yield break;

View File

@@ -36,10 +36,10 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
public override IEnumerable<string> UpdateMapActorNode(ModData modData, MiniYamlNode actorNode)
{
if (actorNode.RemoveNodes("Plugs") > 0)
yield return "Initial plugs for actor {0} will need to be reconfigured using the map editor.".F(actorNode.Key);
yield return $"Initial plugs for actor {actorNode.Key} will need to be reconfigured using the map editor.";
if (actorNode.RemoveNodes("TurretFacings") > 0)
yield return "Initial turret facings for actor {0} will need to be reconfigured using the map editor.".F(actorNode.Key);
yield return $"Initial turret facings for actor {actorNode.Key} will need to be reconfigured using the map editor.";
var bodyFacing = WAngle.Zero;
foreach (var facing in actorNode.ChildrenMatching("Facing"))

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
}
if (removed > 0)
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key} ({actorNode.Location.Filename})");
yield break;
}

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
foreach (var renderSprites in actorNode.ChildrenMatching("RenderSprites"))
if (renderSprites.RemoveNodes("Scale") > 0)
yield return "The actor-level scaling has been removed from {0} ({1}).\n".F(actorNode.Key, actorNode.Location.Filename) +
"You must manually define Scale on its sequences instead.";
yield return $"The actor-level scaling has been removed from {actorNode.Key} ({actorNode.Location.Filename}).\n" +
"You must manually define Scale on its sequences instead.";
}
}
}

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
var locationKey = "{0} ({1})".F(actorNode.Key, actorNode.Location.Filename);
var locationKey = $"{actorNode.Key} ({actorNode.Location.Filename})";
var anyConditionalSmokeTrail = false;
foreach (var smokeTrail in actorNode.ChildrenMatching("SmokeTrailWhenDamaged"))

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
foreach (var projectileNode in weaponNode.ChildrenMatching("Projectile"))
if (projectileNode.RemoveNodes("ShadowPalette") > 0)
locations.Add("{0}: {1} ({2})".F(weaponNode.Key, weaponNode.Key, weaponNode.Location.Filename));
locations.Add($"{weaponNode.Key}: {weaponNode.Key} ({weaponNode.Location.Filename})");
yield break;
}
@@ -47,11 +47,11 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
foreach (var node in actorNode.ChildrenMatching("WithShadow"))
if (node.RemoveNodes("Palette") > 0)
locations.Add("{0}: {1} ({2})".F(actorNode.Key, node.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key}: {node.Key} ({actorNode.Location.Filename})");
foreach (var node in actorNode.ChildrenMatching("WithParachute"))
if (node.RemoveNodes("ShadowPalette") > 0)
locations.Add("{0}: {1} ({2})".F(actorNode.Key, node.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key}: {node.Key} ({actorNode.Location.Filename})");
yield break;
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
{
foreach (var node in actorNode.ChildrenMatching("WithColoredOverlay"))
if (node.RemoveNodes("Palette") > 0)
locations.Add("{0}: {1} ({2})".F(actorNode.Key, node.Key, actorNode.Location.Filename));
locations.Add($"{actorNode.Key}: {node.Key} ({actorNode.Location.Filename})");
yield break;
}

View File

@@ -254,7 +254,7 @@ namespace OpenRA.Mods.Common.UpdateRules
public static string FormatMessageList(IEnumerable<string> messages, int indent = 0, string separator = "*")
{
var prefix = string.Concat(Enumerable.Repeat(" ", indent));
return string.Join("\n", messages.Select(m => prefix + " {0} {1}".F(separator, m.Replace("\n", "\n " + prefix))));
return string.Join("\n", messages.Select(m => prefix + $" {separator} {m.Replace("\n", "\n " + prefix)}"));
}
}