mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-24 17:31:47 +00:00
Add export save button to error component
This commit is contained in:
parent
01045a70ee
commit
c348883c53
1 changed files with 34 additions and 2 deletions
|
@ -13,7 +13,11 @@
|
||||||
Check the console for more details, and consider sharing it with the developers on
|
Check the console for more details, and consider sharing it with the developers on
|
||||||
<a :href="projInfo.discordLink || 'https://discord.gg/yJ4fjnjU54'" class="discord-link"
|
<a :href="projInfo.discordLink || 'https://discord.gg/yJ4fjnjU54'" class="discord-link"
|
||||||
>discord</a
|
>discord</a
|
||||||
>!<br />
|
>!
|
||||||
|
<FeedbackButton @click="exportSave" class="button" style="display: inline-flex"
|
||||||
|
><span class="material-icons" style="font-size: 16px">content_paste</span
|
||||||
|
><span style="margin-left: 8px; font-size: medium">Copy Save</span></FeedbackButton
|
||||||
|
><br />
|
||||||
<div v-if="errors.length > 1" style="margin-top: 20px"><h3>Other errors</h3></div>
|
<div v-if="errors.length > 1" style="margin-top: 20px"><h3>Other errors</h3></div>
|
||||||
<div v-for="(error, i) in errors.slice(1)" :key="i" style="margin-top: 20px">
|
<div v-for="(error, i) in errors.slice(1)" :key="i" style="margin-top: 20px">
|
||||||
<details class="error-details">
|
<details class="error-details">
|
||||||
|
@ -32,8 +36,10 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import projInfo from "data/projInfo.json";
|
import projInfo from "data/projInfo.json";
|
||||||
import player from "game/player";
|
import player, { stringifySave } from "game/player";
|
||||||
|
import LZString from "lz-string";
|
||||||
import { computed, onMounted } from "vue";
|
import { computed, onMounted } from "vue";
|
||||||
|
import FeedbackButton from "./fields/FeedbackButton.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
errors: Error[];
|
errors: Error[];
|
||||||
|
@ -53,6 +59,32 @@ const causes = computed(() =>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function exportSave() {
|
||||||
|
let saveToExport = stringifySave(player);
|
||||||
|
switch (projInfo.exportEncoding) {
|
||||||
|
default:
|
||||||
|
console.warn(`Unknown save encoding: ${projInfo.exportEncoding}. Defaulting to lz`);
|
||||||
|
case "lz":
|
||||||
|
saveToExport = LZString.compressToUTF16(saveToExport);
|
||||||
|
break;
|
||||||
|
case "base64":
|
||||||
|
saveToExport = btoa(unescape(encodeURIComponent(saveToExport)));
|
||||||
|
break;
|
||||||
|
case "plain":
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
console.log(saveToExport);
|
||||||
|
|
||||||
|
// Put on clipboard. Using the clipboard API asks for permissions and stuff
|
||||||
|
const el = document.createElement("textarea");
|
||||||
|
el.value = saveToExport;
|
||||||
|
document.body.appendChild(el);
|
||||||
|
el.select();
|
||||||
|
el.setSelectionRange(0, 99999);
|
||||||
|
document.execCommand("copy");
|
||||||
|
document.body.removeChild(el);
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
player.autosave = false;
|
player.autosave = false;
|
||||||
player.devSpeed = 0;
|
player.devSpeed = 0;
|
||||||
|
|
Loading…
Reference in a new issue