Compare commits

..

6 Commits

Author SHA1 Message Date
jhorv
7969fb6bba Replace and remove obsolete ByteMemoryPool type (#7155)
* refactor: replace usage of ByteMemoryPool with MemoryOwner<byte>

* refactor: delete unused ByteMemoryPool and ByteMemoryPool.ByteMemoryPoolBuffer types

* refactor: change IMemoryOwner<byte> return types to MemoryOwner<byte>

* fix(perf): get span via `MemoryOwner<T>.Span` directly instead of `MemoryOwner<T>.Memory.Span`

* fix(perf): get span via MemoryOwner<T>.Span directly instead of `MemoryOwner<T>.Memory.Span`

* fix(perf): get span via MemoryOwner<T>.Span directly instead of `MemoryOwner<T>.Memory.Span`
2024-08-05 21:09:08 -03:00
gdkchan
4a4b11871e Fix same textures with unmapped start being considered different (#7141)
* Fix same textures with unmapped start being considered different

* Consolidate IsInvalid check

* InvalidAddress const

* Fix typo

Co-authored-by: riperiperi <rhy3756547@hotmail.com>

---------

Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2024-08-05 11:00:41 -03:00
Julien Lebosquain
e85ee673b1 Fix LocaleExtension SetRawSource usages + language perf improvement (#7121)
* Avoid Avalonia CompiledBindingPathBuilder.SetRawSource

* Improve UI language change performance
2024-08-04 19:04:12 +01:00
Isaac Marovitz
42f22fe5d7 Infra: Update Microsoft.IdentityModel.JsonWebTokens (#7070)
* Update Microsoft.IdentityModel.JsonWebTokens

* Update
2024-08-04 18:56:27 +01:00
TSRBerry
263eb97f79 Avoid race conditions while launching games directly from the command line (#7116)
* optimization: Load application metadata only for applications with IDs

* Load applications when necessary

This prevents loading applications when launching an application
directly from the command line (or a shortcut).
Instead, applications will be loaded after the emulation was stopped by the user.

* Show the title in the configured language when launching an application

* Rename DesiredTitleLanguage to DesiredLanguage
2024-08-03 22:31:34 +01:00
dependabot[bot]
3004902257 nuget: bump DynamicData from 8.4.1 to 9.0.1 (#7040)
Bumps [DynamicData](https://github.com/reactiveui/DynamicData) from 8.4.1 to 9.0.1.
- [Release notes](https://github.com/reactiveui/DynamicData/releases)
- [Changelog](https://github.com/reactivemarbles/DynamicData/blob/main/ReleaseNotes.md)
- [Commits](https://github.com/reactiveui/DynamicData/compare/8.4.1...9.0.1)

---
updated-dependencies:
- dependency-name: DynamicData
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-03 22:34:41 +02:00
17 changed files with 124 additions and 228 deletions

View File

@@ -13,14 +13,14 @@
<PackageVersion Include="CommandLineParser" Version="2.9.1" /> <PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="Concentus" Version="2.2.0" /> <PackageVersion Include="Concentus" Version="2.2.0" />
<PackageVersion Include="DiscordRichPresence" Version="1.2.1.24" /> <PackageVersion Include="DiscordRichPresence" Version="1.2.1.24" />
<PackageVersion Include="DynamicData" Version="8.4.1" /> <PackageVersion Include="DynamicData" Version="9.0.1" />
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.5" /> <PackageVersion Include="FluentAvaloniaUI" Version="2.0.5" />
<PackageVersion Include="GtkSharp.Dependencies" Version="1.1.1" /> <PackageVersion Include="GtkSharp.Dependencies" Version="1.1.1" />
<PackageVersion Include="GtkSharp.Dependencies.osx" Version="0.0.5" /> <PackageVersion Include="GtkSharp.Dependencies.osx" Version="0.0.5" />
<PackageVersion Include="LibHac" Version="0.19.0" /> <PackageVersion Include="LibHac" Version="0.19.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" /> <PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" /> <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" /> <PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" /> <PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageVersion Include="MsgPack.Cli" Version="1.0.1" /> <PackageVersion Include="MsgPack.Cli" Version="1.0.1" />

View File

@@ -1,51 +0,0 @@
using System;
using System.Buffers;
using System.Threading;
namespace Ryujinx.Common.Memory
{
public partial class ByteMemoryPool
{
/// <summary>
/// Represents a <see cref="IMemoryOwner{Byte}"/> that wraps an array rented from
/// <see cref="ArrayPool{Byte}.Shared"/> and exposes it as <see cref="Memory{Byte}"/>
/// with a length of the requested size.
/// </summary>
private sealed class ByteMemoryPoolBuffer : IMemoryOwner<byte>
{
private byte[] _array;
private readonly int _length;
public ByteMemoryPoolBuffer(int length)
{
_array = ArrayPool<byte>.Shared.Rent(length);
_length = length;
}
/// <summary>
/// Returns a <see cref="Memory{Byte}"/> belonging to this owner.
/// </summary>
public Memory<byte> Memory
{
get
{
byte[] array = _array;
ObjectDisposedException.ThrowIf(array is null, this);
return new Memory<byte>(array, 0, _length);
}
}
public void Dispose()
{
var array = Interlocked.Exchange(ref _array, null);
if (array != null)
{
ArrayPool<byte>.Shared.Return(array);
}
}
}
}
}

View File

@@ -1,106 +0,0 @@
using System;
using System.Buffers;
namespace Ryujinx.Common.Memory
{
/// <summary>
/// Provides a pool of re-usable byte array instances.
/// </summary>
public static partial class ByteMemoryPool
{
/// <summary>
/// Returns the maximum buffer size supported by this pool.
/// </summary>
public static int MaxBufferSize => Array.MaxLength;
/// <summary>
/// Rents a byte memory buffer from <see cref="ArrayPool{Byte}.Shared"/>.
/// The buffer may contain data from a prior use.
/// </summary>
/// <param name="length">The buffer's required length in bytes</param>
/// <returns>A <see cref="IMemoryOwner{Byte}"/> wrapping the rented memory</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static IMemoryOwner<byte> Rent(long length)
=> RentImpl(checked((int)length));
/// <summary>
/// Rents a byte memory buffer from <see cref="ArrayPool{Byte}.Shared"/>.
/// The buffer may contain data from a prior use.
/// </summary>
/// <param name="length">The buffer's required length in bytes</param>
/// <returns>A <see cref="IMemoryOwner{Byte}"/> wrapping the rented memory</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static IMemoryOwner<byte> Rent(ulong length)
=> RentImpl(checked((int)length));
/// <summary>
/// Rents a byte memory buffer from <see cref="ArrayPool{Byte}.Shared"/>.
/// The buffer may contain data from a prior use.
/// </summary>
/// <param name="length">The buffer's required length in bytes</param>
/// <returns>A <see cref="IMemoryOwner{Byte}"/> wrapping the rented memory</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static IMemoryOwner<byte> Rent(int length)
=> RentImpl(length);
/// <summary>
/// Rents a byte memory buffer from <see cref="ArrayPool{Byte}.Shared"/>.
/// The buffer's contents are cleared (set to all 0s) before returning.
/// </summary>
/// <param name="length">The buffer's required length in bytes</param>
/// <returns>A <see cref="IMemoryOwner{Byte}"/> wrapping the rented memory</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static IMemoryOwner<byte> RentCleared(long length)
=> RentCleared(checked((int)length));
/// <summary>
/// Rents a byte memory buffer from <see cref="ArrayPool{Byte}.Shared"/>.
/// The buffer's contents are cleared (set to all 0s) before returning.
/// </summary>
/// <param name="length">The buffer's required length in bytes</param>
/// <returns>A <see cref="IMemoryOwner{Byte}"/> wrapping the rented memory</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static IMemoryOwner<byte> RentCleared(ulong length)
=> RentCleared(checked((int)length));
/// <summary>
/// Rents a byte memory buffer from <see cref="ArrayPool{Byte}.Shared"/>.
/// The buffer's contents are cleared (set to all 0s) before returning.
/// </summary>
/// <param name="length">The buffer's required length in bytes</param>
/// <returns>A <see cref="IMemoryOwner{Byte}"/> wrapping the rented memory</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static IMemoryOwner<byte> RentCleared(int length)
{
var buffer = RentImpl(length);
buffer.Memory.Span.Clear();
return buffer;
}
/// <summary>
/// Copies <paramref name="buffer"/> into a newly rented byte memory buffer.
/// </summary>
/// <param name="buffer">The byte buffer to copy</param>
/// <returns>A <see cref="IMemoryOwner{Byte}"/> wrapping the rented memory with <paramref name="buffer"/> copied to it</returns>
public static IMemoryOwner<byte> RentCopy(ReadOnlySpan<byte> buffer)
{
var copy = RentImpl(buffer.Length);
buffer.CopyTo(copy.Memory.Span);
return copy;
}
private static ByteMemoryPoolBuffer RentImpl(int length)
{
if ((uint)length > Array.MaxLength)
{
throw new ArgumentOutOfRangeException(nameof(length), length, null);
}
return new ByteMemoryPoolBuffer(length);
}
}
}

View File

@@ -1,6 +1,6 @@
using Ryujinx.Common.Memory;
using Ryujinx.Common.Utilities; using Ryujinx.Common.Utilities;
using System; using System;
using System.Buffers;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@@ -42,14 +42,14 @@ namespace Ryujinx.Common
return StreamUtils.StreamToBytes(stream); return StreamUtils.StreamToBytes(stream);
} }
public static IMemoryOwner<byte> ReadFileToRentedMemory(string filename) public static MemoryOwner<byte> ReadFileToRentedMemory(string filename)
{ {
var (assembly, path) = ResolveManifestPath(filename); var (assembly, path) = ResolveManifestPath(filename);
return ReadFileToRentedMemory(assembly, path); return ReadFileToRentedMemory(assembly, path);
} }
public static IMemoryOwner<byte> ReadFileToRentedMemory(Assembly assembly, string filename) public static MemoryOwner<byte> ReadFileToRentedMemory(Assembly assembly, string filename)
{ {
using var stream = GetStream(assembly, filename); using var stream = GetStream(assembly, filename);

View File

@@ -1,6 +1,5 @@
using Microsoft.IO; using Microsoft.IO;
using Ryujinx.Common.Memory; using Ryujinx.Common.Memory;
using System.Buffers;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -16,7 +15,7 @@ namespace Ryujinx.Common.Utilities
return output.ToArray(); return output.ToArray();
} }
public static IMemoryOwner<byte> StreamToRentedMemory(Stream input) public static MemoryOwner<byte> StreamToRentedMemory(Stream input)
{ {
if (input is MemoryStream inputMemoryStream) if (input is MemoryStream inputMemoryStream)
{ {
@@ -26,9 +25,9 @@ namespace Ryujinx.Common.Utilities
{ {
long bytesExpected = input.Length; long bytesExpected = input.Length;
IMemoryOwner<byte> ownedMemory = ByteMemoryPool.Rent(bytesExpected); MemoryOwner<byte> ownedMemory = MemoryOwner<byte>.Rent(checked((int)bytesExpected));
var destSpan = ownedMemory.Memory.Span; var destSpan = ownedMemory.Span;
int totalBytesRead = 0; int totalBytesRead = 0;
@@ -66,14 +65,14 @@ namespace Ryujinx.Common.Utilities
return stream.ToArray(); return stream.ToArray();
} }
private static IMemoryOwner<byte> MemoryStreamToRentedMemory(MemoryStream input) private static MemoryOwner<byte> MemoryStreamToRentedMemory(MemoryStream input)
{ {
input.Position = 0; input.Position = 0;
IMemoryOwner<byte> ownedMemory = ByteMemoryPool.Rent(input.Length); MemoryOwner<byte> ownedMemory = MemoryOwner<byte>.Rent(checked((int)input.Length));
// Discard the return value because we assume reading a MemoryStream always succeeds completely. // Discard the return value because we assume reading a MemoryStream always succeeds completely.
_ = input.Read(ownedMemory.Memory.Span); _ = input.Read(ownedMemory.Span);
return ownedMemory; return ownedMemory;
} }

View File

@@ -303,9 +303,9 @@ namespace Ryujinx.Cpu.Jit
} }
else else
{ {
IMemoryOwner<byte> memoryOwner = ByteMemoryPool.Rent(size); MemoryOwner<byte> memoryOwner = MemoryOwner<byte>.Rent(size);
Read(va, memoryOwner.Memory.Span); Read(va, memoryOwner.Span);
return new WritableRegion(this, va, memoryOwner); return new WritableRegion(this, va, memoryOwner);
} }

View File

@@ -256,6 +256,12 @@ namespace Ryujinx
MainWindow mainWindow = new(); MainWindow mainWindow = new();
mainWindow.Show(); mainWindow.Show();
// Load the game table if no application was requested by the command line
if (CommandLineState.LaunchPathArg == null)
{
mainWindow.UpdateGameTable();
}
if (OperatingSystem.IsLinux()) if (OperatingSystem.IsLinux())
{ {
int currentVmMaxMapCount = LinuxHelper.VmMaxMapCount; int currentVmMaxMapCount = LinuxHelper.VmMaxMapCount;

View File

@@ -187,7 +187,10 @@ namespace Ryujinx.UI
: IntegrityCheckLevel.None; : IntegrityCheckLevel.None;
// Instantiate GUI objects. // Instantiate GUI objects.
ApplicationLibrary = new ApplicationLibrary(_virtualFileSystem, checkLevel); ApplicationLibrary = new ApplicationLibrary(_virtualFileSystem, checkLevel)
{
DesiredLanguage = ConfigurationState.Instance.System.Language,
};
_uiHandler = new GtkHostUIHandler(this); _uiHandler = new GtkHostUIHandler(this);
_deviceExitStatus = new AutoResetEvent(false); _deviceExitStatus = new AutoResetEvent(false);
@@ -325,7 +328,6 @@ namespace Ryujinx.UI
_hideUI.Label = _hideUI.Label.Replace("SHOWUIKEY", ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI.ToString()); _hideUI.Label = _hideUI.Label.Replace("SHOWUIKEY", ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI.ToString());
UpdateColumns(); UpdateColumns();
UpdateGameTable();
ConfigurationState.Instance.UI.GameDirs.Event += (sender, args) => ConfigurationState.Instance.UI.GameDirs.Event += (sender, args) =>
{ {
@@ -738,7 +740,8 @@ namespace Ryujinx.UI
Thread applicationLibraryThread = new(() => Thread applicationLibraryThread = new(() =>
{ {
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language); ApplicationLibrary.DesiredLanguage = ConfigurationState.Instance.System.Language;
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
_updatingGameTable = false; _updatingGameTable = false;
}) })

View File

@@ -4,6 +4,22 @@ namespace Ryujinx.Memory.Range
{ {
MultiRange Range { get; } MultiRange Range { get; }
ulong BaseAddress => Range.GetSubRange(0).Address; ulong BaseAddress
{
get
{
for (int index = 0; index < Range.Count; index++)
{
MemoryRange subRange = Range.GetSubRange(index);
if (!MemoryRange.IsInvalid(ref subRange))
{
return subRange.Address;
}
}
return MemoryRange.InvalidAddress;
}
}
} }
} }

View File

@@ -5,6 +5,11 @@ namespace Ryujinx.Memory.Range
/// </summary> /// </summary>
public readonly record struct MemoryRange public readonly record struct MemoryRange
{ {
/// <summary>
/// Special address value used to indicate than an address is invalid.
/// </summary>
internal const ulong InvalidAddress = ulong.MaxValue;
/// <summary> /// <summary>
/// An empty memory range, with a null address and zero size. /// An empty memory range, with a null address and zero size.
/// </summary> /// </summary>
@@ -58,13 +63,24 @@ namespace Ryujinx.Memory.Range
return thisAddress < otherEndAddress && otherAddress < thisEndAddress; return thisAddress < otherEndAddress && otherAddress < thisEndAddress;
} }
/// <summary>
/// Checks if a given sub-range of memory is invalid.
/// Those are used to represent unmapped memory regions (holes in the region mapping).
/// </summary>
/// <param name="subRange">Memory range to check</param>
/// <returns>True if the memory range is considered invalid, false otherwise</returns>
internal static bool IsInvalid(ref MemoryRange subRange)
{
return subRange.Address == InvalidAddress;
}
/// <summary> /// <summary>
/// Returns a string summary of the memory range. /// Returns a string summary of the memory range.
/// </summary> /// </summary>
/// <returns>A string summary of the memory range</returns> /// <returns>A string summary of the memory range</returns>
public override string ToString() public override string ToString()
{ {
if (Address == ulong.MaxValue) if (Address == InvalidAddress)
{ {
return $"[Unmapped 0x{Size:X}]"; return $"[Unmapped 0x{Size:X}]";
} }

View File

@@ -30,7 +30,7 @@ namespace Ryujinx.Memory.Range
{ {
var subrange = range.GetSubRange(i); var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange)) if (MemoryRange.IsInvalid(ref subrange))
{ {
continue; continue;
} }
@@ -56,7 +56,7 @@ namespace Ryujinx.Memory.Range
{ {
var subrange = range.GetSubRange(i); var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange)) if (MemoryRange.IsInvalid(ref subrange))
{ {
continue; continue;
} }
@@ -99,7 +99,7 @@ namespace Ryujinx.Memory.Range
{ {
var subrange = range.GetSubRange(i); var subrange = range.GetSubRange(i);
if (IsInvalid(ref subrange)) if (MemoryRange.IsInvalid(ref subrange))
{ {
continue; continue;
} }
@@ -142,17 +142,6 @@ namespace Ryujinx.Memory.Range
return overlapCount; return overlapCount;
} }
/// <summary>
/// Checks if a given sub-range of memory is invalid.
/// Those are used to represent unmapped memory regions (holes in the region mapping).
/// </summary>
/// <param name="subRange">Memory range to checl</param>
/// <returns>True if the memory range is considered invalid, false otherwise</returns>
private static bool IsInvalid(ref MemoryRange subRange)
{
return subRange.Address == ulong.MaxValue;
}
/// <summary> /// <summary>
/// Gets all items on the list starting at the specified memory address. /// Gets all items on the list starting at the specified memory address.
/// </summary> /// </summary>

View File

@@ -130,9 +130,9 @@ namespace Ryujinx.Memory
} }
else else
{ {
IMemoryOwner<byte> memoryOwner = ByteMemoryPool.Rent(size); MemoryOwner<byte> memoryOwner = MemoryOwner<byte>.Rent(size);
Read(va, memoryOwner.Memory.Span); Read(va, memoryOwner.Span);
return new WritableRegion(this, va, memoryOwner); return new WritableRegion(this, va, memoryOwner);
} }

View File

@@ -34,6 +34,7 @@ namespace Ryujinx.UI.App.Common
{ {
public class ApplicationLibrary public class ApplicationLibrary
{ {
public Language DesiredLanguage { get; set; }
public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded; public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated; public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
@@ -45,7 +46,6 @@ namespace Ryujinx.UI.App.Common
private readonly VirtualFileSystem _virtualFileSystem; private readonly VirtualFileSystem _virtualFileSystem;
private readonly IntegrityCheckLevel _checkLevel; private readonly IntegrityCheckLevel _checkLevel;
private Language _desiredTitleLanguage;
private CancellationTokenSource _cancellationToken; private CancellationTokenSource _cancellationToken;
private static readonly ApplicationJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly ApplicationJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
@@ -221,7 +221,7 @@ namespace Ryujinx.UI.App.Common
{ {
using UniqueRef<IFile> icon = new(); using UniqueRef<IFile> icon = new();
controlFs.OpenFile(ref icon.Ref, $"/icon_{_desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure(); controlFs.OpenFile(ref icon.Ref, $"/icon_{DesiredLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
using MemoryStream stream = new(); using MemoryStream stream = new();
@@ -432,35 +432,40 @@ namespace Ryujinx.UI.App.Common
foreach (var data in applications) foreach (var data in applications)
{ {
ApplicationMetadata appMetadata = LoadAndSaveMetaData(data.IdString, appMetadata => // Only load metadata for applications with an ID
if (data.Id != 0)
{ {
appMetadata.Title = data.Name; ApplicationMetadata appMetadata = LoadAndSaveMetaData(data.IdString, appMetadata =>
// Only do the migration if time_played has a value and timespan_played hasn't been updated yet.
if (appMetadata.TimePlayedOld != default && appMetadata.TimePlayed == TimeSpan.Zero)
{ {
appMetadata.TimePlayed = TimeSpan.FromSeconds(appMetadata.TimePlayedOld); appMetadata.Title = data.Name;
appMetadata.TimePlayedOld = default;
}
// Only do the migration if last_played has a value and last_played_utc doesn't exist yet. // Only do the migration if time_played has a value and timespan_played hasn't been updated yet.
if (appMetadata.LastPlayedOld != default && !appMetadata.LastPlayed.HasValue) if (appMetadata.TimePlayedOld != default && appMetadata.TimePlayed == TimeSpan.Zero)
{
// Migrate from string-based last_played to DateTime-based last_played_utc.
if (DateTime.TryParse(appMetadata.LastPlayedOld, out DateTime lastPlayedOldParsed))
{ {
appMetadata.LastPlayed = lastPlayedOldParsed; appMetadata.TimePlayed = TimeSpan.FromSeconds(appMetadata.TimePlayedOld);
appMetadata.TimePlayedOld = default;
// Migration successful: deleting last_played from the metadata file.
appMetadata.LastPlayedOld = default;
} }
} // Only do the migration if last_played has a value and last_played_utc doesn't exist yet.
}); if (appMetadata.LastPlayedOld != default && !appMetadata.LastPlayed.HasValue)
{
// Migrate from string-based last_played to DateTime-based last_played_utc.
if (DateTime.TryParse(appMetadata.LastPlayedOld, out DateTime lastPlayedOldParsed))
{
appMetadata.LastPlayed = lastPlayedOldParsed;
// Migration successful: deleting last_played from the metadata file.
appMetadata.LastPlayedOld = default;
}
}
});
data.Favorite = appMetadata.Favorite;
data.TimePlayed = appMetadata.TimePlayed;
data.LastPlayed = appMetadata.LastPlayed;
}
data.Favorite = appMetadata.Favorite;
data.TimePlayed = appMetadata.TimePlayed;
data.LastPlayed = appMetadata.LastPlayed;
data.FileExtension = Path.GetExtension(applicationPath).TrimStart('.').ToUpper(); data.FileExtension = Path.GetExtension(applicationPath).TrimStart('.').ToUpper();
data.FileSize = fileSize; data.FileSize = fileSize;
data.Path = applicationPath; data.Path = applicationPath;
@@ -482,13 +487,11 @@ namespace Ryujinx.UI.App.Common
controlFile.Get.Read(out _, 0, outProperty, ReadOption.None).ThrowIfFailure(); controlFile.Get.Read(out _, 0, outProperty, ReadOption.None).ThrowIfFailure();
} }
public void LoadApplications(List<string> appDirs, Language desiredTitleLanguage) public void LoadApplications(List<string> appDirs)
{ {
int numApplicationsFound = 0; int numApplicationsFound = 0;
int numApplicationsLoaded = 0; int numApplicationsLoaded = 0;
_desiredTitleLanguage = desiredTitleLanguage;
_cancellationToken = new CancellationTokenSource(); _cancellationToken = new CancellationTokenSource();
// Builds the applications list with paths to found applications // Builds the applications list with paths to found applications
@@ -847,7 +850,7 @@ namespace Ryujinx.UI.App.Common
private void GetApplicationInformation(ref ApplicationControlProperty controlData, ref ApplicationData data) private void GetApplicationInformation(ref ApplicationControlProperty controlData, ref ApplicationData data)
{ {
_ = Enum.TryParse(_desiredTitleLanguage.ToString(), out TitleLanguage desiredTitleLanguage); _ = Enum.TryParse(DesiredLanguage.ToString(), out TitleLanguage desiredTitleLanguage);
if (controlData.Title.ItemsRo.Length > (int)desiredTitleLanguage) if (controlData.Title.ItemsRo.Length > (int)desiredTitleLanguage)
{ {

View File

@@ -21,7 +21,7 @@ namespace Ryujinx.Ava.Common.Locale
var builder = new CompiledBindingPathBuilder(); var builder = new CompiledBindingPathBuilder();
builder.SetRawSource(LocaleManager.Instance) builder
.Property(new ClrPropertyInfo("Item", .Property(new ClrPropertyInfo("Item",
obj => (LocaleManager.Instance[keyToUse]), obj => (LocaleManager.Instance[keyToUse]),
null, null,
@@ -32,7 +32,10 @@ namespace Ryujinx.Ava.Common.Locale
var path = builder.Build(); var path = builder.Build();
var binding = new CompiledBindingExtension(path); var binding = new CompiledBindingExtension(path)
{
Source = LocaleManager.Instance
};
return binding.ProvideValue(serviceProvider); return binding.ProvideValue(serviceProvider);
} }

View File

@@ -139,9 +139,11 @@ namespace Ryujinx.Ava.Common.Locale
foreach (var item in locale) foreach (var item in locale)
{ {
this[item.Key] = item.Value; _localeStrings[item.Key] = item.Value;
} }
OnPropertyChanged("Item");
LocaleChanged?.Invoke(); LocaleChanged?.Invoke();
} }

View File

@@ -1,7 +1,7 @@
using Microsoft.IdentityModel.Tokens;
using Ryujinx.Ava.UI.Models; using Ryujinx.Ava.UI.Models;
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
namespace Ryujinx.Ava.UI.ViewModels namespace Ryujinx.Ava.UI.ViewModels
{ {
@@ -11,7 +11,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
Profiles = new ObservableCollection<BaseModel>(); Profiles = new ObservableCollection<BaseModel>();
LostProfiles = new ObservableCollection<UserProfile>(); LostProfiles = new ObservableCollection<UserProfile>();
IsEmpty = LostProfiles.IsNullOrEmpty(); IsEmpty = !LostProfiles.Any();
} }
public ObservableCollection<BaseModel> Profiles { get; set; } public ObservableCollection<BaseModel> Profiles { get; set; }

View File

@@ -37,6 +37,7 @@ namespace Ryujinx.Ava.UI.Windows
internal static MainWindowViewModel MainWindowViewModel { get; private set; } internal static MainWindowViewModel MainWindowViewModel { get; private set; }
private bool _isLoading; private bool _isLoading;
private bool _applicationsLoadedOnce;
private UserChannelPersistence _userChannelPersistence; private UserChannelPersistence _userChannelPersistence;
private static bool _deferLoad; private static bool _deferLoad;
@@ -224,7 +225,10 @@ namespace Ryujinx.Ava.UI.Windows
? IntegrityCheckLevel.ErrorOnInvalid ? IntegrityCheckLevel.ErrorOnInvalid
: IntegrityCheckLevel.None; : IntegrityCheckLevel.None;
ApplicationLibrary = new ApplicationLibrary(VirtualFileSystem, checkLevel); ApplicationLibrary = new ApplicationLibrary(VirtualFileSystem, checkLevel)
{
DesiredLanguage = ConfigurationState.Instance.System.Language,
};
// Save data created before we supported extra data in directory save data will not work properly if // Save data created before we supported extra data in directory save data will not work properly if
// given empty extra data. Luckily some of that extra data can be created using the data from the // given empty extra data. Luckily some of that extra data can be created using the data from the
@@ -472,7 +476,11 @@ namespace Ryujinx.Ava.UI.Windows
ViewModel.RefreshFirmwareStatus(); ViewModel.RefreshFirmwareStatus();
LoadApplications(); // Load applications if no application was requested by the command line
if (!_deferLoad)
{
LoadApplications();
}
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
CheckLaunchState(); CheckLaunchState();
@@ -485,6 +493,12 @@ namespace Ryujinx.Ava.UI.Windows
if (MainContent.Content != content) if (MainContent.Content != content)
{ {
// Load applications while switching to the GameLibrary if we haven't done that yet
if (!_applicationsLoadedOnce && content == GameLibrary)
{
LoadApplications();
}
MainContent.Content = content; MainContent.Content = content;
} }
} }
@@ -581,6 +595,7 @@ namespace Ryujinx.Ava.UI.Windows
public void LoadApplications() public void LoadApplications()
{ {
_applicationsLoadedOnce = true;
ViewModel.Applications.Clear(); ViewModel.Applications.Clear();
StatusBarView.LoadProgressBar.IsVisible = true; StatusBarView.LoadProgressBar.IsVisible = true;
@@ -622,7 +637,8 @@ namespace Ryujinx.Ava.UI.Windows
Thread applicationLibraryThread = new(() => Thread applicationLibraryThread = new(() =>
{ {
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language); ApplicationLibrary.DesiredLanguage = ConfigurationState.Instance.System.Language;
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
_isLoading = false; _isLoading = false;
}) })