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;
|
SakuraVNE::ImGuiInit *m_ImGui;
|
||||||
|
|
||||||
static Application *s_Instance;
|
static Application *s_Instance;
|
||||||
|
|
||||||
|
friend class SakuraVNE::Layer;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
|
#include "Application.h"
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace SakuraVNE {
|
namespace SakuraVNE {
|
||||||
Layer::Layer(const std::string &name, bool isActive) : m_LayerName(name), m_isActive(isActive) {}
|
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
|
} // namespace SakuraVNE
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SDL3/SDL_stdinc.h"
|
#include "SDL3/SDL_stdinc.h"
|
||||||
|
#include <concepts>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace SakuraVNE {
|
namespace SakuraVNE {
|
||||||
@@ -14,14 +16,18 @@ public:
|
|||||||
virtual void OnAttach() {}
|
virtual void OnAttach() {}
|
||||||
virtual void OnDetach() {}
|
virtual void OnDetach() {}
|
||||||
virtual void OnImGuiRender() {}
|
virtual void OnImGuiRender() {}
|
||||||
virtual void TransitionTo() {}
|
virtual void Suspend() { m_isActive = false; }
|
||||||
virtual void Suspend() {}
|
virtual void Activate() { m_isActive = true; }
|
||||||
virtual void Activate() {}
|
|
||||||
|
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; }
|
const std::string &GetName() const { return m_LayerName; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string m_LayerName;
|
std::string m_LayerName;
|
||||||
bool m_isActive = true;
|
bool m_isActive = true;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void QueueTransition(std::unique_ptr<Layer> layer);
|
||||||
};
|
};
|
||||||
} // namespace SakuraVNE
|
} // namespace SakuraVNE
|
||||||
|
|||||||
Reference in New Issue
Block a user