Skip to content

Add Zelda-like typewriter effect to the NPC dialog box - #2

Open
moufmouf wants to merge 3 commits into
npc-dialog-boxfrom
npc-dialog-typewriter
Open

Add Zelda-like typewriter effect to the NPC dialog box#2
moufmouf wants to merge 3 commits into
npc-dialog-boxfrom
npc-dialog-typewriter

Conversation

@moufmouf

Copy link
Copy Markdown

Stacked on #1.

What

The dialog text is now revealed character by character (25 ms/char), Zelda-style:

  • A click while the text is still typing reveals it instantly instead of advancing — the classic RPG behavior. Only a click on fully revealed text moves to the next step.
  • Skip clicks emit no dialogBoxEvent, so the main script's per-step onDisplay hooks (camera pans) are unaffected.
  • The not-yet-typed remainder of the text stays in the DOM as an invisible span, so line-wrapping and the box layout never shift during the animation.

The speed is one constant (TYPEWRITER_INTERVAL_MS in src/dialog-box/iframe.ts) if 25 ms feels too fast/slow.

Also

src/main.ts: the pre-existing "Plan & Aide" openModal call now passes the closable property, required after the @workadventure/iframe-api-typings bump that came with the lockfile update in #1 — without it tsc (and thus npm run buildmap) fails.

Testing

Verified with the mock-WA harness in a browser: partial reveal visible, skip-click reveals instantly without emitting events, advance/close events unchanged, tsc + npm run buildmap pass.

🤖 Generated with Claude Code

moufmouf and others added 3 commits August 20, 2026 15:04
The step text is now revealed character by character (25ms/char).
Clicking the button while the text is typing reveals it instantly
instead of advancing, like in classic RPG dialogs; only a click on a
fully revealed text advances to the next step, so the main script's
per-step hooks are unaffected by skip clicks.

The not-yet-typed remainder stays in the DOM as an invisible span, so
line-wrapping and layout never shift during the animation.

Also adds the now-required `closable` property to the pre-existing
"Plan & Aide" modal call, following an iframe-api-typings bump.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A click anywhere on the box (text, avatar, background) now triggers the
same action as the button: complete the typewriter reveal, else advance
to the next step, else close. The click handler moved from the button to
the box; button clicks bubble to it, so they keep working and fire once.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Space triggers the same reveal/next/close cascade as a click. Held-key
repeats are ignored, and the keydown is default-prevented so a focused
button's native space activation cannot fire the action twice. Keys
reach the iframe once it has focus (after a first click on the box).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant