mirror of
https://github.com/thepaperpilot/Advent-Incremental.git
synced 2025-02-16 09:31:43 +00:00
Disable auto-saving while between days
This commit is contained in:
parent
00ba83db00
commit
ccca7d72bf
3 changed files with 23 additions and 6 deletions
|
@ -13,10 +13,13 @@
|
|||
</template>
|
||||
<template v-slot:body>
|
||||
<div v-if="isTab('behaviour')">
|
||||
<Toggle :title="autosaveTitle" v-model="autosave" />
|
||||
<FeedbackButton v-if="!autosave" class="button save-button" @click="save()"
|
||||
>Manually save</FeedbackButton
|
||||
>
|
||||
<div v-if="canAutoSave">
|
||||
<Toggle :title="autosaveTitle" v-model="autosave" />
|
||||
<FeedbackButton v-if="!autosave" class="button save-button" @click="save()"
|
||||
>Manually save</FeedbackButton
|
||||
>
|
||||
</div>
|
||||
<div style="text-align: center" v-else>Auto-saving disabled while between days</div>
|
||||
<Toggle v-if="projInfo.enablePausing" :title="isPausedTitle" v-model="isPaused" />
|
||||
</div>
|
||||
<div v-if="isTab('appearance')">
|
||||
|
@ -45,6 +48,7 @@ import { computed, ref, toRefs } from "vue";
|
|||
import Select from "./fields/Select.vue";
|
||||
import Toggle from "./fields/Toggle.vue";
|
||||
import FeedbackButton from "./fields/FeedbackButton.vue";
|
||||
import { layers } from "game/layers";
|
||||
|
||||
const isOpen = ref(false);
|
||||
|
||||
|
@ -91,6 +95,10 @@ const isPaused = computed({
|
|||
}
|
||||
});
|
||||
|
||||
const canAutoSave = computed(
|
||||
() => (layers as any).main.days[(layers as any).main.day.value - 1].opened.value
|
||||
);
|
||||
|
||||
const autosaveTitle = jsx(() => (
|
||||
<span class="option-title">
|
||||
Autosave<Tooltip display="Save-specific">*</Tooltip>
|
||||
|
|
|
@ -13,6 +13,7 @@ import player from "game/player";
|
|||
import Decimal, { format, formatTime } from "util/bignum";
|
||||
import { Computable, convertComputable, ProcessedComputable } from "util/computed";
|
||||
import { createLazyProxy } from "util/proxies";
|
||||
import { save } from "util/save";
|
||||
import { renderRow, VueFeature } from "util/vue";
|
||||
import type { Ref } from "vue";
|
||||
import { computed, ref, unref } from "vue";
|
||||
|
@ -381,6 +382,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
|||
day.value++;
|
||||
main.minimized.value = false;
|
||||
if (player.autoPause) player.devSpeed = 0;
|
||||
save();
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import projInfo from "data/projInfo.json";
|
||||
import { globalBus } from "game/events";
|
||||
import { layers } from "game/layers";
|
||||
import type { Player, PlayerData } from "game/player";
|
||||
import player, { stringifySave } from "game/player";
|
||||
import settings, { loadSettings } from "game/settings";
|
||||
|
@ -126,12 +127,18 @@ export async function loadSave(playerObj: Partial<PlayerData>): Promise<void> {
|
|||
}
|
||||
|
||||
setInterval(() => {
|
||||
if (player.autosave) {
|
||||
if (
|
||||
player.autosave &&
|
||||
(layers as any).main.days[(layers as any).main.day.value - 1].opened.value
|
||||
) {
|
||||
save();
|
||||
}
|
||||
}, 1000);
|
||||
window.onbeforeunload = () => {
|
||||
if (player.autosave) {
|
||||
if (
|
||||
player.autosave &&
|
||||
(layers as any).main.days[(layers as any).main.day.value - 1].opened.value
|
||||
) {
|
||||
save();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue