2022-05-15 07:30:15 -04:00
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using Ryujinx.Ava.Common.Locale;
|
|
|
|
using Ryujinx.Modules;
|
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
namespace Ryujinx.Ava.Ui.Windows
|
|
|
|
{
|
2022-07-24 13:38:38 -04:00
|
|
|
public partial class UpdaterWindow : StyleableWindow
|
2022-05-15 07:30:15 -04:00
|
|
|
{
|
|
|
|
private readonly string _buildUrl;
|
|
|
|
private readonly MainWindow _mainWindow;
|
|
|
|
private readonly Version _newVersion;
|
|
|
|
private bool _restartQuery;
|
|
|
|
|
|
|
|
public UpdaterWindow()
|
|
|
|
{
|
|
|
|
DataContext = this;
|
|
|
|
|
|
|
|
InitializeComponent();
|
2022-07-28 18:41:34 -04:00
|
|
|
|
2022-05-15 07:30:15 -04:00
|
|
|
Title = LocaleManager.Instance["RyujinxUpdater"];
|
|
|
|
}
|
|
|
|
|
|
|
|
public UpdaterWindow(MainWindow mainWindow, Version newVersion, string buildUrl) : this()
|
|
|
|
{
|
|
|
|
_mainWindow = mainWindow;
|
|
|
|
_newVersion = newVersion;
|
|
|
|
_buildUrl = buildUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
[DllImport("libc", SetLastError = true)]
|
|
|
|
private static extern int chmod(string path, uint mode);
|
|
|
|
|
|
|
|
public void YesPressed()
|
|
|
|
{
|
|
|
|
if (_restartQuery)
|
|
|
|
{
|
2022-07-05 14:06:31 -04:00
|
|
|
string ryuName = OperatingSystem.IsWindows() ? "Ryujinx.Ava.exe" : "Ryujinx.Ava";
|
2022-05-15 07:30:15 -04:00
|
|
|
string ryuExe = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ryuName);
|
|
|
|
string ryuArg = string.Join(" ", Environment.GetCommandLineArgs().AsEnumerable().Skip(1).ToArray());
|
|
|
|
|
|
|
|
if (!OperatingSystem.IsWindows())
|
|
|
|
{
|
|
|
|
chmod(ryuExe, 0777);
|
|
|
|
}
|
|
|
|
|
|
|
|
Process.Start(ryuExe, ryuArg);
|
|
|
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ButtonBox.IsVisible = false;
|
|
|
|
ProgressBar.IsVisible = true;
|
|
|
|
|
|
|
|
SecondaryText.Text = "";
|
|
|
|
_restartQuery = true;
|
|
|
|
|
|
|
|
Updater.UpdateRyujinx(this, _buildUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NoPressed()
|
|
|
|
{
|
|
|
|
_mainWindow.UpdateMenuItem.IsEnabled = true;
|
|
|
|
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|