Refactor ProjectSchedulePane to handle different target kinds and effects
This commit is contained in:
@@ -615,128 +615,266 @@ export function ProjectSchedulePane({
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{selectedEffectOptions.find(
|
{selectedRoutine.target.kind === "actor" ? (
|
||||||
(effectOption) => effectOption.id === selectedEffectOptionId
|
<>
|
||||||
)?.valueKind === "number" ? (
|
<div className="form-section">
|
||||||
<div className="form-section">
|
<div className="label">Animation</div>
|
||||||
<div className="label">Value</div>
|
<label className="form-field">
|
||||||
<label className="form-field">
|
<span className="label">Clip</span>
|
||||||
<span className="label">
|
<select
|
||||||
{selectedEffectOptions.find(
|
className="select-input"
|
||||||
(effectOption) => effectOption.id === selectedEffectOptionId
|
value={selectedActorAnimationEffect?.clipName ?? ""}
|
||||||
)?.valueLabel ?? "Value"}
|
onChange={(event) =>
|
||||||
</span>
|
onSetActorRoutineAnimationClip(
|
||||||
<input
|
selectedRoutine.id,
|
||||||
key={`${selectedRoutine.id}-numeric`}
|
event.currentTarget.value === ""
|
||||||
className="text-input"
|
? null
|
||||||
type="number"
|
: event.currentTarget.value
|
||||||
min={
|
)
|
||||||
selectedEffectOptions.find(
|
}
|
||||||
(effectOption) =>
|
>
|
||||||
effectOption.id === selectedEffectOptionId
|
<option value="">None</option>
|
||||||
)?.min ?? 0
|
{(selectedTargetOption.defaults.actorAnimationClipNames ?? []).map(
|
||||||
}
|
(clipName) => (
|
||||||
step={
|
<option key={clipName} value={clipName}>
|
||||||
selectedEffectOptions.find(
|
{clipName}
|
||||||
(effectOption) =>
|
</option>
|
||||||
effectOption.id === selectedEffectOptionId
|
)
|
||||||
)?.step ?? 0.1
|
)}
|
||||||
}
|
</select>
|
||||||
defaultValue={getRoutineNumericValue(selectedRoutine) ?? 0}
|
</label>
|
||||||
onBlur={(event) =>
|
<label className="form-field form-field--inline">
|
||||||
onSetRoutineNumericValue(
|
<input
|
||||||
selectedRoutine.id,
|
type="checkbox"
|
||||||
Number(event.currentTarget.value)
|
checked={selectedActorAnimationEffect?.loop !== false}
|
||||||
)
|
disabled={selectedActorAnimationEffect === null}
|
||||||
}
|
onChange={(event) =>
|
||||||
onKeyDown={(event) =>
|
onSetActorRoutineAnimationLoop(
|
||||||
handleCommitOnEnter(event, () =>
|
selectedRoutine.id,
|
||||||
onSetRoutineNumericValue(
|
event.currentTarget.checked
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<span className="label">Loop</span>
|
||||||
|
</label>
|
||||||
|
{(selectedTargetOption.defaults.actorAnimationClipNames ?? [])
|
||||||
|
.length === 0 ? (
|
||||||
|
<div className="schedule-pane__summary">
|
||||||
|
Animation clips are available only when this actor has one
|
||||||
|
uniquely bound NPC model with imported clips.
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-section">
|
||||||
|
<div className="label">Path</div>
|
||||||
|
<label className="form-field">
|
||||||
|
<span className="label">Path</span>
|
||||||
|
<select
|
||||||
|
className="select-input"
|
||||||
|
value={selectedActorPathEffect?.pathId ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
onSetActorRoutinePath(
|
||||||
|
selectedRoutine.id,
|
||||||
|
event.currentTarget.value === ""
|
||||||
|
? null
|
||||||
|
: event.currentTarget.value
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<option value="">None</option>
|
||||||
|
{(selectedTargetOption.defaults.actorPathOptions ?? []).map(
|
||||||
|
(pathOption) => (
|
||||||
|
<option key={pathOption.pathId} value={pathOption.pathId}>
|
||||||
|
{pathOption.label}
|
||||||
|
</option>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label className="form-field">
|
||||||
|
<span className="label">Speed</span>
|
||||||
|
<input
|
||||||
|
key={`${selectedRoutine.id}-actor-path-speed`}
|
||||||
|
className="text-input"
|
||||||
|
type="number"
|
||||||
|
min="0.01"
|
||||||
|
step="0.1"
|
||||||
|
defaultValue={
|
||||||
|
selectedActorPathEffect?.speed ??
|
||||||
|
selectedTargetOption.defaults.actorPathSpeed ??
|
||||||
|
1
|
||||||
|
}
|
||||||
|
disabled={selectedActorPathEffect === null}
|
||||||
|
onBlur={(event) =>
|
||||||
|
onSetActorRoutinePathSpeed(
|
||||||
selectedRoutine.id,
|
selectedRoutine.id,
|
||||||
Number(event.currentTarget.value)
|
Number(event.currentTarget.value)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
onKeyDown={(event) =>
|
||||||
/>
|
handleCommitOnEnter(event, () =>
|
||||||
</label>
|
onSetActorRoutinePathSpeed(
|
||||||
</div>
|
selectedRoutine.id,
|
||||||
) : null}
|
Number(event.currentTarget.value)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="form-field form-field--inline">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={selectedActorPathEffect?.loop ?? false}
|
||||||
|
disabled={selectedActorPathEffect === null}
|
||||||
|
onChange={(event) =>
|
||||||
|
onSetActorRoutinePathLoop(
|
||||||
|
selectedRoutine.id,
|
||||||
|
event.currentTarget.checked
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<span className="label">Loop</span>
|
||||||
|
</label>
|
||||||
|
{(selectedTargetOption.defaults.actorPathOptions ?? []).length ===
|
||||||
|
0 ? (
|
||||||
|
<div className="schedule-pane__summary">
|
||||||
|
Paths are available only when this actor has one uniquely
|
||||||
|
bound NPC usage in a scene with enabled authored paths.
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{selectedEffectOptions.find(
|
||||||
|
(effectOption) => effectOption.id === selectedEffectOptionId
|
||||||
|
)?.valueKind === "number" ? (
|
||||||
|
<div className="form-section">
|
||||||
|
<div className="label">Value</div>
|
||||||
|
<label className="form-field">
|
||||||
|
<span className="label">
|
||||||
|
{selectedEffectOptions.find(
|
||||||
|
(effectOption) =>
|
||||||
|
effectOption.id === selectedEffectOptionId
|
||||||
|
)?.valueLabel ?? "Value"}
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
key={`${selectedRoutine.id}-numeric`}
|
||||||
|
className="text-input"
|
||||||
|
type="number"
|
||||||
|
min={
|
||||||
|
selectedEffectOptions.find(
|
||||||
|
(effectOption) =>
|
||||||
|
effectOption.id === selectedEffectOptionId
|
||||||
|
)?.min ?? 0
|
||||||
|
}
|
||||||
|
step={
|
||||||
|
selectedEffectOptions.find(
|
||||||
|
(effectOption) =>
|
||||||
|
effectOption.id === selectedEffectOptionId
|
||||||
|
)?.step ?? 0.1
|
||||||
|
}
|
||||||
|
defaultValue={getRoutineNumericValue(selectedRoutine) ?? 0}
|
||||||
|
onBlur={(event) =>
|
||||||
|
onSetRoutineNumericValue(
|
||||||
|
selectedRoutine.id,
|
||||||
|
Number(event.currentTarget.value)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onKeyDown={(event) =>
|
||||||
|
handleCommitOnEnter(event, () =>
|
||||||
|
onSetRoutineNumericValue(
|
||||||
|
selectedRoutine.id,
|
||||||
|
Number(event.currentTarget.value)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{selectedEffectOptions.find(
|
{selectedEffectOptions.find(
|
||||||
(effectOption) => effectOption.id === selectedEffectOptionId
|
(effectOption) => effectOption.id === selectedEffectOptionId
|
||||||
)?.valueKind === "color" ? (
|
)?.valueKind === "color" ? (
|
||||||
<div className="form-section">
|
<div className="form-section">
|
||||||
<div className="label">Value</div>
|
<div className="label">Value</div>
|
||||||
<label className="form-field">
|
<label className="form-field">
|
||||||
<span className="label">
|
<span className="label">
|
||||||
{selectedEffectOptions.find(
|
{selectedEffectOptions.find(
|
||||||
(effectOption) => effectOption.id === selectedEffectOptionId
|
(effectOption) =>
|
||||||
)?.valueLabel ?? "Color"}
|
effectOption.id === selectedEffectOptionId
|
||||||
</span>
|
)?.valueLabel ?? "Color"}
|
||||||
<input
|
</span>
|
||||||
className="color-input"
|
<input
|
||||||
type="color"
|
className="color-input"
|
||||||
value={getRoutineColorValue(selectedRoutine) ?? "#ffffff"}
|
type="color"
|
||||||
onChange={(event) =>
|
value={getRoutineColorValue(selectedRoutine) ?? "#ffffff"}
|
||||||
onSetRoutineColorValue(
|
onChange={(event) =>
|
||||||
selectedRoutine.id,
|
onSetRoutineColorValue(
|
||||||
event.currentTarget.value
|
selectedRoutine.id,
|
||||||
)
|
event.currentTarget.value
|
||||||
}
|
)
|
||||||
/>
|
}
|
||||||
</label>
|
/>
|
||||||
</div>
|
</label>
|
||||||
) : null}
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{selectedEffectOptions.find(
|
{selectedEffectOptions.find(
|
||||||
(effectOption) => effectOption.id === selectedEffectOptionId
|
(effectOption) => effectOption.id === selectedEffectOptionId
|
||||||
)?.valueKind === "animation" ? (
|
)?.valueKind === "animation" ? (
|
||||||
<div className="form-section">
|
<div className="form-section">
|
||||||
<div className="label">Animation</div>
|
<div className="label">Animation</div>
|
||||||
<label className="form-field">
|
<label className="form-field">
|
||||||
<span className="label">Clip</span>
|
<span className="label">Clip</span>
|
||||||
<select
|
<select
|
||||||
className="select-input"
|
className="select-input"
|
||||||
value={
|
value={
|
||||||
selectedRoutine.effect.type === "playModelAnimation"
|
selectedRoutine.effects[0]?.type === "playModelAnimation"
|
||||||
? selectedRoutine.effect.clipName
|
? selectedRoutine.effects[0].clipName
|
||||||
: selectedTargetOption.defaults.animationClipNames?.[0] ?? ""
|
: selectedTargetOption.defaults.animationClipNames?.[0] ??
|
||||||
}
|
""
|
||||||
onChange={(event) =>
|
}
|
||||||
onSetRoutineAnimationClip(
|
onChange={(event) =>
|
||||||
selectedRoutine.id,
|
onSetRoutineAnimationClip(
|
||||||
event.currentTarget.value
|
selectedRoutine.id,
|
||||||
)
|
event.currentTarget.value
|
||||||
}
|
)
|
||||||
>
|
}
|
||||||
{(selectedTargetOption.defaults.animationClipNames ?? []).map(
|
>
|
||||||
(clipName) => (
|
{(selectedTargetOption.defaults.animationClipNames ?? []).map(
|
||||||
<option key={clipName} value={clipName}>
|
(clipName) => (
|
||||||
{clipName}
|
<option key={clipName} value={clipName}>
|
||||||
</option>
|
{clipName}
|
||||||
)
|
</option>
|
||||||
)}
|
)
|
||||||
</select>
|
)}
|
||||||
</label>
|
</select>
|
||||||
<label className="form-field form-field--inline">
|
</label>
|
||||||
<input
|
<label className="form-field form-field--inline">
|
||||||
type="checkbox"
|
<input
|
||||||
checked={
|
type="checkbox"
|
||||||
selectedRoutine.effect.type === "playModelAnimation"
|
checked={
|
||||||
? selectedRoutine.effect.loop !== false
|
selectedRoutine.effects[0]?.type ===
|
||||||
: true
|
"playModelAnimation"
|
||||||
}
|
? selectedRoutine.effects[0].loop !== false
|
||||||
onChange={(event) =>
|
: true
|
||||||
onSetRoutineAnimationLoop(
|
}
|
||||||
selectedRoutine.id,
|
onChange={(event) =>
|
||||||
event.currentTarget.checked
|
onSetRoutineAnimationLoop(
|
||||||
)
|
selectedRoutine.id,
|
||||||
}
|
event.currentTarget.checked
|
||||||
/>
|
)
|
||||||
<span className="label">Loop</span>
|
}
|
||||||
</label>
|
/>
|
||||||
</div>
|
<span className="label">Loop</span>
|
||||||
) : null}
|
</label>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="form-section">
|
<div className="form-section">
|
||||||
<div className="label">Details</div>
|
<div className="label">Details</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user