fixed wrong palette remapping for neutral buildings in editor

for TEMPERAT (fields) and DESERT (buildings, trees, rocks)
This commit is contained in:
Matthias Mailänder
2012-11-26 12:21:50 +01:00
parent 4e0e53c714
commit aad0b3d2d8
5 changed files with 31 additions and 15 deletions

View File

@@ -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<RenderSimpleInfo>();
// 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,

View File

@@ -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)

View File

@@ -13,6 +13,7 @@ namespace OpenRA.Traits
public class EditorAppearanceInfo : TraitInfo<EditorAppearance>
{
public readonly bool RelativeToTopLeft = false;
public readonly bool UseTerrainPalette = false;
}
public class EditorAppearance { }

View File

@@ -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:

View File

@@ -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