Skip to content

Commit

Permalink
Merge branch 'TurboWarp:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
RedMan13 authored Aug 8, 2023
2 parents e677d7d + d835c52 commit 457a37a
Show file tree
Hide file tree
Showing 11 changed files with 1,388 additions and 45 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 457a37a

Please sign in to comment.