Skip to content

Commit

Permalink
Merge pull request #93 from zfi/master
Browse files Browse the repository at this point in the history
Merge 1.1 branch to master
  • Loading branch information
zfi authored Jan 28, 2019
2 parents 00e5e4f + 32d96d9 commit 38c0171
Show file tree
Hide file tree
Showing 17 changed files with 2,858 additions and 2,727 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.idea
node_modules
.eslintrc.js

# This file is generated automatically by a python script
blockly/apps/blockly_uncompressed.js
3,091 changes: 1,706 additions & 1,385 deletions blockly/apps/blockly_compressed.js

Large diffs are not rendered by default.

113 changes: 108 additions & 5 deletions blockly/generators/propc.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ Blockly.propc.init = function (workspace) {
Blockly.propc.variableDB_.reset();
}

//Blockly.propc.variableDB_.setVariableMap(workspace.getVariableMap()); // USE WHEN CORE IS UPDATED
Blockly.propc.variableDB_.setVariableMap(workspace.getVariableMap()); // USE WHEN CORE IS UPDATED

var defvars = [];
var variables = Blockly.Variables.allVariables(workspace);
//var variables = Blockly.Variables.allUsedVarModels(workspace); // USE WHEN CORE IS UPDATED
//var variables = Blockly.Variables.allVariables(workspace);
var variables = Blockly.Variables.allUsedVarModels(workspace); // USE WHEN CORE IS UPDATED
for (var x = 0; x < variables.length; x++) {
var varName = Blockly.propc.variableDB_.getName(variables[x],
//var varName = Blockly.propc.variableDB_.getName(variables[x].getId(), // USE WHEN CORE IS UPDATED
//var varName = Blockly.propc.variableDB_.getName(variables[x],
var varName = Blockly.propc.variableDB_.getName(variables[x].getId(), // USE WHEN CORE IS UPDATED
Blockly.Variables.NAME_TYPE);
defvars[x] = '{{$var_type_' + varName + '}} ' + varName + '{{$var_length_' + varName + '}};';
Blockly.propc.definitions_['variable' + x.toString(10)] = defvars[x];
Expand Down Expand Up @@ -553,7 +553,110 @@ if (!Object.keys) {
}());
};


// NOTE: Replaces core function! // USE WHEN CORE IS UPDATED
Blockly.Field.prototype.render_ = function() {
if (!this.visible_) {
this.size_.width = 0;
return;
}

// Replace the text.
if (this.textElement_) {
this.textElement_.textContent = this.getDisplayText_();
this.updateWidth();
}
};

//NOTE: Replaces core function!
/*
Blockly.FieldDropdown.prototype.render_ = function() {
if (!this.visible_) {
this.size_.width = 0;
return;
}
if (this.sourceBlock_ && this.arrow_) {
// Update arrow's colour.
this.arrow_.style.fill = this.sourceBlock_.getColour();
}
var child;
if (this.textElement_) {
while ((child = this.textElement_.firstChild)) {
this.textElement_.removeChild(child);
}
} else {
this.textElement_ = Blockly.utils.createSvgElement('text',
{'class': 'blocklyText', 'y': this.size_.height - 12.5},
this.fieldGroup_);
}
if (this.imageElement_) {
Blockly.utils.removeNode(this.imageElement_);
this.imageElement_ = null;
}
if (this.imageJson_) {
this.renderSelectedImage_();
} else {
this.renderSelectedText_();
}
this.borderRect_.setAttribute('height', this.size_.height - 9);
this.borderRect_.setAttribute('width', this.size_.width + Blockly.BlockSvg.SEP_SPACE_X);
};
*/


// NOTE: Replaces core function! // USE WHEN CORE IS UPDATED
/**
* Return a sorted list of variable names for variable dropdown menus.
* Include a special option at the end for creating a new variable name.
* @return {!Array.<string>} Array of variable names.
* @this {Blockly.FieldVariable}
*/
Blockly.FieldVariable.dropdownCreate = function() {
if (!this.variable_) {
throw new Error('Tried to call dropdownCreate on a variable field with no' +
' variable selected.');
}
var name = this.getText();
var workspace = null;
if (this.sourceBlock_) {
workspace = this.sourceBlock_.workspace;
}
var variableModelList = [];
if (workspace) {
var variableTypes = this.getVariableTypes_();
// Get a copy of the list, so that adding rename and new variable options
// doesn't modify the workspace's list.
for (var i = 0; i < variableTypes.length; i++) {
var variableType = variableTypes[i];
var variables = workspace.getVariablesOfType(variableType);
variableModelList = variableModelList.concat(variables);
}
}
variableModelList.sort(Blockly.VariableModel.compareByName);

var options = [];
for (var i = 0; i < variableModelList.length; i++) {
// Set the UUID as the internal representation of the variable.
options[i] = [variableModelList[i].name, variableModelList[i].getId()];
}
if (name !== Blockly.LANG_VARIABLES_SET_ITEM) {
options.push([Blockly.Msg['RENAME_VARIABLE'], Blockly.RENAME_VARIABLE_ID]);
}
if (Blockly.Msg['DELETE_VARIABLE'] && name !== Blockly.LANG_VARIABLES_SET_ITEM) { // Prevents user from deleting the default "item" variable.
options.push(
[
Blockly.Msg['DELETE_VARIABLE'].replace('%1', name),
Blockly.DELETE_VARIABLE_ID
]
);
}

return options;
};


// NOTE: Replaces core function!
Blockly.BlockSvg.prototype.setCollapsed = function (b) {
Expand Down
Loading

0 comments on commit 38c0171

Please sign in to comment.