mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
handle sb2 files zipped in a folder
If the asset can’t be found by name, look for the same asset in a folder within the zipfile.
This commit is contained in:
parent
d1d5b80d55
commit
a4b0550013
1 changed files with 14 additions and 2 deletions
|
@ -26,7 +26,13 @@ const deserializeSound = function (sound, runtime, zip, assetFileName) {
|
|||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
const soundFile = zip.file(fileName);
|
||||
let soundFile = zip.file(fileName);
|
||||
if (!soundFile) {
|
||||
// look for assetfile in a flat list of files, or in a folder
|
||||
const fileMatch = new RegExp(`^([^/]*/)?${fileName}$`);
|
||||
soundFile = zip.file(fileMatch)[0]; // use first matching file
|
||||
}
|
||||
|
||||
if (!soundFile) {
|
||||
log.error(`Could not find sound file associated with the ${sound.name} sound.`);
|
||||
return Promise.resolve(null);
|
||||
|
@ -100,7 +106,13 @@ const deserializeCostume = function (costume, runtime, zip, assetFileName, textL
|
|||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
const costumeFile = zip.file(fileName);
|
||||
let costumeFile = zip.file(fileName);
|
||||
if (!costumeFile) {
|
||||
// look for assetfile in a flat list of files, or in a folder
|
||||
const fileMatch = new RegExp(`^([^/]*/)?${fileName}$`);
|
||||
costumeFile = zip.file(fileMatch)[0]; // use the first matched file
|
||||
}
|
||||
|
||||
if (!costumeFile) {
|
||||
log.error(`Could not find costume file associated with the ${costume.name} costume.`);
|
||||
return Promise.resolve(null);
|
||||
|
|
Loading…
Reference in a new issue