diff --git a/OpenRA.Game/Map/TileSet.cs b/OpenRA.Game/Map/TileSet.cs index 0d2dae30e6..05b692d434 100644 --- a/OpenRA.Game/Map/TileSet.cs +++ b/OpenRA.Game/Map/TileSet.cs @@ -184,7 +184,6 @@ namespace OpenRA public readonly string Name; public readonly string Id; public readonly int SheetSize = 512; - public readonly string Palette; public readonly Color[] HeightDebugColors = new[] { Color.Red }; public readonly string[] EditorTemplateOrder; public readonly bool IgnoreTileSpriteOffsets; @@ -234,11 +233,10 @@ namespace OpenRA .Select(y => new TerrainTemplateInfo(this, y)).ToDictionary(t => t.Id).AsReadOnly(); } - public TileSet(string name, string id, string palette, TerrainTypeInfo[] terrainInfo) + public TileSet(string name, string id, TerrainTypeInfo[] terrainInfo) { Name = name; Id = id; - Palette = palette; TerrainInfo = terrainInfo; if (TerrainInfo.Length >= byte.MaxValue) diff --git a/OpenRA.Mods.Cnc/UtilityCommands/LegacyRulesImporter.cs b/OpenRA.Mods.Cnc/UtilityCommands/LegacyRulesImporter.cs index 62aae49658..93200bfcf1 100644 --- a/OpenRA.Mods.Cnc/UtilityCommands/LegacyRulesImporter.cs +++ b/OpenRA.Mods.Cnc/UtilityCommands/LegacyRulesImporter.cs @@ -191,14 +191,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands Console.WriteLine("\tRenderSprites:"); if (useTerrainPalette) - { - if (Game.ModData.DefaultRules.Actors.ContainsKey("world")) - { - var terrainPaletteDefintion = Game.ModData.DefaultRules.Actors["world"].TraitInfos(); - if (terrainPaletteDefintion.Any()) - Console.WriteLine("\t\tPalette: " + terrainPaletteDefintion.Last().Name); - } - } + Console.WriteLine("\t\tPalette: terrain"); var image = rulesSection.GetValue("Image", string.Empty); if (!string.IsNullOrEmpty(image) && image != "none") diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 647dc2c5b4..b1835e72b2 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -537,7 +537,6 @@ - @@ -863,6 +862,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/World/PaletteFromCurrentTileset.cs b/OpenRA.Mods.Common/Traits/World/PaletteFromCurrentTileset.cs deleted file mode 100644 index b6999d95a4..0000000000 --- a/OpenRA.Mods.Common/Traits/World/PaletteFromCurrentTileset.cs +++ /dev/null @@ -1,51 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2018 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 OpenRA.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("Loads the palette specified in the tileset definition")] - public class PaletteFromCurrentTilesetInfo : ITraitInfo - { - [FieldLoader.Require, PaletteDefinition] - [Desc("internal palette name")] - public readonly string Name = null; - - [Desc("Map listed indices to shadow. Ignores previous color.")] - public readonly int[] ShadowIndex = { }; - - public readonly bool AllowModifiers = true; - - public object Create(ActorInitializer init) { return new PaletteFromCurrentTileset(init.World, this); } - } - - public class PaletteFromCurrentTileset : ILoadsPalettes, IProvidesAssetBrowserPalettes - { - readonly World world; - readonly PaletteFromCurrentTilesetInfo info; - - public PaletteFromCurrentTileset(World world, PaletteFromCurrentTilesetInfo info) - { - this.world = world; - this.info = info; - } - - public void LoadPalettes(WorldRenderer wr) - { - wr.AddPalette(info.Name, new ImmutablePalette(wr.World.Map.Open(world.Map.Rules.TileSet.Palette), info.ShadowIndex), info.AllowModifiers); - } - - public IEnumerable PaletteNames { get { yield return info.Name; } } - } -} diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/RemovePaletteFromCurrentTileset.cs b/OpenRA.Mods.Common/UpdateRules/Rules/RemovePaletteFromCurrentTileset.cs new file mode 100644 index 0000000000..98218f92d9 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/RemovePaletteFromCurrentTileset.cs @@ -0,0 +1,88 @@ +#region Copyright & License Information +/* + * Copyright 2007-2018 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 RemovePaletteFromCurrentTileset : UpdateRule + { + public override string Name { get { return "Remove PaletteFromCurrentTileset trait"; } } + 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."; + } + } + + readonly Dictionary tilesetPalettes = new Dictionary(); + readonly List> paletteTraits = new List>(); + + string BuildYaml(string palette, int[] shadow, string tileset, string filename) + { + return "PaletteFromFile@{0}:\n Name: {1}\n Tileset: {2}\n Filename: {3}\n ShadowIndex: {4}".F( + palette + '-' + tileset.ToLower(), palette, tileset, filename, FieldSaver.FormatValue(shadow)); + } + + public override IEnumerable AfterUpdate(ModData modData) + { + if (tilesetPalettes.Any() && paletteTraits.Any()) + yield return "You must add the following to your palette definitions:\n" + + paletteTraits.Select(p => tilesetPalettes.Select(kv => + BuildYaml(p.Item1, p.Item2, kv.Key, kv.Value)).JoinWith("\n")).JoinWith("\n"); + + paletteTraits.Clear(); + yield break; + } + + public override IEnumerable UpdateTilesetNode(ModData modData, MiniYamlNode tilesetNode) + { + if (tilesetNode.Key == "General") + { + var idNode = tilesetNode.LastChildMatching("Id"); + if (idNode == null) + yield break; + + var paletteNode = tilesetNode.LastChildMatching("Palette"); + if (paletteNode != null) + tilesetPalettes[idNode.Value.Value] = paletteNode.Value.Value; + + tilesetNode.RemoveNodes("Palette"); + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + foreach (var paletteNode in actorNode.ChildrenMatching("PaletteFromCurrentTileset")) + { + var name = "terrain"; + var shadow = new int[] { }; + + var shadowNode = paletteNode.LastChildMatching("ShadowIndex"); + if (shadowNode != null) + shadow = shadowNode.NodeValue(); + + var nameNode = paletteNode.LastChildMatching("Name"); + if (nameNode != null) + name = nameNode.Value.Value; + + paletteTraits.Add(Tuple.Create(name, shadow)); + } + + actorNode.RemoveNodes("PaletteFromCurrentTileset"); + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index fdb866e174..4b4f375828 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -46,7 +46,8 @@ namespace OpenRA.Mods.Common.UpdateRules new RenameWormSpawner(), new RemoveWithReloadingSpriteTurret(), new IgnoreAbstractActors(), - new AddEditorPlayer() + new AddEditorPlayer(), + new RemovePaletteFromCurrentTileset() }) }; diff --git a/mods/cnc/rules/palettes.yaml b/mods/cnc/rules/palettes.yaml index 3db222a8ba..7823792e4b 100644 --- a/mods/cnc/rules/palettes.yaml +++ b/mods/cnc/rules/palettes.yaml @@ -1,9 +1,53 @@ ^Palettes: - PaletteFromCurrentTileset@terrain: + PaletteFromFile@terrain-desert: Name: terrain + Tileset: DESERT + Filename: desert.pal ShadowIndex: 4 - PaletteFromCurrentTileset@static: + PaletteFromFile@terrain-winter: + Name: terrain + Tileset: WINTER + Filename: winter.pal + ShadowIndex: 4 + PaletteFromFile@terrain-snow: + Name: terrain + Tileset: SNOW + Filename: snow.pal + ShadowIndex: 4 + PaletteFromFile@terrain-temperat: + Name: terrain + Tileset: TEMPERAT + Filename: temperat.pal + ShadowIndex: 4 + PaletteFromFile@terrain-jungle: + Name: terrain + Tileset: JUNGLE + Filename: jungle.pal + ShadowIndex: 4 + PaletteFromFile@staticterrain-desert: Name: staticterrain + Tileset: DESERT + Filename: desert.pal + ShadowIndex: 4 + PaletteFromFile@staticterrain-winter: + Name: staticterrain + Tileset: WINTER + Filename: winter.pal + ShadowIndex: 4 + PaletteFromFile@staticterrain-snow: + Name: staticterrain + Tileset: SNOW + Filename: snow.pal + ShadowIndex: 4 + PaletteFromFile@staticterrain-temperat: + Name: staticterrain + Tileset: TEMPERAT + Filename: temperat.pal + ShadowIndex: 4 + PaletteFromFile@staticterrain-jungle: + Name: staticterrain + Tileset: JUNGLE + Filename: jungle.pal ShadowIndex: 4 PaletteFromFile@chrome: Name: chrome diff --git a/mods/cnc/tilesets/desert.yaml b/mods/cnc/tilesets/desert.yaml index 1470d0ae92..1ac8fa00a8 100644 --- a/mods/cnc/tilesets/desert.yaml +++ b/mods/cnc/tilesets/desert.yaml @@ -1,7 +1,6 @@ General: Name: Desert Id: DESERT - Palette: desert.pal EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge HeightDebugColors: 880000 diff --git a/mods/cnc/tilesets/jungle.yaml b/mods/cnc/tilesets/jungle.yaml index ab2ad6c869..5d52611750 100644 --- a/mods/cnc/tilesets/jungle.yaml +++ b/mods/cnc/tilesets/jungle.yaml @@ -1,7 +1,6 @@ General: Name: Jungle Id: JUNGLE - Palette: jungle.pal EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge HeightDebugColors: AA0000 diff --git a/mods/cnc/tilesets/snow.yaml b/mods/cnc/tilesets/snow.yaml index b0edb351e4..35ce112a9c 100644 --- a/mods/cnc/tilesets/snow.yaml +++ b/mods/cnc/tilesets/snow.yaml @@ -1,7 +1,6 @@ General: Name: Snow Id: SNOW - Palette: snow.pal EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge HeightDebugColors: 880000 diff --git a/mods/cnc/tilesets/temperat.yaml b/mods/cnc/tilesets/temperat.yaml index afb0a93edc..8ed46c0fe0 100644 --- a/mods/cnc/tilesets/temperat.yaml +++ b/mods/cnc/tilesets/temperat.yaml @@ -1,7 +1,6 @@ General: Name: Temperate Id: TEMPERAT - Palette: temperat.pal EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge HeightDebugColors: AA0000 diff --git a/mods/cnc/tilesets/winter.yaml b/mods/cnc/tilesets/winter.yaml index 1d53e74f48..ec1362db20 100644 --- a/mods/cnc/tilesets/winter.yaml +++ b/mods/cnc/tilesets/winter.yaml @@ -1,7 +1,6 @@ General: Name: Winter Id: WINTER - Palette: winter.pal EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Beach, River, Bridge HeightDebugColors: 880000 diff --git a/mods/d2k/rules/palettes.yaml b/mods/d2k/rules/palettes.yaml index 9fac9205e8..2600050e5a 100644 --- a/mods/d2k/rules/palettes.yaml +++ b/mods/d2k/rules/palettes.yaml @@ -1,6 +1,7 @@ ^Palettes: - PaletteFromCurrentTileset: + PaletteFromFile: Name: terrain + Filename: PALETTE.BIN PaletteFromFile@d2k: Name: d2k Filename: PALETTE.BIN diff --git a/mods/d2k/tilesets/arrakis.yaml b/mods/d2k/tilesets/arrakis.yaml index 7aacd1c919..c6570dcd59 100644 --- a/mods/d2k/tilesets/arrakis.yaml +++ b/mods/d2k/tilesets/arrakis.yaml @@ -2,7 +2,6 @@ General: Name: Arrakis Id: ARRAKIS SheetSize: 1024 - Palette: PALETTE.BIN EditorTemplateOrder: Basic, Dune, Sand-Detail, Rock-Detail, Ice-Detail, Rock-Sand-Smooth, Sand-Sand-Cliff, Sand-Rock-Cliff, Sand-Ice-Cliff, Rock-Rock-Cliff, Rock-Sand-Cliff, Cliff-Type-Changer, Cliff-Ends, Sand-Platform, Bridge, Rotten-Base, Dead-Worm, Unidentified IgnoreTileSpriteOffsets: True HeightDebugColors: 880000 diff --git a/mods/ra/rules/palettes.yaml b/mods/ra/rules/palettes.yaml index 58952c913a..4aa12f235b 100644 --- a/mods/ra/rules/palettes.yaml +++ b/mods/ra/rules/palettes.yaml @@ -1,11 +1,28 @@ ^Palettes: + PaletteFromFile@terrain-snow: + Name: terrain + Tileset: SNOW + Filename: snow.pal + ShadowIndex: 3, 4 + PaletteFromFile@terrain-interior: + Name: terrain + Tileset: INTERIOR + Filename: interior.pal + ShadowIndex: 3, 4 + PaletteFromFile@terrain-temperat: + Name: terrain + Tileset: TEMPERAT + Filename: temperat.pal + ShadowIndex: 3, 4 + PaletteFromFile@terrain-desert: + Name: terrain + Tileset: DESERT + Filename: desert.pal + ShadowIndex: 3, 4 PaletteFromFile@player: Name: player Filename: temperat.pal ShadowIndex: 4 - PaletteFromCurrentTileset: - Name: terrain - ShadowIndex: 3,4 PaletteFromFile@chrome: Name: chrome Filename: temperat.pal diff --git a/mods/ra/tilesets/desert.yaml b/mods/ra/tilesets/desert.yaml index 205d22bfd7..9b734fe94d 100644 --- a/mods/ra/tilesets/desert.yaml +++ b/mods/ra/tilesets/desert.yaml @@ -1,7 +1,6 @@ General: Name: Desert Id: DESERT - Palette: desert.pal EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Water Cliffs, Beach, River, Bridge HeightDebugColors: 880000 diff --git a/mods/ra/tilesets/interior.yaml b/mods/ra/tilesets/interior.yaml index 49d3df54f0..e6c2efdd18 100644 --- a/mods/ra/tilesets/interior.yaml +++ b/mods/ra/tilesets/interior.yaml @@ -1,7 +1,6 @@ General: Name: Interior Id: INTERIOR - Palette: interior.pal EditorTemplateOrder: Floor, Wall HeightDebugColors: 880000 diff --git a/mods/ra/tilesets/snow.yaml b/mods/ra/tilesets/snow.yaml index 250c37c558..6deb23b421 100644 --- a/mods/ra/tilesets/snow.yaml +++ b/mods/ra/tilesets/snow.yaml @@ -1,7 +1,6 @@ General: Name: Snow Id: SNOW - Palette: snow.pal EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Water Cliffs, Beach, River, Bridge HeightDebugColors: 880000 diff --git a/mods/ra/tilesets/temperat.yaml b/mods/ra/tilesets/temperat.yaml index e45f5f2ef0..18e65cc9d0 100644 --- a/mods/ra/tilesets/temperat.yaml +++ b/mods/ra/tilesets/temperat.yaml @@ -1,7 +1,6 @@ General: Name: Temperate Id: TEMPERAT - Palette: temperat.pal SheetSize: 1024 EditorTemplateOrder: Terrain, Debris, Road, Cliffs, Water Cliffs, Beach, River, Bridge HeightDebugColors: AA0000 diff --git a/mods/ts/rules/palettes.yaml b/mods/ts/rules/palettes.yaml index d756745c79..702a0e3fc1 100644 --- a/mods/ts/rules/palettes.yaml +++ b/mods/ts/rules/palettes.yaml @@ -2,6 +2,24 @@ PaletteFromFile@mouse: Name: mouse Filename: mousepal.pal + PaletteFromFile@terraintem: + Name: terrain + Tileset: TEMPERATE + Filename: isotem.pal + PaletteFromFile@terrainsno: + Name: terrain + Tileset: SNOW + Filename: isosno.pal + PaletteFromFile@terraindectem: + Name: terraindecoration + Tileset: TEMPERATE + Filename: isotem.pal + ShadowIndex: 1 + PaletteFromFile@terraindecsno: + Name: terraindecoration + Tileset: SNOW + Filename: isosno.pal + ShadowIndex: 1 PaletteFromFile@playersno: Name: player Tileset: SNOW @@ -15,11 +33,6 @@ PaletteFromFile@depth: Name: depth Filename: depth.pal - PaletteFromCurrentTileset: - Name: terrain - PaletteFromCurrentTileset@decoration: - Name: terraindecoration - ShadowIndex: 1 PaletteFromFile@chrome: Name: chrome Filename: cameo.pal diff --git a/mods/ts/tilesets/snow.yaml b/mods/ts/tilesets/snow.yaml index 6f2b9916e4..3303ee73ff 100644 --- a/mods/ts/tilesets/snow.yaml +++ b/mods/ts/tilesets/snow.yaml @@ -1,7 +1,6 @@ General: Name: Snow Id: SNOW - Palette: isosno.pal HeightDebugColors: 00000080, 00004480, 00008880, 0000CC80, 0000FF80, 4400CC80, 88008880, CC004480, FF110080, FF550080, FF990080, FFDD0080, DDFF0080, 99FF0080, 55FF0080, 11FF0080 EditorTemplateOrder: Bendy Dirt Roads, Blank, Bridges, Civilian Buildings, Clear, Clear/Rough LAT, Cliff Pieces, Cliff Set, Cliff/Water pieces, Dead Oil Tanker, Destroyable Cliffs, Dirt Road Junctions, Dirt Road Slopes, DirtTrackTunnel Floor, DirtTunnel Floor, Grey/Clear LAT, House, Ice 01, Ice 02, Ice 03, Ice Flow, Ice Ramps, Ice shore, Misc Buildings, Monorail Slopes, Paved Road Ends, Paved Road Slopes, Paved Roads, Pavement, Pavement (Use for LAT), Pavement/Clear LAT, Ramp edge fixup, Rough ground, Rough lat, Ruins, Shore Pieces, Slope Set Pieces, Straight Dirt Roads, TrackTunnel Floor, TrainBridges, Tunnel Side, Tunnels, Water, Water slopes, Waterfalls, Waterfalls-B, Waterfalls-C, Waterfalls-D SheetSize: 2048 diff --git a/mods/ts/tilesets/temperate.yaml b/mods/ts/tilesets/temperate.yaml index e474329c6c..33389fab38 100644 --- a/mods/ts/tilesets/temperate.yaml +++ b/mods/ts/tilesets/temperate.yaml @@ -1,7 +1,6 @@ General: Name: Temperate Id: TEMPERATE - Palette: isotem.pal HeightDebugColors: 00000080, 00004480, 00008880, 0000CC80, 0000FF80, 4400CC80, 88008880, CC004480, FF110080, FF550080, FF990080, FFDD0080, DDFF0080, 99FF0080, 55FF0080, 11FF0080 EditorTemplateOrder: Misc Buildings, Clear, Cliff Pieces, Ice Flow, House, Blank, Ice Ramps, Cliff Set, Civilian Buildings, Shore Pieces, Rough LAT tile, Clear/Rough LAT, Cliff/Water pieces, Bendy Dirt Roads, Dirt Road Junctions, Straight Dirt Roads, Bridges, Paved Roads, Water, Dirt Road Slopes, Slope Set Pieces, Dead Oil Tanker, Ruins, Waterfalls, Ground 01, Ground 02, Sand, Sand/Clear LAT, Rough ground, Paved Road Ends, TrainBridges, Pavement, Pavement/Clear LAT, Paved road bits, Green, Green/Clear LAT, Ramp edge fixup, Water slopes, Pavement (Use for LAT), Paved Road Slopes, Monorail Slopes, Waterfalls-B, Waterfalls-C, Waterfalls-D, Tunnel Floor, Tunnel Side, TrackTunnel Floor, Destroyable Cliffs, Water Caves, Scrin Wreckage, DirtTrackTunnel Floor, DirtTunnel Floor, Crystal LAT tile, Clear Crystal LAT, Swampy, Swampy LAT, Blue Mold, Blue Mold LAT, Crystal Cliff, Kodiak Crash SheetSize: 2048