also scan custom blocks for message sends

pull/95/head
jmoenig 2020-09-01 17:45:27 +02:00
rodzic 72888f8cb5
commit 51a8b9e05b
3 zmienionych plików z 50 dodań i 37 usunięć

Wyświetl plik

@ -14,6 +14,7 @@
* gui, blocks: fixed a bunch of typos and UI strings, thanks, Brian Broll! * gui, blocks: fixed a bunch of typos and UI strings, thanks, Brian Broll!
* colors library update, thanks, Brian H.! * colors library update, thanks, Brian H.!
* German translation update * German translation update
* objects: also scan custom blocks for message sends
### 2020-08-31 ### 2020-08-31
* Catalan translation update, thanks, Joan! * Catalan translation update, thanks, Joan!

Wyświetl plik

@ -10,7 +10,7 @@
<script src="src/widgets.js?version=2020-07-27"></script> <script src="src/widgets.js?version=2020-07-27"></script>
<script src="src/blocks.js?version=2020-09-01"></script> <script src="src/blocks.js?version=2020-09-01"></script>
<script src="src/threads.js?version=2020-08-05"></script> <script src="src/threads.js?version=2020-08-05"></script>
<script src="src/objects.js?version=2020-08-07"></script> <script src="src/objects.js?version=2020-09-01"></script>
<script src="src/gui.js?version=2020-09-01"></script> <script src="src/gui.js?version=2020-09-01"></script>
<script src="src/paint.js?version=2020-05-17"></script> <script src="src/paint.js?version=2020-05-17"></script>
<script src="src/lists.js?version=2020-07-01"></script> <script src="src/lists.js?version=2020-07-01"></script>

Wyświetl plik

@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph, localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
HandleMorph, AlignmentMorph, Process, XML_Element, WorldMap, copyCanvas*/ HandleMorph, AlignmentMorph, Process, XML_Element, WorldMap, copyCanvas*/
modules.objects = '2020-August-07'; modules.objects = '2020-September-01';
var SpriteMorph; var SpriteMorph;
var StageMorph; var StageMorph;
@ -5753,23 +5753,8 @@ SpriteMorph.prototype.yBottom = function () {
// SpriteMorph message broadcasting // SpriteMorph message broadcasting
SpriteMorph.prototype.allMessageNames = function () { SpriteMorph.prototype.allMessageNames = function () {
var msgs = [], var msgs = [];
all = this.scripts.children.slice(); this.allScripts().forEach(script => {
this.customBlocks.forEach(def => {
if (def.body) {
all.push(def.body.expression);
}
def.scripts.forEach(scr => all.push(scr));
});
if (this.globalBlocks) {
this.globalBlocks.forEach(def => {
if (def.body) {
all.push(def.body.expression);
}
def.scripts.forEach(scr => all.push(scr));
});
}
all.forEach(script => {
script.allChildren().forEach(morph => { script.allChildren().forEach(morph => {
var txt; var txt;
if (morph instanceof InputSlotMorph && morph.choices && contains( if (morph instanceof InputSlotMorph && morph.choices && contains(
@ -5789,25 +5774,30 @@ SpriteMorph.prototype.allMessageNames = function () {
}; };
SpriteMorph.prototype.allSendersOf = function (message, receiverName) { SpriteMorph.prototype.allSendersOf = function (message, receiverName) {
if (typeof message === 'number') {message = message.toString(); } if (typeof message === 'number') {
return this.scripts.allChildren().filter(morph => { message = message.toString();
var event, eventReceiver; }
if ((morph.selector) && return this.allScripts().filter(script =>
contains( script.allChildren().some(morph => {
['doBroadcast', 'doBroadcastAndWait', 'doSend'], var event, eventReceiver;
morph.selector) if ((morph.selector) &&
) { contains(
event = morph.inputs()[0].evaluate(); ['doBroadcast', 'doBroadcastAndWait', 'doSend'],
if (morph.selector === 'doSend') { morph.selector)
eventReceiver = morph.inputs()[1].evaluate(); ) {
event = morph.inputs()[0].evaluate();
if (morph.selector === 'doSend') {
eventReceiver = morph.inputs()[1].evaluate();
}
return ((morph.selector !== 'doSend') ||
(receiverName === eventReceiver)) &&
((event === message) ||
(message instanceof Array &&
message[0] === 'any message'));
} }
return ((morph.selector !== 'doSend') || return false;
(receiverName === eventReceiver)) && })
((event === message) || );
(message instanceof Array && message[0] === 'any message'));
}
return false;
});
}; };
SpriteMorph.prototype.allHatBlocksFor = function (message) { SpriteMorph.prototype.allHatBlocksFor = function (message) {
@ -5865,6 +5855,25 @@ SpriteMorph.prototype.allGenericHatBlocks = function () {
}); });
}; };
SpriteMorph.prototype.allScripts = function () {
var all = this.scripts.children.slice();
this.customBlocks.forEach(def => {
if (def.body) {
all.push(def.body.expression);
}
def.scripts.forEach(scr => all.push(scr));
});
if (this.globalBlocks) {
this.globalBlocks.forEach(def => {
if (def.body) {
all.push(def.body.expression);
}
def.scripts.forEach(scr => all.push(scr));
});
}
return all;
};
// SpriteMorph events // SpriteMorph events
SpriteMorph.prototype.mouseClickLeft = function () { SpriteMorph.prototype.mouseClickLeft = function () {
@ -9210,6 +9219,9 @@ StageMorph.prototype.allHatBlocksForInteraction
StageMorph.prototype.allGenericHatBlocks StageMorph.prototype.allGenericHatBlocks
= SpriteMorph.prototype.allGenericHatBlocks; = SpriteMorph.prototype.allGenericHatBlocks;
StageMorph.prototype.allScripts
= SpriteMorph.prototype.allScripts;
// StageMorph events // StageMorph events
StageMorph.prototype.mouseClickLeft StageMorph.prototype.mouseClickLeft