summaryrefslogtreecommitdiff
path: root/src/client/app/common/views/components/page/page.button.vue
blob: 87112aca0d33dadffa7156a6adbbfa02bde8d539 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<template>
<div>
	<ui-button class="kudkigyw" @click="click()" :primary="value.primary">{{ script.interpolate(value.text) }}</ui-button>
</div>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
	props: {
		value: {
			required: true
		},
		script: {
			required: true
		}
	},

	methods: {
		click() {
			if (this.value.action === 'dialog') {
				this.script.eval();
				this.$root.dialog({
					text: this.script.interpolate(this.value.content)
				});
			} else if (this.value.action === 'resetRandom') {
				this.script.aiScript.updateRandomSeed(Math.random());
				this.script.eval();
			} else if (this.value.action === 'pushEvent') {
				this.$root.api('page-push', {
					pageId: this.script.page.id,
					event: this.value.event,
					...(this.value.var ? {
						var: this.script.vars[this.value.var]
					} : {})
				});

				this.$root.dialog({
					type: 'success',
					text: this.script.interpolate(this.value.message)
				});
			}
		}
	}
});
</script>

<style lang="stylus" scoped>
.kudkigyw
	display inline-block
	min-width 200px
	max-width 450px
	margin 8px 0
</style>