2020-09-29 16:05:25 -04:00
|
|
|
using Gdk;
|
|
|
|
using Gtk;
|
2021-01-08 03:14:13 -05:00
|
|
|
using Ryujinx.Ui;
|
2022-05-15 07:30:15 -04:00
|
|
|
using Ryujinx.Ui.Common.Configuration;
|
2022-11-12 18:36:36 -05:00
|
|
|
using Ryujinx.Ui.Common.Helper;
|
2020-09-29 16:05:25 -04:00
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
2021-02-07 18:27:12 -05:00
|
|
|
using System.Reflection;
|
2020-09-29 16:05:25 -04:00
|
|
|
|
2021-01-08 03:14:13 -05:00
|
|
|
namespace Ryujinx.Modules
|
2020-09-29 16:05:25 -04:00
|
|
|
{
|
|
|
|
public class UpdateDialog : Gtk.Window
|
|
|
|
{
|
|
|
|
#pragma warning disable CS0649, IDE0044
|
2021-01-08 03:14:13 -05:00
|
|
|
[Builder.Object] public Label MainText;
|
|
|
|
[Builder.Object] public Label SecondaryText;
|
2020-09-29 16:05:25 -04:00
|
|
|
[Builder.Object] public LevelBar ProgressBar;
|
2021-01-08 03:14:13 -05:00
|
|
|
[Builder.Object] public Button YesButton;
|
|
|
|
[Builder.Object] public Button NoButton;
|
2020-09-29 16:05:25 -04:00
|
|
|
#pragma warning restore CS0649, IDE0044
|
|
|
|
|
|
|
|
private readonly MainWindow _mainWindow;
|
2021-01-08 03:14:13 -05:00
|
|
|
private readonly string _buildUrl;
|
|
|
|
private bool _restartQuery;
|
2020-09-29 16:05:25 -04:00
|
|
|
|
2021-01-10 12:20:10 -05:00
|
|
|
public UpdateDialog(MainWindow mainWindow, Version newVersion, string buildUrl) : this(new Builder("Ryujinx.Modules.Updater.UpdateDialog.glade"), mainWindow, newVersion, buildUrl) { }
|
2020-09-29 16:05:25 -04:00
|
|
|
|
2022-12-06 17:00:25 -05:00
|
|
|
private UpdateDialog(Builder builder, MainWindow mainWindow, Version newVersion, string buildUrl) : base(builder.GetRawOwnedObject("UpdateDialog"))
|
2020-09-29 16:05:25 -04:00
|
|
|
{
|
|
|
|
builder.Autoconnect(this);
|
|
|
|
|
|
|
|
_mainWindow = mainWindow;
|
|
|
|
_buildUrl = buildUrl;
|
|
|
|
|
2022-05-15 07:30:15 -04:00
|
|
|
Icon = new Gdk.Pixbuf(Assembly.GetAssembly(typeof(ConfigurationState)), "Ryujinx.Ui.Common.Resources.Logo_Ryujinx.png");
|
2020-09-29 16:05:25 -04:00
|
|
|
MainText.Text = "Do you want to update Ryujinx to the latest version?";
|
|
|
|
SecondaryText.Text = $"{Program.Version} -> {newVersion}";
|
|
|
|
|
|
|
|
ProgressBar.Hide();
|
|
|
|
|
2021-01-08 03:14:13 -05:00
|
|
|
YesButton.Clicked += YesButton_Clicked;
|
|
|
|
NoButton.Clicked += NoButton_Clicked;
|
2020-09-29 16:05:25 -04:00
|
|
|
}
|
2021-02-24 18:35:48 -05:00
|
|
|
|
2021-01-08 03:14:13 -05:00
|
|
|
private void YesButton_Clicked(object sender, EventArgs args)
|
2020-09-29 16:05:25 -04:00
|
|
|
{
|
|
|
|
if (_restartQuery)
|
|
|
|
{
|
2021-12-04 18:02:30 -05:00
|
|
|
string ryuName = OperatingSystem.IsWindows() ? "Ryujinx.exe" : "Ryujinx";
|
2020-09-29 16:05:25 -04:00
|
|
|
string ryuExe = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ryuName);
|
|
|
|
|
2022-11-12 18:36:36 -05:00
|
|
|
Process.Start(ryuExe, CommandLineState.Arguments);
|
2020-09-29 16:05:25 -04:00
|
|
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-08 03:14:13 -05:00
|
|
|
Window.Functions = _mainWindow.Window.Functions = WMFunction.All & WMFunction.Close;
|
2020-09-29 16:05:25 -04:00
|
|
|
_mainWindow.ExitMenuItem.Sensitive = false;
|
|
|
|
|
|
|
|
YesButton.Hide();
|
|
|
|
NoButton.Hide();
|
|
|
|
ProgressBar.Show();
|
|
|
|
|
|
|
|
SecondaryText.Text = "";
|
|
|
|
_restartQuery = true;
|
|
|
|
|
2021-02-22 15:48:45 -05:00
|
|
|
Updater.UpdateRyujinx(this, _buildUrl);
|
2020-09-29 16:05:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-08 03:14:13 -05:00
|
|
|
private void NoButton_Clicked(object sender, EventArgs args)
|
2020-09-29 16:05:25 -04:00
|
|
|
{
|
|
|
|
Updater.Running = false;
|
|
|
|
_mainWindow.Window.Functions = WMFunction.All;
|
|
|
|
|
|
|
|
_mainWindow.ExitMenuItem.Sensitive = true;
|
|
|
|
_mainWindow.UpdateMenuItem.Sensitive = true;
|
|
|
|
|
2021-01-08 03:14:13 -05:00
|
|
|
Dispose();
|
2020-09-29 16:05:25 -04:00
|
|
|
}
|
|
|
|
}
|
2022-11-12 18:36:36 -05:00
|
|
|
}
|