feat: tomodachi life data decrypting and fix hair color rendering

This commit is contained in:
trafficlunar 2025-04-05 17:03:18 +01:00
parent fae79e67af
commit 5de6e924f2
4 changed files with 107 additions and 1 deletions

View file

@ -13,6 +13,7 @@ import { MII_DECRYPTION_KEY } from "@/lib/constants";
import { nameSchema, tagsSchema } from "@/lib/schemas";
import Mii from "@/utils/mii.js/mii";
import TomodachiLifeMii from "@/utils/tomodachi-life-mii";
import TagSelector from "./submit/tag-selector";
import QrUpload from "./submit/qr-upload";
@ -107,9 +108,16 @@ export default function SubmitForm() {
return;
}
// Convert to Mii class
// Convert to Mii classes
const buffer = Buffer.from(result);
const mii = new Mii(buffer);
const tomodachiLifeMii = TomodachiLifeMii.fromBytes(qrBytes);
if (tomodachiLifeMii.hairDyeEnabled) {
mii.hairColor = tomodachiLifeMii.studioHairColor;
mii.eyebrowColor = tomodachiLifeMii.studioHairColor;
mii.facialHairColor = tomodachiLifeMii.studioHairColor;
}
try {
setStudioUrl(mii.studioUrl({ width: 128 }));