Skip to content

Commit

Permalink
Appveyor Ryujinx Updater (#1403)
Browse files Browse the repository at this point in the history
Co-authored-by: Xpl0itR <[email protected]>
  • Loading branch information
MelonSpeedruns and Xpl0itR authored Sep 29, 2020
1 parent 4f65043 commit a154593
Show file tree
Hide file tree
Showing 16 changed files with 686 additions and 62 deletions.
7 changes: 6 additions & 1 deletion Ryujinx.Common/Configuration/ConfigurationFileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ConfigurationFileFormat
/// <summary>
/// The current version of the file format
/// </summary>
public const int CurrentVersion = 12;
public const int CurrentVersion = 14;

public int Version { get; set; }

Expand Down Expand Up @@ -118,6 +118,11 @@ public class ConfigurationFileFormat
/// </summary>
public bool EnableDiscordIntegration { get; set; }

/// <summary>
/// Checks for updates when Ryujinx starts when enabled
/// </summary>
public bool CheckUpdatesOnStart { get; set; }

/// <summary>
/// Enables or disables Vertical Sync
/// </summary>
Expand Down
18 changes: 18 additions & 0 deletions Ryujinx.Common/Configuration/ConfigurationState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ public GraphicsSection()
/// </summary>
public ReactiveObject<bool> EnableDiscordIntegration { get; private set; }

/// <summary>
/// Checks for updates when Ryujinx starts when enabled
/// </summary>
public ReactiveObject<bool> CheckUpdatesOnStart { get; private set; }

private ConfigurationState()
{
Ui = new UiSection();
Expand All @@ -351,6 +356,7 @@ private ConfigurationState()
Graphics = new GraphicsSection();
Hid = new HidSection();
EnableDiscordIntegration = new ReactiveObject<bool>();
CheckUpdatesOnStart = new ReactiveObject<bool>();
}

public ConfigurationFileFormat ToFileFormat()
Expand Down Expand Up @@ -393,6 +399,7 @@ public ConfigurationFileFormat ToFileFormat()
SystemTimeOffset = System.SystemTimeOffset,
DockedMode = System.EnableDockedMode,
EnableDiscordIntegration = EnableDiscordIntegration,
CheckUpdatesOnStart = CheckUpdatesOnStart,
EnableVsync = Graphics.EnableVsync,
EnableMulticoreScheduling = System.EnableMulticoreScheduling,
EnablePtc = System.EnablePtc,
Expand Down Expand Up @@ -452,6 +459,7 @@ public void LoadDefault()
System.SystemTimeOffset.Value = 0;
System.EnableDockedMode.Value = false;
EnableDiscordIntegration.Value = true;
CheckUpdatesOnStart.Value = true;
Graphics.EnableVsync.Value = true;
System.EnableMulticoreScheduling.Value = true;
System.EnablePtc.Value = false;
Expand Down Expand Up @@ -696,6 +704,15 @@ public void Load(ConfigurationFileFormat configurationFileFormat, string configu
configurationFileUpdated = true;
}

if (configurationFileFormat.Version < 14)
{
Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 14.");

configurationFileFormat.CheckUpdatesOnStart = true;

configurationFileUpdated = true;
}

List<InputConfig> inputConfig = new List<InputConfig>();
inputConfig.AddRange(configurationFileFormat.ControllerConfig);
inputConfig.AddRange(configurationFileFormat.KeyboardConfig);
Expand All @@ -720,6 +737,7 @@ public void Load(ConfigurationFileFormat configurationFileFormat, string configu
System.SystemTimeOffset.Value = configurationFileFormat.SystemTimeOffset;
System.EnableDockedMode.Value = configurationFileFormat.DockedMode;
EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
System.EnableMulticoreScheduling.Value = configurationFileFormat.EnableMulticoreScheduling;
System.EnablePtc.Value = configurationFileFormat.EnablePtc;
Expand Down
1 change: 1 addition & 0 deletions Ryujinx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{36F870C1-3E5F-485F-B426-F0645AF78751}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
appveyor.yml = appveyor.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ryujinx.Memory", "Ryujinx.Memory\Ryujinx.Memory.csproj", "{A5E6C691-9E22-4263-8F40-42F002CE66BE}"
Expand Down
3 changes: 2 additions & 1 deletion Ryujinx/Config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 11,
"version": 14,
"res_scale": 1,
"res_scale_custom": 1,
"max_anisotropy": -1,
Expand All @@ -19,6 +19,7 @@
"system_time_offset": 0,
"docked_mode": false,
"enable_discord_integration": true,
"check_updates_on_start": true,
"enable_vsync": true,
"enable_multicore_scheduling": true,
"enable_ptc": false,
Expand Down
11 changes: 10 additions & 1 deletion Ryujinx/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;

namespace Ryujinx
{
Expand Down Expand Up @@ -44,6 +45,9 @@ static void Main(string[] args)
}
}

// Delete backup files after updating
Task.Run(Updater.CleanupUpdate);

Toolkit.Init(new ToolkitOptions
{
Backend = PlatformBackend.PreferNative,
Expand Down Expand Up @@ -122,6 +126,11 @@ static void Main(string[] args)
mainWindow.LoadApplication(launchPath);
}

if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
{
Updater.BeginParse(mainWindow, false);
}

Application.Run();
}

Expand Down Expand Up @@ -167,4 +176,4 @@ private static void ProgramExit()
Logger.Shutdown();
}
}
}
}
5 changes: 4 additions & 1 deletion Ryujinx/Ryujinx.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand Down Expand Up @@ -42,6 +42,7 @@
<None Remove="Ui\ProfileDialog.glade" />
<None Remove="Ui\SettingsWindow.glade" />
<None Remove="Ui\TitleUpdateWindow.glade" />
<None Remove="Ui\UpdateDialog.glade" />
</ItemGroup>

