mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-23 13:45:45 +00:00
AutoLoad DLC/updates (#12)
* Add hooks to ApplicationLibrary for loading DLC/updates * Trigger DLC/update load on games refresh * Initial moving of DLC/updates to UI.Common * Use new models in ApplicationLibrary * Make dlc/updates records; use ApplicationLibrary for loading logic * Fix a bug with DLC window; rework some logic * Auto-load bundled DLC on startup * Autoload DLC * Add setting for autoloading dlc/updates * Remove dead code; bind to AppLibrary apps directly in mainwindow * Stub out bulk dlc menu item * Add localization; stub out bulk load updates * Set autoload dirs explicitly * Begin extracting updates to match DLC refactors * Add title update autoloading * Reduce size of settings sections * Better cache lookup for apps * Dont reload entire library on game version change * Remove ApplicationAdded event; always enumerate nsp when autoloading
This commit is contained in:
parent
c4ee9c7555
commit
06f9adfa90
30 changed files with 1509 additions and 459 deletions
|
@ -1,9 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.UI.App.Common
|
|
||||||
{
|
|
||||||
public class ApplicationAddedEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public ApplicationData AppData { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
using DynamicData;
|
||||||
|
using DynamicData.Kernel;
|
||||||
using LibHac;
|
using LibHac;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using LibHac.Common.Keys;
|
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs.Fsa;
|
using LibHac.Fs.Fsa;
|
||||||
using LibHac.FsSystem;
|
using LibHac.FsSystem;
|
||||||
|
@ -16,8 +17,11 @@ using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.HOS.SystemState;
|
using Ryujinx.HLE.HOS.SystemState;
|
||||||
using Ryujinx.HLE.Loaders.Npdm;
|
using Ryujinx.HLE.Loaders.Npdm;
|
||||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||||
|
using Ryujinx.HLE.Utilities;
|
||||||
using Ryujinx.UI.Common.Configuration;
|
using Ryujinx.UI.Common.Configuration;
|
||||||
using Ryujinx.UI.Common.Configuration.System;
|
using Ryujinx.UI.Common.Configuration.System;
|
||||||
|
using Ryujinx.UI.Common.Helper;
|
||||||
|
using Ryujinx.UI.Common.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -27,7 +31,9 @@ using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using ContentType = LibHac.Ncm.ContentType;
|
using ContentType = LibHac.Ncm.ContentType;
|
||||||
|
using MissingKeyException = LibHac.Common.Keys.MissingKeyException;
|
||||||
using Path = System.IO.Path;
|
using Path = System.IO.Path;
|
||||||
|
using SpanHelpers = LibHac.Common.SpanHelpers;
|
||||||
using TimeSpan = System.TimeSpan;
|
using TimeSpan = System.TimeSpan;
|
||||||
|
|
||||||
namespace Ryujinx.UI.App.Common
|
namespace Ryujinx.UI.App.Common
|
||||||
|
@ -35,9 +41,12 @@ namespace Ryujinx.UI.App.Common
|
||||||
public class ApplicationLibrary
|
public class ApplicationLibrary
|
||||||
{
|
{
|
||||||
public Language DesiredLanguage { get; set; }
|
public Language DesiredLanguage { get; set; }
|
||||||
public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
|
|
||||||
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
|
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
|
||||||
|
|
||||||
|
public readonly IObservableCache<ApplicationData, ulong> Applications;
|
||||||
|
public readonly IObservableCache<(TitleUpdateModel TitleUpdate, bool IsSelected), TitleUpdateModel> TitleUpdates;
|
||||||
|
public readonly IObservableCache<(DownloadableContentModel Dlc, bool IsEnabled), DownloadableContentModel> DownloadableContents;
|
||||||
|
|
||||||
private readonly byte[] _nspIcon;
|
private readonly byte[] _nspIcon;
|
||||||
private readonly byte[] _xciIcon;
|
private readonly byte[] _xciIcon;
|
||||||
private readonly byte[] _ncaIcon;
|
private readonly byte[] _ncaIcon;
|
||||||
|
@ -47,6 +56,9 @@ namespace Ryujinx.UI.App.Common
|
||||||
private readonly VirtualFileSystem _virtualFileSystem;
|
private readonly VirtualFileSystem _virtualFileSystem;
|
||||||
private readonly IntegrityCheckLevel _checkLevel;
|
private readonly IntegrityCheckLevel _checkLevel;
|
||||||
private CancellationTokenSource _cancellationToken;
|
private CancellationTokenSource _cancellationToken;
|
||||||
|
private readonly SourceCache<ApplicationData, ulong> _applications = new(it => it.Id);
|
||||||
|
private readonly SourceCache<(TitleUpdateModel TitleUpdate, bool IsSelected), TitleUpdateModel> _titleUpdates = new(it => it.TitleUpdate);
|
||||||
|
private readonly SourceCache<(DownloadableContentModel Dlc, bool IsEnabled), DownloadableContentModel> _downloadableContents = new(it => it.Dlc);
|
||||||
|
|
||||||
private static readonly ApplicationJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
private static readonly ApplicationJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||||
|
|
||||||
|
@ -55,6 +67,10 @@ namespace Ryujinx.UI.App.Common
|
||||||
_virtualFileSystem = virtualFileSystem;
|
_virtualFileSystem = virtualFileSystem;
|
||||||
_checkLevel = checkLevel;
|
_checkLevel = checkLevel;
|
||||||
|
|
||||||
|
Applications = _applications.AsObservableCache();
|
||||||
|
TitleUpdates = _titleUpdates.AsObservableCache();
|
||||||
|
DownloadableContents = _downloadableContents.AsObservableCache();
|
||||||
|
|
||||||
_nspIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_NSP.png");
|
_nspIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_NSP.png");
|
||||||
_xciIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_XCI.png");
|
_xciIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_XCI.png");
|
||||||
_ncaIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_NCA.png");
|
_ncaIcon = GetResourceBytes("Ryujinx.UI.Common.Resources.Icon_NCA.png");
|
||||||
|
@ -100,7 +116,7 @@ namespace Ryujinx.UI.App.Common
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <exception cref="MissingKeyException">The configured key set is missing a key.</exception>
|
/// <exception cref="LibHac.Common.Keys.MissingKeyException">The configured key set is missing a key.</exception>
|
||||||
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
|
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
|
||||||
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
|
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
|
||||||
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
||||||
|
@ -176,7 +192,7 @@ namespace Ryujinx.UI.App.Common
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <exception cref="MissingKeyException">The configured key set is missing a key.</exception>
|
/// <exception cref="LibHac.Common.Keys.MissingKeyException">The configured key set is missing a key.</exception>
|
||||||
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
|
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
|
||||||
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
|
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
|
||||||
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
||||||
|
@ -474,6 +490,148 @@ namespace Ryujinx.UI.App.Common
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryGetDownloadableContentFromFile(string filePath, out List<DownloadableContentModel> titleUpdates)
|
||||||
|
{
|
||||||
|
titleUpdates = [];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string extension = Path.GetExtension(filePath).ToLower();
|
||||||
|
|
||||||
|
using FileStream file = new(filePath, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
switch (extension)
|
||||||
|
{
|
||||||
|
case ".xci":
|
||||||
|
case ".nsp":
|
||||||
|
{
|
||||||
|
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
|
||||||
|
? IntegrityCheckLevel.ErrorOnInvalid
|
||||||
|
: IntegrityCheckLevel.None;
|
||||||
|
|
||||||
|
using IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(filePath, _virtualFileSystem);
|
||||||
|
|
||||||
|
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
|
||||||
|
{
|
||||||
|
using var ncaFile = new UniqueRef<IFile>();
|
||||||
|
|
||||||
|
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||||
|
|
||||||
|
Nca nca = TryOpenNca(ncaFile.Get.AsStorage());
|
||||||
|
if (nca == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nca.Header.ContentType == NcaContentType.PublicData)
|
||||||
|
{
|
||||||
|
titleUpdates.Add(new DownloadableContentModel(nca.Header.TitleId, filePath, fileEntry.FullPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return titleUpdates.Count != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (MissingKeyException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
|
||||||
|
}
|
||||||
|
catch (InvalidDataException)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {filePath}");
|
||||||
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, exception.Message);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetTitleUpdatesFromFile(string filePath, out List<TitleUpdateModel> titleUpdates)
|
||||||
|
{
|
||||||
|
titleUpdates = [];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string extension = Path.GetExtension(filePath).ToLower();
|
||||||
|
|
||||||
|
using FileStream file = new(filePath, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
switch (extension)
|
||||||
|
{
|
||||||
|
case ".xci":
|
||||||
|
case ".nsp":
|
||||||
|
{
|
||||||
|
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
|
||||||
|
? IntegrityCheckLevel.ErrorOnInvalid
|
||||||
|
: IntegrityCheckLevel.None;
|
||||||
|
|
||||||
|
using IFileSystem pfs =
|
||||||
|
PartitionFileSystemUtils.OpenApplicationFileSystem(filePath, _virtualFileSystem);
|
||||||
|
|
||||||
|
Dictionary<ulong, ContentMetaData> updates =
|
||||||
|
pfs.GetContentData(ContentMetaType.Patch, _virtualFileSystem, checkLevel);
|
||||||
|
|
||||||
|
if (updates.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((_, ContentMetaData content) in updates)
|
||||||
|
{
|
||||||
|
Nca patchNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Program);
|
||||||
|
Nca controlNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Control);
|
||||||
|
|
||||||
|
if (controlNca != null && patchNca != null)
|
||||||
|
{
|
||||||
|
ApplicationControlProperty controlData = new();
|
||||||
|
|
||||||
|
using UniqueRef<IFile> nacpFile = new();
|
||||||
|
|
||||||
|
controlNca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None)
|
||||||
|
.OpenFile(ref nacpFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read)
|
||||||
|
.ThrowIfFailure();
|
||||||
|
nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData),
|
||||||
|
ReadOption.None).ThrowIfFailure();
|
||||||
|
|
||||||
|
var displayVersion = controlData.DisplayVersionString.ToString();
|
||||||
|
var update = new TitleUpdateModel(content.ApplicationId, content.Version.Version,
|
||||||
|
displayVersion, filePath);
|
||||||
|
|
||||||
|
titleUpdates.Add(update);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (MissingKeyException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
|
||||||
|
}
|
||||||
|
catch (InvalidDataException)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {filePath}");
|
||||||
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, exception.Message);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void CancelLoading()
|
public void CancelLoading()
|
||||||
{
|
{
|
||||||
_cancellationToken?.Cancel();
|
_cancellationToken?.Cancel();
|
||||||
|
@ -493,6 +651,7 @@ namespace Ryujinx.UI.App.Common
|
||||||
int numApplicationsLoaded = 0;
|
int numApplicationsLoaded = 0;
|
||||||
|
|
||||||
_cancellationToken = new CancellationTokenSource();
|
_cancellationToken = new CancellationTokenSource();
|
||||||
|
_applications.Clear();
|
||||||
|
|
||||||
// Builds the applications list with paths to found applications
|
// Builds the applications list with paths to found applications
|
||||||
List<string> applicationPaths = new();
|
List<string> applicationPaths = new();
|
||||||
|
@ -569,14 +728,20 @@ namespace Ryujinx.UI.App.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TryGetApplicationsFromFile(applicationPath, out List<ApplicationData> applications))
|
if (TryGetApplicationsFromFile(applicationPath, out List<ApplicationData> applications))
|
||||||
|
{
|
||||||
|
_applications.Edit(it =>
|
||||||
{
|
{
|
||||||
foreach (var application in applications)
|
foreach (var application in applications)
|
||||||
{
|
{
|
||||||
OnApplicationAdded(new ApplicationAddedEventArgs
|
it.AddOrUpdate(application);
|
||||||
|
LoadDlcForApplication(application);
|
||||||
|
if (LoadTitleUpdatesForApplication(application))
|
||||||
{
|
{
|
||||||
AppData = application,
|
// Trigger a reload of the version data
|
||||||
});
|
RefreshApplicationInfo(application.IdBase);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (applications.Count > 1)
|
if (applications.Count > 1)
|
||||||
{
|
{
|
||||||
|
@ -610,9 +775,236 @@ namespace Ryujinx.UI.App.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnApplicationAdded(ApplicationAddedEventArgs e)
|
// Replace the currently stored DLC state for the game with the provided DLC state.
|
||||||
|
public void SaveDownloadableContentsForGame(ApplicationData application, List<(DownloadableContentModel, bool IsEnabled)> dlcs)
|
||||||
{
|
{
|
||||||
ApplicationAdded?.Invoke(null, e);
|
_downloadableContents.Edit(it =>
|
||||||
|
{
|
||||||
|
DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, application.IdBase, dlcs);
|
||||||
|
|
||||||
|
it.Remove(it.Items.Where(item => item.Dlc.TitleIdBase == application.IdBase));
|
||||||
|
it.AddOrUpdate(dlcs);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace the currently stored update state for the game with the provided update state.
|
||||||
|
public void SaveTitleUpdatesForGame(ApplicationData application, List<(TitleUpdateModel, bool IsSelected)> updates)
|
||||||
|
{
|
||||||
|
_titleUpdates.Edit(it =>
|
||||||
|
{
|
||||||
|
TitleUpdatesHelper.SaveTitleUpdatesJson(_virtualFileSystem, application.IdBase, updates);
|
||||||
|
|
||||||
|
it.Remove(it.Items.Where(item => item.TitleUpdate.TitleIdBase == application.IdBase));
|
||||||
|
it.AddOrUpdate(updates);
|
||||||
|
RefreshApplicationInfo(application.IdBase);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Searches the provided directories for DLC NSP files that are _valid for the currently detected games in the
|
||||||
|
// library_, and then enables those DLC.
|
||||||
|
public int AutoLoadDownloadableContents(List<string> appDirs)
|
||||||
|
{
|
||||||
|
_cancellationToken = new CancellationTokenSource();
|
||||||
|
|
||||||
|
List<string> dlcPaths = new();
|
||||||
|
int newDlcLoaded = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string appDir in appDirs)
|
||||||
|
{
|
||||||
|
if (_cancellationToken.Token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return newDlcLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(appDir))
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"The specified autoload directory \"{appDir}\" does not exist.");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
EnumerationOptions options = new()
|
||||||
|
{
|
||||||
|
RecurseSubdirectories = true,
|
||||||
|
IgnoreInaccessible = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", options).Where(
|
||||||
|
file => Path.GetExtension(file).ToLower() is ".nsp");
|
||||||
|
|
||||||
|
foreach (string app in files)
|
||||||
|
{
|
||||||
|
if (_cancellationToken.Token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return newDlcLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileInfo = new FileInfo(app);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
|
||||||
|
|
||||||
|
dlcPaths.Add(fullPath);
|
||||||
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"Failed to resolve the full path to file: \"{app}\" Error: {exception}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"Failed to get access to directory: \"{appDir}\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
|
||||||
|
|
||||||
|
foreach (string dlcPath in dlcPaths)
|
||||||
|
{
|
||||||
|
if (_cancellationToken.Token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return newDlcLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TryGetDownloadableContentFromFile(dlcPath, out var foundDlcs))
|
||||||
|
{
|
||||||
|
foreach (var dlc in foundDlcs.Where(it => appIdLookup.Contains(it.TitleIdBase)))
|
||||||
|
{
|
||||||
|
if (!_downloadableContents.Lookup(dlc).HasValue)
|
||||||
|
{
|
||||||
|
_downloadableContents.AddOrUpdate((dlc, true));
|
||||||
|
SaveDownloadableContentsForGame(dlc.TitleIdBase);
|
||||||
|
newDlcLoaded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_cancellationToken.Dispose();
|
||||||
|
_cancellationToken = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newDlcLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Searches the provided directories for update NSP files that are _valid for the currently detected games in the
|
||||||
|
// library_, and then applies those updates. If a newly-detected update is a newer version than the currently
|
||||||
|
// selected update (or if no update is currently selected), then that update will be selected.
|
||||||
|
public int AutoLoadTitleUpdates(List<string> appDirs)
|
||||||
|
{
|
||||||
|
_cancellationToken = new CancellationTokenSource();
|
||||||
|
|
||||||
|
List<string> updatePaths = new();
|
||||||
|
int numUpdatesLoaded = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string appDir in appDirs)
|
||||||
|
{
|
||||||
|
if (_cancellationToken.Token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return numUpdatesLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(appDir))
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"The specified autoload directory \"{appDir}\" does not exist.");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
EnumerationOptions options = new()
|
||||||
|
{
|
||||||
|
RecurseSubdirectories = true,
|
||||||
|
IgnoreInaccessible = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", options).Where(
|
||||||
|
file => Path.GetExtension(file).ToLower() is ".nsp");
|
||||||
|
|
||||||
|
foreach (string app in files)
|
||||||
|
{
|
||||||
|
if (_cancellationToken.Token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return numUpdatesLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileInfo = new FileInfo(app);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
|
||||||
|
|
||||||
|
updatePaths.Add(fullPath);
|
||||||
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"Failed to resolve the full path to file: \"{app}\" Error: {exception}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"Failed to get access to directory: \"{appDir}\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
|
||||||
|
|
||||||
|
foreach (string updatePath in updatePaths)
|
||||||
|
{
|
||||||
|
if (_cancellationToken.Token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return numUpdatesLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TryGetTitleUpdatesFromFile(updatePath, out var foundUpdates))
|
||||||
|
{
|
||||||
|
foreach (var update in foundUpdates.Where(it => appIdLookup.Contains(it.TitleIdBase)))
|
||||||
|
{
|
||||||
|
if (!_titleUpdates.Lookup(update).HasValue)
|
||||||
|
{
|
||||||
|
var currentlySelected = TitleUpdates.Items.FirstOrOptional(it =>
|
||||||
|
it.TitleUpdate.TitleIdBase == update.TitleIdBase && it.IsSelected);
|
||||||
|
|
||||||
|
var shouldSelect = !currentlySelected.HasValue ||
|
||||||
|
currentlySelected.Value.TitleUpdate.Version < update.Version;
|
||||||
|
_titleUpdates.AddOrUpdate((update, shouldSelect));
|
||||||
|
SaveTitleUpdatesForGame(update.TitleIdBase);
|
||||||
|
numUpdatesLoaded++;
|
||||||
|
|
||||||
|
if (shouldSelect)
|
||||||
|
{
|
||||||
|
RefreshApplicationInfo(update.TitleIdBase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_cancellationToken.Dispose();
|
||||||
|
_cancellationToken = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numUpdatesLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnApplicationCountUpdated(ApplicationCountUpdatedEventArgs e)
|
protected void OnApplicationCountUpdated(ApplicationCountUpdatedEventArgs e)
|
||||||
|
@ -936,5 +1328,128 @@ namespace Ryujinx.UI.App.Common
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Nca TryOpenNca(IStorage ncaStorage)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new Nca(_virtualFileSystem.KeySet, ncaStorage);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Does a two-phase load of DLC. First reading the metadata on disk, then loading anything bundled in the game
|
||||||
|
// file itself
|
||||||
|
private void LoadDlcForApplication(ApplicationData application)
|
||||||
|
{
|
||||||
|
_downloadableContents.Edit(it =>
|
||||||
|
{
|
||||||
|
var savedDlc =
|
||||||
|
DownloadableContentsHelper.LoadDownloadableContentsJson(_virtualFileSystem, application.IdBase);
|
||||||
|
it.AddOrUpdate(savedDlc);
|
||||||
|
|
||||||
|
if (TryGetDownloadableContentFromFile(application.Path, out var bundledDlc))
|
||||||
|
{
|
||||||
|
var savedDlcLookup = savedDlc.Select(dlc => dlc.Item1).ToHashSet();
|
||||||
|
|
||||||
|
bool addedNewDlc = false;
|
||||||
|
foreach (var dlc in bundledDlc)
|
||||||
|
{
|
||||||
|
if (!savedDlcLookup.Contains(dlc))
|
||||||
|
{
|
||||||
|
addedNewDlc = true;
|
||||||
|
it.AddOrUpdate((dlc, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addedNewDlc)
|
||||||
|
{
|
||||||
|
var gameDlcs = it.Items.Where(dlc => dlc.Dlc.TitleIdBase == application.IdBase).ToList();
|
||||||
|
DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, application.IdBase,
|
||||||
|
gameDlcs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Does a two-phase load of updates. First reading the metadata on disk, then loading anything bundled in the game
|
||||||
|
// file itself
|
||||||
|
private bool LoadTitleUpdatesForApplication(ApplicationData application)
|
||||||
|
{
|
||||||
|
var modifiedVersion = false;
|
||||||
|
|
||||||
|
_titleUpdates.Edit(it =>
|
||||||
|
{
|
||||||
|
var savedUpdates =
|
||||||
|
TitleUpdatesHelper.LoadTitleUpdatesJson(_virtualFileSystem, application.IdBase);
|
||||||
|
it.AddOrUpdate(savedUpdates);
|
||||||
|
|
||||||
|
var selectedUpdate = savedUpdates.FirstOrOptional(update => update.IsSelected);
|
||||||
|
|
||||||
|
if (TryGetTitleUpdatesFromFile(application.Path, out var bundledUpdates))
|
||||||
|
{
|
||||||
|
var savedUpdateLookup = savedUpdates.Select(update => update.Item1).ToHashSet();
|
||||||
|
|
||||||
|
bool addedNewUpdate = false;
|
||||||
|
foreach (var update in bundledUpdates.OrderByDescending(bundled => bundled.Version))
|
||||||
|
{
|
||||||
|
if (!savedUpdateLookup.Contains(update))
|
||||||
|
{
|
||||||
|
bool shouldSelect = false;
|
||||||
|
if (!selectedUpdate.HasValue || selectedUpdate.Value.Item1.Version < update.Version)
|
||||||
|
{
|
||||||
|
shouldSelect = true;
|
||||||
|
selectedUpdate = Optional<(TitleUpdateModel, bool IsSelected)>.Create((update, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiedVersion = modifiedVersion || shouldSelect;
|
||||||
|
it.AddOrUpdate((update, shouldSelect));
|
||||||
|
|
||||||
|
addedNewUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addedNewUpdate)
|
||||||
|
{
|
||||||
|
var gameUpdates = it.Items.Where(update => update.TitleUpdate.TitleIdBase == application.IdBase).ToList();
|
||||||
|
TitleUpdatesHelper.SaveTitleUpdatesJson(_virtualFileSystem, application.IdBase, gameUpdates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return modifiedVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the _currently tracked_ DLC state for the game
|
||||||
|
private void SaveDownloadableContentsForGame(ulong titleIdBase)
|
||||||
|
{
|
||||||
|
var dlcs = DownloadableContents.Items.Where(dlc => dlc.Dlc.TitleIdBase == titleIdBase).ToList();
|
||||||
|
DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, titleIdBase, dlcs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the _currently tracked_ update state for the game
|
||||||
|
private void SaveTitleUpdatesForGame(ulong titleIdBase)
|
||||||
|
{
|
||||||
|
var updates = TitleUpdates.Items.Where(update => update.TitleUpdate.TitleIdBase == titleIdBase).ToList();
|
||||||
|
TitleUpdatesHelper.SaveTitleUpdatesJson(_virtualFileSystem, titleIdBase, updates);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApplicationData isnt live-updating (e.g. when an update gets applied) and so this is meant to trigger a refresh
|
||||||
|
// of its state
|
||||||
|
private void RefreshApplicationInfo(ulong appIdBase)
|
||||||
|
{
|
||||||
|
var application = _applications.Lookup(appIdBase);
|
||||||
|
|
||||||
|
if (!application.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!TryGetApplicationsFromFile(application.Value.Path, out List<ApplicationData> newApplications))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var newApplication = newApplications.First(it => it.IdBase == appIdBase);
|
||||||
|
_applications.AddOrUpdate(newApplication);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current version of the file format
|
/// The current version of the file format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int CurrentVersion = 51;
|
public const int CurrentVersion = 52;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the configuration file format
|
/// Version of the configuration file format
|
||||||
|
@ -262,6 +262,11 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> GameDirs { get; set; }
|
public List<string> GameDirs { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of directories containing DLC/updates the user wants to autoload during library refreshes
|
||||||
|
/// </summary>
|
||||||
|
public List<string> AutoloadDirs { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of file types to be hidden in the games List
|
/// A list of file types to be hidden in the games List
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -122,6 +122,11 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<List<string>> GameDirs { get; private set; }
|
public ReactiveObject<List<string>> GameDirs { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of directories containing DLC/updates the user wants to autoload during library refreshes
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveObject<List<string>> AutoloadDirs { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of file types to be hidden in the games List
|
/// A list of file types to be hidden in the games List
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -192,6 +197,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
GuiColumns = new Columns();
|
GuiColumns = new Columns();
|
||||||
ColumnSort = new ColumnSortSettings();
|
ColumnSort = new ColumnSortSettings();
|
||||||
GameDirs = new ReactiveObject<List<string>>();
|
GameDirs = new ReactiveObject<List<string>>();
|
||||||
|
AutoloadDirs = new ReactiveObject<List<string>>();
|
||||||
ShownFileTypes = new ShownFileTypeSettings();
|
ShownFileTypes = new ShownFileTypeSettings();
|
||||||
WindowStartup = new WindowStartupSettings();
|
WindowStartup = new WindowStartupSettings();
|
||||||
EnableCustomTheme = new ReactiveObject<bool>();
|
EnableCustomTheme = new ReactiveObject<bool>();
|
||||||
|
@ -728,6 +734,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
SortAscending = UI.ColumnSort.SortAscending,
|
SortAscending = UI.ColumnSort.SortAscending,
|
||||||
},
|
},
|
||||||
GameDirs = UI.GameDirs,
|
GameDirs = UI.GameDirs,
|
||||||
|
AutoloadDirs = UI.AutoloadDirs,
|
||||||
ShownFileTypes = new ShownFileTypes
|
ShownFileTypes = new ShownFileTypes
|
||||||
{
|
{
|
||||||
NSP = UI.ShownFileTypes.NSP,
|
NSP = UI.ShownFileTypes.NSP,
|
||||||
|
@ -836,6 +843,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
UI.ColumnSort.SortColumnId.Value = 0;
|
UI.ColumnSort.SortColumnId.Value = 0;
|
||||||
UI.ColumnSort.SortAscending.Value = false;
|
UI.ColumnSort.SortAscending.Value = false;
|
||||||
UI.GameDirs.Value = new List<string>();
|
UI.GameDirs.Value = new List<string>();
|
||||||
|
UI.AutoloadDirs.Value = new List<string>();
|
||||||
UI.ShownFileTypes.NSP.Value = true;
|
UI.ShownFileTypes.NSP.Value = true;
|
||||||
UI.ShownFileTypes.PFS0.Value = true;
|
UI.ShownFileTypes.PFS0.Value = true;
|
||||||
UI.ShownFileTypes.XCI.Value = true;
|
UI.ShownFileTypes.XCI.Value = true;
|
||||||
|
@ -1477,6 +1485,15 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
configurationFileUpdated = true;
|
configurationFileUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configurationFileFormat.Version < 52)
|
||||||
|
{
|
||||||
|
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 52.");
|
||||||
|
|
||||||
|
configurationFileFormat.AutoloadDirs = new();
|
||||||
|
|
||||||
|
configurationFileUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
|
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
|
||||||
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
Graphics.ResScale.Value = configurationFileFormat.ResScale;
|
||||||
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
|
||||||
|
@ -1538,6 +1555,7 @@ namespace Ryujinx.UI.Common.Configuration
|
||||||
UI.ColumnSort.SortColumnId.Value = configurationFileFormat.ColumnSort.SortColumnId;
|
UI.ColumnSort.SortColumnId.Value = configurationFileFormat.ColumnSort.SortColumnId;
|
||||||
UI.ColumnSort.SortAscending.Value = configurationFileFormat.ColumnSort.SortAscending;
|
UI.ColumnSort.SortAscending.Value = configurationFileFormat.ColumnSort.SortAscending;
|
||||||
UI.GameDirs.Value = configurationFileFormat.GameDirs;
|
UI.GameDirs.Value = configurationFileFormat.GameDirs;
|
||||||
|
UI.AutoloadDirs.Value = configurationFileFormat.AutoloadDirs;
|
||||||
UI.ShownFileTypes.NSP.Value = configurationFileFormat.ShownFileTypes.NSP;
|
UI.ShownFileTypes.NSP.Value = configurationFileFormat.ShownFileTypes.NSP;
|
||||||
UI.ShownFileTypes.PFS0.Value = configurationFileFormat.ShownFileTypes.PFS0;
|
UI.ShownFileTypes.PFS0.Value = configurationFileFormat.ShownFileTypes.PFS0;
|
||||||
UI.ShownFileTypes.XCI.Value = configurationFileFormat.ShownFileTypes.XCI;
|
UI.ShownFileTypes.XCI.Value = configurationFileFormat.ShownFileTypes.XCI;
|
||||||
|
|
135
src/Ryujinx.UI.Common/Helper/DownloadableContentsHelper.cs
Normal file
135
src/Ryujinx.UI.Common/Helper/DownloadableContentsHelper.cs
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
using LibHac.Common;
|
||||||
|
using LibHac.Fs;
|
||||||
|
using LibHac.Fs.Fsa;
|
||||||
|
using LibHac.Tools.FsSystem;
|
||||||
|
using LibHac.Tools.FsSystem.NcaUtils;
|
||||||
|
using Ryujinx.Common.Configuration;
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Common.Utilities;
|
||||||
|
using Ryujinx.HLE.FileSystem;
|
||||||
|
using Ryujinx.HLE.Utilities;
|
||||||
|
using Ryujinx.UI.Common.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using Path = System.IO.Path;
|
||||||
|
|
||||||
|
namespace Ryujinx.UI.Common.Helper
|
||||||
|
{
|
||||||
|
public static class DownloadableContentsHelper
|
||||||
|
{
|
||||||
|
private static readonly DownloadableContentJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||||
|
|
||||||
|
public static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContentsJson(VirtualFileSystem vfs, ulong applicationIdBase)
|
||||||
|
{
|
||||||
|
var downloadableContentJsonPath = PathToGameDLCJson(applicationIdBase);
|
||||||
|
|
||||||
|
if (!File.Exists(downloadableContentJsonPath))
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var downloadableContentContainerList = JsonHelper.DeserializeFromFile(downloadableContentJsonPath,
|
||||||
|
_serializerContext.ListDownloadableContentContainer);
|
||||||
|
return LoadDownloadableContents(vfs, downloadableContentContainerList);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Configuration, "Downloadable Content JSON failed to deserialize.");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SaveDownloadableContentsJson(VirtualFileSystem vfs, ulong applicationIdBase, List<(DownloadableContentModel, bool IsEnabled)> dlcs)
|
||||||
|
{
|
||||||
|
DownloadableContentContainer container = default;
|
||||||
|
List<DownloadableContentContainer> downloadableContentContainerList = new();
|
||||||
|
|
||||||
|
foreach ((DownloadableContentModel dlc, bool isEnabled) in dlcs)
|
||||||
|
{
|
||||||
|
if (container.ContainerPath != dlc.ContainerPath)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(container.ContainerPath))
|
||||||
|
{
|
||||||
|
downloadableContentContainerList.Add(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
container = new DownloadableContentContainer
|
||||||
|
{
|
||||||
|
ContainerPath = dlc.ContainerPath,
|
||||||
|
DownloadableContentNcaList = [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
container.DownloadableContentNcaList.Add(new DownloadableContentNca
|
||||||
|
{
|
||||||
|
Enabled = isEnabled,
|
||||||
|
TitleId = dlc.TitleId,
|
||||||
|
FullPath = dlc.FullPath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(container.ContainerPath))
|
||||||
|
{
|
||||||
|
downloadableContentContainerList.Add(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
var downloadableContentJsonPath = PathToGameDLCJson(applicationIdBase);
|
||||||
|
JsonHelper.SerializeToFile(downloadableContentJsonPath, downloadableContentContainerList, _serializerContext.ListDownloadableContentContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContents(VirtualFileSystem vfs, List<DownloadableContentContainer> downloadableContentContainers)
|
||||||
|
{
|
||||||
|
var result = new List<(DownloadableContentModel, bool IsEnabled)>();
|
||||||
|
|
||||||
|
foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers)
|
||||||
|
{
|
||||||
|
if (!File.Exists(downloadableContentContainer.ContainerPath))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
using IFileSystem partitionFileSystem = PartitionFileSystemUtils.OpenApplicationFileSystem(downloadableContentContainer.ContainerPath, vfs);
|
||||||
|
|
||||||
|
foreach (DownloadableContentNca downloadableContentNca in downloadableContentContainer.DownloadableContentNcaList)
|
||||||
|
{
|
||||||
|
using UniqueRef<IFile> ncaFile = new();
|
||||||
|
|
||||||
|
partitionFileSystem.OpenFile(ref ncaFile.Ref, downloadableContentNca.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||||
|
|
||||||
|
Nca nca = TryOpenNca(vfs, ncaFile.Get.AsStorage());
|
||||||
|
if (nca == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var content = new DownloadableContentModel(nca.Header.TitleId,
|
||||||
|
downloadableContentContainer.ContainerPath,
|
||||||
|
downloadableContentNca.FullPath);
|
||||||
|
|
||||||
|
result.Add((content, downloadableContentNca.Enabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Nca TryOpenNca(VirtualFileSystem vfs, IStorage ncaStorage)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new Nca(vfs.KeySet, ncaStorage);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string PathToGameDLCJson(ulong applicationIdBase)
|
||||||
|
{
|
||||||
|
return Path.Combine(AppDataManager.GamesDirPath, applicationIdBase.ToString("x16"), "dlc.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
162
src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs
Normal file
162
src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
using LibHac.Common;
|
||||||
|
using LibHac.Common.Keys;
|
||||||
|
using LibHac.Fs;
|
||||||
|
using LibHac.Fs.Fsa;
|
||||||
|
using LibHac.Ncm;
|
||||||
|
using LibHac.Ns;
|
||||||
|
using LibHac.Tools.FsSystem;
|
||||||
|
using LibHac.Tools.FsSystem.NcaUtils;
|
||||||
|
using Ryujinx.Common.Configuration;
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Common.Utilities;
|
||||||
|
using Ryujinx.HLE.FileSystem;
|
||||||
|
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||||
|
using Ryujinx.HLE.Utilities;
|
||||||
|
using Ryujinx.UI.Common.Configuration;
|
||||||
|
using Ryujinx.UI.Common.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using ContentType = LibHac.Ncm.ContentType;
|
||||||
|
using Path = System.IO.Path;
|
||||||
|
using SpanHelpers = LibHac.Common.SpanHelpers;
|
||||||
|
using TitleUpdateMetadata = Ryujinx.Common.Configuration.TitleUpdateMetadata;
|
||||||
|
|
||||||
|
namespace Ryujinx.UI.Common.Helper
|
||||||
|
{
|
||||||
|
public static class TitleUpdatesHelper
|
||||||
|
{
|
||||||
|
private static readonly TitleUpdateMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||||
|
|
||||||
|
public static List<(TitleUpdateModel, bool IsSelected)> LoadTitleUpdatesJson(VirtualFileSystem vfs, ulong applicationIdBase)
|
||||||
|
{
|
||||||
|
var titleUpdatesJsonPath = PathToGameUpdatesJson(applicationIdBase);
|
||||||
|
|
||||||
|
if (!File.Exists(titleUpdatesJsonPath))
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var titleUpdateWindowData = JsonHelper.DeserializeFromFile(titleUpdatesJsonPath, _serializerContext.TitleUpdateMetadata);
|
||||||
|
return LoadTitleUpdates(vfs, titleUpdateWindowData, applicationIdBase);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"Failed to deserialize title update data for {applicationIdBase:x16} at {titleUpdatesJsonPath}");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SaveTitleUpdatesJson(VirtualFileSystem vfs, ulong applicationIdBase, List<(TitleUpdateModel, bool IsSelected)> updates)
|
||||||
|
{
|
||||||
|
var titleUpdateWindowData = new TitleUpdateMetadata
|
||||||
|
{
|
||||||
|
Selected = "",
|
||||||
|
Paths = [],
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach ((TitleUpdateModel update, bool isSelected) in updates)
|
||||||
|
{
|
||||||
|
titleUpdateWindowData.Paths.Add(update.Path);
|
||||||
|
if (isSelected)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(titleUpdateWindowData.Selected))
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Application,
|
||||||
|
$"Tried to save two updates as 'IsSelected' for {applicationIdBase:x16}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
titleUpdateWindowData.Selected = update.Path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var titleUpdatesJsonPath = PathToGameUpdatesJson(applicationIdBase);
|
||||||
|
JsonHelper.SerializeToFile(titleUpdatesJsonPath, titleUpdateWindowData, _serializerContext.TitleUpdateMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<(TitleUpdateModel, bool IsSelected)> LoadTitleUpdates(VirtualFileSystem vfs, TitleUpdateMetadata titleUpdateMetadata, ulong applicationIdBase)
|
||||||
|
{
|
||||||
|
var result = new List<(TitleUpdateModel, bool IsSelected)>();
|
||||||
|
|
||||||
|
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
|
||||||
|
? IntegrityCheckLevel.ErrorOnInvalid
|
||||||
|
: IntegrityCheckLevel.None;
|
||||||
|
|
||||||
|
foreach (string path in titleUpdateMetadata.Paths)
|
||||||
|
{
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(path, vfs);
|
||||||
|
|
||||||
|
Dictionary<ulong, ContentMetaData> updates =
|
||||||
|
pfs.GetContentData(ContentMetaType.Patch, vfs, checkLevel);
|
||||||
|
|
||||||
|
Nca patchNca = null;
|
||||||
|
Nca controlNca = null;
|
||||||
|
|
||||||
|
if (!updates.TryGetValue(applicationIdBase, out ContentMetaData content))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
patchNca = content.GetNcaByType(vfs.KeySet, ContentType.Program);
|
||||||
|
controlNca = content.GetNcaByType(vfs.KeySet, ContentType.Control);
|
||||||
|
|
||||||
|
if (controlNca == null || patchNca == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationControlProperty controlData = new();
|
||||||
|
|
||||||
|
using UniqueRef<IFile> nacpFile = new();
|
||||||
|
|
||||||
|
controlNca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None)
|
||||||
|
.OpenFile(ref nacpFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||||
|
nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData), ReadOption.None)
|
||||||
|
.ThrowIfFailure();
|
||||||
|
|
||||||
|
var displayVersion = controlData.DisplayVersionString.ToString();
|
||||||
|
var update = new TitleUpdateModel(content.ApplicationId, content.Version.Version,
|
||||||
|
displayVersion, path);
|
||||||
|
|
||||||
|
result.Add((update, path == titleUpdateMetadata.Selected));
|
||||||
|
}
|
||||||
|
catch (MissingKeyException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"Your key set is missing a key with the name: {exception.Name}");
|
||||||
|
}
|
||||||
|
catch (InvalidDataException)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {path}");
|
||||||
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, exception.Message);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application,
|
||||||
|
$"The file encountered was not of a valid type. File: '{path}' Error: {exception}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string PathToGameUpdatesJson(ulong applicationIdBase)
|
||||||
|
{
|
||||||
|
return Path.Combine(AppDataManager.GamesDirPath, applicationIdBase.ToString("x16"), "updates.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
src/Ryujinx.UI.Common/Models/DownloadableContentModel.cs
Normal file
12
src/Ryujinx.UI.Common/Models/DownloadableContentModel.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
namespace Ryujinx.UI.Common.Models
|
||||||
|
{
|
||||||
|
// NOTE: most consuming code relies on this model being value-comparable
|
||||||
|
public record DownloadableContentModel(ulong TitleId, string ContainerPath, string FullPath)
|
||||||
|
{
|
||||||
|
public bool IsBundled { get; } = System.IO.Path.GetExtension(ContainerPath)?.ToLower() == ".xci";
|
||||||
|
|
||||||
|
public string FileName => System.IO.Path.GetFileName(ContainerPath);
|
||||||
|
public string TitleIdStr => TitleId.ToString("x16");
|
||||||
|
public ulong TitleIdBase => TitleId & ~0x1FFFUL;
|
||||||
|
}
|
||||||
|
}
|
11
src/Ryujinx.UI.Common/Models/TitleUpdateModel.cs
Normal file
11
src/Ryujinx.UI.Common/Models/TitleUpdateModel.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
namespace Ryujinx.UI.Common.Models
|
||||||
|
{
|
||||||
|
// NOTE: most consuming code relies on this model being value-comparable
|
||||||
|
public record TitleUpdateModel(ulong TitleId, ulong Version, string DisplayVersion, string Path)
|
||||||
|
{
|
||||||
|
public bool IsBundled { get; } = System.IO.Path.GetExtension(Path)?.ToLower() == ".xci";
|
||||||
|
|
||||||
|
public string TitleIdStr => TitleId.ToString("x16");
|
||||||
|
public ulong TitleIdBase => TitleId & ~0x1FFFUL;
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,6 +56,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DiscordRichPresence" />
|
<PackageReference Include="DiscordRichPresence" />
|
||||||
|
<PackageReference Include="DynamicData" />
|
||||||
<PackageReference Include="securifybv.ShellLink" />
|
<PackageReference Include="securifybv.ShellLink" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
"MenuBarFileOpenFromFile": "_Load Application From File",
|
"MenuBarFileOpenFromFile": "_Load Application From File",
|
||||||
"MenuBarFileOpenFromFileError": "No applications found in selected file.",
|
"MenuBarFileOpenFromFileError": "No applications found in selected file.",
|
||||||
"MenuBarFileOpenUnpacked": "Load _Unpacked Game",
|
"MenuBarFileOpenUnpacked": "Load _Unpacked Game",
|
||||||
|
"MenuBarFileLoadDlcFromFolder": "Load DLC From Folder",
|
||||||
|
"MenuBarFileLoadTitleUpdatesFromFolder": "Load Title Updates From Folder",
|
||||||
"MenuBarFileOpenEmuFolder": "Open Ryujinx Folder",
|
"MenuBarFileOpenEmuFolder": "Open Ryujinx Folder",
|
||||||
"MenuBarFileOpenLogsFolder": "Open Logs Folder",
|
"MenuBarFileOpenLogsFolder": "Open Logs Folder",
|
||||||
"MenuBarFileExit": "_Exit",
|
"MenuBarFileExit": "_Exit",
|
||||||
|
@ -103,6 +105,7 @@
|
||||||
"SettingsTabGeneralHideCursorOnIdle": "On Idle",
|
"SettingsTabGeneralHideCursorOnIdle": "On Idle",
|
||||||
"SettingsTabGeneralHideCursorAlways": "Always",
|
"SettingsTabGeneralHideCursorAlways": "Always",
|
||||||
"SettingsTabGeneralGameDirectories": "Game Directories",
|
"SettingsTabGeneralGameDirectories": "Game Directories",
|
||||||
|
"SettingsTabGeneralAutoloadDirectories": "Autoload DLC/Updates Directories",
|
||||||
"SettingsTabGeneralAdd": "Add",
|
"SettingsTabGeneralAdd": "Add",
|
||||||
"SettingsTabGeneralRemove": "Remove",
|
"SettingsTabGeneralRemove": "Remove",
|
||||||
"SettingsTabSystem": "System",
|
"SettingsTabSystem": "System",
|
||||||
|
@ -556,6 +559,9 @@
|
||||||
"AddGameDirBoxTooltip": "Enter a game directory to add to the list",
|
"AddGameDirBoxTooltip": "Enter a game directory to add to the list",
|
||||||
"AddGameDirTooltip": "Add a game directory to the list",
|
"AddGameDirTooltip": "Add a game directory to the list",
|
||||||
"RemoveGameDirTooltip": "Remove selected game directory",
|
"RemoveGameDirTooltip": "Remove selected game directory",
|
||||||
|
"AddAutoloadDirBoxTooltip": "Enter an autoload directory to add to the list",
|
||||||
|
"AddAutoloadDirTooltip": "Add an autoload directory to the list",
|
||||||
|
"RemoveAutoloadDirTooltip": "Remove selected autoload directory",
|
||||||
"CustomThemeCheckTooltip": "Use a custom Avalonia theme for the GUI to change the appearance of the emulator menus",
|
"CustomThemeCheckTooltip": "Use a custom Avalonia theme for the GUI to change the appearance of the emulator menus",
|
||||||
"CustomThemePathTooltip": "Path to custom GUI theme",
|
"CustomThemePathTooltip": "Path to custom GUI theme",
|
||||||
"CustomThemeBrowseTooltip": "Browse for a custom GUI theme",
|
"CustomThemeBrowseTooltip": "Browse for a custom GUI theme",
|
||||||
|
@ -599,6 +605,8 @@
|
||||||
"DebugLogTooltip": "Prints debug log messages in the console.\n\nOnly use this if specifically instructed by a staff member, as it will make logs difficult to read and worsen emulator performance.",
|
"DebugLogTooltip": "Prints debug log messages in the console.\n\nOnly use this if specifically instructed by a staff member, as it will make logs difficult to read and worsen emulator performance.",
|
||||||
"LoadApplicationFileTooltip": "Open a file explorer to choose a Switch compatible file to load",
|
"LoadApplicationFileTooltip": "Open a file explorer to choose a Switch compatible file to load",
|
||||||
"LoadApplicationFolderTooltip": "Open a file explorer to choose a Switch compatible, unpacked application to load",
|
"LoadApplicationFolderTooltip": "Open a file explorer to choose a Switch compatible, unpacked application to load",
|
||||||
|
"LoadDlcFromFolderTooltip": "Open a file explorer to choose one or more folders to bulk load DLC from",
|
||||||
|
"LoadTitleUpdatesFromFolderTooltip": "Open a file explorer to choose one or more folders to bulk load title updates from",
|
||||||
"OpenRyujinxFolderTooltip": "Open Ryujinx filesystem folder",
|
"OpenRyujinxFolderTooltip": "Open Ryujinx filesystem folder",
|
||||||
"OpenRyujinxLogsTooltip": "Opens the folder where logs are written to",
|
"OpenRyujinxLogsTooltip": "Opens the folder where logs are written to",
|
||||||
"ExitTooltip": "Exit Ryujinx",
|
"ExitTooltip": "Exit Ryujinx",
|
||||||
|
@ -709,9 +717,16 @@
|
||||||
"DlcWindowTitle": "Manage Downloadable Content for {0} ({1})",
|
"DlcWindowTitle": "Manage Downloadable Content for {0} ({1})",
|
||||||
"ModWindowTitle": "Manage Mods for {0} ({1})",
|
"ModWindowTitle": "Manage Mods for {0} ({1})",
|
||||||
"UpdateWindowTitle": "Title Update Manager",
|
"UpdateWindowTitle": "Title Update Manager",
|
||||||
|
"UpdateWindowUpdateAddedMessage": "{0} new update(s) added",
|
||||||
|
"UpdateWindowBundledContentNotice": "Bundled updates cannot be removed, only disabled.",
|
||||||
"CheatWindowHeading": "Cheats Available for {0} [{1}]",
|
"CheatWindowHeading": "Cheats Available for {0} [{1}]",
|
||||||
"BuildId": "BuildId:",
|
"BuildId": "BuildId:",
|
||||||
|
"DlcWindowBundledContentNotice": "Bundled DLC cannot be removed, only disabled.",
|
||||||
"DlcWindowHeading": "{0} Downloadable Content(s)",
|
"DlcWindowHeading": "{0} Downloadable Content(s)",
|
||||||
|
"DlcWindowDlcAddedMessage": "{0} new downloadable content(s) added",
|
||||||
|
"AutoloadDlcAddedMessage": "{0} new downloadable content(s) added",
|
||||||
|
"AutoloadUpdateAddedMessage": "{0} new update(s) added",
|
||||||
|
"AutoloadDlcAndUpdateAddedMessage": "{0} new downloadable content(s) and {1} new update(s) added",
|
||||||
"ModWindowHeading": "{0} Mod(s)",
|
"ModWindowHeading": "{0} Mod(s)",
|
||||||
"UserProfilesEditProfile": "Edit Selected",
|
"UserProfilesEditProfile": "Edit Selected",
|
||||||
"Cancel": "Cancel",
|
"Cancel": "Cancel",
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace Ryujinx.Ava.UI.Controls
|
||||||
|
|
||||||
if (viewModel?.SelectedApplication != null)
|
if (viewModel?.SelectedApplication != null)
|
||||||
{
|
{
|
||||||
await TitleUpdateWindow.Show(viewModel.VirtualFileSystem, viewModel.SelectedApplication);
|
await TitleUpdateWindow.Show(viewModel.ApplicationLibrary, viewModel.SelectedApplication);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ namespace Ryujinx.Ava.UI.Controls
|
||||||
|
|
||||||
if (viewModel?.SelectedApplication != null)
|
if (viewModel?.SelectedApplication != null)
|
||||||
{
|
{
|
||||||
await DownloadableContentManagerWindow.Show(viewModel.VirtualFileSystem, viewModel.SelectedApplication);
|
await DownloadableContentManagerWindow.Show(viewModel.ApplicationLibrary, viewModel.SelectedApplication);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
42
src/Ryujinx/UI/Helpers/DownloadableContentLabelConverter.cs
Normal file
42
src/Ryujinx/UI/Helpers/DownloadableContentLabelConverter.cs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Data;
|
||||||
|
using Avalonia.Data.Converters;
|
||||||
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
{
|
||||||
|
internal class DownloadableContentLabelConverter : IMultiValueConverter
|
||||||
|
{
|
||||||
|
public static DownloadableContentLabelConverter Instance = new();
|
||||||
|
|
||||||
|
public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (values.Any(it => it is UnsetValueType))
|
||||||
|
{
|
||||||
|
return BindingOperations.DoNothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.Count != 2 || !targetType.IsAssignableFrom(typeof(string)))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values is not [string label, bool isBundled])
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isBundled ? $"{LocaleManager.Instance[LocaleKeys.TitleBundledDlcLabel]} {label}" : label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object[] ConvertBack(object[] values, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,5 +5,6 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
List,
|
List,
|
||||||
Grid,
|
Grid,
|
||||||
Chip,
|
Chip,
|
||||||
|
Important,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
{ Glyph.List, char.ConvertFromUtf32((int)Symbol.List) },
|
{ Glyph.List, char.ConvertFromUtf32((int)Symbol.List) },
|
||||||
{ Glyph.Grid, char.ConvertFromUtf32((int)Symbol.ViewAll) },
|
{ Glyph.Grid, char.ConvertFromUtf32((int)Symbol.ViewAll) },
|
||||||
{ Glyph.Chip, char.ConvertFromUtf32(59748) },
|
{ Glyph.Chip, char.ConvertFromUtf32(59748) },
|
||||||
|
{ Glyph.Important, char.ConvertFromUtf32((int)Symbol.Important) },
|
||||||
};
|
};
|
||||||
|
|
||||||
public GlyphValueConverter(string key)
|
public GlyphValueConverter(string key)
|
||||||
|
|
42
src/Ryujinx/UI/Helpers/TitleUpdateLabelConverter.cs
Normal file
42
src/Ryujinx/UI/Helpers/TitleUpdateLabelConverter.cs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Data;
|
||||||
|
using Avalonia.Data.Converters;
|
||||||
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
{
|
||||||
|
internal class TitleUpdateLabelConverter : IMultiValueConverter
|
||||||
|
{
|
||||||
|
public static TitleUpdateLabelConverter Instance = new();
|
||||||
|
|
||||||
|
public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (values.Any(it => it is UnsetValueType))
|
||||||
|
{
|
||||||
|
return BindingOperations.DoNothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values.Count != 2 || !targetType.IsAssignableFrom(typeof(string)))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (values is not [string label, bool isBundled])
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var key = isBundled ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel;
|
||||||
|
return LocaleManager.Instance.UpdateAndGetDynamicValue(key, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object[] ConvertBack(object[] values, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,39 +0,0 @@
|
||||||
using Ryujinx.Ava.Common.Locale;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Models
|
|
||||||
{
|
|
||||||
public class DownloadableContentModel : BaseModel
|
|
||||||
{
|
|
||||||
private bool _enabled;
|
|
||||||
|
|
||||||
public bool Enabled
|
|
||||||
{
|
|
||||||
get => _enabled;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_enabled = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string TitleId { get; }
|
|
||||||
public string ContainerPath { get; }
|
|
||||||
public string FullPath { get; }
|
|
||||||
|
|
||||||
public string FileName => Path.GetFileName(ContainerPath);
|
|
||||||
|
|
||||||
public string Label =>
|
|
||||||
Path.GetExtension(FileName)?.ToLower() == ".xci" ? $"{LocaleManager.Instance[LocaleKeys.TitleBundledDlcLabel]} {FileName}" : FileName;
|
|
||||||
|
|
||||||
public DownloadableContentModel(string titleId, string containerPath, string fullPath, bool enabled)
|
|
||||||
{
|
|
||||||
TitleId = titleId;
|
|
||||||
ContainerPath = containerPath;
|
|
||||||
FullPath = fullPath;
|
|
||||||
Enabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
using Ryujinx.Ava.Common.Locale;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Models
|
|
||||||
{
|
|
||||||
public class TitleUpdateModel
|
|
||||||
{
|
|
||||||
public uint Version { get; }
|
|
||||||
public string Path { get; }
|
|
||||||
public string Label { get; }
|
|
||||||
|
|
||||||
public TitleUpdateModel(uint version, string displayVersion, string path)
|
|
||||||
{
|
|
||||||
Version = version;
|
|
||||||
Label = LocaleManager.Instance.UpdateAndGetDynamicValue(
|
|
||||||
System.IO.Path.GetExtension(path)?.ToLower() == ".xci" ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel,
|
|
||||||
displayVersion
|
|
||||||
);
|
|
||||||
Path = path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,47 +3,32 @@ using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using LibHac.Common;
|
using FluentAvalonia.UI.Controls;
|
||||||
using LibHac.Fs;
|
|
||||||
using LibHac.Fs.Fsa;
|
|
||||||
using LibHac.Tools.Fs;
|
|
||||||
using LibHac.Tools.FsSystem;
|
|
||||||
using LibHac.Tools.FsSystem.NcaUtils;
|
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.Models;
|
|
||||||
using Ryujinx.Common.Configuration;
|
|
||||||
using Ryujinx.Common.Logging;
|
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
|
||||||
using Ryujinx.HLE.Utilities;
|
|
||||||
using Ryujinx.UI.App.Common;
|
using Ryujinx.UI.App.Common;
|
||||||
using System;
|
using Ryujinx.UI.Common.Models;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Application = Avalonia.Application;
|
using Application = Avalonia.Application;
|
||||||
using Path = System.IO.Path;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.ViewModels
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
public class DownloadableContentManagerViewModel : BaseModel
|
public class DownloadableContentManagerViewModel : BaseModel
|
||||||
{
|
{
|
||||||
private readonly List<DownloadableContentContainer> _downloadableContentContainerList;
|
private readonly ApplicationLibrary _applicationLibrary;
|
||||||
private readonly string _downloadableContentJsonPath;
|
|
||||||
|
|
||||||
private readonly VirtualFileSystem _virtualFileSystem;
|
|
||||||
private AvaloniaList<DownloadableContentModel> _downloadableContents = new();
|
private AvaloniaList<DownloadableContentModel> _downloadableContents = new();
|
||||||
private AvaloniaList<DownloadableContentModel> _views = new();
|
|
||||||
private AvaloniaList<DownloadableContentModel> _selectedDownloadableContents = new();
|
private AvaloniaList<DownloadableContentModel> _selectedDownloadableContents = new();
|
||||||
|
private AvaloniaList<DownloadableContentModel> _views = new();
|
||||||
|
private bool _showBundledContentNotice = false;
|
||||||
|
|
||||||
private string _search;
|
private string _search;
|
||||||
private readonly ApplicationData _applicationData;
|
private readonly ApplicationData _applicationData;
|
||||||
private readonly IStorageProvider _storageProvider;
|
private readonly IStorageProvider _storageProvider;
|
||||||
|
|
||||||
private static readonly DownloadableContentJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
|
||||||
|
|
||||||
public AvaloniaList<DownloadableContentModel> DownloadableContents
|
public AvaloniaList<DownloadableContentModel> DownloadableContents
|
||||||
{
|
{
|
||||||
get => _downloadableContents;
|
get => _downloadableContents;
|
||||||
|
@ -92,9 +77,19 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
get => string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowHeading], DownloadableContents.Count);
|
get => string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowHeading], DownloadableContents.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadableContentManagerViewModel(VirtualFileSystem virtualFileSystem, ApplicationData applicationData)
|
public bool ShowBundledContentNotice
|
||||||
{
|
{
|
||||||
_virtualFileSystem = virtualFileSystem;
|
get => _showBundledContentNotice;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_showBundledContentNotice = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadableContentManagerViewModel(ApplicationLibrary applicationLibrary, ApplicationData applicationData)
|
||||||
|
{
|
||||||
|
_applicationLibrary = applicationLibrary;
|
||||||
|
|
||||||
_applicationData = applicationData;
|
_applicationData = applicationData;
|
||||||
|
|
||||||
|
@ -103,109 +98,68 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
_storageProvider = desktop.MainWindow.StorageProvider;
|
_storageProvider = desktop.MainWindow.StorageProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
_downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationData.IdBaseString, "dlc.json");
|
|
||||||
|
|
||||||
if (!File.Exists(_downloadableContentJsonPath))
|
|
||||||
{
|
|
||||||
_downloadableContentContainerList = new List<DownloadableContentContainer>();
|
|
||||||
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_downloadableContentContainerList = JsonHelper.DeserializeFromFile(_downloadableContentJsonPath, _serializerContext.ListDownloadableContentContainer);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Logger.Error?.Print(LogClass.Configuration, "Downloadable Content JSON failed to deserialize.");
|
|
||||||
_downloadableContentContainerList = new List<DownloadableContentContainer>();
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadDownloadableContents();
|
LoadDownloadableContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadDownloadableContents()
|
private void LoadDownloadableContents()
|
||||||
{
|
{
|
||||||
foreach (DownloadableContentContainer downloadableContentContainer in _downloadableContentContainerList)
|
var dlcs = _applicationLibrary.DownloadableContents.Items
|
||||||
{
|
.Where(it => it.Dlc.TitleIdBase == _applicationData.IdBase);
|
||||||
if (File.Exists(downloadableContentContainer.ContainerPath))
|
|
||||||
{
|
|
||||||
using IFileSystem partitionFileSystem = PartitionFileSystemUtils.OpenApplicationFileSystem(downloadableContentContainer.ContainerPath, _virtualFileSystem);
|
|
||||||
|
|
||||||
foreach (DownloadableContentNca downloadableContentNca in downloadableContentContainer.DownloadableContentNcaList)
|
bool hasBundledContent = false;
|
||||||
|
foreach ((DownloadableContentModel dlc, bool isEnabled) in dlcs)
|
||||||
{
|
{
|
||||||
using UniqueRef<IFile> ncaFile = new();
|
DownloadableContents.Add(dlc);
|
||||||
|
hasBundledContent = hasBundledContent || dlc.IsBundled;
|
||||||
|
|
||||||
partitionFileSystem.OpenFile(ref ncaFile.Ref, downloadableContentNca.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
if (isEnabled)
|
||||||
|
|
||||||
Nca nca = TryOpenNca(ncaFile.Get.AsStorage(), downloadableContentContainer.ContainerPath);
|
|
||||||
if (nca != null)
|
|
||||||
{
|
{
|
||||||
var content = new DownloadableContentModel(nca.Header.TitleId.ToString("X16"),
|
SelectedDownloadableContents.Add(dlc);
|
||||||
downloadableContentContainer.ContainerPath,
|
|
||||||
downloadableContentNca.FullPath,
|
|
||||||
downloadableContentNca.Enabled);
|
|
||||||
|
|
||||||
DownloadableContents.Add(content);
|
|
||||||
|
|
||||||
if (content.Enabled)
|
|
||||||
{
|
|
||||||
SelectedDownloadableContents.Add(content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPropertyChanged(nameof(UpdateCount));
|
OnPropertyChanged(nameof(UpdateCount));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: Try to load downloadable contents from PFS last to preserve enabled state.
|
ShowBundledContentNotice = hasBundledContent;
|
||||||
AddDownloadableContent(_applicationData.Path);
|
|
||||||
|
|
||||||
// NOTE: Save the list again to remove leftovers.
|
|
||||||
Save();
|
|
||||||
Sort();
|
Sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sort()
|
public void Sort()
|
||||||
{
|
{
|
||||||
DownloadableContents.AsObservableChangeSet()
|
DownloadableContents
|
||||||
|
// Sort bundled last
|
||||||
|
.OrderBy(it => it.IsBundled ? 0 : 1)
|
||||||
|
.ThenBy(it => it.TitleId)
|
||||||
|
.AsObservableChangeSet()
|
||||||
.Filter(Filter)
|
.Filter(Filter)
|
||||||
.Bind(out var view).AsObservableList();
|
.Bind(out var view).AsObservableList();
|
||||||
|
|
||||||
|
// NOTE(jpr): this works around a bug where calling _views.Clear also clears SelectedDownloadableContents for
|
||||||
|
// some reason. so we save the items here and add them back after
|
||||||
|
var items = SelectedDownloadableContents.ToArray();
|
||||||
|
|
||||||
_views.Clear();
|
_views.Clear();
|
||||||
_views.AddRange(view);
|
_views.AddRange(view);
|
||||||
|
|
||||||
|
foreach (DownloadableContentModel item in items)
|
||||||
|
{
|
||||||
|
SelectedDownloadableContents.ReplaceOrAdd(item, item);
|
||||||
|
}
|
||||||
|
|
||||||
OnPropertyChanged(nameof(Views));
|
OnPropertyChanged(nameof(Views));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Filter(object arg)
|
private bool Filter<T>(T arg)
|
||||||
{
|
{
|
||||||
if (arg is DownloadableContentModel content)
|
if (arg is DownloadableContentModel content)
|
||||||
{
|
{
|
||||||
return string.IsNullOrWhiteSpace(_search) || content.FileName.ToLower().Contains(_search.ToLower()) || content.TitleId.ToLower().Contains(_search.ToLower());
|
return string.IsNullOrWhiteSpace(_search) || content.FileName.ToLower().Contains(_search.ToLower()) || content.TitleIdStr.ToLower().Contains(_search.ToLower());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Nca TryOpenNca(IStorage ncaStorage, string containerPath)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return new Nca(_virtualFileSystem.KeySet, ncaStorage);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
|
||||||
{
|
|
||||||
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance[LocaleKeys.DialogLoadFileErrorMessage], ex.Message, containerPath));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Add()
|
public async void Add()
|
||||||
{
|
{
|
||||||
var result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
var result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
|
@ -223,78 +177,88 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var totalDlcAdded = 0;
|
||||||
foreach (var file in result)
|
foreach (var file in result)
|
||||||
{
|
{
|
||||||
if (!AddDownloadableContent(file.Path.LocalPath))
|
if (!AddDownloadableContent(file.Path.LocalPath, out var newDlcAdded))
|
||||||
{
|
{
|
||||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogDlcNoDlcErrorMessage]);
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogDlcNoDlcErrorMessage]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
totalDlcAdded += newDlcAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AddDownloadableContent(string path)
|
if (totalDlcAdded > 0)
|
||||||
{
|
{
|
||||||
if (!File.Exists(path) || _downloadableContentContainerList.Any(x => x.ContainerPath == path))
|
await ShowNewDlcAddedDialog(totalDlcAdded);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
using IFileSystem partitionFileSystem = PartitionFileSystemUtils.OpenApplicationFileSystem(path, _virtualFileSystem);
|
|
||||||
|
|
||||||
bool success = false;
|
|
||||||
foreach (DirectoryEntryEx fileEntry in partitionFileSystem.EnumerateEntries("/", "*.nca"))
|
|
||||||
{
|
|
||||||
using var ncaFile = new UniqueRef<IFile>();
|
|
||||||
|
|
||||||
partitionFileSystem.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
|
||||||
|
|
||||||
Nca nca = TryOpenNca(ncaFile.Get.AsStorage(), path);
|
|
||||||
if (nca == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nca.Header.ContentType == NcaContentType.PublicData)
|
|
||||||
{
|
|
||||||
if (nca.GetProgramIdBase() != _applicationData.IdBase)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var content = new DownloadableContentModel(nca.Header.TitleId.ToString("X16"), path, fileEntry.FullPath, true);
|
|
||||||
DownloadableContents.Add(content);
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() => SelectedDownloadableContents.Add(content));
|
|
||||||
|
|
||||||
success = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success)
|
private bool AddDownloadableContent(string path, out int numDlcAdded)
|
||||||
|
{
|
||||||
|
numDlcAdded = 0;
|
||||||
|
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_applicationLibrary.TryGetDownloadableContentFromFile(path, out var dlcs) || dlcs.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dlcsForThisGame = dlcs.Where(it => it.TitleIdBase == _applicationData.IdBase).ToList();
|
||||||
|
if (dlcsForThisGame.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var dlc in dlcsForThisGame)
|
||||||
|
{
|
||||||
|
if (!DownloadableContents.Contains(dlc))
|
||||||
|
{
|
||||||
|
DownloadableContents.Add(dlc);
|
||||||
|
SelectedDownloadableContents.ReplaceOrAdd(dlc, dlc);
|
||||||
|
|
||||||
|
numDlcAdded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numDlcAdded > 0)
|
||||||
{
|
{
|
||||||
OnPropertyChanged(nameof(UpdateCount));
|
OnPropertyChanged(nameof(UpdateCount));
|
||||||
Sort();
|
Sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(DownloadableContentModel model)
|
public void Remove(DownloadableContentModel model)
|
||||||
|
{
|
||||||
|
SelectedDownloadableContents.Remove(model);
|
||||||
|
|
||||||
|
if (!model.IsBundled)
|
||||||
{
|
{
|
||||||
DownloadableContents.Remove(model);
|
DownloadableContents.Remove(model);
|
||||||
OnPropertyChanged(nameof(UpdateCount));
|
OnPropertyChanged(nameof(UpdateCount));
|
||||||
Sort();
|
Sort();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void RemoveAll()
|
public void RemoveAll()
|
||||||
{
|
{
|
||||||
DownloadableContents.Clear();
|
SelectedDownloadableContents.Clear();
|
||||||
|
DownloadableContents.RemoveMany(DownloadableContents.Where(it => !it.IsBundled));
|
||||||
|
|
||||||
OnPropertyChanged(nameof(UpdateCount));
|
OnPropertyChanged(nameof(UpdateCount));
|
||||||
Sort();
|
Sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnableAll()
|
public void EnableAll()
|
||||||
{
|
{
|
||||||
SelectedDownloadableContents = new(DownloadableContents);
|
SelectedDownloadableContents.Clear();
|
||||||
|
SelectedDownloadableContents.AddRange(DownloadableContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisableAll()
|
public void DisableAll()
|
||||||
|
@ -302,43 +266,29 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
SelectedDownloadableContents.Clear();
|
SelectedDownloadableContents.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Enable(DownloadableContentModel model)
|
||||||
|
{
|
||||||
|
SelectedDownloadableContents.ReplaceOrAdd(model, model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Disable(DownloadableContentModel model)
|
||||||
|
{
|
||||||
|
SelectedDownloadableContents.Remove(model);
|
||||||
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
_downloadableContentContainerList.Clear();
|
var dlcs = DownloadableContents.Select(it => (it, SelectedDownloadableContents.Contains(it))).ToList();
|
||||||
|
_applicationLibrary.SaveDownloadableContentsForGame(_applicationData, dlcs);
|
||||||
DownloadableContentContainer container = default;
|
|
||||||
|
|
||||||
foreach (DownloadableContentModel downloadableContent in DownloadableContents)
|
|
||||||
{
|
|
||||||
if (container.ContainerPath != downloadableContent.ContainerPath)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(container.ContainerPath))
|
|
||||||
{
|
|
||||||
_downloadableContentContainerList.Add(container);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
container = new DownloadableContentContainer
|
private Task ShowNewDlcAddedDialog(int numAdded)
|
||||||
{
|
{
|
||||||
ContainerPath = downloadableContent.ContainerPath,
|
var msg = string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowDlcAddedMessage], numAdded);
|
||||||
DownloadableContentNcaList = new List<DownloadableContentNca>(),
|
return Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
container.DownloadableContentNcaList.Add(new DownloadableContentNca
|
|
||||||
{
|
{
|
||||||
Enabled = downloadableContent.Enabled,
|
await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle], msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);
|
||||||
TitleId = Convert.ToUInt64(downloadableContent.TitleId, 16),
|
|
||||||
FullPath = downloadableContent.FullPath,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(container.ContainerPath))
|
|
||||||
{
|
|
||||||
_downloadableContentContainerList.Add(container);
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonHelper.SerializeToFile(_downloadableContentJsonPath, _downloadableContentContainerList, _serializerContext.ListDownloadableContentContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ using Avalonia.Media;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
|
using DynamicData.Alias;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
|
using FluentAvalonia.UI.Controls;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
using Ryujinx.Ava.Common;
|
using Ryujinx.Ava.Common;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
@ -38,6 +40,7 @@ using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Key = Ryujinx.Input.Key;
|
using Key = Ryujinx.Input.Key;
|
||||||
|
@ -50,7 +53,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
private const int HotKeyPressDelayMs = 500;
|
private const int HotKeyPressDelayMs = 500;
|
||||||
|
|
||||||
private ObservableCollection<ApplicationData> _applications;
|
private ObservableCollectionExtended<ApplicationData> _applications;
|
||||||
private string _aspectStatusText;
|
private string _aspectStatusText;
|
||||||
|
|
||||||
private string _loadHeading;
|
private string _loadHeading;
|
||||||
|
@ -112,7 +115,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
public MainWindowViewModel()
|
public MainWindowViewModel()
|
||||||
{
|
{
|
||||||
Applications = new ObservableCollection<ApplicationData>();
|
Applications = new ObservableCollectionExtended<ApplicationData>();
|
||||||
|
|
||||||
Applications.ToObservableChangeSet()
|
Applications.ToObservableChangeSet()
|
||||||
.Filter(Filter)
|
.Filter(Filter)
|
||||||
|
@ -741,7 +744,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
get => FileAssociationHelper.IsTypeAssociationSupported;
|
get => FileAssociationHelper.IsTypeAssociationSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<ApplicationData> Applications
|
public ObservableCollectionExtended<ApplicationData> Applications
|
||||||
{
|
{
|
||||||
get => _applications;
|
get => _applications;
|
||||||
set
|
set
|
||||||
|
@ -1256,6 +1259,30 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
_rendererWaitEvent.Set();
|
_rendererWaitEvent.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task LoadContentFromFolder(LocaleKeys localeMessageKey, Func<List<string>, int> onDirsSelected)
|
||||||
|
{
|
||||||
|
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||||
|
{
|
||||||
|
Title = LocaleManager.Instance[LocaleKeys.OpenFolderDialogTitle],
|
||||||
|
AllowMultiple = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.Count > 0)
|
||||||
|
{
|
||||||
|
var dirs = result.Select(it => it.Path.LocalPath).ToList();
|
||||||
|
var numAdded = onDirsSelected(dirs);
|
||||||
|
|
||||||
|
var msg = string.Format(LocaleManager.Instance[localeMessageKey], numAdded);
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
await ContentDialogHelper.ShowTextDialog(
|
||||||
|
LocaleManager.Instance[numAdded > 0 ? LocaleKeys.RyujinxConfirm : LocaleKeys.RyujinxInfo],
|
||||||
|
msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region PublicMethods
|
#region PublicMethods
|
||||||
|
@ -1504,6 +1531,18 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task LoadDlcFromFolder()
|
||||||
|
{
|
||||||
|
await LoadContentFromFolder(LocaleKeys.AutoloadDlcAddedMessage,
|
||||||
|
dirs => ApplicationLibrary.AutoLoadDownloadableContents(dirs));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LoadTitleUpdatesFromFolder()
|
||||||
|
{
|
||||||
|
await LoadContentFromFolder(LocaleKeys.AutoloadUpdateAddedMessage,
|
||||||
|
dirs => ApplicationLibrary.AutoLoadTitleUpdates(dirs));
|
||||||
|
}
|
||||||
|
|
||||||
public async Task OpenFolder()
|
public async Task OpenFolder()
|
||||||
{
|
{
|
||||||
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||||
|
|
|
@ -44,7 +44,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
private int _graphicsBackendMultithreadingIndex;
|
private int _graphicsBackendMultithreadingIndex;
|
||||||
private float _volume;
|
private float _volume;
|
||||||
private bool _isVulkanAvailable = true;
|
private bool _isVulkanAvailable = true;
|
||||||
private bool _directoryChanged;
|
private bool _gameDirectoryChanged;
|
||||||
|
private bool _autoloadDirectoryChanged;
|
||||||
private readonly List<string> _gpuIds = new();
|
private readonly List<string> _gpuIds = new();
|
||||||
private int _graphicsBackendIndex;
|
private int _graphicsBackendIndex;
|
||||||
private int _scalingFilter;
|
private int _scalingFilter;
|
||||||
|
@ -115,12 +116,23 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
public bool IsHypervisorAvailable => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
|
public bool IsHypervisorAvailable => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
|
||||||
|
|
||||||
public bool DirectoryChanged
|
public bool GameDirectoryChanged
|
||||||
{
|
{
|
||||||
get => _directoryChanged;
|
get => _gameDirectoryChanged;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_directoryChanged = value;
|
_gameDirectoryChanged = value;
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AutoloadDirectoryChanged
|
||||||
|
{
|
||||||
|
get => _autoloadDirectoryChanged;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_autoloadDirectoryChanged = value;
|
||||||
|
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
}
|
}
|
||||||
|
@ -230,6 +242,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
internal AvaloniaList<TimeZone> TimeZones { get; set; }
|
internal AvaloniaList<TimeZone> TimeZones { get; set; }
|
||||||
public AvaloniaList<string> GameDirectories { get; set; }
|
public AvaloniaList<string> GameDirectories { get; set; }
|
||||||
|
public AvaloniaList<string> AutoloadDirectories { get; set; }
|
||||||
public ObservableCollection<ComboBoxItem> AvailableGpus { get; set; }
|
public ObservableCollection<ComboBoxItem> AvailableGpus { get; set; }
|
||||||
|
|
||||||
public AvaloniaList<string> NetworkInterfaceList
|
public AvaloniaList<string> NetworkInterfaceList
|
||||||
|
@ -272,6 +285,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
public SettingsViewModel()
|
public SettingsViewModel()
|
||||||
{
|
{
|
||||||
GameDirectories = new AvaloniaList<string>();
|
GameDirectories = new AvaloniaList<string>();
|
||||||
|
AutoloadDirectories = new AvaloniaList<string>();
|
||||||
TimeZones = new AvaloniaList<TimeZone>();
|
TimeZones = new AvaloniaList<TimeZone>();
|
||||||
AvailableGpus = new ObservableCollection<ComboBoxItem>();
|
AvailableGpus = new ObservableCollection<ComboBoxItem>();
|
||||||
_validTzRegions = new List<string>();
|
_validTzRegions = new List<string>();
|
||||||
|
@ -397,6 +411,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
GameDirectories.Clear();
|
GameDirectories.Clear();
|
||||||
GameDirectories.AddRange(config.UI.GameDirs.Value);
|
GameDirectories.AddRange(config.UI.GameDirs.Value);
|
||||||
|
|
||||||
|
AutoloadDirectories.Clear();
|
||||||
|
AutoloadDirectories.AddRange(config.UI.AutoloadDirs.Value);
|
||||||
|
|
||||||
BaseStyleIndex = config.UI.BaseStyle.Value switch
|
BaseStyleIndex = config.UI.BaseStyle.Value switch
|
||||||
{
|
{
|
||||||
"Auto" => 0,
|
"Auto" => 0,
|
||||||
|
@ -486,12 +503,18 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
config.RememberWindowState.Value = RememberWindowState;
|
config.RememberWindowState.Value = RememberWindowState;
|
||||||
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
||||||
|
|
||||||
if (_directoryChanged)
|
if (_gameDirectoryChanged)
|
||||||
{
|
{
|
||||||
List<string> gameDirs = new(GameDirectories);
|
List<string> gameDirs = new(GameDirectories);
|
||||||
config.UI.GameDirs.Value = gameDirs;
|
config.UI.GameDirs.Value = gameDirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_autoloadDirectoryChanged)
|
||||||
|
{
|
||||||
|
List<string> autoloadDirs = new(AutoloadDirectories);
|
||||||
|
config.UI.AutoloadDirs.Value = autoloadDirs;
|
||||||
|
}
|
||||||
|
|
||||||
config.UI.BaseStyle.Value = BaseStyleIndex switch
|
config.UI.BaseStyle.Value = BaseStyleIndex switch
|
||||||
{
|
{
|
||||||
0 => "Auto",
|
0 => "Auto",
|
||||||
|
@ -587,7 +610,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
SaveSettingsEvent?.Invoke();
|
SaveSettingsEvent?.Invoke();
|
||||||
|
|
||||||
_directoryChanged = false;
|
_gameDirectoryChanged = false;
|
||||||
|
_autoloadDirectoryChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RevertIfNotSaved()
|
private static void RevertIfNotSaved()
|
||||||
|
|
|
@ -2,48 +2,31 @@ using Avalonia.Collections;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using LibHac.Common;
|
using FluentAvalonia.UI.Controls;
|
||||||
using LibHac.Fs;
|
|
||||||
using LibHac.Fs.Fsa;
|
|
||||||
using LibHac.Ncm;
|
|
||||||
using LibHac.Ns;
|
|
||||||
using LibHac.Tools.FsSystem;
|
|
||||||
using LibHac.Tools.FsSystem.NcaUtils;
|
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.Models;
|
|
||||||
using Ryujinx.Common.Configuration;
|
|
||||||
using Ryujinx.Common.Logging;
|
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
|
||||||
using Ryujinx.HLE.Utilities;
|
|
||||||
using Ryujinx.UI.App.Common;
|
using Ryujinx.UI.App.Common;
|
||||||
using Ryujinx.UI.Common.Configuration;
|
using Ryujinx.UI.Common.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Application = Avalonia.Application;
|
using Application = Avalonia.Application;
|
||||||
using ContentType = LibHac.Ncm.ContentType;
|
|
||||||
using Path = System.IO.Path;
|
|
||||||
using SpanHelpers = LibHac.Common.SpanHelpers;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.ViewModels
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
|
public record TitleUpdateViewNoUpdateSentinal();
|
||||||
|
|
||||||
public class TitleUpdateViewModel : BaseModel
|
public class TitleUpdateViewModel : BaseModel
|
||||||
{
|
{
|
||||||
public TitleUpdateMetadata TitleUpdateWindowData;
|
private ApplicationLibrary ApplicationLibrary { get; }
|
||||||
public readonly string TitleUpdateJsonPath;
|
|
||||||
private VirtualFileSystem VirtualFileSystem { get; }
|
|
||||||
private ApplicationData ApplicationData { get; }
|
private ApplicationData ApplicationData { get; }
|
||||||
|
|
||||||
private AvaloniaList<TitleUpdateModel> _titleUpdates = new();
|
private AvaloniaList<TitleUpdateModel> _titleUpdates = new();
|
||||||
private AvaloniaList<object> _views = new();
|
private AvaloniaList<object> _views = new();
|
||||||
private object _selectedUpdate;
|
private object _selectedUpdate = new TitleUpdateViewNoUpdateSentinal();
|
||||||
|
private bool _showBundledContentNotice = false;
|
||||||
private static readonly TitleUpdateMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
|
||||||
|
|
||||||
public AvaloniaList<TitleUpdateModel> TitleUpdates
|
public AvaloniaList<TitleUpdateModel> TitleUpdates
|
||||||
{
|
{
|
||||||
|
@ -75,11 +58,21 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShowBundledContentNotice
|
||||||
|
{
|
||||||
|
get => _showBundledContentNotice;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_showBundledContentNotice = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IStorageProvider StorageProvider;
|
public IStorageProvider StorageProvider;
|
||||||
|
|
||||||
public TitleUpdateViewModel(VirtualFileSystem virtualFileSystem, ApplicationData applicationData)
|
public TitleUpdateViewModel(ApplicationLibrary applicationLibrary, ApplicationData applicationData)
|
||||||
{
|
{
|
||||||
VirtualFileSystem = virtualFileSystem;
|
ApplicationLibrary = applicationLibrary;
|
||||||
|
|
||||||
ApplicationData = applicationData;
|
ApplicationData = applicationData;
|
||||||
|
|
||||||
|
@ -88,44 +81,29 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
StorageProvider = desktop.MainWindow.StorageProvider;
|
StorageProvider = desktop.MainWindow.StorageProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleUpdateJsonPath = Path.Combine(AppDataManager.GamesDirPath, ApplicationData.IdBaseString, "updates.json");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
TitleUpdateWindowData = JsonHelper.DeserializeFromFile(TitleUpdateJsonPath, _serializerContext.TitleUpdateMetadata);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"Failed to deserialize title update data for {ApplicationData.IdBaseString} at {TitleUpdateJsonPath}");
|
|
||||||
|
|
||||||
TitleUpdateWindowData = new TitleUpdateMetadata
|
|
||||||
{
|
|
||||||
Selected = "",
|
|
||||||
Paths = new List<string>(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadUpdates();
|
LoadUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadUpdates()
|
private void LoadUpdates()
|
||||||
{
|
{
|
||||||
// Try to load updates from PFS first
|
var updates = ApplicationLibrary.TitleUpdates.Items
|
||||||
AddUpdate(ApplicationData.Path, true);
|
.Where(it => it.TitleUpdate.TitleIdBase == ApplicationData.IdBase);
|
||||||
|
|
||||||
foreach (string path in TitleUpdateWindowData.Paths)
|
bool hasBundledContent = false;
|
||||||
|
SelectedUpdate = new TitleUpdateViewNoUpdateSentinal();
|
||||||
|
foreach ((TitleUpdateModel update, bool isSelected) in updates)
|
||||||
{
|
{
|
||||||
AddUpdate(path);
|
TitleUpdates.Add(update);
|
||||||
|
hasBundledContent = hasBundledContent || update.IsBundled;
|
||||||
|
|
||||||
|
if (isSelected)
|
||||||
|
{
|
||||||
|
SelectedUpdate = update;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleUpdateModel selected = TitleUpdates.FirstOrDefault(x => x.Path == TitleUpdateWindowData.Selected, null);
|
ShowBundledContentNotice = hasBundledContent;
|
||||||
|
|
||||||
SelectedUpdate = selected;
|
|
||||||
|
|
||||||
// NOTE: Save the list again to remove leftovers.
|
|
||||||
Save();
|
|
||||||
SortUpdates();
|
SortUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,89 +111,76 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
var sortedUpdates = TitleUpdates.OrderByDescending(update => update.Version);
|
var sortedUpdates = TitleUpdates.OrderByDescending(update => update.Version);
|
||||||
|
|
||||||
|
// NOTE(jpr): this works around a bug where calling Views.Clear also clears SelectedUpdate for
|
||||||
|
// some reason. so we save the item here and restore it after
|
||||||
|
var selected = SelectedUpdate;
|
||||||
|
|
||||||
Views.Clear();
|
Views.Clear();
|
||||||
Views.Add(new BaseModel());
|
Views.Add(new TitleUpdateViewNoUpdateSentinal());
|
||||||
Views.AddRange(sortedUpdates);
|
Views.AddRange(sortedUpdates);
|
||||||
|
|
||||||
if (SelectedUpdate == null)
|
SelectedUpdate = selected;
|
||||||
|
|
||||||
|
if (SelectedUpdate is TitleUpdateViewNoUpdateSentinal)
|
||||||
{
|
{
|
||||||
SelectedUpdate = Views[0];
|
SelectedUpdate = Views[0];
|
||||||
}
|
}
|
||||||
else if (!TitleUpdates.Contains(SelectedUpdate))
|
// this is mainly to handle a scenario where the user removes the selected update
|
||||||
|
else if (!TitleUpdates.Contains((TitleUpdateModel)SelectedUpdate))
|
||||||
{
|
{
|
||||||
if (Views.Count > 1)
|
SelectedUpdate = Views.Count > 1 ? Views[1] : Views[0];
|
||||||
{
|
|
||||||
SelectedUpdate = Views[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SelectedUpdate = Views[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool AddUpdate(string path, out int numUpdatesAdded)
|
||||||
|
{
|
||||||
|
numUpdatesAdded = 0;
|
||||||
|
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddUpdate(string path, bool ignoreNotFound = false, bool selected = false)
|
if (!ApplicationLibrary.TryGetTitleUpdatesFromFile(path, out var updates))
|
||||||
{
|
{
|
||||||
if (!File.Exists(path) || TitleUpdates.Any(x => x.Path == path))
|
return false;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
|
var updatesForThisGame = updates.Where(it => it.TitleIdBase == ApplicationData.Id).ToList();
|
||||||
? IntegrityCheckLevel.ErrorOnInvalid
|
if (updatesForThisGame.Count == 0)
|
||||||
: IntegrityCheckLevel.None;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(path, VirtualFileSystem);
|
return false;
|
||||||
|
|
||||||
Dictionary<ulong, ContentMetaData> updates = pfs.GetContentData(ContentMetaType.Patch, VirtualFileSystem, checkLevel);
|
|
||||||
|
|
||||||
Nca patchNca = null;
|
|
||||||
Nca controlNca = null;
|
|
||||||
|
|
||||||
if (updates.TryGetValue(ApplicationData.Id, out ContentMetaData content))
|
|
||||||
{
|
|
||||||
patchNca = content.GetNcaByType(VirtualFileSystem.KeySet, ContentType.Program);
|
|
||||||
controlNca = content.GetNcaByType(VirtualFileSystem.KeySet, ContentType.Control);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controlNca != null && patchNca != null)
|
foreach (var update in updatesForThisGame)
|
||||||
|
{
|
||||||
|
if (!TitleUpdates.Contains(update))
|
||||||
{
|
{
|
||||||
ApplicationControlProperty controlData = new();
|
|
||||||
|
|
||||||
using UniqueRef<IFile> nacpFile = new();
|
|
||||||
|
|
||||||
controlNca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None).OpenFile(ref nacpFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
|
||||||
nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData), ReadOption.None).ThrowIfFailure();
|
|
||||||
|
|
||||||
var displayVersion = controlData.DisplayVersionString.ToString();
|
|
||||||
var update = new TitleUpdateModel(content.Version.Version, displayVersion, path);
|
|
||||||
|
|
||||||
TitleUpdates.Add(update);
|
TitleUpdates.Add(update);
|
||||||
|
SelectedUpdate = update;
|
||||||
|
|
||||||
if (selected)
|
numUpdatesAdded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numUpdatesAdded > 0)
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.InvokeAsync(() => SelectedUpdate = update);
|
SortUpdates();
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!ignoreNotFound)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() => ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUpdateAddUpdateErrorMessage]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() => ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogLoadFileErrorMessage, ex.Message, path)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveUpdate(TitleUpdateModel update)
|
public void RemoveUpdate(TitleUpdateModel update)
|
||||||
|
{
|
||||||
|
if (!update.IsBundled)
|
||||||
{
|
{
|
||||||
TitleUpdates.Remove(update);
|
TitleUpdates.Remove(update);
|
||||||
|
}
|
||||||
|
else if (update == SelectedUpdate as TitleUpdateModel)
|
||||||
|
{
|
||||||
|
SelectedUpdate = new TitleUpdateViewNoUpdateSentinal();
|
||||||
|
}
|
||||||
|
|
||||||
SortUpdates();
|
SortUpdates();
|
||||||
}
|
}
|
||||||
|
@ -236,30 +201,36 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var totalUpdatesAdded = 0;
|
||||||
foreach (var file in result)
|
foreach (var file in result)
|
||||||
{
|
{
|
||||||
AddUpdate(file.Path.LocalPath, selected: true);
|
if (!AddUpdate(file.Path.LocalPath, out var newUpdatesAdded))
|
||||||
|
{
|
||||||
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUpdateAddUpdateErrorMessage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SortUpdates();
|
totalUpdatesAdded += newUpdatesAdded;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalUpdatesAdded > 0)
|
||||||
|
{
|
||||||
|
await ShowNewUpdatesAddedDialog(totalUpdatesAdded);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
TitleUpdateWindowData.Paths.Clear();
|
var updates = TitleUpdates.Select(it => (it, it == SelectedUpdate as TitleUpdateModel)).ToList();
|
||||||
TitleUpdateWindowData.Selected = "";
|
ApplicationLibrary.SaveTitleUpdatesForGame(ApplicationData, updates);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (TitleUpdateModel update in TitleUpdates)
|
private Task ShowNewUpdatesAddedDialog(int numAdded)
|
||||||
{
|
{
|
||||||
TitleUpdateWindowData.Paths.Add(update.Path);
|
var msg = string.Format(LocaleManager.Instance[LocaleKeys.UpdateWindowUpdateAddedMessage], numAdded);
|
||||||
|
return Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
if (update == SelectedUpdate)
|
|
||||||
{
|
{
|
||||||
TitleUpdateWindowData.Selected = update.Path;
|
await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle], msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
||||||
JsonHelper.SerializeToFile(TitleUpdateJsonPath, TitleUpdateWindowData, _serializerContext.TitleUpdateMetadata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,16 @@
|
||||||
Header="{locale:Locale MenuBarFileOpenUnpacked}"
|
Header="{locale:Locale MenuBarFileOpenUnpacked}"
|
||||||
IsEnabled="{Binding EnableNonGameRunningControls}"
|
IsEnabled="{Binding EnableNonGameRunningControls}"
|
||||||
ToolTip.Tip="{locale:Locale LoadApplicationFolderTooltip}" />
|
ToolTip.Tip="{locale:Locale LoadApplicationFolderTooltip}" />
|
||||||
|
<MenuItem
|
||||||
|
Command="{Binding LoadDlcFromFolder}"
|
||||||
|
Header="{locale:Locale MenuBarFileLoadDlcFromFolder}"
|
||||||
|
IsEnabled="{Binding EnableNonGameRunningControls}"
|
||||||
|
ToolTip.Tip="{locale:Locale LoadDlcFromFolderTooltip}" />
|
||||||
|
<MenuItem
|
||||||
|
Command="{Binding LoadTitleUpdatesFromFolder}"
|
||||||
|
Header="{locale:Locale MenuBarFileLoadTitleUpdatesFromFolder}"
|
||||||
|
IsEnabled="{Binding EnableNonGameRunningControls}"
|
||||||
|
ToolTip.Tip="{locale:Locale LoadTitleUpdatesFromFolderTooltip}" />
|
||||||
<MenuItem Header="{locale:Locale MenuBarFileOpenApplet}" IsEnabled="{Binding IsAppletMenuActive}">
|
<MenuItem Header="{locale:Locale MenuBarFileOpenApplet}" IsEnabled="{Binding IsAppletMenuActive}">
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Click="OpenMiiApplet"
|
Click="OpenMiiApplet"
|
||||||
|
|
|
@ -85,8 +85,8 @@
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
Spacing="10">
|
Spacing="10">
|
||||||
<ListBox
|
<ListBox
|
||||||
Name="GameList"
|
Name="GameDirsList"
|
||||||
MinHeight="230"
|
MinHeight="120"
|
||||||
ItemsSource="{Binding GameDirectories}">
|
ItemsSource="{Binding GameDirectories}">
|
||||||
<ListBox.Styles>
|
<ListBox.Styles>
|
||||||
<Style Selector="ListBoxItem">
|
<Style Selector="ListBoxItem">
|
||||||
|
@ -102,27 +102,78 @@
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBox
|
<TextBox
|
||||||
Name="PathBox"
|
Name="GameDirPathBox"
|
||||||
Margin="0"
|
Margin="0"
|
||||||
ToolTip.Tip="{locale:Locale AddGameDirBoxTooltip}"
|
ToolTip.Tip="{locale:Locale AddGameDirBoxTooltip}"
|
||||||
VerticalAlignment="Stretch" />
|
VerticalAlignment="Stretch" />
|
||||||
<Button
|
<Button
|
||||||
Name="AddButton"
|
Name="AddGameDirButton"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
MinWidth="90"
|
MinWidth="90"
|
||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
ToolTip.Tip="{locale:Locale AddGameDirTooltip}"
|
ToolTip.Tip="{locale:Locale AddGameDirTooltip}"
|
||||||
Click="AddButton_OnClick">
|
Click="AddGameDirButton_OnClick">
|
||||||
<TextBlock HorizontalAlignment="Center"
|
<TextBlock HorizontalAlignment="Center"
|
||||||
Text="{locale:Locale SettingsTabGeneralAdd}" />
|
Text="{locale:Locale SettingsTabGeneralAdd}" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
Name="RemoveButton"
|
Name="RemoveGameDirButton"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
MinWidth="90"
|
MinWidth="90"
|
||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
ToolTip.Tip="{locale:Locale RemoveGameDirTooltip}"
|
ToolTip.Tip="{locale:Locale RemoveGameDirTooltip}"
|
||||||
Click="RemoveButton_OnClick">
|
Click="RemoveGameDirButton_OnClick">
|
||||||
|
<TextBlock HorizontalAlignment="Center"
|
||||||
|
Text="{locale:Locale SettingsTabGeneralRemove}" />
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
<Separator Height="1" />
|
||||||
|
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabGeneralAutoloadDirectories}" />
|
||||||
|
<StackPanel
|
||||||
|
Margin="10,0,0,0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Orientation="Vertical"
|
||||||
|
Spacing="10">
|
||||||
|
<ListBox
|
||||||
|
Name="AutoloadDirsList"
|
||||||
|
MinHeight="120"
|
||||||
|
ItemsSource="{Binding AutoloadDirectories}">
|
||||||
|
<ListBox.Styles>
|
||||||
|
<Style Selector="ListBoxItem">
|
||||||
|
<Setter Property="Padding" Value="10" />
|
||||||
|
<Setter Property="Background" Value="{DynamicResource ListBoxBackground}" />
|
||||||
|
</Style>
|
||||||
|
</ListBox.Styles>
|
||||||
|
</ListBox>
|
||||||
|
<Grid HorizontalAlignment="Stretch">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBox
|
||||||
|
Name="AutoloadDirPathBox"
|
||||||
|
Margin="0"
|
||||||
|
ToolTip.Tip="{locale:Locale AddAutoloadDirBoxTooltip}"
|
||||||
|
VerticalAlignment="Stretch" />
|
||||||
|
<Button
|
||||||
|
Name="AddAutoloadDirButton"
|
||||||
|
Grid.Column="1"
|
||||||
|
MinWidth="90"
|
||||||
|
Margin="10,0,0,0"
|
||||||
|
ToolTip.Tip="{locale:Locale AddAutoloadDirTooltip}"
|
||||||
|
Click="AddAutoloadDirButton_OnClick">
|
||||||
|
<TextBlock HorizontalAlignment="Center"
|
||||||
|
Text="{locale:Locale SettingsTabGeneralAdd}" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
Name="RemoveAutoloadDirButton"
|
||||||
|
Grid.Column="2"
|
||||||
|
MinWidth="90"
|
||||||
|
Margin="10,0,0,0"
|
||||||
|
ToolTip.Tip="{locale:Locale RemoveAutoloadDirTooltip}"
|
||||||
|
Click="RemoveAutoloadDirButton_OnClick">
|
||||||
<TextBlock HorizontalAlignment="Center"
|
<TextBlock HorizontalAlignment="Center"
|
||||||
Text="{locale:Locale SettingsTabGeneralRemove}" />
|
Text="{locale:Locale SettingsTabGeneralRemove}" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -19,14 +19,14 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void AddButton_OnClick(object sender, RoutedEventArgs e)
|
private async void AddGameDirButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
string path = PathBox.Text;
|
string path = GameDirPathBox.Text;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !ViewModel.GameDirectories.Contains(path))
|
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !ViewModel.GameDirectories.Contains(path))
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Add(path);
|
ViewModel.GameDirectories.Add(path);
|
||||||
ViewModel.DirectoryChanged = true;
|
ViewModel.GameDirectoryChanged = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -40,25 +40,68 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
if (result.Count > 0)
|
if (result.Count > 0)
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Add(result[0].Path.LocalPath);
|
ViewModel.GameDirectories.Add(result[0].Path.LocalPath);
|
||||||
ViewModel.DirectoryChanged = true;
|
ViewModel.GameDirectoryChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveButton_OnClick(object sender, RoutedEventArgs e)
|
private void RemoveGameDirButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
int oldIndex = GameList.SelectedIndex;
|
int oldIndex = GameDirsList.SelectedIndex;
|
||||||
|
|
||||||
foreach (string path in new List<string>(GameList.SelectedItems.Cast<string>()))
|
foreach (string path in new List<string>(GameDirsList.SelectedItems.Cast<string>()))
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Remove(path);
|
ViewModel.GameDirectories.Remove(path);
|
||||||
ViewModel.DirectoryChanged = true;
|
ViewModel.GameDirectoryChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameList.ItemCount > 0)
|
if (GameDirsList.ItemCount > 0)
|
||||||
{
|
{
|
||||||
GameList.SelectedIndex = oldIndex < GameList.ItemCount ? oldIndex : 0;
|
GameDirsList.SelectedIndex = oldIndex < GameDirsList.ItemCount ? oldIndex : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void AddAutoloadDirButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
string path = AutoloadDirPathBox.Text;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path) && !ViewModel.AutoloadDirectories.Contains(path))
|
||||||
|
{
|
||||||
|
ViewModel.AutoloadDirectories.Add(path);
|
||||||
|
ViewModel.AutoloadDirectoryChanged = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this.GetVisualRoot() is Window window)
|
||||||
|
{
|
||||||
|
var result = await window.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||||
|
{
|
||||||
|
AllowMultiple = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.Count > 0)
|
||||||
|
{
|
||||||
|
ViewModel.AutoloadDirectories.Add(result[0].Path.LocalPath);
|
||||||
|
ViewModel.AutoloadDirectoryChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveAutoloadDirButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
int oldIndex = AutoloadDirsList.SelectedIndex;
|
||||||
|
|
||||||
|
foreach (string path in new List<string>(AutoloadDirsList.SelectedItems.Cast<string>()))
|
||||||
|
{
|
||||||
|
ViewModel.AutoloadDirectories.Remove(path);
|
||||||
|
ViewModel.AutoloadDirectoryChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AutoloadDirsList.ItemCount > 0)
|
||||||
|
{
|
||||||
|
AutoloadDirsList.SelectedIndex = oldIndex < AutoloadDirsList.ItemCount ? oldIndex : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,22 +6,44 @@
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||||
xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
|
xmlns:models="clr-namespace:Ryujinx.UI.Common.Models;assembly=Ryujinx.UI.Common"
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
Width="500"
|
Width="500"
|
||||||
Height="380"
|
Height="380"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
x:DataType="viewModels:DownloadableContentManagerViewModel"
|
x:DataType="viewModels:DownloadableContentManagerViewModel"
|
||||||
Focusable="True">
|
Focusable="True">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<helpers:DownloadableContentLabelConverter x:Key="DownloadableContentLabel" />
|
||||||
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="0"
|
||||||
|
Margin="0 0 0 10"
|
||||||
|
Spacing="5"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
IsVisible="{Binding ShowBundledContentNotice}">
|
||||||
|
<ui:FontIcon
|
||||||
|
Margin="0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
FontFamily="avares://FluentAvalonia/Fonts#Symbols"
|
||||||
|
Glyph="{helpers:GlyphValueConverter Important}" />
|
||||||
|
<!-- NOTE: aligning to bottom for better visual alignment with glyph -->
|
||||||
|
<TextBlock
|
||||||
|
FontStyle="Italic"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Text="{locale:Locale DlcWindowBundledContentNotice}" />
|
||||||
|
</StackPanel>
|
||||||
<Panel
|
<Panel
|
||||||
Margin="0 0 0 10"
|
Margin="0 0 0 10"
|
||||||
Grid.Row="0">
|
Grid.Row="1">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
@ -60,7 +82,7 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
</Panel>
|
</Panel>
|
||||||
<Border
|
<Border
|
||||||
Grid.Row="1"
|
Grid.Row="2"
|
||||||
Margin="0 0 0 24"
|
Margin="0 0 0 24"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
|
@ -73,7 +95,7 @@
|
||||||
SelectionMode="Multiple, Toggle"
|
SelectionMode="Multiple, Toggle"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
SelectionChanged="OnSelectionChanged"
|
SelectionChanged="OnSelectionChanged"
|
||||||
SelectedItems="{Binding SelectedDownloadableContents, Mode=TwoWay}"
|
SelectedItems="{Binding SelectedDownloadableContents, Mode=OneWay}"
|
||||||
ItemsSource="{Binding Views}">
|
ItemsSource="{Binding Views}">
|
||||||
<ListBox.DataTemplates>
|
<ListBox.DataTemplates>
|
||||||
<DataTemplate
|
<DataTemplate
|
||||||
|
@ -96,8 +118,14 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
MaxLines="2"
|
MaxLines="2"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
TextTrimming="CharacterEllipsis"
|
TextTrimming="CharacterEllipsis">
|
||||||
Text="{Binding Label}" />
|
<TextBlock.Text>
|
||||||
|
<MultiBinding Converter="{StaticResource DownloadableContentLabel}">
|
||||||
|
<Binding Path="FileName" />
|
||||||
|
<Binding Path="IsBundled" />
|
||||||
|
</MultiBinding>
|
||||||
|
</TextBlock.Text>
|
||||||
|
</TextBlock>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="10 0"
|
Margin="10 0"
|
||||||
|
@ -147,7 +175,7 @@
|
||||||
</ListBox>
|
</ListBox>
|
||||||
</Border>
|
</Border>
|
||||||
<Panel
|
<Panel
|
||||||
Grid.Row="2"
|
Grid.Row="3"
|
||||||
HorizontalAlignment="Stretch">
|
HorizontalAlignment="Stretch">
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
|
|
|
@ -3,11 +3,10 @@ using Avalonia.Interactivity;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Models;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.HLE.FileSystem;
|
|
||||||
using Ryujinx.UI.App.Common;
|
using Ryujinx.UI.App.Common;
|
||||||
using Ryujinx.UI.Common.Helper;
|
using Ryujinx.UI.Common.Helper;
|
||||||
|
using Ryujinx.UI.Common.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Windows
|
namespace Ryujinx.Ava.UI.Windows
|
||||||
|
@ -23,21 +22,21 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadableContentManagerWindow(VirtualFileSystem virtualFileSystem, ApplicationData applicationData)
|
public DownloadableContentManagerWindow(ApplicationLibrary applicationLibrary, ApplicationData applicationData)
|
||||||
{
|
{
|
||||||
DataContext = ViewModel = new DownloadableContentManagerViewModel(virtualFileSystem, applicationData);
|
DataContext = ViewModel = new DownloadableContentManagerViewModel(applicationLibrary, applicationData);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task Show(VirtualFileSystem virtualFileSystem, ApplicationData applicationData)
|
public static async Task Show(ApplicationLibrary applicationLibrary, ApplicationData applicationData)
|
||||||
{
|
{
|
||||||
ContentDialog contentDialog = new()
|
ContentDialog contentDialog = new()
|
||||||
{
|
{
|
||||||
PrimaryButtonText = "",
|
PrimaryButtonText = "",
|
||||||
SecondaryButtonText = "",
|
SecondaryButtonText = "",
|
||||||
CloseButtonText = "",
|
CloseButtonText = "",
|
||||||
Content = new DownloadableContentManagerWindow(virtualFileSystem, applicationData),
|
Content = new DownloadableContentManagerWindow(applicationLibrary, applicationData),
|
||||||
Title = string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowTitle], applicationData.Name, applicationData.IdBaseString),
|
Title = string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowTitle], applicationData.Name, applicationData.IdBaseString),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,12 +87,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
{
|
{
|
||||||
if (content is DownloadableContentModel model)
|
if (content is DownloadableContentModel model)
|
||||||
{
|
{
|
||||||
var index = ViewModel.DownloadableContents.IndexOf(model);
|
ViewModel.Enable(model);
|
||||||
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
ViewModel.DownloadableContents[index].Enabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,12 +95,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
{
|
{
|
||||||
if (content is DownloadableContentModel model)
|
if (content is DownloadableContentModel model)
|
||||||
{
|
{
|
||||||
var index = ViewModel.DownloadableContents.IndexOf(model);
|
ViewModel.Disable(model);
|
||||||
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
ViewModel.DownloadableContents[index].Enabled = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
using DynamicData;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using LibHac.Tools.FsSystem;
|
using LibHac.Tools.FsSystem;
|
||||||
using Ryujinx.Ava.Common;
|
using Ryujinx.Ava.Common;
|
||||||
|
@ -26,6 +27,7 @@ using Ryujinx.UI.Common.Configuration;
|
||||||
using Ryujinx.UI.Common.Helper;
|
using Ryujinx.UI.Common.Helper;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reactive.Linq;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -45,6 +47,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
private static string _launchApplicationId;
|
private static string _launchApplicationId;
|
||||||
private static bool _startFullscreen;
|
private static bool _startFullscreen;
|
||||||
internal readonly AvaHostUIHandler UiHandler;
|
internal readonly AvaHostUIHandler UiHandler;
|
||||||
|
private IDisposable _appLibraryAppsSubscription;
|
||||||
|
|
||||||
public VirtualFileSystem VirtualFileSystem { get; private set; }
|
public VirtualFileSystem VirtualFileSystem { get; private set; }
|
||||||
public ContentManager ContentManager { get; private set; }
|
public ContentManager ContentManager { get; private set; }
|
||||||
|
@ -136,14 +139,6 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
Program.DesktopScaleFactor = this.RenderScaling;
|
Program.DesktopScaleFactor = this.RenderScaling;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplicationLibrary_ApplicationAdded(object sender, ApplicationAddedEventArgs e)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
{
|
|
||||||
ViewModel.Applications.Add(e.AppData);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ApplicationLibrary_ApplicationCountUpdated(object sender, ApplicationCountUpdatedEventArgs e)
|
private void ApplicationLibrary_ApplicationCountUpdated(object sender, ApplicationCountUpdatedEventArgs e)
|
||||||
{
|
{
|
||||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarGamesLoaded, e.NumAppsLoaded, e.NumAppsFound);
|
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarGamesLoaded, e.NumAppsLoaded, e.NumAppsFound);
|
||||||
|
@ -475,7 +470,12 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
this);
|
this);
|
||||||
|
|
||||||
ApplicationLibrary.ApplicationCountUpdated += ApplicationLibrary_ApplicationCountUpdated;
|
ApplicationLibrary.ApplicationCountUpdated += ApplicationLibrary_ApplicationCountUpdated;
|
||||||
ApplicationLibrary.ApplicationAdded += ApplicationLibrary_ApplicationAdded;
|
_appLibraryAppsSubscription?.Dispose();
|
||||||
|
_appLibraryAppsSubscription = ApplicationLibrary.Applications
|
||||||
|
.Connect()
|
||||||
|
.ObserveOn(SynchronizationContext.Current)
|
||||||
|
.Bind(ViewModel.Applications)
|
||||||
|
.Subscribe();
|
||||||
|
|
||||||
ViewModel.RefreshFirmwareStatus();
|
ViewModel.RefreshFirmwareStatus();
|
||||||
|
|
||||||
|
@ -578,6 +578,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
ApplicationLibrary.CancelLoading();
|
ApplicationLibrary.CancelLoading();
|
||||||
InputManager.Dispose();
|
InputManager.Dispose();
|
||||||
|
_appLibraryAppsSubscription?.Dispose();
|
||||||
Program.Exit();
|
Program.Exit();
|
||||||
|
|
||||||
base.OnClosing(e);
|
base.OnClosing(e);
|
||||||
|
@ -599,7 +600,6 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
public void LoadApplications()
|
public void LoadApplications()
|
||||||
{
|
{
|
||||||
_applicationsLoadedOnce = true;
|
_applicationsLoadedOnce = true;
|
||||||
ViewModel.Applications.Clear();
|
|
||||||
|
|
||||||
StatusBarView.LoadProgressBar.IsVisible = true;
|
StatusBarView.LoadProgressBar.IsVisible = true;
|
||||||
ViewModel.StatusBarProgressMaximum = 0;
|
ViewModel.StatusBarProgressMaximum = 0;
|
||||||
|
@ -641,8 +641,18 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
Thread applicationLibraryThread = new(() =>
|
Thread applicationLibraryThread = new(() =>
|
||||||
{
|
{
|
||||||
ApplicationLibrary.DesiredLanguage = ConfigurationState.Instance.System.Language;
|
ApplicationLibrary.DesiredLanguage = ConfigurationState.Instance.System.Language;
|
||||||
|
|
||||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
|
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
|
||||||
|
|
||||||
|
var autoloadDirs = ConfigurationState.Instance.UI.AutoloadDirs.Value;
|
||||||
|
if (autoloadDirs.Count > 0)
|
||||||
|
{
|
||||||
|
var updatesLoaded = ApplicationLibrary.AutoLoadTitleUpdates(autoloadDirs);
|
||||||
|
var dlcLoaded = ApplicationLibrary.AutoLoadDownloadableContents(autoloadDirs);
|
||||||
|
|
||||||
|
ShowNewContentAddedDialog(dlcLoaded, updatesLoaded);
|
||||||
|
}
|
||||||
|
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
@ -651,5 +661,33 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
};
|
};
|
||||||
applicationLibraryThread.Start();
|
applicationLibraryThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Task ShowNewContentAddedDialog(int numDlcAdded, int numUpdatesAdded)
|
||||||
|
{
|
||||||
|
var msg = "";
|
||||||
|
|
||||||
|
if (numDlcAdded > 0 && numUpdatesAdded > 0)
|
||||||
|
{
|
||||||
|
msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAndUpdateAddedMessage], numDlcAdded, numUpdatesAdded);
|
||||||
|
}
|
||||||
|
else if (numDlcAdded > 0)
|
||||||
|
{
|
||||||
|
msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAddedMessage], numDlcAdded);
|
||||||
|
}
|
||||||
|
else if (numUpdatesAdded > 0)
|
||||||
|
{
|
||||||
|
msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateAddedMessage], numUpdatesAdded);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle],
|
||||||
|
msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
{
|
{
|
||||||
InputPage.InputView?.SaveCurrentProfile();
|
InputPage.InputView?.SaveCurrentProfile();
|
||||||
|
|
||||||
if (Owner is MainWindow window && ViewModel.DirectoryChanged)
|
if (Owner is MainWindow window && (ViewModel.GameDirectoryChanged || ViewModel.AutoloadDirectoryChanged))
|
||||||
{
|
{
|
||||||
window.LoadApplications();
|
window.LoadApplications();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,20 +6,42 @@
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||||
xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
|
xmlns:models="clr-namespace:Ryujinx.UI.Common.Models;assembly=Ryujinx.UI.Common"
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
Width="500"
|
Width="500"
|
||||||
Height="300"
|
Height="300"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
x:DataType="viewModels:TitleUpdateViewModel"
|
x:DataType="viewModels:TitleUpdateViewModel"
|
||||||
Focusable="True">
|
Focusable="True">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<helpers:TitleUpdateLabelConverter x:Key="TitleUpdateLabel" />
|
||||||
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Border
|
<StackPanel
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
|
Margin="0 0 0 10"
|
||||||
|
Spacing="5"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
IsVisible="{Binding ShowBundledContentNotice}">
|
||||||
|
<ui:FontIcon
|
||||||
|
Margin="0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
FontFamily="avares://FluentAvalonia/Fonts#Symbols"
|
||||||
|
Glyph="{helpers:GlyphValueConverter Important}" />
|
||||||
|
<!-- NOTE: aligning to bottom for better visual alignment with glyph -->
|
||||||
|
<TextBlock
|
||||||
|
FontStyle="Italic"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Text="{locale:Locale UpdateWindowBundledContentNotice}" />
|
||||||
|
</StackPanel>
|
||||||
|
<Border
|
||||||
|
Grid.Row="1"
|
||||||
Margin="0 0 0 24"
|
Margin="0 0 0 24"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
|
@ -38,8 +60,14 @@
|
||||||
<TextBlock
|
<TextBlock
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap">
|
||||||
Text="{Binding Label}" />
|
<TextBlock.Text>
|
||||||
|
<MultiBinding Converter="{StaticResource TitleUpdateLabel}">
|
||||||
|
<Binding Path="DisplayVersion" />
|
||||||
|
<Binding Path="IsBundled" />
|
||||||
|
</MultiBinding>
|
||||||
|
</TextBlock.Text>
|
||||||
|
</TextBlock>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Spacing="10"
|
Spacing="10"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
|
@ -72,7 +100,7 @@
|
||||||
</Panel>
|
</Panel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate
|
<DataTemplate
|
||||||
DataType="viewModels:BaseModel">
|
DataType="viewModels:TitleUpdateViewNoUpdateSentinal">
|
||||||
<Panel
|
<Panel
|
||||||
Height="33"
|
Height="33"
|
||||||
Margin="10">
|
Margin="10">
|
||||||
|
@ -92,7 +120,7 @@
|
||||||
</ListBox>
|
</ListBox>
|
||||||
</Border>
|
</Border>
|
||||||
<Panel
|
<Panel
|
||||||
Grid.Row="1"
|
Grid.Row="2"
|
||||||
HorizontalAlignment="Stretch">
|
HorizontalAlignment="Stretch">
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
|
|
|
@ -5,11 +5,10 @@ using Avalonia.Interactivity;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Models;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.HLE.FileSystem;
|
|
||||||
using Ryujinx.UI.App.Common;
|
using Ryujinx.UI.App.Common;
|
||||||
using Ryujinx.UI.Common.Helper;
|
using Ryujinx.UI.Common.Helper;
|
||||||
|
using Ryujinx.UI.Common.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Windows
|
namespace Ryujinx.Ava.UI.Windows
|
||||||
|
@ -25,21 +24,21 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TitleUpdateWindow(VirtualFileSystem virtualFileSystem, ApplicationData applicationData)
|
public TitleUpdateWindow(ApplicationLibrary applicationLibrary, ApplicationData applicationData)
|
||||||
{
|
{
|
||||||
DataContext = ViewModel = new TitleUpdateViewModel(virtualFileSystem, applicationData);
|
DataContext = ViewModel = new TitleUpdateViewModel(applicationLibrary, applicationData);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task Show(VirtualFileSystem virtualFileSystem, ApplicationData applicationData)
|
public static async Task Show(ApplicationLibrary applicationLibrary, ApplicationData applicationData)
|
||||||
{
|
{
|
||||||
ContentDialog contentDialog = new()
|
ContentDialog contentDialog = new()
|
||||||
{
|
{
|
||||||
PrimaryButtonText = "",
|
PrimaryButtonText = "",
|
||||||
SecondaryButtonText = "",
|
SecondaryButtonText = "",
|
||||||
CloseButtonText = "",
|
CloseButtonText = "",
|
||||||
Content = new TitleUpdateWindow(virtualFileSystem, applicationData),
|
Content = new TitleUpdateWindow(applicationLibrary, applicationData),
|
||||||
Title = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.GameUpdateWindowHeading, applicationData.Name, applicationData.IdBaseString),
|
Title = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.GameUpdateWindowHeading, applicationData.Name, applicationData.IdBaseString),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,17 +59,6 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
{
|
{
|
||||||
ViewModel.Save();
|
ViewModel.Save();
|
||||||
|
|
||||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime al)
|
|
||||||
{
|
|
||||||
foreach (Window window in al.Windows)
|
|
||||||
{
|
|
||||||
if (window is MainWindow mainWindow)
|
|
||||||
{
|
|
||||||
mainWindow.LoadApplications();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
((ContentDialog)Parent).Hide();
|
((ContentDialog)Parent).Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue