Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
Interface.hpp
1#pragma once
2
3#include "../pch.hpp"
4
5#include <cstdint>
6#include <functional>
7
8#include <Common/Display/Display.hpp>
9#include <Common/Graphics/Core.hpp>
10#include <Common/Logging.hpp>
11#include <Common/ResourcePipeline/AssetType.hpp>
12#include <Common/Window/Window.hpp>
13#include <EngineCore/AssetRenderer/BaseAssetRenderer.hpp>
14#include <EngineCore/Assets/AssetImporter.hpp>
15#include <EngineCore/ECS/ComponentFunctions.hpp>
16#include <EngineCore/ECS/ComponentRegistrar.hpp>
17#include <EngineCore/ECS/SystemFactory.hpp>
18#include <EngineCore/ECS/SystemRegistrar.hpp>
19#include <EngineCore/Logger.hpp>
20#include <EngineCore/WorldContext/WorldContext.hpp>
21
22namespace Grindstone {
23 namespace Memory::AllocatorCore {
24 struct AllocatorState;
25 }
26
27 namespace GraphicsAPI {
28 class Core;
29 }
30
31 namespace ECS {
32 class SystemRegistrar;
33 }
34
35 class WindowManager;
36 class DisplayManager;
38
39 namespace Plugins {
40 class Manager;
41
42 class BaseEditorInterface {
43 public:
44 BaseEditorInterface() = default;
45 BaseEditorInterface(const BaseEditorInterface&) = default;
46 BaseEditorInterface(BaseEditorInterface&&) = default;
47 virtual ~BaseEditorInterface() {}
48 };
49
50 class ENGINE_CORE_API Interface {
51 public:
52 Interface(Manager* manager);
53
54 virtual void SetEditorInterface(BaseEditorInterface* editorInterface);
55 virtual BaseEditorInterface* GetEditorInterface() const;
56
57 virtual EngineCore* GetEngineCore();
58 virtual GraphicsAPI::Core* GetGraphicsCore();
59 virtual bool LoadPlugin(const char* name);
60 virtual void LoadPluginCritical(const char* name);
61 virtual void RegisterGraphicsCore(Grindstone::GraphicsAPI::Core* core);
62 virtual void RegisterWindowManager(Grindstone::WindowManager*);
63 virtual void RegisterDisplayManager(Grindstone::DisplayManager*);
64 virtual Window* CreateDisplayWindow(Window::CreateInfo&);
65 virtual Display GetMainDisplay();
66 virtual uint8_t CountDisplays();
67 virtual void EnumerateDisplays(Display* displays);
68 virtual void RegisterSystem(const char* name, ECS::SystemFactory factory);
69 virtual void RegisterEditorSystem(const char* name, ECS::SystemFactory factory);
70 virtual void UnregisterSystem(const char* name);
71 virtual void UnregisterEditorSystem(const char* name);
72 virtual void RegisterAssetRenderer(BaseAssetRenderer* assetRenderer);
73 virtual void UnregisterAssetRenderer(BaseAssetRenderer* assetRenderer);
74 virtual void RegisterAssetType(AssetType assetType, const char* typeName, AssetImporter* assetImporter);
75 virtual void UnregisterAssetType(AssetType assetType);
76 virtual void SetReloadCsharpCallback(std::function<void()> callback);
77 virtual Grindstone::HashedString::HashMap* GetHashedStringMap() const;
78 virtual Grindstone::Logger::LoggerState* GetLoggerState() const;
79 virtual Grindstone::Memory::AllocatorCore::AllocatorState* GetAllocatorState() const;
80 virtual void RegisterWorldContextFactory(Grindstone::HashedString contextName, Grindstone::UniquePtr<Grindstone::WorldContext> (*FactoryFn)());
81 virtual void UnregisterWorldContextFactory(Grindstone::HashedString contextName);
82
83 template<typename ClassType>
84 void RegisterWorldContextFactory(Grindstone::HashedString contextName) {
85 RegisterWorldContextFactory(contextName, Grindstone::WorldContext::Create<ClassType>);
86 }
87
88 template<typename ClassType>
89 void RegisterComponent(Grindstone::ECS::SetupComponentFn setupComponentFn = nullptr, Grindstone::ECS::DestroyComponentFn destroyComponentFn = nullptr) {
90 componentRegistrar->RegisterComponent<ClassType>(setupComponentFn, destroyComponentFn);
91 }
92
93 template<typename T>
94 void UnregisterComponent() {
95 componentRegistrar->UnregisterComponent<T>();
96 }
97
98 ECS::ComponentRegistrar* componentRegistrar = nullptr;
99 ECS::SystemRegistrar* systemRegistrar = nullptr;
100 private:
101 EngineCore* engineCore = nullptr;
102 BaseEditorInterface* editorInterface = nullptr;
103 Manager* manager = nullptr;
104 GraphicsAPI::Core* graphicsCore = nullptr;
105 Grindstone::Window* (*windowFactoryFn)(Grindstone::Window::CreateInfo&) = nullptr;
106 Grindstone::Display(*getMainDisplayFn)() = nullptr;
107 uint8_t (*countDisplaysFn)() = nullptr;
108 void (*enumerateDisplaysFn)(Grindstone::Display*) = nullptr;
109
110 friend Manager;
111 };
112 }
113}
Definition AssetImporter.hpp:11
Definition BaseAssetRenderer.hpp:23
Definition DisplayManager.hpp:8
Definition ComponentRegistrar.hpp:18
Definition SystemRegistrar.hpp:12
Definition EngineCore.hpp:58
Definition Core.hpp:29
Definition HashedString.hpp:9
Definition Interface.hpp:42
Definition Manager.hpp:16
Definition UniquePtr.hpp:7
Definition WindowManager.hpp:7
Definition Window.hpp:12
Definition Display.hpp:6
Definition Logger.hpp:14
Definition Window.hpp:20