mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Moved messagebox code into user interventions, moved FilePicker VMs into Wabbajack (from Wabbajack.Lib)
This commit is contained in:
parent
324ddae397
commit
b0951afb80
@ -52,10 +52,10 @@ namespace Wabbajack.Lib
|
||||
|
||||
if (GameFolder == null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
await Utils.Log(new CriticalFailureIntervention(
|
||||
$"In order to do a proper install Wabbajack needs to know where your {game.MO2Name} folder resides. We tried looking the" +
|
||||
"game location up in the windows registry but were unable to find it, please make sure you launch the game once before running this installer. ",
|
||||
"Could not find game location", MessageBoxButton.OK);
|
||||
"Could not find game location")).Task;
|
||||
Utils.Log("Exiting because we couldn't find the game folder.");
|
||||
return false;
|
||||
}
|
||||
@ -190,42 +190,6 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AskToEndorse()
|
||||
{
|
||||
var mods = ModList.Archives
|
||||
.Select(m => m.State)
|
||||
.OfType<NexusDownloader.State>()
|
||||
.GroupBy(f => (f.GameName, f.ModID))
|
||||
.Select(mod => mod.First())
|
||||
.ToArray();
|
||||
|
||||
var result = MessageBox.Show(
|
||||
$"Installation has completed, but you have installed {mods.Length} from the Nexus, would you like to" +
|
||||
" endorse these mods to show support to the authors? It will only take a few moments.", "Endorse Mods?",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
|
||||
if (result != MessageBoxResult.Yes) return;
|
||||
|
||||
// Shuffle mods so that if we hit a API limit we don't always miss the same mods
|
||||
var r = new Random();
|
||||
for (var i = 0; i < mods.Length; i++)
|
||||
{
|
||||
var a = r.Next(mods.Length);
|
||||
var b = r.Next(mods.Length);
|
||||
var tmp = mods[a];
|
||||
mods[a] = mods[b];
|
||||
mods[b] = tmp;
|
||||
}
|
||||
|
||||
await mods.PMap(Queue, async mod =>
|
||||
{
|
||||
var client = await NexusApiClient.Get();
|
||||
var er = await client.EndorseMod(mod);
|
||||
Utils.Log($"Endorsed {mod.GameName} - {mod.ModID} - Result: {er.message}");
|
||||
});
|
||||
Info("Done! You may now exit the application!");
|
||||
}
|
||||
|
||||
private async Task BuildBSAs()
|
||||
{
|
||||
var bsas = ModList.Directives.OfType<CreateBSA>().ToList();
|
||||
|
27
Wabbajack.Lib/StatusMessages/CriticalFailureIntervention.cs
Normal file
27
Wabbajack.Lib/StatusMessages/CriticalFailureIntervention.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
/// <summary>
|
||||
/// This should probably be replaced with an error, but this is just to get messageboxes out of the .Lib library
|
||||
/// </summary>
|
||||
public class CriticalFailureIntervention : AUserIntervention
|
||||
{
|
||||
private TaskCompletionSource<ConfirmationIntervention.Choice> _source = new TaskCompletionSource<ConfirmationIntervention.Choice>();
|
||||
public Task<ConfirmationIntervention.Choice> Task => _source.Task;
|
||||
|
||||
public CriticalFailureIntervention(string description, string title)
|
||||
{
|
||||
ExtendedDescription = description;
|
||||
ShortDescription = title;
|
||||
}
|
||||
public override string ShortDescription { get; }
|
||||
public override string ExtendedDescription { get; }
|
||||
public override void Cancel()
|
||||
{
|
||||
Handled = true;
|
||||
_source.SetResult(ConfirmationIntervention.Choice.Abort);
|
||||
}
|
||||
}
|
||||
}
|
15
Wabbajack.Lib/StatusMessages/YesNoIntervention.cs
Normal file
15
Wabbajack.Lib/StatusMessages/YesNoIntervention.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
public class YesNoIntervention : ConfirmationIntervention
|
||||
{
|
||||
public YesNoIntervention(string description, string title)
|
||||
{
|
||||
ExtendedDescription = description;
|
||||
ShortDescription = title;
|
||||
}
|
||||
public override string ShortDescription { get; }
|
||||
public override string ExtendedDescription { get; }
|
||||
}
|
||||
}
|
@ -6,8 +6,8 @@ using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Microsoft.WindowsAPICodePack.Shell;
|
||||
using Newtonsoft.Json;
|
||||
using Syroot.Windows.IO;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StoreHandlers;
|
||||
using Wabbajack.Lib.CompilationSteps;
|
||||
|
@ -39,11 +39,15 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
if (cancel.IsCancellationRequested) return false;
|
||||
var metric = Metrics.Send("begin_install", ModList.Name);
|
||||
MessageBox.Show(
|
||||
var result = await Utils.Log(new YesNoIntervention(
|
||||
"Vortex Support is still experimental and may produce unexpected results. " +
|
||||
"If anything fails go to the special vortex support channels on the discord. @erri120#2285 " +
|
||||
"for support.", "Warning",
|
||||
MessageBoxButton.OK);
|
||||
"for support.", "Continue with experimental feature?")).Task;
|
||||
if (result == ConfirmationIntervention.Choice.Abort)
|
||||
{
|
||||
Utils.Log("Exiting at request of user");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cancel.IsCancellationRequested) return false;
|
||||
ConfigureProcessor(10, await RecommendQueueSize());
|
||||
@ -108,11 +112,11 @@ namespace Wabbajack.Lib
|
||||
if (!ModList.Directives.Any(d => d.To.StartsWith(Consts.ManualGameFilesDir)))
|
||||
return;
|
||||
|
||||
var result = MessageBox.Show("Some mods from this ModList must be installed directly into " +
|
||||
var result = await Utils.Log(new YesNoIntervention("Some mods from this ModList must be installed directly into " +
|
||||
"the game folder. Do you want to do this manually or do you want Wabbajack " +
|
||||
"to do this for you?", "Question", MessageBoxButton.YesNo);
|
||||
"to do this for you?", "Install game folder mods?")).Task;
|
||||
|
||||
if (result != MessageBoxResult.Yes)
|
||||
if (result != ConfirmationIntervention.Choice.Continue)
|
||||
return;
|
||||
|
||||
var manualFilesDir = Path.Combine(OutputFolder, Consts.ManualGameFilesDir);
|
||||
@ -167,12 +171,13 @@ namespace Wabbajack.Lib
|
||||
if (!ModList.Directives.Any(s => s is SteamMeta))
|
||||
return;
|
||||
|
||||
var result = MessageBox.Show("The ModList you are installing requires Steam Workshop Items to exist. " +
|
||||
"You can check the Workshop Items in the manifest of this ModList. Wabbajack can start Steam for you " +
|
||||
"and download the Items automatically. Do you want to proceed with this step?",
|
||||
"Warning", MessageBoxButton.YesNo);
|
||||
var result = await Utils.Log(new YesNoIntervention(
|
||||
"The ModList you are installing requires Steam Workshop Items to exist. " +
|
||||
"You can check the Workshop Items in the manifest of this ModList. Wabbajack can start Steam for you " +
|
||||
"and download the Items automatically. Do you want to proceed with this step?",
|
||||
"Download Steam Workshop Items?")).Task;
|
||||
|
||||
if (result != MessageBoxResult.Yes)
|
||||
if (result != ConfirmationIntervention.Choice.Continue)
|
||||
return;
|
||||
|
||||
await ModList.Directives.OfType<SteamMeta>()
|
||||
|
@ -159,8 +159,8 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReportBuilder.cs" />
|
||||
<Compile Include="StatusMessages\ConfirmUpdateOfExistingInstall.cs" />
|
||||
<Compile Include="UI\FilePickerVM.cs" />
|
||||
<Compile Include="UI\UIUtils.cs" />
|
||||
<Compile Include="StatusMessages\CriticalFailureIntervention.cs" />
|
||||
<Compile Include="StatusMessages\YesNoIntervention.cs" />
|
||||
<Compile Include="Validation\DTOs.cs" />
|
||||
<Compile Include="Validation\ValidateModlist.cs" />
|
||||
<Compile Include="ViewModel.cs" />
|
||||
@ -214,9 +214,6 @@
|
||||
<PackageReference Include="MegaApiClient">
|
||||
<Version>1.7.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell">
|
||||
<Version>1.1.3.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Toolkit.Wpf.UI.Controls.WebView">
|
||||
<Version>6.0.0</Version>
|
||||
</PackageReference>
|
||||
|
@ -9,6 +9,7 @@ using DynamicData;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack.Test
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
namespace Wabbajack.UI
|
||||
{
|
||||
public class FilePickerVM : ViewModel
|
||||
{
|
@ -8,7 +8,7 @@ using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
namespace Wabbajack.UI
|
||||
{
|
||||
public static class UIUtils
|
||||
{
|
@ -15,6 +15,7 @@ using System.Windows.Media.Imaging;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StatusFeed;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StoreHandlers;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ using Wabbajack.Common.StatusFeed;
|
||||
using System.Reactive;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Input;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -99,12 +100,10 @@ namespace Wabbajack
|
||||
{
|
||||
if (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location.ToLower()) == KnownFolders.Downloads.Path.ToLower())
|
||||
{
|
||||
MessageBox.Show(
|
||||
Utils.Log(new CriticalFailureIntervention(
|
||||
"Wabbajack is running inside your Downloads folder. This folder is often highly monitored by antivirus software and these can often " +
|
||||
"conflict with the operations Wabbajack needs to perform. Please move this executable outside of your Downloads folder and then restart the app.",
|
||||
"Cannot run inside Downloads",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
"Cannot run inside Downloads")).Task.Wait();
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ using System.Reactive.Linq;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
@ -73,6 +74,19 @@ namespace Wabbajack
|
||||
c.Resume(data);
|
||||
});
|
||||
break;
|
||||
case YesNoIntervention c:
|
||||
var result = MessageBox.Show(c.ExtendedDescription, c.ShortDescription, MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
c.Confirm();
|
||||
else
|
||||
c.Cancel();
|
||||
break;
|
||||
case CriticalFailureIntervention c:
|
||||
MessageBox.Show(c.ExtendedDescription, c.ShortDescription, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
c.Cancel();
|
||||
break;
|
||||
case ConfirmationIntervention c:
|
||||
break;
|
||||
default:
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.UI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
|
@ -172,6 +172,8 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="UI\FilePickerVM.cs" />
|
||||
<Compile Include="UI\UIUtils.cs" />
|
||||
<Compile Include="View Models\BackNavigatingVM.cs" />
|
||||
<Compile Include="View Models\Settings\SettingsVM.cs" />
|
||||
<Compile Include="Views\Settings\SettingsView.xaml.cs">
|
||||
|
Loading…
Reference in New Issue
Block a user