From d582ea7fe8009f18dc90abdf55e933657bf83223 Mon Sep 17 00:00:00 2001 From: Wind-Explorer Date: Mon, 9 Mar 2026 18:00:05 +0800 Subject: [PATCH] replace `RecolorOptions` with DollColorSchemeDto --- src/lib/utils/sprite-utils.ts | 18 +++++-------- .../app-menu/components/doll-preview.svelte | 18 ++++++------- .../tabs/your-dolls/dolls-list.svelte | 5 +--- src/routes/doll-editor/+page.svelte | 26 +++++++++---------- src/routes/welcome/+page.svelte | 10 ++++--- 5 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/lib/utils/sprite-utils.ts b/src/lib/utils/sprite-utils.ts index e2aff2e..25b1c57 100644 --- a/src/lib/utils/sprite-utils.ts +++ b/src/lib/utils/sprite-utils.ts @@ -1,24 +1,18 @@ -import { commands } from "$lib/bindings"; +import { commands, type DollColorSchemeDto } from "$lib/bindings"; import onekoGif from "../../assets/oneko/oneko.gif"; -export interface RecolorOptions { - bodyColor: string; - outlineColor: string; - applyTexture?: boolean; -} - export async function getSpriteSheetUrl( - options?: RecolorOptions, + options?: DollColorSchemeDto, ): Promise { - if (!options || !options.bodyColor || !options.outlineColor) { + if (!options) { return onekoGif; } try { const result = await commands.recolorGifBase64( - options.bodyColor, - options.outlineColor, - options.applyTexture ?? true, + options.body, + options.outline, + true, // TODO: default true for now, will add customization in the future ); return `data:image/gif;base64,${result}`; } catch (e) { diff --git a/src/routes/app-menu/components/doll-preview.svelte b/src/routes/app-menu/components/doll-preview.svelte index c9f260e..1dbf78b 100644 --- a/src/routes/app-menu/components/doll-preview.svelte +++ b/src/routes/app-menu/components/doll-preview.svelte @@ -3,10 +3,9 @@ import { SPRITE_SETS, SPRITE_SIZE } from "$lib/constants/pet-sprites"; import { getSpriteSheetUrl } from "$lib/utils/sprite-utils"; import PetSprite from "$lib/components/PetSprite.svelte"; + import type { DollColorSchemeDto } from "$lib/bindings"; - export let bodyColor: string; - export let outlineColor: string; - export let applyTexture: boolean = true; + export let dollColorScheme: DollColorSchemeDto; let previewBase64: string | null = null; let error: string | null = null; @@ -21,11 +20,7 @@ function generatePreview() { error = null; - getSpriteSheetUrl({ - bodyColor, - outlineColor, - applyTexture, - }) + getSpriteSheetUrl(dollColorScheme) .then((url: string) => { previewBase64 = url; }) @@ -70,7 +65,7 @@ }, 3000); } - $: if (bodyColor && outlineColor) { + $: if (dollColorScheme) { debouncedGeneratePreview(); } @@ -103,7 +98,10 @@ /> {:else} -
+
{/if} diff --git a/src/routes/app-menu/tabs/your-dolls/dolls-list.svelte b/src/routes/app-menu/tabs/your-dolls/dolls-list.svelte index 27fa848..f8f6ebb 100644 --- a/src/routes/app-menu/tabs/your-dolls/dolls-list.svelte +++ b/src/routes/app-menu/tabs/your-dolls/dolls-list.svelte @@ -43,10 +43,7 @@ class="flex flex-col w-full text-center py-6 gap-2 *:mx-auto hover:opacity-70 hover:cursor-pointer" >
- +

{ // Check URL search params for ID @@ -39,8 +39,8 @@ try { const doll: DollDto = await commands.getDoll(id); name = doll.name; - bodyColor = doll.configuration.colorScheme.body; - outlineColor = doll.configuration.colorScheme.outline; + body = doll.configuration.colorScheme.body; + outline = doll.configuration.colorScheme.outline; } catch (e) { error = (e as Error)?.message ?? String(e); console.error("Failed to fetch doll:", e); @@ -59,8 +59,8 @@ name, configuration: { colorScheme: { - body: bodyColor, - outline: outlineColor, + body: body, + outline: outline, }, }, }; @@ -70,8 +70,8 @@ name, configuration: { colorScheme: { - body: bodyColor, - outline: outlineColor, + body: body, + outline: outline, }, }, }; @@ -108,7 +108,7 @@ {:else}

- +
@@ -152,13 +152,13 @@ id="outline-color-input" type="color" class="input input-bordered w-10 p-0" - bind:value={outlineColor} + bind:value={outline} disabled={saving} />
diff --git a/src/routes/welcome/+page.svelte b/src/routes/welcome/+page.svelte index f3d4b4a..033cd3a 100644 --- a/src/routes/welcome/+page.svelte +++ b/src/routes/welcome/+page.svelte @@ -98,7 +98,9 @@ @@ -146,7 +148,9 @@ } }} > - {useRegister ? "Already have an account? Sign in" : "New here? Create an account"} + {useRegister + ? "Already have an account? Sign in" + : "New here? Create an account"}