Explorar o código

Adds the ability to read a amiibo's nickname from the VirtualAmiiboFile (#217)

This feature adds a way to change the Amiibo's nickname inside Smash and
other places where it's used, so it’s not always "Ryujinx." However, I
did not add a GUI or create the Cabinet applet that would allow users to
change this. So you will have to go to system/amiibo and find your
amiibo id to change it.
Jacobwasbeast hai 1 ano
pai
achega
b17e4f79fb

+ 1 - 0
src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/Types/VirtualAmiiboFile.cs

@@ -8,6 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager
         public uint FileVersion { get; set; }
         public byte[] TagUuid { get; set; }
         public string AmiiboId { get; set; }
+        public string NickName { get; set; }
         public DateTime FirstWriteDate { get; set; }
         public DateTime LastWriteDate { get; set; }
         public ushort WriteCounter { get; set; }

+ 7 - 4
src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs

@@ -64,16 +64,17 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
             };
         }
 
-        public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiiboId, string nickname)
+        public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiiboId, string userName)
         {
             VirtualAmiiboFile amiiboFile = LoadAmiiboFile(amiiboId);
-
+            string nickname = amiiboFile.NickName ?? "Ryujinx";
             UtilityImpl utilityImpl = new(tickSource);
             CharInfo charInfo = new();
 
             charInfo.SetFromStoreData(StoreData.BuildDefault(utilityImpl, 0));
 
-            charInfo.Nickname = Nickname.FromString(nickname);
+            // This is the player's name
+            charInfo.Nickname = Nickname.FromString(userName);
 
             RegisterInfo registerInfo = new()
             {
@@ -85,7 +86,9 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
                 Reserved1 = new Array64<byte>(),
                 Reserved2 = new Array58<byte>(),
             };
-            "Ryujinx"u8.CopyTo(registerInfo.Nickname.AsSpan());
+            // This is the amiibo's name
+            byte[] nicknameBytes = System.Text.Encoding.UTF8.GetBytes(nickname);
+            nicknameBytes.CopyTo(registerInfo.Nickname.AsSpan());
 
             return registerInfo;
         }