Skip to content

Commit

Permalink
Fix up goto node.
Browse files Browse the repository at this point in the history
  • Loading branch information
calvertdw committed Jan 31, 2025
1 parent 25c8bc9 commit 2a9af87
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected void renderImGuiWidgetsInternal()

// Validate state in case something earlier in this UI tick messed with things.
// This happens with the Undo non-topological changes button.
state.updateAndValidateGotoNode(rootNode.getOrderedLeaves());
state.validateFields(rootNode.getOrderedLeaves());

String selectedText;
if (definition.getGotoNext().getValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void renderNodeSettingsWidgets()
{
// Validate state in case something earlier in this UI tick messed with things.
// This happens with the Undo non-topological changes button.
state.updateAndValidateExecuteAfter(actionSequence.getOrderedLeaves());
state.validateFields(actionSequence.getOrderedLeaves());

String selectedText;
if (definition.getExecuteAfterPrevious().getValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void update()

for (RDXLeafNode<?, ?> leaf : orderedLeaves)
{
leaf.getState().updateAndValidateExecuteAfter(state.getOrderedLeaves());
leaf.getState().validateFields(state.getOrderedLeaves());
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ public void renderExecutionControlAndProgressWidgets()
ImGuiTools.previousWidgetTooltip("Go to next leaf");

boolean endOfSequence = getState().getExecutionNextIndex() >= getState().getOrderedLeaves().size();
if (!endOfSequence)
ImGui.beginDisabled(endOfSequence); // Use disabled so stuff doesn't glitch around
{
ImGui.sameLine();
ImGui.text("Execute");
Expand All @@ -120,27 +120,25 @@ public void renderExecutionControlAndProgressWidgets()
getDefinition().modify();

ImGuiTools.previousWidgetTooltip("Enables autonomous execution. Will immediately start executing when checked.");
if (!getState().getAutomaticExecution())

ImGui.beginDisabled(getState().getAutomaticExecution());
{
ImGui.sameLine();

boolean disableManuallyExecuteButton = getState().getManualExecutionRequested();
if (disableManuallyExecuteButton)
ImGui.beginDisabled();
if (ImGui.button(labels.get("Manually")))
ImGui.beginDisabled(disableManuallyExecuteButton);
{
getState().setManualExecutionRequested();
if (ImGui.button(labels.get("Manually")))
{
getState().setManualExecutionRequested();
}
}
if (disableManuallyExecuteButton)
ImGui.endDisabled();
ImGui.endDisabled();
ImGuiTools.previousWidgetTooltip("Executes the next leaf.");
}

if (endOfSequence)
{
ImGui.text("End of sequence.");
}
ImGui.endDisabled();
}
ImGui.endDisabled();

ImGui.sameLine();
concurrencyEnabledCheckbox.renderImGuiWidget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void update()

for (LeafNodeExecutor<?, ?> leaf : orderedLeaves)
{
leaf.getState().updateAndValidateExecuteAfter(state.getOrderedLeaves());
leaf.getState().validateFields(state.getOrderedLeaves());
}

// Update concurrency ranks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@ public GotoNodeExecutor(long id, CRDTInfo crdtInfo, WorkspaceResourceDirectory s
@Override
public void updateCurrentlyExecuting()
{
state.setIsExecuting(false); // Completes immediately
}

@Override
public void triggerExecution()
{
super.triggerExecution();

if (!definition.getGotoNext().getValue())
{
LeafNodeState<?> nodeToGoto = state.findNodeToGoto();
BehaviorTreeTools.findRootNode(this).getState().setExecutionNextIndex(nodeToGoto.getLeafIndex());
}

state.setIsExecuting(false); // Completes immediately
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ public GotoNodeState(long id, CRDTInfo crdtInfo, WorkspaceResourceDirectory save
* saving an up to date human readable name in the JSON.
* It also finds the correct node upon loading the name from JSON.
*/
public void updateAndValidateGotoNode(List<LeafNodeState<?>> leafNodes)
@Override
public void validateFields(List<LeafNodeState<?>> leafNodes)
{
super.validateFields(leafNodes);

String gotoNodeName = null;

if (!definition.getGotoNext().getValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public LeafNodeState(long id, D definition, CRDTInfo crdtInfo)
* saving an up to date human readable name in the JSON.
* It also finds the correct node upon loading the name from JSON.
*/
public void updateAndValidateExecuteAfter(List<LeafNodeState<?>> leaves)
public void validateFields(List<LeafNodeState<?>> leaves)
{
String executeAfterLeafName = null;

Expand Down

0 comments on commit 2a9af87

Please sign in to comment.