mirror of
https://github.com/thepaperpilot/Advent-Incremental.git
synced 2024-11-21 16:13:57 +00:00
Add option to ignore date
This commit is contained in:
parent
804dac69f5
commit
bf318bc823
4 changed files with 37 additions and 9 deletions
|
@ -13,6 +13,8 @@
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
<div v-if="isTab('behaviour')">
|
<div v-if="isTab('behaviour')">
|
||||||
|
<Select :title="ignoreDateTitle" :options="ignoreDateOptions" v-model="ignoreDate" />
|
||||||
|
<Toggle v-if="projInfo.enablePausing" :title="isPausedTitle" v-model="isPaused" />
|
||||||
<div v-if="canAutoSave">
|
<div v-if="canAutoSave">
|
||||||
<Toggle :title="autosaveTitle" v-model="autosave" />
|
<Toggle :title="autosaveTitle" v-model="autosave" />
|
||||||
<FeedbackButton v-if="!autosave" class="button save-button" @click="save()">
|
<FeedbackButton v-if="!autosave" class="button save-button" @click="save()">
|
||||||
|
@ -22,7 +24,6 @@
|
||||||
<div style="text-align: center" v-else>
|
<div style="text-align: center" v-else>
|
||||||
Auto-saving is disabled while between days
|
Auto-saving is disabled while between days
|
||||||
</div>
|
</div>
|
||||||
<Toggle v-if="projInfo.enablePausing" :title="isPausedTitle" v-model="isPaused" />
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isTab('appearance')">
|
<div v-if="isTab('appearance')">
|
||||||
<Select :title="themeTitle" :options="themes" v-model="theme" />
|
<Select :title="themeTitle" :options="themes" v-model="theme" />
|
||||||
|
@ -41,7 +42,7 @@ import projInfo from "data/projInfo.json";
|
||||||
import rawThemes from "data/themes";
|
import rawThemes from "data/themes";
|
||||||
import { jsx } from "features/feature";
|
import { jsx } from "features/feature";
|
||||||
import Tooltip from "features/tooltips/Tooltip.vue";
|
import Tooltip from "features/tooltips/Tooltip.vue";
|
||||||
import player from "game/player";
|
import player, { IgnoreDateSettings } from "game/player";
|
||||||
import settings, { settingFields } from "game/settings";
|
import settings, { settingFields } from "game/settings";
|
||||||
import { camelToTitle } from "util/common";
|
import { camelToTitle } from "util/common";
|
||||||
import { save } from "util/save";
|
import { save } from "util/save";
|
||||||
|
@ -80,13 +81,19 @@ const themes = Object.keys(rawThemes).map(theme => ({
|
||||||
value: theme
|
value: theme
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const ignoreDateOptions = [
|
||||||
|
{ label: "Don't Ignore", value: IgnoreDateSettings.AsIntended },
|
||||||
|
{ label: "Ignore Month", value: IgnoreDateSettings.IgnoreMonth },
|
||||||
|
{ label: "Ignore Month and Day", value: IgnoreDateSettings.IgnoreDay }
|
||||||
|
];
|
||||||
|
|
||||||
const settingFieldsComponent = computed(() => {
|
const settingFieldsComponent = computed(() => {
|
||||||
return coerceComponent(jsx(() => (<>{settingFields.map(render)}</>)));
|
return coerceComponent(jsx(() => (<>{settingFields.map(render)}</>)));
|
||||||
});
|
});
|
||||||
|
|
||||||
const { showTPS, theme, usingLog, alignUnits } = toRefs(settings);
|
const { showTPS, theme, usingLog, alignUnits } = toRefs(settings);
|
||||||
|
|
||||||
const { autosave, autoPause } = toRefs(player);
|
const { autosave, autoPause, ignoreDate } = toRefs(player);
|
||||||
|
|
||||||
const isPaused = computed({
|
const isPaused = computed({
|
||||||
get() {
|
get() {
|
||||||
|
@ -107,6 +114,12 @@ const autosaveTitle = jsx(() => (
|
||||||
<desc>Automatically save the game every second or when the game is closed.</desc>
|
<desc>Automatically save the game every second or when the game is closed.</desc>
|
||||||
</span>
|
</span>
|
||||||
));
|
));
|
||||||
|
const ignoreDateTitle = jsx(() => (
|
||||||
|
<span class="option-title">
|
||||||
|
Ignore Date<Tooltip display="Save-specific">*</Tooltip>
|
||||||
|
<desc>Allow playing the game not as an advent calendar</desc>
|
||||||
|
</span>
|
||||||
|
));
|
||||||
const isPausedTitle = jsx(() => (
|
const isPausedTitle = jsx(() => (
|
||||||
<span class="option-title">
|
<span class="option-title">
|
||||||
Pause game<Tooltip display="Save-specific">*</Tooltip>
|
Pause game<Tooltip display="Save-specific">*</Tooltip>
|
||||||
|
|
|
@ -50,6 +50,7 @@ import Notif from "components/Notif.vue";
|
||||||
import { Visibility } from "features/feature";
|
import { Visibility } from "features/feature";
|
||||||
import Tooltip from "features/tooltips/Tooltip.vue";
|
import Tooltip from "features/tooltips/Tooltip.vue";
|
||||||
import { layers } from "game/layers";
|
import { layers } from "game/layers";
|
||||||
|
import player, { IgnoreDateSettings } from "game/player";
|
||||||
import Decimal from "util/bignum";
|
import Decimal from "util/bignum";
|
||||||
import { formatTime } from "util/break_eternity";
|
import { formatTime } from "util/break_eternity";
|
||||||
import { Direction } from "util/common";
|
import { Direction } from "util/common";
|
||||||
|
@ -80,8 +81,8 @@ const canOpen = computed(
|
||||||
() =>
|
() =>
|
||||||
props.layer != null &&
|
props.layer != null &&
|
||||||
Decimal.gte(main.day.value, props.day) &&
|
Decimal.gte(main.day.value, props.day) &&
|
||||||
new Date().getMonth() === 11 &&
|
(new Date().getMonth() === 10 || player.ignoreDate !== IgnoreDateSettings.AsIntended) &&
|
||||||
new Date().getDate() >= props.day
|
(new Date().getDate() >= props.day || player.ignoreDate === IgnoreDateSettings.IgnoreDay)
|
||||||
);
|
);
|
||||||
|
|
||||||
const isMastering = main.isMastery;
|
const isMastering = main.isMastery;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
import { createParticles } from "features/particles/particles";
|
import { createParticles } from "features/particles/particles";
|
||||||
import { BaseLayer, createLayer, GenericLayer, layers } from "game/layers";
|
import { BaseLayer, createLayer, GenericLayer, layers } from "game/layers";
|
||||||
import { isPersistent, Persistent, persistent } from "game/persistence";
|
import { isPersistent, Persistent, persistent } from "game/persistence";
|
||||||
import type { PlayerData } from "game/player";
|
import { IgnoreDateSettings, PlayerData } from "game/player";
|
||||||
import player from "game/player";
|
import player from "game/player";
|
||||||
import { format, formatTime } from "util/bignum";
|
import { format, formatTime } from "util/bignum";
|
||||||
import { Computable, convertComputable, ProcessedComputable } from "util/computed";
|
import { Computable, convertComputable, ProcessedComputable } from "util/computed";
|
||||||
|
@ -86,9 +86,15 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
const day = persistent<number>(1);
|
const day = persistent<number>(1);
|
||||||
const hasWon = persistent<boolean>(false);
|
const hasWon = persistent<boolean>(false);
|
||||||
|
|
||||||
const timeUntilNewDay = computed(
|
const timeUntilNewDay = computed(() => {
|
||||||
() => (+new Date(new Date().getFullYear(), 11, day.value) - player.time) / 1000
|
if (player.ignoreDate === IgnoreDateSettings.IgnoreDay) {
|
||||||
);
|
return 0;
|
||||||
|
} else {
|
||||||
|
const month =
|
||||||
|
player.ignoreDate === IgnoreDateSettings.IgnoreMonth ? new Date().getMonth() : 11;
|
||||||
|
return (+new Date(new Date().getFullYear(), month, day.value) - player.time) / 1000;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const showLoreModal = ref<boolean>(false);
|
const showLoreModal = ref<boolean>(false);
|
||||||
const loreScene = ref<number>(-1);
|
const loreScene = ref<number>(-1);
|
||||||
|
|
|
@ -6,6 +6,12 @@ import { reactive, unref } from "vue";
|
||||||
import type { Ref } from "vue";
|
import type { Ref } from "vue";
|
||||||
import transientState from "./state";
|
import transientState from "./state";
|
||||||
|
|
||||||
|
export enum IgnoreDateSettings {
|
||||||
|
AsIntended,
|
||||||
|
IgnoreMonth,
|
||||||
|
IgnoreDay
|
||||||
|
}
|
||||||
|
|
||||||
/** The player save data object. */
|
/** The player save data object. */
|
||||||
export interface PlayerData {
|
export interface PlayerData {
|
||||||
/** The ID of this save. */
|
/** The ID of this save. */
|
||||||
|
@ -37,6 +43,7 @@ export interface PlayerData {
|
||||||
|
|
||||||
/** Should the game be paused when the player complete a day? */
|
/** Should the game be paused when the player complete a day? */
|
||||||
autoPause: boolean;
|
autoPause: boolean;
|
||||||
|
ignoreDate: IgnoreDateSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The proxied player that is used to track NaN values. */
|
/** The proxied player that is used to track NaN values. */
|
||||||
|
@ -69,6 +76,7 @@ const state = reactive<PlayerData>({
|
||||||
modID: "",
|
modID: "",
|
||||||
modVersion: "",
|
modVersion: "",
|
||||||
layers: {},
|
layers: {},
|
||||||
|
ignoreDate: IgnoreDateSettings.AsIntended,
|
||||||
|
|
||||||
autoPause: true
|
autoPause: true
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue