Moved robots to separate folders and a dedicated robotlist in the UI

This commit is contained in:
=
2026-04-29 14:08:02 +02:00
parent 17057487d6
commit 832fb47ec0
15 changed files with 176 additions and 47 deletions
+3 -36
View File
@@ -6,12 +6,8 @@ public partial class CodingWindow : PanelContainer
{
[Export] VBoxContainer codeBlocks;
[Export] VBoxContainer editorWindow;
[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.
public override void _Ready()
@@ -23,14 +19,10 @@ public partial class CodingWindow : PanelContainer
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
//TODO: If robot that was pressed has a script, load script
if (Input.IsActionJustPressed("codingwindow"))
{
Visible = !Visible;
GameData.canMove = !Visible;
if (Visible)
{
ReloadRobots();
}
}
}
@@ -54,30 +46,6 @@ public partial class CodingWindow : PanelContainer
}
}
public void ReloadRobots()
{
foreach (Node node in robotList.GetChildren())
{
robotList.RemoveChild(node);
node.QueueFree();
}
Button button;
foreach (Robot robotObject in GameData.robots)
{
button = new Button
{
Text = robotObject.Name,
Name = robotObject.Name
};
button.Pressed += () =>
{
EmitSignal(SignalName.OnRobotClicked, robotObject);
};
robotList.AddChild(button);
}
}
public void ClearWindow()
{
foreach (Node node in editorWindow.GetChildren())
@@ -89,7 +57,6 @@ public partial class CodingWindow : PanelContainer
public void CompileProgram()
{
string errorMessage = "";
bool didCompile;
for (int i = 0; i < editorWindow.GetChildCount(); i++)
@@ -106,7 +73,7 @@ public partial class CodingWindow : PanelContainer
if (!didCompile)
{
EmitSignal(SignalName.OnInformation, "ERROR", "Compilation failed " + errorMessage);
}
}
}