Skip to content
Snippets Groups Projects
Commit ba277a52 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Fix namer conventions to be less bizarre

parent 489467e6
No related branches found
No related tags found
Loading
...@@ -136,9 +136,9 @@ class TargetPane extends React.Component { ...@@ -136,9 +136,9 @@ class TargetPane extends React.Component {
handleSpriteUpload (e) { handleSpriteUpload (e) {
const storage = this.props.vm.runtime.storage; const storage = this.props.vm.runtime.storage;
handleFileUpload(e.target, (buffer, fileType, fileName) => { handleFileUpload(e.target, (buffer, fileType, fileName) => {
const pluralizeCostume = i => this.props.intl.formatMessage( const costumeSuffixer = i => this.props.intl.formatMessage(
sharedMessages.costume, {index: i}); sharedMessages.costume, {index: i});
spriteUpload(buffer, fileType, fileName, storage, this.handleNewSprite, pluralizeCostume); spriteUpload(buffer, fileType, fileName, storage, this.handleNewSprite, costumeSuffixer);
}); });
} }
setFileInput (input) { setFileInput (input) {
......
...@@ -90,18 +90,18 @@ const createVMAsset = function (storage, fileName, assetType, dataFormat, data) ...@@ -90,18 +90,18 @@ const createVMAsset = function (storage, fileName, assetType, dataFormat, data)
* @param {ArrayBuffer | string} fileData The costume data to load (this can be a base64 string * @param {ArrayBuffer | string} fileData The costume data to load (this can be a base64 string
* iff the image is a bitmap) * iff the image is a bitmap)
* @param {string} fileType The MIME type of this file * @param {string} fileType The MIME type of this file
* @param {string | Function} costumeNameOrNamer String or function producing the user-readable * @param {string | Function} costumeNamer String or function producing the user-readable
* name to use for the costume. Function will be called with an index in case of gif upload. * name to use for the costume. Function will be called with an index in case of gif upload.
* @param {ScratchStorage} storage The ScratchStorage instance to cache the costume data * @param {ScratchStorage} storage The ScratchStorage instance to cache the costume data
* @param {Function} handleCostume The function to execute on the costume object returned after * @param {Function} handleCostume The function to execute on the costume object returned after
* caching this costume in storage - This function should be responsible for * caching this costume in storage - This function should be responsible for
* adding the costume to the VM and handling other UI flow that should come after adding the costume * adding the costume to the VM and handling other UI flow that should come after adding the costume
*/ */
const costumeUpload = function (fileData, fileType, costumeNameOrNamer, storage, handleCostume) { const costumeUpload = function (fileData, fileType, costumeNamer, storage, handleCostume) {
let costumeFormat = null; let costumeFormat = null;
let assetType = null; let assetType = null;
const costumeNamer = typeof costumeNameOrNamer === 'string' ? const namer = typeof costumeNamer === 'string' ?
(() => costumeNameOrNamer) : costumeNameOrNamer; (() => costumeNamer) : costumeNamer;
switch (fileType) { switch (fileType) {
case 'image/svg+xml': { case 'image/svg+xml': {
costumeFormat = storage.DataFormat.SVG; costumeFormat = storage.DataFormat.SVG;
...@@ -121,7 +121,7 @@ const costumeUpload = function (fileData, fileType, costumeNameOrNamer, storage, ...@@ -121,7 +121,7 @@ const costumeUpload = function (fileData, fileType, costumeNameOrNamer, storage,
case 'image/gif': { case 'image/gif': {
let costumes = []; let costumes = [];
const onFrame = (frameNumber, dataUrl) => { const onFrame = (frameNumber, dataUrl) => {
costumeUpload(dataUrl, 'image/png', costumeNamer(frameNumber + 1), storage, costumes_ => { costumeUpload(dataUrl, 'image/png', namer(frameNumber + 1), storage, costumes_ => {
costumes = costumes.concat(costumes_); costumes = costumes.concat(costumes_);
}); });
}; };
...@@ -140,7 +140,7 @@ const costumeUpload = function (fileData, fileType, costumeNameOrNamer, storage, ...@@ -140,7 +140,7 @@ const costumeUpload = function (fileData, fileType, costumeNameOrNamer, storage,
const addCostumeFromBuffer = function (dataBuffer) { const addCostumeFromBuffer = function (dataBuffer) {
const vmCostume = createVMAsset( const vmCostume = createVMAsset(
storage, storage,
costumeNamer(1), namer(1),
assetType, assetType,
costumeFormat, costumeFormat,
dataBuffer dataBuffer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment