Update the update paths for release-20200202

This commit is contained in:
abcdefg30
2020-02-17 11:23:55 +01:00
committed by Paul Chote
parent 09a019f9c6
commit f73d23661f
11 changed files with 6 additions and 2 deletions

View File

@@ -1,65 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class AddResourceRenderer : UpdateRule
{
public override string Name
{
get { return "Add ResourceRenderer trait"; }
}
public override string Description
{
get { return "The rendering parts of ResourceLayer have been moved to a new trait"; }
}
readonly List<string> locations = new List<string>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (locations.Any())
yield return "[D2k]ResourceRenderer has been added.\n" +
"You need to adjust the the field RenderTypes on trait [D2k]ResourceRenderer\n" +
"on the following actors:\n" +
UpdateUtils.FormatMessageList(locations);
locations.Clear();
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
if (actorNode.ChildrenMatching("ResourceLayer").Any() && !actorNode.ChildrenMatching("ResourceRenderer").Any())
{
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
var resourceRenderer = new MiniYamlNode("ResourceRenderer", "");
resourceRenderer.AddNode("RenderTypes", "");
actorNode.AddNode(resourceRenderer);
}
if (actorNode.ChildrenMatching("D2kResourceLayer").Any() && !actorNode.ChildrenMatching("D2kResourceRenderer").Any())
{
actorNode.RenameChildrenMatching("D2kResourceLayer", "ResourceLayer");
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
var resourceRenderer = new MiniYamlNode("D2kResourceRenderer", "");
resourceRenderer.AddNode("RenderTypes", "");
actorNode.AddNode(resourceRenderer);
}
yield break;
}
}
}

View File

@@ -1,74 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class CreateScreenShakeWarhead : UpdateRule
{
public override string Name { get { return "Create ScreenShakeWarhead to replace hardcoded shaking."; } }
public override string Description
{
get
{
return "The traits MadTank and NukePower (via the NukeLaunch projectile that it uses) no longer have built-in screen shaking.";
}
}
readonly List<Tuple<string, string, string>> weaponsToUpdate = new List<Tuple<string, string, string>>();
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
var madTankTraits = actorNode.ChildrenMatching("MadTank");
var nukePowerTraits = actorNode.ChildrenMatching("NukePower");
foreach (var madTankTrait in madTankTraits)
{
var traitName = madTankTrait.Key;
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)));
madTankTrait.RemoveNodes("ThumpShakeTime");
madTankTrait.RemoveNodes("ThumpShakeIntensity");
madTankTrait.RemoveNodes("ThumpShakeMultiplier");
}
foreach (var nukePowerTrait in nukePowerTraits)
{
var traitName = nukePowerTrait.Key;
var weaponNode = nukePowerTrait.ChildrenMatching("MissileWeapon").FirstOrDefault();
if (weaponNode == null)
continue;
var weaponName = weaponNode.Value.Value;
weaponsToUpdate.Add(new Tuple<string, string, string>(weaponName, traitName, "{0} ({1})".F(actorNode.Key, actorNode.Location.Filename)));
}
yield break;
}
public override IEnumerable<string> AfterUpdate(ModData modData)
{
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)));
weaponsToUpdate.Clear();
}
}
}

View File

