diff --git a/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs b/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs index 91b3c3c24..5d195d0be 100644 --- a/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs +++ b/Ryujinx.Ava/UI/ViewModels/DownloadableContentManagerViewModel.cs @@ -2,6 +2,7 @@ using Avalonia.Collections; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Threading; +using DynamicData; using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; @@ -99,10 +100,17 @@ namespace Ryujinx.Ava.UI.ViewModels Nca nca = TryOpenNca(ncaFile.Get.AsStorage(), downloadableContentContainer.ContainerPath); if (nca != null) { - DownloadableContents.Add(new DownloadableContentModel(nca.Header.TitleId.ToString("X16"), + var content = new DownloadableContentModel(nca.Header.TitleId.ToString("X16"), downloadableContentContainer.ContainerPath, downloadableContentNca.FullPath, - downloadableContentNca.Enabled)); + downloadableContentNca.Enabled); + + DownloadableContents.Add(content); + + if (content.Enabled) + { + SelectedDownloadableContents.Add(content); + } } } } @@ -190,7 +198,10 @@ namespace Ryujinx.Ava.UI.ViewModels break; } - DownloadableContents.Add(new DownloadableContentModel(nca.Header.TitleId.ToString("X16"), path, fileEntry.FullPath, true)); + var content = new DownloadableContentModel(nca.Header.TitleId.ToString("X16"), path, + fileEntry.FullPath, true); + DownloadableContents.Add(content); + SelectedDownloadableContents.Add(content); containsDownloadableContent = true; } diff --git a/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml b/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml index 1b26d21e5..bc976b28f 100644 --- a/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml +++ b/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml @@ -32,6 +32,7 @@ VirtualizationMode="None" SelectionMode="Multiple" Background="Transparent" + SelectionChanged="OnSelectionChanged" SelectedItems="{Binding SelectedDownloadableContents, Mode=TwoWay}" Items="{Binding DownloadableContents}"> diff --git a/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml.cs b/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml.cs index d5f93386b..6dc99fb54 100644 --- a/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml.cs +++ b/Ryujinx.Ava/UI/Windows/DownloadableContentManagerWindow.axaml.cs @@ -82,5 +82,34 @@ namespace Ryujinx.Ava.UI.Windows } } } + + private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + foreach (var content in e.AddedItems) + { + if (content is DownloadableContentModel model) + { + var index = ViewModel.DownloadableContents.IndexOf(model); + + if (index != -1) + { + ViewModel.DownloadableContents[index].Enabled = true; + } + } + } + + foreach (var content in e.RemovedItems) + { + if (content is DownloadableContentModel model) + { + var index = ViewModel.DownloadableContents.IndexOf(model); + + if (index != -1) + { + ViewModel.DownloadableContents[index].Enabled = false; + } + } + } + } } } \ No newline at end of file