kopia lustrzana https://github.com/backface/turtlestitch
import sprites with dependencies
rodzic
81504862c3
commit
d0b06812f1
|
@ -6,6 +6,7 @@
|
||||||
* export / import sprite-local custom block definitions
|
* export / import sprite-local custom block definitions
|
||||||
* added "combinations" primitive to the palette
|
* added "combinations" primitive to the palette
|
||||||
* **Notable Changes:**
|
* **Notable Changes:**
|
||||||
|
* exporting / importing a sprite includes all block dependencies (global custom blocks and palette categories)
|
||||||
* moved "append", "reshape", "combinations" blocks down one group in the palette
|
* moved "append", "reshape", "combinations" blocks down one group in the palette
|
||||||
* **Notable Fixes:**
|
* **Notable Fixes:**
|
||||||
* fixed an edge case for slot type inferral
|
* fixed an edge case for slot type inferral
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
* gui: refactored palette serialization for scripts
|
* gui: refactored palette serialization for scripts
|
||||||
* byob, blocks, gui: refactored blocksLibraryXML()
|
* byob, blocks, gui: refactored blocksLibraryXML()
|
||||||
* gui: new format for exporting sprites, under construction
|
* gui: new format for exporting sprites, under construction
|
||||||
|
* gui: store: import sprites with dependencies
|
||||||
|
|
||||||
### 2022-03-16
|
### 2022-03-16
|
||||||
* restored v7.4.0-dev
|
* restored v7.4.0-dev
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
<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-15"></script>
|
<script src="src/store.js?version=2022-03-17"></script>
|
||||||
<script src="src/locale.js?version=2022-03-16"></script>
|
<script src="src/locale.js?version=2022-03-16"></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>
|
||||||
|
|
32
src/gui.js
32
src/gui.js
|
@ -5808,15 +5808,41 @@ IDE_Morph.prototype.rawOpenSpritesString = function (str) {
|
||||||
this.spriteBar.tabBar.tabTo('scripts');
|
this.spriteBar.tabBar.tabTo('scripts');
|
||||||
if (Process.prototype.isCatchingErrors) {
|
if (Process.prototype.isCatchingErrors) {
|
||||||
try {
|
try {
|
||||||
this.serializer.loadSprites(str, this);
|
this.deserializeSpritesString(str);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.showMessage('Load failed: ' + err);
|
this.showMessage('Load failed: ' + err);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.serializer.loadSprites(str, this);
|
this.deserializeSpritesString(str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IDE_Morph.prototype.deserializeSpritesString = function (str) {
|
||||||
|
var xml = this.serializer.parse(str),
|
||||||
|
blocksModel = xml.childNamed('blocks'),
|
||||||
|
blocks;
|
||||||
|
|
||||||
|
if (blocksModel) {
|
||||||
|
// load the custom block definitions the sprites depend on
|
||||||
|
blocks = this.serializer.loadBlocksModel(blocksModel, this.stage);
|
||||||
|
blocks.global.forEach(def => {
|
||||||
|
def.receiver = this.stage;
|
||||||
|
this.stage.globalBlocks.push(def);
|
||||||
|
this.stage.replaceDoubleDefinitionsFor(def);
|
||||||
|
});
|
||||||
|
// notice, there should not be any local blocks in this part of
|
||||||
|
// the model instead we're expecting them inside each sprite
|
||||||
|
this.flushPaletteCache();
|
||||||
|
this.refreshPalette();
|
||||||
|
this.createCategories();
|
||||||
|
this.categories.refreshEmpty();
|
||||||
|
this.createPaletteHandle();
|
||||||
|
this.categories.fixLayout();
|
||||||
|
this.fixLayout();
|
||||||
|
}
|
||||||
|
this.serializer.loadSpritesModel(xml, this);
|
||||||
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.openMediaString = function (str) {
|
IDE_Morph.prototype.openMediaString = function (str) {
|
||||||
if (Process.prototype.isCatchingErrors) {
|
if (Process.prototype.isCatchingErrors) {
|
||||||
try {
|
try {
|
||||||
|
@ -5898,7 +5924,7 @@ IDE_Morph.prototype.deserializeScriptString = function (str) {
|
||||||
this.categories.fixLayout();
|
this.categories.fixLayout();
|
||||||
this.fixLayout();
|
this.fixLayout();
|
||||||
}
|
}
|
||||||
return this.serializer.loadScriptModule(scriptModel, this.currentSprite);
|
return this.serializer.loadScriptModel(scriptModel, this.currentSprite);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.openDataString = function (str, name, type) {
|
IDE_Morph.prototype.openDataString = function (str, name, type) {
|
||||||
|
|
22
src/store.js
22
src/store.js
|
@ -63,7 +63,7 @@ Project*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.store = '2022-March-15';
|
modules.store = '2022-March-17';
|
||||||
|
|
||||||
// XML_Serializer ///////////////////////////////////////////////////////
|
// XML_Serializer ///////////////////////////////////////////////////////
|
||||||
/*
|
/*
|
||||||
|
@ -705,16 +705,24 @@ SnapSerializer.prototype.loadBlocksModel = function (model, targetStage) {
|
||||||
SnapSerializer.prototype.loadSprites = function (xmlString, ide) {
|
SnapSerializer.prototype.loadSprites = function (xmlString, ide) {
|
||||||
// public - import a set of sprites represented by xmlString
|
// public - import a set of sprites represented by xmlString
|
||||||
// into the current scene of the ide
|
// into the current scene of the ide
|
||||||
var model, scene;
|
var model = this.parse(xmlString);
|
||||||
|
|
||||||
|
if (+model.attributes.version > this.version) {
|
||||||
|
throw 'Module uses newer version of Serializer';
|
||||||
|
}
|
||||||
|
this.loadSpritesModel(model, ide);
|
||||||
|
};
|
||||||
|
|
||||||
|
SnapSerializer.prototype.loadSpritesModel = function (xmlNode, ide) {
|
||||||
|
// public - import a set of sprites represented by an xml model
|
||||||
|
// into the current scene of the ide
|
||||||
|
var model = xmlNode,
|
||||||
|
scene;
|
||||||
|
|
||||||
this.scene = new Scene(ide.stage);
|
this.scene = new Scene(ide.stage);
|
||||||
scene = this.scene;
|
scene = this.scene;
|
||||||
scene.spritesDict[scene.stage.name] = scene.stage;
|
scene.spritesDict[scene.stage.name] = scene.stage;
|
||||||
|
|
||||||
model = this.parse(xmlString);
|
|
||||||
if (+model.attributes.version > this.version) {
|
|
||||||
throw 'Module uses newer version of Serializer';
|
|
||||||
}
|
|
||||||
model.childrenNamed('sprite').forEach(model => {
|
model.childrenNamed('sprite').forEach(model => {
|
||||||
var sprite = new SpriteMorph(scene.globalVariables);
|
var sprite = new SpriteMorph(scene.globalVariables);
|
||||||
|
|
||||||
|
@ -1154,7 +1162,7 @@ SnapSerializer.prototype.loadScriptsArray = function (model, object) {
|
||||||
return scripts;
|
return scripts;
|
||||||
};
|
};
|
||||||
|
|
||||||
SnapSerializer.prototype.loadScriptModule = function (model, object) {
|
SnapSerializer.prototype.loadScriptModel = function (model, object) {
|
||||||
// return a new script represented by the given xml model,
|
// return a new script represented by the given xml model,
|
||||||
// note: custom block definitions referenced here must be loaded before
|
// note: custom block definitions referenced here must be loaded before
|
||||||
var script;
|
var script;
|
||||||
|
|
Ładowanie…
Reference in New Issue