mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Merge branch 'develop' of https://github.com/LLK/scratch-vm into feature/wedo-block-icon
This commit is contained in:
commit
cc35bcc791
2 changed files with 23 additions and 1 deletions
|
@ -7,6 +7,13 @@ const MathUtil = require('../util/math-util');
|
|||
const RenderedTarget = require('../sprites/rendered-target');
|
||||
const log = require('../util/log');
|
||||
|
||||
/**
|
||||
* Icon svg to be displayed at the left edge of each extension block, encoded as a data URI.
|
||||
* @type {string}
|
||||
*/
|
||||
// eslint-disable-next-line max-len
|
||||
const iconURI = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+cGVuLWljb248L3RpdGxlPjxnIHN0cm9rZT0iIzU3NUU3NSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik04Ljc1MyAzNC42MDJsLTQuMjUgMS43OCAxLjc4My00LjIzN2MxLjIxOC0yLjg5MiAyLjkwNy01LjQyMyA1LjAzLTcuNTM4TDMxLjA2NiA0LjkzYy44NDYtLjg0MiAyLjY1LS40MSA0LjAzMi45NjcgMS4zOCAxLjM3NSAxLjgxNiAzLjE3My45NyA0LjAxNUwxNi4zMTggMjkuNTljLTIuMTIzIDIuMTE2LTQuNjY0IDMuOC03LjU2NSA1LjAxMiIgZmlsbD0iI0ZGRiIvPjxwYXRoIGQ9Ik0yOS40MSA2LjExcy00LjQ1LTIuMzc4LTguMjAyIDUuNzcyYy0xLjczNCAzLjc2Ni00LjM1IDEuNTQ2LTQuMzUgMS41NDYiLz48cGF0aCBkPSJNMzYuNDIgOC44MjVjMCAuNDYzLS4xNC44NzMtLjQzMiAxLjE2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Pg==';
|
||||
|
||||
/**
|
||||
* Enum for pen color parameters.
|
||||
* @readonly
|
||||
|
@ -235,6 +242,7 @@ class Scratch3PenBlocks {
|
|||
return {
|
||||
id: 'pen',
|
||||
name: 'Pen',
|
||||
iconURI: iconURI,
|
||||
blocks: [
|
||||
{
|
||||
opcode: 'clear',
|
||||
|
|
|
@ -421,6 +421,7 @@ class Runtime extends EventEmitter {
|
|||
const categoryInfo = {
|
||||
id: extensionInfo.id,
|
||||
name: extensionInfo.name,
|
||||
iconURI: extensionInfo.iconURI,
|
||||
color1: '#FF6680',
|
||||
color2: '#FF4D6A',
|
||||
color3: '#FF3355',
|
||||
|
@ -524,8 +525,21 @@ class Runtime extends EventEmitter {
|
|||
// but each `[ARG]` will need to be replaced with the number in this map instead of `args0.length`.
|
||||
const argsMap = {};
|
||||
|
||||
blockJSON.message0 = blockInfo.text.replace(/\[(.+?)]/g, (match, placeholder) => {
|
||||
blockJSON.message0 = '';
|
||||
|
||||
// If an icon for the extension exists, prepend it to each block
|
||||
if (categoryInfo.iconURI) {
|
||||
blockJSON.message0 = '%1';
|
||||
const iconJSON = {
|
||||
type: 'field_image',
|
||||
src: categoryInfo.iconURI,
|
||||
width: 40,
|
||||
height: 40
|
||||
};
|
||||
blockJSON.args0.push(iconJSON);
|
||||
}
|
||||
|
||||
blockJSON.message0 += blockInfo.text.replace(/\[(.+?)]/g, (match, placeholder) => {
|
||||
// Sanitize the placeholder to ensure valid XML
|
||||
placeholder = placeholder.replace(/[<"&]/, '_');
|
||||
|
||||
|
|
Loading…
Reference in a new issue