kopia lustrzana https://github.com/backface/turtlestitch
made SEND blocks expandable for receivers and renamed them back to BROADCAST
rodzic
c9b3d5f493
commit
f1a5031b7b
|
@ -19,7 +19,8 @@
|
|||
* libraries no longer rely on the JSF primitive, project may need to re-import their libraries to run without having to enable JS extensions
|
||||
* bulk hide/show arbitrary blocks in the palette via the palette's context menu (instead of the primitive blocks' context menus)
|
||||
* hidden blocks don't appear in search results / keyboard input options
|
||||
* renamed BROADCAST to SEND and added a second input for message receivers, default is "all"
|
||||
* made BROADCAST blocks expandable and added a second input for message receivers, default is "all"
|
||||
* migrated SEND blocks to be BROADCAST TO blocks
|
||||
* "when I receive 'any message'" hat scripts are threadsafe (uninterruptable by other messages)
|
||||
* retired Leap Motion library, took out Hummingbird library (get the current one from Birdbrain)
|
||||
* display blocks with their error messages for custom blocks, thanks, Michael!
|
||||
|
@ -47,6 +48,7 @@
|
|||
* blocks, objects: only show the "message" upvar in the "When I receive" hat if "any message" is selected
|
||||
* blocks: only show "key" upvar in the "When ... is pressed" hat if "any key" is selected
|
||||
* blocks: tweaked blocks layout for hidden expansion slots
|
||||
* blocks, objects, store, threads: made SEND blocks expandable for receivers and renamed them back to BROADCAST
|
||||
|
||||
### 2021-10-21
|
||||
* threads, objects: make "when I receive 'any message'" hat scripts threadsafe (uninterruptable by other messages)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<script src="src/symbols.js?version=2021-03-03"></script>
|
||||
<script src="src/widgets.js?version=2021-07-21"></script>
|
||||
<script src="src/blocks.js?version=2021-10-22"></script>
|
||||
<script src="src/threads.js?version=2021-10-21"></script>
|
||||
<script src="src/threads.js?version=2021-10-22"></script>
|
||||
<script src="src/objects.js?version=2021-10-22"></script>
|
||||
<script src="src/scenes.js?version=2021-10-12"></script>
|
||||
<script src="src/gui.js?version=2021-10-20"></script>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<script src="src/maps.js?version=2021-06-15"></script>
|
||||
<script src="src/extensions.js?version=2021-10-06"></script>
|
||||
<script src="src/xml.js?version=2021-07-05"></script>
|
||||
<script src="src/store.js?version=2021-10-12"></script>
|
||||
<script src="src/store.js?version=2021-10-22"></script>
|
||||
<script src="src/locale.js?version=2021-10-21"></script>
|
||||
<script src="src/cloud.js?version=2021-02-04"></script>
|
||||
<script src="src/api.js?version=2021-07-05"></script>
|
||||
|
|
|
@ -1011,6 +1011,13 @@ SyntaxElementMorph.prototype.labelParts = {
|
|||
tags: 'static',
|
||||
max: 1
|
||||
},
|
||||
'%receive': {
|
||||
type: 'multi',
|
||||
slots: '%rcv',
|
||||
label: 'to',
|
||||
tags: 'static',
|
||||
max: 1
|
||||
},
|
||||
'%scriptVars': {
|
||||
type: 'multi',
|
||||
slots: '%t',
|
||||
|
@ -3139,7 +3146,7 @@ BlockMorph.prototype.userMenu = function () {
|
|||
return menu;
|
||||
}
|
||||
if (contains(
|
||||
['doSend', 'doSendAndWait', 'receiveMessage',
|
||||
['doBroadcast', 'doBroadcastAndWait', 'receiveMessage',
|
||||
'receiveOnClone', 'receiveGo'],
|
||||
this.selector
|
||||
)) {
|
||||
|
@ -3192,7 +3199,8 @@ BlockMorph.prototype.showMessageUsers = function () {
|
|||
message = inputs[0].evaluate();
|
||||
}
|
||||
|
||||
if (((this.selector === 'doSend') && inputs[1] instanceof InputSlotMorph)) {
|
||||
if (((this.selector === 'doBroadcast') &&
|
||||
inputs[1] instanceof InputSlotMorph)) {
|
||||
receiverName = this.inputs()[1].evaluate();
|
||||
} else if (this.selector.indexOf('receive') === 0) {
|
||||
receiverName = this.scriptTarget().name;
|
||||
|
@ -3205,7 +3213,7 @@ BlockMorph.prototype.showMessageUsers = function () {
|
|||
corral.frame.contents.children.concat(corral.stageIcon).forEach(
|
||||
icon => {
|
||||
if (icon.object &&
|
||||
((this.selector !== 'doSend' ||
|
||||
((this.selector !== 'doBroadcast' ||
|
||||
receiverName === icon.object.name) &&
|
||||
(icon.object[getter](
|
||||
message,
|
||||
|
@ -3234,7 +3242,7 @@ BlockMorph.prototype.isSending = function (message, receiverName, known = []) {
|
|||
}
|
||||
if ((morph.selector) &&
|
||||
contains(
|
||||
['doSend', 'doSendAndWait'],
|
||||
['doBroadcast', 'doBroadcastAndWait'],
|
||||
morph.selector)
|
||||
) {
|
||||
event = morph.inputs()[0].evaluate();
|
||||
|
@ -11750,6 +11758,15 @@ MultiArgMorph.prototype.getSpec = function () {
|
|||
|
||||
MultiArgMorph.prototype.setContents = function (anArray) {
|
||||
var inputs = this.inputs(), i;
|
||||
|
||||
if (!(anArray instanceof Array) && this.slotSpec === '%rcv') {
|
||||
// special case for migrating former SEND block inputs to
|
||||
// newer BROADCAST expansion slots for receivers
|
||||
// this can be removed once all SEND blocks have been
|
||||
// converted to v7
|
||||
anArray = [anArray];
|
||||
}
|
||||
|
||||
for (i = 0; i < anArray.length; i += 1) {
|
||||
if (anArray[i] !== null && (inputs[i])) {
|
||||
inputs[i].setContents(anArray[i]);
|
||||
|
|
|
@ -758,16 +758,16 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
category: 'control',
|
||||
spec: 'message'
|
||||
},
|
||||
doSend: {
|
||||
doBroadcast: {
|
||||
type: 'command',
|
||||
category: 'control',
|
||||
spec: 'send %msg to %rcv',
|
||||
spec: 'broadcast %msg %receive',
|
||||
defaults: [null, ['all']]
|
||||
},
|
||||
doSendAndWait: {
|
||||
doBroadcastAndWait: {
|
||||
type: 'command',
|
||||
category: 'control',
|
||||
spec: 'send %msg to %rcv and wait',
|
||||
spec: 'broadcast %msg %receive and wait',
|
||||
defaults: [null, ['all']]
|
||||
},
|
||||
doWait: {
|
||||
|
@ -1653,14 +1653,9 @@ SpriteMorph.prototype.initBlockMigrations = function () {
|
|||
inputs: [['length']],
|
||||
offset: 1
|
||||
},
|
||||
doBroadcast: {
|
||||
selector: 'doSend',
|
||||
inputs: [null, ['all']],
|
||||
offset: 0
|
||||
},
|
||||
doBroadcastAndWait: {
|
||||
selector: 'doSendAndWait',
|
||||
inputs: [null, ['all']],
|
||||
doSend: {
|
||||
selector: 'doBroadcast',
|
||||
expand: 1,
|
||||
offset: 0
|
||||
}
|
||||
};
|
||||
|
@ -1733,8 +1728,8 @@ SpriteMorph.prototype.blockAlternatives = {
|
|||
setSize: ['changeSize'],
|
||||
|
||||
// control:
|
||||
doSend: ['doSendAndWait'],
|
||||
doSendAndWait: ['doSend'],
|
||||
doBroadcast: ['doBroadcastAndWait'],
|
||||
doBroadcastAndWait: ['doBroadcast'],
|
||||
doIf: ['doIfElse', 'doUntil'],
|
||||
doIfElse: ['doIf', 'doUntil'],
|
||||
doRepeat: ['doUntil', ['doForever', -1], ['doFor', 2], ['doForEach', 1]],
|
||||
|
@ -2276,6 +2271,9 @@ SpriteMorph.prototype.blockForSelector = function (selector, setDefaults) {
|
|||
block.isStatic = true;
|
||||
}
|
||||
block.setSpec(localize(info.spec));
|
||||
if (migration && migration.expand) {
|
||||
block.inputs()[migration.expand].addInput();
|
||||
}
|
||||
if ((setDefaults && info.defaults) || (migration && migration.inputs)) {
|
||||
defaults = migration ? migration.inputs : info.defaults;
|
||||
block.defaults = defaults;
|
||||
|
@ -2523,8 +2521,8 @@ SpriteMorph.prototype.blockTemplates = function (
|
|||
blocks.push(block('receiveCondition'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('receiveMessage'));
|
||||
blocks.push(block('doSend'));
|
||||
blocks.push(block('doSendAndWait'));
|
||||
blocks.push(block('doBroadcast'));
|
||||
blocks.push(block('doBroadcastAndWait'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doWarp'));
|
||||
blocks.push('-');
|
||||
|
@ -8769,8 +8767,8 @@ StageMorph.prototype.blockTemplates = function (
|
|||
blocks.push(block('receiveCondition'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('receiveMessage'));
|
||||
blocks.push(block('doSend'));
|
||||
blocks.push(block('doSendAndWait'));
|
||||
blocks.push(block('doBroadcast'));
|
||||
blocks.push(block('doBroadcastAndWait'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doWarp'));
|
||||
blocks.push('-');
|
||||
|
|
15
src/store.js
15
src/store.js
|
@ -63,7 +63,7 @@ Project*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.store = '2021-October-12';
|
||||
modules.store = '2021-October-22';
|
||||
|
||||
// XML_Serializer ///////////////////////////////////////////////////////
|
||||
/*
|
||||
|
@ -1316,7 +1316,18 @@ SnapSerializer.prototype.loadInput = function (model, input, block, object) {
|
|||
});
|
||||
input.fixLayout();
|
||||
} else if (model.tag === 'block' || model.tag === 'custom-block') {
|
||||
block.replaceInput(input, this.loadBlock(model, true, object));
|
||||
if (input.slotSpec === '%rcv') {
|
||||
// special case for migrating former SEND block inputs to
|
||||
// newer BROADCAST expansion slots for receivers
|
||||
// this can be removed once all SEND blocks have been
|
||||
// converted to v7
|
||||
input.replaceInput(
|
||||
input.inputs()[0],
|
||||
this.loadBlock(model, true, object)
|
||||
);
|
||||
} else {
|
||||
block.replaceInput(input, this.loadBlock(model, true, object));
|
||||
}
|
||||
} else if (model.tag === 'color') {
|
||||
input.setColor(this.loadColor(model.contents));
|
||||
} else {
|
||||
|
|
|
@ -64,7 +64,7 @@ SnapExtensions, AlignmentMorph, TextMorph, Cloud*/
|
|||
|
||||
/*jshint esversion: 6*/
|
||||
|
||||
modules.threads = '2021-October-21';
|
||||
modules.threads = '2021-October-22';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -3657,20 +3657,20 @@ Process.prototype.checkURLAllowed = function (url) {
|
|||
|
||||
// Process event messages primitives
|
||||
|
||||
Process.prototype.doSend = function (message, target) {
|
||||
Process.prototype.doBroadcast = function (message, receivers) {
|
||||
var stage = this.homeContext.receiver.parentThatIsA(StageMorph),
|
||||
target = this.inputOption(receivers.at(1) || ['all']),
|
||||
thisObj,
|
||||
msg = this.inputOption(message),
|
||||
rcvrs,
|
||||
procs = [];
|
||||
|
||||
if (!this.canBroadcast) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// determine the receivers
|
||||
thisObj = this.blockReceiver();
|
||||
if (target instanceof Array && target[0] === 'all') {
|
||||
if (target === 'all') {
|
||||
rcvrs = stage.children.concat(stage);
|
||||
} else if (isSnapObject(target)) {
|
||||
rcvrs = [target];
|
||||
|
@ -3735,9 +3735,9 @@ Process.prototype.doSend = function (message, target) {
|
|||
return procs;
|
||||
};
|
||||
|
||||
Process.prototype.doSendAndWait = function (message, target) {
|
||||
Process.prototype.doBroadcastAndWait = function (message, target) {
|
||||
if (!this.context.activeSends) {
|
||||
this.context.activeSends = this.doSend(message, target);
|
||||
this.context.activeSends = this.doBroadcast(message, target);
|
||||
if (this.isRunning()) {
|
||||
this.context.activeSends.forEach(proc =>
|
||||
proc.runStep()
|
||||
|
|
Ładowanie…
Reference in New Issue