fix steps in visualizer

pull/119/head
maxime 1 year ago
parent 3091e1a61a
commit cab6fc43ca

@ -67,7 +67,8 @@ function StepsTreeNode({
next: "step-piece-" + child.id, next: "step-piece-" + child.id,
}, },
]} ]}
onSegmentsChanges={() => {}} onSegmentsChanges={() => {
}}
forceStraight={true} forceStraight={true}
wavy={false} wavy={false}
readOnly={true} readOnly={true}
@ -79,15 +80,14 @@ function StepsTreeNode({
<StepPiece <StepPiece
id={node.id} id={node.id}
isSelected={selectedStepId === node.id} isSelected={selectedStepId === node.id}
onAddButtonClicked={() => { onAddButtonClicked={onAddChildren
if (onAddChildren) onAddChildren(node) ? () => onAddChildren(node)
}} : undefined
}
onRemoveButtonClicked={ onRemoveButtonClicked={
rootNode.id === node.id rootNode.id === node.id || !onRemoveNode
? undefined ? undefined
: () => { : () => onRemoveNode(node)
if (onRemoveNode) onRemoveNode(node)
}
} }
onSelected={() => { onSelected={() => {
if (onStepSelected) onStepSelected(node) if (onStepSelected) onStepSelected(node)

@ -408,6 +408,7 @@ export function drainTerminalStateOnChildContent(
childContent.components, childContent.components,
) )
if (!childComponent) { if (!childComponent) {
//if the child does not contain the parent's component, add it to the children's content. //if the child does not contain the parent's component, add it to the children's content.
childContent = { childContent = {
@ -418,6 +419,22 @@ export function drainTerminalStateOnChildContent(
continue continue
} }
if (childComponent.type !== parentComponent.type)
throw Error("child and parent components are not of the same type.")
if (childComponent.type === "ball" && parentComponent.type === "ball") {
gotUpdated = true
childContent = updateComponent(
{
...childComponent,
frozen: true,
pos: parentComponent.pos,
},
childContent,
)
}
// ensure that the component is a player // ensure that the component is a player
if ( if (
parentComponent.type !== "player" || parentComponent.type !== "player" ||
@ -439,7 +456,7 @@ export function drainTerminalStateOnChildContent(
newContentResult?.components, newContentResult?.components,
) )
} }
// update the position of the player if it has been moved // update the position of the component if it has been moved
// also force update if the child component is not frozen (the component was introduced previously by the child step but the parent added it afterward) // also force update if the child component is not frozen (the component was introduced previously by the child step but the parent added it afterward)
if ( if (
!childComponent.frozen || !childComponent.frozen ||
@ -459,6 +476,7 @@ export function drainTerminalStateOnChildContent(
const initialChildCompsCount = childContent.components.length const initialChildCompsCount = childContent.components.length
//remove players if they are not present on the parent's anymore
for (const component of childContent.components) { for (const component of childContent.components) {
if ( if (
component.type !== "phantom" && component.type !== "phantom" &&

@ -420,7 +420,7 @@ function EditorPage({
null, null,
) )
const [isStepsTreeVisible, setStepsTreeVisible] = useState(false) const [isStepsTreeVisible, setStepsTreeVisible] = useState(true)
const courtBounds = useCallback( const courtBounds = useCallback(
() => courtRef.current!.getBoundingClientRect(), () => courtRef.current!.getBoundingClientRect(),

@ -141,7 +141,7 @@ function VisualizerPageContent({
service, service,
showEditButton, showEditButton,
}: VisualizerPageContentProps) { }: VisualizerPageContentProps) {
const [isStepsTreeVisible, setStepsTreeVisible] = useState(false) const [isStepsTreeVisible, setStepsTreeVisible] = useState(true)
const [editorContentCurtainWidth, setEditorContentCurtainWidth] = const [editorContentCurtainWidth, setEditorContentCurtainWidth] =
useState(80) useState(80)

@ -8,7 +8,7 @@
.from-parent .player-piece { .from-parent .player-piece {
color: white; color: white;
background-color: var(--player-from-parent-color); background-color: var(--player-from-parent-color) !important;
} }
.player-content { .player-content {

Loading…
Cancel
Save