soiz1 commited on
Commit
a448ced
·
verified ·
1 Parent(s): cb4901b

Update src/engine/blocks.js

Browse files
Files changed (1) hide show
  1. src/engine/blocks.js +23 -7
src/engine/blocks.js CHANGED
@@ -1097,17 +1097,28 @@ class Blocks {
1097
  * 'backdrop'.
1098
  */
1099
  updateAssetName (oldName, newName, assetType) {
 
1100
  let getAssetField;
1101
- if (assetType === 'costume') {
 
 
 
1102
  getAssetField = this._getCostumeField.bind(this);
1103
- } else if (assetType === 'sound') {
1104
- getAssetField = this._getSoundField.bind(this);
1105
- } else if (assetType === 'backdrop') {
 
1106
  getAssetField = this._getBackdropField.bind(this);
1107
- } else if (assetType === 'sprite') {
 
 
 
 
 
 
1108
  getAssetField = this._getSpriteField.bind(this);
1109
- } else {
1110
- return;
1111
  }
1112
  const blocks = this._blocks;
1113
  for (const blockId in blocks) {
@@ -1117,6 +1128,11 @@ class Blocks {
1117
  }
1118
  }
1119
  this.resetCache();
 
 
 
 
 
1120
  }
1121
 
1122
  /**
 
1097
  * 'backdrop'.
1098
  */
1099
  updateAssetName (oldName, newName, assetType) {
1100
+ let target = this.runtime.getEditingTarget();
1101
  let getAssetField;
1102
+ let eventName;
1103
+ switch (assetType) {
1104
+ case 'costume':
1105
+ eventName = 'COSTUME_RENAMED';
1106
  getAssetField = this._getCostumeField.bind(this);
1107
+ break;
1108
+ case 'backdrop':
1109
+ target = this.runtime.getTargetForStage();
1110
+ eventName = 'COSTUME_RENAMED';
1111
  getAssetField = this._getBackdropField.bind(this);
1112
+ break;
1113
+ case 'sound':
1114
+ eventName = 'SOUND_RENAMED';
1115
+ getAssetField = this._getSoundField.bind(this);
1116
+ break;
1117
+ case 'sprite':
1118
+ eventName = 'SPRITE_RENAMED';
1119
  getAssetField = this._getSpriteField.bind(this);
1120
+ break;
1121
+ default: return
1122
  }
1123
  const blocks = this._blocks;
1124
  for (const blockId in blocks) {
 
1128
  }
1129
  }
1130
  this.resetCache();
1131
+ this.runtime.emit(
1132
+ eventName,
1133
+ { "old": oldName, "new": newName },
1134
+ target
1135
+ );
1136
  }
1137
 
1138
  /**