kopia lustrzana https://github.com/backface/turtlestitch
refactored library serialization
rodzic
0dd5e59b92
commit
f10e88a25c
|
@ -13,6 +13,9 @@
|
||||||
* **Documentation Updates:**
|
* **Documentation Updates:**
|
||||||
* **Translation Updates:**
|
* **Translation Updates:**
|
||||||
|
|
||||||
|
### 2022-03-14
|
||||||
|
* gui, byob: refactored library serialization
|
||||||
|
|
||||||
### 2022-03-11
|
### 2022-03-11
|
||||||
* blocks: fixed an edge case for slot type inferral
|
* blocks: fixed an edge case for slot type inferral
|
||||||
* objects: added "combinations" primitive to the palette
|
* objects: added "combinations" primitive to the palette
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
<script src="src/threads.js?version=2022-03-03"></script>
|
<script src="src/threads.js?version=2022-03-03"></script>
|
||||||
<script src="src/objects.js?version=2022-03-11"></script>
|
<script src="src/objects.js?version=2022-03-11"></script>
|
||||||
<script src="src/scenes.js?version=2022-03-03"></script>
|
<script src="src/scenes.js?version=2022-03-03"></script>
|
||||||
<script src="src/gui.js?version=2022-03-11"></script>
|
<script src="src/gui.js?version=2022-03-14"></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-03-09"></script>
|
<script src="src/byob.js?version=2022-03-14"></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>
|
||||||
|
|
33
src/byob.js
33
src/byob.js
|
@ -111,7 +111,7 @@ ArgLabelMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.byob = '2022-March-09';
|
modules.byob = '2022-March-14';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -4311,25 +4311,11 @@ BlockExportDialogMorph.prototype.selectNone = function () {
|
||||||
// BlockExportDialogMorph ops
|
// BlockExportDialogMorph ops
|
||||||
|
|
||||||
BlockExportDialogMorph.prototype.exportBlocks = function () {
|
BlockExportDialogMorph.prototype.exportBlocks = function () {
|
||||||
var globals = this.blocks.filter(def => def.isGlobal),
|
var 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) {
|
if (this.blocks.length) {
|
||||||
str = '<blocks app="'
|
|
||||||
+ this.serializer.app
|
|
||||||
+ '" version="'
|
|
||||||
+ this.serializer.version
|
|
||||||
+ '">'
|
|
||||||
+ this.paletteXML()
|
|
||||||
+ (globals.length ? glbStr : '')
|
|
||||||
+ (locals.length ? ('<local>' + locStr + '</local>') : '')
|
|
||||||
+ '</blocks>';
|
|
||||||
ide.saveXMLAs(
|
ide.saveXMLAs(
|
||||||
str,
|
ide.blocksLibraryXML(this.blocks),
|
||||||
(ide.getProjectName() || localize('untitled')) +
|
(ide.getProjectName() || localize('untitled')) +
|
||||||
' ' +
|
' ' +
|
||||||
localize('blocks'
|
localize('blocks'
|
||||||
|
@ -4344,19 +4330,6 @@ BlockExportDialogMorph.prototype.exportBlocks = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BlockExportDialogMorph.prototype.paletteXML = function () {
|
|
||||||
var palette = new Map();
|
|
||||||
this.blocks.forEach(def => {
|
|
||||||
if (SpriteMorph.prototype.customCategories.has(def.category)) {
|
|
||||||
palette.set(
|
|
||||||
def.category,
|
|
||||||
SpriteMorph.prototype.customCategories.get(def.category)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return this.serializer.paletteToXML(palette);
|
|
||||||
};
|
|
||||||
|
|
||||||
// BlockExportDialogMorph layout
|
// BlockExportDialogMorph layout
|
||||||
|
|
||||||
BlockExportDialogMorph.prototype.fixLayout
|
BlockExportDialogMorph.prototype.fixLayout
|
||||||
|
|
37
src/gui.js
37
src/gui.js
|
@ -86,7 +86,7 @@ BlockVisibilityDialogMorph, ThreadManager*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.gui = '2022-March-11';
|
modules.gui = '2022-March-14';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -7389,6 +7389,41 @@ IDE_Morph.prototype.getURL = function (url, callback, responseType) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// IDE_Morph serialization helper ops
|
||||||
|
|
||||||
|
IDE_Morph.prototype.blocksLibraryXML = function (definitions) {
|
||||||
|
// answer an XML string encoding of an array of CustomBlockDefinitions
|
||||||
|
var globals = definitions.filter(def => def.isGlobal),
|
||||||
|
locals = definitions.filter(def => !def.isGlobal),
|
||||||
|
glbStr = globals.length ? this.serializer.serialize(globals, true) : '',
|
||||||
|
locStr = locals.length ? this.serializer.serialize(locals, true) : '';
|
||||||
|
|
||||||
|
return '<blocks app="' +
|
||||||
|
this.serializer.app +
|
||||||
|
'" version="' +
|
||||||
|
this.serializer.version +
|
||||||
|
'">' +
|
||||||
|
this.paletteXML(definitions) +
|
||||||
|
(globals.length ? glbStr : '') +
|
||||||
|
(locals.length ? ('<local>' + locStr + '</local>') : '') +
|
||||||
|
'</blocks>';
|
||||||
|
};
|
||||||
|
|
||||||
|
IDE_Morph.prototype.paletteXML = function (definitions) {
|
||||||
|
// private - answer an XML string containing the palette information
|
||||||
|
// found in an array of CustomBlockDefinitions
|
||||||
|
var palette = new Map();
|
||||||
|
definitions.forEach(def => {
|
||||||
|
if (SpriteMorph.prototype.customCategories.has(def.category)) {
|
||||||
|
palette.set(
|
||||||
|
def.category,
|
||||||
|
SpriteMorph.prototype.customCategories.get(def.category)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this.serializer.paletteToXML(palette);
|
||||||
|
};
|
||||||
|
|
||||||
// IDE_Morph user dialog shortcuts
|
// IDE_Morph user dialog shortcuts
|
||||||
|
|
||||||
IDE_Morph.prototype.showMessage = function (message, secs) {
|
IDE_Morph.prototype.showMessage = function (message, secs) {
|
||||||
|
|
Ładowanie…
Reference in New Issue