galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
SceneManager.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_SCENE_SCENEMANAGER_HPP_
9#define GALAXY_SCENE_SCENEMANAGER_HPP_
10
12
13namespace galaxy
14{
15 namespace scene
16 {
21 class SceneManager final : public fs::Serializable
22 {
23 public:
27 SceneManager() noexcept;
28
32 virtual ~SceneManager() noexcept;
33
41 [[maybe_unused]]
42 std::shared_ptr<Scene> create(const std::string& scene);
43
49 void set(const std::string& scene);
50
56 void push(const std::string& scene);
57
61 void pop();
62
66 void pop_all();
67
71 [[nodiscard]]
72 std::shared_ptr<Scene> top() noexcept;
73
77 void update();
78
82 void render();
83
91 void load_app(const std::string& appdata_file);
92
98 void save_app(const std::string& file);
99
103 void clear();
104
110 [[nodiscard]]
111 bool empty() const noexcept;
112
118 [[nodiscard]]
119 nlohmann::json serialize() override;
120
126 void deserialize(const nlohmann::json& json) override;
127
128 private:
132 ankerl::unordered_dense::map<std::uint64_t, std::shared_ptr<Scene>> m_scenes;
133
137 std::vector<std::shared_ptr<Scene>> m_stack;
138
143 };
144 } // namespace scene
145} // namespace galaxy
146
147#endif
Wrapper around entt::registry to expand functionality.
Definition Registry.hpp:21
Allows a class to be serialized.
Scene saving/loading, pushing, popping, creating. Also manages entities.
void save_app(const std::string &file)
Save all active scenes and sub data within those scenes.
bool empty() const noexcept
Are there any scenes.
std::shared_ptr< Scene > top() noexcept
Get top scene.
SceneManager() noexcept
Constructor.
void pop()
Remove scene on top of stack.
void set(const std::string &scene)
Clears all from stack and sets as active.
core::Registry m_registry
Entity data.
std::shared_ptr< Scene > create(const std::string &scene)
Create scene in engine.
void clear()
Deletes all scene data.
void deserialize(const nlohmann::json &json) override
Deserializes from object.
void update()
Process events and updates.
void render()
Render scenes.
ankerl::unordered_dense::map< std::uint64_t, std::shared_ptr< Scene > > m_scenes
Scene storage.
nlohmann::json serialize() override
Serializes object.
void pop_all()
Pop all scenes.
std::vector< std::shared_ptr< Scene > > m_stack
Active scenes.
void load_app(const std::string &appdata_file)
Load app data file into scene manager.
virtual ~SceneManager() noexcept
Destructor.
void push(const std::string &scene)
Push a scene onto the top of stack.
Timer.hpp galaxy.
Definition Async.hpp:17