Cleaned the code
- Cleaned up the private and public fields
This commit is contained in:
parent
8538f2f46f
commit
bedf8cc93e
3 changed files with 49 additions and 48 deletions
|
@ -71,8 +71,8 @@ namespace Ryujinx.Ui
|
||||||
SecondaryText = secText,
|
SecondaryText = secText,
|
||||||
WindowPosition = WindowPosition.Center
|
WindowPosition = WindowPosition.Center
|
||||||
};
|
};
|
||||||
Uri URL = new Uri(UpdateParser._BuildArt);
|
Uri URL = new Uri(UpdateParser.BuildArt);
|
||||||
UpdateParser._Package.DownloadFileAsync(URL, Path.Combine(UpdateParser._RyuDir, "Data", "Update", "RyujinxPackage.zip"));
|
UpdateParser.Package.DownloadFileAsync(URL, Path.Combine(UpdateParser.RyuDir, "Data", "Update", "RyujinxPackage.zip"));
|
||||||
messageDialog.SetSizeRequest(100, 20);
|
messageDialog.SetSizeRequest(100, 20);
|
||||||
return messageDialog;
|
return messageDialog;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,47 +19,48 @@ namespace Ryujinx.Updater.Parser
|
||||||
{
|
{
|
||||||
public class UpdateParser
|
public class UpdateParser
|
||||||
{
|
{
|
||||||
private static string _JobID;
|
private static string _jobid;
|
||||||
private static string _BuildVer;
|
private static string _buildver;
|
||||||
private static string _BuildURL = "https://ci.appveyor.com/api/projects/gdkchan/ryujinx/branch/master";
|
private static string _buildurl = "https://ci.appveyor.com/api/projects/gdkchan/ryujinx/branch/master";
|
||||||
public static string _BuildArt;
|
private static string _buildcommit;
|
||||||
private static string _BuildCommit;
|
private static string _branch;
|
||||||
private static string _Branch;
|
private static string _platformext;
|
||||||
private static string _PlatformExt;
|
|
||||||
public static string _RyuDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
|
public static string BuildArt;
|
||||||
public static WebClient _Package = new WebClient();
|
public static string RyuDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
|
||||||
public static int _PackageProgress;
|
public static WebClient Package = new WebClient();
|
||||||
public static double _Percentage;
|
public static int PackageProgress;
|
||||||
|
public static double Percentage;
|
||||||
public static void BeginParse()
|
public static void BeginParse()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Detect current platform
|
//Detect current platform
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
_PlatformExt = "osx_x64.zip";
|
_platformext = "osx_x64.zip";
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
_PlatformExt = "win_x64.zip";
|
_platformext = "win_x64.zip";
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
_PlatformExt = "linux_x64.tar.gz";
|
_platformext = "linux_x64.tar.gz";
|
||||||
|
|
||||||
//Begin the Appveyor parsing
|
//Begin the Appveyor parsing
|
||||||
WebClient JSONClient = new WebClient();
|
WebClient JSONClient = new WebClient();
|
||||||
string FetchedJSON = JSONClient.DownloadString(_BuildURL);
|
string FetchedJSON = JSONClient.DownloadString(_buildurl);
|
||||||
var __JSONRoot = JObject.Parse(FetchedJSON);
|
var __JSONRoot = JObject.Parse(FetchedJSON);
|
||||||
var __Build = __JSONRoot["build"];
|
var __Build = __JSONRoot["build"];
|
||||||
string __Version = (string)__Build["version"];
|
string __Version = (string)__Build["version"];
|
||||||
string __JobsID = (string)__Build["jobs"][0]["jobId"];
|
string __JobsID = (string)__Build["jobs"][0]["jobId"];
|
||||||
string __Branch = (string)__Build["branch"];
|
string __branch = (string)__Build["branch"];
|
||||||
string __BuildCommit = (string)__Build["commitId"];
|
string __buildcommit = (string)__Build["commitId"];
|
||||||
_JobID = __JobsID;
|
_jobid = __JobsID;
|
||||||
_BuildVer = __Version;
|
_buildver = __Version;
|
||||||
_BuildArt = "https://ci.appveyor.com/api/buildjobs/" + _JobID + "/artifacts/ryujinx-" + _BuildVer + "-" + _PlatformExt;
|
BuildArt = "https://ci.appveyor.com/api/buildjobs/" + _jobid + "/artifacts/ryujinx-" + _buildver + "-" + _platformext;
|
||||||
_BuildCommit = __BuildCommit.Substring(0, 7);
|
_buildcommit = __buildcommit.Substring(0, 7);
|
||||||
_Branch = __Branch;
|
_branch = __branch;
|
||||||
Logger.PrintInfo(LogClass.Application, "Fetched JSON and Parsed:" + Environment.NewLine + "MetaData: JobID(" + __JobsID + ") BuildVer(" + __Version + ")" + Environment.NewLine + "BuildURL(" + _BuildArt + ")");
|
Logger.PrintInfo(LogClass.Application, "Fetched JSON and Parsed:" + Environment.NewLine + "MetaData: JobID(" + __JobsID + ") BuildVer(" + __Version + ")" + Environment.NewLine + "BuildURL(" + BuildArt + ")");
|
||||||
Logger.PrintInfo(LogClass.Application, "Commit-id: (" + _BuildCommit + ")" + " Branch: (" + _Branch + ")");
|
Logger.PrintInfo(LogClass.Application, "Commit-id: (" + _buildcommit + ")" + " Branch: (" + _branch + ")");
|
||||||
|
|
||||||
using (MessageDialog dialog = GtkDialog.CreateAcceptDialog("Update", _BuildVer))
|
using (MessageDialog dialog = GtkDialog.CreateAcceptDialog("Update", _buildver))
|
||||||
{
|
{
|
||||||
if (dialog.Run() == (int)ResponseType.Yes)
|
if (dialog.Run() == (int)ResponseType.Yes)
|
||||||
{
|
{
|
||||||
|
@ -77,31 +78,31 @@ namespace Ryujinx.Updater.Parser
|
||||||
}
|
}
|
||||||
//UpdateData data = new UpdateData()
|
//UpdateData data = new UpdateData()
|
||||||
//{
|
//{
|
||||||
// JobID = _JobID,
|
// JobID = _jobid,
|
||||||
// BuildVer = _BuildVer,
|
// BuildVer = _buildver,
|
||||||
// BuildURL = _BuildURL,
|
// BuildURL = _buildurl,
|
||||||
// BuildArt = _BuildArt,
|
// BuildArt = BuildArt,
|
||||||
// BuildCommit = _BuildCommit,
|
// BuildCommit = _buildcommit,
|
||||||
// Branch = _Branch
|
// Branch = _branch
|
||||||
//};
|
//};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async void GrabPackage()
|
private static async void GrabPackage()
|
||||||
{
|
{
|
||||||
//Check if paths exist
|
//Check if paths exist
|
||||||
if (!Directory.Exists(Path.Combine(_RyuDir, "Data", "Update")) || !Directory.Exists(Path.Combine(_RyuDir, "Data")) || !Directory.Exists(Path.Combine(Environment.CurrentDirectory, "temp")))
|
if (!Directory.Exists(Path.Combine(RyuDir, "Data", "Update")) || !Directory.Exists(Path.Combine(RyuDir, "Data")) || !Directory.Exists(Path.Combine(Environment.CurrentDirectory, "temp")))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.Combine(_RyuDir, "Data", "Update"));
|
Directory.CreateDirectory(Path.Combine(RyuDir, "Data", "Update"));
|
||||||
Directory.CreateDirectory(Path.Combine(_RyuDir, "Data"));
|
Directory.CreateDirectory(Path.Combine(RyuDir, "Data"));
|
||||||
Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "temp"));
|
Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "temp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Attempt to grab the latest package
|
//Attempt to grab the latest package
|
||||||
_Package.DownloadProgressChanged += new DownloadProgressChangedEventHandler(PackageDownloadProgress);
|
Package.DownloadProgressChanged += new DownloadProgressChangedEventHandler(PackageDownloadProgress);
|
||||||
_Package.DownloadFileCompleted += new AsyncCompletedEventHandler(PackageDownloadedAsync);
|
Package.DownloadFileCompleted += new AsyncCompletedEventHandler(PackageDownloadedAsync);
|
||||||
using (MessageDialog dialog = GtkDialog.CreateProgressDialog("Update", "Ryujinx - Update", "Downloading update " + _BuildVer, "Please wait while we download the latest package and extract it."))
|
using (MessageDialog dialog = GtkDialog.CreateProgressDialog("Update", "Ryujinx - Update", "Downloading update " + _buildver, "Please wait while we download the latest package and extract it."))
|
||||||
{
|
{
|
||||||
dialog.Run();
|
dialog.Run();
|
||||||
}
|
}
|
||||||
|
@ -130,15 +131,15 @@ namespace Ryujinx.Updater.Parser
|
||||||
|
|
||||||
private static void PackageDownloadProgress(object sender, DownloadProgressChangedEventArgs e)
|
private static void PackageDownloadProgress(object sender, DownloadProgressChangedEventArgs e)
|
||||||
{
|
{
|
||||||
_Percentage = e.ProgressPercentage;
|
Percentage = e.ProgressPercentage;
|
||||||
_PackageProgress = e.ProgressPercentage;
|
PackageProgress = e.ProgressPercentage;
|
||||||
}
|
}
|
||||||
public static async Task ExtractPackageAsync()
|
public static async Task ExtractPackageAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Begin the extaction process
|
//Begin the extaction process
|
||||||
using (Ionic.Zip.ZipFile Package = Ionic.Zip.ZipFile.Read(Path.Combine(_RyuDir, "Data", "Update", "RyujinxPackage.zip")))
|
using (Ionic.Zip.ZipFile Package = Ionic.Zip.ZipFile.Read(Path.Combine(RyuDir, "Data", "Update", "RyujinxPackage.zip")))
|
||||||
{
|
{
|
||||||
await Task.Run(() => Package.ExtractAll(Path.Combine(Environment.CurrentDirectory,"temp"), ExtractExistingFileAction.OverwriteSilently));
|
await Task.Run(() => Package.ExtractAll(Path.Combine(Environment.CurrentDirectory,"temp"), ExtractExistingFileAction.OverwriteSilently));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ namespace Ryujinx.Updater
|
||||||
{
|
{
|
||||||
public class Update
|
public class Update
|
||||||
{
|
{
|
||||||
|
private static string[] _updatefiles = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory),"*", SearchOption.AllDirectories);
|
||||||
|
private static string _parentdir = Path.Combine(@"..\..");
|
||||||
public static string RyuDir = Environment.CurrentDirectory;
|
public static string RyuDir = Environment.CurrentDirectory;
|
||||||
private static string[] UpdateFiles = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory),"*", SearchOption.AllDirectories);
|
|
||||||
private static string ParentDir = Path.Combine(@"..\..");
|
|
||||||
public static void PerformUpdate()
|
public static void PerformUpdate()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -21,15 +21,15 @@ namespace Ryujinx.Updater
|
||||||
//Get list of files from the current directory, and copy them to the parent directory.
|
//Get list of files from the current directory, and copy them to the parent directory.
|
||||||
foreach (string _PathDir in Directory.GetDirectories(RyuDir, "*",
|
foreach (string _PathDir in Directory.GetDirectories(RyuDir, "*",
|
||||||
SearchOption.AllDirectories))
|
SearchOption.AllDirectories))
|
||||||
Directory.CreateDirectory(_PathDir.Replace(RyuDir, ParentDir));
|
Directory.CreateDirectory(_PathDir.Replace(RyuDir, _parentdir));
|
||||||
foreach (string _PathNew in Directory.GetFiles(RyuDir, "*.*",
|
foreach (string _PathNew in Directory.GetFiles(RyuDir, "*.*",
|
||||||
SearchOption.AllDirectories))
|
SearchOption.AllDirectories))
|
||||||
File.Copy(_PathNew, _PathNew.Replace(RyuDir, ParentDir), true);
|
File.Copy(_PathNew, _PathNew.Replace(RyuDir, _parentdir), true);
|
||||||
Logger.PrintInfo(LogClass.Application, "Package installation was completed.\n");
|
Logger.PrintInfo(LogClass.Application, "Package installation was completed.\n");
|
||||||
GtkDialog.CreateInfoDialog("Update", "Ryujinx - Update", "Almost finished","The package was installed.\nPlease click ok, and the update will complete.");
|
GtkDialog.CreateInfoDialog("Update", "Ryujinx - Update", "Almost finished","The package was installed.\nPlease click ok, and the update will complete.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.Start(new ProcessStartInfo(Path.Combine(ParentDir, "Ryujinx.exe"), "/C") { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo(Path.Combine(_parentdir, "Ryujinx.exe"), "/C") { UseShellExecute = true });
|
||||||
}
|
}
|
||||||
catch (System.ComponentModel.Win32Exception)
|
catch (System.ComponentModel.Win32Exception)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue