TS improvements, WIP loading map objects in game map, WIP loading tile textures
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<MapTiles ref="mapTiles" v-if="tileMap" :tileMapLayer :tileMap @tileMap:create="tileMap = $event" />
|
||||
<PlacedMapObjects ref="mapObjects" v-if="tileMap" :tileMapLayer :tileMap />
|
||||
<MapTiles ref="mapTiles" v-if="tileMap" :tileMap :tileMapLayer />
|
||||
<PlacedMapObjects ref="mapObjects" v-if="tileMap" :tileMap :tileMapLayer />
|
||||
<MapEventTiles ref="eventTiles" v-if="tileMap" :tileMap />
|
||||
</template>
|
||||
|
||||
@ -78,7 +78,6 @@ onMounted(() => {
|
||||
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, mapValue)
|
||||
|
||||
addEventListener('keydown', handleKeyDown)
|
||||
|
@ -1,15 +1,13 @@
|
||||
<template>
|
||||
<Controls v-if="props.tileMapLayer" :layer="props.tileMapLayer" :depth="0" />
|
||||
<Controls v-if="tileMapLayer" :layer="tileMapLayer" :depth="0" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Controls from '@/components/utilities/Controls.vue'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { createTileArray, getTile, placeTile, setLayerTiles } from '@/services/mapService'
|
||||
import { useScene } from 'phavuer'
|
||||
import { createTileArray, getTile, placeTile, placeTiles } from '@/services/mapService'
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
|
||||
const emit = defineEmits(['tileMap:create'])
|
||||
const mapEditor = useMapEditorComposable()
|
||||
|
||||
defineExpose({ handlePointer, finalizeCommand, undo, redo })
|
||||
@ -80,7 +78,7 @@ function paint(pointer: Phaser.Input.Pointer) {
|
||||
|
||||
// Set new tileArray with selected tile
|
||||
const tileArray = createTileArray(props.tileMap.width, props.tileMap.height, mapEditor.selectedTile.value)
|
||||
setLayerTiles(props.tileMap, props.tileMapLayer, tileArray)
|
||||
placeTiles(props.tileMap, props.tileMapLayer, tileArray)
|
||||
|
||||
// Adjust mapEditorStore.map.tiles
|
||||
map.tiles = tileArray
|
||||
@ -182,7 +180,7 @@ function updateMapTiles() {
|
||||
let indexedCommands = commandStack.slice(0, commandIndex.value)
|
||||
let modifiedTiles = applyCommands(originTiles, ...indexedCommands)
|
||||
|
||||
setLayerTiles(props.tileMap, props.tileMapLayer, modifiedTiles)
|
||||
placeTiles(props.tileMap, props.tileMapLayer, modifiedTiles)
|
||||
mapEditor.currentMap.value.tiles = modifiedTiles
|
||||
}
|
||||
|
||||
@ -196,7 +194,7 @@ watch(
|
||||
(shouldClear) => {
|
||||
if (shouldClear && mapEditor.currentMap.value) {
|
||||
const blankTiles = createTileArray(props.tileMapLayer.width, props.tileMapLayer.height, 'blank_tile')
|
||||
setLayerTiles(props.tileMap, props.tileMapLayer, blankTiles)
|
||||
placeTiles(props.tileMap, props.tileMapLayer, blankTiles)
|
||||
mapEditor.currentMap.value.tiles = blankTiles
|
||||
mapEditor.resetClearTilesFlag()
|
||||
}
|
||||
@ -210,6 +208,6 @@ onMounted(async () => {
|
||||
//Clone
|
||||
originTiles = cloneArray(mapState.tiles)
|
||||
|
||||
setLayerTiles(props.tileMap, props.tileMapLayer, mapState.tiles)
|
||||
placeTiles(props.tileMap, props.tileMapLayer, mapState.tiles)
|
||||
})
|
||||
</script>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<SelectedPlacedMapObjectComponent v-if="mapEditor.selectedPlacedObject.value" :placedMapObject="mapEditor.selectedPlacedObject.value" @move="moveMapObject" @rotate="rotatePlacedMapObject" @delete="deletePlacedMapObject" />
|
||||
<PlacedMapObject :tileMapLayer :tileMap v-for="placedMapObject in mapEditor.currentMap.value?.placedMapObjects" :placedMapObject @pointerdown="clickPlacedMapObject(placedMapObject)" />
|
||||
<PlacedMapObject v-for="placedMapObject in mapEditor.currentMap.value?.placedMapObjects" :tileMap :tileMapLayer :placedMapObject @pointerdown="clickPlacedMapObject(placedMapObject)" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
Reference in New Issue
Block a user