Fixed exporting the currently active save not using exportEncoding

This commit is contained in:
thepaperpilot 2022-05-10 21:49:35 -05:00
parent 01ade0984c
commit 55c4476edf

View file

@ -59,7 +59,7 @@
<script setup lang="ts">
import projInfo from "data/projInfo.json";
import Modal from "components/Modal.vue";
import player, { PlayerData } from "game/player";
import player, { PlayerData, stringifySave } from "game/player";
import settings from "game/settings";
import { getUniqueID, loadSave, save, newSave } from "util/save";
import { ComponentPublicInstance, computed, nextTick, ref, shallowReactive, watch } from "vue";
@ -68,6 +68,7 @@ import Text from "./fields/Text.vue";
import Save from "./Save.vue";
import Draggable from "vuedraggable";
import LZString from "lz-string";
import { ProxyState } from "util/proxies";
export type LoadablePlayerData = Omit<Partial<PlayerData>, "id"> & { id: string; error?: unknown };
@ -189,9 +190,10 @@ const saves = computed(() =>
function exportSave(id: string) {
let saveToExport;
if (player.id === id) {
saveToExport = save();
saveToExport = stringifySave(player[ProxyState]);
} else {
saveToExport = JSON.stringify(saves.value[id]);
}
switch (projInfo.exportEncoding) {
default:
console.warn(`Unknown save encoding: ${projInfo.exportEncoding}. Defaulting to lz`);
@ -204,7 +206,6 @@ function exportSave(id: string) {
case "plain":
break;
}
}
// Put on clipboard. Using the clipboard API asks for permissions and stuff
const el = document.createElement("textarea");