diff --git a/src/assets/icons/send.svelte b/src/assets/icons/send.svelte new file mode 100644 index 0000000..3f404c4 --- /dev/null +++ b/src/assets/icons/send.svelte @@ -0,0 +1,15 @@ + diff --git a/src/events/pet-message.ts b/src/events/pet-message.ts new file mode 100644 index 0000000..32863be --- /dev/null +++ b/src/events/pet-message.ts @@ -0,0 +1,27 @@ +import { writable } from "svelte/store"; +import { commands } from "$lib/bindings"; + +export const openPetMessageSendUserId = writable(null); + +function menuStateId(userId: string) { + return `${userId}:pet-message-send`; +} + +export function openPetMessageSend(userId: string) { + openPetMessageSendUserId.update((currentUserId) => { + if (currentUserId && currentUserId !== userId) { + void commands.setPetMenuState(menuStateId(currentUserId), false); + } + return userId; + }); + void commands.setPetMenuState(menuStateId(userId), true); +} + +export function closePetMessageSend() { + openPetMessageSendUserId.update((currentUserId) => { + if (currentUserId) { + void commands.setPetMenuState(menuStateId(currentUserId), false); + } + return null; + }); +} diff --git a/src/routes/scene/+page.svelte b/src/routes/scene/+page.svelte index 9ed26a6..5c5a06b 100644 --- a/src/routes/scene/+page.svelte +++ b/src/routes/scene/+page.svelte @@ -13,7 +13,8 @@ import DebugBar from "./components/debug-bar.svelte"; import Neko from "./components/neko/neko.svelte"; import PetMenu from "./components/pet-menu/pet-menu.svelte"; - import { createPetActions } from "./components/pet-menu/events"; + import PetMessagePop from "./components/pet-message-pop.svelte"; + import PetMessageSend from "./components/pet-message-send.svelte"; import type { UserBasicDto } from "$lib/bindings"; function getFriend(friendId: string): UserBasicDto | undefined { @@ -50,6 +51,8 @@ initialY={position.raw.y} > + + {/if} {/each} diff --git a/src/routes/scene/components/pet-menu/events.ts b/src/routes/scene/components/pet-menu/events.ts index 71b5863..137dac1 100644 --- a/src/routes/scene/components/pet-menu/events.ts +++ b/src/routes/scene/components/pet-menu/events.ts @@ -1,4 +1,5 @@ import type { UserBasicDto } from "$lib/bindings"; +import { openPetMessageSend } from "../../../../events/pet-message"; export type CloseHandler = () => void; @@ -15,7 +16,7 @@ export function createPetActions(user: UserBasicDto) { icon: "💬", label: `Message ${user.name}`, onClick: () => { - console.log(`Message ${user.name}`); + openPetMessageSend(user.id); }, }, { diff --git a/src/routes/scene/components/pet-message-pop.svelte b/src/routes/scene/components/pet-message-pop.svelte new file mode 100644 index 0000000..7680546 --- /dev/null +++ b/src/routes/scene/components/pet-message-pop.svelte @@ -0,0 +1,75 @@ + + +
+ {#if interaction} +
+

+ {interaction.senderName} +

+
+

+ {interaction.content} +

+ {/if} +
diff --git a/src/routes/scene/components/pet-message-send.svelte b/src/routes/scene/components/pet-message-send.svelte new file mode 100644 index 0000000..5261120 --- /dev/null +++ b/src/routes/scene/components/pet-message-send.svelte @@ -0,0 +1,132 @@ + + +
+ + +
+
+

+ {messageText.length}/{MAX_MESSAGE_LENGTH} +

+
+ +
+