Check if game update exists before loading the application.

This commit is contained in:
Tomas Voracek 2023-10-17 14:23:04 +02:00
parent 1e06b28b22
commit cef2ad455b
3 changed files with 47 additions and 0 deletions

View file

@ -928,6 +928,12 @@ namespace Ryujinx.Ui.App.Common
{
updatePath = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, _titleSerializerContext.TitleUpdateMetadata).Selected;
if (!string.IsNullOrWhiteSpace(updatePath)
&& !File.Exists(updatePath))
{
Logger.Warning?.Print(LogClass.Loader, $"Update file {updatePath} for titleId: {titleId} was not found! Game saves can become corrupted!");
}
if (File.Exists(updatePath))
{
FileStream file = new(updatePath, FileMode.Open, FileAccess.Read);

View file

@ -896,6 +896,11 @@ namespace Ryujinx.Ui
}
else
{
if (!CheckGameUpdatesPresent())
{
return;
}
PerformanceCheck();
Logger.RestartTime();
@ -959,6 +964,36 @@ namespace Ryujinx.Ui
}
}
private bool CheckGameUpdatesPresent()
{
bool gameUpdateStatusCheck = true;
_gameTableSelection.GetSelected(out TreeIter treeIter);
string titleId = _tableStore.GetValue(treeIter, 2).ToString().Split("\n")[1].ToLower();
(Nca patchNca, _) = ApplicationLibrary.GetGameUpdateData(_virtualFileSystem, titleId, 0, out string updatePath);
if (!string.IsNullOrWhiteSpace(updatePath)
&& patchNca is null)
{
MessageDialog updateMissingWarningDialog = new(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
{
Title = "Ryujinx - Warning",
Text = "Update file for this title was not found!",
SecondaryText = "Game saves may be incompatible with this version or become corrupted. Do you wish to load the application anyway?",
};
if (updateMissingWarningDialog.Run() == (int)ResponseType.No)
{
gameUpdateStatusCheck = false;
}
updateMissingWarningDialog.Dispose();
}
return gameUpdateStatusCheck;
}
private RendererWidgetBase CreateRendererWidget()
{
if (ConfigurationState.Instance.Graphics.GraphicsBackend == GraphicsBackend.Vulkan)

View file

@ -86,6 +86,12 @@ namespace Ryujinx.Ui.Windows
private void AddUpdate(string path)
{
if (!File.Exists(path))
{
GtkDialog.CreateErrorDialog($"Update file {path} was not found! Current game saves can become corrupted!");
return;
}
if (File.Exists(path))
{
using FileStream file = new(path, FileMode.Open, FileAccess.Read);