diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a1679d412..7bdafe400a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Notable changes to DeepSeekBot are recorded here. See the ## [Unreleased] -Pixel Avatars can be an elf, dwarf, orc or talking flower with beards, medieval outfits and headwear, you can draw your own headpiece into a Part Library, and new PersonaBots start from a face seeded across every species. +Pixel Avatars can be an elf, dwarf, orc or talking flower with beards, medieval outfits and headwear, you can draw your own headpiece and hair pieces into a Part Library, and new PersonaBots start from a face seeded across every species. ### Breaking Changes @@ -13,6 +13,7 @@ Pixel Avatars can be an elf, dwarf, orc or talking flower with beards, medieval ### Added +- Hair pieces can be drawn too: open bangs, left or right side hair or back hair and start from the style you wear, flattened to pixels. Reshape it with the same tools, save it to the Part Library and wear it in that slot. The drawn hair is shaded and recolored like built-in hair, turns with the head and hides under helmets, hoods and on flowers. **Back to the built-in style** restores your original choice ([#1238](https://github.com/BotHarness/DeepSeekBot/issues/1238)). - You can draw your own headpiece for a pixel Avatar: pencil, eraser, fill, mirroring across the face, a front layer over the hair and a back layer behind it, undo and redo, and a 1× preview on the real Avatar. Colors can follow the Avatar's hair, skin, eye or outfit color in five tones, or be fixed. Saved parts go into a Part Library in your Profile and can be worn by any PersonaBot. The worn copy turns and speaks with the Window Companion and travels with an exported Bot, and editing a library part saves a new part without changing Avatars that already wear the old one ([#1211](https://github.com/BotHarness/DeepSeekBot/issues/1211)). - Pixel Avatars can be an elf, dwarf, orc or talking flower. Beards always leave the speaking mouth visible. Armor, robe, tunic and cloak outfits are available, and a helmet or hood hides the hair underneath. Flowers have bead eyes, five petal styles and a stem or pot. Choices a species or headwear doesn't show stay saved, with a note, and return when switched back ([#1212](https://github.com/BotHarness/DeepSeekBot/issues/1212), [#1213](https://github.com/BotHarness/DeepSeekBot/issues/1213)). - A new PersonaBot starts with a random face from every species, part and outfit, based on its name. Existing PersonaBots keep their current face ([#1214](https://github.com/BotHarness/DeepSeekBot/issues/1214)). diff --git a/CHANGELOG.zh.md b/CHANGELOG.zh.md index 908450cf48..fc26b2d6bf 100644 --- a/CHANGELOG.zh.md +++ b/CHANGELOG.zh.md @@ -5,7 +5,7 @@ ## [Unreleased] -像素头像新增精灵、矮人、兽人和会说话的花,以及胡子、中世纪服装和头饰;可以自己画头饰并存入部件库;新建的 PersonaBot 会从全部物种中随机生成初始形象。 +像素头像新增精灵、矮人、兽人和会说话的花,以及胡子、中世纪服装和头饰;可以自己画头饰和头发并存入部件库;新建的 PersonaBot 会从全部物种中随机生成初始形象。 ### Breaking Changes @@ -13,6 +13,7 @@ ### Added +- 头发也能自己画了:在前发、左右侧发或后发里,从当前戴的样式开始(压平成像素),用同样的工具改形状,存进部件库并戴在这个位置。自绘头发会像内置头发一样上阴影、跟着发色变色、随头部转动,戴头盔/兜帽或变成花朵时会隐藏。点 **换回内置样式** 可恢复原来的选择([#1238](https://github.com/BotHarness/DeepSeekBot/issues/1238))。 - 可以为像素头像自己画头饰:铅笔、橡皮、填充、沿脸部中线镜像,前层盖在头发上、后层在头发后面,支持撤销重做,并在真实头像上显示 1× 预览。颜色可以跟随头像的发色、肤色、眼睛或衣服颜色(五档明暗),也可以是固定色。保存的部件进入 Profile 里的部件库,任何 PersonaBot 都能戴上;戴上的副本会在窗口伙伴里随头部转动和说话,并随导出的 Bot 一起带走;修改库里的部件会另存为新部件,不会改变已经戴着旧部件的头像([#1211](https://github.com/BotHarness/DeepSeekBot/issues/1211))。 - 像素头像新增精灵、矮人、兽人和会说话的花。胡子始终露出说话的嘴,新增盔甲、法袍、束腰外衣和斗篷,戴上头盔或兜帽会遮住下面的头发。花有豆豆眼、五种花瓣样式,以及茎叶或花盆。当前物种或头饰不显示的选择会保留并给出提示,换回后恢复([#1212](https://github.com/BotHarness/DeepSeekBot/issues/1212)、[#1213](https://github.com/BotHarness/DeepSeekBot/issues/1213))。 - 新建的 PersonaBot 会按名字从全部物种、部件和服装中随机生成初始形象,已有的 PersonaBot 保持原来的样子([#1214](https://github.com/BotHarness/DeepSeekBot/issues/1214))。 diff --git a/docs/architecture/botharness-architecture.en.md b/docs/architecture/botharness-architecture.en.md index b80f0d9693..be203de5af 100644 --- a/docs/architecture/botharness-architecture.en.md +++ b/docs/architecture/botharness-architecture.en.md @@ -408,7 +408,7 @@ Custom Parts are bounded pixel grids whose cells reference appearance colors or New PersonaBots record a full-domain name-seed version; PersonaBots without it keep the human-only seed. Recipes using species, new slots or Custom Parts raise the asset/schema version and fall back to the saved snapshot on older Clients; existing recipes render unchanged. The first slice proves goblin, split side hair and one drawn headpiece from editor to Part Library to a Window Companion and through export/import. -Implemented so far: goblin, elf, dwarf, orc and flower species, split side hair, beards, medieval outfits and headwear, the full-domain seed (#1210, #1212–#1214), and the first Custom Part path (#1211). A drawn headpiece is an asset version 3 recipe. The Part Library is the `avatar-part-library` module's `avatar_part_library` table (schema generation 73), keyed by the part's content hash and holding name, origins and parent. The `partLibraryList` and `partLibraryAdd` bridge methods expose it to the Client editor (pencil, eraser, 4-connected fill, centerline mirror, front and back layers, undo and redo, and a 1× preview). The appearance embeds a copy of the part, so it travels in `.botharness/bot.json` and Bot Zips. Animal species, imported parts, PNG part files and further drawing tools are still to come. +Implemented so far: goblin, elf, dwarf, orc and flower species, split side hair, beards, medieval outfits and headwear, the full-domain seed (#1210, #1212–#1214), the first Custom Part path (#1211), and drawn hair pieces (#1238). A drawn bangs, side or back piece replaces the built-in piece while that choice stays saved; its live `hairColor` cells are shaded like built-in hair, so editing starts from the worn style flattened to cells. A drawn headpiece is an asset version 3 recipe. The Part Library is the `avatar-part-library` module's `avatar_part_library` table (schema generation 73), keyed by the part's content hash and holding name, origins and parent. The `partLibraryList` and `partLibraryAdd` bridge methods expose it to the Client editor (pencil, eraser, 4-connected fill, centerline mirror, front and back layers, undo and redo, and a 1× preview). The appearance embeds a copy of the part, so it travels in `.botharness/bot.json` and Bot Zips. Animal species, imported parts, PNG part files and further drawing tools are still to come. ## 6 · Persistence, export, and restore boundaries diff --git a/docs/architecture/botharness-architecture.md b/docs/architecture/botharness-architecture.md index aedce1a1cc..08830fd60f 100644 --- a/docs/architecture/botharness-architecture.md +++ b/docs/architecture/botharness-architecture.md @@ -514,7 +514,7 @@ Custom Part 是有界像素网格,每格引用外形颜色或固定色并带 新 PersonaBot 记录全域名字种子版本;没有该记录的 PersonaBot 保持仅人类的种子。使用物种、新槽位或 Custom Part 的 recipe 提升 asset/schema 版本,旧 Client 显示保存的快照;既有 recipe 渲染不变。首个切片验证哥布林、左右侧发分片与一个自绘头饰,从编辑器到 Part Library、再到 Window Companion,并经过导出/导入。 -目前已实现:哥布林、精灵、矮人、兽人和花物种,左右侧发分片,胡子,中世纪服装与头饰,全域种子(#1210、#1212–#1214),以及第一条 Custom Part 路径(#1211)。自绘头饰的 recipe 是 asset version 3。Part Library 是 `avatar-part-library` 模块的 `avatar_part_library` 表(schema generation 73),以部件内容哈希为键,并保存名称、来源和父部件。Client 编辑器通过 `partLibraryList` 和 `partLibraryAdd` 两个桥接方法使用它;编辑器提供铅笔、橡皮、四连通填充、中线镜像、前后两层、撤销重做和 1× 预览。外形嵌入部件副本,因此部件会随 `.botharness/bot.json` 和 Bot Zip 一起带走。动物物种、导入部件、PNG 部件文件和更多绘制工具尚未实现。 +目前已实现:哥布林、精灵、矮人、兽人和花物种,左右侧发分片,胡子,中世纪服装与头饰,全域种子(#1210、#1212–#1214),第一条 Custom Part 路径(#1211),以及自绘头发(#1238)。自绘的前发、侧发或后发会替换对应的内置部件,原来的选择仍会保留;其中发色的像素会像内置头发一样上阴影,所以编辑时从当前样式压平成的格子开始。自绘头饰的 recipe 是 asset version 3。Part Library 是 `avatar-part-library` 模块的 `avatar_part_library` 表(schema generation 73),以部件内容哈希为键,并保存名称、来源和父部件。Client 编辑器通过 `partLibraryList` 和 `partLibraryAdd` 两个桥接方法使用它;编辑器提供铅笔、橡皮、四连通填充、中线镜像、前后两层、撤销重做和 1× 预览。外形嵌入部件副本,因此部件会随 `.botharness/bot.json` 和 Bot Zip 一起带走。动物物种、导入部件、PNG 部件文件和更多绘制工具尚未实现。 ## 6 · 持久化、导出与恢复边界 diff --git a/docs/assets/pr/1238-drawn-hair/README.md b/docs/assets/pr/1238-drawn-hair/README.md new file mode 100644 index 0000000000..1ac6d87b28 --- /dev/null +++ b/docs/assets/pr/1238-drawn-hair/README.md @@ -0,0 +1,35 @@ +# #1238 Draw hair pieces starting from the built-in style + +Captured on an isolated DSH instance built from this branch, with the `@botharness/pixel-avatar` 0.6.0 build (BotHarness/BotPixel#12). + +## Starting from the worn style + +| Bangs category: "Draw or edit this piece" | The worn bangs flattened to cells, with the keep-shape note | +| ----------------------------------------- | ----------------------------------------------------------- | +| ![built-in](hair-builtin-en-light.webp) | ![start](hair-start-en-light.webp) | + +## Reshaping + +| Bangs parted, a tuft on top and a gold pin | Left side hair extended into a long lock | +| ------------------------------------------ | ---------------------------------------- | +| ![bangs](hair-edited-en-light.webp) | ![side](side-edited-en-light.webp) | + +## Library, color and restore + +| Saved and worn | Recolored with the hair color | "Back to the built-in style" | +| ---------------------------------- | -------------------------------------- | ---------------------------------------- | +| ![saved](hair-saved-en-light.webp) | ![recolor](hair-recolor-en-light.webp) | ![restored](hair-restored-en-light.webp) | + +## Window Companion + +The speech is simulated. A test script drives the companion's own mouth layers; no model reply was involved. + +| Speaking with drawn hair | Close-up (×4, cropped from the screenshot) | +| ---------------------------------------- | -------------------------------------------- | +| ![speaking](hair-speaking-en-light.webp) | ![close-up](companion-closeup-en-light.webp) | + +## Full flow + +![full flow](drawn-hair-flow.gif) + +The same recording as video: [drawn-hair-flow.mp4](drawn-hair-flow.mp4) diff --git a/docs/assets/pr/1238-drawn-hair/companion-closeup-en-light.webp b/docs/assets/pr/1238-drawn-hair/companion-closeup-en-light.webp new file mode 100644 index 0000000000..d51f8f385d Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/companion-closeup-en-light.webp differ diff --git a/docs/assets/pr/1238-drawn-hair/drawn-hair-flow.gif b/docs/assets/pr/1238-drawn-hair/drawn-hair-flow.gif new file mode 100644 index 0000000000..ad8ce17ebd Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/drawn-hair-flow.gif differ diff --git a/docs/assets/pr/1238-drawn-hair/drawn-hair-flow.mp4 b/docs/assets/pr/1238-drawn-hair/drawn-hair-flow.mp4 new file mode 100644 index 0000000000..aac97ebc13 Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/drawn-hair-flow.mp4 differ diff --git a/docs/assets/pr/1238-drawn-hair/hair-builtin-en-light.webp b/docs/assets/pr/1238-drawn-hair/hair-builtin-en-light.webp new file mode 100644 index 0000000000..bf8178c1a5 Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/hair-builtin-en-light.webp differ diff --git a/docs/assets/pr/1238-drawn-hair/hair-edited-en-light.webp b/docs/assets/pr/1238-drawn-hair/hair-edited-en-light.webp new file mode 100644 index 0000000000..e7953e597e Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/hair-edited-en-light.webp differ diff --git a/docs/assets/pr/1238-drawn-hair/hair-recolor-en-light.webp b/docs/assets/pr/1238-drawn-hair/hair-recolor-en-light.webp new file mode 100644 index 0000000000..4bcb48cdb7 Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/hair-recolor-en-light.webp differ diff --git a/docs/assets/pr/1238-drawn-hair/hair-restored-en-light.webp b/docs/assets/pr/1238-drawn-hair/hair-restored-en-light.webp new file mode 100644 index 0000000000..d256ac0c6a Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/hair-restored-en-light.webp differ diff --git a/docs/assets/pr/1238-drawn-hair/hair-saved-en-light.webp b/docs/assets/pr/1238-drawn-hair/hair-saved-en-light.webp new file mode 100644 index 0000000000..971076f154 Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/hair-saved-en-light.webp differ diff --git a/docs/assets/pr/1238-drawn-hair/hair-speaking-en-light.webp b/docs/assets/pr/1238-drawn-hair/hair-speaking-en-light.webp new file mode 100644 index 0000000000..714115e3e9 Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/hair-speaking-en-light.webp differ diff --git a/docs/assets/pr/1238-drawn-hair/hair-start-en-light.webp b/docs/assets/pr/1238-drawn-hair/hair-start-en-light.webp new file mode 100644 index 0000000000..6a4de7e328 Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/hair-start-en-light.webp differ diff --git a/docs/assets/pr/1238-drawn-hair/side-edited-en-light.webp b/docs/assets/pr/1238-drawn-hair/side-edited-en-light.webp new file mode 100644 index 0000000000..3004435578 Binary files /dev/null and b/docs/assets/pr/1238-drawn-hair/side-edited-en-light.webp differ diff --git a/packages/client/src/client/avatar-appearance-editor.tsx b/packages/client/src/client/avatar-appearance-editor.tsx index 306b2e8a80..c49a49f0a3 100644 --- a/packages/client/src/client/avatar-appearance-editor.tsx +++ b/packages/client/src/client/avatar-appearance-editor.tsx @@ -16,7 +16,11 @@ import { type IllustratedAvatarRecipe, AVATAR_SWATCHES, withAvatarSpecies, - withAvatarHeadpiece, + withAvatarCustomPart, + wornAvatarPart, + hairPieceStart, + isHairPartSlot, + type PartSlot, customPartId, type PixelCustomPart, avatarSvg, @@ -121,6 +125,19 @@ const SPLIT = new Set([ ...AVATAR_PIECE_COLORS, ...EXTRAS, ]); +const PART_CATEGORY: Partial> = { + headpiece: 'headpiece', + bangs: 'bangs', + sideHair: 'leftSideHair', + rightSideHair: 'rightSideHair', + backHair: 'backHair', +}; +const PIECE_CATEGORY: Record = { + bangs: 'bangs', + leftSideHair: 'sideHair', + rightSideHair: 'rightSideHair', + backHair: 'backHair', +}; const V2_ONLY = (part: string, value: string | number) => (part === 'outfit' || part === 'accessory') && !(AVATAR_PARTS[part] as readonly (string | number)[]).includes(value); @@ -276,9 +293,13 @@ export function AvatarAppearanceEditor({ }): ReactElement { const [parts, setParts] = useState(); const [drawing, setDrawing] = useState<{ + slot: PartSlot; base: IllustratedAvatarRecipe; + restore: IllustratedAvatarRecipe; + backdrop?: IllustratedAvatarRecipe; initial?: PixelCustomPart; parent?: string; + note?: string; }>(); const [drafts, setDrafts] = useState>>(); const [family, setFamily] = useState('illustrated'); @@ -328,6 +349,139 @@ export function AvatarAppearanceEditor({ }; const current = bot.avatar !== undefined && bot.appearance === undefined ? 'image' : 'design'; const inUse = {t('profile.avatar.current')}; + const pieceSlot = draft?.family === 'illustrated' ? PART_CATEGORY[category] : undefined; + const pieceWorn = + pieceSlot !== undefined && + draft?.family === 'illustrated' && + wornAvatarPart(draft, pieceSlot) !== undefined; + const builtIn = (key: string, value: string): AvatarRecipe => { + const next = withPart(draft!, key, value); + const slot = PART_CATEGORY[key]; + return slot && next.family === 'illustrated' + ? withAvatarCustomPart(next, slot, undefined) + : next; + }; + const originLabel = (entry: PartLibraryEntry) => + `${entry.name || t('profile.avatar.part.untitled')} · ${entry.origins + .map((origin) => + t( + `profile.avatar.part.origin.${origin === 'imported-bot' ? 'importedBot' : origin === 'imported-file' ? 'importedFile' : 'drawn'}`, + ), + ) + .join(', ')}`; + const partEditor = () => + drawing ? ( + update(withAvatarCustomPart(drawing.base, drawing.slot, part))} + onSave={async (part, name) => { + const entry = await library?.add(part, name, drawing.parent); + if (!entry) return false; + setParts((current) => [entry, ...(current ?? []).filter((item) => item.id !== entry.id)]); + update(withAvatarCustomPart(drawing.base, drawing.slot, entry.part)); + setDrawing(undefined); + return true; + }} + onCancel={() => { + update(drawing.restore); + setDrawing(undefined); + }} + t={t} + /> + ) : null; + const partActions = (slot: PartSlot, recipe: IllustratedAvatarRecipe) => { + const worn = wornAvatarPart(recipe, slot); + const hair = isHairPartSlot(slot); + const own = (parts ?? []).filter((entry) => entry.part.slot === slot); + const draw = () => + setDrawing( + hair + ? { + slot, + base: withAvatarCustomPart(recipe, slot, undefined), + restore: recipe, + backdrop: withPart( + withAvatarCustomPart(recipe, slot, undefined), + PIECE_CATEGORY[slot]!, + 'none', + ) as IllustratedAvatarRecipe, + initial: hairPieceStart(recipe, slot), + ...(worn + ? { parent: customPartId(worn) } + : { note: t('profile.avatar.part.flattenNote') }), + } + : { slot, base: recipe, restore: recipe }, + ); + return ( + <> +
+ + {worn && !hair ? ( + + ) : null} + {worn && hair ? ( + + ) : null} +
+ {hair ? null : ( + update(withAvatarCustomPart(recipe, slot, undefined))} + /> + )} + {own.map((entry) => ( + update(withAvatarCustomPart(recipe, slot, entry.part))} + /> + ))} + {!hair && parts !== undefined && own.length === 0 ? ( +

{t('profile.avatar.part.libraryEmpty')}

+ ) : null} + + ); + }; return (
{ setCategory(key); - if (key === 'headpiece' && parts === undefined && library) + if (PART_CATEGORY[key] && parts === undefined && library) void library.load().then((loaded) => { if (loaded) setParts(loaded); }); @@ -543,88 +697,7 @@ export function AvatarAppearanceEditor({ id="bh-avatar-panel" aria-labelledby="bh-avatar-tab-headpiece" > - {drawing ? ( - update(withAvatarHeadpiece(drawing.base, part))} - onSave={async (part, name) => { - const entry = await library?.add(part, name, drawing.parent); - if (!entry) return false; - setParts((current) => [ - entry, - ...(current ?? []).filter((item) => item.id !== entry.id), - ]); - update(withAvatarHeadpiece(drawing.base, entry.part)); - setDrawing(undefined); - return true; - }} - onCancel={() => { - update(drawing.base); - setDrawing(undefined); - }} - t={t} - /> - ) : ( - <> -
- - {draft.assetVersion === 3 ? ( - - ) : null} -
- update(withAvatarHeadpiece(draft, undefined))} - /> - {(parts ?? []).map((entry) => ( - - t( - `profile.avatar.part.origin.${origin === 'imported-bot' ? 'importedBot' : origin === 'imported-file' ? 'importedFile' : 'drawn'}`, - ), - ) - .join(', ')}`} - onSelect={() => update(withAvatarHeadpiece(draft, entry.part))} - /> - ))} - {parts !== undefined && parts.length === 0 ? ( -

- {t('profile.avatar.part.libraryEmpty')} -

- ) : null} - - )} + {drawing?.slot === 'headpiece' ? partEditor() : partActions('headpiece', draft)} ) : category === 'presets' ? (
) : null} - {(spec.parts[category] ?? []).map((value) => ( + {pieceSlot && drawing?.slot === pieceSlot ? partEditor() : null} + {pieceSlot && drawing?.slot !== pieceSlot && draft.family === 'illustrated' + ? partActions(pieceSlot, draft) + : null} + {(drawing && pieceSlot && drawing.slot === pieceSlot + ? [] + : (spec.parts[category] ?? []) + ).map((value) => ( set(category, value)} + onSelect={() => update(builtIn(category, value))} /> ))}
diff --git a/packages/client/src/client/custom-part-editor.tsx b/packages/client/src/client/custom-part-editor.tsx index 19b531e3c9..4910e9f689 100644 --- a/packages/client/src/client/custom-part-editor.tsx +++ b/packages/client/src/client/custom-part-editor.tsx @@ -10,7 +10,9 @@ import { paintPartLayer, partLayer, partToneColor, - withAvatarHeadpiece, + withAvatarCustomPart, + isHairPartSlot, + type PartSlot, type IllustratedAvatarRecipe, type PartColor, type PartInk, @@ -24,8 +26,6 @@ type Key = Parameters[0]; type Tool = 'pencil' | 'eraser' | 'fill'; type Layers = Record; -const SLOT = 'headpiece'; -const { width: W, height: H } = PART_SLOTS[SLOT]; const FIXED_COLORS: readonly PartColor[] = [ '#efb93f', '#f4f1ec', @@ -46,6 +46,9 @@ function inkColor(recipe: IllustratedAvatarRecipe, ink: PartInk): string { } export function CustomPartEditor({ + slot = 'headpiece', + note, + backdrop: shownBehind, recipe, initial, onChange, @@ -53,6 +56,9 @@ export function CustomPartEditor({ onCancel, t, }: { + slot?: PartSlot | undefined; + note?: string | undefined; + backdrop?: IllustratedAvatarRecipe | undefined; recipe: IllustratedAvatarRecipe; initial?: PixelCustomPart | undefined; onChange(part: PixelCustomPart): void; @@ -60,9 +66,11 @@ export function CustomPartEditor({ onCancel(): void; t: BotHarnessTranslate; }): ReactElement { + const { width: W, height: H } = PART_SLOTS[slot]; + const hair = isHairPartSlot(slot); const [layers, setLayers] = useState(() => ({ - front: initial ? partLayer(SLOT, initial.front) : emptyPartLayer(SLOT), - back: initial ? partLayer(SLOT, initial.back) : emptyPartLayer(SLOT), + front: initial ? partLayer(slot, initial.front) : emptyPartLayer(slot), + back: initial ? partLayer(slot, initial.back) : emptyPartLayer(slot), })); const [past, setPast] = useState([]); const [future, setFuture] = useState([]); @@ -75,23 +83,23 @@ export function CustomPartEditor({ const [busy, setBusy] = useState(false); const [failed, setFailed] = useState(false); const drawing = useRef(undefined); - const bare = useMemo(() => withAvatarHeadpiece(recipe, undefined), [recipe]); - const part = useMemo(() => createCustomPart(SLOT, layers), [layers]); - const wearing = useMemo(() => withAvatarHeadpiece(recipe, part), [recipe, part]); - const backdrop = useMemo(() => avatarSvg(bare), [bare]); + const bare = useMemo(() => withAvatarCustomPart(recipe, slot, undefined), [recipe]); + const part = useMemo(() => createCustomPart(slot, layers), [layers]); + const wearing = useMemo(() => withAvatarCustomPart(recipe, slot, part), [recipe, part]); + const backdrop = useMemo(() => avatarSvg(shownBehind ?? bare), [shownBehind, bare]); const preview = useMemo(() => avatarSvg(wearing), [wearing]); const empty = part.front.length === 0 && part.back.length === 0; const commit = (next: Layers) => { setLayers(next); - onChange(createCustomPart(SLOT, next)); + onChange(createCustomPart(slot, next)); }; const applyAt = (base: Layers, x: number, y: number): Layers => { const value = tool === 'eraser' ? null : ink; const target = tool === 'fill' - ? fillPartLayer(SLOT, base[layer], x, y, value, mirror) - : paintPartLayer(SLOT, base[layer], [[x, y]], value, mirror); + ? fillPartLayer(slot, base[layer], x, y, value, mirror) + : paintPartLayer(slot, base[layer], [[x, y]], value, mirror); return { ...base, [layer]: target }; }; const start = (x: number, y: number) => { @@ -189,7 +197,7 @@ export function CustomPartEditor({ {t('profile.avatar.part.mirror')}