Compare commits

..

5 Commits

Author SHA1 Message Date
Evan Husted
845c86f545 misc: chore: cleanup AppletMetadata.CanStart 2025-01-09 21:14:35 -06:00
Evan Husted
27993b789f misc: chore: fix some compile warnings 2025-01-09 20:23:26 -06:00
Evan Husted
bdd890cf6f UI: logger function name 2025-01-09 19:48:11 -06:00
Evan Husted
c5574b41a1 UI: collapse LoadFromStream into static ctor
pass the index get delegate to the struct instead of the entire header
2025-01-09 19:44:24 -06:00
Evan Husted
292e27f0da UI: dispose CSV reader when done + use explicit types 2025-01-09 19:24:48 -06:00
5 changed files with 33 additions and 38 deletions

View File

@@ -12,8 +12,8 @@ namespace Ryujinx.Ava.UI.Helpers
private static readonly Lazy<PlayabilityStatusConverter> _shared = new(() => new()); private static readonly Lazy<PlayabilityStatusConverter> _shared = new(() => new());
public static PlayabilityStatusConverter Shared => _shared.Value; public static PlayabilityStatusConverter Shared => _shared.Value;
public object Convert(object? value, Type _, object? __, CultureInfo ___) => public object Convert(object value, Type _, object __, CultureInfo ___)
value.Cast<LocaleKeys>() switch => value.Cast<LocaleKeys>() switch
{ {
LocaleKeys.CompatibilityListNothing or LocaleKeys.CompatibilityListNothing or
LocaleKeys.CompatibilityListBoots or LocaleKeys.CompatibilityListBoots or
@@ -22,7 +22,7 @@ namespace Ryujinx.Ava.UI.Helpers
_ => Brushes.ForestGreen _ => Brushes.ForestGreen
}; };
public object ConvertBack(object? value, Type _, object? __, CultureInfo ___) public object ConvertBack(object value, Type _, object __, CultureInfo ___)
=> throw new NotSupportedException(); => throw new NotSupportedException();
} }
} }

View File

@@ -741,7 +741,10 @@ namespace Ryujinx.Ava.UI.ViewModels
Applications.ToObservableChangeSet() Applications.ToObservableChangeSet()
.Filter(Filter) .Filter(Filter)
.Sort(GetComparer()) .Sort(GetComparer())
.Bind(out _appsObservableList).AsObservableList(); #pragma warning disable MVVMTK0034
.Bind(out _appsObservableList)
#pragma warning enable MVVMTK0034
.AsObservableList();
OnPropertyChanged(nameof(AppsObservableList)); OnPropertyChanged(nameof(AppsObservableList));
} }

View File

@@ -32,29 +32,27 @@ namespace Ryujinx.Ava.Utilities
public string GetContentPath(ContentManager contentManager) public string GetContentPath(ContentManager contentManager)
=> (contentManager ?? _contentManager) => (contentManager ?? _contentManager)
.GetInstalledContentPath(ProgramId, StorageId.BuiltInSystem, NcaContentType.Program); ?.GetInstalledContentPath(ProgramId, StorageId.BuiltInSystem, NcaContentType.Program);
public bool CanStart(ContentManager contentManager, out ApplicationData appData, public bool CanStart(ContentManager contentManager, out ApplicationData appData,
out BlitStruct<ApplicationControlProperty> appControl) out BlitStruct<ApplicationControlProperty> appControl)
{ {
contentManager ??= _contentManager; contentManager ??= _contentManager;
if (contentManager == null) if (contentManager == null)
{ goto BadData;
appData = null;
appControl = new BlitStruct<ApplicationControlProperty>(0); string contentPath = GetContentPath(contentManager);
return false; if (string.IsNullOrEmpty(contentPath))
} goto BadData;
appData = new() { Name = Name, Id = ProgramId, Path = GetContentPath(contentManager) }; appData = new() { Name = Name, Id = ProgramId, Path = GetContentPath(contentManager) };
if (string.IsNullOrEmpty(appData.Path))
{
appControl = new BlitStruct<ApplicationControlProperty>(0);
return false;
}
appControl = StructHelpers.CreateCustomNacpData(Name, Version); appControl = StructHelpers.CreateCustomNacpData(Name, Version);
return true; return true;
BadData:
appData = null;
appControl = new BlitStruct<ApplicationControlProperty>(0);
return false;
} }
} }
} }

View File

