97 lines
2.9 KiB
Dart
97 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 {
|
|
final Wolf3d wolf3d;
|
|
|
|
const DifficultyScreen({
|
|
super.key,
|
|
required this.wolf3d,
|
|
});
|
|
|
|
@override
|
|
State<DifficultyScreen> createState() => _DifficultyScreenState();
|
|
}
|
|
|
|
class _DifficultyScreenState extends State<DifficultyScreen> {
|
|
bool get isShareware =>
|
|
widget.wolf3d.activeGame.version == GameVersion.shareware;
|
|
|
|
@override
|
|
void dispose() {
|
|
widget.wolf3d.audio.stopMusic();
|
|
super.dispose();
|
|
}
|
|
|
|
void _startGame(Difficulty difficulty, {bool showGallery = false}) {
|
|
widget.wolf3d.audio.stopMusic();
|
|
|
|
Navigator.of(context).pushReplacement(
|
|
MaterialPageRoute(
|
|
builder: (context) => GameScreen(
|
|
data: widget.wolf3d.activeGame,
|
|
difficulty: difficulty,
|
|
startingEpisode: widget.wolf3d.activeEpisode,
|
|
audio: widget.wolf3d.audio,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
floatingActionButton: FloatingActionButton(
|
|
backgroundColor: Colors.red[900],
|
|
onPressed: () => _startGame(Difficulty.medium, 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),
|
|
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),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|