Open Lumen on a responsive bookshelf and land pending story work

- Start the app on a shelf of every installed book instead of the last
  book's home. Cards show the cover, translated metadata, available
  languages, restored patterns and either "Continue reading" or a way in.
- Keep each book's saved route: the shelf is never written to
  flutter_screen, so choosing a book resumes its own leaf.
- Lay the shelf out responsively: dense single-column cards on phones,
  a two-column grid from 720 logical pixels, a centred 860 px column on
  tablets and a chevron that exists in the bundled handwriting font.
- Keep Settings reachable from the shelf and let the home page's story
  library button open the shelf instead of a dialog.
- Add tool/shelf_screenshots_test.dart, which renders the shelf at phone
  and tablet metrics, checks that every card and Settings stay reachable
  without overflow, and writes artifacts/library/shelf-*.png.
- Commit the pending Midnight Invitation package (campaign, notebook,
  narration and artwork), cast drama and ambience tooling, region
  selection, phone/tablet integration coverage and related docs.

flutter analyze is clean and all 74 widget/domain tests pass.
This commit is contained in:
Hadrian Burkhardt
2026-11-05 14:29:50 +01:00
parent d45cd0698a
commit 0718e3f252
149 changed files with 16875 additions and 393 deletions
+24 -1
View File
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'puzzle.dart';
import 'library.dart';
import 'soundscape.dart';
class CampaignLevel {
CampaignLevel(Map<String, dynamic> data)
@@ -97,13 +98,15 @@ class Book {
this.defaultLanguage = 'en',
this.presentation = 'mara',
this.coverAsset = 'assets/artwork/home-notebook-cover-v2.png',
this.paperAsset,
this.continueAt = 4,
this.initiallyAccessible = 3,
this.fontFamily = 'MaraHand',
this.copy = const {},
this.atmosphere = const {},
});
final String id, title, description, language, defaultLanguage, presentation;
final String? coverAsset, fontFamily;
final String? coverAsset, paperAsset, fontFamily;
final int? continueAt;
final int initiallyAccessible;
final Map<String, String> copy;
@@ -111,6 +114,7 @@ class Book {
final List<CampaignLevel> levels;
final List<StoryPage> pages;
final Map<String, dynamic> tracks;
final Map<String, Soundscape> atmosphere;
bool get isMara => presentation == 'mara';
List<String> get chapters => levels.map((l) => l.chapterId).toSet().toList();
List<int> chapterLevels(int chapter) => [
@@ -281,11 +285,29 @@ class Book {
final tracks = trackPath == null
? <String, dynamic>{}
: Map<String, dynamic>.from((await read(trackPath))['tracks']);
final atmosphere = <String, Soundscape>{};
if (definition.atmosphereAsset != null) {
final data = await read(definition.atmosphereAsset!);
final scenes = data['scenes'] as Map;
final pageIds = pages.map((p) => p.id).toSet();
for (final entry in (data['pages'] as Map).entries) {
final asset = scenes[entry.value]?['asset'];
if (!pageIds.contains(entry.key) ||
asset is! String ||
!asset.startsWith('assets/') ||
asset.contains('..') ||
!asset.endsWith('.wav')) {
throw FormatException('Invalid atmosphere: ${entry.key}');
}
atmosphere[entry.key as String] = Soundscape(asset);
}
}
return Book(
translation['premise'] as String? ?? campaign['premise'],
levels,
pages,
tracks,
atmosphere: Map.unmodifiable(atmosphere),
id: definition.id,
title: translation['title'] as String? ?? definition.title,
description:
@@ -294,6 +316,7 @@ class Book {
defaultLanguage: definition.defaultLanguage,
presentation: definition.presentation,
coverAsset: translation['coverAsset'] as String? ?? definition.coverAsset,
paperAsset: translation['paperAsset'] as String? ?? definition.paperAsset,
continueAt: definition.continueAt,
initiallyAccessible: definition.initiallyAccessible.clamp(
0,
+30 -1
View File
@@ -8,7 +8,7 @@ import 'book.dart';
import 'library.dart';
import 'puzzle.dart';
enum Screen { home, story, contents, briefing, game, reveal }
enum Screen { library, home, story, contents, briefing, game, reveal }
enum Mode { daily, classic, campaign }
@@ -149,6 +149,35 @@ class Game extends ChangeNotifier {
notifyListeners();
}
/// Claim one of three reading breaks, persisted independently for each book.
/// Existing chapter-ad records count toward the same lifetime cap.
bool claimBookAd(int position, int total) {
final oldCount = List.generate(
book.levels.length,
(i) => i,
).where((i) => progress.flag('storyAd_$i')).length;
final used = List.generate(
3,
(i) => i + 1,
).where((slot) => progress.flag('storyAd_break_$slot')).length;
if (oldCount + used >= 3) return false;
final slot = (position * 3 ~/ total).clamp(0, 3);
if (slot == 0 || progress.flag('storyAd_break_$slot')) return false;
unawaited(progress.set('storyAd_break_$slot', true));
return true;
}
/// The shelf is the app's first window. It is deliberately not written to a
/// story's saved route (`flutter_screen`), so every book keeps its own reading
/// position and the next launch still opens the shelf.
void showLibrary() {
if (library == null) return;
_request++;
busy = false;
screen = Screen.library;
notifyListeners();
}
void home() {
_request++;
busy = false;
+7 -1
View File
@@ -12,6 +12,7 @@ class StoryDefinition {
title = data['title'],
description = data['description'] ?? '',
coverAsset = data['coverAsset'],
paperAsset = data['paperAsset'],
defaultLanguage = (data['defaultLanguage'] as String? ?? 'en')
.replaceAll('_', '-')
.toLowerCase(),
@@ -19,6 +20,7 @@ class StoryDefinition {
notebookAsset = data['notebookAsset'],
scriptsAsset = data['scriptsAsset'],
tracksAsset = data['tracksAsset'],
atmosphereAsset = data['atmosphereAsset'],
presentation = data['presentation'] ?? 'standard',
continueAt = data['continueAt'],
initiallyAccessible = data['initiallyAccessible'] ?? 0,
@@ -29,7 +31,11 @@ class StoryDefinition {
final String id, title, description, defaultLanguage, presentation;
final String campaignAsset, notebookAsset;
final String? coverAsset, scriptsAsset, tracksAsset;
final String? coverAsset,
paperAsset,
scriptsAsset,
tracksAsset,
atmosphereAsset;
final int? continueAt;
final int initiallyAccessible;
final Map<String, dynamic> languages;
+15
View File
@@ -0,0 +1,15 @@
/// A bundled, language-independent loop. Story packages can supply their own.
class Soundscape {
const Soundscape(this.asset);
final String asset;
static const cottage = Soundscape('assets/audio/ambience_cottage.wav');
static const harbour = Soundscape('assets/audio/ambience_harbour.wav');
static const bridge = Soundscape('assets/audio/ambience_bridge.wav');
static const tower = Soundscape('assets/audio/ambience_tower.wav');
@override
bool operator ==(Object other) => other is Soundscape && asset == other.asset;
@override
int get hashCode => asset.hashCode;
}