1
0
forked from noxious/client

added paint feature

This commit is contained in:
Dennis Postma 2024-07-04 12:40:46 +02:00
parent 2fe6f8d9c0
commit 90121be472
4 changed files with 31 additions and 23 deletions

28
package-lock.json generated
View File

@ -2137,30 +2137,30 @@
}
},
"node_modules/@volar/language-core": {
"version": "2.4.0-alpha.13",
"resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.0-alpha.13.tgz",
"integrity": "sha512-tHeJVIRTJ3dlsdNyRjBlqdKHocWkgORM5eXgf6xcGERoXYe6vBpQpxJgpK1pehA8psXNPqkMN1ryBseA0B+m8A==",
"version": "2.4.0-alpha.14",
"resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.0-alpha.14.tgz",
"integrity": "sha512-R6eJcUKo/KftaWHwJrWjBgj/+vW9g4xTByVQEK3IHTciMKmomoSbxaNqolu1/sJKbH9Tdg0EAqTFqIzKU9iQHw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@volar/source-map": "2.4.0-alpha.13"
"@volar/source-map": "2.4.0-alpha.14"
}
},
"node_modules/@volar/source-map": {
"version": "2.4.0-alpha.13",
"resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.0-alpha.13.tgz",
"integrity": "sha512-NABqcuA9QpHsU3FnA5BENP3PI1FOb6hDxqkV1KAHP7gt4fgfQOqSCWpqj3QAS7RV0PtiKTxiDMIJ7doMBhNm7w==",
"version": "2.4.0-alpha.14",
"resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.0-alpha.14.tgz",
"integrity": "sha512-ACOsoDKvW29BIfdfnvQkm8S1m/RLARuHL9x7qS/9c6liMl1K0Y3RqXuC42HhWrWBm4hk0UyRKgdnv2R0teXPvg==",
"dev": true,
"license": "MIT"
},
"node_modules/@volar/typescript": {
"version": "2.4.0-alpha.13",
"resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.0-alpha.13.tgz",
"integrity": "sha512-zW/MOPA9SwkCuuVPqADDYfAEPAh68aJQG3/EAqDYozSuK2YNYHEAC0BWYZESSNZC6jxwwx7w0U82fBkDZ9hHEw==",
"version": "2.4.0-alpha.14",
"resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.0-alpha.14.tgz",
"integrity": "sha512-FQtQruOc7qQwcq5Q666pxF6ekRqZG5ILL3sS40Oac1V69QdAZ7q+IOQ2+z6SHJDENY49ygBv0hN9HrxRLtk15Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@volar/language-core": "2.4.0-alpha.13",
"@volar/language-core": "2.4.0-alpha.14",
"path-browserify": "^1.0.1",
"vscode-uri": "^3.0.8"
}
@ -5213,9 +5213,9 @@
}
},
"node_modules/npm-run-all2": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/npm-run-all2/-/npm-run-all2-6.2.1.tgz",
"integrity": "sha512-eX4MWsUYOSm1FhPh9LPAWbqq2quny3u8gEEWIY4HHECi10qOyi1dNaJFCyOOv2uP05ZuTPETwS2p1GZk9oLJsw==",
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/npm-run-all2/-/npm-run-all2-6.2.2.tgz",
"integrity": "sha512-Q+alQAGIW7ZhKcxLt8GcSi3h3ryheD6xnmXahkMRVM5LYmajcUrSITm8h+OPC9RYWMV2GR0Q1ntTUCfxaNoOJw==",
"dev": true,
"license": "MIT",
"dependencies": {

View File

@ -77,7 +77,7 @@ const props = defineProps({
layer: Phaser.Tilemaps.TilemapLayer
})
const scene = useScene()
const emit = defineEmits(['move', 'eraser', 'pencil', 'save'])
const emit = defineEmits(['move', 'eraser', 'pencil', 'paint', 'save'])
// track select state
let selectPencilOpen = ref(false)
@ -91,7 +91,7 @@ function setDrawMode(value: string) {
}
function drawTile(pointer: Phaser.Input.Pointer) {
if (zoneEditorStore.tool !== 'eraser' && zoneEditorStore.tool !== 'pencil') {
if (zoneEditorStore.tool !== 'eraser' && zoneEditorStore.tool !== 'pencil' && zoneEditorStore.tool !== 'paint') {
return
}
@ -110,6 +110,10 @@ function drawTile(pointer: Phaser.Input.Pointer) {
if (zoneEditorStore.tool === 'pencil') {
emit('pencil', pointer_tile)
}
if (zoneEditorStore.tool === 'paint') {
emit('paint', pointer_tile)
}
}
function drawTiles(pointer: Phaser.Input.Pointer) {
@ -126,7 +130,7 @@ onBeforeUnmount(() => {
})
function clear() {
zoneEditorStore.setTiles(Array.from({ length: zoneEditorStore.width ?? 10 }, () => Array.from({ length: zoneEditorStore.height ?? 10 }, () => 0)))
zoneEditorStore.setTiles(Array.from({ length: zoneEditorStore.width ?? 10 }, () => Array.from({ length: zoneEditorStore.height ?? 10 }, () => 'blank_tile')))
}
</script>

View File

@ -8,8 +8,8 @@
<Image v-for="object in zoneObjects" :key="object.id" :texture="object.object" :x="object.position_x" :y="object.position_y" />
</Container>
<Toolbar :layer="tiles" @eraser="eraser" @pencil="pencil" @save="save" />
<Tiles v-if="(zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser') && zoneEditorStore.drawMode === 'tile'" />
<Toolbar :layer="tiles" @eraser="eraser" @pencil="pencil" @paint="paint" @save="save" />
<Tiles v-if="((zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser') && zoneEditorStore.drawMode === 'tile') || zoneEditorStore.tool === 'paint'" />
<Objects v-if="(zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser') && zoneEditorStore.drawMode === 'object'" />
<ZoneSettings v-if="zoneEditorStore.isSettingsModalShown" />
</template>
@ -29,7 +29,6 @@ import ZoneSettings from '@/components/utilities/zoneEditor/ZoneSettings.vue'
import { placeTile, tileToWorldXY } from '@/services/zone'
import { useAssetStore } from '@/stores/assets'
import Objects from '@/components/utilities/zoneEditor/Objects.vue'
import { randomUUID } from 'crypto'
const scene = useScene()
const socket = useSocketStore()
@ -127,6 +126,11 @@ function pencil(tile: Phaser.Tilemaps.Tile) {
}
}
function paint(tile: Phaser.Tilemaps.Tile) {
if (!zoneEditorStore.selectedTile) return
exampleTilesArray.forEach((row, y) => row.forEach((tile, x) => placeTile(zone, tiles, x, y, zoneEditorStore.selectedTile)))
}
function save() {
socket.connection.emit('gm:zone_editor:zone:save', {
zoneId: socket.character.zoneId,

View File

@ -6,7 +6,7 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
name: '',
width: 10,
height: 10,
tiles: [] as number[][],
tiles: [] as string[][],
objects: [] as number[][],
tool: 'move',
drawMode: 'tile',
@ -27,10 +27,10 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
setHeight(height: number) {
this.height = height
},
setTiles(tiles: number[][]) {
setTiles(tiles: string[][]) {
this.tiles = tiles
},
updateTile(x: number, y: number, tile: number) {
updateTile(x: number, y: number, tile: string) {
this.tiles[y][x] = tile
},
setObjects(objects: number[][]) {