import { AnimatePresence, motion } from 'motion/react'; import type { ReactNode } from 'react'; import { CHROME_ICONS, getNineSliceStyle, UI_CHROME } from '../uiAssets'; import { PixelIcon } from './PixelIcon'; interface CustomWorldCreatorModalProps { isOpen: boolean; draft: string; onDraftChange: (value: string) => void; onClose: () => void; onSubmit: () => void; isGenerating: boolean; progress: number; progressLabel: string; error: string | null; } interface CharacterDraftModalProps { isOpen: boolean; characterLabel: string; draftName: string; draftBackstory: string; onNameChange: (value: string) => void; onBackstoryChange: (value: string) => void; onClose: () => void; onConfirm: () => void; error: string | null; } function ModalShell({ isOpen, title, subtitle, onClose, disableClose = false, children, }: { isOpen: boolean; title: string; subtitle?: string; onClose: () => void; disableClose?: boolean; children: ReactNode; }) { return ( {isOpen && ( event.stopPropagation()} > {title} {subtitle ? ( {subtitle} ) : null} {children} )} ); } export function CustomWorldCreatorModal({ isOpen, draft, onDraftChange, onClose, onSubmit, isGenerating, progress, progressLabel, error, }: CustomWorldCreatorModalProps) { return ( 世界设定文本 onDraftChange(event.target.value)} disabled={isGenerating} placeholder="例如:一个被古老机关城与修真宗门共同争夺的边境世界,灵气潮汐会周期性改写地形,玩家需要在多个势力之间周旋,寻找导致世界裂缝扩大的真正原因。" className="min-h-[22rem] w-full resize-none rounded-[1.75rem] border border-transparent bg-black/18 px-5 py-4 text-sm leading-7 text-zinc-100 outline-none transition-[background-color,box-shadow] placeholder:text-zinc-500 focus:bg-black/24 focus:shadow-[inset_0_0_0_1px_rgba(125,211,252,0.22)]" /> {(isGenerating || progress > 0) && ( {progressLabel} {Math.round(progress)}% )} {error ? ( {error} ) : null} 取消 {isGenerating ? '正在生成世界...' : '确认并开始生成'} {isGenerating ? '...' : '→'} ); } export function CharacterDraftModal({ isOpen, characterLabel, draftName, draftBackstory, onNameChange, onBackstoryChange, onClose, onConfirm, error, }: CharacterDraftModalProps) { return ( 这里的修改会直接带入本轮开场、剧情提示词和后续角色展示,不会改动原始预设。 角色名称 onNameChange(event.target.value)} placeholder="输入新的角色名称" className="w-full rounded-2xl border border-white/10 bg-black/25 px-4 py-3 text-sm text-zinc-100 outline-none transition-colors placeholder:text-zinc-500 focus:border-sky-300/35" /> 角色背景故事 onBackstoryChange(event.target.value)} placeholder="写下这名角色进入世界前后的经历、动机、执念、秘密或人与人之间的纠葛。" className="min-h-44 w-full rounded-2xl border border-white/10 bg-black/25 px-4 py-3 text-sm leading-7 text-zinc-100 outline-none transition-colors placeholder:text-zinc-500 focus:border-sky-300/35" /> {error ? ( {error} ) : null} 取消 保存修改 → ); }