Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish existing update rules #15090

Merged
merged 2 commits into from May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions OpenRA.Mods.Common/UpdateRules/Rules/AddEditorPlayer.cs
Expand Up @@ -21,20 +21,29 @@ public override string Description
{
get
{
return "Map editor now requires an EditorPlayer to avoid loading all kinds of unnecessary player traits.";
return "Map editor now requires an EditorPlayer to avoid loading unnecessary player traits.\n" +
"A warning is displayed if this actor has not been defined.";
}
}

bool messageDisplayed;
bool warningRequired = true;

public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (!messageDisplayed)
if (warningRequired)
{
messageDisplayed = true;
warningRequired = false;
yield return "The map editor now requires an EditorPlayer actor.\n" +
"Please add an EditorPlayer with the traits AlwaysVisible and Shroud to player.yaml\n(or a different rules yaml file of your choice).";
}
}

public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
if (actorNode.KeyMatches("EditorPlayer"))
warningRequired = false;

yield break;
}
}
}
42 changes: 19 additions & 23 deletions OpenRA.Mods.Common/UpdateRules/Rules/DefineSoundDefaults.cs
Expand Up @@ -22,42 +22,38 @@ public override string Description
{
get
{
return "Mod-specific default sound values have been removed from several traits.\n" +
"The original values are added back via yaml.";
return "Mod-specific default sound values have been removed from several traits\n" +
"(" + fields.Select(f => f.Item1 + "." + f.Item2).JoinWith(", ") + ")\n" +
"Uses of these traits are listed for inspection so the values can be overriden in yaml.";
}
}

Tuple<string, string, string, List<MiniYamlNode>>[] fields =
Tuple<string, string, string, List<string>>[] fields =
{
Tuple.Create("ParaDrop", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
Tuple.Create("EjectOnDeath", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
Tuple.Create("ProductionParadrop", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
Tuple.Create("Building", "BuildSounds", "placbldg.aud, build5.aud", new List<MiniYamlNode>()),
Tuple.Create("Building", "UndeploySounds", "cashturn.aud", new List<MiniYamlNode>())
Tuple.Create("ParaDrop", "ChuteSound", "chute1.aud", new List<string>()),
Tuple.Create("EjectOnDeath", "ChuteSound", "chute1.aud", new List<string>()),
Tuple.Create("ProductionParadrop", "ChuteSound", "chute1.aud", new List<string>()),
Tuple.Create("Building", "BuildSounds", "placbldg.aud, build5.aud", new List<string>()),
Tuple.Create("Building", "UndeploySounds", "cashturn.aud", new List<string>())
};

public override IEnumerable<string> BeforeUpdate(ModData modData)
string BuildMessage(Tuple<string, string, string, List<string>> field)
{
// Reset state for each mod/map
foreach (var field in fields)
field.Item4.Clear();

yield break;
}

string BuildMessage(Tuple<string, string, string, List<MiniYamlNode>> field)
{
return "The default value for {0}.{1} has been removed.\n".F(field.Item1, field.Item2)
+ "You may wish to explicitly define `{0}: {1}` at the following\n".F(field.Item2, field.Item3)
+ "locations if the sound has not already been inherited from a parent definition.\n"
+ UpdateUtils.FormatMessageList(field.Item4.Select(n => n.Location.ToString()));
return "The default value for {0}.{1} has been removed.\n".F(field.Item1, field.Item2) +
"You may wish to explicitly define `{0}: {1}` on the `{2}` trait \n".F(field.Item2, field.Item3, field.Item1) +
"definitions on the following actors (if they have not already been inherited from a parent).\n" +
UpdateUtils.FormatMessageList(field.Item4);
}

public override IEnumerable<string> AfterUpdate(ModData modData)
{
foreach (var field in fields)
{
if (field.Item4.Any())
yield return BuildMessage(field);

field.Item4.Clear();
}
}

public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
Expand All @@ -68,7 +64,7 @@ public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNod
{
var node = traitNode.LastChildMatching(field.Item2);
if (node == null)
field.Item4.Add(traitNode);
field.Item4.Add("{0} ({1})".F(actorNode.Key, traitNode.Location.Filename));
}
}

Expand Down
Expand Up @@ -22,38 +22,27 @@ public override string Description
get
{
return "HackyAI no longer automatically excludes actors with Harvester trait from attack squads.\n" +
"They need to be explicitly added to ExcludeFromSquads.";
"They need to be explicitly added to ExcludeFromSquads. HackyAI instances are listed for inspection.";
}
}

readonly List<MiniYamlNode.SourceLocation> locations = new List<MiniYamlNode.SourceLocation>();

public override IEnumerable<string> BeforeUpdate(ModData modData)
{
// Reset state for each mod/map
locations.Clear();
yield break;
}
readonly List<string> locations = new List<string>();

public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (locations.Any())
yield return "The automatic exclusion of harvesters from AI squads has been removed.\n"
+ "You may wish to add your harvester-type actors to `ExcludeFromSquads` under `UnitCommonNames`\n"
+ "at the following locations.\n"
+ UpdateUtils.FormatMessageList(locations.Select(l => l.ToString()));
yield return "The automatic exclusion of harvesters from AI squads has been removed.\n" +
"You may wish to add your harvester-type actors to `ExcludeFromSquads` under `UnitCommonNames`\n" +
"on the following definitions:\n" +
UpdateUtils.FormatMessageList(locations);

locations.Clear();
}

