98 lines
2.9 KiB
Dart
98 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:wolf_dart/features/screens/difficulty_screen.dart';
|
|
import 'package:wolf_dart/wolf_3d.dart';
|
|
|
|
class EpisodeScreen extends StatefulWidget {
|
|
const EpisodeScreen({super.key});
|
|
|
|
@override
|
|
State<EpisodeScreen> createState() => _EpisodeScreenState();
|
|
}
|
|
|
|
class _EpisodeScreenState extends State<EpisodeScreen> {
|
|
final List<String> _episodeNames = [
|
|
"Episode 1\nEscape from Wolfenstein",
|
|
"Episode 2\nOperation: Eisenfaust",
|
|
"Episode 3\nDie, Fuhrer, Die!",
|
|
"Episode 4\nA Dark Secret",
|
|
"Episode 5\nTrail of the Madman",
|
|
"Episode 6\nConfrontation",
|
|
];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
if (Wolf3d.I.music.isNotEmpty) {
|
|
Wolf3d.I.audio.playMusic(Wolf3d.I.music.first);
|
|
}
|
|
}
|
|
|
|
void _selectEpisode(int index) {
|
|
Wolf3d.I.setActiveEpisode(index);
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
// We pass the audio handles so the next screen can stop them when the game starts
|
|
builder: (context) => DifficultyScreen(),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Determine how many episodes are available (10 levels per episode)
|
|
final int numberOfEpisodes = (Wolf3d.I.levels.length / 10).floor().clamp(
|
|
1,
|
|
6,
|
|
);
|
|
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
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: numberOfEpisodes,
|
|
itemBuilder: (context, 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(
|
|
_episodeNames[index],
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(fontSize: 18),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|