From eadd13931fdb66f329d2d352d34c731b179e4bd5 Mon Sep 17 00:00:00 2001 From: Misaki Date: Wed, 4 Feb 2026 19:08:18 +0900 Subject: [PATCH] Updating ProjectBrowser --- .../AssetHandle/AssetImporterAttribute.cs | 15 --- .../AssetHandle/AssetOpenHandlerAttribute .cs | 15 --- Ghost.Editor.Core/Attributes.cs | 102 ++++++++++++++++++ .../Controls/ControlsDictionary.xaml | 3 +- .../Controls/Internal/ComponentView.cs | 2 +- ...ponentDataView.xaml => ComponentView.xaml} | 2 +- .../Controls/Internal/NavigationTabView.cs | 2 +- .../Controls/Internal/NavigationTabView.xaml | 5 - .../Controls/Menu/ContextFlyout.cs | 95 ++++++++++++++++ Ghost.Editor.Core/EditorApplication.cs | 21 ++++ Ghost.Editor.Core/EditorInjectionAttribute.cs | 28 ----- Ghost.Editor.Core/Ghost.Editor.Core.csproj | 8 +- .../Inspector/CustomEditorAttribute.cs | 10 -- Ghost.Editor.Core/Utilities/TypeCache.cs | 57 +++++++++- Ghost.Editor/App.xaml.cs | 4 + Ghost.Editor/Components/LocalToWorldEditor.cs | 1 + Ghost.Editor/Ghost.Editor.csproj | 3 + Ghost.Editor/Themes/Generic.xaml | 4 +- .../View/Controls/ProjectBrowser.Menu.cs | 23 ++++ .../View/Controls/ProjectBrowser.xaml | 18 ++-- .../View/Controls/ProjectBrowser.xaml.cs | 21 +++- .../Pages/EngineEditor/HierarchyPage.xaml | 2 +- .../Pages/EngineEditor/HierarchyPage.xaml.cs | 2 +- .../Pages/EngineEditor/InspectorPage.xaml | 2 +- .../Pages/EngineEditor/InspectorPage.xaml.cs | 2 +- .../View/Pages/EngineEditor/ScenePage.xaml | 2 +- .../View/Pages/EngineEditor/ScenePage.xaml.cs | 2 +- .../View/Windows/EngineEditorWindow.xaml | 60 +++++------ .../View/Windows/SplashWindow.xaml.cs | 3 +- .../Controls/ProjectBrowserViewModel.cs | 7 ++ 30 files changed, 382 insertions(+), 139 deletions(-) delete mode 100644 Ghost.Editor.Core/AssetHandle/AssetImporterAttribute.cs delete mode 100644 Ghost.Editor.Core/AssetHandle/AssetOpenHandlerAttribute .cs create mode 100644 Ghost.Editor.Core/Attributes.cs rename Ghost.Editor.Core/Controls/Internal/{ComponentDataView.xaml => ComponentView.xaml} (93%) delete mode 100644 Ghost.Editor.Core/Controls/Internal/NavigationTabView.xaml create mode 100644 Ghost.Editor.Core/Controls/Menu/ContextFlyout.cs delete mode 100644 Ghost.Editor.Core/EditorInjectionAttribute.cs delete mode 100644 Ghost.Editor.Core/Inspector/CustomEditorAttribute.cs create mode 100644 Ghost.Editor/View/Controls/ProjectBrowser.Menu.cs diff --git a/Ghost.Editor.Core/AssetHandle/AssetImporterAttribute.cs b/Ghost.Editor.Core/AssetHandle/AssetImporterAttribute.cs deleted file mode 100644 index 7b2756e..0000000 --- a/Ghost.Editor.Core/AssetHandle/AssetImporterAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Ghost.Editor.Core.AssetHandle; - -[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] -internal class AssetImporterAttribute : Attribute -{ - public string[] SupportedExtensions - { - get; - } - - public AssetImporterAttribute(params string[] supportedExtensions) - { - SupportedExtensions = supportedExtensions; - } -} \ No newline at end of file diff --git a/Ghost.Editor.Core/AssetHandle/AssetOpenHandlerAttribute .cs b/Ghost.Editor.Core/AssetHandle/AssetOpenHandlerAttribute .cs deleted file mode 100644 index 3ac4d9a..0000000 --- a/Ghost.Editor.Core/AssetHandle/AssetOpenHandlerAttribute .cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Ghost.Editor.Core.AssetHandle; - -[AttributeUsage(AttributeTargets.Method)] -public class AssetOpenHandlerAttribute : Attribute -{ - public string[] Extensions - { - get; - } - - public AssetOpenHandlerAttribute(params string[] extensions) - { - Extensions = extensions.Select(e => e.StartsWith('.') ? e.ToLowerInvariant() : '.' + e.ToLowerInvariant()).ToArray(); - } -} \ No newline at end of file diff --git a/Ghost.Editor.Core/Attributes.cs b/Ghost.Editor.Core/Attributes.cs new file mode 100644 index 0000000..f381aec --- /dev/null +++ b/Ghost.Editor.Core/Attributes.cs @@ -0,0 +1,102 @@ +namespace Ghost.Editor.Core; + +/// +/// The base class for all attributes that can be discovered via . +/// +public abstract class DiscoverableAttributeBase : Attribute; + + +[AttributeUsage(AttributeTargets.Method)] +public class AssetOpenHandlerAttribute : DiscoverableAttributeBase +{ + public string[] Extensions + { + get; + } + + public AssetOpenHandlerAttribute(params string[] extensions) + { + Extensions = extensions.Select(e => e.StartsWith('.') ? e.ToLowerInvariant() : '.' + e.ToLowerInvariant()).ToArray(); + } +} + +[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] +internal class AssetImporterAttribute : DiscoverableAttributeBase +{ + public string[] SupportedExtensions + { + get; + } + + public AssetImporterAttribute(params string[] supportedExtensions) + { + SupportedExtensions = supportedExtensions; + } +} + +[AttributeUsage(AttributeTargets.Class)] +public class CustomEditorAttribute : DiscoverableAttributeBase +{ + internal Type TargetType + { + get; + } + + public CustomEditorAttribute(Type targetType) + { + TargetType = targetType; + } +} + +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] +public class EditorInjectionAttribute : DiscoverableAttributeBase +{ + public enum ServiceLifetime + { + Singleton, + Transient, + Scoped + } + + public ServiceLifetime Lifetime + { + get; + } + + public Type? ImplementationType + { + get; + } + + public EditorInjectionAttribute(ServiceLifetime lifetime, Type? implementationType = null) + { + Lifetime = lifetime; + ImplementationType = implementationType; + } +} + +[AttributeUsage(AttributeTargets.Method)] +public sealed class ContextMenuItemAttribute : DiscoverableAttributeBase +{ + public string Tag + { + get; + } + + public string Name + { + get; + } + + public int Group + { + get; + } + + public ContextMenuItemAttribute(string tag, string name, int group = 0) + { + Tag = tag; + Name = name; + Group = group; + } +} \ No newline at end of file diff --git a/Ghost.Editor.Core/Controls/ControlsDictionary.xaml b/Ghost.Editor.Core/Controls/ControlsDictionary.xaml index 6120a67..c9b0586 100644 --- a/Ghost.Editor.Core/Controls/ControlsDictionary.xaml +++ b/Ghost.Editor.Core/Controls/ControlsDictionary.xaml @@ -4,7 +4,6 @@ - - + diff --git a/Ghost.Editor.Core/Controls/Internal/ComponentView.cs b/Ghost.Editor.Core/Controls/Internal/ComponentView.cs index b3980af..0e7ae6b 100644 --- a/Ghost.Editor.Core/Controls/Internal/ComponentView.cs +++ b/Ghost.Editor.Core/Controls/Internal/ComponentView.cs @@ -7,7 +7,7 @@ using Microsoft.UI.Xaml.Controls; using System.Reflection; using System.Runtime.InteropServices; -namespace Ghost.Editor.Core.Controls.Internal; +namespace Ghost.Editor.Core.Controls; internal sealed unsafe partial class ComponentView : Control { diff --git a/Ghost.Editor.Core/Controls/Internal/ComponentDataView.xaml b/Ghost.Editor.Core/Controls/Internal/ComponentView.xaml similarity index 93% rename from Ghost.Editor.Core/Controls/Internal/ComponentDataView.xaml rename to Ghost.Editor.Core/Controls/Internal/ComponentView.xaml index 2800e65..0c0ee8e 100644 --- a/Ghost.Editor.Core/Controls/Internal/ComponentDataView.xaml +++ b/Ghost.Editor.Core/Controls/Internal/ComponentView.xaml @@ -2,7 +2,7 @@ + xmlns:local="using:Ghost.Editor.Core.Controls">