kopia lustrzana https://github.com/backface/turtlestitch
new "delete block" primitive in sensing, experimental
rodzic
710a4dcb93
commit
9332a1328f
|
@ -19,6 +19,7 @@
|
||||||
* new "label", "type", "scope", "slots", "defaults", "menus" and "editables" choices in the OF BLOCK block-attribute reporter's dropdown
|
* new "label", "type", "scope", "slots", "defaults", "menus" and "editables" choices in the OF BLOCK block-attribute reporter's dropdown
|
||||||
* new "set attribute of block" primitive, experimental
|
* new "set attribute of block" primitive, experimental
|
||||||
* new "define block" primitive, experimental
|
* new "define block" primitive, experimental
|
||||||
|
* new "delete block" primitive, experimental
|
||||||
* new "this script" primitive, experimental
|
* new "this script" primitive, experimental
|
||||||
* new localization extension primitives in the "ide" category, hyperized
|
* new localization extension primitives in the "ide" category, hyperized
|
||||||
* new extension primitive for importing a costume from a url
|
* new extension primitive for importing a costume from a url
|
||||||
|
@ -59,6 +60,7 @@
|
||||||
* blocks, threads: new "editables" selector for block attributes (indicates read-only input slots)
|
* blocks, threads: new "editables" selector for block attributes (indicates read-only input slots)
|
||||||
* German translation update for "editables"
|
* German translation update for "editables"
|
||||||
* blocks, threads: new "defaults" selector for block attributes
|
* blocks, threads: new "defaults" selector for block attributes
|
||||||
|
* blocks, objects, threads: new "delete block" primitive in sensing
|
||||||
|
|
||||||
### 2022-06-27
|
### 2022-06-27
|
||||||
* threads: trim block label before identifying existing definition in DEFINE
|
* threads: trim block label before identifying existing definition in DEFINE
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<script src="src/widgets.js?version=2021-17-09"></script>
|
<script src="src/widgets.js?version=2021-17-09"></script>
|
||||||
<script src="src/blocks.js?version=2022-06-28"></script>
|
<script src="src/blocks.js?version=2022-06-28"></script>
|
||||||
<script src="src/threads.js?version=2022-06-28"></script>
|
<script src="src/threads.js?version=2022-06-28"></script>
|
||||||
<script src="src/objects.js?version=2022-06-23"></script>
|
<script src="src/objects.js?version=2022-06-28"></script>
|
||||||
<script src="src/scenes.js?version=2022-03-03"></script>
|
<script src="src/scenes.js?version=2022-03-03"></script>
|
||||||
<script src="src/gui.js?version=2022-05-19"></script>
|
<script src="src/gui.js?version=2022-05-19"></script>
|
||||||
<script src="src/paint.js?version=2021-07-05"></script>
|
<script src="src/paint.js?version=2021-07-05"></script>
|
||||||
|
|
|
@ -13685,6 +13685,10 @@ ReporterSlotMorph.prototype.isEmptySlot = function () {
|
||||||
|
|
||||||
ReporterSlotMorph.prototype.fixLayout = function () {
|
ReporterSlotMorph.prototype.fixLayout = function () {
|
||||||
var contents = this.contents();
|
var contents = this.contents();
|
||||||
|
if (!contents) {
|
||||||
|
contents = this.emptySlot();
|
||||||
|
this.add(contents);
|
||||||
|
}
|
||||||
this.bounds.setExtent(contents.extent().add(
|
this.bounds.setExtent(contents.extent().add(
|
||||||
this.edge * 2 + this.rfBorder * 2
|
this.edge * 2 + this.rfBorder * 2
|
||||||
));
|
));
|
||||||
|
|
|
@ -94,7 +94,7 @@ embedMetadataPNG*/
|
||||||
|
|
||||||
/*jshint esversion: 6*/
|
/*jshint esversion: 6*/
|
||||||
|
|
||||||
modules.objects = '2022-June-23';
|
modules.objects = '2022-June-28';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -927,6 +927,11 @@ SpriteMorph.prototype.initBlocks = function () {
|
||||||
spec: 'set %byob of block %repRing to %s',
|
spec: 'set %byob of block %repRing to %s',
|
||||||
defaults: [['label']]
|
defaults: [['label']]
|
||||||
},
|
},
|
||||||
|
doDeleteBlock: {
|
||||||
|
type: 'command',
|
||||||
|
category: 'control',
|
||||||
|
spec: 'delete block %repRing'
|
||||||
|
},
|
||||||
reportBlockAttribute: {
|
reportBlockAttribute: {
|
||||||
type: 'reporter',
|
type: 'reporter',
|
||||||
category: 'control',
|
category: 'control',
|
||||||
|
@ -2658,6 +2663,7 @@ SpriteMorph.prototype.blockTemplates = function (
|
||||||
blocks.push(block('doSwitchToScene'));
|
blocks.push(block('doSwitchToScene'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
blocks.push(block('doDefineBlock'));
|
blocks.push(block('doDefineBlock'));
|
||||||
|
blocks.push(block('doDeleteBlock'));
|
||||||
blocks.push(block('doSetBlockAttribute'));
|
blocks.push(block('doSetBlockAttribute'));
|
||||||
blocks.push(block('reportBlockAttribute'));
|
blocks.push(block('reportBlockAttribute'));
|
||||||
blocks.push(block('reportThisContext'));
|
blocks.push(block('reportThisContext'));
|
||||||
|
@ -9138,6 +9144,7 @@ StageMorph.prototype.blockTemplates = function (
|
||||||
blocks.push(block('doSwitchToScene'));
|
blocks.push(block('doSwitchToScene'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
blocks.push(block('doDefineBlock'));
|
blocks.push(block('doDefineBlock'));
|
||||||
|
blocks.push(block('doDeleteBlock'));
|
||||||
blocks.push(block('doSetBlockAttribute'));
|
blocks.push(block('doSetBlockAttribute'));
|
||||||
blocks.push(block('reportBlockAttribute'));
|
blocks.push(block('reportBlockAttribute'));
|
||||||
blocks.push(block('reportThisContext'));
|
blocks.push(block('reportThisContext'));
|
||||||
|
|
|
@ -6175,6 +6175,47 @@ Process.prototype.compileBlockReferences = function (context, varName) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Process.prototype.doDeleteBlock = function (context) {
|
||||||
|
// highly experimental & under construction
|
||||||
|
var rcvr = this.blockReceiver(),
|
||||||
|
ide = rcvr.parentThatIsA(IDE_Morph),
|
||||||
|
stage = ide.stage,
|
||||||
|
expr, def, method, idx;
|
||||||
|
|
||||||
|
this.assertType(context, ['command', 'reporter', 'predicate']);
|
||||||
|
expr = context.expression;
|
||||||
|
if (!expr.isCustomBlock) {
|
||||||
|
throw new Error('expecting a custom block\nbut getting a primitive');
|
||||||
|
}
|
||||||
|
def = expr.isGlobal ? expr.definition : rcvr.getMethod(expr.semanticSpec);
|
||||||
|
rcvr.deleteAllBlockInstances(def);
|
||||||
|
if (def.isGlobal) {
|
||||||
|
idx = stage.globalBlocks.indexOf(def);
|
||||||
|
if (idx !== -1) {
|
||||||
|
stage.globalBlocks.splice(idx, 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// delete local definition
|
||||||
|
idx = rcvr.customBlocks.indexOf(def);
|
||||||
|
if (idx !== -1) {
|
||||||
|
rcvr.customBlocks.splice(idx, 1);
|
||||||
|
}
|
||||||
|
// refresh instances of inherited method, if any
|
||||||
|
method = rcvr.getMethod(def.blockSpec);
|
||||||
|
if (method) {
|
||||||
|
rcvr.allDependentInvocationsOf(method.blockSpec).forEach(
|
||||||
|
block => block.refresh(method)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update the IDE
|
||||||
|
ide.flushPaletteCache();
|
||||||
|
ide.categories.refreshEmpty();
|
||||||
|
ide.refreshPalette();
|
||||||
|
ide.recordUnsavedChanges();
|
||||||
|
};
|
||||||
|
|
||||||
Process.prototype.reportAttributeOf = function (attribute, name) {
|
Process.prototype.reportAttributeOf = function (attribute, name) {
|
||||||
// hyper-dyadic
|
// hyper-dyadic
|
||||||
// note: specifying strings in the left input only accesses
|
// note: specifying strings in the left input only accesses
|
||||||
|
|
Ładowanie…
Reference in New Issue