Merge pull request #173 from Noggog/compiler-multi-source

Compiler multi source
This commit is contained in:
Timothy Baldridge 2019-11-15 05:22:45 -07:00 committed by GitHub
commit 8710f227a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 903 additions and 564 deletions

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reactive; using System.Reactive;
@ -173,5 +173,34 @@ namespace Wabbajack
{ {
return source.Select(x => !x); return source.Select(x => !x);
} }
public static IObservable<(T Previous, T Current)> Pairwise<T>(this IObservable<T> source)
{
T prevStorage = default;
return source.Select(i =>
{
var prev = prevStorage;
prevStorage = i;
return (prev, i);
});
}
public static IObservable<T> DelayInitial<T>(this IObservable<T> source, TimeSpan delay)
{
return source.FilterSwitch(
Observable.Return(System.Reactive.Unit.Default)
.Delay(delay)
.Select(_ => true)
.StartWith(false));
}
public static IObservable<T> DelayInitial<T>(this IObservable<T> source, TimeSpan delay, IScheduler scheduler)
{
return source.FilterSwitch(
Observable.Return(System.Reactive.Unit.Default)
.Delay(delay, scheduler)
.Select(_ => true)
.StartWith(false));
}
} }
} }

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace Wabbajack
{
public class EqualsToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return object.Equals(value, parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return parameter;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@ -10,6 +10,7 @@ using System.Reactive.Subjects;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Wabbajack.Common;
namespace Wabbajack namespace Wabbajack
{ {
@ -22,10 +23,8 @@ namespace Wabbajack
public double PosY { get; set; } public double PosY { get; set; }
public double Height { get; set; } public double Height { get; set; }
public double Width { get; set; } public double Width { get; set; }
public string LastInstalledListLocation { get; set; } public InstallerSettings Installer { get; set; } = new InstallerSettings();
public Dictionary<string, InstallationSettings> InstallationSettings { get; } = new Dictionary<string, InstallationSettings>(); public CompilerSettings Compiler { get; set; } = new CompilerSettings();
public string LastCompiledProfileLocation { get; set; }
public Dictionary<string, CompilationSettings> CompilationSettings { get; } = new Dictionary<string, CompilationSettings>();
[JsonIgnoreAttribute] [JsonIgnoreAttribute]
private Subject<Unit> _saveSignal = new Subject<Unit>(); private Subject<Unit> _saveSignal = new Subject<Unit>();
@ -50,14 +49,27 @@ namespace Wabbajack
} }
} }
public class InstallationSettings public class InstallerSettings
{
public string LastInstalledListLocation { get; set; }
public Dictionary<string, ModlistInstallationSettings> ModlistSettings { get; } = new Dictionary<string, ModlistInstallationSettings>();
}
public class ModlistInstallationSettings
{ {
public string InstallationLocation { get; set; } public string InstallationLocation { get; set; }
public string StagingLocation { get; set; } public string StagingLocation { get; set; }
public string DownloadLocation { get; set; } public string DownloadLocation { get; set; }
} }
public class CompilationSettings public class CompilerSettings
{
public ModManager LastCompiledModManager { get; set; }
public MO2CompilationSettings MO2Compilation { get; } = new MO2CompilationSettings();
public VortexCompilationSettings VortexCompilation { get; } = new VortexCompilationSettings();
}
public class CompilationModlistSettings
{ {
public string ModListName { get; set; } public string ModListName { get; set; }
public string Author { get; set; } public string Author { get; set; }
@ -65,6 +77,19 @@ namespace Wabbajack
public string Website { get; set; } public string Website { get; set; }
public string Readme { get; set; } public string Readme { get; set; }
public string SplashScreen { get; set; } public string SplashScreen { get; set; }
}
public class MO2CompilationSettings
{
public string DownloadLocation { get; set; } public string DownloadLocation { get; set; }
public string LastCompiledProfileLocation { get; set; }
public Dictionary<string, CompilationModlistSettings> ModlistSettings { get; } = new Dictionary<string, CompilationModlistSettings>();
}
public class VortexCompilationSettings
{
public string StagingLocation { get; set; }
public Game LastCompiledGame { get; set; }
public Dictionary<Game, CompilationModlistSettings> ModlistSettings { get; } = new Dictionary<Game, CompilationModlistSettings>();
} }
} }

View File

@ -12,6 +12,7 @@
<local:BoolToVisibilityHiddenConverter x:Key="bool2VisibilityHiddenConverter" /> <local:BoolToVisibilityHiddenConverter x:Key="bool2VisibilityHiddenConverter" />
<local:InverseBooleanConverter x:Key="InverseBooleanConverter" /> <local:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<local:IsNotNullVisibilityConverter x:Key="IsNotNullVisibilityConverter"/> <local:IsNotNullVisibilityConverter x:Key="IsNotNullVisibilityConverter"/>
<local:EqualsToBoolConverter x:Key="EqualsToBoolConverter"/>
<!--Colors--> <!--Colors-->
<Color x:Key="WindowBackgroundColor">#121212</Color> <Color x:Key="WindowBackgroundColor">#121212</Color>

View File

