ISubCompilerVM.ActiveCompilation

This commit is contained in:
Justin Swanson 2019-11-20 23:15:47 -06:00
parent 2bebad5fae
commit 587395e98b
5 changed files with 27 additions and 25 deletions

View File

@ -32,6 +32,9 @@ namespace Wabbajack
private readonly ObservableAsPropertyHelper<StatusUpdateTracker> _CurrentStatusTracker;
public StatusUpdateTracker CurrentStatusTracker => _CurrentStatusTracker.Value;
private readonly ObservableAsPropertyHelper<bool> _Compiling;
public bool Compiling => _Compiling.Value;
public CompilerVM(MainWindowVM mainWindowVM)
{
this.MWVM = mainWindowVM;
@ -93,6 +96,11 @@ namespace Wabbajack
return null;
})
.ToProperty(this, nameof(this.Image));
this._Compiling = this.WhenAny(x => x.Compiler.ActiveCompilation)
.Select(compilation => compilation != null)
.ObserveOnGuiThread()
.ToProperty(this, nameof(this.Compiling));
}
}
}

View File

@ -6,13 +6,14 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack
{
public interface ISubCompilerVM
{
IReactiveCommand BeginCommand { get; }
bool Compiling { get; }
ACompiler ActiveCompilation { get; }
ModlistSettingsEditorVM ModlistSettings { get; }
StatusUpdateTracker StatusTracker { get;}

View File

@ -31,8 +31,8 @@ namespace Wabbajack
public IReactiveCommand BeginCommand { get; }
private readonly ObservableAsPropertyHelper<bool> _Compiling;
public bool Compiling => _Compiling.Value;
[Reactive]
public ACompiler ActiveCompilation { get; private set; }
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _ModlistSettings;
public ModlistSettingsEditorVM ModlistSettings => _ModlistSettings.Value;
@ -101,10 +101,9 @@ namespace Wabbajack
.ObserveOnGuiThread(),
execute: async () =>
{
MO2Compiler compiler;
try
{
compiler = new MO2Compiler(this.Mo2Folder)
this.ActiveCompilation = new MO2Compiler(this.Mo2Folder)
{
MO2Profile = this.MOProfile,
ModListName = this.ModlistSettings.ModListName,
@ -114,10 +113,6 @@ namespace Wabbajack
ModListWebsite = this.ModlistSettings.Website,
ModListReadme = this.ModlistSettings.ReadMeText.TargetPath,
};
// TODO: USE RX HERE
compiler.TextStatus.Subscribe(Utils.Log);
// TODO: Where do we bind this?
//compiler.QueueStatus.Subscribe(_cpuStatus);
}
catch (Exception ex)
{
@ -128,7 +123,7 @@ namespace Wabbajack
try
{
await compiler.Begin();
await this.ActiveCompilation.Begin();
}
catch (Exception ex)
{
@ -138,12 +133,11 @@ namespace Wabbajack
finally
{
this.StatusTracker = null;
compiler.Dispose();
this.ActiveCompilation.Dispose();
this.ActiveCompilation = null;
}
});
this._Compiling = this.BeginCommand.IsExecuting
.ToProperty(this, nameof(this.Compiling));
// Load settings
this.settings = parent.MWVM.Settings.Compiler.MO2Compilation;

View File

@ -18,9 +18,6 @@ namespace Wabbajack
public IReactiveCommand BeginCommand { get; }
private readonly ObservableAsPropertyHelper<bool> _compiling;
public bool Compiling => _compiling.Value;
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _modListSettings;
public ModlistSettingsEditorVM ModlistSettings => _modListSettings.Value;
@ -32,6 +29,9 @@ namespace Wabbajack
public ObservableCollectionExtended<GameVM> GameOptions => _gameOptions;
[Reactive]
public ACompiler ActiveCompilation { get; private set; }
[Reactive]
public GameVM SelectedGame { get; set; }
@ -82,10 +82,9 @@ namespace Wabbajack
.ObserveOnGuiThread(),
execute: async () =>
{
VortexCompiler compiler;
try
{
compiler = new VortexCompiler(
this.ActiveCompilation = new VortexCompiler(
SelectedGame.Game,
GameLocation.TargetPath,
VortexCompiler.TypicalVortexFolder(),
@ -110,7 +109,7 @@ namespace Wabbajack
{
try
{
await compiler.Begin();
await this.ActiveCompilation.Begin();
}
catch (Exception ex)
{
@ -120,11 +119,11 @@ namespace Wabbajack
finally
{
this.StatusTracker = null;
this.ActiveCompilation.Dispose();
this.ActiveCompilation = null;
}
});
});
_compiling = BeginCommand.IsExecuting
.ToProperty(this, nameof(Compiling));
// Load settings
_settings = parent.MWVM.Settings.Compiler.VortexCompilation;

View File

@ -64,7 +64,7 @@
Margin="5"
Background="Transparent"
HorizontalScrollBarVisibility="Disabled"
IsEnabled="{Binding Compiler.Compiling, Converter={StaticResource InverseBooleanConverter}}"
IsEnabled="{Binding Compiling, Converter={StaticResource InverseBooleanConverter}}"
VerticalScrollBarVisibility="Auto">
<StackPanel
Margin="0,5,0,0"
@ -152,7 +152,7 @@
Margin="35,0,35,0"
VerticalAlignment="Center"
ClipToBounds="False"
Visibility="{Binding Compiler.Compiling, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}">
Visibility="{Binding Compiling, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
@ -218,7 +218,7 @@
Grid.Column="0"
Grid.ColumnSpan="5"
Margin="5"
Visibility="{Binding Compiler.Compiling, Converter={StaticResource bool2VisibilityConverter}, FallbackValue=Hidden}">
Visibility="{Binding Compiling, Converter={StaticResource bool2VisibilityConverter}, FallbackValue=Hidden}">
<local:LogCpuView DataContext="{Binding MWVM}" />
</Grid>
</Grid>