Profectus/src/components/Options.vue

89 lines
2.3 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" />
<component :is="settingFieldsComponent" />
2022-01-14 04:25:47 +00:00
<Toggle title="Show TPS" v-model="showTPS" />
<hr />
2022-01-14 04:25:47 +00:00
<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-03-04 03:39:48 +00:00
import Modal from "components/Modal.vue";
import rawThemes from "data/themes";
import player from "game/player";
import settings, { settingFields } from "game/settings";
import { camelToTitle } from "util/common";
import { computed, ref, toRefs } from "vue";
2022-02-27 22:04:56 +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";
2022-03-04 03:39:48 +00:00
import { jsx } from "features/feature";
import { coerceComponent, render } from "util/vue";
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
}));
const settingFieldsComponent = computed(() => {
return coerceComponent(jsx(() => <>{settingFields.map(render)}</>));
});
2022-01-14 04:25:47 +00:00
const { showTPS, theme, 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>