layer transition with temporary testing code until the event system is implemented

This commit is contained in:
2026-04-04 11:38:31 +02:00
parent 8b91c7ab76
commit 3925ccc520
3 changed files with 24 additions and 3 deletions

View File

@@ -99,4 +99,6 @@ private:
SakuraVNE::ImGuiInit *m_ImGui;
static Application *s_Instance;
friend class SakuraVNE::Layer;
};

View File

@@ -1,6 +1,19 @@
#include "Layer.h"
#include "Application.h"
#include <memory>
#include <string>
namespace SakuraVNE {
Layer::Layer(const std::string &name, bool isActive) : m_LayerName(name), m_isActive(isActive) {}
void Layer::QueueTransition(std::unique_ptr<Layer> 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

View File

@@ -1,6 +1,8 @@
#pragma once
#include "SDL3/SDL_stdinc.h"
#include <concepts>
#include <memory>
#include <string>
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 <std::derived_from<Layer> T, typename... Args> void TransitionTo(Args &&...args) { QueueTransition(std::move(std::make_unique<T>(std::forward<Args>(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> layer);
};
} // namespace SakuraVNE