Map event tile improvements

This commit is contained in:
Dennis Postma 2025-01-05 06:22:28 +01:00
parent 0142850983
commit b54b825422
5 changed files with 14 additions and 13 deletions

View File

@ -115,7 +115,6 @@ export type MapEventTile = {
export type MapEventTileTeleport = { export type MapEventTileTeleport = {
id: UUID id: UUID
mapEventTile: MapEventTile mapEventTile: MapEventTile
toMapId: UUID
toMap: Map toMap: Map
toPositionX: number toPositionX: number
toPositionY: number toPositionY: number

View File

@ -58,6 +58,8 @@ function save() {
placedMapObjects: mapEditorStore.map.placedMapObjects?.map(({ id, mapObject, depth, isRotated, positionX, positionY }) => ({ id, mapObject, depth, isRotated, positionX, positionY })) ?? [] placedMapObjects: mapEditorStore.map.placedMapObjects?.map(({ id, mapObject, depth, isRotated, positionX, positionY }) => ({ id, mapObject, depth, isRotated, positionX, positionY })) ?? []
} }
console.log(data.mapEventTiles)
if (mapEditorStore.isSettingsModalShown) { if (mapEditorStore.isSettingsModalShown) {
mapEditorStore.toggleSettingsModal() mapEditorStore.toggleSettingsModal()
} }

View File

@ -51,7 +51,7 @@ function pencil(pointer: Phaser.Input.Pointer) {
if (existingEventTile) return if (existingEventTile) return
// If teleport, check if there is a selected map // If teleport, check if there is a selected map
if (mapEditorStore.drawMode === 'teleport' && !mapEditorStore.teleportSettings.toMapId) return if (mapEditorStore.drawMode === 'teleport' && !mapEditorStore.teleportSettings.toMap) return
const newEventTile = { const newEventTile = {
id: uuidv4(), id: uuidv4(),
@ -63,7 +63,7 @@ function pencil(pointer: Phaser.Input.Pointer) {
teleport: teleport:
mapEditorStore.drawMode === 'teleport' mapEditorStore.drawMode === 'teleport'
? { ? {
toMapId: mapEditorStore.teleportSettings.toMapId, toMap: mapEditorStore.teleportSettings.toMap,
toPositionX: mapEditorStore.teleportSettings.toPositionX, toPositionX: mapEditorStore.teleportSettings.toPositionX,
toPositionY: mapEditorStore.teleportSettings.toPositionY, toPositionY: mapEditorStore.teleportSettings.toPositionY,
toRotation: mapEditorStore.teleportSettings.toRotation toRotation: mapEditorStore.teleportSettings.toRotation

View File

@ -25,10 +25,10 @@
</select> </select>
</div> </div>
<div class="form-field-full"> <div class="form-field-full">
<label for="toMapId">Map to teleport to</label> <label for="toMap">Map to teleport to</label>
<select v-model="toMapId" class="input-field" name="toMapId" id="toMapId"> <select v-model="toMap" class="input-field" name="toMap" id="toMap">
<option :value="0">Select map</option> <option :value="null">Select map</option>
<option v-for="map in mapEditorStore.mapList" :key="map.id" :value="map.id">{{ map.name }}</option> <option v-for="map in mapEditorStore.mapList" :key="map.id" :value="map">{{ map.name }}</option>
</select> </select>
</div> </div>
</div> </div>
@ -57,7 +57,7 @@ function fetchMaps() {
}) })
} }
const { toPositionX, toPositionY, toRotation, toMapId } = useRefTeleportSettings() const { toPositionX, toPositionY, toRotation, toMap } = useRefTeleportSettings()
function useRefTeleportSettings() { function useRefTeleportSettings() {
const settings = mapEditorStore.teleportSettings const settings = mapEditorStore.teleportSettings
@ -65,18 +65,18 @@ function useRefTeleportSettings() {
toPositionX: ref(settings.toPositionX), toPositionX: ref(settings.toPositionX),
toPositionY: ref(settings.toPositionY), toPositionY: ref(settings.toPositionY),
toRotation: ref(settings.toRotation), toRotation: ref(settings.toRotation),
toMapId: ref(settings.toMapId) toMap: ref(settings.toMap)
} }
} }
watch([toPositionX, toPositionY, toRotation, toMapId], updateTeleportSettings) watch([toPositionX, toPositionY, toRotation, toMap], updateTeleportSettings)
function updateTeleportSettings() { function updateTeleportSettings() {
mapEditorStore.setTeleportSettings({ mapEditorStore.setTeleportSettings({
toPositionX: toPositionX.value, toPositionX: toPositionX.value,
toPositionY: toPositionY.value, toPositionY: toPositionY.value,
toRotation: toRotation.value, toRotation: toRotation.value,
toMapId: toMapId.value toMap: toMap.value
}) })
} }
</script> </script>

View File

@ -3,7 +3,7 @@ import { useGameStore } from '@/stores/gameStore'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
export type TeleportSettings = { export type TeleportSettings = {
toMapId: number toMap: Map | null
toPositionX: number toPositionX: number
toPositionY: number toPositionY: number
toRotation: number toRotation: number
@ -36,7 +36,7 @@ export const useMapEditorStore = defineStore('mapEditor', {
mapEffects: [] as MapEffect[] mapEffects: [] as MapEffect[]
}, },
teleportSettings: { teleportSettings: {
toMapId: 0, toMap: null,
toPositionX: 0, toPositionX: 0,
toPositionY: 0, toPositionY: 0,
toRotation: 0 toRotation: 0