Move initialization and access to a singleton
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -4,15 +4,13 @@ import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||
import 'package:wolf_3d_synth/wolf_3d_synth.dart';
|
||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
||||
import 'package:wolf_dart/features/renderer/renderer.dart';
|
||||
import 'package:wolf_dart/wolf_3d.dart';
|
||||
|
||||
class DifficultyScreen extends StatefulWidget {
|
||||
const DifficultyScreen(
|
||||
this.data, {
|
||||
const DifficultyScreen({
|
||||
super.key,
|
||||
});
|
||||
|
||||
final WolfensteinData data;
|
||||
|
||||
@override
|
||||
State<DifficultyScreen> createState() => _DifficultyScreenState();
|
||||
}
|
||||
@@ -21,7 +19,7 @@ class _DifficultyScreenState extends State<DifficultyScreen> {
|
||||
AudioSource? _menuMusicSource;
|
||||
SoundHandle? _menuMusicHandle;
|
||||
|
||||
bool get isShareware => widget.data.version == GameVersion.shareware;
|
||||
bool get isShareware => Wolf3d.I.activeGame.version == GameVersion.shareware;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -37,9 +35,9 @@ class _DifficultyScreenState extends State<DifficultyScreen> {
|
||||
}
|
||||
|
||||
// 2. We only want to play music if the IMF data actually exists
|
||||
if (widget.data.music.isNotEmpty) {
|
||||
if (Wolf3d.I.music.isNotEmpty) {
|
||||
// Get the first track (usually the menu theme "Wondering About My Loved Ones")
|
||||
final music = widget.data.music.first;
|
||||
final music = Wolf3d.I.music.first;
|
||||
|
||||
// Render the hardware instructions into PCM and wrap in a WAV header
|
||||
final pcmSamples = ImfRenderer.render(music);
|
||||
@@ -85,7 +83,7 @@ class _DifficultyScreenState extends State<DifficultyScreen> {
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => WolfRenderer(
|
||||
widget.data,
|
||||
Wolf3d.I.activeGame,
|
||||
difficulty: difficulty,
|
||||
isShareware: isShareware,
|
||||
showSpriteGallery: showGallery,
|
||||
|
||||
Reference in New Issue
Block a user