From 96cf38a5969c11f1bcd0b36337a5eb630a99512b Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Sun, 25 Sep 2022 21:35:53 -0600 Subject: [PATCH] Fix compiler status text --- Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs | 2 +- Wabbajack.Compiler/ACompiler.cs | 11 +++++++---- Wabbajack.Installer/AInstaller.cs | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs b/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs index 26301311..6d1d60d3 100644 --- a/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs +++ b/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs @@ -307,7 +307,7 @@ namespace Wabbajack .Subscribe(update => { var s = update.EventArgs; - StatusText = $"[{s.StepsProgress}] {s.StatusText}"; + StatusText = $"[Step {s.CurrentStep}] {s.StatusText}"; StatusProgress = s.StepProgress; }); diff --git a/Wabbajack.Compiler/ACompiler.cs b/Wabbajack.Compiler/ACompiler.cs index b1180bd7..dd614b36 100644 --- a/Wabbajack.Compiler/ACompiler.cs +++ b/Wabbajack.Compiler/ACompiler.cs @@ -121,7 +121,7 @@ public abstract class ACompiler if (OnStatusUpdate != null) OnStatusUpdate(this, new StatusUpdate(statusCategory, statusText, Percent.FactoryPutInRange(_currentStep, MaxSteps), - Percent.Zero)); + Percent.Zero, _currentStep)); } public void UpdateProgress(long stepProgress) @@ -136,7 +136,7 @@ public abstract class ACompiler if (OnStatusUpdate != null) OnStatusUpdate(this, new StatusUpdate(_statusCategory, _statusText, Percent.FactoryPutInRange(_currentStep, MaxSteps), - Percent.FactoryPutInRange(_currentStepProgress, _maxStepProgress))); + Percent.FactoryPutInRange(_currentStepProgress, _maxStepProgress), _currentStep)); } public void UpdateProgressAbsolute(long cur, long max) @@ -152,7 +152,7 @@ public abstract class ACompiler if (OnStatusUpdate != null) OnStatusUpdate(this, new StatusUpdate(_statusCategory, _statusText, Percent.FactoryPutInRange(_currentStep, MaxSteps), - Percent.FactoryPutInRange(_currentStepProgress, _maxStepProgress))); + Percent.FactoryPutInRange(_currentStepProgress, _maxStepProgress), _currentStep)); } public abstract Task Begin(CancellationToken token); @@ -396,12 +396,15 @@ public abstract class ACompiler _settings.OutputFile.Delete(); + var allFiles = _stagingFolder.EnumerateFiles().ToList(); + NextStep("Finalizing", "Writing Wabbajack File", allFiles.Count); await using (var fs = _settings.OutputFile.Open(FileMode.Create, FileAccess.Write)) { using var za = new ZipArchive(fs, ZipArchiveMode.Create); - foreach (var f in _stagingFolder.EnumerateFiles()) + foreach (var f in allFiles) { + UpdateProgress(1); var ze = za.CreateEntry((string) f.FileName); await using var os = ze.Open(); await using var ins = f.Open(FileMode.Open); diff --git a/Wabbajack.Installer/AInstaller.cs b/Wabbajack.Installer/AInstaller.cs index 4c1e4603..cc25929c 100644 --- a/Wabbajack.Installer/AInstaller.cs +++ b/Wabbajack.Installer/AInstaller.cs @@ -26,7 +26,7 @@ using Wabbajack.VFS; namespace Wabbajack.Installer; -public record StatusUpdate(string StatusCategory, string StatusText, Percent StepsProgress, Percent StepProgress) +public record StatusUpdate(string StatusCategory, string StatusText, Percent StepsProgress, Percent StepProgress, int CurrentStep) { } @@ -113,7 +113,7 @@ public abstract class AInstaller _logger.LogInformation("Next Step: {Step}", statusText); OnStatusUpdate?.Invoke(new StatusUpdate(statusCategory, statusText, - Percent.FactoryPutInRange(_currentStep, MaxSteps), Percent.Zero)); + Percent.FactoryPutInRange(_currentStep, MaxSteps), Percent.Zero, _currentStep)); } public void UpdateProgress(long stepProgress) @@ -122,7 +122,7 @@ public abstract class AInstaller OnStatusUpdate?.Invoke(new StatusUpdate(_statusCategory, $"[{_currentStep}/{MaxSteps}] {_statusText} ({_statusFormatter(_currentStepProgress)}/{_statusFormatter(MaxStepProgress)})", Percent.FactoryPutInRange(_currentStep, MaxSteps), - Percent.FactoryPutInRange(_currentStepProgress, MaxStepProgress))); + Percent.FactoryPutInRange(_currentStepProgress, MaxStepProgress), _currentStep)); } public abstract Task Begin(CancellationToken token);