Skip to content

Instantly share code, notes, and snippets.

@RSamaium
Last active September 23, 2022 16:11
Show Gist options
  • Save RSamaium/ba134d49341be183736722e8047043d4 to your computer and use it in GitHub Desktop.
Save RSamaium/ba134d49341be183736722e8047043d4 to your computer and use it in GitHub Desktop.
Menu in RPGJS
<template>
<div id="prompt">
<rpg-window position="middle">
<p>{{ text }}</p>
<input type="text" v-model="promptText">
<p class="small">(Enter to validate)</p>
</rpg-window>
</div>
</template>
<script lang="ts">
import { Control } from '@rpgjs/client'
export default {
props: ['text'],
name: 'prompt',
inject: ['rpgKeypress', 'rpgGuiClose'],
data() {
return {
promptText: ''
}
},
mounted() {
this.obsKeyPress = this.rpgKeypress.subscribe(({ control }) => {
if (control?.actionName == Control.Action) {
this.rpgGuiClose('prompt', {
promptText: this.promptText
})
}
})
},
unmounted() {
this.obsKeyPress.unsubscribe()
}
}
</script>
<style>
#prompt {
position: absolute;
z-index: 51;
width: 100%;
height: 100%;
}
#prompt input {
margin-top: 15px;
margin-left: 0;
height: 40px;
font-size: 20px;
}
#prompt > div {
height: 100%;
}
.window-content p.small {
font-size: 12px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment