kopia lustrzana https://github.com/backface/turtlestitch
rodzic
9138c69b7b
commit
dd296f5cd4
|
@ -2,6 +2,7 @@
|
|||
|
||||
## in development:
|
||||
* **New Features:**
|
||||
* export / import sprite-local custom block definitions, under construction
|
||||
* **Notable Changes:**
|
||||
* **Notable Fixes:**
|
||||
* **Documentation Updates:**
|
||||
|
@ -9,6 +10,7 @@
|
|||
|
||||
### 2022-03-09
|
||||
* new dev version
|
||||
* byob, store, gui: export / import sprite-local custom block definitions, under construction
|
||||
|
||||
## 7.3.0:
|
||||
* **New Features:**
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
<script src="src/gui.js?version=2022-03-09"></script>
|
||||
<script src="src/paint.js?version=2021-07-05"></script>
|
||||
<script src="src/lists.js?version=2022-02-07"></script>
|
||||
<script src="src/byob.js?version=2022-02-17"></script>
|
||||
<script src="src/byob.js?version=2022-03-09"></script>
|
||||
<script src="src/tables.js?version=2022-01-28"></script>
|
||||
<script src="src/sketch.js?version=2021-11-03"></script>
|
||||
<script src="src/video.js?version=2019-06-27"></script>
|
||||
<script src="src/maps.js?version=2021-06-15"></script>
|
||||
<script src="src/extensions.js?version=2022-02-08"></script>
|
||||
<script src="src/xml.js?version=2021-07-05"></script>
|
||||
<script src="src/store.js?version=2022-03-01"></script>
|
||||
<script src="src/store.js?version=2022-03-09"></script>
|
||||
<script src="src/locale.js?version=2022-03-04"></script>
|
||||
<script src="src/cloud.js?version=2021-02-04"></script>
|
||||
<script src="src/api.js?version=2022-01-03"></script>
|
||||
|
|
37
src/byob.js
37
src/byob.js
|
@ -111,7 +111,7 @@ ArgLabelMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.byob = '2022-February-17';
|
||||
modules.byob = '2022-March-09';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -598,10 +598,12 @@ CustomBlockDefinition.prototype.collectDependencies = function (
|
|||
excluding = [],
|
||||
result = []
|
||||
) {
|
||||
/* // +++ under construction
|
||||
if (!this.isGlobal) {
|
||||
throw new Error('collecting dependencies is only supported\n' +
|
||||
'for global custom blocks');
|
||||
}
|
||||
*/
|
||||
excluding.push(this);
|
||||
this.scripts.concat(
|
||||
this.body ? [this.body.expression] : []
|
||||
|
@ -1277,13 +1279,11 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
|
|||
"duplicate block definition...",
|
||||
'duplicateBlockDefinition'
|
||||
);
|
||||
if (this.isGlobal) {
|
||||
menu.addItem(
|
||||
"export block definition...",
|
||||
'exportBlockDefinition',
|
||||
'including dependencies'
|
||||
);
|
||||
}
|
||||
menu.addItem(
|
||||
"export block definition...",
|
||||
'exportBlockDefinition',
|
||||
'including dependencies'
|
||||
);
|
||||
} else { // inside a script
|
||||
// if global or own method - let the user delete the definition
|
||||
if (this.isGlobal ||
|
||||
|
@ -1308,10 +1308,12 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
|
|||
};
|
||||
|
||||
CustomCommandBlockMorph.prototype.exportBlockDefinition = function () {
|
||||
var ide = this.parentThatIsA(IDE_Morph);
|
||||
var ide = this.parentThatIsA(IDE_Morph),
|
||||
def = this.isGlobal ? this.definition
|
||||
: this.scriptTarget().getMethod(this.blockSpec);
|
||||
new BlockExportDialogMorph(
|
||||
ide.serializer,
|
||||
[this.definition].concat(this.definition.collectDependencies()),
|
||||
[def].concat(def.collectDependencies()),
|
||||
ide
|
||||
).popUp(this.world());
|
||||
};
|
||||
|
@ -4304,17 +4306,22 @@ BlockExportDialogMorph.prototype.selectNone = function () {
|
|||
// BlockExportDialogMorph ops
|
||||
|
||||
BlockExportDialogMorph.prototype.exportBlocks = function () {
|
||||
var str = this.serializer.serialize(this.blocks, true), // for library
|
||||
ide = this.world().children[0];
|
||||
var globals = this.blocks.filter(def => def.isGlobal),
|
||||
glbStr = globals.length ? this.serializer.serialize(globals, true) : '',
|
||||
locals = this.blocks.filter(def => !def.isGlobal),
|
||||
locStr = locals.length ? this.serializer.serialize(locals, true) : '',
|
||||
ide = this.world().children[0],
|
||||
str;
|
||||
|
||||
if (this.blocks.length > 0) {
|
||||
if (this.blocks.length) {
|
||||
str = '<blocks app="'
|
||||
+ this.serializer.app
|
||||
+ '" version="'
|
||||
+ this.serializer.version
|
||||
+ '">'
|
||||
+ this.paletteXML()
|
||||
+ str
|
||||
+ (globals.length ? glbStr : '')
|
||||
+ (locals.length ? ('<local>' + locStr + '</local>') : '')
|
||||
+ '</blocks>';
|
||||
ide.saveXMLAs(
|
||||
str,
|
||||
|
@ -4415,7 +4422,7 @@ BlockImportDialogMorph.prototype.importBlocks = function (name) {
|
|||
var ide = this.target.parentThatIsA(IDE_Morph);
|
||||
if (!ide) {return; }
|
||||
if (this.blocks.length > 0) {
|
||||
this.blocks.forEach(def => {
|
||||
this.blocks.forEach(def => { // +++ under construction
|
||||
def.receiver = ide.stage;
|
||||
ide.stage.globalBlocks.push(def);
|
||||
ide.stage.replaceDoubleDefinitionsFor(def);
|
||||
|
|
|
@ -86,7 +86,7 @@ BlockVisibilityDialogMorph, ThreadManager*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.gui = '2022-March-07';
|
||||
modules.gui = '2022-March-09';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -5709,11 +5709,16 @@ IDE_Morph.prototype.rawOpenBlocksString = function (str, name, silently) {
|
|||
blocks = this.serializer.loadBlocks(str, this.stage);
|
||||
}
|
||||
if (silently) {
|
||||
blocks.forEach(def => {
|
||||
blocks.global.forEach(def => {
|
||||
def.receiver = this.stage;
|
||||
this.stage.globalBlocks.push(def);
|
||||
this.stage.replaceDoubleDefinitionsFor(def);
|
||||
});
|
||||
blocks.local.forEach(def => {
|
||||
def.receiver = this.stage;
|
||||
this.currentSprite.customBlocks.push(def);
|
||||
this.currentSprite.replaceDoubleDefinitionsFor(def);
|
||||
});
|
||||
this.flushPaletteCache();
|
||||
this.refreshPalette();
|
||||
this.showMessage(
|
||||
|
|
22
src/store.js
22
src/store.js
|
@ -63,7 +63,7 @@ Project*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.store = '2022-March-01';
|
||||
modules.store = '2022-March-09';
|
||||
|
||||
// XML_Serializer ///////////////////////////////////////////////////////
|
||||
/*
|
||||
|
@ -661,7 +661,7 @@ SnapSerializer.prototype.loadScene = function (xmlNode, remixID) {
|
|||
};
|
||||
|
||||
SnapSerializer.prototype.loadBlocks = function (xmlString, targetStage) {
|
||||
// public - answer a new Array of custom block definitions
|
||||
// public - answer a new dictionary of custom block definitions
|
||||
// represented by the given XML String
|
||||
var stage, model;
|
||||
|
||||
|
@ -679,18 +679,22 @@ SnapSerializer.prototype.loadBlocks = function (xmlString, targetStage) {
|
|||
);
|
||||
}
|
||||
model.removeChild(model.palette);
|
||||
this.loadCustomBlocks(stage, model, true);
|
||||
this.populateCustomBlocks(
|
||||
stage,
|
||||
model,
|
||||
true
|
||||
);
|
||||
this.loadCustomBlocks(stage, model, true); // global
|
||||
this.populateCustomBlocks(stage, model, true); // global
|
||||
model.local = model.childNamed('local');
|
||||
if (model.local) {
|
||||
this.loadCustomBlocks(stage, model.local, false); // not global
|
||||
this.populateCustomBlocks( stage, model.local, false); // not global
|
||||
}
|
||||
this.objects = {};
|
||||
stage.globalBlocks.forEach(def => def.receiver = null);
|
||||
this.objects = {};
|
||||
this.scene = new Scene();
|
||||
this.mediaDict = {};
|
||||
return stage.globalBlocks;
|
||||
return {
|
||||
global : stage.globalBlocks,
|
||||
local : stage.customBlocks
|
||||
};
|
||||
};
|
||||
|
||||
SnapSerializer.prototype.loadSprites = function (xmlString, ide) {
|
||||
|
|
Ładowanie…
Reference in New Issue