1
0
forked from noxious/client

Restored map editor event tiles

This commit is contained in:
Andrei 2025-02-02 00:02:19 -06:00
parent ad47b37279
commit efeae337ab
4 changed files with 14 additions and 8 deletions

View File

@ -34,10 +34,16 @@ function handlePointerDown(pointer: Phaser.Input.Pointer) {
switch (mapEditor.drawMode.value) {
case 'tile':
mapTiles.value.handlePointer(pointer)
break
case 'map_object':
mapObjects.value.handlePointer(pointer)
break
case 'teleport':
eventTiles.value.handlePointer(pointer)
break
case 'blocking tile':
eventTiles.value.handlePointer(pointer)
break
}
}

View File

@ -30,10 +30,8 @@ function getImageProps(tile: MapEventTile) {
}
function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
if (!tileLayer.value) return
// Check if there is a tile
const tile = getTile(tileLayer.value, pointer.worldX, pointer.worldY)
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
if (!tile) return
// Check if event tile already exists on position
@ -45,8 +43,8 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
const newEventTile = {
id: uuidv4(),
mapId: map?.id,
map: map?.id,
mapId: map.id,
map: map.id,
type: mapEditor.drawMode.value === 'blocking tile' ? MapEventTileType.BLOCK : MapEventTileType.TELEPORT,
positionX: tile.x,
positionY: tile.y,
@ -61,7 +59,7 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
: undefined
}
map!.mapEventTiles = map!.mapEventTiles.concat(newEventTile as MapEventTile)
map.mapEventTiles.push(newEventTile)
}
function erase(pointer: Phaser.Input.Pointer, map: MapT) {
@ -88,6 +86,8 @@ function handlePointer(pointer: Phaser.Input.Pointer) {
// Check if shift is not pressed, this means we are moving the camera
if (pointer.event.shiftKey) return
if (pointer.event.altKey) return
switch (mapEditor.tool.value) {
case 'pencil':
pencil(pointer, map)

View File

@ -20,7 +20,7 @@
</div>
<div class="h-full overflow-auto">
<div class="flex justify-between flex-wrap gap-2.5 items-center">
<div v-for="(mapObject, index) in filteredMapObjects" :key="index" class="max-w-1/4 inline-block">
<div v-for="(mapObject, index) in filteredMapObjects" :key="index" class="max-w-1/4 p-2 inline-block">
<img
class="border-2 border-solid max-w-full"
:src="`${config.server_endpoint}/textures/map_objects/${mapObject.id}.png`"

View File

@ -19,7 +19,7 @@ const movingPlacedObject = ref<PlacedMapObject | null>(null)
const selectedPlacedObject = ref<PlacedMapObject | null>(null)
const shouldClearTiles = ref(false)
const teleportSettings = ref<TeleportSettings>({
toMapId: '',
toMapId: '1000',
toPositionX: 0,
toPositionY: 0,
toRotation: 0