@ -1,264 +0,0 @@
using Microsoft.WindowsAPICodePack.Dialogs;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.IO;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack
{
public class CompilerVM : ViewModel
{
public MainWindowVM MWVM { get; }
private readonly ObservableAsPropertyHelper<string> _Mo2Folder;
public string Mo2Folder => _Mo2Folder.Value;
private readonly ObservableAsPropertyHelper<string> _MOProfile;
public string MOProfile => _MOProfile.Value;
[Reactive]
public string ModListName { get; set; }
public FilePickerVM ModlistLocation { get; }
[Reactive]
public bool Compiling { get; set; }
[Reactive]
public string AuthorText { get; set; }
[Reactive]
public string Description { get; set; }
public FilePickerVM ImagePath { get; }
private readonly ObservableAsPropertyHelper<BitmapImage> _Image;
public BitmapImage Image => _Image.Value;
[Reactive]
public string Website { get; set; }
public FilePickerVM ReadMeText { get; }
[Reactive]
public string HTMLReport { get; set; }
public FilePickerVM DownloadLocation { get; }
public IReactiveCommand BeginCommand { get; }
public CompilerVM(MainWindowVM mainWindowVM, string source)
{
this.MWVM = mainWindowVM;
this.ModlistLocation = new FilePickerVM()
{
TargetPath = source,
DoExistsCheck = true,
PathType = FilePickerVM.PathTypeOptions.File,
PromptTitle = "Select Modlist"
};
this.DownloadLocation = new FilePickerVM()
{
DoExistsCheck = true,
PathType = FilePickerVM.PathTypeOptions.Folder,
PromptTitle = "Select Download Location",
};
this.ImagePath = new FilePickerVM()
{
DoExistsCheck = false,
PathType = FilePickerVM.PathTypeOptions.File,
Filters =
{
new CommonFileDialogFilter("Banner image", "*.png")
}
};
this.ReadMeText = new FilePickerVM()
{
PathType = FilePickerVM.PathTypeOptions.File,
DoExistsCheck = true,
};
this.BeginCommand = ReactiveCommand.CreateFromTask(
execute: this.ExecuteBegin,
canExecute: Observable.CombineLatest(
this.WhenAny(x => x.Compiling),
this.WhenAny(x => x.ModlistLocation.InError),
this.WhenAny(x => x.DownloadLocation.InError),
resultSelector: (c, ml, down) => !c && !ml && !down)
.ObserveOnGuiThread());
this._Image = this.WhenAny(x => x.ImagePath.TargetPath)
.Select(path =>
{
if (string.IsNullOrWhiteSpace(path)) return UIUtils.BitmapImageFromResource("Wabbajack.Resources.Banner_Dark.png");
if (UIUtils.TryGetBitmapImageFromFile(path, out var image))
{
return image;
}
return UIUtils.BitmapImageFromResource("Wabbajack.Resources.none.png");
})
.ToProperty(this, nameof(this.Image));
this._Mo2Folder = this.WhenAny(x => x.ModlistLocation.TargetPath)
.Select(loc =>
{
try
{
var profile_folder = Path.GetDirectoryName(loc);
return Path.GetDirectoryName(Path.GetDirectoryName(profile_folder));
}
catch (Exception)
{
return null;
}
})
.ToProperty(this, nameof(this.Mo2Folder));
this._MOProfile = this.WhenAny(x => x.ModlistLocation.TargetPath)
.Select(loc =>
{
try
{
var profile_folder = Path.GetDirectoryName(loc);
return Path.GetFileName(profile_folder);
}
catch (Exception)
{
return null;
}
})
.ToProperty(this, nameof(this.MOProfile));
// If Mo2 folder changes and download location is empty, set it for convenience
this.WhenAny(x => x.Mo2Folder)
.Where(x => Directory.Exists(x))
.Subscribe(x =>
{
try
{
var tmp_compiler = new Compiler(this.Mo2Folder);
this.DownloadLocation.TargetPath = tmp_compiler.MO2DownloadsFolder;
}
catch (Exception ex)
{
Utils.Log($"Error setting default download location {ex}");
}
})
.DisposeWith(this.CompositeDisposable);
// Wire missing Mo2Folder to signal error state for Modlist Location
this.ModlistLocation.AdditionalError = this.WhenAny(x => x.Mo2Folder)
.Select<string, IErrorResponse>(moFolder =>
{
if (Directory.Exists(moFolder)) return ErrorResponse.Success;
return ErrorResponse.Fail($"MO2 Folder could not be located from the given modlist location.{Environment.NewLine}Make sure your modlist is inside a valid MO2 distribution.");
});
// Load settings
CompilationSettings settings = this.MWVM.Settings.CompilationSettings.TryCreate(source);
this.AuthorText = settings.Author;
if (string.IsNullOrWhiteSpace(settings.ModListName))
{
// Set ModlistName initially off just the MO2Profile
this.ModListName = this.MOProfile;
}
else
{
this.ModListName = settings.ModListName;
}
this.Description = settings.Description;
this.ReadMeText.TargetPath = settings.Readme;
this.ImagePath.TargetPath = settings.SplashScreen;
this.Website = settings.Website;
if (!string.IsNullOrWhiteSpace(settings.DownloadLocation))
{
this.DownloadLocation.TargetPath = settings.DownloadLocation;
}
this.MWVM.Settings.SaveSignal
.Subscribe(_ =>
{
settings.Author = this.AuthorText;
settings.ModListName = this.ModListName;
settings.Description = this.Description;
settings.Readme = this.ReadMeText.TargetPath;
settings.SplashScreen = this.ImagePath.TargetPath;
settings.Website = this.Website;
settings.DownloadLocation = this.DownloadLocation.TargetPath;
})
.DisposeWith(this.CompositeDisposable);
}
private async Task ExecuteBegin()
{
if (false)
{
string[] args = Environment.GetCommandLineArgs();
var compiler = new VortexCompiler(args[1], args[2]);
await Task.Run(() =>
{
Compiling = true;
try
{
compiler.Compile();
}
catch (Exception ex)
{
while (ex.InnerException != null) ex = ex.InnerException;
Utils.Log($"Can't continue: {ex.ExceptionToString()}");
}
finally
{
Compiling = false;
}
});
}else{
Compiler compiler;
try {
compiler = new Compiler(this.Mo2Folder)
{
MO2Profile = this.MOProfile,
ModListName = this.ModListName,
ModListAuthor = this.AuthorText,
ModListDescription = this.Description,
ModListImage = this.ImagePath.TargetPath,
ModListWebsite = this.Website,
ModListReadme = this.ReadMeText.TargetPath,
};
}
catch (Exception ex)
{
while (ex.InnerException != null) ex = ex.InnerException;
Utils.Log($"Compiler error: {ex.ExceptionToString()}");
return;
}
await Task.Run(() =>
{
Compiling = true;
try
{
compiler.Compile();
if (compiler.ModList?.ReportHTML != null)
{
this.HTMLReport = compiler.ModList.ReportHTML;
}
}
catch (Exception ex)
{
while (ex.InnerException != null) ex = ex.InnerException;
Utils.Log($"Compiler error: {ex.ExceptionToString()}");
}
finally
{
Compiling = false;
}
});
}
}
}
}

View File

@ -0,0 +1,84 @@
using Microsoft.WindowsAPICodePack.Dialogs;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.IO;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack
{
public class CompilerVM : ViewModel
{
public MainWindowVM MWVM { get; }
private readonly ObservableAsPropertyHelper<BitmapImage> _Image;
public BitmapImage Image => _Image.Value;
[Reactive]
public ModManager SelectedCompilerType { get; set; }
private readonly ObservableAsPropertyHelper<ISubCompilerVM> _Compiler;
public ISubCompilerVM Compiler => _Compiler.Value;
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _CurrentModlistSettings;
public ModlistSettingsEditorVM CurrentModlistSettings => _CurrentModlistSettings.Value;
public CompilerVM(MainWindowVM mainWindowVM)
{
this.MWVM = mainWindowVM;
// Load settings
CompilerSettings settings = this.MWVM.Settings.Compiler;
this.SelectedCompilerType = settings.LastCompiledModManager;
this.MWVM.Settings.SaveSignal
.Subscribe(_ =>
{
settings.LastCompiledModManager = this.SelectedCompilerType;
})
.DisposeWith(this.CompositeDisposable);
// Swap to proper sub VM based on selected type
this._Compiler = this.WhenAny(x => x.SelectedCompilerType)
// Delay so the initial VM swap comes in immediately, subVM comes right after
.DelayInitial(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
.Select<ModManager, ISubCompilerVM>(type =>
{
switch (type)
{
case ModManager.MO2:
return new MO2CompilerVM(this);
case ModManager.Vortex:
return new VortexCompilerVM();
default:
return null;
}
})
.ToProperty(this, nameof(this.Compiler));
// Let sub VM determine what settings we're displaying and when
this._CurrentModlistSettings = this.WhenAny(x => x.Compiler.ModlistSettings)
.ToProperty(this, nameof(this.CurrentModlistSettings));
this._Image = this.WhenAny(x => x.CurrentModlistSettings.ImagePath.TargetPath)
// Throttle so that it only loads image after any sets of swaps have completed
.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
.DistinctUntilChanged()
.Select(path =>
{
if (string.IsNullOrWhiteSpace(path)) return UIUtils.BitmapImageFromResource("Wabbajack.Resources.Banner_Dark.png");
if (UIUtils.TryGetBitmapImageFromFile(path, out var image))
{
return image;
}
return null;
})
.ToProperty(this, nameof(this.Image));
}
}
}

View File

@ -0,0 +1,17 @@
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Wabbajack
{
public interface ISubCompilerVM
{
IReactiveCommand BeginCommand { get; }
bool Compiling { get; }
ModlistSettingsEditorVM ModlistSettings { get; }
}
}

View File

@ -0,0 +1,199 @@
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack
{
public class MO2CompilerVM : ViewModel, ISubCompilerVM
{
private readonly ObservableAsPropertyHelper<string> _Mo2Folder;
public string Mo2Folder => _Mo2Folder.Value;
private readonly ObservableAsPropertyHelper<string> _MOProfile;
public string MOProfile => _MOProfile.Value;
public FilePickerVM DownloadLocation { get; }
public FilePickerVM ModlistLocation { get; }
public IReactiveCommand BeginCommand { get; }
private readonly ObservableAsPropertyHelper<bool> _Compiling;
public bool Compiling => _Compiling.Value;
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _ModlistSettings;
public ModlistSettingsEditorVM ModlistSettings => _ModlistSettings.Value;
public MO2CompilerVM(CompilerVM parent)
{
this.ModlistLocation = new FilePickerVM()
{
DoExistsCheck = true,
PathType = FilePickerVM.PathTypeOptions.File,
PromptTitle = "Select Modlist"
};
this.DownloadLocation = new FilePickerVM()
{
DoExistsCheck = true,
PathType = FilePickerVM.PathTypeOptions.Folder,
PromptTitle = "Select Download Location",
};
this._Mo2Folder = this.WhenAny(x => x.ModlistLocation.TargetPath)
.Select(loc =>
{
try
{
var profile_folder = Path.GetDirectoryName(loc);
return Path.GetDirectoryName(Path.GetDirectoryName(profile_folder));
}
catch (Exception)
{
return null;
}
})
.ToProperty(this, nameof(this.Mo2Folder));
this._MOProfile = this.WhenAny(x => x.ModlistLocation.TargetPath)
.Select(loc =>
{
try
{
var profile_folder = Path.GetDirectoryName(loc);
return Path.GetFileName(profile_folder);
}
catch (Exception)
{
return null;
}
})
.ToProperty(this, nameof(this.MOProfile));
// Wire missing Mo2Folder to signal error state for Modlist Location
this.ModlistLocation.AdditionalError = this.WhenAny(x => x.Mo2Folder)
.Select<string, IErrorResponse>(moFolder =>
{
if (Directory.Exists(moFolder)) return ErrorResponse.Success;
return ErrorResponse.Fail($"MO2 Folder could not be located from the given modlist location.{Environment.NewLine}Make sure your modlist is inside a valid MO2 distribution.");
});
// Wire start command
this.BeginCommand = ReactiveCommand.CreateFromTask(
canExecute: Observable.CombineLatest(
this.WhenAny(x => x.ModlistLocation.InError),
this.WhenAny(x => x.DownloadLocation.InError),
resultSelector: (ml, down) => !ml && !down)
.ObserveOnGuiThread(),
execute: async () =>
{
Compiler compiler;
try
{
compiler = new Compiler(this.Mo2Folder)
{
MO2Profile = this.MOProfile,
ModListName = this.ModlistSettings.ModListName,
ModListAuthor = this.ModlistSettings.AuthorText,
ModListDescription = this.ModlistSettings.Description,
ModListImage = this.ModlistSettings.ImagePath.TargetPath,
ModListWebsite = this.ModlistSettings.Website,
ModListReadme = this.ModlistSettings.ReadMeText.TargetPath,
};
}
catch (Exception ex)
{
while (ex.InnerException != null) ex = ex.InnerException;
Utils.Log($"Compiler error: {ex.ExceptionToString()}");
return;
}
await Task.Run(() =>
{
try
{
compiler.Compile();
}
catch (Exception ex)
{
while (ex.InnerException != null) ex = ex.InnerException;
Utils.Log($"Compiler error: {ex.ExceptionToString()}");
}
});
});
this._Compiling = this.BeginCommand.IsExecuting
.ToProperty(this, nameof(this.Compiling));
// Load settings
var settings = parent.MWVM.Settings.Compiler.MO2Compilation;
this.ModlistLocation.TargetPath = settings.LastCompiledProfileLocation;
if (!string.IsNullOrWhiteSpace(settings.DownloadLocation))
{
this.DownloadLocation.TargetPath = settings.DownloadLocation;
}
parent.MWVM.Settings.SaveSignal
.Subscribe(_ =>
{
settings.DownloadLocation = this.DownloadLocation.TargetPath;
settings.LastCompiledProfileLocation = this.ModlistLocation.TargetPath;
this.ModlistSettings?.Save();
})
.DisposeWith(this.CompositeDisposable);
// Load custom modlist settings per MO2 profile
this._ModlistSettings = Observable.CombineLatest(
this.WhenAny(x => x.ModlistLocation.ErrorState),
this.WhenAny(x => x.ModlistLocation.TargetPath),
resultSelector: (State, Path) => (State, Path))
// A short throttle is a quick hack to make the above changes "atomic"
.Throttle(TimeSpan.FromMilliseconds(25))
.Select(u =>
{
if (u.State.Failed) return null;
var modlistSettings = settings.ModlistSettings.TryCreate(u.Path);
return new ModlistSettingsEditorVM(modlistSettings, this.MOProfile);
})
// Interject and save old while loading new
.Pairwise()
.Do(pair =>
{
pair.Previous?.Save();
pair.Current?.Init();
})
.Select(x => x.Current)
// Save to property
.ObserveOnGuiThread()
.ToProperty(this, nameof(this.ModlistSettings));
// If Mo2 folder changes and download location is empty, set it for convenience
this.WhenAny(x => x.Mo2Folder)
.DelayInitial(TimeSpan.FromMilliseconds(100))
.Where(x => Directory.Exists(x))
.FilterSwitch(
this.WhenAny(x => x.DownloadLocation.Exists)
.Invert())
.Subscribe(x =>
{
try
{
var tmp_compiler = new Compiler(this.Mo2Folder);
this.DownloadLocation.TargetPath = tmp_compiler.MO2DownloadsFolder;
}
catch (Exception ex)
{
Utils.Log($"Error setting default download location {ex}");
}
})
.DisposeWith(this.CompositeDisposable);
}
}
}

View File

@ -0,0 +1,83 @@
using Microsoft.WindowsAPICodePack.Dialogs;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Wabbajack.Lib;
namespace Wabbajack
{
public class ModlistSettingsEditorVM : ViewModel
{
private CompilationModlistSettings settings;
private string mo2Profile;
[Reactive]
public string ModListName { get; set; }
[Reactive]
public string AuthorText { get; set; }
[Reactive]
public string Description { get; set; }
public FilePickerVM ImagePath { get; }
public FilePickerVM ReadMeText { get; }
[Reactive]
public string Website { get; set; }
public ModlistSettingsEditorVM(CompilationModlistSettings settings, string mo2Profile)
{
this.settings = settings;
this.mo2Profile = mo2Profile;
this.ImagePath = new FilePickerVM()
{
DoExistsCheck = false,
PathType = FilePickerVM.PathTypeOptions.File,
Filters =
{
new CommonFileDialogFilter("Banner image", "*.png")
}
};
this.ReadMeText = new FilePickerVM()
{
PathType = FilePickerVM.PathTypeOptions.File,
DoExistsCheck = true,
};
}
public void Init()
{
this.AuthorText = settings.Author;
if (string.IsNullOrWhiteSpace(settings.ModListName))
{
// Set ModlistName initially off just the MO2Profile
this.ModListName = mo2Profile;
}
else
{
this.ModListName = settings.ModListName;
}
this.Description = settings.Description;
this.ReadMeText.TargetPath = settings.Readme;
this.ImagePath.TargetPath = settings.SplashScreen;
this.Website = settings.Website;
}
public void Save()
{
settings.Author = this.AuthorText;
settings.ModListName = this.ModListName;
settings.Description = this.Description;
settings.Readme = this.ReadMeText.TargetPath;
settings.SplashScreen = this.ImagePath.TargetPath;
settings.Website = this.Website;
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ReactiveUI;
using Wabbajack.Lib;
namespace Wabbajack
{
public class VortexCompilerVM : ViewModel, ISubCompilerVM
{
public IReactiveCommand BeginCommand => throw new NotImplementedException();
public bool Compiling => throw new NotImplementedException();
public ModlistSettingsEditorVM ModlistSettings => throw new NotImplementedException();
}
}

View File

@ -77,7 +77,9 @@ namespace Wabbajack
this.WhenAny(x => x.DoExistsCheck), this.WhenAny(x => x.DoExistsCheck),
this.WhenAny(x => x.PathType), this.WhenAny(x => x.PathType),
this.WhenAny(x => x.TargetPath) this.WhenAny(x => x.TargetPath)
.Throttle(TimeSpan.FromMilliseconds(200)), // Dont want to debounce the initial value, because we know it's null
.Skip(1)
.Debounce(TimeSpan.FromMilliseconds(200)),
resultSelector: (_, DoExists, Type, Path) => (DoExists, Type, Path)) resultSelector: (_, DoExists, Type, Path) => (DoExists, Type, Path))
// Refresh exists // Refresh exists
.Select(t => .Select(t =>
@ -95,6 +97,7 @@ namespace Wabbajack
return true; return true;
} }
}) })
.StartWith(false)
.DistinctUntilChanged() .DistinctUntilChanged()
.ObserveOn(RxApp.MainThreadScheduler) .ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, nameof(this.Exists)); .ToProperty(this, nameof(this.Exists));

