2019-04-29 02:11:57 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div>
|
|
|
|
<MkButton class="kudkigyw" :primary="block.primary" @click="click()">{{
|
|
|
|
hpml.interpolate(block.text)
|
|
|
|
}}</MkButton>
|
|
|
|
</div>
|
2019-04-29 02:11:57 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-04-08 02:01:42 +02:00
|
|
|
import { defineComponent, PropType, unref } from "vue";
|
|
|
|
import MkButton from "../MkButton.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
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: {
|
2023-04-08 02:01:42 +02:00
|
|
|
MkButton,
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
2019-04-29 02:11:57 +02:00
|
|
|
props: {
|
2021-01-30 02:59:05 +01:00
|
|
|
block: {
|
|
|
|
type: Object as PropType<ButtonBlock>,
|
2023-04-08 02:01:42 +02:00
|
|
|
required: true,
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
2020-04-20 14:35:27 +02:00
|
|
|
hpml: {
|
2021-01-30 02:59:05 +01:00
|
|
|
type: Object as PropType<Hpml>,
|
2023-04-08 02:01:42 +02:00
|
|
|
required: true,
|
|
|
|
},
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
click() {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (this.block.action === "dialog") {
|
2020-04-20 14:35:27 +02:00
|
|
|
this.hpml.eval();
|
2021-11-18 10:45:58 +01:00
|
|
|
os.alert({
|
2023-04-08 02:01:42 +02:00
|
|
|
text: this.hpml.interpolate(this.block.content),
|
2019-04-29 02:11:57 +02:00
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
} else if (this.block.action === "resetRandom") {
|
2020-04-20 14:35:27 +02:00
|
|
|
this.hpml.updateRandomSeed(Math.random());
|
|
|
|
this.hpml.eval();
|
2023-04-08 02:01:42 +02:00
|
|
|
} else if (this.block.action === "pushEvent") {
|
|
|
|
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,
|
2023-04-08 02:01:42 +02:00
|
|
|
...(this.block.var
|
|
|
|
? {
|
|
|
|
var: unref(this.hpml.vars)[this.block.var],
|
|
|
|
}
|
|
|
|
: {}),
|
2019-07-06 11:14:50 +02:00
|
|
|
});
|
|
|
|
|
2021-11-18 10:45:58 +01:00
|
|
|
os.alert({
|
2023-04-08 02:01:42 +02:00
|
|
|
type: "success",
|
|
|
|
text: this.hpml.interpolate(this.block.message),
|
2019-07-06 11:14:50 +02:00
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
} else if (this.block.action === "callAiScript") {
|
2021-01-30 02:59:05 +01:00
|
|
|
this.hpml.callAiScript(this.block.fn);
|
2019-04-29 02:11:57 +02:00
|
|
|
}
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
},
|
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>
|