A lot of work, beginning client UI, adding lesson and page handling, etc
This commit is contained in:
@@ -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")]
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
7
ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs
Normal file
7
ADEPT-Godot/Core/Scripts/Interfaces/IPageComponent.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace ADEPT.Core.Interfaces;
|
||||
|
||||
public interface IPageComponent
|
||||
{
|
||||
public void Initialize();
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bre7ys55gndei
|
||||
@@ -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<IPage> 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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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<IPageComponent> Components { get; set; }
|
||||
|
||||
public void Start();
|
||||
public void End();
|
||||
|
||||
|
||||
}
|
||||
@@ -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<IPage> 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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<IPageComponent> Components { get; set; }
|
||||
public void Start()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void End()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
7
ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs
Normal file
7
ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace ADEPT.Core.Lesson;
|
||||
|
||||
public enum PageContext
|
||||
{
|
||||
TwoD,
|
||||
ThreeD,
|
||||
}
|
||||
1
ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs.uid
Normal file
1
ADEPT-Godot/Core/Scripts/Lesson/PageContext.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b2qkm2ug5c116
|
||||
@@ -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<CanvasLayer>("MainCanvas");
|
||||
|
||||
ADEPT.Initialize(this);
|
||||
|
||||
_commandsManager = new CommandsManager();
|
||||
_cogwheelConsole = MainCanvas.GetNode<GodotCogwheelConsole>("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!");
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Godot;
|
||||
|
||||
namespace ADEPT.Core;
|
||||
|
||||
public partial class MainNode : Node
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://bl2h8ot302x3g
|
||||
Reference in New Issue
Block a user