recategorize blocks from a deleted palette to "other"

snap7
jmoenig 2021-07-22 19:52:17 +02:00
rodzic 5bd3c2df7e
commit 1b0dc04942
1 zmienionych plików z 17 dodań i 6 usunięć

Wyświetl plik

@ -4956,16 +4956,26 @@ 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 => {
this.stage.globalBlocks.forEach(def =>{
if (def.category === name) {
def.category = 'other';
// to do: refresh all block instances
this.currentSprite.allBlockInstances(def).reverse().forEach(
block => block.refresh()
);
}
});
this.sprites.asArray().concat(this.stage).forEach(obj => {
obj.customBlocks.forEach(def => {
if (def.category === name) {
def.category = 'other';
obj.allDependentInvocationsOf(
def.blockSpec()
).reverse().forEach(
block => block.refresh(def)
);
}
});
});
SpriteMorph.prototype.customCategories.delete(name);
this.createCategories();
this.createPaletteHandle();
@ -4973,6 +4983,7 @@ IDE_Morph.prototype.deletePaletteCategory = function (name) {
this.flushPaletteCache();
this.refreshPalette();
this.fixLayout();
this.recordUnsavedChanges();
};
IDE_Morph.prototype.save = function () {