Compare commits

...

85 Commits

Author SHA1 Message Date
Davy Hélard
327165482a Add comments. 2023-11-23 19:16:51 +01:00
Davy Hélard
92d7ddf5f7 Ensure RBush compatibility for extensions using it. 2023-11-23 19:16:51 +01:00
Davy Hélard
d153378351 Partially fix collision for groups. 2023-11-23 19:16:50 +01:00
Davy Hélard
5274f68432 Fix state toggling. 2023-11-23 19:16:50 +01:00
Davy Hélard
329d899b47 Fix picking of iterated objects. 2023-11-23 19:16:49 +01:00
Davy Hélard
72603a4c0e Fix the spatial conditions crash when used in extensions. 2023-11-23 19:16:49 +01:00
Davy Hélard
38e187b110 Fix platform update. 2023-11-23 19:16:48 +01:00
Davy Hélard
633071560d do fix types. 2023-11-23 19:16:48 +01:00
Davy Hélard
66f12b848c Fix types 2023-11-23 19:16:48 +01:00
Davy Hélard
9d1233bb09 Fix the conditions with few objects. 2023-11-23 19:16:47 +01:00
Davy Hélard
daa1f305ee Explain a failing test of platformer. 2023-11-23 19:16:47 +01:00
Davy Hélard
0755493f94 Fix TextInput culling. 2023-11-23 19:16:46 +01:00
Davy Hélard
8c7331fc44 Fix Sprite initial life-cycle sleeping state. 2023-11-23 19:16:46 +01:00
Davy Hélard
0f8fcacf98 Better comment. 2023-11-23 19:16:45 +01:00
Davy Hélard
23a39f1e2c Use the isPicked flag. 2023-11-23 19:16:45 +01:00
Davy Hélard
b7787d29f1 Fix the isPick flag handling. 2023-11-23 19:16:45 +01:00
Davy Hélard
ad0f1f163f Add a flag to know if an ObjectsLists has been picked 2023-11-23 19:16:44 +01:00
Davy Hélard
e34aedb15c Add a fast collision condition. 2023-11-23 19:16:44 +01:00
Davy Hélard
27f16a3db0 Fix the distance condition. 2023-11-23 19:16:44 +01:00
Davy Hélard
6e6ddb9edd Allow objects to sleep at the 1st frame. 2023-11-23 19:16:43 +01:00
Davy Hélard
fbf4baebe9 Fix initial state. 2023-11-23 19:16:43 +01:00
Davy Hélard
2cdfc889a8 Fix initial culling. 2023-11-23 19:16:43 +01:00
Davy Hélard
7f7a13dee8 Avoid extra mapping of searched items. 2023-11-23 19:16:42 +01:00
Davy Hélard
e45ba9465d Reduce memory allocation from platform behavior. 2023-11-23 19:16:42 +01:00
Davy Hélard
cbae925680 Try to maintain a R-Tree per layer. 2023-11-23 19:16:41 +01:00
Davy Hélard
852fdd77dd Try to maintain a R-Tree per object. 2023-11-23 19:16:41 +01:00
Davy Hélard
8afea382d4 Add todo 2023-11-23 19:16:41 +01:00
Davy Hélard
c3c0c1961b Watch plaforms passively. 2023-11-23 19:16:40 +01:00
Davy Hélard
40c5012a0e Avoid useless object life-cycle calls. 2023-11-23 19:16:39 +01:00
Clément Pasteau
a848764318 Fix libGD.wasm not properly loaded on Electron local + build warnings (#5942)
Don't show in changelog
2023-11-23 15:55:31 +01:00
github-actions[bot]
c0c6fddcbb Update translations [skip ci] (#5937)
Co-authored-by: AlexandreSi <AlexandreSi@users.noreply.github.com>
2023-11-23 09:49:51 +01:00
AlexandreS
95ac26f05d Add placeholder in menu when no recent project file (#5940) 2023-11-23 09:28:33 +01:00
D8H
1f852648ef Make games launch faster by loading resources in the background (#5572)
* Only the first scene and global objects resources (images, sounds, 3D models etc...) will be downloaded during launch of the game. This usually allows for a very fast loading time.
* Other scenes resources will continue to load in the background. It has no impact on the game performance as this is done on other threads by the browser or the engine running the game.
* Scenes are loaded in the order they are listed in the project manager.
* You can also use actions and expressions to prioritize a scene (if it's known that a level will be needed soon for example) or read the current loading progress. This allows to create lightweight scenes that can act as custom loading screens. Otherwise, the launch loading screen will be shown if a scene is still loading when launched.
* Read more about this on https://wiki.gdevelop.io/gdevelop5/all-features/resources-loading/.
2023-11-22 22:51:24 +01:00
Florian Rival
b7da4361c3 Fix some C++ warnings and improve GDevelop.js README
Don't show in changelog
2023-11-22 19:03:21 +01:00
Arthur Pacaud (arthuro555)
71b369d40e Update Emscripten version to 3.1.21 (#5636)
* Any developer working on the C++ codebase should follow again the [README](https://github.com/4ian/GDevelop/tree/master/GDevelop.js) to install latest Emscripten version and re-compile C++.

Only show in developer changelog
2023-11-22 17:19:13 +01:00
AlexandreS
4d8cf56922 Do not change homepage tab at opening if an item from the asset store is requested (#5936) 2023-11-22 16:29:44 +01:00
github-actions[bot]
1a6e0ba5a1 Update translations [skip ci] (#5918)
Co-authored-by: AlexandreSi <AlexandreSi@users.noreply.github.com>
2023-11-22 14:04:18 +01:00
AlexandreS
ec1ebcbf5b Fix desktop app not opening on Mac (#5934)
Don't show in changelog
2023-11-22 11:48:07 +01:00
Arthur Pacaud (arthuro555)
4ee9ccd7a9 Allow using resources as behavior properties (#5256)
Only show in developer changelog
2023-11-22 11:17:35 +01:00
AlexandreS
1ac248bfa4 Replace parcel watcher with chokidar (#5932) 2023-11-22 09:35:29 +01:00
D8H
65b78d4db7 Fix duplication of the "create" action in the search results (#5930) 2023-11-21 18:14:35 +01:00
D8H
639d90d743 Move deprecated physics actions at the bottom of search results (#5925) 2023-11-21 18:13:38 +01:00
D8H
45d0a78656 Simplify the wording of some actions names (#5929) 2023-11-21 18:12:09 +01:00
Florian Rival
0a0811e355 Fix crash with 'Put the object around another' action when target object was not existing (#5931) 2023-11-21 17:11:37 +01:00
D8H
a8f9df3dac Use descriptions to search actions and conditions (#5928) 2023-11-21 10:36:54 +01:00
Clément Pasteau
35db56d778 Fix Debugger sometimes crashing (#5926)
* Remove pixi effects renderer from the debugger payload, which was causing it to fail.
2023-11-20 16:06:41 +01:00
D8H
27efe8e3dd Improving the grouping of some behaviors actions and conditions (#5923) 2023-11-19 16:13:19 +01:00
github-actions[bot]
3584ee2aaf Update translations (#5916) 2023-11-17 14:49:31 +01:00
D8H
19a762fb60 Fix a memory and CPU leak when a finished tween is replaced (#5917) 2023-11-17 11:44:12 +01:00
AlexandreS
8a6dd8b940 Bump newIDE version (#5914) 2023-11-17 09:55:10 +01:00
AlexandreS
2173b49b19 New get started flow and customize content based on user survey (#5781) 2023-11-17 09:54:49 +01:00
github-actions[bot]
caf2752acb Update translations [skip ci] (#5912)
Co-authored-by: ClementPasteau <ClementPasteau@users.noreply.github.com>
2023-11-16 17:35:40 +01:00
Clément Pasteau
e3291b515d Check existence of elements before destroying (#5913)
Do not show in changelog
2023-11-16 15:55:58 +01:00
Clément Pasteau
c1627b5ab2 Add error id to issue to fully track its trace (#5909)
Do not show in changelog
2023-11-16 11:55:47 +01:00
github-actions[bot]
7db5b97c45 Update translations [skip ci] (#5905)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2023-11-16 10:03:50 +01:00
D8H
425a0e92ca Fix camera flickering when "pixel rounding" is enabled (#5907) 2023-11-16 15:48:47 +09:00
AlexandreS
c2dfe579af Exclude project files (when configured to save scenes and events in different files) from watcher (#5885)
Also, exclude git files when using git versioning.
2023-11-15 16:15:15 +01:00
AlexandreS
4ea6fb78bd Improve objects list (#5895)
- Remove spell check on inputs
- Unselect item when a parent is closed (and the item becomes not visible)
- Allow to remove folder with all the objects contained in it (recursively)
- Improve selected row color 
- Add hover effects on rows
2023-11-15 09:53:15 +01:00
github-actions[bot]
8e668db6ea Update translations [skip ci] (#5900)
Co-authored-by: D8H <D8H@users.noreply.github.com>
2023-11-14 17:59:53 +01:00
D8H
88063a4cad Show instructions about objects with the other object instructions (#5828) 2023-11-13 17:05:49 +01:00
AlexandreS
b180f5032e Fix getThumbanil static methods (#5902)
Don't show in changelog
2023-11-13 13:59:04 +01:00
AlexandreS
29e7f7d7a4 Remove build section ref and effect (#5901)
Don't show in changelog
2023-11-13 10:07:22 +01:00
AlexandreS
547f1e4bce Prevent dragging of treeview row placeholder item (#5899) 2023-11-13 09:42:18 +01:00
github-actions[bot]
9e176d91ec Update translations [skip ci] (#5879)
Co-authored-by: 4ian <4ian@users.noreply.github.com>
2023-11-13 09:41:27 +01:00
Mehrab
cac59d4727 Fix the grid/mask checkbox not updated when toggled on the web-app (#5897) 2023-11-12 17:51:34 +01:00
D8H
4f98ffa9ab Fix memory some memory leaks in the scene editor (#5853) 2023-11-10 16:14:54 +01:00
Clément Pasteau
7229406cfb Add errorBoundaries on all main components to prevent crashing the whole app (#5889)
Do not show in changelog
2023-11-10 10:04:01 +01:00
Clément Pasteau
d39cfd16a2 Prevent possible crashes of the editor in multiple part of the app (#5883)
Do not show in changelog
2023-11-09 17:02:11 +01:00
AlexandreS
2965f374bb Improve resources watching performance (#5882)
- Try at reducing Windows devices resources use
- Remove any `.git` folder from being watched (for project using versioning with git)
2023-11-08 09:17:11 +01:00
Clément Pasteau
2d5b2a49e7 Fix a possible crash of the instance editor when updating a sprite (#5881)
* Fix calling methods on Texture frame which can be null when an image is updated
2023-11-07 11:24:57 +01:00
Clément Pasteau
05df9cb599 Show back preview of list item on drag instead of full row for objects and groups (#5880) 2023-11-06 17:23:36 +01:00
D8H
7b28d2525e Fix a broken link in the extension list page (#5878) 2023-11-06 10:06:54 +01:00
github-actions[bot]
533e61cdbc Update translations [skip ci] (#5869)
Co-authored-by: ClementPasteau <ClementPasteau@users.noreply.github.com>
2023-11-06 09:29:39 +01:00
Clément Pasteau
3a823113f1 Improve issue template (#5872)
Do not show in changelog
2023-11-03 17:17:15 +01:00
Clément Pasteau
17bc8b584d Show error in error boundary for easier debugging (#5855)
Do not show in changelog
2023-11-03 17:14:25 +01:00
AlexandreS
dbaf8a6569 Clear selection before updating list (#5873)
Don't show in changelog
2023-11-03 17:12:32 +01:00
Clément Pasteau
fcbc538c30 Reduce logs for web previews (#5854)
Do not show in changelog
2023-11-03 16:29:37 +01:00
Clément Pasteau
decd96c52f Only allow opening project folder in Resources tab if local project (#5867) 2023-11-02 18:04:20 +01:00
AlexandreS
8dbf9c99ce Bump newIDE version (#5868) 2023-11-02 14:35:50 +01:00
D8H
1318523804 Fix a crash when objects are used after being deleted (#5865) 2023-11-02 13:09:54 +01:00
github-actions[bot]
8ef5e2c1ed Update translations [skip ci] (#5850)
Co-authored-by: AlexandreSi <AlexandreSi@users.noreply.github.com>
2023-11-02 11:50:33 +01:00
AlexandreS
d945426068 Fix custom loading screen not displaying (#5864) 2023-11-02 11:34:45 +01:00
AlexandreS
8eb07a492f Fix treeview search crash when there is no global object (#5866) 2023-11-02 11:14:39 +01:00
Florian Rival
37c9dd95ce Allow installing up to 200 assets at the same time (#5851) 2023-11-02 11:02:40 +01:00
AlexandreS
a6d837cbe6 Use new electron notarize tool (#5857)
Only show in developer changelog
2023-10-31 13:36:10 +01:00
423 changed files with 20526 additions and 8571 deletions

View File

@@ -30,7 +30,7 @@ jobs:
- run:
name: Install Emscripten (for GDevelop.js)
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
# GDevelop.js dependencies
- restore_cache:
@@ -107,7 +107,7 @@ jobs:
- run:
name: Install Emscripten (for GDevelop.js)
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
- run:
name: Install system dependencies for Electron builder
@@ -127,7 +127,8 @@ jobs:
# Build GDevelop.js (and run tests to ensure it works)
- run:
name: Build GDevelop.js
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test && cd ..
# Use "--runInBand" as it's faster and avoid deadlocks on CircleCI Linux machines (probably because limited in processes number).
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test -- --runInBand && cd ..
# GDevelop IDE dependencies (after building GDevelop.js to avoid downloading a pre-built version)
- run:
@@ -184,7 +185,7 @@ jobs:
- run:
name: Install Emscripten (for GDevelop.js)
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
# GDevelop.js dependencies
- restore_cache:
@@ -200,7 +201,8 @@ jobs:
# Build GDevelop.js (and run tests to ensure it works)
- run:
name: Build GDevelop.js
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test && cd ..
# Use "--runInBand" as it's faster and avoid deadlocks on CircleCI Linux machines (probably because limited in processes number).
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test -- --runInBand && cd ..
- save_cache:
paths:

View File

@@ -0,0 +1,37 @@
name: 💥 Automatic crash report
description: Do not use this template for bug reports. This template is only for automatic crash reports.
body:
- type: textarea
id: description
attributes:
label: Describe what you were doing when the crash happened
description: If applicable, add screenshots to help explain your problem.
placeholder: |
1. Went to '...'
2. Clicked on '...'
3. Scrolled down to '...'
4. Saw error
- type: input
id: gdevelop_version
attributes:
label: GDevelop version
description: |
The version of GDevelop used. Leave the prefilled value.
validations:
required: true
- type: textarea
id: platform_info
attributes:
label: Platform info
description: |
The platform you are using GDevelop on. Leave the prefilled value.
- type: textarea
id: error_stack
attributes:
label: Additional error context
description: Additonal context about the problem. Leave the prefilled value.
- type: textarea
id: component_stack
attributes:
label: Additional component context
description: Additonal context about the problem. Leave the prefilled value.

View File

@@ -2,18 +2,21 @@ name: 🐛Bug report
description: Create a bug report about GDevelop or the game engine
body:
- type: checkboxes
id: searched_issues
attributes:
label: Is there an existing issue for this?
options:
- label: I have searched the [existing issues](https://github.com/4ian/GDevelop/issues)
required: true
- label: I have searched the [existing issues](https://github.com/4ian/GDevelop/issues)
required: true
- type: textarea
id: description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: reproduction_steps
attributes:
label: Steps to reproduce
description: |
@@ -27,6 +30,7 @@ body:
validations:
required: true
- type: dropdown
id: platform
attributes:
label: GDevelop platform
description: Which platform of GDevelop are you using?
@@ -38,6 +42,7 @@ body:
validations:
required: true
- type: input
id: gdevelop_version
attributes:
label: GDevelop version
description: |
@@ -47,6 +52,7 @@ body:
validations:
required: true
- type: textarea
id: platform_info
attributes:
label: Platform info
value: |
@@ -66,6 +72,7 @@ body:
</details>
- type: textarea
id: additional_context
attributes:
label: Additional context
description: Add any other context about the problem here.

View File

@@ -14,7 +14,7 @@ tasks:
init: |
sudo apt-get update
sudo apt install cmake python-is-python3 python3-distutils -y
git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
cd GDevelop.js
npm install
source ../emsdk/emsdk_env.sh && npm run build -- --dev

View File

@@ -39,7 +39,7 @@ install:
- cd ..
# Install Emscripten (for GDevelop.js)
- git clone https://github.com/juj/emsdk.git
- cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
- cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
# Install GDevelop.js dependencies
- cd GDevelop.js && npm install && cd ..
# Build GDevelop.js

View File

@@ -113,7 +113,8 @@
"memory_resource": "cpp",
"__bits": "cpp",
"__verbose_abort": "cpp",
"variant": "cpp"
"variant": "cpp",
"charconv": "cpp"
},
"files.exclude": {
"Binaries/*build*": true,

View File

@@ -164,7 +164,7 @@ void LinkEvent::UnserializeFrom(gd::Project& project,
}
bool LinkEvent::AcceptVisitor(gd::EventVisitor &eventVisitor) {
return BaseEvent::AcceptVisitor(eventVisitor) |
return BaseEvent::AcceptVisitor(eventVisitor) ||
eventVisitor.VisitLinkEvent(*this);
}

View File

@@ -103,6 +103,11 @@ void EventsCodeGenerationContext::EmptyObjectsListNeeded(
depthOfLastUse[objectName] = GetContextDepth();
}
void EventsCodeGenerationContext::AddUsedObjectsMapNames(
const gd::String& objectMapName) {
usedObjectsMapNames.insert(objectMapName);
}
std::set<gd::String> EventsCodeGenerationContext::GetAllObjectsToBeDeclared()
const {
std::set<gd::String> allObjectListsToBeDeclared(

View File

@@ -175,6 +175,12 @@ class GD_CORE_API EventsCodeGenerationContext {
return emptyObjectsListsToBeDeclared;
};
const std::set<gd::String>& GetUsedObjectsMapNames() const {
return usedObjectsMapNames;
};
void AddUsedObjectsMapNames(const gd::String& objectMapName);
/**
* Return the objects lists which are already declared and can be used in the
* current context without declaration.
@@ -297,6 +303,8 @@ class GD_CORE_API EventsCodeGenerationContext {
///< necessary objects can be
///< backed up.
std::set<gd::String> usedObjectsMapNames;
std::map<gd::String, unsigned int>
depthOfLastUse; ///< The context depth when an object was last used.
gd::String

View File

@@ -408,6 +408,25 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
arguments, instrInfos, returnBoolean, condition.IsInverted(), context);
}
// Flag the ObjectsLists as modified.
gd::ParameterMetadataTools::IterateOverParameters(
condition.GetParameters(), instrInfos.parameters,
[this, &context,
&conditionCode](const gd::ParameterMetadata &parameterMetadata,
const gd::Expression &parameterValue,
const gd::String &lastObjectName) {
// objectListOrEmptyWithoutPicking are only used by SceneInstancesCount
// and PickedInstancesCount conditions. They are not pass for one
// condition to another.
if (parameterMetadata.GetType() == "objectList" ||
parameterMetadata.GetType() == "objectListOrEmptyIfJustDeclared") {
// TODO FIXME What about groups using the object?
conditionCode +=
GetObjectMapName(parameterValue.GetPlainString(), context) +
".isPicked = true;\n";
}
});
return conditionCode;
}

View File

@@ -585,6 +585,12 @@ class GD_CORE_API EventsCodeGenerator {
return "fakeObjectListOf_" + objectName;
}
// TODO Documentation
virtual gd::String GetObjectMapName(const gd::String &objectName,
gd::EventsCodeGenerationContext &context) {
return "fakeObjectListOf_" + objectName;
}
virtual gd::String GeneratePropertyGetter(
const gd::PropertiesContainer& propertiesContainer,
const gd::NamedPropertyDescriptor& property,

View File

@@ -491,11 +491,6 @@ class GD_CORE_API ExpressionParser2 {
std::vector<std::unique_ptr<ExpressionNode>> parameters;
gd::String lastObjectName = "";
// By convention, object is always the first parameter, and behavior the
// second one.
size_t parameterIndex =
WrittenParametersFirstIndex(objectName, behaviorName);
bool previousCharacterIsParameterSeparator = false;
while (!IsEndReached()) {
SkipAllWhitespaces();
@@ -514,7 +509,6 @@ class GD_CORE_API ExpressionParser2 {
SkipAllWhitespaces();
previousCharacterIsParameterSeparator = CheckIfChar(IsParameterSeparator);
SkipIfChar(IsParameterSeparator);
parameterIndex++;
}
ExpressionParserLocation invalidClosingParenthesisLocation;

View File

@@ -1475,10 +1475,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Position"),
"res/conditions/distance24.png",
"res/conditions/distance.png")
.AddParameter("objectList", _("Object"))
.AddParameter("objectList", _("Object 2"))
.AddParameter("objectListOrEmptyIfJustDeclared", _("Object"))
.AddParameter("objectListOrEmptyIfJustDeclared", _("Object 2"))
.AddParameter("expression", _("Distance"))
.AddCodeOnlyParameter("conditionInverted", "")
.AddCodeOnlyParameter("objectsContext", "")
.MarkAsSimple();
extension
@@ -1585,10 +1586,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Collision"),
"res/conditions/collision24.png",
"res/conditions/collision.png")
.AddParameter("objectList", _("Object"))
.AddParameter("objectList", _("Object"))
.AddParameter("objectListOrEmptyIfJustDeclared", _("Object"))
.AddParameter("objectListOrEmptyIfJustDeclared", _("Object"))
.AddCodeOnlyParameter("conditionInverted", "")
.AddCodeOnlyParameter("currentScene", "")
.AddCodeOnlyParameter("objectsContext", "")
.AddParameter("yesorno",
_("Ignore objects that are touching each other on their "
"edges, but are not overlapping (default: no)"),
@@ -1624,7 +1625,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Cast a ray from _PARAM1_;_PARAM2_, angle: _PARAM3_ and max "
"distance: _PARAM4_px, against _PARAM0_, and save the "
"result in _PARAM5_, _PARAM6_"),
"",
_("Collision"),
"res/conditions/raycast24.png",
"res/conditions/raycast.png")
.AddParameter("objectList", _("Objects to test against the ray"))
@@ -1655,7 +1656,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
_("Cast a ray from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ "
"against _PARAM0_, and save the "
"result in _PARAM5_, _PARAM6_"),
"",
_("Collision"),
"res/conditions/raycast24.png",
"res/conditions/raycast.png")
.AddParameter("objectList", _("Objects to test against the ray"))

View File

@@ -327,7 +327,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
// TODO Deprecated: hide this action in a future release.
extension
.AddAction(
"FixCamera",
@@ -339,6 +338,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
"",
"res/actions/camera24.png",
"res/actions/camera.png")
.SetHidden()
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectPtr", _("Object"))
.AddParameter("expression",
@@ -386,7 +386,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
_("Center the camera on an object"),
_("Center the camera on the specified object."),
_("Center camera on _PARAM1_ (layer: _PARAM3_)"),
"",
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
@@ -548,7 +548,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
extension
.AddAction(
"ChangeLayerTimeScale",
_("Change layer time scale"),
_("Layer time scale"),
_("Change the time scale applied to the objects of the layer."),
_("Set the time scale of layer _PARAM1_ to _PARAM2_"),
"",
@@ -594,7 +594,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
extension
.AddAction(
"SetLayerAmbientLightColor",
_("Set the ambient light color"),
_("Ambient light color"),
_("Set the ambient light color of the lighting layer in format "
"\"R;G;B\" string."),
_("Set the ambient color of the lighting layer _PARAM1_ to _PARAM2_"),

View File

@@ -44,7 +44,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAnimatableExtension(
"number",
"Index",
_("Animation (by number)"),
_("the number of the animation played by the object (the number from "
_("the animation played by the object using the animation number (from "
"the animations list)"),
_("the number of the animation"),
_("Animations and images"),

View File

@@ -5,6 +5,7 @@
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
using namespace std;
namespace gd {
@@ -57,7 +58,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
extension
.AddCondition("DoesSceneExist",
_("Does scene exist"),
_("Check if scene exists."),
_("Check if a scene exists."),
_("Scene _PARAM1_ exists"),
"",
"res/actions/texte.png",
@@ -163,6 +164,45 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
"res/actions/window.png")
.SetHelpPath("/interface/scene-editor/events")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddAction("PrioritizeLoadingOfScene",
_("Preload scene"),
_("Preload a scene resources as soon as possible in background."),
_("Preload scene _PARAM1_ in background"),
"",
"res/actions/replaceScene24.png",
"res/actions/replaceScene.png")
.SetHelpPath("/all-features/resources-loading")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("sceneName", _("Name of the new scene"))
.MarkAsAdvanced();
extension.AddExpressionAndCondition("number",
"SceneLoadingProgress",
_("Scene loading progress"),
_("The progress of resources loading in background for a scene (between 0 and 1)."),
_("_PARAM0_ loading progress"),
_(""),
"res/actions/replaceScene24.png")
.SetHelpPath("/all-features/resources-loading")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("sceneName", _("Scene name"))
.UseStandardParameters("number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
.AddCondition("AreSceneAssetsLoaded",
_("Scene preloaded"),
_("Check if scene resources have finished to load in background."),
_("Scene _PARAM1_ was preloaded in background"),
"",
"res/actions/replaceScene24.png",
"res/actions/replaceScene.png")
.SetHelpPath("/all-features/resources-loading")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("sceneName", _("Scene name"))
.MarkAsAdvanced();
}
} // namespace gd

View File

@@ -87,8 +87,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
extension
.AddAction(
"SetWindowSize",
_("Change the size of the game window"),
_("This action changes the size of the game window. Note that this "
_("Game window size"),
_("Changes the size of the game window. Note that this "
"will only work on platform supporting this operation: games "
"running in browsers or on mobile phones can not update their "
"window size. Game resolution can still be updated."),

View File

@@ -191,6 +191,16 @@ class GD_CORE_API MultipleInstructionMetadata : public AbstractFunctionMetadata
return *this;
}
/**
* \see gd::InstructionMetadata::SetHelpPath
*/
MultipleInstructionMetadata &SetHelpPath(const gd::String &path) {
if (expression) expression->SetHelpPath(path);
if (condition) condition->SetHelpPath(path);
if (action) action->SetHelpPath(path);
return *this;
}
/**
* \see gd::InstructionMetadata::MarkAsSimple
*/

View File

@@ -4,7 +4,6 @@
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#include "DependenciesAnalyzer.h"
#include <algorithm>
#include "GDCore/Events/Builtin/LinkEvent.h"
@@ -29,9 +28,9 @@ DependenciesAnalyzer::DependenciesAnalyzer(const gd::Project& project_,
bool DependenciesAnalyzer::Analyze() {
if (layout)
return Analyze(layout->GetEvents(), true);
return Analyze(layout->GetEvents());
else if (externalEvents)
return Analyze(externalEvents->GetEvents(), true);
return Analyze(externalEvents->GetEvents());
std::cout << "ERROR: DependenciesAnalyzer called without any layout or "
"external events.";
@@ -40,63 +39,38 @@ bool DependenciesAnalyzer::Analyze() {
DependenciesAnalyzer::~DependenciesAnalyzer() {}
bool DependenciesAnalyzer::Analyze(const gd::EventsList& events, bool isOnTopLevel) {
bool DependenciesAnalyzer::Analyze(const gd::EventsList& events) {
for (unsigned int i = 0; i < events.size(); ++i) {
const gd::LinkEvent* linkEvent = dynamic_cast<const gd::LinkEvent*>(&events[i]);
if (linkEvent) {
DependenciesAnalyzer analyzer(*this);
gd::String linked = linkEvent->GetTarget();
if (project.HasExternalEventsNamed(linked)) {
if (std::find(parentExternalEvents.begin(),
parentExternalEvents.end(),
linked) != parentExternalEvents.end())
return false; // Circular dependency!
externalEventsDependencies.insert(
linked); // There is a direct dependency
if (!isOnTopLevel) notTopLevelExternalEventsDependencies.insert(linked);
analyzer.AddParentExternalEvents(linked);
if (!analyzer.Analyze(project.GetExternalEvents(linked).GetEvents(),
isOnTopLevel))
linked) != parentExternalEvents.end()) {
// Circular dependency!
return false;
}
bool wasDependencyJustAdded = externalEventsDependencies.insert(linked).second;
if (wasDependencyJustAdded) {
parentExternalEvents.push_back(linked);
if (!Analyze(project.GetExternalEvents(linked).GetEvents()))
return false;
parentExternalEvents.pop_back();
}
} else if (project.HasLayoutNamed(linked)) {
if (std::find(parentScenes.begin(), parentScenes.end(), linked) !=
parentScenes.end())
return false; // Circular dependency!
scenesDependencies.insert(linked); // There is a direct dependency
if (!isOnTopLevel) notTopLevelScenesDependencies.insert(linked);
analyzer.AddParentScene(linked);
if (!analyzer.Analyze(project.GetLayout(linked).GetEvents(),
isOnTopLevel))
parentScenes.end()) {
// Circular dependency!
return false;
}
// Update with indirect dependencies.
scenesDependencies.insert(analyzer.GetScenesDependencies().begin(),
analyzer.GetScenesDependencies().end());
externalEventsDependencies.insert(
analyzer.GetExternalEventsDependencies().begin(),
analyzer.GetExternalEventsDependencies().end());
sourceFilesDependencies.insert(
analyzer.GetSourceFilesDependencies().begin(),
analyzer.GetSourceFilesDependencies().end());
notTopLevelScenesDependencies.insert(
analyzer.GetNotTopLevelScenesDependencies().begin(),
analyzer.GetNotTopLevelScenesDependencies().end());
notTopLevelExternalEventsDependencies.insert(
analyzer.GetNotTopLevelExternalEventsDependencies().begin(),
analyzer.GetNotTopLevelExternalEventsDependencies().end());
if (!isOnTopLevel) {
notTopLevelScenesDependencies.insert(
analyzer.GetScenesDependencies().begin(),
analyzer.GetScenesDependencies().end());
notTopLevelExternalEventsDependencies.insert(
analyzer.GetExternalEventsDependencies().begin(),
analyzer.GetExternalEventsDependencies().end());
}
bool wasDependencyJustAdded = scenesDependencies.insert(linked).second;
if (wasDependencyJustAdded) {
parentScenes.push_back(linked);
if (!Analyze(project.GetLayout(linked).GetEvents()))
return false;
parentScenes.pop_back();
}
}
}
@@ -112,45 +86,9 @@ bool DependenciesAnalyzer::Analyze(const gd::EventsList& events, bool isOnTopLev
// Analyze sub events dependencies
if (events[i].CanHaveSubEvents()) {
if (!Analyze(events[i].GetSubEvents(), false)) return false;
if (!Analyze(events[i].GetSubEvents())) return false;
}
}
return true;
}
gd::String DependenciesAnalyzer::ExternalEventsCanBeCompiledForAScene() {
if (!externalEvents) {
std::cout << "ERROR: ExternalEventsCanBeCompiledForAScene called without "
"external events set!"
<< std::endl;
return "";
}
gd::String sceneName;
for (unsigned int i = 0; i < project.GetLayoutsCount(); ++i) {
// For each layout, compute the dependencies and the dependencies which are
// not coming from a top level event.
DependenciesAnalyzer analyzer(project, project.GetLayout(i));
if (!analyzer.Analyze()) continue; // Analyze failed -> Cyclic dependencies
const std::set<gd::String>& dependencies =
analyzer.GetExternalEventsDependencies();
const std::set<gd::String>& notTopLevelDependencies =
analyzer.GetNotTopLevelExternalEventsDependencies();
// Check if the external events is a dependency, and that is is only present
// as a link on the top level.
if (dependencies.find(externalEvents->GetName()) != dependencies.end() &&
notTopLevelDependencies.find(externalEvents->GetName()) ==
notTopLevelDependencies.end()) {
if (!sceneName.empty())
return ""; // External events can be compiled only if one scene is
// including them.
else
sceneName = project.GetLayout(i).GetName();
}
}
return sceneName; // External events can be compiled and used for the scene.
}
#endif

View File

@@ -39,11 +39,6 @@ class GD_CORE_API DependenciesAnalyzer {
/**
* \brief Constructor for analyzing the dependencies of external events.
*
* You can also call then
* DependenciesAnalyzer::ExternalEventsCanBeCompiledForAScene to check if the
* external events can be compiled separately and called by a scene. \see
* DependenciesAnalyzer::ExternalEventsCanBeCompiledForAScene
*/
DependenciesAnalyzer(const gd::Project& project_,
const gd::ExternalEvents& externalEvents);
@@ -60,18 +55,6 @@ class GD_CORE_API DependenciesAnalyzer {
*/
bool Analyze();
/**
* Check if the external events (passed in the constructor) can be compiled
* and called by a single scene:<br> This is possible when the link calling
* the external events does not have any parent event and when this situation
* occurs only in a single scene and not in another.
*
* \return The name of the scene which is able to call the compiled external
* events. If empty, no scene is able to call them. (So external events have
* to be included directly by links).
*/
gd::String ExternalEventsCanBeCompiledForAScene();
/**
* \brief Return the scenes being dependencies of the scene or external events
* passed in the constructor.
@@ -96,25 +79,6 @@ class GD_CORE_API DependenciesAnalyzer {
return sourceFilesDependencies;
};
/**
* \brief Return the scenes being dependencies of the scene or external events
* passed in the constructor, but being not top level dependencies: The links
* including them are not a top level events (i.e: They have a parent event).
*/
const std::set<gd::String>& GetNotTopLevelScenesDependencies() const {
return notTopLevelScenesDependencies;
};
/**
* \brief Return the external events being dependencies of the scene or
* external events passed in the constructor, but being not top level
* dependencies: The links including them are not a top level events (i.e:
* They have a parent event).
*/
const std::set<gd::String>& GetNotTopLevelExternalEventsDependencies() const {
return notTopLevelExternalEventsDependencies;
};
private:
/**
* \brief Analyze the dependencies of the events.
@@ -124,32 +88,11 @@ class GD_CORE_API DependenciesAnalyzer {
* (they have no parents). \return false if a circular dependency exists, true
* otherwise.
*/
bool Analyze(const gd::EventsList& events, bool isOnTopLevel);
void AddParentScene(gd::String parentScene) {
parentScenes.push_back(parentScene);
};
void AddParentExternalEvents(gd::String parentExternalEvents_) {
parentExternalEvents.push_back(parentExternalEvents_);
};
/**
* Return true if all links pointing to external events called \a
* externalEventsName are only at the top level of \a events. The function
* return false as soon as it discover a link to external events which is not
* at the top level ( i.e: It has a parent event ).
*
* \warning The function assumes that there are not cyclic dependencies.
*/
bool CheckIfExternalEventsIsLinkedOnlyAtTopLevel(
const gd::String& externalEventsName,
std::vector<std::shared_ptr<gd::BaseEvent> >& events);
bool Analyze(const gd::EventsList& events);
std::set<gd::String> scenesDependencies;
std::set<gd::String> externalEventsDependencies;
std::set<gd::String> sourceFilesDependencies;
std::set<gd::String> notTopLevelScenesDependencies;
std::set<gd::String> notTopLevelExternalEventsDependencies;
std::vector<gd::String>
parentScenes; ///< Used to check for circular dependencies.
std::vector<gd::String>

View File

@@ -226,7 +226,7 @@ void EventsIdentifiersFinder::FindArgumentsInEventsAndDependencies(
eventWorker.Launch(layout.GetEvents(),
gd::ProjectScopedContainers::MakeNewProjectScopedContainersForProjectAndLayout(project, layout));
DependenciesAnalyzer dependenciesAnalyzer = DependenciesAnalyzer(project, layout);
DependenciesAnalyzer dependenciesAnalyzer(project, layout);
dependenciesAnalyzer.Analyze();
for (const gd::String& externalEventName : dependenciesAnalyzer.GetExternalEventsDependencies()) {
const gd::ExternalEvents& externalEvents = project.GetExternalEvents(externalEventName);

View File

@@ -258,7 +258,7 @@ void EventsVariablesFinder::FindArgumentsInEventsAndDependencies(
eventWorker.Launch(layout.GetEvents(),
gd::ProjectScopedContainers::MakeNewProjectScopedContainersForProjectAndLayout(project, layout));
DependenciesAnalyzer dependenciesAnalyzer = DependenciesAnalyzer(project, layout);
DependenciesAnalyzer dependenciesAnalyzer(project, layout);
dependenciesAnalyzer.Analyze();
for (const gd::String& externalEventName : dependenciesAnalyzer.GetExternalEventsDependencies()) {
const gd::ExternalEvents& externalEvents = project.GetExternalEvents(externalEventName);

View File

@@ -43,7 +43,6 @@ void ExtensionsLoader::LoadAllExtensions(const gd::String &directory,
struct dirent *lecture;
DIR *rep;
rep = opendir(directory.c_str());
int l = 0;
if (rep == NULL) {
cout << "Unable to open Extensions (" << directory << ") directory."
@@ -63,8 +62,6 @@ void ExtensionsLoader::LoadAllExtensions(const gd::String &directory,
LoadExtension(directory + "/" + lec, platform, forgiving);
librariesLoaded.push_back(directory + "/" + lec);
l++;
}
}
@@ -103,7 +100,6 @@ void ExtensionsLoader::ExtensionsLoadingDone(const gd::String &directory) {
struct dirent *lecture;
DIR *rep;
rep = opendir(directory.c_str());
int l = 0;
if (rep == NULL) {
cout << "Unable to open Extensions (" << directory << ") directory."
@@ -118,7 +114,6 @@ void ExtensionsLoader::ExtensionsLoadingDone(const gd::String &directory) {
lec.find(".xgd" + suffix, lec.length() - 4 - suffix.length()) !=
string::npos) {
librariesLoaded.push_back(directory + "/" + lec);
l++;
}
}

View File

@@ -262,13 +262,6 @@ bool ResourceWorkerInEventsWorker::DoVisitInstruction(gd::Instruction& instructi
return false;
};
void LaunchResourceWorkerOnEvents(const gd::Project& project,
gd::EventsList& events,
gd::ArbitraryResourceWorker& worker) {
gd::ResourceWorkerInEventsWorker eventsWorker(project, worker);
eventsWorker.Launch(events);
}
gd::ResourceWorkerInEventsWorker
GetResourceWorkerOnEvents(const gd::Project &project,
gd::ArbitraryResourceWorker &worker) {

View File

@@ -37,7 +37,7 @@ namespace gd {
* \see ResourcesMergingHelper
* \see gd::ResourcesInUseHelper
*
* \see gd::LaunchResourceWorkerOnEvents
* \see gd::GetResourceWorkerOnEvents
*
* \ingroup IDE
*/

View File

@@ -51,7 +51,6 @@ bool ProjectResourcesCopier::CopyAllResourcesTo(
// Copy resources
map<gd::String, gd::String>& resourcesNewFilename =
resourcesMergingHelper.GetAllResourcesOldAndNewFilename();
unsigned int i = 0;
for (map<gd::String, gd::String>::const_iterator it =
resourcesNewFilename.begin();
it != resourcesNewFilename.end();
@@ -71,8 +70,6 @@ bool ProjectResourcesCopier::CopyAllResourcesTo(
destinationFile + _("\"."));
}
}
++i;
}
return true;

View File

@@ -0,0 +1,35 @@
/*
* GDevelop JS Platform
* Copyright 2008-2023 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "SceneResourcesFinder.h"
#include "GDCore/IDE/ResourceExposer.h"
#include "GDCore/Project/Layout.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Serialization/SerializerElement.h"
namespace gd {
std::set<gd::String> SceneResourcesFinder::FindProjectResources(gd::Project &project) {
gd::SceneResourcesFinder resourceWorker;
gd::ResourceExposer::ExposeProjectResources(project, resourceWorker);
return resourceWorker.resourceNames;
}
std::set<gd::String> SceneResourcesFinder::FindSceneResources(gd::Project &project,
gd::Layout &layout) {
gd::SceneResourcesFinder resourceWorker;
gd::ResourceExposer::ExposeLayoutResources(project, layout, resourceWorker);
return resourceWorker.resourceNames;
}
void SceneResourcesFinder::AddUsedResource(gd::String &resourceName) {
if (resourceName.empty()) {
return;
}
resourceNames.insert(resourceName);
}
} // namespace gd

View File

@@ -0,0 +1,86 @@
/*
* GDevelop JS Platform
* Copyright 2008-2023 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#pragma once
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
#include "GDCore/String.h"
#include <set>
namespace gd {
class Project;
class Layout;
class SerializerElement;
} // namespace gd
namespace gd {
/**
* \brief Find resource usages in several parts of the project.
*
* \ingroup IDE
*/
class SceneResourcesFinder : private gd::ArbitraryResourceWorker {
public:
/**
* @brief Find resource usages in a given scenes.
*
* It doesn't include resources used globally.
*/
static std::set<gd::String> FindSceneResources(gd::Project &project,
gd::Layout &layout);
/**
* @brief Find resource that are used globally in the project.
*
* It doesn't include resources used in scenes.
*/
static std::set<gd::String> FindProjectResources(gd::Project &project);
virtual ~SceneResourcesFinder(){};
private:
SceneResourcesFinder() : gd::ArbitraryResourceWorker(){};
void AddUsedResource(gd::String &resourceName);
void ExposeFile(gd::String &resourceFileName) override{
// Don't do anything: we're renaming resources, not the files they are
// pointing to.
};
void ExposeImage(gd::String &imageResourceName) override {
AddUsedResource(imageResourceName);
};
void ExposeAudio(gd::String &audioResourceName) override {
AddUsedResource(audioResourceName);
};
void ExposeFont(gd::String &fontResourceName) override {
AddUsedResource(fontResourceName);
};
void ExposeJson(gd::String &jsonResourceName) override {
AddUsedResource(jsonResourceName);
};
void ExposeTilemap(gd::String &tilemapResourceName) override {
AddUsedResource(tilemapResourceName);
};
void ExposeTileset(gd::String &tilesetResourceName) override {
AddUsedResource(tilesetResourceName);
};
void ExposeVideo(gd::String &videoResourceName) override {
AddUsedResource(videoResourceName);
};
void ExposeBitmapFont(gd::String &bitmapFontName) override {
AddUsedResource(bitmapFontName);
};
void ExposeModel3D(gd::String &resourceName) override {
AddUsedResource(resourceName);
};
std::set<gd::String> resourceNames;
};
} // namespace gd

View File

@@ -20,6 +20,7 @@
#include "GDCore/Project/Project.h"
#include "GDCore/Project/ProjectScopedContainers.h"
#include "GDCore/String.h"
#include "GDCore/IDE/DependenciesAnalyzer.h"
namespace gd {
@@ -33,27 +34,8 @@ void ProjectBrowserHelper::ExposeProjectEvents(
// Add events based extensions
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
e++) {
// Add (free) events functions
auto &eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
for (auto &&eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
worker.Launch(eventsFunction->GetEvents());
}
// Add (behavior) events functions
for (auto &&eventsBasedBehavior :
eventsFunctionsExtension.GetEventsBasedBehaviors()
.GetInternalVector()) {
ExposeEventsBasedBehaviorEvents(project, *eventsBasedBehavior, worker);
}
// Add (object) events functions
for (auto &&eventsBasedObject :
eventsFunctionsExtension.GetEventsBasedObjects().GetInternalVector()) {
auto &objectEventsFunctions = eventsBasedObject->GetEventsFunctions();
for (auto &&eventsFunction : objectEventsFunctions.GetInternalVector()) {
worker.Launch(eventsFunction->GetEvents());
}
}
ProjectBrowserHelper::ExposeEventsFunctionsExtensionEvents(project, eventsFunctionsExtension, worker);
}
}
@@ -69,7 +51,7 @@ void ProjectBrowserHelper::ExposeProjectEventsWithoutExtensions(
}
}
void ProjectBrowserHelper::ExposeLayoutEvents(
void ProjectBrowserHelper::ExposeLayoutEventsAndExternalEvents(
gd::Project &project, gd::Layout &layout,
gd::ArbitraryEventsWorker &worker) {
@@ -85,7 +67,7 @@ void ProjectBrowserHelper::ExposeLayoutEvents(
}
}
void ProjectBrowserHelper::ExposeLayoutEvents(
void ProjectBrowserHelper::ExposeLayoutEventsAndExternalEvents(
gd::Project &project, gd::Layout &layout,
gd::ArbitraryEventsWorkerWithContext &worker) {
auto projectScopedContainers =
@@ -103,6 +85,32 @@ void ProjectBrowserHelper::ExposeLayoutEvents(
}
}
void ProjectBrowserHelper::ExposeLayoutEventsAndDependencies(
gd::Project &project, gd::Layout &layout,
gd::ArbitraryEventsWorker &worker) {
// Add layouts events
worker.Launch(layout.GetEvents());
DependenciesAnalyzer dependenciesAnalyzer(project, layout);
bool hasCircularDependencies = !dependenciesAnalyzer.Analyze();
if (hasCircularDependencies) {
// The analyzer stops when it finds circular dependencies so the dependencies are not complete.
// TODO Should the analyzer still continue to avoid side effect on thing that would not be code generation related?
// Maybe a boolean parameter should be added?
return;
}
for (const gd::String& externalEventName : dependenciesAnalyzer.GetExternalEventsDependencies()) {
gd::ExternalEvents& externalEvents = project.GetExternalEvents(externalEventName);
worker.Launch(externalEvents.GetEvents());
}
for (const gd::String& sceneName : dependenciesAnalyzer.GetScenesDependencies()) {
gd::Layout& dependencyLayout = project.GetLayout(sceneName);
worker.Launch(dependencyLayout.GetEvents());
}
}
void ProjectBrowserHelper::ExposeProjectEvents(
gd::Project &project, gd::ArbitraryEventsWorkerWithContext &worker) {
// See also gd::Project::ExposeResources for a method that traverse the whole
@@ -130,8 +138,43 @@ void ProjectBrowserHelper::ExposeProjectEvents(
// Add events based extensions
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
e++) {
// Add (free) events functions
auto &eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
ProjectBrowserHelper::ExposeEventsFunctionsExtensionEvents(project, eventsFunctionsExtension, worker);
}
}
void ProjectBrowserHelper::ExposeEventsFunctionsExtensionEvents(
gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension,
gd::ArbitraryEventsWorker &worker) {
// Add (free) events functions
for (auto &&eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
gd::ObjectsContainer globalObjectsAndGroups;
gd::ObjectsContainer objectsAndGroups;
gd::EventsFunctionTools::FreeEventsFunctionToObjectsContainer(
project, eventsFunctionsExtension, *eventsFunction,
globalObjectsAndGroups, objectsAndGroups);
worker.Launch(eventsFunction->GetEvents());
}
// Add (behavior) events functions
for (auto &&eventsBasedBehavior :
eventsFunctionsExtension.GetEventsBasedBehaviors()
.GetInternalVector()) {
ExposeEventsBasedBehaviorEvents(project, *eventsBasedBehavior, worker);
}
// Add (object) events functions
for (auto &&eventsBasedObject :
eventsFunctionsExtension.GetEventsBasedObjects().GetInternalVector()) {
ExposeEventsBasedObjectEvents(project, *eventsBasedObject, worker);
}
}
void ProjectBrowserHelper::ExposeEventsFunctionsExtensionEvents(
gd::Project &project, const gd::EventsFunctionsExtension &eventsFunctionsExtension,
gd::ArbitraryEventsWorkerWithContext &worker) {
// Add (free) events functions
for (auto &&eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
gd::ObjectsContainer globalObjectsAndGroups;
gd::ObjectsContainer objectsAndGroups;
@@ -157,7 +200,6 @@ void ProjectBrowserHelper::ExposeProjectEvents(
eventsFunctionsExtension.GetEventsBasedObjects().GetInternalVector()) {
ExposeEventsBasedObjectEvents(project, *eventsBasedObject, worker);
}
}
}
void ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
@@ -189,6 +231,21 @@ void ProjectBrowserHelper::ExposeEventsBasedBehaviorEvents(
}
}
void ProjectBrowserHelper::ExposeEventsBasedObjectEvents(
gd::Project &project, const gd::EventsBasedObject &eventsBasedObject,
gd::ArbitraryEventsWorker &worker) {
auto &objectEventsFunctions = eventsBasedObject.GetEventsFunctions();
for (auto &&eventsFunction : objectEventsFunctions.GetInternalVector()) {
gd::ObjectsContainer globalObjectsAndGroups;
gd::ObjectsContainer objectsAndGroups;
gd::EventsFunctionTools::ObjectEventsFunctionToObjectsContainer(
project, eventsBasedObject, *eventsFunction, globalObjectsAndGroups,
objectsAndGroups);
worker.Launch(eventsFunction->GetEvents());
}
}
void ProjectBrowserHelper::ExposeEventsBasedObjectEvents(
gd::Project &project, const gd::EventsBasedObject &eventsBasedObject,
gd::ArbitraryEventsWorkerWithContext &worker) {
@@ -216,7 +273,7 @@ void ProjectBrowserHelper::ExposeProjectObjects(
// Layout objects
for (size_t i = 0; i < project.GetLayoutsCount(); i++) {
worker.Launch(project.GetLayout(i));
gd::ProjectBrowserHelper::ExposeLayoutObjects(project.GetLayout(i), worker);
}
// Event based objects children
@@ -232,6 +289,14 @@ void ProjectBrowserHelper::ExposeProjectObjects(
}
};
void ProjectBrowserHelper::ExposeLayoutObjects(gd::Layout &layout,
gd::ArbitraryObjectsWorker &worker) {
// In the future, layouts may have children object containers.
// Layout objects
worker.Launch(layout);
}
void ProjectBrowserHelper::ExposeProjectFunctions(
gd::Project &project, gd::ArbitraryEventsFunctionsWorker &worker) {

View File

@@ -60,18 +60,52 @@ public:
* \brief Call the specified worker on all events of a layout and
* its external events.
*/
static void ExposeLayoutEvents(gd::Project &project, gd::Layout &layout,
static void ExposeLayoutEventsAndExternalEvents(gd::Project &project, gd::Layout &layout,
gd::ArbitraryEventsWorker &worker);
/**
* \brief Call the specified worker on all events of a layout and
* its external events.
*/
static void ExposeLayoutEvents(gd::Project &project, gd::Layout &layout,
static void ExposeLayoutEventsAndExternalEvents(gd::Project &project, gd::Layout &layout,
gd::ArbitraryEventsWorkerWithContext &worker);
/**
* \brief Call the specified worker on all events of a layout and
* its dependencies according to EventLink (external events or other layout
* events).
*/
static void
ExposeLayoutEventsAndDependencies(gd::Project &project, gd::Layout &layout,
gd::ArbitraryEventsWorker &worker);
/**
* \brief Call the specified worker on all events of the event-based
* behavior
* extension.
*
* This should be the preferred way to traverse all the events of an events
* based extension.
*/
static void ExposeEventsFunctionsExtensionEvents(
gd::Project &project,
const gd::EventsFunctionsExtension &eventsFunctionsExtension,
gd::ArbitraryEventsWorker &worker);
/**
* \brief Call the specified worker on all events of the event-based
* extension.
*
* This should be the preferred way to traverse all the events of an events
* based extension.
*/
static void ExposeEventsFunctionsExtensionEvents(
gd::Project &project,
const gd::EventsFunctionsExtension &eventsFunctionsExtension,
gd::ArbitraryEventsWorkerWithContext &worker);
/**
* \brief Call the specified worker on all events of the event-based
* behavior.
*
* This should be the preferred way to traverse all the events of an events
* based behavior.
@@ -93,10 +127,22 @@ public:
/**
* \brief Call the specified worker on all events of the event-based
* behavior.
* object.
*
* This should be the preferred way to traverse all the events of an
* event-based behavior.
* event-based object.
*/
static void
ExposeEventsBasedObjectEvents(gd::Project &project,
const gd::EventsBasedObject &eventsBasedObject,
gd::ArbitraryEventsWorker &worker);
/**
* \brief Call the specified worker on all events of the event-based
* object.
*
* This should be the preferred way to traverse all the events of an
* event-based object.
*/
static void
ExposeEventsBasedObjectEvents(gd::Project &project,
@@ -112,6 +158,14 @@ public:
static void ExposeProjectObjects(gd::Project &project,
gd::ArbitraryObjectsWorker &worker);
/**
* \brief Call the specified worker on all ObjectContainers of the layout.
*
* This should be the preferred way to traverse all the objects of a layout.
*/
static void ExposeLayoutObjects(gd::Layout &layout,
gd::ArbitraryObjectsWorker &worker);
/**
* \brief Call the specified worker on all FunctionsContainers of the project
* (global, layouts...)

View File

@@ -24,6 +24,7 @@
#include "GDCore/Extensions/Platform.h"
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
#include "GDCore/Extensions/Metadata/EffectMetadata.h"
#include "GDCore/IDE/Events/UsedExtensionsFinder.h"
namespace gd {
@@ -36,6 +37,7 @@ void ResourceExposer::ExposeWholeProjectResources(gd::Project& project, gd::Arbi
// Expose any project resources as files.
worker.ExposeResources(resourcesManager);
project.GetPlatformSpecificAssets().ExposeResources(worker);
// Expose event resources
@@ -73,6 +75,49 @@ void ResourceExposer::ExposeWholeProjectResources(gd::Project& project, gd::Arbi
worker.ExposeImage(loadingScreen.GetBackgroundImageResourceName());
}
void ResourceExposer::ExposeProjectResources(gd::Project& project, gd::ArbitraryResourceWorker& worker) {
// Expose global objects configuration resources
auto objectWorker = gd::GetResourceWorkerOnObjects(project, worker);
objectWorker.Launch(project);
}
void ResourceExposer::ExposeLayoutResources(
gd::Project &project, gd::Layout &layout,
gd::ArbitraryResourceWorker &worker) {
// Expose object configuration resources
auto objectWorker = gd::GetResourceWorkerOnObjects(project, worker);
gd::ProjectBrowserHelper::ExposeLayoutObjects(layout, objectWorker);
// Expose layer effect resources
for (std::size_t layerIndex = 0; layerIndex < layout.GetLayersCount();
layerIndex++) {
auto &layer = layout.GetLayer(layerIndex);
auto &effects = layer.GetEffects();
for (size_t effectIndex = 0; effectIndex < effects.GetEffectsCount();
effectIndex++) {
auto &effect = effects.GetEffect(effectIndex);
gd::ResourceExposer::ExposeEffectResources(project.GetCurrentPlatform(),
effect, worker);
}
}
// Expose event resources
auto eventWorker = gd::GetResourceWorkerOnEvents(project, worker);
gd::ProjectBrowserHelper::ExposeLayoutEventsAndDependencies(project, layout,
eventWorker);
// Exposed extension event resources
// Note that using resources in extensions is very unlikely and probably not
// worth the effort of something smart.
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
e++) {
auto &eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
gd::ProjectBrowserHelper::ExposeEventsFunctionsExtensionEvents(project, eventsFunctionsExtension, eventWorker);
}
}
void ResourceExposer::ExposeEffectResources(
gd::Platform &platform, gd::Effect &effect,
gd::ArbitraryResourceWorker &worker) {
@@ -88,11 +133,13 @@ void ResourceExposer::ExposeEffectResources(
auto &resourceType = propertyDescriptor.GetExtraInfo()[0];
const gd::String &resourceName = effect.GetStringParameter(propertyName);
gd::String potentiallyUpdatedResourceName = resourceName;
worker.ExposeResourceWithType(resourceType,
potentiallyUpdatedResourceName);
if (potentiallyUpdatedResourceName != resourceName) {
effect.SetStringParameter(propertyName, potentiallyUpdatedResourceName);
if (!resourceName.empty()) {
gd::String potentiallyUpdatedResourceName = resourceName;
worker.ExposeResourceWithType(resourceType,
potentiallyUpdatedResourceName);
if (potentiallyUpdatedResourceName != resourceName) {
effect.SetStringParameter(propertyName, potentiallyUpdatedResourceName);
}
}
}
}

View File

@@ -10,6 +10,7 @@ class Platform;
class Project;
class ArbitraryResourceWorker;
class Effect;
class Layout;
} // namespace gd
namespace gd {
@@ -31,6 +32,25 @@ public:
static void ExposeWholeProjectResources(gd::Project &project,
gd::ArbitraryResourceWorker &worker);
/**
* @brief Expose only the resources used globally on a project.
*
* It doesn't include resources used in layouts.
*/
static void ExposeProjectResources(gd::Project &project,
gd::ArbitraryResourceWorker &worker);
/**
* @brief Expose the resources used in a given layout.
*
* It doesn't include resources used globally.
*/
static void ExposeLayoutResources(gd::Project &project, gd::Layout &layout,
gd::ArbitraryResourceWorker &worker);
/**
* @brief Expose the resources used in a given effect.
*/
static void ExposeEffectResources(gd::Platform &platform, gd::Effect &effect,
gd::ArbitraryResourceWorker &worker);
};

View File

@@ -1538,7 +1538,7 @@ void WholeProjectRefactorer::RenameLayer(gd::Project &project,
return;
gd::ProjectElementRenamer projectElementRenamer(project.GetCurrentPlatform(),
"layer", oldName, newName);
gd::ProjectBrowserHelper::ExposeLayoutEvents(project, layout,
gd::ProjectBrowserHelper::ExposeLayoutEventsAndExternalEvents(project, layout,
projectElementRenamer);
}
@@ -1552,7 +1552,7 @@ void WholeProjectRefactorer::RenameLayerEffect(gd::Project &project,
gd::ProjectElementRenamer projectElementRenamer(
project.GetCurrentPlatform(), "layerEffectName", oldName, newName);
projectElementRenamer.SetLayerConstraint(layer.GetName());
gd::ProjectBrowserHelper::ExposeLayoutEvents(project, layout,
gd::ProjectBrowserHelper::ExposeLayoutEventsAndExternalEvents(project, layout,
projectElementRenamer);
}
@@ -1566,7 +1566,7 @@ void WholeProjectRefactorer::RenameObjectAnimation(gd::Project &project,
gd::ProjectElementRenamer projectElementRenamer(
project.GetCurrentPlatform(), "objectAnimationName", oldName, newName);
projectElementRenamer.SetObjectConstraint(object.GetName());
gd::ProjectBrowserHelper::ExposeLayoutEvents(project, layout,
gd::ProjectBrowserHelper::ExposeLayoutEventsAndExternalEvents(project, layout,
projectElementRenamer);
}
@@ -1580,7 +1580,7 @@ void WholeProjectRefactorer::RenameObjectPoint(gd::Project &project,
gd::ProjectElementRenamer projectElementRenamer(
project.GetCurrentPlatform(), "objectPointName", oldName, newName);
projectElementRenamer.SetObjectConstraint(object.GetName());
gd::ProjectBrowserHelper::ExposeLayoutEvents(project, layout,
gd::ProjectBrowserHelper::ExposeLayoutEventsAndExternalEvents(project, layout,
projectElementRenamer);
}
@@ -1594,7 +1594,7 @@ void WholeProjectRefactorer::RenameObjectEffect(gd::Project &project,
gd::ProjectElementRenamer projectElementRenamer(
project.GetCurrentPlatform(), "objectEffectName", oldName, newName);
projectElementRenamer.SetObjectConstraint(object.GetName());
gd::ProjectBrowserHelper::ExposeLayoutEvents(project, layout,
gd::ProjectBrowserHelper::ExposeLayoutEventsAndExternalEvents(project, layout,
projectElementRenamer);
}

View File

@@ -5,6 +5,8 @@
*/
#include "CustomConfigurationHelper.h"
#include <map>
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
#include "GDCore/Project/Behavior.h"
#include "GDCore/Project/Project.h"
@@ -13,8 +15,6 @@
#include "GDCore/Serialization/Serializer.h"
#include "GDCore/Serialization/SerializerElement.h"
#include <map>
using namespace gd;
void CustomConfigurationHelper::InitializeContent(
@@ -25,7 +25,8 @@ void CustomConfigurationHelper::InitializeContent(
auto propertyType = property->GetType();
if (propertyType == "String" || propertyType == "Choice" ||
propertyType == "Color" || propertyType == "Behavior") {
propertyType == "Color" || propertyType == "Behavior" ||
propertyType == "resource") {
element.SetStringValue(property->GetValue());
} else if (propertyType == "Number") {
element.SetDoubleValue(property->GetValue().To<double>());
@@ -51,7 +52,8 @@ std::map<gd::String, gd::PropertyDescriptor> CustomConfigurationHelper::GetPrope
if (configurationContent.HasChild(propertyName)) {
if (propertyType == "String" || propertyType == "Choice" ||
propertyType == "Color" || propertyType == "Behavior") {
propertyType == "Color" || propertyType == "Behavior" ||
propertyType == "resource") {
newProperty.SetValue(
configurationContent.GetChild(propertyName).GetStringValue());
} else if (propertyType == "Number") {
@@ -59,8 +61,9 @@ std::map<gd::String, gd::PropertyDescriptor> CustomConfigurationHelper::GetPrope
configurationContent.GetChild(propertyName).GetDoubleValue()));
} else if (propertyType == "Boolean") {
newProperty.SetValue(
configurationContent.GetChild(propertyName).GetBoolValue() ? "true"
: "false");
configurationContent.GetChild(propertyName).GetBoolValue()
? "true"
: "false");
}
} else {
// No value was serialized for this property. `newProperty`
@@ -85,7 +88,8 @@ bool CustomConfigurationHelper::UpdateProperty(
const gd::String &propertyType = property.GetType();
if (propertyType == "String" || propertyType == "Choice" ||
propertyType == "Color" || propertyType == "Behavior") {
propertyType == "Color" || propertyType == "Behavior" ||
propertyType == "resource") {
element.SetStringValue(newValue);
} else if (propertyType == "Number") {
element.SetDoubleValue(newValue.To<double>());

View File

@@ -534,19 +534,7 @@ void ResourcesManager::SerializeTo(SerializerElement& element) const {
if (resources[i] == std::shared_ptr<Resource>()) break;
SerializerElement& resourceElement = resourcesElement.AddChild("resource");
resourceElement.SetAttribute("kind", resources[i]->GetKind());
resourceElement.SetAttribute("name", resources[i]->GetName());
resourceElement.SetAttribute("metadata", resources[i]->GetMetadata());
const gd::String& originName = resources[i]->GetOriginName();
const gd::String& originIdentifier = resources[i]->GetOriginIdentifier();
if (!originName.empty() || !originIdentifier.empty()) {
resourceElement.AddChild("origin")
.SetAttribute("name", originName)
.SetAttribute("identifier", originIdentifier);
}
resources[i]->SerializeTo(resourceElement);
gd::ResourcesManager::SerializeResourceTo(*resources[i], resourceElement);
}
SerializerElement& resourcesFoldersElement =
@@ -556,6 +544,22 @@ void ResourcesManager::SerializeTo(SerializerElement& element) const {
folders[i].SerializeTo(resourcesFoldersElement.AddChild("folder"));
}
void ResourcesManager::SerializeResourceTo(gd::Resource &resource,
SerializerElement &resourceElement) {
resourceElement.SetAttribute("kind", resource.GetKind());
resourceElement.SetAttribute("name", resource.GetName());
resourceElement.SetAttribute("metadata", resource.GetMetadata());
const gd::String &originName = resource.GetOriginName();
const gd::String &originIdentifier = resource.GetOriginIdentifier();
if (!originName.empty() || !originIdentifier.empty()) {
resourceElement.AddChild("origin")
.SetAttribute("name", originName)
.SetAttribute("identifier", originIdentifier);
}
resource.SerializeTo(resourceElement);
}
void ImageResource::SetFile(const gd::String& newFile) {
file = NormalizePathSeparator(newFile);
}

View File

@@ -662,6 +662,11 @@ class GD_CORE_API ResourcesManager {
*/
void SerializeTo(SerializerElement& element) const;
/**
* \brief Serialize one resource.
*/
static void SerializeResourceTo(gd::Resource& resource, SerializerElement& resourceElement);
/**
* \brief Unserialize the object.
*/

File diff suppressed because it is too large Load Diff

View File

@@ -5398,12 +5398,10 @@ class Runner {
getRegistryHub().getTestCaseRegistry().getFilteredTests(
testSpec, *m_config, testCases);
int testsRunForGroup = 0;
for (std::vector<TestCase>::const_iterator it = testCases.begin(),
itEnd = testCases.end();
it != itEnd;
++it) {
testsRunForGroup++;
if (m_testsAlreadyRun.find(*it) == m_testsAlreadyRun.end()) {
if (context.aborting()) break;

View File

@@ -39,16 +39,18 @@ module.exports = {
.setIcon('res/conditions/3d_box.svg');
{
const base3D = extension.addBehavior(
"Base3DBehavior",
_("3D capability"),
"Object3D",
_("Move the object in 3D space."),
"",
"res/conditions/3d_box.svg",
"Base3DBehavior",
const base3D = extension
.addBehavior(
'Base3DBehavior',
_('3D capability'),
'Object3D',
_('Move the object in 3D space.'),
'',
'res/conditions/3d_box.svg',
'Base3DBehavior',
new gd.Behavior(),
new gd.BehaviorsSharedData())
new gd.BehaviorsSharedData()
)
.setHidden()
.setIncludeFile('Extensions/3D/Base3DBehavior.js');
@@ -63,11 +65,11 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setZ')
.setGetter('getZ');
base3D
.addExpressionAndConditionAndAction(
'number',
@@ -95,23 +97,23 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setDepth')
.setGetter('getDepth');
base3D
base3D
.addExpressionAndConditionAndAction(
'number',
'ScaleZ',
_('Scale on Z axis'),
_("the scale on Z axis of an object (default scale is 1)"),
_("the scale on Z axis scale"),
_('the scale on Z axis of an object (default scale is 1)'),
_('the scale on Z axis scale'),
_('Size'),
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.useStandardParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
@@ -122,7 +124,7 @@ module.exports = {
.setFunctionName('setScaleZ')
.setGetter('getScaleZ');
base3D
base3D
.addScopedAction(
'FlipZ',
_('Flip the object on Z'),
@@ -133,12 +135,12 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.addParameter('yesorno', _('Activate flipping'))
.markAsSimple()
.setFunctionName('flipZ');
base3D
base3D
.addScopedCondition(
'FlippedZ',
_('Flipped on Z'),
@@ -149,10 +151,10 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.setFunctionName('isFlippedZ');
base3D
base3D
.addExpressionAndConditionAndAction(
'number',
'RotationX',
@@ -163,12 +165,12 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setRotationX')
.setGetter('getRotationX');
base3D
base3D
.addExpressionAndConditionAndAction(
'number',
'RotationY',
@@ -179,12 +181,12 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setRotationY')
.setGetter('getRotationY');
base3D
base3D
.addScopedAction(
'TurnAroundX',
_('Turn around X axis'),
@@ -197,12 +199,12 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.addParameter('number', _('Rotation angle'), '', false)
.markAsAdvanced()
.setFunctionName('turnAroundX');
base3D
base3D
.addScopedAction(
'TurnAroundY',
_('Turn around Y axis'),
@@ -215,12 +217,12 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.addParameter('number', _('Rotation angle'), '', false)
.markAsAdvanced()
.setFunctionName('turnAroundY');
base3D
base3D
.addScopedAction(
'TurnAroundZ',
_('Turn around Z axis'),
@@ -233,7 +235,7 @@ module.exports = {
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D object'))
.addParameter("behavior", _("Behavior"), "Base3DBehavior")
.addParameter('behavior', _('Behavior'), 'Base3DBehavior')
.addParameter('number', _('Rotation angle'), '', false)
.markAsAdvanced()
.setFunctionName('turnAroundZ');
@@ -249,7 +251,7 @@ module.exports = {
new gd.Model3DObjectConfiguration()
)
.setCategoryFullName(_('General'))
// Effects are unsupported because the object is not rendered with PIXI.
// Effects are unsupported because the object is not rendered with PIXI.
.addDefaultBehavior('ResizableCapability::ResizableBehavior')
.addDefaultBehavior('ScalableCapability::ScalableBehavior')
.addDefaultBehavior('FlippableCapability::FlippableBehavior')
@@ -280,7 +282,6 @@ module.exports = {
.setFunctionName('setZ')
.setGetter('getZ');
// Deprecated
object
.addExpressionAndConditionAndAction(
@@ -1161,7 +1162,7 @@ module.exports = {
.setFunctionName('setZ')
.setGetter('getZ');
// Deprecated
// Deprecated
object
.addExpressionAndConditionAndAction(
'number',
@@ -1306,7 +1307,7 @@ module.exports = {
.setFunctionName('setScaleX')
.setGetter('getScaleX');
// Deprecated
// Deprecated
object
.addExpressionAndConditionAndAction(
'number',
@@ -1664,7 +1665,7 @@ module.exports = {
'Change the camera rotation to look at an object. The camera top always face the screen.'
),
_('Change the camera rotation of _PARAM2_ to look at _PARAM1_'),
'',
_("Layers and cameras"),
'res/conditions/3d_box.svg',
'res/conditions/3d_box.svg'
)
@@ -2098,6 +2099,12 @@ module.exports = {
this.updateTexture();
}
onRemovedFromScene() {
super.onRemovedFromScene();
// Keep textures because they are shared by all sprites.
this._pixiObject.destroy({ children: true });
}
static _getResourceNameToDisplay(objectConfiguration) {
return getFirstVisibleFaceResourceName(objectConfiguration);
}
@@ -2162,17 +2169,18 @@ module.exports = {
updatePIXISprite() {
const width = this.getWidth();
const height = this.getHeight();
const objectTextureFrame = this._pixiTexturedObject.texture.frame;
// In case the texture is not loaded yet, we don't want to crash.
if (!objectTextureFrame) return;
this._pixiTexturedObject.anchor.x =
this._centerX / this._pixiTexturedObject.texture.frame.width;
this._centerX / objectTextureFrame.width;
this._pixiTexturedObject.anchor.y =
this._centerY / this._pixiTexturedObject.texture.frame.height;
this._centerY / objectTextureFrame.height;
this._pixiTexturedObject.angle = this._instance.getAngle();
this._pixiTexturedObject.scale.x =
width / this._pixiTexturedObject.texture.frame.width;
this._pixiTexturedObject.scale.y =
height / this._pixiTexturedObject.texture.frame.height;
this._pixiTexturedObject.scale.x = width / objectTextureFrame.width;
this._pixiTexturedObject.scale.y = height / objectTextureFrame.height;
this._pixiTexturedObject.position.x =
this._instance.getX() +
@@ -2681,6 +2689,11 @@ module.exports = {
});
}
onRemovedFromScene() {
super.onRemovedFromScene();
this._pixiObject.destroy({ children: true });
}
static getThumbnail(project, resourcesLoader, objectConfiguration) {
return 'JsPlatform/Extensions/3d_box.svg';
}

View File

@@ -86,11 +86,13 @@ namespace gdjs {
export const turnCameraTowardObject = (
runtimeScene: RuntimeScene,
object: gdjs.RuntimeObject,
object: gdjs.RuntimeObject | null,
layerName: string,
cameraIndex: integer,
isStandingOnY: boolean
) => {
if (!object) return;
const layer = runtimeScene.getLayer(layerName);
const layerRenderer = layer.getRenderer();

View File

@@ -36,7 +36,7 @@ module.exports = {
extension
.addAction(
'Focus',
_('Change focus of the window'),
_('Window focus'),
_('Make the window gain or lose focus.'),
_('Focus the window: _PARAM0_'),
_('Windows, Linux, macOS'),
@@ -72,7 +72,7 @@ module.exports = {
extension
.addAction(
'Show',
_('Change visibility of the window'),
_('Window visibility'),
_('Make the window visible or invisible.'),
_('Window visible: _PARAM0_'),
_('Windows, Linux, macOS'),
@@ -624,7 +624,7 @@ module.exports = {
extension
.addAction(
'SetOpacity',
_('Set window opacity'),
_('Window opacity'),
_('Changes the window opacity.'),
_('Set the window opacity to _PARAM0_'),
_('Windows, Linux, macOS'),
@@ -645,7 +645,7 @@ module.exports = {
extension
.addAction(
'SetWindowPosition',
_('Set window position'),
_('Window position'),
_('Changes the window position.'),
_('Set the window position to _PARAM0_;_PARAM1_'),
_('Windows, Linux, macOS'),

View File

@@ -30,6 +30,7 @@ describe('gdjs.AnchorRuntimeBehavior', function () {
behaviorsSharedData: [],
objects: [],
instances: [],
usedResources: [],
});
function createObject(behaviorProperties) {

View File

@@ -130,8 +130,8 @@ namespace gdjs {
}
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.destroy();
}

View File

@@ -141,8 +141,8 @@ namespace gdjs {
}
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.onDestroy();
}

View File

@@ -41,7 +41,7 @@ void DeclareDestroyOutsideBehaviorExtension(gd::PlatformExtension& extension) {
_("Compare the additional border that the object must cross "
"before being deleted."),
_("the additional border"),
"",
_("Destroy outside configuration"),
"CppPlatform/Extensions/destroyoutsideicon24.png",
"CppPlatform/Extensions/destroyoutsideicon16.png")
.AddParameter("object", _("Object"))
@@ -56,7 +56,7 @@ void DeclareDestroyOutsideBehaviorExtension(gd::PlatformExtension& extension) {
_("Change the additional border that the object must cross "
"before being deleted."),
_("the additional border"),
"",
_("Destroy outside configuration"),
"CppPlatform/Extensions/destroyoutsideicon24.png",
"CppPlatform/Extensions/destroyoutsideicon16.png")
.AddParameter("object", _("Object"))

View File

@@ -39,7 +39,7 @@ void DeclareDraggableBehaviorExtension(gd::PlatformExtension& extension) {
_("Being dragged"),
_("Check if the object is being dragged."),
_("_PARAM0_ is being dragged"),
"",
_("Draggable"),
"CppPlatform/Extensions/draggableicon24.png",
"CppPlatform/Extensions/draggableicon16.png")
@@ -51,7 +51,7 @@ void DeclareDraggableBehaviorExtension(gd::PlatformExtension& extension) {
_("Was just dropped"),
_("Check if the object was just dropped after being dragged."),
_("_PARAM0_ was just dropped"),
"",
_("Draggable"),
"CppPlatform/Extensions/draggableicon24.png",
"CppPlatform/Extensions/draggableicon16.png")

View File

@@ -27,6 +27,7 @@ describe('gdjs.DraggableRuntimeBehavior', function () {
behaviorsSharedData: [],
objects: [],
instances: [],
usedResources: [],
});
var object = new gdjs.TestRuntimeObject(runtimeScene, {

View File

@@ -497,89 +497,84 @@ module.exports = {
/**
* Renderer for instances of DummyObject inside the IDE.
*
* @extends RenderedInstance
* @class RenderedDummyObjectInstance
* @constructor
*/
function RenderedDummyObjectInstance(
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
) {
RenderedInstance.call(
this,
class RenderedDummyObjectInstance extends RenderedInstance {
constructor(
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
);
) {
super(
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
);
//Setup the PIXI object:
this._pixiObject = new PIXI.Text('This is a dummy object', {
align: 'left',
});
this._pixiObject.anchor.x = 0.5;
this._pixiObject.anchor.y = 0.5;
this._pixiContainer.addChild(this._pixiObject);
this.update();
//Setup the PIXI object:
this._pixiObject = new PIXI.Text('This is a dummy object', {
align: 'left',
});
this._pixiObject.anchor.x = 0.5;
this._pixiObject.anchor.y = 0.5;
this._pixiContainer.addChild(this._pixiObject);
this.update();
}
onRemovedFromScene() {
super.onRemovedFromScene();
this._pixiObject.destroy(true);
}
/**
* Return the path to the thumbnail of the specified object.
*/
static getThumbnail(project, resourcesLoader, objectConfiguration) {
return 'CppPlatform/Extensions/texticon24.png';
}
/**
* This is called to update the PIXI object on the scene editor
*/
update() {
// Read a property from the object
const property1Value = this._associatedObjectConfiguration
.getProperties()
.get('My first property')
.getValue();
this._pixiObject.text = property1Value;
// Read position and angle from the instance
this._pixiObject.position.x =
this._instance.getX() + this._pixiObject.width / 2;
this._pixiObject.position.y =
this._instance.getY() + this._pixiObject.height / 2;
this._pixiObject.rotation = RenderedInstance.toRad(
this._instance.getAngle()
);
// Custom size can be read in this.getCustomWidth() and
// this.getCustomHeight()
}
/**
* Return the width of the instance, when it's not resized.
*/
getDefaultWidth() {
return this._pixiObject.width;
}
/**
* Return the height of the instance, when it's not resized.
*/
getDefaultHeight() {
return this._pixiObject.height;
}
}
RenderedDummyObjectInstance.prototype = Object.create(
RenderedInstance.prototype
);
/**
* Return the path to the thumbnail of the specified object.
*/
RenderedDummyObjectInstance.getThumbnail = function (
project,
resourcesLoader,
objectConfiguration
) {
return 'CppPlatform/Extensions/texticon24.png';
};
/**
* This is called to update the PIXI object on the scene editor
*/
RenderedDummyObjectInstance.prototype.update = function () {
// Read a property from the object
const property1Value = this._associatedObjectConfiguration
.getProperties()
.get('My first property')
.getValue();
this._pixiObject.text = property1Value;
// Read position and angle from the instance
this._pixiObject.position.x =
this._instance.getX() + this._pixiObject.width / 2;
this._pixiObject.position.y =
this._instance.getY() + this._pixiObject.height / 2;
this._pixiObject.rotation = RenderedInstance.toRad(
this._instance.getAngle()
);
// Custom size can be read in this.getCustomWidth() and
// this.getCustomHeight()
};
/**
* Return the width of the instance, when it's not resized.
*/
RenderedDummyObjectInstance.prototype.getDefaultWidth = function () {
return this._pixiObject.width;
};
/**
* Return the height of the instance, when it's not resized.
*/
RenderedDummyObjectInstance.prototype.getDefaultHeight = function () {
return this._pixiObject.height;
};
objectsRenderingService.registerInstanceRenderer(
'MyDummyExtension::DummyObject',

View File

@@ -86,7 +86,7 @@ module.exports = {
extension
.addAction(
'AnalyticsSetUID',
_('Change user UID'),
_('User UID'),
_(
"Changes the current user's analytics identifier. " +
'This is what let Analytics differentiate user, ' +
@@ -400,7 +400,7 @@ module.exports = {
extension
.addStrExpression(
'GetAuthToken',
_('Get the user authentication token'),
_('User authentication token'),
_(
'Get the user authentication token. The token is the proof of authentication.'
),
@@ -438,8 +438,8 @@ module.exports = {
extension
.addStrExpression(
'GetUserEmail',
_('Get the user email address'),
_('Gets the user email address.'),
_('User email address'),
_('Return the user email address.'),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png'
)
@@ -455,8 +455,8 @@ module.exports = {
extension
.addStrExpression(
'GetAccountCreationTime',
_('Get the accounts creation time'),
_('Gets the accounts creation time.'),
_('Accounts creation time'),
_('Return the accounts creation time.'),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png'
)
@@ -472,8 +472,8 @@ module.exports = {
extension
.addStrExpression(
'GetLastLoginTime',
_('Get the user last login time'),
_('Gets the user last login time.'),
_('User last login time'),
_('Return the user last login time.'),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png'
)
@@ -489,8 +489,8 @@ module.exports = {
extension
.addStrExpression(
'GetUserDisplayName',
_('Get the user display name'),
_('Gets the user display name.'),
_('User display name'),
_('Return the user display name.'),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png'
)
@@ -506,8 +506,8 @@ module.exports = {
extension
.addStrExpression(
'GetPhoneNumber',
_('Get the user phone number'),
_('Gets the user phone number.'),
_('User phone number'),
_('Return the user phone number.'),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png'
)
@@ -523,9 +523,9 @@ module.exports = {
extension
.addStrExpression(
'GetUserUID',
_('Get the user UID'),
_('User UID'),
_(
'Gets the user Unique IDentifier. Use that to link data to an ' +
'Return the user Unique IDentifier. Use that to link data to an ' +
'user instead of the name or email.'
),
_('Authentication/User Management'),
@@ -543,8 +543,8 @@ module.exports = {
extension
.addStrExpression(
'GetTenantID',
_('Get the user tenant ID'),
_('Gets the user tenant ID. For advanced usage only.'),
_('User tenant ID'),
_('Return the user tenant ID. For advanced usage only.'),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png'
)
@@ -560,8 +560,8 @@ module.exports = {
extension
.addStrExpression(
'GetRefreshToken',
_('Get the user refresh token'),
_('Gets the user refresh token. For advanced usage only.'),
_('User refresh token'),
_('Return the user refresh token. For advanced usage only.'),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png'
)
@@ -577,7 +577,7 @@ module.exports = {
extension
.addStrExpression(
'GetPhotoURL',
_('Get the user profile picture URL'),
_('Profile picture URL'),
_('Gets an URL to the user profile picture.'),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png'
@@ -635,7 +635,7 @@ module.exports = {
extension
.addAction(
'SetDisplayName',
_('Set display name'),
_('Display name'),
_('Sets the user display name.'),
_("Set the user's display name to _PARAM0_"),
_('Authentication/User Management'),
@@ -655,9 +655,9 @@ module.exports = {
extension
.addAction(
'SetPhotoURL',
_('Set the user profile picture'),
_('Sets the user profile picture URL to a new one.'),
_("Set the user's profile picture URL to _PARAM0_"),
_('Profile picture'),
_('Change the user profile picture URL to a new one.'),
_("Change the user's profile picture URL to _PARAM0_"),
_('Authentication/User Management'),
'JsPlatform/Extensions/firebase.png',
'JsPlatform/Extensions/firebase.png'
@@ -676,7 +676,7 @@ module.exports = {
extension
.addAction(
'ChangeEmail',
_('Change the user email'),
_('User email'),
_(
'This action is dangerous so it requires reauthentication.\n' +
"Changes the user's email address."
@@ -716,7 +716,7 @@ module.exports = {
extension
.addAction(
'ChangeEmailProvider',
_('Change the user email (Provider)'),
_('User email (Provider)'),
_(
'This action is dangerous so it requires reauthentication.\n' +
"Changes the user's email address.\n" +
@@ -755,7 +755,7 @@ module.exports = {
extension
.addAction(
'ChangePassword',
_('Change the user password'),
_('User password'),
_(
'This action is dangerous so it requires reauthentication.\n' +
'Changes the user password.'
@@ -796,7 +796,7 @@ module.exports = {
extension
.addAction(
'ChangePasswordProvider',
_('Change the user password (Provider)'),
_('User password (Provider)'),
_(
'This action is dangerous so it requires reauthentication.\n' +
'Changes the user password.\n' +
@@ -1782,7 +1782,7 @@ module.exports = {
.addAction(
'FirestoreGetField',
_('Get a field of a document'),
_('Gets the value of a field in a firestore document.'),
_('Return the value of a field in a firestore document.'),
_(
'Load field _PARAM2_ of firestore document _PARAM1_ in collection _PARAM0_ into _PARAM3_ (store result state in _PARAM4_)'
),
@@ -2213,7 +2213,7 @@ module.exports = {
'DatabaseGetField',
_('Get a field of a variable'),
_(
'Gets the value of a field in a variable from the database and store it in a scene variable.'
'Return the value of a field in a variable from the database and store it in a scene variable.'
),
_(
'Load field _PARAM1_ of database variable _PARAM0_ into _PARAM2_ (store result state in _PARAM3_)'

View File

@@ -203,7 +203,7 @@ module.exports = {
object
.addAction(
'SetRadius',
_('Set the radius of light object'),
_('Light radius'),
_('Set the radius of light object'),
_('Set the radius of _PARAM0_ to: _PARAM1_'),
'',
@@ -218,7 +218,7 @@ module.exports = {
object
.addAction(
'SetColor',
_('Set the color of light object'),
_('Light color'),
_('Set the color of light object in format "R;G;B" string.'),
_('Set the color of _PARAM0_ to: _PARAM1_'),
'',
@@ -263,107 +263,107 @@ module.exports = {
/**
* Renderer for instances of LightObject inside the IDE.
*
* @extends RenderedInstance
* @class RenderedLightObjectInstance
* @constructor
*/
function RenderedLightObjectInstance(
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
) {
RenderedInstance.call(
this,
class RenderedLightObjectInstance extends RenderedInstance {
constructor(
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
);
this._radius = parseFloat(
this._associatedObjectConfiguration
.getProperties(this.project)
.get('radius')
.getValue()
);
if (this._radius <= 0) this._radius = 1;
const color = objectsRenderingService.rgbOrHexToHexNumber(
this._associatedObjectConfiguration
.getProperties(this.project)
.get('color')
.getValue()
);
) {
super(
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
);
this._radius = parseFloat(
this._associatedObjectConfiguration
.getProperties(this.project)
.get('radius')
.getValue()
);
if (this._radius <= 0) this._radius = 1;
const color = objectsRenderingService.rgbOrHexToHexNumber(
this._associatedObjectConfiguration
.getProperties(this.project)
.get('color')
.getValue()
);
// The icon in the middle.
const lightIconSprite = new PIXI.Sprite(PIXI.Texture.from('CppPlatform/Extensions/lightIcon32.png'));
lightIconSprite.anchor.x = 0.5;
lightIconSprite.anchor.y = 0.5;
// The icon in the middle.
const lightIconSprite = new PIXI.Sprite(PIXI.Texture.from('CppPlatform/Extensions/lightIcon32.png'));
lightIconSprite.anchor.x = 0.5;
lightIconSprite.anchor.y = 0.5;
// The circle to show the radius of the light.
const radiusBorderWidth = 2;
const radiusGraphics = new PIXI.Graphics();
radiusGraphics.lineStyle(
radiusBorderWidth,
color,
0.8
);
radiusGraphics.drawCircle(0, 0, Math.max(1, this._radius - radiusBorderWidth));
// The circle to show the radius of the light.
const radiusBorderWidth = 2;
const radiusGraphics = new PIXI.Graphics();
radiusGraphics.lineStyle(
radiusBorderWidth,
color,
0.8
);
radiusGraphics.drawCircle(0, 0, Math.max(1, this._radius - radiusBorderWidth));
this._pixiObject = new PIXI.Container();
this._pixiObject.addChild(lightIconSprite);
this._pixiObject.addChild(radiusGraphics);
this._pixiContainer.addChild(this._pixiObject);
this.update();
this._pixiObject = new PIXI.Container();
this._pixiObject.addChild(lightIconSprite);
this._pixiObject.addChild(radiusGraphics);
this._pixiContainer.addChild(this._pixiObject);
this.update();
}
onRemovedFromScene() {
super.onRemovedFromScene();
// Keep textures because they are shared by all sprites.
this._pixiObject.destroy({ children: true });
}
/**
* Return the path to the thumbnail of the specified object.
*/
static getThumbnail(
project,
resourcesLoader,
objectConfiguration
) {
return 'CppPlatform/Extensions/lightIcon32.png';
}
/**
* This is called to update the PIXI object on the scene editor
*/
update() {
this._pixiObject.position.x = this._instance.getX();
this._pixiObject.position.y = this._instance.getY();
}
/**
* Return the width of the instance, when it's not resized.
*/
getDefaultWidth() {
return this._radius * 2;
}
/**
* Return the height of the instance, when it's not resized.
*/
getDefaultHeight() {
return this._radius * 2;
}
getOriginX() {
return this._radius;
}
getOriginY() {
return this._radius;
}
}
RenderedLightObjectInstance.prototype = Object.create(
RenderedInstance.prototype
);
/**
* Return the path to the thumbnail of the specified object.
*/
RenderedLightObjectInstance.getThumbnail = function (
project,
resourcesLoader,
objectConfiguration
) {
return 'CppPlatform/Extensions/lightIcon32.png';
};
/**
* This is called to update the PIXI object on the scene editor
*/
RenderedLightObjectInstance.prototype.update = function () {
this._pixiObject.position.x = this._instance.getX();
this._pixiObject.position.y = this._instance.getY();
};
/**
* Return the width of the instance, when it's not resized.
*/
RenderedLightObjectInstance.prototype.getDefaultWidth = function () {
return this._radius * 2;
};
/**
* Return the height of the instance, when it's not resized.
*/
RenderedLightObjectInstance.prototype.getDefaultHeight = function () {
return this._radius * 2;
};
RenderedLightObjectInstance.prototype.getOriginX = function () {
return this._radius;
};
RenderedLightObjectInstance.prototype.getOriginY = function () {
return this._radius;
};
objectsRenderingService.registerInstanceRenderer(
'Lighting::LightObject',

View File

@@ -1,11 +1,9 @@
namespace gdjs {
declare var rbush: any;
export class LightObstaclesManager {
_obstacleRBush: any;
_obstacleRBush: RBush<LightObstacleRuntimeBehavior>;
constructor(instanceContainer: gdjs.RuntimeInstanceContainer) {
this._obstacleRBush = new rbush();
this._obstacleRBush = new RBush<LightObstacleRuntimeBehavior>();
}
/**
@@ -41,6 +39,9 @@ namespace gdjs {
* added before.
*/
removeObstacle(obstacle: gdjs.LightObstacleRuntimeBehavior) {
if (!obstacle.currentRBushAABB) {
return;
}
this._obstacleRBush.remove(obstacle.currentRBushAABB);
}
@@ -59,9 +60,9 @@ namespace gdjs {
// is not necessarily in the middle of the object (for sprites for example).
const x = object.getX();
const y = object.getY();
const searchArea = gdjs.staticObject(
const searchArea: SearchArea = gdjs.staticObject(
LightObstaclesManager.prototype.getAllObstaclesAround
);
) as SearchArea;
// @ts-ignore
searchArea.minX = x - radius;
// @ts-ignore
@@ -70,13 +71,8 @@ namespace gdjs {
searchArea.maxX = x + radius;
// @ts-ignore
searchArea.maxY = y + radius;
const nearbyObstacles: gdjs.BehaviorRBushAABB<
gdjs.LightObstacleRuntimeBehavior
>[] = this._obstacleRBush.search(searchArea);
result.length = 0;
nearbyObstacles.forEach((nearbyObstacle) =>
result.push(nearbyObstacle.behavior)
);
this._obstacleRBush.search(searchArea, result);
}
}

View File

@@ -34,7 +34,7 @@ void DeclareLinkedObjectsExtension(gd::PlatformExtension& extension) {
_("Link two objects together, so as to be able to get one "
"from the other."),
_("Link _PARAM1_ and _PARAM2_"),
"",
_("Objects"),
"CppPlatform/Extensions/LinkedObjectsicon24.png",
"CppPlatform/Extensions/LinkedObjectsicon24.png")
@@ -49,7 +49,7 @@ void DeclareLinkedObjectsExtension(gd::PlatformExtension& extension) {
_("Unlink two objects"),
_("Unlink two objects."),
_("Unlink _PARAM1_ and _PARAM2_"),
"",
_("Objects"),
"CppPlatform/Extensions/LinkedObjectsicon24.png",
"CppPlatform/Extensions/LinkedObjectsicon24.png")
@@ -64,7 +64,7 @@ void DeclareLinkedObjectsExtension(gd::PlatformExtension& extension) {
_("Unlink all objects from an object"),
_("Unlink all objects from an object."),
_("Unlink all objects from _PARAM1_"),
"",
_("Objects"),
"CppPlatform/Extensions/LinkedObjectsicon24.png",
"CppPlatform/Extensions/LinkedObjectsicon24.png")
@@ -80,7 +80,7 @@ void DeclareLinkedObjectsExtension(gd::PlatformExtension& extension) {
"next conditions and actions.\nThe condition will return "
"false if no object was taken into account."),
_("Take into account all \"_PARAM1_\" linked to _PARAM2_"),
"",
_("Objects"),
"CppPlatform/Extensions/LinkedObjectsicon24.png",
"CppPlatform/Extensions/LinkedObjectsicon24.png")
@@ -97,7 +97,7 @@ void DeclareLinkedObjectsExtension(gd::PlatformExtension& extension) {
_("Take into account linked objects"),
_("Take objects linked to the object into account for next actions."),
_("Take into account all \"_PARAM1_\" linked to _PARAM2_"),
"",
_("Objects"),
"CppPlatform/Extensions/LinkedObjectsicon24.png",
"CppPlatform/Extensions/LinkedObjectsicon24.png")

View File

@@ -195,8 +195,8 @@ namespace gdjs {
export const linkObjects = function (
instanceContainer: gdjs.RuntimeInstanceContainer,
objA: gdjs.RuntimeObject,
objB: gdjs.RuntimeObject
objA: gdjs.RuntimeObject | null,
objB: gdjs.RuntimeObject | null
) {
if (objA === null || objB === null) {
return;
@@ -206,8 +206,8 @@ namespace gdjs {
export const removeLinkBetween = function (
instanceContainer: gdjs.RuntimeInstanceContainer,
objA: gdjs.RuntimeObject,
objB: gdjs.RuntimeObject
objA: gdjs.RuntimeObject | null,
objB: gdjs.RuntimeObject | null
) {
if (objA === null || objB === null) {
return;
@@ -231,7 +231,7 @@ namespace gdjs {
export const pickObjectsLinkedTo = function (
instanceContainer: gdjs.RuntimeInstanceContainer,
objectsLists: Hashtable<gdjs.RuntimeObject[]>,
obj: gdjs.RuntimeObject,
obj: gdjs.RuntimeObject | null,
eventsFunctionContext: EventsFunctionContext | undefined
) {
if (obj === null) {

View File

@@ -33,6 +33,7 @@ describe('gdjs.LinksManager', function () {
name: 'Scene1',
stopSoundsOnStartup: false,
title: '',
usedResources: [],
});
const manager = gdjs.LinksManager.getManager(runtimeScene);

View File

@@ -114,8 +114,8 @@ namespace gdjs {
return this._renderer.getRendererObject();
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.destroy();
}

View File

@@ -405,9 +405,9 @@ namespace gdjs {
}
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
onDestroyed(): void {
this._renderer.destroy();
super.onDestroyFromScene(instanceContainer);
super.onDestroyed();
}
getEmitterForceMin(): number {

View File

@@ -637,8 +637,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.SetFunctionName("GetCost");
aut.AddAction("SetImpassable",
_("Should object be impassable?"),
_("Decide if the object is an impassable obstacle"),
_("Should object be impassable"),
_("Decide if the object is an impassable obstacle."),
_("Set _PARAM0_ as an impassable obstacle: _PARAM2_"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
@@ -646,12 +646,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension) {
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
.AddParameter("yesorno", _("Impassable?"))
.AddParameter("yesorno", _("Impassable"))
.SetFunctionName("SetImpassable");
aut.AddCondition("IsImpassable",
_("Is object impassable?"),
_("Check if the obstacle is impassable"),
_("Impassable obstacle"),
_("Check if the obstacle is impassable."),
_("_PARAM0_ is impassable"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",

View File

@@ -7,7 +7,6 @@ namespace gdjs {
export interface RuntimeInstanceContainer {
pathfindingObstaclesManager: gdjs.PathfindingObstaclesManager;
}
declare var rbush: any;
/**
* PathfindingObstaclesManager manages the common objects shared by objects
@@ -18,10 +17,10 @@ namespace gdjs {
* `gdjs.PathfindingRuntimeBehavior.obstaclesManagers`).
*/
export class PathfindingObstaclesManager {
_obstaclesRBush: any;
_obstaclesRBush: RBush<PathfindingObstacleRuntimeBehavior>;
constructor(instanceContainer: gdjs.RuntimeInstanceContainer) {
this._obstaclesRBush = new rbush();
this._obstaclesRBush = new RBush<PathfindingObstacleRuntimeBehavior>();
}
/**
@@ -60,6 +59,9 @@ namespace gdjs {
removeObstacle(
pathfindingObstacleBehavior: PathfindingObstacleRuntimeBehavior
) {
if (!pathfindingObstacleBehavior.currentRBushAABB) {
return;
}
this._obstaclesRBush.remove(pathfindingObstacleBehavior.currentRBushAABB);
}
@@ -74,9 +76,9 @@ namespace gdjs {
radius: float,
result: gdjs.PathfindingObstacleRuntimeBehavior[]
): void {
const searchArea = gdjs.staticObject(
const searchArea: SearchArea = gdjs.staticObject(
PathfindingObstaclesManager.prototype.getAllObstaclesAround
);
) as SearchArea;
// @ts-ignore
searchArea.minX = x - radius;
// @ts-ignore
@@ -85,13 +87,8 @@ namespace gdjs {
searchArea.maxX = x + radius;
// @ts-ignore
searchArea.maxY = y + radius;
const nearbyObstacles: gdjs.BehaviorRBushAABB<
gdjs.PathfindingObstacleRuntimeBehavior
>[] = this._obstaclesRBush.search(searchArea);
result.length = 0;
nearbyObstacles.forEach((nearbyObstacle) =>
result.push(nearbyObstacle.behavior)
);
this._obstaclesRBush.search(searchArea, result);
}
}

View File

@@ -34,6 +34,7 @@ describe('gdjs.PathfindingRuntimeBehavior', function () {
behaviorsSharedData: [],
objects: [],
instances: [],
usedResources: [],
});
setFramePerSecond(runtimeScene, framePerSecond);
return runtimeScene;

View File

@@ -37,6 +37,7 @@ describe('gdjs.PathfindingRuntimeBehavior', function () {
behaviorsSharedData: [],
objects: [],
instances: [],
usedResources: [],
});
setFramePerSecond(runtimeScene, framePerSecond);
return runtimeScene;

View File

@@ -39,6 +39,7 @@ describe('gdjs.PathfindingRuntimeBehavior', function () {
behaviorsSharedData: [],
objects: [],
instances: [],
usedResources: [],
});
runtimeScene._timeManager.getElapsedTime = function () {
return (1 / 60) * 1000;

View File

@@ -553,7 +553,7 @@ module.exports = {
'While an object is needed, this will apply to all objects using the behavior.'
),
_('Set the world time scale of _PARAM0_ to _PARAM2_'),
'',
_('Global'),
'res/physics32.png',
'res/physics32.png'
)

View File

@@ -1837,7 +1837,7 @@ namespace gdjs {
addDistanceJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
length: float,
@@ -2083,7 +2083,7 @@ namespace gdjs {
addRevoluteJointBetweenTwoBodies(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
enableLimit: boolean,
@@ -2383,7 +2383,7 @@ namespace gdjs {
addPrismaticJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
axisAngle: float,
@@ -2754,7 +2754,7 @@ namespace gdjs {
addPulleyJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
groundX1: float,
@@ -3237,7 +3237,7 @@ namespace gdjs {
addWheelJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
axisAngle: float,
@@ -3522,7 +3522,7 @@ namespace gdjs {
addWeldJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
referenceAngle: float,
@@ -3673,7 +3673,7 @@ namespace gdjs {
addRopeJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
maxLength: float,
@@ -3782,7 +3782,7 @@ namespace gdjs {
addFrictionJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
maxForce: float,
@@ -3914,7 +3914,7 @@ namespace gdjs {
// Motor joint
addMotorJoint(
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
offsetX: float,
offsetY: float,
offsetAngle: float,

View File

@@ -1,9 +1,9 @@
namespace gdjs {
export namespace physics2 {
export const objectsCollide = function (
objectsLists1: Hashtable<Array<gdjs.RuntimeObject>>,
objectsLists1: ObjectsLists,
behaviorName: string,
objectsLists2: Hashtable<Array<gdjs.RuntimeObject>>,
objectsLists2: ObjectsLists,
inverted: boolean
) {
return gdjs.evtTools.object.twoListsTest(
@@ -16,9 +16,9 @@ namespace gdjs {
};
export const haveObjectsStartedColliding = function (
objectsLists1: Hashtable<Array<gdjs.RuntimeObject>>,
objectsLists1: ObjectsLists,
behaviorName: string,
objectsLists2: Hashtable<Array<gdjs.RuntimeObject>>,
objectsLists2: ObjectsLists,
inverted: boolean
) {
return gdjs.evtTools.object.twoListsTest(
@@ -31,9 +31,9 @@ namespace gdjs {
};
export const haveObjectsStoppedColliding = function (
objectsLists1: Hashtable<Array<gdjs.RuntimeObject>>,
objectsLists1: ObjectsLists,
behaviorName: string,
objectsLists2: Hashtable<Array<gdjs.RuntimeObject>>,
objectsLists2: ObjectsLists,
inverted: boolean
) {
return gdjs.evtTools.object.twoListsTest(
@@ -45,7 +45,11 @@ namespace gdjs {
);
};
export const setTimeScale = function (objectsLists, behavior, timeScale) {
export const setTimeScale = function (
objectsLists: ObjectsLists,
behavior: gdjs.Physics2RuntimeBehavior,
timeScale: float
) {
const lists = gdjs.staticArray(gdjs.physics2.setTimeScale);
objectsLists.values(lists);
for (let i = 0, len = lists.length; i < len; i++) {

View File

@@ -17,326 +17,326 @@ This project is released under the MIT License.
void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
extension
.SetExtensionInformation("PhysicsBehavior",
_("Physics Engine (deprecated)"),
("Physics Engine (deprecated)"),
"This is the old, deprecated physics engine. Prefer to use the Physics Engine 2.0.",
"Florian Rival",
"Open source (MIT License)")
.SetCategory("Movement")
.SetExtensionHelpPath("/behaviors/physics");
extension.AddInstructionOrExpressionGroupMetadata(_("Physics Engine (deprecated)"))
.SetIcon("res/physics16.png");
extension.AddInstructionOrExpressionGroupMetadata(("Physics Engine (deprecated)"))
.SetIcon("res/physics-deprecated16.png");
{
gd::BehaviorMetadata& aut = extension.AddBehavior(
"PhysicsBehavior",
_("Physics Engine"),
_("Physics"),
_("Make objects move as if they are subject to the laws of physics. If "
("Physics Engine"),
("Physics"),
("Make objects move as if they are subject to the laws of physics. If "
"you're creating a new game, prefer Physics Engine 2.0"),
"",
"res/physics32.png",
"res/physics-deprecated32.png",
"PhysicsBehavior",
std::make_shared<PhysicsBehavior>(),
std::make_shared<ScenePhysicsDatas>());
aut.AddAction("SetStatic",
_("Make the object static"),
_("Make the object immovable."),
_("Make _PARAM0_ static"),
_("Movement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Make the object static"),
("Make the object immovable."),
("Make _PARAM0_ static"),
("Movement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetStatic");
aut.AddAction("SetDynamic",
_("Make the object dynamic"),
_("Make the object dynamic ( affected by forces and other "
("Make the object dynamic"),
("Make the object dynamic ( affected by forces and other "
"objects )."),
_("Make _PARAM0_ dynamic"),
_("Movement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Make _PARAM0_ dynamic"),
("Movement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetDynamic");
aut.AddCondition("IsDynamic",
_("The object is dynamic"),
_("Test if an object is dynamic ( affected by forces and "
("The object is dynamic"),
("Test if an object is dynamic ( affected by forces and "
"other objects )."),
_("_PARAM0_ is dynamic"),
_("Movement"),
"res/physics24.png",
"res/physics16.png")
("_PARAM0_ is dynamic"),
("Movement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.SetFunctionName("IsDynamic");
aut.AddAction("SetFixedRotation",
_("Fix rotation"),
_("Prevent the object from rotating"),
_("Fix rotation of _PARAM0_"),
_("Rotation"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Fix rotation"),
("Prevent the object from rotating"),
("Fix rotation of _PARAM0_"),
("Rotation"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetFixedRotation");
aut.AddAction(
"AddRevoluteJoint",
_("Add a hinge"),
_("Add a hinge that the object will rotate around.\nThe distance "
("Add a hinge"),
("Add a hinge that the object will rotate around.\nThe distance "
"between the hinge and the object will remain identical."),
_("Add a hinge to _PARAM0_ at _PARAM2_;_PARAM3_"),
_("Joints"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("Hinge X position"))
.AddParameter("expression", _("Hinge Y position"))
("Add a hinge to _PARAM0_ at _PARAM2_;_PARAM3_"),
("Joints"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("Hinge X position"))
.AddParameter("expression", ("Hinge Y position"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("AddRevoluteJoint");
aut.AddAction("AddRevoluteJointBetweenObjects",
_("Add a hinge between two objects"),
_("Add a hinge that the object will rotate around."),
_("Add a hinge between _PARAM0_ and _PARAM2_"),
_("Joints"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("objectPtr", _("Object"))
("Add a hinge between two objects"),
("Add a hinge that the object will rotate around."),
("Add a hinge between _PARAM0_ and _PARAM2_"),
("Joints"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("objectPtr", ("Object"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter(
"expression",
_("X position of the hinge, from the first object mass center"),
("X position of the hinge, from the first object mass center"),
"",
true)
.SetDefaultValue("0")
.AddParameter(
"expression",
_("Y position of the hinge, from the first object mass center"),
("Y position of the hinge, from the first object mass center"),
"",
true)
.SetDefaultValue("0")
.SetFunctionName("AddRevoluteJointBetweenObjects");
aut.AddAction("ActAddGearJointBetweenObjects",
_("Add a gear between two objects"),
_("Add a virtual gear between two objects."),
_("Add a gear between _PARAM0_ and _PARAM2_"),
_("Joints"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("objectPtr", _("Object"))
.AddParameter("expression", _("Ratio"), "", true)
("Add a gear between two objects"),
("Add a virtual gear between two objects."),
("Add a gear between _PARAM0_ and _PARAM2_"),
("Joints"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("objectPtr", ("Object"))
.AddParameter("expression", ("Ratio"), "", true)
.SetDefaultValue("1")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("AddGearJointBetweenObjects");
aut.AddAction("SetFreeRotation",
_("Make object's rotation free"),
_("Allows the object to rotate."),
_("Allow _PARAM0_ to rotate"),
_("Rotation"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Make object's rotation free"),
("Allows the object to rotate."),
("Allow _PARAM0_ to rotate"),
("Rotation"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetFreeRotation");
aut.AddCondition("IsFixedRotation",
_("Fixed rotation"),
_("Test if the object's rotation is fixed."),
_("The rotation of _PARAM0_ is fixed."),
_("Rotation"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Fixed rotation"),
("Test if the object's rotation is fixed."),
("The rotation of _PARAM0_ is fixed."),
("Rotation"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("IsFixedRotation");
aut.AddAction("SetAsBullet",
_("Treat object like a bullet."),
_("Treat the object like a bullet, so it will have better "
("Treat object like a bullet."),
("Treat the object like a bullet, so it will have better "
"collision handling."),
_("Consider _PARAM0_ as a bullet"),
_("Other"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Consider _PARAM0_ as a bullet"),
("Other"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetAsBullet");
aut.AddAction("DontSetAsBullet",
_("Do not treat object like a bullet"),
_("Do not treat the object like a bullet, so it will use "
("Do not treat object like a bullet"),
("Do not treat the object like a bullet, so it will use "
"standard collision handling."),
_("Do not consider _PARAM0_ as a bullet."),
_("Other"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Do not consider _PARAM0_ as a bullet."),
("Other"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("DontSetAsBullet");
aut.AddCondition("IsBullet",
_("Object is treated like a bullet"),
_("Test if the object is treated like a bullet"),
_("_PARAM0_ is considered as a bullet"),
_("Other"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Object is treated like a bullet"),
("Test if the object is treated like a bullet"),
("_PARAM0_ is considered as a bullet"),
("Other"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("IsBullet");
aut.AddAction("ApplyImpulse",
_("Apply an impulse"),
_("Apply an impulse to the object."),
_("Apply to _PARAM0_ impulse _PARAM2_;_PARAM3_"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("X component ( Newtons/Seconds )"))
.AddParameter("expression", _("Y component ( Newtons/Seconds )"))
("Apply an impulse"),
("Apply an impulse to the object."),
("Apply to _PARAM0_ impulse _PARAM2_;_PARAM3_"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("X component ( Newtons/Seconds )"))
.AddParameter("expression", ("Y component ( Newtons/Seconds )"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("ApplyImpulse");
aut.AddAction("ApplyImpulseUsingPolarCoordinates",
_("Apply an impulse (angle)"),
_("Apply an impulse to an object, using an angle and a "
("Apply an impulse (angle)"),
("Apply an impulse to an object, using an angle and a "
"length as coordinates."),
_("Apply to _PARAM0_ impulse _PARAM3_ with angle: "
("Apply to _PARAM0_ impulse _PARAM3_ with angle: "
"_PARAM2_\302\260"), //\302\260 <=> DEGREE SIGN
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("Angle"))
.AddParameter("expression", _("Impulse value ( Newton/seconds )"))
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("Angle"))
.AddParameter("expression", ("Impulse value ( Newton/seconds )"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("ApplyImpulseUsingPolarCoordinates");
aut.AddAction(
"ApplyImpulseTowardPosition",
_("Apply an impulse toward a position"),
_("Apply an impulse, directed toward a position, to the object."),
_("Apply to _PARAM0_ impulse _PARAM4_ toward position "
("Apply an impulse toward a position"),
("Apply an impulse, directed toward a position, to the object."),
("Apply to _PARAM0_ impulse _PARAM4_ toward position "
"_PARAM2_;_PARAM3_"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("expression", _("Impulse value ( Newton/seconds )"))
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("X position"))
.AddParameter("expression", ("Y position"))
.AddParameter("expression", ("Impulse value ( Newton/seconds )"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("ApplyImpulseTowardPosition");
aut.AddAction("ApplyForce",
_("Add a force"),
_("Add a force to the object"),
_("Apply to _PARAM0_ force _PARAM2_;_PARAM3_"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("X component ( Newtons )"))
.AddParameter("expression", _("Y component ( Newtons )"))
("Add a force"),
("Add a force to the object"),
("Apply to _PARAM0_ force _PARAM2_;_PARAM3_"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("X component ( Newtons )"))
.AddParameter("expression", ("Y component ( Newtons )"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("ApplyForce");
aut.AddAction("ApplyForceUsingPolarCoordinates",
_("Apply a force ( angle )"),
_("Apply a force to an object, using an angle and a length "
("Apply a force ( angle )"),
("Apply a force to an object, using an angle and a length "
"as coordinates."),
_("Apply to _PARAM0_ force _PARAM3_ at angle _PARAM2_"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("Angle"))
.AddParameter("expression", _("Length of the force ( Newtons )"))
("Apply to _PARAM0_ force _PARAM3_ at angle _PARAM2_"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("Angle"))
.AddParameter("expression", ("Length of the force ( Newtons )"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("ApplyForceUsingPolarCoordinates");
aut.AddAction(
"ApplyForceTowardPosition",
_("Apply a force toward a position"),
_("Apply a force, directed toward a position, to the object."),
_("Add to _PARAM0_ force _PARAM4_ toward position "
("Apply a force toward a position"),
("Apply a force, directed toward a position, to the object."),
("Add to _PARAM0_ force _PARAM4_ toward position "
"_PARAM2_;_PARAM3_"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("expression", _("Length of the force ( Newtons )"))
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("X position"))
.AddParameter("expression", ("Y position"))
.AddParameter("expression", ("Length of the force ( Newtons )"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("ApplyForceTowardPosition");
aut.AddAction("ApplyTorque",
_("Add a torque (a rotation)"),
_("Add a torque (a rotation) to the object."),
_("Add to _PARAM0_ torque _PARAM2_"),
_("Rotation"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("Torque value"))
("Add a torque (a rotation)"),
("Add a torque (a rotation) to the object."),
("Add to _PARAM0_ torque _PARAM2_"),
("Rotation"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("Torque value"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("ApplyTorque");
aut.AddAction("SetLinearVelocity",
_("Linear velocity"),
_("Modify the velocity of an object."),
_("Set linear velocity of _PARAM0_ to _PARAM2_;_PARAM3_"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("X Coordinate"))
.AddParameter("expression", _("Y Coordinate"))
("Linear velocity"),
("Modify the velocity of an object."),
("Set linear velocity of _PARAM0_ to _PARAM2_;_PARAM3_"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("X Coordinate"))
.AddParameter("expression", ("Y Coordinate"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetLinearVelocity");
aut.AddCondition(
"LinearVelocityX",
_("X component"),
_("Compare the linear velocity on the X axis of the object."),
_("the linear velocity on X axis"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("X component"),
("Compare the linear velocity on the X axis of the object."),
("the linear velocity on X axis"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
@@ -344,184 +344,184 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddCondition(
"LinearVelocityY",
_("Y component"),
_("Compare the linear velocity on the Y axis of the object."),
_("the linear velocity on Y axis"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Y component"),
("Compare the linear velocity on the Y axis of the object."),
("the linear velocity on Y axis"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearVelocityY");
aut.AddCondition("LinearVelocity",
_("Linear speed"),
_("Compare the linear velocity of the object."),
_("the linear velocity"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Linear speed"),
("Compare the linear velocity of the object."),
("the linear velocity"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearVelocity");
aut.AddAction("SetAngularVelocity",
_("Angular speed"),
_("Modify the angular velocity of the object."),
_("Set angular speed of _PARAM0_ to _PARAM2_"),
_("Rotation"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("New value"))
("Angular speed"),
("Modify the angular velocity of the object."),
("Set angular speed of _PARAM0_ to _PARAM2_"),
("Rotation"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("New value"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetAngularVelocity");
aut.AddCondition("AngularVelocity",
_("Angular speed"),
_("Compare the angular speed of the object."),
_("the angular speed"),
_("Rotation"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Angular speed"),
("Compare the angular speed of the object."),
("the angular speed"),
("Rotation"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetAngularVelocity");
aut.AddCondition("LinearDamping",
_("Linear damping"),
_("Compare the linear damping of the object."),
_("the linear damping"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Linear damping"),
("Compare the linear damping of the object."),
("the linear damping"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearDamping");
aut.AddCondition("CollisionWith",
_("Collision"),
_("Test if two objects are colliding.\nAttention! Only "
("Collision"),
("Test if two objects are colliding.\nAttention! Only "
"objects specified in the first parameter will be taken "
"into account by the next actions and conditions, if "
"they are colliding with the other objects."),
_("_PARAM0_ is in collision with a _PARAM2_"),
("_PARAM0_ is in collision with a _PARAM2_"),
"",
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("objectList", _("Object"))
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("objectList", ("Object"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("CollisionWith");
aut.AddAction("SetLinearDamping",
_("Linear damping"),
_("Modify the linear damping of the object."),
_("Set linear damping of _PARAM0_ to _PARAM2_"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("Value"))
("Linear damping"),
("Modify the linear damping of the object."),
("Set linear damping of _PARAM0_ to _PARAM2_"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("Value"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetLinearDamping");
aut.AddCondition("AngularDamping",
_("Angular damping"),
_("Test the object's angular damping"),
_("the angular damping"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Angular damping"),
("Test the object's angular damping"),
("the angular damping"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetAngularDamping");
aut.AddAction("SetAngularDamping",
_("Angular damping"),
_("Modify the angular damping of the object."),
_("Set angular damping of _PARAM0_ to _PARAM2_"),
_("Displacement"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("Value"))
("Angular damping"),
("Modify the angular damping of the object."),
("Set angular damping of _PARAM0_ to _PARAM2_"),
("Displacement"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("Value"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetAngularDamping");
aut.AddAction("SetGravity",
_("Gravity"),
_("Modify the gravity"),
_("Set gravity force to _PARAM2_;_PARAM3_"),
_("Global options"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("X Coordinate"))
.AddParameter("expression", _("Y Coordinate"))
("Gravity"),
("Modify the gravity"),
("Set gravity force to _PARAM2_;_PARAM3_"),
("Global options"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("X Coordinate"))
.AddParameter("expression", ("Y Coordinate"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetGravity");
aut.AddAction("SetPolygonScaleX",
_("Change the X scale of a collision polygon"),
_("Change the X scale of the polygon. Use a value greater "
("Change the X scale of a collision polygon"),
("Change the X scale of the polygon. Use a value greater "
"than 1 to enlarge the polygon, less than 1 to reduce it."),
_("Change the X scale of the collision polygon of _PARAM0_ "
("Change the X scale of the collision polygon of _PARAM0_ "
"to _PARAM2_"),
_("Collision polygon"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("Scale"))
("Collision polygon"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("Scale"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetPolygonScaleX");
aut.AddAction("SetPolygonScaleY",
_("Change the Y scale of a collision polygon"),
_("Change the Y scale of the polygon. Use a value greater "
("Change the Y scale of a collision polygon"),
("Change the Y scale of the polygon. Use a value greater "
"than 1 to enlarge the polygon, less than 1 to reduce it."),
_("Change the Y scale of the collision polygon of _PARAM0_ Y "
("Change the Y scale of the collision polygon of _PARAM0_ Y "
"to _PARAM2_"),
_("Collision polygon"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
.AddParameter("expression", _("Scale"))
("Collision polygon"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddParameter("expression", ("Scale"))
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("SetPolygonScaleY");
aut.AddCondition(
"GetPolygonScaleX",
_("Collision polygon X scale"),
_("Test the value of the X scale of the collision polygon."),
_("the X scale of the collision polygon"),
_("Collision polygon"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Collision polygon X scale"),
("Test the value of the X scale of the collision polygon."),
("the X scale of the collision polygon"),
("Collision polygon"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
@@ -529,96 +529,96 @@ void DeclarePhysicsBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddCondition(
"GetPolygonScaleY",
_("Collision polygon Y scale"),
_("Test the value of the Y scale of the collision polygon."),
_("the Y scale of the collision polygon"),
_("Collision polygon"),
"res/physics24.png",
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Collision polygon Y scale"),
("Test the value of the Y scale of the collision polygon."),
("the Y scale of the collision polygon"),
("Collision polygon"),
"res/physics-deprecated24.png",
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.UseStandardRelationalOperatorParameters(
"number", gd::ParameterOptions::MakeNewOptions())
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetPolygonScaleY");
aut.AddExpression("PolygonScaleX",
_("Collision polygon X scale"),
_("Collision polygon X scale"),
_("Collision polygon"),
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Collision polygon X scale"),
("Collision polygon X scale"),
("Collision polygon"),
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetPolygonScaleX");
aut.AddExpression("PolygonScaleY",
_("Collision polygon Y scale"),
_("Collision polygon Y scale"),
_("Collision polygon"),
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Collision polygon Y scale"),
("Collision polygon Y scale"),
("Collision polygon"),
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetPolygonScaleY");
aut.AddExpression("LinearVelocity",
_("Linear speed"),
_("Linear speed"),
_("Displacement"),
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Linear speed"),
("Linear speed"),
("Displacement"),
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearVelocity");
aut.AddExpression("LinearVelocityX",
_("X component"),
_("X component"),
_("Displacement"),
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("X component"),
("X component"),
("Displacement"),
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearVelocityX");
aut.AddExpression("LinearVelocityY",
_("Y component"),
_("Y component"),
_("Displacement"),
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Y component"),
("Y component"),
("Displacement"),
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearVelocityY");
aut.AddExpression("AngularVelocity",
_("Angular speed"),
_("Angular speed"),
_("Rotation"),
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Angular speed"),
("Angular speed"),
("Rotation"),
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetAngularVelocity");
aut.AddExpression("LinearDamping",
_("Linear damping"),
_("Linear damping"),
_("Displacement"),
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Linear damping"),
("Linear damping"),
("Displacement"),
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetLinearDamping");
aut.AddExpression("AngularDamping",
_("Angular damping"),
_("Angular damping"),
_("Rotation"),
"res/physics16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
("Angular damping"),
("Angular damping"),
("Rotation"),
"res/physics-deprecated16.png")
.AddParameter("object", ("Object"))
.AddParameter("behavior", ("Behavior"), "PhysicsBehavior")
.AddCodeOnlyParameter("currentScene", "")
.SetFunctionName("GetAngularDamping");
}

View File

@@ -50,7 +50,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Check if the object is moving (whether it is on the "
"floor or in the air)."),
_("_PARAM0_ is moving"),
"",
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -64,7 +64,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Check if the object is moving (whether it is on the "
"floor or in the air)."),
_("_PARAM0_ is moving"),
"",
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -75,7 +75,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Is on floor"),
_("Check if the object is on a platform."),
_("_PARAM0_ is on floor"),
"",
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -87,7 +87,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Is on ladder"),
_("Check if the object is on a ladder."),
_("_PARAM0_ is on ladder"),
"",
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -99,7 +99,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Is jumping"),
_("Check if the object is jumping."),
_("_PARAM0_ is jumping"),
"",
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -114,7 +114,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"flagged as jumping and falling at the same time: at the end of a "
"jump, the fall speed becomes higher than the jump speed."),
_("_PARAM0_ is falling"),
"",
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -125,7 +125,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Is grabbing platform ledge"),
_("Check if the object is grabbing a platform ledge."),
_("_PARAM0_ is grabbing a platform ledge"),
"",
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -136,7 +136,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Gravity"),
_("Compare the gravity applied on the object."),
_("the gravity"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -153,7 +153,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Gravity"),
_("Change the gravity applied on an object."),
_("the gravity"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -171,7 +171,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Maximum falling speed"),
_("Compare the maximum falling speed of the object."),
_("the maximum falling speed"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -187,7 +187,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Maximum falling speed"),
_("Change the maximum falling speed of an object."),
_("the maximum falling speed"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -208,7 +208,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Compare the ladder climbing speed (in pixels per "
"second)."),
_("the ladder climbing speed"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -224,7 +224,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Ladder climbing speed"),
_("Change the ladder climbing speed."),
_("the ladder climbing speed"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -241,7 +241,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Acceleration"),
_("Compare the horizontal acceleration of the object."),
_("the horizontal acceleration"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -258,7 +258,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Acceleration"),
_("Change the horizontal acceleration of an object."),
_("the horizontal acceleration"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -276,7 +276,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Deceleration"),
_("Compare the horizontal deceleration of the object."),
_("the horizontal deceleration"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -293,7 +293,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Deceleration"),
_("Change the horizontal deceleration of an object."),
_("the horizontal deceleration"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -311,7 +311,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Maximum horizontal speed"),
_("Compare the maximum horizontal speed of the object."),
_("the maximum horizontal speed"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -326,7 +326,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Maximum horizontal speed"),
_("Change the maximum horizontal speed of an object."),
_("the maximum horizontal speed"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -344,7 +344,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Compare the jump speed of the object."
"Its value is always positive."),
_("the jump speed"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -361,7 +361,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Change the jump speed of an object. "
"Its value is always positive."),
_("the jump speed"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -380,7 +380,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"This is the time during which keeping the jump button held "
"allow the initial jump speed to be maintained."),
_("the jump sustain time"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -398,7 +398,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"This is the time during which keeping the jump button held "
"allow the initial jump speed to be maintained."),
_("the jump sustain time"),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -417,7 +417,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"again this action everytime you want to allow the object to jump "
"(apart if it's on the floor)."),
_("Allow _PARAM0_ to jump again"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -432,7 +432,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"is made unable to jump while in mid air. This has no effect if "
"the object is not in the air."),
_("Forbid _PARAM0_ to air jump"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -445,7 +445,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"This action doesn't have any effect when the character is not "
"jumping."),
_("Abort the current jump of _PARAM0_"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -455,7 +455,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Can jump"),
_("Check if the object can jump."),
_("_PARAM0_ can jump"),
"",
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -467,7 +467,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate left key press"),
_("Simulate a press of the left key."),
_("Simulate pressing Left for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -479,7 +479,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate right key press"),
_("Simulate a press of the right key."),
_("Simulate pressing Right for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -491,7 +491,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate up key press"),
_("Simulate a press of the up key (used when on a ladder)."),
_("Simulate pressing Up for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -504,7 +504,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate down key press"),
_("Simulate a press of the down key (used when on a ladder)."),
_("Simulate pressing Down for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -517,7 +517,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate ladder key press"),
_("Simulate a press of the ladder key (used to grab a ladder)."),
_("Simulate pressing Ladder key for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -530,7 +530,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate release ladder key press"),
_("Simulate a press of the Release Ladder key (used to get off a ladder)."),
_("Simulate pressing Release Ladder key for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -541,7 +541,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate jump key press"),
_("Simulate a press of the jump key."),
_("Simulate pressing Jump key for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -553,7 +553,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate a press of the release platform key (used when grabbing a "
"platform ledge)."),
_("Simulate pressing Release Platform key for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -568,7 +568,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate a press of a key.\nValid keys are Left, Right, "
"Jump, Ladder, Release Ladder, Up, Down."),
_("Simulate pressing _PARAM2_ key for _PARAM0_"),
_("Controls"),
_("Platformer controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -583,7 +583,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Control pressed or simulated"),
_("A control was applied from a default control or simulated by an action."),
_("_PARAM0_ has the _PARAM2_ key pressed or simulated"),
_(""),
_("Platformer state"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -598,7 +598,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("De/activate the use of default controls.\nIf deactivated, "
"use the simulated actions to move the object."),
_("Ignore default controls for _PARAM0_: _PARAM2_"),
_("Options"),
_("Platformer configuration"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -612,7 +612,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Enable (or disable) the ability of the object to grab "
"platforms when falling near to one."),
_("Allow _PARAM0_ to grab platforms: _PARAM2_"),
_("Options"),
_("Platformer configuration"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -624,7 +624,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Can grab platforms"),
_("Check if the object can grab the platforms."),
_("_PARAM0_ can grab the platforms"),
"Options",
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -637,7 +637,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Compare the current falling speed of the object. Its "
"value is always positive."),
_("the current falling speed"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -656,7 +656,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"doesn't have any effect when the character "
"is not falling or is in the first phase of a jump."),
_("the current falling speed"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -672,7 +672,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Compare the current jump speed of the object. Its "
"value is always positive."),
_("the current jump speed"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -691,7 +691,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"moves to the left with negative values and to the right with "
"positive ones"),
_("the current horizontal speed"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -709,7 +709,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
"moves to the left "
"with negative values and to the right with positive ones"),
_("the current horizontal speed"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png",
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
@@ -725,7 +725,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Gravity"),
_("Return the gravity applied on the object "
"(in pixels per second per second)."),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -735,7 +735,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Maximum falling speed"),
_("Return the maximum falling speed of the object "
"(in pixels per second)."),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -745,7 +745,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Ladder climbing speed"),
_("Return the ladder climbing speed of the object "
"(in pixels per second)."),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -755,7 +755,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Acceleration"),
_("Return the horizontal acceleration of the object "
"(in pixels per second per second)."),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -765,7 +765,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Deceleration"),
_("Return the horizontal deceleration of the object "
"(in pixels per second per second)."),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -775,7 +775,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Maximum horizontal speed"),
_("Return the maximum horizontal speed of the object "
"(in pixels per second)."),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -786,7 +786,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Jump speed"),
_("Return the jump speed of the object "
"(in pixels per second). Its value is always positive."),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -797,7 +797,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Return the jump sustain time of the object (in seconds)."
"This is the time during which keeping the jump button held "
"allow the initial jump speed to be maintained."),
_("Options"),
_("Platformer configuration"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior");
@@ -806,7 +806,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Current fall speed"),
_("Return the current fall speed of the object "
"(in pixels per second). Its value is always positive."),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -817,17 +817,17 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Return the current horizontal speed of the object "
"(in pixels per second). The object moves to the left "
"with negative values and to the right with positive ones"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
.SetFunctionName("GetCurrentSpeed");
aut.AddExpression("CurrentJumpSpeed",
_("Current jump speed"),
_("Return the current jump speed of the object "
"(in pixels per second). Its value is always positive."),
_("Current jump speed"),
_(""),
_("Platformer state"),
"CppPlatform/Extensions/platformerobjecticon.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
@@ -850,7 +850,7 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
_("Change the platform type of the object: Platform, "
"Jump-Through, or Ladder."),
_("Set platform type of _PARAM0_ to _PARAM2_"),
"",
_("Platform"),
"CppPlatform/Extensions/platformicon.png",
"CppPlatform/Extensions/platformicon.png")
.AddParameter("object", _("Object"))
@@ -863,10 +863,10 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
}
extension.AddCondition("IsObjectOnGivenFloor",
_("Is object on given floor"),
_("Test if an object is on a given floor."),
_("_PARAM0_ is on floor _PARAM2_"),
"",
_("Character is on given platform"),
_("Check if a platformer character is on a given platform."),
_("_PARAM0_ is on platform _PARAM2_"),
_("Collision"),
"CppPlatform/Extensions/platformicon.png",
"CppPlatform/Extensions/platformicon.png")
.AddParameter("objectList", _("Object"), "", false)

View File

@@ -211,6 +211,9 @@ namespace gdjs {
}
doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {
// Update platforms locations.
this._manager.doStepPreEvents();
const LEFTKEY = 37;
const UPKEY = 38;
const RIGHTKEY = 39;

View File

@@ -3,7 +3,6 @@ GDevelop - Platform Behavior Extension
Copyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)
*/
namespace gdjs {
declare var rbush: any;
type SearchArea = { minX: float; minY: float; maxX: float; maxY: float };
/**
@@ -13,10 +12,12 @@ namespace gdjs {
* of their associated container (see PlatformRuntimeBehavior.getManager).
*/
export class PlatformObjectsManager {
private _platformRBush: any;
private _platformRBush: RBush<PlatformRuntimeBehavior>;
private movedPlatforms: Array<gdjs.PlatformRuntimeBehavior>;
constructor(instanceContainer: gdjs.RuntimeInstanceContainer) {
this._platformRBush = new rbush();
this._platformRBush = new RBush<PlatformRuntimeBehavior>();
this.movedPlatforms = [];
}
/**
@@ -53,9 +54,28 @@ namespace gdjs {
* added before.
*/
removePlatform(platformBehavior: gdjs.PlatformRuntimeBehavior) {
if (!platformBehavior.currentRBushAABB) {
return;
}
this._platformRBush.remove(platformBehavior.currentRBushAABB);
}
invalidatePlatformHitbox(platformBehavior: gdjs.PlatformRuntimeBehavior) {
this.movedPlatforms.push(platformBehavior);
}
doStepPreEvents() {
for (const platformBehavior of this.movedPlatforms) {
this.removePlatform(platformBehavior);
// TODO What if the object is recycled before it can be removed from the tree?
if (platformBehavior.activated() && platformBehavior.owner.isAlive()) {
this.addPlatform(platformBehavior);
}
platformBehavior.onHitboxUpdatedInTree();
}
this.movedPlatforms.length = 0;
}
/**
* Returns all the platforms around the specified object.
* @param maxMovementLength The maximum distance, in pixels, the object is going to do.
@@ -75,21 +95,19 @@ namespace gdjs {
const searchArea: SearchArea = gdjs.staticObject(
PlatformObjectsManager.prototype.getAllPlatformsAround
) as SearchArea;
result.length = 0;
searchArea.minX = x - ow / 2 - maxMovementLength;
searchArea.minY = y - oh / 2 - maxMovementLength;
searchArea.maxX = x + ow / 2 + maxMovementLength;
searchArea.maxY = y + oh / 2 + maxMovementLength;
const nearbyPlatforms: gdjs.BehaviorRBushAABB<
PlatformRuntimeBehavior
>[] = this._platformRBush.search(searchArea);
result.length = 0;
this._platformRBush.search(searchArea, result);
// Extra check on the platform owner AABB
// TODO: PR https://github.com/4ian/GDevelop/pull/2602 should remove the need
// for this extra check once merged.
for (let i = 0; i < nearbyPlatforms.length; i++) {
const platform = nearbyPlatforms[i].behavior;
let writtenIndex = 0;
for (let readIndex = 0; readIndex < result.length; readIndex++) {
const platform = result[readIndex];
const platformAABB = platform.owner.getAABB();
const platformIsStillAround =
platformAABB.min[0] <= searchArea.maxX &&
@@ -100,9 +118,11 @@ namespace gdjs {
// This can happen because platforms are not updated in the RBush before that
// characters movement are being processed.
if (platformIsStillAround) {
result.push(platform);
result[writtenIndex] = platform;
writtenIndex++;
}
}
result.length = writtenIndex;
}
}
@@ -127,6 +147,7 @@ namespace gdjs {
> | null = null;
_manager: gdjs.PlatformObjectsManager;
_registeredInManager: boolean = false;
_isAABBInvalidated = false;
constructor(
instanceContainer: gdjs.RuntimeInstanceContainer,
@@ -145,6 +166,10 @@ namespace gdjs {
this._canBeGrabbed = behaviorData.canBeGrabbed || false;
this._yGrabOffset = behaviorData.yGrabOffset || 0;
this._manager = PlatformObjectsManager.getManager(instanceContainer);
this.owner.registerHitboxChangedCallback((object) =>
this.onHitboxChanged()
);
this.onHitboxChanged();
}
updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {
@@ -161,9 +186,11 @@ namespace gdjs {
}
onDestroy() {
if (this._manager && this._registeredInManager) {
this._manager.removePlatform(this);
}
this.onHitboxChanged();
}
usesLifecycleFunction(): boolean {
return false;
}
doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {
@@ -176,54 +203,28 @@ namespace gdjs {
sceneManager = parentScene ? &ScenePlatformObjectsManager::managers[&scene] : NULL;
registeredInManager = false;
}*/
//Make sure the platform is or is not in the platforms manager.
if (!this.activated() && this._registeredInManager) {
this._manager.removePlatform(this);
this._registeredInManager = false;
} else {
if (this.activated() && !this._registeredInManager) {
this._manager.addPlatform(this);
this._registeredInManager = true;
}
}
//Track changes in size or position
if (
this._oldX !== this.owner.getX() ||
this._oldY !== this.owner.getY() ||
this._oldWidth !== this.owner.getWidth() ||
this._oldHeight !== this.owner.getHeight() ||
this._oldAngle !== this.owner.getAngle()
) {
if (this._registeredInManager) {
this._manager.removePlatform(this);
this._manager.addPlatform(this);
}
this._oldX = this.owner.getX();
this._oldY = this.owner.getY();
this._oldWidth = this.owner.getWidth();
this._oldHeight = this.owner.getHeight();
this._oldAngle = this.owner.getAngle();
}
}
doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}
onActivate() {
if (this._registeredInManager) {
return;
}
this._manager.addPlatform(this);
this._registeredInManager = true;
this.onHitboxChanged();
}
onDeActivate() {
if (!this._registeredInManager) {
this.onHitboxChanged();
}
onHitboxChanged() {
if (this._isAABBInvalidated) {
return;
}
this._manager.removePlatform(this);
this._registeredInManager = false;
this._isAABBInvalidated = true;
this._manager.invalidatePlatformHitbox(this);
}
onHitboxUpdatedInTree() {
this._isAABBInvalidated = false;
}
changePlatformType(platformType: string) {

View File

@@ -2,9 +2,9 @@ namespace gdjs {
export namespace evtTools {
export namespace platform {
export const isOnPlatform = function (
objectsLists1: Hashtable<Array<gdjs.RuntimeObject>>,
objectsLists1: ObjectsLists,
behaviorName: string,
objectsLists2: Hashtable<Array<gdjs.RuntimeObject>>,
objectsLists2: ObjectsLists,
inverted: boolean
) {
return gdjs.evtTools.object.twoListsTest(

View File

@@ -1,8 +1,11 @@
describe('gdjs.PlatformerObjectRuntimeBehavior', function () {
const epsilon = 1 / (2 << 16);
describe('(falling)', function () {
/** @type {gdjs.RuntimeScene} */
let runtimeScene;
/** @type {gdjs.RuntimeObject} */
let object;
/** @type {gdjs.RuntimeObject} */
let platform;
beforeEach(function () {
@@ -114,7 +117,7 @@ describe('gdjs.PlatformerObjectRuntimeBehavior', function () {
expect(object.getBehavior('auto1').isMoving()).to.be(false);
// Remove the platform
runtimeScene.markObjectForDeletion(platform);
platform.deleteFromScene(runtimeScene);
runtimeScene.renderAndStep(1000 / 60);
expect(object.getBehavior('auto1').isFalling()).to.be(true);
expect(object.getBehavior('auto1').isFallingWithoutJumping()).to.be(true);

View File

@@ -379,7 +379,8 @@ namespace gdjs {
// Check origin of message.
if (checkOrigin && !allowedOrigins.includes(event.origin)) {
throw new Error(`Unexpected origin: ${event.origin}`);
// Automatic authentication message ignored: wrong origin. Return silently.
return;
}
// Check that message is not malformed.
if (!event.data.id) {

View File

@@ -174,8 +174,8 @@ namespace gdjs {
super.stepBehaviorsPreEvents(instanceContainer);
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.destroy();
}

View File

@@ -48,6 +48,7 @@ describe('gdjs.ShapePainterRuntimeObject (using a PixiJS RuntimeGame with assets
objects: [],
instances: [],
variables: [],
usedResources: [],
});
};

View File

@@ -67,9 +67,9 @@ module.exports = {
extension
.addAction(
'SetListenerPosition',
_('Set position of the listener'),
_('Sets the spatial position of the listener/player.'),
_('Set the listener position to _PARAM0_, _PARAM1_, _PARAM2_'),
_('Listener position'),
_('Change the spatial position of the listener/player.'),
_('Change the listener position to _PARAM0_, _PARAM1_, _PARAM2_'),
'',
'res/actions/son24.png',
'res/actions/son.png'

View File

@@ -178,7 +178,7 @@ module.exports = {
extension
.addAction(
'SetRichPresence',
_('Change the Steam rich presence'),
_('Steam rich presence'),
_(
"Changes an attribute of Steam's rich presence. Allows other player to see exactly what the player's currently doing in the game."
),

View File

@@ -31,11 +31,9 @@ namespace gdjs {
return true;
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
if (this._renderer.onDestroy) {
this._renderer.onDestroy();
}
onDestroyed(): void {
super.onDestroyed();
this._renderer.onDestroy();
}
update(instanceContainer: gdjs.RuntimeInstanceContainer): void {

View File

@@ -678,6 +678,12 @@ module.exports = {
this.update();
}
onRemovedFromScene() {
super.onRemovedFromScene();
this._pixiText.destroy(true);
this._pixiObject.destroy({ children: true });
}
static getThumbnail(project, resourcesLoader, objectConfiguration) {
return 'JsPlatform/Extensions/text_input.svg';
}

View File

@@ -55,6 +55,7 @@ describe('gdjs.TextInputRuntimeObject (using a PixiJS RuntimeGame with DOM eleme
objects: [],
instances: [],
variables: [],
usedResources: [],
});
};
@@ -147,6 +148,7 @@ describe('gdjs.TextInputRuntimeObject (using a PixiJS RuntimeGame with DOM eleme
expect(gameDomElementContainer.querySelector('textarea')).to.be(null);
object.deleteFromScene(runtimeScene);
runtimeScene.renderAndStep(1000 / 60);
expect(gameDomElementContainer.querySelector('input')).to.be(null);
expect(gameDomElementContainer.querySelector('textarea')).to.be(null);

View File

@@ -26,11 +26,12 @@ namespace gdjs {
);
};
class TextInputRuntimeObjectPixiRenderer {
class TextInputRuntimeObjectPixiRenderer implements RendererObjectInterface {
private _object: gdjs.TextInputRuntimeObject;
private _input: HTMLInputElement | HTMLTextAreaElement | null = null;
private _instanceContainer: gdjs.RuntimeInstanceContainer;
private _runtimeGame: gdjs.RuntimeGame;
private _isVisible = false;
constructor(
runtimeObject: gdjs.TextInputRuntimeObject,
@@ -113,14 +114,25 @@ namespace gdjs {
this._destroyElement();
}
//@ts-ignore
set visible(isVisible: boolean) {
this._isVisible = isVisible;
if (!this._input) return;
this._input.style.display = isVisible ? 'initial' : 'none';
}
//@ts-ignore
get visible(): boolean {
return this._isVisible;
}
updatePreRender() {
if (!this._input) return;
// Hide the input entirely if the object is hidden.
// Because this object is rendered as a DOM element (and not part of the PixiJS
// scene graph), we have to do this manually.
if (this._object.isHidden()) {
this._input.style.display = 'none';
if (!this._isVisible) {
return;
}

View File

@@ -102,7 +102,8 @@ namespace gdjs {
}
getRendererObject() {
return null;
// The renderer is not a Pixi Object but it implements visible.
return this._renderer;
}
updateFromObjectData(
@@ -199,8 +200,8 @@ namespace gdjs {
this._renderer.onSceneResumed();
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.onDestroy();
}

View File

@@ -145,8 +145,8 @@ namespace gdjs {
this._renderer.ensureUpToDate();
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.destroy();
}

File diff suppressed because it is too large Load Diff

View File

@@ -58,6 +58,7 @@ describe('gdjs.TileMapCollisionMaskRuntimeObject', function () {
behaviorsSharedData: [],
objects: [],
instances: [],
usedResources: [],
});
setFramesPerSecond(runtimeScene, framePerSecond);
return runtimeScene;

View File

@@ -158,8 +158,8 @@ namespace gdjs {
);
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.destroy();
}

View File

@@ -71,8 +71,8 @@ namespace gdjs {
return this._renderer.getRendererObject();
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.destroy();
}

View File

@@ -38,12 +38,11 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
std::make_shared<TopDownMovementBehavior>(),
std::make_shared<gd::BehaviorsSharedData>());
#if defined(GD_IDE_ONLY)
aut.AddAction("SimulateLeftKey",
_("Simulate left key press"),
_("Simulate a press of left key."),
_("Simulate pressing Left for _PARAM0_"),
_("Controls"),
_("Top-down controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -55,7 +54,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate right key press"),
_("Simulate a press of right key."),
_("Simulate pressing Right for _PARAM0_"),
_("Controls"),
_("Top-down controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -67,7 +66,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate up key press"),
_("Simulate a press of up key."),
_("Simulate pressing Up for _PARAM0_"),
_("Controls"),
_("Top-down controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -79,7 +78,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate down key press"),
_("Simulate a press of down key."),
_("Simulate pressing Down for _PARAM0_"),
_("Controls"),
_("Top-down controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -92,7 +91,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate control"),
_("Simulate a press of a key.\nValid keys are Left, Right, Up, Down."),
_("Simulate pressing _PARAM2_ key for _PARAM0_"),
_("Controls"),
_("Top-down controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -108,7 +107,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("De/activate the use of default controls.\nIf deactivated, "
"use the simulated actions to move the object."),
_("Ignore default controls for _PARAM0_: _PARAM2_"),
_("Controls"),
_("Top-down controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -121,7 +120,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Simulate stick control"),
_("Simulate a stick control."),
_("Simulate a stick control for _PARAM0_ with a _PARAM2_ angle and a _PARAM3_ force"),
_("Controls"),
_("Top-down controls"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -135,7 +134,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Control pressed or simulated"),
_("A control was applied from a default control or simulated by an action."),
_("_PARAM0_ has the _PARAM2_ key pressed or simulated"),
_("Controls"),
_("Top-down state"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddParameter("object", _("Object"))
@@ -148,7 +147,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("StickAngle",
_("Stick angle"),
_("Return the angle of the simulated stick input (in degrees)"),
_("Controls"),
_("Top-down controls"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior");
@@ -157,7 +156,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Is moving"),
_("Check if the object is moving."),
_("_PARAM0_ is moving"),
"",
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -168,7 +167,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Acceleration"),
_("Change the acceleration of the object"),
_("the acceleration"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -185,7 +184,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Acceleration"),
_("Compare the acceleration of the object"),
_("the acceleration"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -201,7 +200,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Deceleration"),
_("Change the deceleration of the object"),
_("the deceleration"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -218,7 +217,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Deceleration"),
_("Compare the deceleration of the object"),
_("the deceleration"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -234,7 +233,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Maximum speed"),
_("Change the maximum speed of the object"),
_("the max. speed"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -250,7 +249,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Maximum speed"),
_("Compare the maximum speed of the object"),
_("the max. speed"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -266,7 +265,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Speed"),
_("Compare the speed of the object"),
_("the speed"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -281,7 +280,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Angular maximum speed"),
_("Change the maximum angular speed of the object"),
_("the max. angular speed"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -298,7 +297,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Angular maximum speed"),
_("Compare the maximum angular speed of the object"),
_("the max. angular speed"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -314,7 +313,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Rotation offset"),
_("Change the rotation offset applied when moving the object"),
_("the rotation offset"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -332,7 +331,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Rotation offset"),
_("Compare the rotation offset applied when moving the object"),
_("the rotation offset"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -344,12 +343,13 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
.MarkAsAdvanced()
.SetFunctionName("GetAngleOffset");
// Deprecated
aut.AddCondition(
"Angle",
_("Angle of movement"),
_("Compare the angle of the top-down movement of the object."),
_("the angle of movement"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -367,7 +367,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Angle of movement"),
_("Compare the angle of the top-down movement of the object."),
_("Angle of movement of _PARAM0_ is _PARAM2_ ± _PARAM3_°"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -380,7 +380,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Compare the velocity of the top-down movement of the "
"object on the X axis."),
_("the speed of movement on X axis"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -396,7 +396,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Speed on the X axis"),
_("Change the speed on the X axis of the movement"),
_("the speed on the X axis of the movement"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -412,7 +412,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Compare the velocity of the top-down movement of the "
"object on the Y axis."),
_("the speed of movement on Y axis"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -428,7 +428,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Speed on the Y axis"),
_("Change the speed on the Y axis of the movement"),
_("the speed on the Y axis of the movement"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -443,7 +443,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Diagonal movement"),
_("Allow or restrict diagonal movement"),
_("Allow diagonal moves for _PARAM0_: _PARAM2_"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -455,7 +455,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Diagonal movement"),
_("Check if the object is allowed to move diagonally"),
_("Allow diagonal moves for _PARAM0_"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -467,7 +467,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Rotate the object"),
_("Enable or disable rotation of the object"),
_("Enable rotation of _PARAM0_: _PARAM2_"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -481,7 +481,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Object rotated"),
_("Check if the object is rotated while traveling on its path."),
_("_PARAM0_ is rotated when moving"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png",
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
@@ -492,7 +492,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("Acceleration",
_("Acceleration"),
_("Acceleration of the object"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -501,7 +501,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("Deceleration",
_("Deceleration"),
_("Deceleration of the object"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -510,7 +510,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("MaxSpeed",
_("Maximum speed"),
_("Maximum speed of the object"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -519,7 +519,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("Speed",
_("Speed"),
_("Speed of the object"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -528,7 +528,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("AngularMaxSpeed",
_("Angular maximum speed"),
_("Angular maximum speed of the object"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -537,7 +537,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("AngleOffset",
_("Rotation offset"),
_("Rotation offset applied to the object"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -546,7 +546,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("Angle",
_("Angle of the movement"),
_("Angle, in degrees, of the movement"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -555,7 +555,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("XVelocity",
_("Speed on the X axis"),
_("Speed on the X axis of the movement"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -564,7 +564,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
aut.AddExpression("YVelocity",
_("Speed on the Y axis"),
_("Speed on the Y axis of the movement"),
_("Movement"),
_("Top-down state"),
"CppPlatform/Extensions/topdownmovementicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -576,7 +576,7 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
_("Movement angle offset"),
_("the movement angle offset"),
_("the movement angle offset"),
_("Movement"),
_("Top-down configuration"),
"CppPlatform/Extensions/topdownmovementicon24.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "TopDownMovementBehavior")
@@ -584,5 +584,4 @@ void DeclareTopDownMovementBehaviorExtension(gd::PlatformExtension& extension) {
"number",
gd::ParameterOptions::MakeNewOptions().SetDescription(
_("Angle (in degrees)")));
#endif
}

View File

@@ -32,6 +32,7 @@ describe('gdjs.TopDownMovementRuntimeBehavior', function () {
behaviorsSharedData: [],
objects: [],
instances: [],
usedResources: [],
});
runtimeScene._timeManager.getElapsedTime = function () {
return timeDelta;

View File

@@ -1577,9 +1577,21 @@ namespace gdjs {
* @param layoutTimeDelta the duration from the previous step ignoring layer time scale in seconds
*/
step(): void {
for (const tween of this._activeTweens) {
let writeIndex = 0;
for (
let readIndex = 0;
readIndex < this._activeTweens.length;
readIndex++
) {
const tween = this._activeTweens[readIndex];
tween.step();
if (!tween.hasFinished()) {
this._activeTweens[writeIndex] = tween;
writeIndex++;
}
}
this._activeTweens.length = writeIndex;
}
/**

View File

@@ -203,7 +203,7 @@ module.exports = {
object
.addAction(
'SetTime',
_('Set time'),
_('Current time'),
_('Set the time of the video'),
_('the time'),
'',
@@ -224,7 +224,7 @@ module.exports = {
object
.addAction(
'SetVolume',
_('Set volume'),
_('Volume'),
_('Set the volume of the video object.'),
_('the volume'),
'',
@@ -568,127 +568,127 @@ module.exports = {
/**
* Renderer for instances of VideoObject inside the IDE.
*
* @extends RenderedInstance
* @class RenderedVideoObjectInstance
* @constructor
*/
function RenderedVideoObjectInstance(
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
) {
RenderedInstance.call(
this,
class RenderedVideoObjectInstance extends RenderedInstance {
constructor (
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
);
) {
super(
project,
layout,
instance,
associatedObjectConfiguration,
pixiContainer,
pixiResourcesLoader
);
this._videoResource = undefined;
this._videoResource = undefined;
//Setup the PIXI object:
this._pixiObject = new PIXI.Sprite(this._getVideoTexture());
this._pixiObject.anchor.x = 0.5;
this._pixiObject.anchor.y = 0.5;
this._pixiContainer.addChild(this._pixiObject);
this.update();
}
RenderedVideoObjectInstance.prototype = Object.create(
RenderedInstance.prototype
);
//Setup the PIXI object:
this._pixiObject = new PIXI.Sprite(this._getVideoTexture());
this._pixiObject.anchor.x = 0.5;
this._pixiObject.anchor.y = 0.5;
this._pixiContainer.addChild(this._pixiObject);
this.update();
}
/**
* Return the path to the thumbnail of the specified object.
*/
RenderedVideoObjectInstance.getThumbnail = function (
project,
resourcesLoader,
objectConfiguration
) {
return 'JsPlatform/Extensions/videoicon24.png';
};
onRemovedFromScene() {
super.onRemovedFromScene();
// Keep textures because they are shared by all sprites.
this._pixiObject.destroy(false);
}
RenderedVideoObjectInstance.prototype._getVideoTexture = function () {
// Get the video resource to use
const videoResource = this._associatedObjectConfiguration
.getProperties()
.get('videoResource')
.getValue();
/**
* Return the path to the thumbnail of the specified object.
*/
static getThumbnail(
project,
resourcesLoader,
objectConfiguration
) {
return 'JsPlatform/Extensions/videoicon24.png';
}
// This returns a VideoTexture with autoPlay set to false
return this._pixiResourcesLoader.getPIXIVideoTexture(
this._project,
videoResource
);
};
_getVideoTexture() {
// Get the video resource to use
const videoResource = this._associatedObjectConfiguration
.getProperties()
.get('videoResource')
.getValue();
/**
* This is called to update the PIXI object on the scene editor
*/
RenderedVideoObjectInstance.prototype.update = function () {
// Check if the video resource has changed
const videoResource = this._associatedObjectConfiguration
.getProperties()
.get('videoResource')
.getValue();
if (videoResource !== this._videoResource) {
this._videoResource = videoResource;
this._pixiObject.texture = this._getVideoTexture();
// This returns a VideoTexture with autoPlay set to false
return this._pixiResourcesLoader.getPIXIVideoTexture(
this._project,
videoResource
);
}
if (!this._pixiObject.texture.baseTexture.valid) {
var that = this;
/**
* This is called to update the PIXI object on the scene editor
*/
update() {
// Check if the video resource has changed
const videoResource = this._associatedObjectConfiguration
.getProperties()
.get('videoResource')
.getValue();
if (videoResource !== this._videoResource) {
this._videoResource = videoResource;
this._pixiObject.texture = this._getVideoTexture();
that._pixiObject.texture.on('error', function () {
that._pixiObject.texture.off('error', this);
if (!this._pixiObject.texture.baseTexture.valid) {
var that = this;
that._pixiObject.texture =
that._pixiResourcesLoader.getInvalidPIXITexture();
});
that._pixiObject.texture.on('error', function () {
that._pixiObject.texture.off('error', this);
that._pixiObject.texture =
that._pixiResourcesLoader.getInvalidPIXITexture();
});
}
}
// Update opacity
const opacity = this._associatedObjectConfiguration
.getProperties()
.get('Opacity')
.getValue();
this._pixiObject.alpha = opacity / 255;
// Read position and angle from the instance
this._pixiObject.position.x =
this._instance.getX() + this._pixiObject.width / 2;
this._pixiObject.position.y =
this._instance.getY() + this._pixiObject.height / 2;
this._pixiObject.rotation = RenderedInstance.toRad(
this._instance.getAngle()
);
if (this._instance.hasCustomSize()) {
this._pixiObject.width = this.getCustomWidth();
this._pixiObject.height = this.getCustomHeight();
}
}
// Update opacity
const opacity = this._associatedObjectConfiguration
.getProperties()
.get('Opacity')
.getValue();
this._pixiObject.alpha = opacity / 255;
// Read position and angle from the instance
this._pixiObject.position.x =
this._instance.getX() + this._pixiObject.width / 2;
this._pixiObject.position.y =
this._instance.getY() + this._pixiObject.height / 2;
this._pixiObject.rotation = RenderedInstance.toRad(
this._instance.getAngle()
);
if (this._instance.hasCustomSize()) {
this._pixiObject.width = this.getCustomWidth();
this._pixiObject.height = this.getCustomHeight();
/**
* Return the width of the instance, when it's not resized.
*/
getDefaultWidth() {
return this._pixiObject.width;
}
};
/**
* Return the width of the instance, when it's not resized.
*/
RenderedVideoObjectInstance.prototype.getDefaultWidth = function () {
return this._pixiObject.width;
};
/**
* Return the height of the instance, when it's not resized.
*/
RenderedVideoObjectInstance.prototype.getDefaultHeight = function () {
return this._pixiObject.height;
};
/**
* Return the height of the instance, when it's not resized.
*/
getDefaultHeight() {
return this._pixiObject.height;
}
}
// We don't do anything special when instance is removed from the scene,
// because the video is never really played.

View File

@@ -97,8 +97,8 @@ namespace gdjs {
}
}
onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {
super.onDestroyFromScene(instanceContainer);
onDestroyed(): void {
super.onDestroyed();
this._renderer.onDestroy();
}

View File

@@ -767,6 +767,14 @@ gd::String EventsCodeGenerator::GenerateObjectCondition(
}
if (conditionInverted) predicate = GenerateNegatedPredicate(predicate);
// TODO FIXME It doesn't work because usedObjectsMapNames maybe be filled after.
// TODO FIXME What about groups using the object?
// Flag the picking list as modified.
auto objectsMapName = GetObjectMapName(objectName, context);
if (context.GetUsedObjectsMapNames().find(objectsMapName) != context.GetUsedObjectsMapNames().end()) {
conditionCode += objectsMapName + ".isPicked = true;\n";
}
// Generate whole condition code
conditionCode +=
"for (var i = 0, k = 0, l = " + GetObjectListName(objectName, context) +
@@ -823,6 +831,14 @@ gd::String EventsCodeGenerator::GenerateBehaviorCondition(
<< "\" requested for object \'" << objectName
<< "\" (condition: " << instrInfos.GetFullName() << ")." << endl;
} else {
// TODO FIXME It doesn't work because usedObjectsMapNames maybe be filled after.
// TODO FIXME What about groups using the object?
// Flag the picking list as modified.
auto objectsMapName = GetObjectMapName(objectName, context);
if (context.GetUsedObjectsMapNames().find(objectsMapName) != context.GetUsedObjectsMapNames().end()) {
conditionCode += objectsMapName + ".isPicked = true;\n";
}
conditionCode +=
"for (var i = 0, k = 0, l = " + GetObjectListName(objectName, context) +
".length;i<l;++i) {\n";
@@ -1041,7 +1057,7 @@ gd::String EventsCodeGenerator::GenerateObjectsDeclarationCode(
if (!context.ObjectAlreadyDeclaredByParents(object)) {
objectListDeclaration += "gdjs.copyArray(" +
GenerateAllInstancesGetterCode(object, context) +
", " + GetObjectListName(object, context) + ");";
", " + GetObjectListName(object, context) + ");\n";
} else
objectListDeclaration = declareObjectListFromParent(object, context);
@@ -1068,6 +1084,10 @@ gd::String EventsCodeGenerator::GenerateObjectsDeclarationCode(
declarationsCode += objectListDeclaration + "\n";
}
for (auto objectsMapName : context.GetUsedObjectsMapNames()) {
declarationsCode += objectsMapName + ".isPicked = false;\n";
}
return declarationsCode;
}
@@ -1183,6 +1203,26 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
return argOutput;
}
gd::String EventsCodeGenerator::GetObjectMapName(
const gd::String& objectName,
gd::EventsCodeGenerationContext& context) {
std::vector<gd::String> realObjects =
GetObjectsContainersList().ExpandObjectName(objectName,
context.GetCurrentObject());
// The map name must be unique for each set of objects lists.
// We generate it from the objects lists names.
gd::String objectsMapName = GetCodeNamespaceAccessor() + "mapOf";
// Map each declared object to its list.
for (auto &objectName : realObjects) {
objectsMapName += ManObjListName(GetObjectListName(objectName, context));
}
return objectsMapName;
}
gd::String EventsCodeGenerator::GenerateObject(
const gd::String& objectName,
const gd::String& type,
@@ -1234,6 +1274,7 @@ gd::String EventsCodeGenerator::GenerateObject(
for (auto& objectName : realObjects) context.ObjectsListNeeded(objectName);
gd::String objectsMapName = declareMapOfObjects(realObjects, context);
context.AddUsedObjectsMapNames(objectsMapName);
output = objectsMapName;
} else if (type == "objectListOrEmptyIfJustDeclared") {
std::vector<gd::String> realObjects =
@@ -1243,6 +1284,7 @@ gd::String EventsCodeGenerator::GenerateObject(
context.ObjectsListNeededOrEmptyIfJustDeclared(objectName);
gd::String objectsMapName = declareMapOfObjects(realObjects, context);
context.AddUsedObjectsMapNames(objectsMapName);
output = objectsMapName;
} else if (type == "objectListOrEmptyWithoutPicking") {
std::vector<gd::String> realObjects =
@@ -1264,6 +1306,7 @@ gd::String EventsCodeGenerator::GenerateObject(
gd::String objectsMapName = declareMapOfObjects(
objectToBeDeclaredNames, context, objectNotYetDeclaredNames);
context.AddUsedObjectsMapNames(objectsMapName);
output = objectsMapName;
} else if (type == "objectPtr") {
std::vector<gd::String> realObjects =

View File

@@ -335,6 +335,9 @@ class EventsCodeGenerator : public gd::EventsCodeGenerator {
const gd::String& type,
gd::EventsCodeGenerationContext& context) override;
virtual gd::String GetObjectMapName(const gd::String &objectName,
gd::EventsCodeGenerationContext &context) override;
virtual gd::String GenerateNegatedPredicate(const gd::String& predicate) const override {
return "!(" + predicate + ")";
};

View File

@@ -205,13 +205,13 @@ BaseObjectExtension::BaseObjectExtension() {
"gdjs.evtTools.object.getPickedInstancesCount");
GetAllConditions()["CollisionNP"].SetFunctionName(
"gdjs.evtTools.object.hitBoxesCollisionTest");
"gdjs.evtTools.object.position.hitBoxesCollisionCheck");
GetAllConditions()["Raycast"].SetFunctionName(
"gdjs.evtTools.object.raycastObject");
GetAllConditions()["RaycastToPosition"].SetFunctionName(
"gdjs.evtTools.object.raycastObjectToPosition");
GetAllConditions()["Distance"].SetFunctionName(
"gdjs.evtTools.object.distanceTest");
"gdjs.evtTools.object.position.distanceCheck");
GetAllConditions()["SeDirige"].SetFunctionName(
"gdjs.evtTools.object.movesTowardTest");
GetAllConditions()["EstTourne"].SetFunctionName(

View File

@@ -39,6 +39,15 @@ SceneExtension::SceneExtension() {
GetAllConditions()["DoesSceneExist"].SetFunctionName(
"gdjs.evtTools.runtimeScene.doesSceneExist");
GetAllActions()["PrioritizeLoadingOfScene"].SetFunctionName(
"gdjs.evtTools.runtimeScene.prioritizeLoadingOfScene");
GetAllConditions()["AreSceneAssetsLoaded"].SetFunctionName(
"gdjs.evtTools.runtimeScene.areSceneAssetsLoaded");
GetAllConditions()["SceneLoadingProgress"].SetFunctionName(
"gdjs.evtTools.runtimeScene.getSceneLoadingProgress");
GetAllExpressions()["SceneLoadingProgress"].SetFunctionName(
"gdjs.evtTools.runtimeScene.getSceneLoadingProgress");
StripUnimplementedInstructionsAndExpressions();
}

View File

@@ -15,6 +15,7 @@
#include "GDCore/IDE/AbstractFileSystem.h"
#include "GDCore/IDE/Events/UsedExtensionsFinder.h"
#include "GDCore/IDE/Project/ProjectResourcesCopier.h"
#include "GDCore/IDE/Project/SceneResourcesFinder.h"
#include "GDCore/IDE/ProjectStripper.h"
#include "GDCore/Project/ExternalEvents.h"
#include "GDCore/Project/ExternalLayout.h"
@@ -129,14 +130,26 @@ bool Exporter::ExportWholePixiProject(const ExportOptions &options) {
return false;
}
auto projectUsedResources =
gd::SceneResourcesFinder::FindProjectResources(exportedProject);
std::unordered_map<gd::String, std::set<gd::String>> scenesUsedResources;
for (std::size_t layoutIndex = 0;
layoutIndex < exportedProject.GetLayoutsCount(); layoutIndex++) {
auto &layout = exportedProject.GetLayout(layoutIndex);
scenesUsedResources[layout.GetName()] =
gd::SceneResourcesFinder::FindSceneResources(exportedProject,
layout);
}
// Strip the project (*after* generating events as the events may use
// stripped things like objects groups...)...
gd::ProjectStripper::StripProjectForExport(exportedProject);
//...and export it
gd::SerializerElement noRuntimeGameOptions;
helper.ExportProjectData(
fs, exportedProject, codeOutputDir + "/data.js", noRuntimeGameOptions);
helper.ExportProjectData(fs, exportedProject, codeOutputDir + "/data.js",
noRuntimeGameOptions, projectUsedResources,
scenesUsedResources);
includesFiles.push_back(codeOutputDir + "/data.js");
// Export a WebManifest with project metadata

View File

@@ -26,6 +26,7 @@
#include "GDCore/IDE/Events/UsedExtensionsFinder.h"
#include "GDCore/IDE/ExportedDependencyResolver.h"
#include "GDCore/IDE/Project/ProjectResourcesCopier.h"
#include "GDCore/IDE/Project/SceneResourcesFinder.h"
#include "GDCore/IDE/ProjectStripper.h"
#include "GDCore/IDE/SceneNameMangler.h"
#include "GDCore/Project/EventsBasedObject.h"
@@ -187,6 +188,17 @@ bool ExporterHelper::ExportProjectForPixiPreview(
previousTime = LogTimeSpent("Events code export", previousTime);
}
auto projectUsedResources =
gd::SceneResourcesFinder::FindProjectResources(exportedProject);
std::unordered_map<gd::String, std::set<gd::String>> scenesUsedResources;
for (std::size_t layoutIndex = 0;
layoutIndex < exportedProject.GetLayoutsCount(); layoutIndex++) {
auto &layout = exportedProject.GetLayout(layoutIndex);
scenesUsedResources[layout.GetName()] =
gd::SceneResourcesFinder::FindSceneResources(exportedProject,
layout);
}
// Strip the project (*after* generating events as the events may use stripped
// things (objects groups...))
gd::ProjectStripper::StripProjectForExport(exportedProject);
@@ -234,8 +246,9 @@ bool ExporterHelper::ExportProjectForPixiPreview(
}
// Export the project
ExportProjectData(
fs, exportedProject, codeOutputDir + "/data.js", runtimeGameOptions);
ExportProjectData(fs, exportedProject, codeOutputDir + "/data.js",
runtimeGameOptions, projectUsedResources,
scenesUsedResources);
includesFiles.push_back(codeOutputDir + "/data.js");
previousTime = LogTimeSpent("Project data export", previousTime);
@@ -259,14 +272,17 @@ bool ExporterHelper::ExportProjectForPixiPreview(
gd::String ExporterHelper::ExportProjectData(
gd::AbstractFileSystem &fs,
const gd::Project &project,
gd::Project &project,
gd::String filename,
const gd::SerializerElement &runtimeGameOptions) {
const gd::SerializerElement &runtimeGameOptions,
std::set<gd::String> &projectUsedResources,
std::unordered_map<gd::String, std::set<gd::String>> &scenesUsedResources) {
fs.MkDir(fs.DirNameFrom(filename));
// Save the project to JSON
gd::SerializerElement rootElement;
project.SerializeTo(rootElement);
SerializeUsedResources(rootElement, projectUsedResources, scenesUsedResources);
gd::String output =
"gdjs.projectData = " + gd::Serializer::ToJSON(rootElement) + ";\n" +
"gdjs.runtimeGameOptions = " +
@@ -277,6 +293,35 @@ gd::String ExporterHelper::ExportProjectData(
return "";
}
void ExporterHelper::SerializeUsedResources(
gd::SerializerElement &rootElement,
std::set<gd::String> &projectUsedResources,
std::unordered_map<gd::String, std::set<gd::String>> &scenesUsedResources) {
auto serializeUsedResources =
[](gd::SerializerElement &element,
std::set<gd::String> &usedResources) -> void {
auto &resourcesElement = element.AddChild("usedResources");
resourcesElement.ConsiderAsArrayOf("resourceReference");
for (auto &resourceName : usedResources) {
auto &resourceElement = resourcesElement.AddChild("resourceReference");
resourceElement.SetAttribute("name", resourceName);
}
};
serializeUsedResources(rootElement, projectUsedResources);
auto &layoutsElement = rootElement.GetChild("layouts");
for (std::size_t layoutIndex = 0;
layoutIndex < layoutsElement.GetChildrenCount(); layoutIndex++) {
auto &layoutElement = layoutsElement.GetChild(layoutIndex);
const auto layoutName = layoutElement.GetStringAttribute("name");
auto &layoutUsedResources = scenesUsedResources[layoutName];
serializeUsedResources(layoutElement, layoutUsedResources);
}
}
bool ExporterHelper::ExportPixiIndexFile(
const gd::Project &project,
gd::String source,
@@ -614,6 +659,7 @@ void ExporterHelper::AddLibsInclude(bool pixiRenderers,
// First, do not forget common includes (they must be included before events
// generated code files).
InsertUnique(includesFiles, "libs/jshashtable.js");
InsertUnique(includesFiles, "ObjectsLists.js");
InsertUnique(includesFiles, "logger.js");
InsertUnique(includesFiles, "gd.js");
InsertUnique(includesFiles, "libs/rbush.js");
@@ -621,8 +667,12 @@ void ExporterHelper::AddLibsInclude(bool pixiRenderers,
InsertUnique(includesFiles, "inputmanager.js");
InsertUnique(includesFiles, "jsonmanager.js");
InsertUnique(includesFiles, "Model3DManager.js");
InsertUnique(includesFiles, "ResourceLoader.js");
InsertUnique(includesFiles, "ResourceCache.js");
InsertUnique(includesFiles, "timemanager.js");
InsertUnique(includesFiles, "polygon.js");
InsertUnique(includesFiles, "ObjectSleepState.js");
InsertUnique(includesFiles, "ObjectManager.js");
InsertUnique(includesFiles, "runtimeobject.js");
InsertUnique(includesFiles, "profiler.js");
InsertUnique(includesFiles, "RuntimeInstanceContainer.js");
@@ -650,6 +700,7 @@ void ExporterHelper::AddLibsInclude(bool pixiRenderers,
InsertUnique(includesFiles, "events-tools/runtimescenetools.js");
InsertUnique(includesFiles, "events-tools/inputtools.js");
InsertUnique(includesFiles, "events-tools/objecttools.js");
InsertUnique(includesFiles, "events-tools/ObjectPositionTools.js");
InsertUnique(includesFiles, "events-tools/cameratools.js");
InsertUnique(includesFiles, "events-tools/soundtools.js");
InsertUnique(includesFiles, "events-tools/storagetools.js");

View File

@@ -3,12 +3,13 @@
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef EXPORTER_HELPER_H
#define EXPORTER_HELPER_H
#pragma once
#include <map>
#include <set>
#include <string>
#include <vector>
#include <unordered_map>
#include "GDCore/String.h"
namespace gd {
@@ -264,11 +265,12 @@ class ExporterHelper {
* in gdjs.runtimeGameOptions \return Empty string if everything is ok,
* description of the error otherwise.
*/
static gd::String ExportProjectData(
gd::AbstractFileSystem &fs,
const gd::Project &project,
gd::String filename,
const gd::SerializerElement &runtimeGameOptions);
static gd::String
ExportProjectData(gd::AbstractFileSystem &fs, gd::Project &project,
gd::String filename,
const gd::SerializerElement &runtimeGameOptions,
std::set<gd::String> &projectUsedResources,
std::unordered_map<gd::String, std::set<gd::String>> &layersUsedResources);
/**
* \brief Copy all the resources of the project to to the export directory,
@@ -474,7 +476,12 @@ class ExporterHelper {
gdjsRoot; ///< The root directory of GDJS, used to copy runtime files.
gd::String codeOutputDir; ///< The directory where JS code is outputted. Will
///< be then copied to the final output directory.
private:
static void SerializeUsedResources(
gd::SerializerElement &rootElement,
std::set<gd::String> &projectUsedResources,
std::unordered_map<gd::String, std::set<gd::String>> &layersUsedResources);
};
} // namespace gdjs
#endif // EXPORTER_HELPER_H

View File

@@ -60,6 +60,10 @@ namespace gdjs {
this._instanceContainer.loadFrom(objectData);
this.getRenderer().reinitialize(this, parent);
if (this.isNeedingLifecycleFunctions()) {
this.getLifecycleSleepState().wakeUp();
}
// The generated code calls onCreated at the constructor end
// and onCreated calls its super implementation at its end.
}
@@ -88,11 +92,11 @@ namespace gdjs {
}
}
onDestroyFromScene(parent: gdjs.RuntimeInstanceContainer): void {
onDeletedFromScene(parent: gdjs.RuntimeInstanceContainer): void {
// Let subclasses do something before the object is destroyed.
this.onDestroy(parent);
// Let behaviors do something before the object is destroyed.
super.onDestroyFromScene(parent);
super.onDeletedFromScene(parent);
// Destroy the children.
this._instanceContainer.onDestroyFromScene(parent);
}
@@ -120,6 +124,10 @@ namespace gdjs {
*/
onHotReloading(parent: gdjs.RuntimeInstanceContainer) {}
isNeedingLifecycleFunctions(): boolean {
return true;
}
// This is only to handle trigger once.
doStepPreEvents(parent: gdjs.RuntimeInstanceContainer) {}

View File

@@ -177,7 +177,7 @@ namespace gdjs {
const allInstancesList = this.getAdhocListOfAllInstances();
for (let i = 0, len = allInstancesList.length; i < len; ++i) {
const object = allInstancesList[i];
object.onDestroyFromScene(this);
object.onDeletedFromScene(this);
}
this._destroy();
@@ -235,32 +235,6 @@ namespace gdjs {
return;
}
/**
* Update the objects before launching the events.
*/
_updateObjectsPreEvents() {
const allInstancesList = this.getAdhocListOfAllInstances();
for (let i = 0, len = allInstancesList.length; i < len; ++i) {
const obj = allInstancesList[i];
const elapsedTime = obj.getElapsedTime();
if (!obj.hasNoForces()) {
const averageForce = obj.getAverageForce();
const elapsedTimeInSeconds = elapsedTime / 1000;
obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);
obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);
obj.update(this);
obj.updateForces(elapsedTimeInSeconds);
} else {
obj.update(this);
}
obj.updateTimers(elapsedTime);
obj.stepBehaviorsPreEvents(this);
}
// Some behaviors may have request objects to be deleted.
this._cacheOrClearRemovedInstances();
}
/**
* Get the renderer associated to the RuntimeScene.
*/

View File

@@ -5,20 +5,21 @@
*/
namespace gdjs {
const logger = new gdjs.Logger('Model3DManager');
type OnProgressCallback = (loadedCount: integer, totalCount: integer) => void;
const resourceKinds: Array<ResourceKind> = ['model3D'];
/**
* Load GLB files (using `Three.js`), using the "model3D" resources
* registered in the game resources.
*/
export class Model3DManager {
export class Model3DManager implements gdjs.ResourceManager {
/**
* Map associating a resource name to the loaded Three.js model.
*/
private _loadedThreeModels = new Map<String, THREE_ADDONS.GLTF>();
private _loadedThreeModels = new gdjs.ResourceCache<THREE_ADDONS.GLTF>();
private _downloadedArrayBuffers = new gdjs.ResourceCache<ArrayBuffer>();
_resourcesLoader: RuntimeGameResourcesLoader;
_resources: Map<string, ResourceData>;
_resourceLoader: gdjs.ResourceLoader;
_loader: THREE_ADDONS.GLTFLoader | null = null;
_dracoLoader: THREE_ADDONS.DRACOLoader | null = null;
@@ -28,15 +29,10 @@ namespace gdjs {
/**
* @param resourceDataArray The resources data of the game.
* @param resourcesLoader The resources loader of the game.
* @param resourceLoader The resources loader of the game.
*/
constructor(
resourceDataArray: ResourceData[],
resourcesLoader: RuntimeGameResourcesLoader
) {
this._resources = new Map<string, ResourceData>();
this.setResources(resourceDataArray);
this._resourcesLoader = resourcesLoader;
constructor(resourceLoader: gdjs.ResourceLoader) {
this._resourceLoader = resourceLoader;
if (typeof THREE !== 'undefined') {
this._loader = new THREE_ADDONS.GLTFLoader();
@@ -69,17 +65,34 @@ namespace gdjs {
}
}
/**
* Update the resources data of the game. Useful for hot-reloading, should not be used otherwise.
*
* @param resourceDataArray The resources data of the game.
*/
setResources(resourceDataArray: ResourceData[]): void {
this._resources.clear();
for (const resourceData of resourceDataArray) {
if (resourceData.kind === 'model3D') {
this._resources.set(resourceData.name, resourceData);
}
getResourceKinds(): ResourceKind[] {
return resourceKinds;
}
async processResource(resourceName: string): Promise<void> {
const resource = this._resourceLoader.getResource(resourceName);
if (!resource) {
logger.warn(
'Unable to find texture for resource "' + resourceName + '".'
);
return;
}
const loader = this._loader;
if (!loader) {
return;
}
const data = this._downloadedArrayBuffers.get(resource);
if (!data) {
return;
}
this._downloadedArrayBuffers.delete(resource);
try {
const gltf: THREE_ADDONS.GLTF = await loader.parseAsync(data, '');
this._loadedThreeModels.set(resource, gltf);
} catch (error) {
logger.error(
"Can't fetch the 3D model file " + resource.file + ', error: ' + error
);
}
}
@@ -88,42 +101,36 @@ namespace gdjs {
*
* Note that even if a file is already loaded, it will be reloaded (useful for hot-reloading,
* as files can have been modified without the editor knowing).
*
* @param onProgress The function called after each file is loaded.
* @param onComplete The function called when all file are loaded.
*/
async loadModels(onProgress: OnProgressCallback): Promise<integer> {
const loader = this._loader;
if (this._resources.size === 0 || !loader) {
return 0;
async loadResource(resourceName: string): Promise<void> {
const resource = this._resourceLoader.getResource(resourceName);
if (!resource) {
logger.warn(
'Unable to find texture for resource "' + resourceName + '".'
);
return;
}
const loader = this._loader;
if (!loader) {
return;
}
const url = this._resourceLoader.getFullUrl(resource.file);
try {
const response = await fetch(url, {
credentials: this._resourceLoader.checkIfCredentialsRequired(url)
? 'include'
: 'omit',
});
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.arrayBuffer();
this._downloadedArrayBuffers.set(resource, data);
} catch (error) {
logger.error(
"Can't fetch the 3D model file " + resource.file + ', error: ' + error
);
}
let loadedCount = 0;
await Promise.all(
[...this._resources.values()].map(async (resource) => {
const url = this._resourcesLoader.getFullUrl(resource.file);
loader.withCredentials = this._resourcesLoader.checkIfCredentialsRequired(
url
);
try {
const gltf: THREE_ADDONS.GLTF = await loader.loadAsync(
url,
(event) => {}
);
this._loadedThreeModels.set(resource.name, gltf);
} catch (error) {
logger.error(
"Can't fetch the 3D model file " +
resource.file +
', error: ' +
error
);
}
loadedCount++;
onProgress(loadedCount, this._resources.size);
})
);
return loadedCount;
}
/**
@@ -135,7 +142,9 @@ namespace gdjs {
* @returns a 3D model if it exists.
*/
getModel(resourceName: string): THREE_ADDONS.GLTF {
return this._loadedThreeModels.get(resourceName) || this._invalidModel;
return (
this._loadedThreeModels.getFromName(resourceName) || this._invalidModel
);
}
}
}

Some files were not shown because too many files have changed in this diff Show More