feat: Add file selector support and enhance game data directory management

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-23 19:30:50 +01:00
parent 569a3386a8
commit 70b4fc3fe0
9 changed files with 284 additions and 34 deletions
@@ -9,11 +9,27 @@ 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;
@@ -64,7 +80,7 @@ class NoGameDataScreen extends StatelessWidget {
const SizedBox(height: 16),
Text(
'No game files were discovered.\n\n'
'Select a game-data directory in setup.',
'Select a game-data directory, or select one or more game-data files.',
style: TextStyle(
color: _bodyColor,
fontSize: 15,
@@ -81,6 +97,58 @@ class NoGameDataScreen extends StatelessWidget {
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(