Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Olympe::Editor::LevelManager Class Reference

#include <LevelManager.h>

+ Collaboration diagram for Olympe::Editor::LevelManager:

Public Member Functions

 LevelManager ()
 
 ~LevelManager ()
 
bool LoadLevel (const std::string &path)
 
bool SaveLevel (const std::string &path)
 
void NewLevel (const std::string &name)
 
EntityInstanceCreateEntity (const std::string &prefabPath)
 
void DeleteEntity (const std::string &id)
 
EntityInstanceGetEntity (const std::string &id) const
 
std::vector< EntityInstance * > GetAllEntities ()
 
bool UpdateEntityPosition (const std::string &id, const Vector &position)
 
void SetTile (int x, int y, int tileId)
 
int GetTile (int x, int y) const
 
void ResizeTileMap (int width, int height)
 
void SetCollision (int x, int y, uint8_t mask)
 
uint8_t GetCollision (int x, int y) const
 
void ResizeCollisionMap (int width, int height)
 
const LevelDefinitionGetLevelDefinition () const
 
LevelDefinitionGetLevelDefinition ()
 
const std::string & GetCurrentLevelPath () const
 
bool HasUnsavedChanges () const
 
void MarkDirty ()
 
void ClearDirty ()
 

Private Member Functions

void SerializeToJson (json &j) const
 
bool DeserializeFromJson (const json &j)
 
std::string GenerateUniqueEntityId ()
 
std::string GetCurrentTimestamp ()
 

Private Attributes

LevelDefinition m_levelDef
 
std::string m_currentPath
 
bool m_hasUnsavedChanges
 
int m_nextEntityId
 

Detailed Description

Definition at line 213 of file LevelManager.h.

Constructor & Destructor Documentation

◆ LevelManager()

Olympe::Editor::LevelManager::LevelManager ( )

Definition at line 78 of file LevelManager.cpp.

◆ ~LevelManager()

Olympe::Editor::LevelManager::~LevelManager ( )

Definition at line 83 of file LevelManager.cpp.

Member Function Documentation

◆ ClearDirty()

void Olympe::Editor::LevelManager::ClearDirty ( )
inline

Definition at line 248 of file LevelManager.h.

References m_hasUnsavedChanges.

◆ CreateEntity()

EntityInstance * Olympe::Editor::LevelManager::CreateEntity ( const std::string &  prefabPath)

Definition at line 406 of file LevelManager.cpp.

References Olympe::Editor::LevelDefinition::entities, GenerateUniqueEntityId(), GetComponentTypeID_Static(), m_hasUnsavedChanges, and m_levelDef.

+ Here is the call graph for this function:

◆ DeleteEntity()

void Olympe::Editor::LevelManager::DeleteEntity ( const std::string &  id)

Definition at line 422 of file LevelManager.cpp.

References Olympe::Editor::LevelDefinition::entities, GetComponentTypeID_Static(), m_hasUnsavedChanges, and m_levelDef.

+ Here is the call graph for this function:

◆ DeserializeFromJson()

bool Olympe::Editor::LevelManager::DeserializeFromJson ( const json j)
private

◆ GenerateUniqueEntityId()

std::string Olympe::Editor::LevelManager::GenerateUniqueEntityId ( )
private

Definition at line 104 of file LevelManager.cpp.

References GetComponentTypeID_Static(), and m_nextEntityId.

Referenced by CreateEntity().

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

◆ GetAllEntities()

std::vector< EntityInstance * > Olympe::Editor::LevelManager::GetAllEntities ( )

Definition at line 448 of file LevelManager.cpp.

References Olympe::Editor::LevelDefinition::entities, GetComponentTypeID_Static(), and m_levelDef.

+ Here is the call graph for this function:

◆ GetCollision()

uint8_t Olympe::Editor::LevelManager::GetCollision ( int  x,
int  y 
) const

Definition at line 519 of file LevelManager.cpp.

References Olympe::Editor::LevelDefinition::collisionMap, and m_levelDef.

◆ GetCurrentLevelPath()

const std::string & Olympe::Editor::LevelManager::GetCurrentLevelPath ( ) const
inline

Definition at line 245 of file LevelManager.h.

References m_currentPath.

◆ GetCurrentTimestamp()

std::string Olympe::Editor::LevelManager::GetCurrentTimestamp ( )
private

Definition at line 87 of file LevelManager.cpp.

References GetComponentTypeID_Static().

Referenced by NewLevel(), and SaveLevel().

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

◆ GetEntity()

