Compare commits

..

11 Commits

Author SHA1 Message Date
GreemDev
d4107ac05f UI: Add a startup flag to ignore new Amiibo file updates, useful for testing changes you intend on committing to Ryubing/Nfc.
Flag is `--local-only-amiibo`
2025-10-15 21:51:13 -05:00
LotP
1d409f7127 12 GiB heap support (ryubing/ryujinx!166)
See merge request ryubing/ryujinx!166
2025-10-15 15:37:13 -05:00
GreemDev
2434c55266 UI: Updater: Fix "No" opening the changelog and "Show Changelog" doing nothing (aka doing what "No" should be doing) 2025-10-14 18:38:56 -05:00
GreemDev
99126603ba UI: swap the UI reset checkbox text back to a sentence instead of title cased 2025-10-14 16:12:11 -05:00
GreemDev
a62716002e chore: move HasPtcCacheFiles & HasShaderCacheFiles into ApplicationData, instead of having the weird static dependency helpers 2025-10-14 16:09:51 -05:00
GreemDev
47559cd311 Revert game list rounding
The selected highlight was bugged

https://fs.ryujinx.app/40cl4Ih9RiOWLVi7e4lJsw.png
2025-10-14 15:59:02 -05:00
Coxxs
51584a083b Flush the error log before exit (ryubing/ryujinx!163)
See merge request ryubing/ryujinx!163
2025-10-13 17:40:15 -05:00
Coxxs
ceec9617ef gdb: Fix the crash that occurs when GDB is connected early (ryubing/ryujinx!159)
See merge request ryubing/ryujinx!159
2025-10-11 19:06:14 -05:00
Coxxs
1865be47cf gdb: Add monitor minidump command (ryubing/ryujinx!158)
See merge request ryubing/ryujinx!158
2025-10-11 10:01:30 -05:00
LotP
ef9810582a Sync thread name on Schedule (ryubing/ryujinx!157)
See merge request ryubing/ryujinx!157
2025-10-11 07:47:45 -05:00
KeatonTheBot
13878acdb2 Avoid lookup of invalid textures if pool did not change (ryubing/ryujinx!113)
See merge request ryubing/ryujinx!113
2025-10-11 02:56:13 -05:00
22 changed files with 483 additions and 75 deletions

View File

