2020-09-29 22:05:25 +02:00
|
|
|
using Gdk;
|
|
|
|
using Gtk;
|
2021-01-08 09:14:13 +01:00
|
|
|
using Ryujinx.Ui;
|
2022-05-15 13:30:15 +02:00
|
|
|
using Ryujinx.Ui.Common.Configuration;
|
2022-11-13 00:36:36 +01:00
|
|
|
using Ryujinx.Ui.Common.Helper;
|
2020-09-29 22:05:25 +02:00
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
2021-02-08 00:27:12 +01:00
|
|
|
using System.Reflection;
|
2020-09-29 22:05:25 +02:00
|
|
|
|
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
|
|
|
|
2022-12-06 23:00:25 +01:00
|
|
|
private UpdateDialog(Builder builder, MainWindow mainWindow, Version newVersion, string buildUrl) : base(builder.GetRawOwnedObject("UpdateDialog"))
|
2020-09-29 22:05:25 +02:00
|
|
|
{
|
|
|
|
builder.Autoconnect(this);
|
|
|
|
|
|
|
|
_mainWindow = mainWindow;
|
|
|
|
_buildUrl = buildUrl;
|
|
|
|
|
2022-05-15 13:30:15 +02:00
|
|
|
Icon = new Gdk.Pixbuf(Assembly.GetAssembly(typeof(ConfigurationState)), "Ryujinx.Ui.Common.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)
|
|
|
|
{
|
2021-12-05 00:02:30 +01:00
|
|
|
string ryuName = OperatingSystem.IsWindows() ? "Ryujinx.exe" : "Ryujinx";
|
2020-09-29 22:05:25 +02:00
|
|
|
string ryuExe = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ryuName);
|
|
|
|
|
2022-11-13 00:36:36 +01:00
|
|
|
Process.Start(ryuExe, CommandLineState.Arguments);
|
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
|
|
|
}
|
|
|
|
}
|
2022-11-13 00:36:36 +01:00
|
|
|
}
|