Reworked node display and worked on DSL interpretation

This commit is contained in:
=
2026-04-29 12:12:58 +02:00
parent 2cc6e31157
commit 2f922b5e04
14 changed files with 270 additions and 54 deletions
+26 -9
View File
@@ -9,6 +9,8 @@ public partial class CodingWindow : PanelContainer
[Export] VBoxContainer robotList;
[Signal]
public delegate void OnRobotClickedEventHandler(Robot robot);
[Signal]
public delegate void OnInformationEventHandler(string title, string text);
public Dictionary<ProgramNode, PackedScene> DSLNodes;
// Called when the node enters the scene tree for the first time.
@@ -35,19 +37,20 @@ public partial class CodingWindow : PanelContainer
//Move, Harvest, Craft
public void GenerateCodingBlocks()
{
Button button;
NodeDisplay nodeDisplay;
foreach (ProgramNode node in DSLNodes.Keys)
{
button = new Button
nodeDisplay = DSLNodes[node].Instantiate<NodeDisplay>();
nodeDisplay.node = node;
codeBlocks.AddChild(nodeDisplay);
nodeDisplay.ShowListDisplay();
nodeDisplay.listDisplay.Pressed += () =>
{
Text = node.DisplayText,
Name = node.DisplayText
NodeDisplay editorDisplay = DSLNodes[node].Instantiate<NodeDisplay>();
editorDisplay.node = node;
editorWindow.AddChild(editorDisplay);
editorDisplay.ShowEditorDisplay();
};
button.Pressed += () =>
{
editorWindow.AddChild(DSLNodes[node].Instantiate());
};
codeBlocks.AddChild(button);
}
}
@@ -86,6 +89,20 @@ public partial class CodingWindow : PanelContainer
public void CompileProgram()
{
string errorMessage = "";
bool didCompile;
for (int i = 1; i < editorWindow.GetChildCount(); i++)
{
editorWindow.GetChild<NodeDisplay>(i - 1).node.LinkNode(editorWindow.GetChild<NodeDisplay>(i).node);
}
ProgramInterpreter interpreter = new ProgramInterpreter(editorWindow.GetChild<NodeDisplay>(0).node);
didCompile = interpreter.Execute(GameData.robots[0]);
if (!didCompile)
{
EmitSignal(SignalName.OnInformation, "ERROR", "Compilation failed " + errorMessage);
}
}
}