A lot of work, beginning client UI, adding lesson and page handling, etc

This commit is contained in:
2025-02-16 00:57:45 -06:00
parent 119609f38c
commit 4d0e64ed87
22 changed files with 444 additions and 35 deletions

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -0,0 +1,7 @@
namespace ADEPT.Core.Lesson;
public enum PageContext
{
TwoD,
ThreeD,
}

View File

@@ -0,0 +1 @@
uid://b2qkm2ug5c116