Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Clean/Simplify code, reduce restart origin/eadesktop delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Dyvinia committed Mar 31, 2021
1 parent b7192b8 commit f6616dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 32 deletions.
10 changes: 5 additions & 5 deletions AfterPatchWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ private async void btn_restartEA_Click(object sender, RoutedEventArgs e) {
foreach (var process in Process.GetProcessesByName("Origin")) {
process.Kill();
}
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
await Task.Delay(8000);
Mouse.OverrideCursor = Cursors.Wait;
await Task.Delay(5000);
Mouse.OverrideCursor = null;
Process p = new Process();
p.StartInfo.UseShellExecute = true;
Expand All @@ -61,8 +61,8 @@ private async void btn_restartOrigin_Click(object sender, RoutedEventArgs e) {
foreach (var process in Process.GetProcessesByName("Origin")) {
process.Kill();
}
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
await Task.Delay(8000);
Mouse.OverrideCursor = Cursors.Wait;
await Task.Delay(5000);
Mouse.OverrideCursor = null;
Process p = new Process();
p.StartInfo.UseShellExecute = false;
Expand All @@ -81,7 +81,7 @@ private async void btn_restartPC_Click(object sender, RoutedEventArgs e) {
switch (result) {
case MessageBoxResult.Yes:
await Task.Delay(2000);
System.Diagnostics.Process.Start("shutdown.exe", "-r -t 0");
Process.Start("shutdown.exe", "-r -t 0");
break;
}
}
Expand Down
43 changes: 18 additions & 25 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,38 @@ public partial class MainWindow : Window {

public void checkStatus() {
var isenabled = Environment.GetEnvironmentVariable("GAME_DATA_DIR", EnvironmentVariableTarget.User);
if (isenabled == "\\ModData") {
lbl_enabled.Text = "Registry Key is Currently Broken";
lbl_enabled.Foreground = Brushes.Orange;
}
else if (isenabled != null) {
if (isenabled == bf2015 + "\\ModData") {
if (isenabled != null) {
lbl_enabled.Foreground = Brushes.LightGreen;
if (isenabled == "\\ModData") {
lbl_enabled.Text = "Registry Key is Currently Broken";
lbl_enabled.Foreground = Brushes.Orange;
}
else if (isenabled == bf2015 + "\\ModData") {
lbl_enabled.Text = "Mods are Currently Enabled for Star Wars: Battlefront (2015)";
lbl_enabled.Foreground = Brushes.LightGreen;
}
else if (isenabled == bf2017 + "\\ModData") {
lbl_enabled.Text = "Mods are Currently Enabled for Star Wars: Battlefront II (2017)";
lbl_enabled.Foreground = Brushes.LightGreen;
}
else if (isenabled == mea + "\\ModData") {
lbl_enabled.Text = "Mods are Currently Enabled for Mass Effect: Andromeda";
lbl_enabled.Foreground = Brushes.LightGreen;
}
else if (isenabled == bf1 + "\\ModData") {
lbl_enabled.Text = "Mods are Currently Enabled for Battlefield One";
lbl_enabled.Foreground = Brushes.LightGreen;
}
else if (isenabled == nfs + "\\ModData") {
lbl_enabled.Text = "Mods are Currently Enabled for Need for Speed";
lbl_enabled.Foreground = Brushes.LightGreen;
}
else if (isenabled == nfspayback + "\\ModData") {
lbl_enabled.Text = "Mods are Currently Enabled for Need for Speed: Payback";
lbl_enabled.Foreground = Brushes.LightGreen;
}
else if (isenabled == gw2 + "\\ModData") {
lbl_enabled.Text = "Mods are Currently Enabled for PvZ: Garden Warfare 2";
lbl_enabled.Foreground = Brushes.LightGreen;
}
else if (isenabled == dai + "\\ModData") {
lbl_enabled.Text = "Mods are Currently Enabled for Dragon Age: Inquisition";
lbl_enabled.Foreground = Brushes.LightGreen;
}
else {
lbl_enabled.Text = "Mods are Currently Enabled for Custom Game";
lbl_enabled.Foreground = Brushes.LightGreen;
}
}
else {
Expand All @@ -71,7 +63,7 @@ public void checkStatus() {
}

private async void btn_enable_Click(object sender, RoutedEventArgs e) {
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
Mouse.OverrideCursor = Cursors.Wait;
Environment.SetEnvironmentVariable("GAME_DATA_DIR", datadir + "\\ModData", EnvironmentVariableTarget.User);
await Task.Delay(10);
Mouse.OverrideCursor = null;
Expand All @@ -81,7 +73,7 @@ private async void btn_enable_Click(object sender, RoutedEventArgs e) {
}

private async void btn_disable_Click(object sender, RoutedEventArgs e) {
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
Mouse.OverrideCursor = Cursors.Wait;
Environment.SetEnvironmentVariable("GAME_DATA_DIR", "", EnvironmentVariableTarget.User);
await Task.Delay(10);
Mouse.OverrideCursor = null;
Expand All @@ -105,7 +97,7 @@ public MainWindow() {
rbtn_bf2015.IsEnabled = false;
rbtn_bf2015.Foreground = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
}

using (RegistryKey bf2017key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\EA Games\STAR WARS Battlefront II"))
if (bf2017key != null) {
bf2017 = (string)bf2017key.GetValue("Install Dir");
Expand All @@ -125,7 +117,7 @@ public MainWindow() {
rbtn_bf1.IsEnabled = false;
rbtn_bf1.Foreground = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
}

using (RegistryKey meakey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\BioWare\Mass Effect Andromeda"))
if (meakey != null) {
mea = (string)meakey.GetValue("Install Dir");
Expand All @@ -135,7 +127,7 @@ public MainWindow() {
rbtn_mea.IsEnabled = false;
rbtn_mea.Foreground = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
}

using (RegistryKey nfskey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\EA Games\Need for Speed"))
if (nfskey != null) {
nfs = (string)nfskey.GetValue("Install Dir");
Expand All @@ -145,7 +137,7 @@ public MainWindow() {
rbtn_nfs.IsEnabled = false;
rbtn_nfs.Foreground = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
}

using (RegistryKey nfspaybackkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\EA Games\Need for Speed Payback"))
if (nfspaybackkey != null) {
nfspayback = (string)nfspaybackkey.GetValue("Install Dir");
Expand All @@ -155,7 +147,7 @@ public MainWindow() {
rbtn_nfspayback.IsEnabled = false;
rbtn_nfspayback.Foreground = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
}

using (RegistryKey gw2key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\PopCap\Plants vs Zombies GW2"))
if (gw2key != null) {
gw2 = (string)gw2key.GetValue("Install Dir");
Expand All @@ -165,7 +157,7 @@ public MainWindow() {
rbtn_gw2.IsEnabled = false;
rbtn_gw2.Foreground = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
}

using (RegistryKey daikey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Bioware\Dragon Age Inquisition"))
if (daikey != null) {
dai = (string)daikey.GetValue("Install Dir");
Expand Down Expand Up @@ -204,7 +196,8 @@ private void rbtn_custom_Unchecked(object sender, RoutedEventArgs e) {
private void btn_customchoose_Click(object sender, RoutedEventArgs e) {
btn_enable.IsEnabled = true;
btn_disable.IsEnabled = true;
Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog(); {
OpenFileDialog openFileDlg = new OpenFileDialog();
{
openFileDlg.Filter = "Game executable (*.exe)|*.exe";
openFileDlg.FilterIndex = 2;
openFileDlg.RestoreDirectory = true;
Expand Down Expand Up @@ -266,4 +259,4 @@ private void rbtn_dai_Checked(object sender, RoutedEventArgs e) {
btn_disable.IsEnabled = true;
}
}
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0")]
[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyVersion("2.2.1")]
[assembly: AssemblyFileVersion("2.2.1")]

0 comments on commit f6616dd

Please sign in to comment.