2020-09-29 22:05:25 +02:00
|
|
|
using Gdk;
|
|
|
|
using Gtk;
|
|
|
|
using Mono.Unix;
|
2021-01-08 09:14:13 +01:00
|
|
|
using Ryujinx.Ui;
|
2020-09-29 22:05:25 +02:00
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
2020-11-06 19:46:22 +01:00
|
|
|
using System.Linq;
|
2021-02-08 00:27:12 +01:00
|
|
|
using System.Reflection;
|
2020-09-29 22:05:25 +02:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
2021-01-08 09:14:13 +01:00
|
|
|
namespace Ryujinx.Modules
|
2020-09-29 22:05:25 +02:00
|
|
|
{
|
|
|
|
public class UpdateDialog : Gtk.Window
|
|
|
|
{
|
|
|
|
#pragma warning disable CS0649, IDE0044
|
2021-01-08 09:14:13 +01:00
|
|
|
[Builder.Object] public Label MainText;
|
|
|
|
[Builder.Object] public Label SecondaryText;
|
2020-09-29 22:05:25 +02:00
|
|
|
[Builder.Object] public LevelBar ProgressBar;
|
2021-01-08 09:14:13 +01:00
|
|
|
[Builder.Object] public Button YesButton;
|
|
|
|
[Builder.Object] public Button NoButton;
|
2020-09-29 22:05:25 +02:00
|
|
|
#pragma warning restore CS0649, IDE0044
|
|
|
|
|
|
|
|
private readonly MainWindow _mainWindow;
|
2021-01-08 09:14:13 +01:00
|
|
|
private readonly string _buildUrl;
|
|
|
|
private bool _restartQuery;
|
2020-09-29 22:05:25 +02:00
|
|
|
|
2021-01-10 18:20:10 +01:00
|
|
|
public UpdateDialog(MainWindow mainWindow, Version newVersion, string buildUrl) : this(new Builder("Ryujinx.Modules.Updater.UpdateDialog.glade"), mainWindow, newVersion, buildUrl) { }
|
2020-09-29 22:05:25 +02:00
|
|
|
|
|
|
|
private UpdateDialog(Builder builder, MainWindow mainWindow, Version newVersion, string buildUrl) : base(builder.GetObject("UpdateDialog").Handle)
|
|
|
|
{
|
|
|
|
builder.Autoconnect(this);
|
|
|
|
|
|
|
|
_mainWindow = mainWindow;
|
|
|
|
_buildUrl = buildUrl;
|
|
|
|
|
2021-02-08 00:27:12 +01:00
|
|
|
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.Resources.Logo_Ryujinx.png");
|
2020-09-29 22:05:25 +02:00
|
|
|
MainText.Text = "Do you want to update Ryujinx to the latest version?";
|
|
|
|
SecondaryText.Text = $"{Program.Version} -> {newVersion}";
|
|
|
|
|
|
|
|
ProgressBar.Hide();
|
|
|
|
|
2021-01-08 09:14:13 +01:00
|
|
|
YesButton.Clicked += YesButton_Clicked;
|
|
|
|
NoButton.Clicked += NoButton_Clicked;
|
2020-09-29 22:05:25 +02:00
|
|
|
}
|
2021-02-25 00:35:48 +01:00
|
|
|
|
2021-01-08 09:14:13 +01:00
|
|
|
private void YesButton_Clicked(object sender, EventArgs args)
|
2020-09-29 22:05:25 +02:00
|
|
|
{
|
|
|
|
if (_restartQuery)
|
|
|
|
{
|
|
|
|
string ryuName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Ryujinx.exe" : "Ryujinx";
|
|
|
|
string ryuExe = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ryuName);
|
2021-01-08 09:14:13 +01:00
|
|
|
string ryuArg = string.Join(" ", Environment.GetCommandLineArgs().AsEnumerable().Skip(1).ToArray());
|
2020-09-29 22:05:25 +02:00
|
|
|
|
2020-10-29 23:07:10 +01:00
|
|
|
Process.Start(ryuExe, ryuArg);
|
2020-09-29 22:05:25 +02:00
|
|
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-08 09:14:13 +01:00
|
|
|
Window.Functions = _mainWindow.Window.Functions = WMFunction.All & WMFunction.Close;
|
2020-09-29 22:05:25 +02:00
|
|
|
_mainWindow.ExitMenuItem.Sensitive = false;
|
|
|
|
|
|
|
|
YesButton.Hide();
|
|
|
|
NoButton.Hide();
|
|
|
|
ProgressBar.Show();
|
|
|
|
|
|
|
|
SecondaryText.Text = "";
|
|
|
|
_restartQuery = true;
|
|
|
|
|
2021-02-22 21:48:45 +01:00
|
|
|
Updater.UpdateRyujinx(this, _buildUrl);
|
2020-09-29 22:05:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-08 09:14:13 +01:00
|
|
|
private void NoButton_Clicked(object sender, EventArgs args)
|
2020-09-29 22:05:25 +02:00
|
|
|
{
|
|
|
|
Updater.Running = false;
|
|
|
|
_mainWindow.Window.Functions = WMFunction.All;
|
|
|
|
|
|
|
|
_mainWindow.ExitMenuItem.Sensitive = true;
|
|
|
|
_mainWindow.UpdateMenuItem.Sensitive = true;
|
|
|
|
|
2021-01-08 09:14:13 +01:00
|
|
|
Dispose();
|
2020-09-29 22:05:25 +02:00
|
|
|
}
|
|
|
|
}
|
2021-02-08 00:27:12 +01:00
|
|
|
}
|