diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index cdb8792ba6..521f5b9b89 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -103,7 +103,7 @@ namespace OpenRA.Editor Rules.LoadRules(manifest, map); tileset = Rules.TileSets[map.Theater]; tileset.LoadTiles(); - var palette = new Palette(FileSystem.Open(map.Theater.ToLowerInvariant() + ".pal"), true); + var palette = new Palette(FileSystem.Open(tileset.Palette), true); surface1.Bind(map, tileset, palette); diff --git a/OpenRA.FileFormats/Map/TileSet.cs b/OpenRA.FileFormats/Map/TileSet.cs index c2a45c93bc..7dd6c6d158 100644 --- a/OpenRA.FileFormats/Map/TileSet.cs +++ b/OpenRA.FileFormats/Map/TileSet.cs @@ -61,6 +61,7 @@ namespace OpenRA.FileFormats { public readonly string Name; public readonly string Id; + public readonly string Palette; public readonly string[] Extensions; public readonly Dictionary Terrain = new Dictionary(); public readonly Dictionary Tiles = new Dictionary(); diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index e26f13fc40..ee26a4b4b4 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -204,6 +204,7 @@ + diff --git a/OpenRA.Mods.RA/PaletteFromCurrentTheatre.cs b/OpenRA.Mods.RA/PaletteFromCurrentTheatre.cs new file mode 100644 index 0000000000..8cf6267f0e --- /dev/null +++ b/OpenRA.Mods.RA/PaletteFromCurrentTheatre.cs @@ -0,0 +1,42 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it 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. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using OpenRA.FileFormats; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class PaletteFromCurrentTheatreInfo : ITraitInfo + { + public readonly string Name = null; + public readonly bool Transparent = true; + + public object Create(ActorInitializer init) { return new PaletteFromCurrentTheatre(init.world, this); } + } + + class PaletteFromCurrentTheatre + { + public PaletteFromCurrentTheatre(World world, PaletteFromCurrentTheatreInfo info) + { + world.WorldRenderer.AddPalette(info.Name, + new Palette(FileSystem.Open(world.TileSet.Palette), info.Transparent)); + } + } +} diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml index a23d85604b..0f45228575 100644 --- a/mods/cnc/system.yaml +++ b/mods/cnc/system.yaml @@ -51,18 +51,8 @@ World: # HazardLayer: BridgeLayer: Bridges: bridge1, bridge2, bridge3, bridge4 - PaletteFromFile@terrain_desert: + PaletteFromCurrentTheatre: Name: terrain - Theater: desert - Filename: desert.pal - PaletteFromFile@terrain_temperate: - Name: terrain - Theater: temperat - Filename: temperat.pal - PaletteFromFile@terrain_winter: - Name: terrain - Theater: winter - Filename: winter.pal PlayerColorPalette@player0: Name: player0 DisplayName: Gold diff --git a/mods/cnc/tileset-des.yaml b/mods/cnc/tileset-des.yaml index 6f9aab9877..24e41c02b4 100644 --- a/mods/cnc/tileset-des.yaml +++ b/mods/cnc/tileset-des.yaml @@ -2,6 +2,7 @@ General: Name: Desert Id: DESERT Extensions: .des, .shp, .tem + Palette: desert.pal Terrain: TerrainType@Clear: diff --git a/mods/cnc/tileset-tem.yaml b/mods/cnc/tileset-tem.yaml index 9c1a9fade4..4e6bcd811a 100644 --- a/mods/cnc/tileset-tem.yaml +++ b/mods/cnc/tileset-tem.yaml @@ -2,6 +2,7 @@ General: Name: Temperate Id: TEMPERAT Extensions: .tem, .shp + Palette: temperat.pal Terrain: TerrainType@Clear: diff --git a/mods/cnc/tileset-win.yaml b/mods/cnc/tileset-win.yaml index 3381801e1c..1989b41b80 100644 --- a/mods/cnc/tileset-win.yaml +++ b/mods/cnc/tileset-win.yaml @@ -2,6 +2,7 @@ General: Name: Winter Id: WINTER Extensions: .win, .shp, .tem + Palette: winter.pal Terrain: TerrainType@Clear: diff --git a/mods/ra/system.yaml b/mods/ra/system.yaml index 57f17601d6..1fae31fe74 100644 --- a/mods/ra/system.yaml +++ b/mods/ra/system.yaml @@ -101,12 +101,8 @@ World: Maximum: 3 SpawnInterval: 120 WaterChance: .2 - PaletteFromFile@terrain_temperat: + PaletteFromCurrentTheatre: Name: terrain - Filename: temperat.pal - PaletteFromFile@terrain_snow: - Name: snow - Filename: snow.pal PlayerColorPalette@player0: Name: player0 DisplayName: Gold diff --git a/mods/ra/tileset-int.yaml b/mods/ra/tileset-int.yaml index 9f21ebc791..1952a4abfe 100644 --- a/mods/ra/tileset-int.yaml +++ b/mods/ra/tileset-int.yaml @@ -2,6 +2,7 @@ General: Name: Interior Id: INTERIOR Extensions: .int, .shp, .tem + Palette: interior.pal Terrain: TerrainType@Clear: diff --git a/mods/ra/tileset-sno.yaml b/mods/ra/tileset-sno.yaml index f62ed77b38..5fed364732 100644 --- a/mods/ra/tileset-sno.yaml +++ b/mods/ra/tileset-sno.yaml @@ -2,6 +2,7 @@ General: Name: Snow Id: SNOW Extensions: .sno, .shp, .tem + Palette: snow.pal Terrain: TerrainType@Clear: diff --git a/mods/ra/tileset-tem.yaml b/mods/ra/tileset-tem.yaml index 1e5d8e35d8..45003878ef 100644 --- a/mods/ra/tileset-tem.yaml +++ b/mods/ra/tileset-tem.yaml @@ -2,6 +2,7 @@ General: Name: Temperate Id: TEMPERAT Extensions: .tem, .shp + Palette: temperat.pal Terrain: TerrainType@Clear: