forked from Misaki/GhostEngine
Added a new static class `AssetsPath` for asset management. Added a new icon file (`icon-256.ico`) for UI representation. Added new package references to enhance functionality. Added internals visibility attributes for better testing. Added a new `EngineEditorViewModel` class for MVVM support. Added a new `GameObject` class for component management. Added a new `BitSet` class for efficient bit manipulation. Added various utility classes to support the new entity system. Changed the `ID` property in `ProjectInfo` to internal. Changed the `AddProjectAsync` method to return the created `ProjectInfo`. Changed the connection string retrieval method to use the new `Command` constant. Changed the `DataPath` class to use `readonly` fields for folder paths. Changed the `ActivationHandler` class to use new `DataPath` constants. Changed the `OpenProjectPage` layout and interaction for better UI. Updated the target framework to a newer version for compatibility. Updated the `ProjectService` to use new constants from `DataPath`. Updated the `World` class to improve entity management. Refactored the `ProjectRepository` class to encapsulate SQL commands. Refactored the `Transform` class to use properties for better encapsulation.
85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
using Ghost.Data.Services;
|
|
using Ghost.Editor.Helpers;
|
|
using Ghost.Editor.View.Windows;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.UI.Xaml;
|
|
using System;
|
|
|
|
// To learn more about WinUI, the WinUI project structure,
|
|
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
|
|
namespace Ghost.Editor
|
|
{
|
|
/// <summary>
|
|
/// Provides application-specific behavior to supplement the default Application class.
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
private Window? _window;
|
|
|
|
internal IHost Host
|
|
{
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes the singleton application object. This is the first line of authored code
|
|
/// executed, and as such is the logical equivalent of main() or WinMain().
|
|
/// </summary>
|
|
internal App()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Host = Microsoft.Extensions.Hosting.Host.
|
|
CreateDefaultBuilder().
|
|
UseContentRoot(AppContext.BaseDirectory).
|
|
ConfigureServices((context, services) =>
|
|
{
|
|
services.AddSingleton<ProjectService>();
|
|
|
|
HostHelper.SetupPageService(context, services);
|
|
})
|
|
.Build();
|
|
}
|
|
|
|
internal static Window? GetWindow()
|
|
{
|
|
return (Current as App)?._window;
|
|
}
|
|
|
|
internal static void SetWindow(Window window)
|
|
{
|
|
if (Current is App app)
|
|
{
|
|
app._window = window;
|
|
}
|
|
}
|
|
|
|
internal static T GetService<T>() where T : class
|
|
{
|
|
if ((Current as App)!.Host.Services.GetService(typeof(T)) is not T service)
|
|
{
|
|
throw new ArgumentException($"{typeof(T)} needs to be registered in ConfigureServices within App.xaml.cs.");
|
|
}
|
|
|
|
return service;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invoked when the application is launched.
|
|
/// </summary>
|
|
/// <param name="args">Details about the launch request and process.</param>
|
|
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
|
{
|
|
base.OnLaunched(args);
|
|
|
|
ActivationHandler.Handle(args);
|
|
|
|
Host.Start();
|
|
|
|
_window = GetService<LandingWindow>();
|
|
_window.Activate();
|
|
}
|
|
}
|
|
} |