Add reusable NPC dialog box and showroom tutorial - #1
Open
moufmouf wants to merge 1 commit into
Open
Conversation
When the player enters zoneShowStep1, the bot in showroom room 1 opens a video-game-like dialog box (fixed iframe at the bottom of the screen) and runs a tutorial of the 5 showroom rooms, panning the camera to each room (zoneShowStep2-5) as it is described. The dialog box itself is a reusable, map-agnostic module (src/dialog-box/) meant to be extracted into a separate NPM library later: openDialog() in the main script drives an iframe UI through local player variables, and per-step onDisplay hooks keep side effects (camera moves) in the caller. Also upgrades wa-map-optimizer-vite to 1.3.1: 1.2.3 had an un-awaited writeFile that produced an empty dist/campus.tmj once an extra HTML entry (npc-dialog.html) was added to the build inputs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When the player enters
zoneShowStep1(next to the bot sprite in showroom room 1), a video-game-like dialog box opens at the bottom of the screen and runs a 10-step tutorial of the 5 showroom rooms. On room-specific steps the camera pans to the matching zone (zoneShowStep2…zoneShowStep5, read from the Tiled map at runtime) and returns to the player at the end. Walking out of the zone closes the dialog; re-entering restarts it.How
src/dialog-box/— reusable, map-agnostic module (intended for later extraction into a separate NPM library):api.ts: main-script side.openDialog(steps, options)opens the box and resolves when it closes; each step has an optionalonDisplayhook that runs in the main script, so all side effects (camera…) stay in the caller and the box stays generic.closeDialog()force-closes.iframe.ts+style.ts: the UI (avatar, name, text, step counter, Next/Close button), rendered inside a fixed iframe opened withWA.ui.website.open.types.ts: the two local player variables used for cross-iframe communication (dialogBoxDatamain→iframe,dialogBoxEventiframe→main, with a timestamp so repeated events still fireonVariableChange).npc-dialog.html— thin wrapper page for the iframe. Loadsiframe_api.jsfrom the embedding server's origin (viadocument.referrer) so it works on staging, prod and self-hosted alike, and declarescolor-scheme: darkto keep the iframe transparent over WorkAdventure's dark theme.src/showroomTutorial.ts— the map-specific tutorial (French texts, camera hooks). NPC name is a placeholder constant (Cubi).src/main.ts— wires thezoneShowStep1enter/leave events (opens/closes the tutorial, disables proximity meetings while in the zone).npc-avatar.png— front-facing head cropped fromtilesets/Bot1.png, used as the default avatar.campus.tmj— adds thezoneShowStep5area (terrace) used as a camera target.Reviewer notes
wa-map-optimizer-viteis upgraded 1.2.3 → 1.3.1: 1.2.3 has an un-awaitedwriteFilerace that produced an emptydist/campus.tmjoncenpc-dialog.htmlwas added to the build inputs.npm run buildmappasses with 1.3.1.tscand the production build pass. The end-to-end run onhttps://play.staging.workadventu.re/_/zixd24ab2t/localhost:5173/campus.tmj#moveTo=zoneShowStep1should be double-checked visually (camera framing is tunable viaCAMERA_PADDINGinshowroomTutorial.ts).🤖 Generated with Claude Code