Complete cottage notebook with narration and discovery-only artwork
This commit is contained in:
+188
-103
@@ -167,9 +167,14 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
Future<void> turn(int direction) async {
|
||||
final next = (g.storyIndex + direction).clamp(0, 5);
|
||||
if (direction > 0 && g.storyIndex == g.book.pages.length - 1) {
|
||||
crossToHarbour();
|
||||
return;
|
||||
}
|
||||
final next = (g.storyIndex + direction).clamp(0, g.book.pages.length - 1);
|
||||
if (next == g.storyIndex) return;
|
||||
if (g.storyIndex == 2 && direction > 0 && !g.won) {
|
||||
final pageId = g.storyPage.id;
|
||||
if (g.storyPage.type == StoryPageType.puzzle && direction > 0 && !g.won) {
|
||||
unawaited(narrator.stop());
|
||||
if (!await confirm(
|
||||
'Leave a ribbon here?',
|
||||
@@ -181,7 +186,11 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
}
|
||||
await prefs.set('notebook_read_ahead', true);
|
||||
}
|
||||
g.showStory(next);
|
||||
if (mounted && g.storyPage.id == pageId) g.showStory(next);
|
||||
}
|
||||
|
||||
void crossToHarbour() {
|
||||
g.leaveCottage();
|
||||
}
|
||||
|
||||
Future<void> turnCampaign(int direction) async {
|
||||
@@ -191,7 +200,11 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
if (direction > 0) {
|
||||
g.startCampaign(index);
|
||||
} else if (index > 0) {
|
||||
g.reveal(index - 1, readAhead: true);
|
||||
if (index == 4) {
|
||||
g.showStory(g.book.pages.length - 1);
|
||||
} else {
|
||||
g.reveal(index - 1, readAhead: true);
|
||||
}
|
||||
} else {
|
||||
g.contents();
|
||||
}
|
||||
@@ -435,8 +448,10 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
size: wide ? 19 : 21,
|
||||
);
|
||||
final next = InkButton(
|
||||
g.storyIndex == 5 ? 'End of this trail' : 'Next leaf →',
|
||||
g.storyIndex < 5 ? () => turn(1) : null,
|
||||
g.storyIndex == g.book.pages.length - 1
|
||||
? 'Across the tide →'
|
||||
: 'Next leaf →',
|
||||
() => turn(1),
|
||||
size: wide ? 19 : 21,
|
||||
);
|
||||
if (wide) {
|
||||
@@ -476,7 +491,11 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
]);
|
||||
}
|
||||
|
||||
Widget reading(String text) => ListenableBuilder(
|
||||
String get recordingId => g.screen == Screen.story
|
||||
? g.storyPage.id
|
||||
: 'campaign.${g.campaignIndex}.${g.screen == Screen.briefing ? 'before' : 'after'}';
|
||||
|
||||
Widget reading(String text, {double? size}) => ListenableBuilder(
|
||||
listenable: narrator,
|
||||
builder: (context, _) {
|
||||
final passage = narrator.passage,
|
||||
@@ -485,7 +504,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
style: hand(g.storyIndex == 0 ? 22 : 21),
|
||||
style: hand(size ?? (g.storyIndex == 0 ? 22 : 21)),
|
||||
children: index < 0
|
||||
? [TextSpan(text: text)]
|
||||
: [
|
||||
@@ -506,6 +525,13 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
Widget audio() => ListenableBuilder(
|
||||
listenable: narrator,
|
||||
builder: (context, _) => column([
|
||||
writing(
|
||||
g.book.tracks[recordingId]?['speaker'] == 'Narrator'
|
||||
? 'Narrator · recorded story'
|
||||
: 'Mara · diary reading',
|
||||
size: 17,
|
||||
color: muted,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -515,7 +541,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
narrator.loading
|
||||
? null
|
||||
: () => narrator.toggle(
|
||||
g.book.pages[g.storyIndex].id,
|
||||
recordingId,
|
||||
prefs.decimal('recording_speed'),
|
||||
),
|
||||
size: 21,
|
||||
@@ -530,53 +556,42 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
writing(narrator.status, size: 17, color: muted),
|
||||
]),
|
||||
);
|
||||
Widget illustration(
|
||||
String asset,
|
||||
String description, {
|
||||
VoidCallback? onTap,
|
||||
}) => Semantics(
|
||||
image: true,
|
||||
button: onTap != null,
|
||||
label: description,
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Image.asset(
|
||||
'assets/artwork/$asset',
|
||||
height: 155,
|
||||
fit: BoxFit.contain,
|
||||
excludeFromSemantics: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
Widget story() {
|
||||
final p = g.book.pages[g.storyIndex];
|
||||
final heading = <Widget>[
|
||||
folio('MARA’S NOTEBOOK / ${g.storyIndex + 1} OF 6'),
|
||||
folio('THE COTTAGE / ${g.storyIndex + 1} OF ${g.book.pages.length}'),
|
||||
writing(p.title, size: 31),
|
||||
];
|
||||
final body = <Widget>[...heading];
|
||||
Widget? wideBody;
|
||||
switch (g.storyIndex) {
|
||||
case 0:
|
||||
switch (p.type) {
|
||||
case StoryPageType.dedication:
|
||||
body.addAll([
|
||||
writing('A few things worth keeping', size: 20, color: muted),
|
||||
divider(),
|
||||
reading(p.text),
|
||||
audio(),
|
||||
]);
|
||||
case 1:
|
||||
case StoryPageType.entry:
|
||||
body.addAll([
|
||||
illustration(
|
||||
'cottage-vignette-v1.png',
|
||||
'Watercolour of Gran’s stone cottage, blue door and warm window.',
|
||||
),
|
||||
writing('A note beside the window · Mara', size: 17, color: muted),
|
||||
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),
|
||||
audio(),
|
||||
if (g.book.tracks.containsKey(p.id)) audio(),
|
||||
if (p.campaignIndex != 0)
|
||||
action('Turn to the pattern →', () => turn(1)),
|
||||
]);
|
||||
case 2:
|
||||
case StoryPageType.puzzle:
|
||||
final intro = writing(
|
||||
'Restore a small light, or leave a bookmark and read on.',
|
||||
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,
|
||||
);
|
||||
@@ -584,20 +599,27 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
wideBody = splitPuzzle(
|
||||
side: [...heading, intro, areaPicker(), ...puzzleNotes()],
|
||||
);
|
||||
case 3:
|
||||
case StoryPageType.memory:
|
||||
body.addAll([
|
||||
discoveryArt(g.book.levels.first, height: 155),
|
||||
discoveryArt(g.book.levels[p.campaignIndex!], height: 155),
|
||||
writing(
|
||||
g.recovered(0)
|
||||
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),
|
||||
audio(),
|
||||
if (g.book.tracks.containsKey(p.id)) audio(),
|
||||
if (!g.recovered(p.campaignIndex!))
|
||||
action(
|
||||
'Return to this pattern',
|
||||
() => g.showStory(
|
||||
g.book.pageFor(p.campaignIndex!, StoryPageType.puzzle),
|
||||
),
|
||||
),
|
||||
]);
|
||||
case 4:
|
||||
case StoryPageType.note:
|
||||
if (!prefs.flag('notebook_note_open')) {
|
||||
body.addAll([
|
||||
writing('A folded scrap, tucked between the leaves.'),
|
||||
@@ -628,31 +650,39 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
}),
|
||||
]);
|
||||
}
|
||||
case 5:
|
||||
case StoryPageType.inspection:
|
||||
body.addAll([
|
||||
illustration(
|
||||
'lantern-vignette-v1.png',
|
||||
'Watercolour of Mara’s blue storm lantern. Tap to examine the repaired handle.',
|
||||
onTap: inspect,
|
||||
),
|
||||
writing(
|
||||
prefs.flag('notebook_handle_seen')
|
||||
? 'A repair made to keep small fingers safe.'
|
||||
: 'Tap the lantern to look a little closer.',
|
||||
: 'A repair note, tucked into the margin.',
|
||||
size: 20,
|
||||
color: muted,
|
||||
),
|
||||
reading(p.text),
|
||||
audio(),
|
||||
action('Follow the lantern into the next entry →', () {
|
||||
unawaited(
|
||||
prefs.set(
|
||||
'story_access_level',
|
||||
g.accessible < 1 ? 1 : g.accessible,
|
||||
),
|
||||
);
|
||||
g.briefing(1);
|
||||
}),
|
||||
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(
|
||||
@@ -704,42 +734,36 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
);
|
||||
}
|
||||
|
||||
Widget contents() => Leaf(
|
||||
key: const ValueKey('contents'),
|
||||
body: column([
|
||||
folio('THE NOTEBOOK BELONGS TO'),
|
||||
writing('Mara Wren', size: 40),
|
||||
writing('The Last Light', size: 33),
|
||||
writing(
|
||||
'For you, when you are ready.\nWith all my love, Gran.',
|
||||
color: const Color(0xff70503b),
|
||||
),
|
||||
divider(),
|
||||
folio('THE COTTAGE · OPENING LEAVES'),
|
||||
for (var i = 0; i < 6; i++)
|
||||
action('${i + 1} · ${g.book.pages[i].title}', () => g.showStory(i)),
|
||||
action('Return to my ribbon bookmark', () {
|
||||
final i = g.book.pages.indexWhere(
|
||||
(p) => p.id == prefs.text('notebook_manual_bookmark'),
|
||||
);
|
||||
g.showStory(i < 0 ? 0 : i);
|
||||
}),
|
||||
divider(),
|
||||
writing(g.book.premise),
|
||||
writing(
|
||||
'${g.recoveredCount} / 12 memories tucked between these pages',
|
||||
size: 20,
|
||||
color: muted,
|
||||
),
|
||||
for (var i = 0; i < 12; i++) ...[
|
||||
if (i % 4 == 0) ...[
|
||||
gap(24),
|
||||
writing(g.book.levels[i].chapter, size: 28, color: blue),
|
||||
Widget contents() {
|
||||
final chapter = g.contentsChapter;
|
||||
final first = chapter * 4;
|
||||
final savedId = prefs.text('notebook_last_page');
|
||||
final saved = g.book.pages.where((p) => p.id == savedId).firstOrNull;
|
||||
final bookmarkId = prefs.text('notebook_manual_bookmark');
|
||||
final ribbon = g.book.pages.where((p) => p.id == bookmarkId).firstOrNull;
|
||||
return Leaf(
|
||||
key: ValueKey('contents-$chapter'),
|
||||
body: column([
|
||||
folio('MARA’S NOTEBOOK · CONTENTS'),
|
||||
writing(g.book.levels[first].chapter, size: 34),
|
||||
if (chapter == 0) ...[
|
||||
writing(
|
||||
'For you, when you are ready. With all my love, Gran.',
|
||||
color: const Color(0xff70503b),
|
||||
),
|
||||
action('Open the dedication', () => g.showStory(0)),
|
||||
if (saved != null)
|
||||
action('Continue reading · ${saved.title}', g.openNotebook),
|
||||
if (ribbon != null)
|
||||
action(
|
||||
'Return to my ribbon bookmark',
|
||||
() => g.showStory(g.book.pages.indexOf(ribbon)),
|
||||
),
|
||||
divider(),
|
||||
],
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: InkButton(
|
||||
'${(i + 1).toString().padLeft(2, '0')} · ${g.recovered(i) ? '${g.book.levels[i].object} ✓' : g.book.levels[i].title}${i > g.accessible ? ' · not yet' : ''}',
|
||||
for (var i = first; i < first + 4; i++) ...[
|
||||
InkButton(
|
||||
'${i + 1} · ${g.book.levels[i].title}${g.recovered(i) ? ' ✓' : ''}${chapter == 0 && ribbon?.campaignIndex == i ? ' · ribbon' : ''}',
|
||||
i <= g.accessible
|
||||
? () {
|
||||
if (g.recovered(i)) {
|
||||
@@ -750,11 +774,48 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
}
|
||||
: null,
|
||||
),
|
||||
],
|
||||
if (chapter == 0) ...[
|
||||
divider(),
|
||||
action('The folded note', () => g.showStory(4)),
|
||||
action('Gran’s repair note', () => g.showStory(5)),
|
||||
action(
|
||||
'Before you leave',
|
||||
() => g.showStory(g.book.pages.length - 1),
|
||||
),
|
||||
],
|
||||
writing(
|
||||
'${g.recoveredCount} / 12 memories restored',
|
||||
size: 20,
|
||||
color: muted,
|
||||
),
|
||||
],
|
||||
action('Close the notebook', g.home),
|
||||
]),
|
||||
);
|
||||
]),
|
||||
footer: column([
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: InkButton(
|
||||
'← Previous chapter',
|
||||
chapter > 0 ? () => g.contents(chapter - 1) : null,
|
||||
size: 19,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: InkButton(
|
||||
'Next chapter →',
|
||||
chapter < 2 && (chapter + 1) * 4 <= g.accessible
|
||||
? () => g.contents(chapter + 1)
|
||||
: null,
|
||||
size: 19,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
InkButton('Close the notebook', g.home, size: 19),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget briefing() {
|
||||
final l = g.book.levels[g.campaignIndex];
|
||||
return Leaf(
|
||||
@@ -765,7 +826,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
writing(l.chapter, size: 20, color: blue),
|
||||
writing(l.title, size: 33),
|
||||
gap(),
|
||||
writing(l.before, size: 25),
|
||||
reading(l.before, size: 25),
|
||||
if (g.book.tracks.containsKey(recordingId)) audio(),
|
||||
divider(),
|
||||
writing(
|
||||
g.campaignIndex < 2
|
||||
@@ -987,7 +1049,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
g.key != requested ||
|
||||
g.won ||
|
||||
!(g.screen == Screen.game ||
|
||||
g.screen == Screen.story && g.storyIndex == 2)) {
|
||||
g.screen == Screen.story &&
|
||||
g.storyPage.type == StoryPageType.puzzle)) {
|
||||
return;
|
||||
}
|
||||
final h = g.applyHint();
|
||||
@@ -996,7 +1059,13 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
'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.'}',
|
||||
);
|
||||
if (mounted && g.key == requested) g.check();
|
||||
if (mounted &&
|
||||
g.key == requested &&
|
||||
(g.screen == Screen.game ||
|
||||
g.screen == Screen.story &&
|
||||
g.storyPage.type == StoryPageType.puzzle)) {
|
||||
g.check();
|
||||
}
|
||||
}
|
||||
|
||||
if (!prefs.flag('hint_$requested')) {
|
||||
@@ -1027,6 +1096,19 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
Widget discoveryArt(CampaignLevel level, {double height = 190}) {
|
||||
// Discovery images belong only to the leaf after the puzzle, even when
|
||||
// revisiting an earlier page with a completed save.
|
||||
if (!(g.screen == Screen.reveal ||
|
||||
g.screen == Screen.story && g.storyPage.type == StoryPageType.memory)) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
if (!g.recovered(g.book.levels.indexOf(level))) {
|
||||
return writing(
|
||||
'The picture will appear once you restore the pattern.',
|
||||
size: 19,
|
||||
color: muted,
|
||||
);
|
||||
}
|
||||
if (level.illustrationAsset case final asset?) {
|
||||
return Image.asset(
|
||||
asset,
|
||||
@@ -1057,7 +1139,10 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
),
|
||||
writing(l.object, size: 35),
|
||||
discoveryArt(l),
|
||||
writing(l.after, size: 25),
|
||||
reading(l.after, size: 25),
|
||||
if (g.book.tracks.containsKey(recordingId)) audio(),
|
||||
if (!g.recovered(i))
|
||||
action('Return to this pattern', () => g.startCampaign(i)),
|
||||
gap(),
|
||||
writing(
|
||||
g.recovered(i)
|
||||
|
||||
Reference in New Issue
Block a user