kopia lustrzana https://github.com/backface/turtlestitch
load user defined palettes
rodzic
e8bd6aa5ad
commit
1ace29c2e4
|
@ -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
|
||||
|
|
13
src/store.js
13
src/store.js
|
@ -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) {
|
||||
|
|
Ładowanie…
Reference in New Issue