View File

@ -50,15 +50,10 @@ namespace Wabbajack
[Reactive] [Reactive]
public bool InstallingMode { get; set; } public bool InstallingMode { get; set; }
[Reactive]
public bool IsMO2ModList { get; set; }
public FilePickerVM Location { get; } public FilePickerVM Location { get; }
public FilePickerVM DownloadLocation { get; } public FilePickerVM DownloadLocation { get; }
public FilePickerVM StagingLocation { get; }
private readonly ObservableAsPropertyHelper<float> _ProgressPercent; private readonly ObservableAsPropertyHelper<float> _ProgressPercent;
public float ProgressPercent => _ProgressPercent.Value; public float ProgressPercent => _ProgressPercent.Value;
@ -119,25 +114,15 @@ namespace Wabbajack
this.DownloadLocation.AdditionalError = this.WhenAny(x => x.DownloadLocation.TargetPath) this.DownloadLocation.AdditionalError = this.WhenAny(x => x.DownloadLocation.TargetPath)
.Select(x => Utils.IsDirectoryPathValid(x)); .Select(x => Utils.IsDirectoryPathValid(x));
StagingLocation = new FilePickerVM
{
DoExistsCheck = true,
PathType = FilePickerVM.PathTypeOptions.Folder,
PromptTitle = "Select your Vortex Staging Folder",
AdditionalError = this.WhenAny(x => x.StagingLocation.TargetPath)
.Select(Utils.IsDirectoryPathValid)
};
// Load settings // Load settings
var settings = MWVM.Settings.InstallationSettings.TryCreate(source); ModlistInstallationSettings settings = this.MWVM.Settings.Installer.ModlistSettings.TryCreate(source);
this.Location.TargetPath = settings.InstallationLocation;
this.DownloadLocation.TargetPath = settings.DownloadLocation;
this.MWVM.Settings.SaveSignal this.MWVM.Settings.SaveSignal
.Subscribe(_ => .Subscribe(_ =>
{ {
settings.DownloadLocation = DownloadLocation.TargetPath; settings.InstallationLocation = this.Location.TargetPath;
if (IsMO2ModList) settings.DownloadLocation = this.DownloadLocation.TargetPath;
settings.InstallationLocation = Location.TargetPath;
else
settings.StagingLocation = StagingLocation.TargetPath;
}) })
.DisposeWith(this.CompositeDisposable); .DisposeWith(this.CompositeDisposable);
@ -163,38 +148,6 @@ namespace Wabbajack
}); });
return default(ModListVM); return default(ModListVM);
} }
if (modList.ModManager == ModManager.Vortex)
{
IsMO2ModList = false;
StagingLocation.TargetPath = settings.StagingLocation;
var vortexFolder =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Vortex");
var stagingFolder = Path.Combine(vortexFolder, GameRegistry.Games[modList.GameType].NexusName,
"mods");
var downloadFolder = Path.Combine(vortexFolder, "downloads",
GameRegistry.Games[modList.GameType].NexusName);
MessageBox.Show(
"The ModList you are about to install was compiled from a Vortex installation. " +
"Vortex support is still very bleeding edge and installing this ModList WILL OVERRIDE your existing mods. " +
"If you encounter any errors during installation go to our discord and ping erri120#2285 with your error and a log file.",
"Important information regarding Vortex support", MessageBoxButton.OK, MessageBoxImage.Stop);
if (!Directory.Exists(vortexFolder)) return new ModListVM(modList, modListPath);
if (Directory.Exists(stagingFolder) &&
File.Exists(Path.Combine(stagingFolder, "__vortex_staging_folder")))
StagingLocation.TargetPath = stagingFolder;
if (Directory.Exists(Path.Combine(vortexFolder, "downloads")) &&
File.Exists(Path.Combine(vortexFolder, "downloads", "__vortex_downloads_folder")))
DownloadLocation.TargetPath = downloadFolder;
}
else
{
Location.TargetPath = settings.InstallationLocation;
DownloadLocation.TargetPath = settings.DownloadLocation;
IsMO2ModList = true;
}
return new ModListVM(modList, modListPath); return new ModListVM(modList, modListPath);
}) })
.ObserveOnGuiThread() .ObserveOnGuiThread()
@ -266,13 +219,10 @@ namespace Wabbajack
this.WhenAny(x => x.Installing), this.WhenAny(x => x.Installing),
this.WhenAny(x => x.Location.InError), this.WhenAny(x => x.Location.InError),
this.WhenAny(x => x.DownloadLocation.InError), this.WhenAny(x => x.DownloadLocation.InError),
this.WhenAny(x => x.StagingLocation.InError), resultSelector: (installing, loc, download) =>
resultSelector: (installing, loc, download, staging) =>
{ {
if (installing) return false; if (installing) return false;
if (IsMO2ModList)
return !loc && !download; return !loc && !download;
return !staging && !download;
}) })
.ObserveOnGuiThread()); .ObserveOnGuiThread());
this.VisitWebsiteCommand = ReactiveCommand.Create( this.VisitWebsiteCommand = ReactiveCommand.Create(
@ -339,40 +289,8 @@ namespace Wabbajack
private void ExecuteBegin() private void ExecuteBegin()
{ {
Installing = true; this.Installing = true;
InstallingMode = true; this.InstallingMode = true;
if (ModList.ModManager == ModManager.Vortex)
{
var installer = new VortexInstaller(ModListPath, ModList.SourceModList)
{
StagingFolder = StagingLocation.TargetPath,
DownloadFolder = DownloadLocation.TargetPath
};
var th = new Thread(() =>
{
try
{
installer.Install();
}
catch (Exception ex)
{
while (ex.InnerException != null) ex = ex.InnerException;
Utils.Log(ex.StackTrace);
Utils.Log(ex.ToString());
Utils.Log($"{ex.Message} - Can't continue");
}
finally
{
Installing = false;
}
})
{
Priority = ThreadPriority.BelowNormal
};
th.Start();
}
else
{
var installer = new Installer(this.ModListPath, this.ModList.SourceModList, Location.TargetPath) var installer = new Installer(this.ModListPath, this.ModList.SourceModList, Location.TargetPath)
{ {
DownloadFolder = DownloadLocation.TargetPath DownloadFolder = DownloadLocation.TargetPath
@ -403,4 +321,3 @@ namespace Wabbajack
} }
} }
} }
}

View File

@ -50,7 +50,7 @@ namespace Wabbajack
this.MainWindow = mainWindow; this.MainWindow = mainWindow;
this.Settings = settings; this.Settings = settings;
this._Installer = new Lazy<InstallerVM>(() => new InstallerVM(this, source)); this._Installer = new Lazy<InstallerVM>(() => new InstallerVM(this, source));
this._Compiler = new Lazy<CompilerVM>(() => new CompilerVM(this, source)); this._Compiler = new Lazy<CompilerVM>(() => new CompilerVM(this));
// Set up logging // Set up logging
Utils.LogMessages Utils.LogMessages

View File

@ -0,0 +1,67 @@
<UserControl
x:Class="Wabbajack.ImageRadioButtonView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wabbajack"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="35"
ClipToBounds="False"
mc:Ignorable="d">
<Grid>
<Border
x:Name="HoverOverPrimaryGlow"
Margin="-10"
Background="{StaticResource PrimaryVariantBrush}"
CornerRadius="15"
Opacity="0.3"
Visibility="{Binding IsChecked, Converter={StaticResource bool2VisibilityHiddenConverter}, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
<Border.Effect>
<BlurEffect Radius="15" />
</Border.Effect>
</Border>
<Border
x:Name="SelectedSecondaryGlow"
Margin="-2"
Background="{StaticResource SecondaryBrush}"
CornerRadius="12"
Opacity="0.3"
Visibility="{Binding IsMouseOver, Converter={StaticResource bool2VisibilityHiddenConverter}, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
<Border.Effect>
<BlurEffect Radius="10" />
</Border.Effect>
</Border>
<Button
Background="Transparent"
BorderThickness="0"
Click="Button_Click">
<Image Source="{Binding Image, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
<Image.Style>
<Style TargetType="Image">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Value="False" />
<Condition Binding="{Binding IsChecked, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Value="False" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Effect">
<Setter.Value>
<BlurEffect Radius="2" />
</Setter.Value>
</Setter>
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Button>
<Border
BorderBrush="{StaticResource SecondaryBrush}"
BorderThickness="1"
CornerRadius="9"
Opacity="0.8"
Visibility="{Binding IsChecked, Converter={StaticResource bool2VisibilityHiddenConverter}, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
</Grid>
</UserControl>

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.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;
namespace Wabbajack
{
/// <summary>
/// Interaction logic for ImageRadioButtonView.xaml
/// </summary>
public partial class ImageRadioButtonView : UserControl
{
public bool IsChecked
{
get => (bool)GetValue(IsCheckedProperty);
set => SetValue(IsCheckedProperty, value);
}
public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(nameof(IsChecked), typeof(bool), typeof(ImageRadioButtonView),
new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public BitmapImage Image
{
get => (BitmapImage)GetValue(ImageProperty);
set => SetValue(ImageProperty, value);
}
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(nameof(Image), typeof(BitmapImage), typeof(ImageRadioButtonView),
new FrameworkPropertyMetadata(default(BitmapImage)));
public ICommand Command
{
get => (ICommand)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(ImageRadioButtonView),
new FrameworkPropertyMetadata(default(ICommand)));
public ImageRadioButtonView()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.IsChecked = true;
}
}
}

