mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
5c62038341
The virtualization systems invoked by the Top() call seem to have a bug in them when handling duplicate entries (at least on the list-side). Removing it until it can be investigated further and fixed.
79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using DynamicData;
|
|
using DynamicData.Binding;
|
|
using ReactiveUI;
|
|
using ReactiveUI.Fody.Helpers;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Reactive.Disposables;
|
|
using System.Reactive.Linq;
|
|
using Wabbajack.Common;
|
|
using Wabbajack.Lib;
|
|
|
|
namespace Wabbajack
|
|
{
|
|
/// <summary>
|
|
/// Main View Model for the application.
|
|
/// Keeps track of which sub view is being shown in the window, and has some singleton wiring like WorkQueue and Logging.
|
|
/// </summary>
|
|
public class MainWindowVM : ViewModel
|
|
{
|
|
public MainWindow MainWindow { get; }
|
|
|
|
public MainSettings Settings { get; }
|
|
|
|
[Reactive]
|
|
public ViewModel ActivePane { get; set; }
|
|
|
|
public ObservableCollectionExtended<string> Log { get; } = new ObservableCollectionExtended<string>();
|
|
|
|
public readonly Lazy<CompilerVM> Compiler;
|
|
public readonly Lazy<InstallerVM> Installer;
|
|
public readonly ModeSelectionVM ModeSelectionVM;
|
|
|
|
public MainWindowVM(MainWindow mainWindow, MainSettings settings)
|
|
{
|
|
MainWindow = mainWindow;
|
|
Settings = settings;
|
|
Installer = new Lazy<InstallerVM>(() => new InstallerVM(this));
|
|
Compiler = new Lazy<CompilerVM>(() => new CompilerVM(this));
|
|
ModeSelectionVM = new ModeSelectionVM(this);
|
|
|
|
// Set up logging
|
|
Utils.LogMessages
|
|
.ObserveOn(RxApp.TaskpoolScheduler)
|
|
.ToObservableChangeSet()
|
|
.Buffer(TimeSpan.FromMilliseconds(250), RxApp.TaskpoolScheduler)
|
|
.Where(l => l.Count > 0)
|
|
.ObserveOn(RxApp.MainThreadScheduler)
|
|
.FlattenBufferResult()
|
|
.Bind(Log)
|
|
.Subscribe()
|
|
.DisposeWith(CompositeDisposable);
|
|
|
|
if (IsStartingFromModlist(out var path))
|
|
{
|
|
Installer.Value.ModListPath.TargetPath = path;
|
|
ActivePane = Installer.Value;
|
|
}
|
|
else
|
|
{
|
|
// Start on mode selection
|
|
ActivePane = ModeSelectionVM;
|
|
}
|
|
}
|
|
|
|
private static bool IsStartingFromModlist(out string modlistPath)
|
|
{
|
|
string[] args = Environment.GetCommandLineArgs();
|
|
if (args.Length != 3 || !args[1].Contains("-i"))
|
|
{
|
|
modlistPath = default;
|
|
return false;
|
|
}
|
|
|
|
modlistPath = args[2];
|
|
return true;
|
|
}
|
|
}
|
|
}
|