diff --git a/notes.md b/notes.md
index b593d25d..ca36f3fd 100644
--- a/notes.md
+++ b/notes.md
@@ -5,7 +5,6 @@
* cap path ends
* help dialog
* full bug reports
-* .b64 export may not capture or restore tools properly
* onshape mouse mapping option
## 2.4
diff --git a/src/kiri/codec.js b/src/kiri/codec.js
index ecbbc9aa..f5b8356d 100644
--- a/src/kiri/codec.js
+++ b/src/kiri/codec.js
@@ -84,9 +84,38 @@
}
/** ******************************************************************
- * Object CODEC Functions
+ * Object Class CODEC Functions
******************************************************************* */
+ KIRI.Widget.prototype.encode = function(state) {
+ const json = state._json_;
+ const geo = this.getGeoVertices();
+ const coded = {
+ type: 'widget',
+ id: this.id,
+ ver: 1, // for better future encodings
+ json: json, // safe for JSON (float32array mess)
+ group: this.group.id,
+ track: this.track,
+ geo: json ? Array.from(geo) : geo
+ };
+ return coded;
+ };
+
+ registerDecoder('widget', function(v, state) {
+ const id = v.id,
+ group = v.group || id,
+ track = v.track || undefined,
+ widget = KIRI.newWidget(id, KIRI.Widget.Groups.forid(group));
+ widget.loadVertices(v.json ? v.geo.toFloat32() : v.geo);
+ widget.saved = time();
+ if (track && track.pos) {
+ widget.track = track;
+ widget.move(track.pos.x, track.pos.y, track.pos.z, true);
+ }
+ return widget;
+ });
+
KIRI.Slice.prototype.encode = function(state) {
return {
type: 'slice',
diff --git a/src/kiri/init.js b/src/kiri/init.js
index 8c489acc..dd48306c 100644
--- a/src/kiri/init.js
+++ b/src/kiri/init.js
@@ -539,12 +539,26 @@
}
function profileExport() {
- UC.prompt("Export Profile Filename", "kiriconf").then(name => {
+ const opt = {pre: [
+ "
",
+ "
Profile Export
",
+ "
",
+ "
",
+ "
",
+ "
",
+ " include workspace",
+ "
",
+ "
"
+ ]};
+ UC.confirm("Export Filename", {ok:true, cancel: false}, "km_conf", opt).then(name => {
if (name) {
- let json = API.conf.export(),
+ let work = $('incwork').checked,
+ json = API.conf.export({work}),
blob = new Blob([json], {type: "octet/stream"}),
url = WIN.URL.createObjectURL(blob);
- $('mod-any').innerHTML = `x`;
+ $('mod-any').innerHTML = [
+ `x`
+ ].join('');
$('sexport').click();
}
});
@@ -2091,7 +2105,7 @@
$('view-arrange').onclick = API.platform.layout;
$('view-top').onclick = SPACE.view.top;
$('view-home').onclick = SPACE.view.home;
- $('view-clear').onclick = () => { API.platform.delete(API.widgets.all()) };
+ $('view-clear').onclick = API.platform.clear;
$('mode-fdm').onclick = () => { API.mode.set('FDM') };
$('mode-sla').onclick = () => { API.mode.set('SLA') };
$('mode-cam').onclick = () => { API.mode.set('CAM') };
diff --git a/src/kiri/main.js b/src/kiri/main.js
index 420a3aa2..9ff8d858 100644
--- a/src/kiri/main.js
+++ b/src/kiri/main.js
@@ -107,7 +107,8 @@
set_font: SPACE.platform.setFont,
set_axes: SPACE.platform.setAxes,
set_volume: SPACE.platform.setVolume,
- top_z: () => { return topZ }
+ top_z: () => { return topZ },
+ clear: () => { platform.delete(WIDGETS.slice()) }
};
const color = {
@@ -1494,6 +1495,7 @@
if (LOCAL) console.log('import',data);
let isSettings = (data.settings && data.version && data.time);
let isDevice = (data.device && data.version && data.time);
+ let isWork = (data.work);
if (!isSettings && !isDevice) {
UC.alert('invalid settings or device format');
console.log('data',data);
@@ -1522,13 +1524,29 @@
API.show.devices();
}
}
+ if (isWork) {
+ API.platform.clear();
+ KIRI.codec.decode(data.work).forEach(widget => {
+ platform.add(widget, 0, true);
+ });
+ if (data.view) {
+ SPACE.view.load(data.view);
+ }
+ }
}
if (ask) {
- let prompt = `Import settings made in Kiri:Moto version ${data.version} on
${new Date(data.time)}?`;
- if (isDevice) {
- prompt = `Import device "${data.device}"?`;
+ let opt = {};
+ let prompt = isDevice ?
+ `Import device "${data.device}"?` :
+ `Import settings made in Kiri:Moto version ${data.version} on
${new Date(data.time)}?`;
+ if (data.screen) {
+ opt.pre = [
+ '',
+ `

`,
+ '
'
+ ];
}
- UC.confirm(prompt).then((yes) => {
+ UC.confirm(prompt,undefined,undefined,opt).then((yes) => {
if (yes) doit();
});
} else {
@@ -1538,12 +1556,18 @@
function settingsExport(options) {
const opts = options || {};
- const shot = opts.screen ? SPACE.screenshot() : undefined;
+ const note = opts.node || undefined;
+ const shot = opts.work || opts.screen ? SPACE.screenshot() : undefined;
+ const work = opts.work ? KIRI.codec.encode(WIDGETS,{_json_:true}) : undefined;
+ const view = opts.work ? SPACE.view.save() : undefined;
return btoa(JSON.stringify({
settings: settings,
version: KIRI.version,
screen: shot,
space: SPACE.info,
+ note: note,
+ work: work,
+ view: view,
moto: MOTO.id,
init: SDB.getItem('kiri-init'),
time: Date.now()
@@ -1934,6 +1958,7 @@
// updateStockVisibility();
switch (mode) {
case VIEWS.ARRANGE:
+ complete = {};
UI.back.style.display = '';
UI.render.style.display = '';
UI.render.classList.add('lt-enabled');
diff --git a/src/kiri/ui.js b/src/kiri/ui.js
index 959e1ca8..a8486b3d 100644
--- a/src/kiri/ui.js
+++ b/src/kiri/ui.js
@@ -78,7 +78,7 @@
return confirm(message, {ok:true, cancel:false}, value);
}
- function confirm(message, buttons, input) {
+ function confirm(message, buttons, input, opt = {}) {
return new Promise((resolve, reject) => {
let btns = buttons || {
"yes": true,
@@ -90,6 +90,9 @@
``,
``,
];
+ if (opt.pre) {
+ html = opt.pre.appendAll(html);
+ }
let iid;
if (input !== undefined) {
iid = `confirm-input-${rnd}`;
@@ -99,7 +102,11 @@
Object.entries(btns).forEach((row,i) => {
html.append(``);
});
- $('mod-any').innerHTML = html.append(`
`).join('');
+ html.append(``);
+ if (opt.post) {
+ html.appendAll(opt.post);
+ }
+ $('mod-any').innerHTML = html.join('');
function done(value) {
KIRI.api.modal.hide();
setTimeout(() => { resolve(value) }, 150);