gobstones-blockly 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19102f18fe884ada71c61e02008d9ff2fafdf22c24c1832f22fd170ba8d7e902
4
- data.tar.gz: 8c75c63fdf6e00d0d2676befdb34232d1c3ce5c6ead05d9d1d687a25dbaed2a6
3
+ metadata.gz: 2df8843605a77958cbbbc8363ab494219698cb9b1a98210fd2f2bf1a0d257811
4
+ data.tar.gz: 7dc56f808fc135e8dc0917fea99c4be2a6f8ea80620b4d36a9ddb3753da5b632
5
5
  SHA512:
6
- metadata.gz: ad6d4ec5d991561a4466ca6a9312fb3c1287921c25ab28d70b6a7e9027249d5c7b8dcae0dd45351f88c9fb2e1fd5bfc0a4d1e1790f41fdf31d740da80acfb6b4
7
- data.tar.gz: f316a50083297191866808586830391bb091c251a66640dafdb6af5a9dcefb09a795400f9b2647c0d470def4c5a7ed7bced2357f3fcb19825d68d5b65e4142ce
6
+ metadata.gz: bf3e0ae742217b6572f3ac7908977b80dccef29b4ec8222d4e8d3897351b766de195074fc8a2b5ff6a426753ab05d5fd9dacf7f4a6ba3de66c1ec85ed963ddd8
7
+ data.tar.gz: e313b428e16d901ff92cd09a436598e99caed19cfe1ae5116f06adc88823ad3a8a5b1aa64b804a333546cc89c66067be5a5b337c5ae8237727ff19ed3c9d8bac
@@ -63,6 +63,7 @@ Example:
63
63
  <block type="ColorSelector"></block>
64
64
  <block type="DireccionSelector"></block>
65
65
  <block type="BoolSelector"></block>
66
+ <block type="List"></block>
66
67
  </category>
67
68
  <category name="Expresiones primitivas">
68
69
  <block type="hayBolitas"></block>
@@ -4177,7 +4178,7 @@ Blockly.Blocks.InteractiveProgram = {
4177
4178
  _addInit() {
4178
4179
  this.$init = true;
4179
4180
 
4180
- const icon = "minnus.png";
4181
+ const icon = "minus.png";
4181
4182
  var removeButton = new Blockly.FieldImage(
4182
4183
  getLocalMediaUrl(this, icon),
4183
4184
  getLocalMediaSize(icon),
@@ -4278,8 +4279,7 @@ createInteractiveBinding = (name, keys) => {
4278
4279
  options: keys.map(it => [it.name, it.code]),
4279
4280
  }
4280
4281
  ],
4281
- colour: Blockly.CUSTOM_COLORS.InteractiveBinding || Blockly.CUSTOM_COLORS.interactiveBinding,
4282
- tooltip: "Escoger una entrada",
4282
+ colour: Blockly.CUSTOM_COLORS.InteractiveBinding || Blockly.CUSTOM_COLORS.interactiveBinding
4283
4283
  });
4284
4284
 
4285
4285
  this.appendStatementInput('block').setCheck(["Statement"]);
