/// Episode picker and asset-browser entry point for the selected game version. library; import 'package:flutter/material.dart'; import 'package:wolf_3d_dart/wolf_3d_data_types.dart'; import 'package:wolf_3d_flutter/wolf_3d_flutter.dart'; import 'package:wolf_3d_gui/screens/game_screen.dart'; import 'package:wolf_3d_gui/screens/sprite_gallery.dart'; import 'package:wolf_3d_gui/screens/vga_gallery.dart'; /// Presents the episode list and shortcuts into the asset gallery screens. class EpisodeScreen extends StatefulWidget { /// Shared application facade whose active game must already be set. final Wolf3d wolf3d; /// Creates the episode-selection screen for [wolf3d]. const EpisodeScreen({super.key, required this.wolf3d}); @override State createState() => _EpisodeScreenState(); } class _EpisodeScreenState extends State { @override void initState() { super.initState(); widget.wolf3d.audio.playMenuMusic(); } /// Persists the chosen episode and lets the engine present difficulty select. void _selectEpisode(int index) { widget.wolf3d.setActiveEpisode(index); widget.wolf3d.clearActiveDifficulty(); Navigator.of(context).push( MaterialPageRoute( builder: (context) => GameScreen(wolf3d: widget.wolf3d), ), ); } @override Widget build(BuildContext context) { final List episodes = widget.wolf3d.activeGame.episodes; return Scaffold( backgroundColor: Colors.teal, floatingActionButtonLocation: FloatingActionButtonLocation.miniCenterFloat, floatingActionButton: Row( children: [ ElevatedButton( onPressed: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) { return VgaGallery(images: widget.wolf3d.vgaImages); }, ), ); }, child: Text('VGA Gallery'), ), ElevatedButton( onPressed: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) { return SpriteGallery( wolf3d: widget.wolf3d, ); }, ), ); }, child: Text('Sprites'), ), ], ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( 'WHICH EPISODE TO PLAY?', style: TextStyle( color: Colors.red, fontSize: 32, fontWeight: FontWeight.bold, fontFamily: 'Courier', ), ), const SizedBox(height: 40), ListView.builder( shrinkWrap: true, itemCount: episodes.length, itemBuilder: (context, index) { final Episode episode = episodes[index]; return Padding( padding: const EdgeInsets.symmetric( vertical: 8.0, horizontal: 32.0, ), child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: Colors.blueGrey[900], foregroundColor: Colors.white, minimumSize: const Size(300, 60), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4), ), ), onPressed: () => _selectEpisode(index), child: Text( episode.name, textAlign: TextAlign.center, style: const TextStyle(fontSize: 18), ), ), ); }, ), ], ), ), ); } }