diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 9029e94af2..7995bdad39 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -140,10 +140,8 @@ namespace OpenRA.Editor tileset.LoadTiles(); int[] ShadowIndex = { 3, 4 }; var palette = new Palette(FileSystem.Open(tileset.Palette), ShadowIndex); - /* PlayerPalette is only used in RA desert terrain - * TODO: use the palette as defined in YAML - * defaults are wrong for DESERT rocks, trees, walls and ore mine - */ + + // required for desert terrain in RA var playerPalette = tileset.PlayerPalette ?? tileset.Palette; var PlayerPalette = new Palette(FileSystem.Open(playerPalette), ShadowIndex); @@ -217,7 +215,13 @@ namespace OpenRA.Editor if (etf != null && etf.RequireTilesets != null && !etf.RequireTilesets.Contains(tileset.Id)) continue; - var template = RenderUtils.RenderActor(info, tileset, PlayerPalette); + var TemplatePalette = PlayerPalette; + var rsi = info.Traits.GetOrDefault(); + // exception for desert buildings + if (rsi != null && rsi.Palette != null && rsi.Palette.Contains("terrain")) + TemplatePalette = palette; + + var template = RenderUtils.RenderActor(info, tileset, TemplatePalette); var ibox = new PictureBox { Image = template.Bitmap, diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 63a5113c39..86222c192d 100755 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -308,7 +308,10 @@ namespace OpenRA.Editor public void DrawActor(SGraphics g, CPos p, ActorTemplate t, ColorPalette cp) { var centered = t.Appearance == null || !t.Appearance.RelativeToTopLeft; - DrawImage(g, t.Bitmap, p, centered, cp); + var actorPalette = cp; + if (t.Appearance != null && t.Appearance.UseTerrainPalette) + actorPalette = Palette.AsSystemPalette(); + DrawImage(g, t.Bitmap, p, centered, actorPalette); } float2 GetDrawPosition(CPos location, Bitmap bmp, bool centered) diff --git a/OpenRA.Game/Traits/EditorAppearance.cs b/OpenRA.Game/Traits/EditorAppearance.cs index 755a63524a..13d7ba24a8 100644 --- a/OpenRA.Game/Traits/EditorAppearance.cs +++ b/OpenRA.Game/Traits/EditorAppearance.cs @@ -13,6 +13,7 @@ namespace OpenRA.Traits public class EditorAppearanceInfo : TraitInfo { public readonly bool RelativeToTopLeft = false; + public readonly bool UseTerrainPalette = false; } public class EditorAppearance { } diff --git a/mods/ra/rules/civilian.yaml b/mods/ra/rules/civilian.yaml index c05beecec1..8d37d0f48c 100644 --- a/mods/ra/rules/civilian.yaml +++ b/mods/ra/rules/civilian.yaml @@ -1,5 +1,5 @@ FCOM: - Inherits: ^CivBuilding + Inherits: ^TechBuilding Building: Power: -200 Footprint: xx xx @@ -15,7 +15,7 @@ FCOM: Bib: HOSP: - Inherits: ^CivBuilding + Inherits: ^TechBuilding Building: Footprint: xx xx Dimensions: 2,2 @@ -170,7 +170,7 @@ V18: ExcludeTilesets: DESERT BARL: - Inherits: ^CivBuilding + Inherits: ^TechBuilding Selectable: Priority: 0 Health: @@ -181,7 +181,7 @@ BARL: Name: Explosive Barrel BRL3: - Inherits: ^CivBuilding + Inherits: ^TechBuilding Selectable: Priority: 0 Health: @@ -192,7 +192,7 @@ BRL3: Name: Explosive Barrel MISS: - Inherits: ^CivBuilding + Inherits: ^TechBuilding Selectable: Priority: 0 Building: @@ -205,7 +205,7 @@ MISS: Bib: BIO: - Inherits: ^CivBuilding + Inherits: ^TechBuilding Building: Footprint: xx xx Dimensions: 2,2 @@ -214,7 +214,7 @@ BIO: OILB: - Inherits: ^CivBuilding + Inherits: ^TechBuilding Selectable: Priority: 0 Building: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index e711b52911..f134028c97 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -237,12 +237,13 @@ GivesExperience: EditorAppearance: RelativeToTopLeft: yes + UseTerrainPalette: true AutoTargetIgnore: ProximityCaptor: Types:Wall Sellable: -^CivBuilding: +^TechBuilding: Inherits: ^Building -RepairableBuilding: Health: @@ -259,6 +260,11 @@ -Capturable: -CapturableBar: +^CivBuilding: + Inherits: ^TechBuilding + EditorAppearance: + UseTerrainPalette: true + ^CivField: Inherits: ^CivBuilding -Selectable: @@ -281,6 +287,7 @@ Terrain: Tree EditorAppearance: RelativeToTopLeft: yes + UseTerrainPalette: true ProximityCaptor: Types:Tree @@ -369,10 +376,11 @@ Terrain: Tree EditorAppearance: RelativeToTopLeft: yes + UseTerrainPalette: true ProximityCaptor: Types:Tree -^DesertCivBuilding +^DesertCivBuilding: Inherits: ^CivBuilding RenderBuilding: Palette: terrain