Restored tile editing and proper map clearing behavior
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<MapTiles ref="mapTiles" v-if="tileMap && tileMapLayer" :tileMapLayer :tileMap @tileMap:create="tileMap = $event" />
|
||||
<PlacedMapObjects ref="mapObjects" v-if="tileMap && tileMapLayer" :tileMapLayer :tileMap />
|
||||
<MapTiles ref="mapTiles" v-if="tileMap" :tileMapLayer :tileMap @tileMap:create="tileMap = $event" />
|
||||
<PlacedMapObjects ref="mapObjects" v-if="tileMap" :tileMapLayer :tileMap />
|
||||
<MapEventTiles ref="eventTiles" v-if="tileMap" :tileMap />
|
||||
</template>
|
||||
|
||||
@ -75,9 +75,11 @@ function handlePointerUp(pointer: Phaser.Input.Pointer) {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
tileMap.value = createTileMap(scene, mapEditor.currentMap.value!)
|
||||
let mapValue = mapEditor.currentMap.value
|
||||
if (!mapValue) return
|
||||
tileMap.value = createTileMap(scene, mapValue)
|
||||
mapTiles.value?.$emit('tileMap:create', tileMap.value)
|
||||
tileMapLayer.value = createTileLayer(tileMap.value, mapEditor.currentMap.value)
|
||||
tileMapLayer.value = createTileLayer(tileMap.value, mapValue)
|
||||
|
||||
addEventListener('keydown', handleKeyDown)
|
||||
scene.input.on(Phaser.Input.Events.POINTER_DOWN, handlePointerDown)
|
||||
|
@ -78,14 +78,15 @@ function eraser(pointer: Phaser.Input.Pointer) {
|
||||
}
|
||||
|
||||
function paint(pointer: Phaser.Input.Pointer) {
|
||||
let map = mapEditor.currentMap.value
|
||||
if (!map) return
|
||||
|
||||
// Set new tileArray with selected tile
|
||||
const tileArray = createTileArray(props.tileMap.width, props.tileMap.height, mapEditor.selectedTile.value)
|
||||
setLayerTiles(props.tileMap, props.tileMapLayer, tileArray)
|
||||
|
||||
// Adjust mapEditorStore.map.tiles
|
||||
if (mapEditor.currentMap.value) {
|
||||
mapEditor.currentMap.value.tiles = tileArray
|
||||
}
|
||||
map.tiles = tileArray
|
||||
}
|
||||
|
||||
// When alt is pressed, and the pointer is down, select the tile that the pointer is over
|
||||
@ -184,7 +185,6 @@ function updateMapTiles() {
|
||||
let indexedCommands = commandStack.slice(0, commandIndex.value)
|
||||
let modifiedTiles = applyCommands(originTiles, ...indexedCommands)
|
||||
|
||||
//replaceTiles(mapEditor.currentMap.value.tiles, layer, tileMap.value.width, tileMap.value.height)
|
||||
setLayerTiles(props.tileMap, props.tileMapLayer, modifiedTiles)
|
||||
mapEditor.currentMap.value.tiles = modifiedTiles
|
||||
}
|
||||
@ -195,12 +195,12 @@ function cloneArray(arr: any[]) : any[] {
|
||||
}
|
||||
|
||||
watch(
|
||||
() => mapEditor.shouldClearTiles,
|
||||
() => mapEditor.shouldClearTiles.value,
|
||||
(shouldClear) => {
|
||||
if (shouldClear && mapEditor.currentMap.value) {
|
||||
const blankTiles = createTileArray(props.tileMapLayer.width, props.tileMapLayer.height, 'blank_tile')
|
||||
setLayerTiles(props.tileMap, props.tileMapLayer, blankTiles)
|
||||
replaceTiles(mapEditor.currentMap.value.tiles, blankTiles, props.tileMapLayer.width, props.tileMapLayer.height)
|
||||
mapEditor.currentMap.value.tiles = blankTiles
|
||||
mapEditor.resetClearTilesFlag()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user