Skip to content

Commit

Permalink
UI: Only show DLC RomFS button under Extract Data when DLCs are avail…
Browse files Browse the repository at this point in the history
…able.

Also convert the constructor of DlcSelectViewModel to expect a normal title id and not one already converted to the base ID.
  • Loading branch information
GreemDev committed Feb 4, 2025
1 parent fafb99c commit e8a7d5b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Ryujinx/UI/Controls/ApplicationContextMenu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
Header="{ext:Locale GameListContextMenuExtractDataRomFS}"
ToolTip.Tip="{ext:Locale GameListContextMenuExtractDataRomFSToolTip}" />
<MenuItem
IsVisible="{Binding HasDlc}"
Click="ExtractAocRomFs_Click"
Header="{ext:Locale GameListContextMenuExtractDataAocRomFS}"
ToolTip.Tip="{ext:Locale GameListContextMenuExtractDataAocRomFSToolTip}" />
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx/UI/Controls/ApplicationContextMenu.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public async void ExtractAocRomFs_Click(object sender, RoutedEventArgs args)
if (sender is not MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel })
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)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Ryujinx/UI/ViewModels/DlcSelectViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public partial class DlcSelectViewModel : BaseModel

public DlcSelectViewModel(ulong titleId, ApplicationLibrary appLibrary)
{
_dlcs = appLibrary.DownloadableContents.Items
.Where(x => x.Dlc.TitleIdBase == titleId)
.Select(x => x.Dlc)
_dlcs = appLibrary.FindDlcsFor(titleId)
.OrderBy(it => it.IsBundled ? 0 : 1)
.ThenBy(it => it.TitleId)
.ToArray();
Expand Down
2 changes: 2 additions & 0 deletions src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ public bool HasCompatibilityEntry
}
}

public bool HasDlc => ApplicationLibrary.HasDlcs(SelectedApplication.Id);

public bool OpenUserSaveDirectoryEnabled => SelectedApplication.HasControlHolder && SelectedApplication.ControlHolder.Value.UserAccountSaveDataSize > 0;

public bool OpenDeviceSaveDirectoryEnabled => SelectedApplication.HasControlHolder && SelectedApplication.ControlHolder.Value.DeviceSaveDataSize > 0;
Expand Down
18 changes: 18 additions & 0 deletions src/Ryujinx/Utilities/AppLibrary/ApplicationLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@ public bool FindApplication(ulong id, out ApplicationData foundData)

return appData.HasValue;
}

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="InvalidDataException">The NCA header could not be decrypted.</exception>
Expand Down

0 comments on commit e8a7d5b

Please sign in to comment.