remove tools library and merge Snap's new blocks

pull/95/head
Michael 2021-07-08 16:54:16 +02:00
rodzic 8dac5d8a3f
commit a1fc710adb
2 zmienionych plików z 91 dodań i 89 usunięć

Wyświetl plik

@ -1986,22 +1986,6 @@ IDE_Morph.prototype.projectMenu = function () {
menu.addLine();
menu.addItem(
'Import tools',
function () {
if (location.protocol === 'file:') {
myself.importLocalFile();
return;
}
myself.getURL(
myself.resourceURL('libraries', 'tools.xml'),
function (txt) {
myself.droppedText(txt, 'tools');
}
);
},
'load the official library of\npowerful blocks'
);
menu.addItem(
'Libraries...',
function() {
if (location.protocol === 'file:') {

Wyświetl plik

@ -1820,6 +1820,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('yPosition'));
blocks.push(watcherToggle('direction'));
blocks.push(block('direction'));
blocks.push('-');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'looks') {
@ -1848,7 +1850,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('comeToFront'));
blocks.push(block('goBack'));
// for debugging: ///////////////
// for debugging: ///////////////
if (this.world().isDevMode) {
blocks.push('-');
@ -1866,6 +1868,9 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('doScreenshot'));
}
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
/////////////////////////////////
@ -1898,6 +1903,9 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportSounds'));
}
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'pen') {
blocks.push(block('clear'));
@ -1913,6 +1921,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('setOpacity'));
blocks.push(block('changeOpacity'));
blocks.push(block('getOpacity'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'embroidery') {
@ -1932,10 +1942,14 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('jumpStitch'));
blocks.push(block('tieStitch'));
blocks.push(block('trimStitch'));
blocks.push('-');
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'other') {
blocks.push(block('zoomToFit'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'colors') {
blocks.push(block('setColor'));
@ -1951,12 +1965,11 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('setHSB'));
blocks.push(block('changeHSB'));
blocks.push(block('getHSB'));
blocks.push('-');
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'control') {
blocks.push(block('resetAll'));
blocks.push('-');
blocks.push(block('receiveGo'));
blocks.push(block('receiveKey'));
blocks.push(block('receiveInteraction'));
@ -1965,6 +1978,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('doBroadcast'));
blocks.push(block('doBroadcastAndWait'));
blocks.push(block('doSend'));
blocks.push(watcherToggle('getLastMessage'));
blocks.push(block('getLastMessage'));
blocks.push('-');
@ -1976,40 +1990,33 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('doForever'));
blocks.push(block('doRepeat'));
blocks.push(block('doUntil'));
blocks.push(block('doFor'));
blocks.push('-');
blocks.push(block('doIf'));
blocks.push(block('doIfElse'));
blocks.push(block('reportIfElse'));
blocks.push('-');
blocks.push(block('doReport'));
blocks.push('-');
/*
// old STOP variants, migrated to a newer version, now redundant
blocks.push(block('doStopBlock'));
blocks.push(block('doStop'));
blocks.push(block('doStopAll'));
*/
blocks.push(block('doStopThis'));
blocks.push(block('doStopOthers'));
blocks.push('-');
blocks.push(block('doRun'));
blocks.push(block('fork'));
blocks.push(block('evaluate'));
blocks.push('-');
/*
// list variants commented out for now (redundant)
blocks.push(block('doRunWithInputList'));
blocks.push(block('forkWithInputList'));
blocks.push(block('evaluateWithInputList'));
blocks.push(block('doTellTo'));
blocks.push(block('reportAskFor'));
blocks.push('-');
*/
blocks.push(block('doCallCC'));
blocks.push(block('reportCallCC'));
blocks.push('-');
blocks.push(block('receiveOnClone'));
blocks.push(block('createClone'));
blocks.push(block('newClone'));
blocks.push(block('removeClone'));
blocks.push('-');
blocks.push(block('doPauseAll'));
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'sensing') {
@ -2035,7 +2042,6 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(watcherToggle('getTimer'));
blocks.push(block('getTimer'));
blocks.push('-');
blocks.push(block('reportAttributeOf'));
if (SpriteMorph.prototype.enableFirstClass) {
blocks.push(block('reportGet'));
@ -2052,8 +2058,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
// for debugging: ///////////////
// for debugging: ///////////////
if (this.world().isDevMode) {
blocks.push('-');
@ -2070,6 +2076,10 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportStackSize'));
blocks.push(block('reportFrameCount'));
}
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
} else if (cat === 'operators') {
@ -2109,11 +2119,17 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('reportIsA'));
blocks.push(block('reportIsIdentical'));
blocks.push('-');
blocks.push(block('reportJSFunction'));
// for debugging: ///////////////
if (Process.prototype.enableJS) {
blocks.push('-');
blocks.push(block('reportJSFunction'));
if (Process.prototype.enableCompiling) {
blocks.push(block('reportCompiled'));
}
}
// for debugging: ///////////////
if (this.world().isDevMode) {
blocks.push('-');
txt = new TextMorph(localize(
@ -2126,10 +2142,14 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportTypeOf'));
blocks.push(block('reportTextFunction'));
}
blocks.push('=');
blocks.push(this.makeBlockButton(cat));
/////////////////////////////////
} else if (cat === 'variables') {
} else if (cat === 'variables') {
button = new PushButtonMorph(
null,
@ -2160,9 +2180,19 @@ SpriteMorph.prototype.blockTemplates = function (category) {
null,
myself
);
myself.deletableVariableNames().forEach(function (name) {
menu.addItem(name, name);
});
myself.deletableVariableNames().forEach(name =>
menu.addItem(
name,
name,
null,
null,
null,
null,
null,
null,
true // verbatim - don't translate
)
);
menu.popUpAtHand(myself.world());
},
'Delete a variable'
@ -2175,47 +2205,69 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
varNames = this.variables.allNames();
varNames = this.reachableGlobalVariableNames(true);
if (varNames.length > 0) {
varNames.forEach(function (name) {
varNames.forEach(name => {
blocks.push(variableWatcherToggle(name));
blocks.push(variableBlock(name));
});
blocks.push('-');
}
varNames = this.allLocalVariableNames(true);
if (varNames.length > 0) {
varNames.forEach(name => {
blocks.push(variableWatcherToggle(name));
blocks.push(variableBlock(name, true));
});
blocks.push('-');
}
blocks.push(block('doSetVar'));
blocks.push(block('doChangeVar'));
blocks.push(block('doShowVar'));
blocks.push(block('doHideVar'));
blocks.push(block('doDeclareVariables'));
// inheritance:
// inheritance:
if (StageMorph.prototype.enableInheritance) {
blocks.push('-');
blocks.push(block('doDeleteAttr'));
}
///////////////////////////////
///////////////////////////////
blocks.push('=');
blocks.push(block('reportNewList'));
blocks.push(block('reportNumbers'));
blocks.push('-');
blocks.push(block('reportCONS'));
blocks.push(block('reportListItem'));
blocks.push(block('reportCDR'));
blocks.push('-');
blocks.push(block('reportListLength'));
blocks.push(block('reportListAttribute'));
blocks.push(block('reportListIndex'));
blocks.push(block('reportListContainsItem'));
blocks.push(block('reportListIsEmpty'));
blocks.push('-');
blocks.push(block('reportMap'));
blocks.push(block('reportKeep'));
blocks.push(block('reportFindFirst'));
blocks.push(block('reportCombine'));
blocks.push('-');
blocks.push(block('doForEach'));
blocks.push('-');
blocks.push(block('reportConcatenatedLists'));
blocks.push(block('reportReshape'));
blocks.push('-');
blocks.push(block('doAddToList'));
blocks.push(block('doDeleteFromList'));
blocks.push(block('doInsertInList'));
blocks.push(block('doReplaceInList'));
// for debugging: ///////////////
// for debugging: ///////////////
if (this.world().isDevMode) {
blocks.push('-');
@ -2226,9 +2278,6 @@ SpriteMorph.prototype.blockTemplates = function (category) {
txt.setColor(this.paletteTextColor);
blocks.push(txt);
blocks.push('-');
blocks.push(block('reportMap'));
blocks.push('-');
blocks.push(block('doForEach'));
blocks.push(block('doShowTable'));
}
@ -2238,46 +2287,15 @@ SpriteMorph.prototype.blockTemplates = function (category) {
if (StageMorph.prototype.enableCodeMapping) {
blocks.push(block('doMapCodeOrHeader'));
blocks.push(block('doMapStringCode'));
blocks.push(block('doMapValueCode'));
blocks.push(block('doMapListCode'));
blocks.push('-');
blocks.push(block('reportMappedCode'));
blocks.push('=');
}
button = new PushButtonMorph(
null,
function () {
var ide = myself.parentThatIsA(IDE_Morph),
stage = myself.parentThatIsA(StageMorph);
new BlockDialogMorph(
null,
function (definition) {
if (definition.spec !== '') {
if (definition.isGlobal) {
stage.globalBlocks.push(definition);
} else {
myself.customBlocks.push(definition);
}
ide.flushPaletteCache();
ide.refreshPalette();
new BlockEditorMorph(definition, myself).popUp();
}
},
myself
).prompt(
'Make a block',
null,
myself.world()
);
},
'Make a block'
);
button.userMenu = helpMenu;
button.selector = 'addCustomBlock';
button.showHelp = BlockMorph.prototype.showHelp;
blocks.push(button);
}
blocks.push(this.makeBlockButton());
}
return blocks;
};