Refactor project structure and enhance functionality

Added `InternalsVisibleTo` attribute for "Ghost.Editor" in `AssemblyInfo.cs`.
Added a binary file `Empty.zip` to the project.
Added a new `ProjectMetadata` class in `ProjectMetadata.cs`.
Added new states and interfaces for managing application states in `EditorState.cs`, `LandingState.cs`, and `IAppState.cs`.
Added a notification service in `INotificationService.cs` and `StackedNotificationService.cs`.
Added new XAML files for UI components, including `InspectorView.xaml` and `InternalControls.xaml`.

Changed the `ProjectInfo` class in `ProjectInfo.cs` to include a `MetadataPath` property instead of `Path` and `EngineVersion`.
Changed the `TemplateInfo` class in `TemplateInfo.cs` to use a struct instead of a class for `TemplateData`.
Changed the `ProjectService` class to use the new `ProjectRepository` for managing project data.

Removed several using directives and the entire `ProjectRepository` class from `ProjectRepository.cs`, replacing it with a new implementation.
Removed old methods and properties in `EntityManager` and `World` classes to improve entity management and component handling.

Updated the `Ghost.Data.csproj` file to include the new `Empty.zip` file as a content item.
Updated the `ProjectRepository` class to manage project data using SQLite.
Updated various XAML files to include new styles and controls, improving the overall UI design.
Updated the `CreateProjectViewModel` to include a notification service and handle project creation logic.
Updated the test project to include references to the new `Ghost.Graphics` project and modified test cases to align with the new structure.
This commit is contained in:
2025-05-31 01:45:34 +09:00
parent 67b6040b5e
commit 61bbb1bc68
66 changed files with 1923 additions and 733 deletions

View File

@@ -2,7 +2,7 @@
namespace Ghost.Data.Models;
public class ProjectInfo
internal class ProjectInfo
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID
@@ -15,17 +15,7 @@ public class ProjectInfo
get; set;
}
public required string Path
{
get; set;
}
public required Version EngineVersion
{
get; set;
}
public required DateTime LastOpened
public required string MetadataPath
{
get; set;
}

View File

@@ -0,0 +1,51 @@
namespace Ghost.Data.Models;
public class ProjectMetadata
{
public const string PROJECT_EXTENSION = "ghostproj";
public Guid ID
{
get; set;
}
public string Name
{
get; set;
}
public Version EngineVersion
{
get; set;
}
public DateTime CreatedAt
{
get; set;
}
public DateTime LastOpened
{
get; set;
}
public ProjectMetadata(string name, Version engineVersion)
{
ID = Guid.NewGuid();
Name = name;
EngineVersion = engineVersion;
CreatedAt = DateTime.UtcNow;
LastOpened = DateTime.UtcNow;
}
// Parameterless constructor for deserialization
public ProjectMetadata()
{
}
}
public readonly struct ProjectMetadataInfo(string path, ProjectMetadata metadata)
{
public readonly string Path => path;
public readonly ProjectMetadata Metadata => metadata;
}

View File

@@ -0,0 +1,53 @@
namespace Ghost.Data.Models;
public readonly struct Result
{
public readonly bool success;
public readonly string? message;
public Result(bool success, string? message = null)
{
this.success = success;
this.message = message;
}
public static Result OK()
{
return new Result(true);
}
public static Result Error(string? message)
{
return new Result(false, message);
}
public override string ToString() => success ? "OK" : $"Error: {message}";
}
public readonly struct Result<T>
{
public readonly bool success;
public readonly T? data;
public readonly string? message;
public Result(bool success, T? data, string? message = null)
{
this.success = success;
this.data = data;
this.message = message;
}
public static Result<T> OK(T data)
{
return new Result<T>(true, data);
}
public static Result<T> Error(string? message)
{
return new Result<T>(false, default, message);
}
public override string ToString() => success ? $"OK: {data}" : $"Error: {message}";
}

View File

@@ -23,21 +23,21 @@ public class TemplateInfo
}
}
public class TemplateData(string templatePath, TemplateInfo info)
public struct TemplateData(string templatePath, TemplateInfo info)
{
private const string _ICON_NAME = "icon.png";
private const string _PREVIEW_NAME = "preview.png";
public string directory = Path.GetDirectoryName(templatePath)!;
public TemplateInfo Info => info;
public readonly TemplateInfo Info => info;
public Uri GetIconURI()
public readonly Uri GetIconURI()
{
return new Uri(Path.Combine(directory, _ICON_NAME));
}
public Uri GetPreviewURI()
public readonly Uri GetPreviewURI()
{
return new Uri(Path.Combine(directory, _PREVIEW_NAME));
}