2019-08-25 23:52:03 +00:00
|
|
|
|
using System;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
2019-07-30 21:45:04 +00:00
|
|
|
|
using System.ComponentModel;
|
2019-08-30 23:57:56 +00:00
|
|
|
|
using System.Diagnostics;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
using System.IO;
|
2019-09-26 03:18:36 +00:00
|
|
|
|
using System.Linq;
|
2019-10-04 20:50:34 +00:00
|
|
|
|
using System.Net.Http;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Threading;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Input;
|
2019-09-26 03:18:36 +00:00
|
|
|
|
using System.Windows.Media.Imaging;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
using Wabbajack.Common;
|
2019-09-26 20:18:41 +00:00
|
|
|
|
using Wabbajack.NexusApi;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
2019-09-26 14:35:34 +00:00
|
|
|
|
internal class AppState : INotifyPropertyChanged, IDataErrorInfo
|
2019-07-22 22:17:46 +00:00
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
private ICommand _begin;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
private ICommand _changeDownloadPath;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
private ICommand _changePath;
|
|
|
|
|
private string _downloadLocation;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
private string _htmlReport;
|
2019-07-30 21:45:04 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
private bool _ignoreMissingFiles;
|
|
|
|
|
private string _location;
|
|
|
|
|
|
|
|
|
|
private string _mo2Folder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string _mode;
|
|
|
|
|
private ModList _modList;
|
|
|
|
|
private string _modListName;
|
|
|
|
|
|
|
|
|
|
private int _queueProgress;
|
|
|
|
|
|
|
|
|
|
private ICommand _showReportCommand;
|
2019-09-26 03:18:36 +00:00
|
|
|
|
private ICommand _visitNexusSiteCommand;
|
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
private readonly DateTime _startTime;
|
|
|
|
|
|
|
|
|
|
public volatile bool Dirty;
|
|
|
|
|
|
|
|
|
|
private readonly Dispatcher dispatcher;
|
|
|
|
|
|
|
|
|
|
public AppState(Dispatcher d, string mode)
|
2019-07-30 21:45:04 +00:00
|
|
|
|
{
|
2019-09-26 03:18:36 +00:00
|
|
|
|
|
|
|
|
|
var image = new BitmapImage();
|
|
|
|
|
image.BeginInit();
|
|
|
|
|
image.StreamSource = Assembly.GetExecutingAssembly().GetManifestResourceStream("Wabbajack.banner.png");
|
|
|
|
|
image.EndInit();
|
|
|
|
|
_wabbajackLogo = image;
|
|
|
|
|
_splashScreenImage = image;
|
|
|
|
|
|
|
|
|
|
SetupSlideshow();
|
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
if (Assembly.GetEntryAssembly().Location.ToLower().Contains("\\downloads\\"))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(
|
2019-09-24 15:26:44 +00:00
|
|
|
|
"This app seems to be running inside a folder called `Downloads`, such folders are often highly monitored by antivirus software and they can often " +
|
2019-09-14 04:35:42 +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`",
|
|
|
|
|
MessageBoxButton.OK,
|
|
|
|
|
MessageBoxImage.Error);
|
|
|
|
|
Environment.Exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_startTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
Mode = mode;
|
|
|
|
|
Dirty = false;
|
|
|
|
|
dispatcher = d;
|
|
|
|
|
Log = new ObservableCollection<string>();
|
|
|
|
|
Status = new ObservableCollection<CPUStatus>();
|
|
|
|
|
InternalStatus = new List<CPUStatus>();
|
|
|
|
|
|
|
|
|
|
var th = new Thread(() => UpdateLoop());
|
|
|
|
|
th.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
th.IsBackground = true;
|
|
|
|
|
th.Start();
|
2019-07-30 21:45:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-26 03:18:36 +00:00
|
|
|
|
private void SetupSlideshow()
|
|
|
|
|
{
|
2019-09-26 20:18:41 +00:00
|
|
|
|
var files = NexusApiClient.CachedSlideShow;
|
2019-09-26 03:18:36 +00:00
|
|
|
|
if (files.Any())
|
|
|
|
|
{
|
|
|
|
|
SlideShowElements = files.ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Random _random = new Random();
|
2019-09-26 20:18:41 +00:00
|
|
|
|
public List<SlideShowItem> SlideShowElements = new List<SlideShowItem>();
|
2019-09-26 03:18:36 +00:00
|
|
|
|
private DateTime _lastSlideShowUpdate = new DateTime();
|
|
|
|
|
|
2019-07-22 22:17:46 +00:00
|
|
|
|
public ObservableCollection<string> Log { get; }
|
|
|
|
|
public ObservableCollection<CPUStatus> Status { get; }
|
|
|
|
|
|
2019-07-30 21:45:04 +00:00
|
|
|
|
public string Mode
|
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
get => _mode;
|
2019-07-30 21:45:04 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_mode = value;
|
|
|
|
|
OnPropertyChanged("Mode");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string ModListName
|
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
get => _modListName;
|
2019-07-30 21:45:04 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_modListName = value;
|
|
|
|
|
OnPropertyChanged("ModListName");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 03:59:19 +00:00
|
|
|
|
public string Location
|
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
get => _location;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_location = value;
|
|
|
|
|
OnPropertyChanged("Location");
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-26 14:35:34 +00:00
|
|
|
|
|
2019-07-31 03:59:19 +00:00
|
|
|
|
|
2019-09-03 22:12:39 +00:00
|
|
|
|
public string DownloadLocation
|
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
get => _downloadLocation;
|
2019-09-03 22:12:39 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_downloadLocation = value;
|
|
|
|
|
OnPropertyChanged("DownloadLocation");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-30 23:57:56 +00:00
|
|
|
|
public Visibility ShowReportButton => _htmlReport == null ? Visibility.Collapsed : Visibility.Visible;
|
|
|
|
|
|
|
|
|
|
public string HTMLReport
|
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
get => _htmlReport;
|
2019-08-30 23:57:56 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_htmlReport = value;
|
|
|
|
|
OnPropertyChanged("HTMLReport");
|
|
|
|
|
OnPropertyChanged("ShowReportButton");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-02 23:04:04 +00:00
|
|
|
|
public int QueueProgress
|
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
get => _queueProgress;
|
2019-08-02 23:04:04 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _queueProgress)
|
|
|
|
|
{
|
|
|
|
|
_queueProgress = value;
|
|
|
|
|
OnPropertyChanged("QueueProgress");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
|
|
|
|
private List<CPUStatus> InternalStatus { get; }
|
2019-09-14 04:35:42 +00:00
|
|
|
|
public string LogFile { get; }
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
public ICommand ChangePath
|
2019-07-22 22:17:46 +00:00
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
get
|
2019-09-04 01:43:16 +00:00
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
if (_changePath == null) _changePath = new LambdaCommand(() => true, () => ExecuteChangePath());
|
|
|
|
|
return _changePath;
|
2019-09-04 01:43:16 +00:00
|
|
|
|
}
|
2019-09-14 04:35:42 +00:00
|
|
|
|
}
|
2019-09-04 01:43:16 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
public ICommand ChangeDownloadPath
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_changeDownloadPath == null)
|
|
|
|
|
_changeDownloadPath = new LambdaCommand(() => true, () => ExecuteChangeDownloadPath());
|
|
|
|
|
return _changeDownloadPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
public ICommand Begin
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_begin == null) _begin = new LambdaCommand(() => true, () => ExecuteBegin());
|
|
|
|
|
return _begin;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
public ICommand ShowReportCommand
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_showReportCommand == null) _showReportCommand = new LambdaCommand(() => true, () => ShowReport());
|
|
|
|
|
return _showReportCommand;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-09-26 03:18:36 +00:00
|
|
|
|
public ICommand VisitNexusSiteCommand
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_visitNexusSiteCommand == null) _visitNexusSiteCommand = new LambdaCommand(() => true, () => VisitNexusSite());
|
|
|
|
|
return _visitNexusSiteCommand;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-26 11:30:03 +00:00
|
|
|
|
public string _nexusSiteURL = null;
|
2019-09-26 03:18:36 +00:00
|
|
|
|
|
|
|
|
|
private void VisitNexusSite()
|
|
|
|
|
{
|
|
|
|
|
if (_nexusSiteURL != null && _nexusSiteURL.StartsWith("https://"))
|
|
|
|
|
{
|
|
|
|
|
Process.Start(_nexusSiteURL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-09-18 03:12:25 +00:00
|
|
|
|
private bool _uiReady = false;
|
|
|
|
|
public bool UIReady
|
|
|
|
|
{
|
|
|
|
|
get => _uiReady;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_uiReady = value;
|
|
|
|
|
OnPropertyChanged("UIReady");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-26 03:18:36 +00:00
|
|
|
|
private BitmapImage _wabbajackLogo = null;
|
|
|
|
|
private BitmapImage _splashScreenImage = null;
|
|
|
|
|
public BitmapImage SplashScreenImage
|
|
|
|
|
{
|
|
|
|
|
get => _splashScreenImage;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_splashScreenImage = value;
|
|
|
|
|
OnPropertyChanged("SplashScreenImage");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string _splashScreenModName = "Wabbajack";
|
|
|
|
|
public string SplashScreenModName
|
|
|
|
|
{
|
|
|
|
|
get => _splashScreenModName;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_splashScreenModName = value;
|
|
|
|
|
OnPropertyChanged("SplashScreenModName");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string _splashScreenAuthorName = "Halgari & the Wabbajack Team";
|
|
|
|
|
public string SplashScreenAuthorName
|
|
|
|
|
{
|
|
|
|
|
get => _splashScreenAuthorName;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_splashScreenAuthorName = value;
|
|
|
|
|
OnPropertyChanged("SplashScreenAuthorName");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string _splashScreenSummary = "";
|
2019-10-01 22:39:25 +00:00
|
|
|
|
private string _modListPath;
|
|
|
|
|
|
2019-09-26 03:18:36 +00:00
|
|
|
|
public string SplashScreenSummary
|
|
|
|
|
{
|
|
|
|
|
get => _splashScreenSummary;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_splashScreenSummary = value;
|
|
|
|
|
OnPropertyChanged("SplashScreenSummary");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
public void OnPropertyChanged(string name)
|
|
|
|
|
{
|
2019-09-26 14:35:34 +00:00
|
|
|
|
if(PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs(name));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public string Error
|
|
|
|
|
{
|
|
|
|
|
get { return "Error"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string this[string columnName]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Validate(columnName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string Validate(string columnName)
|
|
|
|
|
{
|
|
|
|
|
string validationMessage = null;
|
|
|
|
|
switch (columnName)
|
|
|
|
|
{
|
|
|
|
|
case "Location":
|
|
|
|
|
if (Location == null)
|
|
|
|
|
{
|
|
|
|
|
validationMessage = null;
|
|
|
|
|
}
|
|
|
|
|
else if (Location != null && Directory.Exists(Location) && File.Exists(Path.Combine(Location, "modlist.txt")))
|
|
|
|
|
{
|
|
|
|
|
Location = Path.Combine(Location, "modlist.txt");
|
|
|
|
|
validationMessage = null;
|
|
|
|
|
ConfigureForBuild();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
validationMessage = "Invalid Mod Organizer profile directory";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return validationMessage;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateLoop()
|
|
|
|
|
{
|
2019-09-27 04:07:54 +00:00
|
|
|
|
while (Running)
|
2019-07-22 22:17:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (Dirty)
|
|
|
|
|
lock (InternalStatus)
|
|
|
|
|
{
|
|
|
|
|
var data = InternalStatus.ToArray();
|
|
|
|
|
dispatcher.Invoke(() =>
|
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
for (var idx = 0; idx < data.Length; idx += 1)
|
2019-07-22 22:17:46 +00:00
|
|
|
|
if (idx >= Status.Count)
|
|
|
|
|
Status.Add(data[idx]);
|
|
|
|
|
else if (Status[idx] != data[idx])
|
|
|
|
|
Status[idx] = data[idx];
|
|
|
|
|
});
|
|
|
|
|
Dirty = false;
|
|
|
|
|
}
|
2019-09-14 04:35:42 +00:00
|
|
|
|
|
2019-09-26 03:18:36 +00:00
|
|
|
|
if (SlideShowElements.Any())
|
|
|
|
|
{
|
|
|
|
|
if (DateTime.Now - _lastSlideShowUpdate > TimeSpan.FromSeconds(10))
|
|
|
|
|
{
|
2019-10-04 20:50:34 +00:00
|
|
|
|
var idx = _random.Next(0, SlideShowElements.Count);
|
|
|
|
|
|
|
|
|
|
try
|
2019-09-26 03:18:36 +00:00
|
|
|
|
{
|
2019-10-04 20:50:34 +00:00
|
|
|
|
var element = SlideShowElements[idx];
|
|
|
|
|
|
|
|
|
|
var data = new MemoryStream();
|
2019-10-06 21:58:36 +00:00
|
|
|
|
using (var stream = new HttpClient().GetStreamSync(element.ImageURL))
|
2019-10-04 20:50:34 +00:00
|
|
|
|
stream.CopyTo(data);
|
|
|
|
|
data.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatcher.Invoke(() =>
|
2019-10-01 23:57:42 +00:00
|
|
|
|
{
|
2019-10-04 20:50:34 +00:00
|
|
|
|
var bitmap = new BitmapImage();
|
|
|
|
|
bitmap.BeginInit();
|
|
|
|
|
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
|
|
|
|
bitmap.StreamSource = data;
|
|
|
|
|
bitmap.EndInit();
|
2019-10-01 23:57:42 +00:00
|
|
|
|
|
2019-10-04 20:50:34 +00:00
|
|
|
|
SplashScreenImage = bitmap;
|
2019-10-01 23:57:42 +00:00
|
|
|
|
SplashScreenModName = element.ModName;
|
|
|
|
|
SplashScreenAuthorName = element.AuthorName;
|
|
|
|
|
SplashScreenSummary = element.ModSummary;
|
|
|
|
|
_nexusSiteURL = element.ModURL;
|
2019-10-04 20:50:34 +00:00
|
|
|
|
|
|
|
|
|
_lastSlideShowUpdate = DateTime.Now;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-26 03:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-23 04:27:26 +00:00
|
|
|
|
Thread.Sleep(1000);
|
2019-07-22 22:17:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-27 04:07:54 +00:00
|
|
|
|
public bool Running { get; set; } = true;
|
|
|
|
|
|
2019-10-01 22:39:25 +00:00
|
|
|
|
internal void ConfigureForInstall(string source, ModList modlist)
|
2019-07-31 03:59:19 +00:00
|
|
|
|
{
|
2019-09-12 23:44:35 +00:00
|
|
|
|
_modList = modlist;
|
2019-10-01 22:39:25 +00:00
|
|
|
|
_modListPath = source;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
Mode = "Installing";
|
|
|
|
|
ModListName = _modList.Name;
|
2019-08-30 23:57:56 +00:00
|
|
|
|
HTMLReport = _modList.ReportHTML;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
Location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
2019-09-26 03:18:36 +00:00
|
|
|
|
|
2019-09-26 20:18:41 +00:00
|
|
|
|
SlideShowElements = modlist.Archives.OfType<NexusMod>().Select(m => new SlideShowItem
|
2019-09-26 03:18:36 +00:00
|
|
|
|
{
|
2019-09-26 20:18:41 +00:00
|
|
|
|
ModName = NexusApiUtils.FixupSummary(m.ModName),
|
|
|
|
|
AuthorName = NexusApiUtils.FixupSummary(m.Author),
|
|
|
|
|
ModSummary = NexusApiUtils.FixupSummary(m.Summary),
|
2019-09-26 03:18:36 +00:00
|
|
|
|
ImageURL = m.SlideShowPic,
|
|
|
|
|
ModURL = m.NexusURL,
|
|
|
|
|
}).ToList();
|
2019-07-31 03:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-22 22:17:46 +00:00
|
|
|
|
public void LogMsg(string msg)
|
|
|
|
|
{
|
|
|
|
|
dispatcher.Invoke(() => Log.Add(msg));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetProgress(int id, string msg, int progress)
|
|
|
|
|
{
|
|
|
|
|
lock (InternalStatus)
|
|
|
|
|
{
|
|
|
|
|
Dirty = true;
|
2019-09-14 04:35:42 +00:00
|
|
|
|
while (id >= InternalStatus.Count) InternalStatus.Add(new CPUStatus());
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
InternalStatus[id] = new CPUStatus {ID = id, Msg = msg, Progress = progress};
|
2019-07-22 22:17:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-31 03:59:19 +00:00
|
|
|
|
|
2019-08-02 23:04:04 +00:00
|
|
|
|
public void SetQueueSize(int max, int current)
|
|
|
|
|
{
|
2019-08-22 22:05:16 +00:00
|
|
|
|
if (max == 0)
|
|
|
|
|
max = 1;
|
2019-08-02 23:04:04 +00:00
|
|
|
|
var total = current * 100 / max;
|
|
|
|
|
QueueProgress = total;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 03:59:19 +00:00
|
|
|
|
private void ExecuteChangePath()
|
|
|
|
|
{
|
|
|
|
|
if (Mode == "Installing")
|
|
|
|
|
{
|
2019-09-18 03:12:25 +00:00
|
|
|
|
var folder = UIUtils.ShowFolderSelectionDialog("Select Installation directory");
|
2019-09-18 02:17:12 +00:00
|
|
|
|
if (folder != null)
|
2019-07-31 03:59:19 +00:00
|
|
|
|
{
|
2019-09-18 02:17:12 +00:00
|
|
|
|
Location = folder;
|
2019-09-04 21:19:37 +00:00
|
|
|
|
if (_downloadLocation == null)
|
|
|
|
|
DownloadLocation = Path.Combine(Location, "downloads");
|
2019-07-31 03:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-09-18 03:12:25 +00:00
|
|
|
|
var folder = UIUtils.ShowFolderSelectionDialog("Select Your MO2 profile directory");
|
2019-09-26 14:35:34 +00:00
|
|
|
|
Location = folder;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 22:12:39 +00:00
|
|
|
|
private void ExecuteChangeDownloadPath()
|
|
|
|
|
{
|
2019-09-18 03:12:25 +00:00
|
|
|
|
var folder = UIUtils.ShowFolderSelectionDialog("Select a location for MO2 downloads");
|
2019-09-18 02:17:12 +00:00
|
|
|
|
if (folder != null) DownloadLocation = folder;
|
2019-09-03 22:12:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 03:59:19 +00:00
|
|
|
|
private void ConfigureForBuild()
|
|
|
|
|
{
|
|
|
|
|
var profile_folder = Path.GetDirectoryName(Location);
|
|
|
|
|
var mo2folder = Path.GetDirectoryName(Path.GetDirectoryName(profile_folder));
|
|
|
|
|
if (!File.Exists(Path.Combine(mo2folder, "ModOrganizer.exe")))
|
|
|
|
|
LogMsg($"Error! No ModOrganizer2.exe found in {mo2folder}");
|
|
|
|
|
|
|
|
|
|
var profile_name = Path.GetFileName(profile_folder);
|
|
|
|
|
ModListName = profile_name;
|
|
|
|
|
Mode = "Building";
|
2019-09-03 22:12:39 +00:00
|
|
|
|
|
2019-09-26 22:32:15 +00:00
|
|
|
|
var tmp_compiler = new Compiler(mo2folder);
|
2019-09-03 22:12:39 +00:00
|
|
|
|
DownloadLocation = tmp_compiler.MO2DownloadsFolder;
|
|
|
|
|
|
2019-07-31 03:59:19 +00:00
|
|
|
|
_mo2Folder = mo2folder;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-30 23:57:56 +00:00
|
|
|
|
private void ShowReport()
|
|
|
|
|
{
|
|
|
|
|
var file = Path.GetTempFileName() + ".html";
|
|
|
|
|
File.WriteAllText(file, HTMLReport);
|
|
|
|
|
Process.Start(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-07-31 03:59:19 +00:00
|
|
|
|
private void ExecuteBegin()
|
|
|
|
|
{
|
2019-09-18 03:12:25 +00:00
|
|
|
|
UIReady = false;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
if (Mode == "Installing")
|
|
|
|
|
{
|
2019-10-01 22:39:25 +00:00
|
|
|
|
var installer = new Installer(_modListPath, _modList, Location);
|
2019-09-26 03:18:36 +00:00
|
|
|
|
|
2019-09-03 22:12:39 +00:00
|
|
|
|
installer.DownloadFolder = DownloadLocation;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
var th = new Thread(() =>
|
|
|
|
|
{
|
2019-09-18 03:12:25 +00:00
|
|
|
|
UIReady = false;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
installer.Install();
|
|
|
|
|
}
|
2019-08-02 22:31:13 +00:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2019-08-22 22:05:16 +00:00
|
|
|
|
while (ex.InnerException != null) ex = ex.InnerException;
|
2019-08-07 23:06:38 +00:00
|
|
|
|
LogMsg(ex.StackTrace);
|
2019-08-22 23:29:44 +00:00
|
|
|
|
LogMsg(ex.ToString());
|
2019-08-02 22:31:13 +00:00
|
|
|
|
LogMsg($"{ex.Message} - Can't continue");
|
2019-07-31 03:59:19 +00:00
|
|
|
|
}
|
2019-09-18 03:12:25 +00:00
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
UIReady = true;
|
|
|
|
|
}
|
2019-07-31 03:59:19 +00:00
|
|
|
|
});
|
|
|
|
|
th.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
th.Start();
|
|
|
|
|
}
|
2019-09-26 14:35:34 +00:00
|
|
|
|
else if (_mo2Folder != null)
|
2019-07-31 03:59:19 +00:00
|
|
|
|
{
|
2019-09-26 22:32:15 +00:00
|
|
|
|
var compiler = new Compiler(_mo2Folder);
|
2019-07-31 03:59:19 +00:00
|
|
|
|
compiler.MO2Profile = ModListName;
|
|
|
|
|
var th = new Thread(() =>
|
|
|
|
|
{
|
2019-09-18 03:12:25 +00:00
|
|
|
|
UIReady = false;
|
2019-08-07 23:06:38 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
compiler.Compile();
|
2019-08-30 23:57:56 +00:00
|
|
|
|
if (compiler.ModList != null && compiler.ModList.ReportHTML != null)
|
|
|
|
|
HTMLReport = compiler.ModList.ReportHTML;
|
2019-08-07 23:06:38 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2019-08-22 22:05:16 +00:00
|
|
|
|
while (ex.InnerException != null) ex = ex.InnerException;
|
2019-08-07 23:06:38 +00:00
|
|
|
|
LogMsg(ex.StackTrace);
|
2019-08-22 23:29:44 +00:00
|
|
|
|
LogMsg(ex.ToString());
|
2019-08-07 23:06:38 +00:00
|
|
|
|
LogMsg($"{ex.Message} - Can't continue");
|
|
|
|
|
}
|
2019-09-18 03:12:25 +00:00
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
UIReady = true;
|
|
|
|
|
}
|
2019-07-31 03:59:19 +00:00
|
|
|
|
});
|
|
|
|
|
th.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
th.Start();
|
|
|
|
|
}
|
2019-09-26 14:35:34 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Utils.Log("Cannot compile modlist: no valid Mod Organizer profile directory selected.");
|
|
|
|
|
UIReady = true;
|
|
|
|
|
}
|
2019-07-31 03:59:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-14 04:35:42 +00:00
|
|
|
|
|
2019-09-26 03:18:36 +00:00
|
|
|
|
|
|
|
|
|
|
2019-09-14 04:35:42 +00:00
|
|
|
|
public class CPUStatus
|
|
|
|
|
{
|
|
|
|
|
public int Progress { get; internal set; }
|
|
|
|
|
public string Msg { get; internal set; }
|
|
|
|
|
public int ID { get; internal set; }
|
|
|
|
|
}
|
2019-07-22 22:17:46 +00:00
|
|
|
|
}
|