From a4291f561d5002a0d91e0eac1058b5678523f29a Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Tue, 8 Aug 2023 02:38:51 +0100 Subject: [PATCH] Add experimental Lily/AllMenus extension (#510) --- extensions/Lily/AllMenus.js | 52 +++++++++++++++++++++++++++++++++++++ website/index.ejs | 6 +++++ 2 files changed, 58 insertions(+) create mode 100644 extensions/Lily/AllMenus.js diff --git a/extensions/Lily/AllMenus.js b/extensions/Lily/AllMenus.js new file mode 100644 index 0000000000..b81746d39b --- /dev/null +++ b/extensions/Lily/AllMenus.js @@ -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 => '' + ); + + 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); diff --git a/website/index.ejs b/website/index.ejs index e7690d390e..f12f577897 100644 --- a/website/index.ejs +++ b/website/index.ejs @@ -590,6 +590,12 @@

A few adapter blocks. Created by TrueFantom.

+
+ <%- banner('Lily/AllMenus') %> +

All Menus

+

Special category with every menu from every Scratch category and extensions. Created by LilyMakesThings

+
+
<%- banner('Lily/Cast') %>

Cast