Skip to content

Commit

Permalink
Add support for building Palette= override introduced in RA2 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rampastring committed Jun 17, 2023
1 parent 326d0f5 commit c4167b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/TSMapEditor/Models/ArtConfig/BuildingArtConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class BuildingArtConfig : IArtConfig
public string Image { get; set; }
public string BibShape { get; set; }

/// <summary>
/// Palette override introduced in Red Alert 2.
/// </summary>
public string Palette { get; set; }

public void ReadFromIniSection(IniSection iniSection)
{
if (iniSection == null)
Expand All @@ -43,6 +48,7 @@ public void ReadFromIniSection(IniSection iniSection)
Theater = iniSection.GetBooleanValue(nameof(Theater), Theater);
Image = iniSection.GetStringValue(nameof(Image), Image);
BibShape = iniSection.GetStringValue(nameof(BibShape), BibShape);
Palette = iniSection.GetStringValue(nameof(Palette), Palette);
}

public void DoForFoundationCoords(Action<Point2D> action)
Expand Down
11 changes: 7 additions & 4 deletions src/TSMapEditor/Rendering/TheaterGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,14 @@ public void ReadBuildingTextures(List<BuildingType> buildingTypes)
}
}

// Palette override in RA2/YR
Palette palette = buildingType.ArtConfig.TerrainPalette ? theaterPalette : unitPalette;
if (!string.IsNullOrWhiteSpace(buildingType.ArtConfig.Palette))
palette = GetPaletteOrFail(buildingType.ArtConfig.Palette + Theater.FileExtension + ".pal");

var shpFile = new ShpFile();
shpFile.ParseFromBuffer(shpData);
BuildingTextures[i] = new ObjectImage(graphicsDevice, shpFile, shpData,
buildingType.ArtConfig.TerrainPalette ? theaterPalette : unitPalette, null, buildingType.ArtConfig.Remapable);
BuildingTextures[i] = new ObjectImage(graphicsDevice, shpFile, shpData, palette, null, buildingType.ArtConfig.Remapable);

// If this building has a bib, attempt to load it
if (!string.IsNullOrWhiteSpace(buildingType.ArtConfig.BibShape))
Expand Down Expand Up @@ -665,8 +669,7 @@ public void ReadBuildingTextures(List<BuildingType> buildingTypes)

var bibShpFile = new ShpFile();
bibShpFile.ParseFromBuffer(shpData);
BuildingBibTextures[i] = new ObjectImage(graphicsDevice, bibShpFile, shpData,
buildingType.ArtConfig.TerrainPalette ? theaterPalette : unitPalette, null, buildingType.ArtConfig.Remapable);
BuildingBibTextures[i] = new ObjectImage(graphicsDevice, bibShpFile, shpData, palette, null, buildingType.ArtConfig.Remapable);
}
}
}
Expand Down

0 comments on commit c4167b9

Please sign in to comment.