/// <summary> /// Replaces "$(ProjectDirectory)" with the project's .trproj folder path. /// <para>This is used to make projects inside TombIDE easier to read for the software.</para> /// </summary> public void DecodeProjectPaths(string trprojFilePath) { ProjectPath = Path.GetDirectoryName(trprojFilePath); if (!string.IsNullOrEmpty(LaunchFilePath)) { LaunchFilePath = Path.Combine(ProjectPath, LaunchFilePath.Replace(@"$(ProjectDirectory)\", string.Empty)); } string engineDirectory = Path.Combine(ProjectPath, "Engine"); if (Directory.Exists(engineDirectory)) { foreach (string file in Directory.GetFiles(engineDirectory, "*.exe", SearchOption.TopDirectoryOnly)) { if (((GameVersion == TRVersion.Game.TR4 || GameVersion == TRVersion.Game.TRNG) && Path.GetFileName(file).ToLower() == "tomb4.exe") || (GameVersion == TRVersion.Game.TR5Main && Path.GetFileName(file).ToLower() == "pctomb5.exe")) { EnginePath = engineDirectory; break; } } } // If the /Engine/ directory doesn't exist or no valid .exe file was found in that directory if (string.IsNullOrEmpty(EnginePath)) { EnginePath = ProjectPath; } if (ScriptPath.StartsWith("$(ProjectDirectory)")) { ScriptPath = ScriptPath.Replace("$(ProjectDirectory)", ProjectPath); } if (LevelsPath.StartsWith("$(ProjectDirectory)")) { LevelsPath = LevelsPath.Replace("$(ProjectDirectory)", ProjectPath); } foreach (ProjectLevel level in Levels) { if (level.FolderPath.StartsWith("$(ProjectDirectory)")) { level.FolderPath = level.FolderPath.Replace("$(ProjectDirectory)", ProjectPath); } } }
/// <summary> /// Replaces the project's .trproj folder path with "$(ProjectDirectory)". /// <para>This is used before saving .trproj files to avoid having "hardcoded" paths.</para> /// </summary> public void EncodeProjectPaths() { LaunchFilePath = Path.Combine("$(ProjectDirectory)", Path.GetFileName(LaunchFilePath)); if (ScriptPath.StartsWith(ProjectPath)) { ScriptPath = ScriptPath.Replace(ProjectPath, "$(ProjectDirectory)"); } if (LevelsPath.StartsWith(ProjectPath)) { LevelsPath = LevelsPath.Replace(ProjectPath, "$(ProjectDirectory)"); } foreach (ProjectLevel level in Levels) { if (level.FolderPath.StartsWith(ProjectPath)) { level.FolderPath = level.FolderPath.Replace(ProjectPath, "$(ProjectDirectory)"); } } }