2019-07-22 22:17:46 +00:00
|
|
|
|
using System;
|
2019-08-04 22:08:03 +00:00
|
|
|
|
using System.ComponentModel;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2019-09-14 04:35:42 +00:00
|
|
|
|
/// Interaction logic for MainWindow.xaml
|
2019-07-22 22:17:46 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
2019-09-14 04:35:42 +00:00
|
|
|
|
private AppState _state;
|
|
|
|
|
|
2019-07-22 22:17:46 +00:00
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
2019-07-31 03:59:19 +00:00
|
|
|
|
var args = Environment.GetCommandLineArgs();
|
2019-09-14 04:35:42 +00:00
|
|
|
|
var DebugMode = false;
|
2019-07-31 03:59:19 +00:00
|
|
|
|
string MO2Folder = null, InstallFolder = null, MO2Profile = null;
|
|
|
|
|
|
|
|
|
|
if (args.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
DebugMode = true;
|
|
|
|
|
MO2Folder = args[1];
|
|
|
|
|
MO2Profile = args[2];
|
|
|
|
|
InstallFolder = args[3];
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-22 22:17:46 +00:00
|
|
|
|
InitializeComponent();
|
2019-07-26 20:59:14 +00:00
|
|
|
|
|
2019-07-22 22:17:46 +00:00
|
|
|
|
var context = new AppState(Dispatcher, "Building");
|
2019-08-09 21:13:02 +00:00
|
|
|
|
context.LogMsg($"Wabbajack Build - {ThisAssembly.Git.Sha}");
|
2019-08-04 22:08:03 +00:00
|
|
|
|
SetupHandlers(context);
|
2019-09-14 04:35:42 +00:00
|
|
|
|
DataContext = context;
|
2019-08-02 23:04:04 +00:00
|
|
|
|
WorkQueue.Init((id, msg, progress) => context.SetProgress(id, msg, progress),
|
2019-09-14 04:35:42 +00:00
|
|
|
|
(max, current) => context.SetQueueSize(max, current));
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
2019-08-20 04:57:08 +00:00
|
|
|
|
Utils.SetLoggerFn(s => context.LogMsg(s));
|
|
|
|
|
Utils.SetStatusFn((msg, progress) => WorkQueue.Report(msg, progress));
|
2019-09-18 03:12:25 +00:00
|
|
|
|
UIUtils.Dispatcher = Dispatcher;
|
2019-08-20 04:57:08 +00:00
|
|
|
|
|
2019-07-30 21:45:04 +00:00
|
|
|
|
|
2019-09-18 03:12:25 +00:00
|
|
|
|
new Thread(() =>
|
|
|
|
|
{
|
|
|
|
|
context.UIReady = false;
|
|
|
|
|
var modlist = Installer.CheckForModList();
|
|
|
|
|
if (modlist == null)
|
|
|
|
|
Utils.Log("No Modlist found, running in Compiler mode.");
|
|
|
|
|
else
|
|
|
|
|
context.ConfigureForInstall(modlist);
|
|
|
|
|
context.UIReady = true;
|
|
|
|
|
}).Start();
|
2019-07-22 22:17:46 +00:00
|
|
|
|
}
|
2019-08-04 22:08:03 +00:00
|
|
|
|
|
|
|
|
|
private void SetupHandlers(AppState state)
|
|
|
|
|
{
|
|
|
|
|
_state = state;
|
2019-09-14 04:35:42 +00:00
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += AppHandler;
|
2019-08-04 22:08:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AppHandler(object sender, UnhandledExceptionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_state.LogMsg("Uncaught error:");
|
2019-09-14 04:35:42 +00:00
|
|
|
|
_state.LogMsg(((Exception) e.ExceptionObject).ExceptionToString());
|
2019-08-04 22:08:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Window_Closing(object sender, CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Application.Current.Shutdown();
|
|
|
|
|
}
|
2019-07-22 22:17:46 +00:00
|
|
|
|
}
|
2019-09-14 04:35:42 +00:00
|
|
|
|
}
|