Finished first EA Version #1
@@ -1,7 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://dciwxejdji2lg"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cjae60v4c60vb" path="res://Prefabs/RobotVisual.tscn" id="2_3hvm5"]
|
||||
[ext_resource type="Script" uid="uid://e0pgy7jya41y" path="res://Scripts/Robot.cs" id="2_j80uv"]
|
||||
[ext_resource type="PackedScene" uid="uid://cjae60v4c60vb" path="res://Prefabs/Robot/RobotVisual.tscn" id="2_3hvm5"]
|
||||
[ext_resource type="Script" uid="uid://e0pgy7jya41y" path="res://Scripts/Robot/Robot.cs" id="2_j80uv"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_vquur"]
|
||||
size = Vector3(1.1176758, 0.7307129, 1.0234375)
|
||||
@@ -0,0 +1,45 @@
|
||||
[gd_scene format=3 uid="uid://dribqey54i62n"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dcxom1paffp0p" path="res://Scripts/Robot/RobotDisplay.cs" id="1_ltmdd"]
|
||||
|
||||
[node name="Robot" type="PanelContainer" unique_id=247502695 node_paths=PackedStringArray("listItem")]
|
||||
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_ltmdd")
|
||||
listItem = NodePath("HBoxContainer/ListItem")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=906487472]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
alignment = 1
|
||||
|
||||
[node name="ListItem" type="RichTextLabel" parent="HBoxContainer" unique_id=46246913]
|
||||
layout_mode = 2
|
||||
text = "Robot #1"
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Jump" type="Button" parent="HBoxContainer" unique_id=391426419]
|
||||
layout_mode = 2
|
||||
text = "Jump to"
|
||||
|
||||
[node name="CurrentScript" type="RichTextLabel" parent="HBoxContainer" unique_id=425408407]
|
||||
layout_mode = 2
|
||||
text = "Scriptname"
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ScriptSelect" type="MenuButton" parent="HBoxContainer" unique_id=63458827]
|
||||
layout_mode = 2
|
||||
text = "Select script..."
|
||||
|
||||
[connection signal="pressed" from="HBoxContainer/Jump" to="." method="OnJumpToClicked"]
|
||||
+30
-5
@@ -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://k6vlo7ulvtep" path="res://Scripts/Robot/RobotList.cs" id="7_2irst"]
|
||||
[ext_resource type="Script" uid="uid://c3v2vdj3ghp78" path="res://Scripts/Information.cs" id="7_fgofq"]
|
||||
|
||||
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"]
|
||||
@@ -53,7 +54,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", "information", "mainCam")]
|
||||
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "robotNaming", "information", "mainCam")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -66,6 +67,7 @@ size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("4_fgofq")
|
||||
codingWindow = NodePath("MainUI/Content/CodingWindow")
|
||||
robotList = NodePath("MainUI/Content/RobotList")
|
||||
robotNaming = NodePath("Popup/RobotNaming")
|
||||
information = NodePath("Popup/Information")
|
||||
mainCam = NodePath("../../Camera3D")
|
||||
@@ -119,7 +121,7 @@ text = "Choose Color..."
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="CodingWindow" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=1576652491 node_paths=PackedStringArray("codeBlocks", "editorWindow", "robotList")]
|
||||
[node name="CodingWindow" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=1576652491 node_paths=PackedStringArray("codeBlocks", "editorWindow")]
|
||||
layout_mode = 1
|
||||
anchors_preset = 11
|
||||
anchor_left = 1.0
|
||||
@@ -132,7 +134,6 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_7lihs")
|
||||
script = ExtResource("6_7lihs")
|
||||
codeBlocks = NodePath("HBoxContainer/CodeBlocks/VBoxContainer")
|
||||
editorWindow = NodePath("HBoxContainer/EditorWindow/CodeContainer/VBoxContainer")
|
||||
robotList = NodePath("HBoxContainer/Robotlist/VBoxContainer")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/CodingWindow" unique_id=1934932205]
|
||||
layout_mode = 2
|
||||
@@ -202,12 +203,36 @@ 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]
|
||||
[node name="RobotList" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=1469962195 node_paths=PackedStringArray("robotList")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.25
|
||||
anchor_top = 0.25
|
||||
anchor_right = 0.75
|
||||
anchor_bottom = 0.75
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("7_2irst")
|
||||
robotList = NodePath("VBoxContainer/ScrollContainer/VBoxContainer")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/RobotList" unique_id=1958138787]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/Content/RobotList/VBoxContainer" unique_id=1891991275]
|
||||
layout_mode = 2
|
||||
bbcode_enabled = true
|
||||
text = "[font_size=32]Robotlist[/font_size]"
|
||||
fit_content = true
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="CanvasLayer/UIHandler/MainUI/Content/RobotList/VBoxContainer" unique_id=592644944]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_fgofq")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/CodingWindow/HBoxContainer/Robotlist" unique_id=963718788]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/RobotList/VBoxContainer/ScrollContainer" unique_id=963718788]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,12 @@ public partial class ResourceLoader
|
||||
|
||||
public static PackedScene LoadRobotPrefab()
|
||||
{
|
||||
return GD.Load<PackedScene>($"res://Prefabs/Robot.tscn");
|
||||
return GD.Load<PackedScene>($"res://Prefabs/Robot/Robot.tscn");
|
||||
}
|
||||
|
||||
public static PackedScene LoadRobotDisplay()
|
||||
{
|
||||
return GD.Load<PackedScene>($"res://Prefabs/Robot/RobotDisplay.tscn");
|
||||
}
|
||||
|
||||
public static Dictionary<string, MeshInstance3D> LoadTiles()
|
||||
|
||||
@@ -5,6 +5,7 @@ using Godot;
|
||||
public partial class UIHandler : Control
|
||||
{
|
||||
[Export] CodingWindow codingWindow;
|
||||
[Export] RobotList robotList;
|
||||
[Export] PanelContainer robotNaming;
|
||||
[Export] Information information;
|
||||
[Export] Camera3D mainCam;
|
||||
@@ -16,12 +17,10 @@ public partial class UIHandler : Control
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
codingWindow.OnRobotClicked += (robot) =>
|
||||
robotList.OnRobotJumpTo += (robot) =>
|
||||
{
|
||||
mainCam.Position = new Vector3(robot.Position.X, mainCam.Position.Y, robot.Position.Z);
|
||||
};
|
||||
|
||||
codingWindow.OnInformation += information.DisplayInformation;
|
||||
}
|
||||
|
||||
public void ChangeColor(Color color)
|
||||
|
||||
@@ -3,6 +3,17 @@ using Godot;
|
||||
|
||||
public partial class Robot : Node3D
|
||||
{
|
||||
public ProgramInterpreter interpreter;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
public void Move()
|
||||
{
|
||||
|
||||
@@ -12,4 +23,5 @@ public partial class Robot : Node3D
|
||||
{
|
||||
GetNode<UIHandler>("/root/Main/CanvasLayer/UIHandler").ShowNamingPopup(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Godot;
|
||||
|
||||
public partial class RobotDisplay : PanelContainer
|
||||
{
|
||||
[Export] public RichTextLabel listItem;
|
||||
[Signal]
|
||||
public delegate void OnRobotJumpToEventHandler(Robot robot);
|
||||
public Robot robot;
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnJumpToClicked()
|
||||
{
|
||||
EmitSignal(SignalName.OnRobotJumpTo, robot);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class RobotList : PanelContainer
|
||||
{
|
||||
[Export] VBoxContainer robotList;
|
||||
[Signal]
|
||||
public delegate void OnRobotJumpToEventHandler(Robot robot);
|
||||
public PackedScene robotDisplayPrefab;
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
robotDisplayPrefab = ResourceLoader.LoadRobotDisplay();
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Input.IsActionJustPressed("robot_list"))
|
||||
{
|
||||
Visible = !Visible;
|
||||
if (Visible) ReloadRobots();
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadRobots()
|
||||
{
|
||||
foreach (Node node in robotList.GetChildren())
|
||||
{
|
||||
robotList.RemoveChild(node);
|
||||
node.QueueFree();
|
||||
}
|
||||
RobotDisplay display;
|
||||
|
||||
foreach (Robot robotObject in GameData.robots)
|
||||
{
|
||||
display = robotDisplayPrefab.Instantiate<RobotDisplay>();
|
||||
display.robot = robotObject;
|
||||
display.listItem.Text = robotObject.Name;
|
||||
display.OnRobotJumpTo += (robot) =>
|
||||
{
|
||||
EmitSignal(SignalName.OnRobotJumpTo, robot);
|
||||
};
|
||||
robotList.AddChild(display);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://k6vlo7ulvtep
|
||||
@@ -87,6 +87,11 @@ left_click={
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(394, 15),"global_position":Vector2(403, 63),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
robot_list={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user