Add modular story library and shared-progress translations
This commit is contained in:
@@ -115,3 +115,20 @@ Chapter I page records live in `assets/notebook.json`. The original six IDs and
|
|||||||
To review the complete chapter on an isolated QA install, run `flutter drive --driver test_driver/integration_test.dart --target integration_test/cottage_test.dart --flavor qa --dart-define=QA_TEST=true -d YOUR_ANDROID_DEVICE`. This traverses all sixteen leaves, checks bookmarks/restart, rotates the compass puzzle at larger text, solves all four patterns and checks QA disk persistence. It saves eight screenshots in `artifacts/flutter-check/`.
|
To review the complete chapter on an isolated QA install, run `flutter drive --driver test_driver/integration_test.dart --target integration_test/cottage_test.dart --flavor qa --dart-define=QA_TEST=true -d YOUR_ANDROID_DEVICE`. This traverses all sixteen leaves, checks bookmarks/restart, rotates the compass puzzle at larger text, solves all four patterns and checks QA disk persistence. It saves eight screenshots in `artifacts/flutter-check/`.
|
||||||
|
|
||||||
Device automation can use the `check` flavor (`com.lumen.daily.check`) to preserve the installed QA app and its progress. It has its own preferences and test data. Use `--flavor check` with the integration commands above for an isolated run alongside QA.
|
Device automation can use the `check` flavor (`com.lumen.daily.check`) to preserve the installed QA app and its progress. It has its own preferences and test data. Use `--flavor check` with the integration commands above for an isolated run alongside QA.
|
||||||
|
|
||||||
|
|
||||||
|
## Story library and languages
|
||||||
|
|
||||||
|
The home page now has a story library and a language selector. Mara's original
|
||||||
|
notebook remains available, and **The paper boat** is a short standard story in
|
||||||
|
English and German. English and German app controls are bundled separately from
|
||||||
|
story text; Mara currently falls back to its original English narrative.
|
||||||
|
|
||||||
|
New stories are registered in `assets/library.json`; their pages, puzzles and
|
||||||
|
translations live in independent asset packages. Chapter sizes are data-driven,
|
||||||
|
and each story keeps its own progress. Switching language preserves reading
|
||||||
|
position, bookmarks, marks and undo. Device-language selection, fallback text,
|
||||||
|
optional localized narration and right-to-left layout are supported.
|
||||||
|
|
||||||
|
See [Story packages and translations](docs/STORY_PACKAGES.md) for the schema,
|
||||||
|
example package and validation commands.
|
||||||
|
|||||||
+36
-12
@@ -12,7 +12,9 @@
|
|||||||
"areas": "",
|
"areas": "",
|
||||||
"illustrationAsset": "assets/artwork/match-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/match-vignette-v1.png",
|
||||||
"beforeContinuation": "The notebook is open beside a cup with a blue rim. You remember that cup being too large for your hands. Now it looks small. Outside, the lighthouse is a dark line against the evening sky. Gran must already be up there; she never stayed home when the light needed tending.",
|
"beforeContinuation": "The notebook is open beside a cup with a blue rim. You remember that cup being too large for your hands. Now it looks small. Outside, the lighthouse is a dark line against the evening sky. Gran must already be up there; she never stayed home when the light needed tending.",
|
||||||
"afterContinuation": "You cup the flame, just as she taught you. The smell of the match brings back wet mittens drying by this hearth and Gran counting the seconds between thunder and lightning. You have come to help her after the storm. For the first time since arriving, you know where to begin."
|
"afterContinuation": "You cup the flame, just as she taught you. The smell of the match brings back wet mittens drying by this hearth and Gran counting the seconds between thunder and lightning. You have come to help her after the storm. For the first time since arriving, you know where to begin.",
|
||||||
|
"id": "match",
|
||||||
|
"chapterId": "cottage"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "I · The keeper’s cottage",
|
"chapter": "I · The keeper’s cottage",
|
||||||
@@ -25,7 +27,9 @@
|
|||||||
"clues": "1,5,9,11",
|
"clues": "1,5,9,11",
|
||||||
"areas": "",
|
"areas": "",
|
||||||
"beforeContinuation": "You recognise the crooked handle before the rest of the drawing. As a child, you thought every lantern came with that little bandage of cloth. Beside the pattern Gran has drawn an arrow from the hearth to the door: a tiny journey, but a journey all the same.",
|
"beforeContinuation": "You recognise the crooked handle before the rest of the drawing. As a child, you thought every lantern came with that little bandage of cloth. Beside the pattern Gran has drawn an arrow from the hearth to the door: a tiny journey, but a journey all the same.",
|
||||||
"afterContinuation": "There is oil in the reservoir and a clean spare wick in the drawer. Gran has left both within reach. You touch the initials under the handle. She added a second line beneath them years later, when you were tall enough to carry the lantern without dragging it against your knees."
|
"afterContinuation": "There is oil in the reservoir and a clean spare wick in the drawer. Gran has left both within reach. You touch the initials under the handle. She added a second line beneath them years later, when you were tall enough to carry the lantern without dragging it against your knees.",
|
||||||
|
"id": "lantern",
|
||||||
|
"chapterId": "cottage"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "I · The keeper’s cottage",
|
"chapter": "I · The keeper’s cottage",
|
||||||
@@ -38,7 +42,9 @@
|
|||||||
"areas": "1,2,4,3;3,2,2,4;3,2,2,3",
|
"areas": "1,2,4,3;3,2,2,4;3,2,2,3",
|
||||||
"illustrationAsset": "assets/artwork/brass-key-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/brass-key-vignette-v1.png",
|
||||||
"beforeContinuation": "The floorboard lifts where a nail has worked loose. Under it is the place Gran called her sensible hiding place, though everyone in the family knew about it. You used to keep a shell there. This time your fingers find a tag, its string wound carefully around something cold.",
|
"beforeContinuation": "The floorboard lifts where a nail has worked loose. Under it is the place Gran called her sensible hiding place, though everyone in the family knew about it. You used to keep a shell there. This time your fingers find a tag, its string wound carefully around something cold.",
|
||||||
"afterContinuation": "At first the abandoned preparations worry you. Then you notice today's date on a pencilled list: oil, spare wick, tea. Gran must have gone ahead to the tower, leaving the store key for you. The harbour store holds the little things a crossing needs. She expects you to follow."
|
"afterContinuation": "At first the abandoned preparations worry you. Then you notice today's date on a pencilled list: oil, spare wick, tea. Gran must have gone ahead to the tower, leaving the store key for you. The harbour store holds the little things a crossing needs. She expects you to follow.",
|
||||||
|
"id": "key",
|
||||||
|
"chapterId": "cottage"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "I · The keeper’s cottage",
|
"chapter": "I · The keeper’s cottage",
|
||||||
@@ -51,7 +57,9 @@
|
|||||||
"areas": "1,3,2,2;3,2,3,3;2,0,3,5",
|
"areas": "1,3,2,2;3,2,3,3;2,0,3,5",
|
||||||
"illustrationAsset": "assets/artwork/compass-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/compass-vignette-v1.png",
|
||||||
"beforeContinuation": "You hold the notebook towards the window. Beneath the compass drawing, a faint line follows the old lane down to the harbour steps. You know the road in daylight. Tonight you will need to recognise smaller things: the broken gate, the bend in the wall, the smell of the tide.",
|
"beforeContinuation": "You hold the notebook towards the window. Beneath the compass drawing, a faint line follows the old lane down to the harbour steps. You know the road in daylight. Tonight you will need to recognise smaller things: the broken gate, the bend in the wall, the smell of the tide.",
|
||||||
"afterContinuation": "The needle trembles when you move your hand, then steadies. Inside the lid you find a worn patch where Gran's thumb rested through years of evening rounds. You follow the same motion without meaning to. The notebook goes inside your coat; the lantern stays in your hand."
|
"afterContinuation": "The needle trembles when you move your hand, then steadies. Inside the lid you find a worn patch where Gran's thumb rested through years of evening rounds. You follow the same motion without meaning to. The notebook goes inside your coat; the lantern stays in your hand.",
|
||||||
|
"id": "compass",
|
||||||
|
"chapterId": "cottage"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "II · Across the tide",
|
"chapter": "II · Across the tide",
|
||||||
@@ -64,7 +72,9 @@
|
|||||||
"areas": "0,3,5,2;3,1,3,3;2,2,4,4",
|
"areas": "0,3,5,2;3,1,3,3;2,2,4,4",
|
||||||
"illustrationAsset": "assets/artwork/little-boat-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/little-boat-vignette-v1.png",
|
||||||
"beforeContinuation": "Before going down the steps, you try the brass key in the harbour store. Lift the latch, then turn: Gran's advice works here too. Inside are a bailer, two oars and an oilskin folded over a sack of dry kindling. A toolbox waits beneath the bench, with your name chalked on its lid. You carry it down to the boat with the oars and bailer, then lock the door behind you. On the notebook's margin, Gran has marked a landing sheltered beneath the hill.",
|
"beforeContinuation": "Before going down the steps, you try the brass key in the harbour store. Lift the latch, then turn: Gran's advice works here too. Inside are a bailer, two oars and an oilskin folded over a sack of dry kindling. A toolbox waits beneath the bench, with your name chalked on its lid. You carry it down to the boat with the oars and bailer, then lock the door behind you. On the notebook's margin, Gran has marked a landing sheltered beneath the hill.",
|
||||||
"afterContinuation": "The knot yields when you stop pulling at the wrong loop. You laugh softly; Gran would have noticed. In the water, the cottage window breaks into little squares of reflected gold. You row towards the sheltered landing, watching that reflection grow smaller without quite disappearing."
|
"afterContinuation": "The knot yields when you stop pulling at the wrong loop. You laugh softly; Gran would have noticed. In the water, the cottage window breaks into little squares of reflected gold. You row towards the sheltered landing, watching that reflection grow smaller without quite disappearing.",
|
||||||
|
"id": "boat",
|
||||||
|
"chapterId": "harbour"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "II · Across the tide",
|
"chapter": "II · Across the tide",
|
||||||
@@ -77,7 +87,9 @@
|
|||||||
"areas": "2,3,3,3;2,1,4,2;1,1,3,4",
|
"areas": "2,3,3,3;2,1,4,2;1,1,3,4",
|
||||||
"illustrationAsset": "assets/artwork/anchor-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/anchor-vignette-v1.png",
|
||||||
"beforeContinuation": "You rest the oars inside the boat. The landing is close, but the current slides across its mouth. Beneath the seat, a coil of rope leads to the weight in Gran's drawing. You remember her showing you this quiet waiting place when the tide ran too strongly to come straight in.",
|
"beforeContinuation": "You rest the oars inside the boat. The landing is close, but the current slides across its mouth. Beneath the seat, a coil of rope leads to the weight in Gran's drawing. You remember her showing you this quiet waiting place when the tide ran too strongly to come straight in.",
|
||||||
"afterContinuation": "You wait until the current eases, then draw up the anchor and row the short distance to the landing. The bell sounds again, moved by the wind. It is the bell from Gran's note. Beyond it, the path climbs towards a window with a small, steady light."
|
"afterContinuation": "You wait until the current eases, then draw up the anchor and row the short distance to the landing. The bell sounds again, moved by the wind. It is the bell from Gran's note. Beyond it, the path climbs towards a window with a small, steady light.",
|
||||||
|
"id": "bell",
|
||||||
|
"chapterId": "harbour"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "II · Across the tide",
|
"chapter": "II · Across the tide",
|
||||||
@@ -90,7 +102,9 @@
|
|||||||
"areas": "2,1,3,5;0,2,5,3;2,3,2,2",
|
"areas": "2,1,3,5;0,2,5,3;2,3,2,2",
|
||||||
"illustrationAsset": "assets/artwork/stone-bridge-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/stone-bridge-vignette-v1.png",
|
||||||
"beforeContinuation": "The boat is tied above the tide line. Between the landing and the path lies a narrow stream, swollen with rain. You remember leaping across it once and losing a boot. Gran had carried you home, pretending you weighed as much as a sack of coal. Tonight you are grateful for the bridge.",
|
"beforeContinuation": "The boat is tied above the tide line. Between the landing and the path lies a narrow stream, swollen with rain. You remember leaping across it once and losing a boot. Gran had carried you home, pretending you weighed as much as a sack of coal. Tonight you are grateful for the bridge.",
|
||||||
"afterContinuation": "The print points towards the tower. Beside it is the round mark of Gran's walking stick. She has taken this path with her supplies before you, testing the stones as she went. You set your foot beside hers. The handrail is wet, but it holds."
|
"afterContinuation": "The print points towards the tower. Beside it is the round mark of Gran's walking stick. She has taken this path with her supplies before you, testing the stones as she went. You set your foot beside hers. The handrail is wet, but it holds.",
|
||||||
|
"id": "bridge",
|
||||||
|
"chapterId": "harbour"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "II · Across the tide",
|
"chapter": "II · Across the tide",
|
||||||
@@ -103,7 +117,9 @@
|
|||||||
"clues": "2",
|
"clues": "2",
|
||||||
"areas": "3,2,3,3;2,0,4,4;0,3,5,2",
|
"areas": "3,2,3,3;2,0,4,4;0,3,5,2",
|
||||||
"beforeContinuation": "This is the shore bell, within sight of the lighthouse when the weather is clear. Gran's note said to ring twice. You take up the slack in the rope before pulling; the first stroke will tell you whether the clapper is free. You hope she is listening.",
|
"beforeContinuation": "This is the shore bell, within sight of the lighthouse when the weather is clear. Gran's note said to ring twice. You take up the slack in the rope before pulling; the first stroke will tell you whether the clapper is free. You hope she is listening.",
|
||||||
"afterContinuation": "You give the two strokes she asked for. After a pause, the answering pair comes again from the smaller bell at the tower door. A lantern lifts in the window. You raise yours in return, and the last part of the climb no longer feels so lonely."
|
"afterContinuation": "You give the two strokes she asked for. After a pause, the answering pair comes again from the smaller bell at the tower door. A lantern lifts in the window. You raise yours in return, and the last part of the climb no longer feels so lonely.",
|
||||||
|
"id": "anchor",
|
||||||
|
"chapterId": "harbour"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "III · The last light",
|
"chapter": "III · The last light",
|
||||||
@@ -116,7 +132,9 @@
|
|||||||
"areas": "2,3,3,3;1,3,5,3;1,2,4,3",
|
"areas": "2,3,3,3;1,3,5,3;1,2,4,3",
|
||||||
"illustrationAsset": "assets/artwork/missing-gear-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/missing-gear-vignette-v1.png",
|
||||||
"beforeContinuation": "Her hands are cold when she takes yours. 'You brought the old lantern,' she says, touching its mended handle. She tells you she came up before the tide covered the causeway. The tower is safe, but a loose gear stopped the lamp from turning. She could carry the supplies or the heavy toolbox, never both. You set the box between you.",
|
"beforeContinuation": "Her hands are cold when she takes yours. 'You brought the old lantern,' she says, touching its mended handle. She tells you she came up before the tide covered the causeway. The tower is safe, but a loose gear stopped the lamp from turning. She could carry the supplies or the heavy toolbox, never both. You set the box between you.",
|
||||||
"afterContinuation": "'Your grandfather used to listen for that sound from the stairs,' she says. For a while you both listen. The little ticking fills the room, quieter than the storm ever was. Then Gran gives you a cloth and points upstairs. There is still the glass to clean."
|
"afterContinuation": "'Your grandfather used to listen for that sound from the stairs,' she says. For a while you both listen. The little ticking fills the room, quieter than the storm ever was. Then Gran gives you a cloth and points upstairs. There is still the glass to clean.",
|
||||||
|
"id": "gear",
|
||||||
|
"chapterId": "tower"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "III · The last light",
|
"chapter": "III · The last light",
|
||||||
@@ -129,7 +147,9 @@
|
|||||||
"areas": "1,2,5,3;2,3,3,2;2,2,3,2",
|
"areas": "1,2,5,3;2,3,3,2;2,2,3,2",
|
||||||
"illustrationAsset": "assets/artwork/beacon-lens-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/beacon-lens-vignette-v1.png",
|
||||||
"beforeContinuation": "You climb past the narrow windows with the oilskin over your arm. Gran follows slowly, carrying the lantern. At the top she pauses to catch her breath and lets you take the next bundle. You used to hurry to keep up with her on these stairs. Tonight you match your steps to hers.",
|
"beforeContinuation": "You climb past the narrow windows with the oilskin over your arm. Gran follows slowly, carrying the lantern. At the top she pauses to catch her breath and lets you take the next bundle. You used to hurry to keep up with her on these stairs. Tonight you match your steps to hers.",
|
||||||
"afterContinuation": "Through the cleared glass you can see the sheltered landing and the black thread of the stream. Gran checks the main lamp's oil feed while you put away the cloths. For the first time tonight, the whole route fits into one view. Every small thing you found has brought you here."
|
"afterContinuation": "Through the cleared glass you can see the sheltered landing and the black thread of the stream. Gran checks the main lamp's oil feed while you put away the cloths. For the first time tonight, the whole route fits into one view. Every small thing you found has brought you here.",
|
||||||
|
"id": "lens",
|
||||||
|
"chapterId": "tower"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "III · The last light",
|
"chapter": "III · The last light",
|
||||||
@@ -142,7 +162,9 @@
|
|||||||
"areas": "1,3,4,2;0,3,2,2;2,2,4,2",
|
"areas": "1,3,4,2;0,3,2,2;2,2,4,2",
|
||||||
"illustrationAsset": "assets/artwork/lighthouse-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/lighthouse-vignette-v1.png",
|
||||||
"beforeContinuation": "The lantern lights Gran's hands as she checks the wick of the great oil lamp. Its flame will stay here, beside the spare matches; the beacon has its own much larger burner. She lights it, checks the glass once more, and nods towards the turning handle. This time she stands beside you instead of doing it herself.",
|
"beforeContinuation": "The lantern lights Gran's hands as she checks the wick of the great oil lamp. Its flame will stay here, beside the spare matches; the beacon has its own much larger burner. She lights it, checks the glass once more, and nods towards the turning handle. This time she stands beside you instead of doing it herself.",
|
||||||
"afterContinuation": "Gran waits for the beam to return across the window. Only then does she let out her breath. 'There,' she says. No speech, no grand ceremony. She rests her hand over yours for one turn of the handle, and you feel the weight of the work she has done all these years."
|
"afterContinuation": "Gran waits for the beam to return across the window. Only then does she let out her breath. 'There,' she says. No speech, no grand ceremony. She rests her hand over yours for one turn of the handle, and you feel the weight of the work she has done all these years.",
|
||||||
|
"id": "lighthouse",
|
||||||
|
"chapterId": "tower"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chapter": "III · The last light",
|
"chapter": "III · The last light",
|
||||||
@@ -155,7 +177,9 @@
|
|||||||
"areas": "0,1,6,2;2,3,4,3;0,2,4,3",
|
"areas": "0,1,6,2;2,3,4,3;0,2,4,3",
|
||||||
"illustrationAsset": "assets/artwork/home-vignette-v1.png",
|
"illustrationAsset": "assets/artwork/home-vignette-v1.png",
|
||||||
"beforeContinuation": "You leave the beacon running steadily. On the walk home, Gran names the things to mend tomorrow: a hinge, the store's gutter, that stubborn cottage latch. You add the loose floorboard. She says it has been loose for thirty years, but she hands you the key anyway.",
|
"beforeContinuation": "You leave the beacon running steadily. On the walk home, Gran names the things to mend tomorrow: a hinge, the store's gutter, that stubborn cottage latch. You add the loose floorboard. She says it has been loose for thirty years, but she hands you the key anyway.",
|
||||||
"afterContinuation": "The blue cup waits where she left it. While the kettle warms, you add tomorrow's tide time beneath your drawing. Gran reads it over your shoulder and nods. The notebook has room for repairs, crossings and ordinary evenings. You turn back once to the first small light, then leave a ribbon at the page you will need tomorrow."
|
"afterContinuation": "The blue cup waits where she left it. While the kettle warms, you add tomorrow's tide time beneath your drawing. Gran reads it over your shoulder and nods. The notebook has room for repairs, crossings and ordinary evenings. You turn back once to the first small light, then leave a ribbon at the page you will need tomorrow.",
|
||||||
|
"id": "home",
|
||||||
|
"chapterId": "tower"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"stories": [
|
||||||
|
{
|
||||||
|
"id": "mara-island",
|
||||||
|
"title": "Mara’s notebook",
|
||||||
|
"description": "Follow a storm-scattered trail from Gran’s cottage to the lighthouse.",
|
||||||
|
"coverAsset": "assets/artwork/home-notebook-cover-v2.png",
|
||||||
|
"defaultLanguage": "en",
|
||||||
|
"campaignAsset": "assets/campaign.json",
|
||||||
|
"notebookAsset": "assets/notebook.json",
|
||||||
|
"scriptsAsset": "assets/narration/scripts.json",
|
||||||
|
"tracksAsset": "assets/audio/narration_manifest.json",
|
||||||
|
"presentation": "mara",
|
||||||
|
"continueAt": 4,
|
||||||
|
"initiallyAccessible": 3,
|
||||||
|
"languages": {
|
||||||
|
"en": {
|
||||||
|
"label": "English",
|
||||||
|
"fontFamily": "MaraHand"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "paper-boat",
|
||||||
|
"title": "The paper boat",
|
||||||
|
"description": "A short story about a small journey, in English and German.",
|
||||||
|
"coverAsset": "assets/artwork/little-boat-vignette-v1.png",
|
||||||
|
"defaultLanguage": "en",
|
||||||
|
"campaignAsset": "assets/stories/paper-boat/campaign.json",
|
||||||
|
"notebookAsset": "assets/stories/paper-boat/notebook.json",
|
||||||
|
"languages": {
|
||||||
|
"en": {
|
||||||
|
"label": "English",
|
||||||
|
"fontFamily": "MaraHand"
|
||||||
|
},
|
||||||
|
"de": {
|
||||||
|
"label": "Deutsch",
|
||||||
|
"fontFamily": "MaraHand",
|
||||||
|
"asset": "assets/stories/paper-boat/locales/de.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"en": {
|
||||||
|
"label": "English",
|
||||||
|
"asset": "assets/locales/en.json"
|
||||||
|
},
|
||||||
|
"de": {
|
||||||
|
"label": "Deutsch",
|
||||||
|
"asset": "assets/locales/de.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
{
|
||||||
|
"A SMALL DAILY RITUAL": "EIN KLEINES TÄGLICHES RITUAL",
|
||||||
|
"A careful repair": "Eine sorgsame Reparatur",
|
||||||
|
"A few spare pages for practice. For overlapping-area puzzles, follow the notebook’s story.": "Ein paar freie Seiten zum Üben. Rätsel mit überlappenden Bereichen findest du in der Geschichte.",
|
||||||
|
"A few things worth keeping": "Ein paar Dinge zum Bewahren",
|
||||||
|
"A folded note sealed with red wax": "Ein gefalteter Zettel, mit rotem Wachs versiegelt",
|
||||||
|
"A folded scrap, tucked between the leaves.": "Ein gefalteter Zettel zwischen den Seiten.",
|
||||||
|
"A light kept in these pages. Your unfinished patterns will be here whenever you return.": "Ein Licht, bewahrt auf diesen Seiten. Deine ungelösten Muster warten bei deiner Rückkehr auf dich.",
|
||||||
|
"A light to come\nhome to.": "Ein Licht, das dich\nnach Hause führt.",
|
||||||
|
"A little faster · 1.15×": "Etwas schneller · 1.15×",
|
||||||
|
"A little nudge?": "Ein kleiner Anstoß?",
|
||||||
|
"A memory to read · your pattern can wait": "Eine Erinnerung zum Lesen · dein Muster kann warten",
|
||||||
|
"A memory to read · your puzzle can wait": "Eine Erinnerung zum Lesen · dein Rätsel kann warten",
|
||||||
|
"A moment of clarity.": "Ein Moment der Klarheit.",
|
||||||
|
"A pattern restored · a memory kept": "Ein Muster gelöst · eine Erinnerung bewahrt",
|
||||||
|
"A pencil sketch of a match and a small amber flame": "Bleistiftskizze eines Streichholzes mit kleiner bernsteinfarbener Flamme",
|
||||||
|
"A recorded reading, kept with this page": "Eine aufgenommene Lesung zu dieser Seite",
|
||||||
|
"A repair made to keep small fingers safe.": "Eine Reparatur zum Schutz kleiner Finger.",
|
||||||
|
"A repair note, tucked into the margin.": "Eine Notiz zur Reparatur am Seitenrand.",
|
||||||
|
"A ribbon marks this page.": "Ein Band markiert diese Seite.",
|
||||||
|
"A, B and C are outlined areas with their own light totals. Shared cells count in each area they belong to. Compare clues and subtract their shared parts to find new deductions.": "A, B und C sind umrandete Bereiche mit eigenen Lichtsummen. Gemeinsame Felder zählen in jedem zugehörigen Bereich. Vergleiche Hinweise und ziehe gemeinsame Teile ab, um weitere Felder zu bestimmen.",
|
||||||
|
"Across the tide →": "Über die Gezeiten →",
|
||||||
|
"Already restored. Turn the leaf to revisit the memory.": "Bereits gelöst. Blättere um, um die Erinnerung erneut zu lesen.",
|
||||||
|
"An earlier mark conflicts with the clues. Correct it, then continue comparing the totals.": "Eine frühere Markierung widerspricht den Hinweisen. Korrigiere sie und vergleiche dann die Summen weiter.",
|
||||||
|
"Area {0}": "Bereich {0}",
|
||||||
|
"Atmosphere volume": "Lautstärke der Umgebung",
|
||||||
|
"BY THE COTTAGE WINDOW": "AM FENSTER DES HÄUSCHENS",
|
||||||
|
"Back to contents": "Zum Inhaltsverzeichnis",
|
||||||
|
"Back to notebook": "Zurück zum Notizbuch",
|
||||||
|
"Back to the notebook": "Zurück zum Notizbuch",
|
||||||
|
"Before you leave": "Bevor du gehst",
|
||||||
|
"Bookmark": "Lesezeichen",
|
||||||
|
"CLASSIC / {0} / LEVEL {1}": "KLASSISCH / {0} / STUFE {1}",
|
||||||
|
"Classic practice pace": "Tempo beim klassischen Üben",
|
||||||
|
"Close": "Schließen",
|
||||||
|
"Close book": "Buch schließen",
|
||||||
|
"Close the notebook": "Notizbuch schließen",
|
||||||
|
"Column {0}": "Spalte {0}",
|
||||||
|
"Compare rows, columns and overlapping areas.": "Vergleiche Zeilen, Spalten und überlappende Bereiche.",
|
||||||
|
"Compare the shared areas. Each cell counts in every area it belongs to.": "Vergleiche die überlappenden Bereiche. Jedes Feld zählt in jedem Bereich, zu dem es gehört.",
|
||||||
|
"Compare {0} ({1} more lights) with {2} ({3} more). Shared empty cells cancel. The difference forces the cells outside their overlap.": "Vergleiche {0} (noch {1} Lichter) mit {2} (noch {3}). Gemeinsame leere Felder heben sich auf. Die Differenz bestimmt die Felder außerhalb der Überlappung.",
|
||||||
|
"Contents": "Inhalt",
|
||||||
|
"Continue reading": "Weiterlesen",
|
||||||
|
"Continue reading · {0}": "Weiterlesen · {0}",
|
||||||
|
"Continue this pattern →": "Dieses Muster fortsetzen →",
|
||||||
|
"DAILY / {0}": "TÄGLICH / {0}",
|
||||||
|
"Difficulty · {0} ▾": "Schwierigkeit · {0} ▾",
|
||||||
|
"Easy": "Einfach",
|
||||||
|
"End of the reading · listen again whenever you like": "Ende der Lesung · höre sie dir jederzeit erneut an",
|
||||||
|
"Environmental sounds": "Umgebungsgeräusche",
|
||||||
|
"Every pattern restored. The daily puzzle will be here whenever you return.": "Alle Muster sind gelöst. Das tägliche Rätsel wartet bei deiner Rückkehr auf dich.",
|
||||||
|
"Find the light": "Finde das Licht",
|
||||||
|
"Find the light.": "Finde das Licht.",
|
||||||
|
"Finding a fresh pattern…": "Ein neues Muster wird gesucht …",
|
||||||
|
"Fold the note again": "Den Zettel wieder falten",
|
||||||
|
"Follow device language": "Gerätesprache verwenden",
|
||||||
|
"Follow longer chains to uncover the pattern.": "Folge längeren Schlussketten, um das Muster aufzudecken.",
|
||||||
|
"Follow the lantern into the next entry →": "Mit der Laterne zum nächsten Eintrag →",
|
||||||
|
"For the crossing": "Für die Überfahrt",
|
||||||
|
"For you, when you are ready. With all my love, Gran.": "Für dich, wenn du bereit bist. In Liebe, Oma.",
|
||||||
|
"Four memories in the cottage · {0} patterns restored": "Vier Erinnerungen im Häuschen · {0} Muster gelöst",
|
||||||
|
"Game progress stays on this device. No account or game backend is used. Google advertising services may process device and ad interaction data when ads are available.\n\nNo advertising privacy options are currently required or available for your region.": "Der Spielfortschritt bleibt auf diesem Gerät. Es gibt kein Konto und keinen Spielserver. Google-Werbedienste können Geräte- und Werbeinteraktionsdaten verarbeiten, wenn Werbung verfügbar ist.\n\nFür deine Region sind derzeit keine Datenschutzoptionen für Werbung erforderlich oder verfügbar.",
|
||||||
|
"Got it": "Verstanden",
|
||||||
|
"Gran’s repair note": "Omas Reparaturnotiz",
|
||||||
|
"Hard": "Schwer",
|
||||||
|
"Hint · rewarded ad": "Hinweis · Werbevideo",
|
||||||
|
"How to play": "Spielanleitung",
|
||||||
|
"Keep going": "Weiter",
|
||||||
|
"Keep reading": "Weiterlesen",
|
||||||
|
"Keep solving": "Weiter rätseln",
|
||||||
|
"Keep that thought": "Diesen Gedanken bewahren",
|
||||||
|
"Keep thinking": "Weiter nachdenken",
|
||||||
|
"Kept safe, between these pages. — M.": "Sicher bewahrt zwischen diesen Seiten. — M.",
|
||||||
|
"L U M E N / AN ISLAND STORY": "L U M E N / EINE INSELGESCHICHTE",
|
||||||
|
"L U M E N / STORY LIBRARY": "L U M E N / GESCHICHTENBIBLIOTHEK",
|
||||||
|
"Language": "Sprache",
|
||||||
|
"Leave a light in the window.": "Lass ein Licht im Fenster.",
|
||||||
|
"Leave a ribbon here?": "Hier ein Lesezeichen setzen?",
|
||||||
|
"Light exactly as many cells as the number beside each row and above each column.\n\nTap to cycle: empty → light → crossed out → empty. Mark every cell to finish. Small dots mark fixed clues.\n\nA, B and C are overlapping areas with their own totals. Shared cells count in both areas. Compare clues and subtract their shared parts to find new deductions.\n\nEvery story grid reveals an object. Later pages require area comparisons; all are solvable without guessing. Classic practice grades the length of simpler row and column chains.\n\nWatch a rewarded ad for each explained hint. Hints are optional, and your puzzle remains available if no ad can be shown. Streaks count consecutive daily completions on this device.": "Erhelle genau so viele Felder, wie die Zahlen neben den Zeilen und über den Spalten angeben.\n\nTippen wechselt zwischen leer → Licht → Kreuz → leer. Markiere zum Abschluss jedes Feld. Kleine Punkte kennzeichnen feste Vorgaben.\n\nA, B und C sind überlappende Bereiche mit eigenen Summen. Gemeinsame Felder zählen in beiden Bereichen. Vergleiche die Hinweise und ziehe gemeinsame Teile ab, um weitere Felder zu bestimmen.\n\nJedes Geschichtenrätsel enthüllt einen Gegenstand. Spätere Seiten erfordern Vergleiche zwischen Bereichen; alle Rätsel sind ohne Raten lösbar. Beim klassischen Üben richtet sich die Schwierigkeit nach der Länge der Schlussketten.\n\nFür jeden erklärten Hinweis kannst du ein Werbevideo ansehen. Hinweise sind freiwillig, und dein Rätsel bleibt verfügbar, wenn keine Werbung gezeigt werden kann. Eine Serie zählt aufeinanderfolgende tägliche Abschlüsse auf diesem Gerät.",
|
||||||
|
"Light the cells to match each row and column total. Cross out the cells that stay dark. The finished grid is a picture from the story.": "Erhelle die Felder passend zu den Zeilen- und Spaltensummen. Kreuze die dunklen Felder durch. Das fertige Raster zeigt ein Bild aus der Geschichte.",
|
||||||
|
"Link deductions across rows and columns.": "Verknüpfe Schlussfolgerungen aus Zeilen und Spalten.",
|
||||||
|
"Mara · diary reading": "Mara · Tagebuchlesung",
|
||||||
|
"Mara’s\nisland notebook": "Maras\nInselnotizbuch",
|
||||||
|
"Match the totals. Let the pattern emerge.": "Erfülle die Summen. Lass das Muster entstehen.",
|
||||||
|
"Medium": "Mittel",
|
||||||
|
"Missing translations use the story’s original language. Your reading position and puzzle marks are shared across languages.": "Fehlende Übersetzungen erscheinen in der Originalsprache der Geschichte. Leseposition und Rätselmarkierungen bleiben beim Sprachwechsel erhalten.",
|
||||||
|
"Narrator · recorded story": "Erzählstimme · aufgenommene Geschichte",
|
||||||
|
"Next chapter →": "Nächstes Kapitel →",
|
||||||
|
"Next leaf →": "Nächste Seite →",
|
||||||
|
"Next puzzle →": "Nächstes Rätsel →",
|
||||||
|
"No ad available. Please try again later.": "Keine Werbung verfügbar. Bitte versuche es später erneut.",
|
||||||
|
"Open Mara’s cloth-bound island notebook": "Maras stoffgebundenes Inselnotizbuch öffnen",
|
||||||
|
"Open the dedication": "Die Widmung öffnen",
|
||||||
|
"Open {0} · {1} / {2}": "{0} öffnen · {1} / {2}",
|
||||||
|
"Open-source licenses": "Open-Source-Lizenzen",
|
||||||
|
"Opening recording…": "Aufnahme wird geöffnet …",
|
||||||
|
"Original reading · 1.0×": "Originaltempo · 1.0×",
|
||||||
|
"Pause recording": "Aufnahme pausieren",
|
||||||
|
"Paused · {0} / {1}": "Pausiert · {0} / {1}",
|
||||||
|
"Play this reading": "Diese Lesung abspielen",
|
||||||
|
"Play today’s puzzle →": "Das heutige Rätsel spielen →",
|
||||||
|
"Playing · {0} / {1}": "Wiedergabe · {0} / {1}",
|
||||||
|
"Practice · {0} · Level {1}": "Üben · {0} · Stufe {1}",
|
||||||
|
"Privacy & advertising": "Datenschutz und Werbung",
|
||||||
|
"Read Gran’s margin note": "Omas Randnotiz lesen",
|
||||||
|
"Read ahead": "Weiterlesen",
|
||||||
|
"Readings start 3 seconds after opening a page. You can play, pause or stop them at any time. Your device volume controls the voice.": "Die Lesung beginnt drei Sekunden nach dem Öffnen einer Seite. Du kannst sie jederzeit starten, pausieren oder stoppen. Die Gerätelautstärke regelt die Stimme.",
|
||||||
|
"Recording speed": "Vorlesetempo",
|
||||||
|
"Recovered pixel picture: {0}": "Wiederhergestelltes Pixelbild: {0}",
|
||||||
|
"Replay recording": "Aufnahme erneut abspielen",
|
||||||
|
"Restore a small light, or leave a bookmark and read on.": "Stelle ein kleines Licht wieder her oder setze ein Lesezeichen und lies weiter.",
|
||||||
|
"Restore the pattern →": "Das Muster wiederherstellen →",
|
||||||
|
"Resume recording": "Aufnahme fortsetzen",
|
||||||
|
"Return to my ribbon bookmark": "Zu meinem Lesezeichen zurückkehren",
|
||||||
|
"Return to the notebook": "Zurück zum Notizbuch",
|
||||||
|
"Return to this pattern": "Zurück zu diesem Muster",
|
||||||
|
"Revisit the memory →": "Die Erinnerung erneut lesen →",
|
||||||
|
"Row {0}": "Zeile {0}",
|
||||||
|
"Row {0}, column {1}": "Zeile {0}, Spalte {1}",
|
||||||
|
"Row {0}, column {1}, {2}": "Zeile {0}, Spalte {1}, {2}",
|
||||||
|
"See the transformation again": "Die Verwandlung erneut ansehen",
|
||||||
|
"Short deductions. A gentle place to begin.": "Kurze Schlussfolgerungen. Ein sanfter Einstieg.",
|
||||||
|
"Some things are worth keeping. — Gran": "Manche Dinge sollte man bewahren. — Oma",
|
||||||
|
"Something found. Something remembered.": "Etwas gefunden. Etwas erinnert.",
|
||||||
|
"Sound & atmosphere": "Klang und Atmosphäre",
|
||||||
|
"Speed": "Tempo",
|
||||||
|
"Stop": "Stopp",
|
||||||
|
"Story library": "Geschichtenbibliothek",
|
||||||
|
"THE COTTAGE / {0} OF {1}": "DAS HÄUSCHEN / {0} VON {1}",
|
||||||
|
"THE END · YOUR WATCH HAS BEGUN": "ENDE · DEINE WACHE HAT BEGONNEN",
|
||||||
|
"THE LAST PAGE · COME BACK WHENEVER YOU LIKE": "DIE LETZTE SEITE · KOMM JEDERZEIT ZURÜCK",
|
||||||
|
"Take the path to the harbour →": "Den Weg zum Hafen nehmen →",
|
||||||
|
"Tap A, B or C to highlight its area": "Tippe auf A, B oder C, um den Bereich hervorzuheben",
|
||||||
|
"Tap: light → cross → clear. Mark every cell.": "Tippen: Licht → Kreuz → leer. Markiere jedes Feld.",
|
||||||
|
"The atmosphere could not be played. Your reading is still available.": "Die Umgebungsgeräusche konnten nicht abgespielt werden. Du kannst weiterhin lesen.",
|
||||||
|
"The folded note": "Der gefaltete Zettel",
|
||||||
|
"The picture will appear once you restore the pattern.": "Das Bild erscheint, sobald du das Muster gelöst hast.",
|
||||||
|
"The reading starts automatically in 3 seconds": "Die Lesung beginnt automatisch in drei Sekunden",
|
||||||
|
"The wire is hidden under a strip of cloth. In the margin, Gran has written: “The light matters. So do the hands carrying it.”": "Der Draht ist unter einem Stoffstreifen verborgen. Am Rand hat Oma notiert: „Das Licht ist wichtig. Die Hände, die es tragen, auch.“",
|
||||||
|
"This cell is lit.": "Dieses Feld leuchtet.",
|
||||||
|
"This cell stays dark.": "Dieses Feld bleibt dunkel.",
|
||||||
|
"This language could not be opened. Please try again.": "Diese Sprache konnte nicht geladen werden. Bitte versuche es erneut.",
|
||||||
|
"This recording could not be played. You can still read the entry.": "Diese Aufnahme konnte nicht abgespielt werden. Du kannst den Eintrag weiterhin lesen.",
|
||||||
|
"This story could not be opened. Please try again.": "Diese Geschichte konnte nicht geöffnet werden. Bitte versuche es erneut.",
|
||||||
|
"This story is shown in its original language.": "Diese Geschichte wird in ihrer Originalsprache angezeigt.",
|
||||||
|
"Today’s puzzle": "Das heutige Rätsel",
|
||||||
|
"Turn the page →": "Die Seite umblättern →",
|
||||||
|
"Turn to the pattern →": "Zum Muster umblättern →",
|
||||||
|
"Undo a mark": "Markierung rückgängig",
|
||||||
|
"Unfold Gran’s note": "Omas Zettel auffalten",
|
||||||
|
"Unhurried · 0.85×": "Gemächlich · 0.85×",
|
||||||
|
"View the solved pattern": "Das gelöste Muster ansehen",
|
||||||
|
"View the solved pattern →": "Das gelöste Muster ansehen →",
|
||||||
|
"Watch a rewarded ad for one explained hint.": "Sieh dir ein Werbevideo an und erhalte einen erklärten Hinweis.",
|
||||||
|
"Watch ad": "Werbung ansehen",
|
||||||
|
"Water at the harbour and bridge, wind around the tower. The atmosphere grows quieter while the story is read.": "Wasser am Hafen und an der Brücke, Wind um den Turm. Während des Vorlesens werden die Umgebungsgeräusche leiser.",
|
||||||
|
"Watercolour illustration: {0}": "Aquarell: {0}",
|
||||||
|
"Watercolour of Gran’s stone cottage, blue door and warm window.": "Aquarell von Omas Steinhäuschen mit blauer Tür und warmem Fenster.",
|
||||||
|
"Watercolour of the island at dusk, with the lighthouse and Gran’s cottage.": "Aquarell der Insel in der Abenddämmerung mit dem Leuchtturm und Omas Häuschen.",
|
||||||
|
"You don’t have to solve anything to discover this.": "Dafür musst du kein Rätsel lösen.",
|
||||||
|
"Your pattern is saved for another day.": "Dein Muster ist für einen anderen Tag gespeichert.",
|
||||||
|
"Your puzzle marks are saved. You can read the memory now and come back to solve the pattern whenever you like.": "Deine Markierungen sind gespeichert. Du kannst die Erinnerung jetzt lesen und das Muster später lösen.",
|
||||||
|
"Your puzzle marks are saved. You can read the memory now and return to this pattern whenever you like.": "Deine Markierungen sind gespeichert. Du kannst die Erinnerung jetzt lesen und jederzeit zu diesem Muster zurückkehren.",
|
||||||
|
"Your restored pattern\n{0}": "Dein gelöstes Muster\n{0}",
|
||||||
|
"Your restored pattern: {0}": "Dein gelöstes Muster: {0}",
|
||||||
|
"Your unfinished patterns will wait here for you.": "Deine ungelösten Muster warten hier auf dich.",
|
||||||
|
"crossed out": "durchgekreuzt",
|
||||||
|
"empty": "leer",
|
||||||
|
"lit": "leuchtend",
|
||||||
|
"{0}\nDAY STREAK": "{0}\nTAGE IN FOLGE",
|
||||||
|
"{0}\nPATTERNS FOUND": "{0}\nGEFUNDENE MUSTER",
|
||||||
|
"{0} / LEAF {1}": "{0} / SEITE {1}",
|
||||||
|
"{0} / {1} OF {2}": "{0} / {1} VON {2}",
|
||||||
|
"{0} already has all its lights. Every remaining cell in it must be crossed out.": "{0} enthält bereits alle Lichter. Alle übrigen Felder müssen durchgekreuzt werden.",
|
||||||
|
"{0} needs {1} more lights and has exactly {2} empty cells. They must all be lit.": "{0} braucht noch {1} Lichter und hat genau {2} leere Felder. Alle müssen leuchten.",
|
||||||
|
"{0} · CONTENTS": "{0} · INHALT",
|
||||||
|
"{0} · recorded story": "{0} · aufgenommene Geschichte",
|
||||||
|
"{0}, fixed clue": "{0}, feste Vorgabe",
|
||||||
|
"{0}Follow device language": "{0}Gerätesprache verwenden",
|
||||||
|
"← Previous chapter": "← Vorheriges Kapitel",
|
||||||
|
"← Previous leaf": "← Vorherige Seite"
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
{
|
||||||
|
"A SMALL DAILY RITUAL": "A SMALL DAILY RITUAL",
|
||||||
|
"A careful repair": "A careful repair",
|
||||||
|
"A few spare pages for practice. For overlapping-area puzzles, follow the notebook’s story.": "A few spare pages for practice. For overlapping-area puzzles, follow the notebook’s story.",
|
||||||
|
"A few things worth keeping": "A few things worth keeping",
|
||||||
|
"A folded note sealed with red wax": "A folded note sealed with red wax",
|
||||||
|
"A folded scrap, tucked between the leaves.": "A folded scrap, tucked between the leaves.",
|
||||||
|
"A light kept in these pages. Your unfinished patterns will be here whenever you return.": "A light kept in these pages. Your unfinished patterns will be here whenever you return.",
|
||||||
|
"A light to come\nhome to.": "A light to come\nhome to.",
|
||||||
|
"A little faster · 1.15×": "A little faster · 1.15×",
|
||||||
|
"A little nudge?": "A little nudge?",
|
||||||
|
"A memory to read · your pattern can wait": "A memory to read · your pattern can wait",
|
||||||
|
"A memory to read · your puzzle can wait": "A memory to read · your puzzle can wait",
|
||||||
|
"A moment of clarity.": "A moment of clarity.",
|
||||||
|
"A pattern restored · a memory kept": "A pattern restored · a memory kept",
|
||||||
|
"A pencil sketch of a match and a small amber flame": "A pencil sketch of a match and a small amber flame",
|
||||||
|
"A recorded reading, kept with this page": "A recorded reading, kept with this page",
|
||||||
|
"A repair made to keep small fingers safe.": "A repair made to keep small fingers safe.",
|
||||||
|
"A repair note, tucked into the margin.": "A repair note, tucked into the margin.",
|
||||||
|
"A ribbon marks this page.": "A ribbon marks this page.",
|
||||||
|
"A, B and C are outlined areas with their own light totals. Shared cells count in each area they belong to. Compare clues and subtract their shared parts to find new deductions.": "A, B and C are outlined areas with their own light totals. Shared cells count in each area they belong to. Compare clues and subtract their shared parts to find new deductions.",
|
||||||
|
"Across the tide →": "Across the tide →",
|
||||||
|
"Already restored. Turn the leaf to revisit the memory.": "Already restored. Turn the leaf to revisit the memory.",
|
||||||
|
"An earlier mark conflicts with the clues. Correct it, then continue comparing the totals.": "An earlier mark conflicts with the clues. Correct it, then continue comparing the totals.",
|
||||||
|
"Area {0}": "Area {0}",
|
||||||
|
"Atmosphere volume": "Atmosphere volume",
|
||||||
|
"BY THE COTTAGE WINDOW": "BY THE COTTAGE WINDOW",
|
||||||
|
"Back to contents": "Back to contents",
|
||||||
|
"Back to notebook": "Back to notebook",
|
||||||
|
"Back to the notebook": "Back to the notebook",
|
||||||
|
"Before you leave": "Before you leave",
|
||||||
|
"Bookmark": "Bookmark",
|
||||||
|
"CLASSIC / {0} / LEVEL {1}": "CLASSIC / {0} / LEVEL {1}",
|
||||||
|
"Classic practice pace": "Classic practice pace",
|
||||||
|
"Close": "Close",
|
||||||
|
"Close book": "Close book",
|
||||||
|
"Close the notebook": "Close the notebook",
|
||||||
|
"Column {0}": "Column {0}",
|
||||||
|
"Compare rows, columns and overlapping areas.": "Compare rows, columns and overlapping areas.",
|
||||||
|
"Compare the shared areas. Each cell counts in every area it belongs to.": "Compare the shared areas. Each cell counts in every area it belongs to.",
|
||||||
|
"Compare {0} ({1} more lights) with {2} ({3} more). Shared empty cells cancel. The difference forces the cells outside their overlap.": "Compare {0} ({1} more lights) with {2} ({3} more). Shared empty cells cancel. The difference forces the cells outside their overlap.",
|
||||||
|
"Contents": "Contents",
|
||||||
|
"Continue reading": "Continue reading",
|
||||||
|
"Continue reading · {0}": "Continue reading · {0}",
|
||||||
|
"Continue this pattern →": "Continue this pattern →",
|
||||||
|
"DAILY / {0}": "DAILY / {0}",
|
||||||
|
"Difficulty · {0} ▾": "Difficulty · {0} ▾",
|
||||||
|
"Easy": "Easy",
|
||||||
|
"End of the reading · listen again whenever you like": "End of the reading · listen again whenever you like",
|
||||||
|
"Environmental sounds": "Environmental sounds",
|
||||||
|
"Every pattern restored. The daily puzzle will be here whenever you return.": "Every pattern restored. The daily puzzle will be here whenever you return.",
|
||||||
|
"Find the light": "Find the light",
|
||||||
|
"Find the light.": "Find the light.",
|
||||||
|
"Finding a fresh pattern…": "Finding a fresh pattern…",
|
||||||
|
"Fold the note again": "Fold the note again",
|
||||||
|
"Follow device language": "Follow device language",
|
||||||
|
"Follow longer chains to uncover the pattern.": "Follow longer chains to uncover the pattern.",
|
||||||
|
"Follow the lantern into the next entry →": "Follow the lantern into the next entry →",
|
||||||
|
"For the crossing": "For the crossing",
|
||||||
|
"For you, when you are ready. With all my love, Gran.": "For you, when you are ready. With all my love, Gran.",
|
||||||
|
"Four memories in the cottage · {0} patterns restored": "Four memories in the cottage · {0} patterns restored",
|
||||||
|
"Game progress stays on this device. No account or game backend is used. Google advertising services may process device and ad interaction data when ads are available.\n\nNo advertising privacy options are currently required or available for your region.": "Game progress stays on this device. No account or game backend is used. Google advertising services may process device and ad interaction data when ads are available.\n\nNo advertising privacy options are currently required or available for your region.",
|
||||||
|
"Got it": "Got it",
|
||||||
|
"Gran’s repair note": "Gran’s repair note",
|
||||||
|
"Hard": "Hard",
|
||||||
|
"Hint · rewarded ad": "Hint · rewarded ad",
|
||||||
|
"How to play": "How to play",
|
||||||
|
"Keep going": "Keep going",
|
||||||
|
"Keep reading": "Keep reading",
|
||||||
|
"Keep solving": "Keep solving",
|
||||||
|
"Keep that thought": "Keep that thought",
|
||||||
|
"Keep thinking": "Keep thinking",
|
||||||
|
"Kept safe, between these pages. — M.": "Kept safe, between these pages. — M.",
|
||||||
|
"L U M E N / AN ISLAND STORY": "L U M E N / AN ISLAND STORY",
|
||||||
|
"L U M E N / STORY LIBRARY": "L U M E N / STORY LIBRARY",
|
||||||
|
"Language": "Language",
|
||||||
|
"Leave a light in the window.": "Leave a light in the window.",
|
||||||
|
"Leave a ribbon here?": "Leave a ribbon here?",
|
||||||
|
"Light exactly as many cells as the number beside each row and above each column.\n\nTap to cycle: empty → light → crossed out → empty. Mark every cell to finish. Small dots mark fixed clues.\n\nA, B and C are overlapping areas with their own totals. Shared cells count in both areas. Compare clues and subtract their shared parts to find new deductions.\n\nEvery story grid reveals an object. Later pages require area comparisons; all are solvable without guessing. Classic practice grades the length of simpler row and column chains.\n\nWatch a rewarded ad for each explained hint. Hints are optional, and your puzzle remains available if no ad can be shown. Streaks count consecutive daily completions on this device.": "Light exactly as many cells as the number beside each row and above each column.\n\nTap to cycle: empty → light → crossed out → empty. Mark every cell to finish. Small dots mark fixed clues.\n\nA, B and C are overlapping areas with their own totals. Shared cells count in both areas. Compare clues and subtract their shared parts to find new deductions.\n\nEvery story grid reveals an object. Later pages require area comparisons; all are solvable without guessing. Classic practice grades the length of simpler row and column chains.\n\nWatch a rewarded ad for each explained hint. Hints are optional, and your puzzle remains available if no ad can be shown. Streaks count consecutive daily completions on this device.",
|
||||||
|
"Light the cells to match each row and column total. Cross out the cells that stay dark. The finished grid is a picture from the story.": "Light the cells to match each row and column total. Cross out the cells that stay dark. The finished grid is a picture from the story.",
|
||||||
|
"Link deductions across rows and columns.": "Link deductions across rows and columns.",
|
||||||
|
"Mara · diary reading": "Mara · diary reading",
|
||||||
|
"Mara’s\nisland notebook": "Mara’s\nisland notebook",
|
||||||
|
"Match the totals. Let the pattern emerge.": "Match the totals. Let the pattern emerge.",
|
||||||
|
"Medium": "Medium",
|
||||||
|
"Missing translations use the story’s original language. Your reading position and puzzle marks are shared across languages.": "Missing translations use the story’s original language. Your reading position and puzzle marks are shared across languages.",
|
||||||
|
"Narrator · recorded story": "Narrator · recorded story",
|
||||||
|
"Next chapter →": "Next chapter →",
|
||||||
|
"Next leaf →": "Next leaf →",
|
||||||
|
"Next puzzle →": "Next puzzle →",
|
||||||
|
"No ad available. Please try again later.": "No ad available. Please try again later.",
|
||||||
|
"Open Mara’s cloth-bound island notebook": "Open Mara’s cloth-bound island notebook",
|
||||||
|
"Open the dedication": "Open the dedication",
|
||||||
|
"Open {0} · {1} / {2}": "Open {0} · {1} / {2}",
|
||||||
|
"Open-source licenses": "Open-source licenses",
|
||||||
|
"Opening recording…": "Opening recording…",
|
||||||
|
"Original reading · 1.0×": "Original reading · 1.0×",
|
||||||
|
"Pause recording": "Pause recording",
|
||||||
|
"Paused · {0} / {1}": "Paused · {0} / {1}",
|
||||||
|
"Play this reading": "Play this reading",
|
||||||
|
"Play today’s puzzle →": "Play today’s puzzle →",
|
||||||
|
"Playing · {0} / {1}": "Playing · {0} / {1}",
|
||||||
|
"Practice · {0} · Level {1}": "Practice · {0} · Level {1}",
|
||||||
|
"Privacy & advertising": "Privacy & advertising",
|
||||||
|
"Read Gran’s margin note": "Read Gran’s margin note",
|
||||||
|
"Read ahead": "Read ahead",
|
||||||
|
"Readings start 3 seconds after opening a page. You can play, pause or stop them at any time. Your device volume controls the voice.": "Readings start 3 seconds after opening a page. You can play, pause or stop them at any time. Your device volume controls the voice.",
|
||||||
|
"Recording speed": "Recording speed",
|
||||||
|
"Recovered pixel picture: {0}": "Recovered pixel picture: {0}",
|
||||||
|
"Replay recording": "Replay recording",
|
||||||
|
"Restore a small light, or leave a bookmark and read on.": "Restore a small light, or leave a bookmark and read on.",
|
||||||
|
"Restore the pattern →": "Restore the pattern →",
|
||||||
|
"Resume recording": "Resume recording",
|
||||||
|
"Return to my ribbon bookmark": "Return to my ribbon bookmark",
|
||||||
|
"Return to the notebook": "Return to the notebook",
|
||||||
|
"Return to this pattern": "Return to this pattern",
|
||||||
|
"Revisit the memory →": "Revisit the memory →",
|
||||||
|
"Row {0}": "Row {0}",
|
||||||
|
"Row {0}, column {1}": "Row {0}, column {1}",
|
||||||
|
"Row {0}, column {1}, {2}": "Row {0}, column {1}, {2}",
|
||||||
|
"See the transformation again": "See the transformation again",
|
||||||
|
"Short deductions. A gentle place to begin.": "Short deductions. A gentle place to begin.",
|
||||||
|
"Some things are worth keeping. — Gran": "Some things are worth keeping. — Gran",
|
||||||
|
"Something found. Something remembered.": "Something found. Something remembered.",
|
||||||
|
"Sound & atmosphere": "Sound & atmosphere",
|
||||||
|
"Speed": "Speed",
|
||||||
|
"Stop": "Stop",
|
||||||
|
"Story library": "Story library",
|
||||||
|
"THE COTTAGE / {0} OF {1}": "THE COTTAGE / {0} OF {1}",
|
||||||
|
"THE END · YOUR WATCH HAS BEGUN": "THE END · YOUR WATCH HAS BEGUN",
|
||||||
|
"THE LAST PAGE · COME BACK WHENEVER YOU LIKE": "THE LAST PAGE · COME BACK WHENEVER YOU LIKE",
|
||||||
|
"Take the path to the harbour →": "Take the path to the harbour →",
|
||||||
|
"Tap A, B or C to highlight its area": "Tap A, B or C to highlight its area",
|
||||||
|
"Tap: light → cross → clear. Mark every cell.": "Tap: light → cross → clear. Mark every cell.",
|
||||||
|
"The atmosphere could not be played. Your reading is still available.": "The atmosphere could not be played. Your reading is still available.",
|
||||||
|
"The folded note": "The folded note",
|
||||||
|
"The picture will appear once you restore the pattern.": "The picture will appear once you restore the pattern.",
|
||||||
|
"The reading starts automatically in 3 seconds": "The reading starts automatically in 3 seconds",
|
||||||
|
"The wire is hidden under a strip of cloth. In the margin, Gran has written: “The light matters. So do the hands carrying it.”": "The wire is hidden under a strip of cloth. In the margin, Gran has written: “The light matters. So do the hands carrying it.”",
|
||||||
|
"This cell is lit.": "This cell is lit.",
|
||||||
|
"This cell stays dark.": "This cell stays dark.",
|
||||||
|
"This language could not be opened. Please try again.": "This language could not be opened. Please try again.",
|
||||||
|
"This recording could not be played. You can still read the entry.": "This recording could not be played. You can still read the entry.",
|
||||||
|
"This story could not be opened. Please try again.": "This story could not be opened. Please try again.",
|
||||||
|
"This story is shown in its original language.": "This story is shown in its original language.",
|
||||||
|
"Today’s puzzle": "Today’s puzzle",
|
||||||
|
"Turn the page →": "Turn the page →",
|
||||||
|
"Turn to the pattern →": "Turn to the pattern →",
|
||||||
|
"Undo a mark": "Undo a mark",
|
||||||
|
"Unfold Gran’s note": "Unfold Gran’s note",
|
||||||
|
"Unhurried · 0.85×": "Unhurried · 0.85×",
|
||||||
|
"View the solved pattern": "View the solved pattern",
|
||||||
|
"View the solved pattern →": "View the solved pattern →",
|
||||||
|
"Watch a rewarded ad for one explained hint.": "Watch a rewarded ad for one explained hint.",
|
||||||
|
"Watch ad": "Watch ad",
|
||||||
|
"Water at the harbour and bridge, wind around the tower. The atmosphere grows quieter while the story is read.": "Water at the harbour and bridge, wind around the tower. The atmosphere grows quieter while the story is read.",
|
||||||
|
"Watercolour illustration: {0}": "Watercolour illustration: {0}",
|
||||||
|
"Watercolour of Gran’s stone cottage, blue door and warm window.": "Watercolour of Gran’s stone cottage, blue door and warm window.",
|
||||||
|
"Watercolour of the island at dusk, with the lighthouse and Gran’s cottage.": "Watercolour of the island at dusk, with the lighthouse and Gran’s cottage.",
|
||||||
|
"You don’t have to solve anything to discover this.": "You don’t have to solve anything to discover this.",
|
||||||
|
"Your pattern is saved for another day.": "Your pattern is saved for another day.",
|
||||||
|
"Your puzzle marks are saved. You can read the memory now and come back to solve the pattern whenever you like.": "Your puzzle marks are saved. You can read the memory now and come back to solve the pattern whenever you like.",
|
||||||
|
"Your puzzle marks are saved. You can read the memory now and return to this pattern whenever you like.": "Your puzzle marks are saved. You can read the memory now and return to this pattern whenever you like.",
|
||||||
|
"Your restored pattern\n{0}": "Your restored pattern\n{0}",
|
||||||
|
"Your restored pattern: {0}": "Your restored pattern: {0}",
|
||||||
|
"Your unfinished patterns will wait here for you.": "Your unfinished patterns will wait here for you.",
|
||||||
|
"crossed out": "crossed out",
|
||||||
|
"empty": "empty",
|
||||||
|
"lit": "lit",
|
||||||
|
"{0}\nDAY STREAK": "{0}\nDAY STREAK",
|
||||||
|
"{0}\nPATTERNS FOUND": "{0}\nPATTERNS FOUND",
|
||||||
|
"{0} / LEAF {1}": "{0} / LEAF {1}",
|
||||||
|
"{0} / {1} OF {2}": "{0} / {1} OF {2}",
|
||||||
|
"{0} already has all its lights. Every remaining cell in it must be crossed out.": "{0} already has all its lights. Every remaining cell in it must be crossed out.",
|
||||||
|
"{0} needs {1} more lights and has exactly {2} empty cells. They must all be lit.": "{0} needs {1} more lights and has exactly {2} empty cells. They must all be lit.",
|
||||||
|
"{0} · CONTENTS": "{0} · CONTENTS",
|
||||||
|
"{0} · recorded story": "{0} · recorded story",
|
||||||
|
"{0}, fixed clue": "{0}, fixed clue",
|
||||||
|
"{0}Follow device language": "{0}Follow device language",
|
||||||
|
"← Previous chapter": "← Previous chapter",
|
||||||
|
"← Previous leaf": "← Previous leaf"
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"premise": "A folded page carries a promise across the village pond.",
|
||||||
|
"levels": [
|
||||||
|
{
|
||||||
|
"id": "boat",
|
||||||
|
"chapterId": "pond",
|
||||||
|
"chapter": "A small crossing",
|
||||||
|
"title": "A boat from a page",
|
||||||
|
"object": "The paper boat",
|
||||||
|
"before": "Rain has filled the village pond. In your pocket is a page from an old letter. You fold its corners until it can carry a journey of its own. Restore the pattern to set it afloat.",
|
||||||
|
"after": "The little boat reaches the far bank. A child waves and sends it back with a flower tucked into its bow. Some journeys bring something home.",
|
||||||
|
"picture": "0001000000110000011100001000111111101111101000001",
|
||||||
|
"clues": "3,9",
|
||||||
|
"areas": "0,3,5,2;3,1,3,3;2,2,4,4",
|
||||||
|
"illustrationAsset": "assets/artwork/little-boat-vignette-v1.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"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": "Der Regen hat den Dorfteich gefüllt. In deiner Tasche steckt eine Seite aus einem alten Brief. Du faltest die Ecken, bis daraus ein kleines Boot entsteht. Vervollständige das Muster und lass es zu Wasser.",
|
||||||
|
"after": "Das kleine Boot erreicht das andere Ufer. Ein Kind winkt und schickt es zurück – mit einer Blume im Bug. Manche Reisen bringen etwas nach Hause."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pages": {
|
||||||
|
"boat.entry": {
|
||||||
|
"title": "Ein Boot aus Papier"
|
||||||
|
},
|
||||||
|
"boat.puzzle": {
|
||||||
|
"title": "Eine kleine Überfahrt"
|
||||||
|
},
|
||||||
|
"boat.memory": {
|
||||||
|
"title": "Etwas kommt nach Hause"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"id": "boat.entry",
|
||||||
|
"title": "A boat from a page",
|
||||||
|
"type": "entry",
|
||||||
|
"campaignIndex": 0,
|
||||||
|
"textSource": "before"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "boat.puzzle",
|
||||||
|
"title": "A small crossing",
|
||||||
|
"type": "puzzle",
|
||||||
|
"campaignIndex": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "boat.memory",
|
||||||
|
"title": "Something comes home",
|
||||||
|
"type": "memory",
|
||||||
|
"campaignIndex": 0,
|
||||||
|
"textSource": "after"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+37
-12
@@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
- **What it is:** an offline illustrated logic-puzzle notebook ("Lumen", version 2.0.2+11).
|
- **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.
|
- **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.
|
- **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`.
|
- **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.
|
- **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.
|
- **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/
|
├── domain/
|
||||||
│ ├── puzzle.dart Puzzle, JavaRandom, LogicSolver, Difficulty, Region, Hint
|
│ ├── puzzle.dart Puzzle, JavaRandom, LogicSolver, Difficulty, Region, Hint
|
||||||
│ ├── thinking.dart ThinkingAnalyzer, ThinkingReport — snapshot deduction waves and bounded hypothetical proofs
|
│ ├── 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
|
│ └── game.dart Game (ChangeNotifier), Screen/Mode, puzzle session, awards
|
||||||
├── services/
|
├── services/
|
||||||
|
│ ├── translation.dart TranslationCatalog, MessageTranslator — separate UI catalogues and placeholders
|
||||||
│ ├── progress.dart Progress — typed façade over SharedPreferencesAsync
|
│ ├── progress.dart Progress — typed façade over SharedPreferencesAsync
|
||||||
│ ├── ambience.dart Ambience, Soundscape — location loops, fades and narration ducking
|
│ ├── ambience.dart Ambience, Soundscape — location loops, fades and narration ducking
|
||||||
│ ├── narrator.dart Narrator — just_audio playback and passage cues
|
│ ├── narrator.dart Narrator — just_audio playback and passage cues
|
||||||
@@ -42,9 +44,14 @@ lib/
|
|||||||
└── ui/
|
└── ui/
|
||||||
├── paper.dart Paper, Leaf, Cover, Sketch, InkButton, PageSwipeBlocker
|
├── paper.dart Paper, Leaf, Cover, Sketch, InkButton, PageSwipeBlocker
|
||||||
├── board.dart Board, PencilMark painter, PixelPicture, PatternStamp
|
├── 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/
|
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)
|
├── 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)
|
├── notebook.json sixteen stable cottage leaf records (type, speaker, campaignIndex, text source)
|
||||||
├── narration/scripts.json canonical diary text, one record per recorded page
|
├── narration/scripts.json canonical diary text, one record per recorded page
|
||||||
@@ -131,10 +138,10 @@ Dependency rules:
|
|||||||
|
|
||||||
## Runtime wiring
|
## 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`.
|
- `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.
|
- `_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.
|
- 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()`.
|
- `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).
|
- `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 |
|
| `home()` | `Screen.home`; cancels pending board generation |
|
||||||
| `openNotebook()` | `showStory(index of notebook_last_page, else 0)` |
|
| `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` |
|
| `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 |
|
| `leaveCottage()` | Open Chapter II for reading without awarding unfinished cottage puzzles |
|
||||||
| `briefing(i)` | Clamp to `accessible`; cottage entry leaf or later `Screen.briefing` |
|
| `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` |
|
| `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:
|
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.
|
- **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.
|
- **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.
|
- `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.
|
- `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
|
## 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`.
|
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
|
### 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 |
|
| Key | Type | Written by | Purpose |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| `notebook_last_page` | page id | `Game.showStory` | Resume the last cottage leaf |
|
| `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_manual_bookmark` | page id | `bookmark()` | "Return to my ribbon bookmark" in Contents |
|
||||||
| `notebook_note_open` | bool | folded-note leaf | Note unfolded/folded state |
|
| `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 |
|
| `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 |
|
| `streak` | int | daily completion | Consecutive daily completions |
|
||||||
| `campaignUnlocked` | int 0–11 | campaign completion | Furthest solved campaign level |
|
| `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 |
|
| `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_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 |
|
| `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` |
|
| `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.
|
- 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()`.
|
- 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.
|
- `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
|
### 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.
|
- `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.
|
- `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.
|
- 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.
|
- `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).
|
- 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 |
|
| `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 |
|
| `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 |
|
| `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/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 |
|
| `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/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/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 |
|
| `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 |
|
| 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 |
|
| 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 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` |
|
| 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 |
|
| 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 |
|
| [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 |
|
| [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 |
|
| [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 |
|
| [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.
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
import 'package:lumen/domain/game.dart';
|
||||||
|
import 'package:lumen/domain/library.dart';
|
||||||
|
import 'package:lumen/main.dart';
|
||||||
|
import 'package:lumen/services/progress.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
testWidgets('library switching and translation share progress on a device', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
expect(const bool.fromEnvironment('QA_TEST'), true);
|
||||||
|
final library = await StoryLibrary.load();
|
||||||
|
final g = Game(
|
||||||
|
await library.open('mara-island'),
|
||||||
|
Progress.memory({'language': 'en'}),
|
||||||
|
library: library,
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await binding.convertFlutterSurfaceToImage();
|
||||||
|
Future<void> tap(String text) async {
|
||||||
|
await tester.ensureVisible(find.text(text));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text(text));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
await tap('Story library');
|
||||||
|
await tap('The paper boat');
|
||||||
|
expect(g.book.id, 'paper-boat');
|
||||||
|
await tap('Open The paper boat · 0 / 1');
|
||||||
|
await tap('Next leaf →');
|
||||||
|
await tester.ensureVisible(find.byKey(const ValueKey('cell-0')));
|
||||||
|
await tester.tap(find.byKey(const ValueKey('cell-0')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final marks = List<int>.of(g.cells);
|
||||||
|
await tap('Bookmark');
|
||||||
|
await tap('Language');
|
||||||
|
await tap('Deutsch');
|
||||||
|
expect(g.book.language, 'de');
|
||||||
|
expect(g.cells, marks);
|
||||||
|
expect(g.canUndo, true);
|
||||||
|
expect(g.progress.text('notebook_manual_bookmark'), 'boat.puzzle');
|
||||||
|
expect(find.text('Eine kleine Überfahrt'), findsOneWidget);
|
||||||
|
await binding.takeScreenshot('library-german-puzzle');
|
||||||
|
await tap('Nächste Seite →');
|
||||||
|
await tap('Weiterlesen');
|
||||||
|
expect(g.recoveredCount, 0);
|
||||||
|
expect(g.storyPage.id, 'boat.memory');
|
||||||
|
await binding.takeScreenshot('library-german-memory');
|
||||||
|
await g.selectStory('mara-island');
|
||||||
|
expect(g.book.language, 'en');
|
||||||
|
expect(g.progress.text('notebook_manual_bookmark'), isEmpty);
|
||||||
|
expect(g.recoveredCount, 0);
|
||||||
|
await g.selectStory('paper-boat');
|
||||||
|
g.startCampaign(0);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(g.cells, marks);
|
||||||
|
final puzzle = g.puzzle!;
|
||||||
|
for (var i = 0; i < g.cells.length; i++) {
|
||||||
|
while (g.cells[i] != (puzzle.solution[i] == 1 ? 1 : 2)) {
|
||||||
|
g.mark(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(g.recoveredCount, 1);
|
||||||
|
expect(g.solved, 1);
|
||||||
|
await binding.takeScreenshot('library-german-discovery');
|
||||||
|
await SystemChrome.setPreferredOrientations([
|
||||||
|
DeviceOrientation.landscapeLeft,
|
||||||
|
]);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await binding.takeScreenshot('library-german-landscape');
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
await tester.pumpWidget(const SizedBox());
|
||||||
|
await SystemChrome.setPreferredOrientations([]);
|
||||||
|
});
|
||||||
|
}
|
||||||
+225
-57
@@ -3,10 +3,14 @@ import 'dart:convert';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'puzzle.dart';
|
import 'puzzle.dart';
|
||||||
|
import 'library.dart';
|
||||||
|
|
||||||
class CampaignLevel {
|
class CampaignLevel {
|
||||||
CampaignLevel(Map<String, dynamic> data)
|
CampaignLevel(Map<String, dynamic> data)
|
||||||
: chapter = data['chapter'],
|
: id = data['id'] as String? ?? '',
|
||||||
|
chapterId = data['chapterId'] as String? ?? data['chapter'],
|
||||||
|
size = data['size'] as int? ?? 7,
|
||||||
|
chapter = data['chapter'],
|
||||||
title = data['title'],
|
title = data['title'],
|
||||||
object = data['object'],
|
object = data['object'],
|
||||||
before = data['before'],
|
before = data['before'],
|
||||||
@@ -17,21 +21,30 @@ class CampaignLevel {
|
|||||||
picture = (data['picture'] as String).split('').map(int.parse).toList(),
|
picture = (data['picture'] as String).split('').map(int.parse).toList(),
|
||||||
clues = data['clues'],
|
clues = data['clues'],
|
||||||
areas = data['areas'];
|
areas = data['areas'];
|
||||||
|
final String id, chapterId;
|
||||||
|
final int size;
|
||||||
final String chapter, title, object, before, after, clues, areas;
|
final String chapter, title, object, before, after, clues, areas;
|
||||||
final String beforeContinuation, afterContinuation;
|
final String beforeContinuation, afterContinuation;
|
||||||
final String? illustrationAsset;
|
final String? illustrationAsset;
|
||||||
final List<int> picture;
|
final List<int> picture;
|
||||||
Puzzle puzzle() {
|
Puzzle puzzle() {
|
||||||
final p = Puzzle(7, picture);
|
final p = Puzzle(size, picture);
|
||||||
if (clues.isNotEmpty) {
|
if (clues.isNotEmpty) {
|
||||||
for (final c in clues.split(',')) {
|
for (final c in clues.split(',')) {
|
||||||
p.given[int.parse(c)] = true;
|
final index = int.parse(c);
|
||||||
|
if (index < 0 || index >= picture.length) {
|
||||||
|
throw FormatException('Invalid fixed clue: $id: $index');
|
||||||
|
}
|
||||||
|
p.given[index] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (areas.isNotEmpty) {
|
if (areas.isNotEmpty) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for (final a in areas.split(';')) {
|
for (final a in areas.split(';')) {
|
||||||
final v = a.split(',').map(int.parse).toList();
|
final v = a.split(',').map(int.parse).toList();
|
||||||
|
if (v.length != 4) {
|
||||||
|
throw FormatException('Invalid region: $id');
|
||||||
|
}
|
||||||
p.regions.add(
|
p.regions.add(
|
||||||
Region(String.fromCharCode(65 + i++), v[0], v[1], v[2], v[3]),
|
Region(String.fromCharCode(65 + i++), v[0], v[1], v[2], v[3]),
|
||||||
);
|
);
|
||||||
@@ -61,9 +74,10 @@ class StoryPage {
|
|||||||
this.speaker = '',
|
this.speaker = '',
|
||||||
this.illustrationAsset,
|
this.illustrationAsset,
|
||||||
this.continuation = '',
|
this.continuation = '',
|
||||||
|
this.caption = '',
|
||||||
});
|
});
|
||||||
final String id, title, text;
|
final String id, title, text;
|
||||||
final String continuation;
|
final String continuation, caption;
|
||||||
final StoryPageType type;
|
final StoryPageType type;
|
||||||
final int? campaignIndex;
|
final int? campaignIndex;
|
||||||
final String speaker;
|
final String speaker;
|
||||||
@@ -71,68 +85,222 @@ class StoryPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Book {
|
class Book {
|
||||||
Book(this.premise, this.levels, this.pages, this.tracks);
|
Book(
|
||||||
|
this.premise,
|
||||||
|
this.levels,
|
||||||
|
this.pages,
|
||||||
|
this.tracks, {
|
||||||
|
this.id = 'mara-island',
|
||||||
|
this.title = 'Mara’s notebook',
|
||||||
|
this.description = '',
|
||||||
|
this.language = 'en',
|
||||||
|
this.defaultLanguage = 'en',
|
||||||
|
this.presentation = 'mara',
|
||||||
|
this.coverAsset = 'assets/artwork/home-notebook-cover-v2.png',
|
||||||
|
this.continueAt = 4,
|
||||||
|
this.initiallyAccessible = 3,
|
||||||
|
this.fontFamily = 'MaraHand',
|
||||||
|
this.copy = const {},
|
||||||
|
});
|
||||||
|
final String id, title, description, language, defaultLanguage, presentation;
|
||||||
|
final String? coverAsset, fontFamily;
|
||||||
|
final int? continueAt;
|
||||||
|
final int initiallyAccessible;
|
||||||
|
final Map<String, String> copy;
|
||||||
final String premise;
|
final String premise;
|
||||||
final List<CampaignLevel> levels;
|
final List<CampaignLevel> levels;
|
||||||
final List<StoryPage> pages;
|
final List<StoryPage> pages;
|
||||||
final Map<String, dynamic> tracks;
|
final Map<String, dynamic> tracks;
|
||||||
|
bool get isMara => presentation == 'mara';
|
||||||
|
List<String> get chapters => levels.map((l) => l.chapterId).toSet().toList();
|
||||||
|
List<int> chapterLevels(int chapter) => [
|
||||||
|
for (var i = 0; i < levels.length; i++)
|
||||||
|
if (levels[i].chapterId == chapters[chapter]) i,
|
||||||
|
];
|
||||||
|
int chapterFor(int level) => chapters.indexOf(levels[level].chapterId);
|
||||||
|
String puzzleKey(int index) => id == 'mara-island'
|
||||||
|
? 'story_v1_$index'
|
||||||
|
: 'story_${id}_${levels[index].id}';
|
||||||
int pageFor(int campaignIndex, StoryPageType type) => pages.indexWhere(
|
int pageFor(int campaignIndex, StoryPageType type) => pages.indexWhere(
|
||||||
(p) => p.campaignIndex == campaignIndex && p.type == type,
|
(p) => p.campaignIndex == campaignIndex && p.type == type,
|
||||||
);
|
);
|
||||||
static Future<Book> load() async {
|
static Future<Book> load() async =>
|
||||||
final campaign = jsonDecode(
|
(await StoryLibrary.load()).open('mara-island');
|
||||||
await rootBundle.loadString('assets/campaign.json'),
|
|
||||||
) as Map<String, dynamic>;
|
static Future<Book> loadDefinition(
|
||||||
final scripts = jsonDecode(
|
StoryDefinition definition, {
|
||||||
await rootBundle.loadString('assets/narration/scripts.json'),
|
String language = 'en',
|
||||||
) as List;
|
AssetBundle? bundle,
|
||||||
final tracks =
|
}) async {
|
||||||
jsonDecode(
|
final assets = bundle ?? rootBundle;
|
||||||
await rootBundle.loadString(
|
Future<dynamic> read(String path) async =>
|
||||||
'assets/audio/narration_manifest.json',
|
jsonDecode(await assets.loadString(path));
|
||||||
),
|
final campaign = Map<String, dynamic>.from(
|
||||||
)['tracks']
|
await read(definition.campaignAsset),
|
||||||
as Map<String, dynamic>;
|
);
|
||||||
final levels = (campaign['levels'] as List)
|
final notebook = await read(definition.notebookAsset);
|
||||||
.map((e) => CampaignLevel(e))
|
final scripts = definition.scriptsAsset == null
|
||||||
.toList();
|
? <dynamic>[]
|
||||||
final notebook = jsonDecode(
|
: await read(definition.scriptsAsset!) as List;
|
||||||
await rootBundle.loadString('assets/notebook.json'),
|
final actualLanguage = definition.languageFor(language);
|
||||||
) as Map<String, dynamic>;
|
final locale = definition.languages[actualLanguage] as Map;
|
||||||
return Book(
|
final translation = locale['asset'] == null
|
||||||
campaign['premise'],
|
? <String, dynamic>{}
|
||||||
levels,
|
: Map<String, dynamic>.from(await read(locale['asset']));
|
||||||
(notebook['pages'] as List).map((record) {
|
final translatedLevels = translation['levels'] as Map? ?? {};
|
||||||
final index = record['campaignIndex'] as int?;
|
final translatedPages = translation['pages'] as Map? ?? {};
|
||||||
final text = switch (record['textSource']) {
|
// Translations may only replace presentation fields, never puzzle identity
|
||||||
'before' => levels[index!].before,
|
// or rules. A missing field falls back to the original text.
|
||||||
'after' => levels[index!].after,
|
const levelText = [
|
||||||
'recording' =>
|
'chapter',
|
||||||
scripts
|
'title',
|
||||||
.where((s) => s['pageId'] == record['id'])
|
'object',
|
||||||
.map((s) => (s['baseText'] ?? s['text']) as String)
|
'before',
|
||||||
.firstOrNull ??
|
'after',
|
||||||
'',
|
'beforeContinuation',
|
||||||
_ => record['text'] as String? ?? '',
|
'afterContinuation',
|
||||||
};
|
'illustrationAsset',
|
||||||
return StoryPage(
|
];
|
||||||
record['id'],
|
const pageText = [
|
||||||
record['title'],
|
'title',
|
||||||
text,
|
'text',
|
||||||
type: StoryPageType.values.byName(record['type']),
|
'speaker',
|
||||||
campaignIndex: index,
|
'continuation',
|
||||||
speaker: record['speaker'] as String? ?? '',
|
'caption',
|
||||||
illustrationAsset: record['illustrationAsset'] as String?,
|
'illustrationAsset',
|
||||||
continuation:
|
];
|
||||||
record['continuation'] as String? ??
|
Map<String, dynamic> overlay(
|
||||||
switch (record['textSource']) {
|
Map<String, dynamic> base,
|
||||||
'before' => levels[index!].beforeContinuation,
|
Map? translated,
|
||||||
'after' => levels[index!].afterContinuation,
|
List<String> fields,
|
||||||
_ => '',
|
) => {
|
||||||
},
|
...base,
|
||||||
|
for (final field in fields)
|
||||||
|
if (translated?[field] is String) field: translated![field],
|
||||||
|
};
|
||||||
|
final levels = (campaign['levels'] as List).map((record) {
|
||||||
|
final base = Map<String, dynamic>.from(record);
|
||||||
|
base['chapterId'] ??= base['chapter'];
|
||||||
|
return CampaignLevel(
|
||||||
|
overlay(base, translatedLevels[base['id']], levelText),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
final pages = (notebook['pages'] as List).map((record) {
|
||||||
|
final index = record['campaignIndex'] as int?;
|
||||||
|
if (index != null && (index < 0 || index >= levels.length)) {
|
||||||
|
throw FormatException('Unknown puzzle on page ${record['id']}');
|
||||||
|
}
|
||||||
|
final text = switch (record['textSource']) {
|
||||||
|
'before' => levels[index!].before,
|
||||||
|
'after' => levels[index!].after,
|
||||||
|
'recording' =>
|
||||||
|
scripts
|
||||||
|
.where((s) => s['pageId'] == record['id'])
|
||||||
|
.map((s) => (s['baseText'] ?? s['text']) as String)
|
||||||
|
.firstOrNull ??
|
||||||
|
'',
|
||||||
|
_ => record['text'] as String? ?? '',
|
||||||
|
};
|
||||||
|
final base = <String, dynamic>{
|
||||||
|
...record,
|
||||||
|
'text': text,
|
||||||
|
'continuation':
|
||||||
|
record['continuation'] ??
|
||||||
|
switch (record['textSource']) {
|
||||||
|
'before' => levels[index!].beforeContinuation,
|
||||||
|
'after' => levels[index!].afterContinuation,
|
||||||
|
_ => '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
final page = overlay(base, translatedPages[record['id']], pageText);
|
||||||
|
return StoryPage(
|
||||||
|
page['id'],
|
||||||
|
page['title'],
|
||||||
|
page['text'],
|
||||||
|
type: StoryPageType.values.byName(page['type']),
|
||||||
|
campaignIndex: index,
|
||||||
|
speaker: page['speaker'] as String? ?? '',
|
||||||
|
illustrationAsset: page['illustrationAsset'] as String?,
|
||||||
|
continuation: page['continuation'] as String? ?? '',
|
||||||
|
caption: page['caption'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
if (levels.isEmpty ||
|
||||||
|
pages.isEmpty ||
|
||||||
|
levels.any(
|
||||||
|
(l) =>
|
||||||
|
!RegExp(r'^[a-z0-9._-]+$').hasMatch(l.id) ||
|
||||||
|
l.size < 2 ||
|
||||||
|
l.size > 10 ||
|
||||||
|
l.picture.length != l.size * l.size ||
|
||||||
|
l.picture.any((v) => v != 0 && v != 1),
|
||||||
|
) ||
|
||||||
|
levels.map((l) => l.id).toSet().length != levels.length ||
|
||||||
|
pages.map((p) => p.id).toSet().length != pages.length ||
|
||||||
|
pages.any((p) => p.id.isEmpty) ||
|
||||||
|
definition.continueAt != null &&
|
||||||
|
(definition.continueAt! < 0 ||
|
||||||
|
definition.continueAt! >= levels.length) ||
|
||||||
|
pages.any(
|
||||||
|
(p) =>
|
||||||
|
[StoryPageType.puzzle, StoryPageType.memory].contains(p.type) &&
|
||||||
|
p.campaignIndex == null,
|
||||||
|
)) {
|
||||||
|
throw FormatException('Invalid story content: ${definition.id}');
|
||||||
|
}
|
||||||
|
final seenChapters = <String>{};
|
||||||
|
String? lastChapter;
|
||||||
|
for (final level in levels) {
|
||||||
|
if (level.chapterId != lastChapter &&
|
||||||
|
!seenChapters.add(level.chapterId)) {
|
||||||
|
throw FormatException(
|
||||||
|
'Chapter levels must be contiguous: ${level.chapterId}',
|
||||||
);
|
);
|
||||||
}).toList(),
|
}
|
||||||
|
lastChapter = level.chapterId;
|
||||||
|
final puzzle = level.puzzle();
|
||||||
|
if (puzzle.regions.any(
|
||||||
|
(r) =>
|
||||||
|
r.top < 0 ||
|
||||||
|
r.left < 0 ||
|
||||||
|
r.width <= 0 ||
|
||||||
|
r.height <= 0 ||
|
||||||
|
r.top + r.height > puzzle.size ||
|
||||||
|
r.left + r.width > puzzle.size,
|
||||||
|
)) {
|
||||||
|
throw FormatException('Invalid puzzle region: ${level.id}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Never play original-language narration over translated text. A locale
|
||||||
|
// supplies its own manifest, or remains readable without a recording.
|
||||||
|
final trackPath =
|
||||||
|
locale['tracksAsset'] as String? ??
|
||||||
|
(actualLanguage == definition.defaultLanguage
|
||||||
|
? definition.tracksAsset
|
||||||
|
: null);
|
||||||
|
final tracks = trackPath == null
|
||||||
|
? <String, dynamic>{}
|
||||||
|
: Map<String, dynamic>.from((await read(trackPath))['tracks']);
|
||||||
|
return Book(
|
||||||
|
translation['premise'] as String? ?? campaign['premise'],
|
||||||
|
levels,
|
||||||
|
pages,
|
||||||
tracks,
|
tracks,
|
||||||
|
id: definition.id,
|
||||||
|
title: translation['title'] as String? ?? definition.title,
|
||||||
|
description:
|
||||||
|
translation['description'] as String? ?? definition.description,
|
||||||
|
language: actualLanguage,
|
||||||
|
defaultLanguage: definition.defaultLanguage,
|
||||||
|
presentation: definition.presentation,
|
||||||
|
coverAsset: translation['coverAsset'] as String? ?? definition.coverAsset,
|
||||||
|
continueAt: definition.continueAt,
|
||||||
|
initiallyAccessible: definition.initiallyAccessible.clamp(
|
||||||
|
0,
|
||||||
|
levels.length - 1,
|
||||||
|
),
|
||||||
|
fontFamily: locale['fontFamily'] as String?,
|
||||||
|
copy: Map<String, String>.from(translation['copy'] as Map? ?? {}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+94
-29
@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
|
|
||||||
import '../services/progress.dart';
|
import '../services/progress.dart';
|
||||||
import 'book.dart';
|
import 'book.dart';
|
||||||
|
import 'library.dart';
|
||||||
import 'puzzle.dart';
|
import 'puzzle.dart';
|
||||||
|
|
||||||
enum Screen { home, story, contents, briefing, game, reveal }
|
enum Screen { home, story, contents, briefing, game, reveal }
|
||||||
@@ -17,9 +18,52 @@ Puzzle generatePractice(Map<String, Object> args) => Puzzle.generate(
|
|||||||
);
|
);
|
||||||
|
|
||||||
class Game extends ChangeNotifier {
|
class Game extends ChangeNotifier {
|
||||||
Game(this.book, this.progress);
|
Game(this.book, this.store, {this.library});
|
||||||
final Book book;
|
Book book;
|
||||||
final Progress progress;
|
final Progress store;
|
||||||
|
final StoryLibrary? library;
|
||||||
|
Progress get progress => store.forStory(book.id);
|
||||||
|
String get languagePreference => store.text('language', 'system');
|
||||||
|
String get requestedLanguage =>
|
||||||
|
languagePreference == 'system' ? deviceLanguage : languagePreference;
|
||||||
|
String deviceLanguage = 'en';
|
||||||
|
int _bookRequest = 0;
|
||||||
|
|
||||||
|
Future<void> selectStory(String id) async {
|
||||||
|
final catalogue = library;
|
||||||
|
if (catalogue == null) return;
|
||||||
|
final request = ++_bookRequest;
|
||||||
|
final next = await catalogue.open(id, language: requestedLanguage);
|
||||||
|
if (request != _bookRequest) return;
|
||||||
|
_request++;
|
||||||
|
book = next;
|
||||||
|
puzzle = null;
|
||||||
|
key = '';
|
||||||
|
cells = [];
|
||||||
|
_undo.clear();
|
||||||
|
storyIndex = campaignIndex = contentsChapter = 0;
|
||||||
|
busy = false;
|
||||||
|
screen = Screen.home;
|
||||||
|
unawaited(store.set('selected_story', book.id));
|
||||||
|
await restore();
|
||||||
|
if (request == _bookRequest) notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> selectLanguage(String preference) async {
|
||||||
|
final catalogue = library;
|
||||||
|
if (catalogue == null) return;
|
||||||
|
final request = ++_bookRequest;
|
||||||
|
final next = await catalogue.open(
|
||||||
|
book.id,
|
||||||
|
language: preference == 'system' ? deviceLanguage : preference,
|
||||||
|
);
|
||||||
|
if (request != _bookRequest) return;
|
||||||
|
unawaited(store.set('language', preference));
|
||||||
|
// Identity and puzzle data are unchanged: keep the live grid and undo stack.
|
||||||
|
book = next;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Screen screen = Screen.home;
|
Screen screen = Screen.home;
|
||||||
Mode mode = Mode.classic;
|
Mode mode = Mode.classic;
|
||||||
Difficulty get difficulty =>
|
Difficulty get difficulty =>
|
||||||
@@ -37,12 +81,18 @@ class Game extends ChangeNotifier {
|
|||||||
bool get won => progress.flag('done_$key');
|
bool get won => progress.flag('done_$key');
|
||||||
bool get canUndo => _undo.isNotEmpty && !won;
|
bool get canUndo => _undo.isNotEmpty && !won;
|
||||||
int get solved => progress.number('solved');
|
int get solved => progress.number('solved');
|
||||||
int get recoveredCount =>
|
int get recoveredCount => List.generate(
|
||||||
List.generate(12, (i) => recovered(i)).where((v) => v).length;
|
book.levels.length,
|
||||||
int get unlocked => progress.number('campaignUnlocked').clamp(0, 11);
|
(i) => recovered(i),
|
||||||
|
).where((v) => v).length;
|
||||||
|
int get unlocked =>
|
||||||
|
progress.number('campaignUnlocked').clamp(0, book.levels.length - 1);
|
||||||
int get accessible => math.max(
|
int get accessible => math.max(
|
||||||
3,
|
book.initiallyAccessible,
|
||||||
math.max(unlocked, progress.number('story_access_level').clamp(0, 11)),
|
math.max(
|
||||||
|
unlocked,
|
||||||
|
progress.number('story_access_level').clamp(0, book.levels.length - 1),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
int get practiceLevel => progress.number('level_${difficulty.stored}', 1);
|
int get practiceLevel => progress.number('level_${difficulty.stored}', 1);
|
||||||
int get streak => visibleStreak(
|
int get streak => visibleStreak(
|
||||||
@@ -50,10 +100,12 @@ class Game extends ChangeNotifier {
|
|||||||
progress.number('streak'),
|
progress.number('streak'),
|
||||||
epochDay(DateTime.now()),
|
epochDay(DateTime.now()),
|
||||||
);
|
);
|
||||||
bool recovered(int i) => progress.flag('done_story_v1_$i');
|
bool recovered(int i) => progress.flag('done_${book.puzzleKey(i)}');
|
||||||
Future<void> restore() async {
|
Future<void> restore() async {
|
||||||
final saved = progress.text('flutter_screen', 'home');
|
final saved = progress.text('flutter_screen', 'home');
|
||||||
campaignIndex = progress.number('flutter_campaign').clamp(0, 11);
|
campaignIndex = progress
|
||||||
|
.number('flutter_campaign')
|
||||||
|
.clamp(0, book.levels.length - 1);
|
||||||
if (saved == 'story') {
|
if (saved == 'story') {
|
||||||
showStory(
|
showStory(
|
||||||
book.pages
|
book.pages
|
||||||
@@ -116,9 +168,12 @@ class Game extends ChangeNotifier {
|
|||||||
storyIndex = i.clamp(0, book.pages.length - 1);
|
storyIndex = i.clamp(0, book.pages.length - 1);
|
||||||
mode = Mode.campaign;
|
mode = Mode.campaign;
|
||||||
campaignIndex = storyPage.campaignIndex ?? 0;
|
campaignIndex = storyPage.campaignIndex ?? 0;
|
||||||
|
if (campaignIndex > accessible) {
|
||||||
|
unawaited(progress.set('story_access_level', campaignIndex));
|
||||||
|
}
|
||||||
if (storyPage.type == StoryPageType.puzzle &&
|
if (storyPage.type == StoryPageType.puzzle &&
|
||||||
key != 'story_v1_$campaignIndex') {
|
key != book.puzzleKey(campaignIndex)) {
|
||||||
_read(book.levels[campaignIndex].puzzle(), 'story_v1_$campaignIndex');
|
_read(book.levels[campaignIndex].puzzle(), book.puzzleKey(campaignIndex));
|
||||||
}
|
}
|
||||||
unawaited(progress.set('notebook_last_page', book.pages[storyIndex].id));
|
unawaited(progress.set('notebook_last_page', book.pages[storyIndex].id));
|
||||||
unawaited(progress.set('viewed_${book.pages[storyIndex].id}', true));
|
unawaited(progress.set('viewed_${book.pages[storyIndex].id}', true));
|
||||||
@@ -128,20 +183,29 @@ class Game extends ChangeNotifier {
|
|||||||
void contents([int? chapter]) {
|
void contents([int? chapter]) {
|
||||||
_request++;
|
_request++;
|
||||||
busy = false;
|
busy = false;
|
||||||
contentsChapter = (chapter ?? campaignIndex ~/ 4).clamp(0, accessible ~/ 4);
|
contentsChapter = (chapter ?? book.chapterFor(campaignIndex)).clamp(
|
||||||
|
0,
|
||||||
|
book.chapterFor(accessible),
|
||||||
|
);
|
||||||
unawaited(progress.set('notebook_contents_chapter', contentsChapter));
|
unawaited(progress.set('notebook_contents_chapter', contentsChapter));
|
||||||
_route(Screen.contents);
|
_route(Screen.contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void leaveCottage() {
|
void leaveCottage() {
|
||||||
unawaited(progress.set('story_access_level', math.max(accessible, 4)));
|
final next = book.continueAt;
|
||||||
briefing(4);
|
if (next == null) {
|
||||||
|
contents();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unawaited(progress.set('story_access_level', math.max(accessible, next)));
|
||||||
|
briefing(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void briefing(int i) {
|
void briefing(int i) {
|
||||||
campaignIndex = i.clamp(0, accessible);
|
campaignIndex = i.clamp(0, accessible);
|
||||||
if (campaignIndex < 4) {
|
final page = book.pageFor(campaignIndex, StoryPageType.entry);
|
||||||
showStory(book.pageFor(campaignIndex, StoryPageType.entry));
|
if (page >= 0) {
|
||||||
|
showStory(page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mode = Mode.campaign;
|
mode = Mode.campaign;
|
||||||
@@ -154,8 +218,9 @@ class Game extends ChangeNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
campaignIndex = i;
|
campaignIndex = i;
|
||||||
if (i < 4) {
|
final page = book.pageFor(i, StoryPageType.memory);
|
||||||
showStory(book.pageFor(i, StoryPageType.memory));
|
if (page >= 0) {
|
||||||
|
showStory(page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mode = Mode.campaign;
|
mode = Mode.campaign;
|
||||||
@@ -200,14 +265,15 @@ class Game extends ChangeNotifier {
|
|||||||
void startCampaign(int i) {
|
void startCampaign(int i) {
|
||||||
_request++;
|
_request++;
|
||||||
busy = false;
|
busy = false;
|
||||||
if (i > accessible) return;
|
if (i < 0 || i >= book.levels.length || i > accessible) return;
|
||||||
campaignIndex = i;
|
campaignIndex = i;
|
||||||
mode = Mode.campaign;
|
mode = Mode.campaign;
|
||||||
if (i < 4) {
|
final page = book.pageFor(i, StoryPageType.puzzle);
|
||||||
showStory(book.pageFor(i, StoryPageType.puzzle));
|
if (page >= 0) {
|
||||||
|
showStory(page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_read(book.levels[i].puzzle(), 'story_v1_$i');
|
_read(book.levels[i].puzzle(), book.puzzleKey(i));
|
||||||
_route(Screen.game);
|
_route(Screen.game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,14 +370,13 @@ class Game extends ChangeNotifier {
|
|||||||
unawaited(
|
unawaited(
|
||||||
progress.set(
|
progress.set(
|
||||||
'campaignUnlocked',
|
'campaignUnlocked',
|
||||||
math.max(unlocked, math.min(11, campaignIndex + 1)),
|
math.max(
|
||||||
|
unlocked,
|
||||||
|
math.min(book.levels.length - 1, campaignIndex + 1),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (screen == Screen.story) {
|
reveal(campaignIndex);
|
||||||
showStory(book.pageFor(campaignIndex, StoryPageType.memory));
|
|
||||||
} else {
|
|
||||||
reveal(campaignIndex);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
unawaited(progress.set('level_${difficulty.stored}', playingLevel + 1));
|
unawaited(progress.set('level_${difficulty.stored}', playingLevel + 1));
|
||||||
unawaited(
|
unawaited(
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'book.dart';
|
||||||
|
import '../services/translation.dart';
|
||||||
|
|
||||||
|
/// A catalogue entry identifies a story independently of its translations.
|
||||||
|
class StoryDefinition {
|
||||||
|
StoryDefinition(Map<String, dynamic> data)
|
||||||
|
: id = data['id'],
|
||||||
|
title = data['title'],
|
||||||
|
description = data['description'] ?? '',
|
||||||
|
coverAsset = data['coverAsset'],
|
||||||
|
defaultLanguage = (data['defaultLanguage'] as String? ?? 'en')
|
||||||
|
.replaceAll('_', '-')
|
||||||
|
.toLowerCase(),
|
||||||
|
campaignAsset = data['campaignAsset'],
|
||||||
|
notebookAsset = data['notebookAsset'],
|
||||||
|
scriptsAsset = data['scriptsAsset'],
|
||||||
|
tracksAsset = data['tracksAsset'],
|
||||||
|
presentation = data['presentation'] ?? 'standard',
|
||||||
|
continueAt = data['continueAt'],
|
||||||
|
initiallyAccessible = data['initiallyAccessible'] ?? 0,
|
||||||
|
languages = {
|
||||||
|
for (final entry in (data['languages'] as Map).entries)
|
||||||
|
(entry.key as String).replaceAll('_', '-').toLowerCase(): entry.value,
|
||||||
|
};
|
||||||
|
|
||||||
|
final String id, title, description, defaultLanguage, presentation;
|
||||||
|
final String campaignAsset, notebookAsset;
|
||||||
|
final String? coverAsset, scriptsAsset, tracksAsset;
|
||||||
|
final int? continueAt;
|
||||||
|
final int initiallyAccessible;
|
||||||
|
final Map<String, dynamic> languages;
|
||||||
|
|
||||||
|
String languageFor(String requested) {
|
||||||
|
final tag = requested.replaceAll('_', '-').toLowerCase();
|
||||||
|
if (languages.containsKey(tag)) return tag;
|
||||||
|
final base = tag.split('-').first;
|
||||||
|
return languages.containsKey(base) ? base : defaultLanguage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class StoryLibrary {
|
||||||
|
StoryLibrary(
|
||||||
|
this.stories, {
|
||||||
|
AssetBundle? bundle,
|
||||||
|
this.copy = TranslationCatalog.english,
|
||||||
|
}) : bundle = bundle ?? rootBundle {
|
||||||
|
if (stories.isEmpty ||
|
||||||
|
stories.map((s) => s.id).toSet().length != stories.length) {
|
||||||
|
throw const FormatException('The library needs unique story IDs.');
|
||||||
|
}
|
||||||
|
for (final story in stories) {
|
||||||
|
if (!RegExp(r'^[a-z0-9-]+$').hasMatch(story.id) ||
|
||||||
|
!story.languages.containsKey(story.defaultLanguage)) {
|
||||||
|
throw FormatException('Invalid story definition: ${story.id}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final List<StoryDefinition> stories;
|
||||||
|
final AssetBundle bundle;
|
||||||
|
final TranslationCatalog copy;
|
||||||
|
|
||||||
|
static Future<StoryLibrary> load({AssetBundle? bundle}) async {
|
||||||
|
final assets = bundle ?? rootBundle;
|
||||||
|
final data = jsonDecode(await assets.loadString('assets/library.json'));
|
||||||
|
return StoryLibrary(
|
||||||
|
(data['stories'] as List).map((s) => StoryDefinition(s)).toList(),
|
||||||
|
bundle: assets,
|
||||||
|
copy: await TranslationCatalog.load(assets),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
StoryDefinition definition(String id) =>
|
||||||
|
stories.where((s) => s.id == id).firstOrNull ?? stories.first;
|
||||||
|
|
||||||
|
final Map<String, Future<Book>> _books = {};
|
||||||
|
Future<Book> open(String id, {String language = 'en'}) {
|
||||||
|
final story = definition(id);
|
||||||
|
final key = '${story.id}:${story.languageFor(language)}';
|
||||||
|
return _books.putIfAbsent(
|
||||||
|
key,
|
||||||
|
() => Book.loadDefinition(story, language: language, bundle: bundle)
|
||||||
|
.catchError((Object error, StackTrace stack) {
|
||||||
|
_books.remove(key);
|
||||||
|
Error.throwWithStackTrace(error, stack);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+366
-237
@@ -2,9 +2,17 @@ import 'dart:async';
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'ui/translation.dart';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:intl/date_symbol_data_local.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
|
||||||
|
import 'domain/library.dart';
|
||||||
|
import 'services/translation.dart';
|
||||||
|
|
||||||
import 'domain/book.dart';
|
import 'domain/book.dart';
|
||||||
import 'domain/game.dart';
|
import 'domain/game.dart';
|
||||||
@@ -17,6 +25,8 @@ import 'ui/board.dart';
|
|||||||
import 'ui/discovery.dart';
|
import 'ui/discovery.dart';
|
||||||
import 'ui/paper.dart';
|
import 'ui/paper.dart';
|
||||||
|
|
||||||
|
part 'ui/mara_story.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
LicenseRegistry.addLicense(() async* {
|
LicenseRegistry.addLicense(() async* {
|
||||||
@@ -31,8 +41,17 @@ Future<void> main() async {
|
|||||||
systemNavigationBarColor: Color(0xff314345),
|
systemNavigationBarColor: Color(0xff314345),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final book = await Book.load(), progress = await Progress.load();
|
await initializeDateFormatting();
|
||||||
final game = Game(book, progress);
|
final library = await StoryLibrary.load(), progress = await Progress.load();
|
||||||
|
final deviceLanguage = WidgetsBinding.instance.platformDispatcher.locale
|
||||||
|
.toLanguageTag();
|
||||||
|
final preference = progress.text('language', 'system');
|
||||||
|
final book = await library.open(
|
||||||
|
progress.text('selected_story', 'mara-island'),
|
||||||
|
language: preference == 'system' ? deviceLanguage : preference,
|
||||||
|
);
|
||||||
|
final game = Game(book, progress, library: library)
|
||||||
|
..deviceLanguage = deviceLanguage;
|
||||||
await game.restore();
|
await game.restore();
|
||||||
runApp(LumenApp(game: game));
|
runApp(LumenApp(game: game));
|
||||||
}
|
}
|
||||||
@@ -42,24 +61,62 @@ class LumenApp extends StatelessWidget {
|
|||||||
final Game game;
|
final Game game;
|
||||||
final bool adsEnabled;
|
final bool adsEnabled;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => MaterialApp(
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
title: 'Lumen',
|
listenable: game,
|
||||||
debugShowCheckedModeBanner: false,
|
builder: (context, _) {
|
||||||
theme: ThemeData(
|
final catalog = game.library?.copy ?? TranslationCatalog.english;
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: blue, surface: cream),
|
final language = game.requestedLanguage.replaceAll('_', '-');
|
||||||
scaffoldBackgroundColor: cream,
|
final locale = localeFromTag(language);
|
||||||
fontFamily: 'MaraHand',
|
final parts = language.split('-');
|
||||||
textTheme: ThemeData.light().textTheme.apply(
|
final languages = <String>{
|
||||||
fontFamily: 'MaraHand',
|
...catalog.languages.keys,
|
||||||
bodyColor: ink,
|
...?game.library?.stories.expand((s) => s.languages.keys),
|
||||||
displayColor: ink,
|
};
|
||||||
),
|
final latin = const [
|
||||||
dialogTheme: const DialogThemeData(backgroundColor: cream),
|
'en',
|
||||||
textButtonTheme: TextButtonThemeData(
|
'de',
|
||||||
style: TextButton.styleFrom(textStyle: hand(22), foregroundColor: blue),
|
'fr',
|
||||||
),
|
'es',
|
||||||
),
|
'it',
|
||||||
home: Notebook(game: game, adsEnabled: adsEnabled),
|
'pt',
|
||||||
|
'nl',
|
||||||
|
'da',
|
||||||
|
'sv',
|
||||||
|
'no',
|
||||||
|
'fi',
|
||||||
|
].contains(parts.first);
|
||||||
|
return MaterialApp(
|
||||||
|
title: 'Lumen',
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
locale: locale,
|
||||||
|
supportedLocales: languages.map(localeFromTag).toList(),
|
||||||
|
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||||
|
builder: (context, child) => CopyScope(
|
||||||
|
catalog: catalog,
|
||||||
|
language: language,
|
||||||
|
overrides: game.book.copy,
|
||||||
|
child: child!,
|
||||||
|
),
|
||||||
|
theme: ThemeData(
|
||||||
|
colorScheme: ColorScheme.fromSeed(seedColor: blue, surface: cream),
|
||||||
|
scaffoldBackgroundColor: cream,
|
||||||
|
fontFamily: latin ? 'MaraHand' : null,
|
||||||
|
textTheme: ThemeData.light().textTheme.apply(
|
||||||
|
fontFamily: latin ? 'MaraHand' : null,
|
||||||
|
bodyColor: ink,
|
||||||
|
displayColor: ink,
|
||||||
|
),
|
||||||
|
dialogTheme: const DialogThemeData(backgroundColor: cream),
|
||||||
|
textButtonTheme: TextButtonThemeData(
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
textStyle: hand(22),
|
||||||
|
foregroundColor: blue,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
home: Notebook(game: game, adsEnabled: adsEnabled),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +145,11 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
bool _foreground = true;
|
bool _foreground = true;
|
||||||
String _route = '';
|
String _route = '';
|
||||||
String get route =>
|
String get route =>
|
||||||
'${g.screen.name}:${g.screen == Screen.story ? g.storyIndex : g.campaignIndex}';
|
'${g.book.id}:${g.book.language}:${g.screen.name}:${g.screen == Screen.story ? g.storyIndex : g.campaignIndex}';
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
unawaited(initializeDateFormatting());
|
||||||
narrator = widget.narrator ?? Narrator(g.book.tracks);
|
narrator = widget.narrator ?? Narrator(g.book.tracks);
|
||||||
ambience = Ambience();
|
ambience = Ambience();
|
||||||
narrator.addListener(_syncAtmosphere);
|
narrator.addListener(_syncAtmosphere);
|
||||||
@@ -107,6 +165,9 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _changed() {
|
void _changed() {
|
||||||
|
if (!identical(narrator.tracks, g.book.tracks)) {
|
||||||
|
narrator.replaceTracks(g.book.tracks);
|
||||||
|
}
|
||||||
if (_route != route) {
|
if (_route != route) {
|
||||||
_route = route;
|
_route = route;
|
||||||
unawaited(narrator.stop());
|
unawaited(narrator.stop());
|
||||||
@@ -124,6 +185,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
_foreground &&
|
_foreground &&
|
||||||
[Screen.story, Screen.briefing, Screen.reveal].contains(g.screen) &&
|
[Screen.story, Screen.briefing, Screen.reveal].contains(g.screen) &&
|
||||||
!(g.screen == Screen.story &&
|
!(g.screen == Screen.story &&
|
||||||
|
g.book.isMara &&
|
||||||
g.storyPage.type == StoryPageType.note &&
|
g.storyPage.type == StoryPageType.note &&
|
||||||
!prefs.flag('notebook_note_open'));
|
!prefs.flag('notebook_note_open'));
|
||||||
narrator.scheduleAutoplay(
|
narrator.scheduleAutoplay(
|
||||||
@@ -142,7 +204,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
Screen.reveal,
|
Screen.reveal,
|
||||||
].contains(g.screen);
|
].contains(g.screen);
|
||||||
ambience.update(
|
ambience.update(
|
||||||
scene: inStory ? soundscapeFor(g.campaignIndex) : null,
|
scene: inStory && g.book.isMara ? soundscapeFor(g.campaignIndex) : null,
|
||||||
enabled: atmosphereEnabled,
|
enabled: atmosphereEnabled,
|
||||||
foreground: _foreground,
|
foreground: _foreground,
|
||||||
narrating: narrator.playing || narrator.loading,
|
narrating: narrator.playing || narrator.loading,
|
||||||
@@ -150,6 +212,20 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeLocales(List<Locale>? locales) {
|
||||||
|
g.deviceLanguage = locales?.firstOrNull?.toLanguageTag() ?? 'en';
|
||||||
|
if (g.languagePreference == 'system') {
|
||||||
|
unawaited(
|
||||||
|
g.selectLanguage('system').catchError((Object _) {
|
||||||
|
if (mounted) {
|
||||||
|
toast('This language could not be opened. Please try again.');
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
_foreground = state == AppLifecycleState.resumed;
|
_foreground = state == AppLifecycleState.resumed;
|
||||||
@@ -175,7 +251,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(text, style: hand(20, color: cream)),
|
content: CopyText(text, style: hand(20, color: cream)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -190,16 +266,16 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
await showDialog<bool>(
|
await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (c) => AlertDialog(
|
builder: (c) => AlertDialog(
|
||||||
title: Text(title, style: hand(29)),
|
title: CopyText(title, style: hand(29)),
|
||||||
content: Text(text, style: hand(23)),
|
content: CopyText(text, style: hand(23)),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(c, false),
|
onPressed: () => Navigator.pop(c, false),
|
||||||
child: Text(no),
|
child: CopyText(no),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(c, true),
|
onPressed: () => Navigator.pop(c, true),
|
||||||
child: Text(yes),
|
child: CopyText(yes),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -213,10 +289,10 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
await showDialog<void>(
|
await showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (c) => AlertDialog(
|
builder: (c) => AlertDialog(
|
||||||
title: Text(title, style: hand(29)),
|
title: CopyText(title, style: hand(29)),
|
||||||
content: SingleChildScrollView(child: Text(text, style: hand(23))),
|
content: SingleChildScrollView(child: CopyText(text, style: hand(23))),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(onPressed: () => Navigator.pop(c), child: Text(close)),
|
TextButton(onPressed: () => Navigator.pop(c), child: CopyText(close)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -256,7 +332,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
if (direction > 0) {
|
if (direction > 0) {
|
||||||
g.startCampaign(index);
|
g.startCampaign(index);
|
||||||
} else if (index > 0) {
|
} else if (index > 0) {
|
||||||
if (index == 4) {
|
if (index == g.book.continueAt) {
|
||||||
g.showStory(g.book.pages.length - 1);
|
g.showStory(g.book.pages.length - 1);
|
||||||
} else {
|
} else {
|
||||||
g.reveal(index - 1, readAhead: true);
|
g.reveal(index - 1, readAhead: true);
|
||||||
@@ -292,7 +368,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
void nextCampaign() {
|
void nextCampaign() {
|
||||||
final index = g.campaignIndex;
|
final index = g.campaignIndex;
|
||||||
if (index == 11) {
|
if (index == g.book.levels.length - 1) {
|
||||||
g.contents();
|
g.contents();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -305,7 +381,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g.recovered(index) &&
|
if (g.recovered(index) &&
|
||||||
(index + 1) % 4 == 0 &&
|
g.book.chapterLevels(g.book.chapterFor(index)).last == index &&
|
||||||
!prefs.flag('storyAd_$index')) {
|
!prefs.flag('storyAd_$index')) {
|
||||||
unawaited(prefs.set('storyAd_$index', true));
|
unawaited(prefs.set('storyAd_$index', true));
|
||||||
ads.between(next);
|
ads.between(next);
|
||||||
@@ -397,7 +473,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
Expanded(child: Divider(color: muted.withValues(alpha: .3))),
|
Expanded(child: Divider(color: muted.withValues(alpha: .3))),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: Text('❦', style: hand(27, color: muted)),
|
child: CopyText('❦', style: hand(27, color: muted)),
|
||||||
),
|
),
|
||||||
Expanded(child: Divider(color: muted.withValues(alpha: .3))),
|
Expanded(child: Divider(color: muted.withValues(alpha: .3))),
|
||||||
],
|
],
|
||||||
@@ -416,7 +492,11 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
constraints: const BoxConstraints(maxWidth: 650),
|
constraints: const BoxConstraints(maxWidth: 650),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: folio('L U M E N / AN ISLAND STORY'),
|
child: folio(
|
||||||
|
g.book.isMara
|
||||||
|
? 'L U M E N / AN ISLAND STORY'
|
||||||
|
: 'L U M E N / STORY LIBRARY',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -429,44 +509,81 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: 650),
|
constraints: const BoxConstraints(maxWidth: 650),
|
||||||
child: column([
|
child: column([
|
||||||
writing('A light to come\nhome to.', size: 40),
|
|
||||||
Image.asset(
|
|
||||||
'assets/artwork/home-harbour-v2.png',
|
|
||||||
height: 220,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
semanticLabel: 'Watercolour of the island at dusk, with the lighthouse and Gran’s cottage.',
|
|
||||||
),
|
|
||||||
writing(
|
writing(
|
||||||
'Some things are worth keeping. — Gran',
|
g.book.isMara
|
||||||
|
? 'A light to come\nhome to.'
|
||||||
|
: g.book.title,
|
||||||
|
size: 40,
|
||||||
|
),
|
||||||
|
if (g.book.isMara)
|
||||||
|
Image.asset(
|
||||||
|
'assets/artwork/home-harbour-v2.png',
|
||||||
|
height: 220,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
semanticLabel: 'Watercolour of the island at dusk, with the lighthouse and Gran’s cottage.',
|
||||||
|
),
|
||||||
|
writing(
|
||||||
|
g.book.isMara
|
||||||
|
? 'Some things are worth keeping. — Gran'
|
||||||
|
: g.book.description,
|
||||||
size: 25,
|
size: 25,
|
||||||
color: const Color(0xff70503b),
|
color: const Color(0xff70503b),
|
||||||
),
|
),
|
||||||
Cover(onTap: g.openNotebook),
|
if (g.book.isMara)
|
||||||
|
Cover(onTap: g.openNotebook)
|
||||||
|
else if (g.book.coverAsset case final asset?)
|
||||||
|
InkWell(
|
||||||
|
onTap: g.openNotebook,
|
||||||
|
child: Image.asset(
|
||||||
|
asset,
|
||||||
|
height: 220,
|
||||||
|
semanticLabel: g.book.title,
|
||||||
|
),
|
||||||
|
),
|
||||||
action(
|
action(
|
||||||
'Open Mara’s notebook · ${g.recoveredCount} / 12',
|
'Open ${g.book.title} · ${g.recoveredCount} / ${g.book.levels.length}',
|
||||||
g.openNotebook,
|
g.openNotebook,
|
||||||
primary: true,
|
primary: true,
|
||||||
),
|
),
|
||||||
|
action('Story library', storyLibrary),
|
||||||
|
action('Language', chooseLanguage),
|
||||||
|
if (g.requestedLanguage
|
||||||
|
.replaceAll('_', '-')
|
||||||
|
.split('-')
|
||||||
|
.first !=
|
||||||
|
g.book.language.split('-').first)
|
||||||
|
writing(
|
||||||
|
'This story is shown in its original language.',
|
||||||
|
size: 18,
|
||||||
|
color: muted,
|
||||||
|
),
|
||||||
gap(),
|
gap(),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Expanded(
|
||||||
'${g.streak}\nDAY STREAK',
|
child: CopyText(
|
||||||
textAlign: TextAlign.center,
|
'${g.streak}\nDAY STREAK',
|
||||||
style: hand(18, color: blue),
|
textAlign: TextAlign.center,
|
||||||
|
style: hand(18, color: blue),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Expanded(
|
||||||
'${g.solved}\nPATTERNS FOUND',
|
child: CopyText(
|
||||||
textAlign: TextAlign.center,
|
'${g.solved}\nPATTERNS FOUND',
|
||||||
style: hand(18, color: blue),
|
textAlign: TextAlign.center,
|
||||||
|
style: hand(18, color: blue),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
divider(),
|
divider(),
|
||||||
folio('A SMALL DAILY RITUAL'),
|
folio('A SMALL DAILY RITUAL'),
|
||||||
writing(
|
writing(
|
||||||
DateFormat('EEEE, d MMMM').format(DateTime.now()),
|
DateFormat(
|
||||||
|
'EEEE, d MMMM',
|
||||||
|
Localizations.localeOf(context).languageCode,
|
||||||
|
).format(DateTime.now()),
|
||||||
size: 27,
|
size: 27,
|
||||||
),
|
),
|
||||||
action(
|
action(
|
||||||
@@ -513,6 +630,153 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Future<void> storyLibrary() async {
|
||||||
|
narrator.cancelAutoplay();
|
||||||
|
final catalogue = g.library;
|
||||||
|
if (catalogue == null) return;
|
||||||
|
List<Book> books;
|
||||||
|
try {
|
||||||
|
books = await Future.wait(
|
||||||
|
catalogue.stories.map(
|
||||||
|
(story) => catalogue.open(story.id, language: g.requestedLanguage),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
if (mounted) toast('This story could not be opened. Please try again.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!mounted) return;
|
||||||
|
final selected = await showDialog<String>(
|
||||||
|
context: context,
|
||||||
|
builder: (c) => AlertDialog(
|
||||||
|
title: const CopyText('Story library'),
|
||||||
|
content: SizedBox(
|
||||||
|
width: 520,
|
||||||
|
child: ListView(
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: [
|
||||||
|
for (final story in books)
|
||||||
|
ListTile(
|
||||||
|
leading: story.coverAsset == null
|
||||||
|
? null
|
||||||
|
: Image.asset(story.coverAsset!, width: 56),
|
||||||
|
title: Text(story.title),
|
||||||
|
subtitle: Text(
|
||||||
|
'${story.description}\n${catalogue.definition(story.id).languages.values.map((v) => v['label']).join(' · ')}',
|
||||||
|
),
|
||||||
|
isThreeLine: true,
|
||||||
|
selected: story.id == g.book.id,
|
||||||
|
onTap: () => Navigator.pop(c, story.id),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(c),
|
||||||
|
child: const CopyText('Close'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (selected == null || !mounted) return;
|
||||||
|
try {
|
||||||
|
await g.selectStory(selected);
|
||||||
|
} catch (_) {
|
||||||
|
if (mounted) toast('This story could not be opened. Please try again.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> chooseLanguage() async {
|
||||||
|
narrator.cancelAutoplay();
|
||||||
|
final catalogue = g.library;
|
||||||
|
if (catalogue == null) return;
|
||||||
|
final languages = <String, String>{...catalogue.copy.languages};
|
||||||
|
for (final story in catalogue.stories) {
|
||||||
|
for (final entry in story.languages.entries) {
|
||||||
|
languages[entry.key] = entry.value['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final selected = await showDialog<String>(
|
||||||
|
context: context,
|
||||||
|
builder: (c) => SimpleDialog(
|
||||||
|
title: const CopyText('Language'),
|
||||||
|
children: [
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () => Navigator.pop(c, 'system'),
|
||||||
|
child: CopyText(
|
||||||
|
'${g.languagePreference == 'system' ? '✓ ' : ''}Follow device language',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
for (final entry in languages.entries)
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () => Navigator.pop(c, entry.key),
|
||||||
|
child: Text(
|
||||||
|
'${g.languagePreference == entry.key ? '✓ ' : ''}${entry.value}',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: CopyText(
|
||||||
|
'Missing translations use the story’s original language. Your reading position and puzzle marks are shared across languages.',
|
||||||
|
style: hand(18),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (selected == null || !mounted) return;
|
||||||
|
try {
|
||||||
|
await g.selectLanguage(selected);
|
||||||
|
} catch (_) {
|
||||||
|
if (mounted) {
|
||||||
|
toast('This language could not be opened. Please try again.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget standardStory() {
|
||||||
|
final p = g.storyPage;
|
||||||
|
final heading = <Widget>[
|
||||||
|
folio('${g.book.title} / ${g.storyIndex + 1} OF ${g.book.pages.length}'),
|
||||||
|
writing(p.title, size: 31),
|
||||||
|
];
|
||||||
|
final body = <Widget>[
|
||||||
|
...heading,
|
||||||
|
if (p.speaker.isNotEmpty) writing(p.speaker, size: 17, color: muted),
|
||||||
|
if (p.illustrationAsset case final asset?)
|
||||||
|
Image.asset(
|
||||||
|
asset,
|
||||||
|
height: 155,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
semanticLabel: p.caption.isEmpty ? p.title : p.caption,
|
||||||
|
),
|
||||||
|
if (p.caption.isNotEmpty) reading(p.caption, size: 18),
|
||||||
|
if (p.type == StoryPageType.memory)
|
||||||
|
discoveryArt(g.book.levels[p.campaignIndex!], height: 155),
|
||||||
|
if (p.text.isNotEmpty) reading(p.text),
|
||||||
|
if (p.continuation.isNotEmpty) reading(p.continuation),
|
||||||
|
if (g.book.tracks.containsKey(p.id)) audio(),
|
||||||
|
if (p.type == StoryPageType.puzzle) puzzleBody(),
|
||||||
|
if (p.type == StoryPageType.memory)
|
||||||
|
action(
|
||||||
|
g.recovered(p.campaignIndex!)
|
||||||
|
? 'View the solved pattern'
|
||||||
|
: 'Return to this pattern',
|
||||||
|
() => g.startCampaign(p.campaignIndex!),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
return Leaf(
|
||||||
|
key: ValueKey('${g.book.id}-story-${p.id}'),
|
||||||
|
onTurn: (d) => turn(d),
|
||||||
|
body: column(body),
|
||||||
|
wideBody: p.type == StoryPageType.puzzle
|
||||||
|
? splitPuzzle(side: [...heading, areaPicker(), ...puzzleNotes()])
|
||||||
|
: null,
|
||||||
|
footer: navigation(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void bookmark() {
|
void bookmark() {
|
||||||
unawaited(
|
unawaited(
|
||||||
prefs.set('notebook_manual_bookmark', g.book.pages[g.storyIndex].id),
|
prefs.set('notebook_manual_bookmark', g.book.pages[g.storyIndex].id),
|
||||||
@@ -529,7 +793,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
);
|
);
|
||||||
final next = InkButton(
|
final next = InkButton(
|
||||||
g.storyIndex == g.book.pages.length - 1
|
g.storyIndex == g.book.pages.length - 1
|
||||||
? 'Across the tide →'
|
? (g.book.isMara ? 'Across the tide →' : 'Back to contents')
|
||||||
: 'Next leaf →',
|
: 'Next leaf →',
|
||||||
() => turn(1),
|
() => turn(1),
|
||||||
size: wide ? 19 : 21,
|
size: wide ? 19 : 21,
|
||||||
@@ -542,6 +806,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
Expanded(child: InkButton('Contents', g.contents, size: 19)),
|
Expanded(child: InkButton('Contents', g.contents, size: 19)),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Expanded(child: InkButton('Bookmark', bookmark, size: 19)),
|
Expanded(child: InkButton('Bookmark', bookmark, size: 19)),
|
||||||
|
Expanded(child: InkButton('Language', chooseLanguage, size: 19)),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Expanded(child: InkButton('Close book', g.home, size: 19)),
|
Expanded(child: InkButton('Close book', g.home, size: 19)),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
@@ -557,6 +822,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
Expanded(child: InkButton('Contents', g.contents, size: 20)),
|
Expanded(child: InkButton('Contents', g.contents, size: 20)),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Expanded(child: InkButton('Bookmark', bookmark, size: 20)),
|
Expanded(child: InkButton('Bookmark', bookmark, size: 20)),
|
||||||
|
Expanded(child: InkButton('Language', chooseLanguage, size: 20)),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Expanded(child: InkButton('Close book', g.home, size: 20)),
|
Expanded(child: InkButton('Close book', g.home, size: 20)),
|
||||||
],
|
],
|
||||||
@@ -584,7 +850,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
child: Text.rich(
|
child: Text.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
style: hand(size ?? (g.storyIndex == 0 ? 22 : 21)),
|
style: hand(size ?? (g.storyIndex == 0 ? 22 : 21))
|
||||||
|
.copyWith(fontFamily: g.book.fontFamily ?? 'sans-serif'),
|
||||||
children: index < 0
|
children: index < 0
|
||||||
? [TextSpan(text: text)]
|
? [TextSpan(text: text)]
|
||||||
: [
|
: [
|
||||||
@@ -611,7 +878,9 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
: g.book.tracks[recordingId]?['speaker']) ==
|
: g.book.tracks[recordingId]?['speaker']) ==
|
||||||
'Narrator'
|
'Narrator'
|
||||||
? 'Narrator · recorded story'
|
? 'Narrator · recorded story'
|
||||||
: 'Mara · diary reading',
|
: g.book.isMara
|
||||||
|
? 'Mara · diary reading'
|
||||||
|
: '${g.book.tracks[recordingId]?['speaker'] ?? g.storyPage.speaker} · recorded story',
|
||||||
size: 17,
|
size: 17,
|
||||||
color: muted,
|
color: muted,
|
||||||
),
|
),
|
||||||
@@ -640,162 +909,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
InkButton('Sound & atmosphere', soundSettings, size: 18),
|
InkButton('Sound & atmosphere', soundSettings, size: 18),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
Widget story() {
|
void refreshNotebook() => setState(() {});
|
||||||
final p = g.book.pages[g.storyIndex];
|
Widget story() => g.book.isMara ? maraStory() : standardStory();
|
||||||
final heading = <Widget>[
|
|
||||||
folio('THE COTTAGE / ${g.storyIndex + 1} OF ${g.book.pages.length}'),
|
|
||||||
writing(p.title, size: 31),
|
|
||||||
];
|
|
||||||
final body = <Widget>[...heading];
|
|
||||||
Widget? wideBody;
|
|
||||||
switch (p.type) {
|
|
||||||
case StoryPageType.dedication:
|
|
||||||
body.addAll([
|
|
||||||
writing('A few things worth keeping', size: 20, color: muted),
|
|
||||||
divider(),
|
|
||||||
reading(p.text),
|
|
||||||
audio(),
|
|
||||||
]);
|
|
||||||
case StoryPageType.entry:
|
|
||||||
body.addAll([
|
|
||||||
if (p.illustrationAsset case final asset?)
|
|
||||||
Image.asset(
|
|
||||||
asset,
|
|
||||||
height: 155,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
semanticLabel: 'Watercolour of Gran’s stone cottage, blue door and warm window.',
|
|
||||||
),
|
|
||||||
writing(p.speaker, size: 17, color: muted),
|
|
||||||
reading(p.text),
|
|
||||||
if (p.continuation.isNotEmpty) reading(p.continuation),
|
|
||||||
if (g.book.tracks.containsKey(p.id)) audio(),
|
|
||||||
if (p.campaignIndex != 0)
|
|
||||||
action('Turn to the pattern →', () => turn(1)),
|
|
||||||
]);
|
|
||||||
case StoryPageType.puzzle:
|
|
||||||
final intro = writing(
|
|
||||||
g.campaignIndex < 2
|
|
||||||
? 'Restore a small light, or leave a bookmark and read on.'
|
|
||||||
: 'Compare the shared areas. Each cell counts in every area it belongs to.',
|
|
||||||
size: 21,
|
|
||||||
color: muted,
|
|
||||||
);
|
|
||||||
body.addAll([intro, puzzleBody()]);
|
|
||||||
wideBody = splitPuzzle(
|
|
||||||
side: [...heading, intro, areaPicker(), ...puzzleNotes()],
|
|
||||||
);
|
|
||||||
case StoryPageType.memory:
|
|
||||||
body.addAll([
|
|
||||||
discoveryArt(g.book.levels[p.campaignIndex!], height: 155),
|
|
||||||
writing(
|
|
||||||
g.recovered(p.campaignIndex!)
|
|
||||||
? 'A pattern restored · a memory kept'
|
|
||||||
: 'A memory to read · your puzzle can wait',
|
|
||||||
size: 17,
|
|
||||||
color: muted,
|
|
||||||
),
|
|
||||||
reading(p.text),
|
|
||||||
if (p.continuation.isNotEmpty) reading(p.continuation),
|
|
||||||
if (g.book.tracks.containsKey(p.id)) audio(),
|
|
||||||
action(
|
|
||||||
g.recovered(p.campaignIndex!)
|
|
||||||
? 'View the solved pattern'
|
|
||||||
: 'Return to this pattern',
|
|
||||||
() => g.showStory(
|
|
||||||
g.book.pageFor(p.campaignIndex!, StoryPageType.puzzle),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
case StoryPageType.note:
|
|
||||||
if (!prefs.flag('notebook_note_open')) {
|
|
||||||
body.addAll([
|
|
||||||
writing('A folded scrap, tucked between the leaves.'),
|
|
||||||
GestureDetector(
|
|
||||||
onTap: openLetter,
|
|
||||||
child: const Sketch('envelope', height: 190),
|
|
||||||
),
|
|
||||||
action('Unfold Gran’s note', openLetter),
|
|
||||||
writing(
|
|
||||||
'You don’t have to solve anything to discover this.',
|
|
||||||
size: 20,
|
|
||||||
color: muted,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
body.addAll([
|
|
||||||
writing(
|
|
||||||
'For the crossing',
|
|
||||||
size: 28,
|
|
||||||
color: const Color(0xff70503b),
|
|
||||||
),
|
|
||||||
reading(p.text),
|
|
||||||
audio(),
|
|
||||||
action('Fold the note again', () {
|
|
||||||
unawaited(narrator.stop());
|
|
||||||
unawaited(prefs.set('notebook_note_open', false));
|
|
||||||
setState(() {});
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
case StoryPageType.inspection:
|
|
||||||
body.addAll([
|
|
||||||
writing(
|
|
||||||
prefs.flag('notebook_handle_seen')
|
|
||||||
? 'A repair made to keep small fingers safe.'
|
|
||||||
: 'A repair note, tucked into the margin.',
|
|
||||||
size: 20,
|
|
||||||
color: muted,
|
|
||||||
),
|
|
||||||
reading(p.text),
|
|
||||||
audio(),
|
|
||||||
action('Read Gran’s margin note', inspect),
|
|
||||||
action('Follow the lantern into the next entry →', () => turn(1)),
|
|
||||||
]);
|
|
||||||
case StoryPageType.closing:
|
|
||||||
body.addAll([
|
|
||||||
reading(p.text),
|
|
||||||
if (g.book.tracks.containsKey(p.id)) audio(),
|
|
||||||
writing(
|
|
||||||
'Four memories in the cottage · ${List.generate(4, (i) => g.recovered(i)).where((v) => v).length} patterns restored',
|
|
||||||
size: 19,
|
|
||||||
color: muted,
|
|
||||||
),
|
|
||||||
action(
|
|
||||||
'Take the path to the harbour →',
|
|
||||||
crossToHarbour,
|
|
||||||
primary: true,
|
|
||||||
),
|
|
||||||
writing(
|
|
||||||
'Your unfinished patterns will wait here for you.',
|
|
||||||
size: 19,
|
|
||||||
color: muted,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return Leaf(
|
|
||||||
key: ValueKey('story-${g.storyIndex}'),
|
|
||||||
onTurn: (d) => turn(d),
|
|
||||||
body: column(body),
|
|
||||||
wideBody: wideBody,
|
|
||||||
footer: navigation(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void openLetter() {
|
|
||||||
unawaited(prefs.set('notebook_note_open', true));
|
|
||||||
_scheduleAutoplay();
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> inspect() async {
|
|
||||||
await prefs.set('notebook_handle_seen', true);
|
|
||||||
await message(
|
|
||||||
'A careful repair',
|
|
||||||
'The wire is hidden under a strip of cloth. In the margin, Gran has written: “The light matters. So do the hands carrying it.”',
|
|
||||||
close: 'Keep that thought',
|
|
||||||
);
|
|
||||||
if (mounted) setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> speed() async {
|
Future<void> speed() async {
|
||||||
await narrator.pause();
|
await narrator.pause();
|
||||||
@@ -803,7 +918,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
await showDialog<void>(
|
await showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (c) => SimpleDialog(
|
builder: (c) => SimpleDialog(
|
||||||
title: Text('Recording speed', style: hand(29)),
|
title: CopyText('Recording speed', style: hand(29)),
|
||||||
children: [
|
children: [
|
||||||
for (final entry in [
|
for (final entry in [
|
||||||
(0.85, 'Unhurried · 0.85×'),
|
(0.85, 'Unhurried · 0.85×'),
|
||||||
@@ -815,7 +930,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
unawaited(prefs.set('recording_speed', entry.$1));
|
unawaited(prefs.set('recording_speed', entry.$1));
|
||||||
Navigator.pop(c);
|
Navigator.pop(c);
|
||||||
},
|
},
|
||||||
child: Text(entry.$2, style: hand(23)),
|
child: CopyText(entry.$2, style: hand(23)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -836,7 +951,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text('Sound & atmosphere', style: hand(29)),
|
title: CopyText('Sound & atmosphere', style: hand(29)),
|
||||||
content: SingleChildScrollView(
|
content: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -844,7 +959,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
children: [
|
children: [
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
title: Text('Environmental sounds', style: hand(23)),
|
title: CopyText('Environmental sounds', style: hand(23)),
|
||||||
value: atmosphereEnabled,
|
value: atmosphereEnabled,
|
||||||
onChanged: (value) => save('ambience_enabled', value),
|
onChanged: (value) => save('ambience_enabled', value),
|
||||||
),
|
),
|
||||||
@@ -875,7 +990,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(dialogContext),
|
onPressed: () => Navigator.pop(dialogContext),
|
||||||
child: const Text('Keep going'),
|
child: const CopyText('Keep going'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -886,7 +1001,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
Widget contents() {
|
Widget contents() {
|
||||||
final chapter = g.contentsChapter;
|
final chapter = g.contentsChapter;
|
||||||
final first = chapter * 4;
|
final indices = g.book.chapterLevels(chapter);
|
||||||
|
final first = indices.first;
|
||||||
final savedId = prefs.text('notebook_last_page');
|
final savedId = prefs.text('notebook_last_page');
|
||||||
final saved = g.book.pages.where((p) => p.id == savedId).firstOrNull;
|
final saved = g.book.pages.where((p) => p.id == savedId).firstOrNull;
|
||||||
final bookmarkId = prefs.text('notebook_manual_bookmark');
|
final bookmarkId = prefs.text('notebook_manual_bookmark');
|
||||||
@@ -894,9 +1010,18 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
return Leaf(
|
return Leaf(
|
||||||
key: ValueKey('contents-$chapter'),
|
key: ValueKey('contents-$chapter'),
|
||||||
body: column([
|
body: column([
|
||||||
folio('MARA’S NOTEBOOK · CONTENTS'),
|
folio('${g.book.title.toUpperCase()} · CONTENTS'),
|
||||||
writing(g.book.levels[first].chapter, size: 34),
|
writing(g.book.levels[first].chapter, size: 34),
|
||||||
if (chapter == 0) ...[
|
if (chapter == 0 && !g.book.isMara) ...[
|
||||||
|
reading(g.book.premise),
|
||||||
|
action('Continue reading', g.openNotebook),
|
||||||
|
if (ribbon != null)
|
||||||
|
action(
|
||||||
|
'Return to my ribbon bookmark',
|
||||||
|
() => g.showStory(g.book.pages.indexOf(ribbon)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (chapter == 0 && g.book.isMara) ...[
|
||||||
writing(
|
writing(
|
||||||
'For you, when you are ready. With all my love, Gran.',
|
'For you, when you are ready. With all my love, Gran.',
|
||||||
color: const Color(0xff70503b),
|
color: const Color(0xff70503b),
|
||||||
@@ -911,7 +1036,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
),
|
),
|
||||||
divider(),
|
divider(),
|
||||||
],
|
],
|
||||||
for (var i = first; i < first + 4; i++) ...[
|
for (final i in indices) ...[
|
||||||
InkButton(
|
InkButton(
|
||||||
'${i + 1} · ${g.book.levels[i].title}${g.recovered(i) ? ' ✓' : ''}${chapter == 0 && ribbon?.campaignIndex == i ? ' · ribbon' : ''}',
|
'${i + 1} · ${g.book.levels[i].title}${g.recovered(i) ? ' ✓' : ''}${chapter == 0 && ribbon?.campaignIndex == i ? ' · ribbon' : ''}',
|
||||||
i <= g.accessible
|
i <= g.accessible
|
||||||
@@ -925,7 +1050,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
if (chapter == 0) ...[
|
if (chapter == 0 && g.book.isMara) ...[
|
||||||
divider(),
|
divider(),
|
||||||
action('The folded note', () => g.showStory(4)),
|
action('The folded note', () => g.showStory(4)),
|
||||||
action('Gran’s repair note', () => g.showStory(5)),
|
action('Gran’s repair note', () => g.showStory(5)),
|
||||||
@@ -935,7 +1060,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
writing(
|
writing(
|
||||||
'${g.recoveredCount} / 12 memories restored',
|
'${g.recoveredCount} / ${g.book.levels.length} memories restored',
|
||||||
size: 20,
|
size: 20,
|
||||||
color: muted,
|
color: muted,
|
||||||
),
|
),
|
||||||
@@ -953,7 +1078,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: InkButton(
|
child: InkButton(
|
||||||
'Next chapter →',
|
'Next chapter →',
|
||||||
chapter < 2 && (chapter + 1) * 4 <= g.accessible
|
chapter + 1 < g.book.chapters.length &&
|
||||||
|
g.book.chapterLevels(chapter + 1).first <= g.accessible
|
||||||
? () => g.contents(chapter + 1)
|
? () => g.contents(chapter + 1)
|
||||||
: null,
|
: null,
|
||||||
size: 19,
|
size: 19,
|
||||||
@@ -972,7 +1098,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
key: ValueKey('briefing-${g.campaignIndex}'),
|
key: ValueKey('briefing-${g.campaignIndex}'),
|
||||||
onTurn: (d) => turnCampaign(d),
|
onTurn: (d) => turnCampaign(d),
|
||||||
body: column([
|
body: column([
|
||||||
folio('MARA’S NOTEBOOK / LEAF ${g.campaignIndex + 1}'),
|
folio('${g.book.title.toUpperCase()} / LEAF ${g.campaignIndex + 1}'),
|
||||||
writing(l.chapter, size: 20, color: blue),
|
writing(l.chapter, size: 20, color: blue),
|
||||||
writing(l.title, size: 33),
|
writing(l.title, size: 33),
|
||||||
gap(),
|
gap(),
|
||||||
@@ -990,7 +1116,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
action(
|
action(
|
||||||
g.recovered(g.campaignIndex)
|
g.recovered(g.campaignIndex)
|
||||||
? 'View the solved pattern →'
|
? 'View the solved pattern →'
|
||||||
: prefs.contains('grid_story_v1_${g.campaignIndex}')
|
: prefs.contains('grid_${g.book.puzzleKey(g.campaignIndex)}')
|
||||||
? 'Continue this pattern →'
|
? 'Continue this pattern →'
|
||||||
: 'Restore the pattern →',
|
: 'Restore the pattern →',
|
||||||
() => g.startCampaign(g.campaignIndex),
|
() => g.startCampaign(g.campaignIndex),
|
||||||
@@ -1107,9 +1233,9 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
List<Widget> heading({bool compact = false}) => [
|
List<Widget> heading({bool compact = false}) => [
|
||||||
folio(
|
folio(
|
||||||
g.mode == Mode.daily
|
g.mode == Mode.daily
|
||||||
? 'DAILY / ${DateFormat('d MMMM').format(g.date)}'
|
? 'DAILY / ${DateFormat('d MMMM', Localizations.localeOf(context).languageCode).format(g.date)}'
|
||||||
: g.mode == Mode.campaign
|
: g.mode == Mode.campaign
|
||||||
? 'THE LAST LIGHT / ${g.campaignIndex + 1} OF 12'
|
? '${g.book.title.toUpperCase()} / ${g.campaignIndex + 1} OF ${g.book.levels.length}'
|
||||||
: 'CLASSIC / ${g.difficulty.label} / LEVEL ${g.playingLevel}',
|
: 'CLASSIC / ${g.difficulty.label} / LEVEL ${g.playingLevel}',
|
||||||
),
|
),
|
||||||
writing(
|
writing(
|
||||||
@@ -1213,7 +1339,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
if (h == null) return;
|
if (h == null) return;
|
||||||
await message(
|
await message(
|
||||||
'Row ${h.cell ~/ g.puzzle!.size + 1}, column ${h.cell % g.puzzle!.size + 1}',
|
'Row ${h.cell ~/ g.puzzle!.size + 1}, column ${h.cell % g.puzzle!.size + 1}',
|
||||||
'${h.explanation}\n\n${h.value == 1 ? 'This cell is lit.' : 'This cell stays dark.'}',
|
'${CopyScope.text(context, h.explanation)}\n\n${CopyScope.text(context, h.value == 1 ? 'This cell is lit.' : 'This cell stays dark.')}',
|
||||||
);
|
);
|
||||||
if (mounted &&
|
if (mounted &&
|
||||||
g.key == requested &&
|
g.key == requested &&
|
||||||
@@ -1286,7 +1412,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
key: ValueKey('reveal-$i'),
|
key: ValueKey('reveal-$i'),
|
||||||
onTurn: (d) => turnCampaign(d),
|
onTurn: (d) => turnCampaign(d),
|
||||||
body: column([
|
body: column([
|
||||||
folio('MARA’S NOTEBOOK / LEAF ${i + 1}'),
|
folio('${g.book.title.toUpperCase()} / LEAF ${i + 1}'),
|
||||||
writing(
|
writing(
|
||||||
g.recovered(i)
|
g.recovered(i)
|
||||||
? 'Something found. Something remembered.'
|
? 'Something found. Something remembered.'
|
||||||
@@ -1312,15 +1438,15 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
color: const Color(0xff70503b),
|
color: const Color(0xff70503b),
|
||||||
),
|
),
|
||||||
divider(),
|
divider(),
|
||||||
if (i == 11) ...[
|
if (i == g.book.levels.length - 1) ...[
|
||||||
folio(
|
folio(
|
||||||
g.recoveredCount == 12
|
g.recoveredCount == g.book.levels.length
|
||||||
? 'THE END · YOUR WATCH HAS BEGUN'
|
? 'THE END · YOUR WATCH HAS BEGUN'
|
||||||
: 'THE LAST PAGE · COME BACK WHENEVER YOU LIKE',
|
: 'THE LAST PAGE · COME BACK WHENEVER YOU LIKE',
|
||||||
),
|
),
|
||||||
writing(
|
writing(
|
||||||
g.recoveredCount == 12
|
g.recoveredCount == g.book.levels.length
|
||||||
? 'Twelve patterns. One light brought home. The daily puzzle will be here whenever you return.'
|
? 'Every pattern restored. The daily puzzle will be here whenever you return.'
|
||||||
: 'A light kept in these pages. Your unfinished patterns will be here whenever you return.',
|
: 'A light kept in these pages. Your unfinished patterns will be here whenever you return.',
|
||||||
),
|
),
|
||||||
action('Return to the notebook', g.contents, primary: true),
|
action('Return to the notebook', g.contents, primary: true),
|
||||||
@@ -1336,7 +1462,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
await showDialog<void>(
|
await showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (c) => SimpleDialog(
|
builder: (c) => SimpleDialog(
|
||||||
title: Text('Classic practice pace', style: hand(29)),
|
title: CopyText('Classic practice pace', style: hand(29)),
|
||||||
children: [
|
children: [
|
||||||
for (final d in Difficulty.values)
|
for (final d in Difficulty.values)
|
||||||
SimpleDialogOption(
|
SimpleDialogOption(
|
||||||
@@ -1344,7 +1470,10 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
|||||||
g.selectDifficulty(d);
|
g.selectDifficulty(d);
|
||||||
Navigator.pop(c);
|
Navigator.pop(c);
|
||||||
},
|
},
|
||||||
child: Text('${d.label} — ${d.description}', style: hand(23)),
|
child: CopyText(
|
||||||
|
'${CopyScope.text(context, d.label)} — ${CopyScope.text(context, d.description)}',
|
||||||
|
style: hand(23),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -11,7 +11,12 @@ class Narrator extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
_subscriptions.add(_player.positionStream.listen((_) => notifyListeners()));
|
_subscriptions.add(_player.positionStream.listen((_) => notifyListeners()));
|
||||||
}
|
}
|
||||||
final Map<String, dynamic> tracks;
|
Map<String, dynamic> tracks;
|
||||||
|
void replaceTracks(Map<String, dynamic> value) {
|
||||||
|
unawaited(stop());
|
||||||
|
tracks = value;
|
||||||
|
}
|
||||||
|
|
||||||
final _player = AudioPlayer();
|
final _player = AudioPlayer();
|
||||||
final List<StreamSubscription<dynamic>> _subscriptions = [];
|
final List<StreamSubscription<dynamic>> _subscriptions = [];
|
||||||
String page = '', error = '';
|
String page = '', error = '';
|
||||||
@@ -101,7 +106,10 @@ class Narrator extends ChangeNotifier {
|
|||||||
if (generation != _generation) return;
|
if (generation != _generation) return;
|
||||||
page = id;
|
page = id;
|
||||||
// PCM WAV avoids silent FLAC playback on the API 26 Huawei tablet.
|
// PCM WAV avoids silent FLAC playback on the API 26 Huawei tablet.
|
||||||
await _player.setAsset('assets/audio/${tracks[id]['file']}');
|
await _player.setAsset(
|
||||||
|
tracks[id]['asset'] as String? ??
|
||||||
|
'assets/audio/${tracks[id]['file']}',
|
||||||
|
);
|
||||||
if (generation != _generation) return;
|
if (generation != _generation) return;
|
||||||
} else if (finished) {
|
} else if (finished) {
|
||||||
await _player.seek(Duration.zero);
|
await _player.seek(Duration.zero);
|
||||||
|
|||||||
+36
-14
@@ -2,7 +2,27 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
|
|
||||||
/// Flutter has its own store; the former Android `lumen.xml` is never imported.
|
/// Flutter has its own store; the former Android `lumen.xml` is never imported.
|
||||||
class Progress {
|
class Progress {
|
||||||
Progress._(this._disk, this._values);
|
Progress._(this._disk, this._values, [this._storyId, this._root]);
|
||||||
|
final String? _storyId;
|
||||||
|
final Progress? _root;
|
||||||
|
|
||||||
|
/// The original book retains its existing save keys. Other stories get a
|
||||||
|
/// namespace; device settings, daily/practice records and totals stay global.
|
||||||
|
Progress forStory(String id) => Progress._(_disk, _values, id, _root ?? this);
|
||||||
|
String _key(String key) {
|
||||||
|
if (_storyId == null || _storyId == 'mara-island') return key;
|
||||||
|
final storyKey =
|
||||||
|
key.startsWith('notebook_') ||
|
||||||
|
key.startsWith('flutter_') ||
|
||||||
|
key.startsWith('viewed_') ||
|
||||||
|
key.startsWith('storyAd_') ||
|
||||||
|
key.startsWith('grid_story_') ||
|
||||||
|
key.startsWith('done_story_') ||
|
||||||
|
key == 'campaignUnlocked' ||
|
||||||
|
key == 'story_access_level';
|
||||||
|
return storyKey ? 'story/$_storyId/$key' : key;
|
||||||
|
}
|
||||||
|
|
||||||
final SharedPreferencesAsync? _disk;
|
final SharedPreferencesAsync? _disk;
|
||||||
final Map<String, Object> _values;
|
final Map<String, Object> _values;
|
||||||
static Future<Progress> load() async {
|
static Future<Progress> load() async {
|
||||||
@@ -13,35 +33,37 @@ class Progress {
|
|||||||
factory Progress.memory([Map<String, Object> values = const {}]) =>
|
factory Progress.memory([Map<String, Object> values = const {}]) =>
|
||||||
Progress._(null, Map.of(values));
|
Progress._(null, Map.of(values));
|
||||||
int number(String key, [int fallback = 0]) =>
|
int number(String key, [int fallback = 0]) =>
|
||||||
(_values[key] as num?)?.toInt() ?? fallback;
|
(_values[_key(key)] as num?)?.toInt() ?? fallback;
|
||||||
double decimal(String key, [double fallback = 1]) =>
|
double decimal(String key, [double fallback = 1]) =>
|
||||||
(_values[key] as num?)?.toDouble() ?? fallback;
|
(_values[_key(key)] as num?)?.toDouble() ?? fallback;
|
||||||
bool flag(String key) => _values[key] == true;
|
bool flag(String key) => _values[_key(key)] == true;
|
||||||
String text(String key, [String fallback = '']) =>
|
String text(String key, [String fallback = '']) =>
|
||||||
_values[key] as String? ?? fallback;
|
_values[_key(key)] as String? ?? fallback;
|
||||||
bool contains(String key) => _values.containsKey(key);
|
bool contains(String key) => _values.containsKey(_key(key));
|
||||||
Map<String, Object> get snapshot => Map.unmodifiable(_values);
|
Map<String, Object> get snapshot => Map.unmodifiable(_values);
|
||||||
Future<void> _writes = Future.value();
|
Future<void> _writes = Future.value();
|
||||||
Future<void> set(String key, Object value) {
|
Future<void> set(String key, Object value) {
|
||||||
_values[key] = value;
|
_values[_key(key)] = value;
|
||||||
final disk = _disk;
|
final disk = _disk;
|
||||||
if (disk == null) return Future.value();
|
if (disk == null) return Future.value();
|
||||||
_writes = _writes.then((_) async {
|
final writer = _root ?? this;
|
||||||
|
final storedKey = _key(key);
|
||||||
|
writer._writes = writer._writes.then((_) async {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case bool v:
|
case bool v:
|
||||||
await disk.setBool(key, v);
|
await disk.setBool(storedKey, v);
|
||||||
case int v:
|
case int v:
|
||||||
await disk.setInt(key, v);
|
await disk.setInt(storedKey, v);
|
||||||
case double v:
|
case double v:
|
||||||
await disk.setDouble(key, v);
|
await disk.setDouble(storedKey, v);
|
||||||
case String v:
|
case String v:
|
||||||
await disk.setString(key, v);
|
await disk.setString(storedKey, v);
|
||||||
default:
|
default:
|
||||||
throw ArgumentError('Unsupported preference');
|
throw ArgumentError('Unsupported preference');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return _writes;
|
return writer._writes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> get flushed => _writes;
|
Future<void> get flushed => (_root ?? this)._writes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
/// UI messages use their English source as catalogue keys. Numbered slots in
|
||||||
|
/// dynamic messages are preserved by translators and can be reordered.
|
||||||
|
class TranslationCatalog {
|
||||||
|
const TranslationCatalog(this.languages, this.messages);
|
||||||
|
static const english = TranslationCatalog({'en': 'English'}, {});
|
||||||
|
final Map<String, String> languages;
|
||||||
|
final Map<String, Map<String, String>> messages;
|
||||||
|
|
||||||
|
static Future<TranslationCatalog> load(AssetBundle bundle) async {
|
||||||
|
final index = jsonDecode(
|
||||||
|
await bundle.loadString('assets/locales/catalog.json'),
|
||||||
|
) as Map;
|
||||||
|
final messages = <String, Map<String, String>>{};
|
||||||
|
final languages = <String, String>{};
|
||||||
|
for (final entry in index.entries) {
|
||||||
|
languages[entry.key] = entry.value['label'];
|
||||||
|
messages[entry.key] = Map<String, String>.from(
|
||||||
|
jsonDecode(await bundle.loadString(entry.value['asset'])),
|
||||||
|
);
|
||||||
|
for (final message in messages[entry.key]!.entries) {
|
||||||
|
Set<String> slots(String text) =>
|
||||||
|
RegExp(r'\{\d+\}').allMatches(text).map((m) => m[0]!).toSet();
|
||||||
|
if (slots(message.key).difference(slots(message.value)).isNotEmpty ||
|
||||||
|
slots(message.value).difference(slots(message.key)).isNotEmpty) {
|
||||||
|
throw FormatException(
|
||||||
|
'Translation placeholders differ: ${entry.key}: ${message.key}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TranslationCatalog(languages, messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageTranslator translator(
|
||||||
|
String locale, {
|
||||||
|
Map<String, String> overrides = const {},
|
||||||
|
}) {
|
||||||
|
final tag = locale.replaceAll('_', '-').toLowerCase();
|
||||||
|
return MessageTranslator({
|
||||||
|
...?messages['en'],
|
||||||
|
...?messages[tag.split('-').first],
|
||||||
|
...?messages[tag],
|
||||||
|
...overrides,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
String text(
|
||||||
|
String source,
|
||||||
|
String locale, {
|
||||||
|
Map<String, String> overrides = const {},
|
||||||
|
}) => translator(locale, overrides: overrides).text(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessageTranslator {
|
||||||
|
MessageTranslator(this.messages) {
|
||||||
|
for (final entry in messages.entries) {
|
||||||
|
if (entry.key == entry.value) continue;
|
||||||
|
final slots = _slots.allMatches(entry.key).toList();
|
||||||
|
if (slots.isEmpty) continue;
|
||||||
|
var pattern = '^', end = 0;
|
||||||
|
for (final slot in slots) {
|
||||||
|
pattern += RegExp.escape(entry.key.substring(end, slot.start));
|
||||||
|
pattern += r'([\s\S]*?)';
|
||||||
|
end = slot.end;
|
||||||
|
}
|
||||||
|
pattern += '${RegExp.escape(entry.key.substring(end))}\$';
|
||||||
|
_templates.add(
|
||||||
|
_Template(
|
||||||
|
RegExp(pattern),
|
||||||
|
entry.value,
|
||||||
|
slots.map((m) => m[1]!).toList(),
|
||||||
|
entry.key.length - slots.fold(0, (n, m) => n + m[0]!.length),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// "Row {0}, column {1}" must match before the shorter "Row {0}".
|
||||||
|
_templates.sort((a, b) => b.specificity.compareTo(a.specificity));
|
||||||
|
}
|
||||||
|
static final _slots = RegExp(r'\{(\d+)\}');
|
||||||
|
final Map<String, String> messages;
|
||||||
|
final List<_Template> _templates = [];
|
||||||
|
|
||||||
|
String text(String source) => _text(source, 0);
|
||||||
|
String _text(String source, int depth) {
|
||||||
|
final exact = messages[source];
|
||||||
|
if (exact != null && exact != source) return exact;
|
||||||
|
if (depth > 4) return source;
|
||||||
|
for (final template in _templates) {
|
||||||
|
final match = template.pattern.firstMatch(source);
|
||||||
|
if (match == null) continue;
|
||||||
|
final values = <String, String>{
|
||||||
|
for (var i = 0; i < template.slots.length; i++)
|
||||||
|
template.slots[i]: _text(match[i + 1]!, depth + 1),
|
||||||
|
};
|
||||||
|
return template.value.replaceAllMapped(
|
||||||
|
_slots,
|
||||||
|
(m) => values[m[1]] ?? m[0]!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Template {
|
||||||
|
const _Template(this.pattern, this.value, this.slots, this.specificity);
|
||||||
|
final RegExp pattern;
|
||||||
|
final String value;
|
||||||
|
final List<String> slots;
|
||||||
|
final int specificity;
|
||||||
|
}
|
||||||
+136
-128
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../domain/puzzle.dart';
|
import '../domain/puzzle.dart';
|
||||||
import 'paper.dart';
|
import 'paper.dart';
|
||||||
|
import 'translation.dart';
|
||||||
|
|
||||||
class Board extends StatelessWidget {
|
class Board extends StatelessWidget {
|
||||||
const Board({
|
const Board({
|
||||||
@@ -25,149 +26,155 @@ class Board extends StatelessWidget {
|
|||||||
final double maxWidth;
|
final double maxWidth;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => PageSwipeBlocker(
|
Widget build(BuildContext context) => PageSwipeBlocker(
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: ConstrainedBox(
|
textDirection: TextDirection.ltr,
|
||||||
constraints: BoxConstraints(maxWidth: maxWidth),
|
child: Center(
|
||||||
child: AspectRatio(
|
child: ConstrainedBox(
|
||||||
aspectRatio: 1,
|
constraints: BoxConstraints(maxWidth: maxWidth),
|
||||||
child: LayoutBuilder(
|
child: AspectRatio(
|
||||||
builder: (context, c) {
|
aspectRatio: 1,
|
||||||
final n = puzzle.size,
|
child: LayoutBuilder(
|
||||||
u = c.maxWidth / (n + 1.3),
|
builder: (context, c) {
|
||||||
r = puzzle.regions.isEmpty
|
final n = puzzle.size,
|
||||||
? null
|
u = c.maxWidth / (n + 1.3),
|
||||||
: puzzle.regions[selectedArea];
|
r = puzzle.regions.isEmpty
|
||||||
Widget clue(String text, bool complete) => SizedBox(
|
? null
|
||||||
width: u,
|
: puzzle.regions[selectedArea];
|
||||||
height: u,
|
Widget clue(String text, bool complete) => SizedBox(
|
||||||
child: Center(
|
width: u,
|
||||||
child: Text(
|
height: u,
|
||||||
text,
|
child: Center(
|
||||||
style: hand(
|
child: Text(
|
||||||
(u * .42).clamp(16, 23),
|
text,
|
||||||
color: complete ? blue : muted,
|
style: hand(
|
||||||
|
(u * .42).clamp(16, 23),
|
||||||
|
color: complete ? blue : muted,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
bool complete(Iterable<int> indices, int total) =>
|
||||||
bool complete(Iterable<int> indices, int total) =>
|
indices.where((i) => cells[i] == 1).length == total;
|
||||||
indices.where((i) => cells[i] == 1).length == total;
|
return Align(
|
||||||
return Align(
|
alignment: Alignment.center,
|
||||||
alignment: Alignment.center,
|
child: Column(
|
||||||
child: Column(
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: [
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(width: u, height: u),
|
|
||||||
for (var col = 0; col < n; col++)
|
|
||||||
clue(
|
|
||||||
'${puzzle.cols[col]}',
|
|
||||||
complete(
|
|
||||||
List.generate(n, (i) => i * n + col),
|
|
||||||
puzzle.cols[col],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
for (var row = 0; row < n; row++)
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
clue(
|
SizedBox(width: u, height: u),
|
||||||
'${puzzle.rows[row]}',
|
|
||||||
complete(
|
|
||||||
List.generate(n, (i) => row * n + i),
|
|
||||||
puzzle.rows[row],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
for (var col = 0; col < n; col++)
|
for (var col = 0; col < n; col++)
|
||||||
Builder(
|
clue(
|
||||||
builder: (context) {
|
'${puzzle.cols[col]}',
|
||||||
final i = row * n + col,
|
complete(
|
||||||
value = cells[i],
|
List.generate(n, (i) => i * n + col),
|
||||||
fixed = puzzle.given[i],
|
puzzle.cols[col],
|
||||||
inside = r?.contains(i, n) ?? false;
|
),
|
||||||
final state = value == 0
|
),
|
||||||
? 'empty'
|
],
|
||||||
: value == 1
|
),
|
||||||
? 'lit'
|
for (var row = 0; row < n; row++)
|
||||||
: 'crossed out';
|
Row(
|
||||||
return Semantics(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
label:
|
children: [
|
||||||
|
clue(
|
||||||
|
'${puzzle.rows[row]}',
|
||||||
|
complete(
|
||||||
|
List.generate(n, (i) => row * n + i),
|
||||||
|
puzzle.rows[row],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
for (var col = 0; col < n; col++)
|
||||||
|
Builder(
|
||||||
|
builder: (context) {
|
||||||
|
final i = row * n + col,
|
||||||
|
value = cells[i],
|
||||||
|
fixed = puzzle.given[i],
|
||||||
|
inside = r?.contains(i, n) ?? false;
|
||||||
|
final state = value == 0
|
||||||
|
? 'empty'
|
||||||
|
: value == 1
|
||||||
|
? 'lit'
|
||||||
|
: 'crossed out';
|
||||||
|
return Semantics(
|
||||||
|
label: CopyScope.text(
|
||||||
|
context,
|
||||||
'Row ${row + 1}, column ${col + 1}, $state${fixed ? ', fixed clue' : ''}',
|
'Row ${row + 1}, column ${col + 1}, $state${fixed ? ', fixed clue' : ''}',
|
||||||
button: !fixed && !won,
|
),
|
||||||
enabled: !fixed && !won,
|
button: !fixed && !won,
|
||||||
onTap: fixed || won ? null : () => onMark(i),
|
enabled: !fixed && !won,
|
||||||
excludeSemantics: true,
|
|
||||||
child: GestureDetector(
|
|
||||||
key: ValueKey('cell-$i'),
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
onTap: fixed || won
|
onTap: fixed || won
|
||||||
? null
|
? null
|
||||||
: () => onMark(i),
|
: () => onMark(i),
|
||||||
child: SizedBox(
|
excludeSemantics: true,
|
||||||
width: u,
|
child: GestureDetector(
|
||||||
height: u,
|
key: ValueKey('cell-$i'),
|
||||||
child: Padding(
|
behavior: HitTestBehavior.opaque,
|
||||||
padding: const EdgeInsets.all(2),
|
onTap: fixed || won
|
||||||
child: DecoratedBox(
|
? null
|
||||||
decoration: BoxDecoration(
|
: () => onMark(i),
|
||||||
color: inside
|
child: SizedBox(
|
||||||
? amber.withValues(alpha: .22)
|
width: u,
|
||||||
: Colors.transparent,
|
height: u,
|
||||||
borderRadius: BorderRadius.circular(
|
child: Padding(
|
||||||
2,
|
padding: const EdgeInsets.all(2),
|
||||||
),
|
child: DecoratedBox(
|
||||||
border: Border.all(
|
decoration: BoxDecoration(
|
||||||
color: inside
|
color: inside
|
||||||
? const Color(0xffaa5b2a)
|
? amber.withValues(alpha: .22)
|
||||||
: muted.withValues(
|
: Colors.transparent,
|
||||||
alpha: .48,
|
borderRadius:
|
||||||
),
|
BorderRadius.circular(2),
|
||||||
width: inside ? 1.4 : .65,
|
border: Border.all(
|
||||||
|
color: inside
|
||||||
|
? const Color(0xffaa5b2a)
|
||||||
|
: muted.withValues(
|
||||||
|
alpha: .48,
|
||||||
|
),
|
||||||
|
width: inside ? 1.4 : .65,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
child: Stack(
|
||||||
child: Stack(
|
children: [
|
||||||
children: [
|
if (value != 0)
|
||||||
if (value != 0)
|
Positioned.fill(
|
||||||
Positioned.fill(
|
child: CustomPaint(
|
||||||
child: CustomPaint(
|
painter: PencilMark(
|
||||||
painter: PencilMark(
|
value: value,
|
||||||
value: value,
|
variation: i,
|
||||||
variation: i,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (fixed)
|
||||||
if (fixed)
|
Positioned(
|
||||||
Positioned(
|
right: 3,
|
||||||
right: 3,
|
bottom: 3,
|
||||||
bottom: 3,
|
child: Container(
|
||||||
child: Container(
|
width: 4,
|
||||||
width: 4,
|
height: 4,
|
||||||
height: 4,
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: muted,
|
||||||
color: muted,
|
shape: BoxShape.circle,
|
||||||
shape: BoxShape.circle,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -265,7 +272,7 @@ class PixelPicture extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Semantics(
|
Widget build(BuildContext context) => Semantics(
|
||||||
image: true,
|
image: true,
|
||||||
label: 'Recovered pixel picture: $label',
|
label: CopyScope.text(context, 'Recovered pixel picture: $label'),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: height,
|
width: height,
|
||||||
@@ -307,7 +314,7 @@ class PatternStamp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Semantics(
|
Widget build(BuildContext context) => Semantics(
|
||||||
image: true,
|
image: true,
|
||||||
label: 'Your restored seven by seven pattern: $label',
|
label: CopyScope.text(context, 'Your restored pattern: $label'),
|
||||||
child: SizedBox.square(
|
child: SizedBox.square(
|
||||||
dimension: height,
|
dimension: height,
|
||||||
child: CustomPaint(painter: _Pixels(picture)),
|
child: CustomPaint(painter: _Pixels(picture)),
|
||||||
@@ -320,10 +327,11 @@ class _Pixels extends CustomPainter {
|
|||||||
final List<int> picture;
|
final List<int> picture;
|
||||||
@override
|
@override
|
||||||
void paint(Canvas c, Size s) {
|
void paint(Canvas c, Size s) {
|
||||||
final p = Paint()..color = blue, u = s.width / 7;
|
final n = math.sqrt(picture.length).round();
|
||||||
for (var i = 0; i < 49; i++) {
|
final p = Paint()..color = blue, u = s.width / n;
|
||||||
|
for (var i = 0; i < picture.length; i++) {
|
||||||
if (picture[i] == 1) {
|
if (picture[i] == 1) {
|
||||||
c.drawRect(Rect.fromLTWH(i % 7 * u, i ~/ 7 * u, u + .3, u + .3), p);
|
c.drawRect(Rect.fromLTWH(i % n * u, i ~/ n * u, u + .3, u + .3), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'translation.dart';
|
||||||
|
|
||||||
import 'board.dart';
|
import 'board.dart';
|
||||||
import 'paper.dart';
|
import 'paper.dart';
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ class _DiscoveryState extends State<Discovery>
|
|||||||
PatternStamp(widget.picture, label: widget.label, height: 56),
|
PatternStamp(widget.picture, label: widget.label, height: 56),
|
||||||
const SizedBox(width: 14),
|
const SizedBox(width: 14),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: CopyText(
|
||||||
'Your restored pattern\n${widget.label}',
|
'Your restored pattern\n${widget.label}',
|
||||||
style: hand(18, color: muted),
|
style: hand(18, color: muted),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
part of '../main.dart';
|
||||||
|
|
||||||
|
// The original story's folded note and repair inspection are optional book
|
||||||
|
// presentation behavior. Standard story packages use the reusable page renderer.
|
||||||
|
extension _MaraStory on _NotebookState {
|
||||||
|
Widget maraStory() {
|
||||||
|
final p = g.book.pages[g.storyIndex];
|
||||||
|
final heading = <Widget>[
|
||||||
|
folio('THE COTTAGE / ${g.storyIndex + 1} OF ${g.book.pages.length}'),
|
||||||
|
writing(p.title, size: 31),
|
||||||
|
];
|
||||||
|
final body = <Widget>[...heading];
|
||||||
|
Widget? wideBody;
|
||||||
|
switch (p.type) {
|
||||||
|
case StoryPageType.dedication:
|
||||||
|
body.addAll([
|
||||||
|
writing('A few things worth keeping', size: 20, color: muted),
|
||||||
|
divider(),
|
||||||
|
reading(p.text),
|
||||||
|
audio(),
|
||||||
|
]);
|
||||||
|
case StoryPageType.entry:
|
||||||
|
body.addAll([
|
||||||
|
if (p.illustrationAsset case final asset?)
|
||||||
|
Image.asset(
|
||||||
|
asset,
|
||||||
|
height: 155,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
semanticLabel: 'Watercolour of Gran’s stone cottage, blue door and warm window.',
|
||||||
|
),
|
||||||
|
writing(p.speaker, size: 17, color: muted),
|
||||||
|
reading(p.text),
|
||||||
|
if (p.continuation.isNotEmpty) reading(p.continuation),
|
||||||
|
if (g.book.tracks.containsKey(p.id)) audio(),
|
||||||
|
if (p.campaignIndex != 0)
|
||||||
|
action('Turn to the pattern →', () => turn(1)),
|
||||||
|
]);
|
||||||
|
case StoryPageType.puzzle:
|
||||||
|
final intro = writing(
|
||||||
|
g.campaignIndex < 2
|
||||||
|
? 'Restore a small light, or leave a bookmark and read on.'
|
||||||
|
: 'Compare the shared areas. Each cell counts in every area it belongs to.',
|
||||||
|
size: 21,
|
||||||
|
color: muted,
|
||||||
|
);
|
||||||
|
body.addAll([intro, puzzleBody()]);
|
||||||
|
wideBody = splitPuzzle(
|
||||||
|
side: [...heading, intro, areaPicker(), ...puzzleNotes()],
|
||||||
|
);
|
||||||
|
case StoryPageType.memory:
|
||||||
|
body.addAll([
|
||||||
|
discoveryArt(g.book.levels[p.campaignIndex!], height: 155),
|
||||||
|
writing(
|
||||||
|
g.recovered(p.campaignIndex!)
|
||||||
|
? 'A pattern restored · a memory kept'
|
||||||
|
: 'A memory to read · your puzzle can wait',
|
||||||
|
size: 17,
|
||||||
|
color: muted,
|
||||||
|
),
|
||||||
|
reading(p.text),
|
||||||
|
if (p.continuation.isNotEmpty) reading(p.continuation),
|
||||||
|
if (g.book.tracks.containsKey(p.id)) audio(),
|
||||||
|
action(
|
||||||
|
g.recovered(p.campaignIndex!)
|
||||||
|
? 'View the solved pattern'
|
||||||
|
: 'Return to this pattern',
|
||||||
|
() => g.showStory(
|
||||||
|
g.book.pageFor(p.campaignIndex!, StoryPageType.puzzle),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
case StoryPageType.note:
|
||||||
|
if (!prefs.flag('notebook_note_open')) {
|
||||||
|
body.addAll([
|
||||||
|
writing('A folded scrap, tucked between the leaves.'),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: openLetter,
|
||||||
|
child: const Sketch('envelope', height: 190),
|
||||||
|
),
|
||||||
|
action('Unfold Gran’s note', openLetter),
|
||||||
|
writing(
|
||||||
|
'You don’t have to solve anything to discover this.',
|
||||||
|
size: 20,
|
||||||
|
color: muted,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
body.addAll([
|
||||||
|
writing(
|
||||||
|
'For the crossing',
|
||||||
|
size: 28,
|
||||||
|
color: const Color(0xff70503b),
|
||||||
|
),
|
||||||
|
reading(p.text),
|
||||||
|
audio(),
|
||||||
|
action('Fold the note again', () {
|
||||||
|
unawaited(narrator.stop());
|
||||||
|
unawaited(prefs.set('notebook_note_open', false));
|
||||||
|
refreshNotebook();
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
case StoryPageType.inspection:
|
||||||
|
body.addAll([
|
||||||
|
writing(
|
||||||
|
prefs.flag('notebook_handle_seen')
|
||||||
|
? 'A repair made to keep small fingers safe.'
|
||||||
|
: 'A repair note, tucked into the margin.',
|
||||||
|
size: 20,
|
||||||
|
color: muted,
|
||||||
|
),
|
||||||
|
reading(p.text),
|
||||||
|
audio(),
|
||||||
|
action('Read Gran’s margin note', inspect),
|
||||||
|
action('Follow the lantern into the next entry →', () => turn(1)),
|
||||||
|
]);
|
||||||
|
case StoryPageType.closing:
|
||||||
|
body.addAll([
|
||||||
|
reading(p.text),
|
||||||
|
if (g.book.tracks.containsKey(p.id)) audio(),
|
||||||
|
writing(
|
||||||
|
'Four memories in the cottage · ${List.generate(4, (i) => g.recovered(i)).where((v) => v).length} patterns restored',
|
||||||
|
size: 19,
|
||||||
|
color: muted,
|
||||||
|
),
|
||||||
|
action(
|
||||||
|
'Take the path to the harbour →',
|
||||||
|
crossToHarbour,
|
||||||
|
primary: true,
|
||||||
|
),
|
||||||
|
writing(
|
||||||
|
'Your unfinished patterns will wait here for you.',
|
||||||
|
size: 19,
|
||||||
|
color: muted,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return Leaf(
|
||||||
|
key: ValueKey('story-${g.storyIndex}'),
|
||||||
|
onTurn: (d) => turn(d),
|
||||||
|
body: column(body),
|
||||||
|
wideBody: wideBody,
|
||||||
|
footer: navigation(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void openLetter() {
|
||||||
|
unawaited(prefs.set('notebook_note_open', true));
|
||||||
|
_scheduleAutoplay();
|
||||||
|
refreshNotebook();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> inspect() async {
|
||||||
|
await prefs.set('notebook_handle_seen', true);
|
||||||
|
await message(
|
||||||
|
'A careful repair',
|
||||||
|
'The wire is hidden under a strip of cloth. In the margin, Gran has written: “The light matters. So do the hands carrying it.”',
|
||||||
|
close: 'Keep that thought',
|
||||||
|
);
|
||||||
|
if (mounted) refreshNotebook();
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-3
@@ -1,6 +1,9 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'translation.dart';
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
const ink = Color(0xff36413c),
|
const ink = Color(0xff36413c),
|
||||||
@@ -16,7 +19,7 @@ TextStyle hand(double size, {Color color = ink}) => TextStyle(
|
|||||||
);
|
);
|
||||||
Widget writing(String value, {double size = 23, Color color = ink}) => Padding(
|
Widget writing(String value, {double size = 23, Color color = ink}) => Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||||
child: Text(value, style: hand(size, color: color)),
|
child: CopyText(value, style: hand(size, color: color)),
|
||||||
);
|
);
|
||||||
|
|
||||||
class InkButton extends StatelessWidget {
|
class InkButton extends StatelessWidget {
|
||||||
@@ -49,7 +52,7 @@ class InkButton extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 8),
|
||||||
shape: const RoundedRectangleBorder(),
|
shape: const RoundedRectangleBorder(),
|
||||||
),
|
),
|
||||||
child: Text(label, textAlign: TextAlign.center),
|
child: CopyText(label, textAlign: TextAlign.center),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -241,7 +244,7 @@ class Cover extends StatelessWidget {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: Transform.rotate(
|
child: Transform.rotate(
|
||||||
angle: -.044,
|
angle: -.044,
|
||||||
child: Text(
|
child: CopyText(
|
||||||
'Mara’s\nisland notebook',
|
'Mara’s\nisland notebook',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: hand(28),
|
style: hand(28),
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../services/translation.dart';
|
||||||
|
|
||||||
|
Locale localeFromTag(String tag) {
|
||||||
|
final parts = tag.replaceAll('_', '-').split('-');
|
||||||
|
final script = parts.skip(1).where((p) => p.length == 4).firstOrNull;
|
||||||
|
final region = parts
|
||||||
|
.skip(1)
|
||||||
|
.where((p) => p.length == 2 || p.length == 3)
|
||||||
|
.firstOrNull;
|
||||||
|
return Locale.fromSubtags(
|
||||||
|
languageCode: parts.first.toLowerCase(),
|
||||||
|
scriptCode: script == null
|
||||||
|
? null
|
||||||
|
: '${script[0].toUpperCase()}${script.substring(1).toLowerCase()}',
|
||||||
|
countryCode: region?.toUpperCase(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class CopyScope extends InheritedWidget {
|
||||||
|
CopyScope({
|
||||||
|
super.key,
|
||||||
|
required this.catalog,
|
||||||
|
required this.language,
|
||||||
|
this.overrides = const {},
|
||||||
|
required super.child,
|
||||||
|
}) : translator = catalog.translator(language, overrides: overrides);
|
||||||
|
final TranslationCatalog catalog;
|
||||||
|
final MessageTranslator translator;
|
||||||
|
final String language;
|
||||||
|
final Map<String, String> overrides;
|
||||||
|
static String text(BuildContext context, String source) {
|
||||||
|
final scope = context.dependOnInheritedWidgetOfExactType<CopyScope>();
|
||||||
|
return scope?.translator.text(source) ?? source;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool updateShouldNotify(CopyScope old) =>
|
||||||
|
old.language != language ||
|
||||||
|
old.catalog != catalog ||
|
||||||
|
old.overrides != overrides;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CopyText extends StatelessWidget {
|
||||||
|
const CopyText(this.data, {super.key, this.style, this.textAlign});
|
||||||
|
final String data;
|
||||||
|
final TextStyle? style;
|
||||||
|
final TextAlign? textAlign;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final language = Localizations.maybeLocaleOf(context)?.languageCode ?? 'en';
|
||||||
|
final latin = const [
|
||||||
|
'en',
|
||||||
|
'de',
|
||||||
|
'fr',
|
||||||
|
'es',
|
||||||
|
'it',
|
||||||
|
'pt',
|
||||||
|
'nl',
|
||||||
|
'da',
|
||||||
|
'sv',
|
||||||
|
'no',
|
||||||
|
'fi',
|
||||||
|
].contains(language);
|
||||||
|
return Text(
|
||||||
|
CopyScope.text(context, data),
|
||||||
|
style: latin
|
||||||
|
? style
|
||||||
|
: (style ?? const TextStyle()).copyWith(fontFamily: 'sans-serif'),
|
||||||
|
textAlign: textAlign,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,11 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
|
flutter_localizations:
|
||||||
|
dependency: "direct main"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
shared_preferences: ^2.5.6
|
shared_preferences: ^2.5.6
|
||||||
google_mobile_ads: ^9.2.0
|
google_mobile_ads: ^9.2.0
|
||||||
just_audio: ^0.10.6
|
just_audio: ^0.10.6
|
||||||
@@ -21,6 +23,10 @@ dev_dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
assets:
|
assets:
|
||||||
|
- assets/library.json
|
||||||
|
- assets/locales/
|
||||||
|
- assets/stories/paper-boat/
|
||||||
|
- assets/stories/paper-boat/locales/
|
||||||
- assets/fonts/OFL.txt
|
- assets/fonts/OFL.txt
|
||||||
- assets/campaign.json
|
- assets/campaign.json
|
||||||
- assets/notebook.json
|
- assets/notebook.json
|
||||||
|
|||||||
@@ -0,0 +1,248 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:lumen/domain/game.dart';
|
||||||
|
import 'package:lumen/domain/library.dart';
|
||||||
|
import 'package:lumen/services/progress.dart';
|
||||||
|
|
||||||
|
import 'support/story_fixtures.dart';
|
||||||
|
|
||||||
|
class DelayedTranslationBundle extends FixtureBundle {
|
||||||
|
DelayedTranslationBundle(super.data);
|
||||||
|
final waiting = Completer<void>();
|
||||||
|
final started = Completer<void>();
|
||||||
|
@override
|
||||||
|
Future<ByteData> load(String key) async {
|
||||||
|
if (key == 'fixture/de.json') {
|
||||||
|
if (!started.isCompleted) started.complete();
|
||||||
|
await waiting.future;
|
||||||
|
}
|
||||||
|
return super.load(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
test(
|
||||||
|
'bundled library loads every language and keeps original Mara saves',
|
||||||
|
() async {
|
||||||
|
final library = await StoryLibrary.load();
|
||||||
|
expect(library.stories.map((s) => s.id), ['mara-island', 'paper-boat']);
|
||||||
|
for (final story in library.stories) {
|
||||||
|
for (final language in story.languages.keys) {
|
||||||
|
final book = await library.open(story.id, language: language);
|
||||||
|
expect(book.language, language);
|
||||||
|
expect(book.pages, isNotEmpty);
|
||||||
|
for (final level in book.levels) {
|
||||||
|
expect(level.puzzle().solution.length, level.size * level.size);
|
||||||
|
expect(
|
||||||
|
level.puzzle().countSolutions(),
|
||||||
|
1,
|
||||||
|
reason: '${story.id}: ${level.id}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final mara = await library.open('mara-island', language: 'de-DE');
|
||||||
|
expect(mara.language, 'en');
|
||||||
|
expect(mara.tracks, isNotEmpty);
|
||||||
|
final g = Game(
|
||||||
|
mara,
|
||||||
|
Progress.memory({
|
||||||
|
'done_story_v1_0': true,
|
||||||
|
'campaignUnlocked': 3,
|
||||||
|
'notebook_manual_bookmark': 'cottage.folded.note',
|
||||||
|
'notebook_last_page': 'cottage.window',
|
||||||
|
'flutter_screen': 'story',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await g.restore();
|
||||||
|
expect(g.recovered(0), true);
|
||||||
|
expect(g.storyPage.id, 'cottage.window');
|
||||||
|
expect(
|
||||||
|
g.progress.text('notebook_manual_bookmark'),
|
||||||
|
'cottage.folded.note',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('translations preserve identity and rules, fall back by field, and use their own narration', () async {
|
||||||
|
final library = StoryLibrary([
|
||||||
|
definition('fixture'),
|
||||||
|
], bundle: FixtureBundle(fixture()));
|
||||||
|
final en = await library.open('fixture');
|
||||||
|
final de = await library.open('fixture', language: 'de-AT');
|
||||||
|
expect(de.language, 'de');
|
||||||
|
expect(de.title, 'Eine Testgeschichte');
|
||||||
|
expect(de.pages.first.id, en.pages.first.id);
|
||||||
|
expect(de.levels.first.id, 'puzzle-0');
|
||||||
|
expect(de.levels.first.picture, en.levels.first.picture);
|
||||||
|
expect(de.levels.first.chapterId, 'first');
|
||||||
|
expect(de.pages.first.text, 'Vorher');
|
||||||
|
expect(de.pages.first.title, 'Ein Anfang');
|
||||||
|
expect(de.pages[2].text, en.pages[2].text);
|
||||||
|
expect(en.tracks, isNotEmpty);
|
||||||
|
expect(de.tracks, isEmpty);
|
||||||
|
expect((await library.open('fixture', language: 'it')).language, 'en');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('switching stories isolates marks, bookmarks and achievements; language keeps live undo', () async {
|
||||||
|
final library = StoryLibrary([
|
||||||
|
definition('first'),
|
||||||
|
definition('second'),
|
||||||
|
], bundle: FixtureBundle(fixture()));
|
||||||
|
final store = Progress.memory();
|
||||||
|
final g = Game(await library.open('first'), store, library: library);
|
||||||
|
g.startCampaign(0);
|
||||||
|
g.mark(0);
|
||||||
|
final firstMarks = List<int>.of(g.cells);
|
||||||
|
await g.progress.set('notebook_manual_bookmark', g.storyPage.id);
|
||||||
|
await g.selectLanguage('de');
|
||||||
|
expect(g.book.language, 'de');
|
||||||
|
expect(g.cells, firstMarks);
|
||||||
|
expect(g.canUndo, true);
|
||||||
|
expect(g.storyPage.id, 'puzzle-0');
|
||||||
|
expect(g.progress.text('notebook_manual_bookmark'), 'puzzle-0');
|
||||||
|
g.undo();
|
||||||
|
expect(g.cells.every((c) => c == 0), true);
|
||||||
|
g.mark(0);
|
||||||
|
await g.selectStory('second');
|
||||||
|
expect(g.book.language, 'de');
|
||||||
|
expect(g.progress.text('notebook_manual_bookmark'), isEmpty);
|
||||||
|
expect(g.recoveredCount, 0);
|
||||||
|
g.startCampaign(0);
|
||||||
|
expect(g.cells.every((c) => c == 0), true);
|
||||||
|
g.mark(1);
|
||||||
|
final secondMarks = List<int>.of(g.cells);
|
||||||
|
await g.selectStory('first');
|
||||||
|
expect(g.cells, firstMarks);
|
||||||
|
expect(g.progress.text('notebook_manual_bookmark'), 'puzzle-0');
|
||||||
|
await g.selectStory('second');
|
||||||
|
expect(g.cells, secondMarks);
|
||||||
|
final restarted = Game(
|
||||||
|
await library.open(
|
||||||
|
store.text('selected_story'),
|
||||||
|
language: store.text('language'),
|
||||||
|
),
|
||||||
|
Progress.memory(store.snapshot),
|
||||||
|
library: library,
|
||||||
|
);
|
||||||
|
await restarted.restore();
|
||||||
|
expect(restarted.book.id, 'second');
|
||||||
|
expect(restarted.book.language, 'de');
|
||||||
|
expect(restarted.cells, secondMarks);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('variable chapters and completing a new story award once and restore by stable keys', () async {
|
||||||
|
final library = StoryLibrary([
|
||||||
|
definition('fixture'),
|
||||||
|
], bundle: FixtureBundle(fixture()));
|
||||||
|
final g = Game(
|
||||||
|
await library.open('fixture'),
|
||||||
|
Progress.memory(),
|
||||||
|
library: library,
|
||||||
|
);
|
||||||
|
expect(g.book.chapterLevels(0), [0, 1]);
|
||||||
|
expect(g.book.chapterLevels(1), [2]);
|
||||||
|
for (var i = 0; i < 3; i++) {
|
||||||
|
g.startCampaign(i);
|
||||||
|
expect(g.storyPage.id, 'puzzle-$i');
|
||||||
|
for (var c = 0; c < g.cells.length; c++) {
|
||||||
|
while (g.cells[c] != (g.puzzle!.solution[c] == 1 ? 1 : 2)) {
|
||||||
|
g.mark(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect(g.storyPage.id, 'memory-$i');
|
||||||
|
expect(g.solved, i + 1);
|
||||||
|
g.check();
|
||||||
|
expect(g.solved, i + 1);
|
||||||
|
}
|
||||||
|
expect(g.recoveredCount, 3);
|
||||||
|
g.contents(1);
|
||||||
|
expect(g.contentsChapter, 1);
|
||||||
|
expect(g.book.puzzleKey(0), 'story_fixture_puzzle-0');
|
||||||
|
await g.selectLanguage('de');
|
||||||
|
expect(g.recoveredCount, 3);
|
||||||
|
g.leaveCottage(); // A standard book ends in its own contents.
|
||||||
|
expect(g.screen, Screen.contents);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'UI translations preserve values and prioritize the most specific template',
|
||||||
|
() async {
|
||||||
|
final catalog = (await StoryLibrary.load()).copy;
|
||||||
|
final tr = catalog.translator('de-DE');
|
||||||
|
expect(tr.text('Next leaf →'), 'Nächste Seite →');
|
||||||
|
expect(
|
||||||
|
tr.text('Open The paper boat · 0 / 1'),
|
||||||
|
'The paper boat öffnen · 0 / 1',
|
||||||
|
);
|
||||||
|
expect(tr.text('Row 2, column 3'), 'Zeile 2, Spalte 3');
|
||||||
|
expect(tr.text('Difficulty · Easy ▾'), 'Schwierigkeit · Einfach ▾');
|
||||||
|
expect(tr.text('An unknown message'), 'An unknown message');
|
||||||
|
expect(catalog.text('Close', 'ar'), 'Close');
|
||||||
|
expect(
|
||||||
|
catalog.text('Close', 'de', overrides: {'Close': 'Fertig'}),
|
||||||
|
'Fertig',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'reading into a new chapter unlocks reading access without achievements',
|
||||||
|
() async {
|
||||||
|
final library = StoryLibrary([
|
||||||
|
definition('fixture'),
|
||||||
|
], bundle: FixtureBundle(fixture()));
|
||||||
|
final g = Game(await library.open('fixture'), Progress.memory());
|
||||||
|
expect(g.accessible, 0);
|
||||||
|
g.showStory(6);
|
||||||
|
expect(g.accessible, 2);
|
||||||
|
expect(g.recoveredCount, 0);
|
||||||
|
expect(g.solved, 0);
|
||||||
|
g.contents();
|
||||||
|
expect(g.contentsChapter, 1);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('a late language load cannot replace a newer story selection', () async {
|
||||||
|
final bundle = DelayedTranslationBundle(fixture());
|
||||||
|
final library = StoryLibrary([
|
||||||
|
definition('first'),
|
||||||
|
definition('second'),
|
||||||
|
], bundle: bundle);
|
||||||
|
final g = Game(
|
||||||
|
await library.open('first'),
|
||||||
|
Progress.memory(),
|
||||||
|
library: library,
|
||||||
|
);
|
||||||
|
final oldLanguage = g.selectLanguage('de');
|
||||||
|
await bundle.started.future;
|
||||||
|
await g.selectStory('second');
|
||||||
|
bundle.waiting.complete();
|
||||||
|
await oldLanguage;
|
||||||
|
expect(g.book.id, 'second');
|
||||||
|
expect(g.book.language, 'en');
|
||||||
|
expect(g.languagePreference, 'system');
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'invalid page references and duplicate IDs fail while loading a package',
|
||||||
|
() async {
|
||||||
|
final data = fixture();
|
||||||
|
(data['fixture/notebook.json'] as Map)['pages'] = [
|
||||||
|
{'id': 'bad', 'title': 'Bad', 'type': 'puzzle', 'campaignIndex': 99},
|
||||||
|
];
|
||||||
|
final library = StoryLibrary([
|
||||||
|
definition('fixture'),
|
||||||
|
], bundle: FixtureBundle(data));
|
||||||
|
await expectLater(library.open('fixture'), throwsFormatException);
|
||||||
|
expect(
|
||||||
|
() => StoryLibrary([definition('same'), definition('same')]),
|
||||||
|
throwsFormatException,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:lumen/domain/game.dart';
|
||||||
|
import 'package:lumen/domain/library.dart';
|
||||||
|
import 'package:lumen/main.dart';
|
||||||
|
import 'package:lumen/services/progress.dart';
|
||||||
|
import 'package:lumen/services/translation.dart';
|
||||||
|
import 'package:lumen/ui/translation.dart';
|
||||||
|
|
||||||
|
import 'support/story_fixtures.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets(
|
||||||
|
'library and language controls open a translated story and preserve live marks',
|
||||||
|
(tester) async {
|
||||||
|
tester.view.physicalSize = const Size(600, 960);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
await tester.runAsync(() async {
|
||||||
|
final font = FontLoader('MaraHand')
|
||||||
|
..addFont(rootBundle.load('assets/fonts/DancingScript.ttf'));
|
||||||
|
await font.load();
|
||||||
|
});
|
||||||
|
final library = (await tester.runAsync(StoryLibrary.load))!;
|
||||||
|
for (final story in library.stories) {
|
||||||
|
for (final language in story.languages.keys) {
|
||||||
|
await tester.runAsync(
|
||||||
|
() => library.open(story.id, language: language),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final book = (await tester.runAsync(() => library.open('mara-island')))!;
|
||||||
|
final g = Game(book, Progress.memory(), library: library);
|
||||||
|
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
Future<void> tap(String text) async {
|
||||||
|
await tester.ensureVisible(find.text(text));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text(text));
|
||||||
|
await tester.runAsync(
|
||||||
|
() => Future<void>.delayed(const Duration(milliseconds: 20)),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
await tap('Story library');
|
||||||
|
await tap('The paper boat');
|
||||||
|
expect(g.book.id, 'paper-boat');
|
||||||
|
await tap('Open The paper boat · 0 / 1');
|
||||||
|
expect(g.storyPage.id, 'boat.entry');
|
||||||
|
await tap('Next leaf →');
|
||||||
|
await tester.ensureVisible(find.byKey(const ValueKey('cell-0')));
|
||||||
|
await tester.tap(find.byKey(const ValueKey('cell-0')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final marks = List<int>.of(g.cells);
|
||||||
|
await tap('Bookmark');
|
||||||
|
await tap('Language');
|
||||||
|
await tap('Deutsch');
|
||||||
|
expect(g.book.language, 'de');
|
||||||
|
expect(g.storyPage.id, 'boat.puzzle');
|
||||||
|
expect(g.cells, marks);
|
||||||
|
expect(g.canUndo, true);
|
||||||
|
expect(find.text('Eine kleine Überfahrt'), findsOneWidget);
|
||||||
|
expect(find.text('Nächste Seite →'), findsOneWidget);
|
||||||
|
expect(g.progress.text('notebook_manual_bookmark'), 'boat.puzzle');
|
||||||
|
await tap('Buch schließen');
|
||||||
|
await tap('Geschichtenbibliothek');
|
||||||
|
expect(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(AlertDialog),
|
||||||
|
matching: find.text('Das Papierboot'),
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
await tester.pumpWidget(const SizedBox());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'German story pages fit portrait and landscape with larger text',
|
||||||
|
(tester) async {
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
tester.platformDispatcher.textScaleFactorTestValue = 1.5;
|
||||||
|
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||||
|
final library = (await tester.runAsync(StoryLibrary.load))!;
|
||||||
|
final book = (await tester.runAsync(
|
||||||
|
() => library.open('paper-boat', language: 'de'),
|
||||||
|
))!;
|
||||||
|
for (final size in [const Size(360, 640), const Size(960, 600)]) {
|
||||||
|
tester.view.physicalSize = size;
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
final g = Game(
|
||||||
|
book,
|
||||||
|
Progress.memory({'language': 'de'}),
|
||||||
|
library: library,
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
for (var i = 0; i < book.pages.length; i++) {
|
||||||
|
g.showStory(i);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Sprache').hitTestable(), findsOneWidget);
|
||||||
|
expect(
|
||||||
|
find
|
||||||
|
.text(i == 2 ? 'Zum Inhaltsverzeichnis' : 'Nächste Seite →')
|
||||||
|
.hitTestable(),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
}
|
||||||
|
g.contents();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Eine kleine Überfahrt'), findsOneWidget);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
await tester.pumpWidget(const SizedBox());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
testWidgets('a right-to-left story uses RTL layout and a system font', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final data = fixture();
|
||||||
|
data['fixture/ar.json'] = {
|
||||||
|
'title': 'قصة قصيرة',
|
||||||
|
'pages': {
|
||||||
|
'entry-0': {'title': 'البداية', 'text': 'تبدأ الرحلة هنا.'},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
final original = definition('arabic');
|
||||||
|
original.languages['ar'] = {'label': 'العربية', 'asset': 'fixture/ar.json'};
|
||||||
|
final library = StoryLibrary(
|
||||||
|
[original],
|
||||||
|
bundle: FixtureBundle(data),
|
||||||
|
copy: const TranslationCatalog(
|
||||||
|
{'en': 'English', 'ar': 'العربية'},
|
||||||
|
{
|
||||||
|
'ar': {'Language': 'اللغة'},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final book = (await tester.runAsync(
|
||||||
|
() => library.open('arabic', language: 'ar'),
|
||||||
|
))!;
|
||||||
|
final g = Game(book, Progress.memory({'language': 'ar'}), library: library)
|
||||||
|
..showStory(0);
|
||||||
|
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final heading = find.text('البداية');
|
||||||
|
expect(Directionality.of(tester.element(heading)), TextDirection.rtl);
|
||||||
|
expect(tester.widget<Text>(heading).style?.fontFamily, 'sans-serif');
|
||||||
|
expect(find.text('اللغة'), findsOneWidget);
|
||||||
|
g.startCampaign(0);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
tester.getCenter(find.byKey(const ValueKey('cell-0'))).dx,
|
||||||
|
lessThan(tester.getCenter(find.byKey(const ValueKey('cell-4'))).dx),
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
expect(localeFromTag('zh-Hant-TW').scriptCode, 'Hant');
|
||||||
|
expect(localeFromTag('zh-Hant-TW').countryCode, 'TW');
|
||||||
|
await tester.pumpWidget(const SizedBox());
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:lumen/domain/library.dart';
|
||||||
|
|
||||||
|
class FixtureBundle extends CachingAssetBundle {
|
||||||
|
FixtureBundle(this.data);
|
||||||
|
final Map<String, Object> data;
|
||||||
|
@override
|
||||||
|
Future<ByteData> load(String key) async {
|
||||||
|
final value = data[key];
|
||||||
|
if (value == null) return rootBundle.load(key);
|
||||||
|
return ByteData.sublistView(
|
||||||
|
Uint8List.fromList(utf8.encode(jsonEncode(value))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StoryDefinition definition(String id) => StoryDefinition({
|
||||||
|
'id': id,
|
||||||
|
'title': 'A fixture story',
|
||||||
|
'defaultLanguage': 'en',
|
||||||
|
'campaignAsset': 'fixture/campaign.json',
|
||||||
|
'notebookAsset': 'fixture/notebook.json',
|
||||||
|
'tracksAsset': 'fixture/audio.json',
|
||||||
|
'languages': {
|
||||||
|
'en': {'label': 'English'},
|
||||||
|
'de': {'label': 'Deutsch', 'asset': 'fixture/de.json'},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, Object> fixture() => {
|
||||||
|
'fixture/campaign.json': {
|
||||||
|
'premise': 'A starting point.',
|
||||||
|
'levels': [
|
||||||
|
for (var i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
'id': 'puzzle-$i',
|
||||||
|
'size': 5,
|
||||||
|
'chapterId': i < 2 ? 'first' : 'second',
|
||||||
|
'chapter': i < 2 ? 'First chapter' : 'Second chapter',
|
||||||
|
'title': 'Puzzle $i',
|
||||||
|
'object': 'Object $i',
|
||||||
|
'before': 'Before $i',
|
||||||
|
'after': 'After $i',
|
||||||
|
'picture': '1000001000001000001000001',
|
||||||
|
'clues': '',
|
||||||
|
'areas': '',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'fixture/notebook.json': {
|
||||||
|
'pages': [
|
||||||
|
for (var i = 0; i < 3; i++) ...[
|
||||||
|
{
|
||||||
|
'id': 'entry-$i',
|
||||||
|
'type': 'entry',
|
||||||
|
'title': 'Entry $i',
|
||||||
|
'campaignIndex': i,
|
||||||
|
'textSource': 'before',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'puzzle-$i',
|
||||||
|
'type': 'puzzle',
|
||||||
|
'title': 'Puzzle $i',
|
||||||
|
'campaignIndex': i,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'memory-$i',
|
||||||
|
'type': 'memory',
|
||||||
|
'title': 'Memory $i',
|
||||||
|
'campaignIndex': i,
|
||||||
|
'textSource': 'after',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'fixture/audio.json': {
|
||||||
|
'tracks': {
|
||||||
|
'entry-0': {'file': 'english.wav'},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'fixture/de.json': {
|
||||||
|
'title': 'Eine Testgeschichte',
|
||||||
|
'levels': {
|
||||||
|
'puzzle-0': {
|
||||||
|
'title': 'Ein Muster', 'before': 'Vorher',
|
||||||
|
// Translation records cannot replace the puzzle or its identity.
|
||||||
|
'id': 'tampered', 'picture': '0000', 'chapterId': 'tampered',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'pages': {
|
||||||
|
'entry-0': {'title': 'Ein Anfang', 'id': 'tampered'},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user