From 4d0e64ed8790410056153da419727aa8654cacf9 Mon Sep 17 00:00:00 2001 From: Chris Bell Date: Sun, 16 Feb 2025 00:57:45 -0600 Subject: [PATCH] A lot of work, beginning client UI, adding lesson and page handling, etc --- ADEPT-Godot/ADEPT.sln.DotSettings.user | 1 + ADEPT-Godot/Client/Scenes/ClientMain.tscn | 154 ++++++++++++++++++ ADEPT-Godot/Client/Scenes/MainCanvas.tscn | 5 +- ADEPT-Godot/Client/Scripts/UI/ClientMain.cs | 48 ++++++ .../Client/Scripts/UI/ClientMain.cs.uid | 1 + ADEPT-Godot/Core/Scenes/Main.tscn | 27 ++- .../Core/Scripts/{ADEPT.cs => Adept.cs} | 11 +- .../Scripts/Cogwheel/GodotCogwheelConsole.cs | 10 ++ .../Core/Scripts/Interfaces/IPageComponent.cs | 7 + .../Scripts/Interfaces/IPageComponent.cs.uid | 1 + .../Core/Scripts/Interfaces/Lesson/ILesson.cs | 11 ++ .../Interfaces/Lesson/ILessonHandler.cs | 17 +- .../Core/Scripts/Interfaces/Lesson/IPage.cs | 11 ++ ADEPT-Godot/Core/Scripts/Lesson/Lesson.cs | 26 ++- .../Core/Scripts/Lesson/LessonHandler.cs | 94 ++++++++++- ADEPT-Godot/Core/Scripts/Lesson/Page.cs | 17 +- .../Core/Scripts/Lesson/PageContext.cs | 7 + .../Core/Scripts/Lesson/PageContext.cs.uid | 1 + ADEPT-Godot/Core/Scripts/Main.cs | 16 +- ADEPT-Godot/Core/Scripts/MainNode.cs | 8 - ADEPT-Godot/Core/Scripts/MainNode.cs.uid | 1 - ADEPT-Godot/project.godot | 5 + 22 files changed, 444 insertions(+), 35 deletions(-) create mode 100644 ADEPT-Godot/Client/Scenes/ClientMain.tscn create mode 100644 ADEPT-Godot/Client/Scripts/UI/ClientMain.cs create mode 100644 ADEPT-Godot/Client/Scripts/UI/ClientMain.cs.uid rename ADEPT-Godot/Core/Scripts/{ADEPT.cs => Adept.cs} (61%) create mode 100644 ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs create mode 100644 ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs.uid create mode 100644 ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs create mode 100644 ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs.uid delete mode 100644 ADEPT-Godot/Core/Scripts/MainNode.cs delete mode 100644 ADEPT-Godot/Core/Scripts/MainNode.cs.uid diff --git a/ADEPT-Godot/ADEPT.sln.DotSettings.user b/ADEPT-Godot/ADEPT.sln.DotSettings.user index dce9f62..4fdaeec 100644 --- a/ADEPT-Godot/ADEPT.sln.DotSettings.user +++ b/ADEPT-Godot/ADEPT.sln.DotSettings.user @@ -1,5 +1,6 @@  ForceIncluded + ForceIncluded ForceIncluded <AssemblyExplorer> <Assembly Path="/home/chris/.nuget/packages/cogwheellib/1.3.0/lib/net9.0/CogwheelLib.dll" /> diff --git a/ADEPT-Godot/Client/Scenes/ClientMain.tscn b/ADEPT-Godot/Client/Scenes/ClientMain.tscn new file mode 100644 index 0000000..12059c4 --- /dev/null +++ b/ADEPT-Godot/Client/Scenes/ClientMain.tscn @@ -0,0 +1,154 @@ +[gd_scene load_steps=6 format=3 uid="uid://bbogimp25gyre"] + +[ext_resource type="Script" uid="uid://dta0h5g01sooo" path="res://Client/Scripts/UI/ClientMain.cs" id="1_t0hef"] +[ext_resource type="Texture2D" uid="uid://chm704rgdebfb" path="res://icon.png" id="2_gv8lv"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gv8lv"] +bg_color = Color(0, 0.301961, 0.301961, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nd7pt"] +bg_color = Color(0.6, 0.6, 0.6, 0) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_inrp4"] +bg_color = Color(0.6, 0.6, 0.6, 0) + +[node name="ClientMain" type="Control" node_paths=PackedStringArray("_lessonTitleLabel", "_pageTitleLabel", "_backNavButton", "_nextNavButton", "_menuNavButton")] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource("1_t0hef") +_lessonTitleLabel = NodePath("VBoxContainer/Header/MarginContainer/VBoxContainer/LessonTitle") +_pageTitleLabel = NodePath("VBoxContainer/Header/MarginContainer/VBoxContainer/PageTitle") +_backNavButton = NodePath("VBoxContainer/Footer/MarginContainer/NavigationButtons/Panel/HBoxContainer/BackButton") +_nextNavButton = NodePath("VBoxContainer/Footer/MarginContainer/NavigationButtons/Panel/HBoxContainer/NextButton") +_menuNavButton = NodePath("VBoxContainer/Footer/MarginContainer/NavigationButtons/Panel/HBoxContainer/MenuButton") + +[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="Header" type="Panel" parent="VBoxContainer"] +custom_minimum_size = Vector2(0, 80) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_gv8lv") + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/Header"] +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 = 20 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 20 +theme_override_constants/margin_bottom = 10 + +[node name="TextureRect" type="TextureRect" parent="VBoxContainer/Header/MarginContainer"] +custom_minimum_size = Vector2(0, 50) +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 4 +texture = ExtResource("2_gv8lv") +expand_mode = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/Header/MarginContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 + +[node name="LessonTitle" type="Label" parent="VBoxContainer/Header/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +text = "Lesson Title" + +[node name="PageTitle" type="Label" parent="VBoxContainer/Header/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +text = "Page Title" + +[node name="MainContentMargin" type="MarginContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +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="Panel" type="Panel" parent="VBoxContainer/MainContentMargin"] +visible = false +layout_mode = 2 + +[node name="Footer" type="Panel" parent="VBoxContainer"] +custom_minimum_size = Vector2(0, 60) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_nd7pt") + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/Footer"] +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 = 15 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_right = 15 +theme_override_constants/margin_bottom = 5 + +[node name="NavigationButtons" type="Control" parent="VBoxContainer/Footer/MarginContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 + +[node name="Panel" type="Panel" parent="VBoxContainer/Footer/MarginContainer/NavigationButtons"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_inrp4") + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Footer/MarginContainer/NavigationButtons/Panel"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -49.0 +offset_top = -15.5 +offset_right = 49.0 +offset_bottom = 15.5 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="BackButton" type="Button" parent="VBoxContainer/Footer/MarginContainer/NavigationButtons/Panel/HBoxContainer"] +custom_minimum_size = Vector2(30, 20) +layout_mode = 2 +size_flags_horizontal = 2 +text = "<" + +[node name="MenuButton" type="Button" parent="VBoxContainer/Footer/MarginContainer/NavigationButtons/Panel/HBoxContainer"] +custom_minimum_size = Vector2(30, 20) +layout_mode = 2 +size_flags_horizontal = 6 +text = "≡" + +[node name="NextButton" type="Button" parent="VBoxContainer/Footer/MarginContainer/NavigationButtons/Panel/HBoxContainer"] +custom_minimum_size = Vector2(30, 20) +layout_mode = 2 +size_flags_horizontal = 10 +text = ">" diff --git a/ADEPT-Godot/Client/Scenes/MainCanvas.tscn b/ADEPT-Godot/Client/Scenes/MainCanvas.tscn index 7c91436..eab2d45 100644 --- a/ADEPT-Godot/Client/Scenes/MainCanvas.tscn +++ b/ADEPT-Godot/Client/Scenes/MainCanvas.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=3 uid="uid://c35ohffpqfqnr"] +[gd_scene load_steps=4 format=3 uid="uid://c35ohffpqfqnr"] [ext_resource type="Texture2D" uid="uid://chm704rgdebfb" path="res://icon.png" id="2_swjw6"] +[ext_resource type="PackedScene" uid="uid://bbogimp25gyre" path="res://Client/Scenes/ClientMain.tscn" id="2_uaail"] [ext_resource type="PackedScene" uid="uid://caivf0icbv7gk" path="res://Core/Scenes/CogwheelConsole.tscn" id="3_ama40"] [node name="MainCanvas" type="CanvasLayer"] @@ -30,4 +31,6 @@ grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("2_swjw6") +[node name="ClientMain" parent="." instance=ExtResource("2_uaail")] + [node name="CogwheelConsole" parent="." instance=ExtResource("3_ama40")] diff --git a/ADEPT-Godot/Client/Scripts/UI/ClientMain.cs b/ADEPT-Godot/Client/Scripts/UI/ClientMain.cs new file mode 100644 index 0000000..5f10f75 --- /dev/null +++ b/ADEPT-Godot/Client/Scripts/UI/ClientMain.cs @@ -0,0 +1,48 @@ +using Godot; +using System; +using ADEPT.Core; +using Cogwheel; + +public partial class ClientMain : Control +{ + [Export] private Label _lessonTitleLabel; + [Export] private Label _pageTitleLabel; + + [Export] private Button _backNavButton; + [Export] private Button _nextNavButton; + [Export] private Button _menuNavButton; + + public override void _Ready() + { + GetTree().CreateTimer(1).Timeout += () => { COGWHEEL.RegisterObject(this); Init(); }; + + } + + [Command(Name = "client.init", Description = "Initialize the client")] + private void Init() + { + Adept.LessonHandler.LessonLoaded += (s, o) => + { + _lessonTitleLabel.Text = Adept.LessonHandler.CurrentLesson.Title; + _pageTitleLabel.Text = Adept.LessonHandler.CurrentPage.Title; + }; + + Adept.LessonHandler.PageChanged += (s, o) => + { + _pageTitleLabel.Text = Adept.LessonHandler.CurrentPage.Title; + }; + + _backNavButton.Pressed += () => + { + // Adept.LessonHandler.LoadPreviousPage(); + COGWHEEL.RunCommand("lesson.previous"); + }; + + _nextNavButton.Pressed += () => + { + // Adept.LessonHandler.LoadNextPage(); + COGWHEEL.RunCommand("lesson.next"); + }; + + } +} diff --git a/ADEPT-Godot/Client/Scripts/UI/ClientMain.cs.uid b/ADEPT-Godot/Client/Scripts/UI/ClientMain.cs.uid new file mode 100644 index 0000000..5fc2c79 --- /dev/null +++ b/ADEPT-Godot/Client/Scripts/UI/ClientMain.cs.uid @@ -0,0 +1 @@ +uid://dta0h5g01sooo diff --git a/ADEPT-Godot/Core/Scenes/Main.tscn b/ADEPT-Godot/Core/Scenes/Main.tscn index 43e7b92..637c9f5 100644 --- a/ADEPT-Godot/Core/Scenes/Main.tscn +++ b/ADEPT-Godot/Core/Scenes/Main.tscn @@ -1,9 +1,32 @@ -[gd_scene load_steps=3 format=3 uid="uid://udmowtmx1o3l"] +[gd_scene load_steps=6 format=3 uid="uid://udmowtmx1o3l"] [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"] +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_0ovck"] +sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1) +ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1) + +[sub_resource type="Sky" id="Sky_r0sft"] +sky_material = SubResource("ProceduralSkyMaterial_0ovck") + +[sub_resource type="Environment" id="Environment_h3byd"] +background_mode = 2 +sky = SubResource("Sky_r0sft") +tonemap_mode = 2 +glow_enabled = true + +[node name="Main" type="Node3D"] script = ExtResource("1_0ovck") +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_h3byd") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0) +shadow_enabled = true + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2.21642) + [node name="MainCanvas" parent="." instance=ExtResource("2_0ovck")] diff --git a/ADEPT-Godot/Core/Scripts/ADEPT.cs b/ADEPT-Godot/Core/Scripts/Adept.cs similarity index 61% rename from ADEPT-Godot/Core/Scripts/ADEPT.cs rename to ADEPT-Godot/Core/Scripts/Adept.cs index aa21a67..5fb6cce 100644 --- a/ADEPT-Godot/Core/Scripts/ADEPT.cs +++ b/ADEPT-Godot/Core/Scripts/Adept.cs @@ -1,17 +1,16 @@ -using System.Reflection; -using ADEPT.Core.Cogwheel; -using Cogwheel; -using Godot; +using ADEPT.Core.Lesson; namespace ADEPT.Core; -public static class ADEPT +public static class Adept { public static Main MainNode { get; private set; } + public static LessonHandler LessonHandler { get; private set; } - public static void Initialize(Main mainNode) + public static void Initialize(Main mainNode, LessonHandler lessonHandler) { MainNode = mainNode; + LessonHandler = lessonHandler; } public static class Constants diff --git a/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs b/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs index 7445366..5f368a9 100644 --- a/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs +++ b/ADEPT-Godot/Core/Scripts/Cogwheel/GodotCogwheelConsole.cs @@ -102,6 +102,11 @@ public partial class GodotCogwheelConsole : Control, ICogwheelConsole _output.Text += $"> {command}\n"; _commandsManager.RunCommand(command); } + + if (Input.IsActionJustPressed("debug")) + { + ToggleConsole(); + } } private Godot.Collections.Dictionary BuildKeywords() @@ -115,4 +120,9 @@ public partial class GodotCogwheelConsole : Control, ICogwheelConsole return keywords; } + private void ToggleConsole() + { + Visible = !Visible; + } + } \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs b/ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs new file mode 100644 index 0000000..63b5269 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs @@ -0,0 +1,7 @@ +namespace ADEPT.Core.Interfaces; + +public interface IPageComponent +{ + public void Initialize(); + +} \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs.uid b/ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs.uid new file mode 100644 index 0000000..e7de3b6 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs.uid @@ -0,0 +1 @@ +uid://bre7ys55gndei diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILesson.cs b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILesson.cs index 98d604a..0506b70 100644 --- a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILesson.cs +++ b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILesson.cs @@ -1,6 +1,17 @@ +using System.Collections.Generic; + namespace ADEPT.Core.Lesson; public interface ILesson { + public string Title { get; set; } + public string Description { get; set; } + public List Pages { get; set; } + public object LessonStateMachine { get; set; } // TODO: Implement an ILessonStateMachine + + public void StartLesson(); + public void EndLesson(); + public void AddPage(IPage page); + public void RemovePage(IPage page); } \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILessonHandler.cs b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILessonHandler.cs index 0159712..479adb3 100644 --- a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILessonHandler.cs +++ b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/ILessonHandler.cs @@ -1,7 +1,20 @@ +using System; + namespace ADEPT.Core.Lesson; public interface ILessonHandler { - public ILesson loadLesson(string lessonName); - public void saveLesson(ILesson lesson, string lessonName); + + public event EventHandler LessonLoaded; + public event EventHandler PageChanged; + + public ILesson CurrentLesson { get; } + public IPage CurrentPage { get; } + + public void LoadLesson(string lessonName); + public void SaveLesson(ILesson lesson, string lessonName); + + public void LoadNextPage(); + public void LoadPreviousPage(); + public void LoadPageToIndex(int index); } \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPage.cs b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPage.cs index c0de70d..9f020eb 100644 --- a/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPage.cs +++ b/ADEPT-Godot/Core/Scripts/Interfaces/Lesson/IPage.cs @@ -1,6 +1,17 @@ +using System.Collections.Generic; + namespace ADEPT.Core.Lesson; public interface IPage { + public string Title { get; set; } + public string Description { get; set; } + public ILesson Lesson { get; } + public PageContext PageContext { get; set; } + public List Components { get; set; } + + public void Start(); + public void End(); + } \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Lesson/Lesson.cs b/ADEPT-Godot/Core/Scripts/Lesson/Lesson.cs index 4dd5f42..29fe954 100644 --- a/ADEPT-Godot/Core/Scripts/Lesson/Lesson.cs +++ b/ADEPT-Godot/Core/Scripts/Lesson/Lesson.cs @@ -1,6 +1,30 @@ +using System.Collections.Generic; + namespace ADEPT.Core.Lesson; public class Lesson : ILesson { - + public string Title { get; set; } + public string Description { get; set; } + public List Pages { get; set; } + public object LessonStateMachine { get; set; } + public void StartLesson() + { + throw new System.NotImplementedException(); + } + + public void EndLesson() + { + throw new System.NotImplementedException(); + } + + public void AddPage(IPage page) + { + throw new System.NotImplementedException(); + } + + public void RemovePage(IPage page) + { + throw new System.NotImplementedException(); + } } \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Lesson/LessonHandler.cs b/ADEPT-Godot/Core/Scripts/Lesson/LessonHandler.cs index c32f104..1285aab 100644 --- a/ADEPT-Godot/Core/Scripts/Lesson/LessonHandler.cs +++ b/ADEPT-Godot/Core/Scripts/Lesson/LessonHandler.cs @@ -1,18 +1,104 @@ +using System; using Cogwheel; namespace ADEPT.Core.Lesson; public class LessonHandler : ILessonHandler { - public ILesson loadLesson(string lessonName) + public event EventHandler LessonLoaded; + public event EventHandler PageChanged; + + public ILesson CurrentLesson { get; private set; } + public IPage CurrentPage { get; private set; } + + public void Initialize() { - var path = $"{ADEPT.Constants.DefaultLessonPath}{lessonName}{ADEPT.Constants.DefaultLessonFileExtension}"; + COGWHEEL.RegisterObject(this); + } + + [Command(Name = "lesson.load", Description = "Load a lesson.")] + public void LoadLesson(string lessonName) + { + var path = $"{Adept.Constants.DefaultLessonPath}{lessonName}{Adept.Constants.DefaultLessonFileExtension}"; + COGWHEEL.Log($"[ADEPT] Attempting to load lesson '{lessonName}' at '{path}'"); + + // Lesson lesson = null; + // + // CurrentLesson = lesson; + // CurrentPage = CurrentLesson.Pages.ToArray()[0]; + // + // LessonLoaded?.Invoke(this, EventArgs.Empty); + } + + [Command(Name = "lesson.createtest", Description = "Create a test lesson.")] + private void CreateTestLesson() + { + COGWHEEL.Log($"[ADEPT] Creating a Test Lesson"); + var lesson = new Lesson() + { + Title = "Test Lesson", + Description = "This is a test lesson.", + Pages = new() + { + new Page() { Title = "Test Page 1", Description = "A test page.", PageContext = PageContext.TwoD}, + new Page() { Title = "Test Page 2", Description = "A test page #2.", PageContext = PageContext.ThreeD}, + new Page() { Title = "Test Page 3", Description = "A test page #3.", PageContext = PageContext.TwoD}, + new Page() { Title = "Test Page 4", Description = "A test page #4.", PageContext = PageContext.ThreeD}, + new Page() { Title = "Test Page 5", Description = "A test page #5.", PageContext = PageContext.TwoD}, + } + }; + + CurrentLesson = lesson; + CurrentPage = CurrentLesson.Pages.ToArray()[0]; + + LessonLoaded?.Invoke(this, EventArgs.Empty); + } + + public void SaveLesson(ILesson lesson, string lessonName) + { throw new System.NotImplementedException(); } - public void saveLesson(ILesson lesson, string lessonName) + [Command(Name = "lesson.next", Description = "Load the next page in the current lesson.")] + public void LoadNextPage() { - throw new System.NotImplementedException(); + var nextIndex = CurrentLesson.Pages.IndexOf(CurrentPage) + 1; + if (nextIndex >= CurrentLesson.Pages.Count) + { + COGWHEEL.LogWarning("[LESSONHANDLER] Cannot load next page. No more pages in lesson."); + return; + } + + CurrentPage = CurrentLesson.Pages.ToArray()[nextIndex]; + PageChanged?.Invoke(this, EventArgs.Empty); + } + + [Command(Name = "lesson.previous", Description = "Load the previous page in the current lesson.")] + public void LoadPreviousPage() + { + var prevIndex = CurrentLesson.Pages.IndexOf(CurrentPage) - 1; + if (prevIndex < 0) + { + COGWHEEL.LogWarning("[LESSONHANDLER] Cannot load previous page. No more pages in lesson."); + return; + } + + CurrentPage = CurrentLesson.Pages.ToArray()[prevIndex]; + PageChanged?.Invoke(this, EventArgs.Empty); + } + + [Command(Name = "lesson.gotopage", Description = "Load a specific page in the current lesson.")] + public void LoadPageToIndex(int index) + { + if (index >= CurrentLesson.Pages.Count || index < 0) + { + COGWHEEL.LogWarning("[LESSONHANDLER] Cannot load page. No such page in lesson."); + return; + } + + COGWHEEL.Log("[LESSONHANDLER] Loading Page at index " + index); + CurrentPage = CurrentLesson.Pages.ToArray()[index]; + PageChanged?.Invoke(this, EventArgs.Empty); } } \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Lesson/Page.cs b/ADEPT-Godot/Core/Scripts/Lesson/Page.cs index b84b88b..bb96241 100644 --- a/ADEPT-Godot/Core/Scripts/Lesson/Page.cs +++ b/ADEPT-Godot/Core/Scripts/Lesson/Page.cs @@ -1,6 +1,21 @@ +using System.Collections.Generic; + namespace ADEPT.Core.Lesson; public class Page : IPage { - + public string Title { get; set; } + public string Description { get; set; } + public ILesson Lesson { get; } + public PageContext PageContext { get; set; } + public List Components { get; set; } + public void Start() + { + throw new System.NotImplementedException(); + } + + public void End() + { + throw new System.NotImplementedException(); + } } \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs b/ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs new file mode 100644 index 0000000..0b64c95 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs @@ -0,0 +1,7 @@ +namespace ADEPT.Core.Lesson; + +public enum PageContext +{ + TwoD, + ThreeD, +} \ No newline at end of file diff --git a/ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs.uid b/ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs.uid new file mode 100644 index 0000000..0b97474 --- /dev/null +++ b/ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs.uid @@ -0,0 +1 @@ +uid://b2qkm2ug5c116 diff --git a/ADEPT-Godot/Core/Scripts/Main.cs b/ADEPT-Godot/Core/Scripts/Main.cs index 3b6a857..32144e9 100644 --- a/ADEPT-Godot/Core/Scripts/Main.cs +++ b/ADEPT-Godot/Core/Scripts/Main.cs @@ -2,6 +2,7 @@ using System.Reflection; using Godot; using ADEPT.Core; using ADEPT.Core.Cogwheel; +using ADEPT.Core.Lesson; using Cogwheel; @@ -11,6 +12,7 @@ public partial class Main : Node { private static CommandsManager _commandsManager; private static GodotCogwheelConsole _cogwheelConsole; + private static LessonHandler _lessonHandler; public CanvasLayer MainCanvas { get; private set; } @@ -18,7 +20,6 @@ public partial class Main : Node { MainCanvas = GetNode("MainCanvas"); - ADEPT.Initialize(this); _commandsManager = new CommandsManager(); _cogwheelConsole = MainCanvas.GetNode("CogwheelConsole"); @@ -29,16 +30,13 @@ public partial class Main : Node COGWHEEL.Initialize(_commandsManager, _cogwheelConsole); COGWHEEL.RegisterObject(this); + + _lessonHandler = new LessonHandler(); + _lessonHandler.Initialize(); + Adept.Initialize(this, _lessonHandler); _cogwheelConsole.LogInfo("COGWHEEL " + " initialized."); - _cogwheelConsole.LogInfo("ADEPT " + ADEPT.Constants.Version + " initialized."); + _cogwheelConsole.LogInfo("ADEPT " + Adept.Constants.Version + " initialized."); _cogwheelConsole.LogInfo("Type 'list' for a list of commands."); - - } - - [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/MainNode.cs b/ADEPT-Godot/Core/Scripts/MainNode.cs deleted file mode 100644 index 9c3212b..0000000 --- a/ADEPT-Godot/Core/Scripts/MainNode.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Godot; - -namespace ADEPT.Core; - -public partial class MainNode : Node -{ - -} diff --git a/ADEPT-Godot/Core/Scripts/MainNode.cs.uid b/ADEPT-Godot/Core/Scripts/MainNode.cs.uid deleted file mode 100644 index 0ff0fde..0000000 --- a/ADEPT-Godot/Core/Scripts/MainNode.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bl2h8ot302x3g diff --git a/ADEPT-Godot/project.godot b/ADEPT-Godot/project.godot index 791f3c5..2518918 100644 --- a/ADEPT-Godot/project.godot +++ b/ADEPT-Godot/project.godot @@ -29,3 +29,8 @@ Enter={ , 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) ] } +debug={ +"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":96,"key_label":0,"unicode":96,"location":0,"echo":false,"script":null) +] +}