Added logics for saving zone updates
This commit is contained in:
parent
b36c8117e7
commit
ad94928370
@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button class="btn-cyan">Load</button>
|
<button class="btn-cyan">Load</button>
|
||||||
<button class="btn-cyan">Save</button>
|
<button class="btn-cyan" @click="() => emit('save')">Save</button>
|
||||||
<button class="btn-cyan" @click="clear">Clear</button>
|
<button class="btn-cyan" @click="clear">Clear</button>
|
||||||
<button class="btn-cyan" @click="() => zoneEditorStore.toggleActive()">Exit</button>
|
<button class="btn-cyan" @click="() => zoneEditorStore.toggleActive()">Exit</button>
|
||||||
</div>
|
</div>
|
||||||
@ -56,7 +56,7 @@ const props = defineProps({
|
|||||||
layer: Phaser.Tilemaps.TilemapLayer
|
layer: Phaser.Tilemaps.TilemapLayer
|
||||||
})
|
})
|
||||||
const scene = useScene()
|
const scene = useScene()
|
||||||
const emit = defineEmits(['move', 'eraser', 'pencil'])
|
const emit = defineEmits(['move', 'eraser', 'pencil', 'save'])
|
||||||
|
|
||||||
// drawMode
|
// drawMode
|
||||||
const drawMode = ref('tile')
|
const drawMode = ref('tile')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<TilemapLayerC :tilemap="tileMap" :tileset="zoneEditorStore.tiles" :layerIndex="0" :cull-padding-x="10" :cull-padding-y="10" />
|
<TilemapLayerC :tilemap="tileMap" :tileset="zoneEditorStore.tiles" :layerIndex="0" :cull-padding-x="10" :cull-padding-y="10" />
|
||||||
<Controls :layer="layer" />
|
<Controls :layer="layer" />
|
||||||
<Toolbar :layer="layer" @eraser="eraser" @pencil="pencil" />
|
<Toolbar :layer="layer" @eraser="eraser" @pencil="pencil" @save="save" />
|
||||||
<Tiles v-if="zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser'" />
|
<Tiles v-if="zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser'" />
|
||||||
<Walls v-if="zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser'" />
|
<Walls v-if="zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser'" />
|
||||||
<ZoneSettings v-if="zoneEditorStore.isSettingsModalShown" />
|
<ZoneSettings v-if="zoneEditorStore.isSettingsModalShown" />
|
||||||
@ -69,6 +69,17 @@ function eraser(tile: Phaser.Tilemaps.Tile) {
|
|||||||
function pencil(tile: Phaser.Tilemaps.Tile) {
|
function pencil(tile: Phaser.Tilemaps.Tile) {
|
||||||
if (zoneEditorStore.selectedTile === null) return
|
if (zoneEditorStore.selectedTile === null) return
|
||||||
layer.putTileAt(zoneEditorStore.selectedTile, tile.x, tile.y)
|
layer.putTileAt(zoneEditorStore.selectedTile, tile.x, tile.y)
|
||||||
|
zoneEditorStore.updateTile(tile.x, tile.y, zoneEditorStore.selectedTile);
|
||||||
|
}
|
||||||
|
|
||||||
|
function save() {
|
||||||
|
socket.connection.emit('gm:zone_editor:zone:save', {
|
||||||
|
zoneId: socket.character.zoneId,
|
||||||
|
name: zoneEditorStore.name,
|
||||||
|
width: zoneEditorStore.width,
|
||||||
|
height: zoneEditorStore.height,
|
||||||
|
tiles: zoneEditorStore.tiles,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
@ -40,7 +40,6 @@ const name = ref(zoneEditorStore.name)
|
|||||||
const width = ref(zoneEditorStore.width)
|
const width = ref(zoneEditorStore.width)
|
||||||
const height = ref(zoneEditorStore.height)
|
const height = ref(zoneEditorStore.height)
|
||||||
|
|
||||||
|
|
||||||
watch(name, (value) => {
|
watch(name, (value) => {
|
||||||
zoneEditorStore.setName(value)
|
zoneEditorStore.setName(value)
|
||||||
})
|
})
|
||||||
|
@ -30,6 +30,9 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
|||||||
setTiles(tiles: number[][]) {
|
setTiles(tiles: number[][]) {
|
||||||
this.tiles = tiles
|
this.tiles = tiles
|
||||||
},
|
},
|
||||||
|
updateTile(x: number, y: number, tile: number) {
|
||||||
|
this.tiles[y][x] = tile
|
||||||
|
},
|
||||||
setTool(tool: string) {
|
setTool(tool: string) {
|
||||||
this.tool = tool
|
this.tool = tool
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user