Added onSceneLoaded delegate

This commit is contained in:
antopilo
2025-01-25 17:09:58 -05:00
parent 8831407da0
commit cf8e4cad4d
6 changed files with 35 additions and 3 deletions

View File

@@ -142,6 +142,8 @@ namespace Nuake {
Window::Get()->SetTitlebarHitTestCallback([&](Window& window, int x, int y, bool& hit) {
hit = m_TitleBarHovered;
});
Engine::OnSceneLoaded.AddRaw(this, &EditorInterface::OnSceneLoaded);
}
void EditorInterface::DrawTitlebar(float& outHeight)
@@ -2433,6 +2435,11 @@ namespace Nuake {
window->DC.MenuBarAppending = false;
}
void EditorInterface::OnSceneLoaded(Ref<Scene> scene)
{
Logger::Log("On Scene loaded");
}
bool isLoadingProject = false;
bool isLoadingProjectQueue = false;
bool EditorInterface::isCreatingNewProject = false;

View File

@@ -102,6 +102,8 @@ namespace Nuake
bool BeginMenubar(const ImRect& barRectangle);
void EndMenubar();
void OnSceneLoaded(Ref<Scene> scene);
void SetStatusMessage(const std::string& msg, const Color& color = Color(0.08f, 0.08f, 0.08f, 1.0f)) { m_StatusMessage = msg; m_StatusBarColor = color; }
void DrawViewport();
void DrawStatusBar();

View File

@@ -46,6 +46,8 @@ namespace Nuake
Timestep Engine::timeStep = 0.f;
float Engine::timeScale = 1.0f;
MulticastDelegate<Ref<Scene>> Engine::OnSceneLoaded;
void Engine::Init()
{
//Window::Get()->OnWindowSetScene().AddStatic(&Engine::OnWindowSetScene);
@@ -64,7 +66,7 @@ namespace Nuake
currentWindow = Window::Get();
Input::Init();
//Renderer2D::Init();
Logger::Log("Engine initialized");
RegisterCoreTypes::RegisterCoreComponents();
@@ -250,7 +252,13 @@ namespace Nuake
bool Engine::SetCurrentScene(Ref<Scene> scene)
{
return currentWindow->SetScene(scene);
bool result = currentWindow->SetScene(scene);
if (result)
{
OnSceneLoaded.Broadcast(scene);
}
return result;
}
bool Engine::QueueSceneSwitch(const std::string& scenePath)

View File

@@ -3,6 +3,7 @@
#include "src/Core/Core.h"
#include "src/Core/Logger.h"
#include "src/Window.h"
#include "src/Core/MulticastDelegate.h"
// Welcome to the Nuake source code.
namespace Nuake
@@ -85,6 +86,9 @@ namespace Nuake
static Timestep timeStep;
static float timeScale;
public:
static MulticastDelegate<Ref<Scene>> OnSceneLoaded;
private:
static void GenerateManifest();
};

View File

@@ -274,10 +274,14 @@ void SceneRenderPipeline::Render(PassRenderContext& ctx)
{
{ GBufferAlbedo, GBufferDepth, GBufferNormal, GBufferMaterial }, // GBuffer
{ ShadingOutput }, // Shading
{ TonemappedOutput }
{ TonemappedOutput }, // Tonemap
};
GBufferPipeline.Execute(ctx, pipelineInputs);
// Debug drawing
// Get delegate
}
Ref<VulkanImage> SceneRenderPipeline::ResizeImage(Ref<VulkanImage> image, const Vector2& size)

View File

@@ -5,6 +5,8 @@
#include "src/Rendering/Vulkan/Pipeline/RenderPipeline.h"
#include "src/Rendering/Vulkan/VkResources.h"
#include "src/Core/MulticastDelegate.h"
namespace Nuake
{
struct GBufferConstant
@@ -95,6 +97,9 @@ namespace Nuake
static RenderPipeline GBufferPipeline;
// Delegates
MulticastDelegate<> DebugDrawDelegate;
public:
SceneRenderPipeline();
~SceneRenderPipeline() = default;
@@ -103,6 +108,8 @@ namespace Nuake
void Render(PassRenderContext& ctx);
Ref<VulkanImage> GetOutput() { return TonemappedOutput; }
MulticastDelegate<>& OnDebugDraw() { return DebugDrawDelegate; }
private:
Ref<VulkanImage> ResizeImage(Ref<VulkanImage> image, const Vector2& size);
};