diff --git a/src/TSMapEditor/Config/Constants.ini b/src/TSMapEditor/Config/Constants.ini index ea3c5e3d..3f313392 100644 --- a/src/TSMapEditor/Config/Constants.ini +++ b/src/TSMapEditor/Config/Constants.ini @@ -47,8 +47,9 @@ TerrainPaletteBuildingsAffectedByLighting=true ; Should voxel models be affected by map lighting? VoxelsAffectedByLighting=false -; The file name of the executable that the map editor expects to find from the game directory. +; The file name(s) of the executable file(s) that the map editor tries to find from the game directory. ; Used for the verification that the user has given us the correct game directory. +; You can input multiple executable names by separating them with a comma (,). ExpectedClientExecutableName=DTA.exe ; Specifies the path(s) that we should check in the Windows registry to determine diff --git a/src/TSMapEditor/Constants.cs b/src/TSMapEditor/Constants.cs index 5aaf0bce..66918358 100644 --- a/src/TSMapEditor/Constants.cs +++ b/src/TSMapEditor/Constants.cs @@ -28,7 +28,7 @@ public static class Constants public static bool WarnOfTooManyTriggerActions = true; public static bool DefaultPreview = false; - public static string ExpectedClientExecutableName = "DTA.exe"; + public static string[] ExpectedClientExecutableNames = new string[] { "DTA.exe" }; public static string GameRegistryInstallPath = "SOFTWARE\\DawnOfTheTiberiumAge"; public static string OpenFileDialogFilter = "TS maps|*.map|All files|*.*"; @@ -143,7 +143,12 @@ public static void Init() WarnOfTooManyTriggerActions = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(WarnOfTooManyTriggerActions), WarnOfTooManyTriggerActions); DefaultPreview = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(DefaultPreview), DefaultPreview); - ExpectedClientExecutableName = constantsIni.GetStringValue(ConstantsSectionName, nameof(ExpectedClientExecutableName), ExpectedClientExecutableName); + // Check two keys for backwards compatibility + if (constantsIni.KeyExists(ConstantsSectionName, "ExpectedClientExecutableName")) + ExpectedClientExecutableNames = constantsIni.GetSection(ConstantsSectionName).GetListValue("ExpectedClientExecutableName", ',', s => s).ToArray(); + else + ExpectedClientExecutableNames = constantsIni.GetSection(ConstantsSectionName).GetListValue(nameof(ExpectedClientExecutableNames), ',', s => s).ToArray(); + GameRegistryInstallPath = constantsIni.GetStringValue(ConstantsSectionName, nameof(GameRegistryInstallPath), GameRegistryInstallPath); OpenFileDialogFilter = constantsIni.GetStringValue(ConstantsSectionName, nameof(OpenFileDialogFilter), OpenFileDialogFilter); diff --git a/src/TSMapEditor/Models/ArtConfig/VehicleArtConfig.cs b/src/TSMapEditor/Models/ArtConfig/VehicleArtConfig.cs index 04cef5aa..610b528c 100644 --- a/src/TSMapEditor/Models/ArtConfig/VehicleArtConfig.cs +++ b/src/TSMapEditor/Models/ArtConfig/VehicleArtConfig.cs @@ -39,7 +39,7 @@ public void ReadFromIniSection(IniSection iniSection) // Hackity hackity hack hack // In DTA WalkFrames defaults to 1 instead of 15 - if (Constants.ExpectedClientExecutableName == "DTA.exe") + if (Constants.ExpectedClientExecutableNames[0] == "DTA.exe") WalkFrames = 1; WalkFrames = iniSection.GetIntValue(nameof(WalkFrames), WalkFrames); diff --git a/src/TSMapEditor/UI/MainMenu.cs b/src/TSMapEditor/UI/MainMenu.cs index 67af48e6..3a856e3a 100644 --- a/src/TSMapEditor/UI/MainMenu.cs +++ b/src/TSMapEditor/UI/MainMenu.cs @@ -68,8 +68,7 @@ public override void Initialize() #if DEBUG // When debugging we might often switch between configs - make it a bit more convenient - string expectedPath = Path.Combine(tbGameDirectory.Text, Constants.ExpectedClientExecutableName); - if (!File.Exists(expectedPath)) + if (!VerifyGameDirectory()) { ReadGameInstallDirectoryFromRegistry(); } @@ -304,8 +303,14 @@ private void ReadGameInstallDirectoryFromRegistry() tbGameDirectory.Text = valueAsString; } - if (File.Exists(Path.Combine(tbGameDirectory.Text, Constants.ExpectedClientExecutableName))) - isValid = true; + foreach (string expectedExecutableName in Constants.ExpectedClientExecutableNames) + { + if (File.Exists(Path.Combine(tbGameDirectory.Text, expectedExecutableName))) + { + isValid = true; + break; + } + } } key.Close(); @@ -332,13 +337,28 @@ private void LbFileList_FileDoubleLeftClick(object sender, EventArgs e) BtnLoad_LeftClick(this, EventArgs.Empty); } + private bool VerifyGameDirectory() + { + bool gameDirectoryVerified = false; + foreach (string expectedExecutableName in Constants.ExpectedClientExecutableNames) + { + if (File.Exists(Path.Combine(tbGameDirectory.Text, expectedExecutableName))) + { + gameDirectoryVerified = true; + break; + } + } + + return gameDirectoryVerified; + } + private bool CheckGameDirectory() { - if (!File.Exists(Path.Combine(tbGameDirectory.Text, Constants.ExpectedClientExecutableName))) + if (!VerifyGameDirectory()) { EditorMessageBox.Show(WindowManager, "Invalid game directory", - $"{Constants.ExpectedClientExecutableName} not found, please check that you typed the correct game directory.", + $"{Constants.ExpectedClientExecutableNames[0]} not found, please check that you typed the correct game directory.", MessageBoxButtons.OK); return false; @@ -376,7 +396,7 @@ private void BtnBrowseGameDirectory_LeftClick(object sender, EventArgs e) { openFileDialog.InitialDirectory = tbGameDirectory.Text; openFileDialog.Filter = - $"Game executable|{Constants.ExpectedClientExecutableName}"; + $"Game executable|{string.Join(';', Constants.ExpectedClientExecutableNames)}"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK)