Skip to content

Commit

Permalink
Add generic building graphics fallback (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortonPL committed Jun 17, 2023
1 parent 14c8385 commit c267521
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/TSMapEditor/Config/Constants.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ GameRegistryInstallPath=SOFTWARE\DawnOfTheTiberiumAge
; from Vinifera/Ares instead of the old DTA 32 facings hack?
AdvancedFacingsHack=true

; Is NewTheater generic fallback (letter G) available?
NewTheaterGenericBuilding=false

; Paths to various files that the editor loads
[FilePaths]
Expand Down
4 changes: 4 additions & 0 deletions src/TSMapEditor/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static class Constants

public static bool IsFlatWorld = false;
public static bool TheaterPaletteForTiberium = false;
public static bool NewTheaterGenericBuilding = false;

public static string ExpectedClientExecutableName = "DTA.exe";
public static string GameRegistryInstallPath = "SOFTWARE\\DawnOfTheTiberiumAge";
Expand Down Expand Up @@ -72,6 +73,8 @@ public static class Constants
public const string ClipboardMapDataFormatValue = "ScenarioEditorCopiedMapData";
public const string UserDataFolder = "UserData";

public const char NewTheaterGenericLetter = 'G';

public static void Init()
{
const string ConstantsSectionName = "Constants";
Expand All @@ -90,6 +93,7 @@ public static void Init()

IsFlatWorld = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(IsFlatWorld), IsFlatWorld);
TheaterPaletteForTiberium = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(TheaterPaletteForTiberium), TheaterPaletteForTiberium);
NewTheaterGenericBuilding = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(NewTheaterGenericBuilding), NewTheaterGenericBuilding);
ExpectedClientExecutableName = constantsIni.GetStringValue(ConstantsSectionName, nameof(ExpectedClientExecutableName), ExpectedClientExecutableName);
GameRegistryInstallPath = constantsIni.GetStringValue(ConstantsSectionName, nameof(GameRegistryInstallPath), GameRegistryInstallPath);

Expand Down
8 changes: 8 additions & 0 deletions src/TSMapEditor/Rendering/TheaterGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,14 @@ public void ReadBuildingTextures(List<BuildingType> buildingTypes)
shpData = fileManager.LoadFile(newTheaterShpName);
}

// Support generic building letter
if (Constants.NewTheaterGenericBuilding && shpData == null)
{
string newTheaterShpName = shpFileName.Substring(0, 1) + Constants.NewTheaterGenericLetter + shpFileName.Substring(2);

shpData = fileManager.LoadFile(newTheaterShpName);
}

// The game can apparently fall back to the non-theater-specific SHP file name
// if the theater-specific SHP is not found
if (shpData == null)
Expand Down

0 comments on commit c267521

Please sign in to comment.