- Updated library imports to use the correct package paths for consistency. - Added detailed documentation comments to various classes and methods, improving code readability and maintainability. - Refined the GameSelectScreen, SpriteGallery, and VgaGallery classes with clearer descriptions of their functionality. - Enhanced the CliInput class to better explain the input handling process and its interaction with the engine. - Improved the SixelRasterizer and Opl2Emulator classes with comprehensive comments on their operations and state management. - Removed the deprecated wolf_3d.dart file and consolidated its functionality into wolf_3d_flutter.dart for a cleaner architecture. - Updated the Wolf3dFlutterInput class to clarify its role in merging keyboard and pointer events. - Enhanced the rendering classes to provide better context on their purpose and usage within the Flutter framework. Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
105 lines
3.3 KiB
Dart
105 lines
3.3 KiB
Dart
/// Difficulty picker shown after the player chooses an episode.
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:wolf_3d_dart/wolf_3d_data_types.dart';
|
|
import 'package:wolf_3d_flutter/wolf_3d_flutter.dart';
|
|
import 'package:wolf_3d_gui/screens/game_screen.dart';
|
|
|
|
/// Starts a new game session using the active game and episode from [Wolf3d].
|
|
class DifficultyScreen extends StatefulWidget {
|
|
/// Shared application facade carrying the active game, input, and audio.
|
|
final Wolf3d wolf3d;
|
|
|
|
/// Creates the difficulty-selection screen for [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();
|
|
}
|
|
|
|
/// Replaces the menu flow with an active [GameScreen] using [difficulty].
|
|
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,
|
|
input: widget.wolf3d.input,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@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),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|