Compare commits

...

126 Commits

Author SHA1 Message Date
Florian Rival
dcec81519b Bump newIDE version 2018-08-09 22:19:33 +01:00
Florian Rival
c9c2e41bd9 Delay check for updates to 10 seconds after start and fix default theme preference 2018-08-09 22:05:40 +01:00
Florian Rival
39a6aa2a90 Bump Electron version of exported GDJS games to 2.0.7 2018-08-09 17:48:57 +01:00
Florian Rival
f4532e7e4c Rework preferences to allow users to disable auto-updates (#578) 2018-08-09 17:45:28 +01:00
Florian Rival
9a551673e8 Add explicit dependency on electron with a pinned version for GDJS Electron export 2018-08-07 23:04:44 +01:00
Florian Rival
39887ccc80 Add help links in actions/conditions editor (#576)
* Add support for help links in InstructionParametersEditor.
* Add help paths for extensions/objects/behaviors/instructions
2018-08-07 23:03:50 +01:00
Bouh
97c0761288 Change TextField to SemiControlledTextField in TiledSpriteEditor (#577) 2018-08-07 22:22:51 +01:00
Wend1go
edb33e805f Fix object being selected for insertion on scene after double click #574 (#575)
Clicking the canvas after opening and closing the edit object window via double click no longer adds an object
2018-08-05 11:01:26 +01:00
Florian Rival
e1cfca6930 Bump newIDE version 2018-08-02 20:52:02 +01:00
Florian Rival
26ffcda159 Update Bomb The Crate example 2018-08-02 20:43:51 +01:00
Florian Rival
ee905f4f04 Increase timing before sending HelpFinder analytics 2018-08-02 20:19:01 +01:00
Florian Rival
e4b2fe677b Fix Debugger with Pathfinding behavior (fix #570)
This was due to the HSHG grid being serialized.
Also removed unnecessary circular serialization of behavior owners
2018-08-01 08:52:35 +01:00
Lizard-13
2ed9b058be Add minor fixes on Skeleton extension (#568) 2018-07-31 09:24:39 +01:00
Wend1go
35e3015d66 Fix Pixi flickering on some mobile phones (#566)
* Fix flickering on some mobile devices (Android/Ubuntu Touch)
2018-07-30 16:55:58 +01:00
Florian Rival
b6707d62b2 Fix default font loading for Text object 2018-07-28 12:59:50 +01:00
Florian Rival
76466af778 Bump newIDE version 2018-07-25 22:18:29 +01:00
Florian Rival
193b8fa36e Add/update 7 examples 2018-07-25 22:07:03 +01:00
Florian Rival
1c24e4f14d Fix RuntimeObject::PutAroundAPosition and gdjs.RuntimeObject.prototype.putAround
Positioning was not made using center of object which was making it inconsistent
with other related actions/expressions (like the expression to get distance).
2018-07-25 22:06:34 +01:00
Florian Rival
d0bfb37680 Merge branch 'master' of github.com:4ian/GD 2018-07-23 23:11:53 +01:00
Florian Rival
db480f09d8 Add analytics to help links 2018-07-23 22:35:47 +01:00
Lizard-13
b2b3307ff7 Add RandomInRange, RandomFloat and other random functions (#558) 2018-07-21 19:06:26 +01:00
Florian Rival
17754d4fe5 Add bomb-the-crate example 2018-07-20 17:20:34 +01:00
Florian Rival
0f912472ce Fix opening of HelpIcon links in browser 2018-07-20 17:00:30 +01:00
Florian Rival
8c13b051ad Fix ProjectTitlebar not updating according to the project file path/url 2018-07-20 13:48:11 +01:00
Florian Rival
268075b8bc Don't display intro dialog if a project is opened at startup 2018-07-20 13:37:30 +01:00
Florian Rival
23e899d93d Add support for opening a file from command line option or from url "project" option 2018-07-20 13:26:02 +01:00
Florian Rival
1a76ad9069 Add center-object-within-another example 2018-07-20 08:53:16 +01:00
Florian Rival
1ac26ab8ce Add isometric game example (thanks Mickael Hoarau!) 2018-07-19 20:57:03 +01:00
Wend1go
69fa249db5 Allow to double click to edit object and add Duplicate item menu (#545)
* Open "edit Object" dialog via double click on object
* Add "Duplicate" option to context menu of object list
2018-07-19 14:10:58 +01:00
Florian Rival
f31b46cb14 Update links in README 2018-07-18 14:39:37 +01:00
Todor Imreorov
9e5ca5fb0b Add text field to rename object from object editor (#547) 2018-07-16 23:25:49 +01:00
Lizard-13
b64eeebcbe Add missing functions and bugfix for particles (#555)
* Add missing functions and bugfix for particles

* parseInt in base 10
2018-07-16 23:03:45 +01:00
Lizard-13
c9ae252ae8 Avoid potential errors by using parseInt in base 10 on sprite color (#557) 2018-07-16 23:02:41 +01:00
Florian Rival
ca789c7b0b Fix PlatformerObject behavior not properly staying on floor after object resize 2018-07-12 23:11:24 +01:00
Florian Rival
a142472ea6 Bump newIDE version 2018-07-11 23:29:17 +01:00
Florian Rival
d0c1f7fe03 Fix Facebook Instant Games extension icons and action groups 2018-07-11 23:28:59 +01:00
Florian Rival
6680682001 Bump newIDE version 2018-07-11 22:32:28 +01:00
Florian Rival
91ff59e846 Switch back to ES5 for JsExtension.js 2018-07-11 22:28:31 +01:00
Florian Rival
65aa60e726 Bump newIDE version 2018-07-11 22:17:04 +01:00
Florian Rival
5bb6150861 Add various help links 2018-07-11 22:16:29 +01:00
Florian Rival
6b850e82e7 Add extensions sanity tests 2018-07-11 19:33:47 +01:00
Florian Rival
400c956c2a Expose more features of Facebook Instant Games 2018-07-10 23:31:56 +01:00
Florian Rival
896446f640 Fix missing calls to t("...") in ExampleJsExtension 2018-07-09 22:21:20 +01:00
Wend1go
c8f526e726 Fix getting stuck in camera panning mode bug (#549) 2018-07-08 22:11:25 +01:00
Florian Rival
8bc6ea0744 Exclude extensions named *Example* from newIDE (only in non dev environment) 2018-07-08 19:00:32 +01:00
Florian Rival
215cb0b859 Merge pull request #544 from 4ian/feature/js-extension-dot-js
Add support for extensions declared in JavaScript
2018-07-06 19:39:21 +01:00
Florian Rival
0d9e31f986 Remove console.log 2018-07-06 19:36:39 +01:00
Florian Rival
0019da90c7 Update documentation about implementing JavaScript extensions 2018-07-05 23:38:51 +01:00
Florian Rival
dc870d55ac Update documentation about declaring JavaScript extensions 2018-07-05 00:15:22 +01:00
Florian Rival
df1fff36e4 Update GDJS documentation to add a index page and generate it from GenerateAllDocs script 2018-07-04 23:24:37 +01:00
Florian Rival
5da334a38e Remove yuidoc 2018-07-04 22:37:05 +01:00
Florian Rival
3be5d85733 Update GDJS docs to use JSDoc 2018-07-04 22:26:02 +01:00
Florian Rival
4c62bc2f33 Add comments about GetCodeExtraInformation 2018-07-04 00:32:37 +01:00
Florian Rival
57fbe470b7 Add ExampleJsExtension 2018-07-04 00:20:03 +01:00
Florian Rival
25abff997e Add InitialInstance.SetRaw(Float|String)Property and fix ObjectMetadata constructed with object blueprint 2018-07-04 00:16:42 +01:00
Florian Rival
97ced4145f Add alternative way to call AddObject on an extension using a blueprint object
Also remove dead code
2018-07-01 22:52:18 +01:00
Todor Imreorov
1d7f8958fc Add set folder button in Piskel (#543) 2018-06-29 11:19:47 +01:00
Florian Rival
373c55ddc5 Fix flowtyping 2018-06-29 00:17:16 +01:00
Florian Rival
8e0783e45f Load JsExtensions.js in BrowserJsExtensionsLoader 2018-06-29 00:09:46 +01:00
Florian Rival
22b977fd0e [WIP] Add supports for full JS extensions (JsExtension.js)
Convert FacebookInstantGames to it
2018-06-29 00:08:55 +01:00
Florian Rival
f9925943a3 Fix FacebookInstantGames extension 2018-06-28 22:26:17 +01:00
Florian Rival
26b6c8c6aa Fix test 2018-06-27 09:45:19 +01:00
Florian Rival
ff1fec7c5c Merge pull request #535 from 4ian/feature/profiler
Add basic Profiler for GDevelop 5
2018-06-25 22:25:41 +01:00
Nnarol
97aeafc4c3 Fix compilation issue on Windows due to a windows.h macro (#538)
windows.h defines "Yield" to be empty, which invalidates the definition of wxThread::Yield().
2018-06-25 22:24:57 +01:00
Florian Rival
5468ea19b3 Fix profiler not stopped (and user unable to get results) when changing scene 2018-06-25 21:50:55 +01:00
Florian Rival
4ce2ba08ef Add EventsContextAnalyzer and EventsContextAnalyzerDialog to use it in newIDE 2018-06-25 21:15:12 +01:00
Florian Rival
561ef0434f Refactor parameters type testing into ParameterMetadata::IsExpression 2018-06-24 19:13:37 +01:00
Florian Rival
d229d01aa9 Enable button to open profiler and listen to start/stop messages 2018-06-24 00:33:30 +01:00
Florian Rival
5fc9a4a51a Improve Profiler 2018-06-24 00:06:04 +01:00
Florian Rival
9f05a4e190 Fix gdjs.Profiler for sections appearing more than once 2018-06-23 11:43:33 +01:00
Florian Rival
ac7f681947 Add EmptyMessage explanation when Profiler was not started 2018-06-23 11:43:33 +01:00
Florian Rival
f7ae28bea9 Fix PlatformerObjectRuntimeBehavior using too much potential platforms for collision detection 2018-06-23 11:43:33 +01:00
Florian Rival
3104eeb415 Fix a crash in newIDE when resizing a MosaicWindow 2018-06-23 11:43:33 +01:00
Florian Rival
cdf95811b9 Refactor ingame profiling display & remove profiling at begining of scene 2018-06-23 11:43:33 +01:00
Florian Rival
731356b791 Move Profiler section code generation to EventsCodeGenerator 2018-06-23 11:43:33 +01:00
Florian Rival
8dd13180fd Fix flow typing 2018-06-23 11:43:32 +01:00
Florian Rival
81421907a5 Ensure codegeneration is adapted to preview/export (no profiling in exported games) for GDJS 2018-06-23 11:43:32 +01:00
Florian Rival
bb23e2c018 Add Prettier configuration file for GDJS 2018-06-23 11:43:32 +01:00
Florian Rival
eb6461c819 Refactor serialization in websocket-debugger-client 2018-06-23 11:43:32 +01:00
Florian Rival
1a3bd2423d [WIP] Add support for profiler in GDJS 2018-06-23 11:43:32 +01:00
Florian Rival
c22934d46f Add ThemeConsumer to avoid relying on muiThemeable HOC 2018-06-23 11:43:32 +01:00
Todor Imreorov
6cdee3b977 Add Piskel related improvements (#522)
* Show Resize prompt on Piskel for any new animations
* Add ability to set Piskel animation name
2018-06-23 11:22:39 +01:00
Lizard-13
88d102620a Add support for audio dynamic pitch (GDJS/Howler.js) (#533) 2018-06-21 18:33:12 +01:00
Florian Rival
3c5280a0f0 Merge branch 'master' of github.com:4ian/GD 2018-06-20 21:02:58 +01:00
Florian Rival
ad9abd971c Make Table themable and fix the styling of InstancesList in dark theme 2018-06-20 21:02:32 +01:00
Lizard-13
48465425e4 Fix include order (#527) 2018-06-18 23:51:26 +01:00
Lizard-13
02ddea17ea Add raycast-to-position condition (#526) 2018-06-18 23:50:03 +01:00
Florian Rival
24b68f75b8 Add 2 new examples 2018-06-17 22:45:15 +01:00
Florian Rival
bed9c77c8c Fix link in GDJS/Readme.md 2018-06-17 18:18:53 +01:00
Florian Rival
0a6f810695 Bump newIDE version 2018-06-17 14:37:22 +01:00
Florian Rival
a70f5df386 Add/update 9 examples 2018-06-17 14:33:50 +01:00
Florian Rival
83951c952f Fix icons generation on Windows 2018-06-17 12:46:00 +01:00
Florian Rival
5b0758a035 Bump newIDE version 2018-06-16 18:15:25 +01:00
Florian Rival
058a2e6c82 Add Windows/macOS/Linux to list of exports in web-app 2018-06-16 15:19:30 +01:00
Florian Rival
78b00f8c36 Add 8 examples to GDevelop 5 2018-06-16 15:10:29 +01:00
Florian Rival
2de67eae57 Remove LocalIntroDialog and reference to beta in BrowserIntroDialog 2018-06-16 12:55:37 +01:00
Florian Rival
4b6e8454de Merge pull request #521 from 4ian/feature/online-electron-export
Online (or manual) export for Windows/macOS/Linux for GD5
2018-06-16 12:53:22 +01:00
Florian Rival
b3d9a773b0 Add links to help page 2018-06-16 12:51:25 +01:00
Florian Rival
796937ba5d Update subscriptions details 2018-06-16 12:09:22 +01:00
Florian Rival
977095fb36 Add targets to build for in LocalOnlineElectronExport 2018-06-14 23:52:22 +01:00
Florian Rival
f1f1123dad Improve error message in exporters and reset build when launching new export 2018-06-14 08:39:14 +01:00
ddabrahim
d8e87cd976 Updated the magnet example (#520)
Changed the position of the center and origin point of the big magnet to improve touch experience
2018-06-13 17:31:22 +01:00
Florian Rival
663336c4ee Ensure .DS_Store is not shown in examples list in LocalExamples 2018-06-13 00:08:22 +01:00
Florian Rival
96c993e057 Add 6 examples to GDevelop 5 2018-06-13 00:00:53 +01:00
Florian Rival
5742dcfbf8 Add beta to online electron export 2018-06-12 21:21:36 +01:00
Florian Rival
bf231c6c07 Factor exporter Progress into BuildStepsProgress 2018-06-12 17:28:03 +01:00
Florian Rival
fdbc91137c Factor build progress watching between BuildsList and exporters 2018-06-12 00:28:58 +01:00
Florian Rival
3e409681c2 Add a window showing list of previous builds (no auto-refresh) 2018-06-11 22:36:45 +01:00
Florian Rival
c23642e78c Prevent any error due to quotes or invalid characters when exporting to Electron 2018-06-11 22:36:45 +01:00
Florian Rival
7845a3577c Fix Electron export 2018-06-11 22:36:45 +01:00
Florian Rival
60484ee464 Add Visual Studio code settings for auto-formatting of C++ files 2018-06-11 22:36:44 +01:00
Florian Rival
06b54e277a Add version in properties of a project 2018-06-11 22:36:44 +01:00
Florian Rival
daa683f492 [WIP] Add LocalOnlineElectronExport and LocalElectronExport 2018-06-11 22:36:44 +01:00
Florian Rival
f3a43e8739 Update Asteroids example 2018-06-11 21:48:07 +01:00
Florian Rival
4fb830529a Add Asteroids, Brakeout and Type on text effect examples 2018-06-11 00:06:05 +01:00
Florian Rival
9b7b02fab2 Fix flow typing 2018-06-10 20:25:39 +01:00
Florian Rival
ae3b25f8c0 Add .watchmanconfig file 2018-06-10 10:18:30 +01:00
Florian Rival
c59204ce04 Add contributors list 2018-06-10 10:17:22 +01:00
Florian Rival
fd63f7bc96 Add Examples tab in CreateProjectDialog with new examples
Add a script to update web-app examples from the examples in resources/examples folder (used by IDE running on Electron
runtime).
2018-06-09 16:34:39 +01:00
Florian Rival
147dc321f1 Fix formatting 2018-06-04 16:03:00 +01:00
Florian Rival
fd72c6efe9 Ensure there is only a single Once instructions at the end of an instruction list 2018-05-29 14:35:19 -07:00
Florian Rival
ff1891bb3a Avoid killing CPU by throttling updates to scrollbars while scrolling in scene editors 2018-05-28 23:13:46 -07:00
Florian Rival
ec32788b4c Update newIDE Readme 2018-05-28 21:41:35 -07:00
Florian Rival
95622169a3 Update GDJS Readme 2018-05-28 21:21:51 -07:00
Bouh
e89de02fa6 Move Window mask button to Grid submenu (#507) 2018-05-28 20:36:04 -07:00
Nnarol
63a5734f32 Resolve compilation issue due to incomplete wxBitmap type (#506)
Include wx/bitmap.h in FileProperty.h .
Remove redundant inclusion of wx/control.h .
2018-05-28 00:07:14 -07:00
1289 changed files with 214878 additions and 14659 deletions

1
.clang_format Normal file
View File

@@ -0,0 +1 @@
{BasedOnStyle: Google, BinPackParameters: false, BinPackArguments: false}

View File

@@ -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}"
}

View File

@@ -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 =

View File

@@ -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.

View File

@@ -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("\"\"")

View File

@@ -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

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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"),

View File

@@ -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",

View File

@@ -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",

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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_),

View File

@@ -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 &parameterType) {
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 &parameterType) {
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)

View File

@@ -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,

View File

@@ -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
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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();

View File

@@ -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;

View File

@@ -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];
}

View 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

View 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

View File

@@ -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(

View File

@@ -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);

View File

@@ -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:

View File

@@ -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>

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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> >

View File

@@ -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 {

View File

@@ -23,6 +23,7 @@ namespace gd {
class GD_CORE_API SerializerElement {
public:
SerializerElement();
SerializerElement(const SerializerValue & value);
virtual ~SerializerElement();
/** \name Value

View File

@@ -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 {

View File

@@ -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

View File

@@ -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",

View File

@@ -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)
{

View File

@@ -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",

View File

@@ -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 =

View File

@@ -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()

View File

@@ -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;
}

View File

@@ -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",

View File

@@ -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")

View File

@@ -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",

View 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"
)
];
}
};

View 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.
};

View File

@@ -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.
};

View 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
);

View File

@@ -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)

View File

@@ -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

View 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 []; },
};

View 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

View File

@@ -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() || '';
};

View File

@@ -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

View File

@@ -16,7 +16,7 @@ gdjs.InventoryManager.get = function(runtimeScene, name) {
}
/**
* @namespace gdjs.evtTools
* @memberof gdjs.evtTools
* @class inventory
* @static
* @private

View File

@@ -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)

View File

@@ -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

View File

@@ -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",

View File

@@ -8,7 +8,7 @@
*
* @class PanelSpriteRuntimeObject
* @extends RuntimeObject
* @namespace gdjs
* @memberof gdjs
*/
gdjs.PanelSpriteRuntimeObject = function(runtimeScene, objectData)
{

View File

@@ -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
{

View File

@@ -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);

View File

@@ -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:

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -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(

View File

@@ -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)
{

View File

@@ -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()

View File

@@ -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(

View File

@@ -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);

View File

@@ -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(

View File

@@ -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")

View File

@@ -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.

View File

@@ -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)
{

View File

@@ -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

View File

@@ -8,7 +8,7 @@
*
* @class ShapePainterRuntimeObject
* @extends RuntimeObject
* @namespace gdjs
* @memberof gdjs
*/
gdjs.ShapePainterRuntimeObject = function(runtimeScene, objectData)
{

View File

@@ -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

View File

@@ -20,7 +20,7 @@ gdjs.ShopifyClientsManager.get = function(runtimeScene, name) {
}
/**
* @namespace gdjs.evtTools
* @memberof gdjs.evtTools
* @class shopify
* @static
* @private

View File

@@ -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){

View File

@@ -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
*/

View File

@@ -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
*/

View File

@@ -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);
}
};

View File

@@ -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);

View File

@@ -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