Skip to content
Snippets Groups Projects
Commit 7b9e22c6 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Change the order of params to makeToolboxXML

parent 8aa1d6e3
No related branches found
No related tags found
No related merge requests found
...@@ -175,7 +175,7 @@ class Blocks extends React.Component { ...@@ -175,7 +175,7 @@ class Blocks extends React.Component {
// When we change sprites, update the toolbox to have the new sprite's blocks // When we change sprites, update the toolbox to have the new sprite's blocks
if (this.props.vm.editingTarget) { if (this.props.vm.editingTarget) {
const target = this.props.vm.editingTarget; const target = this.props.vm.editingTarget;
this.props.updateToolboxState(makeToolboxXML(target.id, target.isStage)); this.props.updateToolboxState(makeToolboxXML(target.isStage, target.id));
} }
if (this.props.vm.editingTarget && !this.state.workspaceMetrics[this.props.vm.editingTarget.id]) { if (this.props.vm.editingTarget && !this.state.workspaceMetrics[this.props.vm.editingTarget.id]) {
...@@ -202,7 +202,7 @@ class Blocks extends React.Component { ...@@ -202,7 +202,7 @@ class Blocks extends React.Component {
this.ScratchBlocks.defineBlocksWithJsonArray(blocksInfo.map(blockInfo => blockInfo.json)); this.ScratchBlocks.defineBlocksWithJsonArray(blocksInfo.map(blockInfo => blockInfo.json));
const dynamicBlocksXML = this.props.vm.runtime.getBlocksXML(); const dynamicBlocksXML = this.props.vm.runtime.getBlocksXML();
const target = this.props.vm.editingTarget; const target = this.props.vm.editingTarget;
const toolboxXML = makeToolboxXML(target.id, target.isStage, dynamicBlocksXML); const toolboxXML = makeToolboxXML(target.isStage, target.id, dynamicBlocksXML);
this.props.updateToolboxState(toolboxXML); this.props.updateToolboxState(toolboxXML);
} }
handleCategorySelected (categoryName) { handleCategorySelected (categoryName) {
......
...@@ -2,7 +2,7 @@ const categorySeparator = '<sep gap="36"/>'; ...@@ -2,7 +2,7 @@ const categorySeparator = '<sep gap="36"/>';
const blockSeparator = '<sep gap="36"/>'; // At default scale, about 28px const blockSeparator = '<sep gap="36"/>'; // At default scale, about 28px
const motion = function (targetId, isStage) { const motion = function (isStage, targetId) {
return ` return `
<category name="Motion" colour="#4C97FF" secondaryColour="#3373CC"> <category name="Motion" colour="#4C97FF" secondaryColour="#3373CC">
${isStage ? ` ${isStage ? `
...@@ -132,7 +132,7 @@ const motion = function (targetId, isStage) { ...@@ -132,7 +132,7 @@ const motion = function (targetId, isStage) {
`; `;
}; };
const looks = function (targetId, isStage) { const looks = function (isStage, targetId) {
return ` return `
<category name="Looks" colour="#9966FF" secondaryColour="#774DCB"> <category name="Looks" colour="#9966FF" secondaryColour="#774DCB">
${isStage ? '' : ` ${isStage ? '' : `
...@@ -346,7 +346,7 @@ const events = function () { ...@@ -346,7 +346,7 @@ const events = function () {
`; `;
}; };
const control = function (_targetId, isStage) { const control = function (isStage) {
return ` return `
<category name="Control" colour="#FFAB19" secondaryColour="#CF8B17"> <category name="Control" colour="#FFAB19" secondaryColour="#CF8B17">
<block type="control_wait"> <block type="control_wait">
...@@ -393,7 +393,7 @@ const control = function (_targetId, isStage) { ...@@ -393,7 +393,7 @@ const control = function (_targetId, isStage) {
`; `;
}; };
const sensing = function (_targetId, isStage) { const sensing = function (isStage) {
return ` return `
<category name="Sensing" colour="#4CBFE6" secondaryColour="#2E8EB8"> <category name="Sensing" colour="#4CBFE6" secondaryColour="#2E8EB8">
${isStage ? '' : ` ${isStage ? '' : `
...@@ -658,24 +658,24 @@ const xmlOpen = '<xml style="display: none">'; ...@@ -658,24 +658,24 @@ const xmlOpen = '<xml style="display: none">';
const xmlClose = '</xml>'; const xmlClose = '</xml>';
/** /**
* @param {!string} targetId - The current editing target
* @param {!boolean} isStage - Whether the toolbox is for a stage-type target. * @param {!boolean} isStage - Whether the toolbox is for a stage-type target.
* @param {!string} targetId - The current editing target
* @param {string?} categoriesXML - null for default toolbox, or an XML string with <category> elements. * @param {string?} categoriesXML - null for default toolbox, or an XML string with <category> elements.
* @returns {string} - a ScratchBlocks-style XML document for the contents of the toolbox. * @returns {string} - a ScratchBlocks-style XML document for the contents of the toolbox.
*/ */
const makeToolboxXML = function (targetId, isStage, categoriesXML) { const makeToolboxXML = function (isStage, targetId, categoriesXML) {
const gap = [categorySeparator]; const gap = [categorySeparator];
const everything = [ const everything = [
xmlOpen, xmlOpen,
motion(targetId, isStage), gap, motion(isStage, targetId), gap,
looks(targetId, isStage), gap, looks(isStage, targetId), gap,
sound(targetId, isStage), gap, sound(isStage, targetId), gap,
events(targetId, isStage), gap, events(isStage, targetId), gap,
control(targetId, isStage), gap, control(isStage, targetId), gap,
sensing(targetId, isStage), gap, sensing(isStage, targetId), gap,
operators(targetId, isStage), gap, operators(isStage, targetId), gap,
data(targetId, isStage) data(isStage, targetId)
]; ];
if (categoriesXML) { if (categoriesXML) {
......
...@@ -2,7 +2,7 @@ const UPDATE_TOOLBOX = 'scratch-gui/toolbox/UPDATE_TOOLBOX'; ...@@ -2,7 +2,7 @@ const UPDATE_TOOLBOX = 'scratch-gui/toolbox/UPDATE_TOOLBOX';
import makeToolboxXML from '../lib/make-toolbox-xml'; import makeToolboxXML from '../lib/make-toolbox-xml';
const initialState = { const initialState = {
toolboxXML: makeToolboxXML('', true) toolboxXML: makeToolboxXML(true)
}; };
const reducer = function (state, action) { const reducer = function (state, action) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment