mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
format menu
This commit is contained in:
parent
e4d9f9cdff
commit
c305379393
1 changed files with 29 additions and 0 deletions
|
@ -197,6 +197,35 @@ class Scratch3GoForceBlocks {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats menus into a format suitable for block menus, and loading previously
|
||||
* saved projects:
|
||||
* [
|
||||
* {
|
||||
* text: label,
|
||||
* value: index
|
||||
* },
|
||||
* {
|
||||
* text: label,
|
||||
* value: index
|
||||
* },
|
||||
* etc...
|
||||
* ]
|
||||
*
|
||||
* @param {array} menu - a menu to format.
|
||||
* @return {object} - a formatted menu as an object.
|
||||
* @private
|
||||
*/
|
||||
_formatMenu (menu) {
|
||||
const m = [];
|
||||
for (let i = 0; i < menu.length; i++) {
|
||||
const obj = {};
|
||||
obj.text = menu[i];
|
||||
obj.value = i.toString();
|
||||
m.push(obj);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Scratch3GoForceBlocks;
|
||||
|
|
Loading…
Reference in a new issue