feat: Add tests for Wolf3dGuiApp and refactor game data picker management
- Introduced unit tests for the Wolf3dGuiApp to ensure proper directory configuration and audio management. - Refactored the GameDataPickerManager to streamline directory and file selection processes. - Removed obsolete GameDataPickerManager and Wolf3dAppManager classes to simplify the architecture. - Enhanced the Wolf3dFlutterEngine to improve game version handling during save loading. - Updated existing tests to reflect changes in the game data management structure. - Removed unnecessary dependencies and cleaned up the codebase for better maintainability. Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
library;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wolf_3d_flutter/wolf_3d_flutter.dart';
|
||||
|
||||
/// Minimal app shell that binds a prepared [Wolf3dFlutterEngine] instance to
|
||||
/// host screens.
|
||||
class Wolf3dApp extends StatefulWidget {
|
||||
/// Shared initialized facade that owns game data, input, and audio services.
|
||||
final Wolf3dFlutterEngine engine;
|
||||
|
||||
const Wolf3dApp({
|
||||
super.key,
|
||||
required this.engine,
|
||||
});
|
||||
|
||||
@override
|
||||
State<Wolf3dApp> createState() => _Wolf3dAppState();
|
||||
}
|
||||
|
||||
class _Wolf3dAppState extends State<Wolf3dApp> with WidgetsBindingObserver {
|
||||
late final Wolf3dAppManager _manager;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_manager = Wolf3dAppManager(engine: widget.engine);
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
unawaited(_manager.ensureAudioShutdown());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.detached) {
|
||||
unawaited(_manager.ensureAudioShutdown());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _pickGameDataDirectory() {
|
||||
return _manager.pickGameDataDirectory(
|
||||
notifyChanged: () {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _pickGameDataFiles() {
|
||||
return _manager.pickGameDataFiles(
|
||||
notifyChanged: () {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return widget.engine.availableGames.isEmpty
|
||||
? NoGameDataScreen(
|
||||
configuredDataDirectory: widget.engine.configuredDataDirectory,
|
||||
onPickGameDataDirectory: _pickGameDataDirectory,
|
||||
onPickGameDataFiles: _pickGameDataFiles,
|
||||
isLoadingGameData: _manager.isLoadingGameData,
|
||||
pickerError: _manager.pickerError,
|
||||
)
|
||||
: GameScreen(wolf3d: widget.engine);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user