Profectus/src/components/system/Options.vue

91 lines
2.5 KiB
Vue
Raw Normal View History

2021-05-22 20:29:06 +00:00
<template>
2022-01-14 04:25:47 +00:00
<Modal v-model="isOpen">
<template v-slot:header>
<div class="header">
<h2>Options</h2>
</div>
</template>
<template v-slot:body>
2022-01-14 04:25:47 +00:00
<Select title="Theme" :options="themes" v-model="theme" />
<Select title="Show Milestones" :options="msDisplayOptions" v-model="msDisplay" />
<Toggle title="Show TPS" v-model="showTPS" />
<Toggle title="Hide Maxed Challenges" v-model="hideChallenges" />
<Toggle title="Unthrottled" v-model="unthrottled" />
2022-01-25 04:25:34 +00:00
<Toggle :title="offlineProdTitle" v-model="offlineProd" />
<Toggle :title="autosaveTitle" v-model="autosave" />
<Toggle :title="isPausedTitle" v-model="isPaused" />
</template>
</Modal>
2021-05-22 20:29:06 +00:00
</template>
2022-01-25 04:25:34 +00:00
<script setup lang="tsx">
2022-01-14 04:25:47 +00:00
import Modal from "@/components/system/Modal.vue";
import rawThemes from "@/data/themes";
import { MilestoneDisplay } from "@/features/milestone";
import player from "@/game/player";
import settings from "@/game/settings";
2022-01-14 04:25:47 +00:00
import { camelToTitle } from "@/util/common";
import { computed, ref, toRefs } from "vue";
2022-01-14 04:25:47 +00:00
import Toggle from "../fields/Toggle.vue";
import Select from "../fields/Select.vue";
2022-01-25 04:25:34 +00:00
import Tooltip from "./Tooltip.vue";
import { jsx } from "@/features/feature";
2021-05-22 20:29:06 +00:00
2022-01-14 04:25:47 +00:00
const isOpen = ref(false);
defineExpose({
open() {
isOpen.value = true;
}
});
const themes = Object.keys(rawThemes).map(theme => ({
label: camelToTitle(theme),
value: theme
}));
// TODO allow features to register options
const msDisplayOptions = Object.values(MilestoneDisplay).map(option => ({
label: camelToTitle(option),
value: option
}));
const { showTPS, hideChallenges, theme, msDisplay, unthrottled } = toRefs(settings);
2022-01-25 04:25:34 +00:00
const { autosave, offlineProd } = toRefs(player);
2022-01-14 04:25:47 +00:00
const isPaused = computed({
get() {
return player.devSpeed === 0;
},
2022-01-14 04:25:47 +00:00
set(value: boolean) {
player.devSpeed = value ? 0 : null;
}
});
2022-01-25 04:25:34 +00:00
const offlineProdTitle = jsx(() => (
<span>
2022-01-25 04:25:34 +00:00
Offline Production<Tooltip display="Save-specific">*</Tooltip>
</span>
));
const autosaveTitle = jsx(() => (
<span>
2022-01-25 04:25:34 +00:00
Autosave<Tooltip display="Save-specific">*</Tooltip>
</span>
));
const isPausedTitle = jsx(() => (
<span>
2022-01-25 04:25:34 +00:00
Pause game<Tooltip display="Save-specific">*</Tooltip>
</span>
));
2021-05-22 20:29:06 +00:00
</script>
<style scoped>
2021-06-21 04:29:55 +00:00
.header {
margin-bottom: -10px;
2021-05-22 20:29:06 +00:00
}
2021-09-06 00:03:50 +00:00
*:deep() .tooltip-container {
display: inline;
margin-left: 5px;
}
2021-05-22 20:29:06 +00:00
</style>