Skip to content

Commit

Permalink
UI: Compat: Unload compatibility entries when the window closes.
Browse files Browse the repository at this point in the history
  • Loading branch information
GreemDev committed Jan 19, 2025
1 parent 7fcd9b7 commit 6482e56
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
26 changes: 22 additions & 4 deletions src/Ryujinx/Utilities/Compat/CompatibilityCsv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public struct ColumnIndices(Func<ReadOnlySpan<char>, int> getIndex)

public class CompatibilityCsv
{
static CompatibilityCsv()
static CompatibilityCsv() => Load();

public static void Load()
{
using Stream csvStream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("RyujinxGameCompatibilityList")!;
Expand All @@ -37,15 +39,31 @@ static CompatibilityCsv()
using SepReader reader = Sep.Reader().From(csvStream);
ColumnIndices columnIndices = new(reader.Header.IndexOf);

Entries = reader
_entries = reader
.Enumerate(row => new CompatibilityEntry(ref columnIndices, row))
.OrderBy(it => it.GameName)
.ToArray();

Logger.Debug?.Print(LogClass.UI, "Compatibility CSV loaded.", "LoadCompatCsv");
Logger.Debug?.Print(LogClass.UI, "Compatibility CSV loaded.", "LoadCompatibility");
}

public static void Unload()
{
_entries = null;
}

public static CompatibilityEntry[] Entries { get; private set; }
private static CompatibilityEntry[] _entries;

public static CompatibilityEntry[] Entries
{
get
{
if (_entries == null)
Load();

return _entries;
}
}
}

public class CompatibilityEntry
Expand Down
5 changes: 2 additions & 3 deletions src/Ryujinx/Utilities/Compat/CompatibilityList.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Avalonia.Controls;
using Avalonia.Styling;
using FluentAvalonia.UI.Controls;
using nietras.SeparatedValues;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Helpers;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;

namespace Ryujinx.Ava.Utilities.Compat
Expand Down Expand Up @@ -35,6 +32,8 @@ public static async Task Show()
contentDialog.Styles.Add(closeButtonParent);

await ContentDialogHelper.ShowAsync(contentDialog);

CompatibilityCsv.Unload();
}

public CompatibilityList()
Expand Down

0 comments on commit 6482e56

Please sign in to comment.