diff --git a/ADEPT-Godot/ADEPT.csproj b/ADEPT-Godot/ADEPT.csproj index ae48abd..963d621 100644 --- a/ADEPT-Godot/ADEPT.csproj +++ b/ADEPT-Godot/ADEPT.csproj @@ -6,4 +6,7 @@ + + + \ No newline at end of file diff --git a/ADEPT-Godot/ADEPT.sln.DotSettings.user b/ADEPT-Godot/ADEPT.sln.DotSettings.user index fcf0ed8..dce9f62 100644 --- a/ADEPT-Godot/ADEPT.sln.DotSettings.user +++ b/ADEPT-Godot/ADEPT.sln.DotSettings.user @@ -1,5 +1,6 @@  ForceIncluded + ForceIncluded <AssemblyExplorer> <Assembly Path="/home/chris/.nuget/packages/cogwheellib/1.3.0/lib/net9.0/CogwheelLib.dll" /> </AssemblyExplorer> \ No newline at end of file diff --git a/ADEPT-Godot/Client/Scenes/Main.tscn b/ADEPT-Godot/Client/Scenes/MainCanvas.tscn similarity index 56% rename from ADEPT-Godot/Client/Scenes/Main.tscn rename to ADEPT-Godot/Client/Scenes/MainCanvas.tscn index a5d58f7..7c91436 100644 --- a/ADEPT-Godot/Client/Scenes/Main.tscn +++ b/ADEPT-Godot/Client/Scenes/MainCanvas.tscn @@ -1,28 +1,21 @@ [gd_scene load_steps=3 format=3 uid="uid://c35ohffpqfqnr"] -[ext_resource type="Script" uid="uid://geelevcnulxy" path="res://Client/Scripts/UI/Main.cs" id="1_np6pa"] [ext_resource type="Texture2D" uid="uid://chm704rgdebfb" path="res://icon.png" id="2_swjw6"] +[ext_resource type="PackedScene" uid="uid://caivf0icbv7gk" path="res://Core/Scenes/CogwheelConsole.tscn" id="3_ama40"] [node name="MainCanvas" type="CanvasLayer"] -[node name="Main" type="Control" parent="."] -layout_mode = 3 +[node name="Panel" type="Panel" parent="."] +visible = false anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_np6pa") +size_flags_horizontal = 3 +size_flags_vertical = 3 -[node name="Panel" type="Panel" parent="Main"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="TextureRect" type="TextureRect" parent="Main/Panel"] +[node name="TextureRect" type="TextureRect" parent="Panel"] layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -36,3 +29,5 @@ offset_bottom = 20.0 grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("2_swjw6") + +[node name="CogwheelConsole" parent="." instance=ExtResource("3_ama40")] diff --git a/ADEPT-Godot/Client/Scripts/UI/Main.cs b/ADEPT-Godot/Client/Scripts/UI/Main.cs deleted file mode 100644 index fc49e4d..0000000 --- a/ADEPT-Godot/Client/Scripts/UI/Main.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Godot; - -namespace ADEPT.Client; - -public partial class Main : Control -{ - -} \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scenes/CogwheelConsole.tscn b/ADEPT-Godot/Core/Scenes/CogwheelConsole.tscn new file mode 100644 index 0000000..81f3f99 --- /dev/null +++ b/ADEPT-Godot/Core/Scenes/CogwheelConsole.tscn @@ -0,0 +1,54 @@ +[gd_scene load_steps=2 format=3 uid="uid://caivf0icbv7gk"] + +[ext_resource type="Script" uid="uid://cgn58uiwyog25" path="res://Core/Scripts/Cogwheel/GodotCogwheelConsole.cs" id="1_23urx"] + +[node name="CogwheelConsole" type="Control" node_paths=PackedStringArray("_input", "_output")] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_23urx") +_input = NodePath("VBoxContainer/Input") +_output = NodePath("VBoxContainer/Panel/MarginContainer/Output") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Panel" type="Panel" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/Panel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="Output" type="RichTextLabel" parent="VBoxContainer/Panel/MarginContainer"] +layout_mode = 2 +focus_mode = 2 +bbcode_enabled = true +scroll_following = true +selection_enabled = true + +[node name="Input" type="TextEdit" parent="VBoxContainer"] +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 +placeholder_text = "> Enter Command" +wrap_mode = 1 +autowrap_mode = 1 +scroll_fit_content_height = true +scroll_fit_content_width = true diff --git a/ADEPT-Godot/Core/Scenes/Main.tscn b/ADEPT-Godot/Core/Scenes/Main.tscn index 5c49e94..43e7b92 100644 --- a/ADEPT-Godot/Core/Scenes/Main.tscn +++ b/ADEPT-Godot/Core/Scenes/Main.tscn @@ -1,6 +1,9 @@ -[gd_scene load_steps=2 format=3 uid="uid://udmowtmx1o3l"] +[gd_scene load_steps=3 format=3 uid="uid://udmowtmx1o3l"] -[ext_resource type="Script" uid="uid://bl2h8ot302x3g" path="res://Core/Scripts/MainNode.cs" id="1_wh72m"] +[ext_resource type="Script" uid="uid://dnmj6a1ptvwry" path="res://Core/Scripts/Main.cs" id="1_0ovck"] +[ext_resource type="PackedScene" uid="uid://c35ohffpqfqnr" path="res://Client/Scenes/MainCanvas.tscn" id="2_0ovck"] [node name="Main" type="Node"] -script = ExtResource("1_wh72m") +script = ExtResource("1_0ovck") + +[node name="MainCanvas" parent="." instance=ExtResource("2_0ovck")] diff --git a/ADEPT-Godot/Core/Scripts/ADEPT.cs b/ADEPT-Godot/Core/Scripts/ADEPT.cs index 7aff408..aa21a67 100644 --- a/ADEPT-Godot/Core/Scripts/ADEPT.cs +++ b/ADEPT-Godot/Core/Scripts/ADEPT.cs @@ -7,16 +7,10 @@ namespace ADEPT.Core; public static class ADEPT { - private static CommandsManager _commandsManager = new CommandsManager(); - private static ICogwheelConsole _cogwheelConsole = new GodotCogwheelConsole(); + public static Main MainNode { get; private set; } - public static MainNode MainNode { get; private set; } - - public static void Initialize(MainNode mainNode) + public static void Initialize(Main mainNode) { - COGWHEEL.Initialize(_commandsManager, _cogwheelConsole); - COGWHEEL.AddAssembly(Assembly.GetCallingAssembly()); - MainNode = mainNode; } diff --git a/ADEPT-Godot/Core/Scripts/ADEPT.cs.uid b/ADEPT-Godot/Core/Scripts/ADEPT.cs.uid new file mode 100644 index 0000000..d500dd8 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/ADEPT.cs.uid @@ -0,0 +1 @@ +uid://b8cf4qnyf2hyu diff --git a/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs b/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs index bfbd75f..42ed279 100644 --- a/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs +++ b/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs @@ -1,45 +1,103 @@ +using System.Collections.Generic; +using System.Reflection; using Cogwheel; +using Godot; namespace ADEPT.Core.Cogwheel; -public class GodotCogwheelConsole : ICogwheelConsole +public partial class GodotCogwheelConsole : Control, ICogwheelConsole { + public string OpeningMessage { get; set; } + public bool IsRunning { get; set; } + public CommandsManager CommandsManager { get; set; } + + [Export] private string _openingMessage = "ADEPT Console"; + [Export] private TextEdit _input; + [Export] private RichTextLabel _output; + [Export] private Godot.Collections.Dictionary _colors = new() + { + {"error", new Color(1, 0, 0)}, + {"warning", new Color(1, 1, 0)}, + {"log", new Color(1, 1, 1)}, + {"info", new Color(0, 0, 1)}, + {"commandHighlight", new Color(0, 0.8f, 0.4f)}, + }; + + private CommandsManager _commandsManager; + private CodeHighlighter _codeHighlighter; + public void Initialize(CommandsManager commandsManager) { + _commandsManager = commandsManager; + _codeHighlighter = new CodeHighlighter(); + _input.SyntaxHighlighter = _codeHighlighter; + + _codeHighlighter.KeywordColors = BuildKeywords(); + } + + public override void _Ready() + { + _output.Text += _openingMessage + "\n"; + + } public void Log(string message) { - + Write(message + "\n"); } public void LogError(string message) { - + Log($"[color=#{_colors["error"].ToHtml()}]{message}[/color]"); } public void LogWarning(string message) { - + Log($"[color=#{_colors["warning"].ToHtml()}]{message}[/color]"); + } + + public void LogInfo(string message) + { + Log($"[color=#{_colors["info"].ToHtml()}]{message}[/color]"); } public void Write(string message) { - + _output.Text += message; } public void ClearConsole() { - + _output.Text = ""; } public void Exit() { - + Visible = false; } - public string OpeningMessage { get; set; } - public bool IsRunning { get; set; } - public CommandsManager CommandsManager { get; set; } + public override void _Process(double delta) + { + if (Input.IsActionJustPressed("Enter") && _input.HasFocus() && _input.Text.Length > 0) + { + var command = _input.Text; + _input.Clear(); + _output.Text += $"> {command}\n"; + _commandsManager.RunCommand(command); + } + } + + private Godot.Collections.Dictionary BuildKeywords() + { + var keywords = new Godot.Collections.Dictionary(); + foreach (var commandName in _commandsManager.Commands.Keys) + { + keywords.Add(commandName, _colors["commandHighlight"].ToHtml()); + } + + return keywords; + } + } \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs.uid b/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs.uid new file mode 100644 index 0000000..c765642 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs.uid @@ -0,0 +1 @@ +uid://cgn58uiwyog25 diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILesson.cs.uid b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILesson.cs.uid new file mode 100644 index 0000000..125ddc9 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILesson.cs.uid @@ -0,0 +1 @@ +uid://casaduku5g3p0 diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILessonHandler.cs.uid b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILessonHandler.cs.uid new file mode 100644 index 0000000..f48f24d --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILessonHandler.cs.uid @@ -0,0 +1 @@ +uid://bcf583puvlvt1 diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPage.cs.uid b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPage.cs.uid new file mode 100644 index 0000000..68c4217 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPage.cs.uid @@ -0,0 +1 @@ +uid://n46c56nkxhni diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPageComponent.cs.uid b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPageComponent.cs.uid new file mode 100644 index 0000000..eab7bd7 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPageComponent.cs.uid @@ -0,0 +1 @@ +uid://clgpj02pia5d2 diff --git a/ADEPT-Godot/Core/Scripts/Lesson/BasePageComponent.cs.uid b/ADEPT-Godot/Core/Scripts/Lesson/BasePageComponent.cs.uid new file mode 100644 index 0000000..28ce1fe --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Lesson/BasePageComponent.cs.uid @@ -0,0 +1 @@ +uid://cwhhuavq5ximh diff --git a/ADEPT-Godot/Core/Scripts/Lesson/Lesson.cs.uid b/ADEPT-Godot/Core/Scripts/Lesson/Lesson.cs.uid new file mode 100644 index 0000000..c480d47 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Lesson/Lesson.cs.uid @@ -0,0 +1 @@ +uid://dy3wuh6e6yjda diff --git a/ADEPT-Godot/Core/Scripts/Lesson/LessonHandler.cs.uid b/ADEPT-Godot/Core/Scripts/Lesson/LessonHandler.cs.uid new file mode 100644 index 0000000..dd25c0a --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Lesson/LessonHandler.cs.uid @@ -0,0 +1 @@ +uid://b8aqy8n1dyd7c diff --git a/ADEPT-Godot/Core/Scripts/Lesson/Page.cs.uid b/ADEPT-Godot/Core/Scripts/Lesson/Page.cs.uid new file mode 100644 index 0000000..cb0b5a4 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Lesson/Page.cs.uid @@ -0,0 +1 @@ +uid://dfasrsmo4r2oi diff --git a/ADEPT-Godot/Core/Scripts/Main.cs b/ADEPT-Godot/Core/Scripts/Main.cs new file mode 100644 index 0000000..40477ee --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Main.cs @@ -0,0 +1,42 @@ +using System.Reflection; +using Godot; +using ADEPT.Core; +using ADEPT.Core.Cogwheel; +using Cogwheel; + + +namespace ADEPT.Core; + +public partial class Main : Node +{ + private static CommandsManager _commandsManager; + private static ICogwheelConsole _cogwheelConsole; + + public CanvasLayer MainCanvas { get; private set; } + + public override void _Ready() + { + MainCanvas = GetNode("MainCanvas"); + + ADEPT.Initialize(this); + + _commandsManager = new CommandsManager(); + _cogwheelConsole = MainCanvas.GetNode("CogwheelConsole"); + if (_cogwheelConsole is null) throw new System.Exception("CogwheelConsole not found in MainNode."); + + _commandsManager.AddAssembly(Assembly.GetExecutingAssembly()); + _commandsManager.AddAssembly(Assembly.GetAssembly(typeof(CommandsManager))); + + COGWHEEL.Initialize(_commandsManager, _cogwheelConsole); + + GD.Print("ADEPT initialized."); + + COGWHEEL.RegisterObject(this); + } + + [Command(Name = "test", Description = "Test command.")] + private void Test() + { + COGWHEEL.LogWarning("Testing!\nTesting!\nTesting!"); + } +} \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Main.cs.uid b/ADEPT-Godot/Core/Scripts/Main.cs.uid new file mode 100644 index 0000000..4cd61ed --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Main.cs.uid @@ -0,0 +1 @@ +uid://dnmj6a1ptvwry diff --git a/ADEPT-Godot/Core/Scripts/MainNode.cs b/ADEPT-Godot/Core/Scripts/MainNode.cs index effefc3..9c3212b 100644 --- a/ADEPT-Godot/Core/Scripts/MainNode.cs +++ b/ADEPT-Godot/Core/Scripts/MainNode.cs @@ -4,8 +4,5 @@ namespace ADEPT.Core; public partial class MainNode : Node { - public override void _Ready() - { - ADEPT.Initialize(this); - } + } diff --git a/ADEPT-Godot/project.godot b/ADEPT-Godot/project.godot index 26337d2..791f3c5 100644 --- a/ADEPT-Godot/project.godot +++ b/ADEPT-Godot/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="ADEPT" config/version="0.0.0" -run/main_scene="uid://c35ohffpqfqnr" +run/main_scene="uid://udmowtmx1o3l" config/features=PackedStringArray("4.4", "C#", "Forward Plus") boot_splash/show_image=false config/icon="uid://chm704rgdebfb" @@ -20,3 +20,12 @@ config/icon="uid://chm704rgdebfb" [dotnet] project/assembly_name="ADEPT" + +[input] + +Enter={ +"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":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, 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":4194310,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +}