mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-24 05:16:05 +00:00
Auto-load bundled DLC on startup
This commit is contained in:
parent
57de6a7dc5
commit
867bc7021f
2 changed files with 27 additions and 15 deletions
|
@ -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 =>
|
||||
|
|
|
@ -21,8 +21,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
private readonly ApplicationLibrary _applicationLibrary;
|
||||
private AvaloniaList<DownloadableContentModel> _downloadableContents = new();
|
||||
private AvaloniaList<DownloadableContentModel> _views = new();
|
||||
private AvaloniaList<DownloadableContentModel> _selectedDownloadableContents = new();
|
||||
private AvaloniaList<DownloadableContentModel> _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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue