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