Finished first EA Version #1
@@ -1,24 +1,47 @@
|
||||
[gd_scene format=3 uid="uid://cpdfm3wluj3a6"]
|
||||
[gd_scene format=3 uid="uid://cinn18bl736rk"]
|
||||
|
||||
[node name="CraftNode" type="PanelContainer" unique_id=1839537826]
|
||||
[ext_resource type="Script" uid="uid://b6kxwmuhmruul" path="res://Scripts/DSL/NodeDisplay.cs" id="1_qemp1"]
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=945032897]
|
||||
[node name="Craft" type="PanelContainer" unique_id=247502695 node_paths=PackedStringArray("editorDisplay", "listDisplay")]
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_bottom = 31.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_qemp1")
|
||||
editorDisplay = NodePath("EditorDisplay")
|
||||
listDisplay = NodePath("ListDisplay")
|
||||
|
||||
[node name="EditorDisplay" type="PanelContainer" parent="." unique_id=1839537826]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="EditorDisplay" unique_id=945032897]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Flavour" type="RichTextLabel" parent="HBoxContainer" unique_id=1994560318]
|
||||
[node name="Flavour" type="RichTextLabel" parent="EditorDisplay/HBoxContainer" unique_id=1994560318]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Craft: "
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Item" type="OptionButton" parent="HBoxContainer" unique_id=117577134]
|
||||
[node name="Item" type="OptionButton" parent="EditorDisplay/HBoxContainer" unique_id=117577134]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Amount" type="SpinBox" parent="HBoxContainer" unique_id=1195061461]
|
||||
[node name="Amount" type="SpinBox" parent="EditorDisplay/HBoxContainer" unique_id=1195061461]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
rounded = true
|
||||
alignment = 1
|
||||
prefix = "x"
|
||||
|
||||
[node name="ListDisplay" type="Button" parent="." unique_id=200731038]
|
||||
layout_mode = 2
|
||||
text = "Craft"
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
[gd_scene format=3 uid="uid://com0ou37wj2xo"]
|
||||
|
||||
[node name="HarvestNode" type="PanelContainer" unique_id=970168969]
|
||||
[ext_resource type="Script" uid="uid://b6kxwmuhmruul" path="res://Scripts/DSL/NodeDisplay.cs" id="1_ve3v1"]
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=793343398]
|
||||
[node name="Harvest" type="PanelContainer" unique_id=1323721153 node_paths=PackedStringArray("editorDisplay", "listDisplay")]
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_bottom = 31.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("1_ve3v1")
|
||||
editorDisplay = NodePath("EditorDisplay")
|
||||
listDisplay = NodePath("ListDisplay")
|
||||
|
||||
[node name="EditorDisplay" type="PanelContainer" parent="." unique_id=970168969]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="EditorDisplay" unique_id=793343398]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Flavour" type="RichTextLabel" parent="HBoxContainer" unique_id=1393328640]
|
||||
[node name="Flavour" type="RichTextLabel" parent="EditorDisplay/HBoxContainer" unique_id=1393328640]
|
||||
layout_mode = 2
|
||||
text = "Harvest: "
|
||||
fit_content = true
|
||||
@@ -14,11 +30,15 @@ autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Item" type="OptionButton" parent="HBoxContainer" unique_id=912931137]
|
||||
[node name="Item" type="OptionButton" parent="EditorDisplay/HBoxContainer" unique_id=912931137]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Amount" type="SpinBox" parent="HBoxContainer" unique_id=1234084123]
|
||||
[node name="Amount" type="SpinBox" parent="EditorDisplay/HBoxContainer" unique_id=1234084123]
|
||||
layout_mode = 2
|
||||
rounded = true
|
||||
alignment = 1
|
||||
prefix = "x"
|
||||
|
||||
[node name="ListDisplay" type="Button" parent="." unique_id=884865258]
|
||||
layout_mode = 2
|
||||
text = "Harvest"
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
[gd_scene format=3 uid="uid://by0khq5dmxjvm"]
|
||||
|
||||
[node name="MoveNode" type="PanelContainer" unique_id=245583237]
|
||||
[ext_resource type="Script" uid="uid://b6kxwmuhmruul" path="res://Scripts/DSL/NodeDisplay.cs" id="1_mexpj"]
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=1629099069]
|
||||
[node name="Move" type="PanelContainer" unique_id=1474470717 node_paths=PackedStringArray("editorDisplay", "listDisplay")]
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_bottom = 31.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("1_mexpj")
|
||||
editorDisplay = NodePath("EditorDisplay")
|
||||
listDisplay = NodePath("ListDisplay")
|
||||
|
||||
[node name="EditorDisplay" type="PanelContainer" parent="." unique_id=245583237]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="EditorDisplay" unique_id=1629099069]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Flavour" type="RichTextLabel" parent="HBoxContainer" unique_id=1497013575]
|
||||
[node name="Flavour" type="RichTextLabel" parent="EditorDisplay/HBoxContainer" unique_id=1497013575]
|
||||
layout_mode = 2
|
||||
text = "Move to: "
|
||||
fit_content = true
|
||||
@@ -14,20 +30,24 @@ autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="CoordinateX" type="SpinBox" parent="HBoxContainer" unique_id=485214217]
|
||||
[node name="CoordinateX" type="SpinBox" parent="EditorDisplay/HBoxContainer" unique_id=485214217]
|
||||
layout_mode = 2
|
||||
rounded = true
|
||||
alignment = 1
|
||||
prefix = "X"
|
||||
|
||||
[node name="CoordinateY" type="SpinBox" parent="HBoxContainer" unique_id=724940645]
|
||||
[node name="CoordinateY" type="SpinBox" parent="EditorDisplay/HBoxContainer" unique_id=724940645]
|
||||
layout_mode = 2
|
||||
rounded = true
|
||||
alignment = 1
|
||||
prefix = "Y"
|
||||
|
||||
[node name="CoordinateZ" type="SpinBox" parent="HBoxContainer" unique_id=578943647]
|
||||
[node name="CoordinateZ" type="SpinBox" parent="EditorDisplay/HBoxContainer" unique_id=578943647]
|
||||
layout_mode = 2
|
||||
rounded = true
|
||||
alignment = 1
|
||||
prefix = "Z"
|
||||
|
||||
[node name="ListDisplay" type="Button" parent="." unique_id=347942160]
|
||||
layout_mode = 2
|
||||
text = "Move"
|
||||
|
||||
+54
-1
@@ -6,6 +6,7 @@
|
||||
[ext_resource type="Script" uid="uid://bm7knir4552j5" path="res://Scripts/Helpers/UIHandler.cs" id="4_fgofq"]
|
||||
[ext_resource type="Texture2D" uid="uid://bmcpkt6mae2qi" path="res://Assets/AlarmSign.png" id="5_b2bpf"]
|
||||
[ext_resource type="Script" uid="uid://bsd6n6b06a4pe" path="res://Scripts/DSL/CodingWindow.cs" id="6_7lihs"]
|
||||
[ext_resource type="Script" uid="uid://c3v2vdj3ghp78" path="res://Scripts/Information.cs" id="7_fgofq"]
|
||||
|
||||
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"]
|
||||
|
||||
@@ -52,7 +53,7 @@ environment = SubResource("Environment_sb48q")
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1558432386]
|
||||
follow_viewport_enabled = true
|
||||
|
||||
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotNaming", "mainCam")]
|
||||
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotNaming", "information", "mainCam")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -66,6 +67,7 @@ size_flags_vertical = 3
|
||||
script = ExtResource("4_fgofq")
|
||||
codingWindow = NodePath("MainUI/Content/CodingWindow")
|
||||
robotNaming = NodePath("Popup/RobotNaming")
|
||||
information = NodePath("Popup/Information")
|
||||
mainCam = NodePath("../../Camera3D")
|
||||
|
||||
[node name="MainUI" type="VBoxContainer" parent="CanvasLayer/UIHandler" unique_id=1437975209]
|
||||
@@ -180,6 +182,26 @@ layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Compile"
|
||||
|
||||
[node name="Saving" type="HBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/HBoxContainer/EditorWindow" unique_id=404804163]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
|
||||
[node name="ScriptName" type="LineEdit" parent="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/HBoxContainer/EditorWindow/Saving" unique_id=1831524214]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Name..."
|
||||
max_length = 24
|
||||
|
||||
[node name="Save" type="Button" parent="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/HBoxContainer/EditorWindow/Saving" unique_id=599810254]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Save"
|
||||
|
||||
[node name="Load" type="Button" parent="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/HBoxContainer/EditorWindow" unique_id=2064954816]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Load script"
|
||||
|
||||
[node name="Robotlist" type="ScrollContainer" parent="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/HBoxContainer" unique_id=592644944]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
@@ -232,6 +254,37 @@ max_length = 24
|
||||
layout_mode = 2
|
||||
text = "Submit"
|
||||
|
||||
[node name="Information" type="PanelContainer" parent="CanvasLayer/UIHandler/Popup" unique_id=1457118246 node_paths=PackedStringArray("title", "content")]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("7_fgofq")
|
||||
title = NodePath("VBoxContainer/Title")
|
||||
content = NodePath("VBoxContainer/Content")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/Popup/Information" unique_id=302174818]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="RichTextLabel" parent="CanvasLayer/UIHandler/Popup/Information/VBoxContainer" unique_id=680933734]
|
||||
layout_mode = 2
|
||||
text = "Test"
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Content" type="RichTextLabel" parent="CanvasLayer/UIHandler/Popup/Information/VBoxContainer" unique_id=1438295895]
|
||||
layout_mode = 2
|
||||
text = "Test"
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Button" type="Button" parent="CanvasLayer/UIHandler/Popup/Information/VBoxContainer" unique_id=1927576326]
|
||||
layout_mode = 2
|
||||
text = "OK"
|
||||
|
||||
[connection signal="color_changed" from="CanvasLayer/UIHandler/MainUI/HeaderContainer/Header/LightColor" to="CanvasLayer/UIHandler" method="ChangeColor"]
|
||||
[connection signal="button_up" from="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/HBoxContainer/EditorWindow/Buttons/Clear" to="CanvasLayer/UIHandler/MainUI/Content/CodingWindow" method="ClearWindow"]
|
||||
[connection signal="button_up" from="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/HBoxContainer/EditorWindow/Buttons/Compile" to="CanvasLayer/UIHandler/MainUI/Content/CodingWindow" method="CompileProgram"]
|
||||
[connection signal="pressed" from="CanvasLayer/UIHandler/Popup/Information/VBoxContainer/Button" to="CanvasLayer/UIHandler/Popup/Information" method="HideInformation"]
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+31
-20
@@ -1,30 +1,41 @@
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
public partial class NodeDisplay : RichTextLabel
|
||||
public partial class NodeDisplay : PanelContainer
|
||||
{
|
||||
ProgramNode node;
|
||||
[Export] PanelContainer editorDisplay;
|
||||
[Export] public Button listDisplay;
|
||||
public ProgramNode node;
|
||||
|
||||
public void SetNode(ProgramNode node)
|
||||
{
|
||||
this.node = node;
|
||||
}
|
||||
public void SetNode(ProgramNode node)
|
||||
{
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public void SetupUIElement()
|
||||
{
|
||||
|
||||
}
|
||||
public void SetupUIElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Input.IsActionJustPressed("left_click"))
|
||||
{
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public void ShowListDisplay()
|
||||
{
|
||||
editorDisplay.Visible = false;
|
||||
listDisplay.Visible = true;
|
||||
}
|
||||
|
||||
public void ShowEditorDisplay()
|
||||
{
|
||||
editorDisplay.Visible = true;
|
||||
listDisplay.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,16 @@ public class CraftNode : ProgramNode
|
||||
{
|
||||
DisplayText = "Craft";
|
||||
}
|
||||
public override void Execute(Robot robot)
|
||||
public override bool Execute(Robot robot)
|
||||
{
|
||||
GD.Print("Craft");
|
||||
nextNode.Execute(robot);
|
||||
if (nextNode != null)
|
||||
{
|
||||
return nextNode.Execute(robot);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,16 @@ public class HarvestNode : ProgramNode
|
||||
{
|
||||
DisplayText = "Harvest";
|
||||
}
|
||||
public override void Execute(Robot robot)
|
||||
public override bool Execute(Robot robot)
|
||||
{
|
||||
GD.Print("Harvest");
|
||||
nextNode.Execute(robot);
|
||||
if (nextNode != null)
|
||||
{
|
||||
return nextNode.Execute(robot);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,16 @@ public class MoveNode : ProgramNode
|
||||
{
|
||||
DisplayText = "Move";
|
||||
}
|
||||
public override void Execute(Robot robot)
|
||||
public override bool Execute(Robot robot)
|
||||
{
|
||||
robot.Position = targetPosition;
|
||||
nextNode.Execute(robot);
|
||||
if (nextNode != null)
|
||||
{
|
||||
return nextNode.Execute(robot);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public abstract class ProgramNode
|
||||
|
||||
}
|
||||
|
||||
public abstract void Execute(Robot robot);
|
||||
public abstract bool Execute(Robot robot);
|
||||
public void LinkNode(ProgramNode nextNode)
|
||||
{
|
||||
this.nextNode = nextNode;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
public class ProgramInterpreter
|
||||
{
|
||||
ProgramNode startNode;
|
||||
public ProgramInterpreter(ProgramNode startNode)
|
||||
{
|
||||
this.startNode = startNode;
|
||||
}
|
||||
|
||||
public bool Execute(Robot robot)
|
||||
{
|
||||
return startNode.Execute(robot);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ public partial class UIHandler : Control
|
||||
{
|
||||
[Export] CodingWindow codingWindow;
|
||||
[Export] PanelContainer robotNaming;
|
||||
[Export] Information information;
|
||||
[Export] Camera3D mainCam;
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -19,6 +20,8 @@ public partial class UIHandler : Control
|
||||
{
|
||||
mainCam.Position = new Vector3(robot.Position.X, mainCam.Position.Y, robot.Position.Z);
|
||||
};
|
||||
|
||||
codingWindow.OnInformation += information.DisplayInformation;
|
||||
}
|
||||
|
||||
public void ChangeColor(Color color)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Information : PanelContainer
|
||||
{
|
||||
[Export] RichTextLabel title;
|
||||
[Export] RichTextLabel content;
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
|
||||
public void DisplayInformation(string title, string content)
|
||||
{
|
||||
this.title.Text = title;
|
||||
this.content.Text = content;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
public void HideInformation()
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c3v2vdj3ghp78
|
||||
Reference in New Issue
Block a user