Files
wolf_dart/apps/wolf_3d_gui/lib/screens/difficulty_screen.dart

95 lines
2.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:wolf_3d_dart/wolf_3d_data_types.dart';
import 'package:wolf_3d_flutter/wolf_3d.dart';
import 'package:wolf_3d_gui/screens/game_screen.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: (context) => GameScreen(
data: Wolf3d.I.activeGame,
difficulty: difficulty,
startingEpisode: Wolf3d.I.activeEpisode,
audio: Wolf3d.I.audio,
),
),
);
}
@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),
),
),
);
},
),
],
),
),
);
}
}