@@ -1,215 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Widgets;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class ReformatChromeProvider : UpdateRule
{
public override string Name { get { return "Reformat UI image definitions."; } }
public override string Description
{
get
{
return "The format of the chrome.yaml file defining image regions for the UI has\n" +
"changed to support additional metadata fields. ";
}
}
readonly List<string> overrideLocations = new List<string>();
readonly List<string> panelLocations = new List<string>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (overrideLocations.Any())
yield return "Region-specific image overrides are no longer supported. The following definitions must be replaced:\n" +
UpdateUtils.FormatMessageList(overrideLocations);
if (panelLocations.Any())
yield return "The following definitions appear to be panels, but could not be converted to the new PanelRegion format.\n" +
"You may wish to define PanelRegion/PanelSides manually to reduce duplication:\n" +
UpdateUtils.FormatMessageList(panelLocations);
overrideLocations.Clear();
panelLocations.Clear();
}
readonly string[] edgeKeys =
{
"corner-tl", "corner-tr", "corner-bl", "corner-br",
"border-t", "border-b", "border-l", "border-r"
};
bool ExtractPanelDefinition(MiniYamlNode chromeProviderNode, MiniYamlNode regionsNode)
{
var cNode = regionsNode.LastChildMatching("background");
var hasCenter = cNode != null;
var hasEdges = edgeKeys.Any(k => regionsNode.LastChildMatching(k) != null);
// Not a panel
if (!hasCenter && !hasEdges)
return true;
// Panels may define just the background
if (hasCenter && !hasEdges)
{
var bgRect = cNode.NodeValue<Rectangle>();
chromeProviderNode.AddNode("PanelRegion", new[]
{
bgRect.X, bgRect.Y,
0, 0,
bgRect.Width, bgRect.Height,
0, 0
});
chromeProviderNode.AddNode("PanelSides", PanelSides.Center);
regionsNode.RemoveNode(cNode);
return true;
}
// Panels may define just the edges, or edges plus background
var tlNode = regionsNode.LastChildMatching("corner-tl");
if (tlNode == null)
return false;
var tlRect = tlNode.NodeValue<Rectangle>();
var tNode = regionsNode.LastChildMatching("border-t");
if (tNode == null)
return false;
var tRect = tNode.NodeValue<Rectangle>();
if (tRect.Left != tlRect.Right || tRect.Top != tlRect.Top || tRect.Bottom != tlRect.Bottom)
return false;
var trNode = regionsNode.LastChildMatching("corner-tr");
if (trNode == null)
return false;
var trRect = trNode.NodeValue<Rectangle>();
if (trRect.Left != tRect.Right || trRect.Top != tRect.Top || trRect.Bottom != tRect.Bottom)
return false;
var lNode = regionsNode.LastChildMatching("border-l");
if (lNode == null)
return false;
var lRect = lNode.NodeValue<Rectangle>();
if (lRect.Left != tlRect.Left || lRect.Top != tlRect.Bottom || lRect.Right != tlRect.Right)
return false;
var rNode = regionsNode.LastChildMatching("border-r");
if (rNode == null)
return false;
var rRect = rNode.NodeValue<Rectangle>();
if (rRect.Left != trRect.Left || rRect.Top != trRect.Bottom || rRect.Bottom != lRect.Bottom || rRect.Right != trRect.Right)
return false;
var blNode = regionsNode.LastChildMatching("corner-bl");
if (blNode == null)
return false;
var blRect = blNode.NodeValue<Rectangle>();
if (blRect.Left != lRect.Left || blRect.Top != lRect.Bottom || blRect.Right != lRect.Right)
return false;
var bNode = regionsNode.LastChildMatching("border-b");
if (bNode == null)
return false;
var bRect = bNode.NodeValue<Rectangle>();
if (bRect.Left != blRect.Right || bRect.Top != blRect.Top || bRect.Bottom != blRect.Bottom || bRect.Right != tRect.Right)
return false;
var brNode = regionsNode.LastChildMatching("corner-br");
if (brNode == null)
return false;
var brRect = brNode.NodeValue<Rectangle>();
if (brRect.Left != bRect.Right || brRect.Top != bRect.Top || brRect.Bottom != bRect.Bottom || brRect.Right != rRect.Right)
return false;
// Background definition may be omitted
if (hasCenter)
{
var bgRect = cNode.NodeValue<Rectangle>();
if (bgRect.Left != lRect.Right || bgRect.Top != lRect.Top || bgRect.Bottom != lRect.Bottom || bgRect.Right != tRect.Right)
return false;
}
// Define the short-form panel region
chromeProviderNode.AddNode("PanelRegion", new[]
{
tlRect.X, tlRect.Y,
tlRect.Width, tlRect.Height,
trRect.Left - tlRect.Right, blRect.Top - tlRect.Bottom,
brRect.Width, brRect.Height
});
if (!hasCenter)
chromeProviderNode.AddNode("PanelSides", PanelSides.Edges);
// Remove the now redundant regions
regionsNode.RemoveNode(tlNode);
regionsNode.RemoveNode(tNode);
regionsNode.RemoveNode(trNode);
regionsNode.RemoveNode(lNode);
regionsNode.RemoveNode(rNode);
regionsNode.RemoveNode(blNode);
regionsNode.RemoveNode(bNode);
regionsNode.RemoveNode(brNode);
if (cNode != null)
regionsNode.RemoveNode(cNode);
return true;
}
public override IEnumerable<string> UpdateChromeProviderNode(ModData modData, MiniYamlNode chromeProviderNode)
{
// Migrate image rectangles
var regionsNode = new MiniYamlNode("Regions", "");
foreach (var n in chromeProviderNode.Value.Nodes)
{
if (n.Key == "Inherits")
continue;
// Reformat region as a list
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));
}
chromeProviderNode.Value.Nodes.RemoveAll(n => n.Key != "Inherits");
// Migrate image definition
chromeProviderNode.AddNode(new MiniYamlNode("Image", chromeProviderNode.Value.Value));
chromeProviderNode.Value.Value = "";
if (!ExtractPanelDefinition(chromeProviderNode, regionsNode))
panelLocations.Add("{0} ({1})".F(chromeProviderNode.Key, chromeProviderNode.Location.Filename));
if (regionsNode.Value.Nodes.Any())
chromeProviderNode.AddNode(regionsNode);
yield break;
}
}
}

