@@ -4,7 +4,7 @@ const categorySeparator = '<sep gap="36"/>';
4
4
5
5
const blockSeparator = '<sep gap="36"/>' ; // At default scale, about 28px
6
6
7
- const motion = function ( isStage , targetId ) {
7
+ const motion = function ( _ , isStage , targetId ) {
8
8
const stageSelected = ScratchBlocks . ScratchMsgs . translate (
9
9
'MOTION_STAGE_SELECTED' ,
10
10
'Stage selected: no motion blocks'
@@ -150,7 +150,7 @@ const xmlEscape = function (unsafe) {
150
150
} ) ;
151
151
} ;
152
152
153
- const looks = function ( isStage , targetId , costumeName , backdropName ) {
153
+ const looks = function ( _ , isStage , targetId , costumeName , backdropName ) {
154
154
const hello = ScratchBlocks . ScratchMsgs . translate ( 'LOOKS_HELLO' , 'Hello!' ) ;
155
155
const hmm = ScratchBlocks . ScratchMsgs . translate ( 'LOOKS_HMM' , 'Hmm...' ) ;
156
156
return `
@@ -287,7 +287,7 @@ const looks = function (isStage, targetId, costumeName, backdropName) {
287
287
` ;
288
288
} ;
289
289
290
- const sound = function ( isStage , targetId , soundName ) {
290
+ const sound = function ( _ , isStage , targetId , soundName ) {
291
291
return `
292
292
<category name="%{BKY_CATEGORY_SOUND}" id="sound" colour="#D65CD6" secondaryColour="#BD42BD">
293
293
<block id="${ targetId } _sound_playuntildone" type="sound_playuntildone">
@@ -342,7 +342,7 @@ const sound = function (isStage, targetId, soundName) {
342
342
` ;
343
343
} ;
344
344
345
- const events = function ( isStage ) {
345
+ const events = function ( _ , isStage ) {
346
346
return `
347
347
<category name="%{BKY_CATEGORY_EVENTS}" id="events" colour="#FFD500" secondaryColour="#CC9900">
348
348
<block type="event_whenflagclicked"/>
@@ -381,7 +381,7 @@ const events = function (isStage) {
381
381
` ;
382
382
} ;
383
383
384
- const control = function ( isStage ) {
384
+ const control = function ( _ , isStage ) {
385
385
return `
386
386
<category name="%{BKY_CATEGORY_CONTROL}" id="control" colour="#FFAB19" secondaryColour="#CF8B17">
387
387
<block type="control_wait">
@@ -428,7 +428,7 @@ const control = function (isStage) {
428
428
` ;
429
429
} ;
430
430
431
- const sensing = function ( isStage ) {
431
+ const sensing = function ( isInitialSetup , isStage ) {
432
432
const name = ScratchBlocks . ScratchMsgs . translate ( 'SENSING_ASK_TEXT' , 'What\'s your name?' ) ;
433
433
return `
434
434
<category name="%{BKY_CATEGORY_SENSING}" id="sensing" colour="#4CBFE6" secondaryColour="#2E8EB8">
@@ -458,13 +458,15 @@ const sensing = function (isStage) {
458
458
</block>
459
459
${ blockSeparator }
460
460
` }
461
- <block id="askandwait" type="sensing_askandwait">
462
- <value name="QUESTION">
463
- <shadow type="text">
464
- <field name="TEXT">${ name } </field>
465
- </shadow>
466
- </value>
467
- </block>
461
+ ${ isInitialSetup ? '' : `
462
+ <block id="askandwait" type="sensing_askandwait">
463
+ <value name="QUESTION">
464
+ <shadow type="text">
465
+ <field name="TEXT">${ name } </field>
466
+ </shadow>
467
+ </value>
468
+ </block>
469
+ ` }
468
470
<block id="answer" type="sensing_answer"/>
469
471
${ blockSeparator }
470
472
<block type="sensing_keypressed">
@@ -501,7 +503,7 @@ const sensing = function (isStage) {
501
503
` ;
502
504
} ;
503
505
504
- const operators = function ( ) {
506
+ const operators = function ( isInitialSetup ) {
505
507
const apple = ScratchBlocks . ScratchMsgs . translate ( 'OPERATORS_JOIN_APPLE' , 'apple' ) ;
506
508
const banana = ScratchBlocks . ScratchMsgs . translate ( 'OPERATORS_JOIN_BANANA' , 'banana' ) ;
507
509
const letter = ScratchBlocks . ScratchMsgs . translate ( 'OPERATORS_LETTEROF_APPLE' , 'a' ) ;
@@ -610,49 +612,51 @@ const operators = function () {
610
612
<block type="operator_or"/>
611
613
<block type="operator_not"/>
612
614
${ blockSeparator }
613
- <block type="operator_join">
614
- <value name="STRING1">
615
- <shadow type="text">
616
- <field name="TEXT">${ apple } </field>
617
- </shadow>
618
- </value>
619
- <value name="STRING2">
620
- <shadow type="text">
621
- <field name="TEXT">${ banana } </field>
622
- </shadow>
623
- </value>
624
- </block>
625
- <block type="operator_letter_of">
626
- <value name="LETTER">
627
- <shadow type="math_whole_number">
628
- <field name="NUM">1</field>
629
- </shadow>
630
- </value>
631
- <value name="STRING">
615
+ ${ isInitialSetup ? '' : `
616
+ <block type="operator_join">
617
+ <value name="STRING1">
618
+ <shadow type="text">
619
+ <field name="TEXT">${ apple } </field>
620
+ </shadow>
621
+ </value>
622
+ <value name="STRING2">
623
+ <shadow type="text">
624
+ <field name="TEXT">${ banana } </field>
625
+ </shadow>
626
+ </value>
627
+ </block>
628
+ <block type="operator_letter_of">
629
+ <value name="LETTER">
630
+ <shadow type="math_whole_number">
631
+ <field name="NUM">1</field>
632
+ </shadow>
633
+ </value>
634
+ <value name="STRING">
635
+ <shadow type="text">
636
+ <field name="TEXT">${ apple } </field>
637
+ </shadow>
638
+ </value>
639
+ </block>
640
+ <block type="operator_length">
641
+ <value name="STRING">
642
+ <shadow type="text">
643
+ <field name="TEXT">${ apple } </field>
644
+ </shadow>
645
+ </value>
646
+ </block>
647
+ <block type="operator_contains" id="operator_contains">
648
+ <value name="STRING1">
632
649
<shadow type="text">
633
- <field name="TEXT">${ apple } </field>
650
+ <field name="TEXT">${ apple } </field>
634
651
</shadow>
635
- </value>
636
- </block>
637
- <block type="operator_length">
638
- <value name="STRING">
652
+ </value>
653
+ <value name="STRING2">
639
654
<shadow type="text">
640
- <field name="TEXT">${ apple } </field>
655
+ <field name="TEXT">${ letter } </field>
641
656
</shadow>
642
- </value>
643
- </block>
644
- <block type="operator_contains" id="operator_contains">
645
- <value name="STRING1">
646
- <shadow type="text">
647
- <field name="TEXT">${ apple } </field>
648
- </shadow>
649
- </value>
650
- <value name="STRING2">
651
- <shadow type="text">
652
- <field name="TEXT">${ letter } </field>
653
- </shadow>
654
- </value>
655
- </block>
657
+ </value>
658
+ </block>
659
+ ` }
656
660
${ blockSeparator }
657
661
<block type="operator_mod">
658
662
<value name="NUM1">
@@ -714,7 +718,10 @@ const xmlOpen = '<xml style="display: none">';
714
718
const xmlClose = '</xml>' ;
715
719
716
720
/**
717
- * @param {!boolean } isStage - Whether the toolbox is for a stage-type target.
721
+ * @param {!boolean } isInitialSetup - Whether the toolbox is for initial setup. If the mode is "initial setup",
722
+ * blocks with localized default parameters (e.g. ask and wait) should not be loaded. (LLK/scratch-gui#5445)
723
+ * @param {?boolean } isStage - Whether the toolbox is for a stage-type target. This is always set to true
724
+ * when isInitialSetup is true.
718
725
* @param {?string } targetId - The current editing target
719
726
* @param {?Array.<object> } categoriesXML - optional array of `{id,xml}` for categories. This can include both core
720
727
* and other extensions: core extensions will be placed in the normal Scratch order; others will go at the bottom.
@@ -725,8 +732,9 @@ const xmlClose = '</xml>';
725
732
* @param {?string } soundName - The name of the default selected sound dropdown.
726
733
* @returns {string } - a ScratchBlocks-style XML document for the contents of the toolbox.
727
734
*/
728
- const makeToolboxXML = function ( isStage , targetId , categoriesXML = [ ] ,
735
+ const makeToolboxXML = function ( isInitialSetup , isStage = true , targetId , categoriesXML = [ ] ,
729
736
costumeName = '' , backdropName = '' , soundName = '' ) {
737
+ isStage = isInitialSetup || isStage ;
730
738
const gap = [ categorySeparator ] ;
731
739
732
740
costumeName = xmlEscape ( costumeName ) ;
@@ -743,15 +751,15 @@ const makeToolboxXML = function (isStage, targetId, categoriesXML = [],
743
751
}
744
752
// return `undefined`
745
753
} ;
746
- const motionXML = moveCategory ( 'motion' ) || motion ( isStage , targetId ) ;
747
- const looksXML = moveCategory ( 'looks' ) || looks ( isStage , targetId , costumeName , backdropName ) ;
748
- const soundXML = moveCategory ( 'sound' ) || sound ( isStage , targetId , soundName ) ;
749
- const eventsXML = moveCategory ( 'event' ) || events ( isStage , targetId ) ;
750
- const controlXML = moveCategory ( 'control' ) || control ( isStage , targetId ) ;
751
- const sensingXML = moveCategory ( 'sensing' ) || sensing ( isStage , targetId ) ;
752
- const operatorsXML = moveCategory ( 'operators' ) || operators ( isStage , targetId ) ;
753
- const variablesXML = moveCategory ( 'data' ) || variables ( isStage , targetId ) ;
754
- const myBlocksXML = moveCategory ( 'procedures' ) || myBlocks ( isStage , targetId ) ;
754
+ const motionXML = moveCategory ( 'motion' ) || motion ( isInitialSetup , isStage , targetId ) ;
755
+ const looksXML = moveCategory ( 'looks' ) || looks ( isInitialSetup , isStage , targetId , costumeName , backdropName ) ;
756
+ const soundXML = moveCategory ( 'sound' ) || sound ( isInitialSetup , isStage , targetId , soundName ) ;
757
+ const eventsXML = moveCategory ( 'event' ) || events ( isInitialSetup , isStage , targetId ) ;
758
+ const controlXML = moveCategory ( 'control' ) || control ( isInitialSetup , isStage , targetId ) ;
759
+ const sensingXML = moveCategory ( 'sensing' ) || sensing ( isInitialSetup , isStage , targetId ) ;
760
+ const operatorsXML = moveCategory ( 'operators' ) || operators ( isInitialSetup , isStage , targetId ) ;
761
+ const variablesXML = moveCategory ( 'data' ) || variables ( isInitialSetup , isStage , targetId ) ;
762
+ const myBlocksXML = moveCategory ( 'procedures' ) || myBlocks ( isInitialSetup , isStage , targetId ) ;
755
763
756
764
const everything = [
757
765
xmlOpen ,
0 commit comments