2019-04-29 02:11:57 +02:00
|
|
|
<template>
|
|
|
|
<div>
|
2021-01-30 02:59:05 +01:00
|
|
|
<MkButton class="kudkigyw" @click="click()" :primary="block.primary">{{ hpml.interpolate(block.text) }}</MkButton>
|
2019-04-29 02:11:57 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-01-30 02:59:05 +01:00
|
|
|
import { defineComponent, PropType, unref } from 'vue';
|
2020-01-29 20:37:25 +01:00
|
|
|
import MkButton from '../ui/button.vue';
|
2020-10-17 13:12:00 +02:00
|
|
|
import * as os from '@/os';
|
2021-01-30 02:59:05 +01:00
|
|
|
import { ButtonBlock } from '@/scripts/hpml/block';
|
|
|
|
import { Hpml } from '@/scripts/hpml/evaluator';
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2020-01-29 20:37:25 +01:00
|
|
|
components: {
|
|
|
|
MkButton
|
|
|
|
},
|
2019-04-29 02:11:57 +02:00
|
|
|
props: {
|
2021-01-30 02:59:05 +01:00
|
|
|
block: {
|
|
|
|
type: Object as PropType<ButtonBlock>,
|
2019-04-29 02:11:57 +02:00
|
|
|
required: true
|
|
|
|
},
|
2020-04-20 14:35:27 +02:00
|
|
|
hpml: {
|
2021-01-30 02:59:05 +01:00
|
|
|
type: Object as PropType<Hpml>,
|
2019-04-29 02:11:57 +02:00
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
click() {
|
2021-01-30 02:59:05 +01:00
|
|
|
if (this.block.action === 'dialog') {
|
2020-04-20 14:35:27 +02:00
|
|
|
this.hpml.eval();
|
2020-10-17 13:12:00 +02:00
|
|
|
os.dialog({
|
2021-01-30 02:59:05 +01:00
|
|
|
text: this.hpml.interpolate(this.block.content)
|
2019-04-29 02:11:57 +02:00
|
|
|
});
|
2021-01-30 02:59:05 +01:00
|
|
|
} else if (this.block.action === 'resetRandom') {
|
2020-04-20 14:35:27 +02:00
|
|
|
this.hpml.updateRandomSeed(Math.random());
|
|
|
|
this.hpml.eval();
|
2021-01-30 02:59:05 +01:00
|
|
|
} else if (this.block.action === 'pushEvent') {
|
2020-10-17 13:12:00 +02:00
|
|
|
os.api('page-push', {
|
2020-04-20 14:35:27 +02:00
|
|
|
pageId: this.hpml.page.id,
|
2021-01-30 02:59:05 +01:00
|
|
|
event: this.block.event,
|
|
|
|
...(this.block.var ? {
|
|
|
|
var: unref(this.hpml.vars)[this.block.var]
|
2019-07-06 22:12:31 +02:00
|
|
|
} : {})
|
2019-07-06 11:14:50 +02:00
|
|
|
});
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
os.dialog({
|
2019-07-06 11:14:50 +02:00
|
|
|
type: 'success',
|
2021-01-30 02:59:05 +01:00
|
|
|
text: this.hpml.interpolate(this.block.message)
|
2019-07-06 11:14:50 +02:00
|
|
|
});
|
2021-01-30 02:59:05 +01:00
|
|
|
} else if (this.block.action === 'callAiScript') {
|
|
|
|
this.hpml.callAiScript(this.block.fn);
|
2019-04-29 02:11:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.kudkigyw {
|
|
|
|
display: inline-block;
|
|
|
|
min-width: 200px;
|
|
|
|
max-width: 450px;
|
|
|
|
margin: 8px 0;
|
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
</style>
|