import { SetFlagNode, FlagEffect } from '../../../types/dialogue'; import { useDialogueStore } from '../../../store/dialogueStore'; import { useValidation } from '../../../hooks/useValidation'; import styles from '../RightPanel.module.css'; interface Props { node: SetFlagNode; dialogueId: string; } export function SetFlagInspector({ node, dialogueId }: Props) { const { updateNode, deleteNode, file } = useDialogueStore(); const { issuesByNodeId } = useValidation(); const issues = issuesByNodeId[node.id] ?? []; const dialogue = file?.dialogues.find(d => d.id === dialogueId); const nodeIds = dialogue?.nodes.map(n => n.id) ?? []; function updateEffect(idx: number, patch: Partial) { const effects = node.effects.map((e, i) => i === idx ? { ...e, ...patch } : e); updateNode(dialogueId, node.id, { effects }); } function addEffect() { const effects: FlagEffect[] = [...node.effects, { flag: '', value: 1 }]; updateNode(dialogueId, node.id, { effects }); } function removeEffect(idx: number) { const effects = node.effects.filter((_, i) => i !== idx); updateNode(dialogueId, node.id, { effects }); } return (
SetFlag {node.id}
{issues.length > 0 && (
{issues.map((issue, i) => (
{issue.severity === 'error' ? 'âš ' : '!'} {issue.message}
))}
)}
Flag Effects
{node.effects.map((e, idx) => (
updateEffect(idx, { flag: ev.target.value })} /> = updateEffect(idx, { value: isNaN(Number(ev.target.value)) ? ev.target.value : Number(ev.target.value) })} />
))} {node.effects.length === 0 &&
No effects defined.
}
updateNode(dialogueId, node.id, { next: e.target.value })} list={`nodelist-sf-${node.id}`} /> {nodeIds.map(id =>
); }