Load map data inside a composable instead of Pinia store
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import type { Map, MapEffect, MapObject, Tile, UUID } from '@/application/types'
|
||||
import type { MapObject } from '@/application/types'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export type TeleportSettings = {
|
||||
toMap: Map | null
|
||||
toMapId: string
|
||||
toPositionX: number
|
||||
toPositionY: number
|
||||
toRotation: number
|
||||
@ -12,12 +12,9 @@ export const useMapEditorStore = defineStore('mapEditor', {
|
||||
state: () => {
|
||||
return {
|
||||
active: false,
|
||||
mapId: '',
|
||||
tool: 'move',
|
||||
drawMode: 'tile',
|
||||
eraserMode: 'tile',
|
||||
tileList: [] as Tile[],
|
||||
mapObjectList: [] as MapObject[],
|
||||
selectedTile: '',
|
||||
selectedMapObject: null as MapObject | null,
|
||||
isTileListModalShown: false,
|
||||
@ -26,15 +23,8 @@ export const useMapEditorStore = defineStore('mapEditor', {
|
||||
isCreateMapModalShown: false,
|
||||
isSettingsModalShown: false,
|
||||
shouldClearTiles: false,
|
||||
mapSettings: {
|
||||
name: '',
|
||||
width: 0,
|
||||
height: 0,
|
||||
pvp: false,
|
||||
mapEffects: [] as MapEffect[]
|
||||
},
|
||||
teleportSettings: {
|
||||
toMap: null,
|
||||
toMapId: '',
|
||||
toPositionX: 0,
|
||||
toPositionY: 0,
|
||||
toRotation: 0
|
||||
@ -46,24 +36,6 @@ export const useMapEditorStore = defineStore('mapEditor', {
|
||||
if (this.active) this.reset()
|
||||
this.active = !this.active
|
||||
},
|
||||
setMapId(mapId: UUID) {
|
||||
this.mapId = mapId
|
||||
},
|
||||
setMapName(name: string) {
|
||||
this.mapSettings.name = name
|
||||
},
|
||||
setMapWidth(width: number) {
|
||||
this.mapSettings.width = width
|
||||
},
|
||||
setMapHeight(height: number) {
|
||||
this.mapSettings.height = height
|
||||
},
|
||||
setMapPvp(pvp: boolean) {
|
||||
this.mapSettings.pvp = pvp
|
||||
},
|
||||
setMapEffects(mapEffects: MapEffect[]) {
|
||||
this.mapSettings.mapEffects = mapEffects
|
||||
},
|
||||
setTool(tool: string) {
|
||||
this.tool = tool
|
||||
},
|
||||
@ -73,12 +45,6 @@ export const useMapEditorStore = defineStore('mapEditor', {
|
||||
setEraserMode(mode: string) {
|
||||
this.eraserMode = mode
|
||||
},
|
||||
setTileList(tiles: Tile[]) {
|
||||
this.tileList = tiles
|
||||
},
|
||||
setMapObjectList(objects: MapObject[]) {
|
||||
this.mapObjectList = objects
|
||||
},
|
||||
setSelectedTile(tile: string) {
|
||||
this.selectedTile = tile
|
||||
},
|
||||
@ -105,9 +71,6 @@ export const useMapEditorStore = defineStore('mapEditor', {
|
||||
this.shouldClearTiles = false
|
||||
},
|
||||
reset() {
|
||||
this.mapId = ''
|
||||
this.tileList = []
|
||||
this.mapObjectList = []
|
||||
this.tool = 'move'
|
||||
this.drawMode = 'tile'
|
||||
this.selectedTile = ''
|
||||
|
Reference in New Issue
Block a user