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
galaxy::scene::SceneManager Class Referencefinal

Scene saving/loading, pushing, popping, creating. Also manages entities. More...

#include <SceneManager.hpp>

+ Inheritance diagram for galaxy::scene::SceneManager:
+ Collaboration diagram for galaxy::scene::SceneManager:

Public Member Functions

 SceneManager () noexcept
 Constructor.
 
virtual ~SceneManager () noexcept
 Destructor.
 
std::shared_ptr< Scenecreate (const std::string &scene)
 Create scene in engine.
 
void set (const std::string &scene)
 Clears all from stack and sets as active.
 
void push (const std::string &scene)
 Push a scene onto the top of stack.
 
void pop ()
 Remove scene on top of stack.
 
void pop_all ()
 Pop all scenes.
 
std::shared_ptr< Scenetop () noexcept
 Get top scene.
 
void update ()
 Process events and updates.
 
void render ()
 Render scenes.
 
void load_app (const std::string &appdata_file)
 Load app data file into scene manager.
 
void save_app (const std::string &file)
 Save all active scenes and sub data within those scenes.
 
void clear ()
 Deletes all scene data.
 
bool empty () const noexcept
 Are there any scenes.
 
nlohmann::json serialize () override
 Serializes object.
 
void deserialize (const nlohmann::json &json) override
 Deserializes from object.
 
- Public Member Functions inherited from galaxy::fs::Serializable
virtual ~Serializable ()
 Destructor.
 
virtual Serializableoperator= (Serializable &&)=default
 Move assignment operator.
 
virtual Serializableoperator= (const Serializable &)=default
 Copy assignment operator.
 

Private Attributes

ankerl::unordered_dense::map< std::uint64_t, std::shared_ptr< Scene > > m_scenes
 Scene storage.
 
std::vector< std::shared_ptr< Scene > > m_stack
 Active scenes.
 
core::Registry m_registry
 Entity data.
 

Additional Inherited Members

- Protected Member Functions inherited from galaxy::fs::Serializable
 Serializable ()
 Constructor.
 

Detailed Description

Scene saving/loading, pushing, popping, creating. Also manages entities.

Definition at line 21 of file SceneManager.hpp.

Constructor & Destructor Documentation

◆ SceneManager()

galaxy::scene::SceneManager::SceneManager ( )
noexcept

Constructor.

Definition at line 27 of file SceneManager.cpp.

◆ ~SceneManager()

galaxy::scene::SceneManager::~SceneManager ( )
virtualnoexcept

Destructor.

Definition at line 31 of file SceneManager.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ create()

std::shared_ptr< Scene > galaxy::scene::SceneManager::create ( const std::string & scene)

Create scene in engine.

Parameters
sceneScene name.
Returns
Shared pointer to created scene, or nullptr on failure.

Definition at line 36 of file SceneManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

void galaxy::scene::SceneManager::set ( const std::string & scene)

Clears all from stack and sets as active.

Parameters
sceneScene name.

Definition at line 51 of file SceneManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ push()

void galaxy::scene::SceneManager::push ( const std::string & scene)

Push a scene onto the top of stack.

Parameters
sceneScene name.

Definition at line 57 of file SceneManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop()

void galaxy::scene::SceneManager::pop ( )

Remove scene on top of stack.

Definition at line 64 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ pop_all()

void galaxy::scene::SceneManager::pop_all ( )

Pop all scenes.

Definition at line 73 of file SceneManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ top()

std::shared_ptr< Scene > galaxy::scene::SceneManager::top ( )
nodiscardnoexcept

Get top scene.

Definition at line 81 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ update()

void galaxy::scene::SceneManager::update ( )

Process events and updates.

Definition at line 86 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ render()

void galaxy::scene::SceneManager::render ( )

Render scenes.

Definition at line 94 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ load_app()

void galaxy::scene::SceneManager::load_app ( const std::string & appdata_file)

Load app data file into scene manager.

Will remove any other loaded scenes and adjust the currently loaded scene.

Parameters
appdata_fileZlib + Base64 encoded json data file. Should have .galaxy extension.

Definition at line 102 of file SceneManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save_app()

void galaxy::scene::SceneManager::save_app ( const std::string & file)

Save all active scenes and sub data within those scenes.

Parameters
fileFile to save data to.

Definition at line 151 of file SceneManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void galaxy::scene::SceneManager::clear ( )

Deletes all scene data.

Definition at line 185 of file SceneManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ empty()

bool galaxy::scene::SceneManager::empty ( ) const
nodiscardnoexcept

Are there any scenes.

Returns
True if no scenes.

Definition at line 192 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ serialize()

nlohmann::json galaxy::scene::SceneManager::serialize ( )
nodiscardoverridevirtual

Serializes object.

Returns
JSON object containing data to write out.

Implements galaxy::fs::Serializable.

Definition at line 197 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ deserialize()

void galaxy::scene::SceneManager::deserialize ( const nlohmann::json & json)
overridevirtual

Deserializes from object.

Parameters
jsonJson object to retrieve data from.

Implements galaxy::fs::Serializable.

Definition at line 222 of file SceneManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_scenes

ankerl::unordered_dense::map<std::uint64_t, std::shared_ptr<Scene> > galaxy::scene::SceneManager::m_scenes
private

Scene storage.

Definition at line 132 of file SceneManager.hpp.

◆ m_stack

std::vector<std::shared_ptr<Scene> > galaxy::scene::SceneManager::m_stack
private

Active scenes.

Definition at line 137 of file SceneManager.hpp.

◆ m_registry

core::Registry galaxy::scene::SceneManager::m_registry
private

Entity data.

Definition at line 142 of file SceneManager.hpp.


The documentation for this class was generated from the following files: