From 3925ccc52029e52f6674df04aaa2b930eca9e0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hatvani=20Tam=C3=A1s?= Date: Sat, 4 Apr 2026 11:38:31 +0200 Subject: [PATCH] layer transition with temporary testing code until the event system is implemented --- SakuraCore/src/Application.h | 2 ++ SakuraCore/src/Layer.cpp | 13 +++++++++++++ SakuraCore/src/Layer.h | 12 +++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/SakuraCore/src/Application.h b/SakuraCore/src/Application.h index 976d29d..a7a6ca5 100644 --- a/SakuraCore/src/Application.h +++ b/SakuraCore/src/Application.h @@ -99,4 +99,6 @@ private: SakuraVNE::ImGuiInit *m_ImGui; static Application *s_Instance; + + friend class SakuraVNE::Layer; }; diff --git a/SakuraCore/src/Layer.cpp b/SakuraCore/src/Layer.cpp index 35c9890..7f5bf92 100644 --- a/SakuraCore/src/Layer.cpp +++ b/SakuraCore/src/Layer.cpp @@ -1,6 +1,19 @@ #include "Layer.h" +#include "Application.h" +#include #include namespace SakuraVNE { Layer::Layer(const std::string &name, bool isActive) : m_LayerName(name), m_isActive(isActive) {} + +void Layer::QueueTransition(std::unique_ptr toLayer) { + // TODO: redo this based on the event video + auto &layerStack = Application::Get().m_LayerStack; + for (auto &layer : layerStack) { + if (layer.get() == this) { + layer = std::move(toLayer); + return; + } + } +} } // namespace SakuraVNE diff --git a/SakuraCore/src/Layer.h b/SakuraCore/src/Layer.h index 72e8320..c977b59 100644 --- a/SakuraCore/src/Layer.h +++ b/SakuraCore/src/Layer.h @@ -1,6 +1,8 @@ #pragma once #include "SDL3/SDL_stdinc.h" +#include +#include #include namespace SakuraVNE { @@ -14,14 +16,18 @@ public: virtual void OnAttach() {} virtual void OnDetach() {} virtual void OnImGuiRender() {} - virtual void TransitionTo() {} - virtual void Suspend() {} - virtual void Activate() {} + virtual void Suspend() { m_isActive = false; } + virtual void Activate() { m_isActive = true; } + + template T, typename... Args> void TransitionTo(Args &&...args) { QueueTransition(std::move(std::make_unique(std::forward(args)...))); } const std::string &GetName() const { return m_LayerName; } protected: std::string m_LayerName; bool m_isActive = true; + +private: + void QueueTransition(std::unique_ptr layer); }; } // namespace SakuraVNE