fix steps in visualizer

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

@ -15,12 +15,12 @@ export interface StepsTreeProps {
}
export default function StepsTree({
root,
selectedStepId,
onAddChildren,
onRemoveNode,
onStepSelected,
}: StepsTreeProps) {
root,
selectedStepId,
onAddChildren,
onRemoveNode,
onStepSelected,
}: StepsTreeProps) {
return (
<div className="steps-tree">
<StepsTreeNode
@ -46,13 +46,13 @@ interface StepsTreeContentProps {
}
function StepsTreeNode({
node,
rootNode,
selectedStepId,
onAddChildren,
onRemoveNode,
onStepSelected,
}: StepsTreeContentProps) {
node,
rootNode,
selectedStepId,
onAddChildren,
onRemoveNode,
onStepSelected,
}: StepsTreeContentProps) {
const ref = useRef<HTMLDivElement>(null)
return (
@ -67,7 +67,8 @@ function StepsTreeNode({
next: "step-piece-" + child.id,
},
]}
onSegmentsChanges={() => {}}
onSegmentsChanges={() => {
}}
forceStraight={true}
wavy={false}
readOnly={true}
@ -79,15 +80,14 @@ function StepsTreeNode({
<StepPiece
id={node.id}
isSelected={selectedStepId === node.id}
onAddButtonClicked={() => {
if (onAddChildren) onAddChildren(node)
}}
onAddButtonClicked={onAddChildren
? () => onAddChildren(node)
: undefined
}
onRemoveButtonClicked={
rootNode.id === node.id
rootNode.id === node.id || !onRemoveNode
? undefined
: () => {
if (onRemoveNode) onRemoveNode(node)
}
: () => onRemoveNode(node)
}
onSelected={() => {
if (onStepSelected) onStepSelected(node)
@ -126,13 +126,13 @@ interface StepPieceProps {
}
function StepPiece({
id,
isSelected,
onAddButtonClicked,
onRemoveButtonClicked,
onSelected,
children,
}: StepPieceProps) {
id,
isSelected,
onAddButtonClicked,
onRemoveButtonClicked,
onSelected,
children,
}: StepPieceProps) {
return (
<div
id={"step-piece-" + id}

@ -408,6 +408,7 @@ export function drainTerminalStateOnChildContent(
childContent.components,
)
if (!childComponent) {
//if the child does not contain the parent's component, add it to the children's content.
childContent = {
@ -418,6 +419,22 @@ export function drainTerminalStateOnChildContent(
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
if (
parentComponent.type !== "player" ||
@ -439,7 +456,7 @@ export function drainTerminalStateOnChildContent(
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)
if (
!childComponent.frozen ||
@ -459,6 +476,7 @@ export function drainTerminalStateOnChildContent(
const initialChildCompsCount = childContent.components.length
//remove players if they are not present on the parent's anymore
for (const component of childContent.components) {
if (
component.type !== "phantom" &&

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

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

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

Loading…
Cancel
Save