Enhance postcard puzzles and narration
This commit is contained in:
+142
-10
@@ -206,6 +206,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
Game get g => widget.game;
|
||||
Progress get prefs => g.progress;
|
||||
late final Narrator narrator;
|
||||
late final Narrator postcardNarrator;
|
||||
late final Ambience ambience;
|
||||
late final Ads ads;
|
||||
late final PlayMetrics metrics;
|
||||
@@ -220,6 +221,10 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
super.initState();
|
||||
unawaited(initializeDateFormatting());
|
||||
narrator = widget.narrator ?? Narrator(g.book.tracks);
|
||||
postcardNarrator = Narrator({
|
||||
for (final card in islandPostcards)
|
||||
card.id: {'asset': 'assets/postcards/audio/${card.id}.wav'},
|
||||
});
|
||||
ambience = widget.ambience ?? Ambience();
|
||||
narrator.addListener(_syncAtmosphere);
|
||||
metrics = PlayMetrics(g.store)..visit();
|
||||
@@ -247,6 +252,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
if (_route != route) {
|
||||
_route = route;
|
||||
unawaited(narrator.stop());
|
||||
unawaited(postcardNarrator.stop());
|
||||
_scheduleAutoplay();
|
||||
}
|
||||
_syncAtmosphere();
|
||||
@@ -317,6 +323,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
if (state != AppLifecycleState.resumed) {
|
||||
metrics.endVisit();
|
||||
unawaited(narrator.stop());
|
||||
unawaited(postcardNarrator.stop());
|
||||
unawaited(prefs.flushed);
|
||||
}
|
||||
}
|
||||
@@ -328,6 +335,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
narrator.removeListener(_syncAtmosphere);
|
||||
ambience.dispose();
|
||||
narrator.dispose();
|
||||
postcardNarrator.dispose();
|
||||
ads.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -926,18 +934,96 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
Future<void> readPostcard(int index, {bool completedNow = false}) async {
|
||||
if (g.postcardSolved(index) != 3) return;
|
||||
final card = islandPostcards[index];
|
||||
postcardNarrator.scheduleAutoplay(
|
||||
card.id,
|
||||
prefs.decimal('recording_speed'),
|
||||
);
|
||||
final kept = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (c) => AlertDialog(
|
||||
title: Text(card.title),
|
||||
content: SingleChildScrollView(
|
||||
child: Text(
|
||||
card.message,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'serif',
|
||||
fontSize: 21,
|
||||
height: 1.5,
|
||||
backgroundColor: const Color(0xfffffbef),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
side: const BorderSide(color: Color(0xffc8b797)),
|
||||
),
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'P O S T C A R D',
|
||||
style: TextStyle(
|
||||
fontFamily: 'sans-serif',
|
||||
fontSize: 13,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 48,
|
||||
height: 54,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: const Color(0xffa78361),
|
||||
width: 2,
|
||||
),
|
||||
color: const Color(0xffdbe7df),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.light_mode_outlined,
|
||||
color: Color(0xff8a6a4f),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(card.title),
|
||||
],
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AnimatedBuilder(
|
||||
animation: postcardNarrator,
|
||||
builder: (context, _) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
postcardNarrator.status,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'sans-serif',
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
TextButton.icon(
|
||||
key: const ValueKey('postcard-play'),
|
||||
onPressed: () => unawaited(
|
||||
postcardNarrator.toggle(
|
||||
card.id,
|
||||
prefs.decimal('recording_speed'),
|
||||
),
|
||||
),
|
||||
icon: Icon(
|
||||
postcardNarrator.playing
|
||||
? Icons.pause
|
||||
: Icons.play_arrow,
|
||||
),
|
||||
label: CopyText(postcardNarrator.label),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
SelectableText(
|
||||
card.message,
|
||||
key: const ValueKey('postcard-message'),
|
||||
style: hand(25).copyWith(height: 1.4),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
@@ -948,8 +1034,30 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
],
|
||||
),
|
||||
);
|
||||
if (kept != true ||
|
||||
!mounted ||
|
||||
await postcardNarrator.stop();
|
||||
if (kept != true || !mounted) return;
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (c) => AlertDialog(
|
||||
key: const ValueKey('postcard-reveal'),
|
||||
backgroundColor: const Color(0xfffffbef),
|
||||
title: Text(card.title, style: hand(28)),
|
||||
content: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1.7,
|
||||
child: PostcardRevealArt(card: card),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(c),
|
||||
child: const CopyText('Back to collection'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (!mounted ||
|
||||
!completedNow ||
|
||||
g.mode != Mode.postcard ||
|
||||
g.postcardIndex != index ||
|
||||
@@ -1425,6 +1533,30 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
List<Widget> puzzleNotes() => [
|
||||
if (g.puzzle?.footprintTrails.isNotEmpty ?? false)
|
||||
writing(
|
||||
'Footprints: exactly two marked cells are lit, and they touch.',
|
||||
size: 19,
|
||||
color: regionInk,
|
||||
),
|
||||
if (g.puzzle?.mirrorPairs.isNotEmpty ?? false)
|
||||
writing(
|
||||
'Matching stars are mirrored: both cells match.',
|
||||
size: 19,
|
||||
color: regionInk,
|
||||
),
|
||||
if (g.puzzle?.hiddenRow case final row?)
|
||||
writing(
|
||||
'Row ${row + 1} has one more light than row $row.',
|
||||
size: 19,
|
||||
color: regionInk,
|
||||
),
|
||||
if (g.puzzle?.lanternPairs.isNotEmpty ?? false)
|
||||
writing(
|
||||
'Matching lanterns: exactly one of the two cells is lit.',
|
||||
size: 19,
|
||||
color: regionInk,
|
||||
),
|
||||
if (g.mode == Mode.campaign)
|
||||
InkButton('Sound & atmosphere', soundSettings, size: 18),
|
||||
writing(
|
||||
|
||||
Reference in New Issue
Block a user