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