View File

@ -6,6 +6,7 @@
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"
xmlns:wabbacommon="clr-namespace:Wabbajack.Common;assembly=Wabbajack.Common"
d:DataContext="{d:DesignInstance local:CompilerVM}" d:DataContext="{d:DesignInstance local:CompilerVM}"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
@ -32,12 +33,12 @@
Grid.RowSpan="2" Grid.RowSpan="2"
Grid.Column="4" /> Grid.Column="4" />
<local:DetailImageView <local:DetailImageView
Title="{Binding ModListName}" Title="{Binding CurrentModlistSettings.ModListName}"
Grid.Row="1" Grid.Row="1"
Grid.Column="3" Grid.Column="3"
Author="{Binding AuthorText}" Author="{Binding CurrentModlistSettings.AuthorText}"
BorderThickness="0" BorderThickness="0"
Description="{Binding Description}" Description="{Binding CurrentModlistSettings.Description}"
Image="{Binding Image}" /> Image="{Binding Image}" />
<Rectangle <Rectangle
x:Name="ControlVerticalThinSeparator" x:Name="ControlVerticalThinSeparator"
@ -49,7 +50,7 @@
SnapsToDevicePixels="True" /> SnapsToDevicePixels="True" />
<!-- Comes after image area so shadow can overlay --> <!-- Comes after image area so shadow can overlay -->
<local:TopProgressView <local:TopProgressView
Title="{Binding ModListName, Mode=OneWay}" Title="{Binding CurrentModlistSettings.ModListName, Mode=OneWay}"
Grid.Row="0" Grid.Row="0"
Grid.RowSpan="2" Grid.RowSpan="2"
Grid.Column="0" Grid.Column="0"
@ -60,14 +61,15 @@
<ScrollViewer <ScrollViewer
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
Margin="5,0,5,5" Margin="5"
Background="Transparent" Background="Transparent"
HorizontalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled"
IsEnabled="{Binding Compiling, Converter={StaticResource InverseBooleanConverter}}" IsEnabled="{Binding Compiler.Compiling, Converter={StaticResource InverseBooleanConverter}}"
VerticalScrollBarVisibility="Auto"> VerticalScrollBarVisibility="Auto">
<StackPanel <StackPanel
Margin="0,5,0,0" Margin="0,5,0,0"
Background="Transparent" Background="Transparent"
DataContext="{Binding CurrentModlistSettings}"
Orientation="Vertical"> Orientation="Vertical">
<StackPanel.Resources> <StackPanel.Resources>
<Thickness <Thickness
@ -147,53 +149,62 @@
Margin="35,0,35,0" Margin="35,0,35,0"
VerticalAlignment="Center" VerticalAlignment="Center"
ClipToBounds="False" ClipToBounds="False"
Visibility="{Binding Compiling, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}"> Visibility="{Binding Compiler.Compiling, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="40" /> <RowDefinition Height="*" />
<RowDefinition Height="40" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="20" /> <ColumnDefinition Width="20" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock <Grid
Grid.Row="0" Grid.Row="0"
Grid.RowSpan="5"
Grid.Column="0" Grid.Column="0"
HorizontalAlignment="Right" Margin="15"
VerticalAlignment="Center" VerticalAlignment="Center">
FontSize="14" <Grid.RowDefinitions>
Text="Modlist Location" <RowDefinition Height="Auto" />
TextAlignment="Center" /> <RowDefinition Height="Auto" />
<local:FilePicker </Grid.RowDefinitions>
<local:ImageRadioButtonView
Grid.Row="0" Grid.Row="0"
Grid.Column="2" Height="35"
Height="30" Margin="4"
VerticalAlignment="Center" IsChecked="{Binding SelectedCompilerType, Converter={StaticResource EqualsToBoolConverter}, ConverterParameter={x:Static wabbacommon:ModManager.MO2}}">
DataContext="{Binding ModlistLocation}" <local:ImageRadioButtonView.Image>
FontSize="14" /> <BitmapImage UriSource="../../Resources/MO2Button.png" />
<TextBlock </local:ImageRadioButtonView.Image>
</local:ImageRadioButtonView>
<local:ImageRadioButtonView
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Height="35"
HorizontalAlignment="Right" Margin="4"
VerticalAlignment="Center" IsChecked="{Binding SelectedCompilerType, Converter={StaticResource EqualsToBoolConverter}, ConverterParameter={x:Static wabbacommon:ModManager.Vortex}}">
FontSize="14" <local:ImageRadioButtonView.Image>
Text="Download Location" <BitmapImage UriSource="../../Resources/VortexButton.png" />
TextAlignment="Center" /> </local:ImageRadioButtonView.Image>
<local:FilePicker </local:ImageRadioButtonView>
</Grid>
<ContentPresenter
Grid.Row="1" Grid.Row="1"
Grid.Column="2" Grid.Column="1"
Height="30" Content="{Binding Compiler}">
VerticalAlignment="Center" <ContentPresenter.Resources>
DataContext="{Binding DownloadLocation}" <DataTemplate DataType="{x:Type local:MO2CompilerVM}">
FontSize="14" /> <local:MO2CompilerConfigView />
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
<local:BeginButton <local:BeginButton
Grid.Row="0" Grid.Row="0"
Grid.RowSpan="2" Grid.RowSpan="3"
Grid.Column="4" Grid.Column="5"
Command="{Binding BeginCommand}" /> Command="{Binding Compiler.BeginCommand}" />
</Grid> </Grid>
</Grid> </Grid>
<Grid <Grid
@ -201,7 +212,7 @@
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="5" Grid.ColumnSpan="5"
Margin="5" Margin="5"
Visibility="{Binding Compiling, Converter={StaticResource bool2VisibilityConverter}, FallbackValue=Hidden}"> Visibility="{Binding Compiler.Compiling, Converter={StaticResource bool2VisibilityConverter}, FallbackValue=Hidden}">
<local:LogCpuView DataContext="{Binding MWVM}" /> <local:LogCpuView DataContext="{Binding MWVM}" />
</Grid> </Grid>
</Grid> </Grid>

