gobstones-blockly 0.11.1 → 0.11.2

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: b93b2dbc1357ab9893fa94a10c8416ab43e739df58f2caf7105db16f66fae746
4
- data.tar.gz: a4e3a8dee90769647c4e0b2a6c0a0628e09ea516a646e53a635ece679572ed67
3
+ metadata.gz: 891585669cd266e97df6ffd8181937289f509807199bb7e934ff66912d0736fb
4
+ data.tar.gz: 8d8d8930bf62bec7c4fff979550e434899fe5384c5e10474676e230554c6dc76
5
5
  SHA512:
6
- metadata.gz: fc00dd7bd613135e8f7c6dd47d9e9b92eb5e8cb9b51109f2997d3ff79469097df32359f75ccb140036f5709ab96893728a8385251a867f4c6d4520055eeb5ffe
7
- data.tar.gz: 9428475425df8dcae170389a2ac3a7ce380ef3056c5e42ce6e0063933e328a9e9aa5f305d5b64c6d0eb49a59d809acfc96265745c4527f20c256f0c96da10f3f
6
+ metadata.gz: fd46da04329bf1b411e4019abcaf8f9d08b0d2a2ffdb73566b5148d03092d869219534b9abbda36cd377f447bd2cfcce2c0f8118a47d74cd9b415421850915b5
7
+ data.tar.gz: ec38226415b998814c5efa693285391078d1206d02a0a82d02fefda81eea45738dd8181a4340cdf54d9bde6e43e0dd8b8397dc3ab1458b7f56ae9a25f07673db
@@ -3573,7 +3573,11 @@ window.initProcedsBlockly = function(customStatementType) {
3573
3573
  this.setCommentText(comment);
3574
3574
  }
3575
3575
  this.setCommentText(null);
3576
- this.setColour(Blockly.Blocks.procedures.HUE);
3576
+ this.setColour((
3577
+ Blockly.CUSTOM_COLORS && (
3578
+ Blockly.CUSTOM_COLORS[this.type] ||
3579
+ Blockly.CUSTOM_COLORS[withReturn ? "function" : "procedure"]
3580
+ )) || Blockly.Blocks.procedures.HUE);
3577
3581
  this.setTooltip(tooltip);
3578
3582
  this.setHelpUrl(helpUrl);
3579
3583
  this.arguments_ = [];
@@ -3581,6 +3585,26 @@ window.initProcedsBlockly = function(customStatementType) {
3581
3585
  this.statementConnection_ = null;
3582
3586
 
3583
3587
  // if (!withParametersMutator) this.updateParams_();
3588
+
3589
+ // [!] adding create call button
3590
+ // TODO: Hacer esto
3591
+ // var xmlMutation = goog.dom.createDom('mutation');
3592
+ // xmlMutation.setAttribute('name', name);
3593
+ // for (var i = 0; i < self.arguments_.length; i++) {
3594
+ // var xmlArg = goog.dom.createDom('arg');
3595
+ // xmlArg.setAttribute('name', self.arguments_[i]);
3596
+ // xmlMutation.appendChild(xmlArg);
3597
+ // }
3598
+ // var xmlBlock = goog.dom.createDom('block', null, xmlMutation);
3599
+ // xmlBlock.setAttribute('type', self.callType_);
3600
+ // var createCallButton = new Blockly.FieldImage(
3601
+ // WAND,
3602
+ // 16,
3603
+ // 16,
3604
+ // "",
3605
+ // Blockly.ContextMenu.callbackFactory(self, xmlBlock)
3606
+ // );
3607
+ // input.appendField(createCallButton);
3584
3608
  };
3585
3609
  };
3586
3610
 
@@ -3648,13 +3672,14 @@ window.initProcedsBlockly = function(customStatementType) {
3648
3672
  };
3649
3673
  };
3650
3674
 
3651
- // ----------------------------------------------------
3652
- // [!] Setting custom statement type to procedure calls
3653
- // ----------------------------------------------------
3675
+ // ---------------------------------------------------------------------
3676
+ // [!] Setting custom statement type to procedure calls and adding color
3677
+ // ---------------------------------------------------------------------
3654
3678
 
3655
3679
  var oldProceduresCallNoReturnInit = Blockly.Blocks['procedures_callnoreturn'].init;
