mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-11-28 11:50:50 +01:00
4e26aed816
* Use multiple threads to download different chunks of an update simultaneously. This reduces time to complete the download significantly. * Remove dirty-flag check (for test purposes) * Clean up updater code. * Include fallback to single-threaded updater if mt fails * Reduce connection count to 4. * Improve fallback on error. Correct issue where data was missing during download due to total build size not being cleanly divisble by the connection count. Cleaned up unnecessary code. * Add missing return statements * Fix alignment * Alignment * More alignment * Rely on content-range request instead of xml/json size property. * Re-instate dirty checking and version checking to move into review stage. * Address comments * Address comments * Comments * Comments * Final...? * final final * final final final nit * Use Array.Copy as requested by rip * Updated some names for clarity. * Move addition into for loop (to shorten line width) * Add missing semicolon -- forgot to stage :9
92 lines
3.2 KiB
C#
92 lines
3.2 KiB
C#
using Gdk;
|
|
using Gtk;
|
|
using Mono.Unix;
|
|
using Ryujinx.Ui;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Ryujinx.Modules
|
|
{
|
|
public class UpdateDialog : Gtk.Window
|
|
{
|
|
#pragma warning disable CS0649, IDE0044
|
|
[Builder.Object] public Label MainText;
|
|
[Builder.Object] public Label SecondaryText;
|
|
[Builder.Object] public LevelBar ProgressBar;
|
|
[Builder.Object] public Button YesButton;
|
|
[Builder.Object] public Button NoButton;
|
|
#pragma warning restore CS0649, IDE0044
|
|
|
|
private readonly MainWindow _mainWindow;
|
|
private readonly string _buildUrl;
|
|
private bool _restartQuery;
|
|
|
|
public UpdateDialog(MainWindow mainWindow, Version newVersion, string buildUrl) : this(new Builder("Ryujinx.Modules.Updater.UpdateDialog.glade"), mainWindow, newVersion, buildUrl) { }
|
|
|
|
private UpdateDialog(Builder builder, MainWindow mainWindow, Version newVersion, string buildUrl) : base(builder.GetObject("UpdateDialog").Handle)
|
|
{
|
|
builder.Autoconnect(this);
|
|
|
|
_mainWindow = mainWindow;
|
|
_buildUrl = buildUrl;
|
|
|
|
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.Resources.Logo_Ryujinx.png");
|
|
MainText.Text = "Do you want to update Ryujinx to the latest version?";
|
|
SecondaryText.Text = $"{Program.Version} -> {newVersion}";
|
|
|
|
ProgressBar.Hide();
|
|
|
|
YesButton.Clicked += YesButton_Clicked;
|
|
NoButton.Clicked += NoButton_Clicked;
|
|
}
|
|
|
|
private void YesButton_Clicked(object sender, EventArgs args)
|
|
{
|
|
if (_restartQuery)
|
|
{
|
|
string ryuName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Ryujinx.exe" : "Ryujinx";
|
|
string ryuExe = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ryuName);
|
|
string ryuArg = string.Join(" ", Environment.GetCommandLineArgs().AsEnumerable().Skip(1).ToArray());
|
|
|
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
{
|
|
UnixFileInfo unixFileInfo = new UnixFileInfo(ryuExe);
|
|
unixFileInfo.FileAccessPermissions |= FileAccessPermissions.UserExecute;
|
|
}
|
|
|
|
Process.Start(ryuExe, ryuArg);
|
|
|
|
Environment.Exit(0);
|
|
}
|
|
else
|
|
{
|
|
Window.Functions = _mainWindow.Window.Functions = WMFunction.All & WMFunction.Close;
|
|
_mainWindow.ExitMenuItem.Sensitive = false;
|
|
|
|
YesButton.Hide();
|
|
NoButton.Hide();
|
|
ProgressBar.Show();
|
|
|
|
SecondaryText.Text = "";
|
|
_restartQuery = true;
|
|
|
|
Updater.UpdateRyujinx(this, _buildUrl);
|
|
}
|
|
}
|
|
|
|
private void NoButton_Clicked(object sender, EventArgs args)
|
|
{
|
|
Updater.Running = false;
|
|
_mainWindow.Window.Functions = WMFunction.All;
|
|
|
|
_mainWindow.ExitMenuItem.Sensitive = true;
|
|
_mainWindow.UpdateMenuItem.Sensitive = true;
|
|
|
|
Dispose();
|
|
}
|
|
}
|
|
}
|