forked from Misaki/GhostEngine
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:
@@ -1,6 +1,6 @@
|
||||
using Ghost.Data.Services;
|
||||
using Ghost.Editor.AppStates;
|
||||
using Ghost.Editor.Helpers;
|
||||
using Ghost.Editor.View.Windows;
|
||||
using Ghost.Editor.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.UI.Xaml;
|
||||
@@ -18,6 +18,18 @@ namespace Ghost.Editor
|
||||
{
|
||||
private Window? _window;
|
||||
|
||||
internal static Window? Window
|
||||
{
|
||||
get => (Current as App)?._window;
|
||||
set
|
||||
{
|
||||
if (Current is App app)
|
||||
{
|
||||
app._window = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal IHost Host
|
||||
{
|
||||
get;
|
||||
@@ -36,27 +48,29 @@ namespace Ghost.Editor
|
||||
UseContentRoot(AppContext.BaseDirectory).
|
||||
ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddSingleton<ProjectService>();
|
||||
services.AddSingleton(sp =>
|
||||
{
|
||||
return new AppStateService(
|
||||
new LandingState(),
|
||||
new EditorState());
|
||||
});
|
||||
|
||||
HostHelper.SetupPageService(context, services);
|
||||
HostHelper.AddLandingScope(context, services);
|
||||
HostHelper.AddEngineScope(context, services);
|
||||
|
||||
services.AddSingleton<StackedNotificationService>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
UnhandledException += App_UnhandledException;
|
||||
}
|
||||
|
||||
internal static Window? GetWindow()
|
||||
internal static IServiceScope CreateScope()
|
||||
{
|
||||
return (Current as App)?._window;
|
||||
return (Current as App)!.Host.Services.CreateScope();
|
||||
}
|
||||
|
||||
internal static void SetWindow(Window window)
|
||||
{
|
||||
if (Current is App app)
|
||||
{
|
||||
app._window = window;
|
||||
}
|
||||
}
|
||||
|
||||
internal static T GetService<T>() where T : class
|
||||
public static T GetService<T>() where T : class
|
||||
{
|
||||
if ((Current as App)!.Host.Services.GetService(typeof(T)) is not T service)
|
||||
{
|
||||
@@ -70,7 +84,7 @@ namespace Ghost.Editor
|
||||
/// Invoked when the application is launched.
|
||||
/// </summary>
|
||||
/// <param name="args">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
protected override async void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
base.OnLaunched(args);
|
||||
|
||||
@@ -78,8 +92,13 @@ namespace Ghost.Editor
|
||||
|
||||
Host.Start();
|
||||
|
||||
_window = GetService<LandingWindow>();
|
||||
_window.Activate();
|
||||
await GetService<AppStateService>().TransitionToAsync(StateKey.Landing);
|
||||
}
|
||||
|
||||
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
|
||||
{
|
||||
// TODO: Log and handle exceptions as appropriate.
|
||||
// https://docs.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.unhandledexception.
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user