import { AnimatePresence, motion } from 'motion/react'; import { useEffect, useRef } from 'react'; import type { CharacterChatModalState } from '../hooks/rpg-runtime-story'; import { getNineSliceStyle, UI_CHROME } from '../uiAssets'; import { PlatformActionButton } from './common/PlatformActionButton'; import { PlatformDarkOptionCard } from './common/PlatformDarkOptionCard'; import { PlatformEmptyState } from './common/PlatformEmptyState'; import { PlatformStatusMessage } from './common/PlatformStatusMessage'; import { PlatformSubpanel } from './common/PlatformSubpanel'; import { PlatformTextField } from './common/PlatformTextField'; import { PixelCloseButton } from './PixelCloseButton'; interface CharacterChatModalProps { modal: CharacterChatModalState | null; onClose: () => void; onDraftChange: (value: string) => void; onUseSuggestion: (value: string) => void; onRefreshSuggestions: () => void; onSendDraft: () => void; } export function CharacterChatModal({ modal, onClose, onDraftChange, onUseSuggestion, onRefreshSuggestions, onSendDraft, }: CharacterChatModalProps) { const scrollContainerRef = useRef(null); useEffect(() => { if (!modal || !scrollContainerRef.current) return; scrollContainerRef.current.scrollTop = scrollContainerRef.current.scrollHeight; }, [modal]); return ( {modal && ( event.stopPropagation()} >
角色聊天
{modal.target.character.name}
{modal.target.character.title} / {modal.target.roleLabel}
角色状态
生命值 {modal.target.hp} / {modal.target.maxHp} 内力 {modal.target.mana} / {modal.target.maxMana} {modal.target.character.personality}
聊天总结
{modal.summary || '你们还没有形成新的私下聊天总结。'}
{modal.messages.length > 0 ? ( modal.messages.map((message, index) => (
{message.speaker === 'player' ? '你' : modal.target.character.name}
{message.text || (modal.isSending && message.speaker === 'character' ? '正在回复...' : '...')}
)) ) : ( 这里会保留你和该角色的私下聊天记录。输入框支持自由发挥,上方三条文本可以帮你快速起句。 )}
帮你回复
{modal.isLoadingSuggestions ? '生成中...' : '换一组'}
{modal.suggestions.map((suggestion, index) => ( onUseSuggestion(suggestion)} disabled={modal.isSending} selected={false} tone="sky" radius="md" padding="sm" className="text-xs leading-relaxed" > {suggestion} ))}
{modal.error && ( {modal.error} )}
{ event.preventDefault(); onSendDraft(); }} > onDraftChange(event.target.value)} placeholder={`对${modal.target.character.name}说点什么...`} disabled={modal.isSending} rows={4} surface="editorDark" tone="sky" size="md" density="roomy" className="rounded-2xl bg-black/25 leading-relaxed text-zinc-100 focus:border-sky-300/35" />
)}
); }