2019-10-07 17:33:34 +00:00
|
|
|
|
using Alphaleonis.Win32.Filesystem;
|
|
|
|
|
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;
|
2019-10-16 03:10:34 +00:00
|
|
|
|
using Wabbajack.Lib;
|
2019-09-27 04:07:54 +00:00
|
|
|
|
using Application = System.Windows.Application;
|
|
|
|
|
using MessageBox = System.Windows.MessageBox;
|
2019-07-22 22:17:46 +00:00
|
|
|
|
|
|
|
|
|
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-10-23 04:15:42 +00:00
|
|
|
|
private MainWindowVM _mwvm;
|
2019-09-14 04:35:42 +00:00
|
|
|
|
|
2019-09-27 04:07:54 +00:00
|
|
|
|
public MainWindow(RunMode mode, string source)
|
2019-07-22 22:17:46 +00:00
|
|
|
|
{
|
2019-07-31 03:59:19 +00:00
|
|
|
|
var args = Environment.GetCommandLineArgs();
|
|
|
|
|
|
2019-07-22 22:17:46 +00:00
|
|
|
|
InitializeComponent();
|
2019-07-26 20:59:14 +00:00
|
|
|
|
|
2019-10-23 04:15:42 +00:00
|
|
|
|
this._mwvm = new MainWindowVM(mode);
|
|
|
|
|
var context = _mwvm.AppState;
|
|
|
|
|
Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}");
|
|
|
|
|
DataContext = _mwvm;
|
2019-08-20 04:57:08 +00:00
|
|
|
|
|
2019-09-18 03:12:25 +00:00
|
|
|
|
new Thread(() =>
|
|
|
|
|
{
|
2019-09-27 04:07:54 +00:00
|
|
|
|
if (mode == RunMode.Compile)
|
|
|
|
|
{
|
|
|
|
|
Utils.Log("Compiler ready to execute");
|
|
|
|
|
context.Location = Path.GetDirectoryName(source);
|
2019-10-05 15:05:51 +00:00
|
|
|
|
context.LocationLabel = "MO2 Profile:";
|
2019-09-27 04:07:54 +00:00
|
|
|
|
}
|
|
|
|
|
else if (mode == RunMode.Install)
|
|
|
|
|
{
|
|
|
|
|
context.UIReady = false;
|
2019-10-05 15:05:51 +00:00
|
|
|
|
context.LocationLabel = "Installation Location:";
|
2019-10-01 22:39:25 +00:00
|
|
|
|
var modlist = Installer.LoadFromFile(source);
|
2019-09-27 04:07:54 +00:00
|
|
|
|
if (modlist == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Invalid Modlist, or file not found.", "Invalid Modlist", MessageBoxButton.OK,
|
|
|
|
|
MessageBoxImage.Error);
|
|
|
|
|
Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
ExitWhenClosing = false;
|
2019-10-07 11:48:39 +00:00
|
|
|
|
var window = new ModeSelectionWindow
|
|
|
|
|
{
|
|
|
|
|
ShowActivated = true
|
|
|
|
|
};
|
2019-09-27 04:07:54 +00:00
|
|
|
|
window.Show();
|
|
|
|
|
Close();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-10-01 22:39:25 +00:00
|
|
|
|
context.ConfigureForInstall(source, modlist);
|
2019-09-27 04:07:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-18 03:12:25 +00:00
|
|
|
|
context.UIReady = true;
|
|
|
|
|
}).Start();
|
2019-07-22 22:17:46 +00:00
|
|
|
|
}
|
2019-08-04 22:08:03 +00:00
|
|
|
|
|
2019-09-27 04:07:54 +00:00
|
|
|
|
internal bool ExitWhenClosing = true;
|
|
|
|
|
|
2019-08-04 22:08:03 +00:00
|
|
|
|
private void Window_Closing(object sender, CancelEventArgs e)
|
|
|
|
|
{
|
2019-10-23 04:15:42 +00:00
|
|
|
|
_mwvm.Dispose();
|
2019-09-27 04:07:54 +00:00
|
|
|
|
if (ExitWhenClosing)
|
2019-10-23 04:15:42 +00:00
|
|
|
|
{
|
2019-09-27 04:07:54 +00:00
|
|
|
|
Application.Current.Shutdown();
|
2019-10-23 04:15:42 +00:00
|
|
|
|
}
|
2019-08-04 22:08:03 +00:00
|
|
|
|
}
|
2019-07-22 22:17:46 +00:00
|
|
|
|
}
|
2019-09-14 04:35:42 +00:00
|
|
|
|
}
|