Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
30862b5ffd | ||
|
9f57747c57 | ||
|
fe29a2ff6e | ||
|
e9a173e00c | ||
|
a11784fcbf | ||
|
fd36c8deca | ||
|
70638340b3 | ||
|
4b495f3333 | ||
|
934b5a64e5 | ||
|
cee667b491 |
185
ARMeilleure/CodeGen/Arm64/HardwareCapabilities.cs
Normal file
185
ARMeilleure/CodeGen/Arm64/HardwareCapabilities.cs
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Intrinsics.Arm;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
|
namespace ARMeilleure.CodeGen.Arm64
|
||||||
|
{
|
||||||
|
static partial class HardwareCapabilities
|
||||||
|
{
|
||||||
|
static HardwareCapabilities()
|
||||||
|
{
|
||||||
|
if (!ArmBase.Arm64.IsSupported)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
LinuxFeatureInfoHwCap = (LinuxFeatureFlagsHwCap)getauxval(AT_HWCAP);
|
||||||
|
LinuxFeatureInfoHwCap2 = (LinuxFeatureFlagsHwCap2)getauxval(AT_HWCAP2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OperatingSystem.IsMacOS())
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _sysctlNames.Length; i++)
|
||||||
|
{
|
||||||
|
if (CheckSysctlName(_sysctlNames[i]))
|
||||||
|
{
|
||||||
|
MacOsFeatureInfo |= (MacOsFeatureFlags)(1 << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Linux
|
||||||
|
|
||||||
|
private const ulong AT_HWCAP = 16;
|
||||||
|
private const ulong AT_HWCAP2 = 26;
|
||||||
|
|
||||||
|
[LibraryImport("libc", SetLastError = true)]
|
||||||
|
private static partial ulong getauxval(ulong type);
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum LinuxFeatureFlagsHwCap : ulong
|
||||||
|
{
|
||||||
|
Fp = 1 << 0,
|
||||||
|
Asimd = 1 << 1,
|
||||||
|
Evtstrm = 1 << 2,
|
||||||
|
Aes = 1 << 3,
|
||||||
|
Pmull = 1 << 4,
|
||||||
|
Sha1 = 1 << 5,
|
||||||
|
Sha2 = 1 << 6,
|
||||||
|
Crc32 = 1 << 7,
|
||||||
|
Atomics = 1 << 8,
|
||||||
|
FpHp = 1 << 9,
|
||||||
|
AsimdHp = 1 << 10,
|
||||||
|
CpuId = 1 << 11,
|
||||||
|
AsimdRdm = 1 << 12,
|
||||||
|
Jscvt = 1 << 13,
|
||||||
|
Fcma = 1 << 14,
|
||||||
|
Lrcpc = 1 << 15,
|
||||||
|
DcpOp = 1 << 16,
|
||||||
|
Sha3 = 1 << 17,
|
||||||
|
Sm3 = 1 << 18,
|
||||||
|
Sm4 = 1 << 19,
|
||||||
|
AsimdDp = 1 << 20,
|
||||||
|
Sha512 = 1 << 21,
|
||||||
|
Sve = 1 << 22,
|
||||||
|
AsimdFhm = 1 << 23,
|
||||||
|
Dit = 1 << 24,
|
||||||
|
Uscat = 1 << 25,
|
||||||
|
Ilrcpc = 1 << 26,
|
||||||
|
FlagM = 1 << 27,
|
||||||
|
Ssbs = 1 << 28,
|
||||||
|
Sb = 1 << 29,
|
||||||
|
Paca = 1 << 30,
|
||||||
|
Pacg = 1UL << 31
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum LinuxFeatureFlagsHwCap2 : ulong
|
||||||
|
{
|
||||||
|
Dcpodp = 1 << 0,
|
||||||
|
Sve2 = 1 << 1,
|
||||||
|
SveAes = 1 << 2,
|
||||||
|
SvePmull = 1 << 3,
|
||||||
|
SveBitperm = 1 << 4,
|
||||||
|
SveSha3 = 1 << 5,
|
||||||
|
SveSm4 = 1 << 6,
|
||||||
|
FlagM2 = 1 << 7,
|
||||||
|
Frint = 1 << 8,
|
||||||
|
SveI8mm = 1 << 9,
|
||||||
|
SveF32mm = 1 << 10,
|
||||||
|
SveF64mm = 1 << 11,
|
||||||
|
SveBf16 = 1 << 12,
|
||||||
|
I8mm = 1 << 13,
|
||||||
|
Bf16 = 1 << 14,
|
||||||
|
Dgh = 1 << 15,
|
||||||
|
Rng = 1 << 16,
|
||||||
|
Bti = 1 << 17,
|
||||||
|
Mte = 1 << 18,
|
||||||
|
Ecv = 1 << 19,
|
||||||
|
Afp = 1 << 20,
|
||||||
|
Rpres = 1 << 21,
|
||||||
|
Mte3 = 1 << 22,
|
||||||
|
Sme = 1 << 23,
|
||||||
|
Sme_i16i64 = 1 << 24,
|
||||||
|
Sme_f64f64 = 1 << 25,
|
||||||
|
Sme_i8i32 = 1 << 26,
|
||||||
|
Sme_f16f32 = 1 << 27,
|
||||||
|
Sme_b16f32 = 1 << 28,
|
||||||
|
Sme_f32f32 = 1 << 29,
|
||||||
|
Sme_fa64 = 1 << 30,
|
||||||
|
Wfxt = 1UL << 31,
|
||||||
|
Ebf16 = 1UL << 32,
|
||||||
|
Sve_Ebf16 = 1UL << 33,
|
||||||
|
Cssc = 1UL << 34,
|
||||||
|
Rprfm = 1UL << 35,
|
||||||
|
Sve2p1 = 1UL << 36
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinuxFeatureFlagsHwCap LinuxFeatureInfoHwCap { get; } = 0;
|
||||||
|
public static LinuxFeatureFlagsHwCap2 LinuxFeatureInfoHwCap2 { get; } = 0;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region macOS
|
||||||
|
|
||||||
|
[LibraryImport("libSystem.dylib", SetLastError = true)]
|
||||||
|
private static unsafe partial int sysctlbyname([MarshalAs(UnmanagedType.LPStr)] string name, out int oldValue, ref ulong oldSize, IntPtr newValue, ulong newValueSize);
|
||||||
|
|
||||||
|
[SupportedOSPlatform("macos")]
|
||||||
|
private static bool CheckSysctlName(string name)
|
||||||
|
{
|
||||||
|
ulong size = sizeof(int);
|
||||||
|
if (sysctlbyname(name, out int val, ref size, IntPtr.Zero, 0) == 0 && size == sizeof(int))
|
||||||
|
{
|
||||||
|
return val != 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string[] _sysctlNames = new string[]
|
||||||
|
{
|
||||||
|
"hw.optional.floatingpoint",
|
||||||
|
"hw.optional.AdvSIMD",
|
||||||
|
"hw.optional.arm.FEAT_FP16",
|
||||||
|
"hw.optional.arm.FEAT_AES",
|
||||||
|
"hw.optional.arm.FEAT_PMULL",
|
||||||
|
"hw.optional.arm.FEAT_LSE",
|
||||||
|
"hw.optional.armv8_crc32",
|
||||||
|
"hw.optional.arm.FEAT_SHA1",
|
||||||
|
"hw.optional.arm.FEAT_SHA256"
|
||||||
|
};
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum MacOsFeatureFlags
|
||||||
|
{
|
||||||
|
Fp = 1 << 0,
|
||||||
|
AdvSimd = 1 << 1,
|
||||||
|
Fp16 = 1 << 2,
|
||||||
|
Aes = 1 << 3,
|
||||||
|
Pmull = 1 << 4,
|
||||||
|
Lse = 1 << 5,
|
||||||
|
Crc32 = 1 << 6,
|
||||||
|
Sha1 = 1 << 7,
|
||||||
|
Sha256 = 1 << 8
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MacOsFeatureFlags MacOsFeatureInfo { get; } = 0;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public static bool SupportsAdvSimd => LinuxFeatureInfoHwCap.HasFlag(LinuxFeatureFlagsHwCap.Asimd) || MacOsFeatureInfo.HasFlag(MacOsFeatureFlags.AdvSimd);
|
||||||
|
public static bool SupportsAes => LinuxFeatureInfoHwCap.HasFlag(LinuxFeatureFlagsHwCap.Aes) || MacOsFeatureInfo.HasFlag(MacOsFeatureFlags.Aes);
|
||||||
|
public static bool SupportsPmull => LinuxFeatureInfoHwCap.HasFlag(LinuxFeatureFlagsHwCap.Pmull) || MacOsFeatureInfo.HasFlag(MacOsFeatureFlags.Pmull);
|
||||||
|
public static bool SupportsLse => LinuxFeatureInfoHwCap.HasFlag(LinuxFeatureFlagsHwCap.Atomics) || MacOsFeatureInfo.HasFlag(MacOsFeatureFlags.Lse);
|
||||||
|
public static bool SupportsCrc32 => LinuxFeatureInfoHwCap.HasFlag(LinuxFeatureFlagsHwCap.Crc32) || MacOsFeatureInfo.HasFlag(MacOsFeatureFlags.Crc32);
|
||||||
|
public static bool SupportsSha1 => LinuxFeatureInfoHwCap.HasFlag(LinuxFeatureFlagsHwCap.Sha1) || MacOsFeatureInfo.HasFlag(MacOsFeatureFlags.Sha1);
|
||||||
|
public static bool SupportsSha256 => LinuxFeatureInfoHwCap.HasFlag(LinuxFeatureFlagsHwCap.Sha2) || MacOsFeatureInfo.HasFlag(MacOsFeatureFlags.Sha256);
|
||||||
|
}
|
||||||
|
}
|
@@ -2556,7 +2556,7 @@ namespace ARMeilleure.Instructions
|
|||||||
{
|
{
|
||||||
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
|
||||||
|
|
||||||
if (Optimizations.UseAdvSimd && false) // Not supported by all Arm CPUs.
|
if (Optimizations.UseArm64Pmull)
|
||||||
{
|
{
|
||||||
InstEmitSimdHelperArm64.EmitVectorBinaryOp(context, Intrinsic.Arm64PmullV);
|
InstEmitSimdHelperArm64.EmitVectorBinaryOp(context, Intrinsic.Arm64PmullV);
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
using ARMeilleure.CodeGen.X86;
|
|
||||||
using System.Runtime.Intrinsics.Arm;
|
using System.Runtime.Intrinsics.Arm;
|
||||||
|
|
||||||
namespace ARMeilleure
|
namespace ARMeilleure
|
||||||
{
|
{
|
||||||
|
using Arm64HardwareCapabilities = ARMeilleure.CodeGen.Arm64.HardwareCapabilities;
|
||||||
|
using X86HardwareCapabilities = ARMeilleure.CodeGen.X86.HardwareCapabilities;
|
||||||
|
|
||||||
public static class Optimizations
|
public static class Optimizations
|
||||||
{
|
{
|
||||||
public static bool FastFP { get; set; } = true;
|
public static bool FastFP { get; set; } = true;
|
||||||
@@ -11,6 +13,7 @@ namespace ARMeilleure
|
|||||||
public static bool UseUnmanagedDispatchLoop { get; set; } = true;
|
public static bool UseUnmanagedDispatchLoop { get; set; } = true;
|
||||||
|
|
||||||
public static bool UseAdvSimdIfAvailable { get; set; } = true;
|
public static bool UseAdvSimdIfAvailable { get; set; } = true;
|
||||||
|
public static bool UseArm64PmullIfAvailable { get; set; } = true;
|
||||||
|
|
||||||
public static bool UseSseIfAvailable { get; set; } = true;
|
public static bool UseSseIfAvailable { get; set; } = true;
|
||||||
public static bool UseSse2IfAvailable { get; set; } = true;
|
public static bool UseSse2IfAvailable { get; set; } = true;
|
||||||
@@ -29,25 +32,26 @@ namespace ARMeilleure
|
|||||||
|
|
||||||
public static bool ForceLegacySse
|
public static bool ForceLegacySse
|
||||||
{
|
{
|
||||||
get => HardwareCapabilities.ForceLegacySse;
|
get => X86HardwareCapabilities.ForceLegacySse;
|
||||||
set => HardwareCapabilities.ForceLegacySse = value;
|
set => X86HardwareCapabilities.ForceLegacySse = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool UseAdvSimd => UseAdvSimdIfAvailable && AdvSimd.IsSupported;
|
internal static bool UseAdvSimd => UseAdvSimdIfAvailable && Arm64HardwareCapabilities.SupportsAdvSimd;
|
||||||
|
internal static bool UseArm64Pmull => UseArm64PmullIfAvailable && Arm64HardwareCapabilities.SupportsPmull;
|
||||||
|
|
||||||
internal static bool UseSse => UseSseIfAvailable && HardwareCapabilities.SupportsSse;
|
internal static bool UseSse => UseSseIfAvailable && X86HardwareCapabilities.SupportsSse;
|
||||||
internal static bool UseSse2 => UseSse2IfAvailable && HardwareCapabilities.SupportsSse2;
|
internal static bool UseSse2 => UseSse2IfAvailable && X86HardwareCapabilities.SupportsSse2;
|
||||||
internal static bool UseSse3 => UseSse3IfAvailable && HardwareCapabilities.SupportsSse3;
|
internal static bool UseSse3 => UseSse3IfAvailable && X86HardwareCapabilities.SupportsSse3;
|
||||||
internal static bool UseSsse3 => UseSsse3IfAvailable && HardwareCapabilities.SupportsSsse3;
|
internal static bool UseSsse3 => UseSsse3IfAvailable && X86HardwareCapabilities.SupportsSsse3;
|
||||||
internal static bool UseSse41 => UseSse41IfAvailable && HardwareCapabilities.SupportsSse41;
|
internal static bool UseSse41 => UseSse41IfAvailable && X86HardwareCapabilities.SupportsSse41;
|
||||||
internal static bool UseSse42 => UseSse42IfAvailable && HardwareCapabilities.SupportsSse42;
|
internal static bool UseSse42 => UseSse42IfAvailable && X86HardwareCapabilities.SupportsSse42;
|
||||||
internal static bool UsePopCnt => UsePopCntIfAvailable && HardwareCapabilities.SupportsPopcnt;
|
internal static bool UsePopCnt => UsePopCntIfAvailable && X86HardwareCapabilities.SupportsPopcnt;
|
||||||
internal static bool UseAvx => UseAvxIfAvailable && HardwareCapabilities.SupportsAvx && !ForceLegacySse;
|
internal static bool UseAvx => UseAvxIfAvailable && X86HardwareCapabilities.SupportsAvx && !ForceLegacySse;
|
||||||
internal static bool UseF16c => UseF16cIfAvailable && HardwareCapabilities.SupportsF16c;
|
internal static bool UseF16c => UseF16cIfAvailable && X86HardwareCapabilities.SupportsF16c;
|
||||||
internal static bool UseFma => UseFmaIfAvailable && HardwareCapabilities.SupportsFma;
|
internal static bool UseFma => UseFmaIfAvailable && X86HardwareCapabilities.SupportsFma;
|
||||||
internal static bool UseAesni => UseAesniIfAvailable && HardwareCapabilities.SupportsAesni;
|
internal static bool UseAesni => UseAesniIfAvailable && X86HardwareCapabilities.SupportsAesni;
|
||||||
internal static bool UsePclmulqdq => UsePclmulqdqIfAvailable && HardwareCapabilities.SupportsPclmulqdq;
|
internal static bool UsePclmulqdq => UsePclmulqdqIfAvailable && X86HardwareCapabilities.SupportsPclmulqdq;
|
||||||
internal static bool UseSha => UseShaIfAvailable && HardwareCapabilities.SupportsSha;
|
internal static bool UseSha => UseShaIfAvailable && X86HardwareCapabilities.SupportsSha;
|
||||||
internal static bool UseGfni => UseGfniIfAvailable && HardwareCapabilities.SupportsGfni;
|
internal static bool UseGfni => UseGfniIfAvailable && X86HardwareCapabilities.SupportsGfni;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,7 +1,6 @@
|
|||||||
using ARMeilleure.CodeGen;
|
using ARMeilleure.CodeGen;
|
||||||
using ARMeilleure.CodeGen.Linking;
|
using ARMeilleure.CodeGen.Linking;
|
||||||
using ARMeilleure.CodeGen.Unwinding;
|
using ARMeilleure.CodeGen.Unwinding;
|
||||||
using ARMeilleure.CodeGen.X86;
|
|
||||||
using ARMeilleure.Common;
|
using ARMeilleure.Common;
|
||||||
using ARMeilleure.Memory;
|
using ARMeilleure.Memory;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
@@ -22,12 +21,15 @@ using static ARMeilleure.Translation.PTC.PtcFormatter;
|
|||||||
|
|
||||||
namespace ARMeilleure.Translation.PTC
|
namespace ARMeilleure.Translation.PTC
|
||||||
{
|
{
|
||||||
|
using Arm64HardwareCapabilities = ARMeilleure.CodeGen.Arm64.HardwareCapabilities;
|
||||||
|
using X86HardwareCapabilities = ARMeilleure.CodeGen.X86.HardwareCapabilities;
|
||||||
|
|
||||||
class Ptc : IPtcLoadState
|
class Ptc : IPtcLoadState
|
||||||
{
|
{
|
||||||
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
||||||
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
||||||
|
|
||||||
private const uint InternalVersion = 4114; //! To be incremented manually for each change to the ARMeilleure project.
|
private const uint InternalVersion = 4272; //! To be incremented manually for each change to the ARMeilleure project.
|
||||||
|
|
||||||
private const string ActualDir = "0";
|
private const string ActualDir = "0";
|
||||||
private const string BackupDir = "1";
|
private const string BackupDir = "1";
|
||||||
@@ -259,6 +261,13 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outerHeader.Architecture != (uint)RuntimeInformation.ProcessArchitecture)
|
||||||
|
{
|
||||||
|
InvalidateCompressedStream(compressedStream);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
IntPtr intPtr = IntPtr.Zero;
|
IntPtr intPtr = IntPtr.Zero;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -435,6 +444,7 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
outerHeader.FeatureInfo = GetFeatureInfo();
|
outerHeader.FeatureInfo = GetFeatureInfo();
|
||||||
outerHeader.MemoryManagerMode = GetMemoryManagerMode();
|
outerHeader.MemoryManagerMode = GetMemoryManagerMode();
|
||||||
outerHeader.OSPlatform = GetOSPlatform();
|
outerHeader.OSPlatform = GetOSPlatform();
|
||||||
|
outerHeader.Architecture = (uint)RuntimeInformation.ProcessArchitecture;
|
||||||
|
|
||||||
outerHeader.UncompressedStreamSize =
|
outerHeader.UncompressedStreamSize =
|
||||||
(long)Unsafe.SizeOf<InnerHeader>() +
|
(long)Unsafe.SizeOf<InnerHeader>() +
|
||||||
@@ -951,12 +961,27 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static FeatureInfo GetFeatureInfo()
|
private static FeatureInfo GetFeatureInfo()
|
||||||
|
{
|
||||||
|
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||||
{
|
{
|
||||||
return new FeatureInfo(
|
return new FeatureInfo(
|
||||||
(uint)HardwareCapabilities.FeatureInfo1Ecx,
|
(ulong)Arm64HardwareCapabilities.LinuxFeatureInfoHwCap,
|
||||||
(uint)HardwareCapabilities.FeatureInfo1Edx,
|
(ulong)Arm64HardwareCapabilities.LinuxFeatureInfoHwCap2,
|
||||||
(uint)HardwareCapabilities.FeatureInfo7Ebx,
|
(ulong)Arm64HardwareCapabilities.MacOsFeatureInfo,
|
||||||
(uint)HardwareCapabilities.FeatureInfo7Ecx);
|
0);
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
|
||||||
|
{
|
||||||
|
return new FeatureInfo(
|
||||||
|
(ulong)X86HardwareCapabilities.FeatureInfo1Ecx,
|
||||||
|
(ulong)X86HardwareCapabilities.FeatureInfo1Edx,
|
||||||
|
(ulong)X86HardwareCapabilities.FeatureInfo7Ebx,
|
||||||
|
(ulong)X86HardwareCapabilities.FeatureInfo7Ecx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new FeatureInfo(0, 0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte GetMemoryManagerMode()
|
private byte GetMemoryManagerMode()
|
||||||
@@ -976,7 +1001,7 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
return osPlatform;
|
return osPlatform;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 58*/)]
|
[StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 78*/)]
|
||||||
private struct OuterHeader
|
private struct OuterHeader
|
||||||
{
|
{
|
||||||
public ulong Magic;
|
public ulong Magic;
|
||||||
@@ -987,6 +1012,7 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
public FeatureInfo FeatureInfo;
|
public FeatureInfo FeatureInfo;
|
||||||
public byte MemoryManagerMode;
|
public byte MemoryManagerMode;
|
||||||
public uint OSPlatform;
|
public uint OSPlatform;
|
||||||
|
public uint Architecture;
|
||||||
|
|
||||||
public long UncompressedStreamSize;
|
public long UncompressedStreamSize;
|
||||||
|
|
||||||
@@ -1007,8 +1033,8 @@ namespace ARMeilleure.Translation.PTC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 16*/)]
|
[StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 32*/)]
|
||||||
private record struct FeatureInfo(uint FeatureInfo0, uint FeatureInfo1, uint FeatureInfo2, uint FeatureInfo3);
|
private record struct FeatureInfo(ulong FeatureInfo0, ulong FeatureInfo1, ulong FeatureInfo2, ulong FeatureInfo3);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 128*/)]
|
[StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 128*/)]
|
||||||
private struct InnerHeader
|
private struct InnerHeader
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "Profilbild ändern",
|
"UserProfilesChangeProfileImage": "Profilbild ändern",
|
||||||
"UserProfilesAvailableUserProfiles": "Verfügbare Profile:",
|
"UserProfilesAvailableUserProfiles": "Verfügbare Profile:",
|
||||||
"UserProfilesAddNewProfile": "Neues Profil",
|
"UserProfilesAddNewProfile": "Neues Profil",
|
||||||
"UserProfilesDeleteSelectedProfile": "Profil löschen",
|
"UserProfilesDelete": "Löschen",
|
||||||
"UserProfilesClose": "Schließen",
|
"UserProfilesClose": "Schließen",
|
||||||
"ProfileImageSelectionTitle": "Auswahl des Profilbildes",
|
"ProfileImageSelectionTitle": "Auswahl des Profilbildes",
|
||||||
"ProfileImageSelectionHeader": "Wähle ein Profilbild aus",
|
"ProfileImageSelectionHeader": "Wähle ein Profilbild aus",
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "Αλλαγή Εικόνας Προφίλ",
|
"UserProfilesChangeProfileImage": "Αλλαγή Εικόνας Προφίλ",
|
||||||
"UserProfilesAvailableUserProfiles": "Διαθέσιμα Προφίλ Χρηστών:",
|
"UserProfilesAvailableUserProfiles": "Διαθέσιμα Προφίλ Χρηστών:",
|
||||||
"UserProfilesAddNewProfile": "Προσθήκη Νέου Προφίλ",
|
"UserProfilesAddNewProfile": "Προσθήκη Νέου Προφίλ",
|
||||||
"UserProfilesDeleteSelectedProfile": "Διαγραφή Επιλεγμένου Προφίλ",
|
"UserProfilesDelete": "Διαγράφω",
|
||||||
"UserProfilesClose": "Κλείσιμο",
|
"UserProfilesClose": "Κλείσιμο",
|
||||||
"ProfileImageSelectionTitle": "Επιλογή Εικόνας Προφίλ",
|
"ProfileImageSelectionTitle": "Επιλογή Εικόνας Προφίλ",
|
||||||
"ProfileImageSelectionHeader": "Επιλέξτε μία Εικόνα Προφίλ",
|
"ProfileImageSelectionHeader": "Επιλέξτε μία Εικόνα Προφίλ",
|
||||||
|
@@ -119,7 +119,7 @@
|
|||||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||||
"SettingsTabSystemHacks": "Hacks",
|
"SettingsTabSystemHacks": "Hacks",
|
||||||
"SettingsTabSystemHacksNote": " (may cause instability)",
|
"SettingsTabSystemHacksNote": "May cause instability",
|
||||||
"SettingsTabSystemExpandDramSize": "Use alternative memory layout (Developers)",
|
"SettingsTabSystemExpandDramSize": "Use alternative memory layout (Developers)",
|
||||||
"SettingsTabSystemIgnoreMissingServices": "Ignore Missing Services",
|
"SettingsTabSystemIgnoreMissingServices": "Ignore Missing Services",
|
||||||
"SettingsTabGraphics": "Graphics",
|
"SettingsTabGraphics": "Graphics",
|
||||||
@@ -157,7 +157,8 @@
|
|||||||
"SettingsTabLoggingEnableGuestLogs": "Enable Guest Logs",
|
"SettingsTabLoggingEnableGuestLogs": "Enable Guest Logs",
|
||||||
"SettingsTabLoggingEnableFsAccessLogs": "Enable Fs Access Logs",
|
"SettingsTabLoggingEnableFsAccessLogs": "Enable Fs Access Logs",
|
||||||
"SettingsTabLoggingFsGlobalAccessLogMode": "Fs Global Access Log Mode:",
|
"SettingsTabLoggingFsGlobalAccessLogMode": "Fs Global Access Log Mode:",
|
||||||
"SettingsTabLoggingDeveloperOptions": "Developer Options (WARNING: Will reduce performance)",
|
"SettingsTabLoggingDeveloperOptions": "Developer Options",
|
||||||
|
"SettingsTabLoggingDeveloperOptionsNote": "WARNING: Will reduce performance",
|
||||||
"SettingsTabLoggingGraphicsBackendLogLevel": "Graphics Backend Log Level:",
|
"SettingsTabLoggingGraphicsBackendLogLevel": "Graphics Backend Log Level:",
|
||||||
"SettingsTabLoggingGraphicsBackendLogLevelNone": "None",
|
"SettingsTabLoggingGraphicsBackendLogLevelNone": "None",
|
||||||
"SettingsTabLoggingGraphicsBackendLogLevelError": "Error",
|
"SettingsTabLoggingGraphicsBackendLogLevelError": "Error",
|
||||||
@@ -260,8 +261,9 @@
|
|||||||
"UserProfilesChangeProfileImage": "Change Profile Image",
|
"UserProfilesChangeProfileImage": "Change Profile Image",
|
||||||
"UserProfilesAvailableUserProfiles": "Available User Profiles:",
|
"UserProfilesAvailableUserProfiles": "Available User Profiles:",
|
||||||
"UserProfilesAddNewProfile": "Create Profile",
|
"UserProfilesAddNewProfile": "Create Profile",
|
||||||
"UserProfilesDeleteSelectedProfile": "Delete Selected",
|
"UserProfilesDelete": "Delete",
|
||||||
"UserProfilesClose": "Close",
|
"UserProfilesClose": "Close",
|
||||||
|
"ProfileNameSelectionWatermark": "Choose a nickname",
|
||||||
"ProfileImageSelectionTitle": "Profile Image Selection",
|
"ProfileImageSelectionTitle": "Profile Image Selection",
|
||||||
"ProfileImageSelectionHeader": "Choose a profile Image",
|
"ProfileImageSelectionHeader": "Choose a profile Image",
|
||||||
"ProfileImageSelectionNote": "You may import a custom profile image, or select an avatar from system firmware",
|
"ProfileImageSelectionNote": "You may import a custom profile image, or select an avatar from system firmware",
|
||||||
@@ -273,7 +275,7 @@
|
|||||||
"InputDialogAddNewProfileTitle": "Choose the Profile Name",
|
"InputDialogAddNewProfileTitle": "Choose the Profile Name",
|
||||||
"InputDialogAddNewProfileHeader": "Please Enter a Profile Name",
|
"InputDialogAddNewProfileHeader": "Please Enter a Profile Name",
|
||||||
"InputDialogAddNewProfileSubtext": "(Max Length: {0})",
|
"InputDialogAddNewProfileSubtext": "(Max Length: {0})",
|
||||||
"AvatarChoose": "Choose",
|
"AvatarChoose": "Choose Avatar",
|
||||||
"AvatarSetBackgroundColor": "Set Background Color",
|
"AvatarSetBackgroundColor": "Set Background Color",
|
||||||
"AvatarClose": "Close",
|
"AvatarClose": "Close",
|
||||||
"ControllerSettingsLoadProfileToolTip": "Load Profile",
|
"ControllerSettingsLoadProfileToolTip": "Load Profile",
|
||||||
@@ -368,6 +370,9 @@
|
|||||||
"DialogFirmwareInstallerFirmwareInstallSuccessMessage": "System version {0} successfully installed.",
|
"DialogFirmwareInstallerFirmwareInstallSuccessMessage": "System version {0} successfully installed.",
|
||||||
"DialogUserProfileDeletionWarningMessage": "There would be no other profiles to be opened if selected profile is deleted",
|
"DialogUserProfileDeletionWarningMessage": "There would be no other profiles to be opened if selected profile is deleted",
|
||||||
"DialogUserProfileDeletionConfirmMessage": "Do you want to delete the selected profile",
|
"DialogUserProfileDeletionConfirmMessage": "Do you want to delete the selected profile",
|
||||||
|
"DialogUserProfileUnsavedChangesTitle": "Warning - Unsaved Changes",
|
||||||
|
"DialogUserProfileUnsavedChangesMessage": "You have made changes to this user profile that have not been saved.",
|
||||||
|
"DialogUserProfileUnsavedChangesSubMessage": "Do you want to discard your changes?",
|
||||||
"DialogControllerSettingsModifiedConfirmMessage": "The current controller settings has been updated.",
|
"DialogControllerSettingsModifiedConfirmMessage": "The current controller settings has been updated.",
|
||||||
"DialogControllerSettingsModifiedConfirmSubMessage": "Do you want to save?",
|
"DialogControllerSettingsModifiedConfirmSubMessage": "Do you want to save?",
|
||||||
"DialogDlcLoadNcaErrorMessage": "{0}. Errored File: {1}",
|
"DialogDlcLoadNcaErrorMessage": "{0}. Errored File: {1}",
|
||||||
@@ -584,7 +589,7 @@
|
|||||||
"SettingsTabHotkeysResScaleUpHotkey": "Increase resolution:",
|
"SettingsTabHotkeysResScaleUpHotkey": "Increase resolution:",
|
||||||
"SettingsTabHotkeysResScaleDownHotkey": "Decrease resolution:",
|
"SettingsTabHotkeysResScaleDownHotkey": "Decrease resolution:",
|
||||||
"UserProfilesName": "Name:",
|
"UserProfilesName": "Name:",
|
||||||
"UserProfilesUserId": "User Id:",
|
"UserProfilesUserId": "User ID:",
|
||||||
"SettingsTabGraphicsBackend": "Graphics Backend",
|
"SettingsTabGraphicsBackend": "Graphics Backend",
|
||||||
"SettingsTabGraphicsBackendTooltip": "Graphics Backend to use",
|
"SettingsTabGraphicsBackendTooltip": "Graphics Backend to use",
|
||||||
"SettingsEnableTextureRecompression": "Enable Texture Recompression",
|
"SettingsEnableTextureRecompression": "Enable Texture Recompression",
|
||||||
@@ -603,13 +608,15 @@
|
|||||||
"UserProfilesManageSaves": "Manage Saves",
|
"UserProfilesManageSaves": "Manage Saves",
|
||||||
"DeleteUserSave": "Do you want to delete user save for this game?",
|
"DeleteUserSave": "Do you want to delete user save for this game?",
|
||||||
"IrreversibleActionNote": "This action is not reversible.",
|
"IrreversibleActionNote": "This action is not reversible.",
|
||||||
"SaveManagerHeading": "Manage Saves for {0}",
|
"SaveManagerHeading": "Manage Saves for {0} ({1})",
|
||||||
"SaveManagerTitle": "Save Manager",
|
"SaveManagerTitle": "Save Manager",
|
||||||
"Name": "Name",
|
"Name": "Name",
|
||||||
"Size": "Size",
|
"Size": "Size",
|
||||||
"Search": "Search",
|
"Search": "Search",
|
||||||
"UserProfilesRecoverLostAccounts": "Recover Lost Accounts",
|
"UserProfilesRecoverLostAccounts": "Recover Lost Accounts",
|
||||||
"Recover": "Recover",
|
"Recover": "Recover",
|
||||||
"UserProfilesRecoverHeading" : "Saves were found for the following accounts"
|
"UserProfilesRecoverHeading" : "Saves were found for the following accounts",
|
||||||
|
"UserProfilesRecoverEmptyList": "No profiles to recover",
|
||||||
|
"UserEditorTitle" : "Edit User",
|
||||||
|
"UserEditorTitleCreate" : "Create User"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "Cambiar imagen de perfil",
|
"UserProfilesChangeProfileImage": "Cambiar imagen de perfil",
|
||||||
"UserProfilesAvailableUserProfiles": "Perfiles de usuario disponibles:",
|
"UserProfilesAvailableUserProfiles": "Perfiles de usuario disponibles:",
|
||||||
"UserProfilesAddNewProfile": "Añadir nuevo perfil",
|
"UserProfilesAddNewProfile": "Añadir nuevo perfil",
|
||||||
"UserProfilesDeleteSelectedProfile": "Eliminar perfil seleccionado",
|
"UserProfilesDelete": "Eliminar",
|
||||||
"UserProfilesClose": "Cerrar",
|
"UserProfilesClose": "Cerrar",
|
||||||
"ProfileImageSelectionTitle": "Selección de imagen de perfil",
|
"ProfileImageSelectionTitle": "Selección de imagen de perfil",
|
||||||
"ProfileImageSelectionHeader": "Elige una imagen de perfil",
|
"ProfileImageSelectionHeader": "Elige una imagen de perfil",
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "Changer l'image du profil",
|
"UserProfilesChangeProfileImage": "Changer l'image du profil",
|
||||||
"UserProfilesAvailableUserProfiles": "Profils utilisateurs disponible:",
|
"UserProfilesAvailableUserProfiles": "Profils utilisateurs disponible:",
|
||||||
"UserProfilesAddNewProfile": "Ajouter un nouveau profil",
|
"UserProfilesAddNewProfile": "Ajouter un nouveau profil",
|
||||||
"UserProfilesDeleteSelectedProfile": "Supprimer le profil sélectionné",
|
"UserProfilesDelete": "Supprimer",
|
||||||
"UserProfilesClose": "Fermer",
|
"UserProfilesClose": "Fermer",
|
||||||
"ProfileImageSelectionTitle": "Sélection de l'image du profil",
|
"ProfileImageSelectionTitle": "Sélection de l'image du profil",
|
||||||
"ProfileImageSelectionHeader": "Choisir l'image du profil",
|
"ProfileImageSelectionHeader": "Choisir l'image du profil",
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "プロファイル画像を変更",
|
"UserProfilesChangeProfileImage": "プロファイル画像を変更",
|
||||||
"UserProfilesAvailableUserProfiles": "利用可能なユーザプロファイル:",
|
"UserProfilesAvailableUserProfiles": "利用可能なユーザプロファイル:",
|
||||||
"UserProfilesAddNewProfile": "プロファイルを作成",
|
"UserProfilesAddNewProfile": "プロファイルを作成",
|
||||||
"UserProfilesDeleteSelectedProfile": "削除",
|
"UserProfilesDelete": "削除",
|
||||||
"UserProfilesClose": "閉じる",
|
"UserProfilesClose": "閉じる",
|
||||||
"ProfileImageSelectionTitle": "プロファイル画像選択",
|
"ProfileImageSelectionTitle": "プロファイル画像選択",
|
||||||
"ProfileImageSelectionHeader": "プロファイル画像を選択",
|
"ProfileImageSelectionHeader": "プロファイル画像を選択",
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "Zmień Obraz Profilu",
|
"UserProfilesChangeProfileImage": "Zmień Obraz Profilu",
|
||||||
"UserProfilesAvailableUserProfiles": "Dostępne Profile Użytkowników:",
|
"UserProfilesAvailableUserProfiles": "Dostępne Profile Użytkowników:",
|
||||||
"UserProfilesAddNewProfile": "Utwórz Profil",
|
"UserProfilesAddNewProfile": "Utwórz Profil",
|
||||||
"UserProfilesDeleteSelectedProfile": "Usuń Zaznaczone",
|
"UserProfilesDelete": "Usuwać",
|
||||||
"UserProfilesClose": "Zamknij",
|
"UserProfilesClose": "Zamknij",
|
||||||
"ProfileImageSelectionTitle": "Wybór Obrazu Profilu",
|
"ProfileImageSelectionTitle": "Wybór Obrazu Profilu",
|
||||||
"ProfileImageSelectionHeader": "Wybierz zdjęcie profilowe",
|
"ProfileImageSelectionHeader": "Wybierz zdjęcie profilowe",
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "Mudar imagem de perfil",
|
"UserProfilesChangeProfileImage": "Mudar imagem de perfil",
|
||||||
"UserProfilesAvailableUserProfiles": "Perfis de usuário disponíveis:",
|
"UserProfilesAvailableUserProfiles": "Perfis de usuário disponíveis:",
|
||||||
"UserProfilesAddNewProfile": "Adicionar novo perfil",
|
"UserProfilesAddNewProfile": "Adicionar novo perfil",
|
||||||
"UserProfilesDeleteSelectedProfile": "Apagar perfil selecionado",
|
"UserProfilesDelete": "Apagar",
|
||||||
"UserProfilesClose": "Fechar",
|
"UserProfilesClose": "Fechar",
|
||||||
"ProfileImageSelectionTitle": "Seleção da imagem de perfil",
|
"ProfileImageSelectionTitle": "Seleção da imagem de perfil",
|
||||||
"ProfileImageSelectionHeader": "Escolha uma imagem de perfil",
|
"ProfileImageSelectionHeader": "Escolha uma imagem de perfil",
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "Изменить изображение профиля",
|
"UserProfilesChangeProfileImage": "Изменить изображение профиля",
|
||||||
"UserProfilesAvailableUserProfiles": "Доступные профили пользователей:",
|
"UserProfilesAvailableUserProfiles": "Доступные профили пользователей:",
|
||||||
"UserProfilesAddNewProfile": "Добавить новый профиль",
|
"UserProfilesAddNewProfile": "Добавить новый профиль",
|
||||||
"UserProfilesDeleteSelectedProfile": "Удалить выбранный профиль",
|
"UserProfilesDelete": "Удалить",
|
||||||
"UserProfilesClose": "Закрыть",
|
"UserProfilesClose": "Закрыть",
|
||||||
"ProfileImageSelectionTitle": "Выбор изображения профиля",
|
"ProfileImageSelectionTitle": "Выбор изображения профиля",
|
||||||
"ProfileImageSelectionHeader": "Выберите изображение профиля",
|
"ProfileImageSelectionHeader": "Выберите изображение профиля",
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "Profil Resmini Değiştir",
|
"UserProfilesChangeProfileImage": "Profil Resmini Değiştir",
|
||||||
"UserProfilesAvailableUserProfiles": "Mevcut Kullanıcı Profilleri:",
|
"UserProfilesAvailableUserProfiles": "Mevcut Kullanıcı Profilleri:",
|
||||||
"UserProfilesAddNewProfile": "Yeni Profil Ekle",
|
"UserProfilesAddNewProfile": "Yeni Profil Ekle",
|
||||||
"UserProfilesDeleteSelectedProfile": "Seçili Profili Sil",
|
"UserProfilesDelete": "Sil",
|
||||||
"UserProfilesClose": "Kapat",
|
"UserProfilesClose": "Kapat",
|
||||||
"ProfileImageSelectionTitle": "Profil Resmi Seçimi",
|
"ProfileImageSelectionTitle": "Profil Resmi Seçimi",
|
||||||
"ProfileImageSelectionHeader": "Profil Resmi Seç",
|
"ProfileImageSelectionHeader": "Profil Resmi Seç",
|
||||||
|
@@ -260,7 +260,7 @@
|
|||||||
"UserProfilesChangeProfileImage": "更換頭貼",
|
"UserProfilesChangeProfileImage": "更換頭貼",
|
||||||
"UserProfilesAvailableUserProfiles": "現有的帳號:",
|
"UserProfilesAvailableUserProfiles": "現有的帳號:",
|
||||||
"UserProfilesAddNewProfile": "建立帳號",
|
"UserProfilesAddNewProfile": "建立帳號",
|
||||||
"UserProfilesDeleteSelectedProfile": "刪除選擇的帳號",
|
"UserProfilesDelete": "刪除",
|
||||||
"UserProfilesClose": "關閉",
|
"UserProfilesClose": "關閉",
|
||||||
"ProfileImageSelectionTitle": "頭貼選擇",
|
"ProfileImageSelectionTitle": "頭貼選擇",
|
||||||
"ProfileImageSelectionHeader": "選擇合適的頭貼圖片",
|
"ProfileImageSelectionHeader": "選擇合適的頭貼圖片",
|
||||||
|
@@ -60,5 +60,6 @@
|
|||||||
<Color x:Key="MenuFlyoutPresenterBorderColor">#3D3D3D</Color>
|
<Color x:Key="MenuFlyoutPresenterBorderColor">#3D3D3D</Color>
|
||||||
<Color x:Key="AppListBackgroundColor">#0FFFFFFF</Color>
|
<Color x:Key="AppListBackgroundColor">#0FFFFFFF</Color>
|
||||||
<Color x:Key="AppListHoverBackgroundColor">#1EFFFFFF</Color>
|
<Color x:Key="AppListHoverBackgroundColor">#1EFFFFFF</Color>
|
||||||
|
<Color x:Key="SecondaryTextColor">#A0FFFFFF</Color>
|
||||||
</Styles.Resources>
|
</Styles.Resources>
|
||||||
</Styles>
|
</Styles>
|
@@ -52,5 +52,6 @@
|
|||||||
<Color x:Key="MenuFlyoutPresenterBorderColor">#C1C1C1</Color>
|
<Color x:Key="MenuFlyoutPresenterBorderColor">#C1C1C1</Color>
|
||||||
<Color x:Key="AppListBackgroundColor">#b3ffffff</Color>
|
<Color x:Key="AppListBackgroundColor">#b3ffffff</Color>
|
||||||
<Color x:Key="AppListHoverBackgroundColor">#80cccccc</Color>
|
<Color x:Key="AppListHoverBackgroundColor">#80cccccc</Color>
|
||||||
|
<Color x:Key="SecondaryTextColor">#A0000000</Color>
|
||||||
</Styles.Resources>
|
</Styles.Resources>
|
||||||
</Styles>
|
</Styles>
|
@@ -56,8 +56,8 @@
|
|||||||
<Style Selector="Border.settings">
|
<Style Selector="Border.settings">
|
||||||
<Setter Property="Background" Value="{DynamicResource ThemeDarkColor}" />
|
<Setter Property="Background" Value="{DynamicResource ThemeDarkColor}" />
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderColor}" />
|
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderColor}" />
|
||||||
<Setter Property="BorderThickness" Value="2" />
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
<Setter Property="CornerRadius" Value="3" />
|
<Setter Property="CornerRadius" Value="5" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="Image.small">
|
<Style Selector="Image.small">
|
||||||
<Setter Property="Width" Value="50" />
|
<Setter Property="Width" Value="50" />
|
||||||
@@ -179,6 +179,9 @@
|
|||||||
<Style Selector="Button">
|
<Style Selector="Button">
|
||||||
<Setter Property="MinWidth" Value="80" />
|
<Setter Property="MinWidth" Value="80" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style Selector="ProgressBar /template/ Border#ProgressBarTrack">
|
||||||
|
<Setter Property="IsVisible" Value="False" />
|
||||||
|
</Style>
|
||||||
<Style Selector="ToggleButton">
|
<Style Selector="ToggleButton">
|
||||||
<Setter Property="Padding" Value="0,-5,0,0" />
|
<Setter Property="Padding" Value="0,-5,0,0" />
|
||||||
</Style>
|
</Style>
|
||||||
@@ -231,9 +234,41 @@
|
|||||||
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" />
|
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" />
|
||||||
<Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" />
|
<Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style Selector="TextBox">
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
|
</Style>
|
||||||
<Style Selector="TextBox.NumberBoxTextBoxStyle">
|
<Style Selector="TextBox.NumberBoxTextBoxStyle">
|
||||||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundColor}" />
|
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style Selector="ListBox ListBoxItem">
|
||||||
|
<Setter Property="Padding" Value="0" />
|
||||||
|
<Setter Property="Margin" Value="0" />
|
||||||
|
<Setter Property="CornerRadius" Value="5" />
|
||||||
|
<Setter Property="Background" Value="{DynamicResource AppListBackgroundColor}" />
|
||||||
|
<Setter Property="BorderThickness" Value="2"/>
|
||||||
|
<Style.Animations>
|
||||||
|
<Animation Duration="0:0:0.7">
|
||||||
|
<KeyFrame Cue="0%">
|
||||||
|
<Setter Property="MaxHeight" Value="0" />
|
||||||
|
<Setter Property="Opacity" Value="0.0" />
|
||||||
|
</KeyFrame>
|
||||||
|
<KeyFrame Cue="50%">
|
||||||
|
<Setter Property="MaxHeight" Value="1000" />
|
||||||
|
<Setter Property="Opacity" Value="0.3" />
|
||||||
|
</KeyFrame>
|
||||||
|
<KeyFrame Cue="100%">
|
||||||
|
<Setter Property="MaxHeight" Value="1000" />
|
||||||
|
<Setter Property="Opacity" Value="1.0" />
|
||||||
|
</KeyFrame>
|
||||||
|
</Animation>
|
||||||
|
</Style.Animations>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBox ListBoxItem:selected /template/ ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource AppListBackgroundColor}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBox ListBoxItem:pointerover /template/ ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource AppListHoverBackgroundColor}" />
|
||||||
|
</Style>
|
||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<SolidColorBrush x:Key="ThemeAccentColorBrush" Color="{DynamicResource SystemAccentColor}" />
|
<SolidColorBrush x:Key="ThemeAccentColorBrush" Color="{DynamicResource SystemAccentColor}" />
|
||||||
<StaticResource x:Key="ListViewItemBackgroundSelected" ResourceKey="ThemeAccentColorBrush" />
|
<StaticResource x:Key="ListViewItemBackgroundSelected" ResourceKey="ThemeAccentColorBrush" />
|
||||||
@@ -271,6 +306,9 @@
|
|||||||
<Color x:Key="ThemeControlBorderColor">#FF505050</Color>
|
<Color x:Key="ThemeControlBorderColor">#FF505050</Color>
|
||||||
<Color x:Key="VsyncEnabled">#FF2EEAC9</Color>
|
<Color x:Key="VsyncEnabled">#FF2EEAC9</Color>
|
||||||
<Color x:Key="VsyncDisabled">#FFFF4554</Color>
|
<Color x:Key="VsyncDisabled">#FFFF4554</Color>
|
||||||
|
<Color x:Key="AppListBackgroundColor">#0FFFFFFF</Color>
|
||||||
|
<Color x:Key="AppListHoverBackgroundColor">#1EFFFFFF</Color>
|
||||||
|
<Color x:Key="SecondaryTextColor">#A0FFFFFF</Color>
|
||||||
<x:Double x:Key="ScrollBarThickness">15</x:Double>
|
<x:Double x:Key="ScrollBarThickness">15</x:Double>
|
||||||
<x:Double x:Key="FontSizeSmall">8</x:Double>
|
<x:Double x:Key="FontSizeSmall">8</x:Double>
|
||||||
<x:Double x:Key="FontSizeNormal">10</x:Double>
|
<x:Double x:Key="FontSizeNormal">10</x:Double>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Ryujinx.Ava.UI.Helper;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.Windows;
|
using Ryujinx.Ava.UI.Windows;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
|
@@ -130,6 +130,18 @@
|
|||||||
<DependentUpon>GameListView.axaml</DependentUpon>
|
<DependentUpon>GameListView.axaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="UI\Views\User\UserEditorView.axaml.cs">
|
||||||
|
<DependentUpon>UserEditor.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="UI\Views\User\UserRecovererView.axaml.cs">
|
||||||
|
<DependentUpon>UserRecoverer.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="UI\Views\User\UserSelectorView.axaml.cs">
|
||||||
|
<DependentUpon>UserSelector.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@@ -112,32 +112,8 @@
|
|||||||
</ListBox.ItemsPanel>
|
</ListBox.ItemsPanel>
|
||||||
<ListBox.Styles>
|
<ListBox.Styles>
|
||||||
<Style Selector="ListBoxItem">
|
<Style Selector="ListBoxItem">
|
||||||
<Setter Property="Padding" Value="0" />
|
|
||||||
<Setter Property="Margin" Value="5" />
|
<Setter Property="Margin" Value="5" />
|
||||||
<Setter Property="CornerRadius" Value="4" />
|
<Setter Property="CornerRadius" Value="4" />
|
||||||
<Setter Property="Background" Value="{DynamicResource AppListBackgroundColor}" />
|
|
||||||
<Style.Animations>
|
|
||||||
<Animation Duration="0:0:0.7">
|
|
||||||
<KeyFrame Cue="0%">
|
|
||||||
<Setter Property="MaxWidth" Value="0" />
|
|
||||||
<Setter Property="Opacity" Value="0.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="50%">
|
|
||||||
<Setter Property="MaxWidth" Value="1000" />
|
|
||||||
<Setter Property="Opacity" Value="0.3" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="100%">
|
|
||||||
<Setter Property="MaxWidth" Value="1000" />
|
|
||||||
<Setter Property="Opacity" Value="1.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
</Animation>
|
|
||||||
</Style.Animations>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource AppListBackgroundColor}" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource AppListHoverBackgroundColor}" />
|
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ListBoxItem:selected /template/ Border#SelectionIndicator">
|
<Style Selector="ListBoxItem:selected /template/ Border#SelectionIndicator">
|
||||||
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].DataContext.GridItemSelectorSize}" />
|
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].DataContext.GridItemSelectorSize}" />
|
||||||
|
@@ -111,35 +111,6 @@
|
|||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ListBox.ItemsPanel>
|
</ListBox.ItemsPanel>
|
||||||
<ListBox.Styles>
|
<ListBox.Styles>
|
||||||
<Style Selector="ListBoxItem">
|
|
||||||
<Setter Property="Padding" Value="0" />
|
|
||||||
<Setter Property="Margin" Value="0" />
|
|
||||||
<Setter Property="CornerRadius" Value="5" />
|
|
||||||
<Setter Property="Background" Value="{DynamicResource AppListBackgroundColor}" />
|
|
||||||
<Setter Property="BorderThickness" Value="2"/>
|
|
||||||
<Style.Animations>
|
|
||||||
<Animation Duration="0:0:0.7">
|
|
||||||
<KeyFrame Cue="0%">
|
|
||||||
<Setter Property="MaxHeight" Value="0" />
|
|
||||||
<Setter Property="Opacity" Value="0.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="50%">
|
|
||||||
<Setter Property="MaxHeight" Value="1000" />
|
|
||||||
<Setter Property="Opacity" Value="0.3" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="100%">
|
|
||||||
<Setter Property="MaxHeight" Value="1000" />
|
|
||||||
<Setter Property="Opacity" Value="1.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
</Animation>
|
|
||||||
</Style.Animations>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource AppListBackgroundColor}" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource AppListHoverBackgroundColor}" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBoxItem:selected /template/ Border#SelectionIndicator">
|
<Style Selector="ListBoxItem:selected /template/ Border#SelectionIndicator">
|
||||||
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].DataContext.ListItemSelectorSize}" />
|
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].DataContext.ListItemSelectorSize}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
<ui:Frame
|
<ui:Frame
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
x:Name="ContentFrame" />
|
x:Name="ContentFrame">
|
||||||
|
</ui:Frame>
|
||||||
</UserControl>
|
</UserControl>
|
@@ -1,13 +1,25 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Styling;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using FluentAvalonia.Core;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using LibHac;
|
using LibHac;
|
||||||
|
using LibHac.Common;
|
||||||
|
using LibHac.Fs;
|
||||||
|
using LibHac.Fs.Shim;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
|
using Ryujinx.Ava.UI.Models;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
using Ryujinx.Ava.UI.Views.User;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
namespace Ryujinx.Ava.UI.Controls
|
||||||
{
|
{
|
||||||
@@ -31,14 +43,14 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
ContentManager = contentManager;
|
ContentManager = contentManager;
|
||||||
VirtualFileSystem = virtualFileSystem;
|
VirtualFileSystem = virtualFileSystem;
|
||||||
HorizonClient = horizonClient;
|
HorizonClient = horizonClient;
|
||||||
ViewModel = new UserProfileViewModel(this);
|
ViewModel = new UserProfileViewModel();
|
||||||
|
LoadProfiles();
|
||||||
|
|
||||||
if (contentManager.GetCurrentFirmwareVersion() != null)
|
if (contentManager.GetCurrentFirmwareVersion() != null)
|
||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
AvatarProfileViewModel.PreloadAvatars(contentManager, virtualFileSystem);
|
UserFirmwareAvatarSelectorViewModel.PreloadAvatars(contentManager, virtualFileSystem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -51,7 +63,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
ContentFrame.GoBack();
|
ContentFrame.GoBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewModel.LoadProfiles();
|
LoadProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Navigate(Type sourcePageType, object parameter)
|
public void Navigate(Type sourcePageType, object parameter)
|
||||||
@@ -68,7 +80,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
Title = LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle],
|
Title = LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle],
|
||||||
PrimaryButtonText = "",
|
PrimaryButtonText = "",
|
||||||
SecondaryButtonText = "",
|
SecondaryButtonText = "",
|
||||||
CloseButtonText = LocaleManager.Instance[LocaleKeys.UserProfilesClose],
|
CloseButtonText = "",
|
||||||
Content = content,
|
Content = content,
|
||||||
Padding = new Thickness(0)
|
Padding = new Thickness(0)
|
||||||
};
|
};
|
||||||
@@ -78,6 +90,11 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
content.ViewModel.Dispose();
|
content.ViewModel.Dispose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Style footer = new(x => x.Name("DialogSpace").Child().OfType<Border>());
|
||||||
|
footer.Setters.Add(new Setter(IsVisibleProperty, false));
|
||||||
|
|
||||||
|
contentDialog.Styles.Add(footer);
|
||||||
|
|
||||||
await contentDialog.ShowAsync();
|
await contentDialog.ShowAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +102,117 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
{
|
{
|
||||||
base.OnAttachedToVisualTree(e);
|
base.OnAttachedToVisualTree(e);
|
||||||
|
|
||||||
Navigate(typeof(UserSelector), this);
|
Navigate(typeof(UserSelectorViews), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadProfiles()
|
||||||
|
{
|
||||||
|
ViewModel.Profiles.Clear();
|
||||||
|
ViewModel.LostProfiles.Clear();
|
||||||
|
|
||||||
|
var profiles = AccountManager.GetAllUsers().OrderBy(x => x.Name);
|
||||||
|
|
||||||
|
foreach (var profile in profiles)
|
||||||
|
{
|
||||||
|
ViewModel.Profiles.Add(new UserProfile(profile, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
var saveDataFilter = SaveDataFilter.Make(programId: default, saveType: SaveDataType.Account, default, saveDataId: default, index: default);
|
||||||
|
|
||||||
|
using var saveDataIterator = new UniqueRef<SaveDataIterator>();
|
||||||
|
|
||||||
|
HorizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref(), SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
|
||||||
|
|
||||||
|
Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
|
||||||
|
|
||||||
|
HashSet<HLE.HOS.Services.Account.Acc.UserId> lostAccounts = new();
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
saveDataIterator.Get.ReadSaveDataInfo(out long readCount, saveDataInfo).ThrowIfFailure();
|
||||||
|
|
||||||
|
if (readCount == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < readCount; i++)
|
||||||
|
{
|
||||||
|
var save = saveDataInfo[i];
|
||||||
|
var id = new HLE.HOS.Services.Account.Acc.UserId((long)save.UserId.Id.Low, (long)save.UserId.Id.High);
|
||||||
|
if (ViewModel.Profiles.Cast<UserProfile>().FirstOrDefault( x=> x.UserId == id) == null)
|
||||||
|
{
|
||||||
|
lostAccounts.Add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(var account in lostAccounts)
|
||||||
|
{
|
||||||
|
ViewModel.LostProfiles.Add(new UserProfile(new HLE.HOS.Services.Account.Acc.UserProfile(account, "", null), this));
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewModel.Profiles.Add(new BaseModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void DeleteUser(UserProfile userProfile)
|
||||||
|
{
|
||||||
|
var lastUserId = AccountManager.LastOpenedUser.UserId;
|
||||||
|
|
||||||
|
if (userProfile.UserId == lastUserId)
|
||||||
|
{
|
||||||
|
// If we are deleting the currently open profile, then we must open something else before deleting.
|
||||||
|
var profile = ViewModel.Profiles.Cast<UserProfile>().FirstOrDefault(x => x.UserId != lastUserId);
|
||||||
|
|
||||||
|
if (profile == null)
|
||||||
|
{
|
||||||
|
async void Action()
|
||||||
|
{
|
||||||
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUserProfileDeletionWarningMessage]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Post(Action);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountManager.OpenUser(profile.UserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||||
|
LocaleManager.Instance[LocaleKeys.DialogUserProfileDeletionConfirmMessage],
|
||||||
|
"",
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||||
|
"");
|
||||||
|
|
||||||
|
if (result == UserResult.Yes)
|
||||||
|
{
|
||||||
|
GoBack();
|
||||||
|
AccountManager.DeleteUser(userProfile.UserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadProfiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddUser()
|
||||||
|
{
|
||||||
|
Navigate(typeof(UserEditorView), (this, (UserProfile)null, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EditUser(UserProfile userProfile)
|
||||||
|
{
|
||||||
|
Navigate(typeof(UserEditorView), (this, userProfile, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RecoverLostAccounts()
|
||||||
|
{
|
||||||
|
Navigate(typeof(UserRecovererView), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ManageSaves()
|
||||||
|
{
|
||||||
|
Navigate(typeof(UserSaveManagerView), (this, AccountManager, HorizonClient, VirtualFileSystem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,57 +0,0 @@
|
|||||||
<UserControl
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.ProfileImageSelectionDialog"
|
|
||||||
Focusable="True">
|
|
||||||
<Grid
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Margin="5,10,5, 5">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="70" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock
|
|
||||||
FontWeight="Bold"
|
|
||||||
FontSize="18"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Grid.Row="1"
|
|
||||||
Text="{locale:Locale ProfileImageSelectionHeader}" />
|
|
||||||
<TextBlock
|
|
||||||
FontWeight="Bold"
|
|
||||||
Grid.Row="2"
|
|
||||||
Margin="10"
|
|
||||||
MaxWidth="400"
|
|
||||||
TextWrapping="Wrap"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
TextAlignment="Center"
|
|
||||||
Text="{locale:Locale ProfileImageSelectionNote}" />
|
|
||||||
<StackPanel
|
|
||||||
Margin="5,0"
|
|
||||||
Spacing="10"
|
|
||||||
Grid.Row="4"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
<Button
|
|
||||||
Name="Import"
|
|
||||||
Click="Import_OnClick"
|
|
||||||
Width="200">
|
|
||||||
<TextBlock Text="{locale:Locale ProfileImageSelectionImportImage}" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
Name="SelectFirmwareImage"
|
|
||||||
IsEnabled="{Binding FirmwareFound}"
|
|
||||||
Click="SelectFirmwareImage_OnClick"
|
|
||||||
Width="200">
|
|
||||||
<TextBlock Text="{locale:Locale ProfileImageSelectionSelectAvatar}" />
|
|
||||||
</Button>
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
@@ -1,175 +0,0 @@
|
|||||||
<UserControl
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
|
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
|
||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DesignWidth="800"
|
|
||||||
d:DesignHeight="450"
|
|
||||||
Height="400"
|
|
||||||
Width="550"
|
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.SaveManager"
|
|
||||||
Focusable="True">
|
|
||||||
<UserControl.Resources>
|
|
||||||
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
|
||||||
</UserControl.Resources>
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid
|
|
||||||
Grid.Row="0"
|
|
||||||
HorizontalAlignment="Stretch">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<StackPanel
|
|
||||||
Spacing="10"
|
|
||||||
Orientation="Horizontal"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
VerticalAlignment="Center">
|
|
||||||
<Label
|
|
||||||
Content="{locale:Locale CommonSort}"
|
|
||||||
VerticalAlignment="Center" />
|
|
||||||
<ComboBox SelectedIndex="{Binding SortIndex}" Width="100">
|
|
||||||
<ComboBoxItem>
|
|
||||||
<Label
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalContentAlignment="Left"
|
|
||||||
Content="{locale:Locale Name}" />
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem>
|
|
||||||
<Label
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalContentAlignment="Left"
|
|
||||||
Content="{locale:Locale Size}" />
|
|
||||||
</ComboBoxItem>
|
|
||||||
</ComboBox>
|
|
||||||
<ComboBox SelectedIndex="{Binding OrderIndex}" Width="150">
|
|
||||||
<ComboBoxItem>
|
|
||||||
<Label
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalContentAlignment="Left"
|
|
||||||
Content="{locale:Locale OrderAscending}" />
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem>
|
|
||||||
<Label
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalContentAlignment="Left"
|
|
||||||
Content="{locale:Locale OrderDescending}" />
|
|
||||||
</ComboBoxItem>
|
|
||||||
</ComboBox>
|
|
||||||
</StackPanel>
|
|
||||||
<Grid
|
|
||||||
Grid.Column="1"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Margin="10,0, 0, 0">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
<ColumnDefinition/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Label
|
|
||||||
Content="{locale:Locale Search}"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<TextBox
|
|
||||||
Margin="5,0,0,0"
|
|
||||||
Grid.Column="1"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Text="{Binding Search}"/>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
<Border
|
|
||||||
Grid.Row="1"
|
|
||||||
Margin="0,5"
|
|
||||||
BorderThickness="1"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch">
|
|
||||||
<ListBox
|
|
||||||
Name="SaveList"
|
|
||||||
Items="{Binding View}"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch">
|
|
||||||
<ListBox.ItemTemplate>
|
|
||||||
<DataTemplate x:DataType="models:SaveModel">
|
|
||||||
<Grid HorizontalAlignment="Stretch" Margin="0,5">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<StackPanel Grid.Column="0" Orientation="Horizontal">
|
|
||||||
<Border
|
|
||||||
Height="42"
|
|
||||||
Margin="2"
|
|
||||||
Width="42"
|
|
||||||
Padding="10"
|
|
||||||
IsVisible="{Binding !InGameList}">
|
|
||||||
<ui:SymbolIcon
|
|
||||||
Symbol="Help"
|
|
||||||
FontSize="30"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center" />
|
|
||||||
</Border>
|
|
||||||
<Image
|
|
||||||
IsVisible="{Binding InGameList}"
|
|
||||||
Margin="2"
|
|
||||||
Width="42"
|
|
||||||
Height="42"
|
|
||||||
Source="{Binding Icon,
|
|
||||||
Converter={StaticResource ByteImage}}" />
|
|
||||||
<TextBlock
|
|
||||||
MaxLines="3"
|
|
||||||
Width="320"
|
|
||||||
Margin="5"
|
|
||||||
TextWrapping="Wrap"
|
|
||||||
Text="{Binding Title}" VerticalAlignment="Center" />
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel
|
|
||||||
Grid.Column="1"
|
|
||||||
Spacing="10"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
<Label
|
|
||||||
Content="{Binding SizeString}"
|
|
||||||
IsVisible="{Binding SizeAvailable}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Right" />
|
|
||||||
<Button
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Padding="10"
|
|
||||||
MinWidth="0"
|
|
||||||
MinHeight="0"
|
|
||||||
Name="OpenLocation"
|
|
||||||
Command="{Binding OpenLocation}">
|
|
||||||
<ui:SymbolIcon
|
|
||||||
Symbol="OpenFolder"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Padding="10"
|
|
||||||
MinWidth="0"
|
|
||||||
MinHeight="0"
|
|
||||||
Name="Delete"
|
|
||||||
Command="{Binding Delete}">
|
|
||||||
<ui:SymbolIcon
|
|
||||||
Symbol="Delete"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center" />
|
|
||||||
</Button>
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
@@ -1,160 +0,0 @@
|
|||||||
using Avalonia.Controls;
|
|
||||||
using DynamicData;
|
|
||||||
using DynamicData.Binding;
|
|
||||||
using LibHac;
|
|
||||||
using LibHac.Common;
|
|
||||||
using LibHac.Fs;
|
|
||||||
using LibHac.Fs.Shim;
|
|
||||||
using Ryujinx.Ava.Common;
|
|
||||||
using Ryujinx.Ava.Common.Locale;
|
|
||||||
using Ryujinx.Ava.UI.Models;
|
|
||||||
using Ryujinx.HLE.FileSystem;
|
|
||||||
using Ryujinx.Ui.App.Common;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
|
||||||
{
|
|
||||||
public partial class SaveManager : UserControl
|
|
||||||
{
|
|
||||||
private readonly UserProfile _userProfile;
|
|
||||||
private readonly HorizonClient _horizonClient;
|
|
||||||
private readonly VirtualFileSystem _virtualFileSystem;
|
|
||||||
private int _sortIndex;
|
|
||||||
private int _orderIndex;
|
|
||||||
private ObservableCollection<SaveModel> _view = new ObservableCollection<SaveModel>();
|
|
||||||
private string _search;
|
|
||||||
|
|
||||||
public ObservableCollection<SaveModel> Saves { get; set; } = new ObservableCollection<SaveModel>();
|
|
||||||
|
|
||||||
public ObservableCollection<SaveModel> View
|
|
||||||
{
|
|
||||||
get => _view;
|
|
||||||
set => _view = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int SortIndex
|
|
||||||
{
|
|
||||||
get => _sortIndex;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_sortIndex = value;
|
|
||||||
Sort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int OrderIndex
|
|
||||||
{
|
|
||||||
get => _orderIndex;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_orderIndex = value;
|
|
||||||
Sort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Search
|
|
||||||
{
|
|
||||||
get => _search;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_search = value;
|
|
||||||
Sort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaveManager()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaveManager(UserProfile userProfile, HorizonClient horizonClient, VirtualFileSystem virtualFileSystem)
|
|
||||||
{
|
|
||||||
_userProfile = userProfile;
|
|
||||||
_horizonClient = horizonClient;
|
|
||||||
_virtualFileSystem = virtualFileSystem;
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
DataContext = this;
|
|
||||||
|
|
||||||
Task.Run(LoadSaves);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadSaves()
|
|
||||||
{
|
|
||||||
Saves.Clear();
|
|
||||||
var saveDataFilter = SaveDataFilter.Make(programId: default, saveType: SaveDataType.Account,
|
|
||||||
new UserId((ulong)_userProfile.UserId.High, (ulong)_userProfile.UserId.Low), saveDataId: default, index: default);
|
|
||||||
|
|
||||||
using var saveDataIterator = new UniqueRef<SaveDataIterator>();
|
|
||||||
|
|
||||||
_horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref(), SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
|
|
||||||
|
|
||||||
Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
saveDataIterator.Get.ReadSaveDataInfo(out long readCount, saveDataInfo).ThrowIfFailure();
|
|
||||||
|
|
||||||
if (readCount == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < readCount; i++)
|
|
||||||
{
|
|
||||||
var save = saveDataInfo[i];
|
|
||||||
if (save.ProgramId.Value != 0)
|
|
||||||
{
|
|
||||||
var saveModel = new SaveModel(save, _horizonClient, _virtualFileSystem);
|
|
||||||
Saves.Add(saveModel);
|
|
||||||
saveModel.DeleteAction = () => { Saves.Remove(saveModel); };
|
|
||||||
}
|
|
||||||
|
|
||||||
Sort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Sort()
|
|
||||||
{
|
|
||||||
Saves.AsObservableChangeSet()
|
|
||||||
.Filter(Filter)
|
|
||||||
.Sort(GetComparer())
|
|
||||||
.Bind(out var view).AsObservableList();
|
|
||||||
|
|
||||||
_view.Clear();
|
|
||||||
_view.AddRange(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
private IComparer<SaveModel> GetComparer()
|
|
||||||
{
|
|
||||||
switch (SortIndex)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return OrderIndex == 0
|
|
||||||
? SortExpressionComparer<SaveModel>.Ascending(save => save.Title)
|
|
||||||
: SortExpressionComparer<SaveModel>.Descending(save => save.Title);
|
|
||||||
case 1:
|
|
||||||
return OrderIndex == 0
|
|
||||||
? SortExpressionComparer<SaveModel>.Ascending(save => save.Size)
|
|
||||||
: SortExpressionComparer<SaveModel>.Descending(save => save.Size);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool Filter(object arg)
|
|
||||||
{
|
|
||||||
if (arg is SaveModel save)
|
|
||||||
{
|
|
||||||
return string.IsNullOrWhiteSpace(_search) || save.Title.ToLower().Contains(_search.ToLower());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,72 +0,0 @@
|
|||||||
<UserControl
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
|
||||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DesignWidth="800"
|
|
||||||
d:DesignHeight="450"
|
|
||||||
MinWidth="500"
|
|
||||||
MinHeight="400"
|
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.UserRecoverer"
|
|
||||||
Focusable="True">
|
|
||||||
<Design.DataContext>
|
|
||||||
<viewModels:UserProfileViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
<Grid HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
<RowDefinition/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Button Grid.Row="0"
|
|
||||||
Margin="5"
|
|
||||||
Height="30"
|
|
||||||
Width="50"
|
|
||||||
MinWidth="50"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
Command="{Binding GoBack}">
|
|
||||||
<ui:SymbolIcon Symbol="Back"/>
|
|
||||||
</Button>
|
|
||||||
<TextBlock Grid.Row="1"
|
|
||||||
Text="{locale:Locale UserProfilesRecoverHeading}"/>
|
|
||||||
<ListBox
|
|
||||||
Margin="5"
|
|
||||||
Grid.Row="2"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
Items="{Binding LostProfiles}">
|
|
||||||
<ListBox.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<Border
|
|
||||||
Margin="2"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
ClipToBounds="True"
|
|
||||||
CornerRadius="5">
|
|
||||||
<Grid Margin="0">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition/>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<TextBlock
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Text="{Binding UserId}"
|
|
||||||
TextAlignment="Left"
|
|
||||||
TextWrapping="Wrap" />
|
|
||||||
<Button Grid.Column="1"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Command="{Binding Recover}"
|
|
||||||
CommandParameter="{Binding}"
|
|
||||||
Content="{locale:Locale Recover}"/>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
@@ -1,44 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Interactivity;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using FluentAvalonia.UI.Controls;
|
|
||||||
using FluentAvalonia.UI.Navigation;
|
|
||||||
using Ryujinx.Ava.UI.Models;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
|
||||||
{
|
|
||||||
public partial class UserRecoverer : UserControl
|
|
||||||
{
|
|
||||||
private UserProfileViewModel _viewModel;
|
|
||||||
private NavigationDialogHost _parent;
|
|
||||||
|
|
||||||
public UserRecoverer()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
|
||||||
{
|
|
||||||
NavigatedTo(e);
|
|
||||||
}, RoutingStrategies.Direct);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NavigatedTo(NavigationEventArgs arg)
|
|
||||||
{
|
|
||||||
if (Program.PreviewerDetached)
|
|
||||||
{
|
|
||||||
switch (arg.NavigationMode)
|
|
||||||
{
|
|
||||||
case NavigationMode.New:
|
|
||||||
var args = ((NavigationDialogHost parent, UserProfileViewModel viewModel))arg.Parameter;
|
|
||||||
|
|
||||||
_viewModel = args.viewModel;
|
|
||||||
_parent = args.parent;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataContext = _viewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,145 +0,0 @@
|
|||||||
<UserControl
|
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.UserSelector"
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
|
||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
|
||||||
d:DesignHeight="450"
|
|
||||||
MinWidth="500"
|
|
||||||
d:DesignWidth="800"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
Focusable="True">
|
|
||||||
<UserControl.Resources>
|
|
||||||
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
|
||||||
</UserControl.Resources>
|
|
||||||
<Design.DataContext>
|
|
||||||
<viewModels:UserProfileViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<ListBox
|
|
||||||
Margin="5"
|
|
||||||
MaxHeight="300"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
DoubleTapped="ProfilesList_DoubleTapped"
|
|
||||||
Items="{Binding Profiles}"
|
|
||||||
SelectionChanged="SelectingItemsControl_SelectionChanged">
|
|
||||||
<ListBox.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<flex:FlexPanel
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
AlignContent="FlexStart"
|
|
||||||
JustifyContent="Center" />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ListBox.ItemsPanel>
|
|
||||||
<ListBox.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<Grid>
|
|
||||||
<Border
|
|
||||||
Margin="2"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
ClipToBounds="True"
|
|
||||||
CornerRadius="5">
|
|
||||||
<Grid Margin="0">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Image
|
|
||||||
Grid.Row="0"
|
|
||||||
Width="96"
|
|
||||||
Height="96"
|
|
||||||
Margin="0"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
|
||||||
<StackPanel
|
|
||||||
Grid.Row="1"
|
|
||||||
Height="30"
|
|
||||||
Margin="5"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch">
|
|
||||||
<TextBlock
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Text="{Binding Name}"
|
|
||||||
TextAlignment="Center"
|
|
||||||
TextWrapping="Wrap" />
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
<Border
|
|
||||||
Width="10"
|
|
||||||
Height="10"
|
|
||||||
Margin="5"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Background="LimeGreen"
|
|
||||||
CornerRadius="5"
|
|
||||||
IsVisible="{Binding IsOpened}" />
|
|
||||||
</Grid>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
<Grid
|
|
||||||
Grid.Row="1"
|
|
||||||
HorizontalAlignment="Center">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Button
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Grid.Row="0"
|
|
||||||
Grid.Column="0"
|
|
||||||
Margin="2"
|
|
||||||
Command="{Binding AddUser}"
|
|
||||||
Content="{locale:Locale UserProfilesAddNewProfile}" />
|
|
||||||
<Button
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Grid.Row="0"
|
|
||||||
Margin="2"
|
|
||||||
Grid.Column="1"
|
|
||||||
Command="{Binding EditUser}"
|
|
||||||
Content="{locale:Locale UserProfilesEditProfile}"
|
|
||||||
IsEnabled="{Binding IsSelectedProfiledEditable}" />
|
|
||||||
<Button
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="0"
|
|
||||||
Margin="2"
|
|
||||||
Content="{locale:Locale UserProfilesManageSaves}"
|
|
||||||
Command="{Binding ManageSaves}" />
|
|
||||||
<Button
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="1"
|
|
||||||
Margin="2"
|
|
||||||
Command="{Binding DeleteUser}"
|
|
||||||
Content="{locale:Locale UserProfilesDeleteSelectedProfile}"
|
|
||||||
IsEnabled="{Binding IsSelectedProfileDeletable}" />
|
|
||||||
<Button
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Grid.Row="2"
|
|
||||||
Grid.ColumnSpan="2"
|
|
||||||
Grid.Column="0"
|
|
||||||
Margin="2"
|
|
||||||
Command="{Binding RecoverLostAccounts}"
|
|
||||||
Content="{locale:Locale UserProfilesRecoverLostAccounts}" />
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
@@ -1,77 +0,0 @@
|
|||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Interactivity;
|
|
||||||
using FluentAvalonia.UI.Controls;
|
|
||||||
using FluentAvalonia.UI.Navigation;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
|
||||||
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
|
||||||
{
|
|
||||||
public partial class UserSelector : UserControl
|
|
||||||
{
|
|
||||||
private NavigationDialogHost _parent;
|
|
||||||
public UserProfileViewModel ViewModel { get; set; }
|
|
||||||
|
|
||||||
public UserSelector()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
if (Program.PreviewerDetached)
|
|
||||||
{
|
|
||||||
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
|
||||||
{
|
|
||||||
NavigatedTo(e);
|
|
||||||
}, RoutingStrategies.Direct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NavigatedTo(NavigationEventArgs arg)
|
|
||||||
{
|
|
||||||
if (Program.PreviewerDetached)
|
|
||||||
{
|
|
||||||
if (arg.NavigationMode == NavigationMode.New)
|
|
||||||
{
|
|
||||||
_parent = (NavigationDialogHost)arg.Parameter;
|
|
||||||
ViewModel = _parent.ViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataContext = ViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProfilesList_DoubleTapped(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is ListBox listBox)
|
|
||||||
{
|
|
||||||
int selectedIndex = listBox.SelectedIndex;
|
|
||||||
|
|
||||||
if (selectedIndex >= 0 && selectedIndex < ViewModel.Profiles.Count)
|
|
||||||
{
|
|
||||||
ViewModel.SelectedProfile = ViewModel.Profiles[selectedIndex];
|
|
||||||
|
|
||||||
_parent?.AccountManager?.OpenUser(ViewModel.SelectedProfile.UserId);
|
|
||||||
|
|
||||||
ViewModel.LoadProfiles();
|
|
||||||
|
|
||||||
foreach (UserProfile profile in ViewModel.Profiles)
|
|
||||||
{
|
|
||||||
profile.UpdateState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SelectingItemsControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is ListBox listBox)
|
|
||||||
{
|
|
||||||
int selectedIndex = listBox.SelectedIndex;
|
|
||||||
|
|
||||||
if (selectedIndex >= 0 && selectedIndex < ViewModel.Profiles.Count)
|
|
||||||
{
|
|
||||||
ViewModel.HighlightedProfile = ViewModel.Profiles[selectedIndex];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -2,7 +2,6 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
using Ryujinx.Ava.UI.Helper;
|
|
||||||
using SPB.Graphics;
|
using SPB.Graphics;
|
||||||
using SPB.Platform;
|
using SPB.Platform;
|
||||||
using SPB.Platform.GLX;
|
using SPB.Platform.GLX;
|
||||||
|
@@ -2,7 +2,7 @@ using Avalonia.Utilities;
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Helper
|
namespace Ryujinx.Ava.UI.Helpers
|
||||||
{
|
{
|
||||||
using AvaLogger = Avalonia.Logging.Logger;
|
using AvaLogger = Avalonia.Logging.Logger;
|
||||||
using AvaLogLevel = Avalonia.Logging.LogEventLevel;
|
using AvaLogLevel = Avalonia.Logging.LogEventLevel;
|
||||||
@@ -20,12 +20,12 @@ namespace Ryujinx.Ava.UI.Helper
|
|||||||
{
|
{
|
||||||
return level switch
|
return level switch
|
||||||
{
|
{
|
||||||
AvaLogLevel.Verbose => RyuLogger.Trace,
|
AvaLogLevel.Verbose => RyuLogger.Debug,
|
||||||
AvaLogLevel.Debug => RyuLogger.Debug,
|
AvaLogLevel.Debug => RyuLogger.Debug,
|
||||||
AvaLogLevel.Information => RyuLogger.Info,
|
AvaLogLevel.Information => RyuLogger.Debug,
|
||||||
AvaLogLevel.Warning => RyuLogger.Warning,
|
AvaLogLevel.Warning => RyuLogger.Debug,
|
||||||
AvaLogLevel.Error => RyuLogger.Error,
|
AvaLogLevel.Error => RyuLogger.Error,
|
||||||
AvaLogLevel.Fatal => RyuLogger.Notice,
|
AvaLogLevel.Fatal => RyuLogger.Error,
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(level), level, null)
|
_ => throw new ArgumentOutOfRangeException(nameof(level), level, null)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -37,34 +37,38 @@ namespace Ryujinx.Ava.UI.Helper
|
|||||||
|
|
||||||
public void Log(AvaLogLevel level, string area, object source, string messageTemplate)
|
public void Log(AvaLogLevel level, string area, object source, string messageTemplate)
|
||||||
{
|
{
|
||||||
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, null));
|
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Log<T0>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0)
|
public void Log<T0>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0)
|
||||||
{
|
{
|
||||||
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, new object[] { propertyValue0 }));
|
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Log<T0, T1>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
public void Log<T0, T1>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||||
{
|
{
|
||||||
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, new object[] { propertyValue0, propertyValue1 }));
|
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0, propertyValue1 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Log<T0, T1, T2>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
public void Log<T0, T1, T2>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||||
{
|
{
|
||||||
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, new object[] { propertyValue0, propertyValue1, propertyValue2 }));
|
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0, propertyValue1, propertyValue2 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Log(AvaLogLevel level, string area, object source, string messageTemplate, params object[] propertyValues)
|
public void Log(AvaLogLevel level, string area, object source, string messageTemplate, params object[] propertyValues)
|
||||||
{
|
{
|
||||||
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(area, messageTemplate, source, propertyValues));
|
GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, propertyValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string Format(string area, string template, object source, object[] v)
|
private static string Format(AvaLogLevel level, string area, string template, object source, object[] v)
|
||||||
{
|
{
|
||||||
var result = new StringBuilder();
|
var result = new StringBuilder();
|
||||||
var r = new CharacterReader(template.AsSpan());
|
var r = new CharacterReader(template.AsSpan());
|
||||||
var i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
result.Append('[');
|
||||||
|
result.Append(level);
|
||||||
|
result.Append("] ");
|
||||||
|
|
||||||
result.Append('[');
|
result.Append('[');
|
||||||
result.Append(area);
|
result.Append(area);
|
@@ -3,7 +3,7 @@ using System.Runtime.Versioning;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Helper
|
namespace Ryujinx.Ava.UI.Helpers
|
||||||
{
|
{
|
||||||
public delegate void UpdateBoundsCallbackDelegate(Rect rect);
|
public delegate void UpdateBoundsCallbackDelegate(Rect rect);
|
||||||
|
|
@@ -1,6 +1,9 @@
|
|||||||
|
using Avalonia.Media;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Models
|
namespace Ryujinx.Ava.UI.Models
|
||||||
{
|
{
|
||||||
public class ProfileImageModel
|
public class ProfileImageModel : BaseModel
|
||||||
{
|
{
|
||||||
public ProfileImageModel(string name, byte[] data)
|
public ProfileImageModel(string name, byte[] data)
|
||||||
{
|
{
|
||||||
@@ -10,5 +13,20 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public byte[] Data { get; set; }
|
public byte[] Data { get; set; }
|
||||||
|
|
||||||
|
private SolidColorBrush _backgroundColor = new(Colors.White);
|
||||||
|
|
||||||
|
public SolidColorBrush BackgroundColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _backgroundColor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_backgroundColor = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,15 +1,8 @@
|
|||||||
using LibHac;
|
|
||||||
using LibHac.Fs;
|
using LibHac.Fs;
|
||||||
using LibHac.Fs.Shim;
|
|
||||||
using LibHac.Ncm;
|
using LibHac.Ncm;
|
||||||
using Ryujinx.Ava.Common;
|
|
||||||
using Ryujinx.Ava.Common.Locale;
|
|
||||||
using Ryujinx.Ava.UI.Controls;
|
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.Ava.UI.Windows;
|
using Ryujinx.Ava.UI.Windows;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.Ui.App.Common;
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -19,10 +12,8 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
{
|
{
|
||||||
public class SaveModel : BaseModel
|
public class SaveModel : BaseModel
|
||||||
{
|
{
|
||||||
private readonly HorizonClient _horizonClient;
|
|
||||||
private long _size;
|
private long _size;
|
||||||
|
|
||||||
public Action DeleteAction { get; set; }
|
|
||||||
public ulong SaveId { get; }
|
public ulong SaveId { get; }
|
||||||
public ProgramId TitleId { get; }
|
public ProgramId TitleId { get; }
|
||||||
public string TitleIdString => $"{TitleId.Value:X16}";
|
public string TitleIdString => $"{TitleId.Value:X16}";
|
||||||
@@ -45,11 +36,29 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
|
|
||||||
public bool SizeAvailable { get; set; }
|
public bool SizeAvailable { get; set; }
|
||||||
|
|
||||||
public string SizeString => $"{((float)_size * 0.000000954):0.###}MB";
|
public string SizeString => GetSizeString();
|
||||||
|
|
||||||
public SaveModel(SaveDataInfo info, HorizonClient horizonClient, VirtualFileSystem virtualFileSystem)
|
private string GetSizeString()
|
||||||
|
{
|
||||||
|
const int scale = 1024;
|
||||||
|
string[] orders = { "GiB", "MiB", "KiB" };
|
||||||
|
long max = (long)Math.Pow(scale, orders.Length);
|
||||||
|
|
||||||
|
foreach (string order in orders)
|
||||||
|
{
|
||||||
|
if (Size > max)
|
||||||
|
{
|
||||||
|
return $"{decimal.Divide(Size, max):##.##} {order}";
|
||||||
|
}
|
||||||
|
|
||||||
|
max /= scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "0 KiB";
|
||||||
|
}
|
||||||
|
|
||||||
|
public SaveModel(SaveDataInfo info, VirtualFileSystem virtualFileSystem)
|
||||||
{
|
{
|
||||||
_horizonClient = horizonClient;
|
|
||||||
SaveId = info.SaveDataId;
|
SaveId = info.SaveDataId;
|
||||||
TitleId = info.ProgramId;
|
TitleId = info.ProgramId;
|
||||||
UserId = info.UserId;
|
UserId = info.UserId;
|
||||||
@@ -99,25 +108,5 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenLocation()
|
|
||||||
{
|
|
||||||
ApplicationHelper.OpenSaveDir(SaveId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Delete()
|
|
||||||
{
|
|
||||||
var result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DeleteUserSave],
|
|
||||||
LocaleManager.Instance[LocaleKeys.IrreversibleActionNote],
|
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogNo], "");
|
|
||||||
|
|
||||||
if (result == UserResult.Yes)
|
|
||||||
{
|
|
||||||
_horizonClient.Fs.DeleteSaveData(SaveDataSpaceId.User, SaveId);
|
|
||||||
|
|
||||||
DeleteAction?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -7,10 +7,12 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
public class TempProfile : BaseModel
|
public class TempProfile : BaseModel
|
||||||
{
|
{
|
||||||
private readonly UserProfile _profile;
|
private readonly UserProfile _profile;
|
||||||
private byte[] _image = null;
|
private byte[] _image;
|
||||||
private string _name = String.Empty;
|
private string _name = String.Empty;
|
||||||
private UserId _userId;
|
private UserId _userId;
|
||||||
|
|
||||||
|
public uint MaxProfileNameLength => 0x20;
|
||||||
|
|
||||||
public byte[] Image
|
public byte[] Image
|
||||||
{
|
{
|
||||||
get => _image;
|
get => _image;
|
||||||
@@ -28,9 +30,12 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
{
|
{
|
||||||
_userId = value;
|
_userId = value;
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
|
OnPropertyChanged(nameof(UserIdString));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string UserIdString => _userId.ToString();
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get => _name;
|
get => _name;
|
||||||
@@ -52,7 +57,5 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
UserId = profile.UserId;
|
UserId = profile.UserId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TempProfile(){}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,7 @@
|
|||||||
|
using Avalonia.Media;
|
||||||
using Ryujinx.Ava.UI.Controls;
|
using Ryujinx.Ava.UI.Controls;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
using Ryujinx.Ava.UI.Views.User;
|
||||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
using Profile = Ryujinx.HLE.HOS.Services.Account.Acc.UserProfile;
|
using Profile = Ryujinx.HLE.HOS.Services.Account.Acc.UserProfile;
|
||||||
|
|
||||||
@@ -12,6 +14,8 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
private byte[] _image;
|
private byte[] _image;
|
||||||
private string _name;
|
private string _name;
|
||||||
private UserId _userId;
|
private UserId _userId;
|
||||||
|
private bool _isPointerOver;
|
||||||
|
private IBrush _backgroundColor;
|
||||||
|
|
||||||
public byte[] Image
|
public byte[] Image
|
||||||
{
|
{
|
||||||
@@ -43,27 +47,57 @@ namespace Ryujinx.Ava.UI.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsPointerOver
|
||||||
|
{
|
||||||
|
get => _isPointerOver;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isPointerOver = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBrush BackgroundColor
|
||||||
|
{
|
||||||
|
get => _backgroundColor;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_backgroundColor = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public UserProfile(Profile profile, NavigationDialogHost owner)
|
public UserProfile(Profile profile, NavigationDialogHost owner)
|
||||||
{
|
{
|
||||||
_profile = profile;
|
_profile = profile;
|
||||||
_owner = owner;
|
_owner = owner;
|
||||||
|
|
||||||
|
UpdateBackground();
|
||||||
|
|
||||||
Image = profile.Image;
|
Image = profile.Image;
|
||||||
Name = profile.Name;
|
Name = profile.Name;
|
||||||
UserId = profile.UserId;
|
UserId = profile.UserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsOpened => _profile.AccountState == AccountState.Open;
|
|
||||||
|
|
||||||
public void UpdateState()
|
public void UpdateState()
|
||||||
{
|
{
|
||||||
OnPropertyChanged(nameof(IsOpened));
|
UpdateBackground();
|
||||||
OnPropertyChanged(nameof(Name));
|
OnPropertyChanged(nameof(Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateBackground()
|
||||||
|
{
|
||||||
|
Avalonia.Application.Current.Styles.TryGetResource("ControlFillColorSecondary", out object color);
|
||||||
|
|
||||||
|
if (color is not null)
|
||||||
|
{
|
||||||
|
BackgroundColor = _profile.AccountState == AccountState.Open ? new SolidColorBrush((Color)color) : Brushes.Transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Recover(UserProfile userProfile)
|
public void Recover(UserProfile userProfile)
|
||||||
{
|
{
|
||||||
_owner.Navigate(typeof(UserEditor), (_owner, userProfile, true));
|
_owner.Navigate(typeof(UserEditorView), (_owner, userProfile, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1918,7 +1918,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||||
|
|
||||||
if (result != UserResult.Yes)
|
if (result == UserResult.Yes)
|
||||||
{
|
{
|
||||||
ConfigurationState.Instance.Logger.EnableTrace.Value = false;
|
ConfigurationState.Instance.Logger.EnableTrace.Value = false;
|
||||||
|
|
||||||
@@ -1938,7 +1938,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||||
|
|
||||||
if (result != UserResult.Yes)
|
if (result == UserResult.Yes)
|
||||||
{
|
{
|
||||||
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = "";
|
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = "";
|
||||||
|
|
||||||
|
@@ -151,7 +151,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
public bool IsSoundIoEnabled { get; set; }
|
public bool IsSoundIoEnabled { get; set; }
|
||||||
public bool IsSDL2Enabled { get; set; }
|
public bool IsSDL2Enabled { get; set; }
|
||||||
public bool EnableCustomTheme { get; set; }
|
public bool EnableCustomTheme { get; set; }
|
||||||
public bool IsCustomResolutionScaleActive => _resolutionScale == 0;
|
public bool IsCustomResolutionScaleActive => _resolutionScale == 4;
|
||||||
public bool IsVulkanSelected => GraphicsBackendIndex == 0;
|
public bool IsVulkanSelected => GraphicsBackendIndex == 0;
|
||||||
|
|
||||||
public string TimeZone { get; set; }
|
public string TimeZone { get; set; }
|
||||||
@@ -311,25 +311,66 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
{
|
{
|
||||||
ConfigurationState config = ConfigurationState.Instance;
|
ConfigurationState config = ConfigurationState.Instance;
|
||||||
|
|
||||||
GameDirectories.Clear();
|
// User Interface
|
||||||
GameDirectories.AddRange(config.Ui.GameDirs.Value);
|
|
||||||
|
|
||||||
EnableDiscordIntegration = config.EnableDiscordIntegration;
|
EnableDiscordIntegration = config.EnableDiscordIntegration;
|
||||||
CheckUpdatesOnStart = config.CheckUpdatesOnStart;
|
CheckUpdatesOnStart = config.CheckUpdatesOnStart;
|
||||||
ShowConfirmExit = config.ShowConfirmExit;
|
ShowConfirmExit = config.ShowConfirmExit;
|
||||||
HideCursorOnIdle = config.HideCursorOnIdle;
|
HideCursorOnIdle = config.HideCursorOnIdle;
|
||||||
|
|
||||||
|
GameDirectories.Clear();
|
||||||
|
GameDirectories.AddRange(config.Ui.GameDirs.Value);
|
||||||
|
|
||||||
|
EnableCustomTheme = config.Ui.EnableCustomTheme;
|
||||||
|
CustomThemePath = config.Ui.CustomThemePath;
|
||||||
|
BaseStyleIndex = config.Ui.BaseStyle == "Light" ? 0 : 1;
|
||||||
|
|
||||||
|
// Input
|
||||||
EnableDockedMode = config.System.EnableDockedMode;
|
EnableDockedMode = config.System.EnableDockedMode;
|
||||||
EnableKeyboard = config.Hid.EnableKeyboard;
|
EnableKeyboard = config.Hid.EnableKeyboard;
|
||||||
EnableMouse = config.Hid.EnableMouse;
|
EnableMouse = config.Hid.EnableMouse;
|
||||||
|
|
||||||
|
// Keyboard Hotkeys
|
||||||
|
KeyboardHotkeys = config.Hid.Hotkeys.Value;
|
||||||
|
|
||||||
|
// System
|
||||||
|
Region = (int)config.System.Region.Value;
|
||||||
|
Language = (int)config.System.Language.Value;
|
||||||
|
TimeZone = config.System.TimeZone;
|
||||||
|
|
||||||
|
DateTime dateTimeOffset = DateTime.Now.AddSeconds(config.System.SystemTimeOffset);
|
||||||
|
|
||||||
|
DateOffset = dateTimeOffset.Date;
|
||||||
|
TimeOffset = dateTimeOffset.TimeOfDay;
|
||||||
EnableVsync = config.Graphics.EnableVsync;
|
EnableVsync = config.Graphics.EnableVsync;
|
||||||
EnablePptc = config.System.EnablePtc;
|
|
||||||
EnableInternetAccess = config.System.EnableInternetAccess;
|
|
||||||
EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks;
|
EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks;
|
||||||
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
|
||||||
ExpandDramSize = config.System.ExpandRam;
|
ExpandDramSize = config.System.ExpandRam;
|
||||||
|
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
||||||
|
|
||||||
|
// CPU
|
||||||
|
EnablePptc = config.System.EnablePtc;
|
||||||
|
MemoryMode = (int)config.System.MemoryManagerMode.Value;
|
||||||
|
|
||||||
|
// Graphics
|
||||||
|
GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value;
|
||||||
|
PreferredGpuIndex = _gpuIds.Contains(config.Graphics.PreferredGpu) ? _gpuIds.IndexOf(config.Graphics.PreferredGpu) : 0;
|
||||||
EnableShaderCache = config.Graphics.EnableShaderCache;
|
EnableShaderCache = config.Graphics.EnableShaderCache;
|
||||||
EnableTextureRecompression = config.Graphics.EnableTextureRecompression;
|
EnableTextureRecompression = config.Graphics.EnableTextureRecompression;
|
||||||
EnableMacroHLE = config.Graphics.EnableMacroHLE;
|
EnableMacroHLE = config.Graphics.EnableMacroHLE;
|
||||||
|
ResolutionScale = config.Graphics.ResScale == -1 ? 4 : config.Graphics.ResScale - 1;
|
||||||
|
CustomResolutionScale = config.Graphics.ResScaleCustom;
|
||||||
|
MaxAnisotropy = config.Graphics.MaxAnisotropy == -1 ? 0 : (int)(MathF.Log2(config.Graphics.MaxAnisotropy));
|
||||||
|
AspectRatio = (int)config.Graphics.AspectRatio.Value;
|
||||||
|
GraphicsBackendMultithreadingIndex = (int)config.Graphics.BackendThreading.Value;
|
||||||
|
ShaderDumpPath = config.Graphics.ShadersDumpPath;
|
||||||
|
|
||||||
|
// Audio
|
||||||
|
AudioBackend = (int)config.System.AudioBackend.Value;
|
||||||
|
Volume = config.System.AudioVolume * 100;
|
||||||
|
|
||||||
|
// Network
|
||||||
|
EnableInternetAccess = config.System.EnableInternetAccess;
|
||||||
|
|
||||||
|
// Logging
|
||||||
EnableFileLog = config.Logger.EnableFileLog;
|
EnableFileLog = config.Logger.EnableFileLog;
|
||||||
EnableStub = config.Logger.EnableStub;
|
EnableStub = config.Logger.EnableStub;
|
||||||
EnableInfo = config.Logger.EnableInfo;
|
EnableInfo = config.Logger.EnableInfo;
|
||||||
@@ -339,94 +380,69 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
EnableGuest = config.Logger.EnableGuest;
|
EnableGuest = config.Logger.EnableGuest;
|
||||||
EnableDebug = config.Logger.EnableDebug;
|
EnableDebug = config.Logger.EnableDebug;
|
||||||
EnableFsAccessLog = config.Logger.EnableFsAccessLog;
|
EnableFsAccessLog = config.Logger.EnableFsAccessLog;
|
||||||
EnableCustomTheme = config.Ui.EnableCustomTheme;
|
|
||||||
Volume = config.System.AudioVolume * 100;
|
|
||||||
|
|
||||||
GraphicsBackendMultithreadingIndex = (int)config.Graphics.BackendThreading.Value;
|
|
||||||
|
|
||||||
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
|
|
||||||
|
|
||||||
TimeZone = config.System.TimeZone;
|
|
||||||
ShaderDumpPath = config.Graphics.ShadersDumpPath;
|
|
||||||
CustomThemePath = config.Ui.CustomThemePath;
|
|
||||||
BaseStyleIndex = config.Ui.BaseStyle == "Light" ? 0 : 1;
|
|
||||||
GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value;
|
|
||||||
|
|
||||||
PreferredGpuIndex = _gpuIds.Contains(config.Graphics.PreferredGpu) ? _gpuIds.IndexOf(config.Graphics.PreferredGpu) : 0;
|
|
||||||
|
|
||||||
Language = (int)config.System.Language.Value;
|
|
||||||
Region = (int)config.System.Region.Value;
|
|
||||||
FsGlobalAccessLogMode = config.System.FsGlobalAccessLogMode;
|
FsGlobalAccessLogMode = config.System.FsGlobalAccessLogMode;
|
||||||
AudioBackend = (int)config.System.AudioBackend.Value;
|
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
|
||||||
MemoryMode = (int)config.System.MemoryManagerMode.Value;
|
|
||||||
|
|
||||||
float anisotropy = config.Graphics.MaxAnisotropy;
|
|
||||||
|
|
||||||
MaxAnisotropy = anisotropy == -1 ? 0 : (int)(MathF.Log2(anisotropy));
|
|
||||||
AspectRatio = (int)config.Graphics.AspectRatio.Value;
|
|
||||||
|
|
||||||
int resolution = config.Graphics.ResScale;
|
|
||||||
|
|
||||||
ResolutionScale = resolution == -1 ? 0 : resolution;
|
|
||||||
CustomResolutionScale = config.Graphics.ResScaleCustom;
|
|
||||||
|
|
||||||
DateTime dateTimeOffset = DateTime.Now.AddSeconds(config.System.SystemTimeOffset);
|
|
||||||
|
|
||||||
DateOffset = dateTimeOffset.Date;
|
|
||||||
TimeOffset = dateTimeOffset.TimeOfDay;
|
|
||||||
|
|
||||||
KeyboardHotkeys = config.Hid.Hotkeys.Value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveSettings()
|
public void SaveSettings()
|
||||||
{
|
{
|
||||||
ConfigurationState config = ConfigurationState.Instance;
|
ConfigurationState config = ConfigurationState.Instance;
|
||||||
|
|
||||||
|
// User Interface
|
||||||
|
config.EnableDiscordIntegration.Value = EnableDiscordIntegration;
|
||||||
|
config.CheckUpdatesOnStart.Value = CheckUpdatesOnStart;
|
||||||
|
config.ShowConfirmExit.Value = ShowConfirmExit;
|
||||||
|
config.HideCursorOnIdle.Value = HideCursorOnIdle;
|
||||||
|
|
||||||
if (_directoryChanged)
|
if (_directoryChanged)
|
||||||
{
|
{
|
||||||
List<string> gameDirs = new List<string>(GameDirectories);
|
List<string> gameDirs = new(GameDirectories);
|
||||||
config.Ui.GameDirs.Value = gameDirs;
|
config.Ui.GameDirs.Value = gameDirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.Ui.EnableCustomTheme.Value = EnableCustomTheme;
|
||||||
|
config.Ui.CustomThemePath.Value = CustomThemePath;
|
||||||
|
config.Ui.BaseStyle.Value = BaseStyleIndex == 0 ? "Light" : "Dark";
|
||||||
|
|
||||||
|
// Input
|
||||||
|
config.System.EnableDockedMode.Value = EnableDockedMode;
|
||||||
|
config.Hid.EnableKeyboard.Value = EnableKeyboard;
|
||||||
|
config.Hid.EnableMouse.Value = EnableMouse;
|
||||||
|
|
||||||
|
// Keyboard Hotkeys
|
||||||
|
config.Hid.Hotkeys.Value = KeyboardHotkeys;
|
||||||
|
|
||||||
|
// System
|
||||||
|
config.System.Region.Value = (Region)Region;
|
||||||
|
config.System.Language.Value = (Language)Language;
|
||||||
|
|
||||||
if (_validTzRegions.Contains(TimeZone))
|
if (_validTzRegions.Contains(TimeZone))
|
||||||
{
|
{
|
||||||
config.System.TimeZone.Value = TimeZone;
|
config.System.TimeZone.Value = TimeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Logger.EnableError.Value = EnableError;
|
TimeSpan systemTimeOffset = DateOffset - DateTime.Now;
|
||||||
config.Logger.EnableTrace.Value = EnableTrace;
|
|
||||||
config.Logger.EnableWarn.Value = EnableWarn;
|
config.System.SystemTimeOffset.Value = systemTimeOffset.Seconds;
|
||||||
config.Logger.EnableInfo.Value = EnableInfo;
|
|
||||||
config.Logger.EnableStub.Value = EnableStub;
|
|
||||||
config.Logger.EnableDebug.Value = EnableDebug;
|
|
||||||
config.Logger.EnableGuest.Value = EnableGuest;
|
|
||||||
config.Logger.EnableFsAccessLog.Value = EnableFsAccessLog;
|
|
||||||
config.Logger.EnableFileLog.Value = EnableFileLog;
|
|
||||||
config.Logger.GraphicsDebugLevel.Value = (GraphicsDebugLevel)OpenglDebugLevel;
|
|
||||||
config.System.EnableDockedMode.Value = EnableDockedMode;
|
|
||||||
config.EnableDiscordIntegration.Value = EnableDiscordIntegration;
|
|
||||||
config.CheckUpdatesOnStart.Value = CheckUpdatesOnStart;
|
|
||||||
config.ShowConfirmExit.Value = ShowConfirmExit;
|
|
||||||
config.HideCursorOnIdle.Value = HideCursorOnIdle;
|
|
||||||
config.Graphics.EnableVsync.Value = EnableVsync;
|
config.Graphics.EnableVsync.Value = EnableVsync;
|
||||||
|
config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks;
|
||||||
|
config.System.ExpandRam.Value = ExpandDramSize;
|
||||||
|
config.System.IgnoreMissingServices.Value = IgnoreMissingServices;
|
||||||
|
|
||||||
|
// CPU
|
||||||
|
config.System.EnablePtc.Value = EnablePptc;
|
||||||
|
config.System.MemoryManagerMode.Value = (MemoryManagerMode)MemoryMode;
|
||||||
|
|
||||||
|
// Graphics
|
||||||
|
config.Graphics.GraphicsBackend.Value = (GraphicsBackend)GraphicsBackendIndex;
|
||||||
|
config.Graphics.PreferredGpu.Value = _gpuIds.ElementAtOrDefault(PreferredGpuIndex);
|
||||||
config.Graphics.EnableShaderCache.Value = EnableShaderCache;
|
config.Graphics.EnableShaderCache.Value = EnableShaderCache;
|
||||||
config.Graphics.EnableTextureRecompression.Value = EnableTextureRecompression;
|
config.Graphics.EnableTextureRecompression.Value = EnableTextureRecompression;
|
||||||
config.Graphics.EnableMacroHLE.Value = EnableMacroHLE;
|
config.Graphics.EnableMacroHLE.Value = EnableMacroHLE;
|
||||||
config.Graphics.GraphicsBackend.Value = (GraphicsBackend)GraphicsBackendIndex;
|
config.Graphics.ResScale.Value = ResolutionScale == 4 ? -1 : ResolutionScale + 1;
|
||||||
config.System.EnablePtc.Value = EnablePptc;
|
config.Graphics.ResScaleCustom.Value = CustomResolutionScale;
|
||||||
config.System.EnableInternetAccess.Value = EnableInternetAccess;
|
config.Graphics.MaxAnisotropy.Value = MaxAnisotropy == 0 ? -1 : MathF.Pow(2, MaxAnisotropy);
|
||||||
config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks;
|
config.Graphics.AspectRatio.Value = (AspectRatio)AspectRatio;
|
||||||
config.System.IgnoreMissingServices.Value = IgnoreMissingServices;
|
|
||||||
config.System.ExpandRam.Value = ExpandDramSize;
|
|
||||||
config.Hid.EnableKeyboard.Value = EnableKeyboard;
|
|
||||||
config.Hid.EnableMouse.Value = EnableMouse;
|
|
||||||
config.Ui.CustomThemePath.Value = CustomThemePath;
|
|
||||||
config.Ui.EnableCustomTheme.Value = EnableCustomTheme;
|
|
||||||
config.Ui.BaseStyle.Value = BaseStyleIndex == 0 ? "Light" : "Dark";
|
|
||||||
config.System.Language.Value = (Language)Language;
|
|
||||||
config.System.Region.Value = (Region)Region;
|
|
||||||
|
|
||||||
config.Graphics.PreferredGpu.Value = _gpuIds.ElementAtOrDefault(PreferredGpuIndex);
|
|
||||||
|
|
||||||
if (ConfigurationState.Instance.Graphics.BackendThreading != (BackendThreading)GraphicsBackendMultithreadingIndex)
|
if (ConfigurationState.Instance.Graphics.BackendThreading != (BackendThreading)GraphicsBackendMultithreadingIndex)
|
||||||
{
|
{
|
||||||
@@ -434,22 +450,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
config.Graphics.BackendThreading.Value = (BackendThreading)GraphicsBackendMultithreadingIndex;
|
config.Graphics.BackendThreading.Value = (BackendThreading)GraphicsBackendMultithreadingIndex;
|
||||||
|
|
||||||
TimeSpan systemTimeOffset = DateOffset - DateTime.Now;
|
|
||||||
|
|
||||||
config.System.SystemTimeOffset.Value = systemTimeOffset.Seconds;
|
|
||||||
config.Graphics.ShadersDumpPath.Value = ShaderDumpPath;
|
config.Graphics.ShadersDumpPath.Value = ShaderDumpPath;
|
||||||
config.System.FsGlobalAccessLogMode.Value = FsGlobalAccessLogMode;
|
|
||||||
config.System.MemoryManagerMode.Value = (MemoryManagerMode)MemoryMode;
|
|
||||||
|
|
||||||
float anisotropy = MaxAnisotropy == 0 ? -1 : MathF.Pow(2, MaxAnisotropy);
|
|
||||||
|
|
||||||
config.Graphics.MaxAnisotropy.Value = anisotropy;
|
|
||||||
config.Graphics.AspectRatio.Value = (AspectRatio)AspectRatio;
|
|
||||||
config.Graphics.ResScale.Value = ResolutionScale == 0 ? -1 : ResolutionScale;
|
|
||||||
config.Graphics.ResScaleCustom.Value = CustomResolutionScale;
|
|
||||||
config.System.AudioVolume.Value = Volume / 100;
|
|
||||||
|
|
||||||
|
// Audio
|
||||||
AudioBackend audioBackend = (AudioBackend)AudioBackend;
|
AudioBackend audioBackend = (AudioBackend)AudioBackend;
|
||||||
if (audioBackend != config.System.AudioBackend.Value)
|
if (audioBackend != config.System.AudioBackend.Value)
|
||||||
{
|
{
|
||||||
@@ -458,7 +461,23 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
Logger.Info?.Print(LogClass.Application, $"AudioBackend toggled to: {audioBackend}");
|
Logger.Info?.Print(LogClass.Application, $"AudioBackend toggled to: {audioBackend}");
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Hid.Hotkeys.Value = KeyboardHotkeys;
|
config.System.AudioVolume.Value = Volume / 100;
|
||||||
|
|
||||||
|
// Network
|
||||||
|
config.System.EnableInternetAccess.Value = EnableInternetAccess;
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
config.Logger.EnableFileLog.Value = EnableFileLog;
|
||||||
|
config.Logger.EnableStub.Value = EnableStub;
|
||||||
|
config.Logger.EnableInfo.Value = EnableInfo;
|
||||||
|
config.Logger.EnableWarn.Value = EnableWarn;
|
||||||
|
config.Logger.EnableError.Value = EnableError;
|
||||||
|
config.Logger.EnableTrace.Value = EnableTrace;
|
||||||
|
config.Logger.EnableGuest.Value = EnableGuest;
|
||||||
|
config.Logger.EnableDebug.Value = EnableDebug;
|
||||||
|
config.Logger.EnableFsAccessLog.Value = EnableFsAccessLog;
|
||||||
|
config.System.FsGlobalAccessLogMode.Value = FsGlobalAccessLogMode;
|
||||||
|
config.Logger.GraphicsDebugLevel.Value = (GraphicsDebugLevel)OpenglDebugLevel;
|
||||||
|
|
||||||
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
||||||
|
|
||||||
|
230
Ryujinx.Ava/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs
Normal file
230
Ryujinx.Ava/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
using Avalonia.Media;
|
||||||
|
using LibHac.Common;
|
||||||
|
using LibHac.Fs;
|
||||||
|
using LibHac.Fs.Fsa;
|
||||||
|
using LibHac.FsSystem;
|
||||||
|
using LibHac.Ncm;
|
||||||
|
using LibHac.Tools.Fs;
|
||||||
|
using LibHac.Tools.FsSystem;
|
||||||
|
using LibHac.Tools.FsSystem.NcaUtils;
|
||||||
|
using Ryujinx.Ava.UI.Models;
|
||||||
|
using Ryujinx.HLE.FileSystem;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using System;
|
||||||
|
using System.Buffers.Binary;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
using Color = Avalonia.Media.Color;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
{
|
||||||
|
internal class UserFirmwareAvatarSelectorViewModel : BaseModel
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<string, byte[]> _avatarStore = new();
|
||||||
|
|
||||||
|
private ObservableCollection<ProfileImageModel> _images;
|
||||||
|
private Color _backgroundColor = Colors.White;
|
||||||
|
|
||||||
|
private int _selectedIndex;
|
||||||
|
private byte[] _selectedImage;
|
||||||
|
|
||||||
|
public UserFirmwareAvatarSelectorViewModel()
|
||||||
|
{
|
||||||
|
_images = new ObservableCollection<ProfileImageModel>();
|
||||||
|
|
||||||
|
LoadImagesFromStore();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color BackgroundColor
|
||||||
|
{
|
||||||
|
get => _backgroundColor;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_backgroundColor = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
ChangeImageBackground();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<ProfileImageModel> Images
|
||||||
|
{
|
||||||
|
get => _images;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_images = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SelectedIndex
|
||||||
|
{
|
||||||
|
get => _selectedIndex;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_selectedIndex = value;
|
||||||
|
|
||||||
|
if (_selectedIndex == -1)
|
||||||
|
{
|
||||||
|
SelectedImage = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelectedImage = _images[_selectedIndex].Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] SelectedImage
|
||||||
|
{
|
||||||
|
get => _selectedImage;
|
||||||
|
private set => _selectedImage = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadImagesFromStore()
|
||||||
|
{
|
||||||
|
Images.Clear();
|
||||||
|
|
||||||
|
foreach (var image in _avatarStore)
|
||||||
|
{
|
||||||
|
Images.Add(new ProfileImageModel(image.Key, image.Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeImageBackground()
|
||||||
|
{
|
||||||
|
foreach (var image in Images)
|
||||||
|
{
|
||||||
|
image.BackgroundColor = new SolidColorBrush(BackgroundColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PreloadAvatars(ContentManager contentManager, VirtualFileSystem virtualFileSystem)
|
||||||
|
{
|
||||||
|
if (_avatarStore.Count > 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string contentPath = contentManager.GetInstalledContentPath(0x010000000000080A, StorageId.BuiltInSystem, NcaContentType.Data);
|
||||||
|
string avatarPath = virtualFileSystem.SwitchPathToSystemPath(contentPath);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(avatarPath))
|
||||||
|
{
|
||||||
|
using (IStorage ncaFileStream = new LocalStorage(avatarPath, FileAccess.Read, FileMode.Open))
|
||||||
|
{
|
||||||
|
Nca nca = new(virtualFileSystem.KeySet, ncaFileStream);
|
||||||
|
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
|
||||||
|
|
||||||
|
foreach (DirectoryEntryEx item in romfs.EnumerateEntries())
|
||||||
|
{
|
||||||
|
// TODO: Parse DatabaseInfo.bin and table.bin files for more accuracy.
|
||||||
|
if (item.Type == DirectoryEntryType.File && item.FullPath.Contains("chara") && item.FullPath.Contains("szs"))
|
||||||
|
{
|
||||||
|
using var file = new UniqueRef<IFile>();
|
||||||
|
|
||||||
|
romfs.OpenFile(ref file.Ref(), ("/" + item.FullPath).ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||||
|
|
||||||
|
using (MemoryStream stream = new())
|
||||||
|
using (MemoryStream streamPng = new())
|
||||||
|
{
|
||||||
|
file.Get.AsStream().CopyTo(stream);
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
Image avatarImage = Image.LoadPixelData<Rgba32>(DecompressYaz0(stream), 256, 256);
|
||||||
|
|
||||||
|
avatarImage.SaveAsPng(streamPng);
|
||||||
|
|
||||||
|
_avatarStore.Add(item.FullPath, streamPng.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] DecompressYaz0(Stream stream)
|
||||||
|
{
|
||||||
|
using (BinaryReader reader = new(stream))
|
||||||
|
{
|
||||||
|
reader.ReadInt32(); // Magic
|
||||||
|
|
||||||
|
uint decodedLength = BinaryPrimitives.ReverseEndianness(reader.ReadUInt32());
|
||||||
|
|
||||||
|
reader.ReadInt64(); // Padding
|
||||||
|
|
||||||
|
byte[] input = new byte[stream.Length - stream.Position];
|
||||||
|
stream.Read(input, 0, input.Length);
|
||||||
|
|
||||||
|
uint inputOffset = 0;
|
||||||
|
|
||||||
|
byte[] output = new byte[decodedLength];
|
||||||
|
uint outputOffset = 0;
|
||||||
|
|
||||||
|
ushort mask = 0;
|
||||||
|
byte header = 0;
|
||||||
|
|
||||||
|
while (outputOffset < decodedLength)
|
||||||
|
{
|
||||||
|
if ((mask >>= 1) == 0)
|
||||||
|
{
|
||||||
|
header = input[inputOffset++];
|
||||||
|
mask = 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((header & mask) != 0)
|
||||||
|
{
|
||||||
|
if (outputOffset == output.Length)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
output[outputOffset++] = input[inputOffset++];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte byte1 = input[inputOffset++];
|
||||||
|
byte byte2 = input[inputOffset++];
|
||||||
|
|
||||||
|
uint dist = (uint)((byte1 & 0xF) << 8) | byte2;
|
||||||
|
uint position = outputOffset - (dist + 1);
|
||||||
|
|
||||||
|
uint length = (uint)byte1 >> 4;
|
||||||
|
if (length == 0)
|
||||||
|
{
|
||||||
|
length = (uint)input[inputOffset++] + 0x12;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
length += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint gap = outputOffset - position;
|
||||||
|
uint nonOverlappingLength = length;
|
||||||
|
|
||||||
|
if (nonOverlappingLength > gap)
|
||||||
|
{
|
||||||
|
nonOverlappingLength = gap;
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer.BlockCopy(output, (int)position, output, (int)outputOffset, (int)nonOverlappingLength);
|
||||||
|
outputOffset += nonOverlappingLength;
|
||||||
|
position += nonOverlappingLength;
|
||||||
|
length -= nonOverlappingLength;
|
||||||
|
|
||||||
|
while (length-- > 0)
|
||||||
|
{
|
||||||
|
output[outputOffset++] = output[position++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,18 @@
|
|||||||
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
{
|
||||||
|
internal class UserProfileImageSelectorViewModel : BaseModel
|
||||||
|
{
|
||||||
|
private bool _firmwareFound;
|
||||||
|
|
||||||
|
public bool FirmwareFound
|
||||||
|
{
|
||||||
|
get => _firmwareFound;
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_firmwareFound = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,215 +1,25 @@
|
|||||||
using Avalonia;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Avalonia.Threading;
|
|
||||||
using FluentAvalonia.UI.Controls;
|
|
||||||
using LibHac.Common;
|
|
||||||
using LibHac.Fs;
|
|
||||||
using LibHac.Fs.Shim;
|
|
||||||
using Ryujinx.Ava.Common.Locale;
|
|
||||||
using Ryujinx.Ava.UI.Controls;
|
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
|
||||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
|
||||||
using UserId = Ryujinx.HLE.HOS.Services.Account.Acc.UserId;
|
|
||||||
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.ViewModels
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
public class UserProfileViewModel : BaseModel, IDisposable
|
public class UserProfileViewModel : BaseModel, IDisposable
|
||||||
{
|
{
|
||||||
private readonly NavigationDialogHost _owner;
|
|
||||||
|
|
||||||
private UserProfile _selectedProfile;
|
|
||||||
private UserProfile _highlightedProfile;
|
|
||||||
|
|
||||||
public UserProfileViewModel()
|
public UserProfileViewModel()
|
||||||
{
|
{
|
||||||
Profiles = new ObservableCollection<UserProfile>();
|
Profiles = new ObservableCollection<BaseModel>();
|
||||||
LostProfiles = new ObservableCollection<UserProfile>();
|
LostProfiles = new ObservableCollection<UserProfile>();
|
||||||
|
IsEmpty = LostProfiles.IsNullOrEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserProfileViewModel(NavigationDialogHost owner) : this()
|
public ObservableCollection<BaseModel> Profiles { get; set; }
|
||||||
{
|
|
||||||
_owner = owner;
|
|
||||||
|
|
||||||
LoadProfiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObservableCollection<UserProfile> Profiles { get; set; }
|
|
||||||
|
|
||||||
public ObservableCollection<UserProfile> LostProfiles { get; set; }
|
public ObservableCollection<UserProfile> LostProfiles { get; set; }
|
||||||
|
|
||||||
public UserProfile SelectedProfile
|
public bool IsEmpty { get; set; }
|
||||||
{
|
|
||||||
get => _selectedProfile;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_selectedProfile = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
OnPropertyChanged(nameof(IsHighlightedProfileDeletable));
|
|
||||||
OnPropertyChanged(nameof(IsHighlightedProfileEditable));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsHighlightedProfileEditable => _highlightedProfile != null;
|
|
||||||
|
|
||||||
public bool IsHighlightedProfileDeletable => _highlightedProfile != null && _highlightedProfile.UserId != AccountManager.DefaultUserId;
|
|
||||||
|
|
||||||
public UserProfile HighlightedProfile
|
|
||||||
{
|
|
||||||
get => _highlightedProfile;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_highlightedProfile = value;
|
|
||||||
|
|
||||||
OnPropertyChanged();
|
|
||||||
OnPropertyChanged(nameof(IsHighlightedProfileDeletable));
|
|
||||||
OnPropertyChanged(nameof(IsHighlightedProfileEditable));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
|
|
||||||
public void LoadProfiles()
|
|
||||||
{
|
|
||||||
Profiles.Clear();
|
|
||||||
LostProfiles.Clear();
|
|
||||||
|
|
||||||
var profiles = _owner.AccountManager.GetAllUsers().OrderByDescending(x => x.AccountState == AccountState.Open);
|
|
||||||
|
|
||||||
foreach (var profile in profiles)
|
|
||||||
{
|
|
||||||
Profiles.Add(new UserProfile(profile, _owner));
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectedProfile = Profiles.FirstOrDefault(x => x.UserId == _owner.AccountManager.LastOpenedUser.UserId);
|
|
||||||
|
|
||||||
if (SelectedProfile == null)
|
|
||||||
{
|
|
||||||
SelectedProfile = Profiles.First();
|
|
||||||
|
|
||||||
if (SelectedProfile != null)
|
|
||||||
{
|
|
||||||
_owner.AccountManager.OpenUser(_selectedProfile.UserId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var saveDataFilter = SaveDataFilter.Make(programId: default, saveType: SaveDataType.Account,
|
|
||||||
default, saveDataId: default, index: default);
|
|
||||||
|
|
||||||
using var saveDataIterator = new UniqueRef<SaveDataIterator>();
|
|
||||||
|
|
||||||
_owner.HorizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref(), SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
|
|
||||||
|
|
||||||
Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
|
|
||||||
|
|
||||||
HashSet<UserId> lostAccounts = new HashSet<UserId>();
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
saveDataIterator.Get.ReadSaveDataInfo(out long readCount, saveDataInfo).ThrowIfFailure();
|
|
||||||
|
|
||||||
if (readCount == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < readCount; i++)
|
|
||||||
{
|
|
||||||
var save = saveDataInfo[i];
|
|
||||||
var id = new UserId((long)save.UserId.Id.Low, (long)save.UserId.Id.High);
|
|
||||||
if (Profiles.FirstOrDefault( x=> x.UserId == id) == null)
|
|
||||||
{
|
|
||||||
lostAccounts.Add(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(var account in lostAccounts)
|
|
||||||
{
|
|
||||||
LostProfiles.Add(new UserProfile(new HLE.HOS.Services.Account.Acc.UserProfile(account, "", null), _owner));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddUser()
|
|
||||||
{
|
|
||||||
UserProfile userProfile = null;
|
|
||||||
|
|
||||||
_owner.Navigate(typeof(UserEditor), (this._owner, userProfile, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void ManageSaves()
|
|
||||||
{
|
|
||||||
UserProfile userProfile = _highlightedProfile ?? SelectedProfile;
|
|
||||||
|
|
||||||
SaveManager manager = new SaveManager(userProfile, _owner.HorizonClient, _owner.VirtualFileSystem);
|
|
||||||
|
|
||||||
ContentDialog contentDialog = new ContentDialog
|
|
||||||
{
|
|
||||||
Title = string.Format(LocaleManager.Instance[LocaleKeys.SaveManagerHeading], userProfile.Name),
|
|
||||||
PrimaryButtonText = "",
|
|
||||||
SecondaryButtonText = "",
|
|
||||||
CloseButtonText = LocaleManager.Instance[LocaleKeys.UserProfilesClose],
|
|
||||||
Content = manager,
|
|
||||||
Padding = new Thickness(0)
|
|
||||||
};
|
|
||||||
|
|
||||||
await contentDialog.ShowAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EditUser()
|
|
||||||
{
|
|
||||||
_owner.Navigate(typeof(UserEditor), (this._owner, _highlightedProfile ?? SelectedProfile, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void DeleteUser()
|
|
||||||
{
|
|
||||||
if (_highlightedProfile != null)
|
|
||||||
{
|
|
||||||
var lastUserId = _owner.AccountManager.LastOpenedUser.UserId;
|
|
||||||
|
|
||||||
if (_highlightedProfile.UserId == lastUserId)
|
|
||||||
{
|
|
||||||
// If we are deleting the currently open profile, then we must open something else before deleting.
|
|
||||||
var profile = Profiles.FirstOrDefault(x => x.UserId != lastUserId);
|
|
||||||
|
|
||||||
if (profile == null)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(async () =>
|
|
||||||
{
|
|
||||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUserProfileDeletionWarningMessage]);
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_owner.AccountManager.OpenUser(profile.UserId);
|
|
||||||
}
|
|
||||||
|
|
||||||
var result =
|
|
||||||
await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogUserProfileDeletionConfirmMessage], "",
|
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogYes], LocaleManager.Instance[LocaleKeys.InputDialogNo], "");
|
|
||||||
|
|
||||||
if (result == UserResult.Yes)
|
|
||||||
{
|
|
||||||
_owner.AccountManager.DeleteUser(_highlightedProfile.UserId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadProfiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GoBack()
|
|
||||||
{
|
|
||||||
_owner.GoBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RecoverLostAccounts()
|
|
||||||
{
|
|
||||||
_owner.Navigate(typeof(UserRecoverer), (this._owner, this));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
121
Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs
Normal file
121
Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
using DynamicData;
|
||||||
|
using DynamicData.Binding;
|
||||||
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Models;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
{
|
||||||
|
public class UserSaveManagerViewModel : BaseModel
|
||||||
|
{
|
||||||
|
private int _sortIndex;
|
||||||
|
private int _orderIndex;
|
||||||
|
private string _search;
|
||||||
|
private ObservableCollection<SaveModel> _saves = new();
|
||||||
|
private ObservableCollection<SaveModel> _views = new();
|
||||||
|
private AccountManager _accountManager;
|
||||||
|
|
||||||
|
public string SaveManagerHeading =>
|
||||||
|
string.Format(LocaleManager.Instance[LocaleKeys.SaveManagerHeading], _accountManager.LastOpenedUser.Name, _accountManager.LastOpenedUser.UserId);
|
||||||
|
|
||||||
|
public int SortIndex
|
||||||
|
{
|
||||||
|
get => _sortIndex;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_sortIndex = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
Sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int OrderIndex
|
||||||
|
{
|
||||||
|
get => _orderIndex;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_orderIndex = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
Sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Search
|
||||||
|
{
|
||||||
|
get => _search;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_search = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
Sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<SaveModel> Saves
|
||||||
|
{
|
||||||
|
get => _saves;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_saves = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
Sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<SaveModel> Views
|
||||||
|
{
|
||||||
|
get => _views;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_views = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserSaveManagerViewModel(AccountManager accountManager)
|
||||||
|
{
|
||||||
|
_accountManager = accountManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Sort()
|
||||||
|
{
|
||||||
|
Saves.AsObservableChangeSet()
|
||||||
|
.Filter(Filter)
|
||||||
|
.Sort(GetComparer())
|
||||||
|
.Bind(out var view).AsObservableList();
|
||||||
|
|
||||||
|
_views.Clear();
|
||||||
|
_views.AddRange(view);
|
||||||
|
OnPropertyChanged(nameof(Views));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Filter(object arg)
|
||||||
|
{
|
||||||
|
if (arg is SaveModel save)
|
||||||
|
{
|
||||||
|
return string.IsNullOrWhiteSpace(_search) || save.Title.ToLower().Contains(_search.ToLower());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IComparer<SaveModel> GetComparer()
|
||||||
|
{
|
||||||
|
switch (SortIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return OrderIndex == 0
|
||||||
|
? SortExpressionComparer<SaveModel>.Ascending(save => save.Title)
|
||||||
|
: SortExpressionComparer<SaveModel>.Descending(save => save.Title);
|
||||||
|
case 1:
|
||||||
|
return OrderIndex == 0
|
||||||
|
? SortExpressionComparer<SaveModel>.Ascending(save => save.Size)
|
||||||
|
: SortExpressionComparer<SaveModel>.Descending(save => save.Size);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -74,7 +74,6 @@
|
|||||||
Margin="5,0,5,0"
|
Margin="5,0,5,0"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
VerticalContentAlignment="Center"
|
|
||||||
DockPanel.Dock="Right"
|
DockPanel.Dock="Right"
|
||||||
KeyUp="SearchBox_OnKeyUp"
|
KeyUp="SearchBox_OnKeyUp"
|
||||||
Text="{Binding SearchText}"
|
Text="{Binding SearchText}"
|
||||||
|
@@ -82,9 +82,6 @@
|
|||||||
Width="350"
|
Width="350"
|
||||||
HorizontalContentAlignment="Left"
|
HorizontalContentAlignment="Left"
|
||||||
ToolTip.Tip="{locale:Locale ResolutionScaleTooltip}">
|
ToolTip.Tip="{locale:Locale ResolutionScaleTooltip}">
|
||||||
<ComboBoxItem>
|
|
||||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsResolutionScaleCustom}" />
|
|
||||||
</ComboBoxItem>
|
|
||||||
<ComboBoxItem>
|
<ComboBoxItem>
|
||||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsResolutionScaleNative}" />
|
<TextBlock Text="{locale:Locale SettingsTabGraphicsResolutionScaleNative}" />
|
||||||
</ComboBoxItem>
|
</ComboBoxItem>
|
||||||
@@ -97,6 +94,9 @@
|
|||||||
<ComboBoxItem>
|
<ComboBoxItem>
|
||||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsResolutionScale4x}" />
|
<TextBlock Text="{locale:Locale SettingsTabGraphicsResolutionScale4x}" />
|
||||||
</ComboBoxItem>
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{locale:Locale SettingsTabGraphicsResolutionScaleCustom}" />
|
||||||
|
</ComboBoxItem>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
<ui:NumberBox
|
<ui:NumberBox
|
||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
|
@@ -47,31 +47,34 @@
|
|||||||
ToolTip.Tip="{locale:Locale ErrorLogTooltip}">
|
ToolTip.Tip="{locale:Locale ErrorLogTooltip}">
|
||||||
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableErrorLogs}" />
|
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableErrorLogs}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox IsChecked="{Binding EnableTrace}"
|
|
||||||
ToolTip.Tip="{locale:Locale TraceLogTooltip}">
|
|
||||||
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableTraceLogs}" />
|
|
||||||
</CheckBox>
|
|
||||||
<CheckBox IsChecked="{Binding EnableGuest}"
|
<CheckBox IsChecked="{Binding EnableGuest}"
|
||||||
ToolTip.Tip="{locale:Locale GuestLogTooltip}">
|
ToolTip.Tip="{locale:Locale GuestLogTooltip}">
|
||||||
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableGuestLogs}" />
|
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableGuestLogs}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Separator Height="1" />
|
<Separator Height="1" />
|
||||||
|
<StackPanel Orientation="Vertical" Spacing="2">
|
||||||
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabLoggingDeveloperOptions}" />
|
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabLoggingDeveloperOptions}" />
|
||||||
|
<TextBlock Foreground="{DynamicResource SecondaryTextColor}" Text="{locale:Locale SettingsTabLoggingDeveloperOptionsNote}" />
|
||||||
|
</StackPanel>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
Spacing="10">
|
Spacing="10">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<CheckBox IsChecked="{Binding EnableDebug}"
|
<CheckBox IsChecked="{Binding EnableTrace}"
|
||||||
ToolTip.Tip="{locale:Locale DebugLogTooltip}">
|
ToolTip.Tip="{locale:Locale TraceLogTooltip}">
|
||||||
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableDebugLogs}" />
|
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableTraceLogs}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox IsChecked="{Binding EnableFsAccessLog}"
|
<CheckBox IsChecked="{Binding EnableFsAccessLog}"
|
||||||
ToolTip.Tip="{locale:Locale FileAccessLogTooltip}">
|
ToolTip.Tip="{locale:Locale FileAccessLogTooltip}">
|
||||||
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableFsAccessLogs}" />
|
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableFsAccessLogs}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<CheckBox IsChecked="{Binding EnableDebug}"
|
||||||
|
ToolTip.Tip="{locale:Locale DebugLogTooltip}">
|
||||||
|
<TextBlock Text="{locale:Locale SettingsTabLoggingEnableDebugLogs}" />
|
||||||
|
</CheckBox>
|
||||||
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" VerticalAlignment="Stretch">
|
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" VerticalAlignment="Stretch">
|
||||||
<TextBlock VerticalAlignment="Center"
|
<TextBlock VerticalAlignment="Center"
|
||||||
ToolTip.Tip="{locale:Locale FSAccessLogModeTooltip}"
|
ToolTip.Tip="{locale:Locale FSAccessLogModeTooltip}"
|
||||||
|
@@ -172,9 +172,9 @@
|
|||||||
</CheckBox>
|
</CheckBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Separator Height="1" />
|
<Separator Height="1" />
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Vertical" Spacing="2">
|
||||||
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabSystemHacks}" />
|
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabSystemHacks}" />
|
||||||
<TextBlock Text="{locale:Locale SettingsTabSystemHacksNote}" />
|
<TextBlock Foreground="{DynamicResource SecondaryTextColor}" Text="{locale:Locale SettingsTabSystemHacksNote}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
|
@@ -1,16 +1,20 @@
|
|||||||
<UserControl
|
<UserControl
|
||||||
x:Class="Ryujinx.Ava.UI.Controls.UserEditor"
|
x:Class="Ryujinx.Ava.UI.Views.User.UserEditorView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
|
xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
|
||||||
Margin="0"
|
Margin="0"
|
||||||
MinWidth="500"
|
MinWidth="500"
|
||||||
Padding="0"
|
Padding="0"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Focusable="True">
|
Focusable="True"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
x:DataType="models:TempProfile">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
@@ -23,35 +27,9 @@
|
|||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
Orientation="Vertical">
|
|
||||||
<Image
|
|
||||||
Name="ProfileImage"
|
|
||||||
Width="96"
|
|
||||||
Height="96"
|
|
||||||
Margin="0"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
|
||||||
<Button
|
|
||||||
Name="ChangePictureButton"
|
|
||||||
Margin="5"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Click="ChangePictureButton_Click"
|
|
||||||
Content="{locale:Locale UserProfilesChangeProfileImage}" />
|
|
||||||
<Button
|
|
||||||
Name="AddPictureButton"
|
|
||||||
Margin="5"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Click="ChangePictureButton_Click"
|
|
||||||
Content="{locale:Locale UserProfilesSetProfileImage}" />
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="0"
|
||||||
Margin="5,10"
|
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
Spacing="10">
|
Spacing="10">
|
||||||
@@ -61,9 +39,60 @@
|
|||||||
Width="300"
|
Width="300"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
MaxLength="{Binding MaxProfileNameLength}"
|
MaxLength="{Binding MaxProfileNameLength}"
|
||||||
|
Watermark="{locale:Locale ProfileNameSelectionWatermark}"
|
||||||
Text="{Binding Name}" />
|
Text="{Binding Name}" />
|
||||||
<TextBlock Name="IdText" Text="{locale:Locale UserProfilesUserId}" />
|
<TextBlock Name="IdText" Text="{locale:Locale UserProfilesUserId}" />
|
||||||
<TextBlock Name="IdLabel" Text="{Binding UserId}" />
|
<TextBox
|
||||||
|
Name="IdLabel"
|
||||||
|
Width="300"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Text="{Binding UserIdString}" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Orientation="Vertical">
|
||||||
|
<Border
|
||||||
|
BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
|
||||||
|
BorderThickness="1">
|
||||||
|
<Panel>
|
||||||
|
<ui:SymbolIcon
|
||||||
|
FontSize="60"
|
||||||
|
Width="96"
|
||||||
|
Height="96"
|
||||||
|
Margin="0"
|
||||||
|
Foreground="{DynamicResource AppListHoverBackgroundColor}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Symbol="Camera" />
|
||||||
|
<Image
|
||||||
|
Name="ProfileImage"
|
||||||
|
Width="96"
|
||||||
|
Height="96"
|
||||||
|
Margin="0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
||||||
|
</Panel>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Margin="0 24 0 0"
|
||||||
|
Spacing="10">
|
||||||
|
<Button
|
||||||
|
Width="50"
|
||||||
|
MinWidth="50"
|
||||||
|
Click="BackButton_Click">
|
||||||
|
<ui:SymbolIcon Symbol="Back" />
|
||||||
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
@@ -71,16 +100,24 @@
|
|||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
|
Margin="0 24 0 0"
|
||||||
Spacing="10">
|
Spacing="10">
|
||||||
|
<Button
|
||||||
|
Name="DeleteButton"
|
||||||
|
Click="DeleteButton_Click"
|
||||||
|
Content="{locale:Locale UserProfilesDelete}" />
|
||||||
|
<Button
|
||||||
|
Name="ChangePictureButton"
|
||||||
|
Click="ChangePictureButton_Click"
|
||||||
|
Content="{locale:Locale UserProfilesChangeProfileImage}" />
|
||||||
|
<Button
|
||||||
|
Name="AddPictureButton"
|
||||||
|
Click="ChangePictureButton_Click"
|
||||||
|
Content="{locale:Locale UserProfilesSetProfileImage}" />
|
||||||
<Button
|
<Button
|
||||||
Name="SaveButton"
|
Name="SaveButton"
|
||||||
Click="SaveButton_Click"
|
Click="SaveButton_Click"
|
||||||
Content="{locale:Locale Save}" />
|
Content="{locale:Locale Save}" />
|
||||||
<Button
|
|
||||||
Name="CloseButton"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Click="CloseButton_Click"
|
|
||||||
Content="{locale:Locale Discard}" />
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@@ -4,13 +4,16 @@ using Avalonia.Interactivity;
|
|||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using FluentAvalonia.UI.Navigation;
|
using FluentAvalonia.UI.Navigation;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Controls;
|
||||||
using Ryujinx.Ava.UI.Models;
|
using Ryujinx.Ava.UI.Models;
|
||||||
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
|
using System;
|
||||||
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
namespace Ryujinx.Ava.UI.Views.User
|
||||||
{
|
{
|
||||||
public partial class UserEditor : UserControl
|
public partial class UserEditorView : UserControl
|
||||||
{
|
{
|
||||||
private NavigationDialogHost _parent;
|
private NavigationDialogHost _parent;
|
||||||
private UserProfile _profile;
|
private UserProfile _profile;
|
||||||
@@ -18,8 +21,9 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
|
|
||||||
public TempProfile TempProfile { get; set; }
|
public TempProfile TempProfile { get; set; }
|
||||||
public uint MaxProfileNameLength => 0x20;
|
public uint MaxProfileNameLength => 0x20;
|
||||||
|
public bool IsDeletable => _profile.UserId != AccountManager.DefaultUserId;
|
||||||
|
|
||||||
public UserEditor()
|
public UserEditorView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
||||||
@@ -44,41 +48,84 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - " +
|
||||||
|
$"{ (_isNewUser ? LocaleManager.Instance[LocaleKeys.UserEditorTitleCreate] : LocaleManager.Instance[LocaleKeys.UserEditorTitle])}";
|
||||||
|
|
||||||
DataContext = TempProfile;
|
DataContext = TempProfile;
|
||||||
|
|
||||||
AddPictureButton.IsVisible = _isNewUser;
|
AddPictureButton.IsVisible = _isNewUser;
|
||||||
|
ChangePictureButton.IsVisible = !_isNewUser;
|
||||||
IdLabel.IsVisible = _profile != null;
|
IdLabel.IsVisible = _profile != null;
|
||||||
IdText.IsVisible = _profile != null;
|
IdText.IsVisible = _profile != null;
|
||||||
ChangePictureButton.IsVisible = !_isNewUser;
|
if (!_isNewUser && IsDeletable)
|
||||||
|
{
|
||||||
|
DeleteButton.IsVisible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeleteButton.IsVisible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
private async void BackButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (_isNewUser)
|
||||||
|
{
|
||||||
|
if (TempProfile.Name != String.Empty || TempProfile.Image != null)
|
||||||
|
{
|
||||||
|
if (await ContentDialogHelper.CreateChoiceDialog(
|
||||||
|
LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesTitle],
|
||||||
|
LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesMessage],
|
||||||
|
LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesSubMessage]))
|
||||||
{
|
{
|
||||||
_parent?.GoBack();
|
_parent?.GoBack();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_parent?.GoBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_profile.Name != TempProfile.Name || _profile.Image != TempProfile.Image)
|
||||||
|
{
|
||||||
|
if (await ContentDialogHelper.CreateChoiceDialog(
|
||||||
|
LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesTitle],
|
||||||
|
LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesMessage],
|
||||||
|
LocaleManager.Instance[LocaleKeys.DialogUserProfileUnsavedChangesSubMessage]))
|
||||||
|
{
|
||||||
|
_parent?.GoBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_parent?.GoBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async void SaveButton_Click(object sender, RoutedEventArgs e)
|
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_parent.DeleteUser(_profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
DataValidationErrors.ClearErrors(NameBox);
|
DataValidationErrors.ClearErrors(NameBox);
|
||||||
bool isInvalid = false;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(TempProfile.Name))
|
if (string.IsNullOrWhiteSpace(TempProfile.Name))
|
||||||
{
|
{
|
||||||
DataValidationErrors.SetError(NameBox, new DataValidationException(LocaleManager.Instance[LocaleKeys.UserProfileEmptyNameError]));
|
DataValidationErrors.SetError(NameBox, new DataValidationException(LocaleManager.Instance[LocaleKeys.UserProfileEmptyNameError]));
|
||||||
|
|
||||||
isInvalid = true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TempProfile.Image == null)
|
if (TempProfile.Image == null)
|
||||||
{
|
{
|
||||||
await ContentDialogHelper.CreateWarningDialog(LocaleManager.Instance[LocaleKeys.UserProfileNoImageError], "");
|
_parent.Navigate(typeof(UserProfileImageSelectorView), (_parent, TempProfile));
|
||||||
|
|
||||||
isInvalid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isInvalid)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +151,7 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
|
|
||||||
public void SelectProfileImage()
|
public void SelectProfileImage()
|
||||||
{
|
{
|
||||||
_parent.Navigate(typeof(ProfileImageSelectionDialog), (_parent, TempProfile));
|
_parent.Navigate(typeof(UserProfileImageSelectorView), (_parent, TempProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangePictureButton_Click(object sender, RoutedEventArgs e)
|
private void ChangePictureButton_Click(object sender, RoutedEventArgs e)
|
114
Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml
Normal file
114
Ryujinx.Ava/UI/Views/User/UserFirmwareAvatarSelectorView.axaml
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<UserControl
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Width="528"
|
||||||
|
d:DesignWidth="578"
|
||||||
|
d:DesignHeight="350"
|
||||||
|
x:Class="Ryujinx.Ava.UI.Views.User.UserFirmwareAvatarSelectorView"
|
||||||
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||||
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
x:DataType="viewModels:UserFirmwareAvatarSelectorViewModel"
|
||||||
|
Focusable="True">
|
||||||
|
<Design.DataContext>
|
||||||
|
<viewModels:UserFirmwareAvatarSelectorViewModel />
|
||||||
|
</Design.DataContext>
|
||||||
|
<UserControl.Resources>
|
||||||
|
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
|
</UserControl.Resources>
|
||||||
|
<Grid
|
||||||
|
Margin="0"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<ListBox
|
||||||
|
Grid.Row="1"
|
||||||
|
BorderThickness="0"
|
||||||
|
SelectedIndex="{Binding SelectedIndex}"
|
||||||
|
Height="400"
|
||||||
|
Items="{Binding Images}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<ListBox.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<WrapPanel
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Margin="0"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ListBox.ItemsPanel>
|
||||||
|
<ListBox.Styles>
|
||||||
|
<Style Selector="ListBoxItem">
|
||||||
|
<Setter Property="CornerRadius" Value="4" />
|
||||||
|
<Setter Property="Width" Value="85" />
|
||||||
|
<Setter Property="MaxWidth" Value="85" />
|
||||||
|
<Setter Property="MinWidth" Value="85" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBoxItem /template/ Border#SelectionIndicator">
|
||||||
|
<Setter Property="MinHeight" Value="70" />
|
||||||
|
</Style>
|
||||||
|
</ListBox.Styles>
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Panel
|
||||||
|
Background="{Binding BackgroundColor}"
|
||||||
|
Margin="5">
|
||||||
|
<Image Source="{Binding Data, Converter={StaticResource ByteImage}}" />
|
||||||
|
</Panel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="3"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Spacing="10"
|
||||||
|
Margin="0 24 0 0"
|
||||||
|
HorizontalAlignment="Left">
|
||||||
|
<Button
|
||||||
|
Width="50"
|
||||||
|
MinWidth="50"
|
||||||
|
Height="35"
|
||||||
|
Click="GoBack">
|
||||||
|
<ui:SymbolIcon Symbol="Back" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="3"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Spacing="10"
|
||||||
|
Margin="0 24 0 0"
|
||||||
|
HorizontalAlignment="Right">
|
||||||
|
<ui:ColorPickerButton
|
||||||
|
FlyoutPlacement="Top"
|
||||||
|
IsMoreButtonVisible="False"
|
||||||
|
UseColorPalette="False"
|
||||||
|
UseColorTriangle="False"
|
||||||
|
UseColorWheel="False"
|
||||||
|
ShowAcceptDismissButtons="False"
|
||||||
|
IsAlphaEnabled="False"
|
||||||
|
Color="{Binding BackgroundColor, Mode=TwoWay}"
|
||||||
|
Name="ColorButton">
|
||||||
|
<ui:ColorPickerButton.Styles>
|
||||||
|
<Style Selector="Grid#Root > DockPanel > Grid">
|
||||||
|
<Setter Property="IsVisible" Value="False" />
|
||||||
|
</Style>
|
||||||
|
</ui:ColorPickerButton.Styles>
|
||||||
|
</ui:ColorPickerButton>
|
||||||
|
<Button
|
||||||
|
Content="{locale:Locale AvatarChoose}"
|
||||||
|
Height="35"
|
||||||
|
Name="ChooseButton"
|
||||||
|
Click="ChooseButton_OnClick" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
@@ -6,15 +6,20 @@ using Ryujinx.Ava.UI.Controls;
|
|||||||
using Ryujinx.Ava.UI.Models;
|
using Ryujinx.Ava.UI.Models;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.Formats.Png;
|
||||||
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Windows
|
namespace Ryujinx.Ava.UI.Views.User
|
||||||
{
|
{
|
||||||
public partial class AvatarWindow : UserControl
|
public partial class UserFirmwareAvatarSelectorView : UserControl
|
||||||
{
|
{
|
||||||
private NavigationDialogHost _parent;
|
private NavigationDialogHost _parent;
|
||||||
private TempProfile _profile;
|
private TempProfile _profile;
|
||||||
|
|
||||||
public AvatarWindow(ContentManager contentManager)
|
public UserFirmwareAvatarSelectorView(ContentManager contentManager)
|
||||||
{
|
{
|
||||||
ContentManager = contentManager;
|
ContentManager = contentManager;
|
||||||
|
|
||||||
@@ -23,7 +28,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AvatarWindow()
|
public UserFirmwareAvatarSelectorView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
@@ -43,7 +48,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
ContentManager = _parent.ContentManager;
|
ContentManager = _parent.ContentManager;
|
||||||
if (Program.PreviewerDetached)
|
if (Program.PreviewerDetached)
|
||||||
{
|
{
|
||||||
ViewModel = new AvatarProfileViewModel(() => ViewModel.ReloadImages());
|
ViewModel = new UserFirmwareAvatarSelectorViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
DataContext = ViewModel;
|
DataContext = ViewModel;
|
||||||
@@ -53,22 +58,28 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
|
|
||||||
public ContentManager ContentManager { get; private set; }
|
public ContentManager ContentManager { get; private set; }
|
||||||
|
|
||||||
internal AvatarProfileViewModel ViewModel { get; set; }
|
internal UserFirmwareAvatarSelectorViewModel ViewModel { get; set; }
|
||||||
|
|
||||||
private void CloseButton_OnClick(object sender, RoutedEventArgs e)
|
private void GoBack(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel.Dispose();
|
|
||||||
|
|
||||||
_parent.GoBack();
|
_parent.GoBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChooseButton_OnClick(object sender, RoutedEventArgs e)
|
private void ChooseButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (ViewModel.SelectedIndex > -1)
|
if (ViewModel.SelectedImage != null)
|
||||||
{
|
{
|
||||||
_profile.Image = ViewModel.SelectedImage;
|
MemoryStream streamJpg = new();
|
||||||
|
SixLabors.ImageSharp.Image avatarImage = SixLabors.ImageSharp.Image.Load(ViewModel.SelectedImage, new PngDecoder());
|
||||||
|
|
||||||
ViewModel.Dispose();
|
avatarImage.Mutate(x => x.BackgroundColor(new Rgba32(
|
||||||
|
ViewModel.BackgroundColor.R,
|
||||||
|
ViewModel.BackgroundColor.G,
|
||||||
|
ViewModel.BackgroundColor.B,
|
||||||
|
ViewModel.BackgroundColor.A)));
|
||||||
|
avatarImage.SaveAsJpeg(streamJpg);
|
||||||
|
|
||||||
|
_profile.Image = streamJpg.ToArray();
|
||||||
|
|
||||||
_parent.GoBack();
|
_parent.GoBack();
|
||||||
}
|
}
|
63
Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml
Normal file
63
Ryujinx.Ava/UI/Views/User/UserProfileImageSelectorView.axaml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<UserControl
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
|
xmlns:viewModles="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||||
|
Focusable="True"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
x:Class="Ryujinx.Ava.UI.Views.User.UserProfileImageSelectorView"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
x:DataType="viewModles:UserProfileImageSelectorViewModel"
|
||||||
|
Width="500"
|
||||||
|
d:DesignWidth="500">
|
||||||
|
<Design.DataContext>
|
||||||
|
<viewModles:UserProfileImageSelectorViewModel />
|
||||||
|
</Design.DataContext>
|
||||||
|
<Grid
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="70" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
TextAlignment="Left"
|
||||||
|
Text="{locale:Locale ProfileImageSelectionNote}" />
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="2"
|
||||||
|
Spacing="10"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Width="50"
|
||||||
|
MinWidth="50"
|
||||||
|
Click="GoBack">
|
||||||
|
<ui:SymbolIcon Symbol="Back" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="2"
|
||||||
|
Spacing="10"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Name="Import"
|
||||||
|
Click="Import_OnClick">
|
||||||
|
<TextBlock Text="{locale:Locale ProfileImageSelectionImportImage}" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
Name="SelectFirmwareImage"
|
||||||
|
IsEnabled="{Binding FirmwareFound}"
|
||||||
|
Click="SelectFirmwareImage_OnClick">
|
||||||
|
<TextBlock Text="{locale:Locale ProfileImageSelectionSelectAvatar}" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
@@ -4,25 +4,26 @@ using Avalonia.VisualTree;
|
|||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using FluentAvalonia.UI.Navigation;
|
using FluentAvalonia.UI.Navigation;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Controls;
|
||||||
using Ryujinx.Ava.UI.Models;
|
using Ryujinx.Ava.UI.Models;
|
||||||
using Ryujinx.Ava.UI.Windows;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Image = SixLabors.ImageSharp.Image;
|
using Image = SixLabors.ImageSharp.Image;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Controls
|
namespace Ryujinx.Ava.UI.Views.User
|
||||||
{
|
{
|
||||||
public partial class ProfileImageSelectionDialog : UserControl
|
public partial class UserProfileImageSelectorView : UserControl
|
||||||
{
|
{
|
||||||
private ContentManager _contentManager;
|
private ContentManager _contentManager;
|
||||||
private NavigationDialogHost _parent;
|
private NavigationDialogHost _parent;
|
||||||
private TempProfile _profile;
|
private TempProfile _profile;
|
||||||
|
|
||||||
public bool FirmwareFound => _contentManager.GetCurrentFirmwareVersion() != null;
|
internal UserProfileImageSelectorViewModel ViewModel { get; private set; }
|
||||||
|
|
||||||
public ProfileImageSelectionDialog()
|
public UserProfileImageSelectorView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
||||||
@@ -40,13 +41,23 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
case NavigationMode.New:
|
case NavigationMode.New:
|
||||||
(_parent, _profile) = ((NavigationDialogHost, TempProfile))arg.Parameter;
|
(_parent, _profile) = ((NavigationDialogHost, TempProfile))arg.Parameter;
|
||||||
_contentManager = _parent.ContentManager;
|
_contentManager = _parent.ContentManager;
|
||||||
break;
|
|
||||||
case NavigationMode.Back:
|
((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - {LocaleManager.Instance[LocaleKeys.ProfileImageSelectionHeader]}";
|
||||||
_parent.GoBack();
|
|
||||||
break;
|
if (Program.PreviewerDetached)
|
||||||
|
{
|
||||||
|
DataContext = ViewModel = new UserProfileImageSelectorViewModel();
|
||||||
|
ViewModel.FirmwareFound = _contentManager.GetCurrentFirmwareVersion() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataContext = this;
|
break;
|
||||||
|
case NavigationMode.Back:
|
||||||
|
if (_profile.Image != null)
|
||||||
|
{
|
||||||
|
_parent.GoBack();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,17 +84,25 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
string imageFile = image[0];
|
string imageFile = image[0];
|
||||||
|
|
||||||
_profile.Image = ProcessProfileImage(File.ReadAllBytes(imageFile));
|
_profile.Image = ProcessProfileImage(File.ReadAllBytes(imageFile));
|
||||||
}
|
|
||||||
|
|
||||||
|
if (_profile.Image != null)
|
||||||
|
{
|
||||||
_parent.GoBack();
|
_parent.GoBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GoBack(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_parent.GoBack();
|
||||||
|
}
|
||||||
|
|
||||||
private void SelectFirmwareImage_OnClick(object sender, RoutedEventArgs e)
|
private void SelectFirmwareImage_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (FirmwareFound)
|
if (ViewModel.FirmwareFound)
|
||||||
{
|
{
|
||||||
_parent.Navigate(typeof(AvatarWindow), (_parent, _profile));
|
_parent.Navigate(typeof(UserFirmwareAvatarSelectorView), (_parent, _profile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
83
Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml
Normal file
83
Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<UserControl
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignWidth="550"
|
||||||
|
d:DesignHeight="450"
|
||||||
|
Width="500"
|
||||||
|
Height="400"
|
||||||
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||||
|
x:Class="Ryujinx.Ava.UI.Views.User.UserRecovererView"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
x:DataType="viewModels:UserProfileViewModel"
|
||||||
|
Focusable="True">
|
||||||
|
<Design.DataContext>
|
||||||
|
<viewModels:UserProfileViewModel />
|
||||||
|
</Design.DataContext>
|
||||||
|
<Grid HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Border
|
||||||
|
CornerRadius="5"
|
||||||
|
BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
|
||||||
|
BorderThickness="1"
|
||||||
|
Grid.Row="0">
|
||||||
|
<Panel>
|
||||||
|
<ListBox
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Items="{Binding LostProfiles}">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border
|
||||||
|
Margin="2"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
ClipToBounds="True"
|
||||||
|
CornerRadius="5">
|
||||||
|
<Grid Margin="0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Text="{Binding UserId}"
|
||||||
|
TextAlignment="Left"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
<Button Grid.Column="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Click="Recover"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
Content="{locale:Locale Recover}"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<TextBlock
|
||||||
|
IsVisible="{Binding IsEmpty}"
|
||||||
|
TextAlignment="Center"
|
||||||
|
Text="{locale:Locale UserProfilesRecoverEmptyList}"/>
|
||||||
|
</Panel>
|
||||||
|
</Border>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="1"
|
||||||
|
Margin="0 24 0 0"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Width="50"
|
||||||
|
MinWidth="50"
|
||||||
|
Click="GoBack">
|
||||||
|
<ui:SymbolIcon Symbol="Back"/>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
51
Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml.cs
Normal file
51
Ryujinx.Ava/UI/Views/User/UserRecovererView.axaml.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using FluentAvalonia.UI.Controls;
|
||||||
|
using FluentAvalonia.UI.Navigation;
|
||||||
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Controls;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.Views.User
|
||||||
|
{
|
||||||
|
public partial class UserRecovererView : UserControl
|
||||||
|
{
|
||||||
|
private NavigationDialogHost _parent;
|
||||||
|
|
||||||
|
public UserRecovererView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
||||||
|
{
|
||||||
|
NavigatedTo(e);
|
||||||
|
}, RoutingStrategies.Direct);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NavigatedTo(NavigationEventArgs arg)
|
||||||
|
{
|
||||||
|
if (Program.PreviewerDetached)
|
||||||
|
{
|
||||||
|
switch (arg.NavigationMode)
|
||||||
|
{
|
||||||
|
case NavigationMode.New:
|
||||||
|
var parent = (NavigationDialogHost)arg.Parameter;
|
||||||
|
|
||||||
|
_parent = parent;
|
||||||
|
|
||||||
|
((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - {LocaleManager.Instance[LocaleKeys.UserProfilesRecoverHeading]}";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GoBack(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_parent?.GoBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Recover(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_parent?.RecoverLostAccounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
211
Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml
Normal file
211
Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
<UserControl
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
|
xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
|
||||||
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignWidth="600"
|
||||||
|
d:DesignHeight="500"
|
||||||
|
Height="450"
|
||||||
|
Width="550"
|
||||||
|
x:Class="Ryujinx.Ava.UI.Views.User.UserSaveManagerView"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
x:DataType="viewModels:UserSaveManagerViewModel"
|
||||||
|
Focusable="True">
|
||||||
|
<Design.DataContext>
|
||||||
|
<viewModels:UserSaveManagerViewModel />
|
||||||
|
</Design.DataContext>
|
||||||
|
<UserControl.Resources>
|
||||||
|
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
|
</UserControl.Resources>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid
|
||||||
|
Grid.Row="0"
|
||||||
|
HorizontalAlignment="Stretch">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel
|
||||||
|
Spacing="10"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<Label Content="{locale:Locale CommonSort}" VerticalAlignment="Center" />
|
||||||
|
<ComboBox SelectedIndex="{Binding SortIndex}" Width="100">
|
||||||
|
<ComboBoxItem>
|
||||||
|
<Label
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
Content="{locale:Locale Name}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<Label
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
Content="{locale:Locale Size}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBox.Styles>
|
||||||
|
<Style Selector="ContentControl#ContentPresenter">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||||
|
</Style>
|
||||||
|
</ComboBox.Styles>
|
||||||
|
</ComboBox>
|
||||||
|
<ComboBox SelectedIndex="{Binding OrderIndex}" Width="150">
|
||||||
|
<ComboBoxItem>
|
||||||
|
<Label
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
Content="{locale:Locale OrderAscending}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<Label
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
Content="{locale:Locale OrderDescending}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBox.Styles>
|
||||||
|
<Style Selector="ContentControl#ContentPresenter">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||||
|
</Style>
|
||||||
|
</ComboBox.Styles>
|
||||||
|
</ComboBox>
|
||||||
|
</StackPanel>
|
||||||
|
<Grid
|
||||||
|
Grid.Column="1"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Margin="10,0, 0, 0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Content="{locale:Locale Search}" VerticalAlignment="Center" />
|
||||||
|
<TextBox
|
||||||
|
Margin="5,0,0,0"
|
||||||
|
Grid.Column="1"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Text="{Binding Search}" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<Border
|
||||||
|
Grid.Row="1"
|
||||||
|
Margin="0,5"
|
||||||
|
BorderThickness="1"
|
||||||
|
BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
|
||||||
|
CornerRadius="5"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch">
|
||||||
|
<ListBox
|
||||||
|
Name="SaveList"
|
||||||
|
Items="{Binding Views}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch">
|
||||||
|
<ListBox.Styles>
|
||||||
|
<Style Selector="ListBoxItem">
|
||||||
|
<Setter Property="Padding" Value="10" />
|
||||||
|
<Setter Property="Margin" Value="5" />
|
||||||
|
<Setter Property="CornerRadius" Value="4" />
|
||||||
|
</Style>
|
||||||
|
</ListBox.Styles>
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="models:SaveModel">
|
||||||
|
<Grid HorizontalAlignment="Stretch">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Column="0"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Spacing="5">
|
||||||
|
<Border
|
||||||
|
Height="42"
|
||||||
|
Width="42"
|
||||||
|
Padding="10"
|
||||||
|
BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
|
||||||
|
BorderThickness="1"
|
||||||
|
IsVisible="{Binding !InGameList}">
|
||||||
|
<ui:SymbolIcon
|
||||||
|
Symbol="Help"
|
||||||
|
FontSize="30"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</Border>
|
||||||
|
<Image
|
||||||
|
IsVisible="{Binding InGameList}"
|
||||||
|
Width="42"
|
||||||
|
Height="42"
|
||||||
|
Source="{Binding Icon, Converter={StaticResource ByteImage}}" />
|
||||||
|
<TextBlock
|
||||||
|
MaxLines="3"
|
||||||
|
Width="320"
|
||||||
|
Margin="5"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Text="{Binding Title}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Column="1"
|
||||||
|
Spacing="10"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Label
|
||||||
|
Content="{Binding SizeString}"
|
||||||
|
IsVisible="{Binding SizeAvailable}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right" />
|
||||||
|
<Button
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Padding="10"
|
||||||
|
MinWidth="0"
|
||||||
|
MinHeight="0"
|
||||||
|
Name="OpenLocation"
|
||||||
|
Click="OpenLocation">
|
||||||
|
<ui:SymbolIcon
|
||||||
|
Symbol="OpenFolder"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Padding="10"
|
||||||
|
MinWidth="0"
|
||||||
|
MinHeight="0"
|
||||||
|
Name="Delete"
|
||||||
|
Click="Delete">
|
||||||
|
<ui:SymbolIcon
|
||||||
|
Symbol="Delete"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</Border>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="2"
|
||||||
|
Margin="0 24 0 0"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Width="50"
|
||||||
|
MinWidth="50"
|
||||||
|
Click="GoBack">
|
||||||
|
<ui:SymbolIcon Symbol="Back" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
147
Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs
Normal file
147
Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using FluentAvalonia.UI.Controls;
|
||||||
|
using FluentAvalonia.UI.Navigation;
|
||||||
|
using LibHac;
|
||||||
|
using LibHac.Common;
|
||||||
|
using LibHac.Fs;
|
||||||
|
using LibHac.Fs.Shim;
|
||||||
|
using Ryujinx.Ava.Common;
|
||||||
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Controls;
|
||||||
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
|
using Ryujinx.Ava.UI.Models;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
using Ryujinx.HLE.FileSystem;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UserId = LibHac.Fs.UserId;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.Views.User
|
||||||
|
{
|
||||||
|
public partial class UserSaveManagerView : UserControl
|
||||||
|
{
|
||||||
|
internal UserSaveManagerViewModel ViewModel { get; private set; }
|
||||||
|
|
||||||
|
private AccountManager _accountManager;
|
||||||
|
private HorizonClient _horizonClient;
|
||||||
|
private VirtualFileSystem _virtualFileSystem;
|
||||||
|
private NavigationDialogHost _parent;
|
||||||
|
|
||||||
|
public UserSaveManagerView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
||||||
|
{
|
||||||
|
NavigatedTo(e);
|
||||||
|
}, RoutingStrategies.Direct);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NavigatedTo(NavigationEventArgs arg)
|
||||||
|
{
|
||||||
|
if (Program.PreviewerDetached)
|
||||||
|
{
|
||||||
|
switch (arg.NavigationMode)
|
||||||
|
{
|
||||||
|
case NavigationMode.New:
|
||||||
|
var args = ((NavigationDialogHost parent, AccountManager accountManager, HorizonClient client, VirtualFileSystem virtualFileSystem))arg.Parameter;
|
||||||
|
_accountManager = args.accountManager;
|
||||||
|
_horizonClient = args.client;
|
||||||
|
_virtualFileSystem = args.virtualFileSystem;
|
||||||
|
|
||||||
|
_parent = args.parent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataContext = ViewModel = new UserSaveManagerViewModel(_accountManager);
|
||||||
|
((ContentDialog)_parent.Parent).Title = $"{LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle]} - {ViewModel.SaveManagerHeading}";
|
||||||
|
|
||||||
|
Task.Run(LoadSaves);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadSaves()
|
||||||
|
{
|
||||||
|
ViewModel.Saves.Clear();
|
||||||
|
var saves = new ObservableCollection<SaveModel>();
|
||||||
|
var saveDataFilter = SaveDataFilter.Make(
|
||||||
|
programId: default,
|
||||||
|
saveType: SaveDataType.Account,
|
||||||
|
new UserId((ulong)_accountManager.LastOpenedUser.UserId.High, (ulong)_accountManager.LastOpenedUser.UserId.Low),
|
||||||
|
saveDataId: default,
|
||||||
|
index: default);
|
||||||
|
|
||||||
|
using var saveDataIterator = new UniqueRef<SaveDataIterator>();
|
||||||
|
|
||||||
|
_horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref(), SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
|
||||||
|
|
||||||
|
Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
saveDataIterator.Get.ReadSaveDataInfo(out long readCount, saveDataInfo).ThrowIfFailure();
|
||||||
|
|
||||||
|
if (readCount == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < readCount; i++)
|
||||||
|
{
|
||||||
|
var save = saveDataInfo[i];
|
||||||
|
if (save.ProgramId.Value != 0)
|
||||||
|
{
|
||||||
|
var saveModel = new SaveModel(save, _virtualFileSystem);
|
||||||
|
saves.Add(saveModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Post(() =>
|
||||||
|
{
|
||||||
|
ViewModel.Saves = saves;
|
||||||
|
ViewModel.Sort();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GoBack(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_parent?.GoBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenLocation(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is Avalonia.Controls.Button button)
|
||||||
|
{
|
||||||
|
if (button.DataContext is SaveModel saveModel)
|
||||||
|
{
|
||||||
|
ApplicationHelper.OpenSaveDir(saveModel.SaveId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Delete(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is Avalonia.Controls.Button button)
|
||||||
|
{
|
||||||
|
if (button.DataContext is SaveModel saveModel)
|
||||||
|
{
|
||||||
|
var result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DeleteUserSave],
|
||||||
|
LocaleManager.Instance[LocaleKeys.IrreversibleActionNote],
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogNo], "");
|
||||||
|
|
||||||
|
if (result == UserResult.Yes)
|
||||||
|
{
|
||||||
|
_horizonClient.Fs.DeleteSaveData(SaveDataSpaceId.User, saveModel.SaveId);
|
||||||
|
ViewModel.Saves.Remove(saveModel);
|
||||||
|
ViewModel.Sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
165
Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml
Normal file
165
Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="Ryujinx.Ava.UI.Views.User.UserSelectorViews"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
|
xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
|
||||||
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||||
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
d:DesignHeight="450"
|
||||||
|
MinWidth="500"
|
||||||
|
d:DesignWidth="800"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Focusable="True"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
x:DataType="viewModels:UserProfileViewModel">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
|
</UserControl.Resources>
|
||||||
|
<Design.DataContext>
|
||||||
|
<viewModels:UserProfileViewModel />
|
||||||
|
</Design.DataContext>
|
||||||
|
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Border
|
||||||
|
CornerRadius="5"
|
||||||
|
BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
|
||||||
|
BorderThickness="1">
|
||||||
|
<ListBox
|
||||||
|
MaxHeight="300"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
SelectionChanged="ProfilesList_SelectionChanged"
|
||||||
|
Background="Transparent"
|
||||||
|
Items="{Binding Profiles}">
|
||||||
|
<ListBox.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<flex:FlexPanel
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
AlignContent="FlexStart"
|
||||||
|
JustifyContent="FlexStart" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ListBox.ItemsPanel>
|
||||||
|
<ListBox.Styles>
|
||||||
|
<Style Selector="ListBoxItem">
|
||||||
|
<Setter Property="Margin" Value="5 5 0 5" />
|
||||||
|
<Setter Property="CornerRadius" Value="5" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Border#SelectionIndicator">
|
||||||
|
<Setter Property="Opacity" Value="0" />
|
||||||
|
</Style>
|
||||||
|
</ListBox.Styles>
|
||||||
|
<ListBox.DataTemplates>
|
||||||
|
<DataTemplate
|
||||||
|
DataType="models:UserProfile">
|
||||||
|
<Grid
|
||||||
|
PointerEnter="Grid_PointerEntered"
|
||||||
|
PointerLeave="Grid_OnPointerExited">
|
||||||
|
<Border
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
ClipToBounds="True"
|
||||||
|
CornerRadius="5"
|
||||||
|
Background="{Binding BackgroundColor}">
|
||||||
|
<StackPanel
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch">
|
||||||
|
<Image
|
||||||
|
Width="96"
|
||||||
|
Height="96"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
||||||
|
<TextBlock
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
MaxWidth="90"
|
||||||
|
Text="{Binding Name}"
|
||||||
|
TextAlignment="Center"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
MaxLines="2"
|
||||||
|
Margin="5" />
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
<Border
|
||||||
|
Margin="2"
|
||||||
|
Height="24"
|
||||||
|
Width="24"
|
||||||
|
CornerRadius="12"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Background="{DynamicResource ThemeContentBackgroundColor}"
|
||||||
|
IsVisible="{Binding IsPointerOver}">
|
||||||
|
<Button
|
||||||
|
MaxHeight="24"
|
||||||
|
MaxWidth="24"
|
||||||
|
MinHeight="24"
|
||||||
|
MinWidth="24"
|
||||||
|
CornerRadius="12"
|
||||||
|
Padding="0"
|
||||||
|
Click="EditUser">
|
||||||
|
<ui:SymbolIcon Symbol="Edit" />
|
||||||
|
</Button>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate
|
||||||
|
DataType="viewModels:BaseModel">
|
||||||
|
<Panel
|
||||||
|
Height="118"
|
||||||
|
Width="96">
|
||||||
|
<Button
|
||||||
|
MinWidth="50"
|
||||||
|
MinHeight="50"
|
||||||
|
MaxWidth="50"
|
||||||
|
MaxHeight="50"
|
||||||
|
CornerRadius="25"
|
||||||
|
Margin="10"
|
||||||
|
Padding="0"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Click="AddUser">
|
||||||
|
<ui:SymbolIcon Symbol="Add" />
|
||||||
|
</Button>
|
||||||
|
<Panel.Styles>
|
||||||
|
<Style Selector="Panel">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource ListBoxBackground}"/>
|
||||||
|
</Style>
|
||||||
|
</Panel.Styles>
|
||||||
|
</Panel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.DataTemplates>
|
||||||
|
</ListBox>
|
||||||
|
</Border>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="1"
|
||||||
|
Margin="0 24 0 0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Spacing="10">
|
||||||
|
<Button
|
||||||
|
Click="ManageSaves"
|
||||||
|
Content="{locale:Locale UserProfilesManageSaves}" />
|
||||||
|
<Button
|
||||||
|
Click="RecoverLostAccounts"
|
||||||
|
Content="{locale:Locale UserProfilesRecoverLostAccounts}" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="1"
|
||||||
|
Margin="0 24 0 0"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Click="Close"
|
||||||
|
Content="{locale:Locale UserProfilesClose}" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
128
Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml.cs
Normal file
128
Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml.cs
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using FluentAvalonia.UI.Controls;
|
||||||
|
using FluentAvalonia.UI.Navigation;
|
||||||
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Controls;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.Views.User
|
||||||
|
{
|
||||||
|
public partial class UserSelectorViews : UserControl
|
||||||
|
{
|
||||||
|
private NavigationDialogHost _parent;
|
||||||
|
|
||||||
|
public UserProfileViewModel ViewModel { get; set; }
|
||||||
|
|
||||||
|
public UserSelectorViews()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
if (Program.PreviewerDetached)
|
||||||
|
{
|
||||||
|
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
||||||
|
{
|
||||||
|
NavigatedTo(e);
|
||||||
|
}, RoutingStrategies.Direct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NavigatedTo(NavigationEventArgs arg)
|
||||||
|
{
|
||||||
|
if (Program.PreviewerDetached)
|
||||||
|
{
|
||||||
|
if (arg.NavigationMode == NavigationMode.New)
|
||||||
|
{
|
||||||
|
_parent = (NavigationDialogHost)arg.Parameter;
|
||||||
|
ViewModel = _parent.ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg.NavigationMode == NavigationMode.Back)
|
||||||
|
{
|
||||||
|
((ContentDialog)_parent.Parent).Title = LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle];
|
||||||
|
}
|
||||||
|
|
||||||
|
DataContext = ViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Grid_PointerEntered(object sender, PointerEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is Grid grid)
|
||||||
|
{
|
||||||
|
if (grid.DataContext is UserProfile profile)
|
||||||
|
{
|
||||||
|
profile.IsPointerOver = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Grid_OnPointerExited(object sender, PointerEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is Grid grid)
|
||||||
|
{
|
||||||
|
if (grid.DataContext is UserProfile profile)
|
||||||
|
{
|
||||||
|
profile.IsPointerOver = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProfilesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is ListBox listBox)
|
||||||
|
{
|
||||||
|
int selectedIndex = listBox.SelectedIndex;
|
||||||
|
|
||||||
|
if (selectedIndex >= 0 && selectedIndex < ViewModel.Profiles.Count)
|
||||||
|
{
|
||||||
|
if (ViewModel.Profiles[selectedIndex] is UserProfile userProfile)
|
||||||
|
{
|
||||||
|
_parent?.AccountManager?.OpenUser(userProfile.UserId);
|
||||||
|
|
||||||
|
foreach (BaseModel profile in ViewModel.Profiles)
|
||||||
|
{
|
||||||
|
if (profile is UserProfile uProfile)
|
||||||
|
{
|
||||||
|
uProfile.UpdateState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddUser(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_parent.AddUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditUser(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is Avalonia.Controls.Button button)
|
||||||
|
{
|
||||||
|
if (button.DataContext is UserProfile userProfile)
|
||||||
|
{
|
||||||
|
_parent.EditUser(userProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ManageSaves(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_parent.ManageSaves();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RecoverLostAccounts(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_parent.RecoverLostAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Close(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
((ContentDialog)_parent.Parent).Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,54 +0,0 @@
|
|||||||
<UserControl
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
|
||||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
|
||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="350"
|
|
||||||
x:Class="Ryujinx.Ava.UI.Windows.AvatarWindow"
|
|
||||||
Margin="0"
|
|
||||||
Padding="0"
|
|
||||||
x:CompileBindings="True"
|
|
||||||
x:DataType="viewModels:AvatarProfileViewModel"
|
|
||||||
Focusable="True">
|
|
||||||
<Design.DataContext>
|
|
||||||
<viewModels:AvatarProfileViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
<UserControl.Resources>
|
|
||||||
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
|
||||||
</UserControl.Resources>
|
|
||||||
<Grid Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="*" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<ListBox Grid.Row="1" BorderThickness="0" SelectedIndex="{Binding SelectedIndex}" Height="400"
|
|
||||||
Items="{Binding Images}" HorizontalAlignment="Stretch" VerticalAlignment="Center">
|
|
||||||
<ListBox.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<WrapPanel Orientation="Horizontal" MaxWidth="700" Margin="0" HorizontalAlignment="Center" />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ListBox.ItemsPanel>
|
|
||||||
<ListBox.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<Image Margin="5" Height="96" Width="96"
|
|
||||||
Source="{Binding Data, Converter={StaticResource ByteImage}}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
<ProgressBar Grid.Row="2" IsIndeterminate="{Binding IsIndeterminate}" Value="{Binding ImagesLoaded}" HorizontalAlignment="Stretch" Margin="5"
|
|
||||||
Maximum="{Binding ImageCount}" Minimum="0" />
|
|
||||||
<StackPanel Grid.Row="3" Orientation="Horizontal" Spacing="10" Margin="10" HorizontalAlignment="Center">
|
|
||||||
<Button Content="{locale:Locale AvatarChoose}" Width="200" Name="ChooseButton" Click="ChooseButton_OnClick" />
|
|
||||||
<ui:ColorPickerButton Color="{Binding BackgroundColor, Mode=TwoWay}" Name="ColorButton" />
|
|
||||||
<Button HorizontalAlignment="Right" Content="{locale:Locale Discard}" Click="CloseButton_OnClick"
|
|
||||||
Name="CloseButton"
|
|
||||||
Width="200" />
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
@@ -44,7 +44,8 @@
|
|||||||
<settings:SettingsNetworkView Name="NetworkPage" />
|
<settings:SettingsNetworkView Name="NetworkPage" />
|
||||||
<settings:SettingsLoggingView Name="LoggingPage" />
|
<settings:SettingsLoggingView Name="LoggingPage" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<ui:NavigationView Grid.Row="1"
|
<ui:NavigationView
|
||||||
|
Grid.Row="1"
|
||||||
IsSettingsVisible="False"
|
IsSettingsVisible="False"
|
||||||
Name="NavPanel"
|
Name="NavPanel"
|
||||||
IsBackEnabled="False"
|
IsBackEnabled="False"
|
||||||
@@ -54,7 +55,8 @@
|
|||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
OpenPaneLength="200">
|
OpenPaneLength="200">
|
||||||
<ui:NavigationView.MenuItems>
|
<ui:NavigationView.MenuItems>
|
||||||
<ui:NavigationViewItem IsSelected="True"
|
<ui:NavigationViewItem
|
||||||
|
IsSelected="True"
|
||||||
Content="{locale:Locale SettingsTabGeneral}"
|
Content="{locale:Locale SettingsTabGeneral}"
|
||||||
Tag="UiPage"
|
Tag="UiPage"
|
||||||
Icon="New" />
|
Icon="New" />
|
||||||
@@ -74,7 +76,8 @@
|
|||||||
Content="{locale:Locale SettingsTabCpu}"
|
Content="{locale:Locale SettingsTabCpu}"
|
||||||
Tag="CpuPage">
|
Tag="CpuPage">
|
||||||
<ui:NavigationViewItem.Icon>
|
<ui:NavigationViewItem.Icon>
|
||||||
<ui:FontIcon FontFamily="avares://Ryujinx.Ava/Assets/Fonts#Segoe Fluent Icons"
|
<ui:FontIcon
|
||||||
|
FontFamily="avares://Ryujinx.Ava/Assets/Fonts#Segoe Fluent Icons"
|
||||||
Glyph="{helpers:GlyphValueConverter Chip}" />
|
Glyph="{helpers:GlyphValueConverter Chip}" />
|
||||||
</ui:NavigationViewItem.Icon>
|
</ui:NavigationViewItem.Icon>
|
||||||
</ui:NavigationViewItem>
|
</ui:NavigationViewItem>
|
||||||
@@ -95,6 +98,11 @@
|
|||||||
Tag="LoggingPage"
|
Tag="LoggingPage"
|
||||||
Icon="Document" />
|
Icon="Document" />
|
||||||
</ui:NavigationView.MenuItems>
|
</ui:NavigationView.MenuItems>
|
||||||
|
<ui:NavigationView.Styles>
|
||||||
|
<Style Selector="Grid#PlaceholderGrid">
|
||||||
|
<Setter Property="Height" Value="40" />
|
||||||
|
</Style>
|
||||||
|
</ui:NavigationView.Styles>
|
||||||
</ui:NavigationView>
|
</ui:NavigationView>
|
||||||
<ReversibleStackPanel
|
<ReversibleStackPanel
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
|
@@ -81,7 +81,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
|
|
||||||
private void PrintHeading()
|
private void PrintHeading()
|
||||||
{
|
{
|
||||||
Heading.Text = string.Format(LocaleManager.Instance[LocaleKeys.GameUpdateWindowHeading], _titleUpdates.Count, _titleName, _titleId.ToString("X16"));
|
Heading.Text = string.Format(LocaleManager.Instance[LocaleKeys.GameUpdateWindowHeading], _titleUpdates.Count - 1, _titleName, _titleId.ToString("X16"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadUpdates()
|
private void LoadUpdates()
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Common.Memory;
|
using Ryujinx.Common.Memory;
|
||||||
using Ryujinx.Horizon.Common;
|
using Ryujinx.Horizon.Common;
|
||||||
|
using Ryujinx.Horizon.LogManager.Types;
|
||||||
using Ryujinx.Horizon.Sdk.Lm;
|
using Ryujinx.Horizon.Sdk.Lm;
|
||||||
using Ryujinx.Horizon.Sdk.Sf;
|
using Ryujinx.Horizon.Sdk.Sf;
|
||||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||||
@@ -13,13 +14,19 @@ namespace Ryujinx.Horizon.LogManager.Ipc
|
|||||||
{
|
{
|
||||||
partial class LmLogger : ILmLogger
|
partial class LmLogger : ILmLogger
|
||||||
{
|
{
|
||||||
|
private const int MessageLengthLimit = 5000;
|
||||||
|
|
||||||
private readonly LogService _log;
|
private readonly LogService _log;
|
||||||
private readonly ulong _pid;
|
private readonly ulong _pid;
|
||||||
|
|
||||||
|
private LogPacket _logPacket;
|
||||||
|
|
||||||
public LmLogger(LogService log, ulong pid)
|
public LmLogger(LogService log, ulong pid)
|
||||||
{
|
{
|
||||||
_log = log;
|
_log = log;
|
||||||
_pid = pid;
|
_pid = pid;
|
||||||
|
|
||||||
|
_logPacket = new LogPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
[CmifCommand(0)]
|
[CmifCommand(0)]
|
||||||
@@ -30,7 +37,12 @@ namespace Ryujinx.Horizon.LogManager.Ipc
|
|||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Guest?.Print(LogClass.ServiceLm, LogImpl(message));
|
if (LogImpl(message))
|
||||||
|
{
|
||||||
|
Logger.Guest?.Print(LogClass.ServiceLm, _logPacket.ToString());
|
||||||
|
|
||||||
|
_logPacket = new LogPacket();
|
||||||
|
}
|
||||||
|
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
@@ -60,58 +72,86 @@ namespace Ryujinx.Horizon.LogManager.Ipc
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string LogImpl(ReadOnlySpan<byte> message)
|
private bool LogImpl(ReadOnlySpan<byte> message)
|
||||||
{
|
{
|
||||||
SpanReader reader = new(message);
|
SpanReader reader = new(message);
|
||||||
LogPacketHeader header = reader.Read<LogPacketHeader>();
|
LogPacketHeader header = reader.Read<LogPacketHeader>();
|
||||||
StringBuilder builder = new();
|
|
||||||
|
|
||||||
builder.AppendLine($"Guest Log:\n Log level: {header.Severity}");
|
bool isHeadPacket = (header.Flags & LogPacketFlags.IsHead) != 0;
|
||||||
|
bool isTailPacket = (header.Flags & LogPacketFlags.IsTail) != 0;
|
||||||
|
|
||||||
|
_logPacket.Severity = header.Severity;
|
||||||
|
|
||||||
while (reader.Length > 0)
|
while (reader.Length > 0)
|
||||||
{
|
{
|
||||||
int type = ReadUleb128(ref reader);
|
int type = ReadUleb128(ref reader);
|
||||||
int size = ReadUleb128(ref reader);
|
int size = ReadUleb128(ref reader);
|
||||||
|
|
||||||
LogDataChunkKey field = (LogDataChunkKey)type;
|
LogDataChunkKey key = (LogDataChunkKey)type;
|
||||||
|
|
||||||
string fieldStr;
|
if (key == LogDataChunkKey.Start)
|
||||||
|
|
||||||
if (field == LogDataChunkKey.Start)
|
|
||||||
{
|
{
|
||||||
reader.Skip(size);
|
reader.Skip(size);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (field == LogDataChunkKey.Stop)
|
else if (key == LogDataChunkKey.Stop)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (field == LogDataChunkKey.Line)
|
else if (key == LogDataChunkKey.Line)
|
||||||
{
|
{
|
||||||
fieldStr = $"{field}: {reader.Read<int>()}";
|
_logPacket.Line = reader.Read<int>();
|
||||||
}
|
}
|
||||||
else if (field == LogDataChunkKey.DropCount)
|
else if (key == LogDataChunkKey.DropCount)
|
||||||
{
|
{
|
||||||
fieldStr = $"{field}: {reader.Read<long>()}";
|
_logPacket.DropCount = reader.Read<long>();
|
||||||
}
|
}
|
||||||
else if (field == LogDataChunkKey.Time)
|
else if (key == LogDataChunkKey.Time)
|
||||||
{
|
{
|
||||||
fieldStr = $"{field}: {reader.Read<long>()}s";
|
_logPacket.Time = reader.Read<long>();
|
||||||
}
|
}
|
||||||
else if (field < LogDataChunkKey.Count)
|
else if (key == LogDataChunkKey.Message)
|
||||||
{
|
{
|
||||||
fieldStr = $"{field}: '{Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd()}'";
|
string text = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
|
||||||
|
|
||||||
|
if (isHeadPacket && isTailPacket)
|
||||||
|
{
|
||||||
|
_logPacket.Message = text;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fieldStr = $"Field{field}: '{Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd()}'";
|
_logPacket.Message += text;
|
||||||
|
|
||||||
|
if (_logPacket.Message.Length >= MessageLengthLimit)
|
||||||
|
{
|
||||||
|
isTailPacket = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (key == LogDataChunkKey.Filename)
|
||||||
|
{
|
||||||
|
_logPacket.Filename = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
|
||||||
|
}
|
||||||
|
else if (key == LogDataChunkKey.Function)
|
||||||
|
{
|
||||||
|
_logPacket.Function = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
|
||||||
|
}
|
||||||
|
else if (key == LogDataChunkKey.Module)
|
||||||
|
{
|
||||||
|
_logPacket.Module = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
|
||||||
|
}
|
||||||
|
else if (key == LogDataChunkKey.Thread)
|
||||||
|
{
|
||||||
|
_logPacket.Thread = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
|
||||||
|
}
|
||||||
|
else if (key == LogDataChunkKey.ProgramName)
|
||||||
|
{
|
||||||
|
_logPacket.ProgramName = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.AppendLine($" {fieldStr}");
|
return isTailPacket;
|
||||||
}
|
|
||||||
|
|
||||||
return builder.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int ReadUleb128(ref SpanReader reader)
|
private static int ReadUleb128(ref SpanReader reader)
|
||||||
|
72
Ryujinx.Horizon/LogManager/Types/LogPacket.cs
Normal file
72
Ryujinx.Horizon/LogManager/Types/LogPacket.cs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
using Ryujinx.Horizon.Sdk.Diag;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Ryujinx.Horizon.LogManager.Types
|
||||||
|
{
|
||||||
|
struct LogPacket
|
||||||
|
{
|
||||||
|
public string Message;
|
||||||
|
public int Line;
|
||||||
|
public string Filename;
|
||||||
|
public string Function;
|
||||||
|
public string Module;
|
||||||
|
public string Thread;
|
||||||
|
public long DropCount;
|
||||||
|
public long Time;
|
||||||
|
public string ProgramName;
|
||||||
|
public LogSeverity Severity;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new();
|
||||||
|
builder.AppendLine($"Guest Log:\n Log level: {Severity}");
|
||||||
|
|
||||||
|
if (Time > 0)
|
||||||
|
{
|
||||||
|
builder.AppendLine($" Time: {Time}s");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DropCount > 0)
|
||||||
|
{
|
||||||
|
builder.AppendLine($" DropCount: {DropCount}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(ProgramName))
|
||||||
|
{
|
||||||
|
builder.AppendLine($" ProgramName: {ProgramName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Module))
|
||||||
|
{
|
||||||
|
builder.AppendLine($" Module: {Module}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Thread))
|
||||||
|
{
|
||||||
|
builder.AppendLine($" Thread: {Thread}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Filename))
|
||||||
|
{
|
||||||
|
builder.AppendLine($" Filename: {Filename}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Line > 0)
|
||||||
|
{
|
||||||
|
builder.AppendLine($" Line: {Line}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Function))
|
||||||
|
{
|
||||||
|
builder.AppendLine($" Function: {Function}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Message))
|
||||||
|
{
|
||||||
|
builder.AppendLine($" Message: {Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user