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

@@ -0,0 +1,30 @@
using Ghost.Entities;
using System;
using System.Linq;
namespace Ghost.Editor.Helpers;
public static class ComponentTypeCache
{
private static readonly Type?[][] _componentTypes;
static ComponentTypeCache()
{
_componentTypes = new Type[World.WorldCount][];
for (var i = 0; i < World.WorldCount; i++)
{
var world = World.GetWorld(i);
var typeHandles = world.ComponentStorage.ComponentPools.Keys;
_componentTypes[i] = typeHandles.Select(handle => Type.GetTypeFromHandle(RuntimeTypeHandle.FromIntPtr(handle))).ToArray();
}
}
public static Type?[] GetComponentTypes(int worldIndex)
{
if (worldIndex < 0 || worldIndex >= _componentTypes.Length)
{
throw new ArgumentOutOfRangeException(nameof(worldIndex), "Invalid world index.");
}
return _componentTypes[worldIndex];
}
}

View File

@@ -0,0 +1,17 @@
using Microsoft.UI.Xaml.Data;
using System;
namespace Ghost.Editor.Helpers.Converters;
public partial class GetDirectoryNameConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, string language)
{
return value is string path ? System.IO.Path.GetDirectoryName(path) : null;
}
public object? ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}

View File

@@ -1,4 +1,5 @@
using Ghost.Editor.View.Pages.Landing;
using Ghost.Data.Services;
using Ghost.Editor.View.Pages.Landing;
using Ghost.Editor.View.Windows;
using Ghost.Editor.ViewModel.Pages.Landing;
using Ghost.Editor.ViewModel.Windows;
@@ -9,7 +10,7 @@ namespace Ghost.Editor.Helpers;
internal static partial class HostHelper
{
public static void SetupPageService(HostBuilderContext context, IServiceCollection services)
public static void AddLandingScope(HostBuilderContext context, IServiceCollection services)
{
services.AddSingleton<LandingWindow>();
@@ -18,6 +19,11 @@ internal static partial class HostHelper
services.AddTransient<OpenProjectPage>();
services.AddTransient<ProjectService>();
}
public static void AddEngineScope(HostBuilderContext context, IServiceCollection services)
{
services.AddSingleton<EngineEditorWindow>();
services.AddSingleton<EngineEditorViewModel>();
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Pickers;
@@ -11,7 +12,7 @@ public static class SystemUtilities
public static async Task<StorageFolder?> OpenFolderPickerAsync(PickerLocationId startLocation = PickerLocationId.DocumentsLibrary, string settingsIdentifier = "")
{
var openPicker = new FolderPicker();
var hWnd = WindowNative.GetWindowHandle(App.GetWindow());
var hWnd = WindowNative.GetWindowHandle(App.Window);
InitializeWithWindow.Initialize(openPicker, hWnd);
openPicker.SuggestedStartLocation = startLocation;
@@ -21,4 +22,21 @@ public static class SystemUtilities
var folder = await openPicker.PickSingleFolderAsync();
return folder;
}
public static async Task<StorageFile?> OpenFilePickerAsync(PickerLocationId startLocation = PickerLocationId.DocumentsLibrary, string settingsIdentifier = "", params IEnumerable<string> filter)
{
var openPicker = new FileOpenPicker();
var hWnd = WindowNative.GetWindowHandle(App.Window);
InitializeWithWindow.Initialize(openPicker, hWnd);
openPicker.SuggestedStartLocation = startLocation;
openPicker.SettingsIdentifier = settingsIdentifier;
foreach (var fileType in filter)
{
openPicker.FileTypeFilter.Add(fileType);
}
var file = await openPicker.PickSingleFileAsync();
return file;
}
}