Add modular story library and shared-progress translations
This commit is contained in:
+37
-12
@@ -8,10 +8,10 @@
|
||||
|
||||
- **What it is:** an offline illustrated logic-puzzle notebook ("Lumen", version 2.0.2+11).
|
||||
- **Stack:** Flutter 3.47.5 / Dart 3.13.4, Material widgets, no backend and no account.
|
||||
- **Entry point:** `main()` in `lib/main.dart` → `Book.load()` + `Progress.load()` → `Game(...)` → `await game.restore()` → `runApp(LumenApp(game: game))`.
|
||||
- **Entry point:** `main()` in `lib/main.dart` → `StoryLibrary.load()` + `Progress.load()` → open selected story/language → `Game(...)` → `await game.restore()` → `runApp(LumenApp(game: game))`. `Book.load()` remains an English Mara compatibility loader for existing tests/tools.
|
||||
- **State:** one `Game extends ChangeNotifier` (`lib/domain/game.dart`) owns the current screen, puzzle session, marks, undo history and progress. `_NotebookState` listens to it and rebuilds the active screen.
|
||||
- **Screens:** `Screen { home, story, contents, briefing, game, reveal }`, rendered by six builder methods in `_NotebookState`.
|
||||
- **Puzzle content:** twelve authored 7×7 pictures in `assets/campaign.json`; daily and classic boards are generated 5×5 puzzles.
|
||||
- **Story content:** an offline catalogue in `assets/library.json`; Mara has twelve authored 7×7 pictures, and the short Paper Boat example demonstrates English/German story packages. Daily and classic boards are generated 5×5 puzzles.
|
||||
- **Persistence:** local `SharedPreferencesAsync` behind `lib/services/progress.dart`; legacy Java saves are never imported.
|
||||
- **Platform:** Android is the tested target; iOS scaffolding exists but is unvalidated. `legacy/` is archived Java 1.7 and is excluded from builds and analysis.
|
||||
|
||||
@@ -32,9 +32,11 @@ lib/
|
||||
├── domain/
|
||||
│ ├── puzzle.dart Puzzle, JavaRandom, LogicSolver, Difficulty, Region, Hint
|
||||
│ ├── thinking.dart ThinkingAnalyzer, ThinkingReport — snapshot deduction waves and bounded hypothetical proofs
|
||||
│ ├── book.dart Book, CampaignLevel, StoryPage/StoryPageType — loads authored content
|
||||
│ ├── book.dart Book, CampaignLevel, StoryPage/StoryPageType — validated content and locale overlays
|
||||
│ ├── library.dart StoryDefinition, StoryLibrary — catalogue, locale resolution and cached books
|
||||
│ └── game.dart Game (ChangeNotifier), Screen/Mode, puzzle session, awards
|
||||
├── services/
|
||||
│ ├── translation.dart TranslationCatalog, MessageTranslator — separate UI catalogues and placeholders
|
||||
│ ├── progress.dart Progress — typed façade over SharedPreferencesAsync
|
||||
│ ├── ambience.dart Ambience, Soundscape — location loops, fades and narration ducking
|
||||
│ ├── narrator.dart Narrator — just_audio playback and passage cues
|
||||
@@ -42,9 +44,14 @@ lib/
|
||||
└── ui/
|
||||
├── paper.dart Paper, Leaf, Cover, Sketch, InkButton, PageSwipeBlocker
|
||||
├── board.dart Board, PencilMark painter, PixelPicture, PatternStamp
|
||||
└── discovery.dart Discovery — pattern-to-art transition and replay
|
||||
├── discovery.dart Discovery — pattern-to-art transition and replay
|
||||
├── translation.dart CopyScope, CopyText — translated controls, locale parsing and font fallback
|
||||
└── mara_story.dart Original-story presenter (part of main.dart); standard packages use standardStory
|
||||
|
||||
assets/
|
||||
├── library.json Story catalogue, IDs, asset paths and language metadata
|
||||
├── locales/ App UI catalogue index and English/German messages
|
||||
├── stories/paper-boat/ Small standard story with a German overlay
|
||||
├── campaign.json premise + 12 authored levels (chapter/title/object/before/after/picture/clues/areas; optional illustrationAsset)
|
||||
├── notebook.json sixteen stable cottage leaf records (type, speaker, campaignIndex, text source)
|
||||
├── narration/scripts.json canonical diary text, one record per recorded page
|
||||
@@ -131,10 +138,10 @@ Dependency rules:
|
||||
|
||||
## Runtime wiring
|
||||
|
||||
- `main()` sets the system overlay style, registers the Dancing Script OFL licence, loads `Book` and `Progress`, constructs `Game`, awaits `game.restore()`, then runs `LumenApp`.
|
||||
- `main()` sets the system overlay style, registers the Dancing Script OFL licence, initializes date symbols, loads the catalogue and progress, resolves the saved story and requested language, constructs `Game`, awaits `game.restore()`, then runs `LumenApp`.
|
||||
- `LumenApp` is a `MaterialApp` with seed colour `blue` (`#274956`), cream surface (`#f3e7cc`), `fontFamily: 'MaraHand'` and `Notebook` as `home`.
|
||||
- `_NotebookState` creates exactly one `Narrator(g.book.tracks)` and one `Ads(enabled: widget.adsEnabled)`, subscribes to `Game` with `_changed`, and starts ads after the first frame.
|
||||
- `_changed()` stops narration when the route string (`screen:storyIndex|campaignIndex`) changes, then rebuilds.
|
||||
- `_changed()` replaces narration tracks when the active book/language changes, stops narration when the route string (`storyId:language:screen:storyIndex|campaignIndex`) changes, then rebuilds.
|
||||
- Lifecycle: backgrounding stops narration and awaits `prefs.flushed`; `dispose` stops/disposes the narrator, disposes ads and removes listeners.
|
||||
- `PopScope` intercepts Android back: it pops only on `home` with no `busy` work; otherwise it calls `back()`.
|
||||
- `build()` switches on `g.screen`; a full-screen overlay with `CircularProgressIndicator` covers the app while `g.busy` (classic board generation).
|
||||
@@ -184,7 +191,7 @@ stateDiagram-v2
|
||||
| `home()` | `Screen.home`; cancels pending board generation |
|
||||
| `openNotebook()` | `showStory(index of notebook_last_page, else 0)` |
|
||||
| `showStory(i)` | Clamp `i` to available pages; set campaign mode and the record’s campaign index; on a puzzle leaf load its `story_v1_<index>` unless already loaded; persist last page and `viewed_<pageId>`; `Screen.story` |
|
||||
| `contents([chapter])` | One chapter’s four entries; persist `notebook_contents_chapter`; default to current campaign chapter |
|
||||
| `contents([chapter])` | One chapter’s entries (derived from stable `chapterId`); persist `notebook_contents_chapter`; default to current campaign chapter |
|
||||
| `leaveCottage()` | Open Chapter II for reading without awarding unfinished cottage puzzles |
|
||||
| `briefing(i)` | Clamp to `accessible`; cottage entry leaf or later `Screen.briefing` |
|
||||
| `reveal(i, {readAhead})` | Redirect to `briefing(i)` unless recovered, or read-ahead is allowed for an accessible level; otherwise the cottage memory leaf or later `Screen.reveal` |
|
||||
@@ -232,7 +239,7 @@ Cell encoding across the app:
|
||||
|
||||
Content pipelines:
|
||||
|
||||
- **Campaign:** `Book.load()` parses `assets/campaign.json` → `CampaignLevel.puzzle()` builds `Puzzle(7, picture)` and applies `clues` (forced-given indices) and `areas` (`top,left,height,width` rectangles labelled A, B, C…).
|
||||
- **Campaign:** `Book.load()` parses `assets/campaign.json` → `CampaignLevel.puzzle()` builds `Puzzle(size, picture)` (default size 7) and applies `clues` (forced-given indices) and `areas` (`top,left,height,width` rectangles labelled A, B, C…).
|
||||
- **Daily:** fixed board per local calendar day (`Puzzle.seeded(epochDay * 7919)`), progress keyed by date.
|
||||
- **Classic:** deterministic practice board per difficulty and level (`1000000 + level` seed), generated on an isolate.
|
||||
|
||||
@@ -275,8 +282,22 @@ Content pipelines:
|
||||
- `splitPuzzle` sizing (content width `w`, height `h`): usable width `min(w, 980)`, side panel `min(min(280, max(200, 0.40·usable)), 0.55·usable)`, board `min(min(h, usable − panel − 18), 520)`. The board is always square and is centred; the side column scrolls when text is large.
|
||||
- `navigation()` uses one row of five buttons in landscape and two rows in portrait.
|
||||
|
||||
## Story library and localization
|
||||
|
||||
See [Story packages and translations](STORY_PACKAGES.md) for the authoring schema and a complete recipe.
|
||||
|
||||
- `StoryLibrary` reads `assets/library.json` and caches books by stable story ID and resolved language. `Book.loadDefinition()` merges only display fields from locale overlays, validates IDs/references/grid shapes, and derives chapters from stable `chapterId` values.
|
||||
- `Game.selectStory()` cancels old puzzle work and restores that story's route/marks; `selectLanguage()` replaces localized content without replacing the live grid or undo stack. The library dialog and language picker are reachable from home; language is also available while reading.
|
||||
- `LumenApp` rebuilds its locale/theme and `CopyScope` from `Game`. Flutter localization delegates handle standard controls and RTL direction. `CopyText` translates UI messages separately from authored passages, which `reading()` displays directly. The board explicitly remains LTR so its spatial solution does not change with language.
|
||||
- Mara's special note/inspection pages live in `lib/ui/mara_story.dart`; `standardStory()` supports new packages without Mara-specific assumptions. Existing ambience scenes apply only to Mara.
|
||||
- Languages resolve exact tag → base language → original story language; individual missing fields also use original text. Translated books only use explicitly supplied locale narration manifests, so English recordings do not automatically play over translated text.
|
||||
- The shipped Paper Boat package demonstrates English/German content; Mara's story text is still English. Both English and German app UI catalogues are bundled.
|
||||
|
||||
## Persistence key map
|
||||
|
||||
`selected_story` and `language` (`system` or a locale tag) are global device preferences. New story-local keys below are stored under `story/<story-id>/`; Mara retains the original unprefixed keys for compatibility. Puzzle identity uses `Book.puzzleKey()` (legacy `story_v1_<index>` for Mara; `story_<story-id>_<puzzle-id>` for other stories). Language is never part of a save key. Daily/practice records, device settings and the total solved counter remain global.
|
||||
|
||||
|
||||
All writes go through `Progress.set` (memory is updated synchronously, disk is written in order; `flushed` awaits the queue). There is no migration from the legacy Java `lumen.xml`.
|
||||
|
||||
### Routing and session restore
|
||||
@@ -295,7 +316,7 @@ All writes go through `Progress.set` (memory is updated synchronously, disk is w
|
||||
| Key | Type | Written by | Purpose |
|
||||
| --- | --- | --- | --- |
|
||||
| `notebook_last_page` | page id | `Game.showStory` | Resume the last cottage leaf |
|
||||
| `notebook_contents_chapter` | int 0–2 | `Game.contents` | Restored chapter contents leaf |
|
||||
| `notebook_contents_chapter` | chapter index | `Game.contents` | Restored chapter contents leaf |
|
||||
| `notebook_manual_bookmark` | page id | `bookmark()` | "Return to my ribbon bookmark" in Contents |
|
||||
| `notebook_note_open` | bool | folded-note leaf | Note unfolded/folded state |
|
||||
| `notebook_handle_seen` | bool | `inspect()` | Repair margin note read; never reveals pre-puzzle artwork |
|
||||
@@ -317,7 +338,7 @@ All writes go through `Progress.set` (memory is updated synchronously, disk is w
|
||||
| `streak` | int | daily completion | Consecutive daily completions |
|
||||
| `campaignUnlocked` | int 0–11 | campaign completion | Furthest solved campaign level |
|
||||
| `story_access_level` | int 0–11 | `nextCampaign`, `leaveCottage` | Furthest readable campaign level; effective access is at least 3 for cottage exploration, independent of awards |
|
||||
| `storyAd_<index>` | bool | `nextCampaign` | At most one interstitial per fourth campaign step |
|
||||
| `storyAd_<index>` | bool | `nextCampaign` | At most one interstitial at each completed chapter boundary |
|
||||
| `ambience_enabled` | bool (default true) | Sound & atmosphere | Independent environmental audio switch, applies only within story pages |
|
||||
| `ambience_volume` | double 0–1 (default 0.7) | Sound & atmosphere | Saved environmental volume, independent of narration speed |
|
||||
| `recording_speed` | double | speed dialog | `0.85`, `1.0` or `1.15` |
|
||||
@@ -349,7 +370,7 @@ Board key formats (`<key>`):
|
||||
- Campaign reveals use optional `CampaignLevel.illustrationAsset` paths from campaign JSON. All twelve discoveries have watercolours; absent or unloadable image assets fall back to `PixelPicture`. The opening match memory shares the first campaign illustration through `discoveryArt()`. No puzzle identity or progress keys change.
|
||||
- Font: `assets/fonts/DancingScript.ttf` registered as `MaraHand`; `assets/fonts/OFL.txt` is registered with `LicenseRegistry` in `main()`.
|
||||
- `android/app/src/qa/AndroidManifest.xml` opts the isolated QA package into external installation (`preferExternal`); the production manifest keeps its existing installation policy. Android/OEM support still determines whether an SD-card install is accepted. The review Huawei reports `sm has-adoptable=false` and rejects new ASEC installs; use a compact release build installed internally there.
|
||||
- `pubspec.yaml` lists every bundled asset explicitly (no directory globs), so new assets must be added there.
|
||||
- `pubspec.yaml` registers individual legacy assets and story/UI directories. Directory declarations are not recursive: add each new subdirectory explicitly.
|
||||
|
||||
### Audio flow
|
||||
|
||||
@@ -372,7 +393,7 @@ Board key formats (`<key>`):
|
||||
- `Ads.supported` is false on the web, when `enabled`/`adsEnabled` is false (both test suites pass `adsEnabled: false`) and on platforms other than Android/iOS.
|
||||
- `start()` requests UMP consent, shows the form if required, then initialises the SDK and preloads one rewarded and one interstitial ad.
|
||||
- Hint flow: every hint in campaign, daily and classic requires explicit confirmation and `ads.hint(give)`, including the first hint. The grid changes only in the reward callback; a local guard permits at most one hint per rewarded ad. Late callbacks check the active puzzle key and route. `Notebook.ads` permits deterministic reward/cancel/no-fill tests without bypassing the production gate. If no ad is available the user sees "No ad available. Please try again later." and no hint is consumed.
|
||||
- Interstitials: `nextPractice()` after every fourth classic completion; `nextCampaign()` at most once per fourth campaign step (`storyAd_<index>`). `between(next)` always calls `next()` if ads are unavailable, stale (≥58 min) or unconsented.
|
||||
- Interstitials: `nextPractice()` after every fourth classic completion; `nextCampaign()` at most once at a completed chapter boundary (`storyAd_<index>`). `between(next)` always calls `next()` if ads are unavailable, stale (≥58 min) or unconsented.
|
||||
- `privacy()` opens the privacy options form only when UMP requires it; otherwise `main.dart` shows the local privacy explanation.
|
||||
- Ad unit IDs default to Google test IDs; production overrides come from `ADMOB_APP_ID` (Gradle), `ADMOB_REWARDED_ID` and `ADMOB_INTERSTITIAL_ID` (Dart defines).
|
||||
|
||||
@@ -385,8 +406,11 @@ Board key formats (`<key>`):
|
||||
| `integration_test/autoplay_test.dart` | Real-device delayed playback of bundled WAVs, cancellation when entering a puzzle and Stop preventing restart |
|
||||
| `test/ambience_test.dart` | Scene mapping, voice ducking, mute/background stop, stale loading requests, backend failure/recovery and disposal |
|
||||
| `integration_test/soundscape_test.dart` | Real-device decoding of all 24 new continuations, bridge/narration mixing, saved mute and automatic Mara-to-narrator handoff |
|
||||
| `test/library_test.dart` | All registered packages/locales, unique puzzles, identity-safe overlays, fallback/audio, independent story saves, live language switching, variable chapters, UI placeholders and invalid content |
|
||||
| `test/library_widget_test.dart` | Actual library/language controls, translated metadata, German at larger text in both orientations, Arabic RTL/font behavior |
|
||||
| `test/puzzle_test.dart` | 40 Java reference boards (signed 64-bit seeds), 300 graded boards, solver counts vs. exhaustive search, campaign uniqueness/no-guess, streaks, fresh progress, read-ahead, daily awards and practice levels |
|
||||
| `test/widget_test.dart` | Pattern-to-art timing/replay, back-to-solved-grid navigation, rewarded hints in all modes, declined/unavailable ads and duplicate/stale callbacks, page swipes vs. grid drags, swipes over text/blank paper, vertical scrolling and cancelled drags, small/landscape/1.5× text, landscape two-column puzzle leaf, illustrated campaign reveals and pixel fallback at 1.5× text |
|
||||
| `integration_test/library_test.dart` | Isolated on-device library selection, English/German switching, shared marks/bookmark/undo, story isolation, read-ahead and exactly-once completion; four screenshots |
|
||||
| `integration_test/notebook_test.dart` | On-device QA flow: six leaves, real WAV playback and pause/resume, bookmarks/discoveries, match and lantern solves, exactly-once awards, QA disk round-trip, screenshots |
|
||||
| `integration_test/cottage_test.dart` | All sixteen leaves, larger-text portrait/landscape, bookmarks, legacy-key marks, all four awards, all 23 narrator tracks and isolated test persistence; eight screenshots |
|
||||
| `integration_test/discovery_art_test.dart` | QA tablet screenshots of all twelve discoveries and the opening match memory, portrait/landscape at 1.5× text; checks reachable controls and unchanged awards |
|
||||
@@ -443,6 +467,7 @@ Each run checks four discoveries in both orientations at 1.5× text, including n
|
||||
|
||||
| Goal | Touch | Also |
|
||||
| --- | --- | --- |
|
||||
| Add a story or translation | `assets/library.json`, new package/locale files, `pubspec.yaml` | Follow `docs/STORY_PACKAGES.md`; run library/domain/widget tests |
|
||||
| Edit campaign content or pictures | `assets/campaign.json` | Re-run `flutter test` (uniqueness/no-guess campaign tests) and `scripts/check_narration_assets.py` only if text changes |
|
||||
| Add or reorder cottage leaves | `assets/notebook.json`, `StoryPageType` builders, `Book.pageFor()`, narration scripts if recorded | Add a WAV + manifests + `pubspec.yaml` if narrated; update integration test |
|
||||
| Add a screen | `Screen` enum, `Game._route`/navigation method, `_NotebookState.build` switch, new builder | Back-button behaviour in `back()` and `PopScope` |
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
| Document | Purpose |
|
||||
| --- | --- |
|
||||
| [Code map](CODE_MAP.md) | Agent-oriented architecture, dependency graph, screen state machine, puzzle pipeline, UI/layout rules, persistence keys, asset and service flows, test map, invariants, change recipes and gotchas |
|
||||
| [Story packages and translations](STORY_PACKAGES.md) | Add stories to the library, author puzzles/pages, translate content and UI, and preserve saves across languages |
|
||||
| [Thinking-depth tool](THINKING_DEPTH.md) | CLI usage, reasoning model, depth limits, reports and human-difficulty interpretation |
|
||||
| [Project README](../README.md) | Features, artwork, narration, build and verification commands, publishing notes |
|
||||
| [Roadmap](../ROADMAP.md) | Product direction and the proposed 30–40-leaf campaign |
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
# Story packages and translations
|
||||
|
||||
The library is an offline catalogue in `assets/library.json`. Adding a standard
|
||||
story means adding JSON and assets, registering one catalogue entry, and rebuilding
|
||||
the app. It does not require a new screen or changes to the puzzle engine.
|
||||
`assets/stories/paper-boat/` is a complete, small example in English and German.
|
||||
The original Mara story remains available with its existing saves and narration.
|
||||
|
||||
## Add a story
|
||||
|
||||
1. Copy the `paper-boat` folder to `assets/stories/<story-id>/`.
|
||||
2. Give the story a unique, permanent lowercase ID (letters, digits and hyphens).
|
||||
3. Edit its campaign, notebook and translation files. Keep page and puzzle IDs
|
||||
stable once the story has shipped.
|
||||
4. Add an entry to `assets/library.json` and list every new asset directory in
|
||||
`pubspec.yaml`. Flutter directory declarations are not recursive; include
|
||||
translation, artwork and audio subdirectories explicitly.
|
||||
5. Run `flutter analyze` and `flutter test`. The library tests load every registered
|
||||
story in every declared language and check that each puzzle has one solution.
|
||||
|
||||
Example catalogue entry:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "paper-boat",
|
||||
"title": "The paper boat",
|
||||
"description": "A short story about a small journey.",
|
||||
"coverAsset": "assets/artwork/little-boat-vignette-v1.png",
|
||||
"defaultLanguage": "en",
|
||||
"campaignAsset": "assets/stories/paper-boat/campaign.json",
|
||||
"notebookAsset": "assets/stories/paper-boat/notebook.json",
|
||||
"initiallyAccessible": 0,
|
||||
"languages": {
|
||||
"en": {"label": "English", "fontFamily": "MaraHand"},
|
||||
"de": {
|
||||
"label": "Deutsch",
|
||||
"fontFamily": "MaraHand",
|
||||
"asset": "assets/stories/paper-boat/locales/de.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`presentation` defaults to `standard`. The optional `mara` presentation preserves
|
||||
the original folded-note and repair interactions in `lib/ui/mara_story.dart`;
|
||||
new stories normally use the standard renderer. New *kinds* of interactive pages
|
||||
still need renderer code; ordinary text, pictures, puzzles and memories do not.
|
||||
`continueAt` is an optional campaign index for a book whose initial notebook pages
|
||||
lead into further briefing/puzzle/memory screens. Without it, the final notebook
|
||||
page returns to that story's contents.
|
||||
|
||||
## Campaign and chapters
|
||||
|
||||
`campaign.json` contains `premise` and a `levels` list. Each level supplies:
|
||||
|
||||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `id` | Permanent puzzle ID, unique within this story; letters, digits, `.`, `_`, `-` |
|
||||
| `chapterId` | Permanent chapter ID; levels belonging to a chapter must be contiguous |
|
||||
| `chapter` | Display name of that chapter |
|
||||
| `title`, `object` | Puzzle title and name of the discovered object |
|
||||
| `before`, `after` | Passages before and after the puzzle |
|
||||
| `beforeContinuation`, `afterContinuation` | Optional additional passages |
|
||||
| `size` | Square grid size, default 7; supported range 2–10 |
|
||||
| `picture` | Exactly `size × size` digits, each `0` or `1`, in row order |
|
||||
| `clues` | Comma-separated zero-based cell indices for fixed clues; `""` for none |
|
||||
| `areas` | Semicolon-separated `top,left,height,width` rectangles; `""` for none |
|
||||
| `illustrationAsset` | Optional discovery image |
|
||||
|
||||
Chapter counts and lengths are derived from `chapterId`; neither twelve puzzles
|
||||
nor four puzzles per chapter are required. Solve access advances through levels;
|
||||
reading ahead saves unfinished marks and does not award puzzle completion.
|
||||
|
||||
## Notebook pages
|
||||
|
||||
`notebook.json` contains a `pages` list in reading order. Every page has a stable
|
||||
`id`, a `title`, and a `type`: `dedication`, `entry`, `puzzle`, `memory`, `note`,
|
||||
`inspection`, or `closing`.
|
||||
|
||||
A puzzle or memory page must include its zero-based `campaignIndex`. Entry pages
|
||||
can link to a campaign level as well. Text can be supplied directly in `text`, or
|
||||
selected with `textSource: "before"` or `"after"`. Optional fields are `speaker`,
|
||||
`continuation`, `illustrationAsset` and `caption`. In a standard package, notes
|
||||
and inspections display their authored text and image; they do not inherit
|
||||
Mara-specific actions.
|
||||
|
||||
Prefer an entry, puzzle and memory page for every level, as in the example.
|
||||
If a campaign level has no matching notebook page, its generic briefing, game
|
||||
or reveal screen is used instead. Notebook pages are a sequential reading order;
|
||||
translations cannot reorder pages or change their puzzle associations.
|
||||
|
||||
## Translate a story
|
||||
|
||||
Add a language entry and a JSON overlay. For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "Das Papierboot",
|
||||
"description": "Eine kurze Geschichte über eine kleine Reise.",
|
||||
"premise": "Eine gefaltete Seite trägt ein Versprechen über den Dorfteich.",
|
||||
"levels": {
|
||||
"boat": {
|
||||
"chapter": "Eine kleine Überfahrt",
|
||||
"title": "Ein Boot aus Papier",
|
||||
"object": "Das Papierboot",
|
||||
"before": "…",
|
||||
"after": "…"
|
||||
}
|
||||
},
|
||||
"pages": {
|
||||
"boat.entry": {"title": "Ein Boot aus Papier"},
|
||||
"boat.memory": {"title": "Etwas kommt nach Hause"}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Level overlays are keyed by puzzle ID, and page overlays by page ID. Only display
|
||||
fields are applied: text, titles, speakers, captions and illustration paths.
|
||||
Translations cannot replace IDs, chapter IDs, grid solutions, clues, page order,
|
||||
or campaign associations. An optional top-level `coverAsset` can replace artwork
|
||||
with embedded text; `copy` can override individual UI messages for that story.
|
||||
|
||||
An exact language tag is preferred, then its base language, then the story's
|
||||
original language. Missing fields fall back individually to original text; an
|
||||
explicit empty string can clear an optional passage. Library cards and story
|
||||
headings use the translated metadata. A notice on the home screen identifies
|
||||
when a story falls back to its original language.
|
||||
|
||||
The language control offers device language or a manual choice. Marks, current
|
||||
page, bookmarks, achievements and the live undo stack survive a language change.
|
||||
Nothing is copied into a separate translated-story save.
|
||||
|
||||
## App interface translations
|
||||
|
||||
App controls live separately in `assets/locales/en.json` and `de.json`, registered
|
||||
by `assets/locales/catalog.json`. The English source is the catalogue key. To add
|
||||
an interface language, register its label and asset path and translate a copy of
|
||||
the English file. Missing messages fall back to English.
|
||||
|
||||
Preserve numbered placeholders such as `{0}` and `{1}`; their order may change.
|
||||
For example, `"Open {0} · {1} / {2}"` translates the control while retaining the
|
||||
story title and progress values. Placeholder sets are checked at load time.
|
||||
Longer, more specific templates take precedence over shorter templates.
|
||||
|
||||
Flutter's localized controls, dates and text direction follow the selected
|
||||
language. The handwriting font is used for supported Latin-script interface
|
||||
languages; other scripts use system fallback fonts. A story language can declare
|
||||
its own bundled `fontFamily` (register it under `flutter.fonts`); without one,
|
||||
reading passages use the system font. The puzzle grid keeps its spatial layout
|
||||
in right-to-left languages so switching language does not mirror the solution.
|
||||
|
||||
## Narration
|
||||
|
||||
Audio is optional. A catalogue entry can provide `tracksAsset` for its original
|
||||
language and `scriptsAsset` for existing `textSource: "recording"` pages. Each
|
||||
translated language supplies its own `tracksAsset` if recordings are available.
|
||||
A translated story without its own manifest remains readable and does **not**
|
||||
automatically play the original-language audio.
|
||||
|
||||
A manifest contains a `tracks` map keyed by page ID. A track can use an explicit
|
||||
bundled `asset` path, or the legacy `file` name under `assets/audio/`. Include
|
||||
`speaker`, `durationMs`, and optional timed `cues` (`startMs`, `endMs`, `text`,
|
||||
`speaker`) for passage highlighting. Generic campaign fallback screens use
|
||||
`campaign.<index>.before` and `campaign.<index>.after` track IDs. Keep those level
|
||||
orders stable if using these fallback IDs.
|
||||
|
||||
## Saves and compatibility
|
||||
|
||||
Each additional story uses a `story/<story-id>/` preference namespace for reading
|
||||
position, bookmarks, unlocks, page flags, puzzle marks and achievements. New puzzle
|
||||
save keys include the story ID and permanent puzzle ID. Language is deliberately
|
||||
absent from these keys. Device settings, total solved count and daily/practice
|
||||
progress are shared across the app.
|
||||
|
||||
Mara's reserved `mara-island` story retains its original preference keys and
|
||||
`story_v1_<index>` puzzle keys, so existing installations keep their progress.
|
||||
Do not reuse that ID for another story or reorder Mara's existing campaign levels.
|
||||
Adding packaged stories still requires a rebuilt app; downloading user-created
|
||||
packages and an in-app story editor are not part of this implementation.
|
||||
|
||||
## Verification in this repository
|
||||
|
||||
`test/library_test.dart` covers all bundled stories/locales, unique puzzles,
|
||||
original-language and per-field fallback, immutable puzzle identity under
|
||||
translations, independent story saves, live undo after translation, chapter
|
||||
progression, stale async language loads, and invalid content.
|
||||
`test/library_widget_test.dart` exercises the actual selectors, German at 1.5×
|
||||
text in both orientations, and Arabic direction/font behavior with a fixed
|
||||
puzzle layout. `integration_test/library_test.dart` runs the library flow on
|
||||
the tablet with an in-memory game and ads disabled (`QA_TEST=true`, preferably
|
||||
the isolated `check` flavor). Screenshots are written under
|
||||
`artifacts/flutter-check/library-*.png` by the existing integration driver.
|
||||
|
||||
For every device installation, follow the root `AGENTS.md`: build and verify the
|
||||
intended APK first, then fresh-install its package with no restored app data.
|
||||
Reference in New Issue
Block a user