From 9bce1ef4b423ed32b84adfc74da4a08b14e15150 Mon Sep 17 00:00:00 2001 From: nzgamer41 Date: Wed, 3 Apr 2019 19:37:48 +1300 Subject: [PATCH 1/2] set checkforupdates to be true by default, also added thing so if the updater has never been run it won't check for updates --- TeknoParrotUi.Common/JoystickHelper.cs | 2 + TeknoParrotUi.Common/ParrotData.cs | 2 +- TeknoParrotUi/MainWindow.xaml.cs | 212 +++++++++++++++---------- 3 files changed, 134 insertions(+), 82 deletions(-) diff --git a/TeknoParrotUi.Common/JoystickHelper.cs b/TeknoParrotUi.Common/JoystickHelper.cs index 9c0a131a..d2cba6e7 100644 --- a/TeknoParrotUi.Common/JoystickHelper.cs +++ b/TeknoParrotUi.Common/JoystickHelper.cs @@ -8,6 +8,7 @@ namespace TeknoParrotUi.Common { public class JoystickHelper { + public static bool firstTime = false; /// /// Serializes Lazydata.ParrotData to a ParrotData.xml file. /// @@ -29,6 +30,7 @@ public static void DeSerialize() { if (!File.Exists("ParrotData.xml")) { + firstTime = true; MessageBox.Show("Seems like this is first time you are running me, please set emulation settings.", "Hello World"); Lazydata.ParrotData = new ParrotData(); Serialize(); diff --git a/TeknoParrotUi.Common/ParrotData.cs b/TeknoParrotUi.Common/ParrotData.cs index 052050df..399cc110 100644 --- a/TeknoParrotUi.Common/ParrotData.cs +++ b/TeknoParrotUi.Common/ParrotData.cs @@ -18,6 +18,6 @@ public class ParrotData public bool UseDiscordRPC { get; set; } public bool SilentMode { get; set; } - public bool CheckForUpdates { get; set; } + public bool CheckForUpdates { get; set; } = true; } } diff --git a/TeknoParrotUi/MainWindow.xaml.cs b/TeknoParrotUi/MainWindow.xaml.cs index a49c290c..26a0e16f 100644 --- a/TeknoParrotUi/MainWindow.xaml.cs +++ b/TeknoParrotUi/MainWindow.xaml.cs @@ -254,125 +254,171 @@ async Task> GetGithubReleases(string repo) private async void CheckGitHub(string componentToCheck) { - try - { - if (componentToCheck == "TeknoParrotUI") + try { - var releases = await GetGithubReleases(componentToCheck); - var latest = releases[0]; - int uiId = 0; - try + if (componentToCheck == "TeknoParrotUI") { - using (RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\TeknoGods\\TeknoParrot")) + var releases = await GetGithubReleases(componentToCheck); + var latest = releases[0]; + int uiId = 0; + try { - if (key != null) + using (RegistryKey key = + Registry.CurrentUser.OpenSubKey("Software\\TeknoGods\\TeknoParrot")) { - uiId = (int) key.GetValue("TeknoParrotUI"); + if (key != null) + { + uiId = (int) key.GetValue("TeknoParrotUI"); + } } } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + + if (latest.id != uiId) + { + GitHubUpdates windowGitHubUpdates = + new GitHubUpdates(componentToCheck, latest); + windowGitHubUpdates.Show(); + } } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - if (latest.id != uiId) - { - GitHubUpdates windowGitHubUpdates = - new GitHubUpdates(componentToCheck, latest); - windowGitHubUpdates.Show(); - } - } - else if (componentToCheck == "OpenParrot") - { - //check openparrot32 first - var releases = await GetGithubReleases(componentToCheck); - int x32id = 0; - int x64id = 0; - try + else if (componentToCheck == "OpenParrot") { - using (RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\TeknoGods\\TeknoParrot")) + //check openparrot32 first + var releases = await GetGithubReleases(componentToCheck); + int x32id = 0; + int x64id = 0; + try { - if (key != null) + using (RegistryKey key = + Registry.CurrentUser.OpenSubKey("Software\\TeknoGods\\TeknoParrot")) { - x32id = (int) key.GetValue("OpenParrotWin32"); - x64id = (int) key.GetValue("OpenParrotx64"); + if (key != null) + { + x32id = (int) key.GetValue("OpenParrotWin32"); + x64id = (int) key.GetValue("OpenParrotx64"); + } } } - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } - for (int i = 0; i < releases.Count; i++) - { - var latest = releases[i]; - if (latest.tag_name == "OpenParrotWin32") + for (int i = 0; i < releases.Count; i++) { - if (latest.id != x32id) + var latest = releases[i]; + if (latest.tag_name == "OpenParrotWin32") { - GitHubUpdates windowGitHubUpdates = - new GitHubUpdates(componentToCheck + "Win32", latest); - windowGitHubUpdates.Show(); + if (latest.id != x32id) + { + GitHubUpdates windowGitHubUpdates = + new GitHubUpdates(componentToCheck + "Win32", latest); + windowGitHubUpdates.Show(); + } + else break; } - else break; } - } - //checking openparrot64 - for (int i = 0; i < releases.Count; i++) - { - var latest = releases[i]; - if (latest.tag_name == "OpenParrotx64") + //checking openparrot64 + for (int i = 0; i < releases.Count; i++) { - if (latest.id != x64id) + var latest = releases[i]; + if (latest.tag_name == "OpenParrotx64") { - GitHubUpdates windowGitHubUpdates = new GitHubUpdates(componentToCheck + "x64", latest); - windowGitHubUpdates.Show(); + if (latest.id != x64id) + { + GitHubUpdates windowGitHubUpdates = + new GitHubUpdates(componentToCheck + "x64", latest); + windowGitHubUpdates.Show(); + } + else break; } - else break; } } - } - else - { - var releases = await GetGithubReleases(componentToCheck); - int segaApiId = 0; - try + else { - using (RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\TeknoGods\\TeknoParrot")) + var releases = await GetGithubReleases(componentToCheck); + int segaApiId = 0; + try { - if (key != null) + using (RegistryKey key = + Registry.CurrentUser.OpenSubKey("Software\\TeknoGods\\TeknoParrot")) { - segaApiId = (int) key.GetValue("OpenSegaAPI"); + if (key != null) + { + segaApiId = (int) key.GetValue("OpenSegaAPI"); + } } } - } - catch - { + catch + { - } + } - for (int i = 0; i < releases.Count; i++) - { - var latest = releases[i]; - if (latest.id != segaApiId) + for (int i = 0; i < releases.Count; i++) { - GitHubUpdates windowGitHubUpdates = new GitHubUpdates(componentToCheck, latest); - windowGitHubUpdates.Show(); - break; + var latest = releases[i]; + if (latest.id != segaApiId) + { + GitHubUpdates windowGitHubUpdates = new GitHubUpdates(componentToCheck, latest); + windowGitHubUpdates.Show(); + break; + } + else + break; } - else - break; } + + } + catch (Exception ex) + { } + } + + private async void InitUpdater() + { + var tpUi = await GetGithubReleases("TeknoParrotUI"); + var openParrot = await GetGithubReleases("OpenParrot"); + var openSegaApi = await GetGithubReleases("OpenSegaAPI"); + int op32Id = 0; + int op64Id = 0; + + for (int i = 0; i < openParrot.Count; i++) + { + var latest = openParrot[i]; + if (latest.tag_name == "OpenParrotWin32") + { + op32Id = latest.id; + break; + } } - catch (Exception ex) + //checking openparrot64 + for (int i = 0; i < openParrot.Count; i++) { + var latest = openParrot[i]; + if (latest.tag_name == "OpenParrotx64") + { + op64Id = latest.id; + break; + } } + + + + RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\TeknoGods\TeknoParrot", true); + key.SetValue("TeknoParrotUI", tpUi[0].id); + key.SetValue("OpenSegaAPI", openSegaApi[0].id); + key.SetValue("OpenParrotWin32", op32Id); + key.SetValue("OpenParrotx64", op64Id); + key.Close(); + } + /// /// When the window is loaded, the update checker is run and DiscordRPC is set /// @@ -380,8 +426,12 @@ private async void CheckGitHub(string componentToCheck) /// private void Window_Loaded(object sender, RoutedEventArgs e) { -#if DEBUG - if (Lazydata.ParrotData.CheckForUpdates) +#if !DEBUG + if (JoystickHelper.firstTime) + { + initUpdater(); + } + else if (Lazydata.ParrotData.CheckForUpdates) { CheckGitHub("TeknoParrotUI"); CheckGitHub("OpenParrot"); From 367416b919c3b825ac24e24f9bc622e237016142 Mon Sep 17 00:00:00 2001 From: nzgamer41 Date: Wed, 3 Apr 2019 19:40:07 +1300 Subject: [PATCH 2/2] haha what a good prank i forgot i renamed this --- TeknoParrotUi/MainWindow.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeknoParrotUi/MainWindow.xaml.cs b/TeknoParrotUi/MainWindow.xaml.cs index 26a0e16f..f6978598 100644 --- a/TeknoParrotUi/MainWindow.xaml.cs +++ b/TeknoParrotUi/MainWindow.xaml.cs @@ -429,7 +429,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) #if !DEBUG if (JoystickHelper.firstTime) { - initUpdater(); + InitUpdater(); } else if (Lazydata.ParrotData.CheckForUpdates) {