1
0
forked from noxious/client

Disabled vue dev tools, replaced ref with shallowRef, better naming

This commit is contained in:
2025-01-05 21:00:16 +01:00
parent b54b825422
commit c1d9cc3a11
6 changed files with 107 additions and 107 deletions

View File

@ -13,13 +13,13 @@ import { loadMapTilesIntoScene } from '@/composables/mapComposable'
import { useGameStore } from '@/stores/gameStore'
import { useMapStore } from '@/stores/mapStore'
import { useScene } from 'phavuer'
import { onUnmounted, ref } from 'vue'
import { onUnmounted, ref, shallowRef } from 'vue'
const scene = useScene()
const gameStore = useGameStore()
const mapStore = useMapStore()
const tileMap = ref(null as Phaser.Tilemaps.Tilemap | null)
const tileMap = shallowRef<Phaser.Tilemaps.Tilemap>()
onUnmounted(() => {
mapStore.reset()

View File

@ -27,12 +27,12 @@ import TileList from '@/components/gameMaster/mapEditor/partials/TileList.vue'
import Toolbar from '@/components/gameMaster/mapEditor/partials/Toolbar.vue'
import { useGameStore } from '@/stores/gameStore'
import { useMapEditorStore } from '@/stores/mapEditorStore'
import { onUnmounted, ref } from 'vue'
import { onUnmounted, ref, shallowRef } from 'vue'
const gameStore = useGameStore()
const mapEditorStore = useMapEditorStore()
const tileMap = ref(null as Phaser.Tilemaps.Tilemap | null)
const tileMap = shallowRef<Phaser.Tilemaps.Tilemap>()
function clear() {
if (!mapEditorStore.map) return

View File

@ -1,5 +1,5 @@
<template>
<SelectedPlacedMapObjectComponent v-if="selectedPlacedMapObject" :placedMapObject="selectedPlacedMapObject" @move="moveMapObject" @rotate="rotateMapObject" @delete="deleteMapObject" />
<SelectedPlacedMapObjectComponent v-if="selectedPlacedMapObject" :placedMapObject="selectedPlacedMapObject" @move="moveMapObject" @rotate="rotatePlacedMapObject" @delete="deletePlacedMapObject" />
<PlacedMapObject v-for="placedMapObject in mapEditorStore.map?.placedMapObjects" :tilemap="tilemap" :placedMapObject :selectedPlacedMapObject :movingPlacedMapObject @pointerup="clickPlacedMapObject(placedMapObject)" />
</template>
@ -49,10 +49,10 @@ function pencil(pointer: Phaser.Input.Pointer) {
if (!tile) return
// Check if object already exists on position
const existingObject = mapEditorStore.map.placedMapObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y)
if (existingObject) return
const existingPlacedMapObject = mapEditorStore.map.placedMapObjects.find((placedMapObject) => placedMapObject.positionX === tile.x && placedMapObject.positionY === tile.y)
if (existingPlacedMapObject) return
const newObject = {
const newPlacedMapObject = {
id: uuidv4(),
map: mapEditorStore.map,
mapObject: mapEditorStore.selectedMapObject,
@ -63,7 +63,7 @@ function pencil(pointer: Phaser.Input.Pointer) {
}
// Add new object to mapObjects
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.concat(newObject as PlacedMapObjectT)
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.concat(newPlacedMapObject as PlacedMapObjectT)
}
function eraser(pointer: Phaser.Input.Pointer) {
@ -90,11 +90,11 @@ function eraser(pointer: Phaser.Input.Pointer) {
if (!tile) return
// Check if object already exists on position
const existingObject = mapEditorStore.map.placedMapObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y)
if (!existingObject) return
const existingPlacedMapObject = mapEditorStore.map.placedMapObjects.find((placedMapObject) => placedMapObject.positionX === tile.x && placedMapObject.positionY === tile.y)
if (!existingPlacedMapObject) return
// Remove existing object
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.filter((object) => object.id !== existingObject.id)
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.filter((placedMapObject) => placedMapObject.id !== existingPlacedMapObject.id)
}
function objectPicker(pointer: Phaser.Input.Pointer) {
@ -121,11 +121,11 @@ function objectPicker(pointer: Phaser.Input.Pointer) {
if (!tile) return
// Check if object already exists on position
const existingMapObject = mapEditorStore.map.placedMapObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y)
if (!existingMapObject) return
const existingPlacedMapObject = mapEditorStore.map.placedMapObjects.find((placedMapObject) => placedMapObject.positionX === tile.x && placedMapObject.positionY === tile.y)
if (!existingPlacedMapObject) return
// Select the object
mapEditorStore.setSelectedMapObject(existingMapObject)
mapEditorStore.setSelectedMapObject(existingPlacedMapObject)
}
function moveMapObject(id: string) {
@ -154,22 +154,22 @@ function moveMapObject(id: string) {
scene.input.on(Phaser.Input.Events.POINTER_UP, handlePointerUp)
}
function rotateMapObject(id: string) {
function rotatePlacedMapObject(id: string) {
// Check if map is set
if (!mapEditorStore.map) return
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.map((object) => {
if (object.id === id) {
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.map((placedMapObject) => {
if (placedMapObject.id === id) {
return {
...object,
isRotated: !object.isRotated
...placedMapObject,
isRotated: !placedMapObject.isRotated
}
}
return object
return placedMapObject
})
}
function deleteMapObject(id: string) {
function deletePlacedMapObject(id: string) {
// Check if map is set
if (!mapEditorStore.map) return