View File

@@ -1,56 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class RemoveAirdropActorTypeDefault : UpdateRule
{
public override string Name { get { return "Removed internal default of ProductionAirdrop.ActorType"; } }
public override string Description
{
get
{
return "Removed internal default of 'c17' from ProductionAirdrop.ActorType.";
}
}
readonly List<Tuple<string, string>> missingActorTypes = new List<Tuple<string, string>>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
var message = "ProductionAirdrop.ActorType no longer defaults to 'c17' and must be defined explicitly.\n"
+ "You may have to define it manually now in the following places:\n"
+ UpdateUtils.FormatMessageList(missingActorTypes.Select(n => n.Item1 + " (" + n.Item2 + ")"));
if (missingActorTypes.Any())
yield return message;
missingActorTypes.Clear();
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
var airProd = actorNode.LastChildMatching("ProductionAirdrop");
if (airProd != null)
{
var actorTypeNode = airProd.LastChildMatching("ActorType");
if (actorTypeNode == null)
missingActorTypes.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename));
}
yield break;
}
}
}

View File

@@ -1,65 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class RemoveInitialFacingHardcoding : UpdateRule
{
public override string Name { get { return "Removed InitialFacing hardcoding for non-VTOLs"; } }
public override string Description
{
get
{
return "Removed hardcoding of InitialFacing to 192 for aircraft with VTOL: false.";
}
}
readonly List<Tuple<string, string>> nonVTOLs = new List<Tuple<string, string>>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
var message = "InitialFacing is no longer hardcoded to 192 for aircraft with VTOL: false.\n"
+ "You may have to set it manually now in the following places:\n"
+ UpdateUtils.FormatMessageList(nonVTOLs.Select(n => n.Item1 + " (" + n.Item2 + ")"));
if (nonVTOLs.Any())
yield return message;
nonVTOLs.Clear();
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
var aircraft = actorNode.LastChildMatching("Aircraft");
if (aircraft != null)
{
var initialFacing = aircraft.LastChildMatching("InitialFacing");
var isVTOL = false;
var vtolNode = aircraft.LastChildMatching("VTOL");
if (vtolNode != null)
isVTOL = vtolNode.NodeValue<bool>();
// If InitialFacing is defined or it's a VTOL, no changes are needed.
if (initialFacing != null || isVTOL)
yield break;
nonVTOLs.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename));
}
yield break;
}
}
}

