Skip to content

Commit

Permalink
Add experimental Lily/AllMenus extension (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyMakesThings authored Aug 8, 2023
1 parent 859808e commit a4291f5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
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);
6 changes: 6 additions & 0 deletions website/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,12 @@
<p>A few adapter blocks. Created by <a href="https://scratch.mit.edu/users/TrueFantom/">TrueFantom</a>.</p>
</div>
<div class="extension">
<%- banner('Lily/AllMenus') %>
<h3>All Menus</h3>
<p>Special category with every menu from every Scratch category and extensions. Created by <a href="https://scratch.mit.edu/users/LilyMakesThings/">LilyMakesThings</a></p>
</div>
<div class="extension">
<%- banner('Lily/Cast') %>
<h3>Cast</h3>
Expand Down

0 comments on commit a4291f5

Please sign in to comment.