View File

@ -0,0 +1,75 @@
<UserControl
x:Class="Wabbajack.MO2CompilerConfigView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wabbajack"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DataContext="{d:DesignInstance local:MO2CompilerVM}"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="14"
Text="Modlist Location"
TextAlignment="Center"
ToolTip="The MO2 modlist.txt file you want to use as your source" />
<local:FilePicker
Grid.Row="0"
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding ModlistLocation}"
FontSize="14"
ToolTip="The MO2 modlist.txt file you want to use as your source" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="14"
Text="Download Location"
TextAlignment="Center"
ToolTip="The folder where MO2 downloads your mods." />
<local:FilePicker
Grid.Row="1"
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding DownloadLocation}"
FontSize="14"
ToolTip="The folder where MO2 downloads your mods." />
<TextBlock
Grid.Row="2"
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="14"
Text="Output Location"
TextAlignment="Center"
ToolTip="The folder to place the resulting modlist.wabbajack file" />
<local:FilePicker
Grid.Row="2"
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding OutputLocation}"
FontSize="14"
ToolTip="The folder to place the resulting modlist.wabbajack file" />
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.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;
namespace Wabbajack
{
/// <summary>
/// Interaction logic for MO2CompilerConfigView.xaml
/// </summary>
public partial class MO2CompilerConfigView : UserControl
{
public MO2CompilerConfigView()
{
InitializeComponent();
}
}
}

View File

@ -27,10 +27,17 @@
<RowDefinition Height="4*" /> <RowDefinition Height="4*" />
<RowDefinition Height="*" MinHeight="150" /> <RowDefinition Height="*" MinHeight="150" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<local:BorderFadeDownView <Rectangle
x:Name="BorderEdgeFadeDown" x:Name="BorderEdgeFadeDown"
Grid.Row="1" Grid.Row="1"
Grid.RowSpan="2" /> Grid.RowSpan="2">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#191919" />
<GradientStop Offset="0.4" Color="#00191919" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Grid <Grid
x:Name="Slideshow" x:Name="Slideshow"
Grid.Row="1" Grid.Row="1"
@ -277,21 +284,12 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="80" /> <RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Visibility="{Binding IsMO2ModList, Converter={StaticResource bool2VisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock <TextBlock
Grid.Row="0" Grid.Row="1"
Grid.Column="0" Grid.Column="0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -306,7 +304,7 @@
DataContext="{Binding Location}" DataContext="{Binding Location}"
FontSize="14" /> FontSize="14" />
<TextBlock <TextBlock
Grid.Row="1" Grid.Row="2"
Grid.Column="0" Grid.Column="0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -314,56 +312,15 @@
Text="Download Location" Text="Download Location"
TextAlignment="Center" /> TextAlignment="Center" />
<local:FilePicker <local:FilePicker
Grid.Row="1" Grid.Row="2"
Grid.Column="2" Grid.Column="2"
Height="30" Height="30"
VerticalAlignment="Center" VerticalAlignment="Center"
DataContext="{Binding DownloadLocation}" DataContext="{Binding DownloadLocation}"
FontSize="14" /> FontSize="14" />
</Grid>
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Visibility="{Binding IsMO2ModList, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="14"
Text="Staging Folder"
TextAlignment="Center" />
<local:FilePicker
Grid.Row="0"
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding StagingLocation}"
FontSize="14" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="14"
Text="Download Folder"
TextAlignment="Center" />
<local:FilePicker
Grid.Row="1"
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding DownloadLocation}"
FontSize="14" />
</Grid>
<local:BeginButton <local:BeginButton
Grid.Row="1" Grid.Row="1"
Grid.RowSpan="2"
Grid.Column="4" Grid.Column="4"
Margin="0,0,25,0" Margin="0,0,25,0"
HorizontalAlignment="Right" HorizontalAlignment="Right"

View File

@ -37,42 +37,37 @@ namespace Wabbajack
private void CreateModlist_Click(object sender, RoutedEventArgs e) private void CreateModlist_Click(object sender, RoutedEventArgs e)
{ {
OpenMainWindow( ShutdownOnClose = false;
RunMode.Compile, var window = new MainWindow(RunMode.Compile, null, settings);
UIUtils.OpenFileDialog( window.Left = this.Left;
"MO2 Modlist(modlist.txt)|modlist.txt", window.Top = this.Top;
initialDirectory: settings.LastCompiledProfileLocation)); window.Show();
Close();
} }
private void InstallModlist_Click(object sender, RoutedEventArgs e) private void InstallModlist_Click(object sender, RoutedEventArgs e)
{ {
//OpenMainWindow(
// RunMode.Install,
// UIUtils.OpenFileDialog($"Wabbajack Modlist (*{Consts.ModlistExtension})|*{Consts.ModlistExtension}"));
var result = ((ModeSelectionWindowVM)DataContext).Download(); var result = ((ModeSelectionWindowVM)DataContext).Download();
if (result != null) if (result != null)
{ {
OpenMainWindow(RunMode.Install, result); OpenMainWindowInstall(result);
} }
} }
private void OpenMainWindow(RunMode mode, string file) private void InstallFromList_Click(object sender, RoutedEventArgs e)
{
OpenMainWindowInstall(
UIUtils.OpenFileDialog(
$"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}",
initialDirectory: settings.Installer.LastInstalledListLocation));
}
private void OpenMainWindowInstall(string file)
{ {
if (file == null) return; if (file == null) return;
ShutdownOnClose = false; ShutdownOnClose = false;
switch (mode) settings.Installer.LastInstalledListLocation = Path.GetDirectoryName(file);
{ var window = new MainWindow(RunMode.Install, file, settings);
case RunMode.Compile:
settings.LastCompiledProfileLocation = Path.GetDirectoryName(file);
break;
case RunMode.Install:
settings.LastInstalledListLocation = Path.GetDirectoryName(file);
break;
default:
break;
}
var window = new MainWindow(mode, file, settings);
window.Left = this.Left; window.Left = this.Left;
window.Top = this.Top; window.Top = this.Top;
window.Show(); window.Show();
@ -101,13 +96,5 @@ namespace Wabbajack
{ {
Process.Start("https://discord.gg/zgbrkmA"); Process.Start("https://discord.gg/zgbrkmA");
} }
private void InstallFromList_Click(object sender, RoutedEventArgs e)
{
OpenMainWindow(RunMode.Install,
UIUtils.OpenFileDialog(
$"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}",
initialDirectory: settings.LastInstalledListLocation));
}
} }
} }

