From 4b9c6c474669325c86fe69f2bf7dc260ba314466 Mon Sep 17 00:00:00 2001 From: rob-v Date: Tue, 23 May 2017 16:41:03 +0200 Subject: [PATCH] Allow multiple terrain (tile) categories --- OpenRA.Game/Map/TileSet.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 12 +++++++++++- .../Widgets/Logic/Editor/TileSelectorLogic.cs | 7 ++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Map/TileSet.cs b/OpenRA.Game/Map/TileSet.cs index f23ced59d5..2c5291c786 100644 --- a/OpenRA.Game/Map/TileSet.cs +++ b/OpenRA.Game/Map/TileSet.cs @@ -84,7 +84,7 @@ namespace OpenRA public readonly int[] Frames; public readonly int2 Size; public readonly bool PickAny; - public readonly string Category; + public readonly string[] Categories; public readonly string Palette; readonly TerrainTileInfo[] tileInfo; diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index d21e9fae2f..f1cceb539d 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -867,7 +867,17 @@ namespace OpenRA.Mods.Common.UtilityCommands { foreach (var node in nodes) { - // Add rules here + // Renamed Category to Categories in Template. + if (engineVersion < 20170623) + { + if (node.Key == "Template" || node.Key.StartsWith("Template@", StringComparison.Ordinal)) + { + var category = node.Value.Nodes.FirstOrDefault(n => n.Key == "Category"); + if (category != null) + category.Key = "Categories"; + } + } + UpgradeTileset(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/TileSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/TileSelectorLogic.cs index d1ebe68310..741dffb3c0 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/TileSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/TileSelectorLogic.cs @@ -56,9 +56,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic { panel.RemoveChildren(); - var tileIds = tileset.Templates - .Where(t => t.Value.Category == category) - .Select(t => t.Value.Id); + var categoryTiles = tileset.Templates.Where(t => t.Value.Categories.Contains(category)).Select(t => t.Value).ToList(); + var tileIds = categoryTiles.Where(t => t.Categories[0] == category) + .Concat(categoryTiles.Where(t => t.Categories[0] != category)) + .Select(t => t.Id); foreach (var t in tileIds) {