tweaked loading custom blocks with user-defined categories

snap7
jmoenig 2021-07-22 18:07:14 +02:00
rodzic 2394a52eb7
commit 5bd3c2df7e
2 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -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();
};

Wyświetl plik

@ -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);
}