layer transition with temporary testing code until the event system is implemented
This commit is contained in:
@@ -99,4 +99,6 @@ private:
|
||||
SakuraVNE::ImGuiInit *m_ImGui;
|
||||
|
||||
static Application *s_Instance;
|
||||
|
||||
friend class SakuraVNE::Layer;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user