Smarter asset loading. Better audio rendering.
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -59,6 +59,15 @@ class GameSelectScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Future<ByteData?> tryLoad(String path) async {
|
||||
try {
|
||||
return await rootBundle.load(path);
|
||||
} catch (e) {
|
||||
debugPrint("Asset not found: $path");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<WolfensteinData>> loadData({String? directory}) async {
|
||||
final List<WolfensteinData> loadedGames = [];
|
||||
|
||||
@@ -68,40 +77,28 @@ class GameSelectScreen extends StatelessWidget {
|
||||
(version: GameVersion.shareware, path: 'shareware'),
|
||||
];
|
||||
|
||||
for (final config in versionsToTry) {
|
||||
for (final version in versionsToTry) {
|
||||
try {
|
||||
final ext = version.version.fileExtension;
|
||||
final folder = 'assets/${version.path}';
|
||||
|
||||
final data = WolfensteinLoader.loadFromBytes(
|
||||
version: config.version,
|
||||
vswap: await rootBundle.load(
|
||||
'assets/${config.path}/VSWAP.${config.version.fileExtension}',
|
||||
),
|
||||
mapHead: await rootBundle.load(
|
||||
'assets/${config.path}/MAPHEAD.${config.version.fileExtension}',
|
||||
),
|
||||
gameMaps: await rootBundle.load(
|
||||
'assets/${config.path}/GAMEMAPS.${config.version.fileExtension}',
|
||||
),
|
||||
vgaDict: await rootBundle.load(
|
||||
'assets/${config.path}/VGADICT.${config.version.fileExtension}',
|
||||
),
|
||||
vgaHead: await rootBundle.load(
|
||||
'assets/${config.path}/VGAHEAD.${config.version.fileExtension}',
|
||||
),
|
||||
vgaGraph: await rootBundle.load(
|
||||
'assets/${config.path}/VGAGRAPH.${config.version.fileExtension}',
|
||||
),
|
||||
audioHed: await rootBundle.load(
|
||||
'assets/${config.path}/AUDIOHED.${config.version.fileExtension}',
|
||||
),
|
||||
audioT: await rootBundle.load(
|
||||
'assets/${config.path}/AUDIOT.${config.version.fileExtension}',
|
||||
),
|
||||
version: version.version,
|
||||
vswap: await tryLoad('$folder/VSWAP.$ext'),
|
||||
mapHead: await tryLoad('$folder/MAPHEAD.$ext'),
|
||||
gameMaps: await tryLoad('$folder/GAMEMAPS.$ext'),
|
||||
vgaDict: await tryLoad('$folder/VGADICT.$ext'),
|
||||
vgaHead: await tryLoad('$folder/VGAHEAD.$ext'),
|
||||
vgaGraph: await tryLoad('$folder/VGAGRAPH.$ext'),
|
||||
audioHed: await tryLoad('$folder/AUDIOHED.$ext'),
|
||||
audioT: await tryLoad('$folder/AUDIOT.$ext'),
|
||||
);
|
||||
|
||||
loadedGames.add(data);
|
||||
} catch (e) {
|
||||
debugPrint(
|
||||
"Bundled ${config.version.name} not found or failed to load.",
|
||||
);
|
||||
// The loader now provides the specific error:
|
||||
// "ArgumentError: Cannot load retail: Missing files: VSWAP.WL6, ..."
|
||||
debugPrint(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user