CompilerView revamp. Wiring still needs work

This commit is contained in:
Justin Swanson 2019-11-09 14:28:31 -06:00
parent c340cadd42
commit f339c633bb
2 changed files with 142 additions and 214 deletions

View File

@ -26,16 +26,16 @@ namespace Wabbajack
public string ModListName { get; set; } public string ModListName { get; set; }
[Reactive] [Reactive]
public string Location { get; set; } public string ModlistLocation { get; set; }
[Reactive] [Reactive]
public bool UIReady { get; set; } = true; public bool Compiling { get; set; }
[Reactive] [Reactive]
public string AuthorName { get; set; } public string AuthorText { get; set; }
[Reactive] [Reactive]
public string Summary { get; set; } = "Description (700 characters max)"; public string Description { get; set; }
[Reactive] [Reactive]
public string ImagePath { get; set; } public string ImagePath { get; set; }
@ -55,16 +55,23 @@ namespace Wabbajack
[Reactive] [Reactive]
public string DownloadLocation { get; set; } public string DownloadLocation { get; set; }
[Reactive]
public bool ModlistLocationInError { get; set; }
[Reactive]
public bool DownloadLocationInError { get; set; }
public IReactiveCommand BeginCommand { get; } public IReactiveCommand BeginCommand { get; }
public CompilerVM(MainWindowVM mainWindowVM, string source) public CompilerVM(MainWindowVM mainWindowVM, string source)
{ {
this.MWVM = mainWindowVM; this.MWVM = mainWindowVM;
this.Location = source; this.ModlistLocation = source;
this.BeginCommand = ReactiveCommand.CreateFromTask( this.BeginCommand = ReactiveCommand.CreateFromTask(
execute: this.ExecuteBegin, execute: this.ExecuteBegin,
canExecute: this.WhenAny(x => x.UIReady) canExecute: this.WhenAny(x => x.Compiling)
.Select(compiling => !compiling)
.ObserveOnGuiThread()); .ObserveOnGuiThread());
this._Image = this.WhenAny(x => x.ImagePath) this._Image = this.WhenAny(x => x.ImagePath)
@ -83,9 +90,9 @@ namespace Wabbajack
// Load settings // Load settings
CompilationSettings settings = this.MWVM.Settings.CompilationSettings.TryCreate(source); CompilationSettings settings = this.MWVM.Settings.CompilationSettings.TryCreate(source);
this.AuthorName = settings.Author; this.AuthorText = settings.Author;
this.ModListName = settings.ModListName; this.ModListName = settings.ModListName;
this.Summary = settings.Description; this.Description = settings.Description;
this.ReadMeText = settings.Readme; this.ReadMeText = settings.Readme;
this.ImagePath = settings.SplashScreen; this.ImagePath = settings.SplashScreen;
this.Website = settings.Website; this.Website = settings.Website;
@ -95,18 +102,18 @@ namespace Wabbajack
} }
if (!string.IsNullOrWhiteSpace(settings.Location)) if (!string.IsNullOrWhiteSpace(settings.Location))
{ {
this.Location = settings.Location; this.ModlistLocation = settings.Location;
} }
this.MWVM.Settings.SaveSignal this.MWVM.Settings.SaveSignal
.Subscribe(_ => .Subscribe(_ =>
{ {
settings.Author = this.AuthorName; settings.Author = this.AuthorText;
settings.ModListName = this.ModListName; settings.ModListName = this.ModListName;
settings.Description = this.Summary; settings.Description = this.Description;
settings.Readme = this.ReadMeText; settings.Readme = this.ReadMeText;
settings.SplashScreen = this.ImagePath; settings.SplashScreen = this.ImagePath;
settings.Website = this.Website; settings.Website = this.Website;
settings.Location = this.Location; settings.Location = this.ModlistLocation;
settings.DownloadLocation = this.DownloadLocation; settings.DownloadLocation = this.DownloadLocation;
}) })
.DisposeWith(this.CompositeDisposable); .DisposeWith(this.CompositeDisposable);
@ -136,15 +143,15 @@ namespace Wabbajack
{ {
MO2Profile = this.MOProfile, MO2Profile = this.MOProfile,
ModListName = this.ModListName, ModListName = this.ModListName,
ModListAuthor = this.AuthorName, ModListAuthor = this.AuthorText,
ModListDescription = this.Summary, ModListDescription = this.Description,
ModListImage = this.ImagePath, ModListImage = this.ImagePath,
ModListWebsite = this.Website, ModListWebsite = this.Website,
ModListReadme = this.ReadMeText, ModListReadme = this.ReadMeText,
}; };
await Task.Run(() => await Task.Run(() =>
{ {
UIReady = false; Compiling = true;
try try
{ {
compiler.Compile(); compiler.Compile();
@ -160,14 +167,14 @@ namespace Wabbajack
} }
finally finally
{ {
UIReady = true; Compiling = false;
} }
}); });
} }
else else
{ {
Utils.Log("Cannot compile modlist: no valid Mod Organizer profile directory selected."); Utils.Log("Cannot compile modlist: no valid Mod Organizer profile directory selected.");
UIReady = true; Compiling = false;
} }
} }
} }

