mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-22 08:31:31 +00:00
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();
|
||||
} else {
|
||||
saveToExport = JSON.stringify(saves.value[id]);
|
||||
switch (projInfo.saveEncoding) {
|
||||
switch (projInfo.exportEncoding) {
|
||||
default:
|
||||
console.warn(`Unknown save encoding: ${projInfo.saveEncoding}. Defaulting to lz`);
|
||||
console.warn(`Unknown save encoding: ${projInfo.exportEncoding}. Defaulting to lz`);
|
||||
case "lz":
|
||||
saveToExport = LZString.compressToUTF16(saveToExport);
|
||||
break;
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
"maxTickLength": 3600,
|
||||
"offlineLimit": 1,
|
||||
"enablePausing": true,
|
||||
"saveEncoding": "lz"
|
||||
"exportEncoding": "base64"
|
||||
}
|
||||
|
|
|
@ -25,19 +25,7 @@ const state = reactive<Partial<Settings>>({
|
|||
watch(
|
||||
state,
|
||||
state => {
|
||||
let stringifiedSettings = 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;
|
||||
}
|
||||
const stringifiedSettings = LZString.compressToUTF16(JSON.stringify(state));
|
||||
localStorage.setItem(projInfo.id, stringifiedSettings);
|
||||
},
|
||||
{ deep: true }
|
||||
|
|
|
@ -25,19 +25,9 @@ export function setupInitialStore(player: Partial<PlayerData> = {}): Player {
|
|||
}
|
||||
|
||||
export function save(playerData?: PlayerData): string {
|
||||
let stringifiedSave = stringifySave(playerData ?? player[ProxyState]);
|
||||
switch (projInfo.saveEncoding) {
|
||||
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;
|
||||
}
|
||||
const stringifiedSave = LZString.compressToUTF16(
|
||||
stringifySave(playerData ?? player[ProxyState])
|
||||
);
|
||||
localStorage.setItem((playerData ?? player[ProxyState]).id, stringifiedSave);
|
||||
return stringifiedSave;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue