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": {
|
"node_modules/electron-to-chromium": {
|
||||||
"version": "1.5.101",
|
"version": "1.5.102",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.101.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.102.tgz",
|
||||||
"integrity": "sha512-L0ISiQrP/56Acgu4/i/kfPwWSgrzYZUnQrC0+QPFuhqlLP1Ir7qzPPDVS9BcKIyWTRU8+o6CC8dKw38tSWhYIA==",
|
"integrity": "sha512-eHhqaja8tE/FNpIiBrvBjFV/SSKpyWHLvxuR9dPTdo+3V9ppdLmFB7ZZQ98qNovcngPLYIz0oOBF9P0FfZef5Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
@ -36,12 +36,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { SocketEvent } from '@/application/enums'
|
import { SocketEvent } from '@/application/enums'
|
||||||
import type { CharacterGender, CharacterHair, Sprite } from '@/application/types'
|
import type { CharacterGender, CharacterHair, Sprite } from '@/application/types'
|
||||||
|
import { downloadCache } from '@/application/utilities'
|
||||||
import { socketManager } from '@/managers/SocketManager'
|
import { socketManager } from '@/managers/SocketManager'
|
||||||
|
import { CharacterHairStorage, TileStorage } from '@/storage/storages'
|
||||||
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
const gameStore = useGameStore()
|
|
||||||
const assetManagerStore = useAssetManagerStore()
|
const assetManagerStore = useAssetManagerStore()
|
||||||
|
|
||||||
const selectedCharacterHair = computed(() => assetManagerStore.selectedCharacterHair)
|
const selectedCharacterHair = computed(() => assetManagerStore.selectedCharacterHair)
|
||||||
@ -72,6 +72,8 @@ function removeCharacterHair() {
|
|||||||
console.error('Failed to remove character hair')
|
console.error('Failed to remove character hair')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('character_hair', new CharacterHairStorage())
|
||||||
refreshCharacterHairList()
|
refreshCharacterHairList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -100,6 +102,8 @@ function saveCharacterHair() {
|
|||||||
console.error('Failed to save character type')
|
console.error('Failed to save character type')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('character_hair', new CharacterHairStorage())
|
||||||
refreshCharacterHairList(false)
|
refreshCharacterHairList(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { SocketEvent } from '@/application/enums'
|
import { SocketEvent } from '@/application/enums'
|
||||||
import type { CharacterGender, CharacterRace, CharacterType, Sprite } from '@/application/types'
|
import type { CharacterGender, CharacterRace, CharacterType, Sprite } from '@/application/types'
|
||||||
|
import { downloadCache } from '@/application/utilities'
|
||||||
import { socketManager } from '@/managers/SocketManager'
|
import { socketManager } from '@/managers/SocketManager'
|
||||||
|
import { CharacterTypeStorage } from '@/storage/storages'
|
||||||
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
const gameStore = useGameStore()
|
|
||||||
const assetManagerStore = useAssetManagerStore()
|
const assetManagerStore = useAssetManagerStore()
|
||||||
|
|
||||||
const selectedCharacterType = computed(() => assetManagerStore.selectedCharacterType)
|
const selectedCharacterType = computed(() => assetManagerStore.selectedCharacterType)
|
||||||
@ -81,6 +81,8 @@ function removeCharacterType() {
|
|||||||
console.error('Failed to remove character type')
|
console.error('Failed to remove character type')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('character_types', new CharacterTypeStorage())
|
||||||
refreshCharacterTypeList()
|
refreshCharacterTypeList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -110,6 +112,8 @@ function saveCharacterType() {
|
|||||||
console.error('Failed to save character type')
|
console.error('Failed to save character type')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('character_types', new CharacterTypeStorage())
|
||||||
refreshCharacterTypeList(false)
|
refreshCharacterTypeList(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -59,13 +59,13 @@
|
|||||||
import config from '@/application/config'
|
import config from '@/application/config'
|
||||||
import { SocketEvent } from '@/application/enums'
|
import { SocketEvent } from '@/application/enums'
|
||||||
import type { MapObject } from '@/application/types'
|
import type { MapObject } from '@/application/types'
|
||||||
|
import { downloadCache } from '@/application/utilities'
|
||||||
import ChipsInput from '@/components/forms/ChipsInput.vue'
|
import ChipsInput from '@/components/forms/ChipsInput.vue'
|
||||||
import { socketManager } from '@/managers/SocketManager'
|
import { socketManager } from '@/managers/SocketManager'
|
||||||
|
import { CharacterTypeStorage, MapObjectStorage } from '@/storage/storages'
|
||||||
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
const gameStore = useGameStore()
|
|
||||||
const assetManagerStore = useAssetManagerStore()
|
const assetManagerStore = useAssetManagerStore()
|
||||||
|
|
||||||
const selectedMapObject = computed(() => assetManagerStore.selectedMapObject)
|
const selectedMapObject = computed(() => assetManagerStore.selectedMapObject)
|
||||||
@ -81,6 +81,7 @@ const mapObjectFrameHeight = ref(0)
|
|||||||
const imageRef = ref<HTMLImageElement | null>(null)
|
const imageRef = ref<HTMLImageElement | null>(null)
|
||||||
const isDragging = ref(false)
|
const isDragging = ref(false)
|
||||||
const draggedPointIndex = ref(-1)
|
const draggedPointIndex = ref(-1)
|
||||||
|
const mapObjectStorage = new MapObjectStorage()
|
||||||
|
|
||||||
if (!selectedMapObject.value) {
|
if (!selectedMapObject.value) {
|
||||||
console.error('No map mapObject selected')
|
console.error('No map mapObject selected')
|
||||||
@ -98,11 +99,15 @@ if (selectedMapObject.value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeObject() {
|
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) {
|
if (!response) {
|
||||||
console.error('Failed to remove mapObject')
|
console.error('Failed to remove mapObject')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('map_object', new MapObjectStorage())
|
||||||
refreshObjectList()
|
refreshObjectList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -141,6 +146,8 @@ function saveObject() {
|
|||||||
console.error('Failed to save mapObject')
|
console.error('Failed to save mapObject')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('map_object', new MapObjectStorage())
|
||||||
refreshObjectList(false)
|
refreshObjectList(false)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -69,17 +69,16 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { SocketEvent } from '@/application/enums'
|
import { SocketEvent } from '@/application/enums'
|
||||||
import type { Sprite, SpriteAction, UUID } from '@/application/types'
|
import type { Sprite, SpriteAction } from '@/application/types'
|
||||||
import { uuidv4 } from '@/application/utilities'
|
import { downloadCache, uuidv4 } from '@/application/utilities'
|
||||||
import SpriteActionsInput from '@/components/gameMaster/assetManager/partials/sprite/partials/SpriteImagesInput.vue'
|
import SpriteActionsInput from '@/components/gameMaster/assetManager/partials/sprite/partials/SpriteImagesInput.vue'
|
||||||
import SpritePreview from '@/components/gameMaster/assetManager/partials/sprite/partials/SpritePreview.vue'
|
import SpritePreview from '@/components/gameMaster/assetManager/partials/sprite/partials/SpritePreview.vue'
|
||||||
import Accordion from '@/components/utilities/Accordion.vue'
|
import Accordion from '@/components/utilities/Accordion.vue'
|
||||||
import { socketManager } from '@/managers/SocketManager'
|
import { socketManager } from '@/managers/SocketManager'
|
||||||
|
import { SpriteStorage } from '@/storage/storages'
|
||||||
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
const gameStore = useGameStore()
|
|
||||||
const assetManagerStore = useAssetManagerStore()
|
const assetManagerStore = useAssetManagerStore()
|
||||||
|
|
||||||
const selectedSprite = computed(() => assetManagerStore.selectedSprite)
|
const selectedSprite = computed(() => assetManagerStore.selectedSprite)
|
||||||
@ -104,6 +103,8 @@ function deleteSprite() {
|
|||||||
console.error('Failed to delete sprite')
|
console.error('Failed to delete sprite')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('sprite', new SpriteStorage())
|
||||||
refreshSpriteList()
|
refreshSpriteList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -114,6 +115,8 @@ function copySprite() {
|
|||||||
console.error('Failed to copy sprite')
|
console.error('Failed to copy sprite')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('sprite', new SpriteStorage())
|
||||||
refreshSpriteList(false)
|
refreshSpriteList(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -156,6 +159,8 @@ function saveSprite() {
|
|||||||
console.error('Failed to save sprite')
|
console.error('Failed to save sprite')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('sprite', new SpriteStorage())
|
||||||
refreshSpriteList(false)
|
refreshSpriteList(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -26,16 +26,14 @@
|
|||||||
import config from '@/application/config'
|
import config from '@/application/config'
|
||||||
import { SocketEvent } from '@/application/enums'
|
import { SocketEvent } from '@/application/enums'
|
||||||
import type { Tile } from '@/application/types'
|
import type { Tile } from '@/application/types'
|
||||||
|
import { downloadCache } from '@/application/utilities'
|
||||||
import ChipsInput from '@/components/forms/ChipsInput.vue'
|
import ChipsInput from '@/components/forms/ChipsInput.vue'
|
||||||
import { socketManager } from '@/managers/SocketManager'
|
import { socketManager } from '@/managers/SocketManager'
|
||||||
import { TileStorage } from '@/storage/storages'
|
import { TileStorage } from '@/storage/storages'
|
||||||
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
import { useAssetManagerStore } from '@/stores/assetManagerStore'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, toRaw, watch } from 'vue'
|
|
||||||
|
|
||||||
const gameStore = useGameStore()
|
|
||||||
const assetManagerStore = useAssetManagerStore()
|
const assetManagerStore = useAssetManagerStore()
|
||||||
const tileStorage = new TileStorage()
|
|
||||||
|
|
||||||
const selectedTile = computed(() => assetManagerStore.selectedTile)
|
const selectedTile = computed(() => assetManagerStore.selectedTile)
|
||||||
|
|
||||||
@ -63,7 +61,8 @@ async function deleteTile() {
|
|||||||
console.error('Failed to delete tile')
|
console.error('Failed to delete tile')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await tileStorage.delete(selectedTile.value!.id)
|
|
||||||
|
downloadCache('tile', new TileStorage())
|
||||||
refreshTileList()
|
refreshTileList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -96,6 +95,8 @@ function saveTile() {
|
|||||||
console.error('Failed to save tile')
|
console.error('Failed to save tile')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadCache('tile', new TileStorage())
|
||||||
refreshTileList(false)
|
refreshTileList(false)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -10,9 +10,9 @@ import MapEventTiles from '@/components/gameMaster/mapEditor/mapPartials/MapEven
|
|||||||
import MapTiles from '@/components/gameMaster/mapEditor/mapPartials/MapTiles.vue'
|
import MapTiles from '@/components/gameMaster/mapEditor/mapPartials/MapTiles.vue'
|
||||||
import PlacedMapObjects from '@/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue'
|
import PlacedMapObjects from '@/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue'
|
||||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
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 { TileStorage } from '@/storage/storages'
|
||||||
import { useManualRefHistory, useRefHistory } from '@vueuse/core'
|
import { useRefHistory } from '@vueuse/core'
|
||||||
import { useScene } from 'phavuer'
|
import { useScene } from 'phavuer'
|
||||||
import { onBeforeUnmount, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue'
|
import { onBeforeUnmount, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue'
|
||||||
|
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
<template #modalHeader>
|
<template #modalHeader>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<button class="btn-cyan w-7 h-7 font-normal flex items-center justify-center" @click="createMapModal?.open">+</button>
|
<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">
|
<h3 class="text-lg text-white ml-2">Maps</h3>
|
||||||
Maps
|
|
||||||
</h3>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #modalBody>
|
<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 Toolbar from '@/components/gameMaster/mapEditor/partials/Toolbar.vue'
|
||||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||||
import { loadAllTileTextures } from '@/services/mapService'
|
import { loadAllTileTextures } from '@/services/mapService'
|
||||||
import { MapStorage } from '@/storage/storages'
|
import {CharacterHairStorage, MapStorage} from '@/storage/storages'
|
||||||
import { Game, Scene } from 'phavuer'
|
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 mapStorage = new MapStorage()
|
||||||
const mapEditor = useMapEditorComposable()
|
const mapEditor = useMapEditorComposable()
|
||||||
@ -92,7 +93,8 @@ function save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
socketManager.emit(SocketEvent.GM_MAP_UPDATE, data, (response: MapT) => {
|
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