Skip to content

Commit

Permalink
Merge branch 'master' into Video
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyMakesThings authored Aug 13, 2023
2 parents 2c8c2c3 + db6cfba commit cc08561
Show file tree
Hide file tree
Showing 21 changed files with 1,817 additions and 99 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ module.exports = {
ecmaVersion: 'latest'
},
globals: {
Blockly: 'readonly',
Scratch: 'readonly',
ScratchBlocks: 'readonly',
ScratchExtensions: 'readonly',
scaffolding: 'readonly'
},
Expand Down
52 changes: 52 additions & 0 deletions extensions/Lily/AllMenus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
(function (Scratch) {
'use strict';

var blockXML;
const blacklist = ['looks_costumenumbername', 'extension_wedo_tilt_menu'];

Scratch.vm.addListener('BLOCKSINFO_UPDATE', refreshMenus);

function refreshMenus() {
if (!window.ScratchBlocks) return;
Scratch.vm.removeListener('BLOCKSINFO_UPDATE', refreshMenus);

let allBlocks = Object.keys(ScratchBlocks.Blocks);

allBlocks = allBlocks.filter(
item => item.includes('menu') &&
!blacklist.includes(item)
);

const menuBlocks = allBlocks.map(
item => '<block id="' + item + '" type="' + item + '"/>'
);

blockXML = menuBlocks.join('');
Scratch.vm.runtime.extensionManager.refreshBlocks();
}

class AllMenus {
constructor () {
Scratch.vm.runtime.on('EXTENSION_ADDED', () => {
refreshMenus();
});
}

getInfo() {
return {
id: 'lmsAllMenus',
name: 'All Menus',
blocks: [
{
blockType: Scratch.BlockType.XML,
xml: blockXML
}
]
};
}
}

refreshMenus();

Scratch.extensions.register(new AllMenus());
})(Scratch);
Loading

0 comments on commit cc08561

Please sign in to comment.