feat: Add quit callback support to engine and UI components

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-20 10:04:01 +01:00
parent 9b053e1c02
commit e060aef3f1
5 changed files with 59 additions and 3 deletions

View File

@@ -82,7 +82,10 @@ class Wolf3d {
/// Uses [activeGame], [activeEpisode], and [activeDifficulty]. Stores the
/// engine so it can be retrieved via [engine]. [onGameWon] is invoked when
/// the player completes the final level of the episode.
WolfEngine launchEngine({required void Function() onGameWon}) {
WolfEngine launchEngine({
required void Function() onGameWon,
void Function()? onQuit,
}) {
if (availableGames.isEmpty) {
throw StateError(
'No game data was discovered. Add game files before launching the engine.',
@@ -102,6 +105,7 @@ class Wolf3d {
// In Flutter we keep the renderer screen active while browsing menus,
// so backing out of the top-level menu should not pop the route.
onMenuExit: () {},
onQuit: onQuit,
onGameSelected: (game) {
_activeGame = game;
audio.activeGame = game;