npm run format, moved some files for improved file structure, removed redundant logic

This commit is contained in:
2025-02-05 00:19:55 +01:00
parent aee18956f3
commit 2b40741ca7
26 changed files with 218 additions and 238 deletions

View File

@ -9,9 +9,9 @@ import MapEventTiles from '@/components/gameMaster/mapEditor/mapPartials/MapEven
import MapTiles from '@/components/gameMaster/mapEditor/mapPartials/MapTiles.vue'
import PlacedMapObjects from '@/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue'
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
import { createTileLayer, createTileMap } from '@/services/mapService'
import { useScene } from 'phavuer'
import { onBeforeUnmount, onMounted, onUnmounted, shallowRef, useTemplateRef } from 'vue'
import { createTileLayer, createTileMap } from '@/composables/mapComposable'
const tileMap = shallowRef<Phaser.Tilemaps.Tilemap>()
const tileMapLayer = shallowRef<Phaser.Tilemaps.TilemapLayer>()
@ -52,7 +52,7 @@ function handlePointerDown(pointer: Phaser.Input.Pointer) {
function handleKeyDown(event: KeyboardEvent) {
//CTRL+Y
if (event.key === 'y' && event.ctrlKey ) {
if (event.key === 'y' && event.ctrlKey) {
mapTiles.value!.redo()
}
@ -69,7 +69,7 @@ function handlePointerMove(pointer: Phaser.Input.Pointer) {
}
function handlePointerUp(pointer: Phaser.Input.Pointer) {
if (mapEditor.drawMode.value === 'tile' ) {
if (mapEditor.drawMode.value === 'tile') {
mapTiles.value?.finalizeCommand()
}
}

View File

@ -5,8 +5,8 @@
<script setup lang="ts">
import { MapEventTileType, type MapEventTile, type Map as MapT, type UUID } from '@/application/types'
import { uuidv4 } from '@/application/utilities'
import { getTile, tileToWorldX, tileToWorldY } from '@/composables/mapComposable'
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
import { getTile, tileToWorldX, tileToWorldY } from '@/services/mapService'
import { Image, useScene } from 'phavuer'
import { shallowRef } from 'vue'

View File

@ -4,16 +4,13 @@
<script setup lang="ts">
import Controls from '@/components/utilities/Controls.vue'
import { createTileArray, getTile, placeTile, setLayerTiles } from '@/composables/mapComposable'
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
import { TileStorage } from '@/storage/storages'
import { createTileArray, getTile, placeTile, setLayerTiles } from '@/services/mapService'
import { useScene } from 'phavuer'
import { onMounted, ref, watch } from 'vue'
const emit = defineEmits(['tileMap:create'])
const scene = useScene()
const mapEditor = useMapEditorComposable()
const tileStorage = new TileStorage()
defineExpose({ handlePointer, finalizeCommand, undo, redo })
@ -24,7 +21,7 @@ const props = defineProps<{
class EditorCommand {
public operation: 'draw' | 'erase' = 'draw'
public tileName: string = "blank_tile"
public tileName: string = 'blank_tile'
public affectedTiles: number[][]
constructor(operation: 'draw' | 'erase', tileName: string) {
@ -139,7 +136,7 @@ function createCommandUpdate(x: number, y: number, tileName: string, operation:
if (vec[0] === x && vec[1] === y) return
}
currentCommand.affectedTiles.push([x,y])
currentCommand.affectedTiles.push([x, y])
}
function finalizeCommand() {
@ -190,8 +187,8 @@ function updateMapTiles() {
}
//Recursive Array Clone
function cloneArray(arr: any[]) : any[] {
return arr.map((item) => item instanceof Array ? cloneArray(item) : item)
function cloneArray(arr: any[]): any[] {
return arr.map((item) => (item instanceof Array ? cloneArray(item) : item))
}
watch(
@ -206,17 +203,6 @@ watch(
}
)
// Then overlay the map tiles, but only within the current map dimensions
function replaceTiles(originalTiles: string[][], mapTiles: string[][], width: number, height: number) {
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
if (mapTiles[y] && mapTiles[y][x] !== undefined) {
originalTiles[y][x] = mapTiles[y][x]
}
}
}
}
onMounted(async () => {
if (!mapEditor.currentMap.value) return
const mapState = mapEditor.currentMap.value
@ -226,5 +212,4 @@ onMounted(async () => {
setLayerTiles(props.tileMap, props.tileMapLayer, mapState.tiles)
})
</script>

View File

@ -9,8 +9,9 @@ import { uuidv4 } from '@/application/utilities'
import PlacedMapObject from '@/components/game/map/partials/PlacedMapObject.vue'
import SelectedPlacedMapObjectComponent from '@/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue'
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
import { getTile } from '@/services/mapService'
import { useScene } from 'phavuer'
import { getTile } from '@/composables/mapComposable'
import Tilemap = Phaser.Tilemaps.Tilemap
import TilemapLayer = Phaser.Tilemaps.TilemapLayer
@ -20,7 +21,7 @@ const mapEditor = useMapEditorComposable()
defineExpose({ handlePointer })
const props = defineProps<{
tileMap: Tilemap,
tileMap: Tilemap
tileMapLayer: TilemapLayer
}>()
@ -58,7 +59,7 @@ function eraser(pointer: Phaser.Input.Pointer, map: MapT) {
map.placedMapObjects = map.placedMapObjects.filter((placedMapObject) => placedMapObject.id !== existingPlacedMapObject.id)
}
function findObjectByPointer(pointer: Phaser.Input.Pointer, map: MapT) : PlacedMapObjectT | undefined {
function findObjectByPointer(pointer: Phaser.Input.Pointer, map: MapT): PlacedMapObjectT | undefined {
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
if (!tile) return undefined
@ -136,5 +137,4 @@ function handlePointer(pointer: Phaser.Input.Pointer) {
break
}
}
</script>

View File

@ -60,7 +60,7 @@ const modalRef = useTemplateRef('modalRef')
defineExpose({
open: () => modalRef.value?.open(),
close: () => modalRef.value?.close(),
getModal: () => modalRef.value,
getModal: () => modalRef.value
})
const uniqueTags = computed(() => {

View File

@ -26,7 +26,7 @@
</div>
<div>
<label class="mr-4" for="pvp">PVP enabled</label>
<input type="checkbox" v-model="pvp" @input="updateValue" class="input-field scale-125" name="pvp" id="pvp"/>
<input type="checkbox" v-model="pvp" @input="updateValue" class="input-field scale-125" name="pvp" id="pvp" />
</div>
</div>
</form>
@ -53,7 +53,7 @@ import { onMounted, ref, useTemplateRef, watch } from 'vue'
const mapEditor = useMapEditorComposable()
const screen = ref('settings')
const name = ref<string | undefined>("Map")
const name = ref<string | undefined>('Map')
const width = ref<number>(0)
const height = ref<number>(0)
const pvp = ref<boolean>(false)
@ -69,14 +69,17 @@ function updateValue(event: Event) {
mapEditor.updateProperty(ev.name as 'name' | 'width' | 'height' | 'pvp' | 'mapEffects', ev.value)
}
watch(() => mapEditor.currentMap.value, (map) => {
if (!map) return
name.value = map.name
width.value = map.width
height.value = map.height
pvp.value = map.pvp
mapEffects.value = map.mapEffects
})
watch(
() => mapEditor.currentMap.value,
(map) => {
if (!map) return
name.value = map.name
width.value = map.width
height.value = map.height
pvp.value = map.pvp
mapEffects.value = map.mapEffects
}
)
const addEffect = () => {
mapEffects.value.push({
@ -92,5 +95,4 @@ const removeEffect = (index: number) => {
mapEffects.value.splice(index, 1)
mapEditor.updateProperty('mapEffects', mapEffects.value)
}
</script>

View File

@ -101,7 +101,7 @@ const modalRef = useTemplateRef('modalRef')
defineExpose({
open: () => modalRef.value?.open(),
close: () => modalRef.value?.close(),
getModal: () => modalRef.value,
getModal: () => modalRef.value
})
const uniqueTags = computed(() => {

View File

@ -73,7 +73,7 @@
<div class="w-px bg-cyan"></div>
<label class="my-auto gap-0" for="checkbox">Continuous Drawing</label>
<input @change="handleCheck" v-model="checkboxValue" type="checkbox"/>
<input @change="handleCheck" v-model="checkboxValue" type="checkbox" />
</div>
<div class="toolbar fixed bottom-0 right-0 m-3 rounded flex bg-gray solid border-solid border-2 border-gray-500 text-gray-300 p-1.5 px-3 h-10 space-x-2">