View File

@ -161,27 +161,38 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="BorderFadeDownView.xaml.cs"> <Compile Include="Converters\EqualsToBoolConverter.cs" />
<Compile Include="Views\Compilers\MO2CompilerConfigView.xaml.cs">
<DependentUpon>MO2CompilerConfigView.xaml</DependentUpon>
</Compile>
<Compile Include="View Models\Compilers\ISubCompilerVM.cs" />
<Compile Include="View Models\Compilers\MO2CompilerVM.cs" />
<Compile Include="View Models\Compilers\ModlistSettingsEditorVM.cs" />
<Compile Include="View Models\Compilers\VortexCompilerVM.cs" />
<Compile Include="Views\Common\BorderFadeDownView.xaml.cs">
<DependentUpon>BorderFadeDownView.xaml</DependentUpon> <DependentUpon>BorderFadeDownView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Converters\InverseBooleanConverter.cs" /> <Compile Include="Converters\InverseBooleanConverter.cs" />
<Compile Include="Converters\BoolToVisibilityHiddenConverter.cs" /> <Compile Include="Converters\BoolToVisibilityHiddenConverter.cs" />
<Compile Include="Views\BeginButton.xaml.cs"> <Compile Include="Views\Common\RadioButtonView.xaml.cs">
<DependentUpon>RadioButtonView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Common\BeginButton.xaml.cs">
<DependentUpon>BeginButton.xaml</DependentUpon> <DependentUpon>BeginButton.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Converters\BoolToVisibilityConverter.cs" /> <Compile Include="Converters\BoolToVisibilityConverter.cs" />
<Compile Include="Views\DetailImageView.xaml.cs"> <Compile Include="Views\Common\DetailImageView.xaml.cs">
<DependentUpon>DetailImageView.xaml</DependentUpon> <DependentUpon>DetailImageView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Extensions\EnumerableExt.cs" /> <Compile Include="Extensions\EnumerableExt.cs" />
<Compile Include="Views\TopProgressView.xaml.cs"> <Compile Include="Views\Common\TopProgressView.xaml.cs">
<DependentUpon>TopProgressView.xaml</DependentUpon> <DependentUpon>TopProgressView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Settings.cs" /> <Compile Include="Settings.cs" />
<Compile Include="View Models\FilePickerVM.cs" /> <Compile Include="View Models\FilePickerVM.cs" />
<Compile Include="View Models\ModListVM.cs" /> <Compile Include="View Models\ModListVM.cs" />
<Compile Include="View Models\ModVM.cs" /> <Compile Include="View Models\ModVM.cs" />
<Compile Include="Views\CompilerView.xaml.cs"> <Compile Include="Views\Compilers\CompilerView.xaml.cs">
<DependentUpon>CompilerView.xaml</DependentUpon> <DependentUpon>CompilerView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Converters\IsNotNullVisibilityConverter.cs" /> <Compile Include="Converters\IsNotNullVisibilityConverter.cs" />
@ -191,15 +202,15 @@
</Compile> </Compile>
<Compile Include="View Models\ModeSelectionWindowVM.cs" /> <Compile Include="View Models\ModeSelectionWindowVM.cs" />
<Compile Include="View Models\ModListDefinition.cs" /> <Compile Include="View Models\ModListDefinition.cs" />
<Compile Include="Views\FilePicker.xaml.cs"> <Compile Include="Views\Common\FilePicker.xaml.cs">
<DependentUpon>FilePicker.xaml</DependentUpon> <DependentUpon>FilePicker.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\InstallationView.xaml.cs"> <Compile Include="Views\InstallationView.xaml.cs">
<DependentUpon>InstallationView.xaml</DependentUpon> <DependentUpon>InstallationView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="View Models\CompilerVM.cs" /> <Compile Include="View Models\Compilers\CompilerVM.cs" />
<Compile Include="View Models\MainWindowVM.cs" /> <Compile Include="View Models\MainWindowVM.cs" />
<Compile Include="Views\LogCpuView.xaml.cs"> <Compile Include="Views\Common\LogCpuView.xaml.cs">
<DependentUpon>LogCpuView.xaml</DependentUpon> <DependentUpon>LogCpuView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\ModeSelectionWindow.xaml.cs"> <Compile Include="Views\ModeSelectionWindow.xaml.cs">
@ -215,23 +226,31 @@
<DependentUpon>TextViewer.xaml</DependentUpon> <DependentUpon>TextViewer.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\UserControlRx.cs" /> <Compile Include="Views\UserControlRx.cs" />
<Page Include="BorderFadeDownView.xaml"> <Page Include="Views\Compilers\MO2CompilerConfigView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\BeginButton.xaml"> <Page Include="Views\Common\BorderFadeDownView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\DetailImageView.xaml"> <Page Include="Views\Common\RadioButtonView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\CompilerView.xaml"> <Page Include="Views\Common\BeginButton.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\TopProgressView.xaml"> <Page Include="Views\Common\DetailImageView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Compilers\CompilerView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Common\TopProgressView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@ -239,7 +258,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\FilePicker.xaml"> <Page Include="Views\Common\FilePicker.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
@ -247,7 +266,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\LogCpuView.xaml"> <Page Include="Views\Common\LogCpuView.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
@ -355,9 +374,6 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\Icons\next.png" /> <EmbeddedResource Include="Resources\Icons\next.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\none.jpg" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\Icons\github_light.png" /> <EmbeddedResource Include="Resources\Icons\github_light.png" />
<EmbeddedResource Include="Resources\Icons\patreon_light.png" /> <EmbeddedResource Include="Resources\Icons\patreon_light.png" />
@ -449,5 +465,9 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\Wabba_Mouth.png" /> <EmbeddedResource Include="Resources\Wabba_Mouth.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Resources\MO2Button.png" />
<Resource Include="Resources\VortexButton.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>