1
1
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2025-03-13 10:49:37 -05:00

add compat csv loading

This commit is contained in:
Evan Husted 2025-01-11 12:22:08 -06:00
parent 6b99867050
commit 85f3a10ae9
4 changed files with 158 additions and 2 deletions

View File

@ -17,6 +17,7 @@
<PackageVersion Include="FluentAvaloniaUI" Version="2.1.0" />
<PackageVersion Include="GtkSharp.Dependencies" Version="1.1.1" />
<PackageVersion Include="GtkSharp.Dependencies.osx" Version="0.0.5" />
<PackageVersion Include="Humanizer" Version="2.14.1" />
<PackageVersion Include="LibHac" Version="0.19.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
@ -37,6 +38,7 @@
<PackageVersion Include="Ryujinx.GtkSharp" Version="3.24.24.59-ryujinx" />
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" />
<PackageVersion Include="securifybv.ShellLink" Version="0.1.0" />
<PackageVersion Include="Sep" Version="0.6.0" />
<PackageVersion Include="shaderc.net" Version="0.1.0" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
<PackageVersion Include="Silk.NET.Vulkan" Version="2.21.0" />
@ -49,4 +51,4 @@
<PackageVersion Include="System.Management" Version="8.0.0" />
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
</ItemGroup>
</Project>
</Project>

View File

@ -10,6 +10,7 @@
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
<PackageReference Include="MsgPack.Cli" />
<PackageReference Include="System.Management" />
<PackageReference Include="Humanizer" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,150 @@
using Humanizer;
using nietras.SeparatedValues;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Common.Logging;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
namespace Ryujinx.Ava.Modules.Compatibility
{
public struct ColumnIndices(Func<string, int> getIndex)
{
public const string TitleIdCol = "\"title_id\"";
public const string GameNameCol = "\"game_name\"";
public const string LabelsCol = "\"labels\"";
public const string StatusCol = "\"status\"";
public const string LastUpdatedCol = "\"last_updated\"";
public readonly int TitleId = getIndex(TitleIdCol);
public readonly int GameName = getIndex(GameNameCol);
public readonly int Labels = getIndex(LabelsCol);
public readonly int Status = getIndex(StatusCol);
public readonly int LastUpdated = getIndex(LastUpdatedCol);
}
public class CompatibilityCsv
{
static CompatibilityCsv()
{
using Stream csvStream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("RyujinxGameCompatibilityList")!;
csvStream.Position = 0;
using SepReader reader = Sep.Reader().From(csvStream);
ColumnIndices columnIndices = new(reader.Header.IndexOf);
Entries = reader
.Enumerate(row => new CompatibilityEntry(ref columnIndices, row))
.OrderBy(it => it.GameName)
.ToArray();
Logger.Debug?.Print(LogClass.UI, "Compatibility CSV loaded.", "LoadCompatCsv");
}
public static CompatibilityEntry[] Entries { get; private set; }
}
public class CompatibilityEntry
{
public CompatibilityEntry(ref ColumnIndices indices, SepReader.Row row)
{
string titleIdRow = ColStr(row[indices.TitleId]);
TitleId = !string.IsNullOrEmpty(titleIdRow)
? titleIdRow
: null;
GameName = ColStr(row[indices.GameName]);
Labels = ColStr(row[indices.Labels]).Split(';');
Status = ColStr(row[indices.Status]).ToLower() switch
{
"playable" => LocaleKeys.CompatibilityListPlayable,
"ingame" => LocaleKeys.CompatibilityListIngame,
"menus" => LocaleKeys.CompatibilityListMenus,
"boots" => LocaleKeys.CompatibilityListBoots,
"nothing" => LocaleKeys.CompatibilityListNothing,
_ => null
};
if (DateTime.TryParse(ColStr(row[indices.LastUpdated]), out var dt))
LastUpdated = dt;
return;
string ColStr(SepReader.Col col) => col.ToString().Trim('"');
}
public string GameName { get; }
public string TitleId { get; }
public string[] Labels { get; }
internal LocaleKeys? Status { get; }
public DateTime LastUpdated { get; }
public string LocalizedLastUpdated =>
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.CompatibilityListLastUpdated, LastUpdated.Humanize());
public string LocalizedStatus => LocaleManager.Instance[Status!.Value];
public string FormattedTitleId => TitleId ?? new string(' ', 16);
public string FormattedIssueLabels => string.Join(",", Labels
.Select(FormatLabelName));
public static string FormatLabelName(string labelName) => labelName.ToLower() switch
{
"audio" => "Audio",
"bug" => "Bug",
"cpu" => "CPU",
"gpu" => "GPU",
"gui" => "GUI",
"help wanted" => "Help Wanted",
"horizon" => "Horizon",
"infra" => "Project Infra",
"invalid" => "Invalid",
"kernel" => "Kernel",
"ldn" => "LDN",
"linux" => "Linux",
"macos" => "macOS",
"question" => "Question",
"windows" => "Windows",
"graphics-backend:opengl" => "Graphics: OpenGL",
"graphics-backend:vulkan" => "Graphics: Vulkan",
"ldn-works" => "LDN Works",
"ldn-untested" => "LDN Untested",
"ldn-broken" => "LDN Broken",
"ldn-partial" => "Partial LDN",
"nvdec" => "NVDEC",
"services" => "NX Services",
"services-horizon" => "Horizon OS Services",
"slow" => "Runs Slow",
"crash" => "Crashes",
"deadlock" => "Deadlock",
"regression" => "Regression",
"opengl" => "OpenGL",
"opengl-backend-bug" => "OpenGL Backend Bug",
"vulkan-backend-bug" => "Vulkan Backend Bug",
"mac-bug" => "Mac-specific Bug(s)",
"amd-vendor-bug" => "AMD GPU Bug",
"intel-vendor-bug" => "Intel GPU Bug",
"loader-allocator" => "Loader Allocator",
"audout" => "AudOut",
"32-bit" => "32-bit Game",
"UE4" => "Unreal Engine 4",
"homebrew" => "Homebrew Content",
"online-broken" => "Online Broken",
_ => Capitalize(labelName)
};
public static string Capitalize(string value)
{
if (value == string.Empty)
return string.Empty;
char firstChar = value[0];
string rest = value[1..];
return $"{char.ToUpper(firstChar)}{rest}";
}
}
}

