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