add persistence and defaults to cam animation settings

This commit is contained in:
Stewart Allen 2024-09-03 18:21:57 -04:00
commit 48205cb00f
5 changed files with 42 additions and 14 deletions

View file

@ -60,6 +60,17 @@ const tweak = {
gcode_decimals(v) { api.work.config({base:{gcode_decimals: v}}) }
};
function localGet(key) {
let sloc = api.conf.get().local;
return sloc[key] || api.sdb[key];
}
function localSet(key, val) {
let sloc = api.conf.get().local;
sloc[key] = api.sdb[key] = val;
return val;
}
const api = exports({
clip: (text) => {
navigator.clipboard
@ -84,6 +95,18 @@ const api = exports({
feature,
devel,
tweak,
local: {
get: (key) => localGet(key),
getInt: (key) => parseInt(localGet(key)),
getFloat: (key) => parseFloat(localGet(key)),
getBoolean: (key, def = true) => {
let val = localGet(key);
return val === true || val === 'true' || val === def;
},
toggle: (key, val, def) => localSet(key, val ?? !api.local.getBoolean(key, def)),
put: (key, val) => localSet(key, val),
set: (key, val) => localSet(key, val),
}
});
});

View file

@ -955,7 +955,11 @@ const conf = exports({
// widget extra info for slicing (extruder mapping)
widget: {},
// legacy localStorage settings (like octo print)
local: {},
local: {
'cam.anim.model': false,
'cam.anim.stock': false,
'cam.anim.speed': 3
},
mode: 'FDM',
id: genID(),
ver: CVER

View file

@ -21,14 +21,11 @@ kiri.export = exportFile;
let printSeq = parseInt(local['kiri-print-seq'] || local['print-seq'] || "0") + 1;
function localGet(key) {
let sloc = api.conf.get().local;
return sloc[key] || local[key];
return api.local.get(key);
}
function localSet(key, val) {
let sloc = api.conf.get().local;
sloc[key] = local[key] = val;
return val;
return api.local.set(key, val);
}
function exportFile(options) {

View file

@ -371,9 +371,9 @@ class Widget {
}
}
toggleVisibility() {
toggleVisibility(bool) {
const mat = this.getMaterial();
mat.visible = !mat.visible;
mat.visible = bool ?? !mat.visible;
}
/**