View File

@ -44,7 +44,6 @@
<PackageReference Include="Avalonia.Svg.Skia" />
<PackageReference Include="DynamicData" />
<PackageReference Include="FluentAvaloniaUI" />
<PackageReference Include="OpenTK.Core" />
<PackageReference Include="Ryujinx.Audio.OpenAL.Dependencies" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'linux-arm64' AND '$(RuntimeIdentifier)' != 'osx-x64' AND '$(RuntimeIdentifier)' != 'osx-arm64'" />
<PackageReference Include="Ryujinx.Graphics.Nvdec.Dependencies" />
@ -52,6 +51,7 @@
<PackageReference Include="Silk.NET.Vulkan" />
<PackageReference Include="Silk.NET.Vulkan.Extensions.EXT" />
<PackageReference Include="Silk.NET.Vulkan.Extensions.KHR" />
<PackageReference Include="Sep" />
<PackageReference Include="SPB" />
<PackageReference Include="SharpZipLib" />
</ItemGroup>
@ -137,6 +137,9 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\docs\compatibility.csv" LogicalName="RyujinxGameCompatibilityList">
<Link>Assets\RyujinxGameCompatibility.csv</Link>
</EmbeddedResource>
<EmbeddedResource Include="Assets\Locales\ar_SA.json" />
<EmbeddedResource Include="Assets\Locales\el_GR.json" />
<EmbeddedResource Include="Assets\Locales\en_US.json" />