<ItemGroup>
Expand All @@ -66,6 +67,7 @@
<EmbeddedResource Include="Ui\SettingsWindow.glade" />
<EmbeddedResource Include="Ui\DlcWindow.glade" />
<EmbeddedResource Include="Ui\TitleUpdateWindow.glade" />
<EmbeddedResource Include="Updater\UpdateDialog.glade" />
</ItemGroup>

<ItemGroup>
Expand All @@ -75,6 +77,7 @@
<PackageReference Include="GtkSharp.Dependencies" Version="1.1.0" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'osx-x64'" />
<PackageReference Include="Ryujinx.Graphics.Nvdec.Dependencies" Version="4.3.0" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'osx-x64'" />
<PackageReference Include="OpenTK.NetStandard" Version="1.0.5.12" />
<PackageReference Include="SharpZipLib" Version="1.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Ryujinx/Ui/GLRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void HandleScreenState(KeyboardState keyboard)
{
if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape))
{
if (GtkDialog.CreateExitDialog())
if (GtkDialog.CreateChoiceDialog("Ryujinx - Exit", "Are you sure you want to stop emulation?", "All unsaved data will be lost!"))
{
Exit();
}
Expand Down
25 changes: 11 additions & 14 deletions Ryujinx/Ui/GtkDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Ryujinx.Ui
{
internal class GtkDialog : MessageDialog
{
internal static bool _isExitDialogOpen = false;
private static bool _isChoiceDialogOpen;

private GtkDialog(string title, string mainText, string secondaryText,
MessageType messageType = MessageType.Other, ButtonsType buttonsType = ButtonsType.Ok) : base(null, DialogFlags.Modal, messageType, buttonsType, null)
private GtkDialog(string title, string mainText, string secondaryText, MessageType messageType = MessageType.Other, ButtonsType buttonsType = ButtonsType.Ok)
: base(null, DialogFlags.Modal, messageType, buttonsType, null)
{
Title = title;
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
Expand Down Expand Up @@ -45,19 +45,16 @@ internal static MessageDialog CreateConfirmationDialog(string mainText, string s
return new GtkDialog("Ryujinx - Confirmation", mainText, secondaryText, MessageType.Question, ButtonsType.YesNo);
}

internal static bool CreateExitDialog()
internal static bool CreateChoiceDialog(string title, string mainText, string secondaryText)
{
if (_isExitDialogOpen)
{
if (_isChoiceDialogOpen)
return false;
}

_isExitDialogOpen = true;
ResponseType res = (ResponseType)new GtkDialog("Ryujinx - Exit", "Are you sure you want to stop emulation?",
"All unsaved data will be lost", MessageType.Question, ButtonsType.YesNo).Run();
_isExitDialogOpen = false;

return res == ResponseType.Yes;

_isChoiceDialogOpen = true;
ResponseType response = (ResponseType)new GtkDialog(title, mainText, secondaryText, MessageType.Question, ButtonsType.YesNo).Run();
_isChoiceDialogOpen = false;

return response == ResponseType.Yes;
}
}
}
72 changes: 34 additions & 38 deletions Ryujinx/Ui/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,38 @@ public class MainWindow : Window

#pragma warning disable CS0169, CS0649, IDE0044

[GUI] MenuBar _menuBar;
[GUI] Box _footerBox;
[GUI] Box _statusBar;
[GUI] MenuItem _stopEmulation;
[GUI] MenuItem _fullScreen;
[GUI] CheckMenuItem _favToggle;
[GUI] MenuItem _firmwareInstallDirectory;
[GUI] MenuItem _firmwareInstallFile;
[GUI] Label _hostStatus;
[GUI] CheckMenuItem _iconToggle;
[GUI] CheckMenuItem _developerToggle;
[GUI] CheckMenuItem _appToggle;
[GUI] CheckMenuItem _timePlayedToggle;
[GUI] CheckMenuItem _versionToggle;
[GUI] CheckMenuItem _lastPlayedToggle;
[GUI] CheckMenuItem _fileExtToggle;
[GUI] CheckMenuItem _pathToggle;
[GUI] CheckMenuItem _fileSizeToggle;
[GUI] Label _dockedMode;
[GUI] Label _gameStatus;
[GUI] TreeView _gameTable;
[GUI] TreeSelection _gameTableSelection;
[GUI] ScrolledWindow _gameTableWindow;
[GUI] Label _gpuName;
[GUI] Label _progressLabel;
[GUI] Label _firmwareVersionLabel;
[GUI] LevelBar _progressBar;
[GUI] Box _viewBox;
[GUI] Label _vSyncStatus;
[GUI] Box _listStatusBox;
[GUI] public MenuItem ExitMenuItem;
[GUI] public MenuItem UpdateMenuItem;
[GUI] MenuBar _menuBar;
[GUI] Box _footerBox;
[GUI] Box _statusBar;
[GUI] MenuItem _stopEmulation;
[GUI] MenuItem _fullScreen;
[GUI] CheckMenuItem _favToggle;
[GUI] MenuItem _firmwareInstallDirectory;
[GUI] MenuItem _firmwareInstallFile;
[GUI] Label _hostStatus;
[GUI] CheckMenuItem _iconToggle;
[GUI] CheckMenuItem _developerToggle;
[GUI] CheckMenuItem _appToggle;
[GUI] CheckMenuItem _timePlayedToggle;
[GUI] CheckMenuItem _versionToggle;
[GUI] CheckMenuItem _lastPlayedToggle;
[GUI] CheckMenuItem _fileExtToggle;
[GUI] CheckMenuItem _pathToggle;
[GUI] CheckMenuItem _fileSizeToggle;
[GUI] Label _dockedMode;
[GUI] Label _gameStatus;
[GUI] TreeView _gameTable;
[GUI] TreeSelection _gameTableSelection;
[GUI] ScrolledWindow _gameTableWindow;
[GUI] Label _gpuName;
[GUI] Label _progressLabel;
[GUI] Label _firmwareVersionLabel;
[GUI] LevelBar _progressBar;
[GUI] Box _viewBox;
[GUI] Label _vSyncStatus;
[GUI] Box _listStatusBox;

#pragma warning restore CS0649, IDE0044, CS0169

Expand Down Expand Up @@ -1163,15 +1165,9 @@ private void Settings_Pressed(object sender, EventArgs args)

private void Update_Pressed(object sender, EventArgs args)
{
string ryuUpdater = System.IO.Path.Combine(AppDataManager.BaseDirPath, "RyuUpdater.exe");

try
{
Process.Start(new ProcessStartInfo(ryuUpdater, "/U") { UseShellExecute = true });
}
catch(System.ComponentModel.Win32Exception)
if (Updater.CanUpdate(true))
{
GtkDialog.CreateErrorDialog("Update canceled by user or updater was not found");
Updater.BeginParse(this, true);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Ryujinx/Ui/MainWindow.glade
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</object>
</child>
<child>
<object class="GtkMenuItem" id="Exit">
<object class="GtkMenuItem" id="ExitMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Exit Ryujinx</property>
Expand Down Expand Up @@ -320,10 +320,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="CheckUpdates">
<object class="GtkMenuItem" id="UpdateMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Check for updates to Ryujinx (requires Ryujinx Installer)</property>
<property name="tooltip_text" translatable="yes">Check for updates to Ryujinx</property>
<property name="label" translatable="yes">Check for Updates</property>
<property name="use_underline">True</property>
<signal name="activate" handler="Update_Pressed" swapped="no"/>
Expand Down
7 changes: 7 additions & 0 deletions Ryujinx/Ui/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class SettingsWindow : Window
[GUI] ComboBoxText _graphicsDebugLevel;
[GUI] CheckButton _dockedModeToggle;
[GUI] CheckButton _discordToggle;
[GUI] CheckButton _checkUpdatesToggle;
[GUI] CheckButton _vSyncToggle;
[GUI] CheckButton _multiSchedToggle;
[GUI] CheckButton _ptcToggle;
Expand Down Expand Up @@ -170,6 +171,11 @@ private SettingsWindow(Builder builder, VirtualFileSystem virtualFileSystem, HLE
_discordToggle.Click();
}

if (ConfigurationState.Instance.CheckUpdatesOnStart)
{
_checkUpdatesToggle.Click();
}

if (ConfigurationState.Instance.Graphics.EnableVsync)
{
_vSyncToggle.Click();
Expand Down Expand Up @@ -519,6 +525,7 @@ private void SaveToggle_Activated(object sender, EventArgs args)
ConfigurationState.Instance.Logger.GraphicsDebugLevel.Value = Enum.Parse<GraphicsDebugLevel>(_graphicsDebugLevel.ActiveId);
ConfigurationState.Instance.System.EnableDockedMode.Value = _dockedModeToggle.Active;
ConfigurationState.Instance.EnableDiscordIntegration.Value = _discordToggle.Active;
ConfigurationState.Instance.CheckUpdatesOnStart.Value = _checkUpdatesToggle.Active;
ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active;
ConfigurationState.Instance.System.EnableMulticoreScheduling.Value = _multiSchedToggle.Active;
ConfigurationState.Instance.System.EnablePtc.Value = _ptcToggle.Active;
Expand Down
18 changes: 17 additions & 1 deletion Ryujinx/Ui/SettingsWindow.glade
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,23 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">2</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="_checkUpdatesToggle">
<property name="label" translatable="yes">Check for updates on launch</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
</object>
Expand Down
Loading

0 comments on commit a154593

Please sign in to comment.