Refactoring of modalShown booleans

This commit is contained in:
2025-01-25 23:27:15 -06:00
parent 14aa696197
commit 791830fd6f
23 changed files with 377 additions and 448 deletions

View File

@ -1,5 +1,6 @@
import type { MapObject } from '@/application/types'
import { defineStore } from 'pinia'
import type { Map as MapT } from '@/application/types'
export type TeleportSettings = {
toMapId: string
@ -11,17 +12,11 @@ export type TeleportSettings = {
export const useMapEditorStore = defineStore('mapEditor', {
state: () => {
return {
active: false,
active: true,
tool: 'move',
drawMode: 'tile',
eraserMode: 'tile',
selectedTile: '',
selectedMapObject: null as MapObject | null,
isTileListModalShown: false,
isMapObjectListModalShown: false,
isMapListModalShown: false,
isCreateMapModalShown: false,
isSettingsModalShown: false,
shouldClearTiles: false,
teleportSettings: {
toMapId: '',
@ -32,35 +27,18 @@ export const useMapEditorStore = defineStore('mapEditor', {
}
},
actions: {
toggleActive() {
if (this.active) this.reset()
this.active = !this.active
},
setTool(tool: string) {
this.tool = tool
},
setDrawMode(mode: string) {
this.drawMode = mode
},
setEraserMode(mode: string) {
this.eraserMode = mode
},
setSelectedTile(tile: string) {
this.selectedTile = tile
},
setSelectedMapObject(object: MapObject) {
this.selectedMapObject = object
},
toggleSettingsModal() {
this.isSettingsModalShown = !this.isSettingsModalShown
},
toggleMapListModal() {
this.isMapListModalShown = !this.isMapListModalShown
this.isCreateMapModalShown = false
},
toggleCreateMapModal() {
this.isCreateMapModalShown = !this.isCreateMapModalShown
},
setTeleportSettings(teleportSettings: TeleportSettings) {
this.teleportSettings = teleportSettings
},
@ -75,11 +53,6 @@ export const useMapEditorStore = defineStore('mapEditor', {
this.drawMode = 'tile'
this.selectedTile = ''
this.selectedMapObject = null
this.isTileListModalShown = false
this.isMapObjectListModalShown = false
this.isSettingsModalShown = false
this.isMapListModalShown = false
this.isCreateMapModalShown = false
this.shouldClearTiles = false
}
}