forked from noxious/client
Restored map editor event tiles
This commit is contained in:
parent
ad47b37279
commit
efeae337ab
@ -34,10 +34,16 @@ function handlePointerDown(pointer: Phaser.Input.Pointer) {
|
|||||||
switch (mapEditor.drawMode.value) {
|
switch (mapEditor.drawMode.value) {
|
||||||
case 'tile':
|
case 'tile':
|
||||||
mapTiles.value.handlePointer(pointer)
|
mapTiles.value.handlePointer(pointer)
|
||||||
|
break
|
||||||
case 'map_object':
|
case 'map_object':
|
||||||
mapObjects.value.handlePointer(pointer)
|
mapObjects.value.handlePointer(pointer)
|
||||||
|
break
|
||||||
case 'teleport':
|
case 'teleport':
|
||||||
eventTiles.value.handlePointer(pointer)
|
eventTiles.value.handlePointer(pointer)
|
||||||
|
break
|
||||||
|
case 'blocking tile':
|
||||||
|
eventTiles.value.handlePointer(pointer)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,8 @@ function getImageProps(tile: MapEventTile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
|
function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
|
||||||
if (!tileLayer.value) return
|
|
||||||
|
|
||||||
// Check if there is a tile
|
// 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
|
if (!tile) return
|
||||||
|
|
||||||
// Check if event tile already exists on position
|
// Check if event tile already exists on position
|
||||||
@ -45,8 +43,8 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
|
|||||||
|
|
||||||
const newEventTile = {
|
const newEventTile = {
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
mapId: map?.id,
|
mapId: map.id,
|
||||||
map: map?.id,
|
map: map.id,
|
||||||
type: mapEditor.drawMode.value === 'blocking tile' ? MapEventTileType.BLOCK : MapEventTileType.TELEPORT,
|
type: mapEditor.drawMode.value === 'blocking tile' ? MapEventTileType.BLOCK : MapEventTileType.TELEPORT,
|
||||||
positionX: tile.x,
|
positionX: tile.x,
|
||||||
positionY: tile.y,
|
positionY: tile.y,
|
||||||
@ -61,7 +59,7 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
map!.mapEventTiles = map!.mapEventTiles.concat(newEventTile as MapEventTile)
|
map.mapEventTiles.push(newEventTile)
|
||||||
}
|
}
|
||||||
|
|
||||||
function erase(pointer: Phaser.Input.Pointer, map: MapT) {
|
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
|
// Check if shift is not pressed, this means we are moving the camera
|
||||||
if (pointer.event.shiftKey) return
|
if (pointer.event.shiftKey) return
|
||||||
|
|
||||||
|
if (pointer.event.altKey) return
|
||||||
|
|
||||||
switch (mapEditor.tool.value) {
|
switch (mapEditor.tool.value) {
|
||||||
case 'pencil':
|
case 'pencil':
|
||||||
pencil(pointer, map)
|
pencil(pointer, map)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="h-full overflow-auto">
|
<div class="h-full overflow-auto">
|
||||||
<div class="flex justify-between flex-wrap gap-2.5 items-center">
|
<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
|
<img
|
||||||
class="border-2 border-solid max-w-full"
|
class="border-2 border-solid max-w-full"
|
||||||
:src="`${config.server_endpoint}/textures/map_objects/${mapObject.id}.png`"
|
:src="`${config.server_endpoint}/textures/map_objects/${mapObject.id}.png`"
|
||||||
|
@ -19,7 +19,7 @@ const movingPlacedObject = ref<PlacedMapObject | null>(null)
|
|||||||
const selectedPlacedObject = ref<PlacedMapObject | null>(null)
|
const selectedPlacedObject = ref<PlacedMapObject | null>(null)
|
||||||
const shouldClearTiles = ref(false)
|
const shouldClearTiles = ref(false)
|
||||||
const teleportSettings = ref<TeleportSettings>({
|
const teleportSettings = ref<TeleportSettings>({
|
||||||
toMapId: '',
|
toMapId: '1000',
|
||||||
toPositionX: 0,
|
toPositionX: 0,
|
||||||
toPositionY: 0,
|
toPositionY: 0,
|
||||||
toRotation: 0
|
toRotation: 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user