11 #include <unordered_map>
14 #include "GDCore/IDE/CaptureOptions.h"
15 #include "GDCore/String.h"
20 class SerializerElement;
21 class AbstractFileSystem;
22 class ResourcesContainer;
23 class SourceFileMetadata;
24 class WholeProjectDiagnosticReport;
27 class InGameEditorResourceMetadata;
42 exportPath(exportPath_),
43 useWindowMessageDebuggerClient(false),
44 useMinimalDebuggerClient(false),
45 nativeMobileApp(false),
46 fullLoadingScreen(false),
47 isDevelopmentEnvironment(false),
48 isInGameEdition(false),
49 nonRuntimeScriptsCacheBurst(0),
50 inAppTutorialMessageInPreview(
""),
51 inAppTutorialMessagePositionInPreview(
""),
53 fallbackAuthorUsername(
""),
57 allowAuthenticationUsingIframeForPreview(false) {};
64 const gd::String &address,
const gd::String &port) {
65 websocketDebuggerServerAddress = address;
66 websocketDebuggerServerPort = port;
75 const gd::String &message,
const gd::String &position) {
76 inAppTutorialMessageInPreview = message;
77 inAppTutorialMessagePositionInPreview = position;
86 const gd::String &username) {
87 fallbackAuthorId = id;
88 fallbackAuthorUsername = username;
97 const gd::String &username,
98 const gd::String &token) {
100 playerUsername = username;
110 useWindowMessageDebuggerClient =
true;
118 useMinimalDebuggerClient =
true;
127 nativeMobileApp = enable;
135 layoutName = layoutName_;
144 const gd::String &externalLayoutName_) {
145 externalLayoutName = externalLayoutName_;
154 const gd::String &eventsBasedObjectType_) {
155 eventsBasedObjectType = eventsBasedObjectType_;
164 const gd::String &eventsBasedObjectVariantName_) {
165 eventsBasedObjectVariantName = eventsBasedObjectVariantName_;
175 includeFileHashes[includeFile] = hash;
183 shouldClearExportFolder = enable;
191 shouldReloadProjectData = enable;
199 shouldReloadLibraries = enable;
207 shouldGenerateScenesEventsCode = enable;
216 fullLoadingScreen = enable;
225 isDevelopmentEnvironment = enable;
233 isInGameEdition = enable;
241 inGameEditorSettingsJson = inGameEditorSettingsJson_;
249 editorId = editorId_;
258 double positionY,
double positionZ,
259 double rotationAngle,
double elevationAngle,
261 editorCamera3DCameraMode = cameraMode;
262 editorCamera3DPositionX = positionX;
263 editorCamera3DPositionY = positionY;
264 editorCamera3DPositionZ = positionZ;
265 editorCamera3DRotationAngle = rotationAngle;
266 editorCamera3DElevationAngle = elevationAngle;
267 editorCamera3DDistance = distance;
277 nonRuntimeScriptsCacheBurst = value;
288 const gd::String &electronRemoteRequirePath_) {
289 electronRemoteRequirePath = electronRemoteRequirePath_;
298 const gd::String &gdevelopResourceToken_) {
299 gdevelopResourceToken = gdevelopResourceToken_;
311 bool allowAuthenticationUsingIframeForPreview_) {
312 allowAuthenticationUsingIframeForPreview =
313 allowAuthenticationUsingIframeForPreview_;
321 const gd::String &crashReportUploadLevel_) {
322 crashReportUploadLevel = crashReportUploadLevel_;
330 previewContext = previewContext_;
338 const gd::String &gdevelopVersionWithHash_) {
339 gdevelopVersionWithHash = gdevelopVersionWithHash_;
347 const gd::String &projectTemplateSlug_) {
348 projectTemplateSlug = projectTemplateSlug_;
356 sourceGameId = sourceGameId_;
365 const gd::String &signedUrl,
366 const gd::String &publicUrl) {
367 gd::Screenshot screenshot;
368 screenshot.SetDelayTimeInSeconds(delayTimeInSeconds);
369 screenshot.SetSignedUrl(signedUrl);
370 screenshot.SetPublicUrl(publicUrl);
371 captureOptions.AddScreenshot(screenshot);
375 gd::Project &project;
376 gd::String exportPath;
377 gd::String websocketDebuggerServerAddress;
378 gd::String websocketDebuggerServerPort;
379 bool useWindowMessageDebuggerClient;
380 bool useMinimalDebuggerClient;
381 gd::String layoutName;
382 gd::String externalLayoutName;
383 gd::String eventsBasedObjectType;
384 gd::String eventsBasedObjectVariantName;
385 gd::String fallbackAuthorUsername;
386 gd::String fallbackAuthorId;
388 gd::String playerUsername;
389 gd::String playerToken;
390 gd::String inAppTutorialMessageInPreview;
391 gd::String inAppTutorialMessagePositionInPreview;
392 bool nativeMobileApp;
393 std::map<gd::String, int> includeFileHashes;
394 bool shouldClearExportFolder =
true;
395 bool shouldReloadProjectData =
true;
396 bool shouldReloadLibraries =
true;
397 bool shouldGenerateScenesEventsCode =
true;
398 bool fullLoadingScreen;
399 bool isDevelopmentEnvironment;
400 bool isInGameEdition;
402 gd::String editorCamera3DCameraMode;
403 gd::String inGameEditorSettingsJson;
404 double editorCamera3DPositionX = 0;
405 double editorCamera3DPositionY = 0;
406 double editorCamera3DPositionZ = 0;
407 double editorCamera3DRotationAngle = 0;
408 double editorCamera3DElevationAngle = 0;
409 double editorCamera3DDistance = 0;
410 unsigned int nonRuntimeScriptsCacheBurst;
411 gd::String electronRemoteRequirePath;
412 gd::String gdevelopResourceToken;
413 bool allowAuthenticationUsingIframeForPreview;
414 gd::String crashReportUploadLevel;
415 gd::String previewContext;
416 gd::String gdevelopVersionWithHash;
417 gd::String projectTemplateSlug;
418 gd::String sourceGameId;
419 gd::CaptureOptions captureOptions;
432 exportPath(exportPath_),
434 fallbackAuthorId(
""),
435 fallbackAuthorUsername(
"") {};
442 const gd::String &username) {
443 fallbackAuthorId = id;
444 fallbackAuthorUsername = username;
459 gd::Project &project;
460 gd::String exportPath;
462 gd::String fallbackAuthorUsername;
463 gd::String fallbackAuthorId;
473 gd::String gdjsRoot_,
495 gd::AbstractFileSystem &
fs, gd::Project &project, gd::String filename,
496 const gd::SerializerElement &runtimeGameOptions,
bool isInGameEdition,
497 const std::vector<gd::InGameEditorResourceMetadata> &inGameEditorResources);
509 const gd::Project &project,
511 gd::SerializerElement &projectDataElement,
512 const std::vector<gd::InGameEditorResourceMetadata> &inGameEditorResources);
529 std::vector<gd::String> &includesFiles,
530 gd::SerializerElement &runtimeGameOptionsElement);
543 gd::Project &project,
544 gd::String exportDir);
550 bool pixiInThreeRenderers,
551 bool isInGameEdition,
552 bool includeWebsocketDebuggerClient,
553 bool includeWindowMessageDebuggerClient,
554 bool includeMinimalDebuggerClient,
555 bool includeCaptureManager,
556 bool includeInAppTutorialMessage,
557 gd::String gdevelopLogoStyle,
558 std::vector<gd::String> &includesFiles);
564 std::vector<gd::String> &includesFiles);
577 gd::String exportDir,
578 bool exportSourceMaps);
590 const gd::Project &project,
591 gd::String outputDir,
592 std::vector<gd::String> &includesFiles,
593 gd::WholeProjectDiagnosticReport &wholeProjectDiagnosticReport,
594 bool exportForPreview);
600 std::vector<gd::String> &includesFiles);
621 gd::String exportDir,
622 const std::vector<gd::String> &includesFiles,
623 const std::vector<gd::SourceFileMetadata> &sourceFiles,
624 unsigned int nonRuntimeScriptsCacheBurst,
625 gd::String additionalSpec =
"");
644 gd::String exportDir,
645 const std::vector<gd::String> &includesFiles,
646 unsigned int nonRuntimeScriptsCacheBurst,
647 gd::String additionalSpec);
666 gd::String exportDir,
667 std::set<gd::String> usedExtensions);
677 gd::String exportDir,
678 std::set<gd::String> usedExtensions);
688 gd::String exportDir);
698 gd::String exportDir);
717 std::vector<gd::String> &includesFiles);
727 gd::AbstractFileSystem &
fs,
const gd::String &
gdjsRoot,
728 const gd::String &include,
unsigned int nonRuntimeScriptsCacheBurst = 0);
739 static void AddDeprecatedFontFilesToFontResources(
740 gd::AbstractFileSystem &
fs,
741 gd::ResourcesContainer &resourcesManager,
742 const gd::String &exportDir,
743 gd::String urlPrefix =
"");
745 gd::AbstractFileSystem
755 SerializeUsedResources(gd::SerializerElement &rootElement,
756 std::set<gd::String> &projectUsedResources,
757 std::unordered_map<gd::String, std::set<gd::String>>
758 &layersUsedResources,
759 std::unordered_map<gd::String, std::set<gd::String>>
760 &eventsBasedObjectVariantsUsedResources);
765 static void StripAndSerializeProjectData(gd::Project &project,
766 gd::SerializerElement &rootElement,
767 bool isInGameEdition,
768 const std::vector<gd::InGameEditorResourceMetadata> &inGameEditorResources);
775 AddInGameEditorResources(gd::Project &project,
776 std::set<gd::String> &projectUsedResources,
777 const std::vector<gd::InGameEditorResourceMetadata> &inGameEditorResources);
Export a project or a layout to a playable HTML5/Javascript based game.
Definition: ExporterHelper.h:470
static gd::String ExportProjectData(gd::AbstractFileSystem &fs, gd::Project &project, gd::String filename, const gd::SerializerElement &runtimeGameOptions, bool isInGameEdition, const std::vector< gd::InGameEditorResourceMetadata > &inGameEditorResources)
Export a project without its events and options to 2 JS variables.
Definition: ExporterHelper.cpp:347
bool CompleteIndexFile(gd::String &indexFileContent, gd::String exportDir, const std::vector< gd::String > &includesFiles, unsigned int nonRuntimeScriptsCacheBurst, gd::String additionalSpec)
Replace the annotations in a index.html file by the specified content.
Definition: ExporterHelper.cpp:1079
gd::String lastError
The last error that occurred.
Definition: ExporterHelper.h:747
bool ExportEffectIncludes(gd::Project &project, std::vector< gd::String > &includesFiles)
Add the project effects include files.
Definition: ExporterHelper.cpp:1269
bool ExportHtml5Files(const gd::Project &project, gd::String exportDir)
Generate any HTML5 specific file.
Definition: ExporterHelper.cpp:948
bool ExportBuildResourcesElectronFiles(const gd::Project &project, gd::String exportDir)
Generate the Build Resources files for Electron (mainly for the icons) for packaging and save it to t...
Definition: ExporterHelper.cpp:1060
bool ExportIncludesAndLibs(const std::vector< gd::String > &includesFiles, gd::String exportDir, bool exportSourceMaps)
Copy all the specified files to the export directory. Relative files are copied from "<GDJS root>/Run...
Definition: ExporterHelper.cpp:1356
gd::String gdjsRoot
The root directory of GDJS, used to copy runtime files.
Definition: ExporterHelper.h:749
bool ExportCordovaFiles(const gd::Project &project, gd::String exportDir, std::set< gd::String > usedExtensions)
Generate the Cordova configuration file and save it to the export directory.
Definition: ExporterHelper.cpp:749
bool ExportProjectForPixiPreview(const PreviewExportOptions &options, std::vector< gd::String > &includesFiles)
Create a preview for the specified options.
Definition: ExporterHelper.cpp:109
static void SerializeRuntimeGameOptions(gd::AbstractFileSystem &fs, const gd::String &gdjsRoot, const PreviewExportOptions &options, std::vector< gd::String > &includesFiles, gd::SerializerElement &runtimeGameOptionsElement)
Serialize the content of the extra configuration to store in gdjs.runtimeGameOptions to JSON.
Definition: ExporterHelper.cpp:370
void AddLibsInclude(bool pixiRenderers, bool pixiInThreeRenderers, bool isInGameEdition, bool includeWebsocketDebuggerClient, bool includeWindowMessageDebuggerClient, bool includeMinimalDebuggerClient, bool includeCaptureManager, bool includeInAppTutorialMessage, gd::String gdevelopLogoStyle, std::vector< gd::String > &includesFiles)
Add libraries files to the list of includes.
Definition: ExporterHelper.cpp:1114
static void SerializeProjectData(gd::AbstractFileSystem &fs, const gd::Project &project, const PreviewExportOptions &options, gd::SerializerElement &projectDataElement, const std::vector< gd::InGameEditorResourceMetadata > &inGameEditorResources)
Serialize a project without its events to JSON.
Definition: ExporterHelper.cpp:527
bool ExportFacebookInstantGamesFiles(const gd::Project &project, gd::String exportDir)
Generate the Facebook Instant Games files for packaging and save it to the export directory.
Definition: ExporterHelper.cpp:927
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.
Definition: ExporterHelper.cpp:1395
gd::String codeOutputDir
Definition: ExporterHelper.h:750
bool ExportIndexFile(const gd::Project &project, gd::String source, gd::String exportDir, const std::vector< gd::String > &includesFiles, const std::vector< gd::SourceFileMetadata > &sourceFiles, unsigned int nonRuntimeScriptsCacheBurst, gd::String additionalSpec="")
Generate the standard index file and save it to the export directory.
Definition: ExporterHelper.cpp:702
void RemoveIncludes(bool pixiRenderers, std::vector< gd::String > &includesFiles)
Remove include files that are Pixi renderers.
Definition: ExporterHelper.cpp:1255
bool ExportScenesEventsCode(const gd::Project &project, gd::String outputDir, std::vector< gd::String > &includesFiles, gd::WholeProjectDiagnosticReport &wholeProjectDiagnosticReport, bool exportForPreview)
Generate the events JS code, and save them to the export directory.
Definition: ExporterHelper.cpp:1281
static gd::String GetExportedIncludeFilename(gd::AbstractFileSystem &fs, const gd::String &gdjsRoot, const gd::String &include, unsigned int nonRuntimeScriptsCacheBurst=0)
Given an include file, returns the name of the file to reference in the exported game.
Definition: ExporterHelper.cpp:1316
const gd::String & GetLastError() const
Return the error that occurred during the last export.
Definition: ExporterHelper.h:480
const gd::String GenerateWebManifest(const gd::Project &project)
Generates a WebManifest, a metadata file that allow to make the exported game a working PWA.
Definition: ExporterHelper.cpp:1439
gd::AbstractFileSystem & fs
The abstract file system to be used for exportation.
Definition: ExporterHelper.h:746
bool ExportElectronFiles(const gd::Project &project, gd::String exportDir, std::set< gd::String > usedExtensions)
Generate the Electron files for packaging and save it to the export directory.
Definition: ExporterHelper.cpp:969
void SetCodeOutputDirectory(gd::String codeOutputDir_)
Change the directory where code files are generated.
Definition: ExporterHelper.h:735
The options used to export a project.
Definition: ExporterHelper.h:425
ExportOptions & SetTarget(const gd::String &target_)
Set the (optional) target platform.
Definition: ExporterHelper.h:454
ExportOptions(gd::Project &project_, const gd::String &exportPath_)
Definition: ExporterHelper.h:430
ExportOptions & SetFallbackAuthor(const gd::String &id, const gd::String &username)
Set the fallback author info (if info not present in project properties).
Definition: ExporterHelper.h:441
The options used to export a project for a preview.
Definition: ExporterHelper.h:35
PreviewExportOptions & SetEventsBasedObjectType(const gd::String &eventsBasedObjectType_)
Set the (optional) events-based object to be instantiated in the scene at the beginning of the previe...
Definition: ExporterHelper.h:153
PreviewExportOptions & SetCrashReportUploadLevel(const gd::String &crashReportUploadLevel_)
Set the level of crash reports to be sent to GDevelop APIs.
Definition: ExporterHelper.h:320
PreviewExportOptions & UseWindowMessageDebuggerClient()
Set that the game should connect to the debugger server using the "Window Message " debugger client.
Definition: ExporterHelper.h:109
PreviewExportOptions & SetProjectTemplateSlug(const gd::String &projectTemplateSlug_)
Set the template slug that was used to create the project.
Definition: ExporterHelper.h:346
PreviewExportOptions & SetSourceGameId(const gd::String &sourceGameId_)
Set the source game id that was used to create the project.
Definition: ExporterHelper.h:355
PreviewExportOptions & SetExternalLayoutName(const gd::String &externalLayoutName_)
Set the (optional) external layout to be instantiated in the scene at the beginning of the previewed ...
Definition: ExporterHelper.h:143
PreviewExportOptions & SetEventsBasedObjectVariantName(const gd::String &eventsBasedObjectVariantName_)
Set the (optional) events-based object variant to be instantiated in the scene at the beginning of th...
Definition: ExporterHelper.h:163
PreviewExportOptions & SetElectronRemoteRequirePath(const gd::String &electronRemoteRequirePath_)
Definition: ExporterHelper.h:287
PreviewExportOptions & SetGDevelopResourceToken(const gd::String &gdevelopResourceToken_)
Definition: ExporterHelper.h:297
PreviewExportOptions & SetIncludeFileHash(const gd::String &includeFile, int hash)
Set the hash associated to an include file. Useful for the preview hot-reload, to know if a file chan...
Definition: ExporterHelper.h:173
PreviewExportOptions & SetGDevelopVersionWithHash(const gd::String &gdevelopVersionWithHash_)
Set the GDevelop version so the game is aware of it.
Definition: ExporterHelper.h:337
PreviewExportOptions & SetIsDevelopmentEnvironment(bool enable)
Set if the export should consider to be in a development environment of GDevelop (the game should use...
Definition: ExporterHelper.h:224
PreviewExportOptions & SetPreviewContext(const gd::String &previewContext_)
Set the context of the preview.
Definition: ExporterHelper.h:329
PreviewExportOptions & UseMinimalDebuggerClient()
Set that the game should have a minimal debugger client.
Definition: ExporterHelper.h:117
PreviewExportOptions & SetFullLoadingScreen(bool enable)
Set if the export should show the full loading screen (false by default, skipping the minimum duratio...
Definition: ExporterHelper.h:215
PreviewExportOptions & SetEditorCameraState3D(const gd::String &cameraMode, double positionX, double positionY, double positionZ, double rotationAngle, double elevationAngle, double distance)
Set the camera state to use in the in-game editor.
Definition: ExporterHelper.h:257
PreviewExportOptions & SetShouldReloadProjectData(bool enable)
Set if the ProjectData must be reloaded.
Definition: ExporterHelper.h:190
PreviewExportOptions & SetShouldReloadLibraries(bool enable)
Set if GDJS libraries must be reloaded.
Definition: ExporterHelper.h:198
PreviewExportOptions & UseWebsocketDebuggerClientWithServerAddress(const gd::String &address, const gd::String &port)
Set the address of the debugger server that the game should reach out to, using the "WebSockets" debu...
Definition: ExporterHelper.h:63
PreviewExportOptions & SetFallbackAuthor(const gd::String &id, const gd::String &username)
Set the fallback author info (if info not present in project properties).
Definition: ExporterHelper.h:85
PreviewExportOptions & SetShouldClearExportFolder(bool enable)
Set if the exported folder should be cleared befor the export.
Definition: ExporterHelper.h:182
PreviewExportOptions & SetLayoutName(const gd::String &layoutName_)
Set the layout to be run first in the previewed game.
Definition: ExporterHelper.h:134
PreviewExportOptions & SetAuthenticatedPlayer(const gd::String &id, const gd::String &username, const gd::String &token)
Set the fallback author info (if info not present in project properties).
Definition: ExporterHelper.h:96
PreviewExportOptions & SetInGameEditorSettingsJson(const gd::String &inGameEditorSettingsJson_)
Set the JSON string representation of the in-game editor settings.
Definition: ExporterHelper.h:240
PreviewExportOptions & SetEditorId(const gd::String &editorId_)
Set the in-game editor identifier.
Definition: ExporterHelper.h:248
PreviewExportOptions & SetShouldGenerateScenesEventsCode(bool enable)
Set if the export should export events code.
Definition: ExporterHelper.h:206
PreviewExportOptions & SetInAppTutorialMessageInPreview(const gd::String &message, const gd::String &position)
Set the message to display to the user in a preview (as part of an in-app tutorial).
Definition: ExporterHelper.h:74
PreviewExportOptions(gd::Project &project_, const gd::String &exportPath_)
Definition: ExporterHelper.h:40
PreviewExportOptions & SetNonRuntimeScriptsCacheBurst(unsigned int value)
If set to a non zero value, the exported script URLs will have an extra search parameter added (with ...
Definition: ExporterHelper.h:276
PreviewExportOptions & SetNativeMobileApp(bool enable)
Set that the preview is launched from a GDevelop native mobile app (iOS or Android).
Definition: ExporterHelper.h:126
PreviewExportOptions & AddScreenshotCapture(int delayTimeInSeconds, const gd::String &signedUrl, const gd::String &publicUrl)
Set the capture options to be used for taking screenshots or videos of the preview.
Definition: ExporterHelper.h:364
PreviewExportOptions & SetIsInGameEdition(bool enable)
Set if the export is made for being edited in the editor.
Definition: ExporterHelper.h:232
PreviewExportOptions & SetAllowAuthenticationUsingIframeForPreview(bool allowAuthenticationUsingIframeForPreview_)
Definition: ExporterHelper.h:310