3656
3680
  Blockly.Blocks['procedures_callnoreturn'].init = function() {
3657
3681
  oldProceduresCallNoReturnInit.call(this);
3682
+
3658
3683
  if (customStatementType) {
3659
3684
  this.jsonInit({
3660
3685
  type: customStatementType,
@@ -3662,6 +3687,27 @@ window.initProcedsBlockly = function(customStatementType) {
3662
3687
  nextStatement: customStatementType
3663
3688
  });
3664
3689
  }
3690
+
3691
+ this.setColour((
3692
+ Blockly.CUSTOM_COLORS && (
3693
+ Blockly.CUSTOM_COLORS[this.type] ||
3694
+ Blockly.CUSTOM_COLORS.procedure_call
3695
+ )) || Blockly.Blocks.procedures.HUE);
3696
+ };
3697
+
3698
+ // ----------------------------------
3699
+ // [!] Adding color to function calls
3700
+ // ----------------------------------
3701
+
3702
+ var oldProceduresCallReturnInit = Blockly.Blocks['procedures_callreturn'].init;
3703
+ Blockly.Blocks['procedures_callreturn'].init = function() {
3704
+ oldProceduresCallReturnInit.call(this);
3705
+
3706
+ this.setColour((
3707
+ Blockly.CUSTOM_COLORS && (
3708
+ Blockly.CUSTOM_COLORS[this.type] || // TODO: Usar this.type en todos los cosos de colors
3709
+ Blockly.CUSTOM_COLORS.function_call
3710
+ )) || Blockly.Blocks.procedures.HUE);
3665
3711
  };
3666
3712
 
3667
3713
  // -------------------------------
@@ -3985,10 +4031,11 @@ window.initProcedsBlockly = function(customStatementType) {
3985
4031
  </script>
3986
4032
  <script>initProcedsBlockly("Statement");</script>
3987
4033
  <script>var MINUS = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAQAAAD2e2DtAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfhDAUCCi+xWH4JAAABcUlEQVR42u3c7ZGCMBSG0etuYcTKls7AyrSEVWd4+bjnUECMeSbhD6kCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIBzu4XHm2rUvPekD2yutR57/4itTLXU0/Pvs9SUW5TcDrDUyE3r9Na6ZwZKBWD5PxVKIBPAVGtknGsZibeBTADPyCjXE1idn8A0/gJjXFPgn0sEwIEljgAHwPc2Xx87QHMCaE4AzQmgOQE0J4DmBNCcAJoTQHMCaE4AzQmgOQE0J4DmBNCcAJoTQHMCaE4AzQmgOQE0J4DmBNDcb2SUsfc0T2re/utAO0BzPg49sot8HOoI+M5IDJIJ4OF+gI+F7gpyRcwxxa6Iyb0E3mvYB96y1kgtv2vijubS18QBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAWXq7xrTQhKAi3AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE3LTEyLTA1VDAyOjEwOjQ3LTA1OjAwdZLI/gAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNy0xMi0wNVQwMjoxMDo0Ny0wNTowMATPcEIAAAAASUVORK5CYII=";
4034
+ var HAND = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfiBAUBKBeKSgeBAAABTElEQVQoz22QzyvDcRjHX5/vvrMyStI2uZgftdVCSpJCyW1y00oUF+Xg4OIkx5VyUyJOsgv/gnJw4YCSSFMyB5pGbLJ99/k8LltreB2f9+v50eOigoc5FvGTJF8pugCwaKaNaE98uf9zMBXwjtNpbvmuaH2B0+HXuuyMEbOlQ4U1M5ZVcYbowg02YfZW5cnE9JIROdI7jsiOacoMPLZdEYPR1ouQkxCRG+feESlIXkQOzLR+NhvCpc3UbPcHAoRsADcAQ0Twq0ZosQgEVY0SqvGpkAUCxkIUYRP4bZRRNi9pvaD+TwXyFseHuYzy/Kt8CWfQ5Ems6C/5y7uZyDEH0Nt8vq0dUx0XzaapPyIIoIi23+47+SrlTvrTjLhKy2wmO95OqiacS+QBH9gAFDlOZnYbrimWOixSZCwUlK+vZd7bXiPldyi0yqX1OtkfCBS/9XAtDKAAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTgtMDQtMDVUMDQ6NDQ6NDItMDM6MDD+uUN1AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE4LTA0LTA1VDA0OjQwOjIzLTAzOjAw5hdZgAAAAABJRU5ErkJggg==";
3988
4035
 
3989
4036
  /* global Blockly */
3990
4037
 
3991
- Blockly.GOBSTONES_COLORS = {
4038
+ Blockly.CUSTOM_COLORS = {
3992
4039
  globalHsvSaturation: Blockly.HSV_SATURATION,
3993
4040
  globalHsvValue: Blockly.HSV_VALUE,
3994
4041
  primitiveCommand: "#8DA65B",
@@ -4000,6 +4047,13 @@ Blockly.GOBSTONES_COLORS = {
4000
4047
  interactiveProgram: "#A6805B",
4001
4048
  interactiveBinding: "#A6995B",
4002
4049
  procedure: "#995BA6",
4050
+ function: "#774A77",
4051
+ primitiveProcedure: "#CACACA",
4052
+ primitiveFunction: "#BABABA",
4053
+ procedure_call: "#661CF6",
4054
+ function_call: "#330610",
4055
+ variable: "#FF0000",
4056
+ parameter: "#0000FF",
4003
4057
  complete: "#A65C5B",
4004
4058
  };
4005
4059
 
@@ -4036,7 +4090,7 @@ Blockly.Blocks.Program = {
4036
4090
  }
4037
4091
  ]
4038
4092
  })
4039
- this.setColour(Blockly.GOBSTONES_COLORS.program);
4093
+ this.setColour(Blockly.CUSTOM_COLORS.Program || Blockly.CUSTOM_COLORS.program);
4040
4094
  this.setDeletable(true);
4041
4095
  this.setEditable(true);
4042
4096
  this.setMovable(true);
@@ -4080,7 +4134,7 @@ Blockly.Blocks.InteractiveProgram = {
4080
4134
  }
4081
4135
  ]
4082
4136
  });
4083
- this.setColour(Blockly.GOBSTONES_COLORS.interactiveProgram);
4137
+ this.setColour(Blockly.CUSTOM_COLORS.InteractiveProgram || Blockly.CUSTOM_COLORS.interactiveProgram);
4084
4138
  this.setDeletable(true);
4085
4139
  this.setEditable(true);
4086
4140
  this.setMovable(true);
@@ -4222,7 +4276,7 @@ createInteractiveBinding = (name, keys) => {
4222
4276
  options: keys.map(it => [it.name, it.code]),
4223
4277
  }
4224
4278
  ],
4225
- colour: Blockly.GOBSTONES_COLORS.interactiveBinding,
4279
+ colour: Blockly.CUSTOM_COLORS.InteractiveBinding || Blockly.CUSTOM_COLORS.interactiveBinding,
4226
4280
  tooltip: "Escoger una entrada",
4227
4281
  });
4228
4282
 
@@ -4323,7 +4377,7 @@ Blockly.Blocks.RepeticionSimple = {
4323
4377
  nextStatement: "Statement",
4324
4378
  });
4325
4379
 
4326
- this.setColour(Blockly.GOBSTONES_COLORS.controlStructure);
4380
+ this.setColour(Blockly.CUSTOM_COLORS.RepeticionSimple || Blockly.CUSTOM_COLORS.controlStructure);
4327
4381
  this.appendValueInput('count')
4328
4382
  .appendField('repetir');
4329
4383
  this.appendDummyInput()
@@ -4341,7 +4395,7 @@ Blockly.Blocks.RepeticionCondicional = {
4341
4395
  nextStatement: "Statement",
4342
4396
  });
4343
4397
 
4344
- this.setColour(Blockly.GOBSTONES_COLORS.controlStructure);
4398
+ this.setColour(Blockly.CUSTOM_COLORS.RepeticionCondicional || Blockly.CUSTOM_COLORS.controlStructure);
4345
4399
  this.appendValueInput('condicion')
4346
4400
  .setCheck('Bool')
4347
4401
  .appendField('repetir hasta que');
@@ -4358,7 +4412,7 @@ Blockly.Blocks.AlternativaSimple = {
4358
4412
  nextStatement: "Statement",
4359
4413
  });
4360
4414
 
4361
- this.setColour(Blockly.GOBSTONES_COLORS.controlStructure);
4415
+ this.setColour(Blockly.CUSTOM_COLORS.AlternativaSimple || Blockly.CUSTOM_COLORS.controlStructure);
4362
4416
  this.appendValueInput('condicion')
4363
4417
  .appendField(Blockly.Msg["CONTROLS_IF_MSG_IF"]);
4364
4418
  this.appendStatementInput('block').setCheck(["Statement"]);
@@ -4430,7 +4484,7 @@ Blockly.Blocks.AlternativaCompleta = {
4430
4484
  "extensions": ["controls_if_tooltip"]
4431
4485
  });
4432
4486
 
4433
- this.setColour(Blockly.GOBSTONES_COLORS.controlStructure);
4487
+ this.setColour(Blockly.CUSTOM_COLORS.AlternativaCompleta || Blockly.CUSTOM_COLORS.controlStructure);
4434
4488
  this.setInputsInline(true);
4435
4489
 
4436
4490
  this.elseCount_++;
@@ -4493,7 +4547,7 @@ Blockly.Blocks.Poner = {
4493
4547
  name: 'COLOR'
4494
4548
  }
4495
4549
  ],
4496
- colour: Blockly.GOBSTONES_COLORS.primitiveCommand,
4550
+ colour: Blockly.CUSTOM_COLORS.Poner || Blockly.CUSTOM_COLORS.primitiveCommand,
4497
4551
  tooltip: 'Poner color en casillero.',
4498
4552
  inputsInline: true
4499
4553
  });
@@ -4513,7 +4567,7 @@ Blockly.Blocks.Sacar = {
4513
4567
  name: 'COLOR'
4514
4568
  }
4515
4569
  ],
4516
- colour: Blockly.GOBSTONES_COLORS.primitiveCommand,
4570
+ colour: Blockly.CUSTOM_COLORS.Sacar || Blockly.CUSTOM_COLORS.primitiveCommand,
4517
4571
  tooltip: 'Sacar color de casillero.',
4518
4572
  inputsInline: true
4519
4573
  });
@@ -4533,7 +4587,7 @@ Blockly.Blocks.Mover = {
4533
4587
  name: 'DIRECCION'
4534
4588
  }
4535
4589
  ],
4536
- colour: Blockly.GOBSTONES_COLORS.primitiveCommand,
4590
+ colour: Blockly.CUSTOM_COLORS.Mover || Blockly.CUSTOM_COLORS.primitiveCommand,
4537
4591
  tooltip: 'Mover en una dirección.',
4538
4592
  inputsInline: true
4539
4593
  });
@@ -4553,7 +4607,7 @@ Blockly.Blocks.IrAlBorde = {
4553
4607
  name: 'DIRECCION'
4554
4608
  }
4555
4609
  ],
4556
- colour: Blockly.GOBSTONES_COLORS.primitiveCommand,
4610
+ colour: Blockly.CUSTOM_COLORS.IrAlBorde || Blockly.CUSTOM_COLORS.primitiveCommand,
4557
4611
  tooltip: 'Ir al borde del tablero.',
4558
4612
  inputsInline: true
4559
4613
  });
@@ -4567,7 +4621,7 @@ Blockly.Blocks.VaciarTablero = {
4567
4621
  previousStatement: "Statement",
4568
4622
  nextStatement: "Statement",
4569
4623
  message0: 'Vaciar tablero',
4570
- colour: Blockly.GOBSTONES_COLORS.primitiveCommand,
4624
+ colour: Blockly.CUSTOM_COLORS.VaciarTablero || Blockly.CUSTOM_COLORS.primitiveCommand,
4571
4625
  tooltip: 'Vaciar el tablero.',
4572
4626
  inputsInline: true
4573
4627
  });
@@ -4593,7 +4647,7 @@ Blockly.Blocks.BOOM = {
4593
4647
  }
4594
4648
  ],
4595
4649
  "inputsInline": false,
4596
- "colour": Blockly.GOBSTONES_COLORS.primitiveCommand,
4650
+ "colour": Blockly.CUSTOM_COLORS.BOOM || Blockly.CUSTOM_COLORS.primitiveCommand,
4597
4651
  "tooltip": "Este comando hace que estalle todo."
4598
4652
  });
4599
4653
  }
@@ -4613,7 +4667,7 @@ Blockly.Blocks.ComandoCompletar = {
4613
4667
  "nextStatement": "Statement",
4614
4668
  "lastDummyAlign0": "RIGHT",
4615
4669
  "message0": "COMPLETAR",
4616
- "colour": Blockly.GOBSTONES_COLORS.complete,
4670
+ "colour": Blockly.CUSTOM_COLORS.ComandoCompletar || Blockly.CUSTOM_COLORS.complete,
4617
4671
  "tooltip": "Tenés que reemplazar este bloque por tu solución"
4618
4672
  });
4619
4673
  },
@@ -4629,7 +4683,7 @@ Blockly.Blocks.AsociacionDeTeclaCompletar = {
4629
4683
  "nextStatement": "InteractiveBinding",
4630
4684
  "lastDummyAlign0": "RIGHT",
4631
4685
  "message0": "COMPLETAR",
4632
- "colour": Blockly.GOBSTONES_COLORS.complete,
4686
+ "colour": Blockly.CUSTOM_COLORS.AsociacionDeTeclaCompletar || Blockly.CUSTOM_COLORS.complete,
4633
4687
  "tooltip": "Tenés que reemplazar este bloque por tu solución"
4634
4688
  });
4635
4689
  },
@@ -4641,13 +4695,30 @@ Blockly.Blocks.AsociacionDeTeclaCompletar = {
4641
4695
  // Expresiones:
4642
4696
  // ------------------------------------------------------
4643
4697
 
4698
+ function deepCopyObj(aObject) {
4699
+ var bObject, v, k;
4700
+ bObject = Array.isArray(aObject) ? [] : {};
4701
+ for (k in aObject) {
4702
+ v = aObject[k];
4703
+ bObject[k] = (typeof v === "object") ? deepCopyObj(v) : v;
4704
+ }
4705
+ return bObject;
4706
+ }
4707
+
4708
+ const oldMathNumber = Blockly.Blocks.math_number;
4709
+ Blockly.Blocks.math_number = deepCopyObj(Blockly.Blocks.math_number);
4710
+ Blockly.Blocks.math_number.init = function() {
4711
+ oldMathNumber.init.call(this);
4712
+ this.setColour(Blockly.CUSTOM_COLORS.math_number || Blockly.CUSTOM_COLORS.literalExpression);
4713
+ }
4714
+
4644
4715
  Blockly.Blocks.ExpresionCompletar = {
4645
4716
  init: function () {
4646
4717
  this.jsonInit({
4647
4718
  "type": "completar_expression",
4648
4719
  "message0": "COMPLETAR",
4649
4720
  "output": "any",
4650
- "colour": Blockly.GOBSTONES_COLORS.complete,
4721
+ "colour": Blockly.CUSTOM_COLORS.ExpresionCompletar || Blockly.CUSTOM_COLORS.complete,
4651
4722
  "tooltip": "Tenés que reemplazar este bloque por tu solución"
4652
4723
  });
4653
4724
  },
@@ -4667,7 +4738,7 @@ function createLiteralSelectorBlock(type,values){
4667
4738
  options: values.map(value => [value,value]),
4668
4739
  }],
4669
4740
  output: type,
4670
- colour: Blockly.GOBSTONES_COLORS.literalExpression,
4741
+ colour: Blockly.CUSTOM_COLORS[`${type}Selector`] || Blockly.CUSTOM_COLORS.literalExpression,
4671
4742
  tooltip: "Escoger " + type,
4672
4743
  });
4673
4744
  }
@@ -4689,7 +4760,7 @@ function createSingleParameterExpressionBlock(blockText,returnType){
4689
4760
  name: 'VALUE'
4690
4761
  }
4691
4762
  ],
4692
- colour: Blockly.GOBSTONES_COLORS.expression,
4763
+ colour: Blockly.CUSTOM_COLORS[this.type] || Blockly.CUSTOM_COLORS.expression,
4693
4764
  inputsInline: true,
4694
4765
  output: returnType
4695
4766
  })
@@ -4727,7 +4798,7 @@ Blockly.Blocks.OperadorDeComparacion = {
4727
4798
  name: 'arg2'
4728
4799
  }
4729
4800
  ],
4730
- colour: Blockly.GOBSTONES_COLORS.expression,
4801
+ colour: Blockly.CUSTOM_COLORS.OperadorDeComparacion || Blockly.CUSTOM_COLORS.expression,
4731
4802
  inputsInline: false,
4732
4803
  output: 'Bool'
4733
4804
  });
@@ -4756,7 +4827,7 @@ Blockly.Blocks.OperadorNumerico = {
4756
4827
  name: 'arg2'
4757
4828
  }
4758
4829
  ],
4759
- colour: Blockly.GOBSTONES_COLORS.expression,
4830
+ colour: Blockly.CUSTOM_COLORS.OperadorNumerico || Blockly.CUSTOM_COLORS.expression,
4760
4831
  inputsInline: false,
4761
4832
  output: 'Number'
4762
4833
  });
@@ -4775,7 +4846,7 @@ Blockly.Blocks.OperadorLogico = {
4775
4846
  {
4776
4847
  type: 'field_dropdown',
4777
4848
  name: 'OPERATOR',
4778
- options: [['y también', '&&'], ['o bien', '||']]
4849
+ options: [['y también', 'AND'], ['o bien', '||']]
4779
4850
  },
4780
4851
  {
4781
4852
  type: 'input_dummy'
@@ -4785,7 +4856,7 @@ Blockly.Blocks.OperadorLogico = {
4785
4856
  name: 'arg2'
4786
4857
  }
4787
4858
  ],
4788
- colour: Blockly.GOBSTONES_COLORS.expression,
4859
+ colour: Blockly.CUSTOM_COLORS.OperadorLogico || Blockly.CUSTOM_COLORS.expression,
4789
4860
  inputsInline: false,
4790
4861
  output: 'Bool'
4791
4862
  });
@@ -4796,12 +4867,12 @@ Blockly.Blocks.Asignacion = {
4796
4867
  init: function () {
4797
4868
  this.jsonInit({
4798
4869
  "type": "asignacion",
4799
- "message0": "%1 %2 := %3 %4",
4870
+ "message0": "Recordar que %1 %2 vale %3 %4",
4800
4871
  "args0": [
4801
4872
  {
4802
4873
  "type": "field_input",
4803
4874
  "name": "varName",
4804
- "text": "nombre de variable",
4875
+ "text": "una variable",
4805
4876
  "class": Blockly.Procedures.rename
4806
4877
  },
4807
4878
  {
@@ -4818,11 +4889,24 @@ Blockly.Blocks.Asignacion = {
4818
4889
  "inputsInline": true,
4819
4890
  "previousStatement": null,
4820
4891
  "nextStatement": null,
4821
- "colour": Blockly.GOBSTONES_COLORS.assignation,
4892
+ "colour": Blockly.CUSTOM_COLORS.Asignacion || Blockly.CUSTOM_COLORS.assignation,
4822
4893
  "tooltip": "",
4823
4894
  "helpUrl": ""
4824
4895
  });
4825
- this.getters = [];
4896
+
4897
+ var self = this;
4898
+ var createGetterButton = new Blockly.FieldImage(
4899
+ HAND,
4900
+ 16,
4901
+ 16,
4902
+ "Obtener variable",
4903
+ function() {
4904
+ var name = self.getFieldValue('varName');
4905
+ self.createVariableBlock(name);
4906
+ }
4907
+ );
4908
+
4909
+ this.appendDummyInput().appendField(createGetterButton);
4826
4910
  },
4827
4911
 
4828
4912
  customContextMenu: function(options) {
@@ -4837,20 +4921,7 @@ Blockly.Blocks.Asignacion = {
4837
4921
  return Blockly.createBlockSvg(this.workspace, 'variables_get', b => {
4838
4922
  b.setFieldValue(name, 'VAR');
4839
4923
  b.moveBy(10,5);
4840
- b.parentAssignmentBlock = this;
4841
- this.getters.push(b);
4842
4924
  });
4843
- },
4844
-
4845
- removeGetter: function(block){
4846
- this.getters.splice(this.getters.indexOf(block),1);
4847
- },
4848
-
4849
- onchange: function(event){
4850
- if(event.blockId == this.id && event.type == Blockly.Events.BLOCK_CHANGE &&
4851
- event.element == 'field'){
4852
- this.getters.forEach(block => block.setFieldValue(event.newValue,'VAR'));
4853
- };
4854
4925
  }
4855
4926
  };
4856
4927
 
@@ -4862,13 +4933,13 @@ Blockly.Blocks.variables_get = {
4862
4933
  "message0": "%1",
4863
4934
  "args0": [
4864
4935
  {
4865
- "type": "field_label",
4936
+ "type": "field_input",
4866
4937
  "name": "VAR",
4867
4938
  "text": "nombre de variable"
4868
4939
  }
4869
4940
  ],
4870
4941
  "output": null,
4871
- "colour": 230,
4942
+ "colour": Blockly.CUSTOM_COLORS.variable,
4872
4943
  "tooltip": "",
4873
4944
  "helpUrl": "",
4874
4945
  });
@@ -4886,8 +4957,15 @@ Blockly.Blocks.variables_get = {
4886
4957
  },
4887
4958
 
4888
4959
  onchange: function(event){
4889
- if(event.blockId == this.id && event.type == Blockly.Events.BLOCK_DELETE){
4890
- this.parentAssignmentBlock.removeGetter(this);
4960
+ if (this.$parent) {
4961
+ this.getField("VAR").EDITABLE = false;
4962
+ this.setColour(Blockly.CUSTOM_COLORS.parameter);
4963
+ } else {
4964
+ this.setColour(Blockly.CUSTOM_COLORS.variable);
4965
+ }
4966
+
4967
+ if (event.blockId == this.id && event.type == Blockly.Events.BLOCK_DELETE) {
4968
+ // do something with parent
4891
4969
  }
4892
4970
  }
4893
4971
  };
@@ -5269,6 +5347,7 @@ Blockly.GobstonesLanguage.OperadorNumerico = function (block) {
5269
5347
  Blockly.GobstonesLanguage.OperadorLogico = function(block) {
5270
5348
  // Operations 'and', 'or'.
5271
5349
  var operator = block.getFieldValue('OPERATOR');
5350
+ if (operator === "AND") operator = "&&";
5272
5351
  var order = (operator == '&&') ? Blockly.GobstonesLanguage.ORDER_LOGICAL_AND : Blockly.GobstonesLanguage.ORDER_LOGICAL_OR;
5273
5352
  var argument0 = Blockly.GobstonesLanguage.valueToCode(block, 'arg1', order) || '()';
5274
5353
  var argument1 = Blockly.GobstonesLanguage.valueToCode(block, 'arg2', order) || '()';
@@ -5954,7 +6033,7 @@ Blockly.ErrorInforming.CssContent = [
5954
6033
  for (var item of ttree) {
5955
6034
  if (item.type !== "category") continue;
5956
6035
 
5957
- if (item.name === BLOCKLY_PRIMITIVE_PROCEDURES)
6036
+ if (item.name === categoryName)
5958
6037
  item.child = customTree;
5959
6038
  else
5960
6039
  addCustomActionsChilds(item.child);
@@ -6004,9 +6083,9 @@ Blockly.ErrorInforming.CssContent = [
6004
6083
  return xml.join('\n');
6005
6084
  },
6006
6085
 
6007
- _getPartsByConvention(name) {
6086
+ _getPartsByConvention(isProcedure, name) {
6008
6087
  let parts = name.replace(/([A-Z])/g, " $1").toLowerCase();
6009
- parts = parts[1].toUpperCase() + parts.substring(2);
6088
+ if (isProcedure) parts = parts[1].toUpperCase() + parts.substring(2);
6010
6089
  parts = this._getParts(parts);
6011
6090
 
6012
6091
  return parts;
@@ -6025,14 +6104,14 @@ Blockly.ErrorInforming.CssContent = [
6025
6104
  const icon = definition.attributes && definition.attributes.block_icon;
6026
6105
 
6027
6106
  const finalName = customName || name;
6028
- const parts = (customName ? this._getParts : this._getPartsByConvention)
6107
+ const parts = (customName ? this._getParts : this._getPartsByConvention.bind(this, true))
6029
6108
  .bind(this)(finalName);
6030
6109
 
6031
6110
  // Bloque
6032
6111
  Blockly.Blocks[name] = {
6033
6112
  init: function () {
6034
6113
  let argsIndex = 1;
6035
- this.setColour(Blockly.GOBSTONES_COLORS.primitiveCommand);
6114
+ this.setColour(Blockly.CUSTOM_COLORS.primitiveProcedure);
6036
6115
 
6037
6116
  if (icon) {
6038
6117
  this.appendDummyInput().appendField(new Blockly.FieldImage(
@@ -6085,14 +6164,14 @@ Blockly.ErrorInforming.CssContent = [
6085
6164
  const icon = definition.attributes && definition.attributes.block_icon;
6086
6165
 
6087
6166
  const finalName = customName || name;
6088
- const parts = (customName ? this._getParts : this._getPartsByConvention)
6167
+ const parts = (customName ? this._getParts : this._getPartsByConvention.bind(this, false))
6089
6168
  .bind(this)(finalName);
6090
6169
 
6091
6170
  // Bloque
6092
6171
  Blockly.Blocks[name] = {
6093
6172
  init: function () {
6094
6173
  let argsIndex = 1;
6095
- this.setColour(Blockly.GOBSTONES_COLORS.primitiveCommand);
6174
+ this.setColour(Blockly.CUSTOM_COLORS.primitiveFunction);
6096
6175
 
6097
6176
  if (icon) {
6098
6177
  this.appendDummyInput().appendField(new Blockly.FieldImage(
@@ -6239,7 +6318,10 @@ Blockly.ErrorInforming.CssContent = [
6239
6318
  },
6240
6319
 
6241
6320
  _onWorkspaceUpdate: function () {
6242
- if(this.workspaceXml != this._blocklyWorkspaceXML) {
6321
+ const hasReloadedXml = this._runWorkspaceXmlRetrocompatibilityFixes();
6322
+ if (hasReloadedXml) return;
6323
+
6324
+ if (this.workspaceXml != this._blocklyWorkspaceXML) {
6243
6325
  this.workspace.clear();
6244
6326
  let dom = Blockly.Xml.textToDom(this.workspaceXml);
6245
6327
  try {
@@ -6258,6 +6340,16 @@ Blockly.ErrorInforming.CssContent = [
6258
6340
  }
6259
6341
  },
6260
6342
 
6343
+ _runWorkspaceXmlRetrocompatibilityFixes: function() {
6344
+ const oldAndOperator = `<field name="OPERATOR">&&</field>`;
6345
+ const newAndOperator = `<field name="OPERATOR">AND</field>`;
6346
+
6347
+ if (this.workspaceXml.includes(oldAndOperator)) {
6348
+ this.workspaceXml = this.workspaceXml.replace(new RegExp(oldAndOperator, "g"), newAndOperator);
6349
+ return true;
6350
+ }
6351
+ },
6352
+
6261
6353
  /**
6262
6354
  * Reinicializa el workspace, dejando solo el bloque programa
6263
6355
  */
@@ -6472,16 +6564,18 @@ Blockly.ErrorInforming.CssContent = [
6472
6564
  },
6473
6565
 
6474
6566
  testColors(colors) {
6475
- Blockly.GOBSTONES_COLORS = colors;
6567
+ Blockly.CUSTOM_COLORS = colors;
6476
6568
  Blockly.HSV_SATURATION = colors.globalHsvSaturation;
6477
6569
  Blockly.HSV_VALUE = colors.globalHsvValue;
6478
- Blockly.Constants.Math.HUE = colors.literalExpression;
6479
- Blockly.Msg.MATH_HUE = colors.literalExpression.toString();
6480
6570
  Blockly.Blocks.procedures.HUE = colors.procedure;
6481
6571
 
6482
- var xml = Blockly.Xml.workspaceToDom(this.workspace);
6572
+ var xmlDom = Blockly.Xml.workspaceToDom(this.workspace);
6573
+ const xml = Blockly.Xml.domToText(xmlDom);
6483
6574
  this.resetWorkspace();
6484
- Blockly.Xml.domToWorkspace(xml, this.workspace);
6575
+
6576
+ setTimeout(() => {
6577
+ this.workspaceXml = xml;
6578
+ }, 0);
6485
6579
  }
6486
6580
  });
6487
6581
  </script>
@@ -1,5 +1,5 @@
1
1
  module Gobstones
2
2
  module Blockly
3
- VERSION = "0.11.1"
3
+ VERSION = "0.11.2"
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.11.1
4
+ version: 0.11.2
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-04-04 00:00:00.000000000 Z
11
+ date: 2018-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler