forked from noxious/client
tile editor wip
This commit is contained in:
parent
4bc076d55d
commit
b36c8117e7
@ -28,13 +28,13 @@
|
||||
</select>
|
||||
</button>
|
||||
<div class="divider"></div>
|
||||
<button @click="() => zoneEditorStore.toggleZoneSettings()">
|
||||
<button @click="() => zoneEditorStore.toggleSettingsModal()">
|
||||
<img src="/assets/icons/zoneEditor/gear.svg" alt="Zone settings" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button class="btn-cyan">Save</button>
|
||||
<button class="btn-cyan">Load</button>
|
||||
<button class="btn-cyan">Save</button>
|
||||
<button class="btn-cyan" @click="clear">Clear</button>
|
||||
<button class="btn-cyan" @click="() => zoneEditorStore.toggleActive()">Exit</button>
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<Toolbar :layer="layer" @eraser="eraser" @pencil="pencil" />
|
||||
<Tiles v-if="zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser'" />
|
||||
<Walls v-if="zoneEditorStore.tool === 'pencil' || zoneEditorStore.tool === 'eraser'" />
|
||||
<ZoneSettings v-if="zoneEditorStore.zoneSettingsOpen" />
|
||||
<ZoneSettings v-if="zoneEditorStore.isSettingsModalShown" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@ -21,6 +21,7 @@ import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
import ZoneSettings from '@/components/utilities/zoneEditor/ZoneSettings.vue'
|
||||
import Walls from '@/components/utilities/zoneEditor/Walls.vue'
|
||||
import { generateTilemap } from '@/services/zone'
|
||||
import type { Zone } from '@/types'
|
||||
|
||||
// Phavuer logic
|
||||
let scene = useScene()
|
||||
@ -54,10 +55,11 @@ watch(
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
socket.connection.on('gm:zone_editor:zone:load', (data) => {
|
||||
tileMap = generateTilemap(scene, data.zone.width, data.zone.height);
|
||||
zoneEditorStore.setZoneSettings(data.zone)
|
||||
zoneEditorStore.setTiles(data.zone.tiles)
|
||||
socket.connection.on('gm:zone_editor:zone:load', (data: Zone) => {
|
||||
tileMap = generateTilemap(scene, data.width, data.height);
|
||||
zoneEditorStore.setName(data.name)
|
||||
zoneEditorStore.setWidth(data.width)
|
||||
zoneEditorStore.setTiles(data.tiles)
|
||||
})
|
||||
|
||||
function eraser(tile: Phaser.Tilemaps.Tile) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Modal :isModalOpen="true" @modal:close="() => zoneEditorStore.toggleZoneSettings()">
|
||||
<Modal :isModalOpen="true" @modal:close="() => zoneEditorStore.toggleSettingsModal()">
|
||||
<template #modalHeader>
|
||||
<h3 class="modal-title">Zone settings</h3>
|
||||
</template>
|
||||
@ -9,15 +9,15 @@
|
||||
<div class="form-fields">
|
||||
<div>
|
||||
<label for="name">Name</label>
|
||||
<input name="name" id="name" />
|
||||
<input v-model="name" name="name" id="name" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">Width</label>
|
||||
<input name="name" id="name" />
|
||||
<input v-model="width" name="name" id="name" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">Height</label>
|
||||
<input name="name" id="name" />
|
||||
<input v-model="height" name="name" id="name" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">PVP enabled</label>
|
||||
@ -30,9 +30,26 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
|
||||
const zoneEditorStore = useZoneEditorStore()
|
||||
|
||||
const name = ref(zoneEditorStore.name)
|
||||
const width = ref(zoneEditorStore.width)
|
||||
const height = ref(zoneEditorStore.height)
|
||||
|
||||
|
||||
watch(name, (value) => {
|
||||
zoneEditorStore.setName(value)
|
||||
})
|
||||
|
||||
watch(width, (value) => {
|
||||
zoneEditorStore.setWidth(value)
|
||||
})
|
||||
|
||||
watch(height, (value) => {
|
||||
zoneEditorStore.setHeight(value)
|
||||
})
|
||||
</script>
|
@ -1,23 +1,32 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import config from '@/config'
|
||||
import {type Zone} from '@/types'
|
||||
|
||||
export const useZoneEditorStore = defineStore('zoneEditor', {
|
||||
state: () => ({
|
||||
active: false,
|
||||
name: '',
|
||||
width: 10,
|
||||
height: 10,
|
||||
tiles: [] as number[][],
|
||||
tool: 'move',
|
||||
drawMode: 'tile',
|
||||
selectedTile: null,
|
||||
selectedWall: null,
|
||||
selectedDecoration: null,
|
||||
zoneSettings: null as Zone | null,
|
||||
zoneSettingsOpen: false
|
||||
isSettingsModalShown: false
|
||||
}),
|
||||
actions: {
|
||||
toggleActive() {
|
||||
this.active = !this.active
|
||||
},
|
||||
setName(name: string) {
|
||||
this.name = name
|
||||
},
|
||||
setWidth(width: number) {
|
||||
this.width = width
|
||||
},
|
||||
setHeight(height: number) {
|
||||
this.height = height
|
||||
},
|
||||
setTiles(tiles: number[][]) {
|
||||
this.tiles = tiles
|
||||
},
|
||||
@ -36,21 +45,20 @@ export const useZoneEditorStore = defineStore('zoneEditor', {
|
||||
setSelectedDecoration(decoration: any) {
|
||||
this.selectedDecoration = decoration
|
||||
},
|
||||
setZoneSettings(zone: Zone) {
|
||||
this.zoneSettings = zone
|
||||
},
|
||||
toggleZoneSettings() {
|
||||
this.zoneSettingsOpen = !this.zoneSettingsOpen
|
||||
toggleSettingsModal() {
|
||||
this.isSettingsModalShown = !this.isSettingsModalShown
|
||||
},
|
||||
reset() {
|
||||
this.name = ''
|
||||
this.width = 10
|
||||
this.height = 10
|
||||
this.tiles = []
|
||||
this.tool = 'move'
|
||||
this.drawMode = 'tile'
|
||||
this.selectedTile = null
|
||||
this.selectedWall = null
|
||||
this.selectedDecoration = null
|
||||
this.zoneSettings = null
|
||||
this.zoneSettingsOpen = false
|
||||
this.isSettingsModalShown = false
|
||||
}
|
||||
}
|
||||
})
|
@ -33,7 +33,7 @@ export type Zone = {
|
||||
name: string
|
||||
width: number
|
||||
height: number
|
||||
tiles: Record<string, any>
|
||||
tiles: number[][]
|
||||
characters: Character[]
|
||||
chats: Chat[]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user