View File

@ -6,78 +6,36 @@
xmlns:local="clr-namespace:Wabbajack" xmlns:local="clr-namespace:Wabbajack"
xmlns:mahapps="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:mahapps="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DataContext="{d:DesignInstance local:CompilerVM}"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">
<Viewbox Stretch="Uniform"> <Grid>
<Grid Margin="4,0,4,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="45" />
<RowDefinition Height="435" /> <RowDefinition Height="4*" />
<RowDefinition Height="10" /> <RowDefinition Height="*" MinHeight="150" />
<RowDefinition Height="Auto" />
<RowDefinition Height="320" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="638" />
<ColumnDefinition Width="4" />
<ColumnDefinition Width="638" />
</Grid.ColumnDefinitions>
<StackPanel
Grid.Row="0"
Margin="0,8,0,8"
Orientation="Horizontal">
<TextBlock
FontSize="16"
FontWeight="Bold"
Text="Compiling" />
<TextBlock FontSize="16" Text=" : " />
<TextBlock FontSize="16" Text="{Binding MOProfile}" />
</StackPanel>
<Grid <Grid
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Margin="5,0"
Margin="0,8,0,8" ClipToBounds="False">
IsEnabled="{Binding UIReady}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image
Grid.Row="0"
Source="{Binding Image}"
Stretch="Fill" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="1" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="Splash Screen Path:" />
<local:FilePicker
Grid.Column="1"
Width="534"
HorizontalAlignment="Left"
DoExistsCheck="False"
Filter="Banner image|*.png"
IsEnabled="{Binding UIReady}"
PathType="File"
TargetPath="{Binding ImagePath}" />
</Grid>
</Grid>
<ScrollViewer <ScrollViewer
Grid.Row="1" Grid.Column="0"
Grid.Column="2" Margin="5,0,5,5"
Background="Transparent" Background="Transparent"
HorizontalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled"
IsEnabled="{Binding UIReady}" IsEnabled="{Binding UIReady}"
VerticalScrollBarVisibility="Auto"> VerticalScrollBarVisibility="Auto">
<StackPanel Background="Transparent" Orientation="Vertical"> <StackPanel
Margin="0,20,0,0"
Background="Transparent"
Orientation="Vertical">
<StackPanel.Resources> <StackPanel.Resources>
<Thickness <Thickness
x:Key="TitleMargin" x:Key="TitleMargin"
@ -94,9 +52,9 @@
</Style> </Style>
</StackPanel.Resources> </StackPanel.Resources>
<TextBlock Margin="{StaticResource TitleMargin}" Text="ModList Name" /> <TextBlock Margin="{StaticResource TitleMargin}" Text="ModList Name" />
<TextBox Style="{StaticResource ValueStyle}" Text="{Binding ModListName}" /> <TextBox Style="{StaticResource ValueStyle}" Text="{Binding ModListName, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Margin="{StaticResource TitleMargin}" Text="Author" /> <TextBlock Margin="{StaticResource TitleMargin}" Text="Author" />
<TextBox Style="{StaticResource ValueStyle}" Text="{Binding AuthorName}" /> <TextBox Style="{StaticResource ValueStyle}" Text="{Binding AuthorText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Margin="{StaticResource TitleMargin}" Text="Description" /> <TextBlock Margin="{StaticResource TitleMargin}" Text="Description" />
<TextBox <TextBox
Height="150" Height="150"
@ -105,7 +63,7 @@
AcceptsTab="False" AcceptsTab="False"
MaxLength="700" MaxLength="700"
Style="{StaticResource ValueStyle}" Style="{StaticResource ValueStyle}"
Text="{Binding Summary}" Text="{Binding Description, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<TextBlock Margin="{StaticResource TitleMargin}" Text="Website" /> <TextBlock Margin="{StaticResource TitleMargin}" Text="Website" />
<TextBox Style="{StaticResource ValueStyle}" Text="{Binding Website}" /> <TextBox Style="{StaticResource ValueStyle}" Text="{Binding Website}" />
@ -120,148 +78,111 @@
ToolTip="Path to a readme file." /> ToolTip="Path to a readme file." />
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
<local:DetailImageView
<ProgressBar Title="{Binding ModListName}"
Grid.Row="2" Grid.Column="2"
Grid.Column="0" Author="{Binding AuthorText}"
Grid.ColumnSpan="3" BorderThickness="0"
Margin="1,0,1,0" Description="{Binding Description}"
Background="#444444" Image="{Binding Image}" />
Maximum="100" <Rectangle
Minimum="0" x:Name="ControlVerticalThinSeparator"
Value="{Binding MWVM.QueueProgress, Mode=OneWay}" /> Grid.Column="1"
Width="1"
<!-- Log --> HorizontalAlignment="Center"
<TextBlock Fill="{StaticResource DarkBackgroundBrush}"
Grid.Row="3" SnapsToDevicePixels="True" />
Margin="0,16,0,8" </Grid>
FontSize="14" <!-- Comes after center area so shadow can overlay -->
Text="Log:" /> <local:TopProgressView
<ListBox Title="{Binding ModListName, Mode=OneWay}"
Grid.Row="4" Grid.Row="0"
Margin="0,0,2,0"
local:AutoScrollBehavior.ScrollOnNewItem="True"
ItemsSource="{Binding MWVM.Log}" />
<!-- End Log -->
<!-- Location -->
<Grid
Grid.Row="5"
Grid.RowSpan="2" Grid.RowSpan="2"
Grid.Column="0" OverhangShadow="True"
Margin="-4,10,0,10" ProgressPercent="{Binding ProgressPercent}"
HorizontalAlignment="Stretch"> StatePrefixTitle="Compiling" />
<Rectangle
x:Name="ControlTopThinSeparator"
Grid.Row="2"
Height="1"
Margin="25,0"
VerticalAlignment="Top"
Fill="{StaticResource DarkBackgroundBrush}"
SnapsToDevicePixels="True" />
<Grid Grid.Row="2" MaxWidth="1000">
<Border
x:Name="ConfigurationBackgroundHaze"
Height="120"
Background="{StaticResource PrimaryVariantBrush}"
CornerRadius="50"
Opacity="0.10">
<Border.Effect>
<BlurEffect Radius="45" />
</Border.Effect>
</Border>
<Grid
Margin="35,0,35,0"
VerticalAlignment="Center"
ClipToBounds="False"
Visibility="{Binding Compiling, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition MinHeight="10" />
<RowDefinition />
</Grid.RowDefinitions>
<Label
Grid.Row="0"
Grid.Column="0"
Content="Installation Location:" />
<local:FilePicker
Grid.Row="0"
Grid.Column="1"
DoExistsCheck="False"
IsEnabled="{Binding UIReady}"
PathType="Folder"
SetTargetPathCommand="{Binding ChangePathCommand}"
TargetPath="{Binding Location}" />
<Label
Grid.Row="2"
Grid.Column="0"
Content="Download Location:" />
<local:FilePicker
Grid.Row="2"
Grid.Column="1"
DoExistsCheck="False"
IsEnabled="{Binding UIReady}"
PathType="Folder"
SetTargetPathCommand="{Binding ChangeDownloadPathCommand}"
TargetPath="{Binding DownloadLocation}" />
</Grid>
<!-- End Location -->
<!-- Work Queue Start -->
<TextBlock <TextBlock
Grid.Row="3"
Grid.Column="2"
Margin="0,16,0,8"
FontSize="14"
Text="Work Queue:" />
<ListBox
Grid.Row="4"
Grid.Column="2"
Width="Auto"
HorizontalAlignment="Stretch"
ItemsSource="{Binding MWVM.StatusList}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ProgressBar
Grid.Column="0"
Width="100"
Maximum="100"
Minimum="0"
Value="{Binding Progress, Mode=OneTime}">
<ProgressBar.Style>
<Style TargetType="ProgressBar">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding Progress}" Value="0">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</ProgressBar.Style>
</ProgressBar>
<TextBlock Grid.Column="1" Text=" CPU " />
<TextBlock Grid.Column="2" Text="{Binding ID}" />
<TextBlock Grid.Column="3" Text=" - " />
<TextBlock Grid.Column="4" Text="{Binding Msg}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- Work Queue End -->
<Grid
Grid.Row="5"
Grid.RowSpan="2"
Grid.Column="2"
Margin="0,10,0,10">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Button
Grid.Row="0" Grid.Row="0"
Margin="0,0,0,4" Grid.Column="0"
Command="{Binding ShowReportCommand}" HorizontalAlignment="Right"
Visibility="{Binding HTMLReport, Converter={StaticResource IsNotNullVisibilityConverter}}"> VerticalAlignment="Center"
<TextBlock FontSize="13" FontWeight="Bold">View ModList Contents</TextBlock> FontSize="14"
</Button> Text="Modlist Location"
<Button TextAlignment="Center" />
<local:FilePicker
Grid.Row="0"
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DoExistsCheck="True"
FontSize="14"
PathType="File"
PromptTitle="Select Modlist"
TargetPath="{Binding ModlistLocation}" />
<TextBlock
Grid.Row="1" Grid.Row="1"
Margin="0,4,0,0" Grid.Column="0"
Command="{Binding BeginCommand}"> HorizontalAlignment="Right"
<TextBlock FontSize="13" FontWeight="Bold">Begin</TextBlock> VerticalAlignment="Center"
</Button> FontSize="14"
Text="Download Location"
TextAlignment="Center" />
<local:FilePicker
Grid.Row="1"
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DoExistsCheck="True"
FontSize="14"
PathType="Folder"
PromptTitle="Select Download Location"
TargetPath="{Binding DownloadLocation}" />
<local:BeginButton
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="4" />
</Grid>
</Grid>
<Grid
Grid.Row="2"
Margin="5,0,5,5"
Visibility="{Binding Compiling, Converter={StaticResource bool2VisibilityConverter}, FallbackValue=Hidden}">
<local:LogCpuView DataContext="{Binding MWVM}" />
</Grid> </Grid>
</Grid> </Grid>
</Viewbox>
</UserControl> </UserControl>