Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 2,723 Bytes
932a7fd 241036e 932a7fd 8c5d17c 932a7fd 241036e 932a7fd 8c5d17c 932a7fd 241036e 8c5d17c 932a7fd 241036e 8c5d17c 932a7fd 241036e 932a7fd 241036e 932a7fd 8c5d17c 932a7fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
"use client"
import { create } from "zustand"
import { FontName } from "@/lib/fonts"
import { Preset, getPreset } from "@/app/engine/presets"
import { LayoutName, getRandomLayoutName } from "../layouts"
export const useStore = create<{
prompt: string
font: FontName
preset: Preset
panels: string[]
captions: Record<string, string>
layout: LayoutName
zoomLevel: number
isGeneratingLogic: boolean
panelGenerationStatus: Record<number, boolean>
isGeneratingText: boolean
atLeastOnePanelIsBusy: boolean
setPrompt: (prompt: string) => void
setFont: (font: FontName) => void
setPreset: (preset: Preset) => void
setPanels: (panels: string[]) => void
setLayout: (layout: LayoutName) => void
setCaption: (panelId: number, caption: string) => void
setZoomLevel: (zoomLevel: number) => void
setGeneratingLogic: (isGeneratingLogic: boolean) => void
setGeneratingImages: (panelId: number, value: boolean) => void
setGeneratingText: (isGeneratingText: boolean) => void
}>((set, get) => ({
prompt: "",
font: "cartoonist",
preset: getPreset("japanese_manga"),
panels: [],
captions: {},
layout: getRandomLayoutName(),
zoomLevel: 50,
isGeneratingLogic: false,
panelGenerationStatus: {},
isGeneratingText: false,
atLeastOnePanelIsBusy: false,
setPrompt: (prompt: string) => {
const existingPrompt = get().prompt
if (prompt === existingPrompt) { return }
set({
prompt,
panels: [],
captions: {},
})
},
setFont: (font: FontName) => {
const existingFont = get().font
if (font === existingFont) { return }
set({
font,
panels: [],
captions: {}
})
},
setPreset: (preset: Preset) => {
const existingPreset = get().preset
if (preset.label === existingPreset.label) { return }
set({
preset,
panels: [],
captions: {}
})
},
setPanels: (panels: string[]) => set({ panels }),
setCaption: (panelId: number, caption: string) => {
set({
captions: {
...get().captions,
[panelId]: caption
}
})
},
setLayout: (layout: LayoutName) => set({ layout }),
setZoomLevel: (zoomLevel: number) => set({ zoomLevel }),
setGeneratingLogic: (isGeneratingLogic: boolean) => set({ isGeneratingLogic }),
setGeneratingImages: (panelId: number, value: boolean) => {
const panelGenerationStatus: Record<number, boolean> = {
...get().panelGenerationStatus,
[panelId]: value
}
const atLeastOnePanelIsBusy = Object.values(panelGenerationStatus).includes(true)
set({
panelGenerationStatus,
atLeastOnePanelIsBusy
})
},
setGeneratingText: (isGeneratingText: boolean) => set({ isGeneratingText }),
}))
|