Installation Configuration path error state improvements

Both inputs start blank, and have error circles to display they're unhappy.

Begin button is disabled and styled differently to match
This commit is contained in:
Justin Swanson 2019-11-02 21:36:53 -06:00
parent d872823d7a
commit 24551b62f4
2 changed files with 62 additions and 17 deletions

View File

@ -64,11 +64,17 @@ namespace Wabbajack
public bool InstallingMode { get; set; }
[Reactive]
public string Location { get; set; } = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public string Location { get; set; }
private readonly ObservableAsPropertyHelper<IErrorResponse> _LocationError;
public IErrorResponse LocationError => _LocationError.Value;
[Reactive]
public string DownloadLocation { get; set; }
private readonly ObservableAsPropertyHelper<IErrorResponse> _DownloadLocationError;
public IErrorResponse DownloadLocationError => _DownloadLocationError.Value;
private readonly ObservableAsPropertyHelper<float> _ProgressPercent;
public float ProgressPercent => _ProgressPercent.Value;
@ -222,6 +228,14 @@ namespace Wabbajack
resultSelector: (modList, mod, installing) => installing ? mod : modList)
.ToProperty(this, nameof(this.Description));
this._LocationError = this.WhenAny(x => x.Location)
.Select(x => Utils.IsDirectoryPathValid(x))
.ToProperty(this, nameof(this.LocationError));
this._DownloadLocationError = this.WhenAny(x => x.DownloadLocation)
.Select(x => Utils.IsDirectoryPathValid(x))
.ToProperty(this, nameof(this.DownloadLocationError));
// Define commands
this.ShowReportCommand = ReactiveCommand.Create(ShowReport);
this.OpenReadmeCommand = ReactiveCommand.Create(
@ -231,8 +245,16 @@ namespace Wabbajack
.ObserveOnGuiThread());
this.BeginCommand = ReactiveCommand.Create(
execute: this.ExecuteBegin,
canExecute: this.WhenAny(x => x.Installing)
.Select(installing => !installing)
canExecute: Observable.CombineLatest(
this.WhenAny(x => x.Installing),
this.WhenAny(x => x.LocationError),
this.WhenAny(x => x.DownloadLocationError),
resultSelector: (installing, loc, download) =>
{
if (installing) return false;
return (loc?.Succeeded ?? false)
&& (download?.Succeeded ?? false);
})
.ObserveOnGuiThread());
this.VisitWebsiteCommand = ReactiveCommand.Create(
execute: () => Process.Start(this.ModList.Website),
@ -242,6 +264,7 @@ namespace Wabbajack
// Have Installation location updates modify the downloads location if empty
this.WhenAny(x => x.Location)
.Skip(1) // Don't do it initially
.Subscribe(installPath =>
{
if (string.IsNullOrWhiteSpace(this.DownloadLocation))

View File

@ -617,7 +617,8 @@
Margin="0,0,14,0"
HorizontalAlignment="Right"
Background="{StaticResource PrimaryVariantBrush}"
CornerRadius="43">
CornerRadius="43"
Visibility="{Binding IsEnabled, ElementName=BeginButton, Converter={StaticResource bool2VisibilityConverter}}">
<Border.Effect>
<BlurEffect Radius="10" />
</Border.Effect>
@ -645,6 +646,7 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
AdditionalError="{Binding LocationError}"
DoExistsCheck="False"
FontSize="14"
PathType="Folder"
@ -663,6 +665,7 @@
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
AdditionalError="{Binding DownloadLocationError}"
DoExistsCheck="False"
FontSize="14"
PathType="Folder"
@ -677,10 +680,7 @@
Height="55"
Margin="0,0,25,0"
HorizontalAlignment="Right"
Background="#222222"
BorderBrush="{StaticResource SecondaryBrush}"
Command="{Binding BeginCommand}"
Style="{StaticResource CircleButtonStyle}">
Command="{Binding BeginCommand}">
<icon:PackIconMaterial
Width="25"
Height="25"
@ -688,21 +688,43 @@
Kind="Play">
<icon:PackIconMaterial.Style>
<Style TargetType="icon:PackIconMaterial">
<Setter Property="Foreground" Value="{StaticResource SecondaryBrush}" />
<Setter Property="Foreground" Value="#666666" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=BeginButton}" Value="True">
<Setter Property="Foreground" Value="#00ffe7" />
<DataTrigger Binding="{Binding IsEnabled, ElementName=BeginButton}" Value="True">
<Setter Property="Foreground" Value="{StaticResource SecondaryBrush}" />
</DataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, ElementName=BeginButton}" Value="True" />
<Condition Binding="{Binding IsEnabled, ElementName=BeginButton}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Foreground" Value="#00ffe7" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</icon:PackIconMaterial.Style>
</icon:PackIconMaterial>
<Button.Effect>
<DropShadowEffect
BlurRadius="15"
ShadowDepth="0"
Color="{StaticResource Secondary}" />
</Button.Effect>
<Button.Style>
<Style BasedOn="{StaticResource CircleButtonStyle}" TargetType="Button">
<Setter Property="Background" Value="#333333" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsEnabled, ElementName=BeginButton}" Value="True">
<Setter Property="BorderBrush" Value="{StaticResource SecondaryBrush}" />
<Setter Property="Background" Value="#222222" />
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect
BlurRadius="15"
ShadowDepth="0"
Color="{StaticResource Secondary}" />
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
</ScrollViewer>