diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 3ccb8b5f..bcfd5f59 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -1123,6 +1123,21 @@ namespace Wabbajack.Common File.Delete(path); } + public static void StartProcessFromFile(string file) + { + Process.Start(new ProcessStartInfo("cmd.exe", $"/c {file}") + { + CreateNoWindow = true, + }); + } + + public static void OpenWebsite(string url) + { + Process.Start(new ProcessStartInfo("cmd.exe", $"/c start {url}") + { + CreateNoWindow = true, + }); + } public static bool IsInPath(this string path, string parent) { diff --git a/Wabbajack.Lib/ACompiler.cs b/Wabbajack.Lib/ACompiler.cs index 04c72228..c69cce78 100644 --- a/Wabbajack.Lib/ACompiler.cs +++ b/Wabbajack.Lib/ACompiler.cs @@ -40,8 +40,6 @@ namespace Wabbajack.Lib public abstract string ModListOutputFolder { get; } public abstract string ModListOutputFile { get; } - public bool ShowReportWhenFinished { get; set; } = true; - public bool IgnoreMissingFiles { get; set; } public ICollection SelectedArchives = new List(); @@ -161,15 +159,6 @@ namespace Wabbajack.Lib Utils.DeleteDirectory(ModListOutputFolder); } - public void ShowReport() - { - if (!ShowReportWhenFinished) return; - - var file = Path.GetTempFileName() + ".html"; - File.WriteAllText(file, ModList.ReportHTML); - Process.Start(file); - } - public void GenerateReport() { string css; diff --git a/Wabbajack.Lib/MO2Compiler.cs b/Wabbajack.Lib/MO2Compiler.cs index 2338ff67..ca055bfd 100644 --- a/Wabbajack.Lib/MO2Compiler.cs +++ b/Wabbajack.Lib/MO2Compiler.cs @@ -291,8 +291,6 @@ namespace Wabbajack.Lib ResetMembers(); - ShowReport(); - UpdateTracker.NextStep("Done Building Modlist"); return true; diff --git a/Wabbajack.Lib/VortexCompiler.cs b/Wabbajack.Lib/VortexCompiler.cs index 6024dde5..cd3cb7ab 100644 --- a/Wabbajack.Lib/VortexCompiler.cs +++ b/Wabbajack.Lib/VortexCompiler.cs @@ -255,8 +255,6 @@ namespace Wabbajack.Lib ResetMembers(); - ShowReport(); - UpdateTracker.NextStep("Done Building ModList"); return true; diff --git a/Wabbajack.Test/ACompilerTest.cs b/Wabbajack.Test/ACompilerTest.cs index 6a5490a3..776b2265 100644 --- a/Wabbajack.Test/ACompilerTest.cs +++ b/Wabbajack.Test/ACompilerTest.cs @@ -38,7 +38,6 @@ namespace Wabbajack.Test mo2Folder: utils.MO2Folder, mo2Profile: profile, outputFile: profile + Consts.ModListExtension); - compiler.ShowReportWhenFinished = false; Assert.IsTrue(await compiler.Begin()); return compiler; } diff --git a/Wabbajack.Test/EndToEndTests.cs b/Wabbajack.Test/EndToEndTests.cs index b4dc76c2..f7717658 100644 --- a/Wabbajack.Test/EndToEndTests.cs +++ b/Wabbajack.Test/EndToEndTests.cs @@ -78,7 +78,6 @@ namespace Wabbajack.Test mo2Profile: profile, outputFile: profile + Consts.ModListExtension); compiler.MO2DownloadsFolder = Path.Combine(utils.DownloadsFolder); - compiler.ShowReportWhenFinished = false; Assert.IsTrue(await compiler.Begin()); } @@ -166,7 +165,6 @@ namespace Wabbajack.Test mo2Folder: utils.MO2Folder, mo2Profile: profile, outputFile: profile + Consts.ModListExtension); - compiler.ShowReportWhenFinished = false; Assert.IsTrue(await compiler.Begin()); return compiler; } diff --git a/Wabbajack/View Models/Compilers/CompilerVM.cs b/Wabbajack/View Models/Compilers/CompilerVM.cs index daee630b..fd044cdc 100644 --- a/Wabbajack/View Models/Compilers/CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/CompilerVM.cs @@ -184,8 +184,16 @@ namespace Wabbajack { try { - var successful = await this.Compiler.Compile(); - Completed = ErrorResponse.Create(successful); + var modList = await this.Compiler.Compile(); + Completed = ErrorResponse.Create(modList.Succeeded); + try + { + ShowReport(modList.Value); + } + catch (Exception ex) + { + Utils.Error(ex, $"Error opening manifest report"); + } } catch (Exception ex) { @@ -267,5 +275,12 @@ namespace Wabbajack .Switch() .ToGuiProperty(this, nameof(CurrentCpuCount)); } + + public void ShowReport(ModList modList) + { + var file = Path.GetTempFileName() + ".html"; + File.WriteAllText(file, modList.ReportHTML); + Utils.StartProcessFromFile(file); + } } } diff --git a/Wabbajack/View Models/Compilers/ISubCompilerVM.cs b/Wabbajack/View Models/Compilers/ISubCompilerVM.cs index 472cf29f..b781da89 100644 --- a/Wabbajack/View Models/Compilers/ISubCompilerVM.cs +++ b/Wabbajack/View Models/Compilers/ISubCompilerVM.cs @@ -12,6 +12,6 @@ namespace Wabbajack ModlistSettingsEditorVM ModlistSettings { get; } void Unload(); IObservable CanCompile { get; } - Task Compile(); + Task> Compile(); } } diff --git a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs index 8e1db3fa..daec599c 100644 --- a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs @@ -163,7 +163,7 @@ namespace Wabbajack ModlistSettings?.Save(); } - public async Task Compile() + public async Task> Compile() { string outputFile; if (string.IsNullOrWhiteSpace(Parent.OutputLocation.TargetPath)) @@ -194,7 +194,8 @@ namespace Wabbajack { Parent.MWVM.Settings.Performance.AttachToBatchProcessor(ActiveCompilation); - return await ActiveCompilation.Begin(); + var success = await ActiveCompilation.Begin(); + return GetResponse.Create(success, ActiveCompilation.ModList); } } finally diff --git a/Wabbajack/View Models/Compilers/VortexCompilerVM.cs b/Wabbajack/View Models/Compilers/VortexCompilerVM.cs index 5c79e2c7..35eae55d 100644 --- a/Wabbajack/View Models/Compilers/VortexCompilerVM.cs +++ b/Wabbajack/View Models/Compilers/VortexCompilerVM.cs @@ -177,7 +177,7 @@ namespace Wabbajack GameLocation.TargetPath = StoreHandler.Instance.GetGamePath(SelectedGame.Game, StoreType.GOG); } - public async Task Compile() + public async Task> Compile() { string outputFile = $"{ModlistSettings.ModListName}{Consts.ModListExtension}"; if (!string.IsNullOrWhiteSpace(Parent.OutputLocation.TargetPath)) @@ -204,7 +204,8 @@ namespace Wabbajack }) { Parent.MWVM.Settings.Performance.AttachToBatchProcessor(ActiveCompilation); - return await ActiveCompilation.Begin(); + var success = await ActiveCompilation.Begin(); + return GetResponse.Create(success, ActiveCompilation.ModList); } } finally diff --git a/Wabbajack/View Models/Installers/InstallerVM.cs b/Wabbajack/View Models/Installers/InstallerVM.cs index 3fa080bf..f198a83f 100644 --- a/Wabbajack/View Models/Installers/InstallerVM.cs +++ b/Wabbajack/View Models/Installers/InstallerVM.cs @@ -323,7 +323,7 @@ namespace Wabbajack VisitModListWebsiteCommand = ReactiveCommand.Create( execute: () => { - Process.Start(ModList.Website); + Utils.OpenWebsite(ModList.Website); return Unit.Default; }, canExecute: this.WhenAny(x => x.ModList.Website) @@ -443,7 +443,7 @@ namespace Wabbajack { var file = Path.GetTempFileName() + ".html"; File.WriteAllText(file, HTMLReport); - Process.Start(file); + Utils.StartProcessFromFile(file); } } } diff --git a/Wabbajack/View Models/ModListMetadataVM.cs b/Wabbajack/View Models/ModListMetadataVM.cs index b3583a84..48fd19b3 100644 --- a/Wabbajack/View Models/ModListMetadataVM.cs +++ b/Wabbajack/View Models/ModListMetadataVM.cs @@ -54,7 +54,7 @@ namespace Wabbajack Metadata = metadata; Location = Path.Combine(Consts.ModListDownloadFolder, Metadata.Links.MachineURL + Consts.ModListExtension); IsBroken = metadata.ValidationSummary.HasFailures; - OpenWebsiteCommand = ReactiveCommand.Create(() => Process.Start($"https://www.wabbajack.org/modlist/{Metadata.Links.MachineURL}")); + OpenWebsiteCommand = ReactiveCommand.Create(() => Utils.OpenWebsite($"https://www.wabbajack.org/modlist/{Metadata.Links.MachineURL}")); ExecuteCommand = ReactiveCommand.CreateFromObservable( canExecute: this.WhenAny(x => x.IsBroken).Select(x => !x), execute: (unit) => diff --git a/Wabbajack/View Models/ModListVM.cs b/Wabbajack/View Models/ModListVM.cs index a338296d..7c3f92a6 100644 --- a/Wabbajack/View Models/ModListVM.cs +++ b/Wabbajack/View Models/ModListVM.cs @@ -96,7 +96,7 @@ namespace Wabbajack if (string.IsNullOrEmpty(Readme)) return; if (SourceModList.ReadmeIsWebsite) { - Process.Start(Readme); + Utils.OpenWebsite(Readme); } else { diff --git a/Wabbajack/View Models/SlideShow.cs b/Wabbajack/View Models/SlideShow.cs index 6ccba2ad..4a915515 100644 --- a/Wabbajack/View Models/SlideShow.cs +++ b/Wabbajack/View Models/SlideShow.cs @@ -121,7 +121,7 @@ namespace Wabbajack VisitNexusSiteCommand = ReactiveCommand.Create( execute: () => { - Process.Start(TargetMod.ModURL); + Utils.OpenWebsite(TargetMod.ModURL); return Unit.Default; }, canExecute: this.WhenAny(x => x.TargetMod.ModURL) diff --git a/Wabbajack/Views/LinksView.xaml.cs b/Wabbajack/Views/LinksView.xaml.cs index 4ae06c91..16938432 100644 --- a/Wabbajack/Views/LinksView.xaml.cs +++ b/Wabbajack/Views/LinksView.xaml.cs @@ -17,17 +17,17 @@ namespace Wabbajack private void GitHub_Click(object sender, RoutedEventArgs e) { - Process.Start("https://github.com/wabbajack-tools/wabbajack"); + Utils.OpenWebsite("https://github.com/wabbajack-tools/wabbajack"); } private void Discord_Click(object sender, RoutedEventArgs e) { - Process.Start("https://discord.gg/wabbajack"); + Utils.OpenWebsite("https://discord.gg/wabbajack"); } private void Patreon_Click(object sender, RoutedEventArgs e) { - Process.Start("https://www.patreon.com/user?u=11907933"); + Utils.OpenWebsite("https://www.patreon.com/user?u=11907933"); } } }