Refactor Vector3Field and update project structure
Changed Vector3Field.cs to derive from ValueControl<Vector3> and use NumberBox controls for better UI handling. Changed EditorControls.xaml to update resource paths for new controls. Changed InternalControls.xaml to simplify the resource dictionary by removing unnecessary references. Changed IComponentEditor.cs to reflect updates in the component editor's lifecycle methods. Changed project files for Ghost.Editor and Ghost.Core to include new dependencies and project references. Changed FileExtensions.cs and IInspectorService.cs to align with the new namespace structure. Changed Result.cs to enhance error handling and success checking methods. Changed TypeHandle.cs to improve type handling compatibility. Changed AssemblyInfo.cs files to include new assembly visibility attributes for better encapsulation. Added new graphics-related classes and interfaces in the Ghost.Engine project, including IGraphicsDevice and DX12GraphicsDevice. Added a new Mesh class to handle 3D mesh data and provide methods for creating geometric shapes. Added GraphicsPipeline.cs to manage the graphics rendering loop and device initialization. Added ScenePage.xaml and ScenePage.xaml.cs to create a new page for rendering scenes. Updated HierarchyPage.xaml.cs and InspectorPage.xaml.cs to use the new service locator pattern for service retrieval. Updated LandingWindow.xaml.cs and EngineEditorWindow.xaml.cs to utilize the new service locator pattern for better service access. Updated Logger.cs to enhance logging capabilities with optional stack traces and assertion logging. Updated QueryFilter.cs and QueryEnumerable.cs to use the new TypeHandle structure for improved efficiency. Updated WorldNode.cs and WorldNodeSerializer.cs to enhance serialization and management of world nodes. Updated AssetDatabase and related classes to improve asset management and metadata generation. Updated Ghost.UnitTest.csproj to include new project references and package dependencies for unit tests.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Ghost.Editor.Utilities.Converters;
|
||||
|
||||
public partial class AssetPathToGlyphConverter : IValueConverter
|
||||
{
|
||||
public object? Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is not string path)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
return "\uE8B7";
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(path).ToLowerInvariant();
|
||||
|
||||
// TODO: Use resource dictionary for icons.
|
||||
return extension switch
|
||||
{
|
||||
".ghostscene" => "\uF159",
|
||||
".fbx" or ".obj" => "\uF158",
|
||||
".png" or ".jpg" or ".jpeg" or ".gif" or ".bmp" => "\uE91B",
|
||||
".mp3" or ".wav" or ".ogg" => "\uE767",
|
||||
".mp4" or ".avi" or ".mkv" => "\uE714",
|
||||
".txt" or ".md" => "\uF000",
|
||||
".cs" or ".hlsl" => "\uE943",
|
||||
_ => "\uE8A5",
|
||||
};
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using System;
|
||||
|
||||
namespace Ghost.Editor.Utilities.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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Ghost.Engine.Utilities;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Ghost.Editor.Utilities.Converters;
|
||||
|
||||
public partial class Vector3ToQuaternionConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is Vector3 vector)
|
||||
{
|
||||
return Quaternion.CreateFromYawPitchRoll(vector.Y, vector.X, vector.Z);
|
||||
}
|
||||
|
||||
throw new ArgumentException("Value must be of type System.Numerics.Vector3.", nameof(value));
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is Quaternion quaternion)
|
||||
{
|
||||
return VectorUtility.CreateFromQuaternion(quaternion);
|
||||
}
|
||||
throw new ArgumentException("Value must be of type System.Numerics.Quaternion.", nameof(value));
|
||||
}
|
||||
}
|
||||
50
Ghost.Editor/Utilities/HostHelpers.Page.cs
Normal file
50
Ghost.Editor/Utilities/HostHelpers.Page.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Ghost.Data.Services;
|
||||
using Ghost.Editor.View.Pages.EngineEditor;
|
||||
using Ghost.Editor.View.Pages.Landing;
|
||||
using Ghost.Editor.View.Windows;
|
||||
using Ghost.Editor.ViewModels.Pages.EngineEditor;
|
||||
using Ghost.Editor.ViewModels.Pages.Landing;
|
||||
using Ghost.Editor.ViewModels.Windows;
|
||||
using Ghost.Engine;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Ghost.Editor.Utilities;
|
||||
|
||||
internal static partial class HostHelper
|
||||
{
|
||||
public static void AddLandingScope(HostBuilderContext context, IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<LandingWindow>();
|
||||
|
||||
services.AddTransient<CreateProjectPage>();
|
||||
services.AddTransient<CreateProjectViewModel>();
|
||||
|
||||
services.AddTransient<OpenProjectPage>();
|
||||
services.AddTransient<OpenProjectViewModel>();
|
||||
|
||||
services.AddTransient<ProjectService>();
|
||||
}
|
||||
|
||||
public static void AddEngineScope(HostBuilderContext context, IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<EngineCore>();
|
||||
|
||||
services.AddTransient<EngineEditorWindow>();
|
||||
services.AddTransient<EngineEditorViewModel>();
|
||||
|
||||
services.AddTransient<ScenePage>();
|
||||
|
||||
services.AddTransient<HierarchyPage>();
|
||||
services.AddTransient<HierarchyViewModel>();
|
||||
|
||||
services.AddTransient<ProjectPage>();
|
||||
services.AddTransient<ProjectViewModel>();
|
||||
|
||||
services.AddTransient<ConsolePage>();
|
||||
services.AddTransient<ConsoleViewModel>();
|
||||
|
||||
services.AddTransient<InspectorPage>();
|
||||
services.AddTransient<InspectorViewModel>();
|
||||
}
|
||||
}
|
||||
46
Ghost.Editor/Utilities/ReflectionBinding.cs
Normal file
46
Ghost.Editor/Utilities/ReflectionBinding.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ghost.Editor.Utilities;
|
||||
|
||||
public class ReflectionBinding
|
||||
{
|
||||
private void RefreshField(FieldInfo field, FrameworkElement control, object source)
|
||||
{
|
||||
var value = field.GetValue(source);
|
||||
|
||||
switch (control)
|
||||
{
|
||||
case TextBox tb:
|
||||
tb.Text = value?.ToString();
|
||||
break;
|
||||
case NumberBox nb when value is double d:
|
||||
nb.Value = d;
|
||||
break;
|
||||
// Add more controls...
|
||||
}
|
||||
}
|
||||
|
||||
public void StartPollingField(FieldInfo field, FrameworkElement control, object component)
|
||||
{
|
||||
var lastValue = field.GetValue(component);
|
||||
|
||||
DispatcherTimer timer = new()
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(200)
|
||||
};
|
||||
|
||||
timer.Tick += (_, _) =>
|
||||
{
|
||||
var currentValue = field.GetValue(component);
|
||||
if (!Equals(currentValue, lastValue))
|
||||
{
|
||||
RefreshField(field, control, component);
|
||||
lastValue = currentValue;
|
||||
}
|
||||
};
|
||||
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
39
Ghost.Editor/Utilities/SystemUtility.cs
Normal file
39
Ghost.Editor/Utilities/SystemUtility.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Pickers;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace Ghost.Editor.Utilities;
|
||||
|
||||
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.Window);
|
||||
InitializeWithWindow.Initialize(openPicker, hWnd);
|
||||
|
||||
openPicker.SuggestedStartLocation = startLocation;
|
||||
openPicker.FileTypeFilter.Add("*");
|
||||
openPicker.SettingsIdentifier = settingsIdentifier;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user