EntityInstance * Olympe::Editor::LevelManager::GetEntity ( const std::string &  id) const

Definition at line 436 of file LevelManager.cpp.

References Olympe::Editor::LevelDefinition::entities, and m_levelDef.

Referenced by UpdateEntityPosition().

+ Here is the caller graph for this function:

◆ GetLevelDefinition() [1/2]

LevelDefinition & Olympe::Editor::LevelManager::GetLevelDefinition ( )
inline

Definition at line 243 of file LevelManager.h.

References m_levelDef.

◆ GetLevelDefinition() [2/2]

const LevelDefinition & Olympe::Editor::LevelManager::GetLevelDefinition ( ) const
inline

Definition at line 242 of file LevelManager.h.

References m_levelDef.

◆ GetTile()

int Olympe::Editor::LevelManager::GetTile ( int  x,
int  y 
) const

Definition at line 484 of file LevelManager.cpp.

References m_levelDef, and Olympe::Editor::LevelDefinition::tileMap.

◆ HasUnsavedChanges()

bool Olympe::Editor::LevelManager::HasUnsavedChanges ( ) const
inline

Definition at line 246 of file LevelManager.h.

References m_hasUnsavedChanges.

◆ LoadLevel()

bool Olympe::Editor::LevelManager::LoadLevel ( const std::string &  path)

Definition at line 129 of file LevelManager.cpp.

References DeserializeFromJson(), GetComponentTypeID_Static(), m_currentPath, and m_hasUnsavedChanges.

+ Here is the call graph for this function:

◆ MarkDirty()

void Olympe::Editor::LevelManager::MarkDirty ( )
inline

Definition at line 247 of file LevelManager.h.

References m_hasUnsavedChanges.

◆ NewLevel()

void Olympe::Editor::LevelManager::NewLevel ( const std::string &  name)

◆ ResizeCollisionMap()

void Olympe::Editor::LevelManager::ResizeCollisionMap ( int  width,
int  height 
)

Definition at line 529 of file LevelManager.cpp.

References Olympe::Editor::LevelDefinition::collisionMap, m_hasUnsavedChanges, and m_levelDef.

Referenced by NewLevel().

+ Here is the caller graph for this function:

◆ ResizeTileMap()

void Olympe::Editor::LevelManager::ResizeTileMap ( int  width,
int  height 
)

Definition at line 494 of file LevelManager.cpp.

References m_hasUnsavedChanges, m_levelDef, and Olympe::Editor::LevelDefinition::tileMap.

Referenced by NewLevel().

+ Here is the caller graph for this function:

◆ SaveLevel()

bool Olympe::Editor::LevelManager::SaveLevel ( const std::string &  path)

◆ SerializeToJson()

void Olympe::Editor::LevelManager::SerializeToJson ( json j) const
private

◆ SetCollision()

void Olympe::Editor::LevelManager::SetCollision ( int  x,
int  y,
uint8_t  mask 
)

Definition at line 509 of file LevelManager.cpp.

References Olympe::Editor::LevelDefinition::collisionMap, GetComponentTypeID_Static(), m_hasUnsavedChanges, and m_levelDef.

+ Here is the call graph for this function:

◆ SetTile()

void Olympe::Editor::LevelManager::SetTile ( int  x,
int  y,
int  tileId 
)

Definition at line 474 of file LevelManager.cpp.

References GetComponentTypeID_Static(), m_hasUnsavedChanges, m_levelDef, and Olympe::Editor::LevelDefinition::tileMap.

+ Here is the call graph for this function:

◆ UpdateEntityPosition()

bool Olympe::Editor::LevelManager::UpdateEntityPosition ( const std::string &  id,
const Vector position 
)

Definition at line 458 of file LevelManager.cpp.

References GetEntity(), m_hasUnsavedChanges, and Olympe::Editor::EntityInstance::position.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_currentPath

std::string Olympe::Editor::LevelManager::m_currentPath
private

Definition at line 259 of file LevelManager.h.

Referenced by GetCurrentLevelPath(), LoadLevel(), NewLevel(), and SaveLevel().

◆ m_hasUnsavedChanges

bool Olympe::Editor::LevelManager::m_hasUnsavedChanges
private

◆ m_levelDef

LevelDefinition Olympe::Editor::LevelManager::m_levelDef
private

◆ m_nextEntityId

int Olympe::Editor::LevelManager::m_nextEntityId
private

Definition at line 261 of file LevelManager.h.

Referenced by DeserializeFromJson(), GenerateUniqueEntityId(), and NewLevel().


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