kopia lustrzana https://github.com/backface/turtlestitch
tweaked loading custom blocks with user-defined categories
rodzic
2394a52eb7
commit
5bd3c2df7e
12
src/gui.js
12
src/gui.js
|
@ -4956,10 +4956,22 @@ IDE_Morph.prototype.deleteUserCategory = function () {
|
|||
};
|
||||
|
||||
IDE_Morph.prototype.deletePaletteCategory = function (name) {
|
||||
var allCustomBlocks = this.stage.globalBlocks.slice();
|
||||
this.sprites.asArray().concat(this.stage).forEach(obj =>
|
||||
allCustomBlocks.push(...obj.customBlocks)
|
||||
);
|
||||
allCustomBlocks.forEach(def => {
|
||||
if (def.category === name) {
|
||||
def.category = 'other';
|
||||
// to do: refresh all block instances
|
||||
}
|
||||
});
|
||||
SpriteMorph.prototype.customCategories.delete(name);
|
||||
this.createCategories();
|
||||
this.createPaletteHandle();
|
||||
this.categories.fixLayout();
|
||||
this.flushPaletteCache();
|
||||
this.refreshPalette();
|
||||
this.fixLayout();
|
||||
};
|
||||
|
||||
|
|
|
@ -385,6 +385,7 @@ SnapSerializer.prototype.loadScene = function (xmlNode, remixID) {
|
|||
model.palette = model.scene.childNamed('palette');
|
||||
if (model.palette) {
|
||||
scene.customCategories = this.loadPalette(model.palette);
|
||||
SpriteMorph.prototype.customCategories = scene.customCategories;
|
||||
}
|
||||
model.globalVariables = model.scene.childNamed('variables');
|
||||
|
||||
|
@ -1221,7 +1222,7 @@ SnapSerializer.prototype.loadBlock = function (model, isReporter, object) {
|
|||
}
|
||||
if (!info || !contains(
|
||||
// catch other forks' blocks
|
||||
SpriteMorph.prototype.categories, info.category
|
||||
SpriteMorph.prototype.allCategories(), info.category
|
||||
)) {
|
||||
return this.obsoleteBlock(isReporter);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue