gobstones-blockly 0.24.1 → 0.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/htmls/gs-element-blockly.html +735 -721
- data/lib/gobstones/blockly/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 257925d093065b1837bb02d37c6b9f6eed733b41cfd8570585e45c17bf2a2a83
|
4
|
+
data.tar.gz: 8379df1044a1c264cfabe412f4946707f705e6b0e191dc17f9f34ee48726f168
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bed96f1ef11357e218eea4f32f9e901652c9a596be79b3fd033f3ee3c2373c234c07f0b1413794543329f6c6c4f396860dc6ddede126f3e63b996abfaf4b6ec
|
7
|
+
data.tar.gz: 851c803b2c74322653ba6d1b6cb99a9001cd9126481ee254665ca3c245bfcee69c4d07c342b68e736a89ce4a40a64e013024434ada414c3a48424d0760d223ad
|
@@ -4061,11 +4061,11 @@ const getLocalMediaSize = (name) => hasLocalMedia(name) ? 16 : 0;
|
|
4061
4061
|
* @this Blockly.Block
|
4062
4062
|
*/
|
4063
4063
|
Blockly.createBlockSvg = function(workspace, name, f) {
|
4064
|
-
|
4065
|
-
|
4066
|
-
|
4067
|
-
|
4068
|
-
|
4064
|
+
var newBlock = workspace.newBlock(name);
|
4065
|
+
//newBlock.setEditable(false);
|
4066
|
+
f(newBlock);
|
4067
|
+
newBlock.initSvg();
|
4068
|
+
newBlock.render();
|
4069
4069
|
};
|
4070
4070
|
|
4071
4071
|
const createVariable = (parent, name) => {
|
@@ -4079,161 +4079,168 @@ const createVariable = (parent, name) => {
|
|
4079
4079
|
});
|
4080
4080
|
}
|
4081
4081
|
|
4082
|
+
const triggerRefresh = (block) => {
|
4083
|
+
getOptions(block).parentController.onBlocklyWorkspaceUpdate();
|
4084
|
+
};
|
4085
|
+
|
4082
4086
|
// ---
|
4083
4087
|
|
4084
4088
|
Blockly.Blocks.Program = {
|
4085
|
-
|
4086
|
-
|
4087
|
-
|
4088
|
-
|
4089
|
-
|
4090
|
-
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4105
|
-
|
4106
|
-
|
4107
|
-
|
4108
|
-
|
4109
|
-
|
4110
|
-
|
4111
|
-
|
4112
|
-
|
4113
|
-
|
4114
|
-
|
4115
|
-
|
4116
|
-
|
4117
|
-
|
4118
|
-
|
4119
|
-
|
4120
|
-
|
4121
|
-
|
4122
|
-
|
4123
|
-
|
4124
|
-
|
4089
|
+
init: function () {
|
4090
|
+
this.jsonInit({
|
4091
|
+
"type": "Program",
|
4092
|
+
"message0": "%1 %2 %3",
|
4093
|
+
"args0": [
|
4094
|
+
{
|
4095
|
+
"type": "field_label",
|
4096
|
+
"text": "programa"
|
4097
|
+
},
|
4098
|
+
{
|
4099
|
+
"type": "input_dummy"
|
4100
|
+
},
|
4101
|
+
{
|
4102
|
+
"type": "input_statement",
|
4103
|
+
"name": "program",
|
4104
|
+
"check": ["Statement"]
|
4105
|
+
}
|
4106
|
+
]
|
4107
|
+
})
|
4108
|
+
this.setColour(Blockly.CUSTOM_COLORS.Program || Blockly.CUSTOM_COLORS.program);
|
4109
|
+
this.setDeletable(true);
|
4110
|
+
this.setEditable(true);
|
4111
|
+
this.setMovable(true);
|
4112
|
+
},
|
4113
|
+
|
4114
|
+
setDisabledAndUpdateTimestamp: function(disabled) {
|
4115
|
+
this.setDisabled(disabled);
|
4116
|
+
if (!disabled) this.$timestamp = Date.now();
|
4117
|
+
},
|
4118
|
+
|
4119
|
+
mutationToDom: function() {
|
4120
|
+
var container = document.createElement("mutation");
|
4121
|
+
container.setAttribute("timestamp", this.$timestamp || Date.now());
|
4122
|
+
return container;
|
4123
|
+
},
|
4124
|
+
|
4125
|
+
domToMutation: function(xmlElement) {
|
4126
|
+
const timestamp = xmlElement.getAttribute("timestamp");
|
4127
|
+
this.$timestamp = timestamp || Date.now();
|
4128
|
+
},
|
4125
4129
|
|
4126
4130
|
};
|
4127
4131
|
|
4128
4132
|
Blockly.Blocks.InteractiveProgram = {
|
4129
|
-
|
4130
|
-
|
4131
|
-
|
4132
|
-
|
4133
|
-
|
4134
|
-
|
4135
|
-
|
4136
|
-
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4143
|
-
|
4144
|
-
|
4145
|
-
|
4146
|
-
|
4147
|
-
|
4148
|
-
|
4149
|
-
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4153
|
-
|
4154
|
-
|
4155
|
-
|
4156
|
-
|
4157
|
-
|
4158
|
-
|
4159
|
-
|
4160
|
-
|
4161
|
-
|
4162
|
-
|
4163
|
-
|
4164
|
-
|
4165
|
-
|
4166
|
-
|
4167
|
-
|
4168
|
-
|
4169
|
-
|
4170
|
-
|
4171
|
-
|
4172
|
-
|
4173
|
-
|
4174
|
-
|
4175
|
-
|
4176
|
-
|
4177
|
-
|
4178
|
-
|
4179
|
-
|
4180
|
-
|
4181
|
-
|
4182
|
-
|
4183
|
-
|
4184
|
-
|
4185
|
-
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
|
4191
|
-
|
4192
|
-
|
4193
|
-
|
4194
|
-
this.$init = true;
|
4133
|
+
init: function () {
|
4134
|
+
this.jsonInit({
|
4135
|
+
"type": "InteractiveProgram",
|
4136
|
+
"message0": "%1 %2 %3",
|
4137
|
+
"args0": [
|
4138
|
+
{
|
4139
|
+
"type": "field_label",
|
4140
|
+
"text": "programa interactivo"
|
4141
|
+
},
|
4142
|
+
{
|
4143
|
+
"type": "input_dummy"
|
4144
|
+
},
|
4145
|
+
{
|
4146
|
+
"type": "input_statement",
|
4147
|
+
"name": "interactiveprogram",
|
4148
|
+
"check": ["InteractiveBinding"]
|
4149
|
+
}
|
4150
|
+
]
|
4151
|
+
});
|
4152
|
+
this.setColour(Blockly.CUSTOM_COLORS.InteractiveProgram || Blockly.CUSTOM_COLORS.interactiveProgram);
|
4153
|
+
this.setDeletable(true);
|
4154
|
+
this.setEditable(true);
|
4155
|
+
this.setMovable(true);
|
4156
|
+
},
|
4157
|
+
|
4158
|
+
customContextMenu: function(options) {
|
4159
|
+
options.unshift({ text: `Agregar timeout`, enabled: !this.$timeout, callback: () => {
|
4160
|
+
let x = prompt("Ingrese un número en milisegundos");
|
4161
|
+
if (isNaN(parseInt(x)) || parseInt(x) <= 0) return;
|
4162
|
+
x = parseInt(x);
|
4163
|
+
|
4164
|
+
this._addTimeout(x);
|
4165
|
+
}});
|
4166
|
+
|
4167
|
+
options.unshift({ text: `Agregar inicialización`, enabled: !this.$init, callback: () => {
|
4168
|
+
this._addInit();
|
4169
|
+
}});
|
4170
|
+
},
|
4171
|
+
|
4172
|
+
setDisabledAndUpdateTimestamp: function(disabled) {
|
4173
|
+
this.setDisabled(disabled);
|
4174
|
+
if (!disabled) this.$timestamp = Date.now();
|
4175
|
+
},
|
4176
|
+
|
4177
|
+
mutationToDom: function() {
|
4178
|
+
var container = document.createElement("mutation");
|
4179
|
+
if (this.$init) container.setAttribute("init", this.$init);
|
4180
|
+
if (this.$timeout) container.setAttribute("timeout", this.$timeout);
|
4181
|
+
|
4182
|
+
container.setAttribute("timestamp", this.$timestamp || Date.now());
|
4183
|
+
return container;
|
4184
|
+
},
|
4185
|
+
|
4186
|
+
domToMutation: function(xmlElement) {
|
4187
|
+
const init = xmlElement.getAttribute("init");
|
4188
|
+
const timeout = xmlElement.getAttribute("timeout");
|
4189
|
+
const timestamp = xmlElement.getAttribute("timestamp");
|
4190
|
+
|
4191
|
+
if (init) this._addInit()
|
4192
|
+
if (timeout) this._addTimeout(parseInt(timeout));
|
4193
|
+
this.$timestamp = timestamp || Date.now();
|
4194
|
+
},
|
4195
|
+
|
4196
|
+
_addInit() {
|
4197
|
+
this.$init = true;
|
4195
4198
|
|
4196
4199
|
const icon = "minus.png";
|
4197
|
-
|
4198
|
-
|
4199
|
-
|
4200
|
-
|
4201
|
-
|
4202
|
-
|
4203
|
-
|
4204
|
-
|
4205
|
-
|
4206
|
-
|
4207
|
-
|
4208
|
-
|
4209
|
-
|
4210
|
-
|
4211
|
-
|
4212
|
-
|
4213
|
-
|
4214
|
-
|
4215
|
-
|
4216
|
-
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4200
|
+
var removeButton = new Blockly.FieldImage(
|
4201
|
+
getLocalMediaUrl(this, icon),
|
4202
|
+
getLocalMediaSize(icon),
|
4203
|
+
getLocalMediaSize(icon),
|
4204
|
+
"Eliminar",
|
4205
|
+
function() {
|
4206
|
+
this.$init = false;
|
4207
|
+
this.removeInput("initlabel");
|
4208
|
+
this.removeInput("init");
|
4209
|
+
this.removeInput("statementsLabel");
|
4210
|
+
triggerRefresh(this);
|
4211
|
+
}.bind(this)
|
4212
|
+
);
|
4213
|
+
|
4214
|
+
this.appendDummyInput("initlabel").appendField('Al inicializar:').appendField(removeButton);
|
4215
|
+
this.appendStatementInput('init').setCheck(["Statement"]);
|
4216
|
+
this.appendDummyInput("statementsLabel").appendField('Al apretar...');
|
4217
|
+
this.moveInputBefore("init", "interactiveprogram");
|
4218
|
+
this.moveInputBefore("initlabel", "init");
|
4219
|
+
this.moveInputBefore("statementsLabel", "interactiveprogram");
|
4220
|
+
triggerRefresh(this);
|
4221
|
+
},
|
4222
|
+
|
4223
|
+
_addTimeout(timeout) {
|
4224
|
+
this.$timeout = timeout;
|
4220
4225
|
|
4221
4226
|
const icon = "minus.png";
|
4222
|
-
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
|
4228
|
-
|
4229
|
-
|
4230
|
-
|
4231
|
-
|
4232
|
-
|
4233
|
-
|
4234
|
-
|
4235
|
-
|
4236
|
-
|
4227
|
+
var removeButton = new Blockly.FieldImage(
|
4228
|
+
getLocalMediaUrl(this, icon),
|
4229
|
+
getLocalMediaSize(icon),
|
4230
|
+
getLocalMediaSize(icon),
|
4231
|
+
"Eliminar",
|
4232
|
+
function() {
|
4233
|
+
this.$timeout = undefined;
|
4234
|
+
this.removeInput("timeoutlabel");
|
4235
|
+
this.removeInput("timeout");
|
4236
|
+
triggerRefresh(this);
|
4237
|
+
}.bind(this)
|
4238
|
+
);
|
4239
|
+
|
4240
|
+
this.appendDummyInput("timeoutlabel").appendField(`Al estar inactivo ${timeout} milisegundos:`).appendField(removeButton);
|
4241
|
+
this.appendStatementInput('timeout').setCheck(["Statement"]);
|
4242
|
+
triggerRefresh(this);
|
4243
|
+
}
|
4237
4244
|
};
|
4238
4245
|
|
4239
4246
|
// -------------------------------------
|
@@ -4241,9 +4248,9 @@ Blockly.Blocks.InteractiveProgram = {
|
|
4241
4248
|
// -------------------------------------
|
4242
4249
|
|
4243
4250
|
const modifiers = [
|
4244
|
-
|
4245
|
-
|
4246
|
-
|
4251
|
+
[ 'SHIFT', 'SHIFT' ],
|
4252
|
+
[ 'CTRL', 'CTRL' ],
|
4253
|
+
[ 'ALT', 'ALT' ]
|
4247
4254
|
];
|
4248
4255
|
|
4249
4256
|
const getModifiersInput = (block) => block.inputList[1];
|
@@ -4251,51 +4258,51 @@ const getModifierFields = (block) => getModifiersInput(block).fieldRow.slice(2);
|
|
4251
4258
|
const getModifierDropdownFields = (block) => getModifierFields(block).filter(it => it.constructor === Blockly.FieldDropdown);
|
4252
4259
|
const getModifierValues = (block) => getModifierDropdownFields(block).map(it => it.getValue());
|
4253
4260
|
const getAvailableModifiers = (block) => {
|
4254
|
-
|
4261
|
+
const currentModifiers = getModifierValues(block);
|
4255
4262
|
|
4256
|
-
|
4257
|
-
|
4258
|
-
|
4263
|
+
return modifiers.filter(it =>
|
4264
|
+
currentModifiers.indexOf(it[1]) === -1
|
4265
|
+
);
|
4259
4266
|
};
|
4260
4267
|
const updateModifierMenuGenerators = (block, nameToIgnore) => {
|
4261
|
-
|
4262
|
-
|
4268
|
+
const availableModifiers = getAvailableModifiers(block);
|
4269
|
+
const dropdowns = getModifierDropdownFields(block);
|
4263
4270
|
|
4264
|
-
|
4265
|
-
|
4266
|
-
|
4267
|
-
|
4268
|
-
|
4271
|
+
for (var dropdown of dropdowns) {
|
4272
|
+
if (dropdown.name !== nameToIgnore)
|
4273
|
+
dropdown.menuGenerator_ = modifiers.filter(it => {
|
4274
|
+
return it[1] === dropdown.getValue() || availableModifiers.some(availableModifier => availableModifier[1] === it[1])
|
4275
|
+
});
|
4269
4276
|
|
4270
|
-
|
4277
|
+
}
|
4271
4278
|
}
|
4272
4279
|
|
4273
4280
|
createInteractiveBinding = (name, keys) => {
|
4274
|
-
|
4275
|
-
|
4276
|
-
|
4277
|
-
|
4278
|
-
|
4279
|
-
|
4280
|
-
|
4281
|
-
|
4282
|
-
|
4283
|
-
|
4284
|
-
|
4285
|
-
|
4281
|
+
return {
|
4282
|
+
init: function () {
|
4283
|
+
this.jsonInit({
|
4284
|
+
message0: "%1 %2 %3 %4",
|
4285
|
+
type: "InteractiveBinding",
|
4286
|
+
previousStatement: "InteractiveBinding",
|
4287
|
+
nextStatement: "InteractiveBinding",
|
4288
|
+
args0: [
|
4289
|
+
{
|
4290
|
+
"type": "field_label",
|
4291
|
+
"text": "Al apretar " + name
|
4292
|
+
},
|
4286
4293
|
{ "type": "input_dummy" },
|
4287
4294
|
{
|
4288
4295
|
"type": "field_label",
|
4289
4296
|
"text": "➣"
|
4290
4297
|
},
|
4291
|
-
|
4292
|
-
|
4293
|
-
|
4294
|
-
|
4295
|
-
|
4296
|
-
|
4297
|
-
|
4298
|
-
|
4298
|
+
{
|
4299
|
+
type: "field_dropdown",
|
4300
|
+
name: "InteractiveBindingDropdownKey",
|
4301
|
+
options: keys.map(it => [it.name, it.code]),
|
4302
|
+
}
|
4303
|
+
],
|
4304
|
+
colour: Blockly.CUSTOM_COLORS.InteractiveBinding || Blockly.CUSTOM_COLORS.interactiveBinding
|
4305
|
+
});
|
4299
4306
|
|
4300
4307
|
this.appendStatementInput('block').setCheck(["Statement"]);
|
4301
4308
|
|
@@ -4324,88 +4331,90 @@ createInteractiveBinding = (name, keys) => {
|
|
4324
4331
|
self._cleanModifiers();
|
4325
4332
|
}
|
4326
4333
|
));
|
4327
|
-
|
4328
|
-
|
4329
|
-
|
4330
|
-
|
4331
|
-
|
4332
|
-
|
4333
|
-
|
4334
|
-
|
4335
|
-
|
4336
|
-
|
4337
|
-
|
4338
|
-
|
4339
|
-
|
4340
|
-
|
4341
|
-
|
4342
|
-
|
4343
|
-
|
4344
|
-
|
4345
|
-
|
4346
|
-
|
4347
|
-
|
4348
|
-
|
4349
|
-
|
4350
|
-
|
4351
|
-
|
4352
|
-
|
4334
|
+
},
|
4335
|
+
|
4336
|
+
customContextMenu: function(options) {
|
4337
|
+
const modifiersCount = getModifierFields(this).length / 2;
|
4338
|
+
|
4339
|
+
options.unshift({ text: `Limpiar modificadores`, enabled: modifiersCount > 0, callback: () => {
|
4340
|
+
this._cleanModifiers();
|
4341
|
+
}});
|
4342
|
+
options.unshift({ text: `Agregar modificador`, enabled: modifiersCount < modifiers.length, callback: () => {
|
4343
|
+
this._addModifier();
|
4344
|
+
}});
|
4345
|
+
},
|
4346
|
+
|
4347
|
+
mutationToDom: function() {
|
4348
|
+
var container = document.createElement("mutation");
|
4349
|
+
container.setAttribute("modifierscount", getModifierValues(this).length.toString());
|
4350
|
+
return container;
|
4351
|
+
},
|
4352
|
+
|
4353
|
+
domToMutation: function(xmlElement) {
|
4354
|
+
const $modifiersCount = xmlElement.getAttribute("modifierscount");
|
4355
|
+
if ($modifiersCount) {
|
4356
|
+
const count = parseInt($modifiersCount);
|
4357
|
+
for (var i = 0; i < count; i++)
|
4358
|
+
this._addModifier();
|
4359
|
+
}
|
4353
4360
|
|
4354
|
-
|
4355
|
-
|
4356
|
-
|
4357
|
-
|
4361
|
+
setTimeout(() => {
|
4362
|
+
updateModifierMenuGenerators(this);
|
4363
|
+
}, 0);
|
4364
|
+
},
|
4358
4365
|
|
4359
|
-
|
4360
|
-
|
4366
|
+
_addModifier() {
|
4367
|
+
const availableModifiers = getAvailableModifiers(this);
|
4361
4368
|
|
4362
|
-
|
4363
|
-
|
4364
|
-
|
4365
|
-
|
4369
|
+
const self = this;
|
4370
|
+
const id = getModifierValues(this).length + 1;
|
4371
|
+
const labelName = "l" + id;
|
4372
|
+
const dropdownName = "d" + id;
|
4366
4373
|
|
4367
|
-
|
4368
|
-
|
4369
|
-
|
4370
|
-
|
4371
|
-
|
4374
|
+
getModifiersInput(this).appendField("+").appendField(new Blockly.FieldDropdown(availableModifiers, (newValue) => {
|
4375
|
+
setTimeout(() => {
|
4376
|
+
updateModifierMenuGenerators(self, dropdownName)
|
4377
|
+
}, 0);
|
4378
|
+
}));
|
4372
4379
|
|
4373
|
-
|
4374
|
-
|
4375
|
-
|
4380
|
+
const addedFields = getModifierFields(this).slice(-2);
|
4381
|
+
addedFields[0].name = labelName;
|
4382
|
+
addedFields[1].name = dropdownName;
|
4376
4383
|
|
4377
|
-
|
4378
|
-
|
4384
|
+
updateModifierMenuGenerators(this, dropdownName);
|
4385
|
+
triggerRefresh(this);
|
4386
|
+
},
|
4379
4387
|
|
4380
|
-
|
4381
|
-
|
4388
|
+
_cleanModifiers() {
|
4389
|
+
const fieldsToRemove = getModifierFields(this);
|
4382
4390
|
|
4383
|
-
|
4384
|
-
|
4385
|
-
|
4386
|
-
|
4391
|
+
for (var field of fieldsToRemove)
|
4392
|
+
getModifiersInput(this).removeField(field.name);
|
4393
|
+
triggerRefresh(this);
|
4394
|
+
}
|
4395
|
+
}
|
4387
4396
|
};
|
4388
4397
|
|
4389
4398
|
Blockly.Blocks.InteractiveLetterBinding = createInteractiveBinding("letra", [
|
4390
|
-
|
4399
|
+
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
|
4391
4400
|
].map(it => ({ code: it, name: it })));
|
4392
4401
|
|
4393
4402
|
Blockly.Blocks.InteractiveNumberBinding = createInteractiveBinding("número", [
|
4394
|
-
|
4403
|
+
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
|
4395
4404
|
].map(it => ({ code: it, name: it })));
|
4396
4405
|
|
4397
4406
|
Blockly.Blocks.InteractiveKeyBinding = createInteractiveBinding("tecla", [
|
4398
|
-
|
4399
|
-
|
4400
|
-
|
4401
|
-
|
4402
|
-
|
4403
|
-
|
4404
|
-
|
4405
|
-
|
4406
|
-
|
4407
|
-
|
4408
|
-
|
4407
|
+
{ code: 'LEFT', name: '←' },
|
4408
|
+
{ code: 'RIGHT', name: '→' },
|
4409
|
+
{ code: 'UP', name: '↑' },
|
4410
|
+
{ code: 'DOWN', name: '↓' },
|
4411
|
+
{ code: 'MINUS', name: '-' },
|
4412
|
+
{ code: 'SPACE', name: 'Espacio' },
|
4413
|
+
{ code: 'RETURN', name: 'Enter' },
|
4414
|
+
{ code: 'TAB', name: 'Tab' },
|
4415
|
+
{ code: 'BACKSPACE', name: 'Borrar' },
|
4416
|
+
{ code: 'DELETE', name: 'Suprimir' },
|
4417
|
+
{ code: 'ESCAPE', name: 'Escape' }
|
4409
4418
|
]);
|
4410
4419
|
|
4411
4420
|
// ------------------------------------------------------
|
@@ -4413,53 +4422,53 @@ Blockly.Blocks.InteractiveKeyBinding = createInteractiveBinding("tecla", [
|
|
4413
4422
|
// ------------------------------------------------------
|
4414
4423
|
|
4415
4424
|
Blockly.Blocks.RepeticionSimple = {
|
4416
|
-
|
4417
|
-
|
4418
|
-
|
4419
|
-
|
4420
|
-
|
4421
|
-
|
4425
|
+
init: function () {
|
4426
|
+
this.jsonInit({
|
4427
|
+
type: "Statement",
|
4428
|
+
previousStatement: "Statement",
|
4429
|
+
nextStatement: "Statement",
|
4430
|
+
});
|
4422
4431
|
|
4423
|
-
|
4424
|
-
|
4425
|
-
|
4426
|
-
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4432
|
+
this.setColour(Blockly.CUSTOM_COLORS.RepeticionSimple || Blockly.CUSTOM_COLORS.controlStructure);
|
4433
|
+
this.appendValueInput('count')
|
4434
|
+
.appendField('repetir');
|
4435
|
+
this.appendDummyInput()
|
4436
|
+
.appendField('veces');
|
4437
|
+
this.appendStatementInput('block').setCheck(["Statement"]);
|
4438
|
+
this.setInputsInline(true);
|
4439
|
+
}
|
4431
4440
|
};
|
4432
4441
|
|
4433
4442
|
Blockly.Blocks.RepeticionCondicional = {
|
4434
|
-
|
4435
|
-
|
4436
|
-
|
4437
|
-
|
4438
|
-
|
4439
|
-
|
4443
|
+
init: function () {
|
4444
|
+
this.jsonInit({
|
4445
|
+
type: "Statement",
|
4446
|
+
previousStatement: "Statement",
|
4447
|
+
nextStatement: "Statement",
|
4448
|
+
});
|
4440
4449
|
|
4441
|
-
|
4442
|
-
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4450
|
+
this.setColour(Blockly.CUSTOM_COLORS.RepeticionCondicional || Blockly.CUSTOM_COLORS.controlStructure);
|
4451
|
+
this.appendValueInput('condicion')
|
4452
|
+
.appendField('repetir hasta que');
|
4453
|
+
this.appendStatementInput('block').setCheck(["Statement"]);
|
4454
|
+
this.setInputsInline(true);
|
4455
|
+
}
|
4447
4456
|
};
|
4448
4457
|
|
4449
4458
|
Blockly.Blocks.AlternativaSimple = {
|
4450
|
-
|
4451
|
-
|
4452
|
-
|
4453
|
-
|
4454
|
-
|
4455
|
-
|
4459
|
+
init: function () {
|
4460
|
+
this.jsonInit({
|
4461
|
+
type: "Statement",
|
4462
|
+
previousStatement: "Statement",
|
4463
|
+
nextStatement: "Statement"
|
4464
|
+
});
|
4456
4465
|
|
4457
|
-
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4466
|
+
this.setColour(Blockly.CUSTOM_COLORS.AlternativaSimple || Blockly.CUSTOM_COLORS.controlStructure);
|
4467
|
+
this.appendValueInput('condicion')
|
4468
|
+
.appendField(Blockly.Msg["CONTROLS_IF_MSG_IF"]);
|
4469
|
+
this.appendStatementInput('block').setCheck(["Statement"]);
|
4470
|
+
this.setInputsInline(true);
|
4471
|
+
}
|
4463
4472
|
};
|
4464
4473
|
|
4465
4474
|
Blockly.Msg["CONTROLS_IF_MSG_ELSE"] = "si no";
|
@@ -4469,107 +4478,109 @@ Blockly.Msg["CONTROLS_IF_MSG_THEN"] = "";
|
|
4469
4478
|
delete Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN.compose;
|
4470
4479
|
delete Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN.decompose;
|
4471
4480
|
Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN.updateShape_ = function() {
|
4472
|
-
|
4473
|
-
|
4474
|
-
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
4485
|
-
|
4486
|
-
|
4487
|
-
|
4488
|
-
|
4489
|
-
|
4490
|
-
|
4491
|
-
|
4492
|
-
|
4493
|
-
|
4481
|
+
// Delete everything.
|
4482
|
+
if (this.getInput('block2')) {
|
4483
|
+
this.removeInput('block2');
|
4484
|
+
}
|
4485
|
+
var i = 1;
|
4486
|
+
while (this.getInput('IF' + i)) {
|
4487
|
+
this.removeInput('IF' + i);
|
4488
|
+
this.removeInput('DO' + i);
|
4489
|
+
i++;
|
4490
|
+
}
|
4491
|
+
// Rebuild block.
|
4492
|
+
for (var i = 1; i <= this.elseifCount_; i++) {
|
4493
|
+
this.appendValueInput('IF' + i)
|
4494
|
+
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
|
4495
|
+
this.appendStatementInput('DO' + i)
|
4496
|
+
.setCheck(["Statement"])
|
4497
|
+
}
|
4498
|
+
if (this.elseCount_) {
|
4499
|
+
this.appendStatementInput('block2')
|
4500
|
+
.setCheck(["Statement"])
|
4501
|
+
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
|
4502
|
+
}
|
4503
|
+
|
4504
|
+
triggerRefresh(this);
|
4494
4505
|
};
|
4495
4506
|
Blockly.Extensions.registerMutator(
|
4496
|
-
|
4497
|
-
|
4498
|
-
|
4499
|
-
|
4507
|
+
"controls_if_mutator_without_ui",
|
4508
|
+
Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN,
|
4509
|
+
null,
|
4510
|
+
[]
|
4500
4511
|
);
|
4501
4512
|
|
4502
4513
|
Blockly.Blocks.AlternativaCompleta = {
|
4503
|
-
|
4504
|
-
|
4505
|
-
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
4509
|
-
|
4510
|
-
|
4511
|
-
|
4512
|
-
|
4513
|
-
|
4514
|
-
|
4515
|
-
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4519
|
-
|
4520
|
-
|
4521
|
-
|
4522
|
-
|
4523
|
-
|
4524
|
-
|
4525
|
-
|
4526
|
-
|
4527
|
-
|
4514
|
+
init: function () {
|
4515
|
+
this.jsonInit({
|
4516
|
+
"type": "Statement",
|
4517
|
+
"previousStatement": "Statement",
|
4518
|
+
"nextStatement": "Statement",
|
4519
|
+
"message0": "%{BKY_CONTROLS_IF_MSG_IF} %1",
|
4520
|
+
"args0": [
|
4521
|
+
{
|
4522
|
+
"type": "input_value",
|
4523
|
+
"name": "condicion"
|
4524
|
+
}
|
4525
|
+
],
|
4526
|
+
"message1": "%{BKY_CONTROLS_IF_MSG_THEN} %1",
|
4527
|
+
"args1": [
|
4528
|
+
{
|
4529
|
+
"type": "input_statement",
|
4530
|
+
"name": "block1",
|
4531
|
+
"check": ["Statement"]
|
4532
|
+
}
|
4533
|
+
],
|
4534
|
+
"colour": "%{BKY_LOGIC_HUE}",
|
4535
|
+
"helpUrl": "%{BKY_CONTROLS_IF_HELPURL}",
|
4536
|
+
"mutator": "controls_if_mutator_without_ui",
|
4537
|
+
"extensions": ["controls_if_tooltip"]
|
4538
|
+
});
|
4528
4539
|
|
4529
|
-
|
4530
|
-
|
4540
|
+
this.setColour(Blockly.CUSTOM_COLORS.AlternativaCompleta || Blockly.CUSTOM_COLORS.controlStructure);
|
4541
|
+
this.setInputsInline(true);
|
4531
4542
|
|
4532
|
-
|
4533
|
-
|
4534
|
-
|
4535
|
-
|
4536
|
-
|
4537
|
-
|
4543
|
+
this.elseCount_++;
|
4544
|
+
this.updateShape_();
|
4545
|
+
},
|
4546
|
+
customContextMenu: function(options) {
|
4547
|
+
options.unshift({ text: `Limpiar ramas 'si no, si'`, enabled: true, callback: () => {
|
4548
|
+
this.elseifCount_ = 0;
|
4538
4549
|
|
4539
|
-
|
4540
|
-
|
4550
|
+
this.updateShape_();
|
4551
|
+
}});
|
4541
4552
|
|
4542
|
-
|
4543
|
-
|
4553
|
+
options.unshift({ text: `Agregar 'si no, si'`, enabled: true, callback: () => {
|
4554
|
+
this.elseifCount_++;
|
4544
4555
|
|
4545
|
-
|
4546
|
-
|
4547
|
-
|
4548
|
-
|
4549
|
-
|
4556
|
+
const valueConnections = [null];
|
4557
|
+
const statementConnections = [null];
|
4558
|
+
const elseStatementConnection = this.getInput("block2").connection.targetConnection;
|
4559
|
+
let k;
|
4560
|
+
let input;
|
4550
4561
|
|
4551
|
-
|
4552
|
-
|
4553
|
-
|
4554
|
-
|
4555
|
-
|
4562
|
+
k = 1;
|
4563
|
+
while (input = this.getInput("IF" + k)) {
|
4564
|
+
valueConnections.push(input.connection.targetConnection);
|
4565
|
+
k++;
|
4566
|
+
}
|
4556
4567
|
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
4561
|
-
|
4568
|
+
k = 1;
|
4569
|
+
while (input = this.getInput("DO" + k)) {
|
4570
|
+
statementConnections.push(input.connection.targetConnection);
|
4571
|
+
k++;
|
4572
|
+
}
|
4562
4573
|
|
4563
|
-
|
4574
|
+
this.updateShape_();
|
4564
4575
|
|
4565
|
-
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4570
|
-
|
4571
|
-
|
4572
|
-
|
4576
|
+
// Reconnect any child blocks.
|
4577
|
+
for (var i = 1; i <= this.elseifCount_; i++) {
|
4578
|
+
Blockly.Mutator.reconnect(valueConnections[i], this, 'IF' + i);
|
4579
|
+
Blockly.Mutator.reconnect(statementConnections[i], this, 'DO' + i);
|
4580
|
+
}
|
4581
|
+
Blockly.Mutator.reconnect(elseStatementConnection, this, 'block2');
|
4582
|
+
}});
|
4583
|
+
}
|
4573
4584
|
};
|
4574
4585
|
|
4575
4586
|
// ------------------------------------------------------
|
@@ -4577,126 +4588,126 @@ Blockly.Blocks.AlternativaCompleta = {
|
|
4577
4588
|
// ------------------------------------------------------
|
4578
4589
|
|
4579
4590
|
Blockly.Blocks.Poner = {
|
4580
|
-
|
4591
|
+
init: function () {
|
4581
4592
|
const icon = "putStone.png";
|
4582
4593
|
|
4583
|
-
|
4584
|
-
|
4585
|
-
|
4586
|
-
|
4587
|
-
|
4588
|
-
|
4594
|
+
this.jsonInit({
|
4595
|
+
message0: '%1 Poner %2',
|
4596
|
+
type: "Statement",
|
4597
|
+
previousStatement: "Statement",
|
4598
|
+
nextStatement: "Statement",
|
4599
|
+
args0: [
|
4589
4600
|
{
|
4590
4601
|
"type": "field_image",
|
4591
4602
|
"src": getLocalMediaUrl(this, icon),
|
4592
4603
|
"width": getLocalMediaSize(icon),
|
4593
4604
|
"height": getLocalMediaSize(icon)
|
4594
4605
|
},
|
4595
|
-
|
4596
|
-
|
4597
|
-
|
4598
|
-
|
4599
|
-
|
4600
|
-
|
4601
|
-
|
4602
|
-
|
4603
|
-
|
4604
|
-
|
4606
|
+
{
|
4607
|
+
type: 'input_value',
|
4608
|
+
name: 'COLOR'
|
4609
|
+
}
|
4610
|
+
],
|
4611
|
+
colour: Blockly.CUSTOM_COLORS.Poner || Blockly.CUSTOM_COLORS.primitiveCommand,
|
4612
|
+
tooltip: 'Poner color en casillero.',
|
4613
|
+
inputsInline: true
|
4614
|
+
});
|
4615
|
+
}
|
4605
4616
|
};
|
4606
4617
|
|
4607
4618
|
Blockly.Blocks.Sacar = {
|
4608
|
-
|
4619
|
+
init: function () {
|
4609
4620
|
const icon = "removeStone.png";
|
4610
4621
|
|
4611
|
-
|
4612
|
-
|
4613
|
-
|
4614
|
-
|
4615
|
-
|
4616
|
-
|
4622
|
+
this.jsonInit({
|
4623
|
+
type: "Statement",
|
4624
|
+
previousStatement: "Statement",
|
4625
|
+
nextStatement: "Statement",
|
4626
|
+
message0: '%1 Sacar %2',
|
4627
|
+
args0: [
|
4617
4628
|
{
|
4618
4629
|
"type": "field_image",
|
4619
4630
|
"src": getLocalMediaUrl(this, icon),
|
4620
4631
|
"width": getLocalMediaSize(icon),
|
4621
4632
|
"height": getLocalMediaSize(icon)
|
4622
4633
|
},
|
4623
|
-
|
4624
|
-
|
4625
|
-
|
4626
|
-
|
4627
|
-
|
4628
|
-
|
4629
|
-
|
4630
|
-
|
4631
|
-
|
4632
|
-
|
4634
|
+
{
|
4635
|
+
type: 'input_value',
|
4636
|
+
name: 'COLOR'
|
4637
|
+
}
|
4638
|
+
],
|
4639
|
+
colour: Blockly.CUSTOM_COLORS.Sacar || Blockly.CUSTOM_COLORS.primitiveCommand,
|
4640
|
+
tooltip: 'Sacar color de casillero.',
|
4641
|
+
inputsInline: true
|
4642
|
+
});
|
4643
|
+
}
|
4633
4644
|
};
|
4634
4645
|
|
4635
4646
|
Blockly.Blocks.Mover = {
|
4636
|
-
|
4647
|
+
init: function () {
|
4637
4648
|
const icon = "move.png";
|
4638
4649
|
|
4639
|
-
|
4640
|
-
|
4641
|
-
|
4642
|
-
|
4643
|
-
|
4644
|
-
|
4650
|
+
this.jsonInit({
|
4651
|
+
type: "Statement",
|
4652
|
+
previousStatement: "Statement",
|
4653
|
+
nextStatement: "Statement",
|
4654
|
+
message0: '%1 Mover %2',
|
4655
|
+
args0: [
|
4645
4656
|
{
|
4646
4657
|
"type": "field_image",
|
4647
4658
|
"src": getLocalMediaUrl(this, icon),
|
4648
4659
|
"width": getLocalMediaSize(icon),
|
4649
4660
|
"height": getLocalMediaSize(icon)
|
4650
4661
|
},
|
4651
|
-
|
4652
|
-
|
4653
|
-
|
4654
|
-
|
4655
|
-
|
4656
|
-
|
4657
|
-
|
4658
|
-
|
4659
|
-
|
4660
|
-
|
4662
|
+
{
|
4663
|
+
type: 'input_value',
|
4664
|
+
name: 'DIRECCION'
|
4665
|
+
}
|
4666
|
+
],
|
4667
|
+
colour: Blockly.CUSTOM_COLORS.Mover || Blockly.CUSTOM_COLORS.primitiveCommand,
|
4668
|
+
tooltip: 'Mover en una dirección.',
|
4669
|
+
inputsInline: true
|
4670
|
+
});
|
4671
|
+
}
|
4661
4672
|
};
|
4662
4673
|
|
4663
4674
|
Blockly.Blocks.IrAlBorde = {
|
4664
|
-
|
4675
|
+
init: function () {
|
4665
4676
|
const icon = "goToEdge.png";
|
4666
4677
|
|
4667
|
-
|
4668
|
-
|
4669
|
-
|
4670
|
-
|
4671
|
-
|
4672
|
-
|
4678
|
+
this.jsonInit({
|
4679
|
+
type: "Statement",
|
4680
|
+
previousStatement: "Statement",
|
4681
|
+
nextStatement: "Statement",
|
4682
|
+
message0: '%1 Ir al borde %2',
|
4683
|
+
args0: [
|
4673
4684
|
{
|
4674
4685
|
"type": "field_image",
|
4675
4686
|
"src": getLocalMediaUrl(this, icon),
|
4676
4687
|
"width": getLocalMediaSize(icon),
|
4677
4688
|
"height": getLocalMediaSize(icon)
|
4678
4689
|
},
|
4679
|
-
|
4680
|
-
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4690
|
+
{
|
4691
|
+
type: 'input_value',
|
4692
|
+
name: 'DIRECCION'
|
4693
|
+
}
|
4694
|
+
],
|
4695
|
+
colour: Blockly.CUSTOM_COLORS.IrAlBorde || Blockly.CUSTOM_COLORS.primitiveCommand,
|
4696
|
+
tooltip: 'Ir al borde del tablero.',
|
4697
|
+
inputsInline: true
|
4698
|
+
});
|
4699
|
+
}
|
4689
4700
|
};
|
4690
4701
|
|
4691
4702
|
Blockly.Blocks.VaciarTablero = {
|
4692
|
-
|
4703
|
+
init: function () {
|
4693
4704
|
const icon = "emptyBoard.png";
|
4694
4705
|
|
4695
|
-
|
4696
|
-
|
4697
|
-
|
4698
|
-
|
4699
|
-
|
4706
|
+
this.jsonInit({
|
4707
|
+
type: "Statement",
|
4708
|
+
previousStatement: "Statement",
|
4709
|
+
nextStatement: "Statement",
|
4710
|
+
message0: '%1 Vaciar tablero',
|
4700
4711
|
args0: [
|
4701
4712
|
{
|
4702
4713
|
"type": "field_image",
|
@@ -4705,82 +4716,82 @@ Blockly.Blocks.VaciarTablero = {
|
|
4705
4716
|
"height": getLocalMediaSize(icon)
|
4706
4717
|
},
|
4707
4718
|
],
|
4708
|
-
|
4709
|
-
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4719
|
+
colour: Blockly.CUSTOM_COLORS.VaciarTablero || Blockly.CUSTOM_COLORS.primitiveCommand,
|
4720
|
+
tooltip: 'Vaciar el tablero.',
|
4721
|
+
inputsInline: true
|
4722
|
+
});
|
4723
|
+
}
|
4713
4724
|
};
|
4714
4725
|
|
4715
4726
|
Blockly.Blocks.BOOM = {
|
4716
|
-
|
4727
|
+
init: function () {
|
4717
4728
|
const icon = "boom.png";
|
4718
4729
|
|
4719
|
-
|
4720
|
-
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
4730
|
+
this.jsonInit({
|
4731
|
+
"type": "Statement",
|
4732
|
+
"previousStatement": "Statement",
|
4733
|
+
"nextStatement": "Statement",
|
4734
|
+
"lastDummyAlign0": "RIGHT",
|
4735
|
+
"message0": "%1 Hacer ¡BOOM! porque: %2 %3",
|
4736
|
+
"args0": [
|
4726
4737
|
{
|
4727
4738
|
"type": "field_image",
|
4728
4739
|
"src": getLocalMediaUrl(this, icon),
|
4729
4740
|
"width": getLocalMediaSize(icon),
|
4730
4741
|
"height": getLocalMediaSize(icon)
|
4731
4742
|
},
|
4732
|
-
|
4733
|
-
|
4734
|
-
|
4735
|
-
|
4736
|
-
|
4737
|
-
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4744
|
-
|
4745
|
-
|
4743
|
+
{
|
4744
|
+
"type": "input_dummy"
|
4745
|
+
},
|
4746
|
+
{
|
4747
|
+
"type": "field_input",
|
4748
|
+
"name": "boomDescription",
|
4749
|
+
"text": "Ingresar motivo..."
|
4750
|
+
}
|
4751
|
+
],
|
4752
|
+
"inputsInline": false,
|
4753
|
+
"colour": Blockly.CUSTOM_COLORS.BOOM || Blockly.CUSTOM_COLORS.primitiveCommand,
|
4754
|
+
"tooltip": "Este comando hace que estalle todo."
|
4755
|
+
});
|
4756
|
+
}
|
4746
4757
|
};
|
4747
4758
|
|
4748
4759
|
Blockly.Blocks.makeShadowEventListener = function(event){
|
4749
|
-
|
4750
|
-
|
4751
|
-
|
4760
|
+
if(event.blockId == this.id && event.newParentId){
|
4761
|
+
this.setShadow(true);
|
4762
|
+
}
|
4752
4763
|
};
|
4753
4764
|
|
4754
4765
|
Blockly.Blocks.ComandoCompletar = {
|
4755
|
-
|
4756
|
-
|
4757
|
-
|
4758
|
-
|
4759
|
-
|
4760
|
-
|
4761
|
-
|
4762
|
-
|
4763
|
-
|
4764
|
-
|
4765
|
-
|
4766
|
+
init: function () {
|
4767
|
+
this.jsonInit({
|
4768
|
+
"type": "Statement",
|
4769
|
+
"previousStatement": "Statement",
|
4770
|
+
"nextStatement": "Statement",
|
4771
|
+
"lastDummyAlign0": "RIGHT",
|
4772
|
+
"message0": "COMPLETAR",
|
4773
|
+
"colour": Blockly.CUSTOM_COLORS.ComandoCompletar || Blockly.CUSTOM_COLORS.complete,
|
4774
|
+
"tooltip": "Tenés que reemplazar este bloque por tu solución"
|
4775
|
+
});
|
4776
|
+
},
|
4766
4777
|
|
4767
|
-
|
4778
|
+
onchange: Blockly.Blocks.makeShadowEventListener
|
4768
4779
|
};
|
4769
4780
|
|
4770
4781
|
Blockly.Blocks.AsociacionDeTeclaCompletar = {
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
|
4781
|
-
|
4782
|
+
init: function () {
|
4783
|
+
this.jsonInit({
|
4784
|
+
"type": "InteractiveBinding",
|
4785
|
+
"previousStatement": "InteractiveBinding",
|
4786
|
+
"nextStatement": "InteractiveBinding",
|
4787
|
+
"lastDummyAlign0": "RIGHT",
|
4788
|
+
"message0": "COMPLETAR",
|
4789
|
+
"colour": Blockly.CUSTOM_COLORS.AsociacionDeTeclaCompletar || Blockly.CUSTOM_COLORS.complete,
|
4790
|
+
"tooltip": "Tenés que reemplazar este bloque por tu solución"
|
4791
|
+
});
|
4792
|
+
},
|
4782
4793
|
|
4783
|
-
|
4794
|
+
onchange: Blockly.Blocks.makeShadowEventListener
|
4784
4795
|
};
|
4785
4796
|
|
4786
4797
|
// ------------------------------------------------------
|
@@ -4800,7 +4811,7 @@ function deepCopyObj(aObject) {
|
|
4800
4811
|
const oldMathNumber = Blockly.Blocks.math_number;
|
4801
4812
|
Blockly.Blocks.math_number = deepCopyObj(Blockly.Blocks.math_number);
|
4802
4813
|
Blockly.Blocks.math_number.init = function() {
|
4803
|
-
|
4814
|
+
oldMathNumber.init.call(this);
|
4804
4815
|
|
4805
4816
|
const icon = "number.png";
|
4806
4817
|
var iconField = new Blockly.FieldImage(
|
@@ -4809,30 +4820,30 @@ Blockly.Blocks.math_number.init = function() {
|
|
4809
4820
|
getLocalMediaSize(icon)
|
4810
4821
|
);
|
4811
4822
|
this.inputList[0].insertFieldAt(0, iconField);
|
4812
|
-
|
4823
|
+
this.setColour(Blockly.CUSTOM_COLORS.math_number || Blockly.CUSTOM_COLORS.literalExpression);
|
4813
4824
|
}
|
4814
4825
|
|
4815
4826
|
Blockly.Blocks.ExpresionCompletar = {
|
4816
|
-
|
4817
|
-
|
4818
|
-
|
4819
|
-
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4824
|
-
|
4827
|
+
init: function () {
|
4828
|
+
this.jsonInit({
|
4829
|
+
"type": "completar_expression",
|
4830
|
+
"message0": "COMPLETAR",
|
4831
|
+
"output": "any",
|
4832
|
+
"colour": Blockly.CUSTOM_COLORS.ExpresionCompletar || Blockly.CUSTOM_COLORS.complete,
|
4833
|
+
"tooltip": "Tenés que reemplazar este bloque por tu solución"
|
4834
|
+
});
|
4835
|
+
},
|
4825
4836
|
|
4826
|
-
|
4837
|
+
onchange: Blockly.Blocks.makeShadowEventListener
|
4827
4838
|
};
|
4828
4839
|
|
4829
4840
|
function createLiteralSelectorBlock(type,values){
|
4830
|
-
|
4831
|
-
|
4832
|
-
|
4833
|
-
|
4834
|
-
|
4835
|
-
|
4841
|
+
return {
|
4842
|
+
init: function () {
|
4843
|
+
this.jsonInit({
|
4844
|
+
type: type,
|
4845
|
+
message0: "%1 %2",
|
4846
|
+
args0: [
|
4836
4847
|
{
|
4837
4848
|
"type": "field_image",
|
4838
4849
|
"src": "",
|
@@ -4840,16 +4851,16 @@ function createLiteralSelectorBlock(type,values){
|
|
4840
4851
|
"height": 16
|
4841
4852
|
},
|
4842
4853
|
{
|
4843
|
-
|
4844
|
-
|
4845
|
-
|
4854
|
+
type: "field_dropdown",
|
4855
|
+
name: type + "Dropdown",
|
4856
|
+
options: values.map(value => [value,value])
|
4846
4857
|
}
|
4847
|
-
|
4848
|
-
|
4849
|
-
|
4850
|
-
|
4851
|
-
|
4852
|
-
|
4858
|
+
],
|
4859
|
+
output: type,
|
4860
|
+
colour: Blockly.CUSTOM_COLORS[`${type}Selector`] || Blockly.CUSTOM_COLORS.literalExpression,
|
4861
|
+
tooltip: "Escoger " + type,
|
4862
|
+
});
|
4863
|
+
},
|
4853
4864
|
|
4854
4865
|
onchange: function(event) {
|
4855
4866
|
const [image, dropdown] = this.inputList[0].fieldRow;
|
@@ -4857,7 +4868,7 @@ function createLiteralSelectorBlock(type,values){
|
|
4857
4868
|
|
4858
4869
|
image.setValue(getLocalMediaUrl(this, `${type.toLowerCase()}-${value.toLowerCase()}.svg`));
|
4859
4870
|
}
|
4860
|
-
|
4871
|
+
};
|
4861
4872
|
}
|
4862
4873
|
|
4863
4874
|
Blockly.Blocks.ColorSelector = createLiteralSelectorBlock('Color',['Rojo','Verde','Negro','Azul']);
|
@@ -4898,6 +4909,7 @@ Blockly.Blocks.List = {
|
|
4898
4909
|
const input = this.appendValueInput('element' + this.length);
|
4899
4910
|
this._addRemoveButtonFor(input);
|
4900
4911
|
this._addAddButton();
|
4912
|
+
triggerRefresh(this);
|
4901
4913
|
},
|
4902
4914
|
|
4903
4915
|
_removeElement: function(input) {
|
@@ -4911,6 +4923,7 @@ Blockly.Blocks.List = {
|
|
4911
4923
|
id++;
|
4912
4924
|
}
|
4913
4925
|
}
|
4926
|
+
triggerRefresh(this);
|
4914
4927
|
},
|
4915
4928
|
|
4916
4929
|
_addAddButton: function() {
|
@@ -5000,22 +5013,22 @@ Blockly.Blocks.ForEach = {
|
|
5000
5013
|
};
|
5001
5014
|
|
5002
5015
|
function createSingleParameterExpressionBlock(blockText,returnType, colorType = "operator"){
|
5003
|
-
|
5004
|
-
|
5005
|
-
|
5006
|
-
|
5007
|
-
|
5008
|
-
|
5009
|
-
|
5010
|
-
|
5011
|
-
|
5012
|
-
|
5013
|
-
|
5014
|
-
|
5015
|
-
|
5016
|
-
|
5017
|
-
|
5018
|
-
|
5016
|
+
return {
|
5017
|
+
init: function () {
|
5018
|
+
this.jsonInit({
|
5019
|
+
message0: blockText + ' %1',
|
5020
|
+
args0: [
|
5021
|
+
{
|
5022
|
+
type: 'input_value',
|
5023
|
+
name: 'VALUE'
|
5024
|
+
}
|
5025
|
+
],
|
5026
|
+
colour: Blockly.CUSTOM_COLORS[this.type] || Blockly.CUSTOM_COLORS[colorType],
|
5027
|
+
inputsInline: true,
|
5028
|
+
output: returnType
|
5029
|
+
})
|
5030
|
+
}
|
5031
|
+
};
|
5019
5032
|
}
|
5020
5033
|
|
5021
5034
|
Blockly.Blocks.hayBolitas = createSingleParameterExpressionBlock('hay bolitas','Bool', "primitiveExpression");
|
@@ -5027,132 +5040,132 @@ Blockly.Blocks.nroBolitas = createSingleParameterExpressionBlock('número de bol
|
|
5027
5040
|
// ------------------------------------------------------
|
5028
5041
|
|
5029
5042
|
Blockly.Blocks.OperadorDeComparacion = {
|
5030
|
-
|
5031
|
-
|
5032
|
-
|
5033
|
-
|
5034
|
-
|
5035
|
-
|
5036
|
-
|
5037
|
-
|
5038
|
-
|
5039
|
-
|
5040
|
-
|
5041
|
-
|
5042
|
-
|
5043
|
-
|
5044
|
-
|
5045
|
-
|
5046
|
-
|
5047
|
-
|
5048
|
-
|
5049
|
-
|
5050
|
-
|
5051
|
-
|
5052
|
-
|
5053
|
-
|
5054
|
-
|
5055
|
-
|
5043
|
+
init: function () {
|
5044
|
+
this.jsonInit({
|
5045
|
+
message0: '%1 %2 %3 %4',
|
5046
|
+
args0: [
|
5047
|
+
{
|
5048
|
+
type: 'input_value',
|
5049
|
+
name: 'arg1'
|
5050
|
+
},
|
5051
|
+
{
|
5052
|
+
type: 'field_dropdown',
|
5053
|
+
name: 'RELATION',
|
5054
|
+
options: [['==', '=='], ['/=', '/='], ['<=', '<='], ['<', '<'], ['>=', '>='], ['>', '>']]
|
5055
|
+
},
|
5056
|
+
{
|
5057
|
+
type: 'input_dummy'
|
5058
|
+
},
|
5059
|
+
{
|
5060
|
+
type: 'input_value',
|
5061
|
+
name: 'arg2'
|
5062
|
+
}
|
5063
|
+
],
|
5064
|
+
colour: Blockly.CUSTOM_COLORS.OperadorDeComparacion || Blockly.CUSTOM_COLORS.operator,
|
5065
|
+
inputsInline: false,
|
5066
|
+
output: 'Bool'
|
5067
|
+
});
|
5068
|
+
}
|
5056
5069
|
};
|
5057
5070
|
|
5058
5071
|
Blockly.Blocks.OperadorNumerico = {
|
5059
|
-
|
5060
|
-
|
5061
|
-
|
5062
|
-
|
5063
|
-
|
5064
|
-
|
5065
|
-
|
5066
|
-
|
5067
|
-
|
5068
|
-
|
5069
|
-
|
5070
|
-
|
5071
|
-
|
5072
|
-
|
5073
|
-
|
5074
|
-
|
5075
|
-
|
5076
|
-
|
5077
|
-
|
5078
|
-
|
5079
|
-
|
5080
|
-
|
5081
|
-
|
5082
|
-
|
5083
|
-
|
5084
|
-
|
5072
|
+
init: function () {
|
5073
|
+
this.jsonInit({
|
5074
|
+
message0: '%1 %2 %3 %4',
|
5075
|
+
args0: [
|
5076
|
+
{
|
5077
|
+
type: 'input_value',
|
5078
|
+
name: 'arg1'
|
5079
|
+
},
|
5080
|
+
{
|
5081
|
+
type: 'field_dropdown',
|
5082
|
+
name: 'OPERATOR',
|
5083
|
+
options: [['+', '+'], ['-', '-'], ['*', '*'], ['div', 'div'], ['mod', 'mod'], ['^', '^']]
|
5084
|
+
},
|
5085
|
+
{
|
5086
|
+
type: 'input_dummy'
|
5087
|
+
},
|
5088
|
+
{
|
5089
|
+
type: 'input_value',
|
5090
|
+
name: 'arg2'
|
5091
|
+
}
|
5092
|
+
],
|
5093
|
+
colour: Blockly.CUSTOM_COLORS.OperadorNumerico || Blockly.CUSTOM_COLORS.operator,
|
5094
|
+
inputsInline: false,
|
5095
|
+
output: 'Number'
|
5096
|
+
});
|
5097
|
+
}
|
5085
5098
|
};
|
5086
5099
|
|
5087
5100
|
Blockly.Blocks.OperadorLogico = {
|
5088
|
-
|
5089
|
-
|
5090
|
-
|
5091
|
-
|
5092
|
-
|
5093
|
-
|
5094
|
-
|
5095
|
-
|
5096
|
-
|
5097
|
-
|
5098
|
-
|
5099
|
-
|
5100
|
-
|
5101
|
-
|
5102
|
-
|
5103
|
-
|
5104
|
-
|
5105
|
-
|
5106
|
-
|
5107
|
-
|
5108
|
-
|
5109
|
-
|
5110
|
-
|
5111
|
-
|
5112
|
-
|
5113
|
-
|
5101
|
+
init: function () {
|
5102
|
+
this.jsonInit({
|
5103
|
+
message0: '%1 %2 %3 %4',
|
5104
|
+
args0: [
|
5105
|
+
{
|
5106
|
+
type: 'input_value',
|
5107
|
+
name: 'arg1'
|
5108
|
+
},
|
5109
|
+
{
|
5110
|
+
type: 'field_dropdown',
|
5111
|
+
name: 'OPERATOR',
|
5112
|
+
options: [['y también', 'AND'], ['o bien', '||']]
|
5113
|
+
},
|
5114
|
+
{
|
5115
|
+
type: 'input_dummy'
|
5116
|
+
},
|
5117
|
+
{
|
5118
|
+
type: 'input_value',
|
5119
|
+
name: 'arg2'
|
5120
|
+
}
|
5121
|
+
],
|
5122
|
+
colour: Blockly.CUSTOM_COLORS.OperadorLogico || Blockly.CUSTOM_COLORS.operator,
|
5123
|
+
inputsInline: false,
|
5124
|
+
output: 'Bool'
|
5125
|
+
});
|
5126
|
+
}
|
5114
5127
|
};
|
5115
5128
|
|
5116
5129
|
Blockly.Blocks.Asignacion = {
|
5117
|
-
|
5130
|
+
init: function () {
|
5118
5131
|
const icon = "assignation.png";
|
5119
5132
|
|
5120
|
-
|
5121
|
-
|
5122
|
-
|
5123
|
-
|
5133
|
+
this.jsonInit({
|
5134
|
+
"type": "asignacion",
|
5135
|
+
"message0": "%1 Recordar que %2 %3 vale %4 %5",
|
5136
|
+
"args0": [
|
5124
5137
|
{
|
5125
5138
|
"type": "field_image",
|
5126
5139
|
"src": getLocalMediaUrl(this, icon),
|
5127
5140
|
"width": getLocalMediaSize(icon),
|
5128
5141
|
"height": getLocalMediaSize(icon)
|
5129
5142
|
},
|
5130
|
-
|
5131
|
-
|
5132
|
-
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5137
|
-
|
5138
|
-
|
5139
|
-
|
5140
|
-
|
5141
|
-
|
5142
|
-
|
5143
|
-
|
5144
|
-
|
5145
|
-
|
5146
|
-
|
5147
|
-
|
5148
|
-
|
5149
|
-
|
5150
|
-
|
5151
|
-
|
5152
|
-
|
5153
|
-
|
5143
|
+
{
|
5144
|
+
"type": "field_input",
|
5145
|
+
"name": "varName",
|
5146
|
+
"text": "una variable",
|
5147
|
+
"class": Blockly.Procedures.rename
|
5148
|
+
},
|
5149
|
+
{
|
5150
|
+
"type": "input_dummy"
|
5151
|
+
},
|
5152
|
+
{
|
5153
|
+
"type": "input_dummy"
|
5154
|
+
},
|
5155
|
+
{
|
5156
|
+
"type": "input_value",
|
5157
|
+
"name": "varValue"
|
5158
|
+
}
|
5159
|
+
],
|
5160
|
+
"inputsInline": true,
|
5161
|
+
"previousStatement": null,
|
5162
|
+
"nextStatement": null,
|
5163
|
+
"colour": Blockly.CUSTOM_COLORS.Asignacion || Blockly.CUSTOM_COLORS.assignation,
|
5164
|
+
"tooltip": "",
|
5165
|
+
"helpUrl": ""
|
5166
|
+
});
|
5154
5167
|
|
5155
|
-
|
5168
|
+
var self = this;
|
5156
5169
|
|
5157
5170
|
const handIcon = "hand.png";
|
5158
5171
|
var createGetterButton = new Blockly.FieldImage(
|
@@ -5161,70 +5174,70 @@ Blockly.Blocks.Asignacion = {
|
|
5161
5174
|
getLocalMediaSize(handIcon),
|
5162
5175
|
"Obtener variable",
|
5163
5176
|
function() {
|
5164
|
-
|
5165
|
-
|
5177
|
+
var name = self.getFieldValue('varName');
|
5178
|
+
self.createVariableBlock(name);
|
5166
5179
|
}
|
5167
5180
|
);
|
5168
5181
|
|
5169
5182
|
this.appendDummyInput().appendField(createGetterButton);
|
5170
|
-
|
5183
|
+
},
|
5171
5184
|
|
5172
|
-
|
5173
|
-
|
5185
|
+
customContextMenu: function(options) {
|
5186
|
+
var name = this.getFieldValue('varName');
|
5174
5187
|
|
5175
|
-
|
5176
|
-
|
5177
|
-
|
5178
|
-
|
5188
|
+
options.unshift({ text: `Crear ${name}`, enabled: true, callback: () => {
|
5189
|
+
this.createVariableBlock(name);
|
5190
|
+
}});
|
5191
|
+
},
|
5179
5192
|
|
5180
|
-
|
5181
|
-
|
5182
|
-
|
5193
|
+
createVariableBlock: function(name) {
|
5194
|
+
return createVariable(this, name);
|
5195
|
+
}
|
5183
5196
|
};
|
5184
5197
|
|
5185
5198
|
|
5186
5199
|
Blockly.Blocks.variables_get = {
|
5187
|
-
|
5188
|
-
|
5189
|
-
|
5190
|
-
|
5191
|
-
|
5192
|
-
|
5193
|
-
|
5194
|
-
|
5195
|
-
|
5196
|
-
|
5197
|
-
|
5198
|
-
|
5199
|
-
|
5200
|
-
|
5201
|
-
|
5202
|
-
|
5203
|
-
|
5204
|
-
|
5205
|
-
|
5206
|
-
|
5207
|
-
|
5208
|
-
|
5209
|
-
|
5210
|
-
|
5211
|
-
|
5212
|
-
|
5213
|
-
|
5214
|
-
|
5215
|
-
|
5216
|
-
onchange: function(event){
|
5217
|
-
if (this.$parent) {
|
5218
|
-
this.getField("VAR").EDITABLE = false;
|
5219
|
-
this.setColour(Blockly.CUSTOM_COLORS.parameter);
|
5220
|
-
} else {
|
5221
|
-
this.setColour(Blockly.CUSTOM_COLORS.variable);
|
5222
|
-
}
|
5200
|
+
init: function () {
|
5201
|
+
this.jsonInit({
|
5202
|
+
"type": "variables_get",
|
5203
|
+
"message0": "%1",
|
5204
|
+
"args0": [
|
5205
|
+
{
|
5206
|
+
"type": "field_input",
|
5207
|
+
"name": "VAR",
|
5208
|
+
"text": "nombre de variable"
|
5209
|
+
}
|
5210
|
+
],
|
5211
|
+
"output": null,
|
5212
|
+
"colour": Blockly.CUSTOM_COLORS.variable,
|
5213
|
+
"tooltip": "",
|
5214
|
+
"helpUrl": "",
|
5215
|
+
});
|
5216
|
+
},
|
5217
|
+
mutationToDom: function() {
|
5218
|
+
var container = document.createElement('mutation');
|
5219
|
+
container.setAttribute('var', this.getFieldValue('VAR'));
|
5220
|
+
if (this.$parent) container.setAttribute("parent", this.$parent);
|
5221
|
+
return container;
|
5222
|
+
},
|
5223
|
+
domToMutation: function(xmlElement) {
|
5224
|
+
var var_name = xmlElement.getAttribute('var');
|
5225
|
+
this.setFieldValue(var_name, 'VAR');
|
5226
|
+
this.$parent = xmlElement.getAttribute("parent") || null;
|
5227
|
+
},
|
5223
5228
|
|
5224
|
-
|
5225
|
-
|
5226
|
-
|
5227
|
-
|
5229
|
+
onchange: function(event){
|
5230
|
+
if (this.$parent) {
|
5231
|
+
this.getField("VAR").EDITABLE = false;
|
5232
|
+
this.setColour(Blockly.CUSTOM_COLORS.parameter);
|
5233
|
+
} else {
|
5234
|
+
this.setColour(Blockly.CUSTOM_COLORS.variable);
|
5235
|
+
}
|
5236
|
+
|
5237
|
+
if (event.blockId == this.id && event.type == Blockly.Events.BLOCK_DELETE) {
|
5238
|
+
// do something with parent
|
5239
|
+
}
|
5240
|
+
}
|
5228
5241
|
};
|
5229
5242
|
|
5230
5243
|
Blockly.Blocks.OperadoresDeEnumeracion = {
|
@@ -5258,14 +5271,14 @@ Blockly.Blocks.opuesto = createSingleParameterExpressionBlock('opuesto','*');
|
|
5258
5271
|
// Necesario para sanitizar nombres de procedimientos.
|
5259
5272
|
// En la interfaz de bloques de gobstones por ahora vamos a dejar pasar sólo espacios y letras con tilde
|
5260
5273
|
Blockly.Blocks.GobstonesSanitizer = function(name){
|
5261
|
-
|
5274
|
+
return name.replace(/[^A-Za-z0-9ÁÉÍÓÚÑáéíóúñ_ ]/g,'');
|
5262
5275
|
};
|
5263
5276
|
|
5264
5277
|
|
5265
5278
|
Blockly.Procedures.OldRename = Blockly.Procedures.rename;
|
5266
5279
|
Blockly.Procedures.rename = function(name){
|
5267
|
-
|
5268
|
-
|
5280
|
+
return Blockly.Procedures.OldRename.call(this,
|
5281
|
+
Blockly.Blocks.GobstonesSanitizer(name));
|
5269
5282
|
};
|
5270
5283
|
|
5271
5284
|
// Necesario para sanitizar nombres de parámetros.
|
@@ -5273,8 +5286,8 @@ Blockly.Procedures.rename = function(name){
|
|
5273
5286
|
// Mirá, mirá cómo rompo el encapsulamiento y repito código, mirá.
|
5274
5287
|
Blockly.Blocks.procedures_mutatorarg.validator_old = Blockly.Blocks.procedures_mutatorarg.validator_;
|
5275
5288
|
Blockly.Blocks.procedures_mutatorarg.validator_ = function(name){
|
5276
|
-
|
5277
|
-
|
5289
|
+
return Blockly.Blocks.procedures_mutatorarg.validator_old.call(this,
|
5290
|
+
Blockly.Blocks.GobstonesSanitizer(name));
|
5278
5291
|
};
|
5279
5292
|
</script>
|
5280
5293
|
<script>/* global Blockly, goog */
|
@@ -6609,14 +6622,6 @@ Blockly.ErrorInforming.CssContent = [
|
|
6609
6622
|
}
|
6610
6623
|
},
|
6611
6624
|
|
6612
|
-
_onBlocklyWorkspaceUpdate: function () {
|
6613
|
-
let xml = Blockly.Xml.workspaceToDom(this.workspace);
|
6614
|
-
this._blocklyWorkspaceXML = Blockly.Xml.domToText(xml);
|
6615
|
-
this.workspaceXml = this._blocklyWorkspaceXML;
|
6616
|
-
this._keepOnlyAProgram(xml);
|
6617
|
-
this._checkParameterBounds(xml);
|
6618
|
-
},
|
6619
|
-
|
6620
6625
|
_keepOnlyAProgram(xml) {
|
6621
6626
|
const findProgram = (programType) => {
|
6622
6627
|
const children = xml.children;
|
@@ -6914,11 +6919,12 @@ Blockly.ErrorInforming.CssContent = [
|
|
6914
6919
|
});
|
6915
6920
|
this.workspace.options.localMedia = this.localMedia;
|
6916
6921
|
this.workspace.options.localMediaSuffix = this.localMediaSuffix;
|
6922
|
+
this.workspace.options.parentController = this;
|
6917
6923
|
|
6918
6924
|
var _this = this;
|
6919
6925
|
this.workspace.addChangeListener(function (a, b, c) {
|
6920
6926
|
Blockly.Events.disableOrphans(a, b, c);
|
6921
|
-
_this.
|
6927
|
+
_this.onBlocklyWorkspaceUpdate();
|
6922
6928
|
});
|
6923
6929
|
this.resetWorkspace()
|
6924
6930
|
this._onresize();
|
@@ -7054,7 +7060,15 @@ Blockly.ErrorInforming.CssContent = [
|
|
7054
7060
|
setTimeout(() => {
|
7055
7061
|
this.workspaceXml = xml;
|
7056
7062
|
}, 1);
|
7057
|
-
}
|
7063
|
+
},
|
7064
|
+
|
7065
|
+
onBlocklyWorkspaceUpdate: function () {
|
7066
|
+
let xml = Blockly.Xml.workspaceToDom(this.workspace);
|
7067
|
+
this._blocklyWorkspaceXML = Blockly.Xml.domToText(xml);
|
7068
|
+
this.workspaceXml = this._blocklyWorkspaceXML;
|
7069
|
+
this._keepOnlyAProgram(xml);
|
7070
|
+
this._checkParameterBounds(xml);
|
7071
|
+
},
|
7058
7072
|
});
|
7059
7073
|
</script>
|
7060
7074
|
</dom-module>
|