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, creation, changing and loading. More...

#include <SceneManager.hpp>

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

Public Member Functions

 SceneManager ()
 Constructor.
 
virtual ~SceneManager ()
 Destructor.
 
Sceneadd (const std::string &name)
 Add a new scene.
 
template<std::derived_from< Scene > Custom>
Custom * add_custom (const std::string &name)
 Add a custom scene.
 
Sceneget (const std::string &name)
 Get a specific scene.
 
void remove (const std::string &name)
 Remove a specific scene.
 
bool has (const std::string &name)
 Does a scene exist.
 
void set_scene (const std::string &name)
 Scene to set to currently active.
 
template<meta::is_system System, typename... Args>
void create_system (Args &&... args)
 Add a system to the manager.
 
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 update ()
 Handle events and update logic.
 
void only_update_rendering ()
 Only update rendering.
 
void render ()
 Handle rendering.
 
void clear ()
 Deletes all scene data.
 
scene::Scenecurrent () const
 Get current scene.
 
const Mapmap () const
 Get all scenes.
 
bool empty () const
 Are there any scenes.
 
nlohmann::json serialize () override
 Serializes object.
 
void deserialize (const nlohmann::json &json) override
 Deserializes from object.
 
 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.
 

Private Types

using Map = ankerl::unordered_dense::map<std::uint64_t, std::unique_ptr<Scene>>
 
using SystemContainer = meta::vector<std::unique_ptr<systems::System>>
 

Private Attributes

Map m_scenes
 Scene map.
 
scene::Scenem_current
 Current scene.
 
SystemContainer m_systems
 Stores systems.
 
std::size_t m_rendersystem_index
 Rendersystem index.
 
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.
 

Detailed Description

Scene saving/loading, creation, changing and loading.

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

Definition at line 21 of file SceneManager.hpp.

Member Typedef Documentation

◆ Map

using galaxy::scene::SceneManager::Map = ankerl::unordered_dense::map<std::uint64_t, std::unique_ptr<Scene>>
private

Definition at line 25 of file SceneManager.hpp.

◆ SystemContainer

using galaxy::scene::SceneManager::SystemContainer = meta::vector<std::unique_ptr<systems::System>>
private

Definition at line 26 of file SceneManager.hpp.

Constructor & Destructor Documentation

◆ SceneManager() [1/2]

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

Constructor.

Definition at line 26 of file SceneManager.cpp.

+ Here is the call graph for this function:

◆ ~SceneManager() [1/2]

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

Destructor.

Definition at line 35 of file SceneManager.cpp.

◆ SceneManager() [2/2]

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

Constructor.

◆ ~SceneManager() [2/2]

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

Destructor.

Member Function Documentation

◆ add()

Scene * galaxy::scene::SceneManager::add ( const std::string & name)

Add a new scene.

Parameters
nameScene name to assign.
Returns
Pointer to added scene.

Definition at line 40 of file SceneManager.cpp.

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

◆ add_custom()

template<std::derived_from< Scene > Custom>
Custom * galaxy::scene::SceneManager::add_custom ( const std::string & name)
inline

Add a custom scene.

Template Parameters
typeDerived type of custom scene.
Parameters
nameScene name to assign.

Definition at line 199 of file SceneManager.hpp.

+ Here is the call graph for this function:

◆ get()

Scene * galaxy::scene::SceneManager::get ( const std::string & name)
nodiscard

Get a specific scene.

Parameters
nameName Id for scene.
Returns
Reference to requested scene.

Definition at line 56 of file SceneManager.cpp.

+ Here is the call graph for this function:

◆ remove()

void galaxy::scene::SceneManager::remove ( const std::string & name)

Remove a specific scene.

Preserves insertion order.

Parameters
nameId for scene.

Definition at line 71 of file SceneManager.cpp.

+ Here is the call graph for this function:

◆ has()

bool galaxy::scene::SceneManager::has ( const std::string & name)
nodiscard

Does a scene exist.

Parameters
nameId for scene.
Returns
True if exists.

Definition at line 76 of file SceneManager.cpp.

+ Here is the call graph for this function:

◆ set_scene()

void galaxy::scene::SceneManager::set_scene ( const std::string & name)

Scene to set to currently active.

Parameters
nameScene name.

Definition at line 81 of file SceneManager.cpp.

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

◆ create_system()

template<meta::is_system System, typename... Args>
void galaxy::scene::SceneManager::create_system ( Args &&... args)
inline

Add a system to the manager.

Template Parameters
SystemType of system to create.
ArgsConstructor arguments for system.

Systems will be updated in the order in which they are created.

Parameters
argsConstructor arguments for system.

Definition at line 216 of file SceneManager.hpp.

+ Here is the caller graph for this function:

◆ load_app() [1/2]

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 90 of file SceneManager.cpp.

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

◆ save_app() [1/2]

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 129 of file SceneManager.cpp.

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

◆ update() [1/2]

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

Handle events and update logic.

Definition at line 139 of file SceneManager.cpp.

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

◆ only_update_rendering()

void galaxy::scene::SceneManager::only_update_rendering ( )

Only update rendering.

Definition at line 157 of file SceneManager.cpp.

+ Here is the call graph for this function:

◆ render() [1/2]

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

Handle rendering.

Definition at line 170 of file SceneManager.cpp.

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

◆ clear() [1/2]

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

Deletes all scene data.

Definition at line 178 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ current()

scene::Scene * galaxy::scene::SceneManager::current ( ) const
nodiscard

Get current scene.

Returns
Pointer to current scene, nullptr if no scene.

Definition at line 184 of file SceneManager.cpp.

◆ map()

const SceneManager::Map & galaxy::scene::SceneManager::map ( ) const
nodiscard

Get all scenes.

Returns
Reference to scene object.

Definition at line 189 of file SceneManager.cpp.

◆ empty() [1/2]

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

Are there any scenes.

Returns
True if no scenes.

Definition at line 194 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ serialize() [1/2]

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

Serializes object.

Returns
JSON object containing data to write out.

Definition at line 199 of file SceneManager.cpp.

+ Here is the caller graph for this function:

◆ deserialize() [1/2]

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

Deserializes from object.

Parameters
jsonJson object to retrieve data from.

Definition at line 216 of file SceneManager.cpp.

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

◆ 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() [2/2]

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

Process events and updates.

◆ render() [2/2]

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

Render scenes.

◆ load_app() [2/2]

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.

◆ save_app() [2/2]

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.

◆ clear() [2/2]

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

Deletes all scene data.

◆ empty() [2/2]

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

Are there any scenes.

Returns
True if no scenes.

◆ serialize() [2/2]

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

Serializes object.

Returns
JSON object containing data to write out.

◆ deserialize() [2/2]

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

Deserializes from object.

Parameters
jsonJson object to retrieve data from.

Member Data Documentation

◆ m_scenes [1/2]

Map galaxy::scene::SceneManager::m_scenes
private

Scene map.

Definition at line 180 of file SceneManager.hpp.

◆ m_current

scene::Scene* galaxy::scene::SceneManager::m_current
private

Current scene.

Definition at line 185 of file SceneManager.hpp.

◆ m_systems

SystemContainer galaxy::scene::SceneManager::m_systems
private

Stores systems.

Definition at line 190 of file SceneManager.hpp.

◆ m_rendersystem_index

std::size_t galaxy::scene::SceneManager::m_rendersystem_index
private

Rendersystem index.

Definition at line 195 of file SceneManager.hpp.

◆ m_scenes [2/2]

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: