From 97e70432f06fbf3f68d4ff1da11b601e8ca6ad99 Mon Sep 17 00:00:00 2001 From: Moritz Ruth Date: Sat, 12 Apr 2025 23:29:25 +0200 Subject: [PATCH] Fix UI screens --- backend/game.ts | 8 ++-- backend/scene-types/interaction.ts | 9 ++-- frontend/App.vue | 4 +- frontend/components/TabbedContainer.vue | 6 ++- frontend/game.ts | 7 +-- .../{ObjectsTab.vue => InteractTab.vue} | 34 +++++++++------ .../interaction/InteractionQueueItemCard.vue | 40 +++++++++++------- .../scene-types/interaction/ObjectCard.vue | 5 ++- .../scene-types/interaction/ObjectPicture.vue | 2 +- .../scene-types/interaction/PlayerView.vue | 30 ++++++++++++- frontend/scene-types/interaction/QueueTab.vue | 20 ++++++--- frontend/scene-types/interaction/index.ts | 35 ++++++++++++++- frontend/screens/PlayerScreen.vue | 2 +- frontend/trpc.ts | 2 +- public/objects/buehnenbildner.png | Bin 0 -> 40180 bytes public/objects/escobar.png | Bin 0 -> 32396 bytes public/objects/h-milch.png | Bin 0 -> 30376 bytes public/objects/haferflocken.png | Bin 0 -> 30943 bytes public/objects/haustür.png | Bin 11838 -> 0 bytes public/objects/kaffeebohnen.png | Bin 0 -> 36207 bytes public/objects/kakao.png | Bin 16479 -> 0 bytes public/objects/kakaopulver.png | Bin 16564 -> 0 bytes public/objects/kettensaege.png | Bin 0 -> 30695 bytes public/objects/kuehlschrank.png | Bin 0 -> 37658 bytes public/objects/kühlschrank.png | Bin 23849 -> 0 bytes public/objects/milch.png | Bin 21845 -> 30508 bytes public/objects/muesli-unfertig.png | Bin 0 -> 34087 bytes public/objects/muesli.png | Bin 0 -> 49417 bytes public/objects/offene-haustür.png | Bin 12809 -> 0 bytes public/objects/peruecke.png | Bin 0 -> 17915 bytes public/objects/redner.png | Bin 0 -> 28930 bytes public/objects/schlüssel.png | Bin 19356 -> 0 bytes public/objects/schüssel.png | Bin 17997 -> 0 bytes public/objects/thunfisch.png | Bin 0 -> 31211 bytes public/objects/vorhang.png | Bin 0 -> 14146 bytes shared/scene-types/interaction.ts | 2 +- 36 files changed, 149 insertions(+), 57 deletions(-) rename frontend/scene-types/interaction/{ObjectsTab.vue => InteractTab.vue} (72%) create mode 100644 public/objects/buehnenbildner.png create mode 100644 public/objects/escobar.png create mode 100644 public/objects/h-milch.png create mode 100644 public/objects/haferflocken.png delete mode 100644 public/objects/haustür.png create mode 100644 public/objects/kaffeebohnen.png delete mode 100644 public/objects/kakao.png delete mode 100644 public/objects/kakaopulver.png create mode 100644 public/objects/kettensaege.png create mode 100644 public/objects/kuehlschrank.png delete mode 100644 public/objects/kühlschrank.png create mode 100644 public/objects/muesli-unfertig.png create mode 100644 public/objects/muesli.png delete mode 100644 public/objects/offene-haustür.png create mode 100644 public/objects/peruecke.png create mode 100644 public/objects/redner.png delete mode 100644 public/objects/schlüssel.png delete mode 100644 public/objects/schüssel.png create mode 100644 public/objects/thunfisch.png create mode 100644 public/objects/vorhang.png diff --git a/backend/game.ts b/backend/game.ts index db4b8a5..ab7a554 100644 --- a/backend/game.ts +++ b/backend/game.ts @@ -2,7 +2,7 @@ import EventEmitter from "node:events" import type { PlayerBroadcast } from "../shared/broadcast" import { script } from "../shared/script" import type { SceneDefinition } from "../shared/script/types" -import { sceneTypesById } from "./scene-types" +import { type SceneEvent, sceneTypesById } from "./scene-types" import type { Tagged } from "type-fest" import type { SessionId } from "./session" @@ -32,7 +32,7 @@ export class Game { getConnectionPlayerBroadcasts(): PlayerBroadcast[] { const events: PlayerBroadcast[] = [] events.push({ type: "scene-changed", sceneId: this.currentScene.id }) - events.push(...this.currentScene.state.getConnectionEvents()) + events.push(...this.currentScene.state.getConnectionEvents().map((event: SceneEvent) => ({ type: "scene-event", event }))) return events } @@ -45,12 +45,14 @@ export class Game { const definition = script.scenesById.get(sceneId) if (definition === undefined) throw new Error(`Unknown scene: ${sceneId}`) const type = sceneTypesById[definition.type] + + this.eventBus.emit("player-broadcast", { type: "scene-changed", sceneId: sceneId }) + this.currentScene = { id: sceneId, definition, state: type.createState(this, definition as any) } - this.eventBus.emit("player-broadcast", { type: "scene-changed", sceneId: sceneId }) } withSceneState(type: Type, block: (state: ReturnType) => R): R | null { diff --git a/backend/scene-types/interaction.ts b/backend/scene-types/interaction.ts index 7a07495..d6dbb4b 100644 --- a/backend/scene-types/interaction.ts +++ b/backend/scene-types/interaction.ts @@ -19,14 +19,14 @@ export class InteractionSceneState implements SceneState private objectVisibilityById = new Map() constructor(private game: Game, private definition: InteractionSceneDefinition) { - definition.objectsById.entries().forEach(([id, o]) => this.objectVisibilityById.set(id, o.reveal)) + definition.objectsById.entries().forEach(([id, o]) => this.setObjectVisibility(id, o.reveal)) } getConnectionEvents(): InteractionSceneEvent[] { const events: InteractionSceneEvent[] = [] events.push(this.getVotesChangedEvent()) - this.objectVisibilityById.entries().forEach(([id, isVisible]) => events.push({ type: "object-visibility-changed", id, isVisible })) + this.objectVisibilityById.entries().forEach(([id, isVisible]) => events.push({ type: "object-visibility-changed", objectId: id, isVisible })) if (this.ongoingInteractionExecution !== null) events.push({ type: "interaction-execution-started", interaction: this.ongoingInteractionExecution }) @@ -107,7 +107,7 @@ export class InteractionSceneState implements SceneState switch (interaction.type) { case "use": if (interaction.consume) { - this.emit({ type: "object-visibility-changed", id: interaction.objectId, isVisible: false }) + this.emit({ type: "object-visibility-changed", objectId: interaction.objectId, isVisible: false }) } break @@ -139,10 +139,9 @@ export class InteractionSceneState implements SceneState setObjectVisibility(objectId: string, isVisible: boolean) { const current = this.objectVisibilityById.get(objectId) - if (current === undefined) throw new Error(`Unknown object: ${objectId}`) if (current === isVisible) return this.objectVisibilityById.set(objectId, isVisible) - this.emit({ type: "object-visibility-changed", id: objectId, isVisible }) + this.emit({ type: "object-visibility-changed", objectId: objectId, isVisible }) } } \ No newline at end of file diff --git a/frontend/App.vue b/frontend/App.vue index dd4c2e3..7836df3 100644 --- a/frontend/App.vue +++ b/frontend/App.vue @@ -1,8 +1,8 @@