Expand Lumen stories and add island postcards
This commit is contained in:
+141
-10
@@ -19,6 +19,10 @@ import 'services/translation.dart';
|
||||
import 'domain/book.dart';
|
||||
import 'domain/game.dart';
|
||||
import 'domain/puzzle.dart';
|
||||
import 'domain/postcards.dart';
|
||||
import 'services/ad_pacing.dart';
|
||||
import 'services/play_metrics.dart';
|
||||
import 'ui/postcards.dart';
|
||||
import 'services/ads.dart';
|
||||
import 'services/ambience.dart';
|
||||
import 'services/narrator.dart';
|
||||
@@ -204,6 +208,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
late final Narrator narrator;
|
||||
late final Ambience ambience;
|
||||
late final Ads ads;
|
||||
late final PlayMetrics metrics;
|
||||
bool _foreground = true;
|
||||
String _route = '';
|
||||
Future<List<Book>>? _shelf;
|
||||
@@ -217,7 +222,14 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
narrator = widget.narrator ?? Narrator(g.book.tracks);
|
||||
ambience = widget.ambience ?? Ambience();
|
||||
narrator.addListener(_syncAtmosphere);
|
||||
ads = widget.ads ?? Ads(enabled: widget.adsEnabled);
|
||||
metrics = PlayMetrics(g.store)..visit();
|
||||
ads =
|
||||
widget.ads ??
|
||||
Ads(
|
||||
enabled: widget.adsEnabled,
|
||||
pacing: AdPacing(g.store),
|
||||
metrics: metrics,
|
||||
);
|
||||
g.addListener(_changed);
|
||||
_route = route;
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
@@ -299,8 +311,11 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
_foreground = state == AppLifecycleState.resumed;
|
||||
ads.foreground = _foreground;
|
||||
if (_foreground) metrics.visit();
|
||||
_syncAtmosphere();
|
||||
if (state != AppLifecycleState.resumed) {
|
||||
metrics.endVisit();
|
||||
unawaited(narrator.stop());
|
||||
unawaited(prefs.flushed);
|
||||
}
|
||||
@@ -482,6 +497,20 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
void back() {
|
||||
if (g.screen == Screen.postcards) {
|
||||
g.library == null ? g.home() : g.showLibrary();
|
||||
return;
|
||||
}
|
||||
if (g.screen == Screen.game && g.mode == Mode.postcard) {
|
||||
g.showPostcards();
|
||||
return;
|
||||
}
|
||||
if (g.screen == Screen.game &&
|
||||
g.mode != Mode.campaign &&
|
||||
g.library != null) {
|
||||
g.showLibrary();
|
||||
return;
|
||||
}
|
||||
if (g.busy) {
|
||||
g.home();
|
||||
return;
|
||||
@@ -519,6 +548,12 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
Screen.briefing => briefing(),
|
||||
Screen.game => game(),
|
||||
Screen.reveal => reveal(),
|
||||
Screen.postcards => PostcardCollectionView(
|
||||
game: g,
|
||||
onBack: back,
|
||||
onOpen: g.startPostcard,
|
||||
onRead: (index) => unawaited(readPostcard(index)),
|
||||
),
|
||||
},
|
||||
if (g.busy)
|
||||
Positioned.fill(
|
||||
@@ -583,6 +618,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
return LibraryShelf(
|
||||
key: const ValueKey('library'),
|
||||
onSettings: settings,
|
||||
activities: ShelfActivities(game: g, onPostcards: g.showPostcards),
|
||||
builder: (context, width) => FutureBuilder<List<Book>>(
|
||||
future: shelfBooks(catalogue),
|
||||
builder: (context, snapshot) {
|
||||
@@ -792,6 +828,7 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
),
|
||||
divider(),
|
||||
folio('A SMALL DAILY RITUAL'),
|
||||
action('Island postcards', g.showPostcards),
|
||||
writing(
|
||||
DateFormat(
|
||||
'EEEE, d MMMM',
|
||||
@@ -851,6 +888,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
('Sound & atmosphere', soundSettings),
|
||||
('Recording speed', speed),
|
||||
('Privacy & advertising', privacy),
|
||||
if (kDebugMode || appFlavor == 'qa' || appFlavor == 'check')
|
||||
('Playtest report', playtestReport),
|
||||
])
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
@@ -863,6 +902,69 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
),
|
||||
);
|
||||
|
||||
Future<void> playtestReport() => showDialog<void>(
|
||||
context: context,
|
||||
builder: (c) => AlertDialog(
|
||||
title: const Text('Local playtest report'),
|
||||
content: SingleChildScrollView(child: SelectableText(metrics.export())),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await Clipboard.setData(ClipboardData(text: metrics.export()));
|
||||
if (c.mounted) Navigator.pop(c);
|
||||
},
|
||||
child: const Text('Copy report'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(c),
|
||||
child: const Text('Close'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Future<void> readPostcard(int index, {bool completedNow = false}) async {
|
||||
if (g.postcardSolved(index) != 3) return;
|
||||
final card = islandPostcards[index];
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(c, true),
|
||||
child: const CopyText('Keep this postcard'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (kept != true ||
|
||||
!mounted ||
|
||||
!completedNow ||
|
||||
g.mode != Mode.postcard ||
|
||||
g.postcardIndex != index ||
|
||||
g.screen != Screen.game) {
|
||||
return;
|
||||
}
|
||||
if (g.claimPostcardBreak()) {
|
||||
await ads.between(() {
|
||||
if (mounted) g.showPostcards();
|
||||
});
|
||||
} else {
|
||||
g.showPostcards();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> chooseLanguage() async {
|
||||
narrator.cancelAutoplay();
|
||||
final catalogue = g.library;
|
||||
@@ -1407,6 +1509,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
folio(
|
||||
g.mode == Mode.daily
|
||||
? 'DAILY / ${DateFormat('d MMMM', Localizations.localeOf(context).languageCode).format(g.date)}'
|
||||
: g.mode == Mode.postcard
|
||||
? 'POSTCARD / ${g.postcardIndex + 1} / PATTERN ${g.postcardSlot + 1} OF 3'
|
||||
: g.mode == Mode.campaign
|
||||
? '${g.book.title.toUpperCase()} / ${g.campaignIndex + 1} OF ${g.book.levels.length}'
|
||||
: 'CLASSIC / ${g.difficulty.label} / LEVEL ${g.playingLevel}',
|
||||
@@ -1414,6 +1518,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
writing(
|
||||
g.mode == Mode.campaign
|
||||
? g.book.levels[g.campaignIndex].title
|
||||
: g.mode == Mode.postcard
|
||||
? g.postcard.title
|
||||
: 'Find the light.',
|
||||
size: compact ? 27 : 32,
|
||||
),
|
||||
@@ -1428,13 +1534,21 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
final actions = <({String label, VoidCallback run, bool primary})>[
|
||||
if (g.won)
|
||||
(
|
||||
label: g.mode == Mode.daily
|
||||
? 'Return to the notebook'
|
||||
label: g.mode == Mode.postcard
|
||||
? (g.postcardSolved(g.postcardIndex) == 3
|
||||
? 'Read your postcard'
|
||||
: 'Next pattern →')
|
||||
: g.mode == Mode.daily
|
||||
? (g.library == null
|
||||
? 'Return to the notebook'
|
||||
: 'Back to the shelf')
|
||||
: g.mode == Mode.campaign
|
||||
? 'Revisit the memory →'
|
||||
: 'Next puzzle →',
|
||||
run: g.mode == Mode.daily
|
||||
? g.home
|
||||
run: g.mode == Mode.postcard
|
||||
? nextPostcard
|
||||
: g.mode == Mode.daily
|
||||
? back
|
||||
: g.mode == Mode.campaign
|
||||
? () => g.reveal(g.campaignIndex)
|
||||
: nextPractice,
|
||||
@@ -1442,8 +1556,16 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
),
|
||||
(label: 'How to play', run: rules, primary: false),
|
||||
(
|
||||
label: 'Back to notebook',
|
||||
run: g.mode == Mode.campaign ? g.contents : g.home,
|
||||
label: g.mode == Mode.postcard
|
||||
? 'Back to postcards'
|
||||
: g.mode != Mode.campaign && g.library != null
|
||||
? 'Back to the shelf'
|
||||
: 'Back to notebook',
|
||||
run: g.mode == Mode.postcard
|
||||
? g.showPostcards
|
||||
: g.mode == Mode.campaign
|
||||
? g.contents
|
||||
: back,
|
||||
primary: false,
|
||||
),
|
||||
];
|
||||
@@ -1558,14 +1680,23 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
void nextPractice() {
|
||||
final n = prefs.number('practiceCompleted');
|
||||
if (n > 0 && n % 4 == 0) {
|
||||
ads.between(() => unawaited(g.startPractice()));
|
||||
if (g.claimPracticeBreak()) {
|
||||
ads.between(() {
|
||||
if (mounted) unawaited(g.startPractice());
|
||||
});
|
||||
} else {
|
||||
unawaited(g.startPractice());
|
||||
}
|
||||
}
|
||||
|
||||
void nextPostcard() {
|
||||
if (g.postcardSolved(g.postcardIndex) == 3) {
|
||||
unawaited(readPostcard(g.postcardIndex, completedNow: true));
|
||||
} else {
|
||||
g.startPostcard(g.postcardIndex);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user