mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
922 B
37 lines
922 B
2 years ago
|
import 'package:dashbook/dashbook.dart';
|
||
|
import 'package:flame/game.dart';
|
||
|
import 'package:sandbox/common/common.dart';
|
||
|
|
||
|
const _path =
|
||
|
'https://github.com/VGVentures/pinball/tree/main/packages/pinball_components/sandbox/lib/stories/';
|
||
|
|
||
|
extension StoryAddGame on Story {
|
||
|
void addGame({
|
||
|
required String title,
|
||
|
required String description,
|
||
|
required Game Function(DashbookContext) gameBuilder,
|
||
|
}) {
|
||
|
final _chapter = Chapter(
|
||
|
title,
|
||
|
(DashbookContext context) {
|
||
|
final game = gameBuilder(context);
|
||
|
if (game is Traceable) {
|
||
|
game.trace = context.boolProperty('Trace', true);
|
||
|
}
|
||
|
|
||
|
return GameWidget(game: game);
|
||
|
},
|
||
|
this,
|
||
|
codeLink: '$_path${name.toPath()}/${title.toPath()}',
|
||
|
info: description,
|
||
|
);
|
||
|
chapters.add(_chapter);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
extension on String {
|
||
|
String toPath() {
|
||
|
return replaceAll(' ', '_')..toLowerCase();
|
||
|
}
|
||
|
}
|