refactored library serialization

snap8
Jens Mönig 2022-03-14 18:35:34 +01:00
rodzic 0dd5e59b92
commit f10e88a25c
4 zmienionych plików z 44 dodań i 33 usunięć

Wyświetl plik

@ -13,6 +13,9 @@
* **Documentation Updates:**
* **Translation Updates:**
### 2022-03-14
* gui, byob: refactored library serialization
### 2022-03-11
* blocks: fixed an edge case for slot type inferral
* objects: added "combinations" primitive to the palette

Wyświetl plik

@ -20,10 +20,10 @@
<script src="src/threads.js?version=2022-03-03"></script>
<script src="src/objects.js?version=2022-03-11"></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/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/sketch.js?version=2021-11-03"></script>
<script src="src/video.js?version=2019-06-27"></script>

Wyświetl plik

@ -111,7 +111,7 @@ ArgLabelMorph*/
// Global stuff ////////////////////////////////////////////////////////
modules.byob = '2022-March-09';
modules.byob = '2022-March-14';
// Declarations
@ -4311,25 +4311,11 @@ BlockExportDialogMorph.prototype.selectNone = function () {
// BlockExportDialogMorph ops
BlockExportDialogMorph.prototype.exportBlocks = function () {
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;
var ide = this.world().children[0];
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(
str,
ide.blocksLibraryXML(this.blocks),
(ide.getProjectName() || localize('untitled')) +
' ' +
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.prototype.fixLayout

Wyświetl plik

@ -86,7 +86,7 @@ BlockVisibilityDialogMorph, ThreadManager*/
// Global stuff ////////////////////////////////////////////////////////
modules.gui = '2022-March-11';
modules.gui = '2022-March-14';
// 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.prototype.showMessage = function (message, secs) {