@@ -3,7 +3,6 @@ using nietras.SeparatedValues;
using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Common.Locale;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@@ -11,7 +10,7 @@ using System.Text;
namespace Ryujinx.Ava.Utilities.Compat namespace Ryujinx.Ava.Utilities.Compat
{ {
public struct ColumnIndices(SepReaderHeader header) public struct ColumnIndices(Func<ReadOnlySpan<char>, int> getIndex)
{ {
public const string TitleIdCol = "\"title_id\""; public const string TitleIdCol = "\"title_id\"";
public const string GameNameCol = "\"game_name\""; public const string GameNameCol = "\"game_name\"";
@@ -19,11 +18,11 @@ namespace Ryujinx.Ava.Utilities.Compat
public const string StatusCol = "\"status\""; public const string StatusCol = "\"status\"";
public const string LastUpdatedCol = "\"last_updated\""; public const string LastUpdatedCol = "\"last_updated\"";
public readonly int TitleId = header.IndexOf(TitleIdCol); public readonly int TitleId = getIndex(TitleIdCol);
public readonly int GameName = header.IndexOf(GameNameCol); public readonly int GameName = getIndex(GameNameCol);
public readonly int Labels = header.IndexOf(LabelsCol); public readonly int Labels = getIndex(LabelsCol);
public readonly int Status = header.IndexOf(StatusCol); public readonly int Status = getIndex(StatusCol);
public readonly int LastUpdated = header.IndexOf(LastUpdatedCol); public readonly int LastUpdated = getIndex(LastUpdatedCol);
} }
public class CompatibilityCsv public class CompatibilityCsv
@@ -34,20 +33,15 @@ namespace Ryujinx.Ava.Utilities.Compat
.GetManifestResourceStream("RyujinxGameCompatibilityList")!; .GetManifestResourceStream("RyujinxGameCompatibilityList")!;
csvStream.Position = 0; csvStream.Position = 0;
LoadFromStream(csvStream); using SepReader reader = Sep.Reader().From(csvStream);
} ColumnIndices columnIndices = new(reader.Header.IndexOf);
public static void LoadFromStream(Stream stream)
{
var reader = Sep.Reader().From(stream);
var columnIndices = new ColumnIndices(reader.Header);
Entries = reader Entries = reader
.Enumerate(row => new CompatibilityEntry(ref columnIndices, row)) .Enumerate(row => new CompatibilityEntry(ref columnIndices, row))
.OrderBy(it => it.GameName) .OrderBy(it => it.GameName)
.ToArray(); .ToArray();
Logger.Debug?.Print(LogClass.UI, "Compatibility CSV loaded."); Logger.Debug?.Print(LogClass.UI, "Compatibility CSV loaded.", "LoadCompatCsv");
} }
public static CompatibilityEntry[] Entries { get; private set; } public static CompatibilityEntry[] Entries { get; private set; }
@@ -57,7 +51,7 @@ namespace Ryujinx.Ava.Utilities.Compat
{ {
public CompatibilityEntry(ref ColumnIndices indices, SepReader.Row row) public CompatibilityEntry(ref ColumnIndices indices, SepReader.Row row)
{ {
var titleIdRow = ColStr(row[indices.TitleId]); string titleIdRow = ColStr(row[indices.TitleId]);
TitleId = !string.IsNullOrEmpty(titleIdRow) TitleId = !string.IsNullOrEmpty(titleIdRow)
? titleIdRow ? titleIdRow
: default(Optional<string>); : default(Optional<string>);
@@ -100,7 +94,7 @@ namespace Ryujinx.Ava.Utilities.Compat
public override string ToString() public override string ToString()
{ {
var sb = new StringBuilder("CompatibilityEntry: {"); StringBuilder sb = new("CompatibilityEntry: {");
sb.Append($"{nameof(GameName)}=\"{GameName}\", "); sb.Append($"{nameof(GameName)}=\"{GameName}\", ");
sb.Append($"{nameof(TitleId)}={TitleId}, "); sb.Append($"{nameof(TitleId)}={TitleId}, ");
sb.Append($"{nameof(Labels)}=\"{Labels}\", "); sb.Append($"{nameof(Labels)}=\"{Labels}\", ");
@@ -161,8 +155,8 @@ namespace Ryujinx.Ava.Utilities.Compat
if (value == string.Empty) if (value == string.Empty)
return string.Empty; return string.Empty;
var firstChar = value[0]; char firstChar = value[0];
var rest = value[1..]; string rest = value[1..];
return $"{char.ToUpper(firstChar)}{rest}"; return $"{char.ToUpper(firstChar)}{rest}";
} }

View File

@@ -42,7 +42,7 @@ namespace Ryujinx.Ava.Utilities.Compat
InitializeComponent(); InitializeComponent();
} }
private void TextBox_OnTextChanged(object? sender, TextChangedEventArgs e) private void TextBox_OnTextChanged(object sender, TextChangedEventArgs e)
{ {
if (DataContext is not CompatibilityViewModel cvm) if (DataContext is not CompatibilityViewModel cvm)
return; return;