Stop using builtinHelper.cache

And start just creating assets to hand to the VM. Towards https://github.com/LLK/scratch-vm/issues/1577
This commit is contained in:
Ray Schamp committed 2018-10-25 11:03:16 +01:00
1 parent f64243d553
commit 1a0bf07ea6
3 files changed
+15 -10

No files matched your search

+7 -5
View File
@@ -80,17 +80,19 @@ class RecordModal extends React.Component {
sampleCount: clippedSamples.length
};
// Load the encoded .wav into the storage cache and get resulting
// md5 from storage
const storage = this.props.vm.runtime.storage;
const md5 = storage.builtinHelper.cache(
// Create an asset from the encoded .wav and get resulting md5
const storage = this.props.vm.storage;
vmSound.asset = storage.createAsset(
storage.AssetType.Sound,
storage.DataFormat.WAV,
new Uint8Array(wavBuffer),
null,
true // generate md5
);
vmSound.assetId = vmSound.asset.assetId;
// update vmSound object with md5 property
vmSound.md5 = `${md5}.${vmSound.dataFormat}`;
vmSound.md5 = `${vmSound.assetId}.${vmSound.dataFormat}`;
// The VM will update the sound name to a fresh name
// if the following is already taken
vmSound.name = 'recording1';
+7 -4
View File
@@ -63,17 +63,20 @@ const handleFileUpload = function (fileInput, onload) {
* which can be used to look up the data in storage
*/
const cacheAsset = function (storage, fileName, assetType, dataFormat, data) {
const md5 = storage.builtinHelper.cache(
const asset = storage.createAsset(
assetType,
dataFormat,
data
data,
null,
true // generate md5
);
return {
name: fileName,
dataFormat: dataFormat,
md5: `${md5}.${dataFormat}`,
assetId: md5
asset: asset,
md5: `${asset.assetId}.${dataFormat}`,
assetId: asset.assetId
};
};
+1 -1
View File
@@ -55,7 +55,7 @@ class Storage extends ScratchStorage {
}
cacheDefaultProject () {
const defaultProjectAssets = defaultProject(this.translator);
defaultProjectAssets.forEach(asset => this.cache(
defaultProjectAssets.forEach(asset => this.builtinHelper._store(
this.AssetType[asset.assetType],
this.DataFormat[asset.dataFormat],
asset.data,