Skip to content

Commit

Permalink
Embed compatibility list into executable
Browse files Browse the repository at this point in the history
instead of downloading

Co-Authored-By: Vita Chumakova <[email protected]>
  • Loading branch information
GreemDev and ezhevita committed Jan 7, 2025
1 parent 2595264 commit d8265f7
Show file tree
Hide file tree
Showing 6 changed files with 4,328 additions and 44 deletions.
4,303 changes: 4,303 additions & 0 deletions docs/compatibility.csv

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Ryujinx/Ryujinx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
<EmbeddedResource Include="..\..\distribution\macos\shortcut-template.plist">
<Link>Assets\ShortcutFiles\shortcut-template.plist</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\docs\compatibility.csv" LogicalName="RyujinxGameCompatibilityList">
<Link>Assets\RyujinxGameCompatibility.csv</Link>
</EmbeddedResource>
<EmbeddedResource Include="Assets\locales.json" />
<EmbeddedResource Include="Assets\Styles\Styles.xaml" />
<EmbeddedResource Include="Assets\Icons\Controller_JoyConLeft.svg" />
Expand Down
1 change: 1 addition & 0 deletions src/Ryujinx/UI/Helpers/MiniCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public abstract class MiniCommand : ICommand
public static MiniCommand Create(Action callback) => new MiniCommand<object>(_ => callback());
public static MiniCommand Create<TArg>(Action<TArg> callback) => new MiniCommand<TArg>(callback);
public static MiniCommand CreateFromTask(Func<Task> callback) => new MiniCommand<object>(_ => callback());
public static MiniCommand CreateFromTask<TArg>(Func<TArg, Task> callback) => new MiniCommand<TArg>(callback);

public abstract bool CanExecute(object parameter);
public abstract void Execute(object parameter);
Expand Down
21 changes: 10 additions & 11 deletions src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public MainMenuBarView()
WindowSize2160PMenuItem.Command = new RelayCommand<string>(ChangeWindowSize);
}

private CheckBox[] GenerateToggleFileTypeItems() =>
private IEnumerable<CheckBox> GenerateToggleFileTypeItems() =>
Enum.GetValues<FileTypes>()
.Select(it => (FileName: Enum.GetName(it)!, FileType: it))
.Select(it =>
Expand All @@ -76,15 +76,13 @@ private CheckBox[] GenerateToggleFileTypeItems() =>
IsChecked = it.FileType.GetConfigValue(ConfigurationState.Instance.UI.ShownFileTypes),
Command = MiniCommand.Create(() => Window.ToggleFileType(it.FileName))
}
).ToArray();
);

private static MenuItem[] GenerateLanguageMenuItems()
private static IEnumerable<MenuItem> GenerateLanguageMenuItems()
{
List<MenuItem> menuItems = new();

string localePath = "Ryujinx/Assets/locales.json";
const string LocalePath = "Ryujinx/Assets/locales.json";

string languageJson = EmbeddedResources.ReadAllText(localePath);
string languageJson = EmbeddedResources.ReadAllText(LocalePath);

LocalesJson locales = JsonHelper.Deserialize(languageJson, LocalesJsonContext.Default.LocalesJson);

Expand All @@ -99,7 +97,10 @@ private static MenuItem[] GenerateLanguageMenuItems()
}
else
{
languageName = locales.Locales[index].Translations[language] == "" ? language : locales.Locales[index].Translations[language];
string tr = locales.Locales[index].Translations[language];
languageName = string.IsNullOrEmpty(tr)
? language
: tr;
}

MenuItem menuItem = new()
Expand All @@ -111,10 +112,8 @@ private static MenuItem[] GenerateLanguageMenuItems()
Command = MiniCommand.Create(() => MainWindowViewModel.ChangeLanguage(language))
};

menuItems.Add(menuItem);
yield return menuItem;
}

return menuItems.ToArray();
}

protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
Expand Down
32 changes: 0 additions & 32 deletions src/Ryujinx/Utilities/Compat/CompatibilityHelper.cs

This file was deleted.

12 changes: 11 additions & 1 deletion src/Ryujinx/Utilities/Compat/CompatibilityList.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Avalonia.Controls;
using Avalonia.Styling;
using nietras.SeparatedValues;
using Ryujinx.Ava.UI.Helpers;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;

namespace Ryujinx.Ava.Utilities.Compat
Expand All @@ -9,8 +12,15 @@ public partial class CompatibilityList : UserControl
{
public static async Task Show()
{
await CompatibilityHelper.InitAsync();
if (CompatibilityCsv.Shared is null)
{
await using Stream csvStream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("RyujinxGameCompatibilityList")!;
csvStream.Position = 0;

CompatibilityCsv.Shared = new CompatibilityCsv(Sep.Reader().From(csvStream));
}

CompatibilityContentDialog contentDialog = new()
{
Content = new CompatibilityList { DataContext = new CompatibilityViewModel(RyujinxApp.MainWindow.ViewModel.ApplicationLibrary) }
Expand Down

0 comments on commit d8265f7

Please sign in to comment.