@@ -6445,26 +6445,27 @@
{
"ID": "SettingsButtonResetConfirm",
"Translations": {
"ar_SA": "أريد إعادة تعيين إعداداتي",
"de_DE": "Ich möchte meine Einstellungen zurücksetzen",
"el_GR": "Θέλω να επαναφέρω τις ρυθμίσεις μου",
"en_US": "I Want To Reset My Settings",
"es_ES": "Quiero Restablecer Mi Configuración",
"fr_FR": "Je Veux Réinitialiser Mes Paramètres",
"he_IL": "אני רוצה לאפס את ההגדרות שלי",
"it_IT": "Voglio reimpostare le mie impostazioni",
"ja_JP": "設定をリセットしたいです",
"ko_KR": "설정을 초기화하고 싶습니다",
"no_NO": "Jeg vil tilbakestille innstillingene mine",
"pl_PL": "Chcę zresetować moje ustawienia",
"pt_BR": "Quero redefinir minhas configurações",
"ru_RU": "Я хочу сбросить свои настройки",
"sv_SE": "Jag vill nollställa mina inställningar",
"th_TH": "ฉันต้องการรีเซ็ตการตั้งค่าของฉัน",
"tr_TR": "Ayarlarımı sıfırlamak istiyorum",
"uk_UA": "Я хочу скинути налаштування",
"zh_CN": "我要重置我的设置",
"zh_TW": "我想重設我的設定"
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "I want to reset my settings.",
"es_ES": "Quiero restablecer mi Configuración.",
"fr_FR": "Je veux réinitialiser mes paramètres.",
"he_IL": "",
"it_IT": "Voglio ripristinare le mie impostazioni.",
"ja_JP": "",
"ko_KR": "설정을 초기화하고 싶습니다.",
"no_NO": "Jeg vil tilbakestille innstillingene mine.",
"pl_PL": "",
"pt_BR": "Quero redefinir minhas configurações.",
"ru_RU": "Я хочу сбросить свои настройки.",
"sv_SE": "Jag vill nollställa mina inställningar.",
"th_TH": "",
"tr_TR": "",
"uk_UA": "Я хочу скинути налаштування.",
"zh_CN": "我要重置我的设置",
"zh_TW": "我想重設我的設定"
}
},
{

View File

@@ -0,0 +1,226 @@
namespace Ryujinx.Common.Collections
{
/// <summary>
/// Represents a collection that can store 1 bit values.
/// </summary>
public struct BitMap
{
/// <summary>
/// Size in bits of the integer used internally for the groups of bits.
/// </summary>
public const int IntSize = 64;
private const int IntShift = 6;
private const int IntMask = IntSize - 1;
private readonly long[] _masks;
/// <summary>
/// Gets or sets the value of a bit.
/// </summary>
/// <param name="bit">Bit to access</param>
/// <returns>Bit value</returns>
public bool this[int bit]
{
get => IsSet(bit);
set
{
if (value)
{
Set(bit);
}
else
{
Clear(bit);
}
}
}
/// <summary>
/// Creates a new bitmap.
/// </summary>
/// <param name="count">Total number of bits</param>
public BitMap(int count)
{
_masks = new long[(count + IntMask) / IntSize];
}
/// <summary>
/// Checks if any bit is set.
/// </summary>
/// <returns>True if any bit is set, false otherwise</returns>
public bool AnySet()
{
for (int i = 0; i < _masks.Length; i++)
{
if (_masks[i] != 0)
{
return true;
}
}
return false;
}
/// <summary>
/// Checks if a specific bit is set.
/// </summary>
/// <param name="bit">Bit to be checked</param>
/// <returns>True if set, false otherwise</returns>
public bool IsSet(int bit)
{
int wordIndex = bit >> IntShift;
int wordBit = bit & IntMask;
long wordMask = 1L << wordBit;
return (_masks[wordIndex] & wordMask) != 0;
}
/// <summary>
/// Checks if any bit inside a given range of bits is set.
/// </summary>
/// <param name="start">Start bit of the range</param>
/// <param name="end">End bit of the range (inclusive)</param>
/// <returns>True if any bit is set, false otherwise</returns>
public bool IsSet(int start, int end)
{
if (start == end)
{
return IsSet(start);
}
int startIndex = start >> IntShift;
int startBit = start & IntMask;
long startMask = -1L << startBit;
int endIndex = end >> IntShift;
int endBit = end & IntMask;
long endMask = (long)(ulong.MaxValue >> (IntMask - endBit));
if (startIndex == endIndex)
{
return (_masks[startIndex] & startMask & endMask) != 0;
}
if ((_masks[startIndex] & startMask) != 0)
{
return true;
}
for (int i = startIndex + 1; i < endIndex; i++)
{
if (_masks[i] != 0)
{
return true;
}
}
if ((_masks[endIndex] & endMask) != 0)
{
return true;
}
return false;
}
/// <summary>
/// Sets the value of a bit to 1.
/// </summary>
/// <param name="bit">Bit to be set</param>
/// <returns>True if the bit was 0 and then changed to 1, false if it was already 1</returns>
public bool Set(int bit)
{
int wordIndex = bit >> IntShift;
int wordBit = bit & IntMask;
long wordMask = 1L << wordBit;
if ((_masks[wordIndex] & wordMask) != 0)
{
return false;
}
_masks[wordIndex] |= wordMask;
return true;
}
/// <summary>
/// Sets a given range of bits to 1.
/// </summary>
/// <param name="start">Start bit of the range</param>
/// <param name="end">End bit of the range (inclusive)</param>
public void SetRange(int start, int end)
{
if (start == end)
{
Set(start);
return;
}
int startIndex = start >> IntShift;
int startBit = start & IntMask;
long startMask = -1L << startBit;
int endIndex = end >> IntShift;
int endBit = end & IntMask;
long endMask = (long)(ulong.MaxValue >> (IntMask - endBit));
if (startIndex == endIndex)
{
_masks[startIndex] |= startMask & endMask;
}
else
{
_masks[startIndex] |= startMask;
for (int i = startIndex + 1; i < endIndex; i++)
{
_masks[i] |= -1;
}
_masks[endIndex] |= endMask;
}
}
/// <summary>
/// Sets a given bit to 0.
/// </summary>
/// <param name="bit">Bit to be cleared</param>
public void Clear(int bit)
{
int wordIndex = bit >> IntShift;
int wordBit = bit & IntMask;
long wordMask = 1L << wordBit;
_masks[wordIndex] &= ~wordMask;
}
/// <summary>
/// Sets all bits to 0.
/// </summary>
public void Clear()
{
for (int i = 0; i < _masks.Length; i++)
{
_masks[i] = 0;
}
}
/// <summary>
/// Sets one or more groups of bits to 0.
/// See <see cref="IntSize"/> for how many bits are inside each group.
/// </summary>
/// <param name="start">Start index of the group</param>
/// <param name="end">End index of the group (inclusive)</param>
public void ClearInt(int start, int end)
{
for (int i = start; i <= end; i++)
{
_masks[i] = 0;
}
}
}
}

View File

@@ -187,6 +187,17 @@ namespace Ryujinx.Common.Logging
}
}
public static void Flush()
{
foreach (ILogTarget target in _logTargets)
{
if (target is AsyncLogTargetWrapper asyncTarget)
{
asyncTarget.Flush();
}
}
}
public static void Shutdown()
{
Updated = null;

View File

@@ -27,6 +27,17 @@ namespace Ryujinx.Common.Logging.Targets
private readonly int _overflowTimeout;
private sealed class FlushEventArgs : LogEventArgs
{
public readonly ManualResetEventSlim SignalEvent;
public FlushEventArgs(ManualResetEventSlim signalEvent)
: base(LogLevel.Notice, TimeSpan.Zero, string.Empty, string.Empty)
{
SignalEvent = signalEvent;
}
}
string ILogTarget.Name => _target.Name;
public AsyncLogTargetWrapper(ILogTarget target, int queueLimit = -1, AsyncLogTargetOverflowAction overflowAction = AsyncLogTargetOverflowAction.Block)
@@ -41,7 +52,15 @@ namespace Ryujinx.Common.Logging.Targets
{
try
{
_target.Log(this, _messageQueue.Take());
LogEventArgs item = _messageQueue.Take();
if (item is FlushEventArgs flush)
{
flush.SignalEvent.Set();
continue;
}
_target.Log(this, item);
}
catch (InvalidOperationException)
{
@@ -68,6 +87,26 @@ namespace Ryujinx.Common.Logging.Targets
}
}
public void Flush()
{
if (_messageQueue.Count == 0 || _messageQueue.IsAddingCompleted)
{
return;
}
using var signal = new ManualResetEventSlim(false);
try
{
_messageQueue.Add(new FlushEventArgs(signal));
}
catch (InvalidOperationException)
{
return;
}
signal.Wait();
}
public void Dispose()
{
GC.SuppressFinalize(this);

View File

@@ -1,3 +1,4 @@
using Ryujinx.Common.Collections;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Memory;
@@ -72,6 +73,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
private readonly GpuChannel _channel;
private readonly BitMap _invalidMap;
private readonly ConcurrentQueue<DereferenceRequest> _dereferenceQueue = new();
private TextureDescriptor _defaultDescriptor;
@@ -166,6 +168,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
_channel = channel;
_aliasLists = new Dictionary<Texture, TextureAliasList>();
_invalidMap = new BitMap(maximumId + 1);
}
/// <summary>
@@ -182,6 +185,11 @@ namespace Ryujinx.Graphics.Gpu.Image
if (texture == null)
{
if (_invalidMap.IsSet(id))
{
return ref descriptor;
}
texture = PhysicalMemory.TextureCache.FindShortCache(descriptor);
if (texture == null)
@@ -198,6 +206,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// If this happens, then the texture address is invalid, we can't add it to the cache.
if (texture == null)
{
_invalidMap.Set(id);
return ref descriptor;
}
}
@@ -515,6 +524,8 @@ namespace Ryujinx.Graphics.Gpu.Image
RemoveAliasList(texture);
}
}
_invalidMap.Clear(id);
}
}

