mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
1 Commits
feature/em
...
feat/previ
Author | SHA1 | Date | |
---|---|---|---|
![]() |
aa6aada8be |
@@ -78,6 +78,28 @@ void DeclareSystemInfoExtension(gd::PlatformExtension& extension) {
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"IsPreviewingAnExternalLayout",
|
||||
_("Is the game running an external layout as a preview"),
|
||||
_("Check if the game is currently being previewed in the editor, "
|
||||
"and this preview was launched for an external layout."),
|
||||
_("An external layout of the game is being previewed in the editor"),
|
||||
"",
|
||||
"CppPlatform/Extensions/systeminfoicon.png",
|
||||
"CppPlatform/Extensions/systeminfoicon.png")
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
extension
|
||||
.AddExpression("PreviewedExternalLayoutName",
|
||||
_("Name of the previewed external layout"),
|
||||
_("Returns the name of the external layout being "
|
||||
"previewed from the editor"),
|
||||
"",
|
||||
"CppPlatform/Extensions/systeminfoicon.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"HasTouchScreen",
|
||||
|
@@ -39,6 +39,12 @@ class SystemInfoJsExtension : public gd::PlatformExtension {
|
||||
GetAllConditions()["SystemInfo::IsPreview"]
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isPreview");
|
||||
GetAllConditions()["SystemInfo::IsPreviewingAnExternalLayout"]
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isPreviewingAnExternalLayout");
|
||||
GetAllExpressions()["SystemInfo::PreviewedExternalLayoutName"]
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.getPreviewedExternalLayoutName");
|
||||
GetAllConditions()["SystemInfo::HasTouchScreen"]
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.hasTouchScreen");
|
||||
|
@@ -81,6 +81,34 @@ namespace gdjs {
|
||||
): boolean => {
|
||||
return instanceContainer.getGame().isPreview();
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the game is running as a preview, launched from an editor,
|
||||
* for an external layout.
|
||||
* @param instanceContainer The current container.
|
||||
* @returns true if the game is running as a preview for an external layout.
|
||||
*/
|
||||
export const isPreviewingAnExternalLayout = (
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
): boolean => {
|
||||
const game = instanceContainer.getGame();
|
||||
return game.isPreview() && !!game.getPreviewedExternalLayoutName();
|
||||
};
|
||||
|
||||
/**
|
||||
* If the game is running as a preview, launched from an editor,
|
||||
* this returns the name of the external layout being previewed - if any.
|
||||
* Otherwise, returns an empty string.
|
||||
*
|
||||
* @param instanceContainer The current container.
|
||||
* @returns the name of the previewed external layout.
|
||||
*/
|
||||
export const getPreviewedExternalLayoutName = (
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer
|
||||
): string => {
|
||||
const game = instanceContainer.getGame();
|
||||
return game.getPreviewedExternalLayoutName();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -186,7 +186,7 @@ namespace gdjs {
|
||||
/**
|
||||
* Allow to specify an external layout to insert in the first scene.
|
||||
*/
|
||||
_injectExternalLayout: any;
|
||||
_injectExternalLayout: string;
|
||||
_options: RuntimeGameOptions;
|
||||
|
||||
/**
|
||||
@@ -1078,6 +1078,15 @@ namespace gdjs {
|
||||
return this._isPreview;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the external layout that was automatically created at position 0;0
|
||||
* for this preview, if any.
|
||||
* @returns the name of the external layout, or an empty string if none was injected.
|
||||
*/
|
||||
getPreviewedExternalLayoutName(): string {
|
||||
return this._injectExternalLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the game should call GDevelop development APIs or not.
|
||||
*
|
||||
|
Reference in New Issue
Block a user