diff --git a/public/tutorial/switch/step1.jpg b/public/tutorial/switch/step1.jpg new file mode 100755 index 0000000..6d6a27d Binary files /dev/null and b/public/tutorial/switch/step1.jpg differ diff --git a/public/tutorial/switch/step2.jpg b/public/tutorial/switch/step2.jpg new file mode 100755 index 0000000..aadf89a Binary files /dev/null and b/public/tutorial/switch/step2.jpg differ diff --git a/public/tutorial/switch/step3.jpg b/public/tutorial/switch/step3.jpg new file mode 100755 index 0000000..4cb8859 Binary files /dev/null and b/public/tutorial/switch/step3.jpg differ diff --git a/public/tutorial/switch/step4.jpg b/public/tutorial/switch/step4.jpg new file mode 100755 index 0000000..af940a0 Binary files /dev/null and b/public/tutorial/switch/step4.jpg differ diff --git a/public/tutorial/switch/step5.jpg b/public/tutorial/switch/step5.jpg new file mode 100755 index 0000000..3d0a06b Binary files /dev/null and b/public/tutorial/switch/step5.jpg differ diff --git a/src/app/api/submit/route.ts b/src/app/api/submit/route.ts index 4d699f0..73642a5 100644 --- a/src/app/api/submit/route.ts +++ b/src/app/api/submit/route.ts @@ -94,17 +94,23 @@ export async function POST(request: NextRequest) { // Minify instructions to save space and improve user experience let minifiedInstructions: Partial | undefined; if (formData.get("platform") === "SWITCH") { + const DEFAULT_ZERO_FIELDS = new Set(["height", "distance", "rotation", "size", "stretch"]); + function minify(object: Partial): Partial { for (const key in object) { const value = object[key as keyof SwitchMiiInstructions]; - if (!value) { + if (value === null || value === undefined) { delete object[key as keyof SwitchMiiInstructions]; continue; } - // Recurse into nested objects - if (typeof value === "object") { + if (DEFAULT_ZERO_FIELDS.has(key) && value === 0) { + delete object[key as keyof SwitchMiiInstructions]; + continue; + } + + if (typeof value === "object" && !Array.isArray(value)) { minify(value as Partial); if (Object.keys(value).length === 0) { diff --git a/src/app/mii/[id]/page.tsx b/src/app/mii/[id]/page.tsx index 5c21a82..5c9fb13 100644 --- a/src/app/mii/[id]/page.tsx +++ b/src/app/mii/[id]/page.tsx @@ -14,7 +14,7 @@ import ImageViewer from "@/components/image-viewer"; import DeleteMiiButton from "@/components/mii/delete-mii-button"; import ShareMiiButton from "@/components/mii/share-mii-button"; import ThreeDsScanTutorialButton from "@/components/tutorial/3ds-scan"; -import SwitchScanTutorialButton from "@/components/tutorial/switch-scan"; +import SwitchScanTutorialButton from "@/components/tutorial/switch-add-mii"; import Description from "@/components/description"; import MiiInstructions from "@/components/mii/instructions"; diff --git a/src/components/mii/list/index.tsx b/src/components/mii/list/index.tsx index 06187bc..0c190e1 100644 --- a/src/components/mii/list/index.tsx +++ b/src/components/mii/list/index.tsx @@ -192,7 +192,7 @@ export default async function MiiList({ searchParams, userId, inLikesPage }: Pro {miis.map((mii) => (
("SWITCH"); const [gender, setGender] = useState("MALE"); - const instructions = useRef({ - head: { type: 0, skinColor: 0 }, + const instructions = useRef>({ + head: { type: 1, skinColor: 1 }, hair: { - setType: 0, - bangsType: 0, - backType: 0, + setType: 43, + bangsType: null, + backType: null, color: 0, - subColor: 0, - style: 0, + subColor: null, + subColor2: null, + style: 1, isFlipped: false, }, - eyebrows: { type: 0, color: 0, height: 0, distance: 0, rotation: 0, size: 0, stretch: 0 }, + eyebrows: { type: 28, color: 0, height: 0, distance: 0, rotation: 0, size: 0, stretch: 0 }, eyes: { - eyesType: 0, - eyelashesTop: 0, - eyelashesBottom: 0, - eyelidTop: 0, - eyelidBottom: 0, - eyeliner: 0, - pupil: 0, - color: 0, - height: 0, - distance: 0, - rotation: 0, - size: 0, - stretch: 0, + main: { type: 6, color: 0, height: 0, distance: 0, rotation: 0, size: 0, stretch: 0 }, + eyelashesTop: { type: 1, height: 0, distance: 0, rotation: 0, size: 0, stretch: 0 }, + eyelashesBottom: { type: 1, height: 0, distance: 0, rotation: 0, size: 0, stretch: 0 }, + eyelidTop: { type: 1, height: 0, distance: 0, rotation: 0, size: 0, stretch: 0 }, + eyelidBottom: { type: 1, height: 0, distance: 0, rotation: 0, size: 0, stretch: 0 }, + eyeliner: { type: 1, color: 0 }, + pupil: { type: 1, height: 0, distance: 0, rotation: 0, size: 0, stretch: 0 }, }, - nose: { type: 0, height: 0, size: 0 }, - lips: { type: 0, color: 0, height: 0, rotation: 0, size: 0, stretch: 0, hasLipstick: false }, - ears: { type: 0, height: 0, size: 0 }, - glasses: { type: 0, ringColor: 0, shadesColor: 0, height: 0, size: 0, stretch: 0 }, + nose: { type: 6, height: 0, size: 0 }, + lips: { type: 2, color: 0, height: 0, rotation: 0, size: 0, stretch: 0, hasLipstick: false }, + ears: { type: 1, height: 0, size: 0 }, + glasses: { type: 1, ringColor: 0, shadesColor: 0, height: 0, size: 0, stretch: 0 }, other: { - wrinkles1: { type: 0, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, - wrinkles2: { type: 0, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, - beard: { type: 0, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, - moustache: { type: 0, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, - goatee: { type: 0, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, - mole: { type: 0, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, - eyeShadow: { type: 0, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, - blush: { type: 0, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, + wrinkles1: { type: 1, height: 0, distance: 0, size: 0, stretch: 0 }, + wrinkles2: { type: 1, height: 0, distance: 0, size: 0, stretch: 0 }, + beard: { type: 1, color: 0 }, + moustache: { type: 1, color: 0, height: 0, isFlipped: false, size: 0, stretch: 0 }, + goatee: { type: 1, color: 0 }, + mole: { type: 1, color: 0, height: 0, distance: 0, size: 0 }, + eyeShadow: { type: 1, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, + blush: { type: 1, color: 0, height: 0, distance: 0, size: 0, stretch: 0 }, }, height: 0, weight: 0, @@ -378,6 +373,7 @@ export default function SubmitForm() {
+
@@ -416,7 +412,9 @@ export default function SubmitForm() {
- Instructions are recommended, but not required. + + Mii editor may be inaccurate. Instructions are recommended, but not required - you do not have to add every instruction. +
diff --git a/src/components/submit-form/mii-editor/index.tsx b/src/components/submit-form/mii-editor/index.tsx index 71c4aea..98add0f 100644 --- a/src/components/submit-form/mii-editor/index.tsx +++ b/src/components/submit-form/mii-editor/index.tsx @@ -14,7 +14,7 @@ import MiscTab from "./tabs/misc"; import { Icon } from "@iconify/react"; interface Props { - instructions: React.RefObject; + instructions: React.RefObject>; } type Tab = "head" | "hair" | "eyebrows" | "eyes" | "nose" | "lips" | "ears" | "glasses" | "other" | "misc"; @@ -28,7 +28,7 @@ export const TAB_ICONS: Record = { lips: "material-symbols-light:lips", ears: "ion:ear", glasses: "solar:glasses-bold", - other: "mingcute:head-ai-fill", + other: "mdi:sparkles", misc: "material-symbols:settings", }; diff --git a/src/components/submit-form/mii-editor/number-inputs.tsx b/src/components/submit-form/mii-editor/number-inputs.tsx index 552d838..0ef6ed8 100644 --- a/src/components/submit-form/mii-editor/number-inputs.tsx +++ b/src/components/submit-form/mii-editor/number-inputs.tsx @@ -1,7 +1,7 @@ import { useState } from "react"; interface Props { - target: { height?: number; distance?: number; rotation?: number; size?: number; stretch?: number }; + target: { height?: number; distance?: number; rotation?: number; size?: number; stretch?: number } | any; } export default function NumberInputs({ target }: Props) { @@ -11,8 +11,10 @@ export default function NumberInputs({ target }: Props) { const [size, setSize] = useState(0); const [stretch, setStretch] = useState(0); + if (!target) return null; + return ( -
+
{target.height != undefined && (