View File

@@ -859,7 +859,13 @@ namespace Ryujinx.HLE.Debugger
{
if (threadId == 0 || threadId == null)
{
threadId = GetThreads().First().ThreadUid;
var threads = GetThreads();
if (threads.Length == 0)
{
ReplyError();
return;
}
threadId = threads.First().ThreadUid;
}
if (DebugProcess.GetThread(threadId.Value) == null)
@@ -1037,12 +1043,13 @@ namespace Ryujinx.HLE.Debugger
string response = command.Trim().ToLowerInvariant() switch
{
"help" => "backtrace\nbt\nregisters\nreg\nget info\n",
"help" => "backtrace\nbt\nregisters\nreg\nget info\nminidump\n",
"get info" => GetProcessInfo(),
"backtrace" => GetStackTrace(),
"bt" => GetStackTrace(),
"registers" => GetRegisters(),
"reg" => GetRegisters(),
"minidump" => GetMinidump(),
_ => $"Unknown command: {command}\n"
};
@@ -1077,6 +1084,42 @@ namespace Ryujinx.HLE.Debugger
return Process.Debugger.GetCpuRegisterPrintout(DebugProcess.GetThread(gThread.Value));
}
private string GetMinidump()
{
var response = new StringBuilder();
response.AppendLine("=== Begin Minidump ===\n");
response.AppendLine(GetProcessInfo());
foreach (var thread in GetThreads())
{
response.AppendLine($"=== Thread {thread.ThreadUid} ===");
try
{
string stackTrace = Process.Debugger.GetGuestStackTrace(thread);
response.AppendLine(stackTrace);
}
catch (Exception e)
{
response.AppendLine($"[Error getting stack trace: {e.Message}]");
}
try
{
string registers = Process.Debugger.GetCpuRegisterPrintout(thread);
response.AppendLine(registers);
}
catch (Exception e)
{
response.AppendLine($"[Error getting registers: {e.Message}]");
}
}
response.AppendLine("=== End Minidump ===");
Logger.Info?.Print(LogClass.GdbStub, response.ToString());
return response.ToString();
}
private string GetProcessInfo()
{
try
@@ -1155,11 +1198,11 @@ namespace Ryujinx.HLE.Debugger
// If the user connects before the application is running, wait for the application to start.
int retries = 10;
while (DebugProcess == null && retries-- > 0)
while ((DebugProcess == null || GetThreads().Length == 0) && retries-- > 0)
{
Thread.Sleep(200);
}
if (DebugProcess == null)
if (DebugProcess == null || GetThreads().Length == 0)
{
Logger.Warning?.Print(LogClass.GdbStub, "Application is not running, cannot accept GDB client connection");
ClientSocket.Close();

View File

@@ -29,6 +29,7 @@ namespace Ryujinx.HLE.HOS.Kernel
capabilities,
context.ResourceLimit,
MemoryRegion.Service,
context.Device.Configuration.MemoryConfiguration,
null,
customThreadStart);

View File

@@ -102,6 +102,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
ProcessCreationFlags flags,
bool fromBack,
MemoryRegion memRegion,
MemoryConfiguration memConfig,
ulong address,
ulong size,
KMemoryBlockSlabManager slabManager)
@@ -117,6 +118,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
addrSpaceBase,
addrSpaceSize,
memRegion,
memConfig,
address,
size,
slabManager);
@@ -159,6 +161,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
ulong addrSpaceStart,
ulong addrSpaceEnd,
MemoryRegion memRegion,
MemoryConfiguration memConfig,
ulong address,
ulong size,
KMemoryBlockSlabManager slabManager)
@@ -193,7 +196,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
case ProcessCreationFlags.AddressSpace64BitDeprecated:
aliasRegion.Size = 0x180000000;
heapRegion.Size = 0x180000000;
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
stackRegion.Size = 0;
tlsIoRegion.Size = 0;
CodeRegionStart = 0x8000000;
@@ -223,7 +226,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
int addressSpaceWidth = (int)ulong.Log2(_reservedAddressSpaceSize);
aliasRegion.Size = 1UL << (addressSpaceWidth - 3);
heapRegion.Size = 0x180000000;
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
stackRegion.Size = 1UL << (addressSpaceWidth - 8);
tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3);
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
@@ -237,7 +240,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
else
{
aliasRegion.Size = 0x1000000000;
heapRegion.Size = 0x180000000;
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
stackRegion.Size = 0x80000000;
tlsIoRegion.Size = 0x1000000000;
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);

