-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMainWindow.xaml.cs
144 lines (123 loc) · 4.59 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Farplane.Common;
using Farplane.Common.Controls;
using Farplane.Common.Dialogs;
using Farplane.FFX;
using Farplane.FFX2;
using Farplane.Properties;
using MahApps.Metro;
using MahApps.Metro.Controls;
using Farplane.Memory;
namespace Farplane
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : MetroWindow
{
private ConfigFlyout _configFlyout = new ConfigFlyout();
private int _splashCounter = 10;
public MainWindow()
{
var exeVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
if (exeVersion > new Version(Settings.Default.SettingsVersion))
Settings.Default.Upgrade();
Settings.Default.SettingsVersion = exeVersion.ToString();
Settings.Default.Save();
try
{
// Load app theme and accent
var currentTheme = ThemeManager.GetAppTheme(Settings.Default.AppTheme);
var currentAccent = ThemeManager.GetAccent(Settings.Default.AppAccent);
ThemeManager.ChangeAppStyle(Application.Current, currentAccent, currentTheme);
}
catch
{
// Theme error, revert to default
Settings.Default.AppTheme = "BaseLight";
Settings.Default.AppAccent = "Blue";
Settings.Default.Save();
var currentTheme = ThemeManager.GetAppTheme(Settings.Default.AppTheme);
var currentAccent = ThemeManager.GetAccent(Settings.Default.AppAccent);
ThemeManager.ChangeAppStyle(Application.Current, currentAccent, currentTheme);
}
InitializeComponent();
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Title = string.Format(Title, $"{version.Major}.{version.Minor}.{version.Build}");
Flyouts = new FlyoutsControl();
Flyouts.Items.Add(_configFlyout);
}
private void FFX2_Click(object sender, RoutedEventArgs e)
{
_configFlyout.IsOpen = false;
var processSelect = new ProcessSelectWindow("FFX-2") {Owner=this};
processSelect.ShowDialog();
if (processSelect.DialogResult == true)
{
Hide();
var FFX2Editor = new FFX2Editor();
FFX2Editor.ShowDialog();
GameMemory.Detach();
if(Settings.Default.CloseWithGame) Environment.Exit(0);
Show();
Topmost = true;
Topmost = false;
}
}
private async void FFX_Click(object sender, RoutedEventArgs e)
{
_configFlyout.IsOpen = false;
var processSelect = new ProcessSelectWindow("FFX") {Owner=this};
processSelect.ShowDialog();
if (processSelect.DialogResult == true)
{
Hide();
if (processSelect.ResultProcess == null)
{
var FFXEditor = new FFXEditor(true);
FFXEditor.ShowDialog();
}
else
{
var FFXEditor = new FFXEditor();
FFXEditor.ShowDialog();
}
GameMemory.Detach();
if (Settings.Default.CloseWithGame) Environment.Exit(0);
Show();
Topmost = true;
Topmost = false;
}
}
private void ButtonConfig_Click(object sender, RoutedEventArgs e)
{
_configFlyout.IsOpen = !_configFlyout.IsOpen;
}
private void SplashLogo_MouseDown(object sender, MouseButtonEventArgs e)
{
_splashCounter--;
if (_splashCounter > 0) return;
_splashCounter = 10;
var credits = new CreditsWindow() {Owner=this, ShowInTaskbar = false, WindowStartupLocation = WindowStartupLocation.CenterOwner};
credits.ShowDialog();
}
}
}