View File

@@ -1,52 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class RemoveWithPermanentInjury : UpdateRule
{
public override string Name { get { return "WithPermanentInjury trait has been removed."; } }
public override string Description
{
get
{
return "The WithPermanentInjury trait has been removed, and should be replaced by\n" +
"TakeCover with negative ProneTime value + GrantConditionOnDamageState/-Health.\n" +
"Affected actors are listed so that these traits can be defined.";
}
}
readonly List<string> locations = new List<string>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (locations.Any())
yield return "The WithPermanentInjury trait has been removed from the following actors.\n" +
"You must manually define TakeCover with a negative ProneTime and use\n" +
"GrantConditionOnDamageState/-Health with 'GrantPermanently: true'\n" +
"to enable TakeCover at the desired damage state:\n" +
UpdateUtils.FormatMessageList(locations);
locations.Clear();
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
if (actorNode.RemoveNodes("WithPermanentInjury") > 0)
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
yield break;
}
}
}

View File

@@ -1,61 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class RemoveYesNo : UpdateRule
{
public override string Name { get { return "Remove 'yes' and 'no' in favor of 'true' and 'false'."; } }
public override string Description
{
get
{
return "'Yes' and 'no' are no longer valid values for booleans. " +
"Use 'true' and 'false' instead.";
}
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var traitNode in actorNode.Value.Nodes)
{
foreach (var n in traitNode.Value.Nodes)
{
var value = n.NodeValue<string>();
if (value == null)
continue;
if (value.ToLowerInvariant() == "yes")
n.ReplaceValue("true");
else if (value.ToLowerInvariant() == "no")
n.ReplaceValue("false");
}
}
yield break;
}
bool displayed;
public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (displayed)
yield break;
displayed = true;
yield return "'Yes' and 'no' have been removed from the mod rules. "
+ "Chrome yaml files may need a manual update.";
}
}
}

View File

@@ -1,35 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
class RenameProneTime : UpdateRule
{
public override string Name { get { return "Renamed ProneTime to Duration"; } }
public override string Description
{
get
{
return "Renamed TakeCover property ProneTime to Duration.";
}
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var takeCover in actorNode.ChildrenMatching("TakeCover"))
takeCover.RenameChildrenMatching("ProneTime", "Duration");
yield break;
}
}
}

View File

@@ -1,35 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
class RenameRallyPointPath : UpdateRule
{
public override string Name { get { return "Renamed RallyPoint Offset to Path"; } }
public override string Description
{
get
{
return "The RallyPoint Offset property has been renamed to Path and now accepts multiple (or no) values.";
}
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var rp in actorNode.ChildrenMatching("RallyPoint"))
rp.RenameChildrenMatching("Offset", "Path");
yield break;
}
}
}

View File

@@ -1,60 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2019 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class RenameSpins : UpdateRule
{
public override string Name { get { return "FallsToEarth.Spins has been refactored to MaximumSpinSpeed."; } }
public override string Description
{
get
{
return "The FallsToEarth.Spins property has been refactored to MaximumSpinSpeed.";
}
}
readonly List<string> locations = new List<string>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (locations.Any())
yield return "The Spins property has been refactored to MaximumSpinSpeed.\n" +
"MaximumSpinSpeed defaults to 'unlimited', while disabling is done by setting it to 0.\n" +
"You may want to set a custom MaximumSpinSpeed limiting value in the following places:\n" +
UpdateUtils.FormatMessageList(locations);
locations.Clear();
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var fallsToEarth in actorNode.ChildrenMatching("FallsToEarth"))
{
var spinsNode = fallsToEarth.LastChildMatching("Spins");
if (spinsNode != null)
{
var spins = spinsNode.NodeValue<bool>();
if (!spins)
fallsToEarth.AddNode("MaximumSpinSpeed", "0");
fallsToEarth.RemoveNode(spinsNode);
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
}
}
yield break;
}
}
}