Refractor socket store into game store
This commit is contained in:
@ -35,11 +35,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useGameStore } from '@/stores/game'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
import type { Zone } from '@/types'
|
||||
|
||||
const socket = useSocketStore()
|
||||
const gameStore = useGameStore()
|
||||
const zoneEditorStore = useZoneEditorStore()
|
||||
|
||||
const name = ref('')
|
||||
@ -47,7 +47,7 @@ const width = ref(0)
|
||||
const height = ref(0)
|
||||
|
||||
function submit() {
|
||||
socket.connection.emit('gm:zone_editor:zone:create', { name: name.value, width: width.value, height: height.value }, (response: Zone[]) => {
|
||||
gameStore.connection.emit('gm:zone_editor:zone:create', { name: name.value, width: width.value, height: height.value }, (response: Zone[]) => {
|
||||
zoneEditorStore.setZoneList(response)
|
||||
})
|
||||
zoneEditorStore.toggleCreateZoneModal()
|
||||
|
@ -50,11 +50,11 @@
|
||||
import config from '@/config'
|
||||
import { ref, onMounted, computed, watch } from 'vue'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useGameStore } from '@/stores/game'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import type { Object } from '@/types'
|
||||
|
||||
const socket = useSocketStore()
|
||||
const gameStore = useGameStore()
|
||||
const isModalOpen = ref(false)
|
||||
const zoneEditorStore = useZoneEditorStore()
|
||||
const searchQuery = ref('')
|
||||
@ -77,7 +77,7 @@ onMounted(async () => {
|
||||
zoneEditorStore.setObjectDepth(0)
|
||||
|
||||
isModalOpen.value = true
|
||||
socket.connection.emit('gm:object:list', {}, (response: Object[]) => {
|
||||
gameStore.connection.emit('gm:object:list', {}, (response: Object[]) => {
|
||||
zoneEditorStore.setObjectList(response)
|
||||
})
|
||||
})
|
||||
|
@ -46,11 +46,11 @@
|
||||
import config from '@/config'
|
||||
import { ref, onMounted, computed, watch } from 'vue'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useGameStore } from '@/stores/game'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import type { Tile } from '@/types'
|
||||
|
||||
const socket = useSocketStore()
|
||||
const gameStore = useGameStore()
|
||||
const isModalOpen = ref(false)
|
||||
const zoneEditorStore = useZoneEditorStore()
|
||||
const searchQuery = ref('')
|
||||
@ -66,7 +66,7 @@ const filteredTiles = computed(() => {
|
||||
|
||||
onMounted(async () => {
|
||||
isModalOpen.value = true
|
||||
socket.connection.emit('gm:tile:list', {}, (response: Tile[]) => {
|
||||
gameStore.connection.emit('gm:tile:list', {}, (response: Tile[]) => {
|
||||
zoneEditorStore.setTileList(response)
|
||||
})
|
||||
})
|
||||
|
@ -22,7 +22,7 @@ import config from '@/config'
|
||||
import { Container, Image, TilemapLayer as TilemapLayerC, useScene } from 'phavuer'
|
||||
import { onBeforeMount, onBeforeUnmount, ref, toRaw, watch } from 'vue'
|
||||
import Controls from '@/components/utilities/Controls.vue'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useGameStore } from '@/stores/game'
|
||||
import Toolbar from '@/components/utilities/zoneEditor/Toolbar.vue'
|
||||
import Tiles from '@/components/utilities/zoneEditor/Tiles.vue'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
@ -43,7 +43,7 @@ function uuidv4() {
|
||||
}
|
||||
|
||||
const scene = useScene()
|
||||
const socket = useSocketStore()
|
||||
const gameStore = useGameStore()
|
||||
const zoneEditorStore = useZoneEditorStore()
|
||||
const assetStore = useAssetStore()
|
||||
|
||||
@ -192,9 +192,9 @@ function save() {
|
||||
}))
|
||||
};
|
||||
|
||||
socket.connection.emit('gm:zone_editor:zone:update', data);
|
||||
gameStore.connection.emit('gm:zone_editor:zone:update', data);
|
||||
|
||||
socket.connection.emit('gm:zone_editor:zone:request', { zoneId: zoneEditorStore.zone.id }, (response: Zone) => {
|
||||
gameStore.connection.emit('gm:zone_editor:zone:request', { zoneId: zoneEditorStore.zone.id }, (response: Zone) => {
|
||||
zoneEditorStore.setZone(response)
|
||||
});
|
||||
|
||||
|
@ -30,13 +30,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useSocketStore } from '@/stores/socket'
|
||||
import { useGameStore } from '@/stores/game'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import type { Zone } from '@/types'
|
||||
import { useZoneEditorStore } from '@/stores/zoneEditor'
|
||||
import CreateZone from '@/components/utilities/zoneEditor/CreateZone.vue'
|
||||
|
||||
const socket = useSocketStore()
|
||||
const gameStore = useGameStore()
|
||||
const zoneEditorStore = useZoneEditorStore()
|
||||
|
||||
onMounted(async () => {
|
||||
@ -44,21 +44,21 @@ onMounted(async () => {
|
||||
})
|
||||
|
||||
function fetchZones() {
|
||||
socket.connection.emit('gm:zone_editor:zone:list', {}, (response: Zone[]) => {
|
||||
gameStore.connection.emit('gm:zone_editor:zone:list', {}, (response: Zone[]) => {
|
||||
zoneEditorStore.setZoneList(response)
|
||||
})
|
||||
}
|
||||
|
||||
function loadZone(id: number) {
|
||||
console.log('loadZone', id)
|
||||
socket.connection.emit('gm:zone_editor:zone:request', { zoneId: id }, (response: Zone) => {
|
||||
gameStore.connection.emit('gm:zone_editor:zone:request', { zoneId: id }, (response: Zone) => {
|
||||
zoneEditorStore.setZone(response)
|
||||
});
|
||||
zoneEditorStore.toggleZoneListModal()
|
||||
}
|
||||
|
||||
function deleteZone(id: number) {
|
||||
socket.connection.emit('gm:zone_editor:zone:delete', { zoneId: id }, () => {
|
||||
gameStore.connection.emit('gm:zone_editor:zone:delete', { zoneId: id }, () => {
|
||||
fetchZones()
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user