diff --git a/src/components/gameMaster/mapEditor/partials/MapObjectList.vue b/src/components/gameMaster/mapEditor/partials/MapObjectList.vue index dd8790d..5f7db97 100644 --- a/src/components/gameMaster/mapEditor/partials/MapObjectList.vue +++ b/src/components/gameMaster/mapEditor/partials/MapObjectList.vue @@ -1,10 +1,20 @@ <template> <div class="absolute border-0 border-l-2 border-solid border-gray-500 w-1/4 min-w-80 flex flex-col top-0 right-0 z-10 h-dvh bg-gray-800" v-if="mapEditor.tool.value === 'pencil' && mapEditor.drawMode.value === 'map_object'"> <div class="flex flex-col gap-2.5 p-2.5"> - <div class="relative flex"> - <img src="/assets/icons/mapEditor/search.svg" class="w-4 h-4 py-0.5 absolute top-1/2 -translate-y-1/2 left-2.5" alt="Search icon" /> - <label class="mb-1.5 font-titles hidden" for="search">Search</label> - <input @mousedown.stop class="!pl-7 input-field w-full" type="text" name="search" placeholder="Search" v-model="searchQuery" /> + <div class="flex justify-between items-center"> + <div class="flex-grow"> + <div class="relative flex"> + <img src="/assets/icons/mapEditor/search.svg" class="w-4 h-4 py-0.5 absolute top-1/2 -translate-y-1/2 left-2.5" alt="Search icon" /> + <label class="mb-1.5 font-titles hidden" for="search">Search</label> + <input @mousedown.stop class="!pl-7 input-field w-full" type="text" name="search" placeholder="Search" v-model="searchQuery" /> + </div> + </div> + <img + src="/assets/icons/mapEditor/dropdown-chevron.svg" + class="w-12 h-12 ml-2 cursor-pointer hover:opacity-80 -rotate-90" + alt="Close" + @click="mapEditor.setTool('move')" + /> </div> <div class="flex"> <select class="input-field w-full" name="lists" v-model="mapEditor.drawMode.value" @change="(event: any) => mapEditor.setDrawMode(event.target.value)"> diff --git a/src/components/gameMaster/mapEditor/partials/TeleportModal.vue b/src/components/gameMaster/mapEditor/partials/TeleportModal.vue index 9cfd613..94a17d8 100644 --- a/src/components/gameMaster/mapEditor/partials/TeleportModal.vue +++ b/src/components/gameMaster/mapEditor/partials/TeleportModal.vue @@ -1,5 +1,5 @@ <template> - <Modal 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="() => mapEditorStore.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> @@ -39,31 +39,22 @@ </template> <script setup lang="ts"> -import { SocketEvent } from '@/application/enums' import type { Map } from '@/application/types' import Modal from '@/components/utilities/Modal.vue' -import { useGameStore } from '@/stores/gameStore' import { useMapEditorStore } from '@/stores/mapEditorStore' import { computed, onMounted, ref, useTemplateRef, watch } from 'vue' +import {MapStorage} from "@/storage/storages"; const showTeleportModal = computed(() => mapEditorStore.tool === 'pencil' && mapEditorStore.drawMode === 'teleport') +const mapStorage = new MapStorage() const mapEditorStore = useMapEditorStore() -const gameStore = useGameStore() -const mapList = ref<Map[]>([]) const modalRef = useTemplateRef('modalRef') +const mapList = ref<Map[]>([]) defineExpose({ open: () => modalRef.value?.open() }) -onMounted(fetchMaps) - -function fetchMaps() { - // gameStore.connection?.emit(SocketEvent.GM_MAP_LIST, {}, (response: Map[]) => { - // mapList.value = response - // }) -} - const { toPositionX, toPositionY, toRotation, toMap } = useRefTeleportSettings() function useRefTeleportSettings() { @@ -86,4 +77,12 @@ function updateTeleportSettings() { toMapId: toMap.value }) } + +async function fetchMaps() { + mapList.value = await mapStorage.getAll() +} + +onMounted(async () => { + await fetchMaps() +}) </script> diff --git a/src/components/gameMaster/mapEditor/partials/TileList.vue b/src/components/gameMaster/mapEditor/partials/TileList.vue index ba6467f..d7e7825 100644 --- a/src/components/gameMaster/mapEditor/partials/TileList.vue +++ b/src/components/gameMaster/mapEditor/partials/TileList.vue @@ -1,10 +1,20 @@ <template> <div class="absolute border-0 border-l-2 border-solid border-gray-500 w-1/4 min-w-80 flex flex-col top-0 right-0 z-10 h-dvh bg-gray-800" v-if="(mapEditor.tool.value === 'pencil' && mapEditor.drawMode.value === 'tile') || mapEditor.tool.value === 'paint'"> <div class="flex flex-col gap-2.5 p-2.5"> - <div class="relative flex"> - <img src="/assets/icons/mapEditor/search.svg" class="w-4 h-4 py-0.5 absolute top-1/2 -translate-y-1/2 left-2.5" alt="Search icon" /> - <label class="mb-1.5 font-titles hidden" for="search">Search</label> - <input @mousedown.stop class="!pl-7 input-field w-full" type="text" name="search" placeholder="Search" v-model="searchQuery" /> + <div class="flex justify-between items-center"> + <div class="flex-grow"> + <div class="relative flex"> + <img src="/assets/icons/mapEditor/search.svg" class="w-4 h-4 py-0.5 absolute top-1/2 -translate-y-1/2 left-2.5" alt="Search icon" /> + <label class="mb-1.5 font-titles hidden" for="search">Search</label> + <input @mousedown.stop class="!pl-7 input-field w-full" type="text" name="search" placeholder="Search" v-model="searchQuery" /> + </div> + </div> + <img + src="/assets/icons/mapEditor/dropdown-chevron.svg" + class="w-12 h-12 ml-2 cursor-pointer hover:opacity-80 -rotate-90" + alt="Close" + @click="mapEditor.setTool('move')" + /> </div> <div class="flex"> <select class="input-field w-full" name="lists" v-model="mapEditor.drawMode.value" @change="(event: any) => mapEditor.setDrawMode(event.target.value)"> diff --git a/src/composables/useMapEditorComposable.ts b/src/composables/useMapEditorComposable.ts index b4ecd93..216691a 100644 --- a/src/composables/useMapEditorComposable.ts +++ b/src/composables/useMapEditorComposable.ts @@ -1,5 +1,6 @@ import type { Map, MapObject, PlacedMapObject, UUID } from '@/application/types' import { ref } from 'vue' +import {useGameStore} from "@/stores/gameStore"; export type TeleportSettings = { toMapId: string @@ -46,6 +47,8 @@ export function useMapEditorComposable() { const toggleActive = () => { if (active.value) reset() active.value = !active.value + const gameStore = useGameStore() + gameStore.toggleGmPanel() } const togglePlacedMapObjectPreview = () => {