kopia lustrzana https://github.com/backface/turtlestitch
added “inherited” toggle option to inheritable variable templates
(context menu) in the paletteupd4.1
rodzic
5516f93da5
commit
eea73bae07
31
blocks.js
31
blocks.js
|
@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2017-September-06';
|
||||
modules.blocks = '2017-September-15';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -2399,7 +2399,30 @@ BlockMorph.prototype.userMenu = function () {
|
|||
}
|
||||
} else { // in palette
|
||||
if (this.selector === 'reportGetVar') {
|
||||
if (!this.isInheritedVariable()) {
|
||||
rcvr = this.scriptTarget();
|
||||
if (this.isInheritedVariable(false)) { // fully inherited
|
||||
addOption(
|
||||
'inherited',
|
||||
function () {
|
||||
rcvr.toggleInheritedVariable(myself.blockSpec);
|
||||
},
|
||||
true,
|
||||
'uncheck to\ndisinherit',
|
||||
null
|
||||
);
|
||||
} else { // not inherited
|
||||
if (this.isInheritedVariable(true)) { // shadowed
|
||||
addOption(
|
||||
'inherited',
|
||||
function () {
|
||||
rcvr.toggleInheritedVariable(myself.blockSpec);
|
||||
},
|
||||
false,
|
||||
null,
|
||||
localize('check to inherit\nfrom')
|
||||
+ ' ' + rcvr.exemplar.name
|
||||
);
|
||||
}
|
||||
addOption(
|
||||
'transient',
|
||||
'toggleTransientVariable',
|
||||
|
@ -2653,13 +2676,13 @@ BlockMorph.prototype.hidePrimitive = function () {
|
|||
ide.refreshPalette();
|
||||
};
|
||||
|
||||
BlockMorph.prototype.isInheritedVariable = function () {
|
||||
BlockMorph.prototype.isInheritedVariable = function (shadowedOnly) {
|
||||
// private - only for variable getter template inside the palette
|
||||
if (this.isTemplate &&
|
||||
(this.selector === 'reportGetVar') &&
|
||||
(this.parent instanceof FrameMorph)) {
|
||||
return contains(
|
||||
this.scriptTarget().inheritedVariableNames(),
|
||||
this.scriptTarget().inheritedVariableNames(shadowedOnly),
|
||||
this.blockSpec
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3623,13 +3623,17 @@ Fixes:
|
|||
------
|
||||
* GUI: disable camera (but make it accessible as hidden setting) because of retina issues
|
||||
|
||||
170914
|
||||
------
|
||||
* Blocks, Objects: added “inherited” option to inheritable variable templates’ context menu in the palette
|
||||
|
||||
|
||||
v4.1 Features:
|
||||
* polymorphic sprite-local custom blocks
|
||||
* inheritance of sprite-local custom blocks
|
||||
* inheritance of sprite attributes (x, y, direction, size, costumes, costume #, sounds, scripts)
|
||||
* first-class costumes and sounds
|
||||
* camera snapshots for costumes and new sprites
|
||||
* [experimental, hidden] camera snapshots for costumes and new sprites
|
||||
* localization support when typing expressions
|
||||
* support for user-forced line-breaks in custom block labels
|
||||
* ternary Boolean slot setting: support to limit Boolean input slots to “true/false” outside of rings and in palette
|
||||
|
|
10
objects.js
10
objects.js
|
@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
|
|||
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
||||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph*/
|
||||
|
||||
modules.objects = '2017-September-08';
|
||||
modules.objects = '2017-September-15';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -5606,6 +5606,14 @@ SpriteMorph.prototype.shadowVar = function (name, value) {
|
|||
}
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.toggleInheritedVariable = function (vName) {
|
||||
if (contains(this.inheritedVariableNames(true), vName)) { // is shadowed
|
||||
this.deleteVariable(vName);
|
||||
} else if (contains(this.inheritedVariableNames(), vName)) { // inherited
|
||||
this.shadowVar(vName, this.variables.getVar(vName));
|
||||
}
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.inheritedVariableNames = function (shadowedOnly) {
|
||||
var names = [],
|
||||
own = this.variables.names(),
|
||||
|
|
Ładowanie…
Reference in New Issue