${p.includes("<") ? p : esc(t(p))}
${esc(t("Original rulebook"))} ↗ · ${esc(t("Two-player rules"))} ↗
`; + return `${p.includes("<") ? p : prose(p)}
${esc(t("Original rulebook"))} ↗ · ${esc(t("Two-player rules"))} ↗
`; } diff --git a/viewer/style.css b/viewer/style.css index d15d8e6..66a4aaa 100644 --- a/viewer/style.css +++ b/viewer/style.css @@ -1889,3 +1889,19 @@ body:has(.vanuatu) { vertical-align: -2px; flex-shrink: 0; } + +/* Inline rules/tutorial symbols stay legible at prose size and keep native + tooltip labels. They do not intercept gestures or add another scroll area. */ +:is(.vanuatu, .vanuatu-tutorial) .prose-icon { + display: inline-block; + vertical-align: -0.3em; + line-height: 1; + white-space: nowrap; +} +:is(.vanuatu, .vanuatu-tutorial) .prose-icon > .icon { + width: 1.55em; + height: 1.55em; + min-width: 20px; + min-height: 20px; + vertical-align: baseline; +} diff --git a/viewer/tutorial-mount.js b/viewer/tutorial-mount.js index 5898501..0d9961c 100644 --- a/viewer/tutorial-mount.js +++ b/viewer/tutorial-mount.js @@ -2,6 +2,8 @@ import { createTutorial } from "@boardgamers/protocol/tutorial"; import { mountTutorialGuide } from "@boardgamers/protocol/tutorial/dom"; import { stripSecret } from "../engine/index.js"; import { chapters } from "./tutorials.js"; +import { pictogramText } from "./prose.js"; +import { translateText } from "./localization/index.js"; import { mountGame } from "./ui.js"; export async function mountLesson(target, options) { const config = chapters[options.chapter]; @@ -41,7 +43,24 @@ export async function mountLesson(target, options) { const unmount = mountTutorialGuide(guide, tutorial, { nextChapter: options.nextChapter, }); + // The protocol owns the guide and navigation. Format its authored paragraphs + // after each snapshot; no DOM observer or changes to the board are needed. + const paragraphs = guide.querySelectorAll( + ".bgs-tutorial-body > p:nth-child(-n+2)", + ); + for (const paragraph of paragraphs) paragraph.setAttribute("translate", "no"); + const offProse = tutorial.subscribe((snapshot) => { + [snapshot.text, snapshot.hint].forEach((source, i) => { + const paragraph = paragraphs[i]; + if (!paragraph || !source) return; + paragraph.innerHTML = pictogramText( + translateText(source, options.locale), + options.locale, + ); + }); + }); return () => { + offProse(); off(); unmount(); tutorial.destroy(); diff --git a/viewer/ui.js b/viewer/ui.js index a718de4..34a8e03 100644 --- a/viewer/ui.js +++ b/viewer/ui.js @@ -27,6 +27,7 @@ import { boardSvg, center, tilePreviewSvg } from "./board.js"; import { mountMapZoom } from "./map-zoom.js"; import { translator, characterHelp } from "./labels.js"; import { mountActivity } from "./activity.js"; +import { pictogramText } from "./prose.js"; import { rulesHtml } from "./rules.js"; import { createMoveSound } from "./sound.js"; import { @@ -169,6 +170,8 @@ export function mountGame(target, options = {}) { const own = () => s?.players[player]; const charName = (c) => esc(CHARACTERS[c]?.["name"] ?? c); const charHelp = (c) => esc(characterHelp[c]?.[0] ?? ""); + const charHelpHtml = (c) => + `${pictogramText(translateText(characterHelp[c]?.[0] ?? "", lang), lang)}`; function btn(content, attr = "", className = "") { return ``; } @@ -346,7 +349,7 @@ export function mountGame(target, options = {}) { .map((m) => { const c = CHARACTERS[m.character]; return btn( - `${charHelp(m.character)}
${moveButton(m, true)}${charHelpHtml(m.character)}
${moveButton(m, true)}${charHelp(d.character)}
${"Once per round."}${charHelpHtml(d.character)}
${"Once per round."}