Minor improvement

This commit is contained in:
Dennis Postma 2024-09-29 16:07:55 +02:00
parent df3b9db45d
commit 1f46b94441
3 changed files with 57 additions and 51 deletions

View File

@ -5,23 +5,25 @@ import config from '@/config'
import { useCookies } from '@vueuse/integrations/useCookies' import { useCookies } from '@vueuse/integrations/useCookies'
export const useGameStore = defineStore('game', { export const useGameStore = defineStore('game', {
state: () => ({ state: () => {
notifications: [] as Notification[], return {
assets: [] as Asset[], notifications: [] as Notification[],
token: '' as string | null, assets: [] as Asset[],
connection: null as Socket | null, token: '' as string | null,
user: null as User | null, connection: null as Socket | null,
character: null as Character | null, user: null as User | null,
isPlayerDraggingCamera: false, character: null as Character | null,
gameSettings: { isPlayerDraggingCamera: false,
isCameraFollowingCharacter: false gameSettings: {
}, isCameraFollowingCharacter: false
uiSettings: { },
isChatOpen: false, uiSettings: {
isUserPanelOpen: false, isChatOpen: false,
isGmPanelOpen: false isUserPanelOpen: false,
isGmPanelOpen: false
}
} }
}), },
getters: { getters: {
getNotifications: (state: any) => state.notifications, getNotifications: (state: any) => state.notifications,
getAssetByKey: (state) => { getAssetByKey: (state) => {

View File

@ -10,37 +10,39 @@ type TeleportSettings = {
} }
export const useZoneEditorStore = defineStore('zoneEditor', { export const useZoneEditorStore = defineStore('zoneEditor', {
state: () => ({ state: () => {
active: false, return {
zone: null as Zone | null, active: false,
tool: 'move', zone: null as Zone | null,
drawMode: 'tile', tool: 'move',
eraserMode: 'tile', drawMode: 'tile',
zoneList: [] as Zone[], eraserMode: 'tile',
tileList: [] as Tile[], zoneList: [] as Zone[],
objectList: [] as Object[], tileList: [] as Tile[],
selectedTile: null as Tile | null, objectList: [] as Object[],
selectedObject: null as Object | null, selectedTile: null as Tile | null,
selectedZoneObject: null as ZoneObject | null, selectedObject: null as Object | null,
objectDepth: 0, selectedZoneObject: null as ZoneObject | null,
isTileListModalShown: false, objectDepth: 0,
isObjectListModalShown: false, isTileListModalShown: false,
isZoneListModalShown: false, isObjectListModalShown: false,
isCreateZoneModalShown: false, isZoneListModalShown: false,
isSettingsModalShown: false, isCreateZoneModalShown: false,
zoneSettings: { isSettingsModalShown: false,
name: '', zoneSettings: {
width: 0, name: '',
height: 0, width: 0,
pvp: false height: 0,
}, pvp: false
teleportSettings: { },
toZoneId: 0, teleportSettings: {
toPositionX: 0, toZoneId: 0,
toPositionY: 0, toPositionX: 0,
toRotation: 0 toPositionY: 0,
toRotation: 0
}
} }
}), },
actions: { actions: {
toggleActive() { toggleActive() {
const gameStore = useGameStore() const gameStore = useGameStore()

View File

@ -2,11 +2,13 @@ import { defineStore } from 'pinia'
import type { ExtendedCharacter, Zone } from '@/types' import type { ExtendedCharacter, Zone } from '@/types'
export const useZoneStore = defineStore('zone', { export const useZoneStore = defineStore('zone', {
state: () => ({ state: () => {
zone: null as Zone | null, return {
characters: [] as ExtendedCharacter[], zone: null as Zone | null,
characterLoaded: false characters: [] as ExtendedCharacter[],
}), characterLoaded: false
}
},
getters: { getters: {
getCharacterById: (state) => { getCharacterById: (state) => {
return (id: number) => state.characters.find((char) => char.id === id) return (id: number) => state.characters.find((char) => char.id === id)