From 77cbbea9678de1b97a43d8ca1d0f534113473964 Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Tue, 16 Jul 2024 01:19:27 +0200 Subject: [PATCH] Added quick editor logics for zoneObjects --- .../zoneEditor/SelectedZoneObject.vue | 67 +++++++++++++++++++ .../utilities/zoneEditor/ZoneEditor.vue | 17 +++++ src/config.ts | 2 +- src/stores/zoneEditor.ts | 7 +- 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 src/components/utilities/zoneEditor/SelectedZoneObject.vue diff --git a/src/components/utilities/zoneEditor/SelectedZoneObject.vue b/src/components/utilities/zoneEditor/SelectedZoneObject.vue new file mode 100644 index 0000000..160206c --- /dev/null +++ b/src/components/utilities/zoneEditor/SelectedZoneObject.vue @@ -0,0 +1,67 @@ + + + \ No newline at end of file diff --git a/src/components/utilities/zoneEditor/ZoneEditor.vue b/src/components/utilities/zoneEditor/ZoneEditor.vue index c68031a..74e21c1 100644 --- a/src/components/utilities/zoneEditor/ZoneEditor.vue +++ b/src/components/utilities/zoneEditor/ZoneEditor.vue @@ -4,6 +4,7 @@ @@ -20,6 +22,7 @@ + @@ -34,6 +37,7 @@ import Controls from '@/components/utilities/Controls.vue' import { useGameStore } from '@/stores/game' import Toolbar from '@/components/utilities/zoneEditor/Toolbar.vue' import Tiles from '@/components/utilities/zoneEditor/Tiles.vue' +import SelectedZoneObject from '@/components/utilities/zoneEditor/SelectedZoneObject.vue' import { useZoneEditorStore } from '@/stores/zoneEditor' import ZoneSettings from '@/components/utilities/zoneEditor/ZoneSettings.vue' import { placeTile, setAllTiles, tileToWorldX, tileToWorldY } from '@/services/zone' @@ -217,6 +221,19 @@ function clear() { zoneObjects.value = [] } +function updateZoneObjectDepth(depth: number) { + zoneObjects.value = zoneObjects.value.map((object) => { + if (object.id === zoneEditorStore.selectedZoneObject?.id) { + return { ...object, depth } + } + return object + }) +} + +function deleteZoneObject(objectId: string) { + zoneObjects.value = zoneObjects.value.filter((object) => object.id !== objectId) +} + onBeforeMount(() => { exampleTilesArray.forEach((row, y) => row.forEach((tile, x) => placeTile(zoneTilemap, tiles, x, y, 'blank_tile'))) zoneTiles = exampleTilesArray diff --git a/src/config.ts b/src/config.ts index 4a929c1..763f5d6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,4 @@ -const dev: boolean = false +const dev: boolean = true export default { name: 'New Quest', diff --git a/src/stores/zoneEditor.ts b/src/stores/zoneEditor.ts index c9a9eb4..8938740 100644 --- a/src/stores/zoneEditor.ts +++ b/src/stores/zoneEditor.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia' -import type { Zone, Object, Tile } from '@/types' +import type { Zone, Object, Tile, ZoneObject } from '@/types' export const useZoneEditorStore = defineStore('zoneEditor', { state: () => ({ @@ -12,6 +12,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', { objectList: [] as Object[], selectedTile: null as Tile | null, selectedObject: null as Object | null, + selectedZoneObject: null as ZoneObject | null, objectDepth: 0, isZoneListModalShown: false, isCreateZoneModalShown: false, @@ -60,6 +61,9 @@ export const useZoneEditorStore = defineStore('zoneEditor', { setSelectedObject(object: any) { this.selectedObject = object }, + setSelectedZoneObject(zoneObject: ZoneObject) { + this.selectedZoneObject = zoneObject + }, setObjectDepth(depth: number) { this.objectDepth = depth }, @@ -81,6 +85,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', { this.drawMode = 'tile' this.selectedTile = null this.selectedObject = null + this.selectedZoneObject = null this.objectDepth = 0 this.isSettingsModalShown = false this.isZoneListModalShown = false