Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks Class Reference

Provides callback's for the JavaScript. More...

Collaboration diagram for anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks:

Public Member Functions

 CMapGenerationCallbacks (std::atomic< int > &progress, ScriptInterface &scriptInterface, Script::StructuredClone &mapData, const u16 flags)
 
 ~CMapGenerationCallbacks ()
 

Private Member Functions

bool LoadLibrary (const VfsPath &libraryName)
 Load all scripts of the given library. More...
 
void ExportMap (JS::HandleValue data)
 Finalize map generation and pass results from the script to the engine. More...
 
JS::Value LoadHeightmapImage (const VfsPath &filename)
 Load an image file and return it as a height array. More...
 
JS::Value LoadMapTerrain (const VfsPath &filename)
 Load an Atlas terrain file (PMP) returning textures and heightmap. More...
 
void SetProgress (int progress)
 Sets the map generation progress, which is one of multiple stages determining the loading screen progress. More...
 
double GetMicroseconds () const
 Microseconds since the epoch. More...
 
CParamNode GetTemplate (const std::string &templateName)
 Return the template data of the given template name. More...
 
bool TemplateExists (const std::string &templateName) const
 Check whether the given template exists. More...
 
std::vector< std::string > FindTemplates (const std::string &path, bool includeSubdirectories)
 Returns all template names of simulation entity templates. More...
 
std::vector< std::string > FindActorTemplates (const std::string &path, bool includeSubdirectories)
 Returns all template names of actors. More...
 

Private Attributes

std::atomic< int > & m_Progress
 Current map generation progress. More...
 
ScriptInterfacem_ScriptInterface
 Provides the script context. More...
 
Script::StructuredClonem_MapData
 Result of the mapscript generation including terrain, entities and environment settings. More...
 
std::set< VfsPathm_LoadedLibraries
 Currently loaded script librarynames. More...
 
CTemplateLoader m_TemplateLoader
 Backend to loading template data. More...
 

Detailed Description

Provides callback's for the JavaScript.

Constructor & Destructor Documentation

◆ CMapGenerationCallbacks()

anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::CMapGenerationCallbacks ( std::atomic< int > &  progress,
ScriptInterface scriptInterface,
Script::StructuredClone mapData,
const u16  flags 
)
inline

◆ ~CMapGenerationCallbacks()

anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::~CMapGenerationCallbacks ( )
inline

Member Function Documentation

◆ ExportMap()

void anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::ExportMap ( JS::HandleValue  data)
inlineprivate

Finalize map generation and pass results from the script to the engine.

The data has to be according to this format: https://trac.wildfiregames.com/wiki/Random_Map_Generator_Internals#Dataformat

◆ FindActorTemplates()

std::vector< std::string > anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::FindActorTemplates ( const std::string &  path,
bool  includeSubdirectories 
)
inlineprivate

Returns all template names of actors.

◆ FindTemplates()

std::vector< std::string > anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::FindTemplates ( const std::string &  path,
bool  includeSubdirectories 
)
inlineprivate

Returns all template names of simulation entity templates.

◆ GetMicroseconds()

double anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::GetMicroseconds ( ) const
inlineprivate

Microseconds since the epoch.

◆ GetTemplate()

CParamNode anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::GetTemplate ( const std::string &  templateName)
inlineprivate

Return the template data of the given template name.

◆ LoadHeightmapImage()

JS::Value anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::LoadHeightmapImage ( const VfsPath filename)
inlineprivate

Load an image file and return it as a height array.

◆ LoadLibrary()

bool anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::LoadLibrary ( const VfsPath libraryName)
inlineprivate

Load all scripts of the given library.

Parameters
libraryNameVfsPath specifying name of the library (subfolder of ../maps/random/)
Returns
true if all scripts ran successfully, false if there's an error

◆ LoadMapTerrain()

JS::Value anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::LoadMapTerrain ( const VfsPath filename)
inlineprivate

Load an Atlas terrain file (PMP) returning textures and heightmap.

See CMapReader::UnpackTerrain, CMapReader::ParseTerrain for the reordering

◆ SetProgress()

void anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::SetProgress ( int  progress)
inlineprivate

Sets the map generation progress, which is one of multiple stages determining the loading screen progress.

◆ TemplateExists()

bool anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::TemplateExists ( const std::string &  templateName) const
inlineprivate

Check whether the given template exists.

Member Data Documentation

◆ m_LoadedLibraries

std::set<VfsPath> anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::m_LoadedLibraries
private

Currently loaded script librarynames.

◆ m_MapData

Script::StructuredClone& anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::m_MapData
private

Result of the mapscript generation including terrain, entities and environment settings.

◆ m_Progress

std::atomic<int>& anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::m_Progress
private

Current map generation progress.

◆ m_ScriptInterface

ScriptInterface& anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::m_ScriptInterface
private

Provides the script context.

◆ m_TemplateLoader

CTemplateLoader anonymous_namespace{MapGenerator.cpp}::CMapGenerationCallbacks::m_TemplateLoader
private

Backend to loading template data.


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