mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Rework the InstallVMs
This commit is contained in:
parent
2215acf0e9
commit
7faa65ca77
@ -11,6 +11,7 @@ using ReactiveUI;
|
|||||||
using Splat;
|
using Splat;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack;
|
using Wabbajack;
|
||||||
|
using Wabbajack.Models;
|
||||||
using Wabbajack.Services.OSIntegrated;
|
using Wabbajack.Services.OSIntegrated;
|
||||||
using Wabbajack.Util;
|
using Wabbajack.Util;
|
||||||
|
|
||||||
@ -48,12 +49,14 @@ namespace Wabbajack
|
|||||||
services.AddTransient<MainWindowVM>();
|
services.AddTransient<MainWindowVM>();
|
||||||
services.AddSingleton<SystemParametersConstructor>();
|
services.AddSingleton<SystemParametersConstructor>();
|
||||||
services.AddSingleton<LauncherUpdater>();
|
services.AddSingleton<LauncherUpdater>();
|
||||||
|
services.AddSingleton<ResourceMonitor>();
|
||||||
|
|
||||||
services.AddSingleton<MainSettings>();
|
services.AddSingleton<MainSettings>();
|
||||||
services.AddTransient<CompilerVM>();
|
services.AddTransient<CompilerVM>();
|
||||||
services.AddTransient<InstallerVM>();
|
services.AddTransient<InstallerVM>();
|
||||||
services.AddTransient<ModeSelectionVM>();
|
services.AddTransient<ModeSelectionVM>();
|
||||||
services.AddTransient<ModListGalleryVM>();
|
services.AddTransient<ModListGalleryVM>();
|
||||||
|
services.AddTransient<InstallerVM>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,21 @@ public class LoadingLock : ReactiveObject, IDisposable
|
|||||||
this.WhenAnyValue(vm => vm.LoadLevel)
|
this.WhenAnyValue(vm => vm.LoadLevel)
|
||||||
.Subscribe(v => IsLoading = v > 0)
|
.Subscribe(v => IsLoading = v > 0)
|
||||||
.DisposeWith(_disposable);
|
.DisposeWith(_disposable);
|
||||||
|
|
||||||
|
this.WhenAnyValue(vm => vm.LoadLevel)
|
||||||
|
.Subscribe(v => IsNotLoading = v == 0)
|
||||||
|
.DisposeWith(_disposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Reactive] public int LoadLevel { get; private set; }
|
[Reactive] public int LoadLevel { get; private set; }
|
||||||
|
|
||||||
[Reactive] public bool IsLoading { get; private set; }
|
[Reactive] public bool IsLoading { get; private set; }
|
||||||
|
|
||||||
|
[Reactive] public bool IsNotLoading { get; private set; }
|
||||||
|
|
||||||
|
public IObservable<bool> IsLoadingObservable => this.WhenAnyValue(ll => ll.IsLoading);
|
||||||
|
public IObservable<bool> IsNotLoadingObservable => this.WhenAnyValue(ll => ll.IsNotLoading);
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
|
19
Wabbajack.App.Wpf/Messages/LoadModlistForInstalling.cs
Normal file
19
Wabbajack.App.Wpf/Messages/LoadModlistForInstalling.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using ReactiveUI;
|
||||||
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
|
namespace Wabbajack.Messages;
|
||||||
|
|
||||||
|
public class LoadModlistForInstalling
|
||||||
|
{
|
||||||
|
public AbsolutePath Path { get; }
|
||||||
|
|
||||||
|
public LoadModlistForInstalling(AbsolutePath path)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Send(AbsolutePath path)
|
||||||
|
{
|
||||||
|
MessageBus.Current.SendMessage(new LoadModlistForInstalling(path));
|
||||||
|
}
|
||||||
|
}
|
44
Wabbajack.App.Wpf/Models/ResourceMonitor.cs
Normal file
44
Wabbajack.App.Wpf/Models/ResourceMonitor.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive.Subjects;
|
||||||
|
using System.Timers;
|
||||||
|
using Wabbajack.RateLimiter;
|
||||||
|
|
||||||
|
namespace Wabbajack.Models;
|
||||||
|
|
||||||
|
public class ResourceMonitor : IDisposable
|
||||||
|
{
|
||||||
|
private readonly IResource[] _resources;
|
||||||
|
private readonly Timer _timer;
|
||||||
|
|
||||||
|
private readonly Subject<(string Name, long Througput)[]> _updates = new ();
|
||||||
|
private (string Name, long Throughput)[] _prev;
|
||||||
|
public IObservable<(string Name, long Throughput)[]> Updates => _updates;
|
||||||
|
|
||||||
|
|
||||||
|
public ResourceMonitor(IEnumerable<IResource> resources)
|
||||||
|
{
|
||||||
|
_resources = resources.ToArray();
|
||||||
|
_timer = new Timer();
|
||||||
|
_timer.Interval = 1000;
|
||||||
|
_timer.Elapsed += Elapsed;
|
||||||
|
_timer.Enabled = true;
|
||||||
|
_prev = _resources.Select(x => (x.Name, (long)0)).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Elapsed(object? sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
var current = _resources.Select(x => (x.Name, x.StatusReport.Transferred)).ToArray();
|
||||||
|
var diff = _prev.Zip(current)
|
||||||
|
.Select(t => (t.First.Name, (long)((t.Second.Transferred - t.First.Throughput) / (_timer.Interval / 1000.0))))
|
||||||
|
.ToArray();
|
||||||
|
_prev = current;
|
||||||
|
_updates.OnNext(diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_timer?.Dispose();
|
||||||
|
}
|
||||||
|
}
|
@ -142,59 +142,19 @@ namespace Wabbajack
|
|||||||
IsLoadingIdle.OnNext(true);
|
IsLoadingIdle.OnNext(true);
|
||||||
}
|
}
|
||||||
}, IsLoadingIdle.StartWith(true));
|
}, IsLoadingIdle.StartWith(true));
|
||||||
ExecuteCommand = ReactiveCommand.CreateFromObservable<Unit, Unit>(
|
|
||||||
canExecute: this.WhenAny(x => x.IsBroken).Select(x => !x),
|
ExecuteCommand = ReactiveCommand.CreateFromTask(async () =>
|
||||||
execute: (unit) =>
|
|
||||||
Observable.Return(unit)
|
|
||||||
.WithLatestFrom(
|
|
||||||
this.WhenAny(x => x.Exists),
|
|
||||||
(_, e) => e)
|
|
||||||
// Do any download work on background thread
|
|
||||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
|
||||||
.SelectTask(async (exists) =>
|
|
||||||
{
|
{
|
||||||
if (!exists)
|
if (await _maintainer.HaveModList(Metadata))
|
||||||
{
|
{
|
||||||
try
|
LoadModlistForInstalling.Send(_maintainer.ModListPath(Metadata));
|
||||||
|
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Installer);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
await Download();
|
await Download();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}, LoadingLock.WhenAnyValue(ll => ll.IsLoading).Select(v => !v));
|
||||||
{
|
|
||||||
Error = ErrorResponse.Fail(ex);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Return an updated check on exists
|
|
||||||
return Location.FileExists();
|
|
||||||
}
|
|
||||||
return exists;
|
|
||||||
})
|
|
||||||
.Where(exists => exists)
|
|
||||||
// Do any install page swap over on GUI thread
|
|
||||||
.ObserveOnGuiThread()
|
|
||||||
.Select(_ =>
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
//_parent.MWVM.OpenInstaller(Location);
|
|
||||||
|
|
||||||
// Wait for modlist member to be filled, then open its readme
|
|
||||||
return _parent.MWVM.Installer.Value.WhenAny(x => x.ModList)
|
|
||||||
.NotNull()
|
|
||||||
.Take(1)
|
|
||||||
.Do(modList =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
modList.OpenReadme();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "While opening modlist README");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.Switch()
|
|
||||||
.Unit());
|
|
||||||
|
|
||||||
_Exists = Observable.Interval(TimeSpan.FromSeconds(0.5))
|
_Exists = Observable.Interval(TimeSpan.FromSeconds(0.5))
|
||||||
.Unit()
|
.Unit()
|
||||||
|
@ -8,14 +8,19 @@ using System.Windows.Media;
|
|||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||||
using Microsoft.WindowsAPICodePack.Shell;
|
using Microsoft.WindowsAPICodePack.Shell;
|
||||||
|
using Wabbajack.Common;
|
||||||
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.DTOs.JsonConverters;
|
using Wabbajack.DTOs.JsonConverters;
|
||||||
using Wabbajack.Extensions;
|
using Wabbajack.Extensions;
|
||||||
|
using Wabbajack.Installer;
|
||||||
using Wabbajack.Interventions;
|
using Wabbajack.Interventions;
|
||||||
using Wabbajack.Messages;
|
using Wabbajack.Messages;
|
||||||
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.RateLimiter;
|
using Wabbajack.RateLimiter;
|
||||||
using Wabbajack.View_Models;
|
using Wabbajack.View_Models;
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
@ -29,65 +34,48 @@ public enum ModManager
|
|||||||
Standard
|
Standard
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
|
public class InstallerVM : BackNavigatingVM, IBackNavigatingVM
|
||||||
{
|
{
|
||||||
public SlideShow Slideshow { get; }
|
|
||||||
|
|
||||||
public MainWindowVM MWVM { get; }
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<ModListVM> _modList;
|
|
||||||
public ModListVM ModList => _modList.Value;
|
|
||||||
|
|
||||||
public FilePickerVM ModListLocation { get; }
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<ISubInstallerVM> _installer;
|
|
||||||
public ISubInstallerVM Installer => _installer.Value;
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<bool> _installing;
|
|
||||||
public bool Installing => _installing.Value;
|
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool StartedInstallation { get; set; }
|
public ModList ModList { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public ErrorResponse? Completed { get; set; }
|
public ErrorResponse? Completed { get; set; }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<ImageSource> _image;
|
[Reactive]
|
||||||
public ImageSource Image => _image.Value;
|
public FilePickerVM ModListLocation { get; set; }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<string> _titleText;
|
[Reactive]
|
||||||
public string TitleText => _titleText.Value;
|
public MO2InstallerVM Installer { get; set; }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<string> _authorText;
|
[Reactive]
|
||||||
public string AuthorText => _authorText.Value;
|
public BitmapFrame ModListImage { get; set; }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<string> _description;
|
[Reactive]
|
||||||
public string Description => _description.Value;
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<string> _progressTitle;
|
public BitmapFrame SlideShowImage { get; set; }
|
||||||
public string ProgressTitle => _progressTitle.Value;
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<string> _modListName;
|
|
||||||
public string ModListName => _modListName.Value;
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<Percent> _percentCompleted;
|
/// <summary>
|
||||||
public Percent PercentCompleted => _percentCompleted.Value;
|
/// Slideshow Data
|
||||||
|
/// </summary>
|
||||||
|
[Reactive]
|
||||||
|
public string SlideShowTitle { get; set; }
|
||||||
|
|
||||||
public ObservableCollectionExtended<CPUDisplayVM> StatusList { get; } = new ObservableCollectionExtended<CPUDisplayVM>();
|
[Reactive]
|
||||||
public ObservableCollectionExtended<IStatusMessage> Log => MWVM.Log;
|
public string SlideShowAuthor { get; set; }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<ModManager?> _TargetManager;
|
[Reactive]
|
||||||
public ModManager? TargetManager => _TargetManager.Value;
|
public string SlideShowDescription { get; set; }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<IUserIntervention> _ActiveGlobalUserIntervention;
|
|
||||||
public IUserIntervention ActiveGlobalUserIntervention => _ActiveGlobalUserIntervention.Value;
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<(int CurrentCPUs, int DesiredCPUs)> _CurrentCpuCount;
|
private readonly ObservableAsPropertyHelper<bool> _installing;
|
||||||
public (int CurrentCPUs, int DesiredCPUs) CurrentCpuCount => _CurrentCpuCount.Value;
|
private readonly DTOSerializer _dtos;
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<bool> _LoadingModlist;
|
|
||||||
private readonly ILogger<InstallerVM> _logger;
|
private readonly ILogger<InstallerVM> _logger;
|
||||||
public bool LoadingModlist => _LoadingModlist.Value;
|
|
||||||
|
[Reactive]
|
||||||
|
public bool Installing { get; set; }
|
||||||
|
|
||||||
|
|
||||||
// Command properties
|
// Command properties
|
||||||
public ReactiveCommand<Unit, Unit> ShowManifestCommand { get; }
|
public ReactiveCommand<Unit, Unit> ShowManifestCommand { get; }
|
||||||
@ -99,31 +87,25 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
|
|||||||
public ReactiveCommand<Unit, Unit> GoToInstallCommand { get; }
|
public ReactiveCommand<Unit, Unit> GoToInstallCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> BeginCommand { get; }
|
public ReactiveCommand<Unit, Unit> BeginCommand { get; }
|
||||||
|
|
||||||
public InstallerVM(ILogger<InstallerVM> logger, MainWindowVM mainWindowVM, IServiceProvider serviceProvider) : base(logger)
|
public ReactiveCommand<Unit, Unit> BackCommand { get; }
|
||||||
|
|
||||||
|
public InstallerVM(ILogger<InstallerVM> logger, DTOSerializer dtos) : base(logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_dtos = dtos;
|
||||||
|
Installer = new MO2InstallerVM(this);
|
||||||
|
|
||||||
/* TODO
|
BackCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModeSelectionView));
|
||||||
var downloadsPath = KnownFolders.Downloads.Path;
|
|
||||||
var skyDrivePath = KnownFolders.SkyDrive.Path;
|
|
||||||
|
|
||||||
if (downloadsPath != null && AbsolutePath.EntryPoint.IsChildOf(new AbsolutePath(downloadsPath)))
|
OpenReadmeCommand = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
logger.LogError(Error(new CriticalFailureIntervention(
|
UIUtils.OpenWebsite(new Uri(ModList!.Readme));
|
||||||
"Wabbajack is running inside your Downloads folder. This folder is often highly monitored by antivirus software and these can often " +
|
}, LoadingLock.IsNotLoadingObservable);
|
||||||
"conflict with the operations Wabbajack needs to perform. Please move Wabbajack outside of your Downloads folder and then restart the app.",
|
|
||||||
"Cannot run inside Downloads", true));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skyDrivePath != null && AbsolutePath.EntryPoint.IsChildOf(new AbsolutePath(skyDrivePath)))
|
VisitModListWebsiteCommand = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
Utils.Error(new CriticalFailureIntervention(
|
UIUtils.OpenWebsite(ModList!.Website);
|
||||||
$"Wabbajack is running inside a OneDrive folder \"{skyDrivePath}\". This folder is known to cause issues with Wabbajack. " +
|
}, LoadingLock.IsNotLoadingObservable);
|
||||||
"Please move Wabbajack outside of your OneDrive folder and then restart the app.",
|
|
||||||
"Cannot run inside OneDrive", true));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
MWVM = mainWindowVM;
|
|
||||||
|
|
||||||
ModListLocation = new FilePickerVM
|
ModListLocation = new FilePickerVM
|
||||||
{
|
{
|
||||||
@ -133,349 +115,46 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
|
|||||||
};
|
};
|
||||||
ModListLocation.Filters.Add(new CommonFileDialogFilter("Wabbajack Modlist", "*.wabbajack"));
|
ModListLocation.Filters.Add(new CommonFileDialogFilter("Wabbajack Modlist", "*.wabbajack"));
|
||||||
|
|
||||||
// Swap to proper sub VM based on selected type
|
MessageBus.Current.Listen<LoadModlistForInstalling>()
|
||||||
_installer = this.WhenAny(x => x.TargetManager)
|
.Subscribe(msg => LoadModlist(msg.Path).FireAndForget())
|
||||||
// Delay so the initial VM swap comes in immediately, subVM comes right after
|
|
||||||
.DelayInitial(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
|
||||||
.Select<ModManager?, ISubInstallerVM>(type =>
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ModManager.Standard:
|
|
||||||
return new MO2InstallerVM(this);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// Unload old VM
|
|
||||||
.Pairwise()
|
|
||||||
.Do(pair =>
|
|
||||||
{
|
|
||||||
pair.Previous?.Unload();
|
|
||||||
})
|
|
||||||
.Select(p => p.Current)
|
|
||||||
.ToGuiProperty(this, nameof(Installer));
|
|
||||||
|
|
||||||
// Load settings
|
|
||||||
MWVM.Settings.SaveSignal
|
|
||||||
.Subscribe(_ =>
|
|
||||||
{
|
|
||||||
MWVM.Settings.Installer.LastInstalledListLocation = ModListLocation.TargetPath;
|
|
||||||
})
|
|
||||||
.DisposeWith(CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
// Active path represents the path to currently have loaded
|
this.WhenActivated(disposables =>
|
||||||
// If we're not actively showing, then "unload" the active path
|
|
||||||
var activePath = Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.ModListLocation.TargetPath),
|
|
||||||
this.WhenAny(x => x.IsActive),
|
|
||||||
resultSelector: (path, active) => (path, active))
|
|
||||||
.Select(x =>
|
|
||||||
{
|
{
|
||||||
if (!x.active) return default;
|
ModListLocation.WhenAnyValue(l => l.TargetPath)
|
||||||
return x.path;
|
.Subscribe(p => LoadModlist(p).FireAndForget())
|
||||||
})
|
.DisposeWith(disposables);
|
||||||
// Throttle slightly so changes happen more atomically
|
|
||||||
.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
|
||||||
.Replay(1)
|
|
||||||
.RefCount();
|
|
||||||
|
|
||||||
|
|
||||||
_modList = activePath
|
|
||||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
|
||||||
// Convert from active path to modlist VM
|
|
||||||
.Select(modListPath =>
|
|
||||||
{
|
|
||||||
if (modListPath == default) return default;
|
|
||||||
if (!modListPath.FileExists()) return default;
|
|
||||||
return new ModListVM(serviceProvider.GetRequiredService<ILogger<ModListVM>>()!, modListPath, serviceProvider.GetRequiredService<DTOSerializer>());
|
|
||||||
})
|
|
||||||
.DisposeOld()
|
|
||||||
.ObserveOnGuiThread()
|
|
||||||
.StartWith(default(ModListVM))
|
|
||||||
.ToGuiProperty(this, nameof(ModList));
|
|
||||||
|
|
||||||
// Force GC collect when modlist changes, just to make sure we clean up any loose large items immediately
|
|
||||||
this.WhenAny(x => x.ModList)
|
|
||||||
.Delay(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
|
||||||
.Subscribe(x =>
|
|
||||||
{
|
|
||||||
GC.Collect();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
_LoadingModlist = Observable.Merge(
|
|
||||||
// When active path changes, mark as loading
|
|
||||||
activePath
|
|
||||||
.Select(_ => true),
|
|
||||||
// When the resulting modlist comes in, mark it as done
|
|
||||||
this.WhenAny(x => x.ModList)
|
|
||||||
.Select(_ => false))
|
|
||||||
.ToGuiProperty(this, nameof(LoadingModlist));
|
|
||||||
_installing = this.WhenAny(x => x.Installer.ActiveInstallation)
|
|
||||||
.Select(i => i != null)
|
|
||||||
.ToGuiProperty(this, nameof(Installing));
|
|
||||||
|
|
||||||
/*TODO
|
|
||||||
_TargetManager = this.WhenAny(x => x.ModList)
|
|
||||||
.Select(modList => ModManager.Standard)
|
|
||||||
.ToGuiProperty(this, nameof(TargetManager));
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Add additional error check on ModList
|
|
||||||
ModListLocation.AdditionalError = this.WhenAny(x => x.ModList)
|
|
||||||
.Select<ModListVM, IErrorResponse>(modList =>
|
|
||||||
{
|
|
||||||
if (modList == null) return ErrorResponse.Fail("Modlist path resulted in a null object.");
|
|
||||||
if (modList.Error != null) return ErrorResponse.Fail("Modlist is corrupt", modList.Error);
|
|
||||||
if (modList.WabbajackVersion != null && modList.WabbajackVersion > Consts.CurrentMinimumWabbajackVersion)
|
|
||||||
return ErrorResponse.Fail("The Modlist you are trying to install was made using a newer Version of Wabbajack. Please update Wabbajack before installing!");
|
|
||||||
return ErrorResponse.Success;
|
|
||||||
});
|
|
||||||
|
|
||||||
BackCommand = ReactiveCommand.Create(
|
|
||||||
execute: () =>
|
|
||||||
{
|
|
||||||
StartedInstallation = false;
|
|
||||||
Completed = null;
|
|
||||||
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModeSelectionView);
|
|
||||||
},
|
|
||||||
canExecute: Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.Installing)
|
|
||||||
.Select(x => !x),
|
|
||||||
this.ConstructCanNavigateBack(),
|
|
||||||
resultSelector: (i, b) => i && b)
|
|
||||||
.ObserveOnGuiThread());
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
_percentCompleted = this.WhenAny(x => x.Installer.ActiveInstallation)
|
|
||||||
.StartWith(default(IInstaller))
|
|
||||||
.CombineLatest(
|
|
||||||
this.WhenAny(x => x.Completed),
|
|
||||||
(installer, completed) =>
|
|
||||||
{
|
|
||||||
if (installer == null)
|
|
||||||
{
|
|
||||||
return Observable.Return<Percent>(completed != null ? Percent.One : Percent.Zero);
|
|
||||||
}
|
}
|
||||||
return installer.PercentCompleted.StartWith(Percent.Zero);
|
|
||||||
})
|
|
||||||
.Switch()
|
|
||||||
.Debounce(TimeSpan.FromMilliseconds(25), RxApp.MainThreadScheduler)
|
|
||||||
.ToGuiProperty(this, nameof(PercentCompleted));
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
private async Task LoadModlist(AbsolutePath path)
|
||||||
Slideshow = new SlideShow( this, serviceProvider);
|
|
||||||
|
|
||||||
// Set display items to ModList if configuring or complete,
|
|
||||||
// or to the current slideshow data if installing
|
|
||||||
_image = Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.ModList.Error),
|
|
||||||
this.WhenAny(x => x.ModList)
|
|
||||||
.Select(x => x?.ImageObservable ?? Observable.Return(default(BitmapImage)))
|
|
||||||
.Switch()
|
|
||||||
.StartWith(default(BitmapImage)),
|
|
||||||
this.WhenAny(x => x.Slideshow.Image)
|
|
||||||
.StartWith(default(BitmapImage)),
|
|
||||||
this.WhenAny(x => x.Installing),
|
|
||||||
this.WhenAny(x => x.LoadingModlist),
|
|
||||||
resultSelector: (err, modList, slideshow, installing, loading) =>
|
|
||||||
{
|
|
||||||
if (err != null)
|
|
||||||
{
|
|
||||||
return ResourceLinks.WabbajackErrLogo.Value;
|
|
||||||
}
|
|
||||||
if (loading) return default;
|
|
||||||
return installing ? slideshow : modList;
|
|
||||||
})
|
|
||||||
.Select<BitmapImage, ImageSource>(x => x)
|
|
||||||
.ToGuiProperty(this, nameof(Image));
|
|
||||||
_titleText = Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.ModList)
|
|
||||||
.Select(modList => modList?.Name ?? string.Empty),
|
|
||||||
this.WhenAny(x => x.Slideshow.TargetMod.State.Name)
|
|
||||||
.StartWith(default(string)),
|
|
||||||
this.WhenAny(x => x.Installing),
|
|
||||||
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
|
||||||
.ToGuiProperty(this, nameof(TitleText));
|
|
||||||
_authorText = Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.ModList)
|
|
||||||
.Select(modList => modList?.Author ?? string.Empty),
|
|
||||||
this.WhenAny(x => x.Slideshow.TargetMod.State.Author)
|
|
||||||
.StartWith(default(string)),
|
|
||||||
this.WhenAny(x => x.Installing),
|
|
||||||
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
|
||||||
.ToGuiProperty(this, nameof(AuthorText));
|
|
||||||
_description = Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.ModList)
|
|
||||||
.Select(modList => modList?.Description ?? string.Empty),
|
|
||||||
this.WhenAny(x => x.Slideshow.TargetMod.State.Description)
|
|
||||||
.StartWith(default(string)),
|
|
||||||
this.WhenAny(x => x.Installing),
|
|
||||||
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
|
||||||
.ToGuiProperty(this, nameof(Description));
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
_modListName = Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.ModList.Error)
|
|
||||||
.Select(x => x != null),
|
|
||||||
this.WhenAny(x => x.ModList)
|
|
||||||
.Select(x => x?.Name),
|
|
||||||
resultSelector: (err, name) =>
|
|
||||||
{
|
|
||||||
if (err) return "Corrupted Modlist";
|
|
||||||
return name;
|
|
||||||
})
|
|
||||||
.Merge(this.WhenAny(x => x.Installer.ActiveInstallation)
|
|
||||||
.Where(c => c != null)
|
|
||||||
.SelectMany(c => c.TextStatus))
|
|
||||||
.ToGuiProperty(this, nameof(ModListName));
|
|
||||||
*/
|
|
||||||
|
|
||||||
ShowManifestCommand = ReactiveCommand.Create(() =>
|
|
||||||
{
|
|
||||||
UIUtils.OpenWebsite(new Uri("https://www.wabbajack.org/#/modlists/manifest"));
|
|
||||||
}, this.WhenAny(x => x.ModList)
|
|
||||||
.Select(x => x?.SourceModList != null)
|
|
||||||
.ObserveOnGuiThread());
|
|
||||||
|
|
||||||
OpenReadmeCommand = ReactiveCommand.Create(
|
|
||||||
execute: () => this.ModList?.OpenReadme(),
|
|
||||||
canExecute: this.WhenAny(x => x.ModList)
|
|
||||||
.Select(modList => !string.IsNullOrEmpty(modList?.Readme))
|
|
||||||
.ObserveOnGuiThread());
|
|
||||||
|
|
||||||
/*TODO
|
|
||||||
OpenLogsCommand = ReactiveCommand.Create(
|
|
||||||
execute: () => UIUtils.OpenFolder(Consts.LogsFolder));
|
|
||||||
*/
|
|
||||||
VisitModListWebsiteCommand = ReactiveCommand.Create(
|
|
||||||
execute: () =>
|
|
||||||
{
|
|
||||||
UIUtils.OpenWebsite(ModList.Website);
|
|
||||||
return Unit.Default;
|
|
||||||
},
|
|
||||||
canExecute: this.WhenAny(x => x.ModList.Website)
|
|
||||||
.Select(x => x != null)
|
|
||||||
.ObserveOnGuiThread());
|
|
||||||
|
|
||||||
_progressTitle = this.WhenAnyValue(
|
|
||||||
x => x.Installing,
|
|
||||||
x => x.StartedInstallation,
|
|
||||||
x => x.Completed,
|
|
||||||
selector: (installing, started, completed) =>
|
|
||||||
{
|
|
||||||
if (installing)
|
|
||||||
{
|
|
||||||
return "Installing";
|
|
||||||
}
|
|
||||||
else if (started)
|
|
||||||
{
|
|
||||||
if (completed == null) return "Installing";
|
|
||||||
return completed.Value.Succeeded ? "Installed" : "Failed";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "Awaiting Input";
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.ToGuiProperty(this, nameof(ProgressTitle));
|
|
||||||
|
|
||||||
/*
|
|
||||||
UIUtils.BindCpuStatus(
|
|
||||||
this.WhenAny(x => x.Installer.ActiveInstallation)
|
|
||||||
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>()),
|
|
||||||
StatusList)
|
|
||||||
.DisposeWith(CompositeDisposable);
|
|
||||||
*/
|
|
||||||
BeginCommand = ReactiveCommand.CreateFromTask(
|
|
||||||
canExecute: this.WhenAny(x => x.Installer.CanInstall)
|
|
||||||
.Select(err => err.Succeeded),
|
|
||||||
execute: async () =>
|
|
||||||
{
|
{
|
||||||
|
using var ll = LoadingLock.WithLoading();
|
||||||
|
ModListLocation.TargetPath = path;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Starting to install {Name}", ModList.Name);
|
ModList = await StandardInstaller.LoadFromFile(_dtos, path);
|
||||||
IsBackEnabledSubject.OnNext(false);
|
ModListImage = BitmapFrame.Create(await StandardInstaller.ModListImageStream(path));
|
||||||
var success = await this.Installer.Install();
|
PopulateSlideShow(ModList);
|
||||||
Completed = ErrorResponse.Create(success);
|
|
||||||
try
|
ll.Succeed();
|
||||||
{
|
|
||||||
this.ModList?.OpenReadme();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "During installation");
|
_logger.LogError(ex, "While loading modlist");
|
||||||
|
ll.Fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
|
||||||
|
private void PopulateSlideShow(ModList modList)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, $"Encountered error, can't continue");
|
SlideShowTitle = modList.Name;
|
||||||
while (ex.InnerException != null) ex = ex.InnerException;
|
SlideShowAuthor = modList.Author;
|
||||||
Completed = ErrorResponse.Fail(ex);
|
SlideShowDescription = modList.Description;
|
||||||
|
SlideShowImage = ModListImage;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
IsBackEnabledSubject.OnNext(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// When sub installer begins an install, mark state variable
|
|
||||||
BeginCommand.StartingExecution()
|
|
||||||
.Subscribe(_ =>
|
|
||||||
{
|
|
||||||
StartedInstallation = true;
|
|
||||||
})
|
|
||||||
.DisposeWith(CompositeDisposable);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Listen for user interventions, and compile a dynamic list of all unhandled ones
|
|
||||||
var activeInterventions = this.WhenAny(x => x.Installer.ActiveInstallation)
|
|
||||||
.WithLatestFrom(
|
|
||||||
this.WhenAny(x => x.Installer),
|
|
||||||
(activeInstall, installer) =>
|
|
||||||
{
|
|
||||||
if (activeInstall == null) return Observable.Empty<IChangeSet<IUserIntervention>>();
|
|
||||||
return activeInstall.LogMessages
|
|
||||||
.WhereCastable<IStatusMessage, IUserIntervention>()
|
|
||||||
.ToObservableChangeSet()
|
|
||||||
.AutoRefresh(i => i.Handled)
|
|
||||||
.Filter(i => !i.Handled)
|
|
||||||
.Transform(x => installer.InterventionConverter(x));
|
|
||||||
})
|
|
||||||
.Switch()
|
|
||||||
.AsObservableList();
|
|
||||||
|
|
||||||
// Find the top intervention /w no CPU ID to be marked as "global"
|
|
||||||
_ActiveGlobalUserIntervention = activeInterventions.Connect()
|
|
||||||
.Filter(x => x.CpuID == WorkQueue.UnassignedCpuId)
|
|
||||||
.QueryWhenChanged(query => query.FirstOrDefault())
|
|
||||||
.ToGuiProperty(this, nameof(ActiveGlobalUserIntervention));
|
|
||||||
*/
|
|
||||||
|
|
||||||
CloseWhenCompleteCommand = ReactiveCommand.CreateFromTask(
|
|
||||||
canExecute: this.WhenAny(x => x.Completed)
|
|
||||||
.Select(x => x != null),
|
|
||||||
execute: async () =>
|
|
||||||
{
|
|
||||||
await MWVM.ShutdownApplication();
|
|
||||||
});
|
|
||||||
|
|
||||||
GoToInstallCommand = ReactiveCommand.Create(
|
|
||||||
canExecute: Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.Completed)
|
|
||||||
.Select(x => x != null),
|
|
||||||
this.WhenAny(x => x.Installer.SupportsAfterInstallNavigation),
|
|
||||||
resultSelector: (complete, supports) => complete && supports),
|
|
||||||
execute: () =>
|
|
||||||
{
|
|
||||||
Installer.AfterInstallNavigation();
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
_CurrentCpuCount = this.WhenAny(x => x.Installer.ActiveInstallation.Queue.CurrentCpuCount)
|
|
||||||
.Switch()
|
|
||||||
.ToGuiProperty(this, nameof(CurrentCpuCount));
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -12,6 +12,7 @@ using ReactiveUI.Fody.Helpers;
|
|||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack.Installer;
|
using Wabbajack.Installer;
|
||||||
using Wabbajack;
|
using Wabbajack;
|
||||||
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.Interventions;
|
using Wabbajack.Interventions;
|
||||||
using Wabbajack.Util;
|
using Wabbajack.Util;
|
||||||
|
|
||||||
@ -21,14 +22,14 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
public InstallerVM Parent { get; }
|
public InstallerVM Parent { get; }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<ErrorResponse> _CanInstall;
|
[Reactive]
|
||||||
public ErrorResponse CanInstall => _CanInstall.Value;
|
public ErrorResponse CanInstall { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public IInstaller ActiveInstallation { get; private set; }
|
public IInstaller ActiveInstallation { get; private set; }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<Mo2ModlistInstallationSettings> _CurrentSettings;
|
|
||||||
public Mo2ModlistInstallationSettings CurrentSettings => _CurrentSettings.Value;
|
[Reactive] public Mo2ModlistInstallationSettings CurrentSettings { get; set; }
|
||||||
|
|
||||||
public FilePickerVM Location { get; }
|
public FilePickerVM Location { get; }
|
||||||
|
|
||||||
@ -150,7 +151,7 @@ namespace Wabbajack
|
|||||||
|
|
||||||
private void SaveSettings(Mo2ModlistInstallationSettings settings)
|
private void SaveSettings(Mo2ModlistInstallationSettings settings)
|
||||||
{
|
{
|
||||||
Parent.MWVM.Settings.Installer.LastInstalledListLocation = Parent.ModListLocation.TargetPath;
|
//Parent.MWVM.Settings.Installer.LastInstalledListLocation = Parent.ModListLocation.TargetPath;
|
||||||
if (settings == null) return;
|
if (settings == null) return;
|
||||||
settings.InstallationLocation = Location.TargetPath;
|
settings.InstallationLocation = Location.TargetPath;
|
||||||
settings.DownloadLocation = DownloadLocation.TargetPath;
|
settings.DownloadLocation = DownloadLocation.TargetPath;
|
||||||
|
@ -3,6 +3,7 @@ using ReactiveUI;
|
|||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@ -16,6 +17,7 @@ using Wabbajack.Downloaders.GameFile;
|
|||||||
using Wabbajack;
|
using Wabbajack;
|
||||||
using Wabbajack.Interventions;
|
using Wabbajack.Interventions;
|
||||||
using Wabbajack.Messages;
|
using Wabbajack.Messages;
|
||||||
|
using Wabbajack.Models;
|
||||||
using Wabbajack.Networking.WabbajackClientApi;
|
using Wabbajack.Networking.WabbajackClientApi;
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.View_Models;
|
using Wabbajack.View_Models;
|
||||||
@ -38,7 +40,7 @@ namespace Wabbajack
|
|||||||
public ObservableCollectionExtended<IStatusMessage> Log { get; } = new ObservableCollectionExtended<IStatusMessage>();
|
public ObservableCollectionExtended<IStatusMessage> Log { get; } = new ObservableCollectionExtended<IStatusMessage>();
|
||||||
|
|
||||||
public readonly Lazy<CompilerVM> Compiler;
|
public readonly Lazy<CompilerVM> Compiler;
|
||||||
public readonly Lazy<InstallerVM> Installer;
|
public readonly InstallerVM Installer;
|
||||||
public readonly Lazy<SettingsVM> SettingsPane;
|
public readonly Lazy<SettingsVM> SettingsPane;
|
||||||
public readonly ModListGalleryVM Gallery;
|
public readonly ModListGalleryVM Gallery;
|
||||||
public readonly ModeSelectionVM ModeSelectionVM;
|
public readonly ModeSelectionVM ModeSelectionVM;
|
||||||
@ -46,6 +48,7 @@ namespace Wabbajack
|
|||||||
public readonly UserInterventionHandlers UserInterventionHandlers;
|
public readonly UserInterventionHandlers UserInterventionHandlers;
|
||||||
private readonly Client _wjClient;
|
private readonly Client _wjClient;
|
||||||
private readonly ILogger<MainWindowVM> _logger;
|
private readonly ILogger<MainWindowVM> _logger;
|
||||||
|
private readonly ResourceMonitor _resourceMonitor;
|
||||||
|
|
||||||
public ICommand CopyVersionCommand { get; }
|
public ICommand CopyVersionCommand { get; }
|
||||||
public ICommand ShowLoginManagerVM { get; }
|
public ICommand ShowLoginManagerVM { get; }
|
||||||
@ -53,17 +56,22 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public string VersionDisplay { get; }
|
public string VersionDisplay { get; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string ResourceStatus { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool UpdateAvailable { get; private set; }
|
public bool UpdateAvailable { get; private set; }
|
||||||
|
|
||||||
public MainWindowVM(ILogger<MainWindowVM> logger, MainSettings settings, Client wjClient,
|
public MainWindowVM(ILogger<MainWindowVM> logger, MainSettings settings, Client wjClient,
|
||||||
IServiceProvider serviceProvider, ModeSelectionVM modeSelectionVM, ModListGalleryVM modListGalleryVM)
|
IServiceProvider serviceProvider, ModeSelectionVM modeSelectionVM, ModListGalleryVM modListGalleryVM, ResourceMonitor resourceMonitor,
|
||||||
|
InstallerVM installer)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_wjClient = wjClient;
|
_wjClient = wjClient;
|
||||||
|
_resourceMonitor = resourceMonitor;
|
||||||
ConverterRegistration.Register();
|
ConverterRegistration.Register();
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Installer = new Lazy<InstallerVM>(() => new InstallerVM(serviceProvider.GetRequiredService<ILogger<InstallerVM>>(), this, serviceProvider));
|
Installer = installer;
|
||||||
Compiler = new Lazy<CompilerVM>(() => new CompilerVM(serviceProvider.GetRequiredService<ILogger<CompilerVM>>(), this));
|
Compiler = new Lazy<CompilerVM>(() => new CompilerVM(serviceProvider.GetRequiredService<ILogger<CompilerVM>>(), this));
|
||||||
SettingsPane = new Lazy<SettingsVM>(() => new SettingsVM(serviceProvider.GetRequiredService<ILogger<SettingsVM>>(), this, serviceProvider));
|
SettingsPane = new Lazy<SettingsVM>(() => new SettingsVM(serviceProvider.GetRequiredService<ILogger<SettingsVM>>(), this, serviceProvider));
|
||||||
Gallery = modListGalleryVM;
|
Gallery = modListGalleryVM;
|
||||||
@ -75,6 +83,12 @@ namespace Wabbajack
|
|||||||
.Subscribe(m => HandleNavigateTo(m.Screen))
|
.Subscribe(m => HandleNavigateTo(m.Screen))
|
||||||
.DisposeWith(CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
|
|
||||||
|
_resourceMonitor.Updates
|
||||||
|
.Select(r => string.Join(", ", r.Where(r => r.Throughput > 0)
|
||||||
|
.Select(s => $"{s.Name} - {s.Throughput.ToFileSizeString()}/sec")))
|
||||||
|
.BindToStrict(this, view => view.ResourceStatus);
|
||||||
|
|
||||||
|
|
||||||
// Set up logging
|
// Set up logging
|
||||||
/* TODO
|
/* TODO
|
||||||
Utils.LogMessages
|
Utils.LogMessages
|
||||||
@ -120,7 +134,7 @@ namespace Wabbajack
|
|||||||
|
|
||||||
if (IsStartingFromModlist(out var path))
|
if (IsStartingFromModlist(out var path))
|
||||||
{
|
{
|
||||||
Installer.Value.ModListLocation.TargetPath = path;
|
LoadModlistForInstalling.Send(path);
|
||||||
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Installer);
|
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Installer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -161,7 +175,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
NavigateToGlobal.ScreenType.ModeSelectionView => ModeSelectionVM,
|
NavigateToGlobal.ScreenType.ModeSelectionView => ModeSelectionVM,
|
||||||
NavigateToGlobal.ScreenType.ModListGallery => Gallery,
|
NavigateToGlobal.ScreenType.ModListGallery => Gallery,
|
||||||
NavigateToGlobal.ScreenType.Installer => Installer.Value,
|
NavigateToGlobal.ScreenType.Installer => Installer,
|
||||||
NavigateToGlobal.ScreenType.Settings => SettingsPane.Value,
|
NavigateToGlobal.ScreenType.Settings => SettingsPane.Value,
|
||||||
_ => ActivePane
|
_ => ActivePane
|
||||||
};
|
};
|
||||||
@ -183,15 +197,6 @@ namespace Wabbajack
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenInstaller(AbsolutePath path)
|
|
||||||
{
|
|
||||||
if (path == default) return;
|
|
||||||
var installer = Installer.Value;
|
|
||||||
Settings.Installer.LastInstalledListLocation = path;
|
|
||||||
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Installer);
|
|
||||||
installer.ModListLocation.TargetPath = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void NavigateTo(ViewModel vm)
|
public void NavigateTo(ViewModel vm)
|
||||||
{
|
{
|
||||||
|
@ -23,19 +23,7 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public ModeSelectionVM()
|
public ModeSelectionVM()
|
||||||
{
|
{
|
||||||
InstallCommand = ReactiveCommand.Create(
|
InstallCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Installer));
|
||||||
execute: () =>
|
|
||||||
{
|
|
||||||
/* TODO
|
|
||||||
var path = mainVM.Settings.Installer.LastInstalledListLocation;
|
|
||||||
if (path == default || !path.FileExists())
|
|
||||||
{
|
|
||||||
path = UIUtils.OpenFileDialog($"*{Ext.Wabbajack}|*{Ext.Wabbajack}");
|
|
||||||
}
|
|
||||||
_mainVM.OpenInstaller(path);
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
|
|
||||||
CompileCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Compiler));
|
CompileCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Compiler));
|
||||||
BrowseCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModListGallery));
|
BrowseCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModListGallery));
|
||||||
}
|
}
|
||||||
|
@ -1,161 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reactive;
|
|
||||||
using System.Reactive.Linq;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using DynamicData;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ReactiveUI;
|
|
||||||
using ReactiveUI.Fody.Helpers;
|
|
||||||
using Wabbajack.Common;
|
|
||||||
using Wabbajack.DTOs.DownloadStates;
|
|
||||||
using Wabbajack;
|
|
||||||
using Wabbajack.Extensions;
|
|
||||||
|
|
||||||
namespace Wabbajack.View_Models
|
|
||||||
{
|
|
||||||
public class SlideShow : ViewModel
|
|
||||||
{
|
|
||||||
private readonly Random _random = new Random();
|
|
||||||
|
|
||||||
public InstallerVM Installer { get; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public bool ShowNSFW { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public bool Enable { get; set; } = true;
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<BitmapImage> _image;
|
|
||||||
public BitmapImage Image => _image.Value;
|
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<ModVM> _targetMod;
|
|
||||||
public ModVM TargetMod => _targetMod.Value;
|
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> SlideShowNextItemCommand { get; } = ReactiveCommand.Create(() => { });
|
|
||||||
public ReactiveCommand<Unit, Unit> VisitURLCommand { get; }
|
|
||||||
|
|
||||||
public const int PreloadAmount = 4;
|
|
||||||
|
|
||||||
public SlideShow(InstallerVM appState, IServiceProvider provider)
|
|
||||||
{
|
|
||||||
Installer = appState;
|
|
||||||
|
|
||||||
// Wire target slideshow index
|
|
||||||
var intervalSeconds = 10;
|
|
||||||
// Compile all the sources that trigger a slideshow update, any of which trigger a counter update
|
|
||||||
var selectedIndex = Observable.Merge(
|
|
||||||
// If user requests one manually
|
|
||||||
SlideShowNextItemCommand.StartingExecution(),
|
|
||||||
// If the natural timer fires
|
|
||||||
Observable.Merge(
|
|
||||||
// Start with an initial timer
|
|
||||||
Observable.Return(Observable.Interval(TimeSpan.FromSeconds(intervalSeconds))),
|
|
||||||
// but reset timer if user requests one
|
|
||||||
SlideShowNextItemCommand.StartingExecution()
|
|
||||||
.Select(_ => Observable.Interval(TimeSpan.FromSeconds(intervalSeconds))))
|
|
||||||
// When a new timer comes in, swap to it
|
|
||||||
.Switch()
|
|
||||||
.Unit()
|
|
||||||
// Only subscribe to timer if enabled and installing
|
|
||||||
.FlowSwitch(
|
|
||||||
Observable.CombineLatest(
|
|
||||||
this.WhenAny(x => x.Enable),
|
|
||||||
this.WhenAny(x => x.Installer.Installing),
|
|
||||||
resultSelector: (enabled, installing) => enabled && installing)))
|
|
||||||
// When filter switch enabled, fire an initial signal
|
|
||||||
.StartWith(Unit.Default)
|
|
||||||
// Only subscribe to slideshow triggers if started
|
|
||||||
.FlowSwitch(this.WhenAny(x => x.Installer.StartedInstallation))
|
|
||||||
// Block spam
|
|
||||||
.Debounce(TimeSpan.FromMilliseconds(250), RxApp.MainThreadScheduler)
|
|
||||||
.Scan(
|
|
||||||
seed: 0,
|
|
||||||
accumulator: (i, _) => i + 1)
|
|
||||||
.Publish()
|
|
||||||
.RefCount();
|
|
||||||
|
|
||||||
// Dynamic list changeset of mod VMs to display
|
|
||||||
var modVMs = this.WhenAny(x => x.Installer.ModList)
|
|
||||||
// Whenever modlist changes, grab the list of its slides
|
|
||||||
.Select(modList =>
|
|
||||||
{
|
|
||||||
if (modList?.SourceModList?.Archives == null)
|
|
||||||
{
|
|
||||||
return Observable.Empty<IMetaState>()
|
|
||||||
.ToObservableChangeSet(x => x.LinkUrl);
|
|
||||||
}
|
|
||||||
return modList.SourceModList.Archives
|
|
||||||
.Select(m => m.State)
|
|
||||||
.OfType<IMetaState>()
|
|
||||||
.Where(x => x.LinkUrl != default && x.ImageURL != default)
|
|
||||||
.DistinctBy(x => x.LinkUrl)
|
|
||||||
// Shuffle it
|
|
||||||
.Shuffle(_random)
|
|
||||||
.AsObservableChangeSet(x => x.LinkUrl);
|
|
||||||
})
|
|
||||||
// Switch to the new list after every ModList change
|
|
||||||
.Switch()
|
|
||||||
.Transform(mod => new ModVM(provider.GetRequiredService<ILogger<ModVM>>(), mod))
|
|
||||||
.DisposeMany()
|
|
||||||
// Filter out any NSFW slides if we don't want them
|
|
||||||
.AutoRefreshOnObservable(slide => this.WhenAny(x => x.ShowNSFW))
|
|
||||||
.Filter(slide => !slide.State.IsNSFW || ShowNSFW)
|
|
||||||
.RefCount();
|
|
||||||
|
|
||||||
// Find target mod to display by combining dynamic list with currently desired index
|
|
||||||
_targetMod = Observable.CombineLatest(
|
|
||||||
modVMs.QueryWhenChanged(),
|
|
||||||
selectedIndex,
|
|
||||||
resultSelector: (query, selected) =>
|
|
||||||
{
|
|
||||||
var index = selected % (query.Count == 0 ? 1 : query.Count);
|
|
||||||
return query.Items.ElementAtOrDefault(index);
|
|
||||||
})
|
|
||||||
.StartWith(default(ModVM))
|
|
||||||
.ToGuiProperty(this, nameof(TargetMod));
|
|
||||||
|
|
||||||
// Mark interest and materialize image of target mod
|
|
||||||
_image = this.WhenAny(x => x.TargetMod)
|
|
||||||
// We want to Switch here, not SelectMany, as we want to hotswap to newest target without waiting on old ones
|
|
||||||
.Select(x => x?.ImageObservable ?? Observable.Return(default(BitmapImage)))
|
|
||||||
.Switch()
|
|
||||||
.ToGuiProperty(this, nameof(Image));
|
|
||||||
|
|
||||||
VisitURLCommand = ReactiveCommand.Create(
|
|
||||||
execute: () =>
|
|
||||||
{
|
|
||||||
UIUtils.OpenWebsite(TargetMod.State.LinkUrl);
|
|
||||||
return Unit.Default;
|
|
||||||
},
|
|
||||||
canExecute: this.WhenAny(x => x.TargetMod.State.LinkUrl)
|
|
||||||
.Select(x =>
|
|
||||||
{
|
|
||||||
//var regex = new Regex("^(http|https):\\/\\/");
|
|
||||||
var scheme = x?.Scheme;
|
|
||||||
return scheme != null &&
|
|
||||||
(scheme.Equals("https", StringComparison.OrdinalIgnoreCase) ||
|
|
||||||
scheme.Equals("http", StringComparison.OrdinalIgnoreCase));
|
|
||||||
})
|
|
||||||
.ObserveOnGuiThread());
|
|
||||||
|
|
||||||
// Preload upcoming images
|
|
||||||
var list = Observable.CombineLatest(
|
|
||||||
modVMs.QueryWhenChanged(),
|
|
||||||
selectedIndex,
|
|
||||||
resultSelector: (query, selected) =>
|
|
||||||
{
|
|
||||||
// Retrieve the mods that should be preloaded
|
|
||||||
var index = selected % (query.Count == 0 ? 1 : query.Count);
|
|
||||||
var amountToTake = Math.Min(query.Count - index, PreloadAmount);
|
|
||||||
return query.Items.Skip(index).Take(amountToTake).ToObservable();
|
|
||||||
})
|
|
||||||
.Select(i => i.ToObservableChangeSet())
|
|
||||||
.Switch()
|
|
||||||
.Transform(mod => mod.ImageObservable.Subscribe())
|
|
||||||
.DisposeMany()
|
|
||||||
.AsObservableList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -119,6 +119,7 @@ namespace Wabbajack
|
|||||||
.BindToStrict(this, x => x.BadgeImage.Source)
|
.BindToStrict(this, x => x.BadgeImage.Source)
|
||||||
.DisposeWith(dispose);
|
.DisposeWith(dispose);
|
||||||
this.WhenAny(x => x.Image)
|
this.WhenAny(x => x.Image)
|
||||||
|
.Select(f => f)
|
||||||
.BindToStrict(this, x => x.ModlistImage.Source)
|
.BindToStrict(this, x => x.ModlistImage.Source)
|
||||||
.DisposeWith(dispose);
|
.DisposeWith(dispose);
|
||||||
this.WhenAny(x => x.Image)
|
this.WhenAny(x => x.Image)
|
||||||
|
@ -301,6 +301,7 @@
|
|||||||
<local:CpuView Grid.Column="2"
|
<local:CpuView Grid.Column="2"
|
||||||
x:Name="CpuView"
|
x:Name="CpuView"
|
||||||
ViewModel="{Binding}" />
|
ViewModel="{Binding}" />
|
||||||
|
<!--
|
||||||
<local:AttentionBorder Grid.Column="2"
|
<local:AttentionBorder Grid.Column="2"
|
||||||
x:Name="UserInterventionsControl"
|
x:Name="UserInterventionsControl"
|
||||||
Content="{Binding ActiveGlobalUserIntervention}">
|
Content="{Binding ActiveGlobalUserIntervention}">
|
||||||
@ -313,6 +314,7 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</local:AttentionBorder.Resources>
|
</local:AttentionBorder.Resources>
|
||||||
</local:AttentionBorder>
|
</local:AttentionBorder>
|
||||||
|
-->
|
||||||
<local:InstallationCompleteView Grid.Column="2"
|
<local:InstallationCompleteView Grid.Column="2"
|
||||||
x:Name="InstallComplete"
|
x:Name="InstallComplete"
|
||||||
ViewModel="{Binding}" />
|
ViewModel="{Binding}" />
|
||||||
|
@ -14,130 +14,48 @@ namespace Wabbajack
|
|||||||
public InstallationView()
|
public InstallationView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.WhenActivated(dispose =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
this.MarkAsNeeded<InstallationView, InstallerVM, bool>(this.ViewModel, x => x.Installing);
|
MidInstallDisplayGrid.Visibility = Visibility.Collapsed;
|
||||||
this.MarkAsNeeded<InstallationView, InstallerVM, bool>(this.ViewModel, x => x.Slideshow.Enable);
|
LogView.Visibility = Visibility.Collapsed;
|
||||||
|
CpuView.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
// General progress indicators
|
//ViewModel.WhenAnyValue(vm => vm.ModList.Name)
|
||||||
this.WhenAny(x => x.ViewModel.PercentCompleted)
|
// .BindToStrict(this, view => view.Name)
|
||||||
.Select(x => (double)x)
|
|
||||||
.BindToStrict(this, x => x.HeatedBackground.PercentCompleted)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
|
|
||||||
// Top Progress Bar
|
ViewModel.WhenAnyValue(vm => vm.BackCommand)
|
||||||
this.WhenAny(x => x.ViewModel.ModListName)
|
.BindToStrict(this, view => view.BackButton.Command)
|
||||||
.BindToStrict(this, x => x.TopProgressBar.Title)
|
.DisposeWith(disposables);
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.ProgressTitle)
|
|
||||||
.BindToStrict(this, x => x.TopProgressBar.StatePrefixTitle)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.PercentCompleted)
|
|
||||||
.Select(x => (double)x)
|
|
||||||
.BindToStrict(this, x => x.TopProgressBar.ProgressPercent)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.BackCommand)
|
|
||||||
.BindToStrict(this, x => x.BackButton.Command)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
|
|
||||||
// Detail Image
|
ViewModel.WhenAnyValue(vm => vm.OpenReadmeCommand)
|
||||||
this.WhenAny(x => x.ViewModel.TitleText)
|
.BindToStrict(this, view => view.OpenReadmePreInstallButton.Command)
|
||||||
.BindToStrict(this, x => x.DetailImage.Title)
|
.DisposeWith(disposables);
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.AuthorText)
|
|
||||||
.BindToStrict(this, x => x.DetailImage.Author)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.Description)
|
|
||||||
.BindToStrict(this, x => x.DetailImage.Description)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.Image)
|
|
||||||
.BindToStrict(this, x => x.DetailImage.Image)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.LoadingModlist)
|
|
||||||
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
|
||||||
.BindToStrict(this, x => x.ModlistLoadingRing.Visibility)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
|
|
||||||
// Slideshow controls
|
ViewModel.WhenAnyValue(vm => vm.VisitModListWebsiteCommand)
|
||||||
this.WhenAny(x => x.ViewModel.Slideshow.SlideShowNextItemCommand)
|
.BindToStrict(this, view => view.OpenWebsite.Command)
|
||||||
.BindToStrict(this, x => x.SkipSlideButton.Command)
|
.DisposeWith(disposables);
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.BindStrict(this.ViewModel, x => x.Slideshow.Enable, x => x.PlayPauseButton.IsChecked,
|
|
||||||
vmToViewConverter: x => x,
|
|
||||||
viewToVmConverter: x => x ?? true)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.Slideshow.Enable)
|
|
||||||
.Select(enabled =>
|
|
||||||
{
|
|
||||||
return $"{(enabled ? "Pause" : "Play")} slideshow";
|
|
||||||
})
|
|
||||||
.BindToStrict(this, x => x.PlayPauseButton.ToolTip)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.Slideshow.VisitURLCommand)
|
|
||||||
.BindToStrict(this, x => x.OpenWebsite.Command)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.BindStrict(this.ViewModel, x => x.Slideshow.ShowNSFW, x => x.ShowNSFWButton.IsChecked,
|
|
||||||
vmToViewConverter: x => x,
|
|
||||||
viewToVmConverter: x => x ?? true)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.Slideshow.ShowNSFW)
|
|
||||||
.Select(show =>
|
|
||||||
{
|
|
||||||
return $"{(show ? "Hide" : "Show")} NSFW mods";
|
|
||||||
})
|
|
||||||
.BindToStrict(this, x => x.ShowNSFWButton.ToolTip)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.Slideshow.ShowNSFW)
|
|
||||||
.Select(show => show ? Visibility.Collapsed : Visibility.Visible)
|
|
||||||
.BindToStrict(this, x => x.NSFWSlashIcon.Visibility)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
|
|
||||||
// Bottom Input Customization
|
ViewModel.WhenAnyValue(vm => vm.LoadingLock.IsLoading)
|
||||||
this.WhenAny(x => x.ViewModel.StartedInstallation)
|
.Select(loading => loading ? Visibility.Visible : Visibility.Collapsed)
|
||||||
.Select(started => started ? Visibility.Hidden : Visibility.Visible)
|
.BindToStrict(this, view => view.ModlistLoadingRing.Visibility)
|
||||||
.BindToStrict(this, x => x.BottomButtonInputGrid.Visibility)
|
.DisposeWith(disposables);
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.OpenReadmeCommand)
|
// Slideshow
|
||||||
.BindToStrict(this, x => x.OpenReadmePreInstallButton.Command)
|
ViewModel.WhenAnyValue(vm => vm.SlideShowTitle)
|
||||||
.DisposeWith(dispose);
|
.Select(f => f)
|
||||||
this.WhenAny(x => x.ViewModel.VisitModListWebsiteCommand)
|
.BindToStrict(this, view => view.DetailImage.Title)
|
||||||
.BindToStrict(this, x => x.VisitWebsitePreInstallButton.Command)
|
.DisposeWith(disposables);
|
||||||
.DisposeWith(dispose);
|
ViewModel.WhenAnyValue(vm => vm.SlideShowAuthor)
|
||||||
this.WhenAny(x => x.ViewModel.ShowManifestCommand)
|
.BindToStrict(this, view => view.DetailImage.Author)
|
||||||
.BindToStrict(this, x => x.ShowManifestPreInstallButton.Command)
|
.DisposeWith(disposables);
|
||||||
.DisposeWith(dispose);
|
ViewModel.WhenAnyValue(vm => vm.SlideShowDescription)
|
||||||
this.WhenAny(x => x.ViewModel.StartedInstallation)
|
.BindToStrict(this, view => view.DetailImage.Description)
|
||||||
.Select(started => started ? Visibility.Collapsed : Visibility.Visible)
|
.DisposeWith(disposables);
|
||||||
.BindToStrict(this, x => x.InstallationConfigurationView.Visibility)
|
|
||||||
.DisposeWith(dispose);
|
ViewModel.WhenAnyValue(vm => vm.SlideShowImage)
|
||||||
|
.BindToStrict(this, view => view.DetailImage.Image)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
// Bottom mid-install display
|
|
||||||
this.WhenAny(x => x.ViewModel.StartedInstallation)
|
|
||||||
.Select(started => started ? Visibility.Visible : Visibility.Hidden)
|
|
||||||
.BindToStrict(this, x => x.MidInstallDisplayGrid.Visibility)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.PercentCompleted)
|
|
||||||
.Select(x => (double)x)
|
|
||||||
.BindToStrict(this, x => x.LogView.ProgressPercent)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.PercentCompleted)
|
|
||||||
.BindToStrict(this, x => x.CpuView.ProgressPercent)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.MWVM.Settings)
|
|
||||||
.BindToStrict(this, x => x.CpuView.SettingsHook)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.ActiveGlobalUserIntervention)
|
|
||||||
.Select(x => x == null ? Visibility.Visible : Visibility.Collapsed)
|
|
||||||
.BindToStrict(this, x => x.CpuView.Visibility)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.ActiveGlobalUserIntervention)
|
|
||||||
.Select(x => x != null ? Visibility.Visible : Visibility.Collapsed)
|
|
||||||
.BindToStrict(this, x => x.UserInterventionsControl.Visibility)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
this.WhenAny(x => x.ViewModel.Completed)
|
|
||||||
.Select(completed => completed != null ? Visibility.Visible : Visibility.Collapsed)
|
|
||||||
.BindToStrict(this, x => x.InstallComplete.Visibility)
|
|
||||||
.DisposeWith(dispose);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,12 @@
|
|||||||
UseLayoutRounding="True"
|
UseLayoutRounding="True"
|
||||||
WindowTitleBrush="{StaticResource MahApps.Brushes.Accent}"
|
WindowTitleBrush="{StaticResource MahApps.Brushes.Accent}"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<ContentPresenter Content="{Binding ActivePane}">
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<ContentPresenter Grid.Row="0" Content="{Binding ActivePane}">
|
||||||
<ContentPresenter.Resources>
|
<ContentPresenter.Resources>
|
||||||
<DataTemplate DataType="{x:Type local:CompilerVM}">
|
<DataTemplate DataType="{x:Type local:CompilerVM}">
|
||||||
<local:CompilerView ViewModel="{Binding}" />
|
<local:CompilerView ViewModel="{Binding}" />
|
||||||
@ -46,12 +51,15 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ContentPresenter.Resources>
|
</ContentPresenter.Resources>
|
||||||
</ContentPresenter>
|
</ContentPresenter>
|
||||||
|
<TextBlock Grid.Row="1" Margin="5, 0" Name="ResourceUsage" HorizontalAlignment="Right"></TextBlock>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<mahapps:MetroWindow.RightWindowCommands>
|
<mahapps:MetroWindow.RightWindowCommands>
|
||||||
<mahapps:WindowCommands>
|
<mahapps:WindowCommands>
|
||||||
<mahapps:WindowCommands.Resources>
|
<mahapps:WindowCommands.Resources>
|
||||||
<Style BasedOn="{StaticResource IconBareButtonStyle}" TargetType="Button" />
|
<Style BasedOn="{StaticResource IconBareButtonStyle}" TargetType="Button" />
|
||||||
</mahapps:WindowCommands.Resources>
|
</mahapps:WindowCommands.Resources>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Command="{Binding CopyVersionCommand}"
|
Command="{Binding CopyVersionCommand}"
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Reactive.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
using MahApps.Metro.Controls;
|
using MahApps.Metro.Controls;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ReactiveUI;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack;
|
using Wabbajack;
|
||||||
using Wabbajack.LibCefHelpers;
|
using Wabbajack.LibCefHelpers;
|
||||||
@ -92,6 +95,15 @@ namespace Wabbajack
|
|||||||
_logger.LogError(ex, "During Main Window Startup");
|
_logger.LogError(ex, "During Main Window Startup");
|
||||||
Environment.Exit(-1);
|
Environment.Exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vm.WhenAnyValue(vm => vm.ResourceStatus)
|
||||||
|
.BindToStrict(this, view => view.ResourceUsage.Text);
|
||||||
|
|
||||||
|
vm.WhenAnyValue(vm => vm.ResourceStatus)
|
||||||
|
.Select(x => string.IsNullOrWhiteSpace(x) ? Visibility.Collapsed : Visibility.Visible)
|
||||||
|
.BindToStrict(this, view => view.ResourceUsage.Visibility);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(MainWindowVM vm, MainSettings settings)
|
public void Init(MainWindowVM vm, MainSettings settings)
|
||||||
|
@ -111,8 +111,4 @@
|
|||||||
<SplashScreen Include="Resources\Wabba_Mouth_Small.png" />
|
<SplashScreen Include="Resources\Wabba_Mouth_Small.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Models" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -165,6 +165,16 @@ public abstract class AInstaller<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<Stream> ModListImageStream(AbsolutePath path)
|
||||||
|
{
|
||||||
|
await using var fs = path.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
using var ar = new ZipArchive(fs, ZipArchiveMode.Read);
|
||||||
|
var entry = ar.GetEntry("modlist-image.png");
|
||||||
|
if (entry == null)
|
||||||
|
throw new InvalidDataException("No modlist image found");
|
||||||
|
return new MemoryStream(await entry.Open().ReadAllAsync());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// We don't want to make the installer index all the archives, that's just a waste of time, so instead
|
/// We don't want to make the installer index all the archives, that's just a waste of time, so instead
|
||||||
/// we'll pass just enough information to VFS to let it know about the files we have.
|
/// we'll pass just enough information to VFS to let it know about the files we have.
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Modlist/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wabbajack/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wabbajack/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
Loading…
Reference in New Issue
Block a user