View File

@@ -124,6 +124,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
KPageList pageList,
KResourceLimit resourceLimit,
MemoryRegion memRegion,
MemoryConfiguration memConfig,
IProcessContextFactory contextFactory,
ThreadStart customThreadStart = null)
{
@@ -153,6 +154,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
creationInfo.Flags,
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
memRegion,
memConfig,
codeAddress,
codeSize,
slabManager);
@@ -189,6 +191,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
ReadOnlySpan<uint> capabilities,
KResourceLimit resourceLimit,
MemoryRegion memRegion,
MemoryConfiguration memConfig,
IProcessContextFactory contextFactory,
ThreadStart customThreadStart = null)
{
@@ -252,6 +255,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
creationInfo.Flags,
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
memRegion,
memConfig,
codeAddress,
codeSize,
slabManager);
@@ -1095,6 +1099,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
Logger.Error?.Print(LogClass.Cpu, $"Invalid memory access at virtual address 0x{va:X16}.");
Logger.Flush();
return false;
}
@@ -1103,6 +1109,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
KernelStatic.GetCurrentThread().PrintGuestStackTrace();
KernelStatic.GetCurrentThread()?.PrintGuestRegisterPrintout();
Logger.Flush();
throw new UndefinedInstructionException(address, opCode);
}

