Refactor sequence step handling to use clips
This commit is contained in:
@@ -197,7 +197,7 @@ import {
|
|||||||
createProjectSequence,
|
createProjectSequence,
|
||||||
type ProjectSequenceLibrary
|
type ProjectSequenceLibrary
|
||||||
} from "../sequencer/project-sequences";
|
} from "../sequencer/project-sequences";
|
||||||
import type { SequenceStep } from "../sequencer/project-sequence-steps";
|
import type { SequenceClip } from "../sequencer/project-sequence-steps";
|
||||||
import {
|
import {
|
||||||
createScenePath,
|
createScenePath,
|
||||||
createScenePathPoint,
|
createScenePathPoint,
|
||||||
@@ -3517,7 +3517,7 @@ function readProjectDialogueLibrary(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function readProjectSequenceStep(value: unknown, label: string): SequenceStep {
|
function readProjectSequenceClip(value: unknown, label: string): SequenceClip {
|
||||||
if (!isRecord(value)) {
|
if (!isRecord(value)) {
|
||||||
throw new Error(`${label} must be an object.`);
|
throw new Error(`${label} must be an object.`);
|
||||||
}
|
}
|
||||||
@@ -3574,7 +3574,7 @@ function readProjectSequenceStep(value: unknown, label: string): SequenceStep {
|
|||||||
: expectBoolean(value.visible, `${label}.visible`)
|
: expectBoolean(value.visible, `${label}.visible`)
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
throw new Error(`${label}.type must be a supported sequence step.`);
|
throw new Error(`${label}.type must be a supported sequence clip.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3606,10 +3606,14 @@ function readProjectSequenceLibrary(
|
|||||||
throw new Error(`${label}.sequences.${sequenceKey} must be an object.`);
|
throw new Error(`${label}.sequences.${sequenceKey} must be an object.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const stepsValue = sequenceValue.steps;
|
const clipsValue = Array.isArray(sequenceValue.clips)
|
||||||
|
? sequenceValue.clips
|
||||||
|
: sequenceValue.steps;
|
||||||
|
|
||||||
if (!Array.isArray(stepsValue)) {
|
if (!Array.isArray(clipsValue)) {
|
||||||
throw new Error(`${label}.sequences.${sequenceKey}.steps must be an array.`);
|
throw new Error(
|
||||||
|
`${label}.sequences.${sequenceKey}.clips must be an array.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sequences[sequenceKey] = createProjectSequence({
|
sequences[sequenceKey] = createProjectSequence({
|
||||||
@@ -3618,10 +3622,10 @@ function readProjectSequenceLibrary(
|
|||||||
sequenceValue.title,
|
sequenceValue.title,
|
||||||
`${label}.sequences.${sequenceKey}.title`
|
`${label}.sequences.${sequenceKey}.title`
|
||||||
),
|
),
|
||||||
steps: stepsValue.map((stepValue, stepIndex) =>
|
clips: clipsValue.map((clipValue, clipIndex) =>
|
||||||
readProjectSequenceStep(
|
readProjectSequenceClip(
|
||||||
stepValue,
|
clipValue,
|
||||||
`${label}.sequences.${sequenceKey}.steps.${stepIndex}`
|
`${label}.sequences.${sequenceKey}.clips.${clipIndex}`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4805,40 +4805,40 @@ function validateProjectSequence(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sequence.steps.length === 0) {
|
if (sequence.clips.length === 0) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
"error",
|
"error",
|
||||||
"invalid-project-sequence-steps-empty",
|
"invalid-project-sequence-clips-empty",
|
||||||
"Project sequences must contain at least one step.",
|
"Project sequences must contain at least one clip.",
|
||||||
`${path}.steps`
|
`${path}.clips`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [stepIndex, step] of sequence.steps.entries()) {
|
for (const [clipIndex, clip] of sequence.clips.entries()) {
|
||||||
const stepPath = `${path}.steps.${stepIndex}`;
|
const clipPath = `${path}.clips.${clipIndex}`;
|
||||||
|
|
||||||
switch (step.type) {
|
switch (clip.type) {
|
||||||
case "controlEffect":
|
case "controlEffect":
|
||||||
validateProjectSchedulerEffect(
|
validateProjectSchedulerEffect(
|
||||||
step.effect,
|
clip.effect,
|
||||||
`${stepPath}.effect`,
|
`${clipPath}.effect`,
|
||||||
context,
|
context,
|
||||||
diagnostics
|
diagnostics
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "startDialogue":
|
case "startDialogue":
|
||||||
if (
|
if (
|
||||||
projectResources.dialogues.dialogues[step.dialogueId] === undefined
|
projectResources.dialogues.dialogues[clip.dialogueId] === undefined
|
||||||
) {
|
) {
|
||||||
diagnostics.push(
|
diagnostics.push(
|
||||||
createDiagnostic(
|
createDiagnostic(
|
||||||
"error",
|
"error",
|
||||||
"missing-sequence-dialogue-resource",
|
"missing-sequence-dialogue-resource",
|
||||||
`Dialogue ${step.dialogueId} does not exist in the project dialogue library.`,
|
`Dialogue ${clip.dialogueId} does not exist in the project dialogue library.`,
|
||||||
`${stepPath}.dialogueId`
|
`${clipPath}.dialogueId`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ import {
|
|||||||
type ProjectSequenceLibrary
|
type ProjectSequenceLibrary
|
||||||
} from "../sequencer/project-sequences";
|
} from "../sequencer/project-sequences";
|
||||||
|
|
||||||
export const SCENE_DOCUMENT_VERSION = 53 as const;
|
export const SCENE_DOCUMENT_VERSION = 54 as const;
|
||||||
|
export const PROJECT_SEQUENCE_CLIPS_SCENE_DOCUMENT_VERSION = 54 as const;
|
||||||
export const PROJECT_SEQUENCE_LIBRARY_SCENE_DOCUMENT_VERSION = 53 as const;
|
export const PROJECT_SEQUENCE_LIBRARY_SCENE_DOCUMENT_VERSION = 53 as const;
|
||||||
export const PLAYER_START_PAUSE_BINDINGS_SCENE_DOCUMENT_VERSION = 52 as const;
|
export const PLAYER_START_PAUSE_BINDINGS_SCENE_DOCUMENT_VERSION = 52 as const;
|
||||||
export const NPC_DIALOGUE_REFERENCE_SCENE_DOCUMENT_VERSION = 51 as const;
|
export const NPC_DIALOGUE_REFERENCE_SCENE_DOCUMENT_VERSION = 51 as const;
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import { createOpaqueId } from "../core/ids";
|
import { createOpaqueId } from "../core/ids";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
cloneSequenceStep,
|
cloneSequenceClip,
|
||||||
|
type SequenceClip,
|
||||||
type SequenceStep
|
type SequenceStep
|
||||||
} from "./project-sequence-steps";
|
} from "./project-sequence-steps";
|
||||||
|
|
||||||
export interface ProjectSequence {
|
export interface ProjectSequence {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
steps: SequenceStep[];
|
clips: SequenceClip[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProjectSequenceLibrary {
|
export interface ProjectSequenceLibrary {
|
||||||
@@ -33,13 +34,14 @@ export function createEmptyProjectSequenceLibrary(): ProjectSequenceLibrary {
|
|||||||
|
|
||||||
export function createProjectSequence(
|
export function createProjectSequence(
|
||||||
overrides: Partial<Pick<ProjectSequence, "id" | "title">> & {
|
overrides: Partial<Pick<ProjectSequence, "id" | "title">> & {
|
||||||
|
clips?: SequenceClip[];
|
||||||
steps?: SequenceStep[];
|
steps?: SequenceStep[];
|
||||||
} = {}
|
} = {}
|
||||||
): ProjectSequence {
|
): ProjectSequence {
|
||||||
return {
|
return {
|
||||||
id: overrides.id ?? createOpaqueId("sequence"),
|
id: overrides.id ?? createOpaqueId("sequence"),
|
||||||
title: normalizeProjectSequenceTitle(overrides.title ?? "Sequence"),
|
title: normalizeProjectSequenceTitle(overrides.title ?? "Sequence"),
|
||||||
steps: overrides.steps?.map(cloneSequenceStep) ?? []
|
clips: (overrides.clips ?? overrides.steps)?.map(cloneSequenceClip) ?? []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ export function cloneProjectSequence(
|
|||||||
return {
|
return {
|
||||||
id: sequence.id,
|
id: sequence.id,
|
||||||
title: sequence.title,
|
title: sequence.title,
|
||||||
steps: sequence.steps.map(cloneSequenceStep)
|
clips: sequence.clips.map(cloneSequenceClip)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,19 +75,19 @@ export function areProjectSequencesEqual(
|
|||||||
if (
|
if (
|
||||||
left.id !== right.id ||
|
left.id !== right.id ||
|
||||||
left.title !== right.title ||
|
left.title !== right.title ||
|
||||||
left.steps.length !== right.steps.length
|
left.clips.length !== right.clips.length
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return left.steps.every((step, index) => {
|
return left.clips.every((clip, index) => {
|
||||||
const rightStep = right.steps[index];
|
const rightClip = right.clips[index];
|
||||||
|
|
||||||
if (rightStep === undefined) {
|
if (rightClip === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.stringify(step) === JSON.stringify(rightStep);
|
return JSON.stringify(clip) === JSON.stringify(rightClip);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user