Teleport fix WIP
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Modal v-if="showTeleportModal" ref="modalRef" @modal:close="() => mapEditorStore.setTool('move')" :modal-width="300" :modal-height="350" :is-resizable="false" bg-style="none">
|
||||
<Modal v-if="showTeleportModal" ref="modalRef" @modal:close="() => mapEditor.setTool('move')" :modal-width="300" :modal-height="350" :is-resizable="false" bg-style="none">
|
||||
<template #modalHeader>
|
||||
<h3 class="m-0 font-medium shrink-0 text-white">Teleport settings</h3>
|
||||
</template>
|
||||
@ -26,9 +26,9 @@
|
||||
</div>
|
||||
<div class="form-field-full">
|
||||
<label for="toMap">Map to teleport to</label>
|
||||
<select v-model="toMap" class="input-field" name="toMap" id="toMap">
|
||||
<select v-model="toMapId" class="input-field" name="toMap" id="toMap">
|
||||
<option :value="null">Select map</option>
|
||||
<option v-for="map in mapList" :key="map.id" :value="map">{{ map.name }}</option>
|
||||
<option v-for="map in mapList" :key="map.id" :value="map.id">{{ map.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -41,9 +41,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { Map } from '@/application/types'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { MapStorage } from '@/storage/storages'
|
||||
import { computed, onMounted, ref, useTemplateRef, watch } from 'vue'
|
||||
import {MapStorage} from "@/storage/storages";
|
||||
import {useMapEditorComposable} from "@/composables/useMapEditorComposable";
|
||||
|
||||
const showTeleportModal = computed(() => mapEditor.tool.value === 'pencil' && mapEditor.drawMode.value === 'teleport')
|
||||
const mapStorage = new MapStorage()
|
||||
@ -55,7 +55,7 @@ defineExpose({
|
||||
open: () => modalRef.value?.open()
|
||||
})
|
||||
|
||||
const { toPositionX, toPositionY, toRotation, toMap } = useRefTeleportSettings()
|
||||
const { toPositionX, toPositionY, toRotation, toMapId } = useRefTeleportSettings()
|
||||
|
||||
function useRefTeleportSettings() {
|
||||
const settings = mapEditor.teleportSettings.value
|
||||
@ -63,18 +63,18 @@ function useRefTeleportSettings() {
|
||||
toPositionX: ref(settings.toPositionX),
|
||||
toPositionY: ref(settings.toPositionY),
|
||||
toRotation: ref(settings.toRotation),
|
||||
toMap: ref(settings.toMapId)
|
||||
toMapId: ref(settings.toMapId)
|
||||
}
|
||||
}
|
||||
|
||||
watch([toPositionX, toPositionY, toRotation, toMap], updateTeleportSettings)
|
||||
watch([toPositionX, toPositionY, toRotation, toMapId], updateTeleportSettings)
|
||||
|
||||
function updateTeleportSettings() {
|
||||
mapEditor.setTeleportSettings({
|
||||
toPositionX: toPositionX.value,
|
||||
toPositionY: toPositionY.value,
|
||||
toRotation: toRotation.value,
|
||||
toMapId: toMap.value
|
||||
toMapId: toMapId.value
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user