2019-12-03 05:35:51 +00:00
|
|
|
|
using Syroot.Windows.IO;
|
2019-10-11 22:18:51 +00:00
|
|
|
|
using System;
|
2019-10-12 21:10:58 +00:00
|
|
|
|
using ReactiveUI;
|
2019-08-30 23:57:56 +00:00
|
|
|
|
using System.Diagnostics;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
using System.IO;
|
2019-10-11 11:15:54 +00:00
|
|
|
|
using System.IO.Compression;
|
2019-09-26 03:18:36 +00:00
|
|
|
|
using System.Linq;
|
2019-10-12 03:07:57 +00:00
|
|
|
|
using System.Reactive.Disposables;
|
|
|
|
|
using System.Reactive.Linq;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
using System.Reflection;
|
2019-11-17 23:48:32 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
using System.Windows;
|
2019-09-26 03:18:36 +00:00
|
|
|
|
using System.Windows.Media.Imaging;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
using Wabbajack.Common;
|
2019-10-16 03:10:34 +00:00
|
|
|
|
using Wabbajack.Lib;
|
2019-11-02 23:23:11 +00:00
|
|
|
|
using ReactiveUI.Fody.Helpers;
|
2019-11-09 01:53:32 +00:00
|
|
|
|
using System.Windows.Media;
|
2019-11-20 00:15:46 +00:00
|
|
|
|
using DynamicData;
|
|
|
|
|
using DynamicData.Binding;
|
2019-12-02 05:36:47 +00:00
|
|
|
|
using System.Reactive;
|
2019-12-04 04:12:08 +00:00
|
|
|
|
using Wabbajack.Common.StatusFeed;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
2019-10-30 19:45:42 +00:00
|
|
|
|
public class InstallerVM : ViewModel
|
2019-07-22 22:17:46 +00:00
|
|
|
|
{
|
2019-10-13 19:12:33 +00:00
|
|
|
|
public SlideShow Slideshow { get; }
|
2019-10-30 19:45:42 +00:00
|
|
|
|
|
2019-10-22 03:03:01 +00:00
|
|
|
|
public MainWindowVM MWVM { get; }
|
2019-10-11 10:14:01 +00:00
|
|
|
|
|
2019-11-28 08:00:43 +00:00
|
|
|
|
public BitmapImage WabbajackLogo { get; } = UIUtils.BitmapImageFromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Wabbajack;component/Resources/Wabba_Mouth_No_Text.png")).Stream);
|
2019-12-03 05:35:51 +00:00
|
|
|
|
public BitmapImage WabbajackErrLogo { get; } = UIUtils.BitmapImageFromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Wabbajack;component/Resources/Wabba_Ded.png")).Stream);
|
2019-10-30 19:45:42 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<ModListVM> _modList;
|
|
|
|
|
public ModListVM ModList => _modList.Value;
|
2019-10-12 03:07:57 +00:00
|
|
|
|
|
2019-12-03 05:40:59 +00:00
|
|
|
|
public FilePickerVM ModListLocation { get; }
|
2019-10-12 03:31:33 +00:00
|
|
|
|
|
2019-12-02 05:36:47 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<ISubInstallerVM> _installer;
|
|
|
|
|
public ISubInstallerVM Installer => _installer.Value;
|
2019-10-12 18:42:47 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<string> _htmlReport;
|
|
|
|
|
public string HTMLReport => _htmlReport.Value;
|
2019-10-12 19:11:52 +00:00
|
|
|
|
|
2019-11-24 03:17:22 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<bool> _installing;
|
|
|
|
|
public bool Installing => _installing.Value;
|
2019-10-12 21:04:14 +00:00
|
|
|
|
|
2019-11-01 00:21:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tracks whether to show the installing pane
|
|
|
|
|
/// </summary>
|
2019-11-02 23:23:11 +00:00
|
|
|
|
[Reactive]
|
|
|
|
|
public bool InstallingMode { get; set; }
|
2019-11-01 00:21:24 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<ImageSource> _image;
|
|
|
|
|
public ImageSource Image => _image.Value;
|
2019-10-30 19:45:42 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<string> _titleText;
|
|
|
|
|
public string TitleText => _titleText.Value;
|
2019-11-01 01:02:39 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<string> _authorText;
|
|
|
|
|
public string AuthorText => _authorText.Value;
|
2019-11-01 01:02:39 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<string> _description;
|
|
|
|
|
public string Description => _description.Value;
|
2019-11-01 01:02:39 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<string> _progressTitle;
|
|
|
|
|
public string ProgressTitle => _progressTitle.Value;
|
2019-11-07 05:33:08 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<string> _modListName;
|
|
|
|
|
public string ModListName => _modListName.Value;
|
2019-11-07 05:37:40 +00:00
|
|
|
|
|
2019-11-24 03:17:22 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<float> _percentCompleted;
|
|
|
|
|
public float PercentCompleted => _percentCompleted.Value;
|
|
|
|
|
|
|
|
|
|
public ObservableCollectionExtended<CPUStatus> StatusList { get; } = new ObservableCollectionExtended<CPUStatus>();
|
2019-12-04 04:12:08 +00:00
|
|
|
|
public ObservableCollectionExtended<IStatusMessage> Log => MWVM.Log;
|
2019-11-24 03:17:22 +00:00
|
|
|
|
|
2019-12-02 05:36:47 +00:00
|
|
|
|
private readonly ObservableAsPropertyHelper<ModManager?> _TargetManager;
|
|
|
|
|
public ModManager? TargetManager => _TargetManager.Value;
|
|
|
|
|
|
2019-10-11 22:30:12 +00:00
|
|
|
|
// Command properties
|
2019-10-13 08:03:41 +00:00
|
|
|
|
public IReactiveCommand ShowReportCommand { get; }
|
2019-10-12 03:07:57 +00:00
|
|
|
|
public IReactiveCommand OpenReadmeCommand { get; }
|
2019-11-01 02:57:49 +00:00
|
|
|
|
public IReactiveCommand VisitWebsiteCommand { get; }
|
2019-11-24 23:42:28 +00:00
|
|
|
|
public IReactiveCommand BackCommand { get; }
|
2019-10-11 22:30:12 +00:00
|
|
|
|
|
2019-11-24 08:12:28 +00:00
|
|
|
|
public InstallerVM(MainWindowVM mainWindowVM)
|
2019-07-30 21:45:04 +00:00
|
|
|
|
{
|
2019-10-12 08:02:58 +00:00
|
|
|
|
if (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location.ToLower()) == KnownFolders.Downloads.Path.ToLower())
|
2019-09-14 04:35:42 +00:00
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(
|
2019-10-12 09:12:53 +00:00
|
|
|
|
"Wabbajack is running inside your Downloads folder. This folder is often highly monitored by antivirus software and these can often " +
|
2019-10-12 08:02:58 +00:00
|
|
|
|
"conflict with the operations Wabbajack needs to perform. Please move this executable outside of your Downloads folder and then restart the app.",
|
|
|
|
|
"Cannot run inside Downloads",
|
2019-09-14 04:35:42 +00:00
|
|
|
|
MessageBoxButton.OK,
|
|
|
|
|
MessageBoxImage.Error);
|
|
|
|
|
Environment.Exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-21 15:04:33 +00:00
|
|
|
|
MWVM = mainWindowVM;
|
2019-11-06 03:22:38 +00:00
|
|
|
|
|
2019-12-03 05:40:59 +00:00
|
|
|
|
ModListLocation = new FilePickerVM()
|
2019-11-24 08:44:41 +00:00
|
|
|
|
{
|
|
|
|
|
ExistCheckOption = FilePickerVM.ExistCheckOptions.On,
|
|
|
|
|
PathType = FilePickerVM.PathTypeOptions.File,
|
|
|
|
|
PromptTitle = "Select a modlist to install"
|
|
|
|
|
};
|
2019-11-09 20:20:32 +00:00
|
|
|
|
|
2019-12-02 05:36:47 +00:00
|
|
|
|
// Swap to proper sub VM based on selected type
|
|
|
|
|
_installer = this.WhenAny(x => x.TargetManager)
|
|
|
|
|
// 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.MO2:
|
|
|
|
|
return new MO2InstallerVM(this);
|
|
|
|
|
case ModManager.Vortex:
|
2019-12-03 02:38:33 +00:00
|
|
|
|
return new VortexInstallerVM(this);
|
2019-12-02 05:36:47 +00:00
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// Unload old VM
|
|
|
|
|
.Pairwise()
|
|
|
|
|
.Do(pair =>
|
|
|
|
|
{
|
|
|
|
|
pair.Previous?.Unload();
|
|
|
|
|
})
|
|
|
|
|
.Select(p => p.Current)
|
|
|
|
|
.ToProperty(this, nameof(Installer));
|
|
|
|
|
|
2019-11-06 03:22:38 +00:00
|
|
|
|
// Load settings
|
2019-12-03 02:38:33 +00:00
|
|
|
|
MWVM.Settings.SaveSignal
|
|
|
|
|
.Subscribe(_ =>
|
2019-11-06 03:22:38 +00:00
|
|
|
|
{
|
2019-12-03 05:40:59 +00:00
|
|
|
|
MWVM.Settings.Installer.LastInstalledListLocation = ModListLocation.TargetPath;
|
2019-11-06 03:22:38 +00:00
|
|
|
|
})
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.DisposeWith(CompositeDisposable);
|
2019-09-14 04:35:42 +00:00
|
|
|
|
|
2019-12-03 05:40:59 +00:00
|
|
|
|
_modList = this.WhenAny(x => x.ModListLocation.TargetPath)
|
2019-10-30 19:45:42 +00:00
|
|
|
|
.ObserveOn(RxApp.TaskpoolScheduler)
|
2019-11-06 03:22:38 +00:00
|
|
|
|
.Select(modListPath =>
|
2019-10-28 04:59:58 +00:00
|
|
|
|
{
|
2019-11-06 03:22:38 +00:00
|
|
|
|
if (modListPath == null) return default(ModListVM);
|
2019-11-25 00:03:33 +00:00
|
|
|
|
if (!File.Exists(modListPath)) return default(ModListVM);
|
2019-12-03 05:35:51 +00:00
|
|
|
|
return new ModListVM(modListPath);
|
2019-10-28 04:59:58 +00:00
|
|
|
|
})
|
|
|
|
|
.ObserveOnGuiThread()
|
2019-11-03 06:01:19 +00:00
|
|
|
|
.StartWith(default(ModListVM))
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.ToProperty(this, nameof(ModList));
|
2019-11-21 15:45:00 +00:00
|
|
|
|
_htmlReport = this.WhenAny(x => x.ModList)
|
2019-10-28 04:59:58 +00:00
|
|
|
|
.Select(modList => modList?.ReportHTML)
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.ToProperty(this, nameof(HTMLReport));
|
2019-12-02 05:36:47 +00:00
|
|
|
|
_installing = this.WhenAny(x => x.Installer.ActiveInstallation)
|
2019-11-24 03:17:22 +00:00
|
|
|
|
.Select(compilation => compilation != null)
|
|
|
|
|
.ObserveOnGuiThread()
|
|
|
|
|
.ToProperty(this, nameof(Installing));
|
2019-12-02 05:36:47 +00:00
|
|
|
|
_TargetManager = this.WhenAny(x => x.ModList)
|
|
|
|
|
.Select(modList => modList?.ModManager)
|
|
|
|
|
.ToProperty(this, nameof(TargetManager));
|
2019-11-24 03:17:22 +00:00
|
|
|
|
|
2019-12-03 05:35:51 +00:00
|
|
|
|
// Add additional error check on modlist
|
2019-12-03 05:40:59 +00:00
|
|
|
|
ModListLocation.AdditionalError = this.WhenAny(x => x.ModList)
|
2019-12-03 05:35:51 +00:00
|
|
|
|
.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);
|
|
|
|
|
return ErrorResponse.Success;
|
|
|
|
|
});
|
|
|
|
|
|
2019-11-24 23:42:28 +00:00
|
|
|
|
BackCommand = ReactiveCommand.Create(
|
|
|
|
|
execute: () => mainWindowVM.ActivePane = mainWindowVM.ModeSelectionVM,
|
|
|
|
|
canExecute: this.WhenAny(x => x.Installing)
|
|
|
|
|
.Select(x => !x));
|
|
|
|
|
|
2019-12-02 05:36:47 +00:00
|
|
|
|
_percentCompleted = this.WhenAny(x => x.Installer.ActiveInstallation)
|
2019-11-24 03:17:22 +00:00
|
|
|
|
.StartWith(default(AInstaller))
|
|
|
|
|
.Pairwise()
|
|
|
|
|
.Select(c =>
|
|
|
|
|
{
|
|
|
|
|
if (c.Current == null)
|
|
|
|
|
{
|
|
|
|
|
return Observable.Return<float>(c.Previous == null ? 0f : 1f);
|
|
|
|
|
}
|
|
|
|
|
return c.Current.PercentCompleted;
|
|
|
|
|
})
|
|
|
|
|
.Switch()
|
|
|
|
|
.Debounce(TimeSpan.FromMilliseconds(25))
|
|
|
|
|
.ToProperty(this, nameof(PercentCompleted));
|
2019-10-28 04:59:58 +00:00
|
|
|
|
|
2019-11-21 15:04:33 +00:00
|
|
|
|
Slideshow = new SlideShow(this);
|
2019-10-30 19:45:42 +00:00
|
|
|
|
|
2019-11-01 01:02:39 +00:00
|
|
|
|
// Set display items to modlist if configuring or complete,
|
|
|
|
|
// or to the current slideshow data if installing
|
2019-11-21 15:45:00 +00:00
|
|
|
|
_image = Observable.CombineLatest(
|
2019-12-03 05:35:51 +00:00
|
|
|
|
this.WhenAny(x => x.ModList.Error),
|
2019-11-03 06:01:19 +00:00
|
|
|
|
this.WhenAny(x => x.ModList)
|
|
|
|
|
.SelectMany(x => x?.ImageObservable ?? Observable.Empty<BitmapImage>())
|
|
|
|
|
.NotNull()
|
|
|
|
|
.StartWith(WabbajackLogo),
|
2019-11-01 01:02:39 +00:00
|
|
|
|
this.WhenAny(x => x.Slideshow.Image)
|
|
|
|
|
.StartWith(default(BitmapImage)),
|
|
|
|
|
this.WhenAny(x => x.Installing),
|
2019-12-03 05:35:51 +00:00
|
|
|
|
resultSelector: (err, modList, slideshow, installing) =>
|
|
|
|
|
{
|
|
|
|
|
if (err != null)
|
|
|
|
|
{
|
|
|
|
|
return WabbajackErrLogo;
|
|
|
|
|
}
|
|
|
|
|
return installing ? slideshow : modList;
|
|
|
|
|
})
|
2019-11-09 01:53:32 +00:00
|
|
|
|
.Select<BitmapImage, ImageSource>(x => x)
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.ToProperty(this, nameof(Image));
|
2019-11-21 15:45:00 +00:00
|
|
|
|
_titleText = Observable.CombineLatest(
|
2019-11-01 04:59:10 +00:00
|
|
|
|
this.WhenAny(x => x.ModList.Name),
|
2019-11-03 06:01:19 +00:00
|
|
|
|
this.WhenAny(x => x.Slideshow.TargetMod.ModName)
|
|
|
|
|
.StartWith(default(string)),
|
2019-11-01 01:02:39 +00:00
|
|
|
|
this.WhenAny(x => x.Installing),
|
|
|
|
|
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.ToProperty(this, nameof(TitleText));
|
2019-11-21 15:45:00 +00:00
|
|
|
|
_authorText = Observable.CombineLatest(
|
2019-11-01 04:59:10 +00:00
|
|
|
|
this.WhenAny(x => x.ModList.Author),
|
2019-11-03 06:01:19 +00:00
|
|
|
|
this.WhenAny(x => x.Slideshow.TargetMod.ModAuthor)
|
|
|
|
|
.StartWith(default(string)),
|
2019-11-01 01:02:39 +00:00
|
|
|
|
this.WhenAny(x => x.Installing),
|
|
|
|
|
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.ToProperty(this, nameof(AuthorText));
|
2019-11-21 15:45:00 +00:00
|
|
|
|
_description = Observable.CombineLatest(
|
2019-11-01 04:59:10 +00:00
|
|
|
|
this.WhenAny(x => x.ModList.Description),
|
2019-11-03 06:01:19 +00:00
|
|
|
|
this.WhenAny(x => x.Slideshow.TargetMod.ModDescription)
|
|
|
|
|
.StartWith(default(string)),
|
2019-11-01 01:02:39 +00:00
|
|
|
|
this.WhenAny(x => x.Installing),
|
|
|
|
|
resultSelector: (modList, mod, installing) => installing ? mod : modList)
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.ToProperty(this, nameof(Description));
|
2019-12-03 05:35:51 +00:00
|
|
|
|
_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;
|
|
|
|
|
})
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.ToProperty(this, nameof(ModListName));
|
2019-10-30 19:45:42 +00:00
|
|
|
|
|
2019-10-13 08:03:41 +00:00
|
|
|
|
// Define commands
|
2019-11-21 15:04:33 +00:00
|
|
|
|
ShowReportCommand = ReactiveCommand.Create(ShowReport);
|
|
|
|
|
OpenReadmeCommand = ReactiveCommand.Create(
|
|
|
|
|
execute: OpenReadmeWindow,
|
2019-10-13 20:14:11 +00:00
|
|
|
|
canExecute: this.WhenAny(x => x.ModList)
|
|
|
|
|
.Select(modList => !string.IsNullOrEmpty(modList?.Readme))
|
2019-10-12 18:42:47 +00:00
|
|
|
|
.ObserveOnGuiThread());
|
2019-11-21 15:04:33 +00:00
|
|
|
|
VisitWebsiteCommand = ReactiveCommand.Create(
|
|
|
|
|
execute: () => Process.Start(ModList.Website),
|
2019-11-01 02:57:49 +00:00
|
|
|
|
canExecute: this.WhenAny(x => x.ModList.Website)
|
|
|
|
|
.Select(x => x?.StartsWith("https://") ?? false)
|
|
|
|
|
.ObserveOnGuiThread());
|
2019-10-12 03:07:57 +00:00
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
_progressTitle = Observable.CombineLatest(
|
2019-11-07 05:33:08 +00:00
|
|
|
|
this.WhenAny(x => x.Installing),
|
|
|
|
|
this.WhenAny(x => x.InstallingMode),
|
|
|
|
|
resultSelector: (installing, mode) =>
|
|
|
|
|
{
|
|
|
|
|
if (!installing) return "Configuring";
|
|
|
|
|
return mode ? "Installing" : "Installed";
|
|
|
|
|
})
|
2019-11-21 15:04:33 +00:00
|
|
|
|
.ToProperty(this, nameof(ProgressTitle));
|
2019-11-24 03:17:22 +00:00
|
|
|
|
|
|
|
|
|
// Compile progress updates and populate ObservableCollection
|
2019-12-02 05:36:47 +00:00
|
|
|
|
this.WhenAny(x => x.Installer.ActiveInstallation)
|
2019-11-24 03:17:22 +00:00
|
|
|
|
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>())
|
|
|
|
|
.ObserveOn(RxApp.TaskpoolScheduler)
|
|
|
|
|
.ToObservableChangeSet(x => x.ID)
|
|
|
|
|
.Batch(TimeSpan.FromMilliseconds(250), RxApp.TaskpoolScheduler)
|
|
|
|
|
.EnsureUniqueChanges()
|
2019-11-28 17:30:19 +00:00
|
|
|
|
.Filter(i => i.IsWorking)
|
2019-11-24 03:17:22 +00:00
|
|
|
|
.ObserveOn(RxApp.MainThreadScheduler)
|
|
|
|
|
.Sort(SortExpressionComparer<CPUStatus>.Ascending(s => s.ID), SortOptimisations.ComparesImmutableValuesOnly)
|
|
|
|
|
.Bind(StatusList)
|
|
|
|
|
.Subscribe()
|
|
|
|
|
.DisposeWith(CompositeDisposable);
|
2019-12-02 05:36:47 +00:00
|
|
|
|
|
|
|
|
|
// When sub installer begins an install, mark state variable
|
|
|
|
|
this.WhenAny(x => x.Installer.BeginCommand)
|
|
|
|
|
.Select(x => x?.StartingExecution() ?? Observable.Empty<Unit>())
|
|
|
|
|
.Switch()
|
|
|
|
|
.Subscribe(_ =>
|
|
|
|
|
{
|
|
|
|
|
InstallingMode = true;
|
|
|
|
|
})
|
|
|
|
|
.DisposeWith(CompositeDisposable);
|
2019-10-09 09:22:03 +00:00
|
|
|
|
}
|
2019-09-26 03:18:36 +00:00
|
|
|
|
|
2019-10-09 09:22:03 +00:00
|
|
|
|
private void ShowReport()
|
|
|
|
|
{
|
|
|
|
|
var file = Path.GetTempFileName() + ".html";
|
|
|
|
|
File.WriteAllText(file, HTMLReport);
|
|
|
|
|
Process.Start(file);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 12:57:42 +00:00
|
|
|
|
private void OpenReadmeWindow()
|
|
|
|
|
{
|
2019-11-21 15:04:33 +00:00
|
|
|
|
if (string.IsNullOrEmpty(ModList.Readme)) return;
|
2019-12-03 05:40:59 +00:00
|
|
|
|
using (var fs = new FileStream(ModListLocation.TargetPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
2019-10-11 13:06:56 +00:00
|
|
|
|
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
|
|
|
|
using (var ms = new MemoryStream())
|
2019-10-11 12:57:42 +00:00
|
|
|
|
{
|
2019-11-21 15:04:33 +00:00
|
|
|
|
var entry = ar.GetEntry(ModList.Readme);
|
2019-10-30 19:45:42 +00:00
|
|
|
|
if (entry == null)
|
|
|
|
|
{
|
2019-11-21 15:04:33 +00:00
|
|
|
|
Utils.Log($"Tried to open a non-existant readme: {ModList.Readme}");
|
2019-10-30 19:45:42 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-10-11 13:06:56 +00:00
|
|
|
|
using (var e = entry.Open())
|
2019-10-13 20:21:09 +00:00
|
|
|
|
{
|
2019-10-11 13:06:56 +00:00
|
|
|
|
e.CopyTo(ms);
|
2019-10-13 20:21:09 +00:00
|
|
|
|
}
|
2019-10-11 13:06:56 +00:00
|
|
|
|
ms.Seek(0, SeekOrigin.Begin);
|
2019-10-13 20:21:09 +00:00
|
|
|
|
using (var reader = new StreamReader(ms))
|
2019-10-11 12:57:42 +00:00
|
|
|
|
{
|
2019-11-21 15:04:33 +00:00
|
|
|
|
var viewer = new TextViewer(reader.ReadToEnd(), ModList.Name);
|
2019-10-13 20:21:09 +00:00
|
|
|
|
viewer.Show();
|
2019-10-11 12:57:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-09 22:59:58 +00:00
|
|
|
|
}
|
2019-11-20 00:15:46 +00:00
|
|
|
|
}
|