npm update, improved gameStore structure

This commit is contained in:
2024-09-29 15:12:20 +02:00
parent c31dada1f9
commit d214bd37ad
5 changed files with 23 additions and 18 deletions

View File

@ -1,5 +1,5 @@
<template>
<Modal :isModalOpen="gameStore.isGmPanelOpen" @modal:close="() => gameStore.toggleGmPanel()" :modal-width="1000" :modal-height="650" :can-full-screen="true">
<Modal :isModalOpen="gameStore.uiSettings.isGmPanelOpen" @modal:close="() => gameStore.toggleGmPanel()" :modal-width="1000" :modal-height="650" :can-full-screen="true">
<template #modalHeader>
<h3 class="m-0 font-medium shrink-0">GM Panel</h3>
<div class="flex gap-1.5 flex-wrap">

View File

@ -1,6 +1,6 @@
<template>
<div class="w-full md:min-w-[350px] max-w-[750px] flex flex-col">
<div ref="chatWindow" class="w-full overflow-auto h-32 mb-5 bg-gray-300/80 rounded-lg border-2 border-solid border-cyan-200" v-show="gameStore.isChatOpen">
<div ref="chatWindow" class="w-full overflow-auto h-32 mb-5 bg-gray-300/80 rounded-lg border-2 border-solid border-cyan-200" v-show="gameStore.uiSettings.isChatOpen">
<div v-for="message in chats" class="flex-col py-2 items-center p-3">
<span class="text-ellipsis overflow-hidden whitespace-nowrap text-sm">{{ message.character.name }}</span>
<p class="text-gray-50 m-0">{{ message.message }}</p>

View File

@ -1,5 +1,5 @@
<template>
<div class="absolute z-50 w-full h-dvh top-0 left-0 bg-black/60" v-show="gameStore.isUserPanelOpen">
<div class="absolute z-50 w-full h-dvh top-0 left-0 bg-black/60" v-show="gameStore.uiSettings.isUserPanelOpen">
<div class="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 max-w-[875px] max-h-[600px] h-full w-[80%] bg-gray-300/80 border-solid border-2 border-cyan-200 rounded-lg z-50 flex flex-col backdrop-blur-sm shadow-lg">
<div class="p-2.5 flex max-sm:flex-wrap justify-between items-center gap-5 border-solid border-0 border-b border-cyan-200">
<h3 class="m-0 font-medium shrink-0">Game menu</h3>

View File

@ -12,11 +12,15 @@ export const useGameStore = defineStore('game', {
connection: null as Socket | null,
user: null as User | null,
character: null as Character | null,
isGmPanelOpen: false,
isPlayerDraggingCamera: false,
isCameraFollowingCharacter: false,
isChatOpen: false,
isUserPanelOpen: false
gameSettings: {
isCameraFollowingCharacter: false
},
uiSettings: {
isChatOpen: false,
isUserPanelOpen: false,
isGmPanelOpen: false
}
}),
getters: {
getNotifications: (state: any) => state.notifications,
@ -92,7 +96,7 @@ export const useGameStore = defineStore('game', {
this.character = character
},
toggleGmPanel() {
this.isGmPanelOpen = !this.isGmPanelOpen
this.uiSettings.isGmPanelOpen = !this.uiSettings.isGmPanelOpen
},
togglePlayerDraggingCamera() {
this.isPlayerDraggingCamera = !this.isPlayerDraggingCamera
@ -101,16 +105,16 @@ export const useGameStore = defineStore('game', {
this.isPlayerDraggingCamera = moving
},
toggleCameraFollowingCharacter() {
this.isCameraFollowingCharacter = !this.isCameraFollowingCharacter
this.gameSettings.isCameraFollowingCharacter = !this.gameSettings.isCameraFollowingCharacter
},
setCameraFollowingCharacter(following: boolean) {
this.isCameraFollowingCharacter = following
this.gameSettings.isCameraFollowingCharacter = following
},
toggleChat() {
this.isChatOpen = !this.isChatOpen
this.uiSettings.isChatOpen = !this.uiSettings.isChatOpen
},
toggleUserPanel() {
this.isUserPanelOpen = !this.isUserPanelOpen
this.uiSettings.isUserPanelOpen = !this.uiSettings.isUserPanelOpen
},
initConnection() {
this.connection = io(config.server_endpoint, {
@ -151,10 +155,11 @@ export const useGameStore = defineStore('game', {
this.token = null
this.user = null
this.character = null
this.isGmPanelOpen = false
this.uiSettings.isGmPanelOpen = false
this.isPlayerDraggingCamera = false
this.isChatOpen = false
this.isUserPanelOpen = false
this.gameSettings.isCameraFollowingCharacter = false
this.uiSettings.isChatOpen = false
this.uiSettings.isUserPanelOpen = false
}
}
})