Fixed all the reviewer's complains
This commit is contained in:
parent
4ead6bca86
commit
8e75c2952d
6 changed files with 90 additions and 128 deletions
|
@ -54,7 +54,7 @@ namespace Ryujinx
|
|||
|
||||
Application.Init();
|
||||
|
||||
string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx", "system", "prod.keys");
|
||||
string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx", "system", "prod.keys");
|
||||
string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys");
|
||||
if (!File.Exists(appDataPath) && !File.Exists(userProfilePath) && !Migration.IsMigrationNeeded())
|
||||
{
|
||||
|
@ -64,26 +64,17 @@ namespace Ryujinx
|
|||
MainWindow mainWindow = new MainWindow();
|
||||
mainWindow.Show();
|
||||
|
||||
if (args.Length == 1)
|
||||
if (args.Length > 1)
|
||||
{
|
||||
foreach (string arg in args)
|
||||
{
|
||||
switch (arg.Substring(0, 2).ToUpper())
|
||||
{
|
||||
case "/U":
|
||||
//Do that update stuffs
|
||||
Updater.Update.PerformUpdate();
|
||||
break;
|
||||
case "/C":
|
||||
//Do that update stuffs
|
||||
Updater.Update.Cleanup();
|
||||
break;
|
||||
default:
|
||||
mainWindow.LoadApplication(args[0]);
|
||||
break;
|
||||
case "/U": Updater.Update.PerformUpdate(); break;
|
||||
case "/C": Updater.Update.Cleanup(); break;
|
||||
default: mainWindow.LoadApplication(args[0]); break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Application.Run();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using Gtk;
|
||||
using System.Reflection;
|
||||
using Ryujinx.Updater.Parser;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ryujinx.Ui
|
||||
{
|
||||
|
@ -23,24 +23,14 @@ namespace Ryujinx.Ui
|
|||
errorDialog.Dispose();
|
||||
}
|
||||
|
||||
internal static void CreateWarningDialog(string text, string secondaryText)
|
||||
{
|
||||
CreateDialog("Ryujinx - Warning", text, secondaryText);
|
||||
}
|
||||
|
||||
internal static void CreateErrorDialog(string errorMessage)
|
||||
{
|
||||
CreateDialog("Ryujinx - Error", "Ryujinx has encountered an error", errorMessage);
|
||||
}
|
||||
|
||||
internal static MessageDialog CreateAcceptDialog(string iconType, string acceptMessage)
|
||||
internal static MessageDialog CreateAcceptDialog(string iconType, string titleMessage, string textMessage, string secText)
|
||||
{
|
||||
MessageDialog messageDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, null)
|
||||
{
|
||||
Title = "Ryujinx - Update",
|
||||
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Update.png"),
|
||||
Text = "Would you like to update?",
|
||||
SecondaryText = "Version " + acceptMessage + " is available.",
|
||||
Title = titleMessage,
|
||||
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), $"Ryujinx.Ui.assets.{iconType}.png"),
|
||||
Text = textMessage,
|
||||
SecondaryText = secText,
|
||||
WindowPosition = WindowPosition.Center
|
||||
};
|
||||
messageDialog.SetSizeRequest(100, 20);
|
||||
|
@ -52,7 +42,7 @@ namespace Ryujinx.Ui
|
|||
MessageDialog messageDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, null)
|
||||
{
|
||||
Title = titleMessage,
|
||||
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets." + iconType +".png"),
|
||||
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), $"Ryujinx.Ui.assets.{iconType}.png"),
|
||||
Text = textMessage,
|
||||
SecondaryText = secText,
|
||||
WindowPosition = WindowPosition.Center
|
||||
|
@ -66,7 +56,7 @@ namespace Ryujinx.Ui
|
|||
MessageDialog messageDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.None, null)
|
||||
{
|
||||
Title = titleMessage,
|
||||
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets." + iconType + ".png"),
|
||||
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), $"Ryujinx.Ui.assets.{iconType}.png"),
|
||||
Text = textMessage,
|
||||
SecondaryText = secText,
|
||||
WindowPosition = WindowPosition.Center
|
||||
|
@ -74,6 +64,7 @@ namespace Ryujinx.Ui
|
|||
Uri URL = new Uri(UpdateParser.BuildArt);
|
||||
UpdateParser.Package.DownloadFileAsync(URL, Path.Combine(UpdateParser.RyuDir, "Data", "Update", "RyujinxPackage.zip"));
|
||||
messageDialog.SetSizeRequest(100, 20);
|
||||
|
||||
return messageDialog;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Gtk;
|
||||
using JsonPrettyPrinterPlus;
|
||||
using Ryujinx.Audio;
|
||||
using Ryujinx.Updater.Parser;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Configuration;
|
||||
using Ryujinx.Debugger.Profiler;
|
||||
|
@ -896,7 +897,7 @@ namespace Ryujinx.Ui
|
|||
|
||||
private void Update_Pressed(object sender, EventArgs args)
|
||||
{
|
||||
Ryujinx.Updater.Parser.UpdateParser.BeginParse();
|
||||
UpdateParser.BeginParse();
|
||||
}
|
||||
|
||||
private void About_Pressed(object sender, EventArgs args)
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
using Gtk;
|
||||
using Ionic.Zip;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.Ui;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZipFile = System.IO.Compression.ZipFile;
|
||||
|
||||
namespace Ryujinx.Updater.Parser
|
||||
{
|
||||
|
@ -22,46 +17,62 @@ namespace Ryujinx.Updater.Parser
|
|||
{
|
||||
private static string _jobid;
|
||||
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";
|
||||
private static string _buildcommit;
|
||||
private static string _branch;
|
||||
private static string _platformext;
|
||||
|
||||
public static string BuildArt;
|
||||
public static string RyuDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
|
||||
public static WebClient Package = new WebClient();
|
||||
public static int PackageProgress;
|
||||
public static double Percentage;
|
||||
public static string BuildArt;
|
||||
public static string RyuDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
|
||||
public static WebClient Package = new WebClient();
|
||||
public static int PackageProgress;
|
||||
public static double Percentage;
|
||||
|
||||
public static void BeginParse()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Detect current platform
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
_platformext = "osx_x64.zip";
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
_platformext = "win_x64.zip";
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
_platformext = "linux_x64.tar.gz";
|
||||
// Detect current platform
|
||||
|
||||
if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
_platformext = "osx_x64.zip";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
_platformext = "win_x64.zip";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
_platformext = "linux_x64.tar.gz";
|
||||
}
|
||||
}
|
||||
|
||||
// Begin the Appveyor parsing
|
||||
|
||||
WebClient jsonClient = new WebClient();
|
||||
string fetchedJSON = jsonClient.DownloadString(_buildurl);
|
||||
JObject jsonRoot = JObject.Parse(fetchedJSON);
|
||||
|
||||
var __Build = jsonRoot["build"];
|
||||
|
||||
string __Version = (string)__Build["version"];
|
||||
string __JobsID = (string)__Build["jobs"][0]["jobId"];
|
||||
string __branch = (string)__Build["branch"];
|
||||
string __buildcommit = (string)__Build["commitId"];
|
||||
|
||||
_jobid = __JobsID;
|
||||
_buildver = __Version;
|
||||
BuildArt = "https://ci.appveyor.com/api/buildjobs/" + _jobid + "/artifacts/ryujinx-" + _buildver + "-" + _platformext;
|
||||
_buildcommit = __buildcommit.Substring(0, 7);
|
||||
_branch = __branch;
|
||||
|
||||
//Begin the Appveyor parsing
|
||||
WebClient JSONClient = new WebClient();
|
||||
string FetchedJSON = JSONClient.DownloadString(_buildurl);
|
||||
var __JSONRoot = JObject.Parse(FetchedJSON);
|
||||
var __Build = __JSONRoot["build"];
|
||||
string __Version = (string)__Build["version"];
|
||||
string __JobsID = (string)__Build["jobs"][0]["jobId"];
|
||||
string __branch = (string)__Build["branch"];
|
||||
string __buildcommit = (string)__Build["commitId"];
|
||||
_jobid = __JobsID;
|
||||
_buildver = __Version;
|
||||
BuildArt = "https://ci.appveyor.com/api/buildjobs/" + _jobid + "/artifacts/ryujinx-" + _buildver + "-" + _platformext;
|
||||
_buildcommit = __buildcommit.Substring(0, 7);
|
||||
_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, "Commit-id: (" + _buildcommit + ")" + " Branch: (" + _branch + ")");
|
||||
|
||||
using (MessageDialog dialog = GtkDialog.CreateAcceptDialog("Update", _buildver))
|
||||
using (MessageDialog dialog = GtkDialog.CreateAcceptDialog("Update", "Ryujinx - Update", "Would you like to update?", "Version " + _buildver + " is available."))
|
||||
{
|
||||
if (dialog.Run() == (int)ResponseType.Yes)
|
||||
{
|
||||
|
@ -69,28 +80,19 @@ namespace Ryujinx.Updater.Parser
|
|||
GrabPackage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.PrintError(LogClass.Application, ex.Message);
|
||||
GtkDialog.CreateErrorDialog("Update canceled by user or failed to grab or parse the information.\nPlease try at a later time, or report the error to our GitHub.");
|
||||
return;
|
||||
}
|
||||
//UpdateData data = new UpdateData()
|
||||
//{
|
||||
// JobID = _jobid,
|
||||
// BuildVer = _buildver,
|
||||
// BuildURL = _buildurl,
|
||||
// BuildArt = BuildArt,
|
||||
// BuildCommit = _buildcommit,
|
||||
// Branch = _branch
|
||||
//};
|
||||
}
|
||||
|
||||
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")))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(RyuDir, "Data", "Update"));
|
||||
|
@ -100,7 +102,8 @@ namespace Ryujinx.Updater.Parser
|
|||
|
||||
try
|
||||
{
|
||||
//Attempt to grab the latest package
|
||||
// Attempt to grab the latest package
|
||||
|
||||
Package.DownloadProgressChanged += new DownloadProgressChangedEventHandler(PackageDownloadProgress);
|
||||
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."))
|
||||
|
@ -112,21 +115,19 @@ namespace Ryujinx.Updater.Parser
|
|||
{
|
||||
Logger.PrintError(LogClass.Application, ex.InnerException.ToString());
|
||||
GtkDialog.CreateErrorDialog(ex.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static async void PackageDownloadedAsync(object sender, AsyncCompletedEventArgs e)
|
||||
{
|
||||
if (e.Cancelled == true)
|
||||
{
|
||||
Logger.PrintError(LogClass.Application, "Package download failed or cancelled");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.PrintWarning(LogClass.Application, "Package is now installing");
|
||||
await ExtractPackageAsync();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,30 +136,34 @@ namespace Ryujinx.Updater.Parser
|
|||
Percentage = e.ProgressPercentage;
|
||||
PackageProgress = e.ProgressPercentage;
|
||||
}
|
||||
|
||||
public static async Task ExtractPackageAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Begin the extaction process
|
||||
// Begin the extaction process
|
||||
|
||||
await Task.Run(() => ZipFile.ExtractToDirectory(Path.Combine(RyuDir, "Data", "Update", "RyujinxPackage.zip"), Path.Combine(Environment.CurrentDirectory, "temp")));
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(Path.Combine(Environment.CurrentDirectory, "temp", "publish", "Ryujinx.exe"), "/U") { UseShellExecute = true });
|
||||
Application.Quit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GtkDialog.CreateErrorDialog("Package installation has failed\nCheck the log for more information.");
|
||||
Logger.PrintError(LogClass.Application, "Package installation has failed\n" + ex.InnerException.ToString());
|
||||
|
||||
return;
|
||||
}
|
||||
Application.Quit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.PrintError(LogClass.Application, "Package installation has failed\n" + ex.InnerException.ToString());
|
||||
GtkDialog.CreateErrorDialog("Package installation has failed\nCheck the log for more information.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -11,38 +11,41 @@ namespace Ryujinx.Updater
|
|||
{
|
||||
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 void PerformUpdate()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Get list of files from the current directory, and copy them to the parent directory.
|
||||
foreach (string _PathDir in Directory.GetDirectories(RyuDir, "*",
|
||||
SearchOption.AllDirectories))
|
||||
foreach (string _PathDir in Directory.GetDirectories(RyuDir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
Directory.CreateDirectory(_PathDir.Replace(RyuDir, _parentdir));
|
||||
foreach (string _PathNew in Directory.GetFiles(RyuDir, "*.*",
|
||||
SearchOption.AllDirectories))
|
||||
}
|
||||
|
||||
foreach (string _PathNew in Directory.GetFiles(RyuDir, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
File.Copy(_PathNew, _PathNew.Replace(RyuDir, _parentdir), true);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(Path.Combine(_parentdir, "Ryujinx.exe"), "/C") { UseShellExecute = true });
|
||||
Application.Quit();
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
GtkDialog.CreateErrorDialog("Update canceled by user or the installation was not found");
|
||||
return;
|
||||
GtkDialog.CreateErrorDialog(ex.Message);
|
||||
}
|
||||
Application.Quit();
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
GtkDialog.CreateErrorDialog("Package installation has failed\nCheck the log for more information.");
|
||||
GtkDialog.CreateErrorDialog(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void Cleanup()
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/* =========================================
|
||||
* This service is responsible for parsing
|
||||
* the appveyor json.
|
||||
*
|
||||
* =========================================
|
||||
*
|
||||
* Strings and other variables: These are stored for the config page.
|
||||
*
|
||||
* JobID: String, stores the parsed JobID.
|
||||
* BuildVer: String, stores the parsed BuildVersion.
|
||||
* BuildURL: String, stores the BuildURL.
|
||||
* BuildArt: String, stores the parsed build artifact (URL).
|
||||
* BuildCommit: String, stores the parsed build commit; and is stored in a five character substring.
|
||||
* Branch: String, stores the parsed branch for the build.
|
||||
* =========================================
|
||||
*/
|
||||
|
||||
namespace Ryujinx.Updater
|
||||
{
|
||||
public struct UpdateData
|
||||
{
|
||||
public string JobID { get; set; }
|
||||
public string BuildVer { get; set; }
|
||||
public string BuildURL { get; set; }
|
||||
public string BuildArt { get; set; }
|
||||
public string BuildCommit { get; set; }
|
||||
public string Branch { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue