generated from VLADIMIR/template_frontend
fix
This commit is contained in:
@@ -56,6 +56,7 @@ const game = ref<Game>({
|
||||
})
|
||||
const screens = ref<ScreenState[]>([])
|
||||
const mapItems = ref<MapItem[]>([])
|
||||
const mapSaving = ref(false)
|
||||
const mapScale = ref(1)
|
||||
const mapOffset = ref({ x: 0, y: 0 })
|
||||
let dragState: { item: MapItem; startX: number; startY: number; itemX: number; itemY: number } | undefined
|
||||
@@ -107,14 +108,20 @@ async function getGameScreens() {
|
||||
getGameScreens()
|
||||
|
||||
async function getGameMap() {
|
||||
if (dragState) return
|
||||
if (dragState || mapSaving.value) return
|
||||
const res = await client.GetGameMap({ gameId: Number(gameId) })
|
||||
if (res.error == '') mapItems.value = res.items || []
|
||||
}
|
||||
getGameMap()
|
||||
|
||||
async function saveMapItem(item: MapItem, hidden = item.hidden) {
|
||||
await client.UpdateGameMapItem({ gameId: Number(gameId), kind: item.kind, itemId: item.itemId, x: item.x, y: item.y, hidden })
|
||||
mapSaving.value = true
|
||||
try {
|
||||
const res = await client.UpdateGameMapItem({ gameId: Number(gameId), kind: item.kind, itemId: item.itemId, x: item.x, y: item.y, hidden })
|
||||
if (res.error != '') message.error(res.error || 'Не удалось сохранить координаты')
|
||||
} finally {
|
||||
mapSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function startMapDrag(item: MapItem, event: PointerEvent) {
|
||||
|
||||
Reference in New Issue
Block a user