Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/MapGenerator.h
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | public: | ||||
shared_ptr<ScriptInterface::StructuredClone> GetResults(); | shared_ptr<ScriptInterface::StructuredClone> GetResults(); | ||||
/** | /** | ||||
* Set initial seed, callback data. | * Set initial seed, callback data. | ||||
* Expose functions, globals and classes defined in this class relevant to the map and test scripts. | * Expose functions, globals and classes defined in this class relevant to the map and test scripts. | ||||
*/ | */ | ||||
void InitScriptInterface(const u32 seed); | void InitScriptInterface(const u32 seed); | ||||
static CMapGeneratorWorker* GetWorkerFromCxPrivateData(JSContext* cx, JS::CallArgs&); | |||||
private: | private: | ||||
/** | /** | ||||
* Expose functions defined in this class that are relevant to mapscripts but not the tests. | * Expose functions defined in this class that are relevant to mapscripts but not the tests. | ||||
*/ | */ | ||||
void RegisterScriptFunctions_MapGenerator(); | void RegisterScriptFunctions_MapGenerator(); | ||||
/** | /** | ||||
* Load all scripts of the given library | * Load all scripts of the given library | ||||
* | * | ||||
* @param libraryName VfsPath specifying name of the library (subfolder of ../maps/random/) | * @param libraryName VfsPath specifying name of the library (subfolder of ../maps/random/) | ||||
* @return true if all scripts ran successfully, false if there's an error | * @return true if all scripts ran successfully, false if there's an error | ||||
*/ | */ | ||||
bool LoadScripts(const VfsPath& libraryName); | bool LoadScripts(const VfsPath& libraryName); | ||||
/** | /** | ||||
* Recursively load all script files in the given folder. | |||||
*/ | |||||
static bool LoadLibrary(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& name); | |||||
/** | |||||
* Finalize map generation and pass results from the script to the engine. | * Finalize map generation and pass results from the script to the engine. | ||||
*/ | */ | ||||
static void ExportMap(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data); | void ExportMap(JS::HandleValue data); | ||||
/** | /** | ||||
* Load an image file and return it as a height array. | * Load an image file and return it as a height array. | ||||
*/ | */ | ||||
static JS::Value LoadHeightmap(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& src); | std::vector<u16> LoadHeightmapImage(const VfsPath& src); | ||||
/** | /** | ||||
* Load an Atlas terrain file (PMP) returning textures and heightmap. | * Load an Atlas terrain file (PMP) returning textures and heightmap. | ||||
*/ | */ | ||||
static JS::Value LoadMapTerrain(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& filename); | JS::Value LoadMapTerrain(const VfsPath& filename); | ||||
/** | /** | ||||
* Sets the map generation progress, which is one of multiple stages determining the loading screen progress. | * Sets the map generation progress, which is one of multiple stages determining the loading screen progress. | ||||
*/ | */ | ||||
static void SetProgress(ScriptInterface::CxPrivate* pCxPrivate, int progress); | void SetProgress(int progress); | ||||
/** | /** | ||||
* Microseconds since the epoch. | * Microseconds since the epoch. | ||||
*/ | */ | ||||
static double GetMicroseconds(ScriptInterface::CxPrivate* pCxPrivate); | double GetMicroseconds(); | ||||
/** | /** | ||||
* Return the template data of the given template name. | * Return the template data of the given template name. | ||||
*/ | */ | ||||
static CParamNode GetTemplate(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName); | CParamNode GetTemplate(const std::string& templateName); | ||||
/** | /** | ||||
* Check whether the given template exists. | * Check whether the given template exists. | ||||
*/ | */ | ||||
static bool TemplateExists(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName); | bool TemplateExists(const std::string& templateName); | ||||
/** | /** | ||||
* Returns all template names of simulation entity templates. | * Returns all template names of simulation entity templates. | ||||
*/ | */ | ||||
static std::vector<std::string> FindTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories); | std::vector<std::string> FindTemplates(const std::string& path, bool includeSubdirectories); | ||||
/** | /** | ||||
* Returns all template names of actors. | * Returns all template names of actors. | ||||
*/ | */ | ||||
static std::vector<std::string> FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories); | std::vector<std::string> FindActorTemplates(const std::string& path, bool includeSubdirectories); | ||||
private: | |||||
/** | /** | ||||
* Perform map generation in an independent thread. | * Perform map generation in an independent thread. | ||||
*/ | */ | ||||
static void* RunThread(CMapGeneratorWorker* self); | static void* RunThread(CMapGeneratorWorker* self); | ||||
/** | /** | ||||
* Perform the map generation. | * Perform the map generation. | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator