Compiler-side progress bars wired up again

This commit is contained in:
Justin Swanson 2019-11-23 21:11:25 -06:00
parent fbe3b9edb7
commit ece11e9f41
3 changed files with 21 additions and 3 deletions

View File

@ -38,9 +38,9 @@ namespace Wabbajack.Common
_progress.OnNext(0.0f);
}
public void MakeUpdate(double progress)
public void MakeUpdate(float progress)
{
_progress.OnNext((float)0.0);
_progress.OnNext(progress);
}
public void MakeUpdate(int max, int curr)

View File

@ -34,6 +34,9 @@ namespace Wabbajack
private readonly ObservableAsPropertyHelper<bool> _compiling;
public bool Compiling => _compiling.Value;
private readonly ObservableAsPropertyHelper<float> _percentCompleted;
public float PercentCompleted => _percentCompleted.Value;
public CompilerVM(MainWindowVM mainWindowVM)
{
MWVM = mainWindowVM;
@ -113,6 +116,21 @@ namespace Wabbajack
.Bind(MWVM.StatusList)
.Subscribe()
.DisposeWith(CompositeDisposable);
_percentCompleted = this.WhenAny(x => x.Compiler.ActiveCompilation)
.StartWith(default(ACompiler))
.Pairwise()
.Select(c =>
{
if (c.Current == null)
{
return Observable.Return<float>(c.Previous == null ? 0f : 1f);
}
return c.Current.PercentCompleted;
})
.Switch()
.Debounce(TimeSpan.FromMilliseconds(25))
.ToProperty(this, nameof(PercentCompleted));
}
}
}

View File

@ -56,7 +56,7 @@
Grid.Column="0"
Grid.ColumnSpan="5"
OverhangShadow="True"
ProgressPercent="{Binding ProgressPercent}"
ProgressPercent="{Binding PercentCompleted}"
StatePrefixTitle="Compiling" />
<ScrollViewer
Grid.Row="1"