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