forked from noxious/client
#236: Fixed clear button in map editor
This commit is contained in:
parent
a653b61b51
commit
bdc566e30f
@ -38,8 +38,10 @@ const tileMap = ref(null as Phaser.Tilemaps.Tilemap | null)
|
|||||||
function clear() {
|
function clear() {
|
||||||
if (!zoneEditorStore.zone) return
|
if (!zoneEditorStore.zone) return
|
||||||
|
|
||||||
|
// Clear objects, event tiles and tiles
|
||||||
zoneEditorStore.zone.zoneObjects = []
|
zoneEditorStore.zone.zoneObjects = []
|
||||||
zoneEditorStore.zone.zoneEventTiles = []
|
zoneEditorStore.zone.zoneEventTiles = []
|
||||||
|
zoneEditorStore.triggerClearTiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import { useScene } from 'phavuer'
|
import { useScene } from 'phavuer'
|
||||||
import { useZoneEditorStore } from '@/stores/zoneEditorStore'
|
import { useZoneEditorStore } from '@/stores/zoneEditorStore'
|
||||||
import { onMounted, onUnmounted } from 'vue'
|
import { onMounted, onUnmounted, watch } from 'vue'
|
||||||
import { createTileArray, getTile, placeTile, setLayerTiles } from '@/composables/zoneComposable'
|
import { createTileArray, getTile, placeTile, setLayerTiles } from '@/composables/zoneComposable'
|
||||||
import Controls from '@/components/utilities/Controls.vue'
|
import Controls from '@/components/utilities/Controls.vue'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
import { useGameStore } from '@/stores/gameStore'
|
||||||
@ -175,6 +175,18 @@ function tilePicker(pointer: Phaser.Input.Pointer) {
|
|||||||
zoneEditorStore.setSelectedTile(zoneEditorStore.zone.tiles[tile.y][tile.x])
|
zoneEditorStore.setSelectedTile(zoneEditorStore.zone.tiles[tile.y][tile.x])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => zoneEditorStore.shouldClearTiles,
|
||||||
|
(shouldClear) => {
|
||||||
|
if (shouldClear && zoneEditorStore.zone) {
|
||||||
|
const blankTiles = createTileArray(tileMap.width, tileMap.height, 'blank_tile')
|
||||||
|
setLayerTiles(tileMap, tileLayer, blankTiles)
|
||||||
|
zoneEditorStore.zone.tiles = blankTiles
|
||||||
|
zoneEditorStore.resetClearTilesFlag()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!zoneEditorStore.zone?.tiles) {
|
if (!zoneEditorStore.zone?.tiles) {
|
||||||
return
|
return
|
||||||
|
@ -12,7 +12,7 @@ export type TeleportSettings = {
|
|||||||
export const useZoneEditorStore = defineStore('zoneEditor', {
|
export const useZoneEditorStore = defineStore('zoneEditor', {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
active: false,
|
active: true,
|
||||||
zone: null as Zone | null,
|
zone: null as Zone | null,
|
||||||
tool: 'move',
|
tool: 'move',
|
||||||
drawMode: 'tile',
|
drawMode: 'tile',
|
||||||
@ -27,6 +27,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
isZoneListModalShown: false,
|
isZoneListModalShown: false,
|
||||||
isCreateZoneModalShown: false,
|
isCreateZoneModalShown: false,
|
||||||
isSettingsModalShown: false,
|
isSettingsModalShown: false,
|
||||||
|
shouldClearTiles: false,
|
||||||
zoneSettings: {
|
zoneSettings: {
|
||||||
name: '',
|
name: '',
|
||||||
width: 0,
|
width: 0,
|
||||||
@ -106,6 +107,13 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
setTeleportSettings(teleportSettings: TeleportSettings) {
|
setTeleportSettings(teleportSettings: TeleportSettings) {
|
||||||
this.teleportSettings = teleportSettings
|
this.teleportSettings = teleportSettings
|
||||||
},
|
},
|
||||||
|
triggerClearTiles() {
|
||||||
|
this.shouldClearTiles = true
|
||||||
|
},
|
||||||
|
|
||||||
|
resetClearTilesFlag() {
|
||||||
|
this.shouldClearTiles = false
|
||||||
|
},
|
||||||
reset(resetZone = false) {
|
reset(resetZone = false) {
|
||||||
if (resetZone) this.zone = null
|
if (resetZone) this.zone = null
|
||||||
this.zoneList = []
|
this.zoneList = []
|
||||||
@ -118,6 +126,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
this.isSettingsModalShown = false
|
this.isSettingsModalShown = false
|
||||||
this.isZoneListModalShown = false
|
this.isZoneListModalShown = false
|
||||||
this.isCreateZoneModalShown = false
|
this.isCreateZoneModalShown = false
|
||||||
|
this.shouldClearTiles = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user