From 4108a0a4e5a4bebf6789e10e7e9e2d12f4215337 Mon Sep 17 00:00:00 2001 From: Andrew Sliwinski Date: Wed, 8 Mar 2017 19:11:13 -0500 Subject: [PATCH 1/2] Do not accept an input for some drop-down meuns. Resolves GH-827 --- blocks_vertical/default_toolbox.js | 23 +++---------- blocks_vertical/looks.js | 52 +++++++++-------------------- blocks_vertical/operators.js | 31 ++--------------- blocks_vertical/sound.js | 53 +++++++++--------------------- 4 files changed, 37 insertions(+), 122 deletions(-) diff --git a/blocks_vertical/default_toolbox.js b/blocks_vertical/default_toolbox.js index cf05c8652b..1923c9bb71 100644 --- a/blocks_vertical/default_toolbox.js +++ b/blocks_vertical/default_toolbox.js @@ -196,9 +196,6 @@ Blockly.Blocks.defaultToolbox = ''+ - ''+ - ''+ - ''+ ''+ ''+ '10'+ @@ -206,9 +203,6 @@ Blockly.Blocks.defaultToolbox = ''+ - ''+ - ''+ - ''+ ''+ ''+ '10'+ @@ -289,23 +283,17 @@ Blockly.Blocks.defaultToolbox = '' + '' + ''+ - '' + - '' + - '' + - '' + + '' + '' + ''+ - '100'+ + '10'+ ''+ '' + '' + - '' + - '' + - '' + - '' + + '' + '' + ''+ - '10'+ + '100'+ ''+ '' + '' + @@ -741,9 +729,6 @@ Blockly.Blocks.defaultToolbox = ''+ - ''+ - ''+ - ''+ ''+ ''+ ''+ diff --git a/blocks_vertical/looks.js b/blocks_vertical/looks.js index 81259d4ff5..aa0196c7fe 100644 --- a/blocks_vertical/looks.js +++ b/blocks_vertical/looks.js @@ -169,39 +169,15 @@ Blockly.Blocks['looks_hide'] = { } }; -Blockly.Blocks['looks_effectmenu'] = { - /** - * Graphic effects drop-down menu. - * @this Blockly.Block - */ - init: function() { - this.jsonInit( - { - "message0": "%1", - "args0": [ - { - "type": "field_dropdown", - "name": "EFFECT", - "options": [ - ['color', 'COLOR'], - ['fisheye', 'FISHEYE'], - ['whirl', 'WHIRL'], - ['pixelate', 'PIXELATE'], - ['mosaic', 'MOSAIC'], - ['brightness', 'BRIGHTNESS'], - ['ghost', 'GHOST'] - ] - } - ], - "inputsInline": true, - "output": "String", - "colour": Blockly.Colours.looks.secondary, - "colourSecondary": Blockly.Colours.looks.secondary, - "colourTertiary": Blockly.Colours.looks.tertiary, - "outputShape": Blockly.OUTPUT_SHAPE_ROUND - }); - } -}; +Blockly.Blocks['looks_effect_menu_options'] = [ + ['color', 'COLOR'], + ['fisheye', 'FISHEYE'], + ['whirl', 'WHIRL'], + ['pixelate', 'PIXELATE'], + ['mosaic', 'MOSAIC'], + ['brightness', 'BRIGHTNESS'], + ['ghost', 'GHOST'] +]; Blockly.Blocks['looks_changeeffectby'] = { /** @@ -213,8 +189,9 @@ Blockly.Blocks['looks_changeeffectby'] = { "message0": "change effect %1 by %2", "args0": [ { - "type": "input_value", - "name": "EFFECT" + "type": "field_dropdown", + "name": "EFFECT", + "options": Blockly.Blocks['looks_effect_menu_options'] }, { "type": "input_value", @@ -242,8 +219,9 @@ Blockly.Blocks['looks_seteffectto'] = { "message0": "set effect %1 to %2", "args0": [ { - "type": "input_value", - "name": "EFFECT" + "type": "field_dropdown", + "name": "EFFECT", + "options": Blockly.Blocks['looks_effect_menu_options'] }, { "type": "input_value", diff --git a/blocks_vertical/operators.js b/blocks_vertical/operators.js index d518fa86a8..f2f52a3ca1 100644 --- a/blocks_vertical/operators.js +++ b/blocks_vertical/operators.js @@ -491,15 +491,15 @@ Blockly.Blocks['operator_round'] = { } }; -Blockly.Blocks['operator_mathop_menu'] = { +Blockly.Blocks['operator_mathop'] = { /** - * Math ops drop-down menu. + * Block for "advanced" math ops on a number. * @this Blockly.Block */ init: function() { this.jsonInit( { - "message0": "%1", + "message0": "%1 of %2", "args0": [ { "type": "field_dropdown", @@ -520,31 +520,6 @@ Blockly.Blocks['operator_mathop_menu'] = { ['e ^', 'e ^'], ['10 ^', '10 ^'] ] - } - ], - "inputsInline": true, - "output": "String", - "colour": Blockly.Colours.operators.secondary, - "colourSecondary": Blockly.Colours.operators.secondary, - "colourTertiary": Blockly.Colours.operators.tertiary, - "outputShape": Blockly.OUTPUT_SHAPE_ROUND - }); - } -}; - -Blockly.Blocks['operator_mathop'] = { - /** - * Block for "advanced" math ops on a number. - * @this Blockly.Block - */ - init: function() { - this.jsonInit( - { - "message0": "%1 of %2", - "args0": [ - { - "type": "input_value", - "name": "OPERATOR" }, { "type": "input_value", diff --git a/blocks_vertical/sound.js b/blocks_vertical/sound.js index b38c41087d..f2b64428a4 100644 --- a/blocks_vertical/sound.js +++ b/blocks_vertical/sound.js @@ -26,7 +26,6 @@ goog.require('Blockly.Blocks'); goog.require('Blockly.Colours'); goog.require('Blockly.constants'); - Blockly.Blocks['sound_sounds_menu'] = { /** * Sound effects drop-down menu. @@ -256,38 +255,14 @@ Blockly.Blocks['sound_playnoteforbeats'] = { } }; -Blockly.Blocks['sound_effects_menu'] = { - /** - * Sound effects drop-down menu. - * @this Blockly.Block - */ - init: function() { - this.jsonInit( - { - "message0": "%1", - "args0": [ - { - "type": "field_dropdown", - "name": "EFFECT", - "options": [ - ['pitch', 'PITCH'], - ['pan left/right', 'PAN'], - ['echo', 'ECHO'], - ['reverb', 'REVERB'], - ['fuzz', 'FUZZ'], - ['robot', 'ROBOT'] - ] - } - ], - "inputsInline": true, - "output": "String", - "colour": Blockly.Colours.sounds.secondary, - "colourSecondary": Blockly.Colours.sounds.secondary, - "colourTertiary": Blockly.Colours.sounds.tertiary, - "outputShape": Blockly.OUTPUT_SHAPE_ROUND - }); - } -}; +Blockly.Blocks['sound_effects_menu_options'] = [ + ['pitch', 'PITCH'], + ['pan left/right', 'PAN'], + ['echo', 'ECHO'], + ['reverb', 'REVERB'], + ['fuzz', 'FUZZ'], + ['robot', 'ROBOT'] +]; Blockly.Blocks['sound_seteffectto'] = { /** @@ -299,8 +274,9 @@ Blockly.Blocks['sound_seteffectto'] = { "message0": "set effect %1 to %2", "args0": [ { - "type": "input_value", - "name": "EFFECT" + "type": "field_dropdown", + "name": "EFFECT", + "options": Blockly.Blocks['sound_effects_menu_options'] }, { "type": "input_value", @@ -327,8 +303,9 @@ Blockly.Blocks['sound_changeeffectby'] = { "message0": "change effect %1 by %2", "args0": [ { - "type": "input_value", - "name": "EFFECT" + "type": "field_dropdown", + "name": "EFFECT", + "options": Blockly.Blocks['sound_effects_menu_options'] }, { "type": "input_value", @@ -351,7 +328,7 @@ Blockly.Blocks['sound_cleareffects'] = { */ init: function() { this.jsonInit({ - "message0": "clear audio effects", + "message0": "clear sound effects", "previousStatement": null, "nextStatement": null, "colour": Blockly.Colours.sounds.primary, From c098ec9ee13a6d75b0f1807f7f8b297f1e7b96d6 Mon Sep 17 00:00:00 2001 From: Andrew Sliwinski Date: Fri, 10 Mar 2017 00:54:42 -0500 Subject: [PATCH 2/2] Convert motion_setrotationstyle dropdown to field_dropdown --- blocks_vertical/default_toolbox.js | 6 +---- blocks_vertical/motion.js | 39 ++++++------------------------ 2 files changed, 8 insertions(+), 37 deletions(-) diff --git a/blocks_vertical/default_toolbox.js b/blocks_vertical/default_toolbox.js index 1923c9bb71..c3255c1505 100644 --- a/blocks_vertical/default_toolbox.js +++ b/blocks_vertical/default_toolbox.js @@ -128,11 +128,7 @@ Blockly.Blocks.defaultToolbox = ''+ - ''+ - ''+ - ''+ - ''+ - ''+ + ''+ ''+ ''+ ''+ diff --git a/blocks_vertical/motion.js b/blocks_vertical/motion.js index 9fcffc5a65..e85c47bfd0 100644 --- a/blocks_vertical/motion.js +++ b/blocks_vertical/motion.js @@ -426,36 +426,6 @@ Blockly.Blocks['motion_ifonedgebounce'] = { } }; -Blockly.Blocks['motion_setrotationstyle_menu'] = { - /** - * Rotation style drop-down menu. - * @this Blockly.Block - */ - init: function() { - this.jsonInit( - { - "message0": "%1", - "args0": [ - { - "type": "field_dropdown", - "name": "STYLE", - "options": [ - ['left-right', 'left-right'], - ['don\'t rotate', 'don\'t rotate'], - ['all around', 'all around'] - ] - } - ], - "inputsInline": true, - "output": "String", - "colour": Blockly.Colours.motion.secondary, - "colourSecondary": Blockly.Colours.motion.secondary, - "colourTertiary": Blockly.Colours.motion.tertiary, - "outputShape": Blockly.OUTPUT_SHAPE_ROUND - }); - } -}; - Blockly.Blocks['motion_setrotationstyle'] = { /** * Block to set rotation style. @@ -466,8 +436,13 @@ Blockly.Blocks['motion_setrotationstyle'] = { "message0": "set rotation style %1", "args0": [ { - "type": "input_value", - "name": "STYLE" + "type": "field_dropdown", + "name": "STYLE", + "options": [ + ['left-right', 'left-right'], + ['don\'t rotate', 'don\'t rotate'], + ['all around', 'all around'] + ] } ], "previousStatement": null,