View File

@@ -137,6 +137,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
capabilities,
resourceLimit,
memRegion,
_context.Device.Configuration.MemoryConfiguration,
contextFactory,
customThreadStart);
@@ -888,7 +889,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
[Svc(1)]
public Result SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size)
{
if ((size & 0xfffffffe001fffff) != 0)
if ((size & 0xfffffffd001fffff) != 0)
{
address = 0;
@@ -1893,6 +1894,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return;
}
Logger.Error?.Print(LogClass.KernelSvc, "The guest program broke execution!");
Logger.Flush();
// TODO: Debug events.
currentThread.Owner.TerminateCurrentProcess();

View File

@@ -293,6 +293,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
KThread currentThread = KernelStatic.GetCurrentThread();
KThread selectedThread = _state.SelectedThread;
if (!currentThread.IsThreadNamed && currentThread.GetThreadName() != "")
{
currentThread.HostThread.Name = $"<{currentThread.GetThreadName()}>";
currentThread.IsThreadNamed = true;
}
// If the thread is already scheduled and running on the core, we have nothing to do.
if (currentThread == selectedThread)
{

View File

@@ -53,6 +53,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public ulong AffinityMask { get; set; }
public ulong ThreadUid { get; private set; }
public bool IsThreadNamed { get; set; }
private long _totalTimeRunning;

View File

@@ -189,7 +189,7 @@ namespace Ryujinx.HLE.Loaders.Processes
codeAddress,
codeSize);
result = process.InitializeKip(creationInfo, kip.Capabilities, pageList, context.ResourceLimit, memoryRegion, processContextFactory);
result = process.InitializeKip(creationInfo, kip.Capabilities, pageList, context.ResourceLimit, memoryRegion, context.Device.Configuration.MemoryConfiguration, processContextFactory);
if (result != Result.Success)
{
Logger.Error?.Print(LogClass.Loader, $"Process initialization returned error \"{result}\".");
@@ -389,6 +389,7 @@ namespace Ryujinx.HLE.Loaders.Processes
MemoryMarshal.Cast<byte, uint>(npdm.KernelCapabilityData),
resourceLimit,
memoryRegion,
context.Device.Configuration.MemoryConfiguration,
processContextFactory);
if (result != Result.Success)

View File

@@ -351,7 +351,10 @@ namespace Ryujinx.Ava
if (isTerminating)
{
Logger.Flush();
Exit();
}
}
internal static void Exit()

View File

@@ -11,11 +11,13 @@ using LibHac.Tools.FsSystem.NcaUtils;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Systems.PlayReport;
using Ryujinx.Ava.Utilities;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.Loaders.Processes.Extensions;
using System;
using System.IO;
using System.Linq;
using System.Text.Json.Serialization;
namespace Ryujinx.Ava.Systems.AppLibrary
@@ -84,6 +86,32 @@ namespace Ryujinx.Ava.Systems.AppLibrary
public LocaleKeys? PlayabilityStatus => Compatibility.Convert(x => x.Status).OrElse(null);
public bool HasPtcCacheFiles
{
get
{
DirectoryInfo mainDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, IdString, "cache", "cpu", "0"));
DirectoryInfo backupDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, IdString, "cache", "cpu", "1"));
return (mainDir.Exists && (mainDir.EnumerateFiles("*.cache").Any() || mainDir.EnumerateFiles("*.info").Any())) ||
(backupDir.Exists && (backupDir.EnumerateFiles("*.cache").Any() || backupDir.EnumerateFiles("*.info").Any()));
}
}
public bool HasShaderCacheFiles
{
get
{
DirectoryInfo shaderCacheDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, IdString, "cache", "shader"));
if (!shaderCacheDir.Exists) return false;
return shaderCacheDir.EnumerateDirectories("*").Any() ||
shaderCacheDir.GetFiles("*.toc").Length != 0 ||
shaderCacheDir.GetFiles("*.data").Length != 0;
}
}
public string LocalizedStatusTooltip =>
Compatibility.Convert(x =>
#pragma warning disable CS8509 // It is exhaustive for all possible values this can contain.

View File

@@ -120,13 +120,13 @@
CommandParameter="{Binding}"
Header="{ext:Locale GameListContextMenuCacheManagementNukePptc}"
Icon="{ext:Icon fa-solid fa-trash-can}"
IsEnabled="{Binding HasPtcCacheFiles}" />
IsEnabled="{Binding SelectedApplication.HasPtcCacheFiles, FallbackValue=False}" />
<MenuItem
Command="{Binding PurgeShaderCache}"
CommandParameter="{Binding}"
Header="{ext:Locale GameListContextMenuCacheManagementPurgeShaderCache}"
Icon="{ext:Icon fa-solid fa-trash-can}"
IsEnabled="{Binding HasShaderCacheFiles}" />
IsEnabled="{Binding SelectedApplication.HasShaderCacheFiles, FallbackValue=False}" />
<Separator/>
<MenuItem
Command="{Binding OpenPtcDirectory}"

View File

@@ -354,8 +354,8 @@ namespace Ryujinx.Ava.UI.Helpers
primary,
secondaryText,
LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.InputDialogNo],
LocaleManager.Instance[LocaleKeys.DialogUpdaterShowChangelogMessage],
LocaleManager.Instance[LocaleKeys.InputDialogNo],
(int)Symbol.Help,
UserResult.Yes);

View File

@@ -6,6 +6,7 @@ using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Common.Models.Amiibo;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Windows;
using Ryujinx.Ava.Utilities;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
@@ -250,6 +251,7 @@ namespace Ryujinx.Ava.UI.ViewModels
catch (Exception exception)
{
Logger.Warning?.Print(LogClass.Application, $"Unable to read data from '{_amiiboJsonPath}': {exception}");
localIsValid = false;
}
if (!localIsValid || await NeedsUpdate(amiiboJson.LastUpdated))
@@ -280,11 +282,59 @@ namespace Ryujinx.Ava.UI.ViewModels
return amiiboJson;
}
private async Task<AmiiboJson?> ReadLocalJsonFileAsync()
{
bool isValid = false;
AmiiboJson amiiboJson = new();
try
{
try
{
if (File.Exists(_amiiboJsonPath))
{
isValid = TryGetAmiiboJson(await File.ReadAllTextAsync(_amiiboJsonPath), out amiiboJson);
}
}
catch (Exception exception)
{
Logger.Warning?.Print(LogClass.Application, $"Unable to read data from '{_amiiboJsonPath}': {exception}");
isValid = false;
}
if (!isValid)
{
return null;
}
}
catch (Exception exception)
{
if (!isValid)
{
Logger.Error?.Print(LogClass.Application, $"Couldn't get valid amiibo data: {exception}");
// Neither local file is not valid JSON, close window.
await ShowInfoDialog();
Close();
}
}
return amiiboJson;
}
private async Task LoadContentAsync()
{
AmiiboJson amiiboJson = await GetMostRecentAmiiboListOrDefaultJson();
AmiiboJson? amiiboJson;
_amiiboList = amiiboJson.Amiibo.OrderBy(amiibo => amiibo.AmiiboSeries).ToList();
if (CommandLineState.OnlyLocalAmiibo)
amiiboJson = await ReadLocalJsonFileAsync();
else
amiiboJson = await GetMostRecentAmiiboListOrDefaultJson();
if (!amiiboJson.HasValue)
return;
_amiiboList = amiiboJson.Value.Amiibo.OrderBy(amiibo => amiibo.AmiiboSeries).ToList();
ParseAmiiboData();
}

View File

