Update ProjectSequencesPanel to support adding control effects

This commit is contained in:
2026-04-15 07:38:36 +02:00
parent 053ebc84be
commit d6c81008fe

View File

@@ -41,7 +41,11 @@ interface ProjectSequencesPanelProps {
onAddSequence(): void; onAddSequence(): void;
onDeleteSequence(sequenceId: string): void; onDeleteSequence(sequenceId: string): void;
onSetSequenceTitle(sequenceId: string, title: string): void; onSetSequenceTitle(sequenceId: string, title: string): void;
onAddControlStep(sequenceId: string, targetKey: string): void; onAddControlEffect(
sequenceId: string,
targetKey: string,
effectOptionId: ProjectScheduleEffectOptionId
): void;
onAddDialogueStep(sequenceId: string, dialogueId: string): void; onAddDialogueStep(sequenceId: string, dialogueId: string): void;
onAddTeleportStep(sequenceId: string, targetEntityId: string): void; onAddTeleportStep(sequenceId: string, targetEntityId: string): void;
onAddSceneTransitionStep(sequenceId: string, targetKey: string): void; onAddSceneTransitionStep(sequenceId: string, targetKey: string): void;
@@ -172,7 +176,7 @@ export function ProjectSequencesPanel({
onAddSequence, onAddSequence,
onDeleteSequence, onDeleteSequence,
onSetSequenceTitle, onSetSequenceTitle,
onAddControlStep, onAddControlEffect,
onAddDialogueStep, onAddDialogueStep,
onAddTeleportStep, onAddTeleportStep,
onAddSceneTransitionStep, onAddSceneTransitionStep,
@@ -198,12 +202,24 @@ export function ProjectSequencesPanel({
const editableTargetOptions = targetOptions.filter( const editableTargetOptions = targetOptions.filter(
(targetOption) => listProjectScheduleEffectOptions(targetOption).length > 0 (targetOption) => listProjectScheduleEffectOptions(targetOption).length > 0
); );
const defaultControlTargetKey = const preferredControlTargetOption =
editableTargetOptions.find( editableTargetOptions.find(
(targetOption) => targetOption.key === preferredControlTargetKey (targetOption) => targetOption.key === preferredControlTargetKey
)?.key ?? ) ?? null;
editableTargetOptions[0]?.key ?? const addableControlTargetOptions =
""; preferredControlTargetOption === null
? editableTargetOptions
: [preferredControlTargetOption];
const addableControlEffects = addableControlTargetOptions.flatMap((targetOption) =>
listProjectScheduleEffectOptions(targetOption).map((effectOption) => ({
targetKey: targetOption.key,
effectOptionId: effectOption.id,
label:
preferredControlTargetOption === null
? `Add ${targetOption.label} ${effectOption.label} Effect`
: `Add ${effectOption.label} Effect`
}))
);
const selectedSequence = const selectedSequence =
selectedSequenceId === null selectedSequenceId === null
? null ? null
@@ -765,19 +781,22 @@ export function ProjectSequencesPanel({
)} )}
<div className="inline-actions"> <div className="inline-actions">
{addableControlEffects.map((effectButton) => (
<button <button
key={`${effectButton.targetKey}:${effectButton.effectOptionId}`}
className="toolbar__button toolbar__button--compact" className="toolbar__button toolbar__button--compact"
type="button" type="button"
disabled={editableTargetOptions.length === 0}
onClick={() => onClick={() =>
onAddControlStep( onAddControlEffect(
selectedSequence.id, selectedSequence.id,
defaultControlTargetKey effectButton.targetKey,
effectButton.effectOptionId
) )
} }
> >
Add Effect {effectButton.label}
</button> </button>
))}
<button <button
className="toolbar__button toolbar__button--compact" className="toolbar__button toolbar__button--compact"
type="button" type="button"