Delegate all audio management to the new audio package, then manage that through a new wolf3d class
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
94
lib/features/screens/difficulty_screen.dart
Normal file
94
lib/features/screens/difficulty_screen.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wolf_3d_data_types/wolf_3d_data_types.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({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<DifficultyScreen> createState() => _DifficultyScreenState();
|
||||
}
|
||||
|
||||
class _DifficultyScreenState extends State<DifficultyScreen> {
|
||||
bool get isShareware => Wolf3d.I.activeGame.version == GameVersion.shareware;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
Wolf3d.I.audio.stopMusic();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _startGame(Difficulty difficulty, {bool showGallery = false}) {
|
||||
Wolf3d.I.audio.stopMusic();
|
||||
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => WolfRenderer(
|
||||
Wolf3d.I.activeGame,
|
||||
difficulty: difficulty,
|
||||
startingEpisode: Wolf3d.I.activeEpisode,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: Colors.red[900],
|
||||
onPressed: () => _startGame(Difficulty.bringEmOn, showGallery: true),
|
||||
child: const Icon(Icons.bug_report, color: Colors.white),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'HOW TOUGH ARE YOU?',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Courier',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// --- Difficulty Buttons ---
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: Difficulty.values.length,
|
||||
itemBuilder: (context, index) {
|
||||
final Difficulty difficulty = Difficulty.values[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.blueGrey[900],
|
||||
foregroundColor: Colors.white,
|
||||
minimumSize: const Size(300, 50),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
onPressed: () => _startGame(difficulty),
|
||||
child: Text(
|
||||
difficulty.title,
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user