@@ -2121,8 +2121,7 @@ namespace Ryujinx.Ava.UI.ViewModels
});
public static AsyncRelayCommand<MainWindowViewModel> NukePtcCache { get; } =
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null &&
vm.HasPtcCacheFiles(),
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication?.HasPtcCacheFiles ?? false,
async viewModel =>
{
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(
@@ -2171,22 +2170,9 @@ namespace Ryujinx.Ava.UI.ViewModels
}
});
private bool HasPtcCacheFiles()
{
if (this.SelectedApplication == null) return false;
DirectoryInfo mainDir = new DirectoryInfo(Path.Combine(AppDataManager.GamesDirPath,
this.SelectedApplication.IdString, "cache", "cpu", "0"));
DirectoryInfo backupDir = new DirectoryInfo(Path.Combine(AppDataManager.GamesDirPath,
this.SelectedApplication.IdString, "cache", "cpu", "1"));
return (mainDir.Exists && (mainDir.EnumerateFiles("*.cache").Any() || mainDir.EnumerateFiles("*.info").Any())) ||
(backupDir.Exists && (backupDir.EnumerateFiles("*.cache").Any() || backupDir.EnumerateFiles("*.info").Any()));
}
public static AsyncRelayCommand<MainWindowViewModel> PurgeShaderCache { get; } =
Commands.CreateConditional<MainWindowViewModel>(
vm => vm?.SelectedApplication != null && vm.HasShaderCacheFiles(),
vm => vm?.SelectedApplication?.HasShaderCacheFiles ?? false,
async viewModel =>
{
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(
@@ -2243,20 +2229,6 @@ namespace Ryujinx.Ava.UI.ViewModels
}
});
private bool HasShaderCacheFiles()
{
if (this.SelectedApplication == null) return false;
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath,
this.SelectedApplication.IdString, "cache", "shader"));
if (!shaderCacheDir.Exists) return false;
return shaderCacheDir.EnumerateDirectories("*").Any() ||
shaderCacheDir.GetFiles("*.toc").Any() ||
shaderCacheDir.GetFiles("*.data").Any();
}
public static RelayCommand<MainWindowViewModel> OpenPtcDirectory { get; } =
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null,
viewModel =>

View File

@@ -35,7 +35,7 @@
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="Margin" Value="5" />
<Setter Property="CornerRadius" Value="15" />
<Setter Property="CornerRadius" Value="4" />
</Style>
<Style Selector="ListBoxItem:selected /template/ Rectangle#SelectionIndicator">
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).GridItemSelectorSize}" />
@@ -53,7 +53,7 @@
Classes.normal="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridMedium}"
Classes.small="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridSmall}"
ClipToBounds="True"
CornerRadius="12.5">
CornerRadius="4">
<Grid RowDefinitions="Auto,Auto">
<Image
Grid.Row="0"

View File

@@ -34,9 +34,6 @@
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="CornerRadius" Value="15" />
</Style>
<Style Selector="ListBoxItem:selected /template/ Rectangle#SelectionIndicator">
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).ListItemSelectorSize}" />
</Style>
@@ -49,11 +46,9 @@
Padding="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ClipToBounds="True">
ClipToBounds="True"
CornerRadius="5">
<Grid ColumnDefinitions="Auto,10,*,150,100">
<Border
ClipToBounds="True"
CornerRadius="7">
<Image
Grid.RowSpan="3"
Grid.Column="0"
@@ -63,7 +58,6 @@
Classes.normal="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridMedium}"
Classes.small="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridSmall}"
Source="{Binding Icon, Converter={x:Static helpers:BitmapArrayValueConverter.Instance}}" />
</Border>
<Border
Grid.Column="2"

View File

@@ -25,6 +25,7 @@ namespace Ryujinx.Ava.Utilities
public static string LaunchApplicationId { get; private set; }
public static bool StartFullscreenArg { get; private set; }
public static bool HideAvailableUpdates { get; private set; }
public static bool OnlyLocalAmiibo { get; private set; }
public static void ParseArguments(string[] args)
{
@@ -130,6 +131,10 @@ namespace Ryujinx.Ava.Utilities
OverridePPTC = args[++i];
break;
case "-la":
case "--local-only-amiibo":
OnlyLocalAmiibo = true;
break;
case "-m":
case "--memory-manager-mode":
if (i + 1 >= args.Length)