From bfb2bcb93908d846450e675f966f2a362dfad2fc Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Sun, 16 Feb 2025 21:18:06 +0100 Subject: [PATCH] Map editor teleport enhancements --- .../gameMaster/mapEditor/mapPartials/MapEventTiles.vue | 7 ++----- .../mapEditor/mapPartials/PlacedMapObjects.vue | 2 +- .../gameMaster/mapEditor/partials/TeleportModal.vue | 10 +++++----- src/components/screens/MapEditor.vue | 1 - src/composables/useMapEditorComposable.ts | 4 ++-- src/stores/mapEditorStore.ts | 4 ++-- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue b/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue index cada9d0..e4bc7d8 100644 --- a/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue +++ b/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue @@ -88,20 +88,17 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) { if (existingEventTile) return // If teleport, check if there is a selected map - if (mapEditor.drawMode.value === 'teleport' && !mapEditor.teleportSettings.value.toMapId) return - - console.log(mapEditor.teleportSettings.value.toMapId) + if (mapEditor.drawMode.value === 'teleport' && !mapEditor.teleportSettings.value.toMap) return const newEventTile = { id: uuidv4() as UUID, - map: map.id, type: mapEditor.drawMode.value === 'blocking tile' ? MapEventTileType.BLOCK : MapEventTileType.TELEPORT, positionX: tile.x, positionY: tile.y, teleport: mapEditor.drawMode.value === 'teleport' ? { - toMapId: mapEditor.teleportSettings.value.toMapId, + toMap: mapEditor.teleportSettings.value.toMap, toPositionX: mapEditor.teleportSettings.value.toPositionX, toPositionY: mapEditor.teleportSettings.value.toPositionY, toRotation: mapEditor.teleportSettings.value.toRotation diff --git a/src/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue b/src/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue index 70919d5..2ba4122 100644 --- a/src/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue +++ b/src/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue @@ -129,7 +129,7 @@ function moveMapObject(id: string, map: MapT) { const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY) if (!tile) return - console.log(id) + map.placedMapObjects.map((placed) => { if (placed.id === id) { placed.positionX = tile.x diff --git a/src/components/gameMaster/mapEditor/partials/TeleportModal.vue b/src/components/gameMaster/mapEditor/partials/TeleportModal.vue index cb04533..2bd7a35 100644 --- a/src/components/gameMaster/mapEditor/partials/TeleportModal.vue +++ b/src/components/gameMaster/mapEditor/partials/TeleportModal.vue @@ -26,7 +26,7 @@
- @@ -55,7 +55,7 @@ defineExpose({ open: () => modalRef.value?.open() }) -const { toPositionX, toPositionY, toRotation, toMapId } = useRefTeleportSettings() +const { toPositionX, toPositionY, toRotation, toMap } = 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), - toMapId: ref(settings.toMapId) + toMap: ref(settings.toMap) } } -watch([toPositionX, toPositionY, toRotation, toMapId], updateTeleportSettings) +watch([toPositionX, toPositionY, toRotation, toMap], updateTeleportSettings) function updateTeleportSettings() { mapEditor.setTeleportSettings({ toPositionX: toPositionX.value, toPositionY: toPositionY.value, toRotation: toRotation.value, - toMapId: toMapId.value + toMap: toMap.value }) } diff --git a/src/components/screens/MapEditor.vue b/src/components/screens/MapEditor.vue index e4ddd23..5a5219d 100644 --- a/src/components/screens/MapEditor.vue +++ b/src/components/screens/MapEditor.vue @@ -91,7 +91,6 @@ function save() { ...currentMap, mapId: currentMap.id } - console.log(data) gameStore.connection?.emit(SocketEvent.GM_MAP_UPDATE, data, (response: MapT) => { mapStorage.update(response.id, response) diff --git a/src/composables/useMapEditorComposable.ts b/src/composables/useMapEditorComposable.ts index 087bd34..e7c1151 100644 --- a/src/composables/useMapEditorComposable.ts +++ b/src/composables/useMapEditorComposable.ts @@ -3,7 +3,7 @@ import { useGameStore } from '@/stores/gameStore' import { ref } from 'vue' export type TeleportSettings = { - toMapId: string + toMap: string toPositionX: number toPositionY: number toRotation: number @@ -21,7 +21,7 @@ const movingPlacedObject = ref(null) const selectedPlacedObject = ref(null) const shouldClearTiles = ref(false) const teleportSettings = ref({ - toMapId: '1000', + toMap: '1000', toPositionX: 0, toPositionY: 0, toRotation: 0 diff --git a/src/stores/mapEditorStore.ts b/src/stores/mapEditorStore.ts index 63867bf..e417294 100644 --- a/src/stores/mapEditorStore.ts +++ b/src/stores/mapEditorStore.ts @@ -2,7 +2,7 @@ import type { MapObject, Map as MapT } from '@/application/types' import { defineStore } from 'pinia' export type TeleportSettings = { - toMapId: string + toMap: string toPositionX: number toPositionY: number toRotation: number @@ -18,7 +18,7 @@ export const useMapEditorStore = defineStore('mapEditor', { selectedMapObject: null as MapObject | null, shouldClearTiles: false, teleportSettings: { - toMapId: '', + toMap: '', toPositionX: 0, toPositionY: 0, toRotation: 0