1
0
forked from noxious/client

#366 : Add storage logic to asset manager

This commit is contained in:
2025-02-18 16:37:15 +01:00
parent d51fbc8030
commit 7097eb1580
9 changed files with 48 additions and 27 deletions

View File

@ -59,13 +59,13 @@
import config from '@/application/config'
import { SocketEvent } from '@/application/enums'
import type { MapObject } from '@/application/types'
import { downloadCache } from '@/application/utilities'
import ChipsInput from '@/components/forms/ChipsInput.vue'
import { socketManager } from '@/managers/SocketManager'
import { CharacterTypeStorage, MapObjectStorage } from '@/storage/storages'
import { useAssetManagerStore } from '@/stores/assetManagerStore'
import { useGameStore } from '@/stores/gameStore'
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
const gameStore = useGameStore()
const assetManagerStore = useAssetManagerStore()
const selectedMapObject = computed(() => assetManagerStore.selectedMapObject)
@ -81,6 +81,7 @@ const mapObjectFrameHeight = ref(0)
const imageRef = ref<HTMLImageElement | null>(null)
const isDragging = ref(false)
const draggedPointIndex = ref(-1)
const mapObjectStorage = new MapObjectStorage()
if (!selectedMapObject.value) {
console.error('No map mapObject selected')
@ -98,11 +99,15 @@ if (selectedMapObject.value) {
}
function removeObject() {
socketManager.emit(SocketEvent.GM_MAPOBJECT_REMOVE, { mapObject: selectedMapObject.value?.id }, (response: boolean) => {
if (!selectedMapObject.value) return
socketManager.emit(SocketEvent.GM_MAPOBJECT_REMOVE, { mapObject: selectedMapObject.value.id }, (response: boolean) => {
if (!response) {
console.error('Failed to remove mapObject')
return
}
downloadCache('map_object', new MapObjectStorage())
refreshObjectList()
})
}
@ -141,6 +146,8 @@ function saveObject() {
console.error('Failed to save mapObject')
return
}
downloadCache('map_object', new MapObjectStorage())
refreshObjectList(false)
}
)