see your own pet

This commit is contained in:
2026-02-08 01:15:03 +08:00
parent f0cb2fd1d0
commit 624ee9a222
2 changed files with 25 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
import { listen } from "@tauri-apps/api/event"; import { listen } from "@tauri-apps/api/event";
import { onMount } from "svelte"; import { onMount } from "svelte";
import type { AppMetadata } from "../../types/bindings/AppMetadata"; import type { AppMetadata } from "../../types/bindings/AppMetadata";
import type { DollDto } from "../../types/bindings/DollDto";
let innerWidth = $state(0); let innerWidth = $state(0);
let innerHeight = $state(0); let innerHeight = $state(0);
@@ -36,6 +37,12 @@
return $friendsUserStatuses[userId]; return $friendsUserStatuses[userId];
} }
function getUserDoll(): DollDto | undefined {
const user = $appData?.user;
if (!user || !user.activeDollId) return undefined;
return $appData?.dolls?.find((d) => d.id === user.activeDollId);
}
let appMetadata: AppMetadata | null = $state(null); let appMetadata: AppMetadata | null = $state(null);
onMount(() => { onMount(() => {
@@ -145,5 +152,21 @@
{/if} {/if}
{/each} {/each}
{/if} {/if}
{#if $appData?.user && getUserDoll()}
<DesktopPet
id={$appData.user.id}
targetX={$cursorPositionOnScreen.mapped.x * innerWidth}
targetY={$cursorPositionOnScreen.mapped.y * innerHeight}
user={{
id: $appData.user.id,
name: $appData.user.name,
username: $appData.user.username,
activeDoll: getUserDoll() ?? null,
}}
userStatus={undefined}
doll={getUserDoll()}
isInteractive={false}
/>
{/if}
</div> </div>
</div> </div>

View File

@@ -170,7 +170,9 @@
</div> </div>
{/if} {/if}
<button <button
disabled={!isInteractive}
onclick={() => { onclick={() => {
if (!isInteractive) return;
isPetMenuOpen = !isPetMenuOpen; isPetMenuOpen = !isPetMenuOpen;
if (!isPetMenuOpen) { if (!isPetMenuOpen) {
// Clear message when closing menu manually // Clear message when closing menu manually