From 6bede8c44e92cc880759440aa3f8a4ee648cb7f6 Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 27 Jan 2025 14:33:29 -0600 Subject: [PATCH] Map editor ui fixes, switching back to game from map editor, draw/tap checkbox, and partial restoration of tile picker function --- src/App.vue | 2 +- src/components/gameMaster/mapEditor/Map.vue | 3 --- .../mapEditor/mapPartials/MapTiles.vue | 16 +++++++++++----- .../mapEditor/partials/MapObjectList.vue | 3 ++- .../mapEditor/partials/TileList.vue | 3 ++- .../gameMaster/mapEditor/partials/Toolbar.vue | 19 ++++++++++++++----- src/components/screens/MapEditor.vue | 10 +++++----- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/App.vue b/src/App.vue index b948b35..4fe99f7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,7 +2,7 @@ - + diff --git a/src/components/gameMaster/mapEditor/Map.vue b/src/components/gameMaster/mapEditor/Map.vue index df1ee55..f9a129a 100644 --- a/src/components/gameMaster/mapEditor/Map.vue +++ b/src/components/gameMaster/mapEditor/Map.vue @@ -30,9 +30,6 @@ function handlePointer(pointer: Phaser.Input.Pointer) { // Check if shift is not pressed, this means we are moving the camera if (pointer.event.shiftKey) return - // Check if alt is pressed - if (pointer.event.altKey) return - // Check if draw mode is tile switch (mapEditor.drawMode.value) { case 'tile': diff --git a/src/components/gameMaster/mapEditor/mapPartials/MapTiles.vue b/src/components/gameMaster/mapEditor/mapPartials/MapTiles.vue index 72b6214..8c0c593 100644 --- a/src/components/gameMaster/mapEditor/mapPartials/MapTiles.vue +++ b/src/components/gameMaster/mapEditor/mapPartials/MapTiles.vue @@ -111,10 +111,15 @@ function tilePicker(pointer: Phaser.Input.Pointer) { let map = mapEditor.currentMap.value if (!map) return + console.log("herer") + if (!tileMap.value || !tileLayer.value) return + // Check if there is a tile - const tile = getTile(tileLayer.value!, pointer.worldX, pointer.worldY) + const tile = getTile(tileLayer.value, pointer.worldX, pointer.worldY) if (!tile) return + console.log(tile.index) + // Select the tile mapEditor.setSelectedTile(map.tiles[tile.y][tile.x]) } @@ -145,7 +150,11 @@ function handlePointer(pointer: Phaser.Input.Pointer) { if (pointer.event.shiftKey) return // Check if alt is pressed - if (pointer.event.altKey) return + if (pointer.event.altKey) { + tilePicker(pointer); + return + } + // Check if draw mode is tile switch (mapEditor.tool.value) { case 'pencil': @@ -157,9 +166,6 @@ function handlePointer(pointer: Phaser.Input.Pointer) { case 'paint': paint(pointer) break - case 'tile picker': - tilePicker(pointer) - break } } diff --git a/src/components/gameMaster/mapEditor/partials/MapObjectList.vue b/src/components/gameMaster/mapEditor/partials/MapObjectList.vue index 3c2b8f5..c9a3ffc 100644 --- a/src/components/gameMaster/mapEditor/partials/MapObjectList.vue +++ b/src/components/gameMaster/mapEditor/partials/MapObjectList.vue @@ -58,7 +58,8 @@ const mapObjectList = ref([]) const modalRef = useTemplateRef('modalRef') defineExpose({ - open: () => modalRef.value?.open() + open: () => modalRef.value?.open(), + close: () => modalRef.value?.close() }) const uniqueTags = computed(() => { diff --git a/src/components/gameMaster/mapEditor/partials/TileList.vue b/src/components/gameMaster/mapEditor/partials/TileList.vue index 01e17bc..451ca08 100644 --- a/src/components/gameMaster/mapEditor/partials/TileList.vue +++ b/src/components/gameMaster/mapEditor/partials/TileList.vue @@ -99,7 +99,8 @@ const tiles = ref([]) const modalRef = useTemplateRef('modalRef') defineExpose({ - open: () => modalRef.value?.open() + open: () => modalRef.value?.open(), + close: () => modalRef.value?.close() }) const uniqueTags = computed(() => { diff --git a/src/components/gameMaster/mapEditor/partials/Toolbar.vue b/src/components/gameMaster/mapEditor/partials/Toolbar.vue index 116ee3c..22041ad 100644 --- a/src/components/gameMaster/mapEditor/partials/Toolbar.vue +++ b/src/components/gameMaster/mapEditor/partials/Toolbar.vue @@ -47,7 +47,7 @@ Tile
- + Map object
@@ -69,6 +69,11 @@
+ +
+ + +
@@ -89,7 +94,7 @@ import { useScene } from 'phavuer' const mapEditor = useMapEditorComposable() -const emit = defineEmits(['save', 'clear', 'open-maps', 'open-settings', 'close-editor', 'open-tile-list', 'open-map-object-list']) +const emit = defineEmits(['save', 'clear', 'open-maps', 'open-settings', 'close-editor', 'open-tile-list', 'open-map-object-list', 'close-lists']) // track when clicked outside of toolbar items const toolbar = ref(null) @@ -105,8 +110,12 @@ defineExpose({tileListShown, mapObjectListShown}) // drawMode function setDrawMode(value: string) { - if (value === 'tile') emit('open-tile-list') - if (value === 'map_object') emit('open-map-object-list') + + if (mapEditor.tool.value === 'paint' || mapEditor.tool.value === 'pencil') { + emit('close-lists') + if (value === 'tile') emit('open-tile-list') + if (value === 'map_object') emit('open-map-object-list') + } mapEditor.setDrawMode(value) selectPencilOpen.value = false @@ -136,7 +145,7 @@ function handleClick(tool: string) { } function cycleToolMode(tool: 'pencil' | 'eraser') { - const modes = ['tile', 'object', 'teleport', 'blocking tile'] + const modes = ['tile', 'map_object', 'teleport', 'blocking tile'] const currentIndex = modes.indexOf(mapEditor.drawMode.value) const nextIndex = (currentIndex + 1) % modes.length const nextMode = modes[nextIndex] diff --git a/src/components/screens/MapEditor.vue b/src/components/screens/MapEditor.vue index ce8199c..1db0101 100644 --- a/src/components/screens/MapEditor.vue +++ b/src/components/screens/MapEditor.vue @@ -5,11 +5,11 @@
Loading...
- - + +