Moved away from singleton pattern
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -6,7 +6,9 @@ import 'package:wolf_3d_gui/screens/sprite_gallery.dart';
|
||||
import 'package:wolf_3d_gui/screens/vga_gallery.dart';
|
||||
|
||||
class EpisodeScreen extends StatefulWidget {
|
||||
const EpisodeScreen({super.key});
|
||||
final Wolf3d wolf3d;
|
||||
|
||||
const EpisodeScreen({super.key, required this.wolf3d});
|
||||
|
||||
@override
|
||||
State<EpisodeScreen> createState() => _EpisodeScreenState();
|
||||
@@ -16,21 +18,21 @@ class _EpisodeScreenState extends State<EpisodeScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Wolf3d.I.audio.playMenuMusic();
|
||||
widget.wolf3d.audio.playMenuMusic();
|
||||
}
|
||||
|
||||
void _selectEpisode(int index) {
|
||||
Wolf3d.I.setActiveEpisode(index);
|
||||
widget.wolf3d.setActiveEpisode(index);
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DifficultyScreen(),
|
||||
builder: (context) => DifficultyScreen(wolf3d: widget.wolf3d),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Episode> episodes = Wolf3d.I.activeGame.episodes;
|
||||
final List<Episode> episodes = widget.wolf3d.activeGame.episodes;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.teal,
|
||||
@@ -43,7 +45,7 @@ class _EpisodeScreenState extends State<EpisodeScreen> {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return VgaGallery(images: Wolf3d.I.vgaImages);
|
||||
return VgaGallery(images: widget.wolf3d.vgaImages);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -55,7 +57,9 @@ class _EpisodeScreenState extends State<EpisodeScreen> {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return SpriteGallery(sprites: Wolf3d.I.sprites);
|
||||
return SpriteGallery(
|
||||
wolf3d: widget.wolf3d,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user