UI: Only show DLC RomFS button under Extract Data when DLCs are available.

Also convert the constructor of DlcSelectViewModel to expect a normal title id and not one already converted to the base ID.
This commit is contained in:
Evan Husted 2025-02-04 17:21:54 -06:00 committed by KeatonTheBot
parent 2471bb8ede
commit d3bce3f361
5 changed files with 23 additions and 4 deletions

View file

@ -127,6 +127,24 @@ namespace Ryujinx.UI.App.Common
return data; return data;
} }
public bool FindUpdate(ulong id, out TitleUpdateModel foundData)
{
Gommon.Optional<TitleUpdateModel> appData =
TitleUpdates.Keys.FindFirst(x => x.TitleId == id);
foundData = appData.HasValue ? appData.Value : null;
return appData.HasValue;
}
public TitleUpdateModel[] FindUpdatesFor(ulong id)
=> TitleUpdates.Keys.Where(x => x.TitleIdBase == (id & ~0x1FFFUL)).ToArray();
public DownloadableContentModel[] FindDlcsFor(ulong id)
=> DownloadableContents.Keys.Where(x => x.TitleIdBase == (id & ~0x1FFFUL)).ToArray();
public bool HasDlcs(ulong id)
=> DownloadableContents.Keys.Any(x => x.TitleIdBase == (id & ~0x1FFFUL));
/// <exception cref="LibHac.Common.Keys.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>

View file

@ -98,6 +98,7 @@
Header="{locale:Locale GameListContextMenuExtractDataRomFS}" Header="{locale:Locale GameListContextMenuExtractDataRomFS}"
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataRomFSToolTip}" /> ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataRomFSToolTip}" />
<MenuItem <MenuItem
IsVisible="{Binding HasDlc}"
Click="ExtractAocRomFs_Click" Click="ExtractAocRomFs_Click"
Header="{locale:Locale GameListContextMenuExtractDataAocRomFS}" Header="{locale:Locale GameListContextMenuExtractDataAocRomFS}"
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataAocRomFSToolTip}" /> ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataAocRomFSToolTip}" />

View file

@ -378,7 +378,7 @@ namespace Ryujinx.Ava.UI.Controls
if (sender is not MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel }) if (sender is not MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel })
return; return;
DownloadableContentModel selectedDlc = await DlcSelectView.Show(viewModel.SelectedApplication.IdBase, viewModel.ApplicationLibrary); DownloadableContentModel selectedDlc = await DlcSelectView.Show(viewModel.SelectedApplication.Id, viewModel.ApplicationLibrary);
if (selectedDlc is not null) if (selectedDlc is not null)
{ {

View file

@ -34,9 +34,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public DlcSelectViewModel(ulong titleId, ApplicationLibrary appLibrary) public DlcSelectViewModel(ulong titleId, ApplicationLibrary appLibrary)
{ {
_dlcs = appLibrary.DownloadableContents.Items _dlcs = appLibrary.FindDlcsFor(titleId)
.Where(x => x.Dlc.TitleIdBase == titleId)
.Select(x => x.Dlc)
.OrderBy(it => it.IsBundled ? 0 : 1) .OrderBy(it => it.IsBundled ? 0 : 1)
.ThenBy(it => it.TitleId) .ThenBy(it => it.TitleId)
.ToArray(); .ToArray();

View file

@ -481,6 +481,8 @@ namespace Ryujinx.Ava.UI.ViewModels
} }
} }
public bool HasDlc => ApplicationLibrary.HasDlcs(SelectedApplication.Id);
public string CacheLoadStatus public string CacheLoadStatus
{ {
get => _cacheLoadStatus; get => _cacheLoadStatus;