summaryrefslogtreecommitdiff
path: root/objects.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-05-06 15:32:17 +0200
committerGubolin <gubolin@fantasymail.de>2015-05-06 15:32:17 +0200
commitb0d5fca03273d74c009c1415285c0ec375e1f848 (patch)
tree38a6a8ab1714f0f0945cd6b1a093503c8e9ac127 /objects.js
parent8a83be1c8a37ed3b3672c77028741ec5ec8c7b5a (diff)
parent83628bc0aca42c078a96b0a6fbb2675cf6cae5c3 (diff)
downloadsnap-b0d5fca03273d74c009c1415285c0ec375e1f848.tar.gz
snap-b0d5fca03273d74c009c1415285c0ec375e1f848.zip
merge upstream
Diffstat (limited to 'objects.js')
-rw-r--r--objects.js71
1 files changed, 68 insertions, 3 deletions
diff --git a/objects.js b/objects.js
index 96fda2e..39aa567 100644
--- a/objects.js
+++ b/objects.js
@@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.objects = '2015-March-24';
+modules.objects = '2015-April-17';
var SpriteMorph;
var StageMorph;
@@ -2503,6 +2503,29 @@ SpriteMorph.prototype.freshPalette = function (category) {
}
});
+ // inherited custom blocks: (under construction...)
+
+ // y += unit * 1.6;
+ if (this.exemplar) {
+ this.inheritedBlocks(true).forEach(function (definition) {
+ var block;
+ if (definition.category === category ||
+ (category === 'variables'
+ && contains(
+ ['lists', 'other'],
+ definition.category
+ ))) {
+ block = definition.templateInstance();
+ y += unit * 0.3;
+ block.setPosition(new Point(x, y));
+ palette.addContents(block);
+ block.ghost();
+ x = 0;
+ y += block.height();
+ }
+ });
+ }
+
//layout
palette.scrollX(palette.padding);
@@ -3281,7 +3304,7 @@ SpriteMorph.prototype.setEffect = function (effect, value) {
if (eff === 'ghost') {
this.alpha = 1 - Math.min(Math.max(+value || 0, 0), 100) / 100;
} else {
- this.graphicsValues[eff] = value;
+ this.graphicsValues[eff] = +value;
}
this.drawNew();
this.changed();
@@ -3296,7 +3319,7 @@ SpriteMorph.prototype.changeEffect = function (effect, value) {
if (eff === 'ghost') {
this.setEffect(effect, this.getGhostEffect() + (+value || 0));
} else {
- this.setEffect(effect, this.graphicsValues[eff] + value);
+ this.setEffect(effect, +this.graphicsValues[eff] + (+value));
}
};
@@ -4458,6 +4481,48 @@ SpriteMorph.prototype.deletableVariableNames = function () {
);
};
+// SpriteMorph inheritance - custom blocks
+
+SpriteMorph.prototype.ownBlocks = function () {
+ var dict = {};
+ this.customBlocks.forEach(function (def) {
+ dict[def.blockSpec()] = def;
+ });
+ return dict;
+};
+
+SpriteMorph.prototype.allBlocks = function (valuesOnly) {
+ var dict = {};
+ this.allExemplars().reverse().forEach(function (sprite) {
+ sprite.customBlocks.forEach(function (def) {
+ dict[def.blockSpec()] = def;
+ });
+ });
+ if (valuesOnly) {
+ return Object.keys(dict).map(function (key) {return dict[key]; });
+ }
+ return dict;
+};
+
+SpriteMorph.prototype.inheritedBlocks = function (valuesOnly) {
+ var dict = {},
+ own = Object.keys(this.ownBlocks()),
+ others = this.allExemplars().reverse();
+ others.pop();
+ others.forEach(function (sprite) {
+ sprite.customBlocks.forEach(function (def) {
+ var spec = def.blockSpec();
+ if (!contains(own, spec)) {
+ dict[spec] = def;
+ }
+ });
+ });
+ if (valuesOnly) {
+ return Object.keys(dict).map(function (key) {return dict[key]; });
+ }
+ return dict;
+};
+
// SpriteMorph highlighting
SpriteMorph.prototype.addHighlight = function (oldHighlight) {