GDevelop JS Platform
Platform for developing HTML5/Javascript based games with GDevelop
 All Classes Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
gdjs::ExporterHelper Class Reference

Export a project or a layout to a playable HTML5/Javascript based game. More...

#include <ExporterHelper.h>

Public Member Functions

 ExporterHelper (gd::AbstractFileSystem &fileSystem, gd::String gdjsRoot_, gd::String codeOutputDir)
 
const gd::String & GetLastError () const
 Return the error that occurred during the last export.
 
void AddLibsInclude (bool pixiRenderers, bool cocosRenderers, bool websocketDebuggerClient, std::vector< gd::String > &includesFiles)
 Add libraries files from Pixi.js or Cocos2d to the list of includes.
 
void RemoveIncludes (bool pixiRenderers, bool cocosRenderers, std::vector< gd::String > &includesFiles)
 Remove include files that are Pixi or Cocos2d renderers.
 
bool ExportIncludesAndLibs (std::vector< gd::String > &includesFiles, gd::String exportDir, bool minify)
 Copy all the includes files and the standard libraries files to the export directory. More...
 
bool ExportEventsCode (gd::Project &project, gd::String outputDir, std::vector< gd::String > &includesFiles, bool exportForPreview)
 Generate the events JS code, and save them to the export directory. More...
 
bool ExportEffectIncludes (gd::Project &project, std::vector< gd::String > &includesFiles)
 Add the project effects include files.
 
bool ExportExternalSourceFiles (gd::Project &project, gd::String outputDir, std::vector< gd::String > &includesFiles)
 Copy the external source files used by the game into the export directory, and add them into files to be included. More...
 
bool ExportPixiIndexFile (const gd::Project &project, gd::String source, gd::String exportDir, const std::vector< gd::String > &includesFiles, gd::String additionalSpec="")
 Generate the standard index file and save it to the export directory. More...
 
bool CompleteIndexFile (gd::String &indexFileContent, gd::String customCss, gd::String customHtml, gd::String exportDir, const std::vector< gd::String > &includesFiles, gd::String additionalSpec)
 Replace the annotations in a index.html file by the specified content. More...
 
bool ExportCordovaFiles (const gd::Project &project, gd::String exportDir)
 Generate the Cordova configuration file and save it to the export directory. More...
 
bool ExportCocos2dFiles (const gd::Project &project, gd::String exportDir, bool debugMode, const std::vector< gd::String > &includesFiles)
 Generate the base Cocos2d files.
 
bool ExportElectronFiles (const gd::Project &project, gd::String exportDir)
 Generate the Electron files for packaging and save it to the export directory. More...
 
bool ExportFacebookInstantGamesFiles (const gd::Project &project, gd::String exportDir)
 Generate the Facebook Instant Games files for packaging and save it to the export directory. More...
 
bool ExportLayoutForPixiPreview (gd::Project &project, gd::Layout &layout, gd::String exportDir, gd::String additionalSpec)
 Launch all export methods to generate a complete, stand-alone game for previewing. More...
 
void SetCodeOutputDirectory (gd::String codeOutputDir_)
 Change the directory where code files are generated. More...
 

Static Public Member Functions

static gd::String ExportToJSON (gd::AbstractFileSystem &fs, const gd::Project &project, gd::String filename, gd::String wrapIntoVariable)
 Export a project to JSON. More...
 
static void ExportResources (gd::AbstractFileSystem &fs, gd::Project &project, gd::String exportDir)
 Copy all the resources of the project to to the export directory, updating the resources filenames. More...
 

Public Attributes

gd::AbstractFileSystem & fs
 The abstract file system to be used for exportation.
 
gd::String lastError
 The last error that occurred.
 
gd::String gdjsRoot
 The root directory of GDJS, used to copy runtime files.
 
gd::String codeOutputDir
 

Detailed Description

Export a project or a layout to a playable HTML5/Javascript based game.

Member Function Documentation

bool gdjs::ExporterHelper::CompleteIndexFile ( gd::String &  indexFileContent,
gd::String  customCss,
gd::String  customHtml,
gd::String  exportDir,
const std::vector< gd::String > &  includesFiles,
gd::String  additionalSpec 
)

Replace the annotations in a index.html file by the specified content.

Parameters
indexFileContentThe source of the index.html file.
customCss"<!-- GDJS_CUSTOM_STYLE -->" will be replaced by the content of the string.
customHtml"<!-- GDJS_CUSTOM_HTML -->" will be replaced by the content of the string.
exportDirThe directory where the project must be generated.
codeFilesIncludes"" will be replaced by HTML tags to include the filenames contained inside the vector.
additionalSpecThe string "GDJS_ADDITIONAL_SPEC" surrounded by comments marks will be replaced by the content of the string.
bool gdjs::ExporterHelper::ExportCordovaFiles ( const gd::Project &  project,
gd::String  exportDir 
)

Generate the Cordova configuration file and save it to the export directory.

Parameters
projectThe project to be used to generate the configuration file.
exportDirThe directory where the config.xml must be created.
bool gdjs::ExporterHelper::ExportElectronFiles ( const gd::Project &  project,
gd::String  exportDir 
)

Generate the Electron files for packaging and save it to the export directory.

Parameters
projectThe project to be used to generate the files.
exportDirThe directory where the files must be created.
bool gdjs::ExporterHelper::ExportEventsCode ( gd::Project &  project,
gd::String  outputDir,
std::vector< gd::String > &  includesFiles,
bool  exportForPreview 
)

Generate the events JS code, and save them to the export directory.

Files are named "codeX.js", X being the number of the layout in the project.

Parameters
projectThe project with resources to be exported.
outputDirThe directory where the events code must be generated.
includesFilesA reference to a vector that will be filled with JS files to be exported along with the project. ( including "codeX.js" files ).
bool gdjs::ExporterHelper::ExportExternalSourceFiles ( gd::Project &  project,
gd::String  outputDir,
std::vector< gd::String > &  includesFiles 
)

Copy the external source files used by the game into the export directory, and add them into files to be included.

Files are named "ext-codeX.js", X being the index of the external source file in the project.

Parameters
projectThe project with resources to be exported.
outputDirThe directory where the events code must be generated.
includesFilesA reference to a vector that will be filled with JS files to be exported along with the project. (including "ext-codeX.js" files).
bool gdjs::ExporterHelper::ExportFacebookInstantGamesFiles ( const gd::Project &  project,
gd::String  exportDir 
)

Generate the Facebook Instant Games files for packaging and save it to the export directory.

Parameters
projectThe project to be used to generate the files.
exportDirThe directory where the files must be created.
bool gdjs::ExporterHelper::ExportIncludesAndLibs ( std::vector< gd::String > &  includesFiles,
gd::String  exportDir,
bool  minify 
)

Copy all the includes files and the standard libraries files to the export directory.

The includes files are also modified so as to be relative to the export directory ( Files with absolute filenames are copied into the export directory and their path are stripped ).

Parameters
includesFilesA vector with filenames to be copied.
exportDirThe directory where the preview must be created.
minifyIf true, the includes files must be merged into one file using Google Closure Compiler. ( includesFiles parameter will be updated with the new filename )
bool gdjs::ExporterHelper::ExportLayoutForPixiPreview ( gd::Project &  project,
gd::Layout &  layout,
gd::String  exportDir,
gd::String  additionalSpec 
)

Launch all export methods to generate a complete, stand-alone game for previewing.

Parameters
layoutThe layout to be previewed.
exportDirThe directory where the preview must be created.
additionalSpecAny additional parameters to be passed to the gdjs.RuntimeGame.
Returns
true if export was successful.
bool gdjs::ExporterHelper::ExportPixiIndexFile ( const gd::Project &  project,
gd::String  source,
gd::String  exportDir,
const std::vector< gd::String > &  includesFiles,
gd::String  additionalSpec = "" 
)

Generate the standard index file and save it to the export directory.

The includes files must be relative to the export directory.

Parameters
projectThe project with layouts to be exported.
sourceThe file to be used as a template for the final file.
exportDirThe directory where the preview must be created.
includesFilesThe JS files to be included in the HTML file. Order is important.
additionalSpecJSON string that will be passed to the gdjs.RuntimeGame object.
void gdjs::ExporterHelper::ExportResources ( gd::AbstractFileSystem &  fs,
gd::Project &  project,
gd::String  exportDir 
)
static

Copy all the resources of the project to to the export directory, updating the resources filenames.

Parameters
fsThe abstract file system to use
projectThe project with resources to be exported.
exportDirThe directory where the preview must be created.
progressDlgOptional wxProgressDialog which will be updated with the progress.
gd::String gdjs::ExporterHelper::ExportToJSON ( gd::AbstractFileSystem &  fs,
const gd::Project &  project,
gd::String  filename,
gd::String  wrapIntoVariable 
)
static

Export a project to JSON.

Parameters
fsThe abstract file system to use to write the file
projectThe project to be exported.
filenameThe filename where export the project
wrapIntoVariableIf not empty, the resulting json will be wrapped in this javascript variable allowing to use it as a classical javascript object.
Returns
Empty string if everthing is ok, description of the error otherwise.
void gdjs::ExporterHelper::SetCodeOutputDirectory ( gd::String  codeOutputDir_)
inline

Change the directory where code files are generated.

By default, this is set to a temporary directory.

Member Data Documentation

gd::String gdjs::ExporterHelper::codeOutputDir

The directory where JS code is outputted. Will be then copied to the final output directory.


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