Skip to content

Commit

Permalink
[nzgamer] fixed updater, fixed !debug thing, also set checkforupdates…
Browse files Browse the repository at this point in the history
… to be true by default

fixed updater, fixed !debug thing, also set checkforupdates to be true by default
  • Loading branch information
ReaverTeknoGods authored Apr 3, 2019
2 parents 453d989 + 367416b commit 641afd5
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 82 deletions.
2 changes: 2 additions & 0 deletions TeknoParrotUi.Common/JoystickHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace TeknoParrotUi.Common
{
public class JoystickHelper
{
public static bool firstTime = false;
/// <summary>
/// Serializes Lazydata.ParrotData to a ParrotData.xml file.
/// </summary>
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion TeknoParrotUi.Common/ParrotData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
212 changes: 131 additions & 81 deletions TeknoParrotUi/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,134 +254,184 @@ async Task<List<GithubRelease>> 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();

}


/// <summary>
/// When the window is loaded, the update checker is run and DiscordRPC is set
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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");
Expand Down

0 comments on commit 641afd5

Please sign in to comment.