Profectus/src/components/system/Options.vue

119 lines
3.5 KiB
Vue
Raw Normal View History

2021-05-22 20:29:06 +00:00
<template>
<Modal :show="show" @close="$emit('closeDialog', 'Options')">
<template v-slot:header>
<div class="header">
<h2>Options</h2>
</div>
</template>
<template v-slot:body>
<Select
title="Theme"
:options="themes"
:value="theme"
@change="setTheme"
default="classic"
/>
<Select
title="Show Milestones"
:options="msDisplayOptions"
:value="msDisplay"
@change="setMSDisplay"
default="all"
/>
<Toggle title="Show TPS" :value="showTPS" @change="toggleSettingsOption('showTPS')" />
<Toggle
title="Hide Maxed Challenges"
:value="hideChallenges"
@change="toggleSettingsOption('hideChallenges')"
/>
2021-09-06 00:13:56 +00:00
<Toggle
title="Unthrottled"
:value="unthrottled"
@change="toggleSettingsOption('unthrottled')"
/>
<Toggle
title="Offline Production<tooltip display='Save-specific'>*</tooltip>"
:value="offlineProd"
@change="togglePlayerOption('offlineProd')"
/>
<Toggle
title="Autosave<tooltip display='Save-specific'>*</tooltip>"
:value="autosave"
@change="togglePlayerOption('autosave')"
/>
<Toggle
title="Pause game<tooltip display='Save-specific'>*</tooltip>"
:value="paused"
@change="togglePaused"
/>
</template>
</Modal>
2021-05-22 20:29:06 +00:00
</template>
<script lang="ts">
import { defineComponent } from "vue";
import themes, { Themes } from "@/data/themes";
import { camelToTitle } from "@/util/common";
import { mapPlayer, mapSettings } from "@/util/vue";
import player from "@/game/player";
import { MilestoneDisplay } from "@/game/enums";
import { PlayerData } from "@/typings/player";
import settings from "@/game/settings";
import { Settings } from "@/typings/settings";
2021-05-22 20:29:06 +00:00
export default defineComponent({
name: "Options",
props: {
show: Boolean
},
emits: ["closeDialog"],
data() {
return {
themes: Object.keys(themes).map(theme => ({
label: camelToTitle(theme),
value: theme
})),
msDisplayOptions: Object.values(MilestoneDisplay).map(option => ({
label: camelToTitle(option),
value: option
}))
};
},
computed: {
2021-09-06 00:13:56 +00:00
...mapSettings(["showTPS", "hideChallenges", "theme", "msDisplay", "unthrottled"]),
...mapPlayer(["autosave", "offlineProd"]),
paused() {
return player.devSpeed === 0;
}
},
methods: {
togglePlayerOption(option: keyof PlayerData) {
player[option] = !player[option];
},
toggleSettingsOption(option: keyof Settings) {
settings[option] = !settings[option];
},
setTheme(theme: Themes) {
settings.theme = theme;
},
setMSDisplay(msDisplay: MilestoneDisplay) {
settings.msDisplay = msDisplay;
},
togglePaused() {
player.devSpeed = this.paused ? 1 : 0;
}
}
});
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>