(window["webpackJsonpGUI"] = window["webpackJsonpGUI"] || []).push([["addon-entry-custom-block-shape"],{ /***/ "./src/addons/addons/custom-block-shape/_runtime_entry.js": /*!****************************************************************!*\ !*** ./src/addons/addons/custom-block-shape/_runtime_entry.js ***! \****************************************************************/ /*! exports provided: resources */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resources", function() { return resources; }); /* harmony import */ var _userscript_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./userscript.js */ "./src/addons/addons/custom-block-shape/userscript.js"); /* generated by pull.js */ const resources = { "userscript.js": _userscript_js__WEBPACK_IMPORTED_MODULE_0__["default"] }; /***/ }), /***/ "./src/addons/addons/custom-block-shape/userscript.js": /*!************************************************************!*\ !*** ./src/addons/addons/custom-block-shape/userscript.js ***! \************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony default export */ __webpack_exports__["default"] = (async function (_ref) { let { addon, console } = _ref; var BlocklyInstance = await addon.tab.traps.getBlockly(); (function (Blockly) { const BlockSvg = BlocklyInstance.BlockSvg; var vm = addon.tab.traps.vm; const { GRID_UNIT } = BlockSvg; function updateAllBlocks() { const workspace = Blockly.getMainWorkspace(); if (workspace) { if (vm.editingTarget) { vm.emitWorkspaceUpdate(); } const flyout = workspace.getFlyout(); if (flyout) { const flyoutWorkspace = flyout.getWorkspace(); Blockly.Xml.clearWorkspaceAndLoadFromXml(Blockly.Xml.workspaceToDom(flyoutWorkspace), flyoutWorkspace); workspace.getToolbox().refreshSelection(); workspace.toolboxRefreshEnabled_ = true; } } } function applyChanges() { let paddingSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : addon.settings.get("paddingSize"); let cornerSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : addon.settings.get("cornerSize"); let notchSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : addon.settings.get("notchSize"); let multiplier = paddingSize / 100; cornerSize = cornerSize / 100; notchSize = notchSize / 100; BlockSvg.SEP_SPACE_Y = 2 * GRID_UNIT * multiplier; BlockSvg.MIN_BLOCK_X = 16 * GRID_UNIT * multiplier; BlockSvg.MIN_BLOCK_X_OUTPUT = 12 * GRID_UNIT * multiplier; BlockSvg.MIN_BLOCK_X_SHADOW_OUTPUT = 10 * GRID_UNIT * multiplier; BlockSvg.MIN_BLOCK_Y = 12 * GRID_UNIT * multiplier; BlockSvg.EXTRA_STATEMENT_ROW_Y = 8 * GRID_UNIT * multiplier; BlockSvg.MIN_BLOCK_X_WITH_STATEMENT = 40 * GRID_UNIT * multiplier; BlockSvg.MIN_BLOCK_Y_SINGLE_FIELD_OUTPUT = 8 * GRID_UNIT * multiplier; BlockSvg.MIN_BLOCK_Y_REPORTER = 10 * GRID_UNIT * multiplier; BlockSvg.MIN_STATEMENT_INPUT_HEIGHT = 6 * GRID_UNIT * multiplier; BlockSvg.NOTCH_WIDTH = 8 * GRID_UNIT * multiplier; BlockSvg.NOTCH_HEIGHT = 2 * GRID_UNIT * multiplier * notchSize; BlockSvg.NOTCH_START_PADDING = 3 * GRID_UNIT; //* multiplier BlockSvg.ICON_SEPARATOR_HEIGHT = 10 * GRID_UNIT * multiplier; BlockSvg.NOTCH_PATH_LEFT = "c 2 0 3 ".concat(1 * notchSize, " 4 ").concat(2 * notchSize, " ") + "l ".concat(4 * multiplier * notchSize, " ").concat(4 * multiplier * notchSize, " ") + "c 1 ".concat(1 * notchSize, " 2 ").concat(2 * notchSize, " 4 ").concat(2 * notchSize, " ") + "h ".concat(24 * (multiplier - 0.5), " ") + "c 2 0 3 ".concat(-1 * notchSize, " 4 ").concat(-2 * notchSize, " ") + "l ".concat(4 * multiplier * notchSize, " ").concat(-4 * multiplier * notchSize, " ") + "c 1 ".concat(-1 * notchSize, " 2 ").concat(-2 * notchSize, " 4 ").concat(-2 * notchSize, " "); BlockSvg.NOTCH_PATH_RIGHT = "h ".concat(-4 * (cornerSize - 1) - 5 * (1 - notchSize), " ") + "c -2 0 -3 ".concat(1 * notchSize, " -4 ").concat(2 * notchSize, " ") + "l ".concat(-4 * multiplier * notchSize, " ").concat(4 * multiplier * notchSize, " ") + "c -1 ".concat(1 * notchSize, " -2 ").concat(2 * notchSize, " -4 ").concat(2 * notchSize, " ") + "h ".concat(-24 * (multiplier - 0.5), " ") + "c -2 0 -3 ".concat(-1 * notchSize, " -4 ").concat(-2 * notchSize, " ") + "l ".concat(-4 * multiplier * notchSize, " ").concat(-4 * multiplier * notchSize, " ") + "c -1 ".concat(-1 * notchSize, " -2 ").concat(-2 * notchSize, " -4 ").concat(-2 * notchSize, " "); BlockSvg.NOTCH_SWITCH_PATH_LEFT = "c 2 0 3 ".concat(1 * notchSize, " 4 ").concat(2 * notchSize, " ") + "l ".concat(4 * multiplier * notchSize, " ").concat(4 * multiplier * notchSize, " ") + "c 1 ".concat(1 * notchSize, " 2 ").concat(2 * notchSize, " 4 ").concat(2 * notchSize, " ") + "c ".concat(4 * (multiplier - 0.5), " 0 ").concat(8 * (multiplier - 0.5), " ").concat(-8 * (multiplier - 0.5) * notchSize, " ").concat(12 * (multiplier - 0.5), " ").concat(-8 * (multiplier - 0.5) * notchSize, " ") + "c ".concat(4 * (multiplier - 0.5), " 0 ").concat(8 * (multiplier - 0.5), " ").concat(8 * (multiplier - 0.5) * notchSize, " ").concat(12 * (multiplier - 0.5), " ").concat(8 * (multiplier - 0.5) * notchSize, " ") + "c 2 0 3 ".concat(-1 * notchSize, " 4 ").concat(-2 * notchSize, " ") + "l ".concat(4 * multiplier * notchSize, " ").concat(-4 * multiplier * notchSize, " ") + "c 1 ".concat(-1 * notchSize, " 2 ").concat(-2 * notchSize, " 4 ").concat(-2 * notchSize, " "); BlockSvg.NOTCH_SWITCH_PATH_RIGHT = "h ".concat(-4 * (cornerSize - 1) - 5 * (1 - notchSize), " ") + "c -2 0 -3 ".concat(1 * notchSize, " -4 ").concat(2 * notchSize, " ") + "l ".concat(-4 * multiplier * notchSize, " ").concat(4 * multiplier * notchSize, " ") + "c -1 ".concat(1 * notchSize, " -2 ").concat(2 * notchSize, " -4 ").concat(2 * notchSize, " ") + "c ".concat(-4 * (multiplier - 0.5), " 0 ").concat(-8 * (multiplier - 0.5), " ").concat(-8 * (multiplier - 0.5) * notchSize, " ").concat(-12 * (multiplier - 0.5), " ").concat(-8 * (multiplier - 0.5) * notchSize, " ") + "c ".concat(-4 * (multiplier - 0.5), " 0 ").concat(-8 * (multiplier - 0.5), " ").concat(8 * (multiplier - 0.5) * notchSize, " ").concat(-12 * (multiplier - 0.5), " ").concat(8 * (multiplier - 0.5) * notchSize, " ") + "c -2 0 -3 ".concat(-1 * notchSize, " -4 ").concat(-2 * notchSize, " ") + "l ".concat(-4 * multiplier * notchSize, " ").concat(-4 * multiplier * notchSize, " ") + "c -1 ".concat(-1 * notchSize, " -2 ").concat(-2 * notchSize, " -4 ").concat(-2 * notchSize, " "); BlockSvg.INPUT_SHAPE_HEXAGONAL = "M " + 4 * GRID_UNIT * multiplier + ",0 " + " h " + 4 * GRID_UNIT + " l " + 4 * GRID_UNIT * multiplier + "," + 4 * GRID_UNIT * multiplier + " l " + -4 * GRID_UNIT * multiplier + "," + 4 * GRID_UNIT * multiplier + " h " + -4 * GRID_UNIT + " l " + -4 * GRID_UNIT * multiplier + "," + -4 * GRID_UNIT * multiplier + " l " + 4 * GRID_UNIT * multiplier + "," + -4 * GRID_UNIT * multiplier + " z"; BlockSvg.INPUT_SHAPE_HEXAGONAL_WIDTH = 12 * GRID_UNIT * multiplier; BlockSvg.INPUT_SHAPE_ROUND = "M " + 4 * GRID_UNIT * multiplier + ",0" + " h " + 4 * GRID_UNIT * multiplier + " a " + 4 * GRID_UNIT * multiplier + " " + 4 * GRID_UNIT * multiplier + " 0 0 1 0 " + 8 * GRID_UNIT * multiplier + " h " + -4 * GRID_UNIT * multiplier + " a " + 4 * GRID_UNIT * multiplier + " " + 4 * GRID_UNIT * multiplier + " 0 0 1 0 -" + 8 * GRID_UNIT * multiplier + " z"; BlockSvg.INPUT_SHAPE_ROUND_WIDTH = 12 * GRID_UNIT * multiplier; BlockSvg.INPUT_SHAPE_HEIGHT = 8 * GRID_UNIT * multiplier; BlockSvg.FIELD_HEIGHT = 8 * GRID_UNIT * multiplier; // NOTE: Determines string input heights BlockSvg.FIELD_WIDTH = 6 * GRID_UNIT * Math.min(multiplier, 1) + 10 * GRID_UNIT * Math.max(multiplier - 1, 0); BlockSvg.FIELD_DEFAULT_CORNER_RADIUS = 4 * GRID_UNIT * multiplier; BlockSvg.EDITABLE_FIELD_PADDING = 1.5 * GRID_UNIT * multiplier; BlockSvg.BOX_FIELD_PADDING = 2 * GRID_UNIT * multiplier; BlockSvg.DROPDOWN_ARROW_PADDING = 2 * GRID_UNIT * multiplier; BlockSvg.FIELD_WIDTH_MIN_EDIT = 8 * GRID_UNIT * multiplier; BlockSvg.INPUT_AND_FIELD_MIN_X = 12 * GRID_UNIT * multiplier; BlockSvg.INLINE_PADDING_Y = 1 * GRID_UNIT * multiplier; // For when reporters are inside reporters BlockSvg.SHAPE_IN_SHAPE_PADDING[1][0] = 5 * GRID_UNIT * multiplier; BlockSvg.SHAPE_IN_SHAPE_PADDING[1][2] = 5 * GRID_UNIT * multiplier; BlockSvg.SHAPE_IN_SHAPE_PADDING[1][3] = 5 * GRID_UNIT * multiplier; var originalDropdownObject = BlocklyInstance.FieldDropdown.prototype.positionArrow; BlocklyInstance.FieldDropdown.prototype.positionArrow = function (x) { this.arrowY_ = 11 * multiplier; return originalDropdownObject.call(this, x); }; // Corner setting BlockSvg.CORNER_RADIUS = 1 * GRID_UNIT * cornerSize * 100 / 100; BlockSvg.TOP_LEFT_CORNER_START = "m 0," + BlockSvg.CORNER_RADIUS; BlockSvg.TOP_LEFT_CORNER = "A " + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS + " 0 0,1 " + BlockSvg.CORNER_RADIUS + ",0"; BlockSvg.TOP_RIGHT_CORNER = "a " + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS + " 0 0,1 " + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS; BlockSvg.BOTTOM_RIGHT_CORNER = " a " + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS + " 0 0,1 -" + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS; BlockSvg.BOTTOM_LEFT_CORNER = "a " + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS + " 0 0,1 -" + BlockSvg.CORNER_RADIUS + ",-" + BlockSvg.CORNER_RADIUS; BlockSvg.INNER_TOP_LEFT_CORNER = " a " + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS + " 0 0,0 -" + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS; BlockSvg.INNER_BOTTOM_LEFT_CORNER = "a " + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS + " 0 0,0 " + BlockSvg.CORNER_RADIUS + "," + BlockSvg.CORNER_RADIUS; BlockSvg.TOP_RIGHT_CORNER_DEFINE_HAT = "a " + BlockSvg.DEFINE_HAT_CORNER_RADIUS + "," + BlockSvg.DEFINE_HAT_CORNER_RADIUS + " 0 0,1 " + BlockSvg.DEFINE_HAT_CORNER_RADIUS + "," + BlockSvg.DEFINE_HAT_CORNER_RADIUS + " v " + (1 * GRID_UNIT - BlockSvg.CORNER_RADIUS); BlockSvg.STATEMENT_INPUT_INNER_SPACE = 2.8 * GRID_UNIT - 0.9 * GRID_UNIT * cornerSize; } function applyAndUpdate() { applyChanges(...arguments); updateAllBlocks(); } addon.settings.addEventListener("change", () => applyAndUpdate()); addon.self.addEventListener("disabled", () => { // Scratch 3.0 blocks applyAndUpdate(100, 100, 100); }); addon.self.addEventListener("reenabled", () => applyAndUpdate()); applyAndUpdate(); })(window.Blockly); }); /***/ }) }]); //# sourceMappingURL=addon-entry-custom-block-shape.js.map