Replaced Go to Modlist with Open Logs Folder when complation failed

This commit is contained in:
erri120 2020-02-28 17:27:37 +01:00
parent e01eb31d1f
commit 87dc2c7773
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
4 changed files with 21 additions and 28 deletions

View File

@ -39,7 +39,8 @@ namespace Wabbajack.Common
return processList.Where(process => process.ProcessName == "ModOrganizer").Any(process => Path.GetDirectoryName(process.MainModule?.FileName) == mo2Path); return processList.Where(process => process.ProcessName == "ModOrganizer").Any(process => Path.GetDirectoryName(process.MainModule?.FileName) == mo2Path);
} }
public static string LogFile { get; private set; } public static string LogFile { get; }
public static string LogFolder { get; }
public enum FileEventType public enum FileEventType
{ {
@ -57,6 +58,7 @@ namespace Wabbajack.Common
Directory.CreateDirectory(Consts.LogsFolder); Directory.CreateDirectory(Consts.LogsFolder);
var programName = Assembly.GetEntryAssembly()?.Location ?? "Wabbajack"; var programName = Assembly.GetEntryAssembly()?.Location ?? "Wabbajack";
LogFolder = Path.Combine(Path.GetDirectoryName(programName), Consts.LogsFolder);
LogFile = Path.Combine(Consts.LogsFolder, Path.GetFileNameWithoutExtension(programName) + ".current.log"); LogFile = Path.Combine(Consts.LogsFolder, Path.GetFileNameWithoutExtension(programName) + ".current.log");
_startTime = DateTime.Now; _startTime = DateTime.Now;

View File

@ -48,7 +48,7 @@ namespace Wabbajack
public ObservableCollectionExtended<IStatusMessage> Log => MWVM.Log; public ObservableCollectionExtended<IStatusMessage> Log => MWVM.Log;
public ReactiveCommand<Unit, Unit> BackCommand { get; } public ReactiveCommand<Unit, Unit> BackCommand { get; }
public ReactiveCommand<Unit, Unit> GoToModlistCommand { get; } public ReactiveCommand<Unit, Unit> GoToCommand { get; }
public ReactiveCommand<Unit, Unit> CloseWhenCompleteCommand { get; } public ReactiveCommand<Unit, Unit> CloseWhenCompleteCommand { get; }
public ReactiveCommand<Unit, Unit> BeginCommand { get; } public ReactiveCommand<Unit, Unit> BeginCommand { get; }
@ -226,18 +226,21 @@ namespace Wabbajack
MWVM.ShutdownApplication(); MWVM.ShutdownApplication();
}); });
GoToModlistCommand = ReactiveCommand.Create( GoToCommand = ReactiveCommand.Create(
canExecute: this.WhenAny(x => x.Completed) canExecute: this.WhenAny(x => x.Completed)
.Select(x => x != null), .Select(x => x != null),
execute: () => execute: () =>
{ {
if (string.IsNullOrWhiteSpace(OutputLocation.TargetPath)) if (Completed?.Failed ?? false)
{ {
Process.Start("explorer.exe", Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)); Process.Start("explorer.exe", Utils.LogFolder);
} }
else else
{ {
Process.Start("explorer.exe", OutputLocation.TargetPath); Process.Start("explorer.exe",
string.IsNullOrWhiteSpace(OutputLocation.TargetPath)
? Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
: OutputLocation.TargetPath);
} }
}); });

View File

@ -85,7 +85,7 @@
Grid.Row="1" Grid.Row="1"
Margin="0,10,0,0" Margin="0,10,0,0"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Text="Go To Modlist" /> x:Name="ActionText" />
</Grid> </Grid>
<Grid <Grid
Grid.Row="1" Grid.Row="1"

View File

@ -1,19 +1,5 @@
using System; using System.Reactive.Disposables;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ReactiveUI; using ReactiveUI;
namespace Wabbajack namespace Wabbajack
@ -21,7 +7,7 @@ namespace Wabbajack
/// <summary> /// <summary>
/// Interaction logic for CompilationCompleteView.xaml /// Interaction logic for CompilationCompleteView.xaml
/// </summary> /// </summary>
public partial class CompilationCompleteView : ReactiveUserControl<CompilerVM> public partial class CompilationCompleteView
{ {
public CompilationCompleteView() public CompilationCompleteView()
{ {
@ -34,16 +20,18 @@ namespace Wabbajack
.DisposeWith(dispose); .DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.Completed) this.WhenAny(x => x.ViewModel.Completed)
.Select(x => x?.Failed ?? false) .Select(x => x?.Failed ?? false)
.Select(failed => .Select(failed => $"Compilation {(failed ? "Failed" : "Complete")}")
{
return $"Compilation {(failed ? "Failed" : "Complete")}";
})
.BindToStrict(this, x => x.TitleText.Text) .BindToStrict(this, x => x.TitleText.Text)
.DisposeWith(dispose); .DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.Completed)
.Select(x => x?.Failed ?? false)
.Select(failed => failed ? "Open Logs Folder" : "Go to Modlist")
.BindToStrict(this, x => x.ActionText.Text)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.BackCommand) this.WhenAny(x => x.ViewModel.BackCommand)
.BindToStrict(this, x => x.BackButton.Command) .BindToStrict(this, x => x.BackButton.Command)
.DisposeWith(dispose); .DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.GoToModlistCommand) this.WhenAny(x => x.ViewModel.GoToCommand)
.BindToStrict(this, x => x.GoToModlistButton.Command) .BindToStrict(this, x => x.GoToModlistButton.Command)
.DisposeWith(dispose); .DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.CloseWhenCompleteCommand) this.WhenAny(x => x.ViewModel.CloseWhenCompleteCommand)