Failure compiles/installs show red

This commit is contained in:
Justin Swanson 2019-12-18 23:22:39 -06:00
parent b4bdaa5f07
commit 5a8c19fbae
8 changed files with 100 additions and 34 deletions

View File

@ -58,7 +58,7 @@ namespace Wabbajack
public bool StartedCompilation { get; set; }
[Reactive]
public bool Completed { get; set; }
public ErrorResponse? Completed { get; set; }
public CompilerVM(MainWindowVM mainWindowVM)
{
@ -137,7 +137,7 @@ namespace Wabbajack
{
mainWindowVM.ActivePane = mainWindowVM.ModeSelectionVM;
StartedCompilation = false;
Completed = false;
Completed = null;
},
canExecute: this.WhenAny(x => x.Compiling)
.Select(x => !x));
@ -174,7 +174,7 @@ namespace Wabbajack
{
if (compiler == null)
{
return Observable.Return<float>(completed ? 1f : 0f);
return Observable.Return<float>(completed != null ? 1f : 0f);
}
return compiler.PercentCompleted.StartWith(0);
})
@ -190,9 +190,11 @@ namespace Wabbajack
try
{
await this.Compiler.Compile();
Completed = ErrorResponse.Success;
}
catch (Exception ex)
{
Completed = ErrorResponse.Fail(ex);
while (ex.InnerException != null) ex = ex.InnerException;
Utils.Error(ex, $"Compiler error");
}
@ -206,14 +208,6 @@ namespace Wabbajack
})
.DisposeWith(CompositeDisposable);
// When sub compiler finishes a compile, mark state variable
BeginCommand.EndingExecution()
.Subscribe(_ =>
{
Completed = true;
})
.DisposeWith(CompositeDisposable);
// Listen for user interventions, and compile a dynamic list of all unhandled ones
var activeInterventions = this.WhenAny(x => x.Compiler.ActiveCompilation)
.SelectMany(c => c?.LogMessages ?? Observable.Empty<IStatusMessage>())
@ -231,14 +225,16 @@ namespace Wabbajack
.ToProperty(this, nameof(ActiveGlobalUserIntervention));
CloseWhenCompleteCommand = ReactiveCommand.Create(
canExecute: this.WhenAny(x => x.Completed),
canExecute: this.WhenAny(x => x.Completed)
.Select(x => x != null),
execute: () =>
{
MWVM.ShutdownApplication();
});
GoToModlistCommand = ReactiveCommand.Create(
canExecute: this.WhenAny(x => x.Completed),
canExecute: this.WhenAny(x => x.Completed)
.Select(x => x != null),
execute: () =>
{
if (string.IsNullOrWhiteSpace(OutputLocation.TargetPath))

View File

@ -50,7 +50,7 @@ namespace Wabbajack
public bool StartedInstallation { get; set; }
[Reactive]
public bool Completed { get; set; }
public ErrorResponse? Completed { get; set; }
private readonly ObservableAsPropertyHelper<ImageSource> _image;
public ImageSource Image => _image.Value;
@ -181,7 +181,7 @@ namespace Wabbajack
execute: () =>
{
StartedInstallation = false;
Completed = false;
Completed = null;
mainWindowVM.ActivePane = mainWindowVM.ModeSelectionVM;
},
canExecute: this.WhenAny(x => x.Installing)
@ -195,7 +195,7 @@ namespace Wabbajack
{
if (installer == null)
{
return Observable.Return<float>(completed ? 1f : 0f);
return Observable.Return<float>(completed != null ? 1f : 0f);
}
return installer.PercentCompleted.StartWith(0f);
})
@ -315,6 +315,7 @@ namespace Wabbajack
try
{
await this.Installer.Install();
Completed = ErrorResponse.Success;
}
catch (Exception ex)
{
@ -322,6 +323,7 @@ namespace Wabbajack
Utils.Log(ex.StackTrace);
Utils.Log(ex.ToString());
Utils.Log($"{ex.Message} - Can't continue");
Completed = ErrorResponse.Fail(ex);
}
});
@ -333,14 +335,6 @@ namespace Wabbajack
})
.DisposeWith(CompositeDisposable);
// When sub installer ends an install, mark state variable
BeginCommand.EndingExecution()
.Subscribe(_ =>
{
Completed = true;
})
.DisposeWith(CompositeDisposable);
// Listen for user interventions, and compile a dynamic list of all unhandled ones
var activeInterventions = this.WhenAny(x => x.Installer.ActiveInstallation)
.SelectMany(c => c?.LogMessages ?? Observable.Empty<IStatusMessage>())
@ -358,7 +352,8 @@ namespace Wabbajack
.ToProperty(this, nameof(ActiveGlobalUserIntervention));
CloseWhenCompleteCommand = ReactiveCommand.Create(
canExecute: this.WhenAny(x => x.Completed),
canExecute: this.WhenAny(x => x.Completed)
.Select(x => x != null),
execute: () =>
{
MWVM.ShutdownApplication();
@ -366,7 +361,8 @@ namespace Wabbajack
GoToInstallCommand = ReactiveCommand.Create(
canExecute: Observable.CombineLatest(
this.WhenAny(x => x.Completed),
this.WhenAny(x => x.Completed)
.Select(x => x != null),
this.WhenAny(x => x.Installer.SupportsAfterInstallNavigation),
resultSelector: (complete, supports) => complete && supports),
execute: () =>

View File

@ -18,6 +18,7 @@
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsVisible, RelativeSource={RelativeSource Self}}" Value="True" />
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="False" />
<Condition Binding="{Binding Failure, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Value="False" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard>
@ -60,6 +61,53 @@
</BeginStoryboard>
</MultiDataTrigger.ExitActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsVisible, RelativeSource={RelativeSource Self}}" Value="True" />
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="False" />
<Condition Binding="{Binding Failure, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
AutoReverse="True"
RepeatBehavior="Forever"
Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
To="#ff0026"
Duration="0:0:1.5" />
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
AutoReverse="True"
RepeatBehavior="Forever"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#540914"
Duration="0:0:1.5" />
</Storyboard>
</BeginStoryboard>
</MultiDataTrigger.EnterActions>
<MultiDataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
To="#700d1c"
Duration="0:0:0.1" />
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#1c0307"
Duration="0:0:0.1" />
</Storyboard>
</BeginStoryboard>
</MultiDataTrigger.ExitActions>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Border.Style>

View File

@ -28,6 +28,14 @@ namespace Wabbajack
public static readonly DependencyProperty DisplayContentProperty = DependencyProperty.Register(nameof(DisplayContent), typeof(object), typeof(AttentionBorder),
new FrameworkPropertyMetadata(default(object)));
public bool Failure
{
get => (bool)GetValue(FailureProperty);
set => SetValue(FailureProperty, value);
}
public static readonly DependencyProperty FailureProperty = DependencyProperty.Register(nameof(Failure), typeof(bool), typeof(AttentionBorder),
new FrameworkPropertyMetadata(default(bool)));
public AttentionBorder()
{
InitializeComponent();

View File

@ -9,7 +9,7 @@
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<local:AttentionBorder ClipToBounds="True">
<local:AttentionBorder ClipToBounds="True" Failure="{Binding Completed.Failed}">
<local:AttentionBorder.DisplayContent>
<Grid Margin="5">
<Grid.RowDefinitions>
@ -29,11 +29,20 @@
VerticalAlignment="Bottom"
FontFamily="Lucida Sans"
FontSize="22"
FontWeight="Black"
Text="Compilation Complete">
FontWeight="Black">
<TextBlock.Effect>
<DropShadowEffect BlurRadius="25" Opacity="0.5" />
</TextBlock.Effect>
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="Compilation Complete" />
<Style.Triggers>
<DataTrigger Binding="{Binding Completed.Failed}" Value="True">
<Setter Property="Text" Value="Compilation Failed" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<Grid
Grid.Row="1"

View File

@ -258,7 +258,7 @@
</Grid>
</local:AttentionBorder.DisplayContent>
</local:AttentionBorder>
<local:CompilationCompleteView Grid.Column="2" Visibility="{Binding Completed, Converter={StaticResource bool2VisibilityConverter}, FallbackValue=Collapsed}" />
<local:CompilationCompleteView Grid.Column="2" Visibility="{Binding Completed, Converter={StaticResource IsNotNullVisibilityConverter}, FallbackValue=Collapsed}" />
</Grid>
</Grid>
</UserControl>

View File

@ -9,7 +9,7 @@
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<local:AttentionBorder ClipToBounds="True">
<local:AttentionBorder ClipToBounds="True" Failure="{Binding Completed.Failed}">
<local:AttentionBorder.DisplayContent>
<Grid Margin="5">
<Grid.RowDefinitions>
@ -30,11 +30,20 @@
VerticalAlignment="Bottom"
FontFamily="Lucida Sans"
FontSize="22"
FontWeight="Black"
Text="Installation Complete">
FontWeight="Black">
<TextBlock.Effect>
<DropShadowEffect BlurRadius="25" Opacity="0.5" />
</TextBlock.Effect>
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="Installation Complete" />
<Style.Triggers>
<DataTrigger Binding="{Binding Completed.Failed}" Value="True">
<Setter Property="Text" Value="Installation Failed" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<Grid
Grid.Row="1"

View File

@ -413,7 +413,7 @@
</Grid>
</local:AttentionBorder.DisplayContent>
</local:AttentionBorder>
<local:InstallationCompleteView Grid.Column="2" Visibility="{Binding Completed, Converter={StaticResource bool2VisibilityConverter}, FallbackValue=Collapsed}" />
<local:InstallationCompleteView Grid.Column="2" Visibility="{Binding Completed, Converter={StaticResource IsNotNullVisibilityConverter}, FallbackValue=Collapsed}" />
</Grid>
</Grid>
</UserControl>