Add modular story library and shared-progress translations

This commit is contained in:
Hadrian Burkhardt
2026-11-03 17:15:15 +01:00
parent 5b9a76fb53
commit d45cd0698a
30 changed files with 2694 additions and 495 deletions
+96
View File
@@ -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'},
},
},
};