@@ -4849,6 +4849,95 @@ Blockly.Blocks.ColorSelector = createLiteralSelectorBlock('Color',['Rojo','Verde
4849
4849
  Blockly.Blocks.DireccionSelector = createLiteralSelectorBlock('Direccion',['Este','Oeste','Norte','Sur']);
4850
4850
  Blockly.Blocks.BoolSelector = createLiteralSelectorBlock('Bool',['True','False']);
4851
4851
 
4852
+ Blockly.Blocks.List = {
4853
+ init: function () {
4854
+ const type = "List";
4855
+
4856
+ this.jsonInit({
4857
+ type: type,
4858
+ message0: "[",
4859
+ args0: [],
4860
+ output: type,
4861
+ colour: Blockly.CUSTOM_COLORS.list || Blockly.CUSTOM_COLORS.literalExpression,
4862
+ inputsInline: false
4863
+ });
4864
+
4865
+ this._addAddButton();
4866
+ this.length = 0;
4867
+ },
4868
+
4869
+ mutationToDom: function() {
4870
+ var container = document.createElement('mutation');
4871
+ container.setAttribute('length', this.length);
4872
+ return container;
4873
+ },
4874
+
4875
+ domToMutation: function(xmlElement) {
4876
+ var length = parseInt(xmlElement.getAttribute('length')) || 0;
4877
+ for (let i = 0; i < length; i++) this._addElement();
4878
+ },
4879
+
4880
+ _addElement: function() {
4881
+ this.length++;
4882
+ this._removeAddButton();
4883
+ const input = this.appendValueInput('element' + this.length);
4884
+ this._addRemoveButtonFor(input);
4885
+ this._addAddButton();
4886
+ },
4887
+
4888
+ _removeElement: function(input) {
4889
+ this.removeInput(input.name);
4890
+ this.length--;
4891
+
4892
+ let id = 1;
4893
+ for (let input of this.inputList) {
4894
+ if (input.name.startsWith("element")) {
4895
+ input.name = "element" + id;
4896
+ id++;
4897
+ }
4898
+ }
4899
+ },
4900
+
4901
+ _addAddButton: function() {
4902
+ const icon = "plus.png";
4903
+ var addButton = new Blockly.FieldImage(
4904
+ getLocalMediaUrl(this, icon),
4905
+ getLocalMediaSize(icon),
4906
+ getLocalMediaSize(icon),
4907
+ "Agregar elemento",
4908
+ function() {
4909
+ this._addElement();
4910
+ }.bind(this)
4911
+ );
4912
+ const input = this.appendDummyInput();
4913
+ input.appendField(addButton);
4914
+ input.name = "addButton";
4915
+
4916
+ const closingBracket = this.appendDummyInput();
4917
+ closingBracket.appendField("]");
4918
+ closingBracket.name = "closingBracket";
4919
+ },
4920
+
4921
+ _removeAddButton: function() {
4922
+ this.removeInput("addButton")
4923
+ this.removeInput("closingBracket");
4924
+ },
4925
+
4926
+ _addRemoveButtonFor: function(input) {
4927
+ const icon = "minus.png";
4928
+ var removeButton = new Blockly.FieldImage(
4929
+ getLocalMediaUrl(this, icon),
4930
+ getLocalMediaSize(icon),
4931
+ getLocalMediaSize(icon),
4932
+ "Quitar elemento",
4933
+ function() {
4934
+ this._removeElement(input);
4935
+ }.bind(this)
4936
+ );
4937
+ input.appendField(removeButton);
4938
+ }
4939
+ };
4940
+
4852
4941
  function createSingleParameterExpressionBlock(blockText,returnType, colorType = "operator"){
4853
4942
  return {
4854
4943
  init: function () {
@@ -5478,6 +5567,17 @@ Blockly.GobstonesLanguage.ColorSelector = literalSelectorBlockCodeGenerator('Col
5478
5567
  Blockly.GobstonesLanguage.DireccionSelector = literalSelectorBlockCodeGenerator('Direccion');
5479
5568
  Blockly.GobstonesLanguage.BoolSelector = literalSelectorBlockCodeGenerator('Bool');
5480
5569
 
5570
+ Blockly.GobstonesLanguage.List = function(block) {
5571
+ const elements = block
5572
+ .inputList
5573
+ .filter((it) => it.name.startsWith("element"))
5574
+ .map((it) => Blockly.GobstonesLanguage.valueToCode(block, it.name, Blockly.GobstonesLanguage.ORDER_NONE))
5575
+ .join(", ");
5576
+ const code = `[${elements}]`;
5577
+
5578
+ return [code, Blockly.GobstonesLanguage.ORDER_ATOMIC];
5579
+ };
5580
+
5481
5581
  Blockly.GobstonesLanguage.OperadorDeComparacion = function (block) {
5482
5582
  var code =
5483
5583
  (Blockly.GobstonesLanguage.valueToCode(block, 'arg1', Blockly.GobstonesLanguage.ORDER_RELATIONAL) || '()') +
@@ -6572,6 +6672,8 @@ Blockly.ErrorInforming.CssContent = [
6572
6672
  const oldAndOperator = `<field name="OPERATOR">&&</field>`;
6573
6673
  const newAndOperator = `<field name="OPERATOR">AND</field>`;
6574
6674
 
6675
+ if (!this.workspaceXml) return;
6676
+
6575
6677
  if (this.workspaceXml.includes(oldAndOperator)) {
6576
6678
  this.workspaceXml = this.workspaceXml.replace(new RegExp(oldAndOperator, "g"), newAndOperator);
6577
6679
  return true;
@@ -1,5 +1,5 @@
1
1
  module Gobstones
2
2
  module Blockly
3
- VERSION = "0.22.0"
3
+ VERSION = "0.23.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobstones-blockly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Alfonso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-04 00:00:00.000000000 Z
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler