Profectus/src/components/system/Options.vue

67 lines
1.9 KiB
Vue
Raw Normal View History

2021-05-22 15:29:06 -05:00
<template>
<Modal :show="show" @close="$emit('closeDialog', 'Options')">
2021-07-24 17:08:52 -05:00
<template v-slot:header>
<div class="header">
<h2>Options</h2>
</div>
</template>
<template v-slot:body>
2021-06-11 23:38:16 -05:00
<Select title="Theme" :options="themes" :value="theme" @change="setTheme" default="classic" />
<Select title="Show Milestones" :options="msDisplayOptions" :value="msDisplay" @change="setMSDisplay" default="all" />
2021-05-22 15:29:06 -05:00
<Toggle title="Offline Production" :value="offlineProd" @change="toggleOption('offlineProd')" />
<Toggle title="Autosave" :value="autosave" @change="toggleOption('autosave')" />
<Toggle title="Pause game" :value="paused" @change="togglePaused" />
2021-05-22 15:29:06 -05:00
<Toggle title="Show TPS" :value="showTPS" @change="toggleOption('showTPS')" />
2021-06-11 23:38:16 -05:00
<Toggle title="Hide Maxed Challenges" :value="hideChallenges" @change="toggleOption('hideChallenges')" />
2021-07-24 17:08:52 -05:00
</template>
2021-05-22 15:29:06 -05:00
</Modal>
</template>
<script>
2021-05-25 20:57:02 -05:00
import themes from '../../data/themes';
import { camelToTitle } from '../../util/common';
2021-07-24 17:08:52 -05:00
import { mapState } from '../../util/vue';
import player from '../../game/player';
2021-05-22 15:29:06 -05:00
export default {
name: 'Options',
props: {
show: Boolean
},
2021-07-24 17:08:52 -05:00
emits: [ 'closeDialog' ],
2021-05-22 15:29:06 -05:00
data() {
return {
2021-06-11 23:38:16 -05:00
themes: Object.keys(themes).map(theme => ({ label: camelToTitle(theme), value: theme })),
msDisplayOptions: [ "all", "last", "configurable", "incomplete", "none" ]
.map(option => ({ label: camelToTitle(option), value: option }))
}
},
computed: {
2021-07-24 17:08:52 -05:00
...mapState([ "autosave", "offlineProd", "showTPS", "hideChallenges", "theme", "msDisplay" ]),
paused() {
return player.devSpeed === 0;
2021-05-22 15:29:06 -05:00
}
},
methods: {
toggleOption(option) {
2021-05-25 20:57:02 -05:00
player[option] = !player[option];
2021-05-22 15:29:06 -05:00
},
setTheme(theme) {
2021-05-25 20:57:02 -05:00
player.theme = theme;
2021-05-22 15:29:06 -05:00
},
2021-06-11 23:38:16 -05:00
setMSDisplay(msDisplay) {
player.msDisplay = msDisplay;
},
togglePaused() {
player.devSpeed = this.paused ? 1 : 0;
2021-05-22 15:29:06 -05:00
}
}
};
</script>
<style scoped>
2021-06-20 23:29:55 -05:00
.header {
margin-bottom: -10px;
2021-05-22 15:29:06 -05:00
}
</style>