From 654152a9cc025c356b81119a5bbf576e2998af02 Mon Sep 17 00:00:00 2001 From: Software Antics Date: Thu, 18 Apr 2024 23:23:08 +1000 Subject: [PATCH] Ready --- FinalEngine.ECS/EntitySystemBase.cs | 5 +- .../Systems/EditorUpdateEntitySystem.cs | 33 ++++++++++++ FinalEngine.Editor.Desktop/App.xaml.cs | 2 + .../Extensions/ServiceCollectionExtensions.cs | 17 +++++++ .../FinalEngine.Editor.Desktop.csproj | 4 ++ .../Extensions/ServiceCollectionExtensions.cs | 2 +- .../Batching/SpriteDrawer.cs | 1 - .../Extensions/ServiceCollectionExtensions.cs | 1 - .../Renderers/SkyboxRenderer.cs | 1 - .../Extensions/ServiceCollectionExtensions.cs | 4 -- .../Rendering/DisplayManager.cs | 51 ------------------- .../Rendering/DisplayResolution.cs | 16 ------ .../Rendering/IDisplayManager.cs | 14 ----- 13 files changed, 61 insertions(+), 90 deletions(-) create mode 100644 FinalEngine.Editor.Common/Driver/Systems/EditorUpdateEntitySystem.cs create mode 100644 FinalEngine.Editor.Desktop/Extensions/ServiceCollectionExtensions.cs delete mode 100644 FinalEngine.Runtime/Rendering/DisplayManager.cs delete mode 100644 FinalEngine.Runtime/Rendering/DisplayResolution.cs delete mode 100644 FinalEngine.Runtime/Rendering/IDisplayManager.cs diff --git a/FinalEngine.ECS/EntitySystemBase.cs b/FinalEngine.ECS/EntitySystemBase.cs index 26058f57..6a4cc10f 100644 --- a/FinalEngine.ECS/EntitySystemBase.cs +++ b/FinalEngine.ECS/EntitySystemBase.cs @@ -55,7 +55,10 @@ internal void RemoveAllEntities() this.entities.Clear(); } - protected abstract bool IsMatch([NotNull] IReadOnlyEntity entity); + protected virtual bool IsMatch([NotNull] IReadOnlyEntity entity) + { + return false; + } protected virtual void OnEntityAdded(Entity entity) { diff --git a/FinalEngine.Editor.Common/Driver/Systems/EditorUpdateEntitySystem.cs b/FinalEngine.Editor.Common/Driver/Systems/EditorUpdateEntitySystem.cs new file mode 100644 index 00000000..d69cf880 --- /dev/null +++ b/FinalEngine.Editor.Common/Driver/Systems/EditorUpdateEntitySystem.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) Software Antics. All rights reserved. +// + +namespace FinalEngine.Editor.Common.Driver.Systems; + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using FinalEngine.ECS; +using FinalEngine.ECS.Attributes; +using FinalEngine.Input.Keyboards; +using FinalEngine.Input.Mouses; + +[EntitySystemProcess(ExecutionType = GameLoopType.Update)] +public sealed class EditorUpdateEntitySystem : EntitySystemBase +{ + private readonly IKeyboard keyboard; + + private readonly IMouse mouse; + + public EditorUpdateEntitySystem(IKeyboard keyboard, IMouse mouse) + { + this.keyboard = keyboard ?? throw new ArgumentNullException(nameof(keyboard)); + this.mouse = mouse ?? throw new ArgumentNullException(nameof(mouse)); + } + + protected override void Process([NotNull] IEnumerable entities) + { + this.keyboard.Update(); + this.mouse.Update(); + } +} diff --git a/FinalEngine.Editor.Desktop/App.xaml.cs b/FinalEngine.Editor.Desktop/App.xaml.cs index 564ac978..7ba1d302 100644 --- a/FinalEngine.Editor.Desktop/App.xaml.cs +++ b/FinalEngine.Editor.Desktop/App.xaml.cs @@ -13,6 +13,7 @@ namespace FinalEngine.Editor.Desktop; using FinalEngine.Editor.Common.Services.Application; using FinalEngine.Editor.Common.Services.Environment; using FinalEngine.Editor.Common.Services.Scenes; +using FinalEngine.Editor.Desktop.Extensions; using FinalEngine.Editor.Desktop.Services.Actions; using FinalEngine.Editor.Desktop.Services.Layout; using FinalEngine.Editor.Desktop.Views; @@ -90,6 +91,7 @@ private static void ConfigureServices(HostBuilderContext context, IServiceCollec }); services.AddRuntime(); + services.AddEditorPlatform(); services.AddTransient(); diff --git a/FinalEngine.Editor.Desktop/Extensions/ServiceCollectionExtensions.cs b/FinalEngine.Editor.Desktop/Extensions/ServiceCollectionExtensions.cs new file mode 100644 index 00000000..a49740b2 --- /dev/null +++ b/FinalEngine.Editor.Desktop/Extensions/ServiceCollectionExtensions.cs @@ -0,0 +1,17 @@ +// +// Copyright (c) Software Antics. All rights reserved. +// + +namespace FinalEngine.Editor.Desktop.Extensions; + +using System; +using Microsoft.Extensions.DependencyInjection; + +public static class ServiceCollectionExtensions +{ + public static IServiceCollection AddEditorPlatform(this IServiceCollection services) + { + ArgumentNullException.ThrowIfNull(services, nameof(services)); + return services; + } +} diff --git a/FinalEngine.Editor.Desktop/FinalEngine.Editor.Desktop.csproj b/FinalEngine.Editor.Desktop/FinalEngine.Editor.Desktop.csproj index e3e7fcca..e5a62b05 100644 --- a/FinalEngine.Editor.Desktop/FinalEngine.Editor.Desktop.csproj +++ b/FinalEngine.Editor.Desktop/FinalEngine.Editor.Desktop.csproj @@ -64,4 +64,8 @@ Always + + + + diff --git a/FinalEngine.Platform.Desktop/Extensions/ServiceCollectionExtensions.cs b/FinalEngine.Platform.Desktop/Extensions/ServiceCollectionExtensions.cs index c6ba2d54..a71ca896 100644 --- a/FinalEngine.Platform.Desktop/Extensions/ServiceCollectionExtensions.cs +++ b/FinalEngine.Platform.Desktop/Extensions/ServiceCollectionExtensions.cs @@ -31,7 +31,7 @@ public static void AddDesktopPlatform(this IServiceCollection services) Profile = ContextProfile.Core, AutoLoadBindings = false, - StartVisible = true, + StartVisible = false, WindowBorder = WindowBorder.Fixed, WindowState = WindowState.Normal, diff --git a/FinalEngine.Rendering/Batching/SpriteDrawer.cs b/FinalEngine.Rendering/Batching/SpriteDrawer.cs index 1e309dc4..1da564d0 100644 --- a/FinalEngine.Rendering/Batching/SpriteDrawer.cs +++ b/FinalEngine.Rendering/Batching/SpriteDrawer.cs @@ -35,7 +35,6 @@ internal sealed class SpriteDrawer : ISpriteDrawer, IDisposable private IVertexBuffer? vertexBuffer; - //// TODO: Projection width and height should be customizable and not set in constructor for DI. public SpriteDrawer(IRenderDevice renderDevice, ISpriteBatcher batcher, ITextureBinder binder, int projectionWidth, int projectionHeight) { this.renderDevice = renderDevice ?? throw new ArgumentNullException(nameof(renderDevice)); diff --git a/FinalEngine.Rendering/Extensions/ServiceCollectionExtensions.cs b/FinalEngine.Rendering/Extensions/ServiceCollectionExtensions.cs index 7ad0a591..6583f5a7 100644 --- a/FinalEngine.Rendering/Extensions/ServiceCollectionExtensions.cs +++ b/FinalEngine.Rendering/Extensions/ServiceCollectionExtensions.cs @@ -45,7 +45,6 @@ public static IServiceCollection AddRendering(this IServiceCollection services) services.AddSingleton(); services.AddSingleton(); - // TODO: Model should be IModel? Think about a better solution to the whole thing tbh. services.AddResourceLoader(); services.AddResourceLoader(); services.AddResourceLoader(); diff --git a/FinalEngine.Rendering/Renderers/SkyboxRenderer.cs b/FinalEngine.Rendering/Renderers/SkyboxRenderer.cs index 7b771a56..73f81ce6 100644 --- a/FinalEngine.Rendering/Renderers/SkyboxRenderer.cs +++ b/FinalEngine.Rendering/Renderers/SkyboxRenderer.cs @@ -29,7 +29,6 @@ internal sealed class SkyboxRenderer : ISkyboxRenderer, IDisposable private ITextureCube? texture; - //// TODO: Fix this for DI stuff. public SkyboxRenderer(IRenderDevice renderDevice) { this.renderDevice = renderDevice ?? throw new ArgumentNullException(nameof(renderDevice)); diff --git a/FinalEngine.Runtime/Extensions/ServiceCollectionExtensions.cs b/FinalEngine.Runtime/Extensions/ServiceCollectionExtensions.cs index 7f02a9cb..a3aff216 100644 --- a/FinalEngine.Runtime/Extensions/ServiceCollectionExtensions.cs +++ b/FinalEngine.Runtime/Extensions/ServiceCollectionExtensions.cs @@ -8,11 +8,9 @@ namespace FinalEngine.Runtime.Extensions; using System.IO.Abstractions; using FinalEngine.Audio.OpenAL.Extensions; using FinalEngine.Input.Extensions; -using FinalEngine.Platform.Desktop.Extensions; using FinalEngine.Rendering.Extensions; using FinalEngine.Rendering.OpenGL.Extensions; using FinalEngine.Resources.Extensionss; -using FinalEngine.Runtime.Rendering; using Microsoft.Extensions.DependencyInjection; public static class ServiceCollectionExtensions @@ -22,10 +20,8 @@ public static IServiceCollection AddRuntime(this IServiceCollection services) ArgumentNullException.ThrowIfNull(services, nameof(services)); services.AddSingleton(); - services.AddSingleton(); services.AddSingleton(); - services.AddDesktopPlatform(); services.AddOpenGL(); services.AddOpenAL(); services.AddInput(); diff --git a/FinalEngine.Runtime/Rendering/DisplayManager.cs b/FinalEngine.Runtime/Rendering/DisplayManager.cs deleted file mode 100644 index a9b9314a..00000000 --- a/FinalEngine.Runtime/Rendering/DisplayManager.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) Software Antics. All rights reserved. -// - -namespace FinalEngine.Runtime.Rendering; - -using System; -using System.Drawing; -using FinalEngine.Platform; -using FinalEngine.Rendering; - -internal sealed class DisplayManager : IDisplayManager -{ - private readonly IRasterizer rasterizer; - - private readonly IWindow window; - - public DisplayManager(IRasterizer rasterizer, IWindow window) - { - this.rasterizer = rasterizer ?? throw new ArgumentNullException(nameof(rasterizer)); - this.window = window ?? throw new ArgumentNullException(nameof(window)); - } - - public int DisplayHeight - { - get { return this.rasterizer.GetViewport().Height; } - } - - public int DisplayWidth - { - get { return this.rasterizer.GetViewport().Width; } - } - - public void ChangeResolution(DisplayResolution resolution) - { - var viewport = resolution switch - { - DisplayResolution.StandardDefinition => new Rectangle(0, 0, 640, 480), - DisplayResolution.HighDefinition => new Rectangle(0, 0, 1280, 720), - DisplayResolution.FullHighDefinition => new Rectangle(0, 0, 1920, 1080), - DisplayResolution.UltraHighDefinition => new Rectangle(0, 0, 3840, 2160), - _ => throw new NotSupportedException($"The specified {nameof(resolution)} is not supported."), - }; - - this.window.Size = new Size( - viewport.Width, - viewport.Height); - - this.rasterizer.SetViewport(viewport); - } -} diff --git a/FinalEngine.Runtime/Rendering/DisplayResolution.cs b/FinalEngine.Runtime/Rendering/DisplayResolution.cs deleted file mode 100644 index 424bca55..00000000 --- a/FinalEngine.Runtime/Rendering/DisplayResolution.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Software Antics. All rights reserved. -// - -namespace FinalEngine.Runtime.Rendering; - -public enum DisplayResolution -{ - StandardDefinition, - - HighDefinition, - - FullHighDefinition, - - UltraHighDefinition, -} diff --git a/FinalEngine.Runtime/Rendering/IDisplayManager.cs b/FinalEngine.Runtime/Rendering/IDisplayManager.cs deleted file mode 100644 index 8beb1704..00000000 --- a/FinalEngine.Runtime/Rendering/IDisplayManager.cs +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Software Antics. All rights reserved. -// - -namespace FinalEngine.Runtime.Rendering; - -public interface IDisplayManager -{ - int DisplayHeight { get; } - - int DisplayWidth { get; } - - void ChangeResolution(DisplayResolution resolution); -}