mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
126 Commits
v5.0.0-bet
...
v5.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dcec81519b | ||
![]() |
c9c2e41bd9 | ||
![]() |
39a6aa2a90 | ||
![]() |
f4532e7e4c | ||
![]() |
9a551673e8 | ||
![]() |
39887ccc80 | ||
![]() |
97c0761288 | ||
![]() |
edb33e805f | ||
![]() |
e1cfca6930 | ||
![]() |
26ffcda159 | ||
![]() |
ee905f4f04 | ||
![]() |
e4b2fe677b | ||
![]() |
2ed9b058be | ||
![]() |
35e3015d66 | ||
![]() |
b6707d62b2 | ||
![]() |
76466af778 | ||
![]() |
193b8fa36e | ||
![]() |
1c24e4f14d | ||
![]() |
d0bfb37680 | ||
![]() |
db480f09d8 | ||
![]() |
b2b3307ff7 | ||
![]() |
17754d4fe5 | ||
![]() |
0f912472ce | ||
![]() |
8c13b051ad | ||
![]() |
268075b8bc | ||
![]() |
23e899d93d | ||
![]() |
1a76ad9069 | ||
![]() |
1ac26ab8ce | ||
![]() |
69fa249db5 | ||
![]() |
f31b46cb14 | ||
![]() |
9e5ca5fb0b | ||
![]() |
b64eeebcbe | ||
![]() |
c9ae252ae8 | ||
![]() |
ca789c7b0b | ||
![]() |
a142472ea6 | ||
![]() |
d0c1f7fe03 | ||
![]() |
6680682001 | ||
![]() |
91ff59e846 | ||
![]() |
65aa60e726 | ||
![]() |
5bb6150861 | ||
![]() |
6b850e82e7 | ||
![]() |
400c956c2a | ||
![]() |
896446f640 | ||
![]() |
c8f526e726 | ||
![]() |
8bc6ea0744 | ||
![]() |
215cb0b859 | ||
![]() |
0d9e31f986 | ||
![]() |
0019da90c7 | ||
![]() |
dc870d55ac | ||
![]() |
df1fff36e4 | ||
![]() |
5da334a38e | ||
![]() |
3be5d85733 | ||
![]() |
4c62bc2f33 | ||
![]() |
57fbe470b7 | ||
![]() |
25abff997e | ||
![]() |
97ced4145f | ||
![]() |
1d7f8958fc | ||
![]() |
373c55ddc5 | ||
![]() |
8e0783e45f | ||
![]() |
22b977fd0e | ||
![]() |
f9925943a3 | ||
![]() |
26b6c8c6aa | ||
![]() |
ff1fec7c5c | ||
![]() |
97aeafc4c3 | ||
![]() |
5468ea19b3 | ||
![]() |
4ce2ba08ef | ||
![]() |
561ef0434f | ||
![]() |
d229d01aa9 | ||
![]() |
5fc9a4a51a | ||
![]() |
9f05a4e190 | ||
![]() |
ac7f681947 | ||
![]() |
f7ae28bea9 | ||
![]() |
3104eeb415 | ||
![]() |
cdf95811b9 | ||
![]() |
731356b791 | ||
![]() |
8dd13180fd | ||
![]() |
81421907a5 | ||
![]() |
bb23e2c018 | ||
![]() |
eb6461c819 | ||
![]() |
1a3bd2423d | ||
![]() |
c22934d46f | ||
![]() |
6cdee3b977 | ||
![]() |
88d102620a | ||
![]() |
3c5280a0f0 | ||
![]() |
ad9abd971c | ||
![]() |
48465425e4 | ||
![]() |
02ddea17ea | ||
![]() |
24b68f75b8 | ||
![]() |
bed9c77c8c | ||
![]() |
0a6f810695 | ||
![]() |
a70f5df386 | ||
![]() |
83951c952f | ||
![]() |
5b0758a035 | ||
![]() |
058a2e6c82 | ||
![]() |
78b00f8c36 | ||
![]() |
2de67eae57 | ||
![]() |
4b6e8454de | ||
![]() |
b3d9a773b0 | ||
![]() |
796937ba5d | ||
![]() |
977095fb36 | ||
![]() |
f1f1123dad | ||
![]() |
d8e87cd976 | ||
![]() |
663336c4ee | ||
![]() |
96c993e057 | ||
![]() |
5742dcfbf8 | ||
![]() |
bf231c6c07 | ||
![]() |
fdbc91137c | ||
![]() |
3e409681c2 | ||
![]() |
c23642e78c | ||
![]() |
7845a3577c | ||
![]() |
60484ee464 | ||
![]() |
06b54e277a | ||
![]() |
daa683f492 | ||
![]() |
f3a43e8739 | ||
![]() |
4fb830529a | ||
![]() |
9b7b02fab2 | ||
![]() |
ae3b25f8c0 | ||
![]() |
c59204ce04 | ||
![]() |
fd63f7bc96 | ||
![]() |
147dc321f1 | ||
![]() |
fd72c6efe9 | ||
![]() |
ff1891bb3a | ||
![]() |
ec32788b4c | ||
![]() |
95622169a3 | ||
![]() |
e89de02fa6 | ||
![]() |
63a5734f32 |
1
.clang_format
Normal file
1
.clang_format
Normal file
@@ -0,0 +1 @@
|
||||
{BasedOnStyle: Google, BinPackParameters: false, BinPackArguments: false}
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -74,7 +74,8 @@
|
||||
"__string": "cpp",
|
||||
"cstring": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"cstdint": "cpp"
|
||||
"cstdint": "cpp",
|
||||
"forward_list": "cpp"
|
||||
},
|
||||
"files.exclude": {
|
||||
"Binaries/*build*": true,
|
||||
@@ -93,5 +94,8 @@
|
||||
},
|
||||
// Support for Flowtype:
|
||||
"javascript.validate.enable": false,
|
||||
"flow.useNPMPackagedFlow": true
|
||||
"flow.useNPMPackagedFlow": true,
|
||||
|
||||
// Clang format styling (duplicated in scripts/CMakeClangUtils.txt)
|
||||
"C_Cpp.clang_format_style": "{BasedOnStyle: Google, BinPackParameters: false, BinPackArguments: false}"
|
||||
}
|
||||
|
@@ -586,7 +586,7 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
|
||||
supplementaryParametersTypes) {
|
||||
gd::String argOutput;
|
||||
|
||||
if (metadata.type == "expression" || metadata.type == "camera") {
|
||||
if (ParameterMetadata::IsExpression("number", metadata.type)) {
|
||||
CallbacksForGeneratingExpressionCode callbacks(argOutput, *this, context);
|
||||
|
||||
gd::ExpressionParser parser(parameter);
|
||||
@@ -598,9 +598,7 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
|
||||
}
|
||||
|
||||
if (argOutput.empty()) argOutput = "0";
|
||||
} else if (metadata.type == "string" || metadata.type == "layer" ||
|
||||
metadata.type == "color" || metadata.type == "file" ||
|
||||
metadata.type == "joyaxis") {
|
||||
} else if (ParameterMetadata::IsExpression("string", metadata.type)) {
|
||||
CallbacksForGeneratingExpressionCode callbacks(argOutput, *this, context);
|
||||
|
||||
gd::ExpressionParser parser(parameter);
|
||||
@@ -828,6 +826,7 @@ gd::String EventsCodeGenerator::ConvertToStringExplicit(
|
||||
std::vector<gd::String> EventsCodeGenerator::ExpandObjectsName(
|
||||
const gd::String& objectName,
|
||||
const EventsCodeGenerationContext& context) const {
|
||||
// Note: this logic is duplicated in EventsContextAnalyzer::ExpandObjectsName
|
||||
std::vector<gd::String> realObjects;
|
||||
if (project.GetObjectGroups().Has(objectName))
|
||||
realObjects =
|
||||
|
@@ -374,6 +374,17 @@ class GD_CORE_API EventsCodeGenerator {
|
||||
virtual gd::String GetObjectListName(
|
||||
const gd::String& name, const gd::EventsCodeGenerationContext& context);
|
||||
|
||||
/**
|
||||
* \brief Generate the code to notify the profiler of the beginning of a
|
||||
* section.
|
||||
*/
|
||||
virtual gd::String GenerateProfilerSectionBegin(const gd::String& section) { return ""; };
|
||||
|
||||
/**
|
||||
* \brief Generate the code to notify the profiler of the end of a section.
|
||||
*/
|
||||
virtual gd::String GenerateProfilerSectionEnd(const gd::String& section) { return ""; };
|
||||
|
||||
protected:
|
||||
/**
|
||||
* \brief Generate the code for a single parameter.
|
||||
|
@@ -867,7 +867,7 @@ bool ExpressionParser::PrepareParameter(
|
||||
gd::Expression& parameter,
|
||||
const gd::ParameterMetadata& parametersInfo,
|
||||
const size_t positionInExpression) {
|
||||
if (parametersInfo.type == "expression" || parametersInfo.type == "camera") {
|
||||
if (ParameterMetadata::IsExpression("number", parametersInfo.type)) {
|
||||
if (parametersInfo.optional && parameter.GetPlainString().empty())
|
||||
parameter = parametersInfo.defaultValue.empty()
|
||||
? gd::Expression("0")
|
||||
@@ -879,10 +879,7 @@ bool ExpressionParser::PrepareParameter(
|
||||
|
||||
return false;
|
||||
}
|
||||
} else if (parametersInfo.type == "string" ||
|
||||
parametersInfo.type == "layer" || parametersInfo.type == "color" ||
|
||||
parametersInfo.type == "file" ||
|
||||
parametersInfo.type == "joyaxis") {
|
||||
} else if (ParameterMetadata::IsExpression("string", parametersInfo.type)) {
|
||||
if (parametersInfo.optional && parameter.GetPlainString().empty())
|
||||
parameter = parametersInfo.defaultValue.empty()
|
||||
? gd::Expression("\"\"")
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinAdvanced",
|
||||
_("Advanced control features"),
|
||||
_("Built-in extension providing advanced control features."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinAdvanced",
|
||||
_("Advanced control features"),
|
||||
_("Built-in extension providing advanced control features."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -11,11 +11,13 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation("BuiltinAudio",
|
||||
_("Audio"),
|
||||
_("Builtin audio extension"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("BuiltinAudio",
|
||||
_("Audio"),
|
||||
_("Builtin audio extension"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/audio");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -12,11 +12,13 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation("BuiltinObject",
|
||||
_("Base object"),
|
||||
_("Base object"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("BuiltinObject",
|
||||
_("Base object"),
|
||||
_("Base object"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/base_object");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<gd::Object>(
|
||||
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
||||
@@ -34,7 +36,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("relationalOperator", _("Sign of the test"))
|
||||
.AddParameter("expression", _("X position"))
|
||||
.MarkAsSimple()
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.SetManipulatedType("number");
|
||||
|
||||
obj.AddAction("MettreX",
|
||||
@@ -49,7 +50,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("operator", _("Modification's sign"))
|
||||
.AddParameter("expression", _("Value"))
|
||||
.MarkAsSimple()
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.SetManipulatedType("number");
|
||||
|
||||
obj.AddCondition("PosY",
|
||||
@@ -64,7 +64,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("relationalOperator", _("Sign of the test"))
|
||||
.AddParameter("expression", _("Y position"))
|
||||
.MarkAsSimple()
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.SetManipulatedType("number");
|
||||
|
||||
obj.AddAction("MettreY",
|
||||
@@ -79,7 +78,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("operator", _("Modification's sign"))
|
||||
.AddParameter("expression", _("Value"))
|
||||
.MarkAsSimple()
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.SetManipulatedType("number");
|
||||
|
||||
obj.AddAction(
|
||||
@@ -96,12 +94,12 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("expression", _("X position"))
|
||||
.AddParameter("operator", _("Modification's sign"))
|
||||
.AddParameter("expression", _("Y position"))
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction("MettreAutourPos",
|
||||
_("Put an object around a position"),
|
||||
_("Position an object around a position, with specified angle "
|
||||
_("Position the center of the given object around a position, "
|
||||
"using the specified angle "
|
||||
"and distance."),
|
||||
_("Put _PARAM0_ around _PARAM1_;_PARAM2_, with an angle of "
|
||||
"_PARAM4_ degrees and _PARAM3_ pixels distance."),
|
||||
@@ -114,7 +112,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("expression", _("Y position"))
|
||||
.AddParameter("expression", _("Distance"))
|
||||
.AddParameter("expression", _("Angle, in degrees"))
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("SetAngle",
|
||||
@@ -128,7 +125,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("operator", _("Modification's sign"))
|
||||
.AddParameter("expression", _("Value"))
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.SetManipulatedType("number");
|
||||
|
||||
obj.AddAction("Rotate",
|
||||
@@ -143,7 +139,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("expression", _("Angular speed (in degrees per second)"))
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction(
|
||||
@@ -160,7 +155,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter(
|
||||
"expression",
|
||||
_("Angular speed (in degrees per second) (0 for immediate rotation)"))
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
obj.AddAction(
|
||||
@@ -180,7 +174,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"expression",
|
||||
_("Angular speed (in degrees per second) (0 for immediate rotation)"))
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("AddForceXY",
|
||||
@@ -196,8 +189,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("expression", _("Speed on X axis (in pixels per second)"))
|
||||
.AddParameter("expression", _("Speed on Y axis (in pixels per second)"))
|
||||
.AddParameter("expression", _("Damping (Default: 0)"))
|
||||
.SetHelpPage("gdevelop/documentation/manual/base");
|
||||
.AddParameter("expression", _("Damping (Default: 0)"));
|
||||
|
||||
obj.AddAction("AddForceAL",
|
||||
_("Add a force (angle)"),
|
||||
@@ -214,7 +206,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("expression", _("Angle"))
|
||||
.AddParameter("expression", _("Speed (in pixels per second)"))
|
||||
.AddParameter("expression", _("Damping (Default: 0)"))
|
||||
.SetHelpPage("gdevelop/documentation/manual/base")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
@@ -232,7 +223,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("expression", _("Y position"))
|
||||
.AddParameter("expression", _("Speed (in pixels per second)"))
|
||||
.AddParameter("expression", _("Damping (Default: 0)"))
|
||||
.SetHelpPage("gdevelop/documentation/manual/base#displacement")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
@@ -265,7 +255,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/actions/arreter.png")
|
||||
|
||||
.AddParameter("object", _("Object"))
|
||||
.SetHelpPage("gdevelop/documentation/manual/base#displacement")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("Delete",
|
||||
@@ -599,7 +588,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
obj.AddAction("MettreAutour",
|
||||
_("Put an object around another"),
|
||||
_("Position an object around another, with the specified angle "
|
||||
"and distance."),
|
||||
"and distance. The center of the objects are used for "
|
||||
"positioning them."),
|
||||
_("Put _PARAM0_ around _PARAM1_, with an angle of _PARAM3_ "
|
||||
"degrees and _PARAM2_ pixels distance."),
|
||||
_("Position"),
|
||||
@@ -1026,6 +1016,34 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"RaycastToPosition",
|
||||
_("Raycast to position"),
|
||||
_("Sends a ray from the given source position to the final point, "
|
||||
"intersecting the closest object.\nThe instersected "
|
||||
"object will become the only one taken into account.\nIf "
|
||||
"the condition is inverted, the object to be intersected "
|
||||
"will be the farthest one within the ray radius."),
|
||||
_("Raycast _PARAM0_ from _PARAM1_;_PARAM2_, and save the "
|
||||
"result in _PARAM5_, _PARAM6_"),
|
||||
_("Collision"),
|
||||
"res/conditions/raycast24.png",
|
||||
"res/conditions/raycast.png")
|
||||
.AddParameter("objectList", _("Objects to test against the ray"))
|
||||
.AddParameter("expression", _("Ray source X position"))
|
||||
.AddParameter("expression", _("Ray source Y position"))
|
||||
.AddParameter("expression", _("Ray target X position"))
|
||||
.AddParameter("expression", _("Ray target Y position"))
|
||||
.AddParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the X position of the intersection"))
|
||||
.AddParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the Y position of the intersection"))
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
"Count",
|
||||
|
@@ -11,11 +11,13 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation("BuiltinCamera",
|
||||
_("Cameras and layers features"),
|
||||
_("Built-in camera extension"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("BuiltinCamera",
|
||||
_("Cameras and layers features"),
|
||||
_("Built-in camera extension"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -12,12 +12,14 @@ namespace gd {
|
||||
void GD_CORE_API
|
||||
BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinCommonConversions",
|
||||
_("Standard Conversions"),
|
||||
_("Built-in extension providing standard conversions expressions."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinCommonConversions",
|
||||
_("Standard Conversions"),
|
||||
_("Built-in extension providing standard conversions expressions."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
|
||||
|
@@ -22,12 +22,14 @@ namespace gd {
|
||||
void GD_CORE_API
|
||||
BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinCommonInstructions",
|
||||
_("Standard events"),
|
||||
_("Built-in extension providing standard events."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinCommonInstructions",
|
||||
_("Standard events"),
|
||||
_("Built-in extension providing standard events."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -12,13 +12,15 @@ namespace gd {
|
||||
void GD_CORE_API
|
||||
BuiltinExtensionsImplementer::ImplementsExternalLayoutsExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinExternalLayouts",
|
||||
_("External layouts"),
|
||||
_("Built-in extension providing actions and conditions related to "
|
||||
"external layouts"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinExternalLayouts",
|
||||
_("External layouts"),
|
||||
_("Built-in extension providing actions and conditions related to "
|
||||
"external layouts"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation("BuiltinFile",
|
||||
_("Storage and files"),
|
||||
_("Built-in extension providing functions "
|
||||
"to store data and manipulate files."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("BuiltinFile",
|
||||
_("Storage and files"),
|
||||
_("Built-in extension providing functions "
|
||||
"to store data and manipulate files."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/storage");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsJoystickExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinJoystick",
|
||||
_("Joysticks features"),
|
||||
_("Built-in extension that enables the use of joysticks"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinJoystick",
|
||||
_("Joysticks features"),
|
||||
_("Built-in extension that enables the use of joysticks"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinKeyboard",
|
||||
_("Keyboard features"),
|
||||
_("Built-in extension that enables the use of a keyboard"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinKeyboard",
|
||||
_("Keyboard features"),
|
||||
_("Built-in extension that enables the use of a keyboard"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinMouse",
|
||||
_("Mouse features"),
|
||||
_("Built-in extension that enables the use of a mouse"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinMouse",
|
||||
_("Mouse features"),
|
||||
_("Built-in extension that enables the use of a mouse"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/events/mouse-touch");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinNetwork",
|
||||
_("Basic internet features"),
|
||||
_("Built-in extension providing network features."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinNetwork",
|
||||
_("Basic internet features"),
|
||||
_("Built-in extension providing network features."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/network");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -11,23 +11,61 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinScene",
|
||||
_("Scene management features"),
|
||||
_("This Built-in extension allows you to manipulate scenes"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinScene",
|
||||
_("Scene management features"),
|
||||
_("Built-in extension allowing to manipulate scenes and providing common features"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
|
||||
extension
|
||||
.AddExpression("Random",
|
||||
_("Random value"),
|
||||
_("Random value"),
|
||||
_("Random integer"),
|
||||
_("Random integer"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomInRange",
|
||||
_("Random integer in range"),
|
||||
_("Random integer in range"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomFloat",
|
||||
_("Random float"),
|
||||
_("Random float"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomFloatInRange",
|
||||
_("Random float in range"),
|
||||
_("Random float in range"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomWithStep",
|
||||
_("Random value in steps"),
|
||||
_("Random value in steps"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"))
|
||||
.AddParameter("expression", _("Step"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("CurrentSceneName",
|
||||
_("Current scene name"),
|
||||
|
@@ -14,13 +14,13 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"Sprite",
|
||||
_("Sprite"),
|
||||
_("Extension for adding animated objects in the scene, which can contain "
|
||||
"animations with directions within each."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("Sprite",
|
||||
_("Sprite"),
|
||||
_("Sprite are animated object which can be used for most elements of a game."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/sprite");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<SpriteObject>(
|
||||
"Sprite",
|
||||
|
@@ -12,13 +12,15 @@ namespace gd {
|
||||
void GD_CORE_API
|
||||
BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinStringInstructions",
|
||||
_("Text manipulation"),
|
||||
_("Built-in extension providing expressions for manipulating text "
|
||||
"objects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinStringInstructions",
|
||||
_("Text manipulation"),
|
||||
_("Built-in extension providing expressions for manipulating text "
|
||||
"objects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension.AddStrExpression("NewLine",
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinTime",
|
||||
_("Time"),
|
||||
_("Built-in extension providing actions and conditions related to time."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("BuiltinTime",
|
||||
_("Time"),
|
||||
_("Built-in extension providing actions and "
|
||||
"conditions related to time."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/timers");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinVariables",
|
||||
_("Variable features"),
|
||||
_("This Built-in extension allows the manipulation of variables"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinVariables",
|
||||
_("Variable features"),
|
||||
_("Built-in extension allowing to manipulate variables"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/variables");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -11,12 +11,14 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation("BuiltinWindow",
|
||||
_("Window features"),
|
||||
_("This Built-in extension enables the "
|
||||
"manipulation of the game's window"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("BuiltinWindow",
|
||||
_("Window features"),
|
||||
_("Built-in extension allowing to manipulate "
|
||||
"the game window and canvas"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -75,7 +75,8 @@ gd::InstructionMetadata& BehaviorMetadata::AddCondition(
|
||||
sentence,
|
||||
group,
|
||||
icon,
|
||||
smallicon);
|
||||
smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return conditionsInfos[nameWithNamespace];
|
||||
#endif
|
||||
}
|
||||
@@ -98,7 +99,8 @@ gd::InstructionMetadata& BehaviorMetadata::AddAction(
|
||||
sentence,
|
||||
group,
|
||||
icon,
|
||||
smallicon);
|
||||
smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return actionsInfos[nameWithNamespace];
|
||||
#endif
|
||||
}
|
||||
|
@@ -14,16 +14,10 @@
|
||||
#endif
|
||||
namespace gd {
|
||||
class Behavior;
|
||||
}
|
||||
namespace gd {
|
||||
class BehaviorsSharedData;
|
||||
}
|
||||
namespace gd {
|
||||
class InstructionMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class ExpressionMetadata;
|
||||
}
|
||||
} // namespace gd
|
||||
class wxBitmap;
|
||||
|
||||
namespace gd {
|
||||
@@ -110,6 +104,22 @@ class GD_CORE_API BehaviorMetadata {
|
||||
*/
|
||||
BehaviorMetadata& AddIncludeFile(const gd::String& includeFile);
|
||||
|
||||
/**
|
||||
* Get the help path of the behavior, relative to the documentation root.
|
||||
*/
|
||||
const gd::String &GetHelpPath() const { return helpPath; }
|
||||
|
||||
/**
|
||||
* Set the help path of the behavior, relative to the documentation root.
|
||||
*
|
||||
* The behavior instructions will have this help path set by
|
||||
* default, unless you call SetHelpPath on them.
|
||||
*/
|
||||
BehaviorMetadata &SetHelpPath(const gd::String &path) {
|
||||
helpPath = path;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
const gd::String& GetFullName() const { return fullname; }
|
||||
const gd::String& GetDefaultName() const { return defaultName; }
|
||||
@@ -136,6 +146,7 @@ class GD_CORE_API BehaviorMetadata {
|
||||
#endif
|
||||
private:
|
||||
gd::String extensionNamespace;
|
||||
gd::String helpPath;
|
||||
#if defined(GD_IDE_ONLY)
|
||||
gd::String fullname;
|
||||
gd::String defaultName;
|
||||
|
@@ -181,6 +181,14 @@ class GD_CORE_API ExpressionMetadata {
|
||||
return codeExtraInformation.SetFunctionName(functionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return the structure containing the information about code
|
||||
* generation for the expression.
|
||||
*/
|
||||
ExpressionCodeGenerationInformation& GetCodeExtraInformation() {
|
||||
return codeExtraInformation;
|
||||
};
|
||||
|
||||
ExpressionCodeGenerationInformation codeExtraInformation;
|
||||
|
||||
/** Don't use this constructor. Only here to fullfil std::map requirements
|
||||
|
@@ -28,7 +28,7 @@ InstructionMetadata::InstructionMetadata(const gd::String& extensionNamespace_,
|
||||
const gd::String& smallIcon_)
|
||||
: fullname(fullname_),
|
||||
description(description_),
|
||||
helpPage(),
|
||||
helpPath(""),
|
||||
sentence(sentence_),
|
||||
group(group_),
|
||||
iconFilename(icon_),
|
||||
|
@@ -19,16 +19,10 @@
|
||||
class wxBitmap;
|
||||
namespace gd {
|
||||
class Project;
|
||||
}
|
||||
namespace gd {
|
||||
class Layout;
|
||||
}
|
||||
namespace gd {
|
||||
class EventsCodeGenerator;
|
||||
}
|
||||
namespace gd {
|
||||
class EventsCodeGenerationContext;
|
||||
}
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -91,9 +85,26 @@ class GD_CORE_API ParameterMetadata {
|
||||
* \brief Return true if the type of the parameter is "object", "objectPtr" or
|
||||
* "objectList". \see gd::ParameterMetadata::GetType
|
||||
*/
|
||||
static bool IsObject(const gd::String &type) {
|
||||
return type == "object" || type == "objectPtr" || type == "objectList" ||
|
||||
type == "objectListWithoutPicking";
|
||||
static bool IsObject(const gd::String ¶meterType) {
|
||||
return parameterType == "object" || parameterType == "objectPtr" ||
|
||||
parameterType == "objectList" ||
|
||||
parameterType == "objectListWithoutPicking";
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return true if the type of the parameter is "object", "objectPtr" or
|
||||
* "objectList". \see gd::ParameterMetadata::GetType
|
||||
*/
|
||||
static bool IsExpression(const gd::String &type,
|
||||
const gd::String ¶meterType) {
|
||||
if (type == "number") {
|
||||
return parameterType == "expression" || parameterType == "camera";
|
||||
} else if (type == "string") {
|
||||
return parameterType == "string" || parameterType == "layer" ||
|
||||
parameterType == "color" || parameterType == "file" ||
|
||||
parameterType == "joyaxis";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -132,15 +143,15 @@ class GD_CORE_API InstructionMetadata {
|
||||
bool CanHaveSubInstructions() const { return canHaveSubInstructions; }
|
||||
|
||||
/**
|
||||
* Get the help page of the instruction.
|
||||
* Get the help path of the instruction, relative to the documentation root.
|
||||
*/
|
||||
const gd::String &GetHelpPage() const { return helpPage; }
|
||||
const gd::String &GetHelpPath() const { return helpPath; }
|
||||
|
||||
/**
|
||||
* Set the help page of the instruction.
|
||||
* Set the help path of the instruction, relative to the documentation root.
|
||||
*/
|
||||
InstructionMetadata &SetHelpPage(const gd::String &page) {
|
||||
helpPage = page;
|
||||
InstructionMetadata &SetHelpPath(const gd::String &path) {
|
||||
helpPath = path;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -374,6 +385,12 @@ class GD_CORE_API InstructionMetadata {
|
||||
ExtraInformation codeExtraInformation; ///< Information about how generate
|
||||
///< code for the instruction
|
||||
|
||||
/**
|
||||
* \brief Return the structure containing the information about code
|
||||
* generation for the instruction.
|
||||
*/
|
||||
ExtraInformation &GetCodeExtraInformation() { return codeExtraInformation; }
|
||||
|
||||
/**
|
||||
* \brief Declare if the instruction being declared is somewhat manipulating
|
||||
* in a standard way. \param type "number" or "string" \note Shortcut for
|
||||
@@ -404,7 +421,7 @@ class GD_CORE_API InstructionMetadata {
|
||||
private:
|
||||
gd::String fullname;
|
||||
gd::String description;
|
||||
gd::String helpPage;
|
||||
gd::String helpPath;
|
||||
gd::String sentence;
|
||||
gd::String group;
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
|
@@ -9,17 +9,9 @@
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class BehaviorMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class ObjectMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class ExpressionMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class ExpressionMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class Platform;
|
||||
}
|
||||
|
||||
@@ -47,14 +39,14 @@ class GD_CORE_API MetadataProvider {
|
||||
|
||||
/**
|
||||
* Get the metadata of an action.
|
||||
* Must work for object, behaviors and static actions.
|
||||
* Works for object, behaviors and static actions.
|
||||
*/
|
||||
static const gd::InstructionMetadata& GetActionMetadata(
|
||||
const gd::Platform& platform, gd::String actionType);
|
||||
|
||||
/**
|
||||
* Get the metadata of a condition.
|
||||
* Must Work for object, behaviors and static conditions.
|
||||
* Works for object, behaviors and static conditions.
|
||||
*/
|
||||
static const gd::InstructionMetadata& GetConditionMetadata(
|
||||
const gd::Platform& platform, gd::String conditionType);
|
||||
@@ -81,109 +73,109 @@ class GD_CORE_API MetadataProvider {
|
||||
const gd::Platform& platform, gd::String autoType, gd::String exprType);
|
||||
|
||||
/**
|
||||
* Get information about a gd::String expression from its type
|
||||
* Get information about a string expression from its type
|
||||
* Works for static expressions.
|
||||
*/
|
||||
static const gd::ExpressionMetadata& GetStrExpressionMetadata(
|
||||
const gd::Platform& platform, gd::String exprType);
|
||||
|
||||
/**
|
||||
* Get information about a gd::String expression from its type
|
||||
* Get information about a string expression from its type
|
||||
* Works for object expressions.
|
||||
*/
|
||||
static const gd::ExpressionMetadata& GetObjectStrExpressionMetadata(
|
||||
const gd::Platform& platform, gd::String objectType, gd::String exprType);
|
||||
|
||||
/**
|
||||
* Get information about a gd::String expression from its type
|
||||
* Get information about a string expression from its type
|
||||
* Works for behavior expressions.
|
||||
*/
|
||||
static const gd::ExpressionMetadata& GetBehaviorStrExpressionMetadata(
|
||||
const gd::Platform& platform, gd::String autoType, gd::String exprType);
|
||||
|
||||
/**
|
||||
* Verifying if a ( static ) condition exists
|
||||
* @return true if the ( static ) condition exists
|
||||
* \brief Check if a (static) condition exists
|
||||
* @return true if the (static) condition exists
|
||||
*/
|
||||
static bool HasCondition(const gd::Platform& platform, gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( static ) action exists
|
||||
* @return true if the ( static ) action exists
|
||||
* \brief Check if a (static) action exists
|
||||
* @return true if the (static) action exists
|
||||
*/
|
||||
static bool HasAction(const gd::Platform& platform, gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( object ) action exists
|
||||
* @return true if the ( object ) action exists
|
||||
* \brief Check if a (object) action exists
|
||||
* @return true if the (object) action exists
|
||||
*/
|
||||
static bool HasObjectAction(const gd::Platform& platform,
|
||||
gd::String objectType,
|
||||
gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( object ) condition exists
|
||||
* @return true if the ( object ) condition exists
|
||||
* \brief Check if a (object) condition exists
|
||||
* @return true if the (object) condition exists
|
||||
*/
|
||||
static bool HasObjectCondition(const gd::Platform& platform,
|
||||
gd::String objectType,
|
||||
gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( Behavior ) action exists
|
||||
* @return true if the ( Behavior ) action exists
|
||||
* \brief Check if a (behavior) action exists
|
||||
* @return true if the (behavior) action exists
|
||||
*/
|
||||
static bool HasBehaviorAction(const gd::Platform& platform,
|
||||
gd::String behaviorType,
|
||||
gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( Behavior ) condition exists
|
||||
* @return true if the ( Behavior ) condition exists
|
||||
* \brief Check if a (behavior) condition exists
|
||||
* @return true if the (behavior) condition exists
|
||||
*/
|
||||
static bool HasBehaviorCondition(const gd::Platform& platform,
|
||||
gd::String behaviorType,
|
||||
gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( static ) expression exists
|
||||
* @return true if the ( static ) expression exists
|
||||
* \brief Check if a (static) expression exists
|
||||
* @return true if the (static) expression exists
|
||||
*/
|
||||
static bool HasExpression(const gd::Platform& platform, gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( object ) expression exists
|
||||
* @return true if the ( object ) expression exists
|
||||
* \brief Check if a (object) expression exists
|
||||
* @return true if the (object) expression exists
|
||||
*/
|
||||
static bool HasObjectExpression(const gd::Platform& platform,
|
||||
gd::String objectType,
|
||||
gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( behavior ) expression exists
|
||||
* @return true if the ( behavior ) expression exists
|
||||
* \brief Check if a (behavior) expression exists
|
||||
* @return true if the (behavior) expression exists
|
||||
*/
|
||||
static bool HasBehaviorExpression(const gd::Platform& platform,
|
||||
gd::String behaviorType,
|
||||
gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( static ) gd::String expression exists
|
||||
* @return true if the ( static ) gd::String expression exists
|
||||
* \brief Check if a (static) string expression exists
|
||||
* @return true if the (static) string expression exists
|
||||
*/
|
||||
static bool HasStrExpression(const gd::Platform& platform, gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( object ) gd::String expression exists
|
||||
* @return true if the ( object ) gd::String expression exists
|
||||
* \brief Check if a (object) string expression exists
|
||||
* @return true if the (object) string expression exists
|
||||
*/
|
||||
static bool HasObjectStrExpression(const gd::Platform& platform,
|
||||
gd::String objectType,
|
||||
gd::String name);
|
||||
|
||||
/**
|
||||
* Verifying if a ( object ) gd::String expression exists
|
||||
* @return true if the ( object ) gd::String expression exists
|
||||
* \brief Check if a (behavior) string expression exists
|
||||
* @return true if the (behavior) string expression exists
|
||||
*/
|
||||
static bool HasBehaviorStrExpression(const gd::Platform& platform,
|
||||
gd::String behaviorType,
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <iostream>
|
||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/file.h>
|
||||
@@ -19,14 +20,58 @@ namespace gd {
|
||||
ObjectMetadata::ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& informations_,
|
||||
const gd::String& description_,
|
||||
const gd::String& icon24x24,
|
||||
std::shared_ptr<gd::Object> blueprintObject_)
|
||||
: extensionNamespace(extensionNamespace_),
|
||||
blueprintObject(blueprintObject_) {
|
||||
name = name_;
|
||||
#if defined(GD_IDE_ONLY)
|
||||
SetFullName(gd::String(fullname_));
|
||||
SetDescription(gd::String(description_));
|
||||
iconFilename = icon24x24;
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
if (!iconFilename.empty()) {
|
||||
if (gd::SkinHelper::IconExists(icon24x24, 24))
|
||||
SetBitmapIcon(gd::SkinHelper::GetIcon(icon24x24, 24));
|
||||
else if (wxFile::Exists(icon24x24))
|
||||
SetBitmapIcon(wxBitmap(icon24x24, wxBITMAP_TYPE_ANY));
|
||||
else {
|
||||
std::cout << "Warning: The icon file for object \"" << name_
|
||||
<< " was not found in the current skin icons"
|
||||
<< " and the specified name is not an existing filename.";
|
||||
SetBitmapIcon(wxBitmap(24, 24));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
createFunPtr =
|
||||
[blueprintObject_](gd::String name) -> std::unique_ptr<gd::Object> {
|
||||
if (blueprintObject_ == std::shared_ptr<gd::Object>()) {
|
||||
std::cout
|
||||
<< "Error: Unable to create object. Have you declared an extension "
|
||||
"(or ObjectMetadata) without specifying an object as blueprint?"
|
||||
<< std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<gd::Object> newObject = blueprintObject_->Clone();
|
||||
newObject->SetName(name);
|
||||
return newObject;
|
||||
};
|
||||
}
|
||||
|
||||
ObjectMetadata::ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& description_,
|
||||
const gd::String& icon24x24,
|
||||
CreateFunPtr createFunPtrP)
|
||||
: extensionNamespace(extensionNamespace_) {
|
||||
name = name_;
|
||||
#if defined(GD_IDE_ONLY)
|
||||
SetFullName(gd::String(fullname_));
|
||||
SetDescription(gd::String(informations_));
|
||||
SetDescription(gd::String(description_));
|
||||
iconFilename = icon24x24;
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
if (!iconFilename.empty()) {
|
||||
@@ -64,7 +109,8 @@ gd::InstructionMetadata& ObjectMetadata::AddCondition(
|
||||
sentence,
|
||||
group,
|
||||
icon,
|
||||
smallicon);
|
||||
smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return conditionsInfos[nameWithNamespace];
|
||||
#endif
|
||||
}
|
||||
@@ -87,7 +133,8 @@ gd::InstructionMetadata& ObjectMetadata::AddAction(
|
||||
sentence,
|
||||
group,
|
||||
icon,
|
||||
smallicon);
|
||||
smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return actionsInfos[nameWithNamespace];
|
||||
#endif
|
||||
}
|
||||
|
@@ -7,24 +7,21 @@
|
||||
#define OBJECTMETADATA_H
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/String.h"
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
#include <wx/bitmap.h>
|
||||
#endif
|
||||
namespace gd {
|
||||
class Object;
|
||||
}
|
||||
namespace gd {
|
||||
class InstructionMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class ExpressionMetadata;
|
||||
}
|
||||
} // namespace gd
|
||||
class wxBitmap;
|
||||
|
||||
typedef std::unique_ptr<gd::Object> (*CreateFunPtr)(gd::String name);
|
||||
typedef std::function<std::unique_ptr<gd::Object>(gd::String name)> CreateFunPtr;
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -36,10 +33,25 @@ namespace gd {
|
||||
*/
|
||||
class GD_CORE_API ObjectMetadata {
|
||||
public:
|
||||
/**
|
||||
* \brief Construct an object metadata, using a "blueprint" object that will
|
||||
* be copied when a new object is asked.
|
||||
*/
|
||||
ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& informations_,
|
||||
const gd::String& description_,
|
||||
const gd::String& icon24x24_,
|
||||
std::shared_ptr<gd::Object> blueprintObject_);
|
||||
|
||||
/**
|
||||
* \brief Construct an object metadata, with a function that will be called
|
||||
* to instanciate a new object.
|
||||
*/
|
||||
ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& description_,
|
||||
const gd::String& icon24x24_,
|
||||
CreateFunPtr createFunPtrP);
|
||||
ObjectMetadata() : createFunPtr(NULL) {}
|
||||
@@ -105,6 +117,22 @@ class GD_CORE_API ObjectMetadata {
|
||||
*/
|
||||
ObjectMetadata& SetBitmapIcon(const wxBitmap& bitmap_);
|
||||
|
||||
/**
|
||||
* Get the help path of the object, relative to the documentation root.
|
||||
*/
|
||||
const gd::String &GetHelpPath() const { return helpPath; }
|
||||
|
||||
/**
|
||||
* Set the help path of the object, relative to the documentation root.
|
||||
*
|
||||
* The object instructions will have this help path set by
|
||||
* default, unless you call SetHelpPath on them.
|
||||
*/
|
||||
ObjectMetadata &SetHelpPath(const gd::String &path) {
|
||||
helpPath = path;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const gd::String& GetName() const { return name; }
|
||||
#if defined(GD_IDE_ONLY)
|
||||
const gd::String& GetFullName() const { return fullname; }
|
||||
@@ -119,6 +147,7 @@ class GD_CORE_API ObjectMetadata {
|
||||
/**
|
||||
* \brief Set the URL pointing to the help page about this object
|
||||
* \note The path to the page must be relative to the wiki url.
|
||||
* \deprecated Use SetHelpPath instead
|
||||
*/
|
||||
ObjectMetadata& SetHelpUrl(const gd::String& url);
|
||||
|
||||
@@ -148,8 +177,9 @@ class GD_CORE_API ObjectMetadata {
|
||||
private:
|
||||
gd::String extensionNamespace;
|
||||
gd::String name;
|
||||
gd::String helpPath;
|
||||
#if defined(GD_IDE_ONLY)
|
||||
gd::String helpUrl;
|
||||
gd::String helpUrl; ///< Deprecated. Use helpPath instead.
|
||||
gd::String fullname;
|
||||
gd::String description;
|
||||
gd::String iconFilename;
|
||||
@@ -157,6 +187,10 @@ class GD_CORE_API ObjectMetadata {
|
||||
wxBitmap icon;
|
||||
#endif
|
||||
#endif
|
||||
std::shared_ptr<gd::Object>
|
||||
blueprintObject; ///< The "blueprint" object to be copied when a new
|
||||
///< object is asked. Can be null in case a creation
|
||||
///< function is passed.
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -20,20 +20,21 @@ namespace gd {
|
||||
gd::ChangesNotifier Platform::defaultEmptyChangesNotifier;
|
||||
#endif
|
||||
|
||||
Platform::Platform() {
|
||||
}
|
||||
Platform::Platform() {}
|
||||
|
||||
Platform::~Platform() {
|
||||
}
|
||||
Platform::~Platform() {}
|
||||
|
||||
bool Platform::AddExtension(std::shared_ptr<gd::PlatformExtension> extension) {
|
||||
std::cout << extension->GetName();
|
||||
bool loaded = false;
|
||||
for (std::size_t i = 0; i < extensionsLoaded.size(); ++i) {
|
||||
if (extensionsLoaded[i]->GetName() == extension->GetName()) {
|
||||
std::cout << "(Already loaded!)" << std::endl;
|
||||
return false;
|
||||
std::cout << "(replacing existing extension)" << std::endl;
|
||||
extensionsLoaded[i] = extension;
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
if (!loaded) extensionsLoaded.push_back(extension);
|
||||
|
||||
// Load all creation/destruction functions for objects provided by the
|
||||
// extension
|
||||
@@ -43,7 +44,6 @@ bool Platform::AddExtension(std::shared_ptr<gd::PlatformExtension> extension) {
|
||||
extension->GetObjectCreationFunctionPtr(objectsTypes[i]);
|
||||
}
|
||||
|
||||
extensionsLoaded.push_back(extension);
|
||||
std::cout << ", ";
|
||||
return true;
|
||||
}
|
||||
|
@@ -25,9 +25,9 @@ class BehaviorsSharedData;
|
||||
class PlatformExtension;
|
||||
class LayoutEditorCanvas;
|
||||
class ProjectExporter;
|
||||
}
|
||||
} // namespace gd
|
||||
|
||||
typedef std::unique_ptr<gd::Object> (*CreateFunPtr)(gd::String name);
|
||||
typedef std::function<std::unique_ptr<gd::Object>(gd::String name)> CreateFunPtr;
|
||||
|
||||
#undef CreateEvent
|
||||
|
||||
|
@@ -50,7 +50,8 @@ gd::InstructionMetadata& PlatformExtension::AddCondition(
|
||||
sentence,
|
||||
group,
|
||||
icon,
|
||||
smallicon);
|
||||
smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return conditionsInfos[nameWithNamespace];
|
||||
#endif
|
||||
}
|
||||
@@ -73,7 +74,8 @@ gd::InstructionMetadata& PlatformExtension::AddAction(
|
||||
sentence,
|
||||
group,
|
||||
icon,
|
||||
smallicon);
|
||||
smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return actionsInfos[nameWithNamespace];
|
||||
#endif
|
||||
}
|
||||
@@ -116,6 +118,25 @@ gd::ExpressionMetadata& PlatformExtension::AddStrExpression(
|
||||
#endif
|
||||
}
|
||||
|
||||
gd::ObjectMetadata& PlatformExtension::AddObject(
|
||||
const gd::String& name,
|
||||
const gd::String& fullname,
|
||||
const gd::String& description,
|
||||
const gd::String& icon24x24,
|
||||
std::shared_ptr<gd::Object> instance) {
|
||||
gd::String nameWithNamespace =
|
||||
GetNameSpace().empty() ? name : GetNameSpace() + name;
|
||||
objectsInfos[nameWithNamespace] = ObjectMetadata(GetNameSpace(),
|
||||
nameWithNamespace,
|
||||
fullname,
|
||||
description,
|
||||
icon24x24,
|
||||
instance)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
|
||||
return objectsInfos[nameWithNamespace];
|
||||
}
|
||||
|
||||
gd::BehaviorMetadata& PlatformExtension::AddBehavior(
|
||||
const gd::String& name,
|
||||
const gd::String& fullname,
|
||||
@@ -137,7 +158,8 @@ gd::BehaviorMetadata& PlatformExtension::AddBehavior(
|
||||
icon24x24,
|
||||
className,
|
||||
instance,
|
||||
sharedDatasInstance);
|
||||
sharedDatasInstance)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return behaviorsInfo[nameWithNamespace];
|
||||
}
|
||||
|
||||
@@ -161,17 +183,19 @@ gd::EventMetadata& PlatformExtension::AddEvent(
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlatformExtension::SetExtensionInformation(const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& description_,
|
||||
const gd::String& author_,
|
||||
const gd::String& license_) {
|
||||
PlatformExtension& PlatformExtension::SetExtensionInformation(
|
||||
const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& description_,
|
||||
const gd::String& author_,
|
||||
const gd::String& license_) {
|
||||
name = name_;
|
||||
fullname = fullname_;
|
||||
informations = description_;
|
||||
author = author_;
|
||||
license = license_;
|
||||
SetNameSpace(name_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::vector<gd::String> PlatformExtension::GetExtensionObjectsTypes() const {
|
||||
@@ -399,131 +423,6 @@ bool PlatformExtension::IsBuiltin() const {
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void PlatformExtension::CloneExtension(
|
||||
const gd::String& platformName,
|
||||
const gd::String& extensionName,
|
||||
bool stripFunctionsNameAndCodeGeneration) {
|
||||
gd::Platform* platform =
|
||||
gd::PlatformManager::Get()->GetPlatform(platformName);
|
||||
if (!platform) {
|
||||
std::cout << "Unable to clone extension \"" << extensionName << "\" from "
|
||||
<< platformName << ": This platform doesn't exist.";
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<gd::PlatformExtension> extension =
|
||||
platform->GetExtension(extensionName);
|
||||
if (!extension) {
|
||||
std::cout << "Unable to clone extension \"" << extensionName << "\" from "
|
||||
<< platformName << ": This extension doesn't exist.";
|
||||
return;
|
||||
}
|
||||
|
||||
*this = *extension;
|
||||
|
||||
if (stripFunctionsNameAndCodeGeneration) {
|
||||
for (std::map<gd::String, gd::InstructionMetadata>::iterator it =
|
||||
GetAllActions().begin();
|
||||
it != GetAllActions().end();
|
||||
++it)
|
||||
it->second.SetFunctionName("").SetGetter("").RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::InstructionMetadata>::iterator it =
|
||||
GetAllConditions().begin();
|
||||
it != GetAllConditions().end();
|
||||
++it)
|
||||
it->second.SetFunctionName("").SetGetter("").RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::ExpressionMetadata>::iterator it =
|
||||
GetAllExpressions().begin();
|
||||
it != GetAllExpressions().end();
|
||||
++it)
|
||||
it->second.SetFunctionName("").RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::ExpressionMetadata>::iterator it =
|
||||
GetAllStrExpressions().begin();
|
||||
it != GetAllStrExpressions().end();
|
||||
++it)
|
||||
it->second.SetFunctionName("").RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::ObjectMetadata>::iterator objIt =
|
||||
objectsInfos.begin();
|
||||
objIt != objectsInfos.end();
|
||||
++objIt) {
|
||||
gd::ObjectMetadata& obj = objIt->second;
|
||||
|
||||
for (std::map<gd::String, gd::InstructionMetadata>::iterator it =
|
||||
obj.actionsInfos.begin();
|
||||
it != obj.actionsInfos.end();
|
||||
++it)
|
||||
it->second.SetFunctionName("")
|
||||
.SetGetter("")
|
||||
.RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::InstructionMetadata>::iterator it =
|
||||
obj.conditionsInfos.begin();
|
||||
it != obj.conditionsInfos.end();
|
||||
++it)
|
||||
it->second.SetFunctionName("")
|
||||
.SetGetter("")
|
||||
.RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::ExpressionMetadata>::iterator it =
|
||||
obj.expressionsInfos.begin();
|
||||
it != obj.expressionsInfos.end();
|
||||
++it)
|
||||
it->second.SetFunctionName("").RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::ExpressionMetadata>::iterator it =
|
||||
obj.strExpressionsInfos.begin();
|
||||
it != obj.strExpressionsInfos.end();
|
||||
++it)
|
||||
it->second.SetFunctionName("").RemoveCustomCodeGenerator();
|
||||
}
|
||||
|
||||
for (std::map<gd::String, gd::BehaviorMetadata>::iterator objIt =
|
||||
behaviorsInfo.begin();
|
||||
objIt != behaviorsInfo.end();
|
||||
++objIt) {
|
||||
gd::BehaviorMetadata& obj = objIt->second;
|
||||
|
||||
for (std::map<gd::String, gd::InstructionMetadata>::iterator it =
|
||||
obj.actionsInfos.begin();
|
||||
it != obj.actionsInfos.end();
|
||||
++it)
|
||||
it->second.SetFunctionName("")
|
||||
.SetGetter("")
|
||||
.RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::InstructionMetadata>::iterator it =
|
||||
obj.conditionsInfos.begin();
|
||||
it != obj.conditionsInfos.end();
|
||||
++it)
|
||||
it->second.SetFunctionName("")
|
||||
.SetGetter("")
|
||||
.RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::ExpressionMetadata>::iterator it =
|
||||
obj.expressionsInfos.begin();
|
||||
it != obj.expressionsInfos.end();
|
||||
++it)
|
||||
it->second.SetFunctionName("").RemoveCustomCodeGenerator();
|
||||
|
||||
for (std::map<gd::String, gd::ExpressionMetadata>::iterator it =
|
||||
obj.strExpressionsInfos.begin();
|
||||
it != obj.strExpressionsInfos.end();
|
||||
++it)
|
||||
it->second.SetFunctionName("").RemoveCustomCodeGenerator();
|
||||
}
|
||||
|
||||
for (std::map<gd::String, gd::EventMetadata>::iterator it =
|
||||
eventsInfos.begin();
|
||||
it != eventsInfos.end();
|
||||
++it)
|
||||
it->second.ClearCodeGenerationAndPreprocessing();
|
||||
}
|
||||
}
|
||||
|
||||
void PlatformExtension::StripUnimplementedInstructionsAndExpressions() {
|
||||
for (std::map<gd::String, gd::InstructionMetadata>::iterator it =
|
||||
GetAllActions().begin();
|
||||
|
@@ -19,42 +19,21 @@
|
||||
|
||||
namespace gd {
|
||||
class Instruction;
|
||||
}
|
||||
namespace gd {
|
||||
class InstructionMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class ExpressionMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class ObjectMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class BehaviorMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
}
|
||||
namespace gd {
|
||||
class EventMetadata;
|
||||
}
|
||||
namespace gd {
|
||||
class EventCodeGenerator;
|
||||
}
|
||||
namespace gd {
|
||||
class ArbitraryResourceWorker;
|
||||
}
|
||||
namespace gd {
|
||||
class BehaviorsSharedData;
|
||||
}
|
||||
namespace gd {
|
||||
class Behavior;
|
||||
}
|
||||
namespace gd {
|
||||
class Object;
|
||||
}
|
||||
} // namespace gd
|
||||
|
||||
typedef std::unique_ptr<gd::Object> (*CreateFunPtr)(gd::String name);
|
||||
typedef std::function<std::unique_ptr<gd::Object>(gd::String name)>
|
||||
CreateFunPtr;
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -107,11 +86,24 @@ class GD_CORE_API PlatformExtension {
|
||||
/**
|
||||
* \brief Must be called to declare the main information about the extension.
|
||||
*/
|
||||
void SetExtensionInformation(const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& description_,
|
||||
const gd::String& author_,
|
||||
const gd::String& license_);
|
||||
PlatformExtension& SetExtensionInformation(const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& description_,
|
||||
const gd::String& author_,
|
||||
const gd::String& license_);
|
||||
|
||||
/**
|
||||
* \brief Set the path to the help, relative to the wiki/documentation root.
|
||||
* For example, "/all-features/collisions" for
|
||||
* "http://wiki.compilgames.net/doku.php/gdevelop5/all-features/collisions".
|
||||
*
|
||||
* The instructions, objects and behaviors will have this help path set by
|
||||
* default, unless you call SetHelpPath on them.
|
||||
*/
|
||||
PlatformExtension& SetExtensionHelpPath(const gd::String& helpPath_) {
|
||||
helpPath = helpPath_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mark this extension as deprecated: the IDE will hide it from the
|
||||
@@ -171,7 +163,6 @@ class GD_CORE_API PlatformExtension {
|
||||
* \param icon The 24x24 icon of the object:
|
||||
res/icons_[SkinName]/[iconName]24.png will be first tried,
|
||||
* and then if it does not exists, the full entered name will be tried.
|
||||
\endcode
|
||||
*/
|
||||
template <class T>
|
||||
gd::ObjectMetadata& AddObject(const gd::String& name_,
|
||||
@@ -179,6 +170,24 @@ class GD_CORE_API PlatformExtension {
|
||||
const gd::String& description_,
|
||||
const gd::String& icon24x24_);
|
||||
|
||||
/**
|
||||
* \brief Declare a new object as being part of the extension.
|
||||
* \note This method does nothing when used for GD C++ runtime.
|
||||
* \param name The name of the object
|
||||
* \param fullname The user friendly name of the object
|
||||
* \param description The user friendly description of the object
|
||||
* \param icon The 24x24 icon of the object:
|
||||
res/icons_[SkinName]/[iconName]24.png will be first tried,
|
||||
* and then if it does not exists, the full entered name will be tried.
|
||||
* \param instance The "blueprint" object to be copied when a new object is
|
||||
asked for.
|
||||
*/
|
||||
gd::ObjectMetadata& AddObject(const gd::String& name_,
|
||||
const gd::String& fullname_,
|
||||
const gd::String& description_,
|
||||
const gd::String& icon24x24_,
|
||||
std::shared_ptr<gd::Object> instance);
|
||||
|
||||
/**
|
||||
* \brief Declare a new behavior as being part of the extension.
|
||||
* \note This method does nothing when used for GD C++ runtime.
|
||||
@@ -240,6 +249,12 @@ class GD_CORE_API PlatformExtension {
|
||||
*/
|
||||
const gd::String& GetLicense() const { return license; }
|
||||
|
||||
/**
|
||||
* \brief Return the help path of extension, relative to the
|
||||
* wiki/documentation root.
|
||||
*/
|
||||
const gd::String& GetHelpPath() const { return helpPath; }
|
||||
|
||||
/**
|
||||
* \brief Check if the extension is flagged as being deprecated.
|
||||
*/
|
||||
@@ -404,24 +419,6 @@ class GD_CORE_API PlatformExtension {
|
||||
virtual void ExposeActionsResources(Instruction& action,
|
||||
gd::ArbitraryResourceWorker& worker){};
|
||||
|
||||
/**
|
||||
* \brief Clone the extension of another platform.
|
||||
*
|
||||
* This can be used when you want a platform to conform to another.<br>
|
||||
* It is still possible to make some changes after the cloning by using getter
|
||||
* methods.<br> See also
|
||||
* gd::PlatformExtension::StripUnimplementedInstructionsAndExpressions.
|
||||
*
|
||||
* \param platformName The name of the platform in which the source extension
|
||||
* must be searched for. \param extensionName The name of the source extension
|
||||
* to be copied. \param stripFunctionsNameAndCodeGeneration If set to true,
|
||||
* all functions names and code generator of all
|
||||
* instructions/expression/events will be removed.
|
||||
*/
|
||||
void CloneExtension(const gd::String& platformName,
|
||||
const gd::String& extensionName,
|
||||
bool stripFunctionsNameAndCodeGeneration = true);
|
||||
|
||||
/**
|
||||
* \brief Delete all instructions having no functions name or custom code
|
||||
* generator.
|
||||
@@ -451,7 +448,10 @@ class GD_CORE_API PlatformExtension {
|
||||
gd::String informations; ///< Description displayed to users at edittime
|
||||
gd::String author; ///< Author displayed to users at edittime
|
||||
gd::String license; ///< License name displayed to users at edittime
|
||||
bool deprecated;
|
||||
bool deprecated; ///< true if the extension is deprecated and shouldn't be
|
||||
///< shown in IDE.
|
||||
gd::String helpPath; ///< The relative path to the help for this extension in
|
||||
///< the documentation.
|
||||
|
||||
std::map<gd::String, gd::ObjectMetadata> objectsInfos;
|
||||
std::map<gd::String, gd::BehaviorMetadata> behaviorsInfo;
|
||||
|
@@ -27,7 +27,8 @@ gd::ObjectMetadata& PlatformExtension::AddObject(const gd::String& name,
|
||||
icon24x24,
|
||||
[](gd::String name) -> std::unique_ptr<gd::Object> {
|
||||
return gd::make_unique<T>(name);
|
||||
});
|
||||
})
|
||||
.SetHelpPath(GetHelpPath());
|
||||
|
||||
return objectsInfos[nameWithNamespace];
|
||||
}
|
||||
|
188
Core/GDCore/IDE/Events/EventsContextAnalyzer.cpp
Normal file
188
Core/GDCore/IDE/Events/EventsContextAnalyzer.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/IDE/Events/EventsContextAnalyzer.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Events/EventsList.h"
|
||||
#include "GDCore/Events/Parsers/ExpressionParser.h"
|
||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
class CallbacksForListingObjects : public gd::ParserCallbacks {
|
||||
public:
|
||||
CallbacksForListingObjects(const gd::Platform& platform_,
|
||||
const gd::Project& project_,
|
||||
const gd::Layout& layout_,
|
||||
EventsContext& context_)
|
||||
: platform(platform_),
|
||||
project(project_),
|
||||
layout(layout_),
|
||||
context(context_){};
|
||||
virtual ~CallbacksForListingObjects(){};
|
||||
|
||||
virtual void OnConstantToken(gd::String text){};
|
||||
|
||||
virtual void OnStaticFunction(gd::String functionName,
|
||||
const std::vector<gd::Expression>& parameters,
|
||||
const gd::ExpressionMetadata& expressionInfo) {
|
||||
for (std::size_t i = 0;
|
||||
i < parameters.size() && i < expressionInfo.parameters.size();
|
||||
++i) {
|
||||
EventsContextAnalyzer::AnalyzeParameter(platform,
|
||||
project,
|
||||
layout,
|
||||
expressionInfo.parameters[i],
|
||||
parameters[i],
|
||||
context);
|
||||
}
|
||||
};
|
||||
|
||||
virtual void OnObjectFunction(gd::String functionName,
|
||||
const std::vector<gd::Expression>& parameters,
|
||||
const gd::ExpressionMetadata& expressionInfo) {
|
||||
for (std::size_t i = 0;
|
||||
i < parameters.size() && i < expressionInfo.parameters.size();
|
||||
++i) {
|
||||
EventsContextAnalyzer::AnalyzeParameter(platform,
|
||||
project,
|
||||
layout,
|
||||
expressionInfo.parameters[i],
|
||||
parameters[i],
|
||||
context);
|
||||
}
|
||||
};
|
||||
|
||||
virtual void OnObjectBehaviorFunction(
|
||||
gd::String functionName,
|
||||
const std::vector<gd::Expression>& parameters,
|
||||
const gd::ExpressionMetadata& expressionInfo) {
|
||||
for (std::size_t i = 0;
|
||||
i < parameters.size() && i < expressionInfo.parameters.size();
|
||||
++i) {
|
||||
EventsContextAnalyzer::AnalyzeParameter(platform,
|
||||
project,
|
||||
layout,
|
||||
expressionInfo.parameters[i],
|
||||
parameters[i],
|
||||
context);
|
||||
}
|
||||
};
|
||||
|
||||
virtual bool OnSubMathExpression(const gd::Platform& platform,
|
||||
const gd::Project& project,
|
||||
const gd::Layout& layout,
|
||||
gd::Expression& expression) {
|
||||
CallbacksForListingObjects callbacks(platform, project, layout, context);
|
||||
|
||||
gd::ExpressionParser parser(expression.GetPlainString());
|
||||
parser.ParseMathExpression(platform, project, layout, callbacks);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool OnSubTextExpression(const gd::Platform& platform,
|
||||
const gd::Project& project,
|
||||
const gd::Layout& layout,
|
||||
gd::Expression& expression) {
|
||||
CallbacksForListingObjects callbacks(platform, project, layout, context);
|
||||
|
||||
gd::ExpressionParser parser(expression.GetPlainString());
|
||||
parser.ParseStringExpression(platform, project, layout, callbacks);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
const gd::Platform& platform;
|
||||
const gd::Project& project;
|
||||
const gd::Layout& layout;
|
||||
EventsContext& context;
|
||||
};
|
||||
|
||||
bool EventsContextAnalyzer::DoVisitInstruction(gd::Instruction& instruction,
|
||||
bool isCondition) {
|
||||
const gd::InstructionMetadata& instrInfo =
|
||||
isCondition ? MetadataProvider::GetConditionMetadata(
|
||||
project.GetCurrentPlatform(), instruction.GetType())
|
||||
: MetadataProvider::GetActionMetadata(
|
||||
project.GetCurrentPlatform(), instruction.GetType());
|
||||
|
||||
for (int i = 0; i < instruction.GetParametersCount() &&
|
||||
i < instrInfo.GetParametersCount();
|
||||
++i) {
|
||||
AnalyzeParameter(platform,
|
||||
project,
|
||||
layout,
|
||||
instrInfo.GetParameter(i),
|
||||
instruction.GetParameter(i),
|
||||
context);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void EventsContextAnalyzer::AnalyzeParameter(
|
||||
const gd::Platform& platform,
|
||||
const gd::Project& project,
|
||||
const gd::Layout& layout,
|
||||
const gd::ParameterMetadata& metadata,
|
||||
const gd::Expression& parameter,
|
||||
EventsContext& context) {
|
||||
const auto& value = parameter.GetPlainString();
|
||||
const auto& type = metadata.GetType();
|
||||
if (ParameterMetadata::IsObject(type)) {
|
||||
context.AddObjectName(value);
|
||||
} else if (ParameterMetadata::IsExpression("number", type)) {
|
||||
CallbacksForListingObjects callbacks(platform, project, layout, context);
|
||||
|
||||
gd::ExpressionParser parser(value);
|
||||
parser.ParseMathExpression(platform, project, layout, callbacks);
|
||||
} else if (ParameterMetadata::IsExpression("string", type)) {
|
||||
CallbacksForListingObjects callbacks(platform, project, layout, context);
|
||||
|
||||
gd::ExpressionParser parser(value);
|
||||
parser.ParseStringExpression(platform, project, layout, callbacks);
|
||||
}
|
||||
}
|
||||
|
||||
void EventsContext::AddObjectName(const gd::String& objectName) {
|
||||
for (auto& realObjectName : ExpandObjectsName(objectName)) {
|
||||
objectNames.insert(realObjectName);
|
||||
}
|
||||
objectOrGroupNames.insert(objectName);
|
||||
}
|
||||
|
||||
std::vector<gd::String> EventsContext::ExpandObjectsName(
|
||||
const gd::String& objectName) {
|
||||
// Note: this logic is duplicated in EventsCodeGenerator::ExpandObjectsName
|
||||
std::vector<gd::String> realObjects;
|
||||
if (project.GetObjectGroups().Has(objectName))
|
||||
realObjects =
|
||||
project.GetObjectGroups().Get(objectName).GetAllObjectsNames();
|
||||
else if (layout.GetObjectGroups().Has(objectName))
|
||||
realObjects = layout.GetObjectGroups().Get(objectName).GetAllObjectsNames();
|
||||
else
|
||||
realObjects.push_back(objectName);
|
||||
|
||||
// Ensure that all returned objects actually exists.
|
||||
for (std::size_t i = 0; i < realObjects.size();) {
|
||||
if (!layout.HasObjectNamed(realObjects[i]) &&
|
||||
!project.HasObjectNamed(realObjects[i]))
|
||||
realObjects.erase(realObjects.begin() + i);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
|
||||
return realObjects;
|
||||
}
|
||||
|
||||
} // namespace gd
|
99
Core/GDCore/IDE/Events/EventsContextAnalyzer.h
Normal file
99
Core/GDCore/IDE/Events/EventsContextAnalyzer.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#ifndef EventsContextAnalyzer_H
|
||||
#define EventsContextAnalyzer_H
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
class Platform;
|
||||
class Project;
|
||||
class Layout;
|
||||
class EventsList;
|
||||
class ParameterMetadata;
|
||||
class Expression;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Store the results of a search done by EventsContextAnalyzer.
|
||||
*/
|
||||
class GD_CORE_API EventsContext {
|
||||
public:
|
||||
EventsContext(gd::Project& project_, gd::Layout& layout_)
|
||||
: project(project_), layout(layout_){};
|
||||
virtual ~EventsContext(){};
|
||||
|
||||
void AddObjectName(const gd::String& objectName);
|
||||
|
||||
std::vector<gd::String> ExpandObjectsName(const gd::String& objectName);
|
||||
|
||||
/**
|
||||
* \brief Get object or group names being referenced in the events.
|
||||
*/
|
||||
const std::set<gd::String>& GetObjectOrGroupNames() {
|
||||
return objectOrGroupNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get objects referenced in the events, without groups (all groups
|
||||
* have been "expanded" to the real objects being referenced by the group).
|
||||
*/
|
||||
const std::set<gd::String>& GetObjectNames() { return objectNames; }
|
||||
|
||||
private:
|
||||
std::set<gd::String> objectOrGroupNames;
|
||||
std::set<gd::String> objectNames;
|
||||
gd::Project& project;
|
||||
gd::Layout& layout;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Analyze events to list all the objects being used in them.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API EventsContextAnalyzer : public ArbitraryEventsWorker {
|
||||
public:
|
||||
EventsContextAnalyzer(const gd::Platform& platform_,
|
||||
gd::Project& project_,
|
||||
gd::Layout& layout_)
|
||||
: platform(platform_),
|
||||
project(project_),
|
||||
layout(layout_),
|
||||
context(project, layout){};
|
||||
virtual ~EventsContextAnalyzer(){};
|
||||
|
||||
/**
|
||||
* Get the context containing the objects that are used in the events.
|
||||
*/
|
||||
const EventsContext& GetEventsContext() { return context; }
|
||||
|
||||
static void AnalyzeParameter(const gd::Platform& platform,
|
||||
const gd::Project& project,
|
||||
const gd::Layout& layout,
|
||||
const gd::ParameterMetadata& metadata,
|
||||
const gd::Expression& parameter,
|
||||
EventsContext& context);
|
||||
|
||||
private:
|
||||
virtual bool DoVisitInstruction(gd::Instruction& instruction,
|
||||
bool isCondition);
|
||||
|
||||
const gd::Platform& platform;
|
||||
gd::Project& project;
|
||||
gd::Layout& layout;
|
||||
EventsContext context;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // EventsContextAnalyzer_H
|
@@ -217,7 +217,7 @@ bool EventsRefactorer::RenameObjectInActions(const gd::Platform& platform,
|
||||
actions[aId].GetParameter(pNb).GetPlainString() == oldName)
|
||||
actions[aId].SetParameter(pNb, gd::Expression(newName));
|
||||
// Replace object's name in expressions
|
||||
else if (instrInfos.parameters[pNb].type == "expression") {
|
||||
else if (ParameterMetadata::IsExpression("number", instrInfos.parameters[pNb].type)) {
|
||||
gd::String newExpression;
|
||||
gd::String oldExpression =
|
||||
actions[aId].GetParameter(pNb).GetPlainString();
|
||||
@@ -232,11 +232,7 @@ bool EventsRefactorer::RenameObjectInActions(const gd::Platform& platform,
|
||||
}
|
||||
}
|
||||
// Replace object's name in text expressions
|
||||
else if (instrInfos.parameters[pNb].type == "string" ||
|
||||
instrInfos.parameters[pNb].type == "file" ||
|
||||
instrInfos.parameters[pNb].type == "joyaxis" ||
|
||||
instrInfos.parameters[pNb].type == "color" ||
|
||||
instrInfos.parameters[pNb].type == "layer") {
|
||||
else if (ParameterMetadata::IsExpression("string", instrInfos.parameters[pNb].type)) {
|
||||
gd::String newExpression;
|
||||
gd::String oldExpression =
|
||||
actions[aId].GetParameter(pNb).GetPlainString();
|
||||
@@ -285,7 +281,7 @@ bool EventsRefactorer::RenameObjectInConditions(
|
||||
conditions[cId].GetParameter(pNb).GetPlainString() == oldName)
|
||||
conditions[cId].SetParameter(pNb, gd::Expression(newName));
|
||||
// Replace object's name in expressions
|
||||
else if (instrInfos.parameters[pNb].type == "expression") {
|
||||
else if (ParameterMetadata::IsExpression("number", instrInfos.parameters[pNb].type)) {
|
||||
gd::String newExpression;
|
||||
gd::String oldExpression =
|
||||
conditions[cId].GetParameter(pNb).GetPlainString();
|
||||
@@ -299,11 +295,7 @@ bool EventsRefactorer::RenameObjectInConditions(
|
||||
}
|
||||
}
|
||||
// Replace object's name in text expressions
|
||||
else if (instrInfos.parameters[pNb].type == "string" ||
|
||||
instrInfos.parameters[pNb].type == "file" ||
|
||||
instrInfos.parameters[pNb].type == "joyaxis" ||
|
||||
instrInfos.parameters[pNb].type == "color" ||
|
||||
instrInfos.parameters[pNb].type == "layer") {
|
||||
else if (ParameterMetadata::IsExpression("string", instrInfos.parameters[pNb].type)) {
|
||||
gd::String newExpression;
|
||||
gd::String oldExpression =
|
||||
conditions[cId].GetParameter(pNb).GetPlainString();
|
||||
@@ -389,7 +381,7 @@ bool EventsRefactorer::RemoveObjectInActions(const gd::Platform& platform,
|
||||
break;
|
||||
}
|
||||
// Replace object's name in expressions
|
||||
else if (instrInfos.parameters[pNb].type == "expression") {
|
||||
else if (ParameterMetadata::IsExpression("number", instrInfos.parameters[pNb].type)) {
|
||||
CallbacksForRemovingObject callbacks(name);
|
||||
|
||||
gd::ExpressionParser parser(
|
||||
@@ -401,11 +393,7 @@ bool EventsRefactorer::RemoveObjectInActions(const gd::Platform& platform,
|
||||
}
|
||||
}
|
||||
// Replace object's name in text expressions
|
||||
else if (instrInfos.parameters[pNb].type == "string" ||
|
||||
instrInfos.parameters[pNb].type == "file" ||
|
||||
instrInfos.parameters[pNb].type == "joyaxis" ||
|
||||
instrInfos.parameters[pNb].type == "color" ||
|
||||
instrInfos.parameters[pNb].type == "layer") {
|
||||
else if (ParameterMetadata::IsExpression("string", instrInfos.parameters[pNb].type)) {
|
||||
CallbacksForRemovingObject callbacks(name);
|
||||
|
||||
gd::ExpressionParser parser(
|
||||
@@ -457,7 +445,7 @@ bool EventsRefactorer::RemoveObjectInConditions(
|
||||
break;
|
||||
}
|
||||
// Replace object's name in expressions
|
||||
else if (instrInfos.parameters[pNb].type == "expression") {
|
||||
else if (ParameterMetadata::IsExpression("number", instrInfos.parameters[pNb].type)) {
|
||||
CallbacksForRemovingObject callbacks(name);
|
||||
|
||||
gd::ExpressionParser parser(
|
||||
@@ -469,11 +457,7 @@ bool EventsRefactorer::RemoveObjectInConditions(
|
||||
}
|
||||
}
|
||||
// Replace object's name in text expressions
|
||||
else if (instrInfos.parameters[pNb].type == "string" ||
|
||||
instrInfos.parameters[pNb].type == "file" ||
|
||||
instrInfos.parameters[pNb].type == "joyaxis" ||
|
||||
instrInfos.parameters[pNb].type == "color" ||
|
||||
instrInfos.parameters[pNb].type == "layer") {
|
||||
else if (ParameterMetadata::IsExpression("string", instrInfos.parameters[pNb].type)) {
|
||||
CallbacksForRemovingObject callbacks(name);
|
||||
|
||||
gd::ExpressionParser parser(
|
||||
|
@@ -174,7 +174,7 @@ std::set<gd::String> EventsVariablesFinder::FindArgumentsInInstructions(
|
||||
results.insert(instructions[aId].GetParameter(pNb).GetPlainString());
|
||||
}
|
||||
// Search in expressions
|
||||
else if (instrInfos.parameters[pNb].type == "expression") {
|
||||
else if (ParameterMetadata::IsExpression("number", instrInfos.parameters[pNb].type)) {
|
||||
CallbacksForSearchingVariable callbacks(
|
||||
results, parameterType, objectName);
|
||||
|
||||
@@ -183,11 +183,7 @@ std::set<gd::String> EventsVariablesFinder::FindArgumentsInInstructions(
|
||||
parser.ParseMathExpression(platform, project, layout, callbacks);
|
||||
}
|
||||
// Search in gd::String expressions
|
||||
else if (instrInfos.parameters[pNb].type == "string" ||
|
||||
instrInfos.parameters[pNb].type == "file" ||
|
||||
instrInfos.parameters[pNb].type == "joyaxis" ||
|
||||
instrInfos.parameters[pNb].type == "color" ||
|
||||
instrInfos.parameters[pNb].type == "layer") {
|
||||
else if (ParameterMetadata::IsExpression("string", instrInfos.parameters[pNb].type)) {
|
||||
CallbacksForSearchingVariable callbacks(
|
||||
results, parameterType, objectName);
|
||||
|
||||
|
@@ -17,8 +17,13 @@ namespace gd {
|
||||
/**
|
||||
* \brief Internal class loading static extensions.
|
||||
*
|
||||
* Class that load extensions and store them in ExtensionsManager
|
||||
* \see ExtensionsManager
|
||||
* Class that load extensions and store them in a Platform.
|
||||
*
|
||||
* \note This is for loading extensions declared in C++, usually in
|
||||
* files called "Extension.cpp" or "JsExtension.cpp".
|
||||
* GDevelop 5 extensions can also be declared directly in JavaScript.
|
||||
* See newIDE/app/src/JsExtensionsLoader and "JsExtension.js" files
|
||||
* for extensions declared in JavaScript.
|
||||
*/
|
||||
class GD_CORE_API ExtensionsLoader {
|
||||
public:
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
#ifndef GDCORE_FILEPROPERTY_H
|
||||
#define GDCORE_FILEPROPERTY_H
|
||||
#include <wx/control.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/propgrid/propgrid.h>
|
||||
#include <wx/propgrid/props.h>
|
||||
|
||||
|
@@ -145,6 +145,16 @@ const gd::String& InitialInstance::GetRawStringProperty(
|
||||
const auto& it = stringInfos.find(name);
|
||||
return it != stringInfos.end() ? it->second : *badStringProperyValue;
|
||||
}
|
||||
|
||||
void InitialInstance::SetRawFloatProperty(const gd::String& name, float value)
|
||||
{
|
||||
floatInfos[name] = value;
|
||||
}
|
||||
|
||||
void InitialInstance::SetRawStringProperty(const gd::String& name, const gd::String& value)
|
||||
{
|
||||
stringInfos[name] = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -206,7 +206,8 @@ class GD_CORE_API InitialInstance {
|
||||
/**
|
||||
* \brief Get the value of a float property stored in the instance.
|
||||
* \note Only use this when \a GetCustomProperties is too slow (when rendering
|
||||
* instances for example). \return the value of the property, or 0 if it does
|
||||
* instances for example).
|
||||
* \return the value of the property, or 0 if it does
|
||||
* not exists.
|
||||
*/
|
||||
float GetRawFloatProperty(const gd::String& name) const;
|
||||
@@ -214,10 +215,21 @@ class GD_CORE_API InitialInstance {
|
||||
/**
|
||||
* \brief Get the value of a string property stored in the instance.
|
||||
* \note Only use this when \a GetCustomProperties is too slow (when rendering
|
||||
* instances for example). \return the value of the propety, or an empty
|
||||
* instances for example).
|
||||
* \return the value of the propety, or an empty
|
||||
* string if it does not exists.
|
||||
*/
|
||||
const gd::String& GetRawStringProperty(const gd::String& name) const;
|
||||
|
||||
/**
|
||||
* \brief Set the value of a float property stored in the instance.
|
||||
*/
|
||||
void SetRawFloatProperty(const gd::String& name, float value);
|
||||
|
||||
/**
|
||||
* \brief Set the value of a string property stored in the instance.
|
||||
*/
|
||||
void SetRawStringProperty(const gd::String& name, const gd::String& value);
|
||||
///@}
|
||||
#endif
|
||||
|
||||
|
@@ -1,6 +1,12 @@
|
||||
#ifndef LAYOUTEDITORPREVIEWER_H
|
||||
#define LAYOUTEDITORPREVIEWER_H
|
||||
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
|
||||
#ifdef WINDOWS
|
||||
#include <wx/msw/winundef.h>
|
||||
#endif
|
||||
|
||||
#include <wx/event.h>
|
||||
namespace gd {
|
||||
class LayoutEditorCanvas;
|
||||
|
@@ -61,6 +61,7 @@ Project::Project()
|
||||
:
|
||||
#if defined(GD_IDE_ONLY)
|
||||
name(_("Project")),
|
||||
version("1.0.0"),
|
||||
packageName("com.example.gamename"),
|
||||
orientation("landscape"),
|
||||
folderProject(false),
|
||||
@@ -524,6 +525,7 @@ void Project::UnserializeFrom(const SerializerElement& element) {
|
||||
const SerializerElement& propElement =
|
||||
element.GetChild("properties", 0, "Info");
|
||||
SetName(propElement.GetChild("name", 0, "Nom").GetValue().GetString());
|
||||
SetVersion(propElement.GetStringAttribute("version", "1.0.0"));
|
||||
SetDefaultWidth(
|
||||
propElement.GetChild("windowWidth", 0, "WindowW").GetValue().GetInt());
|
||||
SetDefaultHeight(
|
||||
@@ -782,6 +784,7 @@ void Project::SerializeTo(SerializerElement& element) const {
|
||||
|
||||
SerializerElement& propElement = element.AddChild("properties");
|
||||
propElement.AddChild("name").SetValue(GetName());
|
||||
propElement.SetAttribute("version", GetVersion());
|
||||
propElement.AddChild("author").SetValue(GetAuthor());
|
||||
propElement.AddChild("windowWidth").SetValue(GetMainWindowDefaultWidth());
|
||||
propElement.AddChild("windowHeight").SetValue(GetMainWindowDefaultHeight());
|
||||
@@ -1100,6 +1103,7 @@ Project& Project::operator=(const Project& other) {
|
||||
void Project::Init(const gd::Project& game) {
|
||||
// Some properties
|
||||
name = game.name;
|
||||
version = game.version;
|
||||
windowWidth = game.windowWidth;
|
||||
windowHeight = game.windowHeight;
|
||||
maxFPS = game.maxFPS;
|
||||
|
@@ -21,44 +21,18 @@ class TiXmlElement;
|
||||
#include "GDCore/Project/VariablesContainer.h"
|
||||
namespace gd {
|
||||
class Platform;
|
||||
}
|
||||
namespace gd {
|
||||
class Layout;
|
||||
}
|
||||
namespace gd {
|
||||
class ExternalEvents;
|
||||
}
|
||||
namespace gd {
|
||||
class ResourcesManager;
|
||||
}
|
||||
namespace gd {
|
||||
class ExternalLayout;
|
||||
}
|
||||
namespace gd {
|
||||
class Object;
|
||||
}
|
||||
namespace gd {
|
||||
class VariablesContainer;
|
||||
}
|
||||
namespace gd {
|
||||
class ArbitraryResourceWorker;
|
||||
}
|
||||
namespace gd {
|
||||
class SourceFile;
|
||||
}
|
||||
namespace gd {
|
||||
class ImageManager;
|
||||
}
|
||||
namespace gd {
|
||||
class Behavior;
|
||||
}
|
||||
namespace gd {
|
||||
class BehaviorsSharedData;
|
||||
}
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
}
|
||||
namespace gd {
|
||||
class SerializerElement;
|
||||
}
|
||||
#undef GetObject // Disable an annoying macro
|
||||
@@ -92,6 +66,17 @@ class GD_CORE_API Project : public ClassWithObjects {
|
||||
*/
|
||||
const gd::String& GetName() const { return name; }
|
||||
|
||||
/**
|
||||
* \brief Change the version of the project.
|
||||
* This can be freely set, but should follow "X.Y.Z" format for compatibility with some exporters.
|
||||
*/
|
||||
void SetVersion(const gd::String& version_) { version = version_; };
|
||||
|
||||
/**
|
||||
* \brief Get project version.
|
||||
*/
|
||||
const gd::String& GetVersion() const { return version; }
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* \brief Change the author of the project.
|
||||
@@ -222,13 +207,16 @@ class GD_CORE_API Project : public ClassWithObjects {
|
||||
/**
|
||||
* \brief Get how the game size should be adapted to the screen.
|
||||
*/
|
||||
const gd::String & GetSizeOnStartupMode() const { return sizeOnStartupMode; }
|
||||
|
||||
const gd::String& GetSizeOnStartupMode() const { return sizeOnStartupMode; }
|
||||
|
||||
/**
|
||||
* \brief Set how to adapt the game size to the screen.
|
||||
* \param mode The size to be used. Can be "adaptWidth", "adaptHeight" or empty fpr no changes to game size.
|
||||
* \brief Set how to adapt the game size to the screen.
|
||||
* \param mode The size to be used. Can be "adaptWidth", "adaptHeight" or
|
||||
* empty fpr no changes to game size.
|
||||
*/
|
||||
void SetSizeOnStartupMode(const gd::String & mode) { sizeOnStartupMode = mode; }
|
||||
void SetSizeOnStartupMode(const gd::String& mode) {
|
||||
sizeOnStartupMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the default maximum number of frames allowed to be rendered per
|
||||
@@ -874,13 +862,16 @@ class GD_CORE_API Project : public ClassWithObjects {
|
||||
void LoadProjectInformationFromXml(const TiXmlElement* elem);
|
||||
|
||||
gd::String name; ///< Game name
|
||||
gd::String version; ///< Game version number (used for some exports)
|
||||
unsigned int windowWidth; ///< Window default width
|
||||
unsigned int windowHeight; ///< Window default height
|
||||
int maxFPS; ///< Maximum Frame Per Seconds, -1 for unlimited
|
||||
unsigned int minFPS; ///< Minimum Frame Per Seconds ( slow down game if FPS
|
||||
///< are below this number )
|
||||
bool verticalSync; ///< If true, must activate vertical synchronization.
|
||||
gd::String sizeOnStartupMode; ///< How to adapt the game size to the screen. Can be "adaptWidth", "adaptHeight" or empty
|
||||
gd::String
|
||||
sizeOnStartupMode; ///< How to adapt the game size to the screen. Can be
|
||||
///< "adaptWidth", "adaptHeight" or empty
|
||||
std::vector<std::unique_ptr<gd::Layout> > scenes; ///< List of all scenes
|
||||
gd::VariablesContainer variables; ///< Initial global variables
|
||||
std::vector<std::unique_ptr<gd::ExternalLayout> >
|
||||
|
@@ -8,6 +8,9 @@ SerializerElement SerializerElement::nullElement;
|
||||
|
||||
SerializerElement::SerializerElement() : valueUndefined(true) {}
|
||||
|
||||
SerializerElement::SerializerElement(const SerializerValue& value)
|
||||
: valueUndefined(false), elementValue(value) {}
|
||||
|
||||
SerializerElement::~SerializerElement() {}
|
||||
|
||||
const SerializerValue& SerializerElement::GetValue() const {
|
||||
|
@@ -23,6 +23,7 @@ namespace gd {
|
||||
class GD_CORE_API SerializerElement {
|
||||
public:
|
||||
SerializerElement();
|
||||
SerializerElement(const SerializerValue & value);
|
||||
virtual ~SerializerElement();
|
||||
|
||||
/** \name Value
|
||||
|
@@ -8,8 +8,8 @@
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#if defined(WINDOWS)
|
||||
#include "psapi.h"
|
||||
#include "windows.h"
|
||||
#include "psapi.h"
|
||||
#endif
|
||||
|
||||
namespace gd {
|
||||
|
@@ -1699,7 +1699,7 @@ HIDE_UNDOC_RELATIONS = YES
|
||||
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
|
||||
# have no effect if this option is set to NO (the default)
|
||||
|
||||
HAVE_DOT = YES
|
||||
HAVE_DOT = NO
|
||||
|
||||
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
|
||||
# allowed to run in parallel. When set to 0 (the default) doxygen will
|
||||
|
@@ -11,12 +11,14 @@ This project is released under the MIT License.
|
||||
#include "AdMobObject.h"
|
||||
|
||||
void DeclareAdMobObjectExtension(gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"AdMobObject",
|
||||
_("AdMob banners and interstitial screens"),
|
||||
_("Display an ads banner and interstitial screens powered by AdMob."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"AdMobObject",
|
||||
_("AdMob banners and interstitial screens"),
|
||||
_("Display an ads banner and interstitial screens powered by AdMob."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/admob");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<AdMobObject>(
|
||||
"AdMob",
|
||||
|
@@ -12,10 +12,10 @@ if (typeof AdMob !== "undefined")
|
||||
* The AdMobRuntimeObject displays an AdMob ad banner on screen.
|
||||
* This works with Cordova compatible platforms with `cordova-plugin-admobpro` plugin installed.
|
||||
*
|
||||
* @namespace gdjs
|
||||
* @memberof gdjs
|
||||
* @class AdMobRuntimeObject
|
||||
* @extends RuntimeObject
|
||||
* @namespace gdjs
|
||||
* @memberof gdjs
|
||||
*/
|
||||
gdjs.AdMobRuntimeObject = function(runtimeScene, objectData)
|
||||
{
|
||||
|
@@ -10,11 +10,13 @@ This project is released under the MIT License.
|
||||
#include "GDCpp/Runtime/Project/BehaviorsSharedData.h"
|
||||
|
||||
void DeclareAnchorBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation("AnchorBehavior",
|
||||
_("Anchor"),
|
||||
_("Anchor objects to the window's bounds."),
|
||||
"Victor Levasseur",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("AnchorBehavior",
|
||||
_("Anchor"),
|
||||
_("Anchor objects to the window's bounds."),
|
||||
"Victor Levasseur",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/behaviors/anchor");
|
||||
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
"AnchorBehavior",
|
||||
|
@@ -26,7 +26,8 @@ class Extension : public ExtensionBase {
|
||||
_("3D Box Object"),
|
||||
_("This Extension enables the use of 3D Box objects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
{
|
||||
gd::ObjectMetadata& obj =
|
||||
|
@@ -20,7 +20,7 @@ IF (NOT EMSCRIPTEN)
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY(DestroyOutsideBehavior)
|
||||
ADD_SUBDIRECTORY(DraggableBehavior)
|
||||
ADD_SUBDIRECTORY(FacebookInstantGames)
|
||||
# ADD_SUBDIRECTORY(FacebookInstantGames) - Pure JS extension, see "JsExtension.js".
|
||||
IF (NOT EMSCRIPTEN)
|
||||
ADD_SUBDIRECTORY(Function)
|
||||
ENDIF()
|
||||
|
@@ -7,96 +7,108 @@ This project is released under the MIT License.
|
||||
|
||||
#include "GDCpp/Extensions/ExtensionBase.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief This class declares information about the extension.
|
||||
*/
|
||||
class Extension : public ExtensionBase
|
||||
{
|
||||
public:
|
||||
class Extension : public ExtensionBase {
|
||||
public:
|
||||
/**
|
||||
* Constructor of an extension declares everything the extension contains:
|
||||
* objects, actions, conditions and expressions.
|
||||
*/
|
||||
Extension() {
|
||||
SetExtensionInformation("CommonDialogs",
|
||||
_("Common dialogs"),
|
||||
_("This Extension can display common dialogs ( "
|
||||
"Message box, open file dialog... )"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
#if defined(GD_IDE_ONLY)
|
||||
|
||||
/**
|
||||
* Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
|
||||
*/
|
||||
Extension()
|
||||
{
|
||||
SetExtensionInformation("CommonDialogs",
|
||||
_("Common dialogs"),
|
||||
_("This Extension can display common dialogs ( Message box, open file dialog... )"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
#if defined(GD_IDE_ONLY)
|
||||
AddAction(
|
||||
"ShowMsgBox",
|
||||
_("Show a message box"),
|
||||
_("Display a message box with the specified text and an Ok button."),
|
||||
_("Display message \"_PARAM1_\" with title \"_PARAM2_\""),
|
||||
_("Interfaces"),
|
||||
"res/actions/msgbox24.png",
|
||||
"res/actions/msgbox.png")
|
||||
|
||||
AddAction("ShowMsgBox",
|
||||
_("Show a message box"),
|
||||
_("Display a message box with the specified text and an Ok button."),
|
||||
_("Display message \"_PARAM1_\" with title \"_PARAM2_\""),
|
||||
_("Interfaces"),
|
||||
"res/actions/msgbox24.png",
|
||||
"res/actions/msgbox.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("string", _("Message"))
|
||||
.AddParameter("string", _("Title"))
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("string", _("Message"))
|
||||
.AddParameter("string", _("Title"))
|
||||
.SetFunctionName("GDpriv::CommonDialogs::ShowMessageBox")
|
||||
.SetIncludeFile("CommonDialogs/CommonDialogs.h");
|
||||
|
||||
.SetFunctionName("GDpriv::CommonDialogs::ShowMessageBox").SetIncludeFile("CommonDialogs/CommonDialogs.h");
|
||||
AddAction(
|
||||
"ShowOpenFile",
|
||||
_("Show a window to choose a file"),
|
||||
_("Display a window that allows a player to choose a file.\nThe name "
|
||||
"and the directory of the file will be saved in the specified "
|
||||
"variable."),
|
||||
_("Open a window for choosing a file, and save the result in _PARAM1_"),
|
||||
_("Interfaces"),
|
||||
"res/actions/openfile24.png",
|
||||
"res/actions/openfile.png")
|
||||
|
||||
AddAction("ShowOpenFile",
|
||||
_("Show a window to choose a file"),
|
||||
_("Display a window that allows a player to choose a file.\nThe name and the directory of the file will be saved in the specified variable."),
|
||||
_("Open a window for choosing a file, and save the result in _PARAM1_"),
|
||||
_("Interfaces"),
|
||||
"res/actions/openfile24.png",
|
||||
"res/actions/openfile.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("scenevar", _("Save result to scene variable"))
|
||||
.AddParameter("string", _("Title"))
|
||||
.AddParameter(
|
||||
"string",
|
||||
_("Wildcard filter ( \"FileType|*.ext;*.ext2|2ndFileType|*.ext3\" "
|
||||
") ( Windows only ) "))
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("scenevar", _("Save result to scene variable"))
|
||||
.AddParameter("string", _("Title"))
|
||||
.AddParameter("string", _("Wildcard filter ( \"FileType|*.ext;*.ext2|2ndFileType|*.ext3\" ) ( Windows only ) "))
|
||||
.SetFunctionName("GDpriv::CommonDialogs::ShowOpenFile")
|
||||
.SetIncludeFile("CommonDialogs/CommonDialogs.h");
|
||||
|
||||
.SetFunctionName("GDpriv::CommonDialogs::ShowOpenFile").SetIncludeFile("CommonDialogs/CommonDialogs.h");
|
||||
AddAction("ShowTextInput",
|
||||
_("Show a window to enter a text"),
|
||||
_("Show a window that allows a player to enter text.\nThe text "
|
||||
"will be saved in the specified scene variable."),
|
||||
_("Open a text input dialog, and save the result in _PARAM1_"),
|
||||
_("Interfaces"),
|
||||
"res/actions/textenter24.png",
|
||||
"res/actions/textenter.png")
|
||||
|
||||
AddAction("ShowTextInput",
|
||||
_("Show a window to enter a text"),
|
||||
_("Show a window that allows a player to enter text.\nThe text will be saved in the specified scene variable."),
|
||||
_("Open a text input dialog, and save the result in _PARAM1_"),
|
||||
_("Interfaces"),
|
||||
"res/actions/textenter24.png",
|
||||
"res/actions/textenter.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("scenevar", _("Save result to scene variable"))
|
||||
.AddParameter("string", _("Message"))
|
||||
.AddParameter("string", _("Title"))
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("scenevar", _("Save result to scene variable"))
|
||||
.AddParameter("string", _("Message"))
|
||||
.AddParameter("string", _("Title"))
|
||||
.SetFunctionName("GDpriv::CommonDialogs::ShowTextInput")
|
||||
.SetIncludeFile("CommonDialogs/CommonDialogs.h");
|
||||
|
||||
.SetFunctionName("GDpriv::CommonDialogs::ShowTextInput").SetIncludeFile("CommonDialogs/CommonDialogs.h");
|
||||
AddAction(
|
||||
"ShowYesNoMsgBox",
|
||||
_("Display a Yes/No message box"),
|
||||
_("Open a message box that allows a player to choose Yes or No.\nThe "
|
||||
"answer ( \"yes\"/\"no\" ) will be saved in the specified variable."),
|
||||
_("Open a Yes/No message box, and save the result in _PARAM1_"),
|
||||
_("Interfaces"),
|
||||
"res/actions/msgbox24.png",
|
||||
"res/actions/msgbox.png")
|
||||
|
||||
AddAction("ShowYesNoMsgBox",
|
||||
_("Display a Yes/No message box"),
|
||||
_("Open a message box that allows a player to choose Yes or No.\nThe answer ( \"yes\"/\"no\" ) will be saved in the specified variable."),
|
||||
_("Open a Yes/No message box, and save the result in _PARAM1_"),
|
||||
_("Interfaces"),
|
||||
"res/actions/msgbox24.png",
|
||||
"res/actions/msgbox.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("scenevar", _("Save result to scene variable"))
|
||||
.AddParameter("string", _("Message"))
|
||||
.AddParameter("string", _("Title"))
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("scenevar", _("Save result to scene variable"))
|
||||
.AddParameter("string", _("Message"))
|
||||
.AddParameter("string", _("Title"))
|
||||
.SetFunctionName("GDpriv::CommonDialogs::ShowYesNoMsgBox")
|
||||
.SetIncludeFile("CommonDialogs/CommonDialogs.h");
|
||||
|
||||
.SetFunctionName("GDpriv::CommonDialogs::ShowYesNoMsgBox").SetIncludeFile("CommonDialogs/CommonDialogs.h");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
|
||||
};
|
||||
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by GDevelop to create the extension class
|
||||
* -- Do not need to be modified. --
|
||||
*/
|
||||
extern "C" ExtensionBase * GD_EXTENSION_API CreateGDExtension() {
|
||||
return new Extension;
|
||||
extern "C" ExtensionBase* GD_EXTENSION_API CreateGDExtension() {
|
||||
return new Extension;
|
||||
}
|
||||
|
@@ -16,7 +16,8 @@ void DeclareDestroyOutsideBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
_("This Extension can be used to destroy objects when they go outside of "
|
||||
"the borders of the game's window."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/behaviors/destroyoutside");
|
||||
|
||||
gd::BehaviorMetadata& aut =
|
||||
extension.AddBehavior("DestroyOutside",
|
||||
|
@@ -22,12 +22,6 @@ class DestroyOutsideBehaviorJsExtension : public gd::PlatformExtension {
|
||||
* contains: objects, actions, conditions and expressions.
|
||||
*/
|
||||
DestroyOutsideBehaviorJsExtension() {
|
||||
SetExtensionInformation(
|
||||
"DestroyOutsideBehavior",
|
||||
_("Destroy Outside Screen Behavior"),
|
||||
_("Behavior destroying object when they go outside the screen"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
DeclareDestroyOutsideBehaviorExtension(*this);
|
||||
|
||||
GetBehaviorMetadata("DestroyOutsideBehavior::DestroyOutside")
|
||||
|
@@ -15,7 +15,8 @@ void DeclareDraggableBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
_("Draggable Behavior"),
|
||||
_("This Extension enables the movement of objects with a mouse."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("behaviors/draggable");
|
||||
|
||||
gd::BehaviorMetadata& aut =
|
||||
extension.AddBehavior("Draggable",
|
||||
|
355
Extensions/ExampleJsExtension/JsExtension.js
Normal file
355
Extensions/ExampleJsExtension/JsExtension.js
Normal file
@@ -0,0 +1,355 @@
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
* and search for any errors.
|
||||
*
|
||||
* More information on https://github.com/4ian/GD/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
module.exports = {
|
||||
createExtension: function(t, gd) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
"MyDummyExtension",
|
||||
"My Dummy Extension",
|
||||
"An example of a declaration of an extension",
|
||||
"Florian Rival",
|
||||
"MIT"
|
||||
);
|
||||
|
||||
// Declare conditions, actions or expressions:
|
||||
extension
|
||||
.addCondition(
|
||||
"MyNewCondition",
|
||||
t("Dummy condition example"),
|
||||
t(
|
||||
"This is an example of a condition displayed in the events sheet. Will return true if the number is less than 10 and the length of the text is less than 5."
|
||||
),
|
||||
t("Call the example condition with _PARAM0_ and _PARAM1_"),
|
||||
t("Dummy Extension"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png"
|
||||
)
|
||||
.addParameter("expression", t("Number 1"), "", false)
|
||||
.addParameter("string", t("Text 1"), "", false)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile(
|
||||
"Extensions/ExampleJsExtension/examplejsextensiontools.js"
|
||||
)
|
||||
.setFunctionName("gdjs.evtTools.exampleJsExtension.myConditionFunction");
|
||||
|
||||
extension
|
||||
.addExpression(
|
||||
"DummyExpression",
|
||||
t("Dummy expression example"),
|
||||
t("This is an example of an expression"),
|
||||
t("Dummy Extension"),
|
||||
"res/actions/camera.png"
|
||||
)
|
||||
.addParameter("expression", t("Maximum"), "", false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("gdjs.random");
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
"DummyStrExpression",
|
||||
t("Dummy string expression example"),
|
||||
t("This is an example of an expression returning a string"),
|
||||
t("Dummy Extension"),
|
||||
"res/actions/camera.png"
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile(
|
||||
"Extensions/ExampleJsExtension/examplejsextensiontools.js"
|
||||
)
|
||||
.setFunctionName("gdjs.evtTools.exampleJsExtension.getString");
|
||||
|
||||
// Declare a behavior.
|
||||
// Create a new gd.BehaviorJsImplementation object and implement the methods
|
||||
// that are called to get and set the properties of the behavior.
|
||||
// Everything that is stored inside the behavior is in "behaviorContent" and is automatically
|
||||
// saved/loaded to JSON.
|
||||
var dummyBehavior = new gd.BehaviorJsImplementation();
|
||||
dummyBehavior.updateProperty = function(
|
||||
behaviorContent,
|
||||
propertyName,
|
||||
newValue
|
||||
) {
|
||||
if (propertyName === "My first property") {
|
||||
behaviorContent.property1 = newValue;
|
||||
return true;
|
||||
}
|
||||
if (propertyName === "My other property") {
|
||||
behaviorContent.property2 = newValue === "1";
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
dummyBehavior.getProperties = function(behaviorContent) {
|
||||
var behaviorProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
behaviorProperties.set(
|
||||
"My first property",
|
||||
new gd.PropertyDescriptor(behaviorContent.property1)
|
||||
);
|
||||
behaviorProperties.set(
|
||||
"My other property",
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.property2 ? "true" : "false"
|
||||
).setType("Boolean")
|
||||
);
|
||||
|
||||
return behaviorProperties;
|
||||
};
|
||||
dummyBehavior.setRawJSONContent(
|
||||
JSON.stringify({
|
||||
property1: "Initial value 1",
|
||||
property2: true
|
||||
})
|
||||
);
|
||||
extension
|
||||
.addBehavior(
|
||||
"DummyBehavior",
|
||||
t("Dummy behavior for testing"),
|
||||
"DummyBehavior",
|
||||
t("This dummy behavior does nothing"),
|
||||
"",
|
||||
"CppPlatform/Extensions/topdownmovementicon.png",
|
||||
"DummyBehavior",
|
||||
dummyBehavior,
|
||||
new gd.BehaviorsSharedData()
|
||||
)
|
||||
.setIncludeFile("Extensions/ExampleJsExtension/dummyruntimebehavior.js")
|
||||
// You can optionally include more than one file when the behavior is used:
|
||||
.addIncludeFile(
|
||||
"Extensions/ExampleJsExtension/examplejsextensiontools.js"
|
||||
);
|
||||
|
||||
// Declare another behavior, with shared data between the behaviors
|
||||
// In addition to the usual behavior:
|
||||
// Create a new gd.BehaviorSharedDataJsImplementation object and implement the methods
|
||||
// that are called to get and set the properties of the shared data.
|
||||
var dummyBehaviorWithSharedData = new gd.BehaviorJsImplementation();
|
||||
dummyBehaviorWithSharedData.updateProperty = function(
|
||||
behaviorContent,
|
||||
propertyName,
|
||||
newValue
|
||||
) {
|
||||
if (propertyName === "My behavior property") {
|
||||
behaviorContent.property1 = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
dummyBehaviorWithSharedData.getProperties = function(behaviorContent) {
|
||||
var behaviorProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
behaviorProperties.set(
|
||||
"My behavior property",
|
||||
new gd.PropertyDescriptor(behaviorContent.property1)
|
||||
);
|
||||
|
||||
return behaviorProperties;
|
||||
};
|
||||
dummyBehaviorWithSharedData.setRawJSONContent(
|
||||
JSON.stringify({
|
||||
property1: "Initial value 1"
|
||||
})
|
||||
);
|
||||
|
||||
var sharedData = new gd.BehaviorSharedDataJsImplementation();
|
||||
sharedData.updateProperty = function(
|
||||
sharedContent,
|
||||
propertyName,
|
||||
newValue
|
||||
) {
|
||||
if (propertyName === "My shared property") {
|
||||
sharedContent.sharedProperty1 = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
sharedData.getProperties = function(sharedContent) {
|
||||
var sharedProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
sharedProperties.set(
|
||||
"My shared property",
|
||||
new gd.PropertyDescriptor(sharedContent.sharedProperty1 || "")
|
||||
);
|
||||
|
||||
return sharedProperties;
|
||||
};
|
||||
sharedData.setRawJSONContent(
|
||||
JSON.stringify({
|
||||
sharedProperty1: "Initial shared value 1"
|
||||
})
|
||||
);
|
||||
extension
|
||||
.addBehavior(
|
||||
"DummyBehaviorWithSharedData",
|
||||
t("Dummy behavior with shared data for testing"),
|
||||
"DummyBehaviorWithSharedData",
|
||||
t("This dummy behavior uses shared data and does nothing"),
|
||||
"",
|
||||
"CppPlatform/Extensions/topdownmovementicon.png",
|
||||
"DummyBehaviorWithSharedData",
|
||||
dummyBehaviorWithSharedData,
|
||||
sharedData
|
||||
)
|
||||
.setIncludeFile(
|
||||
"Extensions/ExampleJsExtension/dummywithshareddataruntimebehavior.js"
|
||||
)
|
||||
// You can optionally include more than one file when the behavior is used:
|
||||
.addIncludeFile(
|
||||
"Extensions/ExampleJsExtension/examplejsextensiontools.js"
|
||||
);
|
||||
|
||||
// Declare an object.
|
||||
// Create a new gd.ObjectJsImplementation object and implement the methods
|
||||
// that are called to get and set the properties of the object, as well
|
||||
// as the properties of the initial instances of this object
|
||||
// Everything that is stored inside the object is in "content" and is automatically
|
||||
// saved/loaded to JSON.
|
||||
var dummyObject = new gd.ObjectJsImplementation();
|
||||
dummyObject.updateProperty = function(
|
||||
objectContent,
|
||||
propertyName,
|
||||
newValue
|
||||
) {
|
||||
if (propertyName === "My first property") {
|
||||
objectContent.property1 = newValue;
|
||||
return true;
|
||||
}
|
||||
if (propertyName === "My other property") {
|
||||
objectContent.property2 = newValue === "1";
|
||||
return true;
|
||||
}
|
||||
if (propertyName === "My third property") {
|
||||
objectContent.property3 = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
dummyObject.getProperties = function(objectContent) {
|
||||
var objectProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
objectProperties.set(
|
||||
"My first property",
|
||||
new gd.PropertyDescriptor(objectContent.property1)
|
||||
);
|
||||
objectProperties.set(
|
||||
"My other property",
|
||||
new gd.PropertyDescriptor(
|
||||
objectContent.property2 ? "true" : "false"
|
||||
).setType("boolean")
|
||||
);
|
||||
objectProperties.set(
|
||||
"My third property",
|
||||
new gd.PropertyDescriptor(objectContent.property3.toString()).setType(
|
||||
"number"
|
||||
)
|
||||
);
|
||||
|
||||
return objectProperties;
|
||||
};
|
||||
dummyObject.setRawJSONContent(
|
||||
JSON.stringify({
|
||||
property1: "Initial value",
|
||||
property2: true,
|
||||
property3: 123
|
||||
})
|
||||
);
|
||||
|
||||
dummyObject.updateInitialInstanceProperty = function(
|
||||
objectContent,
|
||||
instance,
|
||||
propertyName,
|
||||
newValue,
|
||||
project,
|
||||
layout
|
||||
) {
|
||||
if (propertyName === "My instance property") {
|
||||
instance.setRawStringProperty("instanceprop1", newValue);
|
||||
return true;
|
||||
}
|
||||
if (propertyName === "My other instance property") {
|
||||
instance.setRawFloatProperty("instanceprop2", parseFloat(newValue));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
dummyObject.getInitialInstanceProperties = function(
|
||||
content,
|
||||
instance,
|
||||
project,
|
||||
layout
|
||||
) {
|
||||
var instanceProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
instanceProperties.set(
|
||||
"My instance property",
|
||||
new gd.PropertyDescriptor(
|
||||
instance.getRawStringProperty("instanceprop1")
|
||||
)
|
||||
);
|
||||
instanceProperties.set(
|
||||
"My other instance property",
|
||||
new gd.PropertyDescriptor(
|
||||
instance.getRawFloatProperty("instanceprop2").toString()
|
||||
).setType("number")
|
||||
);
|
||||
|
||||
return instanceProperties;
|
||||
};
|
||||
|
||||
extension.addObject(
|
||||
"DummyObject",
|
||||
t("Dummy object for testing"),
|
||||
t("This dummy object does nothing"),
|
||||
"CppPlatform/Extensions/topdownmovementicon.png",
|
||||
dummyObject
|
||||
);
|
||||
|
||||
return extension;
|
||||
},
|
||||
/**
|
||||
* You can optionally add sanity tests that will check the basic working
|
||||
* of your extension behaviors/objects by instanciating behaviors/objects
|
||||
* and setting the property to a given value.
|
||||
*
|
||||
* If you don't have any tests, you can simply return an empty array like this:
|
||||
* `runExtensionSanityTests: function(extension) { return []; }`
|
||||
*
|
||||
* But it is recommended to create tests for the behaviors/objects properties you created
|
||||
* to avoid mistakes.
|
||||
*/
|
||||
runExtensionSanityTests: function(extension) {
|
||||
const dummyBehavior = extension
|
||||
.getBehaviorMetadata("MyDummyExtension::DummyBehavior")
|
||||
.get();
|
||||
const sharedData = extension
|
||||
.getBehaviorMetadata("MyDummyExtension::DummyBehaviorWithSharedData")
|
||||
.getSharedDataInstance();
|
||||
return [
|
||||
gd.ProjectHelper.sanityCheckBehaviorProperty(
|
||||
dummyBehavior,
|
||||
"My first property",
|
||||
"Testing value"
|
||||
),
|
||||
gd.ProjectHelper.sanityCheckBehaviorsSharedDataProperty(
|
||||
sharedData,
|
||||
"My shared property",
|
||||
"Testing value"
|
||||
)
|
||||
];
|
||||
}
|
||||
};
|
35
Extensions/ExampleJsExtension/dummyruntimebehavior.js
Normal file
35
Extensions/ExampleJsExtension/dummyruntimebehavior.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* The DummyRuntimeBehavior changes a variable in the object that is owning
|
||||
* it, at every tick before events are run, to set it to the string that was
|
||||
* set in one of the behavior property.
|
||||
*
|
||||
* @class DummyRuntimeBehavior
|
||||
* @extends gdjs.RuntimeBehavior
|
||||
* @constructor
|
||||
*/
|
||||
gdjs.DummyRuntimeBehavior = function(runtimeScene, behaviorData, owner)
|
||||
{
|
||||
gdjs.RuntimeBehavior.call(this, runtimeScene, behaviorData, owner);
|
||||
|
||||
// Here you can access to the behavior data (JSON declared in JsExtension.js)
|
||||
// using behaviorData.content:
|
||||
this._textToSet = behaviorData.content.property1;
|
||||
|
||||
// You can also run arbitrary code at the creation of the behavior:
|
||||
console.log("DummyRuntimeBehavior was created for object:", owner);
|
||||
};
|
||||
|
||||
gdjs.DummyRuntimeBehavior.prototype = Object.create( gdjs.RuntimeBehavior.prototype );
|
||||
gdjs.DummyRuntimeBehavior.thisIsARuntimeBehaviorConstructor = "MyDummyExtension::DummyBehavior";
|
||||
|
||||
gdjs.DummyRuntimeBehavior.prototype.onDeActivate = function() {
|
||||
};
|
||||
|
||||
gdjs.DummyRuntimeBehavior.prototype.doStepPreEvents = function(runtimeScene) {
|
||||
// This is run at every frame, before events are launched.
|
||||
this.owner.getVariables().get("VariableSetFromBehavior").setString(this._textToSet);
|
||||
};
|
||||
|
||||
gdjs.DummyRuntimeBehavior.prototype.doStepPostEvents = function(runtimeScene) {
|
||||
// This is run at every frame, after events are launched.
|
||||
};
|
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @class DummyWithSharedDataRuntimeBehavior
|
||||
* @extends gdjs.RuntimeBehavior
|
||||
* @constructor
|
||||
*/
|
||||
gdjs.DummyWithSharedDataRuntimeBehavior = function(runtimeScene, behaviorData, owner)
|
||||
{
|
||||
gdjs.RuntimeBehavior.call(this, runtimeScene, behaviorData, owner);
|
||||
|
||||
// Here you can access to the behavior data (JSON declared in JsExtension.js)
|
||||
// using behaviorData.content:
|
||||
this._textToSet = behaviorData.content.property1;
|
||||
|
||||
// You can also access to the shared data:
|
||||
var sharedData = runtimeScene.getInitialSharedDataForBehavior(behaviorData.name);
|
||||
this._textToSet = sharedData.content.sharedProperty1;
|
||||
|
||||
// You can also run arbitrary code at the creation of the behavior:
|
||||
console.log("DummyWithSharedDataRuntimeBehavior was created for object:", owner);
|
||||
console.log("The shared data are:", sharedData);
|
||||
};
|
||||
|
||||
gdjs.DummyWithSharedDataRuntimeBehavior.prototype = Object.create( gdjs.RuntimeBehavior.prototype );
|
||||
gdjs.DummyWithSharedDataRuntimeBehavior.thisIsARuntimeBehaviorConstructor = "MyDummyExtension::DummyBehaviorWithSharedData";
|
||||
|
||||
gdjs.DummyWithSharedDataRuntimeBehavior.prototype.onDeActivate = function() {
|
||||
};
|
||||
|
||||
gdjs.DummyWithSharedDataRuntimeBehavior.prototype.doStepPreEvents = function(runtimeScene) {
|
||||
// This is run at every frame, before events are launched.
|
||||
this.owner.getVariables().get("VariableSetFromBehavior").setString(this._textToSet);
|
||||
};
|
||||
|
||||
gdjs.DummyWithSharedDataRuntimeBehavior.prototype.doStepPostEvents = function(runtimeScene) {
|
||||
// This is run at every frame, after events are launched.
|
||||
};
|
73
Extensions/ExampleJsExtension/examplejsextensiontools.js
Normal file
73
Extensions/ExampleJsExtension/examplejsextensiontools.js
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* This is an example of some functions that can be used through events.
|
||||
* They could live on any object but it's usual to store them in an object
|
||||
* with the extension name in `gdjs.evtTools`.
|
||||
*
|
||||
* Functions are being passed the arguments that were declared in the extension.
|
||||
*
|
||||
* @memberof gdjs.evtTools
|
||||
* @class exampleJsExtension
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
gdjs.evtTools.exampleJsExtension = {};
|
||||
|
||||
gdjs.evtTools.exampleJsExtension.myConditionFunction = function(number, text) {
|
||||
return number <= 10 && text.length < 5;
|
||||
};
|
||||
|
||||
gdjs.evtTools.exampleJsExtension.getString = function() {
|
||||
return "Hello World";
|
||||
};
|
||||
|
||||
/**
|
||||
* You can also attach an object to gdjs, that you can use to store more information
|
||||
* or objects - even if you should have doing so as global state can make things harder
|
||||
* to debug. Most of the time you can have all the logic in your functions, your gdjs.RuntimeBehavior
|
||||
* or your gdjs.RuntimeObject.
|
||||
*/
|
||||
gdjs.exampleJsExtension = {
|
||||
myGlobalString: "Hello World"
|
||||
};
|
||||
|
||||
/**
|
||||
* In **rare cases** you may want to run code at the start of the scene. You can define a callback
|
||||
* that will be called at this moment. Name you callback gdjsCallbackRuntimeSceneLoaded.
|
||||
* GDJS will scan anything declared inside gdjs for these names.
|
||||
*/
|
||||
gdjs.exampleJsExtension.gdjsCallbackRuntimeSceneLoaded = function(
|
||||
runtimeScene
|
||||
) {
|
||||
console.log("A gdjs.RuntimeScene was loaded:", runtimeScene);
|
||||
};
|
||||
|
||||
/**
|
||||
* In **rare cases** you may want to run code at the end of a scene. You can define a callback
|
||||
* that will be called at this moment. Name you callback gdjsCallbackRuntimeSceneLoaded.
|
||||
* GDJS will scan anything declared inside gdjs for these names.
|
||||
*/
|
||||
gdjs.exampleJsExtension.callbacksRuntimeSceneUnloaded = function(runtimeScene) {
|
||||
console.log("A gdjs.RuntimeScene was unloaded:", runtimeScene);
|
||||
};
|
||||
|
||||
/**
|
||||
* In **very rare cases** you may want to run code whenever an object is deleted.
|
||||
* You can create a callback named "callbacksObjectDeletedFromScene" on your extension object.
|
||||
* GDJS will scan anything declared inside gdjs for this name.
|
||||
*/
|
||||
gdjs.exampleJsExtension.callbacksObjectDeletedFromScene = function(
|
||||
runtimeScene,
|
||||
runtimeObject
|
||||
) {
|
||||
console.log(
|
||||
"A gdjs.RuntimeObject was deleted from a gdjs.RuntimeScene:",
|
||||
runtimeScene,
|
||||
runtimeObject
|
||||
);
|
||||
};
|
||||
|
||||
// Finally, note that you can also simply run code here. Most of the time you shouldn't need it though.
|
||||
console.log(
|
||||
"gdjs.exampleJsExtension was created, with myGlobalString containing:" +
|
||||
gdjs.exampleJsExtension.myGlobalString
|
||||
);
|
@@ -1,21 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_policy(SET CMP0015 NEW)
|
||||
|
||||
project(FacebookInstantGames)
|
||||
gd_add_extension_includes()
|
||||
|
||||
#Defines
|
||||
###
|
||||
gd_add_extension_definitions(FacebookInstantGames)
|
||||
|
||||
#The targets
|
||||
###
|
||||
include_directories(.)
|
||||
file(GLOB source_files *.cpp *.h)
|
||||
|
||||
gd_add_extension_target(FacebookInstantGames "${source_files}" "JsPlatform")
|
||||
gd_add_clang_utils(FacebookInstantGames "${source_files}")
|
||||
|
||||
#Linker files for the IDE extension
|
||||
###
|
||||
gd_extension_link_libraries(FacebookInstantGames)
|
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
|
||||
GDevelop - Facebook Instant Games Extension
|
||||
Copyright (c)2018 Florian Rival (Florian.Rival@gmail.com)
|
||||
This project is released under the MIT License.
|
||||
*/
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
void DeclareFacebookInstantGamesExtension(gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"FacebookInstantGames",
|
||||
_("Facebook Instant Games"),
|
||||
_("Allow your game to send scores and interact with Facebook Instant Games"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension.AddStrExpression("PlayerId",
|
||||
_("Player identifier"),
|
||||
_("Get the player unique identifier"),
|
||||
_("Facebook Instant Games"),
|
||||
"JsPlatform/Extensions/Facebookicon16.png");
|
||||
|
||||
extension.AddStrExpression("PlayerName",
|
||||
_("Player name"),
|
||||
_("Get the player name"),
|
||||
_("Facebook Instant Games"),
|
||||
"JsPlatform/Extensions/Facebookicon16.png");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief This class declares information about the JS extension.
|
||||
*/
|
||||
class FacebookInstantGamesJsExtension : public gd::PlatformExtension {
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor of an extension declares everything the extension
|
||||
* contains: objects, actions, conditions and expressions.
|
||||
*/
|
||||
FacebookInstantGamesJsExtension() {
|
||||
DeclareFacebookInstantGamesExtension(*this);
|
||||
|
||||
GetAllStrExpressions()["FacebookInstantGames::PlayerId"]
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/FacebookInstantGames/facebookinstantgamestools.js")
|
||||
.SetFunctionName("gdjs.evtTools.facebookInstantGames.getPlayerId()");
|
||||
|
||||
GetAllStrExpressions()["FacebookInstantGames::PlayerName"]
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/FacebookInstantGames/facebookinstantgamestools.js")
|
||||
.SetFunctionName("gdjs.evtTools.facebookInstantGames.getPlayerName()");
|
||||
|
||||
StripUnimplementedInstructionsAndExpressions();
|
||||
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
|
||||
};
|
||||
};
|
||||
|
||||
#if defined(EMSCRIPTEN)
|
||||
extern "C" gd::PlatformExtension* CreateGDJSFacebookInstantGamesExtension() {
|
||||
return new FacebookInstantGamesJsExtension;
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* Used by GDevelop to create the extension class
|
||||
* -- Do not need to be modified. --
|
||||
*/
|
||||
extern "C" gd::PlatformExtension* GD_EXTENSION_API CreateGDJSExtension() {
|
||||
return new FacebookInstantGamesJsExtension;
|
||||
}
|
||||
#endif
|
||||
#endif
|
198
Extensions/FacebookInstantGames/JsExtension.js
Normal file
198
Extensions/FacebookInstantGames/JsExtension.js
Normal file
@@ -0,0 +1,198 @@
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
* and search for any errors.
|
||||
*
|
||||
* More information on https://github.com/4ian/GD/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
module.exports = {
|
||||
createExtension: function(t, gd) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
"FacebookInstantGames",
|
||||
t("Facebook Instant Games"),
|
||||
t(
|
||||
"Allow your game to send scores and interact with Facebook Instant Games"
|
||||
),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)"
|
||||
);
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
"SavePlayerData",
|
||||
t("Save player data"),
|
||||
t("Save the content of the given variable in the player data, stored on Facebook Instant Games servers"),
|
||||
t("Save the content of _PARAM1_ in key _PARAM1_ of player data (store success message in _PARAM2_ or error in _PARAM3_)"),
|
||||
t("Facebook Instant Games/Player data"),
|
||||
"JsPlatform/Extensions/facebookicon24.png",
|
||||
"JsPlatform/Extensions/facebookicon16.png"
|
||||
)
|
||||
.addParameter("string", 'Data key name (e.g: "Lives")', "", false)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
"Variable with the content to save",
|
||||
"",
|
||||
false
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
"Variable where to store the success message (optional)",
|
||||
"",
|
||||
true
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
"Variable where to error message (optional, if an error occurs)",
|
||||
"",
|
||||
true
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile(
|
||||
"Extensions/FacebookInstantGames/facebookinstantgamestools.js"
|
||||
)
|
||||
.setFunctionName("gdjs.evtTools.facebookInstantGames.setPlayerData");
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
"LoadPlayerData",
|
||||
t("Load player data"),
|
||||
t("Load the player data with the given key in a variable"),
|
||||
t("Load player data with key _PARAM0_ in _PARAM1_ (or error in _PARAM2_)"),
|
||||
t("Facebook Instant Games/Player data"),
|
||||
"JsPlatform/Extensions/facebookicon24.png",
|
||||
"JsPlatform/Extensions/facebookicon16.png"
|
||||
)
|
||||
.addParameter("string", t('Data key name (e.g: "Lives")'), "", false)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
t("Variable where to store loaded data"),
|
||||
"",
|
||||
false
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
t("Variable where to error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile(
|
||||
"Extensions/FacebookInstantGames/facebookinstantgamestools.js"
|
||||
)
|
||||
.setFunctionName("gdjs.evtTools.facebookInstantGames.loadPlayerData");
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
"SavePlayerScore",
|
||||
t("Save player score"),
|
||||
t("Save the score, and optionally the content of the given variable in the player score, for the given metadata."),
|
||||
t("In leaderboard _PARAM0_, save score _PARAM1_ for the player and extra data from _PARAM2_ (store success message in _PARAM3_ or error in _PARAM4_)"),
|
||||
t("Facebook Instant Games/Leaderboards"),
|
||||
"JsPlatform/Extensions/facebookicon24.png",
|
||||
"JsPlatform/Extensions/facebookicon16.png"
|
||||
)
|
||||
.addParameter("string", 'Leaderboard name (e.g: "PlayersBestTimes")', "", false)
|
||||
.addParameter("expression", 'Score to register for the player', "", false)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
"Optional variable with metadata to save",
|
||||
"",
|
||||
true
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
"Variable where to store the success message (optional)",
|
||||
"",
|
||||
true
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
"Variable where to error message (optional, if an error occurs)",
|
||||
"",
|
||||
true
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile(
|
||||
"Extensions/FacebookInstantGames/facebookinstantgamestools.js"
|
||||
)
|
||||
.setFunctionName("gdjs.evtTools.facebookInstantGames.setPlayerScore");
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
"LoadPlayerEntry",
|
||||
t("Load player entry"),
|
||||
t("Load the player entry in the given leaderboard"),
|
||||
t("Load player entry from leaderboard _PARAM0_. Set rank in _PARAM1_, score in _PARAM2_ (extra data if any in _PARAM3_ and error in _PARAM4_)"),
|
||||
t("Facebook Instant Games/Leaderboards"),
|
||||
"JsPlatform/Extensions/facebookicon24.png",
|
||||
"JsPlatform/Extensions/facebookicon16.png"
|
||||
)
|
||||
.addParameter("string", 'Leaderboard name (e.g: "PlayersBestTimes")', "", false)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
t("Variable where to store the player rank (of -1 if not ranked)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
t("Variable where to store the player score (of -1 if no score)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
t("Variable where to store extra data (if any)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
t("Variable where to error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile(
|
||||
"Extensions/FacebookInstantGames/facebookinstantgamestools.js"
|
||||
)
|
||||
.setFunctionName("gdjs.evtTools.facebookInstantGames.getPlayerEntry");
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
"PlayerId",
|
||||
t("Player identifier"),
|
||||
t("Get the player unique identifier"),
|
||||
t("Facebook Instant Games"),
|
||||
"JsPlatform/Extensions/facebookicon16.png"
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile(
|
||||
"Extensions/FacebookInstantGames/facebookinstantgamestools.js"
|
||||
)
|
||||
.setFunctionName("gdjs.evtTools.facebookInstantGames.getPlayerId");
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
"PlayerName",
|
||||
t("Player name"),
|
||||
t("Get the player name"),
|
||||
t("Facebook Instant Games"),
|
||||
"JsPlatform/Extensions/facebookicon16.png"
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile(
|
||||
"Extensions/FacebookInstantGames/facebookinstantgamestools.js"
|
||||
)
|
||||
.setFunctionName("gdjs.evtTools.facebookInstantGames.getPlayerName");
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(extension) { return []; },
|
||||
};
|
183
Extensions/FacebookInstantGames/facebookinstantgamestools.js
Normal file
183
Extensions/FacebookInstantGames/facebookinstantgamestools.js
Normal file
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* @memberof gdjs.evtTools
|
||||
* @class facebookInstantGames
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
gdjs.evtTools.facebookInstantGames = {};
|
||||
|
||||
gdjs.evtTools.facebookInstantGames.getPlayerId = function() {
|
||||
if (typeof FBInstant === "undefined") return "";
|
||||
|
||||
return FBInstant.player.getID() || "";
|
||||
};
|
||||
|
||||
gdjs.evtTools.facebookInstantGames.getPlayerName = function() {
|
||||
if (typeof FBInstant === "undefined") return "";
|
||||
|
||||
return FBInstant.player.getName() || "";
|
||||
};
|
||||
|
||||
gdjs.evtTools.facebookInstantGames.loadPlayerData = function(
|
||||
key,
|
||||
successVariable,
|
||||
errorVariable
|
||||
) {
|
||||
if (typeof FBInstant === "undefined") return;
|
||||
errorVariable.setString("");
|
||||
successVariable.setString("");
|
||||
|
||||
FBInstant.player
|
||||
.getDataAsync([key])
|
||||
.then(function(data) {
|
||||
gdjs.evtTools.network.jsonToVariableStructure(data[key], successVariable);
|
||||
})
|
||||
.catch(function(error) {
|
||||
errorVariable.setString(error.message || "Unknown error");
|
||||
});
|
||||
};
|
||||
|
||||
gdjs.evtTools.facebookInstantGames.setPlayerData = function(
|
||||
key,
|
||||
variable,
|
||||
successVariable,
|
||||
errorVariable
|
||||
) {
|
||||
if (typeof FBInstant === "undefined") return;
|
||||
errorVariable.setString("");
|
||||
successVariable.setString("");
|
||||
|
||||
var data = {};
|
||||
data[key] = gdjs.evtTools.network.variableStructureToJSON(variable);
|
||||
|
||||
FBInstant.player
|
||||
.setDataAsync(data)
|
||||
.then(function() {
|
||||
successVariable.setString("Player data saved");
|
||||
})
|
||||
.catch(function(error) {
|
||||
errorVariable.setString(error.message || "Unknown error");
|
||||
});
|
||||
};
|
||||
|
||||
gdjs.evtTools.facebookInstantGames.setPlayerScore = function(
|
||||
leaderboardName,
|
||||
score,
|
||||
extraDataVariable,
|
||||
successVariable,
|
||||
errorVariable
|
||||
) {
|
||||
if (typeof FBInstant === "undefined") return;
|
||||
errorVariable.setString("");
|
||||
successVariable.setString("");
|
||||
|
||||
var data = gdjs.evtTools.network.variableStructureToJSON(extraDataVariable);
|
||||
|
||||
FBInstant.getLeaderboardAsync(leaderboardName)
|
||||
.then(function(leaderboard) {
|
||||
return leaderboard.setScoreAsync(score, data);
|
||||
})
|
||||
.then(function() {
|
||||
successVariable.setString("Player score saved");
|
||||
})
|
||||
.catch(function(error) {
|
||||
errorVariable.setString(error.message || "Unknown error");
|
||||
});
|
||||
};
|
||||
|
||||
gdjs.evtTools.facebookInstantGames.getPlayerEntry = function(
|
||||
leaderboardName,
|
||||
rankVariable,
|
||||
scoreVariable,
|
||||
extraDataVariable,
|
||||
errorVariable
|
||||
) {
|
||||
if (typeof FBInstant === "undefined") return;
|
||||
errorVariable.setString("");
|
||||
extraDataVariable.setString("");
|
||||
|
||||
FBInstant.getLeaderboardAsync(leaderboardName)
|
||||
.then(function(leaderboard) {
|
||||
return leaderboard.getPlayerEntryAsync();
|
||||
})
|
||||
.then(function(entry) {
|
||||
rankVariable.setNumber(entry.getRank() === null ? -1 : entry.getRank());
|
||||
scoreVariable.setNumber(entry.getScore() === null ? -1 : entry.getScore());
|
||||
gdjs.evtTools.network.jsonToVariableStructure(
|
||||
entry.getExtraData(),
|
||||
extraDataVariable
|
||||
);
|
||||
})
|
||||
.catch(function(error) {
|
||||
errorVariable.setString(error.message || "Unknown error");
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof FBInstant === "undefined" && typeof window !== "undefined") {
|
||||
console.log("Creating a mocked version of Facebook Instant Games");
|
||||
|
||||
function MockedLeaderboard() {
|
||||
this._playerScore = null;
|
||||
this._playerRank = null;
|
||||
this._playerExtraData = null;
|
||||
}
|
||||
MockedLeaderboard.prototype.setScoreAsync = function(score, extraData) {
|
||||
var that = this;
|
||||
return new Promise(function(resolve) {
|
||||
that._playerScore = score;
|
||||
that._playerRank = 1;
|
||||
that._playerExtraData = extraData;
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
MockedLeaderboard.prototype.getPlayerEntryAsync = function() {
|
||||
var that = this;
|
||||
return new Promise(function(resolve) {
|
||||
resolve({
|
||||
getScore: function() {
|
||||
return that._playerScore;
|
||||
},
|
||||
getRank: function() {
|
||||
return that._playerRank;
|
||||
},
|
||||
getExtraData: function() {
|
||||
return that._playerExtraData;
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var FBInstantMock = {
|
||||
_mockedPlayerData: {},
|
||||
_mockedLeaderboards: {},
|
||||
player: {
|
||||
getName: function() {
|
||||
return "Fake player name";
|
||||
},
|
||||
getID: function() {
|
||||
return "12345678";
|
||||
},
|
||||
getDataAsync: function(key) {
|
||||
return new Promise(function(resolve) {
|
||||
resolve(FBInstantMock._mockedPlayerData);
|
||||
});
|
||||
},
|
||||
setDataAsync: function(data) {
|
||||
return new Promise(function(resolve) {
|
||||
FBInstantMock._mockedPlayerData = data;
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
},
|
||||
getLeaderboardAsync: function(leaderboardName) {
|
||||
return new Promise(function(resolve) {
|
||||
FBInstantMock._mockedLeaderboards[leaderboardName] =
|
||||
FBInstantMock._mockedLeaderboards[leaderboardName] ||
|
||||
new MockedLeaderboard();
|
||||
resolve(FBInstantMock._mockedLeaderboards[leaderboardName]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
window.FBInstant = FBInstantMock;
|
||||
}
|
File diff suppressed because one or more lines are too long
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* @namespace gdjs.evtTools
|
||||
* @class facebookInstantGames
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
gdjs.evtTools.facebookInstantGames = {};
|
||||
|
||||
gdjs.evtTools.facebookInstantGames.getPlayerId = function() {
|
||||
if (typeof FBInstant === 'undefined') return;
|
||||
|
||||
return FBInstant.player.getID() || '';
|
||||
};
|
||||
|
||||
gdjs.evtTools.facebookInstantGames.getPlayerName = function() {
|
||||
if (typeof FBInstant === 'undefined') return;
|
||||
|
||||
return FBInstant.player.getName() || '';
|
||||
};
|
@@ -17,7 +17,8 @@ void DeclareInventoryExtension(gd::PlatformExtension& extension) {
|
||||
_("Provides actions and conditions to add an inventory to your game, "
|
||||
"with items in memory."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("all-features/inventory");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -16,7 +16,7 @@ gdjs.InventoryManager.get = function(runtimeScene, name) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @namespace gdjs.evtTools
|
||||
* @memberof gdjs.evtTools
|
||||
* @class inventory
|
||||
* @static
|
||||
* @private
|
||||
|
@@ -11,12 +11,14 @@ This project is released under the MIT License.
|
||||
#include <iostream>
|
||||
|
||||
void DeclareLinkedObjectsExtension(gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"LinkedObjects",
|
||||
_("Linked objects"),
|
||||
_("This Extension can virtually link two objects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"LinkedObjects",
|
||||
_("Linked objects"),
|
||||
_("This Extension can virtually link two objects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/linked-objects");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
|
||||
|
@@ -6,7 +6,7 @@ Copyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)
|
||||
/**
|
||||
* Manages the links between objects.
|
||||
*
|
||||
* @namespace gdjs
|
||||
* @memberof gdjs
|
||||
* @class LinksManager
|
||||
* @constructor
|
||||
*/
|
||||
@@ -17,9 +17,6 @@ gdjs.LinksManager = function()
|
||||
|
||||
/**
|
||||
* Get the links manager of a scene.
|
||||
*
|
||||
* @method getManager
|
||||
* @static
|
||||
*/
|
||||
gdjs.LinksManager.getManager = function(runtimeScene) {
|
||||
if (!runtimeScene.linkedObjectsManager) { //Create the shared manager if necessary.
|
||||
@@ -77,7 +74,7 @@ gdjs.LinksManager.prototype.removeLinkBetween = function(objA, objB) {
|
||||
};
|
||||
|
||||
/**
|
||||
* @namespace gdjs.evtTools
|
||||
* @memberof gdjs.evtTools
|
||||
* @class linkedObjects
|
||||
* @static
|
||||
* @private
|
||||
|
@@ -14,12 +14,14 @@ This project is released under the MIT License.
|
||||
#include "PanelSpriteObject.h"
|
||||
|
||||
void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation("PanelSpriteObject",
|
||||
_("Panel Sprite (9-patch) Object"),
|
||||
_("This Extension enables the use of Panel "
|
||||
"Sprite (\"9-patch\") Objects."),
|
||||
"Victor Levasseur and Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("PanelSpriteObject",
|
||||
_("Panel Sprite (9-patch) Object"),
|
||||
_("This Extension enables the use of Panel "
|
||||
"Sprite (\"9-patch\") Objects."),
|
||||
"Victor Levasseur and Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/panel_sprite");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<PanelSpriteObject>(
|
||||
"PanelSprite",
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* @class PanelSpriteRuntimeObject
|
||||
* @extends RuntimeObject
|
||||
* @namespace gdjs
|
||||
* @memberof gdjs
|
||||
*/
|
||||
gdjs.PanelSpriteRuntimeObject = function(runtimeScene, objectData)
|
||||
{
|
||||
|
@@ -20,7 +20,8 @@ void DeclareParticleSystemExtension(gd::PlatformExtension& extension) {
|
||||
_("Particle system"),
|
||||
_("This Extension can display a large number of small particles."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/particles_emitter");
|
||||
|
||||
// Declaration of all objects available
|
||||
{
|
||||
|
@@ -237,7 +237,8 @@ void ParticleEmitterObject::DoSerializeTo(
|
||||
ParticleEmitterBase::SerializeParticleEmitterBaseTo(element);
|
||||
}
|
||||
|
||||
void ParticleEmitterBase::SerializeParticleEmitterBaseTo(gd::SerializerElement& element) const {
|
||||
void ParticleEmitterBase::SerializeParticleEmitterBaseTo(
|
||||
gd::SerializerElement& element) const {
|
||||
element.SetAttribute("tank", tank);
|
||||
element.SetAttribute("flow", flow);
|
||||
element.SetAttribute("emitterForceMin", emitterForceMin);
|
||||
|
@@ -89,9 +89,7 @@ class GD_EXTENSION_API ParticleEmitterBase {
|
||||
void SetEmitterZDirection(float newValue);
|
||||
void SetEmitterAngleA(float newValue);
|
||||
void SetEmitterAngleB(float newValue);
|
||||
void SetConeSprayAngle(float newValue) {
|
||||
SetEmitterAngleB(newValue);
|
||||
};
|
||||
void SetConeSprayAngle(float newValue) { SetEmitterAngleB(newValue); };
|
||||
void SetZoneRadius(float newValue);
|
||||
void SetParticleGravityX(float newValue);
|
||||
void SetParticleGravityY(float newValue);
|
||||
@@ -207,9 +205,7 @@ class GD_EXTENSION_API ParticleEmitterBase {
|
||||
float GetEmitterZDirection() const { return emitterZDirection; };
|
||||
float GetEmitterAngleA() const { return emitterAngleA; };
|
||||
float GetEmitterAngleB() const { return emitterAngleB; };
|
||||
float GetConeSprayAngle() const {
|
||||
return GetEmitterAngleB();
|
||||
};
|
||||
float GetConeSprayAngle() const { return GetEmitterAngleB(); };
|
||||
float GetZoneRadius() const { return zoneRadius; };
|
||||
float GetParticleGravityX() const { return particleGravityX; };
|
||||
float GetParticleGravityY() const { return particleGravityY; };
|
||||
@@ -265,9 +261,11 @@ class GD_EXTENSION_API ParticleEmitterBase {
|
||||
void SetRenderingAlpha() { additive = false; };
|
||||
|
||||
protected:
|
||||
virtual void UnserializeParticleEmitterBaseFrom(const gd::SerializerElement& element);
|
||||
virtual void UnserializeParticleEmitterBaseFrom(
|
||||
const gd::SerializerElement& element);
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual void SerializeParticleEmitterBaseTo(gd::SerializerElement& element) const;
|
||||
virtual void SerializeParticleEmitterBaseTo(
|
||||
gd::SerializerElement& element) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@@ -199,6 +199,10 @@ gdjs.ParticleEmitterObjectPixiRenderer.prototype.setColor = function(r1, g1, b1,
|
||||
this.emitter.startColor.value.r = r1;
|
||||
this.emitter.startColor.value.g = g1;
|
||||
this.emitter.startColor.value.b = b1;
|
||||
this.emitter.startColor.next = this.emitter.startColor.next || {
|
||||
time : 1,
|
||||
value : {}
|
||||
};
|
||||
this.emitter.startColor.next.value.r = r2;
|
||||
this.emitter.startColor.next.value.g = g2;
|
||||
this.emitter.startColor.next.value.b = b2;
|
||||
|
@@ -381,6 +381,24 @@ gdjs.ParticleEmitterObject.prototype.setParticleBlue2 = function(blue){
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.ParticleEmitterObject.prototype.setParticleColor1 = function(rgbColor){
|
||||
var colors = rgbColor.split(";");
|
||||
if ( colors.length < 3 ) return;
|
||||
|
||||
this.setParticleRed1(parseInt(colors[0], 10));
|
||||
this.setParticleGreen1(parseInt(colors[1], 10));
|
||||
this.setParticleBlue1(parseInt(colors[2], 10));
|
||||
};
|
||||
|
||||
gdjs.ParticleEmitterObject.prototype.setParticleColor2 = function(rgbColor){
|
||||
var colors = rgbColor.split(";");
|
||||
if ( colors.length < 3 ) return;
|
||||
|
||||
this.setParticleRed2(parseInt(colors[0], 10));
|
||||
this.setParticleGreen2(parseInt(colors[1], 10));
|
||||
this.setParticleBlue2(parseInt(colors[2], 10));
|
||||
};
|
||||
|
||||
gdjs.ParticleEmitterObject.prototype.getParticleSize1 = function(){
|
||||
return this.size1;
|
||||
};
|
||||
|
@@ -16,7 +16,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
_("Pathfinding behavior"),
|
||||
_("Compute paths for objects avoiding obstacles."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/behaviors/pathfinding");
|
||||
|
||||
{
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
|
@@ -10,8 +10,7 @@ Copyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)
|
||||
* ( see gdjs.PathfindingRuntimeBehavior.obstaclesManagers ).
|
||||
*
|
||||
* @class PathfindingObstaclesManager
|
||||
* @namespace gdjs
|
||||
* @constructor
|
||||
* @memberof gdjs
|
||||
*/
|
||||
gdjs.PathfindingObstaclesManager = function(runtimeScene)
|
||||
{
|
||||
@@ -21,9 +20,6 @@ gdjs.PathfindingObstaclesManager = function(runtimeScene)
|
||||
|
||||
/**
|
||||
* Get the obstacles manager of a scene.
|
||||
*
|
||||
* @method getManager
|
||||
* @static
|
||||
*/
|
||||
gdjs.PathfindingObstaclesManager.getManager = function(runtimeScene) {
|
||||
if (!runtimeScene.pathfindingObstaclesManager) { //Create the shared manager if necessary.
|
||||
@@ -35,8 +31,6 @@ gdjs.PathfindingObstaclesManager.getManager = function(runtimeScene) {
|
||||
|
||||
/**
|
||||
* Add a obstacle to the list of existing obstacles.
|
||||
*
|
||||
* @method addObstacle
|
||||
*/
|
||||
gdjs.PathfindingObstaclesManager.prototype.addObstacle = function(pathfindingObstacleBehavior) {
|
||||
this._obstaclesHSHG.addObject(pathfindingObstacleBehavior);
|
||||
@@ -45,8 +39,6 @@ gdjs.PathfindingObstaclesManager.prototype.addObstacle = function(pathfindingObs
|
||||
/**
|
||||
* Remove a obstacle from the list of existing obstacles. Be sure that the obstacle was
|
||||
* added before.
|
||||
*
|
||||
* @method removeObstacle
|
||||
*/
|
||||
gdjs.PathfindingObstaclesManager.prototype.removeObstacle = function(pathfindingObstacleBehavior) {
|
||||
this._obstaclesHSHG.removeObject(pathfindingObstacleBehavior);
|
||||
@@ -55,9 +47,8 @@ gdjs.PathfindingObstaclesManager.prototype.removeObstacle = function(pathfinding
|
||||
/**
|
||||
* Tool class which represents a simple point with a radius and a getAABB method.
|
||||
* @class Vertex
|
||||
* @namespace gdjs.PathfindingObstaclesManager
|
||||
* @memberof gdjs.PathfindingObstaclesManager
|
||||
* @private
|
||||
* @constructor
|
||||
*/
|
||||
gdjs.PathfindingObstaclesManager.Vertex = function(x,y,radius) {
|
||||
this.x = x;
|
||||
@@ -67,7 +58,6 @@ gdjs.PathfindingObstaclesManager.Vertex = function(x,y,radius) {
|
||||
|
||||
/**
|
||||
* Return an axis aligned bouding box for the vertex.
|
||||
* @method getAABB
|
||||
*/
|
||||
gdjs.PathfindingObstaclesManager.Vertex.prototype.getAABB = function(){
|
||||
var rad = this.radius, x = this.x, y = this.y;
|
||||
@@ -81,7 +71,6 @@ gdjs.PathfindingObstaclesManager.Vertex.prototype.getAABB = function(){
|
||||
* @param radius The radius of the search
|
||||
* @param result If defined, the obstacles near the object will be inserted into result (Using the identifier of their owner object as key).
|
||||
* @return If result is not defined, an array with all obstacles near the position. Otherwise, nothing is returned.
|
||||
* @method getAllObstaclesAround
|
||||
*/
|
||||
gdjs.PathfindingObstaclesManager.prototype.getAllObstaclesAround = function(x, y, radius, result) {
|
||||
var vertex = new gdjs.PathfindingObstaclesManager.Vertex(x,y, radius);
|
||||
@@ -95,8 +84,7 @@ gdjs.PathfindingObstaclesManager.prototype.getAllObstaclesAround = function(x, y
|
||||
* considered as a obstacle by objects having Pathfinding Behavior.
|
||||
*
|
||||
* @class PathfindingObstacleRuntimeBehavior
|
||||
* @namespace gdjs
|
||||
* @constructor
|
||||
* @memberof gdjs
|
||||
*/
|
||||
gdjs.PathfindingObstacleRuntimeBehavior = function(runtimeScene, behaviorData, owner)
|
||||
{
|
||||
|
@@ -8,7 +8,7 @@ Copyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)
|
||||
* follow a path computed to avoid obstacles.
|
||||
*
|
||||
* @class PathfindingRuntimeBehavior
|
||||
* @constructor
|
||||
* @memberof gdjs
|
||||
*/
|
||||
gdjs.PathfindingRuntimeBehavior = function(runtimeScene, behaviorData, owner)
|
||||
{
|
||||
@@ -169,7 +169,6 @@ gdjs.PathfindingRuntimeBehavior.prototype.getDestinationY = function() {
|
||||
|
||||
/**
|
||||
* Return true if the latest call to moveTo succeeded.
|
||||
* @method pathFound
|
||||
*/
|
||||
gdjs.PathfindingRuntimeBehavior.prototype.pathFound = function() {
|
||||
return this._pathFound;
|
||||
@@ -177,7 +176,6 @@ gdjs.PathfindingRuntimeBehavior.prototype.pathFound = function() {
|
||||
|
||||
/**
|
||||
* Return true if the object reached its destination.
|
||||
* @method destinationReached
|
||||
*/
|
||||
gdjs.PathfindingRuntimeBehavior.prototype.destinationReached = function() {
|
||||
return this._reachedEnd;
|
||||
@@ -185,7 +183,6 @@ gdjs.PathfindingRuntimeBehavior.prototype.destinationReached = function() {
|
||||
|
||||
/**
|
||||
* Compute and move on the path to the specified destination.
|
||||
* @method moveTo
|
||||
*/
|
||||
gdjs.PathfindingRuntimeBehavior.prototype.moveTo = function(runtimeScene, x, y)
|
||||
{
|
||||
@@ -319,7 +316,7 @@ gdjs.PathfindingRuntimeBehavior.prototype.doStepPostEvents = function(runtimeSce
|
||||
/**
|
||||
* Internal tool class representing a node when looking for a path
|
||||
* @private
|
||||
* @namespace gdjs.PathfindingRuntimeBehavior
|
||||
* @memberof gdjs.PathfindingRuntimeBehavior
|
||||
* @class Node
|
||||
*/
|
||||
gdjs.PathfindingRuntimeBehavior.Node = function(xPos, yPos)
|
||||
@@ -341,8 +338,7 @@ gdjs.PathfindingRuntimeBehavior.Node = function(xPos, yPos)
|
||||
/**
|
||||
* Compute the euclidean distance between two positions.
|
||||
* @private
|
||||
* @namespace gdjs.PathfindingRuntimeBehavior
|
||||
* @method euclideanDistance
|
||||
* @memberof gdjs.PathfindingRuntimeBehavior
|
||||
*/
|
||||
gdjs.PathfindingRuntimeBehavior.euclideanDistance = function(a, b)
|
||||
{
|
||||
@@ -352,8 +348,7 @@ gdjs.PathfindingRuntimeBehavior.euclideanDistance = function(a, b)
|
||||
/**
|
||||
* Compute the taxi distance between two positions.
|
||||
* @private
|
||||
* @namespace gdjs.PathfindingRuntimeBehavior
|
||||
* @method manhattanDistance
|
||||
* @memberof gdjs.PathfindingRuntimeBehavior
|
||||
*/
|
||||
gdjs.PathfindingRuntimeBehavior.manhattanDistance = function(a, b)
|
||||
{
|
||||
@@ -361,7 +356,7 @@ gdjs.PathfindingRuntimeBehavior.manhattanDistance = function(a, b)
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Internal tool class containing the structures used by A* and members functions related
|
||||
* Internal tool class containing the structures used by A* and members functions related
|
||||
* to them.
|
||||
*/
|
||||
gdjs.PathfindingRuntimeBehavior.SearchContext = function()
|
||||
|
@@ -20,7 +20,8 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
_("This extension enables the movement of objects as if they are subject "
|
||||
"to the laws of physics."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/behaviors/physics");
|
||||
|
||||
{
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
|
@@ -6,6 +6,8 @@ Copyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)
|
||||
/**
|
||||
* Manage the common objects shared by objects having a
|
||||
* physics behavior.
|
||||
* @memberof gdjs
|
||||
* @class PhysicsSharedData
|
||||
*/
|
||||
gdjs.PhysicsSharedData = function(runtimeScene, sharedData)
|
||||
{
|
||||
@@ -70,9 +72,6 @@ gdjs.PhysicsSharedData = function(runtimeScene, sharedData)
|
||||
|
||||
/**
|
||||
* Get the shared data for a scene.
|
||||
*
|
||||
* @method getSharedData
|
||||
* @static
|
||||
*/
|
||||
gdjs.PhysicsSharedData.getSharedData = function(runtimeScene, name) {
|
||||
if (!runtimeScene.physicsSharedData) { //Create the shared data if necessary.
|
||||
@@ -162,9 +161,6 @@ gdjs.PhysicsRuntimeBehavior.prototype.ownerRemovedFromScene = function() {
|
||||
/**
|
||||
* Return a Box2D.b2Vec2 with the specified coordinates.
|
||||
* Should be used instead of doing 'new Box2D.b2Vec2(x, y)'.
|
||||
*
|
||||
* @method b2Vec2
|
||||
* @private
|
||||
*/
|
||||
gdjs.PhysicsRuntimeBehavior.prototype.b2Vec2 = function(x, y) {
|
||||
this._tempb2Vec2.set_x(x);
|
||||
|
@@ -18,7 +18,8 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
_("This Extension enables the use of controllable objects that can run "
|
||||
"and jump on platforms."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/behaviors/platformer");
|
||||
|
||||
{
|
||||
gd::BehaviorMetadata& aut = extension.AddBehavior(
|
||||
|
@@ -23,12 +23,6 @@ class PlatformBehaviorJsExtension : public gd::PlatformExtension {
|
||||
* contains: objects, actions, conditions and expressions.
|
||||
*/
|
||||
PlatformBehaviorJsExtension() {
|
||||
SetExtensionInformation("PlatformBehavior",
|
||||
_("Platform Behavior"),
|
||||
_("Allows to use controllable objects which can "
|
||||
"run and jump on platforms."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
DeclarePlatformBehaviorExtension(*this);
|
||||
|
||||
GetBehaviorMetadata("PlatformBehavior::PlatformBehavior")
|
||||
|
@@ -88,8 +88,22 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.doStepPreEvents = function(runtim
|
||||
if (this._currentSpeed < -this._maxSpeed) this._currentSpeed = -this._maxSpeed;
|
||||
requestedDeltaX += this._currentSpeed*timeDelta;
|
||||
|
||||
//0.2) Track changes in object size
|
||||
|
||||
//Stick the object to the floor if its height has changed.
|
||||
if ( this._isOnFloor && this._oldHeight !== object.getHeight() ) {
|
||||
object.setY(this._floorLastY
|
||||
- object.getHeight()
|
||||
+ (object.getY() - object.getDrawableY())
|
||||
- 1
|
||||
);
|
||||
}
|
||||
this._oldHeight = object.getHeight();
|
||||
|
||||
//0.3) Update list of platforms around/related to the object
|
||||
|
||||
//Compute the list of the objects that will be used
|
||||
this._updatePotentialCollidingObjects(Math.max(requestedDeltaX, this._maxFallingSpeed) );
|
||||
this._updatePotentialCollidingObjects(Math.max(requestedDeltaX, this._maxFallingSpeed*timeDelta) );
|
||||
this._updateOverlappedJumpThru();
|
||||
|
||||
//Check that the floor object still exists and is near the object.
|
||||
@@ -103,19 +117,6 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.doStepPreEvents = function(runtim
|
||||
this._releaseGrabbedPlatform();
|
||||
}
|
||||
|
||||
//0.2) Track changes in object size
|
||||
|
||||
//Stick the object to the floor if its height has changed.
|
||||
if ( this._isOnFloor && this._oldHeight !== object.getHeight() ) {
|
||||
object.setY(this._floorLastY
|
||||
- object.getHeight()
|
||||
+ (object.getY() - object.getDrawableY())
|
||||
- 1
|
||||
);
|
||||
}
|
||||
|
||||
this._oldHeight = object.getHeight();
|
||||
|
||||
//1) X axis:
|
||||
|
||||
//Shift the object according to the floor movement.
|
||||
|
@@ -10,8 +10,7 @@ Copyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)
|
||||
* (see gdjs.PlatformRuntimeBehavior.getManager).
|
||||
*
|
||||
* @class PlatformObjectsManager
|
||||
* @namespace gdjs
|
||||
* @constructor
|
||||
* @memberof gdjs
|
||||
*/
|
||||
gdjs.PlatformObjectsManager = function(runtimeScene, sharedData)
|
||||
{
|
||||
@@ -20,9 +19,6 @@ gdjs.PlatformObjectsManager = function(runtimeScene, sharedData)
|
||||
|
||||
/**
|
||||
* Get the platforms manager of a scene.
|
||||
*
|
||||
* @method getManager
|
||||
* @static
|
||||
*/
|
||||
gdjs.PlatformObjectsManager.getManager = function(runtimeScene) {
|
||||
if (!runtimeScene.platformsObjectsManager) { //Create the shared manager if necessary.
|
||||
@@ -34,8 +30,6 @@ gdjs.PlatformObjectsManager.getManager = function(runtimeScene) {
|
||||
|
||||
/**
|
||||
* Add a platform to the list of existing platforms.
|
||||
*
|
||||
* @method addPlatform
|
||||
*/
|
||||
gdjs.PlatformObjectsManager.prototype.addPlatform = function(platformBehavior) {
|
||||
this._platformRBush.insert(platformBehavior);
|
||||
@@ -44,8 +38,6 @@ gdjs.PlatformObjectsManager.prototype.addPlatform = function(platformBehavior) {
|
||||
/**
|
||||
* Remove a platform from the list of existing platforms. Be sure that the platform was
|
||||
* added before.
|
||||
*
|
||||
* @method removePlatform
|
||||
*/
|
||||
gdjs.PlatformObjectsManager.prototype.removePlatform = function(platformBehavior) {
|
||||
this._platformRBush.remove(platformBehavior);
|
||||
@@ -53,10 +45,9 @@ gdjs.PlatformObjectsManager.prototype.removePlatform = function(platformBehavior
|
||||
|
||||
/**
|
||||
* Returns all the platforms around the specified object.
|
||||
* @param object {gdjs.RuntimeObject} The object
|
||||
* @param maxMovementLength The maximum distance, in pixels, the object is going to do.
|
||||
* @param {gdjs.RuntimeObject} object The object
|
||||
* @param {number} maxMovementLength The maximum distance, in pixels, the object is going to do.
|
||||
* @return An array with all platforms near the object.
|
||||
* @method getAllPlatformsAround
|
||||
*/
|
||||
gdjs.PlatformObjectsManager.prototype.getAllPlatformsAround = function(object, maxMovementLength, result) {
|
||||
var ow = object.getWidth();
|
||||
@@ -79,8 +70,7 @@ gdjs.PlatformObjectsManager.prototype.getAllPlatformsAround = function(object, m
|
||||
* considered as a platform by objects having PlatformerObject Behavior.
|
||||
*
|
||||
* @class PlatformRuntimeBehavior
|
||||
* @namespace gdjs
|
||||
* @constructor
|
||||
* @memberof gdjs
|
||||
*/
|
||||
gdjs.PlatformRuntimeBehavior = function(runtimeScene, behaviorData, owner)
|
||||
{
|
||||
|
@@ -10,12 +10,14 @@ This project is released under the MIT License.
|
||||
#include "ShapePainterObject.h"
|
||||
|
||||
void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"PrimitiveDrawing",
|
||||
_("Primitive drawing"),
|
||||
_("This Extension allows you to draw shapes and manipulate images."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"PrimitiveDrawing",
|
||||
_("Primitive drawing"),
|
||||
_("This Extension allows you to draw shapes and manipulate images."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/shape_painter");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<ShapePainterObject>(
|
||||
"Drawer", //"Drawer" is kept for compatibility with GD<=3.6.76
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* @class ShapePainterRuntimeObject
|
||||
* @extends RuntimeObject
|
||||
* @namespace gdjs
|
||||
* @memberof gdjs
|
||||
*/
|
||||
gdjs.ShapePainterRuntimeObject = function(runtimeScene, objectData)
|
||||
{
|
||||
|
@@ -15,7 +15,8 @@ void DeclareShopifyExtension(gd::PlatformExtension& extension) {
|
||||
_("Interact with products and generate URLs for checkouts with your "
|
||||
"Shopify shop."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/shopify");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -20,7 +20,7 @@ gdjs.ShopifyClientsManager.get = function(runtimeScene, name) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @namespace gdjs.evtTools
|
||||
* @memberof gdjs.evtTools
|
||||
* @class shopify
|
||||
* @static
|
||||
* @private
|
||||
|
@@ -6,7 +6,7 @@ This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
*/
|
||||
gdjs.sk = gdjs.sk || {
|
||||
// Some useful constants
|
||||
@@ -27,7 +27,7 @@ gdjs.sk = gdjs.sk || {
|
||||
/**
|
||||
* The Matrix holds the basic transformation data in a matrix form.
|
||||
*
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class Matrix
|
||||
*/
|
||||
gdjs.sk.Matrix = function(a=1, b=0, tx=0, c=0, d=1, ty=0){
|
||||
@@ -110,7 +110,7 @@ gdjs.sk.Matrix.prototype.str = function(){
|
||||
/**
|
||||
* The Transform is the basic class for transformable objects as bones, slots and armatures.
|
||||
*
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class Transform
|
||||
*/
|
||||
gdjs.sk.Transform = function(x=0, y=0, rot=0, sx=1, sy=1){
|
||||
|
@@ -7,7 +7,7 @@ This project is released under the MIT License.
|
||||
|
||||
|
||||
/**
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class SharedBone
|
||||
*/
|
||||
gdjs.sk.SharedBone = function(){
|
||||
@@ -47,7 +47,7 @@ gdjs.sk.SharedBone.prototype.loadDragonBones = function(boneData){
|
||||
/**
|
||||
* The Bone holds basic transform data in a hierarchy tree.
|
||||
*
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class Bone
|
||||
* @extends gdjs.sk.Transform
|
||||
*/
|
||||
|
@@ -7,7 +7,7 @@ This project is released under the MIT License.
|
||||
|
||||
|
||||
/**
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class SharedSlot
|
||||
*/
|
||||
gdjs.sk.SharedSlot = function(){
|
||||
@@ -157,7 +157,7 @@ gdjs.sk.SharedSlot.prototype.loadDragonBonesSkinData = function(skinDatas, index
|
||||
/**
|
||||
* The Slot display images transformed by animations itself and bones.
|
||||
*
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class Slot
|
||||
* @extends gdjs.sk.Transform
|
||||
*/
|
||||
|
@@ -7,7 +7,7 @@ This project is released under the MIT License.
|
||||
|
||||
|
||||
/**
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class SharedArmature
|
||||
*/
|
||||
gdjs.sk.SharedArmature = function(){
|
||||
@@ -78,7 +78,7 @@ gdjs.sk.SharedArmature.prototype.loadDragonBones = function(armatureData, textur
|
||||
/**
|
||||
* The Armature holds the bones and slots/attachments as well as its animations.
|
||||
*
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class Armature
|
||||
* @extends gdjs.sk.Transform
|
||||
*/
|
||||
@@ -183,7 +183,7 @@ gdjs.sk.Armature.prototype.setRenderers = function(){
|
||||
}
|
||||
}
|
||||
|
||||
if(this.isRoot){
|
||||
if(this.isRoot && this.debugRenderer){
|
||||
this.renderer.addDebugRenderer(this.debugRenderer);
|
||||
}
|
||||
};
|
||||
|
@@ -6,7 +6,7 @@ This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class SharedAnimation
|
||||
*/
|
||||
gdjs.sk.SharedAnimation = function(){
|
||||
@@ -75,7 +75,7 @@ gdjs.sk.SharedAnimation.prototype.loadDragonBones = function(animationData, fps,
|
||||
/**
|
||||
* The Animation holds information to transform bones and slots through time.
|
||||
*
|
||||
* @namespace gdjs.sk
|
||||
* @memberof gdjs.sk
|
||||
* @class Animation
|
||||
*/
|
||||
gdjs.sk.Animation = function(armature){
|
||||
@@ -155,7 +155,7 @@ gdjs.sk.Animation.prototype.update = function(delta){
|
||||
this.finished = true;
|
||||
}
|
||||
|
||||
var frame = this.getFrameAtTime(this.time);
|
||||
var frame = this.finished ? this.shared.duration : this.getFrameAtTime(this.time);
|
||||
|
||||
for(var i=0; i<this.boneAnimators.length; i++){
|
||||
this.boneAnimators[i].setFrame(frame);
|
||||
@@ -937,6 +937,8 @@ gdjs.sk.BlendBoneAnimator.prototype.blend = function(first, second, duration){
|
||||
var x1 = second ? second.shared.channelX.getKey(0) : 0.0;
|
||||
var y1 = second ? second.shared.channelY.getKey(0) : 0.0;
|
||||
var rot1 = second ? second.shared.channelRot.getKey(0) : 0.0;
|
||||
if(rot1 <= 0 && Math.abs(rot1 - rot0) > Math.abs(rot1 + 360 - rot0)) rot1 += 360;
|
||||
if(rot1 >= 0 && Math.abs(rot1 - rot0) > Math.abs(rot1 - 360 - rot0)) rot1 -= 360;
|
||||
var sx1 = second ? second.shared.channelSclX.getKey(0) : 1.0;
|
||||
var sy1 = second ? second.shared.channelSclY.getKey(0) : 1.0;
|
||||
this.channelX.blend(x0, x1, duration);
|
||||
|
@@ -9,7 +9,7 @@ This project is released under the MIT License.
|
||||
/**
|
||||
* The SkeletonRuntimeObject imports and displays skeletal animations files.
|
||||
*
|
||||
* @namespace gdjs
|
||||
* @memberof gdjs
|
||||
* @class SkeletonRuntimeObject
|
||||
* @extends RuntimeObject
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user