Moved away from singleton pattern
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -4,8 +4,11 @@ import 'package:wolf_3d_flutter/wolf_3d.dart';
|
||||
import 'package:wolf_3d_gui/screens/game_screen.dart';
|
||||
|
||||
class DifficultyScreen extends StatefulWidget {
|
||||
final Wolf3d wolf3d;
|
||||
|
||||
const DifficultyScreen({
|
||||
super.key,
|
||||
required this.wolf3d,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -13,24 +16,25 @@ class DifficultyScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DifficultyScreenState extends State<DifficultyScreen> {
|
||||
bool get isShareware => Wolf3d.I.activeGame.version == GameVersion.shareware;
|
||||
bool get isShareware =>
|
||||
widget.wolf3d.activeGame.version == GameVersion.shareware;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
Wolf3d.I.audio.stopMusic();
|
||||
widget.wolf3d.audio.stopMusic();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _startGame(Difficulty difficulty, {bool showGallery = false}) {
|
||||
Wolf3d.I.audio.stopMusic();
|
||||
widget.wolf3d.audio.stopMusic();
|
||||
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => GameScreen(
|
||||
data: Wolf3d.I.activeGame,
|
||||
data: widget.wolf3d.activeGame,
|
||||
difficulty: difficulty,
|
||||
startingEpisode: Wolf3d.I.activeEpisode,
|
||||
audio: Wolf3d.I.audio,
|
||||
startingEpisode: widget.wolf3d.activeEpisode,
|
||||
audio: widget.wolf3d.audio,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -59,8 +63,6 @@ class _DifficultyScreenState extends State<DifficultyScreen> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// --- Difficulty Buttons ---
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: Difficulty.values.length,
|
||||
|
||||
Reference in New Issue
Block a user