minecraft-clone / src /stores /uiStore.ts
TomatitoToho's picture
Upload src/stores/uiStore.ts with huggingface_hub
370a1ce verified
Raw
History Blame Contribute Delete
933 Bytes
'use client'
import { create } from 'zustand'
interface UIStore {
hotbarSlot: number
showInventory: boolean
showPause: boolean
showChat: boolean
chatMessages: string[]
setHotbarSlot: (slot: number) => void
toggleInventory: () => void
togglePause: () => void
addChatMessage: (msg: string) => void
setShowInventory: (v: boolean) => void
setShowPause: (v: boolean) => void
}
export const useUIStore = create<UIStore>((set, get) => ({
hotbarSlot: 0,
showInventory: false,
showPause: false,
showChat: false,
chatMessages: [],
setHotbarSlot: (slot) => set({ hotbarSlot: slot }),
toggleInventory: () => set(s => ({ showInventory: !s.showInventory })),
togglePause: () => set(s => ({ showPause: !s.showPause })),
addChatMessage: (msg) => set(s => ({ chatMessages: [...s.chatMessages, msg] })),
setShowInventory: (v) => set({ showInventory: v }),
setShowPause: (v) => set({ showPause: v }),
}))