This commit is contained in:
DrHacknik 2020-01-22 17:54:08 -05:00 committed by Ash
parent 41d4dbe30f
commit ce5f4b2a91
4 changed files with 62 additions and 12 deletions

View file

@ -64,9 +64,22 @@ namespace Ryujinx
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
if (args.Length == 1)
if (args.Length > 0)
{
mainWindow.LoadApplication(args[0]);
foreach (string arg in args)
{
switch (arg.Substring(0, 2).ToUpper())
{
case "/U":
//Do that update stuffs
Updater.Update.PerformUpdate();
return;
default:
mainWindow.LoadApplication(args[0]);
break;
}
}
}
Application.Run();

View file

@ -76,6 +76,7 @@
<PackageReference Include="DiscordRichPresence" Version="1.0.147" />
<PackageReference Include="GLWidget" Version="1.0.0" />
<PackageReference Include="GtkSharp" Version="3.22.25.56" />
<PackageReference Include="DotNetZip" Version="1.13.5" />
<PackageReference Include="GtkSharp.Dependencies" Version="1.1.0" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'osx-x64'" />
<PackageReference Include="OpenTK.NetStandard" Version="1.0.5.12" />
</ItemGroup>

View file

@ -1,10 +1,13 @@
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;
@ -25,7 +28,6 @@ namespace Ryujinx.Updater.Parser
private static string _PlatformExt;
public static string _RyuDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
public static WebClient _Package = new WebClient();
private static string _URLStr;
public static int _PackageProgress;
public static double _Percentage;
public static void BeginParse()
@ -85,20 +87,22 @@ namespace Ryujinx.Updater.Parser
private static async void GrabPackage()
{
if (!Directory.Exists(Path.Combine(_RyuDir, "Data", "Update")) || !Directory.Exists(Path.Combine(_RyuDir, "Data")))
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"));
Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "temp"));
}
try
{
_Package.DownloadProgressChanged += new DownloadProgressChangedEventHandler(PackageDownloadProgress);
_Package.DownloadFileCompleted += new AsyncCompletedEventHandler(PackageDownloadedAsync);
using (MessageDialog dialog = await GtkDialog.CreateProgressDialogAsync(false, "Update", "Ryujinx - Update", "Downloading update " + _BuildVer + ", 0% complete...", "Please wait while we download the latest package"))
using (MessageDialog dialog = await GtkDialog.CreateProgressDialogAsync(false, "Update", "Ryujinx - Update", "Downloading update " + _BuildVer, "Please wait while we download the latest package"))
{
dialog.Run();
}
}
catch (Exception ex)
{
@ -119,9 +123,9 @@ namespace Ryujinx.Updater.Parser
Logger.PrintWarning(LogClass.Application, "Package is now installing");
using (MessageDialog dialog = await GtkDialog.CreateProgressDialogAsync(true, "Update", "Ryujinx - Update", "Installing update " + _BuildVer + "...", "Please wait while we install the latest package"))
{
dialog.Dispose();
dialog.Run();
}
return;
}
}
@ -134,11 +138,21 @@ namespace Ryujinx.Updater.Parser
{
try
{
//using (ZipFile Package = ZipFile.Read(Path.Combine(_RyuDir, "Data", "Update", "RyujinxPackage.zip")))
//{
// await Task.Run(() => Package.ExtractAll(_InstallDir, ExtractExistingFileAction.OverwriteSilently));
//}
throw new Exception("This is a test exception.\nThis is the package extract thread.");
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));
}
try
{
Process.Start(new ProcessStartInfo(Path.Combine(Environment.CurrentDirectory, "temp", "Ryujinx.exe"), "/U") { UseShellExecute = true });
}
catch (System.ComponentModel.Win32Exception)
{
GtkDialog.CreateErrorDialog("Update canceled by user or the installation was not found");
return;
}
Application.Quit();
}
catch (Exception ex)
{
@ -148,4 +162,4 @@ namespace Ryujinx.Updater.Parser
}
}
}
}
}

22
Ryujinx/Updater/Update.cs Normal file
View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Ryujinx.Updater
{
public class Update
{
public static string _RyuDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
public static void PerformUpdate()
{
return;
}
private void Cleanup()
{
return;
}
}
}