Files
wolf_dart/lib/features/screens/episode_screen.dart
2026-03-15 14:54:57 +01:00

94 lines
2.7 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();
Wolf3d.I.audio.playMenuMusic();
}
void _selectEpisode(int index) {
Wolf3d.I.setActiveEpisode(index);
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DifficultyScreen(),
),
);
}
@override
Widget build(BuildContext context) {
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),
),
),
);
},
),
],
),
),
);
}
}