kopia lustrzana https://github.com/backface/turtlestitch
include a representation of the stage as sprite in the "scripts pic" export if it is more than a single one
rodzic
9afe325dc2
commit
a17f104d4d
|
@ -62,6 +62,9 @@
|
|||
* German
|
||||
* Greek, thank you, HM100!
|
||||
|
||||
### 2022-08-01
|
||||
* blocks, objects, store: include a representation of the stage as sprite in the "scripts pic" export if it is more than a single one
|
||||
|
||||
### 2022-07-31
|
||||
* threads: fixed #3085 (I hope ^^)
|
||||
* byob: fixed #3088 (I hope ^^)
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<script src="src/morphic.js?version=2022-04-26"></script>
|
||||
<script src="src/symbols.js?version=2021-03-03"></script>
|
||||
<script src="src/widgets.js?version=2021-17-09"></script>
|
||||
<script src="src/blocks.js?version=2022-07-31"></script>
|
||||
<script src="src/blocks.js?version=2022-08-01"></script>
|
||||
<script src="src/threads.js?version=2022-07-31"></script>
|
||||
<script src="src/objects.js?version=2022-07-19"></script>
|
||||
<script src="src/objects.js?version=2022-08-01"></script>
|
||||
<script src="src/scenes.js?version=2022-03-03"></script>
|
||||
<script src="src/gui.js?version=2022-07-31"></script>
|
||||
<script src="src/paint.js?version=2021-07-05"></script>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<script src="src/maps.js?version=2021-06-15"></script>
|
||||
<script src="src/extensions.js?version=2022-07-11"></script>
|
||||
<script src="src/xml.js?version=2021-07-05"></script>
|
||||
<script src="src/store.js?version=2022-04-26"></script>
|
||||
<script src="src/store.js?version=2022-08-01"></script>
|
||||
<script src="src/locale.js?version=2022-07-30"></script>
|
||||
<script src="src/cloud.js?version=2021-02-04"></script>
|
||||
<script src="src/api.js?version=2022-07-19"></script>
|
||||
|
|
|
@ -161,7 +161,7 @@ CostumeIconMorph, SoundIconMorph, SVG_Costume, embedMetadataPNG*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2022-July-31';
|
||||
modules.blocks = '2022-August-01';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -8164,10 +8164,10 @@ ScriptsMorph.prototype.scriptsXML = function () {
|
|||
return scripts[0].toXMLString();
|
||||
}
|
||||
target = this.scriptTarget();
|
||||
if (target instanceof SpriteMorph) {
|
||||
if (isSnapObject(target)) {
|
||||
return target.toXMLString();
|
||||
}
|
||||
return null; // +++ for now
|
||||
return null;
|
||||
};
|
||||
|
||||
ScriptsMorph.prototype.addComment = function () {
|
||||
|
|
|
@ -94,7 +94,7 @@ embedMetadataPNG*/
|
|||
|
||||
/*jshint esversion: 6*/
|
||||
|
||||
modules.objects = '2022-July-19';
|
||||
modules.objects = '2022-August-01';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -10231,6 +10231,74 @@ StageMorph.prototype.globalBlocksSending = function (message, receiverName) {
|
|||
return all;
|
||||
};
|
||||
|
||||
// StageMorph serialization & exporting utils
|
||||
|
||||
StageMorph.prototype.toXMLString = function () {
|
||||
// answer an xml string representation of this sprite and all parts
|
||||
// attached to it, including all dependencies (global custom blocks).
|
||||
var ide = this.parentThatIsA(IDE_Morph),
|
||||
dependencies = [],
|
||||
categories = [],
|
||||
blocksXML = '',
|
||||
conversion,
|
||||
xml;
|
||||
|
||||
function collect(item, array) {
|
||||
// only once
|
||||
if (!contains(array, item)) {
|
||||
array.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
function collectAll(items, array) {
|
||||
items.forEach(item => collect(item, array));
|
||||
}
|
||||
|
||||
// collect all dependencies and custom categories.
|
||||
// only collect global custom block dependencies, because the locals
|
||||
// will be included in each sprite's serialization code
|
||||
|
||||
// global block definition in scripts
|
||||
this.scripts.children.filter(
|
||||
morph => morph instanceof BlockMorph
|
||||
).forEach(script =>
|
||||
collectAll(
|
||||
script.dependencies(true),
|
||||
dependencies
|
||||
)
|
||||
);
|
||||
|
||||
// global block definitions referenced in local block definitions
|
||||
this.customBlocks.forEach(def => {
|
||||
collect(def.category, categories);
|
||||
collectAll(
|
||||
def.collectDependencies([], [], this)
|
||||
.filter(each => each.isGlobal),
|
||||
dependencies
|
||||
);
|
||||
});
|
||||
|
||||
// encode both parts of the export-file:
|
||||
// the blocks library and the sprites
|
||||
|
||||
if (dependencies.length || categories.length) {
|
||||
blocksXML = ide.blocksLibraryXML(dependencies, categories);
|
||||
}
|
||||
|
||||
conversion = this.toXML;
|
||||
this.toXML = this.toSpriteXML;
|
||||
xml = '<sprites app="' +
|
||||
ide.serializer.app +
|
||||
'" version="' +
|
||||
ide.serializer.version +
|
||||
'">' +
|
||||
blocksXML +
|
||||
ide.serializer.serialize([this]) +
|
||||
'</sprites>';
|
||||
this.toXML = conversion;
|
||||
return xml;
|
||||
};
|
||||
|
||||
// SpriteBubbleMorph ////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
|
|
44
src/store.js
44
src/store.js
|
@ -63,7 +63,7 @@ Project*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.store = '2022-April-26';
|
||||
modules.store = '2022-August-01';
|
||||
|
||||
// XML_Serializer ///////////////////////////////////////////////////////
|
||||
/*
|
||||
|
@ -1892,6 +1892,48 @@ StageMorph.prototype.toXML = function (serializer) {
|
|||
);
|
||||
};
|
||||
|
||||
StageMorph.prototype.toSpriteXML = function (serializer) {
|
||||
// special case: export the stage as a sprite, so it can be
|
||||
// imported into another project or scene
|
||||
var costumeIdx = this.getCostumeIdx();
|
||||
|
||||
return serializer.format(
|
||||
'<sprite name="@" idx="1" x="0" y="0"' +
|
||||
' heading="90"' +
|
||||
' scale="1"' +
|
||||
' volume="@"' +
|
||||
' pan="@"' +
|
||||
' rotation="0"' +
|
||||
'%' +
|
||||
' draggable="true"' +
|
||||
' costume="@" color="80,80,80,1" pen="tip" ~>' +
|
||||
'%' + // current costume
|
||||
'<costumes>%</costumes>' +
|
||||
'<sounds>%</sounds>' +
|
||||
'<blocks>%</blocks>' +
|
||||
'<variables>%</variables>' +
|
||||
'<scripts>%</scripts>' +
|
||||
'</sprite>',
|
||||
this.name,
|
||||
this.volume,
|
||||
this.pan,
|
||||
this.instrument ?
|
||||
' instrument="' + parseInt(this.instrument) + '" ' : '',
|
||||
costumeIdx,
|
||||
|
||||
// current costume, if it's not in the wardrobe
|
||||
!costumeIdx && this.costume ?
|
||||
'<wear>' + serializer.store(this.costume) + '</wear>'
|
||||
: '',
|
||||
|
||||
serializer.store(this.costumes, this.name + '_cst'),
|
||||
serializer.store(this.sounds, this.name + '_snd'),
|
||||
!this.customBlocks ? '' : serializer.store(this.customBlocks),
|
||||
serializer.store(this.variables),
|
||||
serializer.store(this.scripts)
|
||||
);
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.toXML = function (serializer) {
|
||||
var idx = serializer.scene.sprites.asArray().indexOf(this) + 1,
|
||||
costumeIdx = this.getCostumeIdx(),
|
||||
|
|
Ładowanie…
Reference in New Issue