wabbajack/Wabbajack/Views/ModeSelectionWindow.xaml.cs

114 lines
3.9 KiB
C#
Raw Normal View History

2019-10-20 11:26:42 +00:00
using System.Collections.Generic;
using System.ComponentModel;
2019-09-27 11:51:37 +00:00
using System.Diagnostics;
using System.IO;
2019-10-07 17:33:34 +00:00
using System.Windows;
2019-09-27 04:07:54 +00:00
using System.Windows.Input;
using Wabbajack.Common;
using Wabbajack.Lib;
2019-10-20 11:26:42 +00:00
using Wabbajack.Lib.ModListRegistry;
using Wabbajack.UI;
2019-09-27 04:07:54 +00:00
using static Wabbajack.MainWindow;
namespace Wabbajack
{
/// <summary>
/// Interaction logic for ModeSelectionWindow.xaml
/// </summary>
public partial class ModeSelectionWindow : Window
{
MainSettings settings;
2019-10-20 11:26:42 +00:00
2019-09-27 04:07:54 +00:00
public ModeSelectionWindow()
{
InitializeComponent();
2019-10-22 01:08:26 +00:00
var bannerImage = UIUtils.BitmapImageFromResource("Wabbajack.Resources.banner_small_dark.png");
2019-09-27 11:51:37 +00:00
Banner.Source = bannerImage;
2019-10-22 01:08:26 +00:00
var patreonIcon = UIUtils.BitmapImageFromResource("Wabbajack.Resources.Icons.patreon_light.png");
2019-09-27 11:51:37 +00:00
Patreon.Source = patreonIcon;
2019-10-22 01:08:26 +00:00
var githubIcon = UIUtils.BitmapImageFromResource("Wabbajack.Resources.Icons.github_light.png");
2019-09-27 11:51:37 +00:00
GitHub.Source = githubIcon;
2019-10-22 01:08:26 +00:00
var discordIcon = UIUtils.BitmapImageFromResource("Wabbajack.Resources.Icons.discord.png");
2019-09-27 11:51:37 +00:00
Discord.Source = discordIcon;
2019-10-20 11:26:42 +00:00
settings = MainSettings.LoadSettings();
2019-11-02 20:55:14 +00:00
DataContext = new ModeSelectionWindowVM();
2019-09-27 04:07:54 +00:00
}
private void CreateModlist_Click(object sender, RoutedEventArgs e)
{
OpenMainWindow(
RunMode.Compile,
UIUtils.OpenFileDialog(
"MO2 Modlist(modlist.txt)|modlist.txt",
initialDirectory: settings.LastCompiledProfileLocation));
2019-09-27 04:07:54 +00:00
}
private void InstallModlist_Click(object sender, RoutedEventArgs e)
{
2019-10-20 11:26:42 +00:00
//OpenMainWindow(
// RunMode.Install,
// UIUtils.OpenFileDialog($"Wabbajack Modlist (*{Consts.ModlistExtension})|*{Consts.ModlistExtension}"));
2019-11-02 20:55:14 +00:00
var result = ((ModeSelectionWindowVM)DataContext).Download();
2019-10-20 19:30:39 +00:00
if (result != null)
{
OpenMainWindow(RunMode.Install, result);
}
2019-09-27 04:07:54 +00:00
}
private void OpenMainWindow(RunMode mode, string file)
{
if (file == null) return;
ShutdownOnClose = false;
switch (mode)
{
case RunMode.Compile:
settings.LastCompiledProfileLocation = Path.GetDirectoryName(file);
break;
case RunMode.Install:
settings.LastInstalledListLocation = Path.GetDirectoryName(file);
break;
default:
break;
}
var window = new MainWindow(mode, file, settings);
window.Left = this.Left;
window.Top = this.Top;
window.Show();
Close();
}
2019-09-27 04:07:54 +00:00
public void Close_Window(object sender, CancelEventArgs e)
{
if (ShutdownOnClose)
Application.Current.Shutdown();
}
public bool ShutdownOnClose { get; set; } = true;
2019-09-27 11:51:37 +00:00
private void GitHub_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
2019-10-01 03:04:21 +00:00
Process.Start("https://github.com/wabbajack-tools/wabbajack");
2019-09-27 11:51:37 +00:00
}
private void Patreon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Process.Start("https://www.patreon.com/user?u=11907933");
}
private void Discord_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Process.Start("https://discord.gg/zgbrkmA");
}
2019-10-22 12:05:57 +00:00
private void InstallFromList_Click(object sender, RoutedEventArgs e)
{
OpenMainWindow(RunMode.Install,
UIUtils.OpenFileDialog(
$"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}",
initialDirectory: settings.LastInstalledListLocation));
2019-10-22 12:05:57 +00:00
}
2019-09-27 04:07:54 +00:00
}
}