From 4e760d4c0db0cc1684386b71b4797b9d93fee033 Mon Sep 17 00:00:00 2001 From: Nicola Date: Wed, 6 May 2026 09:50:42 +0200 Subject: [PATCH] Removed script select from the robotlist and added current script name to display. --- Prefabs/Robot/RobotDisplay.tscn | 10 +++++----- Scripts/DSL/CodingWindow.cs | 1 + Scripts/Robot/Robot.cs | 5 +---- Scripts/Robot/RobotDisplay.cs | 7 ++++++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Prefabs/Robot/RobotDisplay.tscn b/Prefabs/Robot/RobotDisplay.tscn index 1edec0b..ddd89e2 100644 --- a/Prefabs/Robot/RobotDisplay.tscn +++ b/Prefabs/Robot/RobotDisplay.tscn @@ -2,7 +2,7 @@ [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")] +[node name="Robot" type="PanelContainer" unique_id=247502695 node_paths=PackedStringArray("listItem", "currentScript")] anchors_preset = 14 anchor_top = 0.5 anchor_right = 1.0 @@ -12,6 +12,7 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_ltmdd") listItem = NodePath("HBoxContainer/ListItem") +currentScript = NodePath("HBoxContainer/CurrentScript") [node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=906487472] layout_mode = 2 @@ -20,6 +21,7 @@ alignment = 1 [node name="ListItem" type="RichTextLabel" parent="HBoxContainer" unique_id=46246913] layout_mode = 2 +size_flags_horizontal = 3 text = "Robot #1" fit_content = true autowrap_mode = 0 @@ -28,18 +30,16 @@ vertical_alignment = 1 [node name="Jump" type="Button" parent="HBoxContainer" unique_id=391426419] layout_mode = 2 +size_flags_horizontal = 3 text = "Jump to" [node name="CurrentScript" type="RichTextLabel" parent="HBoxContainer" unique_id=425408407] layout_mode = 2 +size_flags_horizontal = 3 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"] diff --git a/Scripts/DSL/CodingWindow.cs b/Scripts/DSL/CodingWindow.cs index 86b5418..00e1598 100644 --- a/Scripts/DSL/CodingWindow.cs +++ b/Scripts/DSL/CodingWindow.cs @@ -114,6 +114,7 @@ public partial class CodingWindow : PanelContainer } if (nodes.Count > 0) robot.SetupExecution(nodes); + robot.currentProgram = scriptName.Text.Length <= 0 ? $"Script{availableScripts.ItemCount}" : scriptName.Text; } public void SetRobot(Robot robot) diff --git a/Scripts/Robot/Robot.cs b/Scripts/Robot/Robot.cs index b0ecddb..bda6840 100644 --- a/Scripts/Robot/Robot.cs +++ b/Scripts/Robot/Robot.cs @@ -8,6 +8,7 @@ public partial class Robot : Node3D List nodes; bool isExecuting = false; ProgramNode currentNode; + public string currentProgram; public override void _Ready() { @@ -40,10 +41,6 @@ public partial class Robot : Node3D Visible = Math.Round(Math.Abs(Position.Y / GameData.tileHeight), 0) == GameData.visibleLayer; - } - public void Move() - { - } public void SetupExecution(List nodes) diff --git a/Scripts/Robot/RobotDisplay.cs b/Scripts/Robot/RobotDisplay.cs index 50593d1..db25257 100644 --- a/Scripts/Robot/RobotDisplay.cs +++ b/Scripts/Robot/RobotDisplay.cs @@ -1,8 +1,10 @@ +using System.Collections.Generic; using Godot; public partial class RobotDisplay : PanelContainer { [Export] public RichTextLabel listItem; + [Export] public RichTextLabel currentScript; [Signal] public delegate void OnRobotJumpToEventHandler(Robot robot); public Robot robot; @@ -13,7 +15,10 @@ public partial class RobotDisplay : PanelContainer public override void _Process(double delta) { - + if (robot.currentProgram != currentScript.Text) + { + currentScript.Text = robot.currentProgram; + } } public void OnJumpToClicked()