public LoadMods ( string FileNames, int &numMods, bool ExternalCall = false ) : bool? | ||
FileNames | string | |
numMods | int | |
ExternalCall | bool | |
Результат | bool? |
private void LoadMOD(string filename) { ModMaker modmaker = new ModMaker(); string basetemppath = Path.Combine(TemporaryPath, "MOD CONVERSION"); // KFreon: Setup temp folder for (int i = 0; i < 3; i++) try { if (Directory.Exists(basetemppath)) Directory.Delete(basetemppath); else break; } catch { System.Threading.Thread.Sleep(100); } Directory.CreateDirectory(basetemppath); // KFreon: Load mods Overall.UpdateText("Loading Mod: " + filename); int nummods; modmaker.LoadMods(new string[] { filename }, out nummods, true); Overall.UpdateText("Formatting/Updating .mods..."); bool conflict; var result = modmaker.FormatJobs(true, true, out conflict); // Heff: prompt user to chose version and re-run with version chosen if (conflict) { this.Invoke(new Action(() => { var gameVers = VersionPickDialog.AskForGameVersion(this, message: "Could not detect game version, the files in this .mod were present in more than one game. \n" + "Please choose the correct version:"); result = modmaker.FormatJobs(true, true, out conflict, gameVers); })); } if (result.Count == 0) { Overall.UpdateText("ERROR! See debug output."); OverallProg.ChangeProgressBar(0, 1); return; } List<TreeTexInfo> TreeTexes = Tree.GetTreeAsList(); int count = 1; OverallProg.ChangeProgressBar(0, nummods); foreach (KFreonLib.Scripting.ModMaker.ModJob job in KFreonLib.Scripting.ModMaker.JobList) { if (cts.IsCancellationRequested) break; if (job.JobType != "TEXTURE") DebugOutput.PrintLn("Job:" + job.Name + " isn't a texture job. Ignoring..."); else { Overall.UpdateText("Converting job: " + count++ + " of " + nummods); // KFreon: Change Trees if necessary if (WhichGame != job.WhichGame) ChangeTrees(job.WhichGame); // wait here? uint inthash = KFreonLib.Textures.Methods.FindHashByName(job.Texname, job.PCCs, job.ExpIDs, TreeTexes); string hash = KFreonLib.Textures.Methods.FormatTexmodHashAsString(inthash); if (hash == "0") DebugOutput.PrintLn("Unable to find hash for " + job.Texname + ". Continuing..."); else { string newname = "MASSEFFECT" + WhichGame + ".EXE_" + hash + ".dds"; string newpath = Path.Combine(basetemppath, newname); File.WriteAllBytes(newpath, job.data); LoadExternal(newpath, false); } } } if (!cts.IsCancellationRequested) Overall.UpdateText("Loaded " + (count - 1) + " jobs out of " + KFreonLib.Scripting.ModMaker.JobList.Count + " from Modmaker."); else Overall.UpdateText("Mod loading cancelled!"); OverallProg.ChangeProgressBar(1, 1); RedrawTreeView(); }
private void LoadMOD(string filename) { ModMaker modmaker = new ModMaker(); string basetemppath = Path.Combine(TemporaryPath, "MOD CONVERSION"); // KFreon: Setup temp folder for (int i = 0; i < 3; i++) try { if (Directory.Exists(basetemppath)) Directory.Delete(basetemppath); else break; } catch { System.Threading.Thread.Sleep(100); } Directory.CreateDirectory(basetemppath); // KFreon: Load mods Overall.UpdateText("Loading Mod: " + filename); int nummods; modmaker.LoadMods(new string[] { filename }, out nummods, true); Overall.UpdateText("Formatting/Updating .mods..."); modmaker.FormatJobs(true, true); List<TreeTexInfo> TreeTexes = Tree.GetTreeAsList(); int count = 1; OverallProg.ChangeProgressBar(0, nummods); foreach (KFreonLib.Scripting.ModMaker.ModJob job in KFreonLib.Scripting.ModMaker.JobList) { if (cts.IsCancellationRequested) break; if (job.JobType != "TEXTURE") DebugOutput.PrintLn("Job:" + job.Name + " isn't a texture job. Ignoring..."); else { Overall.UpdateText("Converting job: " + count++ + " of " + nummods); // KFreon: Change Trees if necessary if (WhichGame != job.WhichGame) ChangeTrees(job.WhichGame); // wait here? uint inthash = KFreonLib.Textures.Methods.FindHashByName(job.Texname, job.PCCs, job.ExpIDs, TreeTexes); string hash = KFreonLib.Textures.Methods.FormatTexmodHashAsString(inthash); if (hash == "0") DebugOutput.PrintLn("Unable to find hash for " + job.Texname + ". Continuing..."); else { string newname = "MASSEFFECT" + WhichGame + ".EXE_" + hash + ".dds"; string newpath = Path.Combine(basetemppath, newname); File.WriteAllBytes(newpath, job.data); LoadExternal(newpath, false); } } } if (!cts.IsCancellationRequested) Overall.UpdateText("Loaded " + (count - 1) + " jobs out of " + KFreonLib.Scripting.ModMaker.JobList.Count + " from Modmaker."); else Overall.UpdateText("Mod loading cancelled!"); OverallProg.ChangeProgressBar(1, 1); RedrawTreeView(); }