diff --git a/Wabbajack.App.Blazor/.editorconfig b/Wabbajack.App.Blazor/.editorconfig index fe9d005d..154d1fe7 100644 --- a/Wabbajack.App.Blazor/.editorconfig +++ b/Wabbajack.App.Blazor/.editorconfig @@ -4,11 +4,5 @@ indent_style = space indent_size = 4 insert_final_newline = true -# C# and Razor files -[*.{cs,razor}] -# RZ10012: Markup element with unexpected name. -# Reason: The component namespace is added to the global _Imports.razor file. -dotnet_diagnostic.RZ10012.severity = none - [*.scss] indent_size = 2 diff --git a/Wabbajack.App.Blazor/App.xaml.cs b/Wabbajack.App.Blazor/App.xaml.cs index f89cc3af..a87e4ba1 100644 --- a/Wabbajack.App.Blazor/App.xaml.cs +++ b/Wabbajack.App.Blazor/App.xaml.cs @@ -40,12 +40,13 @@ public partial class App Layout = "${processtime} [${level:uppercase=true}] (${logger}) ${message:withexception=true}", Header = "############ Wabbajack log file - ${longdate} ############" }; + var consoleTarget = new ConsoleTarget("console"); - var uiTarget = new MemoryTarget + + var uiTarget = new UiLoggerTarget { Name = "ui", Layout = "${message}", - }; var blackholeTarget = new NullTarget("blackhole"); diff --git a/Wabbajack.App.Blazor/Components/BottomBar.razor b/Wabbajack.App.Blazor/Components/BottomBar.razor index 24ba53e4..3dcd42e2 100644 --- a/Wabbajack.App.Blazor/Components/BottomBar.razor +++ b/Wabbajack.App.Blazor/Components/BottomBar.razor @@ -16,15 +16,15 @@ @code { [Parameter] - public string Title { get; set; } + public string? Title { get; set; } [Parameter] - public string Subtitle { get; set; } + public string? Subtitle { get; set; } [Parameter] - public string Image { get; set; } + public string? Image { get; set; } [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment? ChildContent { get; set; } } diff --git a/Wabbajack.App.Blazor/Components/InfoBlock.razor b/Wabbajack.App.Blazor/Components/InfoBlock.razor index d51c622f..c65e0ebc 100644 --- a/Wabbajack.App.Blazor/Components/InfoBlock.razor +++ b/Wabbajack.App.Blazor/Components/InfoBlock.razor @@ -1,7 +1,7 @@ @namespace Wabbajack.App.Blazor.Components
- @if (Supertitle != string.Empty) + @if (Supertitle is not null) { @Supertitle } @@ -14,18 +14,18 @@ @code { [Parameter] - public string Supertitle { get; set; } = string.Empty; + public string? Supertitle { get; set; } [Parameter] - public string Title { get; set; } + public string? Title { get; set; } [Parameter] - public string Subtitle { get; set; } + public string? Subtitle { get; set; } [Parameter] - public string Comment { get; set; } + public string? Comment { get; set; } [Parameter] - public string Description { get; set; } + public string? Description { get; set; } } diff --git a/Wabbajack.App.Blazor/Components/InfoImage.razor b/Wabbajack.App.Blazor/Components/InfoImage.razor index c1b07b4d..67280ea2 100644 --- a/Wabbajack.App.Blazor/Components/InfoImage.razor +++ b/Wabbajack.App.Blazor/Components/InfoImage.razor @@ -23,15 +23,14 @@ @code { [Parameter] - public string Image { get; set; } + public string? Image { get; set; } [Parameter] - public string Title { get; set; } + public string? Title { get; set; } [Parameter] - public string Subtitle { get; set; } + public string? Subtitle { get; set; } [Parameter] - public string Description { get; set; } - + public string? Description { get; set; } } diff --git a/Wabbajack.App.Blazor/Components/InfoModal.razor b/Wabbajack.App.Blazor/Components/InfoModal.razor index 4b027d2f..153279c5 100644 --- a/Wabbajack.App.Blazor/Components/InfoModal.razor +++ b/Wabbajack.App.Blazor/Components/InfoModal.razor @@ -5,5 +5,5 @@ @code { [Parameter] - public string Content { get; set; } + public string? Content { get; set; } } diff --git a/Wabbajack.App.Blazor/Components/InteractionIcon.razor b/Wabbajack.App.Blazor/Components/InteractionIcon.razor index 433af99c..85f26b82 100644 --- a/Wabbajack.App.Blazor/Components/InteractionIcon.razor +++ b/Wabbajack.App.Blazor/Components/InteractionIcon.razor @@ -5,15 +5,14 @@ @code { [Parameter] - public string Icon { get; set; } + public string? Icon { get; set; } [Parameter] - public string Label { get; set; } + public string? Label { get; set; } [Parameter] - public string Size { get; set; } + public string? Size { get; set; } [Parameter] public EventCallback OnClick { get; set; } - } diff --git a/Wabbajack.App.Blazor/Components/OptionCheckbox.razor b/Wabbajack.App.Blazor/Components/OptionCheckbox.razor index dd4be6c3..6d5a3e53 100644 --- a/Wabbajack.App.Blazor/Components/OptionCheckbox.razor +++ b/Wabbajack.App.Blazor/Components/OptionCheckbox.razor @@ -2,26 +2,28 @@ @code { // TODO: [Low] Implement parameters to customize style. - // TODO: [High] Implement a way to set a passed bool without using callback function. - + [Parameter] - public string Label { get; set; } - + public string? Label { get; set; } + [Parameter] - public EventCallback OnChecked { get; set; } - - private bool IsChecked { get; set; } + public bool IsChecked { get; set; } + + [Parameter] + public EventCallback IsCheckedChanged { get; set; } private async Task CheckBoxChanged(ChangeEventArgs e) { - IsChecked = (bool)(e.Value ?? false); - await OnChecked.InvokeAsync(IsChecked); + if (e.Value is not bool newValue) return; + if (IsChecked == newValue) return; + + IsChecked = newValue; + await IsCheckedChanged.InvokeAsync(IsChecked); } - } diff --git a/Wabbajack.App.Blazor/Components/ProgressBar.razor b/Wabbajack.App.Blazor/Components/ProgressBar.razor index 41766e5a..9c0994e0 100644 --- a/Wabbajack.App.Blazor/Components/ProgressBar.razor +++ b/Wabbajack.App.Blazor/Components/ProgressBar.razor @@ -1,32 +1,38 @@ @using Wabbajack.RateLimiter @using System @using System.Reactive.Linq +@implements IDisposable @namespace Wabbajack.App.Blazor.Components
- + @Text
@code { + [Parameter] public IObservable? ProgressObserver { get; set; } private double CurrentProgress { get; set; } + private string Text { get; set; } = string.Empty; - [Parameter] public IObservable ProgressObserver { get; set; } - - [Parameter] public string? Text { get; set; } - + private IDisposable? _disposable; + protected override void OnInitialized() { - var textPercentage = string.IsNullOrEmpty(Text); - ProgressObserver + if (ProgressObserver is null) return; + + _disposable = ProgressObserver .Sample(TimeSpan.FromMilliseconds(250)) .DistinctUntilChanged(p => p.Value) - .Subscribe(p => { + .Subscribe(p => + { CurrentProgress = p.Value; - if (textPercentage) Text = p.ToString(); + Text = p.ToString(); InvokeAsync(StateHasChanged); }); } + + public void Dispose() => _disposable?.Dispose(); + } diff --git a/Wabbajack.App.Blazor/Components/SideBar.razor b/Wabbajack.App.Blazor/Components/SideBar.razor index be9cfb37..4eebeaf3 100644 --- a/Wabbajack.App.Blazor/Components/SideBar.razor +++ b/Wabbajack.App.Blazor/Components/SideBar.razor @@ -1,4 +1,5 @@ -@code { +@using Wabbajack.App.Blazor.Utility +@code { private void OpenPatreonPage() => UIUtils.OpenWebsite(new Uri("https://www.patreon.com/user?u=11907933")); private void OpenGithubPage() => UIUtils.OpenWebsite(new Uri("https://github.com/wabbajack-tools/wabbajack")); private void OpenDiscord() => UIUtils.OpenWebsite(new Uri("https://discord.gg/wabbajack")); diff --git a/Wabbajack.App.Blazor/Components/VirtualLogger.razor b/Wabbajack.App.Blazor/Components/VirtualLogger.razor index f2d897a2..a30d6993 100644 --- a/Wabbajack.App.Blazor/Components/VirtualLogger.razor +++ b/Wabbajack.App.Blazor/Components/VirtualLogger.razor @@ -1,23 +1,41 @@ @using NLog @using NLog.Targets +@using Wabbajack.App.Blazor.Utility +@using System.Reactive.Linq @namespace Wabbajack.App.Blazor.Components +@implements IDisposable
- - @logItem + + @logItem
@code { - // TODO: [Low] More parameters to customise the logger. E.g. Reverse order. // TODO: [High] Find a way to auto-scroll. (JS interop?) - private MemoryTarget? _memoryTarget; - private ICollection Logs => _memoryTarget?.Logs ?? Array.Empty(); + private UiLoggerTarget? _loggerTarget; + private ICollection _logs = new List(); - protected override void OnInitialized() - { - _memoryTarget = LogManager.Configuration.FindTargetByName("ui"); + private bool _shouldRender = false; + protected override bool ShouldRender() => _shouldRender; + + private IDisposable? _disposable; + + protected override Task OnInitializedAsync() + { + _loggerTarget = LogManager.Configuration.FindTargetByName("ui"); + + _disposable = _loggerTarget.Logs.Sample(TimeSpan.FromMilliseconds(250)).Subscribe(next => + { + _logs.Add(next); + InvokeAsync(StateHasChanged); + }); + + _shouldRender = true; + return Task.CompletedTask; } + + public void Dispose() => _disposable?.Dispose(); } diff --git a/Wabbajack.App.Blazor/Main.razor b/Wabbajack.App.Blazor/Main.razor index aa4eeeb9..13e645c7 100644 --- a/Wabbajack.App.Blazor/Main.razor +++ b/Wabbajack.App.Blazor/Main.razor @@ -1,6 +1,5 @@ - +@using Wabbajack.App.Blazor.Shared -@using Wabbajack.App.Blazor.Shared diff --git a/Wabbajack.App.Blazor/Pages/Gallery.razor.cs b/Wabbajack.App.Blazor/Pages/Gallery.razor.cs index f443bdab..6d0b6a1d 100644 --- a/Wabbajack.App.Blazor/Pages/Gallery.razor.cs +++ b/Wabbajack.App.Blazor/Pages/Gallery.razor.cs @@ -22,9 +22,9 @@ public partial class Gallery [Inject] private IStateContainer StateContainer { get; set; } = default!; [Inject] private NavigationManager NavigationManager { get; set; } = default!; [Inject] private ModListDownloadMaintainer Maintainer { get; set; } = default!; - [Inject] private IModalService Modal { get; set; } = default!; - private IObservable DownloadProgress { get; set; } + + private IObservable? DownloadProgress { get; set; } private ModlistMetadata? DownloadingMetaData { get; set; } private IEnumerable Modlists => StateContainer.Modlists; @@ -58,7 +58,7 @@ public partial class Gallery NavigationManager.NavigateTo(Configure.Route); } - private async Task OnClickInformation(ModlistMetadata metadata) + private void OnClickInformation(ModlistMetadata metadata) { // TODO: [High] Implement information modal. var parameters = new ModalParameters(); diff --git a/Wabbajack.App.Blazor/Pages/Install/Configure.razor b/Wabbajack.App.Blazor/Pages/Install/Configure.razor index a8ba0f6b..f631d8d0 100644 --- a/Wabbajack.App.Blazor/Pages/Install/Configure.razor +++ b/Wabbajack.App.Blazor/Pages/Install/Configure.razor @@ -38,8 +38,8 @@
- - + +
diff --git a/Wabbajack.App.Blazor/Pages/Install/Configure.razor.cs b/Wabbajack.App.Blazor/Pages/Install/Configure.razor.cs index 7b3772b0..c6b53b1d 100644 --- a/Wabbajack.App.Blazor/Pages/Install/Configure.razor.cs +++ b/Wabbajack.App.Blazor/Pages/Install/Configure.razor.cs @@ -24,18 +24,19 @@ public partial class Configure [Inject] private SettingsManager SettingsManager { get; set; } = default!; [Inject] private NavigationManager NavigationManager { get; set; } = default!; [Inject] private IJSRuntime JSRuntime { get; set; } = default!; - [Inject] private IToastService toastService { get; set; } + [Inject] private IToastService ToastService { get; set; } = default!; private ModList? Modlist => StateContainer.Modlist; private string? ModlistImage => StateContainer.ModlistImage; private AbsolutePath ModlistPath => StateContainer.ModlistPath; private AbsolutePath InstallPath => StateContainer.InstallPath; private AbsolutePath DownloadPath => StateContainer.DownloadPath; - - private InstallState InstallState => StateContainer.InstallState; - + private const string InstallSettingsPrefix = "install-settings-"; + private bool OverwriteInstallation { get; set; } + private bool UseCompression { get; set; } + private bool _shouldRender; protected override bool ShouldRender() => _shouldRender; @@ -55,8 +56,8 @@ public partial class Configure } catch (Exception e) { - toastService.ShowError("Could not load modlist!"); - Logger.LogError(e, "Exception loading Modlist file {Name}", ModlistPath); + ToastService.ShowError("Could not load modlist!"); + Logger.LogError(e, "Exception loading Modlist file {Name}", ModlistPath.ToString()); NavigationManager.NavigateTo(Select.Route); return; } @@ -74,19 +75,19 @@ public partial class Configure } catch (Exception e) { - Logger.LogWarning(e, "Exception loading previous settings for {Name}", ModlistPath); + Logger.LogWarning(e, "Exception loading previous settings for {Name}", ModlistPath.ToString()); } try { var imageStream = await StandardInstaller.ModListImageStream(ModlistPath); var dotnetImageStream = new DotNetStreamReference(imageStream); - StateContainer.ModlistImage = await JSRuntime.InvokeAsync("getBlobUrlFromStream", dotnetImageStream); + StateContainer.ModlistImage = await JSRuntime.InvokeAsync(JsInterop.GetBlobUrlFromStream, dotnetImageStream); } catch (Exception e) { - toastService.ShowWarning("Could not load modlist image."); - Logger.LogWarning(e, "Exception loading modlist image for {Name}", ModlistPath); + ToastService.ShowWarning("Could not load modlist image."); + Logger.LogWarning(e, "Exception loading modlist image for {Name}", ModlistPath.ToString()); } } diff --git a/Wabbajack.App.Blazor/Pages/Install/Installing.razor b/Wabbajack.App.Blazor/Pages/Install/Installing.razor index 94528959..649939f5 100644 --- a/Wabbajack.App.Blazor/Pages/Install/Installing.razor +++ b/Wabbajack.App.Blazor/Pages/Install/Installing.razor @@ -4,7 +4,10 @@
- + @if (ModlistImage is not null) + { + + }
@if (Modlist is not null) diff --git a/Wabbajack.App.Blazor/Pages/Install/Installing.razor.cs b/Wabbajack.App.Blazor/Pages/Install/Installing.razor.cs index d53727ea..11108d2e 100644 --- a/Wabbajack.App.Blazor/Pages/Install/Installing.razor.cs +++ b/Wabbajack.App.Blazor/Pages/Install/Installing.razor.cs @@ -29,36 +29,31 @@ public partial class Installing [Inject] private IJSRuntime JSRuntime { get; set; } = default!; private ModList? Modlist => StateContainer.Modlist; - private string ModlistImage => StateContainer.ModlistImage; + private string? ModlistImage => StateContainer.ModlistImage; private AbsolutePath ModlistPath => StateContainer.ModlistPath; private AbsolutePath InstallPath => StateContainer.InstallPath; private AbsolutePath DownloadPath => StateContainer.DownloadPath; - public string StatusCategory { get; set; } - - private string LastStatus { get; set; } - - public List StatusStep { get; set; } = new(); - - private InstallState InstallState => StateContainer.InstallState; - + private string? StatusCategory { get; set; } + private string? LastStatus { get; set; } + private List StatusStep { get; set; } = new(); + private const string InstallSettingsPrefix = "install-settings-"; private bool _shouldRender; protected override bool ShouldRender() => _shouldRender; - - protected override void OnInitialized() + + protected override async Task OnInitializedAsync() { - Install(); _shouldRender = true; + await Task.Run(Install); } private async Task Install() { if (Modlist is null) return; - StateContainer.InstallState = InstallState.Installing; - await Task.Run(() => BeginInstall(Modlist)); + await BeginInstall(Modlist); } private async Task BeginInstall(ModList modlist) diff --git a/Wabbajack.App.Blazor/Shared/MainLayout.razor b/Wabbajack.App.Blazor/Shared/MainLayout.razor index fc248bcd..b2ee7cb4 100644 --- a/Wabbajack.App.Blazor/Shared/MainLayout.razor +++ b/Wabbajack.App.Blazor/Shared/MainLayout.razor @@ -2,6 +2,7 @@ @inherits LayoutComponentBase @namespace Wabbajack.App.Blazor.Shared +
diff --git a/Wabbajack.App.Blazor/Utility/JsInterop.cs b/Wabbajack.App.Blazor/Utility/JsInterop.cs new file mode 100644 index 00000000..751bcdce --- /dev/null +++ b/Wabbajack.App.Blazor/Utility/JsInterop.cs @@ -0,0 +1,12 @@ +using Microsoft.JSInterop; + +namespace Wabbajack.App.Blazor.Utility; + +public static class JsInterop +{ + /// + /// Converts a into a blob URL. Useful for streaming images. + /// async function getBlobUrlFromStream(imageStream: DotNetStreamReference) + /// + public const string GetBlobUrlFromStream = "getBlobUrlFromStream"; +} diff --git a/Wabbajack.App.Blazor/Utility/UILoggerTarget.cs b/Wabbajack.App.Blazor/Utility/UILoggerTarget.cs new file mode 100644 index 00000000..db948321 --- /dev/null +++ b/Wabbajack.App.Blazor/Utility/UILoggerTarget.cs @@ -0,0 +1,17 @@ +using System; +using System.Reactive.Subjects; +using NLog; +using NLog.Targets; + +namespace Wabbajack.App.Blazor.Utility; + +public class UiLoggerTarget : TargetWithLayout +{ + private readonly Subject _logs = new(); + public IObservable Logs => _logs; + + protected override void Write(LogEventInfo logEvent) + { + _logs.OnNext(RenderLogEvent(Layout, logEvent)); + } +} diff --git a/Wabbajack.App.Blazor/Utility/UIUtils.cs b/Wabbajack.App.Blazor/Utility/UIUtils.cs index 652cb2b6..e870992b 100644 --- a/Wabbajack.App.Blazor/Utility/UIUtils.cs +++ b/Wabbajack.App.Blazor/Utility/UIUtils.cs @@ -1,16 +1,10 @@ using System; using System.Diagnostics; -using System.IO; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; -using System.Windows.Media.Imaging; -using Wabbajack.Hashing.xxHash64; using Wabbajack.Paths; using Wabbajack.Paths.IO; -namespace Wabbajack +namespace Wabbajack.App.Blazor.Utility { public static class UIUtils { @@ -31,11 +25,11 @@ namespace Wabbajack } - public static AbsolutePath OpenFileDialog(string filter, string initialDirectory = null) + public static AbsolutePath OpenFileDialog(string filter, string? initialDirectory = null) { - OpenFileDialog ofd = new OpenFileDialog(); + var ofd = new OpenFileDialog(); ofd.Filter = filter; - ofd.InitialDirectory = initialDirectory; + ofd.InitialDirectory = initialDirectory ?? string.Empty; if (ofd.ShowDialog() == DialogResult.OK) return (AbsolutePath)ofd.FileName; return default; diff --git a/Wabbajack.Installer/AInstaller.cs b/Wabbajack.Installer/AInstaller.cs index bc962a22..02e38ab1 100644 --- a/Wabbajack.Installer/AInstaller.cs +++ b/Wabbajack.Installer/AInstaller.cs @@ -120,7 +120,7 @@ public abstract class AInstaller ExtractedModlistFolder = _manager.CreateFolder(); await using var stream = _configuration.ModlistArchive.Open(FileMode.Open, FileAccess.Read, FileShare.Read); using var archive = new ZipArchive(stream, ZipArchiveMode.Read); - NextStep("Preparing","Extracting Modlist", archive.Entries.Count); + NextStep(Consts.StepPreparing,"Extracting Modlist", archive.Entries.Count); foreach (var entry in archive.Entries) { var path = entry.FullName.ToRelativePath().RelativeTo(ExtractedModlistFolder); @@ -182,7 +182,7 @@ public abstract class AInstaller /// protected async Task PrimeVFS() { - NextStep("Preparing","Priming VFS", 0); + NextStep(Consts.StepPreparing,"Priming VFS", 0); _vfs.AddKnown(_configuration.ModList.Directives.OfType().Select(d => d.ArchiveHashPath), HashedArchives); await _vfs.BackfillMissing(); @@ -190,7 +190,7 @@ public abstract class AInstaller public async Task BuildFolderStructure() { - NextStep("Preparing", "Building Folder Structure", 0); + NextStep(Consts.StepPreparing, "Building Folder Structure", 0); _logger.LogInformation("Building Folder Structure"); ModList.Directives .Where(d => d.To.Depth > 1) @@ -201,7 +201,7 @@ public abstract class AInstaller public async Task InstallArchives(CancellationToken token) { - NextStep("Installing", "Installing files", ModList.Directives.Sum(d => d.Size)); + NextStep(Consts.StepInstalling, "Installing files", ModList.Directives.Sum(d => d.Size)); var grouped = ModList.Directives .OfType() .Select(a => new {VF = _vfs.Index.FileForArchiveHashPath(a.ArchiveHashPath), Directive = a}) @@ -302,15 +302,15 @@ public abstract class AInstaller } } - _logger.LogInformation("Downloading {count} archives", missing.Count); - NextStep("Downloading", "Downloading files", missing.Count); + _logger.LogInformation("Downloading {Count} archives", missing.Count.ToString()); + NextStep(Consts.StepDownloading, "Downloading files", missing.Count); await missing .OrderBy(a => a.Size) .Where(a => a.State is not Manual) .PDoAll(async archive => { - _logger.LogInformation("Downloading {archive}", archive.Name); + _logger.LogInformation("Downloading {Archive}", archive.Name); var outputPath = _configuration.Downloads.Combine(archive.Name); if (download) @@ -364,7 +364,7 @@ public abstract class AInstaller public async Task HashArchives(CancellationToken token) { - NextStep("Hashing", "Hashing Archives", 0); + NextStep(Consts.StepHashing, "Hashing Archives", 0); _logger.LogInformation("Looking for files to hash"); var allFiles = _configuration.Downloads.EnumerateFiles() @@ -415,7 +415,7 @@ public abstract class AInstaller var savePath = (RelativePath) "saves"; var existingFiles = _configuration.Install.EnumerateFiles().ToList(); - NextStep("Preparing", "Looking for files to delete", existingFiles.Count); + NextStep(Consts.StepPreparing, "Looking for files to delete", existingFiles.Count); await existingFiles .PDoAll(async f => { @@ -434,7 +434,7 @@ public abstract class AInstaller }); _logger.LogInformation("Cleaning empty folders"); - NextStep("Preparing", "Cleaning empty folders", indexed.Keys.Count); + NextStep(Consts.StepPreparing, "Cleaning empty folders", indexed.Keys.Count); var expectedFolders = (indexed.Keys .Select(f => f.RelativeTo(_configuration.Install)) // We ignore the last part of the path, so we need a dummy file name @@ -469,7 +469,7 @@ public abstract class AInstaller var existingfiles = _configuration.Install.EnumerateFiles().ToHashSet(); - NextStep("Preparing", "Removing redundant directives", indexed.Count); + NextStep(Consts.StepPreparing, "Removing redundant directives", indexed.Count); await indexed.Values.PMapAll(async d => { // Bit backwards, but we want to return null for @@ -488,7 +488,7 @@ public abstract class AInstaller _logger.LogInformation("Optimized {optimized} directives to {indexed} required", ModList.Directives.Length, indexed.Count); - NextStep("Preparing", "Finalizing modlist optimization", 0); + NextStep(Consts.StepPreparing, "Finalizing modlist optimization", 0); var requiredArchives = indexed.Values.OfType() .GroupBy(d => d.ArchiveHashPath.Hash) .Select(d => d.Key) diff --git a/Wabbajack.Installer/Consts.cs b/Wabbajack.Installer/Consts.cs index d3ef7b15..a4c81009 100644 --- a/Wabbajack.Installer/Consts.cs +++ b/Wabbajack.Installer/Consts.cs @@ -2,7 +2,7 @@ using Wabbajack.Paths; namespace Wabbajack.Installer; -public class Consts +public static class Consts { public static string GAME_PATH_MAGIC_BACK = "{--||GAME_PATH_MAGIC_BACK||--}"; public static string GAME_PATH_MAGIC_DOUBLE_BACK = "{--||GAME_PATH_MAGIC_DOUBLE_BACK||--}"; @@ -20,4 +20,10 @@ public class Consts public static RelativePath MO2ModFolderName = "mods".ToRelativePath(); public static RelativePath MO2ProfilesFolderName = "profiles".ToRelativePath(); + + public const string StepPreparing = "Preparing"; + public const string StepInstalling = "Installing"; + public const string StepDownloading = "Downloading"; + public const string StepHashing = "Hashing"; + public const string StepFinished = "Finished"; } \ No newline at end of file diff --git a/Wabbajack.Installer/StandardInstaller.cs b/Wabbajack.Installer/StandardInstaller.cs index 13de952a..2be0601f 100644 --- a/Wabbajack.Installer/StandardInstaller.cs +++ b/Wabbajack.Installer/StandardInstaller.cs @@ -61,7 +61,7 @@ public class StandardInstaller : AInstaller { if (token.IsCancellationRequested) return false; await _wjClient.SendMetric(MetricNames.BeginInstall, ModList.Name); - NextStep("Preparing", "Configuring Installer", 0); + NextStep(Consts.StepPreparing, "Configuring Installer", 0); _logger.LogInformation("Configuring Processor"); if (_configuration.GameFolder == default) @@ -145,7 +145,7 @@ public class StandardInstaller : AInstaller await ExtractedModlistFolder!.DisposeAsync(); await _wjClient.SendMetric(MetricNames.FinishInstall, ModList.Name); - NextStep("Finished", "Finished", 1); + NextStep(Consts.StepFinished, "Finished", 1); _logger.LogInformation("Finished Installation"); return true; } @@ -275,7 +275,7 @@ public class StandardInstaller : AInstaller private async Task InstallIncludedFiles(CancellationToken token) { _logger.LogInformation("Writing inline files"); - NextStep("Installing", "Installing Included Files", ModList.Directives.OfType().Count()); + NextStep(Consts.StepInstalling, "Installing Included Files", ModList.Directives.OfType().Count()); await ModList.Directives .OfType() .PDoAll(async directive =>