Files
wolf_dart/apps/wolf_3d_gui/lib/screens/episode_screen.dart
Hans Kokx 3c6a4672f7 Refactor and enhance documentation across the Wolf3D project
- Updated library imports to use the correct package paths for consistency.
- Added detailed documentation comments to various classes and methods, improving code readability and maintainability.
- Refined the GameSelectScreen, SpriteGallery, and VgaGallery classes with clearer descriptions of their functionality.
- Enhanced the CliInput class to better explain the input handling process and its interaction with the engine.
- Improved the SixelRasterizer and Opl2Emulator classes with comprehensive comments on their operations and state management.
- Removed the deprecated wolf_3d.dart file and consolidated its functionality into wolf_3d_flutter.dart for a cleaner architecture.
- Updated the Wolf3dFlutterInput class to clarify its role in merging keyboard and pointer events.
- Enhanced the rendering classes to provide better context on their purpose and usage within the Flutter framework.

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-03-18 10:01:12 +01:00

127 lines
3.9 KiB
Dart

/// 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/difficulty_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<EpisodeScreen> createState() => _EpisodeScreenState();
}
class _EpisodeScreenState extends State<EpisodeScreen> {
@override
void initState() {
super.initState();
widget.wolf3d.audio.playMenuMusic();
}
/// Persists the chosen episode in [Wolf3d] and advances to difficulty select.
void _selectEpisode(int index) {
widget.wolf3d.setActiveEpisode(index);
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DifficultyScreen(wolf3d: widget.wolf3d),
),
);
}
@override
Widget build(BuildContext context) {
final List<Episode> 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),
),
),
);
},
),
],
),
),
);
}
}