mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 11:03:04 +00:00
Fix a bug with DLC window; rework some logic
This commit is contained in:
parent
48b7517284
commit
472feb9680
4 changed files with 24 additions and 32 deletions
|
@ -176,12 +176,22 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
.Filter(Filter)
|
.Filter(Filter)
|
||||||
.Bind(out var view).AsObservableList();
|
.Bind(out var view).AsObservableList();
|
||||||
|
|
||||||
|
// NOTE(jpr): this works around a bug where calling _views.Clear also clears SelectedDownloadableContents for
|
||||||
|
// some reason. so we save the items here and add them back after
|
||||||
|
var items = SelectedDownloadableContents.ToArray();
|
||||||
|
|
||||||
_views.Clear();
|
_views.Clear();
|
||||||
_views.AddRange(view);
|
_views.AddRange(view);
|
||||||
|
|
||||||
|
foreach (DownloadableContentModel item in items)
|
||||||
|
{
|
||||||
|
SelectedDownloadableContents.ReplaceOrAdd(item, item);
|
||||||
|
}
|
||||||
|
|
||||||
OnPropertyChanged(nameof(Views));
|
OnPropertyChanged(nameof(Views));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Filter(object arg)
|
private bool Filter<T>(T arg)
|
||||||
{
|
{
|
||||||
if (arg is DownloadableContentModel content)
|
if (arg is DownloadableContentModel content)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,24 +2,14 @@ using Avalonia.Collections;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using LibHac.Common;
|
using DynamicData.Kernel;
|
||||||
using LibHac.Fs;
|
|
||||||
using LibHac.Fs.Fsa;
|
|
||||||
using LibHac.Ncm;
|
|
||||||
using LibHac.Ns;
|
|
||||||
using LibHac.Tools.FsSystem;
|
|
||||||
using LibHac.Tools.FsSystem.NcaUtils;
|
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.Models;
|
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Common.Utilities;
|
using Ryujinx.Common.Utilities;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
|
||||||
using Ryujinx.HLE.Utilities;
|
|
||||||
using Ryujinx.UI.App.Common;
|
using Ryujinx.UI.App.Common;
|
||||||
using Ryujinx.UI.Common.Configuration;
|
|
||||||
using Ryujinx.UI.Common.Models;
|
using Ryujinx.UI.Common.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -27,14 +17,15 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Application = Avalonia.Application;
|
using Application = Avalonia.Application;
|
||||||
using ContentType = LibHac.Ncm.ContentType;
|
|
||||||
using Path = System.IO.Path;
|
using Path = System.IO.Path;
|
||||||
using SpanHelpers = LibHac.Common.SpanHelpers;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.ViewModels
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
|
public record TitleUpdateViewNoUpdateSentinal();
|
||||||
|
|
||||||
public class TitleUpdateViewModel : BaseModel
|
public class TitleUpdateViewModel : BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
public TitleUpdateMetadata TitleUpdateWindowData;
|
public TitleUpdateMetadata TitleUpdateWindowData;
|
||||||
public readonly string TitleUpdateJsonPath;
|
public readonly string TitleUpdateJsonPath;
|
||||||
private VirtualFileSystem VirtualFileSystem { get; }
|
private VirtualFileSystem VirtualFileSystem { get; }
|
||||||
|
@ -43,7 +34,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
private AvaloniaList<TitleUpdateModel> _titleUpdates = new();
|
private AvaloniaList<TitleUpdateModel> _titleUpdates = new();
|
||||||
private AvaloniaList<object> _views = new();
|
private AvaloniaList<object> _views = new();
|
||||||
private object _selectedUpdate;
|
private object _selectedUpdate = new TitleUpdateViewNoUpdateSentinal();
|
||||||
|
|
||||||
private static readonly TitleUpdateMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
private static readonly TitleUpdateMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||||
|
|
||||||
|
@ -123,9 +114,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
AddUpdate(path);
|
AddUpdate(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleUpdateModel selected = TitleUpdates.FirstOrDefault(x => x.Path == TitleUpdateWindowData.Selected, null);
|
var selected = TitleUpdates.FirstOrOptional(x => x.Path == TitleUpdateWindowData.Selected);
|
||||||
|
SelectedUpdate = selected.HasValue ? selected.Value : new TitleUpdateViewNoUpdateSentinal();
|
||||||
SelectedUpdate = selected;
|
|
||||||
|
|
||||||
// NOTE: Save the list again to remove leftovers.
|
// NOTE: Save the list again to remove leftovers.
|
||||||
Save();
|
Save();
|
||||||
|
@ -137,23 +127,16 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
var sortedUpdates = TitleUpdates.OrderByDescending(update => update.Version);
|
var sortedUpdates = TitleUpdates.OrderByDescending(update => update.Version);
|
||||||
|
|
||||||
Views.Clear();
|
Views.Clear();
|
||||||
Views.Add(new BaseModel());
|
Views.Add(new TitleUpdateViewNoUpdateSentinal());
|
||||||
Views.AddRange(sortedUpdates);
|
Views.AddRange(sortedUpdates);
|
||||||
|
|
||||||
if (SelectedUpdate == null)
|
if (SelectedUpdate is TitleUpdateViewNoUpdateSentinal)
|
||||||
{
|
{
|
||||||
SelectedUpdate = Views[0];
|
SelectedUpdate = Views[0];
|
||||||
}
|
}
|
||||||
else if (!TitleUpdates.Contains(SelectedUpdate))
|
else if (!TitleUpdates.Contains((TitleUpdateModel)SelectedUpdate))
|
||||||
{
|
{
|
||||||
if (Views.Count > 1)
|
SelectedUpdate = Views.Count > 1 ? Views[1] : Views[0];
|
||||||
{
|
|
||||||
SelectedUpdate = Views[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SelectedUpdate = Views[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,8 @@
|
||||||
SelectionMode="Multiple, Toggle"
|
SelectionMode="Multiple, Toggle"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
SelectionChanged="OnSelectionChanged"
|
SelectionChanged="OnSelectionChanged"
|
||||||
SelectedItems="{Binding SelectedDownloadableContents}"
|
SelectedItems="{Binding SelectedDownloadableContents, Mode=OneWay}"
|
||||||
ItemsSource="{Binding Views}">
|
ItemsSource="{Binding Views}">
|
||||||
<!-- SelectedItems="{Binding SelectedDownloadableContents, Mode=TwoWay}" -->
|
|
||||||
<ListBox.DataTemplates>
|
<ListBox.DataTemplates>
|
||||||
<DataTemplate
|
<DataTemplate
|
||||||
DataType="models:DownloadableContentModel">
|
DataType="models:DownloadableContentModel">
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
</Panel>
|
</Panel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate
|
<DataTemplate
|
||||||
DataType="viewModels:BaseModel">
|
DataType="viewModels:TitleUpdateViewNoUpdateSentinal">
|
||||||
<Panel
|
<Panel
|
||||||
Height="33"
|
Height="33"
|
||||||
Margin="10">
|
Margin="10">
|
||||||
|
|
Loading…
Reference in a new issue