Refactor.

This commit is contained in:
Eusth 2018-10-08 21:00:38 +02:00
parent 527b52f5ce
commit 6869e584fe

View file

@ -49,7 +49,7 @@ namespace IPA
context.ProjectName = Path.GetFileNameWithoutExtension(context.Executable);
context.DataPathDst = Path.Combine(context.ProjectRoot, context.ProjectName + "_Data");
context.ManagedPath = Path.Combine(context.DataPathDst, "Managed");
context.EngineFile = Path.Combine(context.ManagedPath, (File.Exists(Path.Combine(context.ManagedPath, "UnityEngine.CoreModule.dll")) ? "UnityEngine.CoreModule.dll" : "UnityEngine.dll"));
context.EngineFile = DetermineEngineFile(context.ManagedPath, "UnityEngine.dll", "UnityEngine.CoreModule.dll");
context.AssemblyFile = Path.Combine(context.ManagedPath, "Assembly-Csharp.dll");
context.BackupPath = Path.Combine(Path.Combine(context.IPARoot, "Backups"), context.ProjectName);
string shortcutName = string.Format("{0} (Patch & Launch)", context.ProjectName);
@ -59,5 +59,19 @@ namespace IPA
return context;
}
private static string DetermineEngineFile(string basePath, params string[] candidates)
{
foreach(var candidate in candidates)
{
var fullPath = Path.Combine(basePath, candidate);
if(File.Exists(fullPath))
{
return fullPath;
}
}
throw new FileNotFoundException("Could not find engine DLL!");
}
}
}