forked from profectus/Profectus
Saving is now always lz-string. saveEncoding renamed to exportEncoding.
exportEncoding only affects exports, and defaults to base64 so it's obfuscated but doesn't have issues with being pasted in discord
This commit is contained in:
parent
521c0d1ea4
commit
868a77af29
4 changed files with 7 additions and 29 deletions
|
@ -192,9 +192,9 @@ function exportSave(id: string) {
|
||||||
saveToExport = save();
|
saveToExport = save();
|
||||||
} else {
|
} else {
|
||||||
saveToExport = JSON.stringify(saves.value[id]);
|
saveToExport = JSON.stringify(saves.value[id]);
|
||||||
switch (projInfo.saveEncoding) {
|
switch (projInfo.exportEncoding) {
|
||||||
default:
|
default:
|
||||||
console.warn(`Unknown save encoding: ${projInfo.saveEncoding}. Defaulting to lz`);
|
console.warn(`Unknown save encoding: ${projInfo.exportEncoding}. Defaulting to lz`);
|
||||||
case "lz":
|
case "lz":
|
||||||
saveToExport = LZString.compressToUTF16(saveToExport);
|
saveToExport = LZString.compressToUTF16(saveToExport);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -19,5 +19,5 @@
|
||||||
"maxTickLength": 3600,
|
"maxTickLength": 3600,
|
||||||
"offlineLimit": 1,
|
"offlineLimit": 1,
|
||||||
"enablePausing": true,
|
"enablePausing": true,
|
||||||
"saveEncoding": "lz"
|
"exportEncoding": "base64"
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,19 +25,7 @@ const state = reactive<Partial<Settings>>({
|
||||||
watch(
|
watch(
|
||||||
state,
|
state,
|
||||||
state => {
|
state => {
|
||||||
let stringifiedSettings = JSON.stringify(state);
|
const stringifiedSettings = LZString.compressToUTF16(JSON.stringify(state));
|
||||||
switch (projInfo.saveEncoding) {
|
|
||||||
default:
|
|
||||||
console.warn(`Unknown save encoding: ${projInfo.saveEncoding}. Defaulting to lz`);
|
|
||||||
case "lz":
|
|
||||||
stringifiedSettings = LZString.compressToUTF16(stringifiedSettings);
|
|
||||||
break;
|
|
||||||
case "base64":
|
|
||||||
stringifiedSettings = btoa(unescape(encodeURIComponent(stringifiedSettings)));
|
|
||||||
break;
|
|
||||||
case "plain":
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
localStorage.setItem(projInfo.id, stringifiedSettings);
|
localStorage.setItem(projInfo.id, stringifiedSettings);
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
|
|
|
@ -25,19 +25,9 @@ export function setupInitialStore(player: Partial<PlayerData> = {}): Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function save(playerData?: PlayerData): string {
|
export function save(playerData?: PlayerData): string {
|
||||||
let stringifiedSave = stringifySave(playerData ?? player[ProxyState]);
|
const stringifiedSave = LZString.compressToUTF16(
|
||||||
switch (projInfo.saveEncoding) {
|
stringifySave(playerData ?? player[ProxyState])
|
||||||
default:
|
);
|
||||||
console.warn(`Unknown save encoding: ${projInfo.saveEncoding}. Defaulting to lz`);
|
|
||||||
case "lz":
|
|
||||||
stringifiedSave = LZString.compressToUTF16(stringifiedSave);
|
|
||||||
break;
|
|
||||||
case "base64":
|
|
||||||
stringifiedSave = btoa(unescape(encodeURIComponent(stringifiedSave)));
|
|
||||||
break;
|
|
||||||
case "plain":
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
localStorage.setItem((playerData ?? player[ProxyState]).id, stringifiedSave);
|
localStorage.setItem((playerData ?? player[ProxyState]).id, stringifiedSave);
|
||||||
return stringifiedSave;
|
return stringifiedSave;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue