diff --git a/editor/src/Actions/EditorActions.h b/editor/src/Actions/EditorActions.h index 01f19f10..d4e0b50f 100644 --- a/editor/src/Actions/EditorActions.h +++ b/editor/src/Actions/EditorActions.h @@ -141,8 +141,16 @@ inline ActionBinding MakeCreateCameraEntityAction() { return MakeAction("Camera"); } -inline ActionBinding MakeCreateLightEntityAction() { - return MakeAction("Light"); +inline ActionBinding MakeCreateDirectionalLightEntityAction() { + return MakeAction("Directional Light"); +} + +inline ActionBinding MakeCreatePointLightEntityAction() { + return MakeAction("Point Light"); +} + +inline ActionBinding MakeCreateSpotLightEntityAction() { + return MakeAction("Spot Light"); } inline ActionBinding MakeCreateCubeEntityAction() { diff --git a/editor/src/Actions/HierarchyActionRouter.h b/editor/src/Actions/HierarchyActionRouter.h index b77af805..58499293 100644 --- a/editor/src/Actions/HierarchyActionRouter.h +++ b/editor/src/Actions/HierarchyActionRouter.h @@ -180,6 +180,18 @@ inline void DrawHierarchyCreateActions(IEditorContext& context, ::XCEngine::Comp std::to_string(created ? created->GetID() : 0)); }); }; + const auto drawTypedLightCreateAction = [&]( + const ActionBinding& action, + const char* label, + auto&& createLight) { + DrawMenuAction(action, [&]() { + TraceHierarchyPopup(std::string("Hierarchy create clicked: ") + label); + auto* created = createLight(); + TraceHierarchyPopup( + std::string("Hierarchy create result: ") + label + ", createdId=" + + std::to_string(created ? created->GetID() : 0)); + }); + }; DrawMenuAction(MakeCreateEmptyEntityAction(), [&]() { TraceHierarchyPopup("Hierarchy create clicked: Empty Object"); @@ -198,6 +210,21 @@ inline void DrawHierarchyCreateActions(IEditorContext& context, ::XCEngine::Comp drawPrimitiveCreateAction(MakeCreateQuadEntityAction(), ::XCEngine::Resources::BuiltinPrimitiveType::Quad); }); + UI::DrawContextSubmenu("Light", [&]() { + drawTypedLightCreateAction( + MakeCreateDirectionalLightEntityAction(), + "Directional Light", + [&]() { return Commands::CreateDirectionalLightEntity(context, parent); }); + drawTypedLightCreateAction( + MakeCreatePointLightEntityAction(), + "Point Light", + [&]() { return Commands::CreatePointLightEntity(context, parent); }); + drawTypedLightCreateAction( + MakeCreateSpotLightEntityAction(), + "Spot Light", + [&]() { return Commands::CreateSpotLightEntity(context, parent); }); + }); + DrawMenuSeparator(); DrawMenuAction(MakeCreateCameraEntityAction(), [&]() { TraceHierarchyPopup("Hierarchy create clicked: Camera"); @@ -206,13 +233,6 @@ inline void DrawHierarchyCreateActions(IEditorContext& context, ::XCEngine::Comp std::string("Hierarchy create result: Camera, createdId=") + std::to_string(created ? created->GetID() : 0)); }); - DrawMenuAction(MakeCreateLightEntityAction(), [&]() { - TraceHierarchyPopup("Hierarchy create clicked: Light"); - auto* created = Commands::CreateLightEntity(context, parent); - TraceHierarchyPopup( - std::string("Hierarchy create result: Light, createdId=") + - std::to_string(created ? created->GetID() : 0)); - }); } inline void HandleHierarchyItemContextRequest(