Merge pull request #833 from paulkaplan/update-block-spacing

Add block chunking to toolbox xml
This commit is contained in:
Paul Kaplan authored and GitHub committed 2017-11-02 10:03:18 -04:00
commit d0fe2e83da
1 file changed
+45 -3
+45 -3
View File
@@ -1,4 +1,6 @@
const separator = '<sep gap="45"/>';
const categorySeparator = '<sep gap="36"/>';
const blockSeparator = '<sep gap="36"/>'; // At default scale, about 28px
const motion = `
<category name="Motion" colour="#4C97FF" secondaryColour="#3373CC">
@@ -23,6 +25,7 @@ const motion = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="motion_pointindirection">
<value name="DIRECTION">
<shadow type="math_angle">
@@ -36,6 +39,7 @@ const motion = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="motion_gotoxy">
<value name="X">
<shadow id="movex" type="math_number">
@@ -82,6 +86,7 @@ const motion = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="motion_changexby">
<value name="DX">
<shadow type="math_number">
@@ -110,11 +115,15 @@ const motion = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="motion_ifonedgebounce"/>
${blockSeparator}
<block type="motion_setrotationstyle"/>
${blockSeparator}
<block id="xposition" type="motion_xposition"/>
<block id="yposition" type="motion_yposition"/>
<block id="direction" type="motion_direction"/>
${categorySeparator}
</category>
`;
@@ -158,8 +167,10 @@ const looks = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="looks_show"/>
<block type="looks_hide"/>
${blockSeparator}
<block type="looks_switchcostumeto">
<value name="COSTUME">
<shadow type="looks_costume"/>
@@ -177,6 +188,7 @@ const looks = `
<shadow type="looks_backdrops"/>
</value>
</block>
${blockSeparator}
<block type="looks_changeeffectby">
<value name="CHANGE">
<shadow type="math_number">
@@ -192,6 +204,7 @@ const looks = `
</value>
</block>
<block type="looks_cleargraphiceffects"/>
${blockSeparator}
<block type="looks_changesizeby">
<value name="CHANGE">
<shadow type="math_number">
@@ -206,6 +219,7 @@ const looks = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="looks_gotofront"/>
<block type="looks_gobacklayers">
<value name="NUM">
@@ -214,10 +228,12 @@ const looks = `
</shadow>
</value>
</block>
${blockSeparator}
<block id="costumeorder" type="looks_costumeorder"/>
<block id="backdroporder" type="looks_backdroporder"/>
<block id="backdropname" type="looks_backdropname"/>
<block id="size" type="looks_size"/>
${categorySeparator}
</category>
`;
@@ -234,6 +250,7 @@ const sound = `
</value>
</block>
<block type="sound_stopallsounds"/>
${blockSeparator}
<block type="sound_playdrumforbeats">
<value name="DRUM">
<shadow type="sound_drums_menu"/>
@@ -251,6 +268,7 @@ const sound = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="sound_playnoteforbeats">
<value name="NOTE">
<shadow type="math_number">
@@ -268,6 +286,7 @@ const sound = `
<shadow type="sound_instruments_menu"/>
</value>
</block>
${blockSeparator}
<block type="sound_changeeffectby">
<value name="VALUE">
<shadow type="math_number">
@@ -283,6 +302,7 @@ const sound = `
</value>
</block>
<block type="sound_cleareffects"/>
${blockSeparator}
<block type="sound_changevolumeby">
<value name="VOLUME">
<shadow type="math_number">
@@ -298,6 +318,7 @@ const sound = `
</value>
</block>
<block id="volume" type="sound_volume"/>
${blockSeparator}
<block type="sound_changetempoby">
<value name="TEMPO">
<shadow type="math_number">
@@ -313,6 +334,7 @@ const sound = `
</value>
</block>
<block id="tempo" type="sound_tempo"/>
${categorySeparator}
</category>
`;
@@ -324,6 +346,7 @@ const events = `
<block type="event_whenthisspriteclicked"/>
<block type="event_whenbackdropswitchesto">
</block>
${blockSeparator}
<block type="event_whengreaterthan">
<value name="VALUE">
<shadow type="math_number">
@@ -331,6 +354,7 @@ const events = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="event_whenbroadcastreceived">
</block>
<block type="event_broadcast">
@@ -343,6 +367,7 @@ const events = `
<shadow type="event_broadcast_menu"/>
</value>
</block>
${categorySeparator}
</category>
`;
@@ -355,6 +380,7 @@ const control = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="control_repeat">
<value name="TIMES">
<shadow type="math_whole_number">
@@ -363,11 +389,14 @@ const control = `
</value>
</block>
<block type="control_forever"/>
${blockSeparator}
<block type="control_if"/>
<block type="control_if_else"/>
<block type="control_wait_until"/>
<block type="control_repeat_until"/>
${blockSeparator}
<block type="control_stop"/>
${blockSeparator}
<block type="control_start_as_clone"/>
<block type="control_create_clone_of">
<value name="CLONE_OPTION">
@@ -375,6 +404,7 @@ const control = `
</value>
</block>
<block type="control_delete_this_clone"/>
${categorySeparator}
</category>
`;
@@ -403,6 +433,7 @@ const sensing = `
<shadow type="sensing_distancetomenu"/>
</value>
</block>
${blockSeparator}
<block type="sensing_keypressed">
<value name="KEY_OPTION">
<shadow type="sensing_keyoptions"/>
@@ -411,9 +442,12 @@ const sensing = `
<block type="sensing_mousedown"/>
<block type="sensing_mousex"/>
<block type="sensing_mousey"/>
${blockSeparator}
<block id="loudness" type="sensing_loudness"/>
${blockSeparator}
<block id="timer" type="sensing_timer"/>
<block type="sensing_resettimer"/>
${blockSeparator}
<block id="of" type="sensing_of">
<value name="PROPERTY">
<shadow id="sensing_of_property_menu" type="sensing_of_property_menu"/>
@@ -422,12 +456,14 @@ const sensing = `
<shadow id="sensing_of_object_menu" type="sensing_of_object_menu"/>
</value>
</block>
${blockSeparator}
<block id="current" type="sensing_current">
<value name="CURRENTMENU">
<shadow id="sensing_currentmenu" type="sensing_currentmenu"/>
</value>
</block>
<block type="sensing_dayssince2000"/>
${categorySeparator}
</category>
`;
@@ -481,6 +517,7 @@ const operators = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="operator_random">
<value name="FROM">
<shadow type="math_number">
@@ -493,6 +530,7 @@ const operators = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="operator_lt">
<value name="OPERAND1">
<shadow type="text">
@@ -529,9 +567,11 @@ const operators = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="operator_and"/>
<block type="operator_or"/>
<block type="operator_not"/>
${blockSeparator}
<block type="operator_join">
<value name="STRING1">
<shadow type="text">
@@ -563,6 +603,7 @@ const operators = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="operator_mod">
<value name="NUM1">
<shadow type="math_number">
@@ -582,6 +623,7 @@ const operators = `
</shadow>
</value>
</block>
${blockSeparator}
<block type="operator_mathop">
<value name="NUM">
<shadow type="math_number">
@@ -589,6 +631,7 @@ const operators = `
</shadow>
</value>
</block>
${categorySeparator}
</category>
`;
@@ -605,7 +648,7 @@ const xmlClose = '</xml>';
* @returns {string} - a ScratchBlocks-style XML document for the contents of the toolbox.
*/
const makeToolboxXML = function (categoriesXML) {
const gap = [separator];
const gap = [categorySeparator];
const everything = [
xmlOpen,
@@ -624,7 +667,6 @@ const makeToolboxXML = function (categoriesXML) {
}
everything.push(xmlClose);
return everything.join('\n');
};