|
11 | 11 | } |
12 | 12 |
|
13 | 13 | const BlockType = Scratch.BlockType |
| 14 | + const BlockShape = Scratch.BlockShape |
14 | 15 | const ArgumentType = Scratch.ArgumentType |
15 | 16 | const Cast = Scratch.Cast |
16 | 17 | const vm = Scratch.vm; |
17 | 18 |
|
18 | | - if (Scratch.gui) { |
19 | | - Scratch.gui.getBlockly().then(ScratchBlocks => { |
20 | | - ScratchBlocks.BlockSvg.registerCustomShape( |
21 | | - "dogeiscutRegularExpressions-RegularExpression",{ |
| 19 | + if (!vm.runtime.pmVersion) { |
| 20 | + if (Scratch.gui) { |
| 21 | + Scratch.gui.getBlockly().then(ScratchBlocks => { |
| 22 | + ScratchBlocks.BlockSvg.registerCustomShape( |
| 23 | + "dogeiscutRegularExpressions-RegularExpression", { |
22 | 24 | emptyInputPath: "m 16 0 h 16 h 32 l -16 32 h -16 h -16 h -16 z", |
23 | 25 | emptyInputWidth: 16 * ScratchBlocks.BlockSvg.GRID_UNIT, |
24 | 26 | leftPath: (block) => { |
|
45 | 47 | return (row.height - 16) / 2; |
46 | 48 | } |
47 | 49 | } |
48 | | - ); |
49 | | - }) |
| 50 | + ); |
| 51 | + }) |
| 52 | + } |
50 | 53 | } |
51 | 54 |
|
52 | 55 | function span(text) { |
|
244 | 247 | Type: RegularExpressionType, |
245 | 248 | Block: { |
246 | 249 | blockType: BlockType.REPORTER, |
247 | | - blockShape: 'dogeiscutRegularExpressions-RegularExpression', |
| 250 | + blockShape: vm.runtime.pmVersion ? BlockShape.SLANTED : 'dogeiscutRegularExpressions-RegularExpression', |
248 | 251 | forceOutputType: "Regular Expression", |
249 | 252 | disableMonitor: true |
250 | 253 | }, |
251 | 254 | Argument: { |
252 | | - shape: 'dogeiscutRegularExpressions-RegularExpression', |
| 255 | + shape: vm.runtime.pmVersion ? BlockShape.SLANTED : 'dogeiscutRegularExpressions-RegularExpression', |
253 | 256 | exemptFromNormalization: true, |
254 | 257 | check: ["Regular Expression"], |
255 | 258 | }, |
|
279 | 282 | // blockType: BlockType.BUTTON, |
280 | 283 | // text: '⚠ Add Missing Dependencies ⚠', |
281 | 284 | // func: "addDependencies", |
282 | | - // hideFromPalette: !!vm.runtime.ext_jwArray & !!vm.runtime.ext_dogeiscutObject, |
| 285 | + // hideFromPalette: !!vm.jwArray & !!vm.dogeiscutObject, |
283 | 286 | // }, |
284 | | - // ...(!vm.runtime.ext_jwArray || !vm.runtime.ext_dogeiscutObject ? ['---'] : []), |
| 287 | + // ...(!vm.jwArray || !vm.dogeiscutObject ? ['---'] : []), |
285 | 288 | { |
286 | 289 | opcode: 'regex', |
287 | 290 | text: 'regular expression [PATTERN] [FLAGS]', |
|
398 | 401 | }, |
399 | 402 | REGEX: dogeiscutRegularExpression.Argument, |
400 | 403 | }, |
401 | | - hideFromPalette: !vm.runtime.ext_jwArray, |
402 | | - ...(vm.runtime.ext_jwArray ? vm.jwArray.Block : {}), |
| 404 | + hideFromPalette: !vm.jwArray, |
| 405 | + ...(vm.jwArray ? vm.jwArray.Block : {}), |
403 | 406 | }, |
404 | 407 | { |
405 | 408 | opcode: 'match', |
|
411 | 414 | defaultValue: "foo" |
412 | 415 | }, |
413 | 416 | }, |
414 | | - hideFromPalette: !vm.runtime.ext_jwArray, |
415 | | - ...(vm.runtime.ext_jwArray ? vm.jwArray.Block : {}), |
| 417 | + hideFromPalette: !vm.jwArray, |
| 418 | + ...(vm.jwArray ? vm.jwArray.Block : {}), |
416 | 419 | }, |
417 | 420 | { |
418 | 421 | opcode: 'matchAll', |
|
424 | 427 | defaultValue: "foo" |
425 | 428 | }, |
426 | 429 | }, |
427 | | - hideFromPalette: !vm.runtime.ext_jwArray, |
428 | | - ...(vm.runtime.ext_jwArray ? vm.jwArray.Block : {}), |
| 430 | + hideFromPalette: !vm.jwArray, |
| 431 | + ...(vm.jwArray ? vm.jwArray.Block : {}), |
429 | 432 | }, |
430 | 433 | '---', |
431 | 434 | { |
|
438 | 441 | defaultValue: "foo" |
439 | 442 | }, |
440 | 443 | }, |
441 | | - hideFromPalette: !vm.runtime.ext_dogeiscutObject, |
442 | | - ...(vm.runtime.ext_dogeiscutObject ? vm.dogeiscutObject.Block : {}), |
| 444 | + hideFromPalette: !vm.dogeiscutObject, |
| 445 | + ...(vm.dogeiscutObject ? vm.dogeiscutObject.Block : {}), |
443 | 446 | }, |
444 | 447 | { |
445 | 448 | opcode: 'getLastIndex', |
|
476 | 479 | async addDependencies() { |
477 | 480 | let string ='Due to missing extensions, the blocks in this extension have been reduced.\n' |
478 | 481 | string += 'By confirming this prompt, the following extensions will automatically be added for you:\n\n' |
479 | | - if (!vm.runtime.ext_jwArray) string += '• Arrays by jwklong\n' |
480 | | - if (!vm.runtime.ext_dogeiscutObject) string += '• Objects by DogeisCut\n' |
| 482 | + if (!vm.jwArray) string += '• Arrays by jwklong\n' |
| 483 | + if (!vm.dogeiscutObject) string += '• Objects by DogeisCut\n' |
481 | 484 | if (confirm(string)) { |
482 | 485 | // technically i only need to load objects since that will load arrays, but just in case |
483 | | - if (!vm.runtime.ext_jwArray) vm.extensionManager.loadExtensionIdSync('jwArray') |
484 | | - if (!vm.runtime.ext_dogeiscutObject) await vm.extensionManager.loadExtensionURL("https://extensions.penguinmod.com/extensions/DogeisCut/dogeiscutObject.js") |
| 486 | + if (!vm.jwArray) vm.extensionManager.loadExtensionIdSync('jwArray') |
| 487 | + if (!vm.dogeiscutObject) await vm.extensionManager.loadExtensionURL("https://extensions.penguinmod.com/extensions/DogeisCut/dogeiscutObject.js") |
485 | 488 | vm.runtime.requestBlocksUpdate() |
486 | 489 | vm.runtime.requestToolboxExtensionsUpdate() |
487 | 490 | vm.emitWorkspaceUpdate() |
|
584 | 587 | } |
585 | 588 |
|
586 | 589 | (async () => { |
587 | | - if (!vm.runtime.ext_dogeiscutObject) await vm.extensionManager.loadExtensionURL("https://extensions.penguinmod.com/extensions/DogeisCut/dogeiscutObject.js") |
588 | | - if (!vm.runtime.ext_jwArray) vm.extensionManager.loadExtensionIdSync('jwArray') |
| 590 | + if (!vm.dogeiscutObject) await vm.extensionManager.loadExtensionURL("https://extensions.penguinmod.com/extensions/DogeisCut/dogeiscutObject.js") |
| 591 | + if (!vm.jwArray) vm.extensionManager.loadExtensionIdSync('jwArray') |
589 | 592 | vm.runtime.requestBlocksUpdate() |
590 | 593 | vm.runtime.requestToolboxExtensionsUpdate() |
591 | 594 | vm.emitWorkspaceUpdate() |
|
0 commit comments