load user defined palettes

snap7
jmoenig 2021-07-22 12:17:50 +02:00
rodzic e8bd6aa5ad
commit 1ace29c2e4
2 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -32,6 +32,7 @@
### 2021-07-22
* store: serialize user defined block palettes
* objects: enabled custom categories for the stage
* store: load user defined palettes
### 2021-07-21
* user defined custom block palettes, under construction

Wyświetl plik

@ -382,6 +382,10 @@ SnapSerializer.prototype.loadScene = function (xmlNode, remixID) {
if (model.notes) {
scene.notes = model.notes.contents;
}
model.palette = model.scene.childNamed('palette');
if (model.palette) {
scene.customCategories = this.loadPalette(model.palette);
}
model.globalVariables = model.scene.childNamed('variables');
/* Stage */
@ -1620,6 +1624,15 @@ SnapSerializer.prototype.loadColor = function (colorString) {
);
};
SnapSerializer.prototype.loadPalette = function (model) {
// private
var p = new Map();
model.childrenNamed('category').forEach(node =>
p.set(node.attributes.name, this.loadColor(node.attributes.color))
);
return p;
};
// SnapSerializer XML-representation of objects:
SnapSerializer.prototype.paletteToXML = function (aMap) {