diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bdafe400a..bdd46cd1e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Pixel Avatars can be an elf, dwarf, orc or talking flower with beards, medieval ### Added +- Every other part can be drawn as well: outfit, accessory, beard, glasses, nose, cheeks, petals and flower base each offer **Draw or edit this piece**, starting from the style you wear. Pixels in an appearance color stay recolorable. A drawn face part never covers the speaking mouth. Drawn parts hide where the species or headwear hides the built-in part, and **Back to the built-in style** restores your choice. Picking a built-in style no longer upgrades an older Avatar's recipe unless a drawn part is being taken off ([#1240](https://github.com/BotHarness/DeepSeekBot/issues/1240)). - 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)). diff --git a/CHANGELOG.zh.md b/CHANGELOG.zh.md index fc26b2d6bf..c59ae11303 100644 --- a/CHANGELOG.zh.md +++ b/CHANGELOG.zh.md @@ -13,6 +13,7 @@ ### Added +- 其他部件也都能自己画了:衣服、配饰、胡子、眼镜、鼻子、腮红、花瓣和花盆都有 **绘制/修改这一片**,从当前戴的样式开始;外形颜色的像素仍会跟着变色;自绘的脸部部件不会挡住说话的嘴;物种或头饰隐藏内置部件时,自绘部件也会隐藏;**换回内置样式** 可恢复原来的选择。只有在取下自绘部件时,选内置样式才会升级旧头像的 recipe([#1240](https://github.com/BotHarness/DeepSeekBot/issues/1240))。 - 头发也能自己画了:在前发、左右侧发或后发里,从当前戴的样式开始(压平成像素),用同样的工具改形状,存进部件库并戴在这个位置。自绘头发会像内置头发一样上阴影、跟着发色变色、随头部转动,戴头盔/兜帽或变成花朵时会隐藏。点 **换回内置样式** 可恢复原来的选择([#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))。 diff --git a/docs/assets/pr/1240-drawn-parts/README.md b/docs/assets/pr/1240-drawn-parts/README.md new file mode 100644 index 0000000000..1244105a74 --- /dev/null +++ b/docs/assets/pr/1240-drawn-parts/README.md @@ -0,0 +1,21 @@ +# #1240 Draw every other part starting from the built-in style + +Captured on an isolated DSH instance built from this branch with `@botharness/pixel-avatar` 0.7.0 (BotHarness/BotPixel#15). + +| Outfit flattened from the worn sailor outfit | Gold badges and a darker hem drawn in | +| -------------------------------------------- | --------------------------------------------- | +| ![outfit start](outfit-start-en-light.webp) | ![outfit edited](outfit-edited-en-light.webp) | + +| Round glasses flattened | Lenses filled pink | +| --------------------------------------------- | ----------------------------------------------- | +| ![glasses start](glasses-start-en-light.webp) | ![glasses edited](glasses-edited-en-light.webp) | + +| Shirt color recolors the shirt-colored pixels of the drawn outfit | Window Companion speaking (simulated) | +| ----------------------------------------------------------------- | ----------------------------------------- | +| ![recolor](parts-recolor-en-light.webp) | ![speaking](parts-speaking-en-light.webp) | + +The speech is simulated: a test script drives the companion's own mouth layers, and no model reply was involved. + +![full flow](drawn-parts-flow.gif) + +Video: [drawn-parts-flow.mp4](drawn-parts-flow.mp4) diff --git a/docs/assets/pr/1240-drawn-parts/drawn-parts-flow.gif b/docs/assets/pr/1240-drawn-parts/drawn-parts-flow.gif new file mode 100644 index 0000000000..51e8403dfb Binary files /dev/null and b/docs/assets/pr/1240-drawn-parts/drawn-parts-flow.gif differ diff --git a/docs/assets/pr/1240-drawn-parts/drawn-parts-flow.mp4 b/docs/assets/pr/1240-drawn-parts/drawn-parts-flow.mp4 new file mode 100644 index 0000000000..7b07c3abdc Binary files /dev/null and b/docs/assets/pr/1240-drawn-parts/drawn-parts-flow.mp4 differ diff --git a/docs/assets/pr/1240-drawn-parts/glasses-edited-en-light.webp b/docs/assets/pr/1240-drawn-parts/glasses-edited-en-light.webp new file mode 100644 index 0000000000..14afb63642 Binary files /dev/null and b/docs/assets/pr/1240-drawn-parts/glasses-edited-en-light.webp differ diff --git a/docs/assets/pr/1240-drawn-parts/glasses-start-en-light.webp b/docs/assets/pr/1240-drawn-parts/glasses-start-en-light.webp new file mode 100644 index 0000000000..8f2ccf73f9 Binary files /dev/null and b/docs/assets/pr/1240-drawn-parts/glasses-start-en-light.webp differ diff --git a/docs/assets/pr/1240-drawn-parts/outfit-edited-en-light.webp b/docs/assets/pr/1240-drawn-parts/outfit-edited-en-light.webp new file mode 100644 index 0000000000..b97dd72d07 Binary files /dev/null and b/docs/assets/pr/1240-drawn-parts/outfit-edited-en-light.webp differ diff --git a/docs/assets/pr/1240-drawn-parts/outfit-start-en-light.webp b/docs/assets/pr/1240-drawn-parts/outfit-start-en-light.webp new file mode 100644 index 0000000000..123829b78f Binary files /dev/null and b/docs/assets/pr/1240-drawn-parts/outfit-start-en-light.webp differ diff --git a/docs/assets/pr/1240-drawn-parts/parts-recolor-en-light.webp b/docs/assets/pr/1240-drawn-parts/parts-recolor-en-light.webp new file mode 100644 index 0000000000..19dd3b155a Binary files /dev/null and b/docs/assets/pr/1240-drawn-parts/parts-recolor-en-light.webp differ diff --git a/docs/assets/pr/1240-drawn-parts/parts-speaking-en-light.webp b/docs/assets/pr/1240-drawn-parts/parts-speaking-en-light.webp new file mode 100644 index 0000000000..a9297a914a Binary files /dev/null and b/docs/assets/pr/1240-drawn-parts/parts-speaking-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 c49a49f0a3..c59fc5ee33 100644 --- a/packages/client/src/client/avatar-appearance-editor.tsx +++ b/packages/client/src/client/avatar-appearance-editor.tsx @@ -20,6 +20,8 @@ import { wornAvatarPart, hairPieceStart, isHairPartSlot, + isReplacePartSlot, + replacePartStart, type PartSlot, customPartId, type PixelCustomPart, @@ -131,12 +133,14 @@ const PART_CATEGORY: Partial> = { sideHair: 'leftSideHair', rightSideHair: 'rightSideHair', backHair: 'backHair', -}; -const PIECE_CATEGORY: Record = { - bangs: 'bangs', - leftSideHair: 'sideHair', - rightSideHair: 'rightSideHair', - backHair: 'backHair', + outfit: 'outfit', + accessory: 'accessory', + beard: 'beard', + glasses: 'glasses', + nose: 'nose', + cheeks: 'cheeks', + petals: 'petals', + flowerBase: 'flowerBase', }; const V2_ONLY = (part: string, value: string | number) => (part === 'outfit' || part === 'accessory') && @@ -357,7 +361,7 @@ export function AvatarAppearanceEditor({ const builtIn = (key: string, value: string): AvatarRecipe => { const next = withPart(draft!, key, value); const slot = PART_CATEGORY[key]; - return slot && next.family === 'illustrated' + return slot && next.family === 'illustrated' && wornAvatarPart(next, slot) ? withAvatarCustomPart(next, slot, undefined) : next; }; @@ -396,7 +400,7 @@ export function AvatarAppearanceEditor({ ) : null; const partActions = (slot: PartSlot, recipe: IllustratedAvatarRecipe) => { const worn = wornAvatarPart(recipe, slot); - const hair = isHairPartSlot(slot); + const hair = isHairPartSlot(slot) || isReplacePartSlot(slot); const own = (parts ?? []).filter((entry) => entry.part.slot === slot); const draw = () => setDrawing( @@ -405,15 +409,23 @@ export function AvatarAppearanceEditor({ slot, base: withAvatarCustomPart(recipe, slot, undefined), restore: recipe, - backdrop: withPart( - withAvatarCustomPart(recipe, slot, undefined), - PIECE_CATEGORY[slot]!, - 'none', - ) as IllustratedAvatarRecipe, - initial: hairPieceStart(recipe, slot), + backdrop: withAvatarCustomPart(recipe, slot, { + slot, + front: [], + back: [], + }) as IllustratedAvatarRecipe, + initial: isHairPartSlot(slot) + ? hairPieceStart(recipe, slot) + : replacePartStart(recipe, slot as Parameters[1]), ...(worn ? { parent: customPartId(worn) } - : { note: t('profile.avatar.part.flattenNote') }), + : { + note: t( + isHairPartSlot(slot) + ? 'profile.avatar.part.flattenNote' + : 'profile.avatar.part.flattenPartNote', + ), + }), } : { slot, base: recipe, restore: recipe }, ); diff --git a/packages/client/src/client/custom-part-editor.tsx b/packages/client/src/client/custom-part-editor.tsx index 4910e9f689..eeca31e38d 100644 --- a/packages/client/src/client/custom-part-editor.tsx +++ b/packages/client/src/client/custom-part-editor.tsx @@ -67,7 +67,7 @@ export function CustomPartEditor({ t: BotHarnessTranslate; }): ReactElement { const { width: W, height: H } = PART_SLOTS[slot]; - const hair = isHairPartSlot(slot); + const hair = slot !== 'headpiece'; const [layers, setLayers] = useState(() => ({ front: initial ? partLayer(slot, initial.front) : emptyPartLayer(slot), back: initial ? partLayer(slot, initial.back) : emptyPartLayer(slot), diff --git a/packages/client/src/client/locale.ts b/packages/client/src/client/locale.ts index 2a0bf3acb3..83b9ec0ab9 100644 --- a/packages/client/src/client/locale.ts +++ b/packages/client/src/client/locale.ts @@ -1759,6 +1759,7 @@ export const zh = { 'profile.avatar.part.drawPiece': '绘制/修改这一片', 'profile.avatar.part.removePiece': '换回内置样式', 'profile.avatar.part.flattenNote': '从当前样式开始:画好后形状固定,不再跟随脸型和发长变化。', + 'profile.avatar.part.flattenPartNote': '从当前样式开始:画好后形状固定,不再跟随脸型或物种变化。', 'profile.avatar.leftSideHairColor': '左侧发色', 'profile.avatar.rightSideHairColor': '右侧发色', 'profile.avatar.followHairColor': '跟随发色', @@ -4325,6 +4326,8 @@ My relationship with you, established lore and topics to avoid: [fill in]. 'profile.avatar.part.removePiece': 'Back to the built-in style', 'profile.avatar.part.flattenNote': 'Starting from the current style. The drawn piece keeps this shape and no longer follows face shape or hair length.', + 'profile.avatar.part.flattenPartNote': + 'Starting from the current style. The drawn part keeps this shape and no longer adapts to face shape or species.', 'profile.avatar.leftSideHairColor': 'Left side hair color', 'profile.avatar.rightSideHairColor': 'Right side hair color', 'profile.avatar.followHairColor': 'Follow hair color', diff --git a/packages/client/test/avatar-appearance-editor.test.ts b/packages/client/test/avatar-appearance-editor.test.ts index 18a9c05546..25325b12fc 100644 --- a/packages/client/test/avatar-appearance-editor.test.ts +++ b/packages/client/test/avatar-appearance-editor.test.ts @@ -21,6 +21,7 @@ import { canonicalCustomPart, customPartId, hairPieceStart, + replacePartStart, type PixelCustomPart, } from '../../core/src/bots/avatar-appearance.js'; import type { PartLibraryEntry } from '../../core/src/bots/part-library.js'; @@ -642,6 +643,68 @@ describe('Profile Avatar Appearance editing', () => { } }); + it('draws an outfit from the built-in style and switches back', async () => { + Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true }); + const save = vi.fn(async () => true); + const add = vi.fn(async (part: PixelCustomPart, name: string): Promise => ({ + id: customPartId(part), + part: canonicalCustomPart(part), + name, + origins: ['drawn'], + addedAt: '', + })); + const container = document.createElement('div'); + document.body.append(container); + const root = createRoot(container); + const bot = { + slug: 'ada', + displayName: 'Ada', + roles: [], + aggregateState: 'idle', + workspaces: [], + createdAt: '', + }; + const $ = (selector: string) => container.querySelector(selector); + const click = async (selector: string) => act(() => $(selector)!.click()); + const start = replacePartStart(seededAvatarRecipe('Ada'), 'outfit'); + const [x, y, color, tone] = start.front[0]!; + try { + await act(() => + root.render( + createElement(AvatarAppearanceEditor, { + bot, + channelId: 'dm-ada', + onSave: save, + library: { load: vi.fn(async () => []), add }, + t: zhTranslate, + }), + ), + ); + await click('[data-avatar-edit]'); + await click('[data-avatar-category="outfit"]'); + await click('[data-part-draw="outfit"]'); + expect($('[data-part-note]')?.textContent).toBe( + zhTranslate('profile.avatar.part.flattenPartNote'), + ); + expect($('[data-part-layer="back"]')).toBeNull(); + expect($(`[data-part-cell="${x},${y}"]`)?.getAttribute('data-part-ink')).toBe( + `${color}:${tone}`, + ); + await click('[data-part-save]'); + const [part] = add.mock.calls[0]!; + expect(part.slot).toBe('outfit'); + expect(part.front).toHaveLength(start.front.length); + await click('[data-avatar-save]'); + expect(save).toHaveBeenCalledWith( + 'dm-ada', + expect.objectContaining({ assetVersion: 3, outfitPart: canonicalCustomPart(part) }), + ); + } finally { + await act(() => root.unmount()); + container.remove(); + } + }); + it('retries loading the Part Library after a failed load', async () => { Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true }); const load = vi diff --git a/packages/core/package.json b/packages/core/package.json index 1698e130f6..fe59680190 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -14,7 +14,7 @@ "./package.json": "./package.json" }, "dependencies": { - "@botharness/pixel-avatar": "0.6.0", + "@botharness/pixel-avatar": "0.7.0", "@botharness/pixel-banner": "0.1.0", "@resvg/resvg-js": "2.6.2", "silk-wasm": "3.7.1" diff --git a/packages/core/src/bots/avatar-appearance.ts b/packages/core/src/bots/avatar-appearance.ts index 2758a6bf94..354ad514c7 100644 --- a/packages/core/src/bots/avatar-appearance.ts +++ b/packages/core/src/bots/avatar-appearance.ts @@ -44,6 +44,10 @@ export { withCustomPart as withAvatarCustomPart, wornPart as wornAvatarPart, hairPieceStart, + replacePartStart, + REPLACE_PART_SLOTS, + isReplacePartSlot, + type ReplacePartSlot, HAIR_PART_SLOTS, isHairPartSlot, type HairPartSlot, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02f26e3b41..a6e33386ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -568,8 +568,8 @@ importers: packages/core: dependencies: '@botharness/pixel-avatar': - specifier: 0.6.0 - version: 0.6.0 + specifier: 0.7.0 + version: 0.7.0 '@botharness/pixel-banner': specifier: 0.1.0 version: 0.1.0 @@ -1173,8 +1173,8 @@ packages: '@botharness/botui-core@0.3.0': resolution: {integrity: sha512-ZfuyXyAtxIijqxPb7zWKu3/aO3GKT8kTzQpCBYD08t9vOp858r/xL8BsQvwjswTTH2bTZ8saXBnUgjYBRnY8xQ==} - '@botharness/pixel-avatar@0.6.0': - resolution: {integrity: sha512-/faY4TNY47+8osEDPdLm0QTiGXwVPDbwEAFrZ+EqixNVpuRlz92H8fC3SZIc3IvxKxUWStCEj3JnzQl8MXjr2w==} + '@botharness/pixel-avatar@0.7.0': + resolution: {integrity: sha512-ehy9LsKSb0bpphNF/ieVT8IT+1WDjHSN+rKqR/fY1b6tLXHasmayntpIvKZK4D8UPwpDskCGrIipHxwG5aZTPg==} '@botharness/pixel-banner@0.1.0': resolution: {integrity: sha512-2qzZK8O73u9m97sCeQh9s/4QaRsMwCTM42n2HLxCHQNiQp7dYYhulYiYNviasr/9eAGR4ARZr3B06yOCD/Ge1A==} @@ -10790,7 +10790,7 @@ snapshots: '@botharness/botui-core@0.3.0': {} - '@botharness/pixel-avatar@0.6.0': + '@botharness/pixel-avatar@0.7.0': dependencies: '@botharness/pixel-morph': 0.2.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 28d572d048..34dbdc15d5 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -308,7 +308,7 @@ minimumReleaseAgeExclude: - '@deepseek-ai/dsh-experimental-schedule-bundle@0.2.0-rc.1' - '@deepseek-ai/dsh-host-product-telemetry-otel@0.2.0-rc.1' - '@deepseek-ai/dsh-otel@0.2.0-rc.1' - - '@botharness/pixel-avatar@0.1.0 || 0.2.0 || 0.3.0 || 0.4.0 || 0.5.0 || 0.6.0' + - '@botharness/pixel-avatar@0.1.0 || 0.2.0 || 0.3.0 || 0.4.0 || 0.5.0 || 0.6.0 || 0.7.0' - '@botharness/pixel-banner@0.1.0' - '@botharness/pixel-morph@0.1.0 || 0.2.0'