diff --git a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs index 987052fad..a7b0a080e 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs @@ -786,12 +786,33 @@ namespace Ryujinx.UI.App.Common foreach (ApplicationData application in Applications.Items) { - var res = DownloadableContentsHelper.LoadDownloadableContentsJson(_virtualFileSystem, application.IdBase); - it.AddOrUpdate(res); + 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); + } + } } }); } - + public void SaveDownloadableContentsForGame(ApplicationData application, List<(DownloadableContentModel, bool IsEnabled)> dlcs) { _downloadableContents.Edit(it => diff --git a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs index 7f1e83d38..18e17ff64 100644 --- a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs @@ -21,8 +21,8 @@ namespace Ryujinx.Ava.UI.ViewModels { private readonly ApplicationLibrary _applicationLibrary; private AvaloniaList _downloadableContents = new(); - private AvaloniaList _views = new(); private AvaloniaList _selectedDownloadableContents = new(); + private AvaloniaList _views = new(); private string _search; private readonly ApplicationData _applicationData; @@ -106,14 +106,6 @@ namespace Ryujinx.Ava.UI.ViewModels OnPropertyChanged(nameof(UpdateCount)); } - // NOTE: Try to load downloadable contents from PFS last to preserve enabled state. - if (AddDownloadableContent(_applicationData.Path, out var newDlc) && newDlc > 0) - { - ShowNewDlcAddedDialog(newDlc); - } - - // NOTE: Save the list again to remove leftovers. - Save(); Sort(); } @@ -182,7 +174,7 @@ namespace Ryujinx.Ava.UI.ViewModels if (totalDlcAdded > 0) { - await ShowNewDlcAddedDialog(0); + await ShowNewDlcAddedDialog(totalDlcAdded); } } @@ -205,7 +197,7 @@ namespace Ryujinx.Ava.UI.ViewModels if (!DownloadableContents.Contains(dlc)) { DownloadableContents.Add(dlc); - Dispatcher.UIThread.InvokeAsync(() => SelectedDownloadableContents.ReplaceOrAdd(dlc, dlc)); + SelectedDownloadableContents.ReplaceOrAdd(dlc, dlc); numDlcAdded++; } @@ -276,6 +268,5 @@ namespace Ryujinx.Ava.UI.ViewModels await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle], msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark); }); } - } }