public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var hackyAINode in actorNode.ChildrenMatching("HackyAI"))
{
var commonNamesNode = hackyAINode.LastChildMatching("UnitsCommonNames");
if (commonNamesNode != null)
locations.Add(commonNamesNode.Location);
else
locations.Add(hackyAINode.Location);
}
locations.Add("{0} ({1})".F(hackyAINode.Key, hackyAINode.Location.Filename));

yield break;
}
Expand Down
7 changes: 3 additions & 4 deletions OpenRA.Mods.Common/UpdateRules/Rules/IgnoreAbstractActors.cs
Expand Up @@ -24,8 +24,8 @@ public override string Description
{
get
{
return "Actor ids starting with '^' are now reserved for abstract\n" +
"inheritance templates, and will not be parsed by the game.";
return "Actor ids starting with '^' are now reserved for abstract inheritance templates.\n" +
"Definitions that may be affected are listed for inspection so that they can be renamed if necessary.";
}
}

Expand Down Expand Up @@ -53,8 +53,7 @@ public override IEnumerable<string> AfterUpdate(ModData modData)
yield return "Actor ids starting with '^' are now reserved for abstract\n" +
"inheritance templates, and will not be parsed by the game.\n" +
"Check the following definitions and rename them if they are not used for inheritance:\n" +
UpdateUtils.FormatMessageList(actors.Select(n => n.Key + ":\n" +
UpdateUtils.FormatMessageList(n.Value.Select(v => v.Location.ToString()))));
UpdateUtils.FormatMessageList(actors.Select(n => n.Key + " (" + n.Value.Select(v => v.Location.Filename).JoinWith(", ") + ")"));
}
}
}
Expand Up @@ -23,7 +23,8 @@ public override string Description
get
{
return "The PaletteFromCurrentTileset trait and Palette field on TileSets have been removed.\n" +
"Terrain palettes are now explicitly defined on the world actor.";
"Terrain palettes are now explicitly defined on the world actor.\n" +
"Palette definitions are generated based on the Tileset metadata.";
}
}

Expand Down
Expand Up @@ -10,6 +10,7 @@
#endregion

using System.Collections.Generic;
using System.Linq;

namespace OpenRA.Mods.Common.UpdateRules.Rules
{
Expand All @@ -21,17 +22,29 @@ public override string Description
get
{
return "WithReloadingSpriteTurret has been superseded by conditions.\n" +
"The trait is switched for with WithSpriteTurret.";
"Instances of this trait are replaced by WithSpriteTurret.";
}
}

readonly List<string> locations = new List<string>();

public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (locations.Any())
yield return "WithReloadingSpriteTurret has been replaced by WithSpriteTurret\n" +
"You should use AmmoPool.AmmoConditions to switch turret type when reloading\n" +
"to restore the previous behaviour on the following actors:\n" +
UpdateUtils.FormatMessageList(locations);

locations.Clear();
}

public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var turret in actorNode.ChildrenMatching("WithReloadingSpriteTurret"))
{
turret.RenameKeyPreservingSuffix("WithSpriteTurret");
yield return turret.Location.ToString() + ": WithReloadingSpriteTurret has been replaced by WithSpriteTurret.\n" +
"You should use AmmoPool.AmmoConditions to switch turret type when reloading to restore the previous behaviour.";
locations.Add("{0} ({1})".F(actorNode.Key, turret.Location.Filename));
}

yield break;
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Common/UpdateRules/Rules/RenameWormSpawner.cs
Expand Up @@ -20,8 +20,8 @@ public override string Description
{
get
{
return "The D2k-specific WormSpawner trait was renamed to ActorSpawner,\n" +
"generalized, and moved into the common mod code.";
return "The D2k-specific WormSpawner trait was renamed to ActorSpawner, generalized,\n" +
"and moved into the common mod code. Uses of the old traits are updated to account for this.";
}
}

Expand Down