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,174 +0,0 @@
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wolf_3d_dart/wolf_3d_data_types.dart';
|
||||
import 'package:wolf_3d_dart/wolf_3d_menu.dart';
|
||||
|
||||
/// Fallback screen shown when no Wolf3D game data files are discovered.
|
||||
class NoGameDataScreen extends StatelessWidget {
|
||||
const NoGameDataScreen({
|
||||
super.key,
|
||||
this.configuredDataDirectory,
|
||||
this.onPickGameDataDirectory,
|
||||
this.onPickGameDataFiles,
|
||||
this.isLoadingGameData = false,
|
||||
this.pickerError,
|
||||
});
|
||||
|
||||
/// Previously configured external game-data directory, if any.
|
||||
final String? configuredDataDirectory;
|
||||
|
||||
/// Invoked when the user requests selecting a game-data directory.
|
||||
final Future<void> Function()? onPickGameDataDirectory;
|
||||
|
||||
/// Invoked when the user requests selecting one or more data files.
|
||||
final Future<void> Function()? onPickGameDataFiles;
|
||||
|
||||
/// Whether the host is currently reloading after picker selection.
|
||||
final bool isLoadingGameData;
|
||||
|
||||
/// Optional picker/reload error shown to the user.
|
||||
final String? pickerError;
|
||||
|
||||
static Color _colorFromVgaIndex(int index) {
|
||||
final int packed = ColorPalette.vga32Bit[index]; // 0xAABBGGRR
|
||||
final int r = packed & 0xFF;
|
||||
final int g = (packed >> 8) & 0xFF;
|
||||
final int b = (packed >> 16) & 0xFF;
|
||||
return Color((0xFF << 24) | (r << 16) | (g << 8) | b);
|
||||
}
|
||||
|
||||
static final Color _backgroundColor = _colorFromVgaIndex(111);
|
||||
static final Color _panelColor = _colorFromVgaIndex(103);
|
||||
static final Color _borderColor = _colorFromVgaIndex(87);
|
||||
static final Color _titleColor = _colorFromVgaIndex(
|
||||
WolfMenuPalette.headerTextIndex,
|
||||
);
|
||||
static final Color _bodyColor = _colorFromVgaIndex(
|
||||
WolfMenuPalette.unselectedTextIndex,
|
||||
);
|
||||
static final Color _emphasisColor = _colorFromVgaIndex(10);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: _backgroundColor,
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 640),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: _panelColor,
|
||||
border: Border.all(color: _borderColor, width: 2),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'WOLF3D DATA NOT FOUND',
|
||||
style: TextStyle(
|
||||
color: _titleColor,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'No game files were discovered.\n\n'
|
||||
'Select a game-data directory, or select one or more game-data files.',
|
||||
style: TextStyle(
|
||||
color: _bodyColor,
|
||||
fontSize: 15,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'Once all required files are present, the game starts automatically.',
|
||||
style: TextStyle(
|
||||
color: _emphasisColor,
|
||||
fontSize: 14,
|
||||
height: 1.35,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: isLoadingGameData
|
||||
? null
|
||||
: onPickGameDataDirectory,
|
||||
child: Text(
|
||||
isLoadingGameData
|
||||
? 'Loading data...'
|
||||
: 'Select data directory',
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: isLoadingGameData
|
||||
? null
|
||||
: onPickGameDataFiles,
|
||||
child: Text(
|
||||
isLoadingGameData
|
||||
? 'Loading data...'
|
||||
: 'Select data files',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (isLoadingGameData)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
'Scanning selected locations...',
|
||||
style: TextStyle(
|
||||
color: _bodyColor,
|
||||
fontSize: 13,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (pickerError != null && pickerError!.trim().isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Text(
|
||||
pickerError!.trim(),
|
||||
style: TextStyle(
|
||||
color: _emphasisColor,
|
||||
fontSize: 13,
|
||||
height: 1.3,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (configuredDataDirectory != null &&
|
||||
configuredDataDirectory!.trim().isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Text(
|
||||
'Configured data directory: ${configuredDataDirectory!.trim()}',
|
||||
style: TextStyle(
|
||||
color: _bodyColor,
|
||||
fontSize: 13,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user