mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Compilation View spruces/fixes. Basic FilePicker.Filter
This commit is contained in:
parent
75f61c2e18
commit
6eb75e1a9a
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@ -15,15 +16,16 @@ using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class CompilerVM : ViewModel, IDataErrorInfo
|
||||
public class CompilerVM : ViewModel
|
||||
{
|
||||
public MainWindowVM MWVM { get; }
|
||||
|
||||
public RunMode Mode => RunMode.Compile;
|
||||
|
||||
private string _Mo2Folder;
|
||||
public string Mo2Folder { get => _Mo2Folder; set => this.RaiseAndSetIfChanged(ref _Mo2Folder, value); }
|
||||
|
||||
private string _MOProfile;
|
||||
public string MOProfile { get => _MOProfile; set => this.RaiseAndSetIfChanged(ref _MOProfile, value); }
|
||||
|
||||
private string _ModListName;
|
||||
public string ModListName { get => _ModListName; set => this.RaiseAndSetIfChanged(ref _ModListName, value); }
|
||||
|
||||
@ -33,9 +35,6 @@ namespace Wabbajack
|
||||
private bool _UIReady = true;
|
||||
public bool UIReady { get => _UIReady; set => this.RaiseAndSetIfChanged(ref _UIReady, value); }
|
||||
|
||||
private string _ModName;
|
||||
public string ModName { get => _ModName; set => this.RaiseAndSetIfChanged(ref _ModName, value); }
|
||||
|
||||
private string _AuthorName;
|
||||
public string AuthorName { get => _AuthorName; set => this.RaiseAndSetIfChanged(ref _AuthorName, value); }
|
||||
|
||||
@ -61,34 +60,16 @@ namespace Wabbajack
|
||||
public string DownloadLocation { get => _DownloadLocation; set => this.RaiseAndSetIfChanged(ref _DownloadLocation, value); }
|
||||
|
||||
public IReactiveCommand BeginCommand { get; }
|
||||
public IReactiveCommand ChangePathCommand { get; }
|
||||
public IReactiveCommand ChangeDownloadPathCommand { get; }
|
||||
public IReactiveCommand ChangeSplashScreenCommand { get; }
|
||||
|
||||
public CompilerVM(MainWindowVM mainWindowVM, string source)
|
||||
{
|
||||
this.MWVM = mainWindowVM;
|
||||
this.Location = Path.GetDirectoryName(source);
|
||||
this.Location = source;
|
||||
|
||||
this.BeginCommand = ReactiveCommand.Create(
|
||||
this.BeginCommand = ReactiveCommand.CreateFromTask(
|
||||
execute: this.ExecuteBegin,
|
||||
canExecute: this.WhenAny(x => x.UIReady)
|
||||
.ObserveOnGuiThread());
|
||||
this.ChangePathCommand = ReactiveCommand.Create(
|
||||
ExecuteChangePath,
|
||||
canExecute: this.WhenAny(x => x.UIReady)
|
||||
.ObserveOnGuiThread());
|
||||
this.ChangeDownloadPathCommand = ReactiveCommand.Create(
|
||||
ExecuteChangeDownloadPath,
|
||||
canExecute: this.WhenAny(x => x.UIReady)
|
||||
.ObserveOnGuiThread());
|
||||
this.ChangeSplashScreenCommand = ReactiveCommand.Create(
|
||||
canExecute: this.WhenAny(x => x.UIReady)
|
||||
.ObserveOnGuiThread(),
|
||||
execute: () =>
|
||||
{
|
||||
this.ImagePath = UIUtils.OpenFileDialog("Banner image|*.png");
|
||||
});
|
||||
|
||||
this._Image = this.WhenAny(x => x.ImagePath)
|
||||
.Select(path =>
|
||||
@ -101,57 +82,47 @@ namespace Wabbajack
|
||||
return UIUtils.BitmapImageFromResource("Wabbajack.Resources.none.png");
|
||||
})
|
||||
.ToProperty(this, nameof(this.Image));
|
||||
|
||||
ConfigureForBuild(source);
|
||||
}
|
||||
|
||||
private void ExecuteChangePath()
|
||||
private void ConfigureForBuild(string location)
|
||||
{
|
||||
Location = UIUtils.ShowFolderSelectionDialog("Select Your MO2 profile directory");
|
||||
}
|
||||
|
||||
private void ExecuteChangeDownloadPath()
|
||||
{
|
||||
var folder = UIUtils.ShowFolderSelectionDialog("Select a location for MO2 downloads");
|
||||
if (folder != null)
|
||||
{
|
||||
DownloadLocation = folder;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureForBuild()
|
||||
{
|
||||
var profile_folder = Path.GetDirectoryName(Location);
|
||||
var profile_folder = Path.GetDirectoryName(location);
|
||||
this.Mo2Folder = Path.GetDirectoryName(Path.GetDirectoryName(profile_folder));
|
||||
if (!File.Exists(Path.Combine(this.Mo2Folder, "ModOrganizer.exe")))
|
||||
{
|
||||
this.Log().Error($"Error! No ModOrganizer2.exe found in {this.Mo2Folder}");
|
||||
}
|
||||
|
||||
var profile_name = Path.GetFileName(profile_folder);
|
||||
this.ModListName = profile_name;
|
||||
this.MOProfile = Path.GetFileName(profile_folder);
|
||||
this.ModListName = this.MOProfile;
|
||||
|
||||
var tmp_compiler = new Compiler(this.Mo2Folder);
|
||||
DownloadLocation = tmp_compiler.MO2DownloadsFolder;
|
||||
this.DownloadLocation = tmp_compiler.MO2DownloadsFolder;
|
||||
}
|
||||
|
||||
private void ExecuteBegin()
|
||||
private async Task ExecuteBegin()
|
||||
{
|
||||
if (this.Mo2Folder != null)
|
||||
{
|
||||
var compiler = new Compiler(this.Mo2Folder)
|
||||
{
|
||||
MO2Profile = this.ModListName,
|
||||
ModListName = this.ModName,
|
||||
MO2Profile = this.MOProfile,
|
||||
ModListName = this.ModListName,
|
||||
ModListAuthor = this.AuthorName,
|
||||
ModListDescription = this.Summary,
|
||||
ModListImage = this.ImagePath,
|
||||
ModListWebsite = this.NexusSiteURL,
|
||||
ModListReadme = this.ReadMeText,
|
||||
};
|
||||
var th = new Thread(() =>
|
||||
await Task.Run(() =>
|
||||
{
|
||||
UIReady = false;
|
||||
try
|
||||
{
|
||||
compiler.Compile();
|
||||
if (compiler.ModList != null && compiler.ModList.ReportHTML != null)
|
||||
if (compiler.ModList?.ReportHTML != null)
|
||||
{
|
||||
this.HTMLReport = compiler.ModList.ReportHTML;
|
||||
}
|
||||
@ -165,11 +136,7 @@ namespace Wabbajack
|
||||
{
|
||||
UIReady = true;
|
||||
}
|
||||
})
|
||||
{
|
||||
Priority = ThreadPriority.BelowNormal
|
||||
};
|
||||
th.Start();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -177,41 +144,5 @@ namespace Wabbajack
|
||||
UIReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Error => "Error";
|
||||
|
||||
public string this[string columnName] => Validate(columnName);
|
||||
|
||||
private string Validate(string columnName)
|
||||
{
|
||||
string validationMessage = null;
|
||||
switch (columnName)
|
||||
{
|
||||
case "Location":
|
||||
if (Location == null)
|
||||
{
|
||||
validationMessage = null;
|
||||
}
|
||||
else switch (Mode)
|
||||
{
|
||||
case RunMode.Compile when Location != null && Directory.Exists(Location) && File.Exists(Path.Combine(Location, "modlist.txt")):
|
||||
Location = Path.Combine(Location, "modlist.txt");
|
||||
validationMessage = null;
|
||||
ConfigureForBuild();
|
||||
break;
|
||||
case RunMode.Install when Location != null && Directory.Exists(Location) && !Directory.EnumerateFileSystemEntries(Location).Any():
|
||||
validationMessage = null;
|
||||
break;
|
||||
case RunMode.Install when Location != null && Directory.Exists(Location) && Directory.EnumerateFileSystemEntries(Location).Any():
|
||||
validationMessage = "You have selected a non-empty directory. Installing the modlist here might result in a broken install!";
|
||||
break;
|
||||
default:
|
||||
validationMessage = "Invalid Mod Organizer profile directory";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return validationMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,9 @@
|
||||
<TextBlock
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding Mode}" />
|
||||
Text="Compiling" />
|
||||
<TextBlock FontSize="16" Text=" : " />
|
||||
<TextBlock FontSize="16" Text="{Binding ModListName}" />
|
||||
<TextBlock FontSize="16" Text="{Binding MOProfile}" />
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="0"
|
||||
@ -50,24 +50,21 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label
|
||||
Grid.Column="0"
|
||||
Content="Splash Screen Path:" />
|
||||
<TextBox
|
||||
Grid.Column="1"
|
||||
IsEnabled="{Binding UIReady}"
|
||||
Text="{Binding ImagePath}" />
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
MinWidth="80"
|
||||
Command="{Binding ChangeSplashScreenCommand}"
|
||||
Content="Select" />
|
||||
<local:FilePicker Grid.Column="1"
|
||||
PathType="File"
|
||||
DoExistsCheck="False"
|
||||
TargetPath="{Binding ImagePath}"
|
||||
Filter="Banner image|*.png"
|
||||
IsEnabled="{Binding UIReady}" HorizontalAlignment="Left" Width="534" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer Grid.Row="1" Grid.Column="2" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"
|
||||
IsEnabled="{Binding UIReady}"
|
||||
Background="Transparent">
|
||||
<StackPanel Orientation="Vertical" Background="Transparent" >
|
||||
<StackPanel.Resources>
|
||||
@ -80,7 +77,7 @@
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<TextBlock Text="ModList Name" Margin="{StaticResource TitleMargin}" />
|
||||
<TextBox Text="{Binding ModName}" Style="{StaticResource ValueStyle}" />
|
||||
<TextBox Text="{Binding ModListName}" Style="{StaticResource ValueStyle}" />
|
||||
<TextBlock Text="Author" Margin="{StaticResource TitleMargin}" />
|
||||
<TextBox Text="{Binding AuthorName}" Style="{StaticResource ValueStyle}" />
|
||||
<TextBlock Text="Description" Margin="{StaticResource TitleMargin}" />
|
||||
@ -88,7 +85,10 @@
|
||||
<TextBlock Text="Website" Margin="{StaticResource TitleMargin}" />
|
||||
<TextBox Text="{Binding NexusSiteURL}" Style="{StaticResource ValueStyle}" />
|
||||
<TextBlock Text="Readme Path" Margin="{StaticResource TitleMargin}" ToolTip="Path to a readme file." />
|
||||
<TextBox Text="{Binding NexusSiteURL}" Style="{StaticResource ValueStyle}" ToolTip="Path to a readme file." />
|
||||
<local:FilePicker TargetPath="{Binding ReadMeText}"
|
||||
PathType="File"
|
||||
DoExistsCheck="False"
|
||||
ToolTip="Path to a readme file." />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
@ -125,7 +125,6 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
@ -136,33 +135,25 @@
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Content="Installation Location:" />
|
||||
<TextBox
|
||||
<local:FilePicker
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
IsEnabled="{Binding UIReady}"
|
||||
Text="{Binding Location, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
|
||||
<Button
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
MinWidth="80"
|
||||
Command="{Binding ChangePathCommand}"
|
||||
Content="Select"
|
||||
PathType="Folder"
|
||||
DoExistsCheck="False"
|
||||
TargetPath="{Binding Location}"
|
||||
SetTargetPathCommand="{Binding ChangePathCommand}"
|
||||
IsEnabled="{Binding UIReady}" />
|
||||
<Label
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Content="Download Location:" />
|
||||
<TextBox
|
||||
<local:FilePicker
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
IsEnabled="{Binding UIReady}"
|
||||
Text="{Binding DownloadLocation}" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
MinWidth="80"
|
||||
Command="{Binding ChangeDownloadPathCommand}"
|
||||
Content="Select"
|
||||
PathType="Folder"
|
||||
DoExistsCheck="False"
|
||||
TargetPath="{Binding DownloadLocation}"
|
||||
SetTargetPathCommand="{Binding ChangeDownloadPathCommand}"
|
||||
IsEnabled="{Binding UIReady}" />
|
||||
</Grid>
|
||||
<!-- End Location -->
|
||||
|
@ -89,6 +89,14 @@ namespace Wabbajack
|
||||
public static readonly DependencyProperty PromptTitleProperty = DependencyProperty.Register(nameof(PromptTitle), typeof(string), typeof(FilePicker),
|
||||
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
||||
|
||||
public string Filter
|
||||
{
|
||||
get => (string)GetValue(FilterProperty);
|
||||
set => SetValue(FilterProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty FilterProperty = DependencyProperty.Register(nameof(Filter), typeof(string), typeof(FilePicker),
|
||||
new FrameworkPropertyMetadata(default(string)));
|
||||
|
||||
public FilePicker()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -115,6 +123,14 @@ namespace Wabbajack
|
||||
dlg.EnsureFileExists = true;
|
||||
dlg.EnsurePathExists = true;
|
||||
dlg.EnsureReadOnly = false;
|
||||
if (!string.IsNullOrWhiteSpace(this.Filter))
|
||||
{
|
||||
var split = this.Filter.Split('|');
|
||||
if (split.Length == 2)
|
||||
{
|
||||
dlg.Filters.Add(new CommonFileDialogFilter(split[0], split[1]));
|
||||
}
|
||||
}
|
||||
dlg.EnsureValidNames = true;
|
||||
dlg.Multiselect = false;
|
||||
dlg.ShowPlacesList = true;
|
||||
|
Loading…
Reference in New Issue
Block a user