Added node highlight, fixed temporary load to include start node as well, fixed For-Condition

This commit is contained in:
2026-05-14 21:37:26 +02:00
parent eee59b6385
commit 672628ee13
9 changed files with 116 additions and 15 deletions
+60 -4
View File
@@ -15,6 +15,7 @@ public partial class CodingWindow : PanelContainer
public System.Collections.Generic.Dictionary<ProgramNode, PackedScene> DSLNodes;
public NodeDisplay selectedNode;
public NodeDisplay highlightedNode;
public override void _Ready()
{
@@ -30,7 +31,7 @@ public partial class CodingWindow : PanelContainer
}
}
public override void _Process(double delta)
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("delete_node"))
{
@@ -41,11 +42,63 @@ public partial class CodingWindow : PanelContainer
editorWindow.RemoveChild(selectedNode);
selectedNode.QueueFree();
}
if (robot != null && Visible && robot.isExecuting)
{
UpdateCurrentNode();
}
}
private void UpdateCurrentNode()
{
if (robot.currentNode == null)
{
ClearHighlightedNode();
return;
}
if (highlightedNode != null)
{
if (IsCurrentRuntimeNode(highlightedNode))
{
return;
}
ClearHighlightedNode();
}
foreach (Node child in editorWindow.GetChildren())
{
NodeDisplay nodeDisplay = child as NodeDisplay;
if (nodeDisplay == null) continue;
if (IsCurrentRuntimeNode(nodeDisplay))
{
nodeDisplay.SetHighlighted(true);
highlightedNode = nodeDisplay;
break;
}
}
}
private bool IsCurrentRuntimeNode(NodeDisplay nodeDisplay)
{
return robot.currentNode.EditorNodeId != null
&& robot.currentNode.EditorNodeId.Length > 0
&& nodeDisplay.Name.ToString() == robot.currentNode.EditorNodeId;
}
private void ClearHighlightedNode()
{
if (highlightedNode == null) return;
highlightedNode.SetHighlighted(false);
highlightedNode = null;
}
public void OnMapToggled(bool toggledOn)
{
if(robot == null) return;
if (robot == null) return;
robot.showOnMap = toggledOn;
}
@@ -133,6 +186,7 @@ public partial class CodingWindow : PanelContainer
public void ClearWindow()
{
ClearHighlightedNode();
DisconnectAllNodes();
RemoveEditorNodes();
scriptName.Text = "";
@@ -210,16 +264,18 @@ public partial class CodingWindow : PanelContainer
public void LoadTemporaryProgram()
{
if (robot == null) return;
if (robot.currentNode == null) return;
ProgramNode rootNode = robot.programStartNode ?? robot.currentNode;
if (rootNode == null) return;
RunningProgramGraphBuilder builder = new RunningProgramGraphBuilder(
DSLNodes,
AddLoadedNode,
ConnectNodes
);
builder.Load(robot.currentNode);
builder.Load(rootNode);
scriptName.Text = robot.currentProgram ?? "";
UpdateCurrentNode();
}
public void DeleteProgram()