#pragma once #include "../Actions/EditorSelection.h" #include "Nuake/Scene/Entities/Entity.h" #include "Nuake/FileSystem/FileSystem.h" #include #include "../ComponentsPanel/TransformPanel.h" #include "../ComponentsPanel/LightPanel.h" #include "../ComponentsPanel/MeshPanel.h" #include "../ComponentsPanel/SkinnedMeshPanel.h" #include "../ComponentsPanel/CameraPanel.h" #include "../ComponentsPanel/CapsuleColliderPanel.h" #include "../ComponentsPanel/CylinderColliderPanel.h" #include "../ComponentsPanel/MeshColliderPanel.h" #include "../ComponentsPanel/CharacterControllerPanel.h" #include "../ComponentsPanel/BonePanel.h" #include "../ComponentsPanel/NetScriptPanel.h" #include "../ComponentsPanel/NavMeshVolumePanel.h" #include namespace Nuake { class Scene; } class EditorSelectionPanel { using DrawComponentTypeFn = std::function; using DrawFieldTypeFn = std::function; private: TransformPanel mTransformPanel; MeshPanel meshPanel; SkinnedMeshPanel skinnedMeshPanel; EditorSelection* selection = nullptr; Ref currentFile; Ref selectedResource; Ref virtualScene; public: EditorSelectionPanel(EditorSelection& selection); void Draw(EditorSelection selection, const std::string& id = ""); void DrawNone(); void DrawEntity(Nuake::Entity entity); void DrawAddComponentMenu(Nuake::Entity entity); void DrawFile(Ref file); void DrawResource(Nuake::Resource resource); void DrawPrefabPanel(Ref prefab); template void RegisterComponentDrawer() { const auto t = entt::type_id(); ComponentTypeDrawers[t.hash()] = std::bind(Func, std::placeholders::_1, std::placeholders::_2); } template void RegisterComponentDrawer(O* o) { ComponentTypeDrawers[entt::type_id().hash()] = std::bind(Func, o, std::placeholders::_1, std::placeholders::_2); } template void RegisterTypeDrawer(O* o) { FieldTypeDrawers[entt::type_id().hash()] = std::bind(Func, o, std::placeholders::_1, std::placeholders::_2); } protected: // Drawing functions for each component (for writing very specific inspectors for specific components) std::unordered_map ComponentTypeDrawers; // List of functions to call for each component field type that needs to be drawn std::unordered_map FieldTypeDrawers; private: void ResolveFile(Ref file); void DrawMaterialPanel(Ref material); void DrawProjectPanel(Ref project); void DrawNetScriptPanel(Ref file); void DrawComponent(Nuake::Entity& entity, entt::meta_any& component); void DrawComponentContent(entt::meta_any& component); void DrawFieldTypeFloat(entt::meta_data& field, entt::meta_any& component); void DrawFieldTypeBool(entt::meta_data& field, entt::meta_any& component); void DrawFieldTypeVector2(entt::meta_data& field, entt::meta_any& component); void DrawFieldTypeVector3(entt::meta_data& field, entt::meta_any& component); void DrawFieldTypeString(entt::meta_data& field, entt::meta_any& component); void DrawFieldTypeResourceFile(entt::meta_data& field, entt::meta_any& component); void DrawFieldTypeDynamicItemList(entt::meta_data& field, entt::meta_any& component); };