forked from noxious/client
#366 : Add storage logic to asset manager
This commit is contained in:
parent
d51fbc8030
commit
7097eb1580
6
package-lock.json
generated
6
package-lock.json
generated
@ -2903,9 +2903,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.5.101",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.101.tgz",
|
||||
"integrity": "sha512-L0ISiQrP/56Acgu4/i/kfPwWSgrzYZUnQrC0+QPFuhqlLP1Ir7qzPPDVS9BcKIyWTRU8+o6CC8dKw38tSWhYIA==",
|
||||
"version": "1.5.102",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.102.tgz",
|
||||
"integrity": "sha512-eHhqaja8tE/FNpIiBrvBjFV/SSKpyWHLvxuR9dPTdo+3V9ppdLmFB7ZZQ98qNovcngPLYIz0oOBF9P0FfZef5Q==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
|
@ -36,12 +36,12 @@
|
||||
<script setup lang="ts">
|
||||
import { SocketEvent } from '@/application/enums'
|
||||
import type { CharacterGender, CharacterHair, Sprite } from '@/application/types'
|
||||
import { downloadCache } from '@/application/utilities'
|
||||
import { socketManager } from '@/managers/SocketManager'
|
||||
import { CharacterHairStorage, TileStorage } 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 selectedCharacterHair = computed(() => assetManagerStore.selectedCharacterHair)
|
||||
@ -72,6 +72,8 @@ function removeCharacterHair() {
|
||||
console.error('Failed to remove character hair')
|
||||
return
|
||||
}
|
||||
|
||||
downloadCache('character_hair', new CharacterHairStorage())
|
||||
refreshCharacterHairList()
|
||||
})
|
||||
}
|
||||
@ -100,6 +102,8 @@ function saveCharacterHair() {
|
||||
console.error('Failed to save character type')
|
||||
return
|
||||
}
|
||||
|
||||
downloadCache('character_hair', new CharacterHairStorage())
|
||||
refreshCharacterHairList(false)
|
||||
})
|
||||
}
|
||||
|
@ -42,12 +42,12 @@
|
||||
<script setup lang="ts">
|
||||
import { SocketEvent } from '@/application/enums'
|
||||
import type { CharacterGender, CharacterRace, CharacterType, Sprite } from '@/application/types'
|
||||
import { downloadCache } from '@/application/utilities'
|
||||
import { socketManager } from '@/managers/SocketManager'
|
||||
import { CharacterTypeStorage } 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 selectedCharacterType = computed(() => assetManagerStore.selectedCharacterType)
|
||||
@ -81,6 +81,8 @@ function removeCharacterType() {
|
||||
console.error('Failed to remove character type')
|
||||
return
|
||||
}
|
||||
|
||||
downloadCache('character_types', new CharacterTypeStorage())
|
||||
refreshCharacterTypeList()
|
||||
})
|
||||
}
|
||||
@ -110,6 +112,8 @@ function saveCharacterType() {
|
||||
console.error('Failed to save character type')
|
||||
return
|
||||
}
|
||||
|
||||
downloadCache('character_types', new CharacterTypeStorage())
|
||||
refreshCharacterTypeList(false)
|
||||
})
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
)
|
||||
|
@ -69,17 +69,16 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { SocketEvent } from '@/application/enums'
|
||||
import type { Sprite, SpriteAction, UUID } from '@/application/types'
|
||||
import { uuidv4 } from '@/application/utilities'
|
||||
import type { Sprite, SpriteAction } from '@/application/types'
|
||||
import { downloadCache, uuidv4 } from '@/application/utilities'
|
||||
import SpriteActionsInput from '@/components/gameMaster/assetManager/partials/sprite/partials/SpriteImagesInput.vue'
|
||||
import SpritePreview from '@/components/gameMaster/assetManager/partials/sprite/partials/SpritePreview.vue'
|
||||
import Accordion from '@/components/utilities/Accordion.vue'
|
||||
import { socketManager } from '@/managers/SocketManager'
|
||||
import { SpriteStorage } 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 selectedSprite = computed(() => assetManagerStore.selectedSprite)
|
||||
@ -104,6 +103,8 @@ function deleteSprite() {
|
||||
console.error('Failed to delete sprite')
|
||||
return
|
||||
}
|
||||
|
||||
downloadCache('sprite', new SpriteStorage())
|
||||
refreshSpriteList()
|
||||
})
|
||||
}
|
||||
@ -114,6 +115,8 @@ function copySprite() {
|
||||
console.error('Failed to copy sprite')
|
||||
return
|
||||
}
|
||||
|
||||
downloadCache('sprite', new SpriteStorage())
|
||||
refreshSpriteList(false)
|
||||
})
|
||||
}
|
||||
@ -156,6 +159,8 @@ function saveSprite() {
|
||||
console.error('Failed to save sprite')
|
||||
return
|
||||
}
|
||||
|
||||
downloadCache('sprite', new SpriteStorage())
|
||||
refreshSpriteList(false)
|
||||
})
|
||||
}
|
||||
|
@ -26,16 +26,14 @@
|
||||
import config from '@/application/config'
|
||||
import { SocketEvent } from '@/application/enums'
|
||||
import type { Tile } from '@/application/types'
|
||||
import { downloadCache } from '@/application/utilities'
|
||||
import ChipsInput from '@/components/forms/ChipsInput.vue'
|
||||
import { socketManager } from '@/managers/SocketManager'
|
||||
import { TileStorage } from '@/storage/storages'
|
||||
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import { computed, onBeforeUnmount, onMounted, ref, toRaw, watch } from 'vue'
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
|
||||
const gameStore = useGameStore()
|
||||
const assetManagerStore = useAssetManagerStore()
|
||||
const tileStorage = new TileStorage()
|
||||
|
||||
const selectedTile = computed(() => assetManagerStore.selectedTile)
|
||||
|
||||
@ -63,7 +61,8 @@ async function deleteTile() {
|
||||
console.error('Failed to delete tile')
|
||||
return
|
||||
}
|
||||
await tileStorage.delete(selectedTile.value!.id)
|
||||
|
||||
downloadCache('tile', new TileStorage())
|
||||
refreshTileList()
|
||||
})
|
||||
}
|
||||
@ -96,6 +95,8 @@ function saveTile() {
|
||||
console.error('Failed to save tile')
|
||||
return
|
||||
}
|
||||
|
||||
downloadCache('tile', new TileStorage())
|
||||
refreshTileList(false)
|
||||
}
|
||||
)
|
||||
|
@ -10,9 +10,9 @@ import MapEventTiles from '@/components/gameMaster/mapEditor/mapPartials/MapEven
|
||||
import MapTiles from '@/components/gameMaster/mapEditor/mapPartials/MapTiles.vue'
|
||||
import PlacedMapObjects from '@/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { cloneArray, createTileArray, createTileLayer, createTileMap, placeTiles } from '@/services/mapService'
|
||||
import { cloneArray, createTileLayer, createTileMap, placeTiles } from '@/services/mapService'
|
||||
import { TileStorage } from '@/storage/storages'
|
||||
import { useManualRefHistory, useRefHistory } from '@vueuse/core'
|
||||
import { useRefHistory } from '@vueuse/core'
|
||||
import { useScene } from 'phavuer'
|
||||
import { onBeforeUnmount, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue'
|
||||
|
||||
|
@ -3,9 +3,7 @@
|
||||
<template #modalHeader>
|
||||
<div class="flex items-center">
|
||||
<button class="btn-cyan w-7 h-7 font-normal flex items-center justify-center" @click="createMapModal?.open">+</button>
|
||||
<h3 class="text-lg text-white ml-2">
|
||||
Maps
|
||||
</h3>
|
||||
<h3 class="text-lg text-white ml-2">Maps</h3>
|
||||
</div>
|
||||
</template>
|
||||
<template #modalBody>
|
||||
|
@ -32,9 +32,10 @@ import TileList from '@/components/gameMaster/mapEditor/partials/TileList.vue'
|
||||
import Toolbar from '@/components/gameMaster/mapEditor/partials/Toolbar.vue'
|
||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||
import { loadAllTileTextures } from '@/services/mapService'
|
||||
import { MapStorage } from '@/storage/storages'
|
||||
import {CharacterHairStorage, MapStorage} from '@/storage/storages'
|
||||
import { Game, Scene } from 'phavuer'
|
||||
import {ref, toRaw, useTemplateRef} from 'vue'
|
||||
import { ref, toRaw, useTemplateRef } from 'vue'
|
||||
import {downloadCache} from "@/application/utilities";
|
||||
|
||||
const mapStorage = new MapStorage()
|
||||
const mapEditor = useMapEditorComposable()
|
||||
@ -92,7 +93,8 @@ function save() {
|
||||
}
|
||||
|
||||
socketManager.emit(SocketEvent.GM_MAP_UPDATE, data, (response: MapT) => {
|
||||
mapStorage.update(response.id, response)
|
||||
if (!response.id) return
|
||||
downloadCache('maps', new MapStorage())
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user