mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
288 Commits
v5.0.0-bet
...
v5.0.124
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b3ea46d7e6 | ||
![]() |
0e8adaab92 | ||
![]() |
c055fbcb3c | ||
![]() |
5051de0787 | ||
![]() |
4976d8ef8b | ||
![]() |
bf1ffd3e65 | ||
![]() |
9163e998f9 | ||
![]() |
a4d0c591a8 | ||
![]() |
8c717ba910 | ||
![]() |
be0f760f02 | ||
![]() |
919d596d07 | ||
![]() |
35cfd627ad | ||
![]() |
ba687aa60c | ||
![]() |
4d8e835b9a | ||
![]() |
834a28ddbc | ||
![]() |
945555a8e9 | ||
![]() |
ad3d1dd8c3 | ||
![]() |
fd47282456 | ||
![]() |
dff1c88ef7 | ||
![]() |
4ea622ff99 | ||
![]() |
17ea918a91 | ||
![]() |
cc6af8979d | ||
![]() |
132e20fd24 | ||
![]() |
fb6a88785a | ||
![]() |
8a159d7ff5 | ||
![]() |
13c85bbe45 | ||
![]() |
ce8323e8e1 | ||
![]() |
dbc7a74e45 | ||
![]() |
cfb1d6888e | ||
![]() |
816dc8cc74 | ||
![]() |
106549e5fa | ||
![]() |
f8ca06d530 | ||
![]() |
34cbcdbc3a | ||
![]() |
3b208502ae | ||
![]() |
e3654fca99 | ||
![]() |
2a386cdcf1 | ||
![]() |
b134896687 | ||
![]() |
705dff43bc | ||
![]() |
d9eaf71ed1 | ||
![]() |
008b4291ab | ||
![]() |
3596896b16 | ||
![]() |
db05e98bc8 | ||
![]() |
98c1a93da5 | ||
![]() |
c39d3ee35c | ||
![]() |
c68a25573d | ||
![]() |
2b72b6b3e7 | ||
![]() |
db60151150 | ||
![]() |
0971a4b464 | ||
![]() |
93a57b1a31 | ||
![]() |
d0f7e2517d | ||
![]() |
9523c98cad | ||
![]() |
ea38a2ff0f | ||
![]() |
3065ba53b1 | ||
![]() |
dc19f030fc | ||
![]() |
9fb36a375f | ||
![]() |
a366934fdb | ||
![]() |
9626ea6dcf | ||
![]() |
08388893bf | ||
![]() |
2f933f2cad | ||
![]() |
2517b47401 | ||
![]() |
86cad60194 | ||
![]() |
b1658d4619 | ||
![]() |
c72026e8cd | ||
![]() |
4936b4b104 | ||
![]() |
5623d12eac | ||
![]() |
8757cfe8b2 | ||
![]() |
968402e99f | ||
![]() |
6f59a0921d | ||
![]() |
167307f1c4 | ||
![]() |
36fb4ec9b2 | ||
![]() |
124e1f3683 | ||
![]() |
9c350729a8 | ||
![]() |
9186daa782 | ||
![]() |
c6161c4752 | ||
![]() |
5d3f207216 | ||
![]() |
cf462f6c6e | ||
![]() |
bc979031e3 | ||
![]() |
406bae5e12 | ||
![]() |
5f5f50e039 | ||
![]() |
394fb4c587 | ||
![]() |
599d48afca | ||
![]() |
bccef185cb | ||
![]() |
d0f4370026 | ||
![]() |
77d6f0310c | ||
![]() |
c73a5a046f | ||
![]() |
c37e129a5b | ||
![]() |
aeecb0e29f | ||
![]() |
a6525e5617 | ||
![]() |
f67aeedaeb | ||
![]() |
0c2f023c63 | ||
![]() |
d6d4569dbf | ||
![]() |
965ec330cf | ||
![]() |
c09d29a959 | ||
![]() |
67612009d1 | ||
![]() |
2da5194672 | ||
![]() |
7f5821a299 | ||
![]() |
a3fdeec6a7 | ||
![]() |
852ad1d92b | ||
![]() |
8fdba503ab | ||
![]() |
50d7bec375 | ||
![]() |
0c85e9bf30 | ||
![]() |
08c41ece71 | ||
![]() |
bd9fffba3f | ||
![]() |
413caf6f62 | ||
![]() |
530d0baffe | ||
![]() |
e78d2c6962 | ||
![]() |
bc606ed1be | ||
![]() |
c705f89de8 | ||
![]() |
3b73b5eb6d | ||
![]() |
107410f0a4 | ||
![]() |
b7b95d5e09 | ||
![]() |
a470e9b86c | ||
![]() |
cf5c8ae631 | ||
![]() |
8f8ac2fd1e | ||
![]() |
cdac70425e | ||
![]() |
378f0a48ad | ||
![]() |
e653639366 | ||
![]() |
e105d4c9f6 | ||
![]() |
5b80bed305 | ||
![]() |
a4ac323e63 | ||
![]() |
bc23d6a084 | ||
![]() |
2c24359fba | ||
![]() |
a6b01fc01d | ||
![]() |
44b81f52ea | ||
![]() |
cfdf13538e | ||
![]() |
7ee38a50bf | ||
![]() |
e2b8620b83 | ||
![]() |
7ed8660edc | ||
![]() |
75cc70368c | ||
![]() |
0d3dfe5cf4 | ||
![]() |
e7aa75bcd7 | ||
![]() |
c5ad127e83 | ||
![]() |
acfdebfc0f | ||
![]() |
d3f8b410b0 | ||
![]() |
4b7d67ce97 | ||
![]() |
46a81ef4be | ||
![]() |
fe2812b8e8 | ||
![]() |
042cf49b3b | ||
![]() |
7cf334ad1c | ||
![]() |
f999bee387 | ||
![]() |
0627d4b865 | ||
![]() |
92e6a5e67f | ||
![]() |
d980400c2b | ||
![]() |
e235694fac | ||
![]() |
cdf00d10f1 | ||
![]() |
218520b836 | ||
![]() |
3ce71813ba | ||
![]() |
90300f895c | ||
![]() |
9c8aa57fb6 | ||
![]() |
84876a1dff | ||
![]() |
19ef8742f0 | ||
![]() |
567efafa70 | ||
![]() |
c70685ccc7 | ||
![]() |
ec8daa7d8d | ||
![]() |
0d817f4dae | ||
![]() |
9dbbaada01 | ||
![]() |
342a6dc56f | ||
![]() |
baae910fe8 | ||
![]() |
2c6d30b28e | ||
![]() |
9321f0ec7c | ||
![]() |
e463f352b7 | ||
![]() |
5e3430aea5 | ||
![]() |
2d899d7c52 | ||
![]() |
0b933a569e | ||
![]() |
4904e7e7fb | ||
![]() |
bfb1b6b15d | ||
![]() |
9364a485cd | ||
![]() |
176a2a0b47 | ||
![]() |
a10c9362dd | ||
![]() |
3a0f55ee1b | ||
![]() |
0b6bddc5a4 | ||
![]() |
bf910e0cba | ||
![]() |
763d8e8175 | ||
![]() |
135ba2b4df | ||
![]() |
d4a3722ec8 | ||
![]() |
477e88d4ce | ||
![]() |
023ed8f7b5 | ||
![]() |
55020a3d15 | ||
![]() |
552219e48f | ||
![]() |
4dfac41d81 | ||
![]() |
33deca92e3 | ||
![]() |
adc7584981 | ||
![]() |
23d5296a52 | ||
![]() |
2febbf439f | ||
![]() |
169a49a246 | ||
![]() |
c8c4322ece | ||
![]() |
349703e287 | ||
![]() |
1326ffd3b6 | ||
![]() |
baff4d3cb0 | ||
![]() |
b40e2d3fdf | ||
![]() |
8e6ba3abce | ||
![]() |
aaebbe47d5 | ||
![]() |
a51003040c | ||
![]() |
cfce635419 | ||
![]() |
3d299c5a14 | ||
![]() |
f33196dc85 | ||
![]() |
7b2dc2223c | ||
![]() |
b37d05f78c | ||
![]() |
dcba0b45a6 | ||
![]() |
f2ec46ca1e | ||
![]() |
5c33e9e8d0 | ||
![]() |
fc23517bae | ||
![]() |
24c74af79b | ||
![]() |
2a19ea5182 | ||
![]() |
705c7af134 | ||
![]() |
028eebefab | ||
![]() |
25acb603b4 | ||
![]() |
27d4ead51e | ||
![]() |
1704d196f9 | ||
![]() |
d40e360b8a | ||
![]() |
183a0bd08e | ||
![]() |
8780f2f415 | ||
![]() |
5adb3c92ee | ||
![]() |
a54ee812bd | ||
![]() |
f8db01706d | ||
![]() |
d9368921af | ||
![]() |
12743f6f7e | ||
![]() |
3d3048906e | ||
![]() |
413fbc529e | ||
![]() |
287ebd4244 | ||
![]() |
f2199c8ab4 | ||
![]() |
64b63d4efa | ||
![]() |
3820c2613a | ||
![]() |
c42603bb29 | ||
![]() |
b879d3043f | ||
![]() |
8be448fd0e | ||
![]() |
9535fbca0f | ||
![]() |
6667a0005c | ||
![]() |
860faae853 | ||
![]() |
dd47c7f6c4 | ||
![]() |
c4f76efbcd | ||
![]() |
56d9dc05f1 | ||
![]() |
599ccb677f | ||
![]() |
b97f716c09 | ||
![]() |
58917aec02 | ||
![]() |
fdaba4a6d5 | ||
![]() |
d1f49cd1f7 | ||
![]() |
71a9a3f1d0 | ||
![]() |
9173e704be | ||
![]() |
1a27f689e0 | ||
![]() |
ef198b2c64 | ||
![]() |
d5039b5b51 | ||
![]() |
4b19696523 | ||
![]() |
32978c22e8 | ||
![]() |
1f6f2701ff | ||
![]() |
fbf2340f00 | ||
![]() |
4ff208b39f | ||
![]() |
3d0a893c1c | ||
![]() |
2581021a57 | ||
![]() |
e4fc065dc1 | ||
![]() |
d1f4d26e49 | ||
![]() |
a1b840a4fa | ||
![]() |
465629b688 | ||
![]() |
38758c62c6 | ||
![]() |
26f6e95e46 | ||
![]() |
34abf8290e | ||
![]() |
52677f5512 | ||
![]() |
df2b51bb1b | ||
![]() |
6b0ff984f2 | ||
![]() |
f4512242e4 | ||
![]() |
8beabbadef | ||
![]() |
9491a8ed45 | ||
![]() |
f945dfd987 | ||
![]() |
ff42591354 | ||
![]() |
21fb93c66a | ||
![]() |
068fbe653a | ||
![]() |
80891dcc59 | ||
![]() |
34155d65f1 | ||
![]() |
18f22470ca | ||
![]() |
92a8ebc58b | ||
![]() |
565384e270 | ||
![]() |
8335b2edf9 | ||
![]() |
12c77d0455 | ||
![]() |
13b62a06eb | ||
![]() |
d27119d8ea | ||
![]() |
dd3ff554d5 | ||
![]() |
287a17b634 | ||
![]() |
7dc477e29e | ||
![]() |
8174bca3b1 | ||
![]() |
7f6388c6f5 | ||
![]() |
da3a099ff2 | ||
![]() |
7b2c7b4a00 | ||
![]() |
f750a356c3 | ||
![]() |
611a72aee1 | ||
![]() |
1b965b65a4 | ||
![]() |
c077628eb4 | ||
![]() |
f1a6da0cb2 | ||
![]() |
df4a780311 |
@@ -1,9 +1,79 @@
|
|||||||
# CircleCI 2.0 configuration file to build GDevelop app running
|
# CircleCI configuration to build GDevelop app running
|
||||||
# on the Electron runtime (newIDE/electron-app).
|
# on the Electron runtime (newIDE/electron-app) for macOS and Linux.
|
||||||
|
# For Windows, see the appveyor.yml file.
|
||||||
|
|
||||||
version: 2
|
version: 2.1
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-macos:
|
||||||
|
macos:
|
||||||
|
xcode: 12.5.1
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
|
||||||
|
# System dependencies (for Emscripten and upload)
|
||||||
|
- run:
|
||||||
|
name: Install dependencies for Emscripten
|
||||||
|
command: brew install cmake
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Install dependencies for AWS S3 upload
|
||||||
|
command: curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" && sudo installer -pkg AWSCLIV2.pkg -target /
|
||||||
|
|
||||||
|
- 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 ..
|
||||||
|
|
||||||
|
# GDevelop.js dependencies
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- gd-macos-nodejs-dependencies-{{ checksum "newIDE/app/package.json" }}-{{ checksum "newIDE/electron-app/package.json" }}-{{ checksum "GDevelop.js/package.json" }}
|
||||||
|
# fallback to using the latest cache if no exact match is found
|
||||||
|
- gd-macos-nodejs-dependencies---
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Install GDevelop.js dependencies and build it
|
||||||
|
command: cd GDevelop.js && npm install && cd ..
|
||||||
|
|
||||||
|
# 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 ..
|
||||||
|
|
||||||
|
# GDevelop IDE dependencies (after building GDevelop.js to avoid downloading a pre-built version)
|
||||||
|
- run:
|
||||||
|
name: Install GDevelop IDE dependencies
|
||||||
|
command: cd newIDE/app && npm install && cd ../electron-app && npm install
|
||||||
|
|
||||||
|
- save_cache:
|
||||||
|
paths:
|
||||||
|
- newIDE/electron-app/node_modules
|
||||||
|
- newIDE/app/node_modules
|
||||||
|
- GDevelop.js/node_modules
|
||||||
|
key: gd-macos-nodejs-dependencies-{{ checksum "newIDE/app/package.json" }}-{{ checksum "newIDE/electron-app/package.json" }}-{{ checksum "GDevelop.js/package.json" }}
|
||||||
|
|
||||||
|
# Build GDevelop IDE (seems like we need to allow Node.js to use more space than usual)
|
||||||
|
# Note: Code signing is done using CSC_LINK (see https://www.electron.build/code-signing).
|
||||||
|
- run:
|
||||||
|
name: Build GDevelop IDE
|
||||||
|
command: export NODE_OPTIONS="--max-old-space-size=7168" && cd newIDE/electron-app && npm run build -- --mac --publish=never
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Clean dist folder to keep only installers/binaries.
|
||||||
|
command: rm -rf "newIDE/electron-app/dist/mac/GDevelop 5.app"
|
||||||
|
|
||||||
|
# Upload artifacts (CircleCI)
|
||||||
|
- store_artifacts:
|
||||||
|
path: newIDE/electron-app/dist
|
||||||
|
|
||||||
|
# Upload artifacts (AWS)
|
||||||
|
- run:
|
||||||
|
name: Deploy to S3 (specific commit)
|
||||||
|
command: export PATH=~/.local/bin:$PATH && aws s3 sync newIDE/electron-app/dist s3://gdevelop-releases/$(git rev-parse --abbrev-ref HEAD)/commit/$(git rev-parse HEAD)/
|
||||||
|
- run:
|
||||||
|
name: Deploy to S3 (latest)
|
||||||
|
command: export PATH=~/.local/bin:$PATH && aws s3 sync newIDE/electron-app/dist s3://gdevelop-releases/$(git rev-parse --abbrev-ref HEAD)/latest/
|
||||||
|
|
||||||
|
build-linux:
|
||||||
# CircleCI docker workers are failing if they don't have enough memory (no swap)
|
# CircleCI docker workers are failing if they don't have enough memory (no swap)
|
||||||
resource_class: xlarge
|
resource_class: xlarge
|
||||||
docker:
|
docker:
|
||||||
@@ -23,10 +93,6 @@ jobs:
|
|||||||
name: Install Emscripten (for GDevelop.js)
|
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 1.39.6 && ./emsdk activate 1.39.6 && cd ..
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Install Wine for Electron builder
|
|
||||||
command: sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt install wine32
|
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Install system dependencies for Electron builder
|
name: Install system dependencies for Electron builder
|
||||||
command: sudo apt install icnsutils && sudo apt install graphicsmagick && sudo apt install rsync
|
command: sudo apt install icnsutils && sudo apt install graphicsmagick && sudo apt install rsync
|
||||||
@@ -34,15 +100,15 @@ jobs:
|
|||||||
# GDevelop.js dependencies
|
# GDevelop.js dependencies
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- gd-nodejs-dependencies-{{ checksum "newIDE/app/package.json" }}-{{ checksum "newIDE/electron-app/package.json" }}-{{ checksum "GDevelop.js/package.json" }}
|
- gd-linux-nodejs-dependencies-{{ checksum "newIDE/app/package.json" }}-{{ checksum "newIDE/electron-app/package.json" }}-{{ checksum "GDevelop.js/package.json" }}
|
||||||
# fallback to using the latest cache if no exact match is found
|
# fallback to using the latest cache if no exact match is found
|
||||||
- gd-nodejs-dependencies---
|
- gd-linux-nodejs-dependencies---
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Install GDevelop.js dependencies and build it
|
name: Install GDevelop.js dependencies and build it
|
||||||
command: cd GDevelop.js && sudo npm install -g grunt-cli && npm install && cd ..
|
command: cd GDevelop.js && npm install && cd ..
|
||||||
|
|
||||||
# Build GDevelop.js
|
# Build GDevelop.js (and run tests to ensure it works)
|
||||||
- run:
|
- run:
|
||||||
name: Build GDevelop.js
|
name: Build GDevelop.js
|
||||||
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test && cd ..
|
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test && cd ..
|
||||||
@@ -57,16 +123,16 @@ jobs:
|
|||||||
- newIDE/electron-app/node_modules
|
- newIDE/electron-app/node_modules
|
||||||
- newIDE/app/node_modules
|
- newIDE/app/node_modules
|
||||||
- GDevelop.js/node_modules
|
- GDevelop.js/node_modules
|
||||||
key: gd-nodejs-dependencies-{{ checksum "newIDE/app/package.json" }}-{{ checksum "newIDE/electron-app/package.json" }}
|
key: gd-linux-nodejs-dependencies-{{ checksum "newIDE/app/package.json" }}-{{ checksum "newIDE/electron-app/package.json" }}-{{ checksum "GDevelop.js/package.json" }}
|
||||||
|
|
||||||
# Build GDevelop IDE (seems like we need to allow Node.js to use more space than usual)
|
# Build GDevelop IDE (seems like we need to allow Node.js to use more space than usual)
|
||||||
- run:
|
- run:
|
||||||
name: Build GDevelop IDE
|
name: Build GDevelop IDE
|
||||||
command: export NODE_OPTIONS="--max-old-space-size=7168" && cd newIDE/electron-app && npm run build -- --mac zip --win --linux tar.gz --publish=never
|
command: export NODE_OPTIONS="--max-old-space-size=7168" && cd newIDE/electron-app && npm run build -- --linux AppImage --publish=never
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Clean dist folder to keep only installers/binaries.
|
name: Clean dist folder to keep only installers/binaries.
|
||||||
command: rm -rf newIDE/electron-app/dist/linux-unpacked && rm -rf newIDE/electron-app/dist/win-unpacked && rm -rf newIDE/electron-app/dist/mac
|
command: rm -rf newIDE/electron-app/dist/linux-unpacked
|
||||||
|
|
||||||
# Upload artifacts (CircleCI)
|
# Upload artifacts (CircleCI)
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
@@ -79,3 +145,20 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: Deploy to S3 (latest)
|
name: Deploy to S3 (latest)
|
||||||
command: aws s3 sync newIDE/electron-app/dist s3://gdevelop-releases/$(git rev-parse --abbrev-ref HEAD)/latest/
|
command: aws s3 sync newIDE/electron-app/dist s3://gdevelop-releases/$(git rev-parse --abbrev-ref HEAD)/latest/
|
||||||
|
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
builds:
|
||||||
|
jobs:
|
||||||
|
- build-macos:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- /experimental-build.*/
|
||||||
|
- build-linux:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- /experimental-build.*/
|
||||||
|
@@ -13,6 +13,5 @@
|
|||||||
-fPIC
|
-fPIC
|
||||||
-I./ExtLibs/SFML/include
|
-I./ExtLibs/SFML/include
|
||||||
-I./Core
|
-I./Core
|
||||||
-I./GDCpp/.
|
|
||||||
-I./GDJS/.
|
-I./GDJS/.
|
||||||
-F./ExtLibs/SFML/extlibs/libs-osx/Frameworks
|
-F./ExtLibs/SFML/extlibs/libs-osx/Frameworks
|
||||||
|
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,6 +1,5 @@
|
|||||||
Core/GDCore/Serialization/rapidjson/rapidjson.h/* linguist-vendored
|
Core/GDCore/Serialization/rapidjson/rapidjson.h/* linguist-vendored
|
||||||
Core/GDCore/TinyXml/* linguist-vendored
|
Core/GDCore/TinyXml/* linguist-vendored
|
||||||
GDCpp/GDCpp/Runtime/TinyXml/* linguist-vendored
|
|
||||||
Extensions/ParticleSystem/SPARK/* linguist-vendored
|
Extensions/ParticleSystem/SPARK/* linguist-vendored
|
||||||
Extensions/PhysicsBehavior/Box2D/* linguist-vendored
|
Extensions/PhysicsBehavior/Box2D/* linguist-vendored
|
||||||
Extensions/PhysicsBehavior/box2djs/* linguist-vendored
|
Extensions/PhysicsBehavior/box2djs/* linguist-vendored
|
||||||
|
15
.github/stale.yml
vendored
Normal file
15
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Automatically close issues with certain tags indicating that we need more information,
|
||||||
|
# after some days have passed.
|
||||||
|
|
||||||
|
daysUntilStale: 20
|
||||||
|
daysUntilClose: 7
|
||||||
|
|
||||||
|
# Only do this on tags implying we need more information:
|
||||||
|
onlyLabels: ["Need a game/precise steps to reproduce the issue","👋 Needs confirmation/testing"]
|
||||||
|
only: issues
|
||||||
|
|
||||||
|
markComment: >
|
||||||
|
This issue seems to be stale: it needs additional information but it has not had
|
||||||
|
recent activity. It will be closed in 7 days if no further activity occurs. Thank you
|
||||||
|
for your contributions.
|
||||||
|
|
71
.github/workflows/build-storybook.yml
vendored
Normal file
71
.github/workflows/build-storybook.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# GitHub Action to build the Storybook of the editor and publish it for testing.
|
||||||
|
#
|
||||||
|
# Note that only the Storybook is built and GDevelop.js is not rebuilt (for speed concerns),
|
||||||
|
# so changes in the C++ source could not be reflected if the CI run by Travis-CI
|
||||||
|
# did not upload a freshly built GDevelop.js.
|
||||||
|
|
||||||
|
name: Build Storybook
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Launch on all commits.
|
||||||
|
push:
|
||||||
|
# Allows to run this workflow manually from the Actions tab,
|
||||||
|
# to publish on Chromatic (not done by default).
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-storybook:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Configure AWS Credentials
|
||||||
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
|
with:
|
||||||
|
aws-access-key-id: ${{ secrets.BUILD_STORYBOOK_AWS_ACCESS_KEY_ID }}
|
||||||
|
aws-secret-access-key: ${{ secrets.BUILD_STORYBOOK_AWS_SECRET_ACCESS_KEY }}
|
||||||
|
aws-region: us-east-1
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 50
|
||||||
|
|
||||||
|
# Cache npm dependencies to speed up the workflow
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-newIDE-app-node_modules
|
||||||
|
with:
|
||||||
|
# npm cache files are stored in `~/.npm` on Linux/macOS
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('newIDE/app/package-lock.json') }}
|
||||||
|
|
||||||
|
- name: Install newIDE dependencies
|
||||||
|
run: npm install
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
- name: Build Storybook
|
||||||
|
run: npm run build-storybook
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
# Publish on S3 to allow quick testing of components.
|
||||||
|
- name: Publish Storybook to S3 bucket (specific commit)
|
||||||
|
run: aws s3 sync ./build-storybook/ s3://gdevelop-storybook/$(git rev-parse --abbrev-ref HEAD)/commit/$(git rev-parse HEAD)/ --delete
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
- name: Publish Storybook to S3 bucket (latest)
|
||||||
|
run: aws s3 sync ./build-storybook/ s3://gdevelop-storybook/$(git rev-parse --abbrev-ref HEAD)/latest/ --delete
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
- name: Log urls to the Storybook
|
||||||
|
run: |
|
||||||
|
echo "Find the latest Storybook for this branch on http://gdevelop-storybook.s3-website-us-east-1.amazonaws.com/$(git rev-parse --abbrev-ref HEAD)/latest/index.html"
|
||||||
|
echo "Find the Storybook for this commit on http://gdevelop-storybook.s3-website-us-east-1.amazonaws.com/$(git rev-parse --abbrev-ref HEAD)/commit/$(git rev-parse HEAD)/index.html"
|
||||||
|
|
||||||
|
# Publish on Chromatic, only when manually launched (too costly to run on every commit).
|
||||||
|
- name: Publish Storybook to Chromatic
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
uses: chromaui/action@v1
|
||||||
|
with:
|
||||||
|
workingDir: newIDE/app
|
||||||
|
storybookBuildDir: "build-storybook"
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
47
.github/workflows/extract-translations.yml
vendored
Normal file
47
.github/workflows/extract-translations.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# GitHub Action to extract translations and (later) upload them to Crowdin.
|
||||||
|
|
||||||
|
name: Extract translations
|
||||||
|
on:
|
||||||
|
# Execute for all commits (to ensure translations extraction works)
|
||||||
|
push:
|
||||||
|
# Allows to run this workflow manually from the Actions tab.
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
extract-translations:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Cache npm dependencies to speed up the workflow
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-newIDE-app-node_modules
|
||||||
|
with:
|
||||||
|
# npm cache files are stored in `~/.npm` on Linux/macOS
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('newIDE/app/package-lock.json') }}
|
||||||
|
|
||||||
|
- name: Install gettext
|
||||||
|
run: sudo apt update && sudo apt install gettext -y
|
||||||
|
|
||||||
|
- name: Install newIDE dependencies
|
||||||
|
run: npm install
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
- name: Extract translations
|
||||||
|
run: npm run extract-all-translations
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
# Only upload on Crowdin for the master branch
|
||||||
|
- name: Install Crowdin CLI
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
run: npm i -g @crowdin/cli
|
||||||
|
|
||||||
|
- name: Upload translations to Crowdin
|
||||||
|
run: crowdin upload sources
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
env:
|
||||||
|
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||||
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
15
.github/workflows/issues.yml
vendored
15
.github/workflows/issues.yml
vendored
@@ -4,13 +4,6 @@ jobs:
|
|||||||
autoclose:
|
autoclose:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Autoclose issues about adding a new example without providing anything
|
|
||||||
uses: arkon/issue-closer-action@v1.1
|
|
||||||
with:
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
type: "body"
|
|
||||||
regex: ".*INSERT the link to your game here, or add it as an attachment.*"
|
|
||||||
message: "Hi @${issue.user.login}! 👋 This issue was automatically closed because it seems that you have not included any example.\n\nGitHub is a place for the technical development of GDevelop itself - you may want to go on the [forum](https://forum.gdevelop-app.com/), the Discord chat or [read the documentation](http://wiki.compilgames.net/doku.php/gdevelop5/start) to learn more about GDevelop. Thanks!"
|
|
||||||
- name: Autoclose issues about adding a bug without changing the bug report template
|
- name: Autoclose issues about adding a bug without changing the bug report template
|
||||||
uses: arkon/issue-closer-action@v1.1
|
uses: arkon/issue-closer-action@v1.1
|
||||||
with:
|
with:
|
||||||
@@ -25,3 +18,11 @@ jobs:
|
|||||||
type: "body"
|
type: "body"
|
||||||
regex: ".*_instance.getRawFloatProperty is not a function.*"
|
regex: ".*_instance.getRawFloatProperty is not a function.*"
|
||||||
message: "Hi @${issue.user.login}! 👋 This issue was automatically closed as this seems to be a known bug. It can be solved by **closing entirely the web-app and opening it again**. This will allow the web-app to auto-update and the problem should be gone."
|
message: "Hi @${issue.user.login}! 👋 This issue was automatically closed as this seems to be a known bug. It can be solved by **closing entirely the web-app and opening it again**. This will allow the web-app to auto-update and the problem should be gone."
|
||||||
|
- name: Autoclose known beta 114 web-app update bug
|
||||||
|
uses: arkon/issue-closer-action@v1.1
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
type: "body"
|
||||||
|
regex: ".*getAssociatedSettings is not a function.*"
|
||||||
|
message: "Hi @${issue.user.login}! 👋 This issue was automatically closed as this seems to be a known bug. It can be solved by **closing entirely the web-app and opening it again**. This will allow the web-app to auto-update and the problem should be gone."
|
||||||
|
|
||||||
|
73
.github/workflows/update-translations.yml
vendored
Normal file
73
.github/workflows/update-translations.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# GitHub Action to update translations by downloading them from Crowdin,
|
||||||
|
# and open a Pull Request with the changes.
|
||||||
|
|
||||||
|
name: Update translations
|
||||||
|
on:
|
||||||
|
# Execute only on master
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
# Allows to run this workflow manually from the Actions tab.
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-translations:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Cache npm dependencies to speed up the workflow
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-newIDE-app-node_modules
|
||||||
|
with:
|
||||||
|
# npm cache files are stored in `~/.npm` on Linux/macOS
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('newIDE/app/package-lock.json') }}
|
||||||
|
|
||||||
|
- name: Install gettext
|
||||||
|
run: sudo apt update && sudo apt install gettext -y
|
||||||
|
|
||||||
|
- name: Install newIDE dependencies
|
||||||
|
run: npm install
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
# We need to extract translations first to make sure all the source strings
|
||||||
|
# are included in the English catalogs. Otherwise, missing source strings
|
||||||
|
# with parameters (like "My name is {0}.") would be shown as-is when
|
||||||
|
# the app is built (but not in development - unclear why, LinguiJS issue?).
|
||||||
|
- name: Extract translations
|
||||||
|
run: npm run extract-all-translations
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
# (Build and) download the most recent translations (PO files) from Crowdin.
|
||||||
|
- name: Install Crowdin CLI
|
||||||
|
run: npm i -g @crowdin/cli
|
||||||
|
|
||||||
|
- name: Download new translations from Crowdin
|
||||||
|
run: crowdin download
|
||||||
|
env:
|
||||||
|
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||||
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||||
|
|
||||||
|
# Seems like the three letters code is not handled properly by LinguiJS?
|
||||||
|
# Do without this language while we find a solution.
|
||||||
|
- name: Remove catalogs not handled properly by LinguiJS compile command.
|
||||||
|
run: rm -rf newIDE/app/src/locales/pcm_NG/
|
||||||
|
|
||||||
|
- name: Compile translations into .js files that are read by LinguiJS
|
||||||
|
run: npm run compile-translations
|
||||||
|
working-directory: newIDE/app
|
||||||
|
|
||||||
|
- name: Create a Pull Request with the changes
|
||||||
|
uses: peter-evans/create-pull-request@v3.10.1
|
||||||
|
with:
|
||||||
|
commit-message: Update translations [skip ci]
|
||||||
|
branch: chore/update-translations
|
||||||
|
delete-branch: true
|
||||||
|
title: '[Auto PR] Update translations'
|
||||||
|
body: |
|
||||||
|
This updates the translations by downloading them from Crowdin and compiling them for usage by the app.
|
||||||
|
|
||||||
|
Please double check the values in `newIDE/app/src/locales/LocalesMetadata.js` to ensure the changes are sensible.
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
/Core/GDCore/Tools/VersionPriv.h
|
|
||||||
/docs
|
/docs
|
||||||
/docs-wiki
|
/docs-wiki
|
||||||
/ExtLibs/SFML
|
/ExtLibs/SFML
|
||||||
@@ -16,7 +15,6 @@
|
|||||||
*.bc
|
*.bc
|
||||||
/Binaries/Output
|
/Binaries/Output
|
||||||
*.autosave
|
*.autosave
|
||||||
!/GDCpp/scripts/bcp.exe
|
|
||||||
!/scripts/libgettextlib-0-17.dll
|
!/scripts/libgettextlib-0-17.dll
|
||||||
!/scripts/libgettextsrc-0-17.dll
|
!/scripts/libgettextsrc-0-17.dll
|
||||||
!/xgettext.exe
|
!/xgettext.exe
|
||||||
|
107
.semaphore/semaphore.yml
Normal file
107
.semaphore/semaphore.yml
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
version: v1.0
|
||||||
|
name: Fast tests (not building GDevelop.js - can have false negatives)
|
||||||
|
agent:
|
||||||
|
machine:
|
||||||
|
type: e1-standard-2
|
||||||
|
os_image: ubuntu2004
|
||||||
|
auto_cancel:
|
||||||
|
running:
|
||||||
|
when: "true"
|
||||||
|
blocks:
|
||||||
|
- name: Install
|
||||||
|
task:
|
||||||
|
jobs:
|
||||||
|
- name: Install node_modules and cache them
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- node -v && npm -v
|
||||||
|
- |-
|
||||||
|
if ! cache has_key newIDE-app-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum newIDE/app/package-lock.json); then
|
||||||
|
cd newIDE/app
|
||||||
|
npm ci
|
||||||
|
cd ../..
|
||||||
|
cache store newIDE-app-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum newIDE/app/package-lock.json) newIDE/app/node_modules
|
||||||
|
fi
|
||||||
|
- |-
|
||||||
|
if ! cache has_key GDJS-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/package-lock.json); then
|
||||||
|
cd GDJS
|
||||||
|
git checkout package-lock.json # Ensure no changes was made by newIDE post-install tasks.
|
||||||
|
npm ci
|
||||||
|
cd ..
|
||||||
|
cache store GDJS-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/package-lock.json) GDJS/node_modules
|
||||||
|
fi
|
||||||
|
- |-
|
||||||
|
if ! cache has_key GDJS-tests-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/tests/package-lock.json); then
|
||||||
|
cd GDJS/tests
|
||||||
|
npm ci
|
||||||
|
cd ../..
|
||||||
|
cache store GDJS-tests-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/tests/package-lock.json) GDJS/tests/node_modules
|
||||||
|
fi
|
||||||
|
dependencies: []
|
||||||
|
- name: Type checks
|
||||||
|
dependencies:
|
||||||
|
- Install
|
||||||
|
task:
|
||||||
|
jobs:
|
||||||
|
- name: newIDE typing
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- cache restore newIDE-app-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum newIDE/app/package-lock.json)
|
||||||
|
- cache restore GDJS-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/package-lock.json)
|
||||||
|
- cd newIDE/app
|
||||||
|
- npm run postinstall
|
||||||
|
- npm run flow
|
||||||
|
- npm run check-script-types
|
||||||
|
- cd ../..
|
||||||
|
- name: GDJS typing and documentation generation
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- cache restore GDJS-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/package-lock.json)
|
||||||
|
- cache restore GDJS-tests-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/tests/package-lock.json)
|
||||||
|
- cd GDJS
|
||||||
|
- npm run check-types
|
||||||
|
- npm run generate-doc
|
||||||
|
- name: Auto formatting
|
||||||
|
dependencies:
|
||||||
|
- Install
|
||||||
|
task:
|
||||||
|
jobs:
|
||||||
|
- name: newIDE auto-formatting
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- cache restore newIDE-app-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum newIDE/app/package-lock.json)
|
||||||
|
- cache restore GDJS-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/package-lock.json)
|
||||||
|
- cd newIDE/app
|
||||||
|
- npm run postinstall
|
||||||
|
- npm run check-format
|
||||||
|
- cd ../..
|
||||||
|
- name: GDJS auto-formatting
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- cache restore GDJS-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/package-lock.json)
|
||||||
|
- cd GDJS
|
||||||
|
- npm run check-format
|
||||||
|
- cd ..
|
||||||
|
- name: Tests
|
||||||
|
dependencies:
|
||||||
|
- Install
|
||||||
|
task:
|
||||||
|
jobs:
|
||||||
|
- name: newIDE tests
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- cache restore newIDE-app-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum newIDE/app/package-lock.json)
|
||||||
|
- cache restore GDJS-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/package-lock.json)
|
||||||
|
- cd newIDE/app
|
||||||
|
- npm run postinstall
|
||||||
|
- npm run analyze-test-coverage
|
||||||
|
- cd ../..
|
||||||
|
- name: GDJS tests
|
||||||
|
commands:
|
||||||
|
- checkout
|
||||||
|
- cache restore GDJS-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/package-lock.json)
|
||||||
|
- cache restore GDJS-tests-node_modules-$SEMAPHORE_GIT_BRANCH-revision-$(checksum GDJS/tests/package-lock.json)
|
||||||
|
- cd GDJS
|
||||||
|
- npm run build
|
||||||
|
- npm run test
|
||||||
|
- cd ../..
|
19
.travis.yml
19
.travis.yml
@@ -1,3 +1,12 @@
|
|||||||
|
# Travis CI configuration to build and run all tests
|
||||||
|
# (and typing/formatting) for the Core, newIDE, GDJS.
|
||||||
|
#
|
||||||
|
# This builds GDevelop.js and store it on a S3 so it can be used to run
|
||||||
|
# GDevelop without building it.
|
||||||
|
#
|
||||||
|
# See also Semaphore CI for quick tests (not building GDevelop.js, so
|
||||||
|
# faster but not always reliable).
|
||||||
|
|
||||||
language: cpp
|
language: cpp
|
||||||
sudo: false
|
sudo: false
|
||||||
compiler:
|
compiler:
|
||||||
@@ -53,7 +62,7 @@ before_install:
|
|||||||
install:
|
install:
|
||||||
#Get the correct version of gcc/g++
|
#Get the correct version of gcc/g++
|
||||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi
|
- if [ "$CXX" = "g++" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi
|
||||||
#Compile the tests only for GDCore and GDCpp
|
#Compile the tests only for GDCore
|
||||||
- mkdir .build-tests
|
- mkdir .build-tests
|
||||||
- cd .build-tests
|
- cd .build-tests
|
||||||
- cmake -DBUILD_GDJS=FALSE -DBUILD_TESTS=TRUE -DCMAKE_CXX_COMPILER=$(which $CXX) -DCMAKE_C_COMPILER=$(which $CC) ..
|
- cmake -DBUILD_GDJS=FALSE -DBUILD_TESTS=TRUE -DCMAKE_CXX_COMPILER=$(which $CXX) -DCMAKE_C_COMPILER=$(which $CC) ..
|
||||||
@@ -80,12 +89,9 @@ install:
|
|||||||
- cd ../..
|
- cd ../..
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# GDCore and GDCpp game engine tests:
|
# GDCore tests:
|
||||||
- cd .build-tests
|
- cd .build-tests
|
||||||
- Core/GDCore_tests
|
- Core/GDCore_tests
|
||||||
- GDCpp/GDCpp_tests
|
|
||||||
- Extensions/PathfindingBehavior/PathfindingBehavior_Runtime_tests
|
|
||||||
- Extensions/LinkedObjects/LinkedObjects_Runtime_tests
|
|
||||||
- cd ..
|
- cd ..
|
||||||
# GDevelop.js tests
|
# GDevelop.js tests
|
||||||
- cd GDevelop.js
|
- cd GDevelop.js
|
||||||
@@ -96,12 +102,13 @@ script:
|
|||||||
- npm test
|
- npm test
|
||||||
- npm run flow
|
- npm run flow
|
||||||
- npm run check-format
|
- npm run check-format
|
||||||
|
- npm run check-script-types
|
||||||
- cd ../..
|
- cd ../..
|
||||||
# GDJS tests:
|
# GDJS tests:
|
||||||
- cd GDJS
|
- cd GDJS
|
||||||
- npm run check-format
|
- npm run check-format
|
||||||
- cd ..
|
- cd ..
|
||||||
# GDJS game engine tests, disabled on Travis CI because ChromeHeadless can't be started.
|
# GDJS game engine tests, disabled on Travis CI because ChromeHeadless can't be started.
|
||||||
# See them running on Semaphore-CI instead: https://semaphoreci.com/4ian/gd
|
# See them running on Semaphore-CI instead: https://gdevelop.semaphoreci.com/projects/GDevelop
|
||||||
# - cd GDJS/tests && npm test
|
# - cd GDJS/tests && npm test
|
||||||
# - cd ../..
|
# - cd ../..
|
||||||
|
200
.vscode/c_cpp_properties.json
vendored
200
.vscode/c_cpp_properties.json
vendored
@@ -1,98 +1,104 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Mac",
|
"name": "Mac",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceRoot}",
|
"${workspaceRoot}",
|
||||||
"${workspaceRoot}/GDCpp",
|
"${workspaceRoot}/GDJS",
|
||||||
"${workspaceRoot}/GDJS",
|
"${workspaceRoot}/Extensions",
|
||||||
"${workspaceRoot}/Extensions",
|
"${workspaceRoot}/Core",
|
||||||
"${workspaceRoot}/Core",
|
"${workspaceRoot}/ExtLibs/SFML/include",
|
||||||
"${workspaceRoot}/ExtLibs/SFML/include",
|
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
|
||||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
|
"/usr/local/include",
|
||||||
"/usr/local/include",
|
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
|
||||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
|
"/usr/include",
|
||||||
"/usr/include",
|
"${workspaceRoot}"
|
||||||
"${workspaceRoot}"
|
],
|
||||||
],
|
"defines": [
|
||||||
"defines": [
|
"EMSCRIPTEN",
|
||||||
"EMSCRIPTEN",
|
"GD_IDE_ONLY",
|
||||||
"GD_IDE_ONLY",
|
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
|
||||||
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
|
"GD_API=/* Macro used to export classes on Windows, please ignore */",
|
||||||
"GD_API=/* Macro used to export classes on Windows, please ignore */",
|
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */"
|
||||||
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */"
|
],
|
||||||
],
|
"intelliSenseMode": "clang-x64",
|
||||||
"intelliSenseMode": "clang-x64",
|
"browse": {
|
||||||
"browse": {
|
"path": [
|
||||||
"path": [
|
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
|
||||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
|
"/usr/local/include",
|
||||||
"/usr/local/include",
|
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
|
||||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
|
"/usr/include",
|
||||||
"/usr/include",
|
"${workspaceRoot}"
|
||||||
"${workspaceRoot}"
|
],
|
||||||
],
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
"databaseFilename": ""
|
||||||
"databaseFilename": ""
|
},
|
||||||
},
|
"macFrameworkPath": [
|
||||||
"macFrameworkPath": ["/System/Library/Frameworks", "/Library/Frameworks"],
|
"/System/Library/Frameworks",
|
||||||
"compilerPath": "/usr/bin/clang",
|
"/Library/Frameworks"
|
||||||
"cStandard": "c11",
|
],
|
||||||
"cppStandard": "c++17"
|
"compilerPath": "/usr/bin/clang",
|
||||||
},
|
"cStandard": "c11",
|
||||||
{
|
"cppStandard": "c++17"
|
||||||
"name": "Linux",
|
},
|
||||||
"includePath": [
|
{
|
||||||
"${workspaceRoot}",
|
"name": "Linux",
|
||||||
"${workspaceRoot}/GDCpp",
|
"includePath": [
|
||||||
"${workspaceRoot}/GDJS",
|
"${workspaceRoot}",
|
||||||
"${workspaceRoot}/Extensions",
|
"${workspaceRoot}/GDJS",
|
||||||
"${workspaceRoot}/Core",
|
"${workspaceRoot}/Extensions",
|
||||||
"${workspaceRoot}/ExtLibs/SFML/include",
|
"${workspaceRoot}/Core",
|
||||||
"/usr/include",
|
"${workspaceRoot}/ExtLibs/SFML/include",
|
||||||
"/usr/local/include",
|
"/usr/include",
|
||||||
"${workspaceRoot}"
|
"/usr/local/include",
|
||||||
],
|
"${workspaceRoot}"
|
||||||
"defines": [
|
],
|
||||||
"EMSCRIPTEN",
|
"defines": [
|
||||||
"GD_IDE_ONLY",
|
"EMSCRIPTEN",
|
||||||
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
|
"GD_IDE_ONLY",
|
||||||
"GD_API=/* Macro used to export classes on Windows, please ignore */",
|
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
|
||||||
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */"
|
"GD_API=/* Macro used to export classes on Windows, please ignore */",
|
||||||
],
|
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */"
|
||||||
"intelliSenseMode": "clang-x64",
|
],
|
||||||
"browse": {
|
"intelliSenseMode": "clang-x64",
|
||||||
"path": ["/usr/include", "/usr/local/include", "${workspaceRoot}"],
|
"browse": {
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
"path": [
|
||||||
"databaseFilename": ""
|
"/usr/include",
|
||||||
}
|
"/usr/local/include",
|
||||||
},
|
"${workspaceRoot}"
|
||||||
{
|
],
|
||||||
"name": "Win32",
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
"includePath": [
|
"databaseFilename": ""
|
||||||
"${workspaceRoot}",
|
}
|
||||||
"${workspaceRoot}/GDCpp",
|
},
|
||||||
"${workspaceRoot}/GDJS",
|
{
|
||||||
"${workspaceRoot}/Extensions",
|
"name": "Win32",
|
||||||
"${workspaceRoot}/Core",
|
"includePath": [
|
||||||
"${workspaceRoot}/ExtLibs/SFML/include",
|
"${workspaceRoot}",
|
||||||
"${workspaceRoot}"
|
"${workspaceRoot}/GDJS",
|
||||||
],
|
"${workspaceRoot}/Extensions",
|
||||||
"defines": [
|
"${workspaceRoot}/Core",
|
||||||
"_DEBUG",
|
"${workspaceRoot}/ExtLibs/SFML/include",
|
||||||
"UNICODE",
|
"${workspaceRoot}"
|
||||||
"EMSCRIPTEN",
|
],
|
||||||
"GD_IDE_ONLY",
|
"defines": [
|
||||||
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
|
"_DEBUG",
|
||||||
"GD_API=/* Macro used to export classes on Windows, please ignore */",
|
"UNICODE",
|
||||||
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */"
|
"EMSCRIPTEN",
|
||||||
],
|
"GD_IDE_ONLY",
|
||||||
"intelliSenseMode": "msvc-x64",
|
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
|
||||||
"browse": {
|
"GD_API=/* Macro used to export classes on Windows, please ignore */",
|
||||||
"path": ["${workspaceRoot}"],
|
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */"
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
],
|
||||||
"databaseFilename": ""
|
"intelliSenseMode": "msvc-x64",
|
||||||
}
|
"browse": {
|
||||||
}
|
"path": [
|
||||||
],
|
"${workspaceRoot}"
|
||||||
"version": 4
|
],
|
||||||
}
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
29
.vscode/launch.json
vendored
29
.vscode/launch.json
vendored
@@ -4,13 +4,36 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "GDevelop.js Jest tests (all)",
|
||||||
|
"program": "${workspaceFolder}/GDevelop.js/node_modules/.bin/jest",
|
||||||
|
"args": ["--runInBand"],
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"internalConsoleOptions": "neverOpen",
|
||||||
|
"disableOptimisticBPs": true,
|
||||||
|
"cwd": "${workspaceFolder}/GDevelop.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "GDevelop.js Jest tests (current file)",
|
||||||
|
"program": "${workspaceFolder}/GDevelop.js/node_modules/.bin/jest",
|
||||||
|
"args": [
|
||||||
|
"${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"internalConsoleOptions": "neverOpen",
|
||||||
|
"disableOptimisticBPs": true,
|
||||||
|
"cwd": "${workspaceFolder}/GDevelop.js"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "pwa-chrome",
|
"type": "pwa-chrome",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Launch Chrome against localhost",
|
"name": "Debug with Chrome (web-app, local development server)",
|
||||||
"url": "http://localhost:3000",
|
"url": "http://localhost:3000",
|
||||||
"webRoot": "${workspaceFolder}",
|
"webRoot": "${workspaceFolder}"
|
||||||
"preLaunchTask": "Start development server"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -108,7 +108,8 @@
|
|||||||
"xtree": "cpp",
|
"xtree": "cpp",
|
||||||
"xutility": "cpp",
|
"xutility": "cpp",
|
||||||
"xlocbuf": "cpp",
|
"xlocbuf": "cpp",
|
||||||
"xlocmes": "cpp"
|
"xlocmes": "cpp",
|
||||||
|
"xmemory0": "cpp"
|
||||||
},
|
},
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"Binaries/*build*": true,
|
"Binaries/*build*": true,
|
||||||
|
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -80,7 +80,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "typescript",
|
"type": "typescript",
|
||||||
"tsconfig": "GDJS/tsconfig.json",
|
"tsconfig": "tsconfig.json",
|
||||||
"option": "watch",
|
"option": "watch",
|
||||||
"problemMatcher": ["$tsc-watch"],
|
"problemMatcher": ["$tsc-watch"],
|
||||||
"group": "test",
|
"group": "test",
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
This is the directory where native or WebAssembly binaries of the C++ code of GDCore, GDCpp and GDJS are produced.
|
This is the directory where native or WebAssembly binaries of the C++ code of GDCore and GDJS are produced.
|
||||||
|
|
||||||
See GDevelop.js README for the instructions to compile after a change in the C++ source code.
|
See GDevelop.js README for the instructions to compile after a change in the C++ source code.
|
@@ -14,12 +14,10 @@ macro(gd_set_option var default type docstring)
|
|||||||
endif()
|
endif()
|
||||||
set(${var} ${${var}} CACHE ${type} ${docstring} FORCE)
|
set(${var} ${${var}} CACHE ${type} ${docstring} FORCE)
|
||||||
endmacro()
|
endmacro()
|
||||||
gd_set_option(BUILD_CORE TRUE BOOL "TRUE to build GDevelop Core library, FALSE to use the already compiled binaries")
|
gd_set_option(BUILD_CORE TRUE BOOL "TRUE to build GDevelop Core library")
|
||||||
gd_set_option(BUILD_GDCPP TRUE BOOL "TRUE to build GDevelop C++ Platform")
|
|
||||||
gd_set_option(BUILD_GDJS TRUE BOOL "TRUE to build GDevelop JS Platform")
|
gd_set_option(BUILD_GDJS TRUE BOOL "TRUE to build GDevelop JS Platform")
|
||||||
gd_set_option(BUILD_EXTENSIONS TRUE BOOL "TRUE to build the extensions")
|
gd_set_option(BUILD_EXTENSIONS TRUE BOOL "TRUE to build the extensions")
|
||||||
gd_set_option(BUILD_TESTS FALSE BOOL "TRUE to build the tests")
|
gd_set_option(BUILD_TESTS FALSE BOOL "TRUE to build the tests")
|
||||||
gd_set_option(FULL_VERSION_NUMBER TRUE BOOL "TRUE to build GDevelop with its full version number (lastest tag + commit hash), FALSE to only use the lastest tag (avoid rebulding many source file when developping)")
|
|
||||||
|
|
||||||
# Disable deprecated code
|
# Disable deprecated code
|
||||||
set(NO_GUI TRUE CACHE BOOL "" FORCE) #Force disable old GUI related code.
|
set(NO_GUI TRUE CACHE BOOL "" FORCE) #Force disable old GUI related code.
|
||||||
@@ -49,15 +47,11 @@ IF(APPLE)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
#Sanity checks
|
#Sanity checks
|
||||||
IF ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
IF ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||||
message( "CMAKE_BUILD_TYPE is empty, assuming build type is Release" )
|
message( "CMAKE_BUILD_TYPE is empty, assuming build type is Release" )
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF (EMSCRIPTEN)
|
|
||||||
set(BUILD_GDCPP FALSE CACHE BOOL "" FORCE) #Force disable GDC++ when compiling with emscripten.
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
|
IF("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
|
||||||
SET(CMAKE_SHARED_LINKER_FLAGS "-s") #Force stripping to avoid errors when packaging for linux.
|
SET(CMAKE_SHARED_LINKER_FLAGS "-s") #Force stripping to avoid errors when packaging for linux.
|
||||||
@@ -77,6 +71,13 @@ endif()
|
|||||||
|
|
||||||
# Mark some warnings as errors
|
# Mark some warnings as errors
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
# Activate as much warnings as possible to avoid errors like
|
||||||
|
# uninitialized variables or other hard to debug bugs.
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder-ctor -Wno-reorder -Wno-pessimizing-move -Wno-unused-variable -Wno-unused-private-field")
|
||||||
|
|
||||||
|
# Make as much warnings considered as errors as possible (only one for now).
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-stack-address")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-stack-address")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -84,7 +85,6 @@ endif()
|
|||||||
set(GD_base_dir ${CMAKE_CURRENT_SOURCE_DIR})
|
set(GD_base_dir ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
#Add all the CMakeLists:
|
#Add all the CMakeLists:
|
||||||
ADD_SUBDIRECTORY(Version)
|
|
||||||
ADD_SUBDIRECTORY(ExtLibs)
|
ADD_SUBDIRECTORY(ExtLibs)
|
||||||
IF(BUILD_CORE)
|
IF(BUILD_CORE)
|
||||||
ADD_SUBDIRECTORY(Core)
|
ADD_SUBDIRECTORY(Core)
|
||||||
@@ -92,10 +92,7 @@ ENDIF()
|
|||||||
IF(BUILD_GDJS)
|
IF(BUILD_GDJS)
|
||||||
ADD_SUBDIRECTORY(GDJS)
|
ADD_SUBDIRECTORY(GDJS)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF(BUILD_GDCPP)
|
IF(EMSCRIPTEN)
|
||||||
ADD_SUBDIRECTORY(GDCpp)
|
|
||||||
ENDIF()
|
|
||||||
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/GDevelop.js/CMakeLists.txt" AND EMSCRIPTEN)
|
|
||||||
ADD_SUBDIRECTORY(GDevelop.js)
|
ADD_SUBDIRECTORY(GDevelop.js)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF(BUILD_EXTENSIONS)
|
IF(BUILD_EXTENSIONS)
|
||||||
|
@@ -57,7 +57,6 @@ IF(EMSCRIPTEN)
|
|||||||
ELSE()
|
ELSE()
|
||||||
add_library(GDCore SHARED ${source_files})
|
add_library(GDCore SHARED ${source_files})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
add_dependencies(GDCore GDVersion)
|
|
||||||
IF(EMSCRIPTEN)
|
IF(EMSCRIPTEN)
|
||||||
set_target_properties(GDCore PROPERTIES SUFFIX ".bc")
|
set_target_properties(GDCore PROPERTIES SUFFIX ".bc")
|
||||||
ELSEIF(WIN32)
|
ELSEIF(WIN32)
|
||||||
|
@@ -14,9 +14,8 @@
|
|||||||
*
|
*
|
||||||
* \section other Other documentations
|
* \section other Other documentations
|
||||||
*
|
*
|
||||||
* GDevelop is architectured around a `Core` (this library), platforms (`GDJS`, `GDCpp`) and extensions (`Extensions` folder). The editor (`newIDE` folder) is using all of these libraries.
|
* GDevelop is architectured around a `Core` (this library), a game engine (`GDJS`) and extensions (`Extensions` folder). The editor (`newIDE` folder) is using all of these libraries.
|
||||||
*
|
*
|
||||||
* - [Open GDevelop C++ Platform documentation](../GDCpp Documentation/index.html)
|
|
||||||
* - [Open GDevelop JS Platform documentation](../GDJS Documentation/index.html)
|
* - [Open GDevelop JS Platform documentation](../GDJS Documentation/index.html)
|
||||||
* - <a href="https://github.com/4ian/GDevelop/blob/master/newIDE/README.md">Getting started with the editor</a>
|
* - <a href="https://github.com/4ian/GDevelop/blob/master/newIDE/README.md">Getting started with the editor</a>
|
||||||
* - <a href="https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md">Getting started with the extensions</a>
|
* - <a href="https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md">Getting started with the extensions</a>
|
||||||
|
@@ -3,14 +3,17 @@
|
|||||||
* Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights
|
* Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights
|
||||||
* reserved. This project is released under the MIT License.
|
* reserved. This project is released under the MIT License.
|
||||||
*/
|
*/
|
||||||
#include <iostream>
|
|
||||||
#include "EffectsCodeGenerator.h"
|
#include "EffectsCodeGenerator.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "GDCore/Extensions/Metadata/EffectMetadata.h"
|
#include "GDCore/Extensions/Metadata/EffectMetadata.h"
|
||||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||||
#include "GDCore/Project/Effect.h"
|
#include "GDCore/Project/Effect.h"
|
||||||
#include "GDCore/Project/Layer.h"
|
|
||||||
#include "GDCore/Project/EffectsContainer.h"
|
#include "GDCore/Project/EffectsContainer.h"
|
||||||
|
#include "GDCore/Project/Layer.h"
|
||||||
#include "GDCore/Project/Layout.h"
|
#include "GDCore/Project/Layout.h"
|
||||||
|
#include "GDCore/Project/Object.h"
|
||||||
#include "GDCore/Project/Project.h"
|
#include "GDCore/Project/Project.h"
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
@@ -33,6 +36,24 @@ void ExposeProjectEffects(
|
|||||||
worker(effect);
|
worker(effect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < layout.GetObjectsCount(); i++) {
|
||||||
|
auto& object = layout.GetObject(i);
|
||||||
|
auto& effects = object.GetEffects();
|
||||||
|
for (std::size_t e = 0; e < effects.GetEffectsCount(); e++) {
|
||||||
|
auto& effect = effects.GetEffect(e);
|
||||||
|
worker(effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add global object effects
|
||||||
|
for (std::size_t s = 0; s < project.GetObjectsCount(); s++) {
|
||||||
|
auto& effects = project.GetObject(s).GetEffects();
|
||||||
|
for (std::size_t e = 0; e < effects.GetEffectsCount(); e++) {
|
||||||
|
auto& effect = effects.GetEffect(e);
|
||||||
|
worker(effect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -261,8 +261,11 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
|||||||
EventsCodeGenerationContext& context) {
|
EventsCodeGenerationContext& context) {
|
||||||
gd::String conditionCode;
|
gd::String conditionCode;
|
||||||
|
|
||||||
gd::InstructionMetadata instrInfos =
|
const gd::InstructionMetadata& instrInfos =
|
||||||
MetadataProvider::GetConditionMetadata(platform, condition.GetType());
|
MetadataProvider::GetConditionMetadata(platform, condition.GetType());
|
||||||
|
if (MetadataProvider::IsBadInstructionMetadata(instrInfos)) {
|
||||||
|
return "/* Unknown instruction - skipped. */";
|
||||||
|
}
|
||||||
|
|
||||||
AddIncludeFiles(instrInfos.codeExtraInformation.GetIncludeFiles());
|
AddIncludeFiles(instrInfos.codeExtraInformation.GetIncludeFiles());
|
||||||
maxConditionsListsSize =
|
maxConditionsListsSize =
|
||||||
@@ -299,15 +302,13 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
|||||||
!GetObjectsAndGroups().GetObjectGroups().Has(objectInParameter) &&
|
!GetObjectsAndGroups().GetObjectGroups().Has(objectInParameter) &&
|
||||||
!GetGlobalObjectsAndGroups().GetObjectGroups().Has(
|
!GetGlobalObjectsAndGroups().GetObjectGroups().Has(
|
||||||
objectInParameter)) {
|
objectInParameter)) {
|
||||||
condition.SetParameter(pNb, gd::Expression(""));
|
return "/* Unknown object - skipped. */";
|
||||||
condition.SetType("");
|
|
||||||
} else if (!instrInfos.parameters[pNb].supplementaryInformation.empty() &&
|
} else if (!instrInfos.parameters[pNb].supplementaryInformation.empty() &&
|
||||||
gd::GetTypeOfObject(GetGlobalObjectsAndGroups(),
|
gd::GetTypeOfObject(GetGlobalObjectsAndGroups(),
|
||||||
GetObjectsAndGroups(),
|
GetObjectsAndGroups(),
|
||||||
objectInParameter) !=
|
objectInParameter) !=
|
||||||
instrInfos.parameters[pNb].supplementaryInformation) {
|
instrInfos.parameters[pNb].supplementaryInformation) {
|
||||||
condition.SetParameter(pNb, gd::Expression(""));
|
return "/* Mismatched object type - skipped. */";
|
||||||
condition.SetType("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -425,6 +426,11 @@ gd::String EventsCodeGenerator::GenerateConditionsListCode(
|
|||||||
outputCode += "{\n";
|
outputCode += "{\n";
|
||||||
outputCode += conditionCode;
|
outputCode += conditionCode;
|
||||||
outputCode += "}";
|
outputCode += "}";
|
||||||
|
} else {
|
||||||
|
// Deprecated way to cancel code generation - but still honor it.
|
||||||
|
// Can be removed once condition is passed by const reference to
|
||||||
|
// GenerateConditionCode.
|
||||||
|
outputCode += "/* Skipped condition (empty type) */";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,8 +446,11 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
|||||||
gd::Instruction& action, EventsCodeGenerationContext& context) {
|
gd::Instruction& action, EventsCodeGenerationContext& context) {
|
||||||
gd::String actionCode;
|
gd::String actionCode;
|
||||||
|
|
||||||
gd::InstructionMetadata instrInfos =
|
const gd::InstructionMetadata& instrInfos =
|
||||||
MetadataProvider::GetActionMetadata(platform, action.GetType());
|
MetadataProvider::GetActionMetadata(platform, action.GetType());
|
||||||
|
if (MetadataProvider::IsBadInstructionMetadata(instrInfos)) {
|
||||||
|
return "/* Unknown instruction - skipped. */";
|
||||||
|
}
|
||||||
|
|
||||||
AddIncludeFiles(instrInfos.codeExtraInformation.GetIncludeFiles());
|
AddIncludeFiles(instrInfos.codeExtraInformation.GetIncludeFiles());
|
||||||
|
|
||||||
@@ -466,15 +475,13 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
|||||||
!GetObjectsAndGroups().GetObjectGroups().Has(objectInParameter) &&
|
!GetObjectsAndGroups().GetObjectGroups().Has(objectInParameter) &&
|
||||||
!GetGlobalObjectsAndGroups().GetObjectGroups().Has(
|
!GetGlobalObjectsAndGroups().GetObjectGroups().Has(
|
||||||
objectInParameter)) {
|
objectInParameter)) {
|
||||||
action.SetParameter(pNb, gd::Expression(""));
|
return "/* Unknown object - skipped. */";
|
||||||
action.SetType("");
|
|
||||||
} else if (!instrInfos.parameters[pNb].supplementaryInformation.empty() &&
|
} else if (!instrInfos.parameters[pNb].supplementaryInformation.empty() &&
|
||||||
gd::GetTypeOfObject(GetGlobalObjectsAndGroups(),
|
gd::GetTypeOfObject(GetGlobalObjectsAndGroups(),
|
||||||
GetObjectsAndGroups(),
|
GetObjectsAndGroups(),
|
||||||
objectInParameter) !=
|
objectInParameter) !=
|
||||||
instrInfos.parameters[pNb].supplementaryInformation) {
|
instrInfos.parameters[pNb].supplementaryInformation) {
|
||||||
action.SetParameter(pNb, gd::Expression(""));
|
return "/* Mismatched object type - skipped. */";
|
||||||
action.SetType("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -556,7 +563,14 @@ gd::String EventsCodeGenerator::GenerateActionsListCode(
|
|||||||
gd::String actionCode = GenerateActionCode(actions[aId], context);
|
gd::String actionCode = GenerateActionCode(actions[aId], context);
|
||||||
|
|
||||||
outputCode += "{";
|
outputCode += "{";
|
||||||
if (!actions[aId].GetType().empty()) outputCode += actionCode;
|
if (actions[aId].GetType().empty()) {
|
||||||
|
// Deprecated way to cancel code generation - but still honor it.
|
||||||
|
// Can be removed once action is passed by const reference to
|
||||||
|
// GenerateActionCode.
|
||||||
|
outputCode += "/* Skipped action (empty type) */";
|
||||||
|
} else {
|
||||||
|
outputCode += actionCode;
|
||||||
|
}
|
||||||
outputCode += "}";
|
outputCode += "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,8 +621,14 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
|
|||||||
argOutput = GenerateGetBehaviorNameCode(parameter);
|
argOutput = GenerateGetBehaviorNameCode(parameter);
|
||||||
} else if (metadata.type == "key") {
|
} else if (metadata.type == "key") {
|
||||||
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
||||||
} else if (metadata.type == "password" || metadata.type == "musicfile" ||
|
} else if (metadata.type == "password" || // Deprecated
|
||||||
metadata.type == "soundfile" || metadata.type == "police") {
|
metadata.type ==
|
||||||
|
"musicfile" || // Should be renamed "largeAudioResource"
|
||||||
|
metadata.type ==
|
||||||
|
"soundfile" || // Should be renamed "audioResource"
|
||||||
|
metadata.type == "police" || // Should be renamed "fontResource"
|
||||||
|
metadata.type == "bitmapFontResource" ||
|
||||||
|
metadata.type == "imageResource") {
|
||||||
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
||||||
} else if (metadata.type == "mouse") {
|
} else if (metadata.type == "mouse") {
|
||||||
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
||||||
|
@@ -462,24 +462,21 @@ class GD_CORE_API EventsCodeGenerator {
|
|||||||
* Other standard parameters type that should be implemented by platforms:
|
* Other standard parameters type that should be implemented by platforms:
|
||||||
* - currentScene: Reference to the current runtime scene.
|
* - currentScene: Reference to the current runtime scene.
|
||||||
* - objectList : a map containing lists of objects which are specified by the
|
* - objectList : a map containing lists of objects which are specified by the
|
||||||
object name in another parameter. (C++: std::map <gd::String,
|
object name in another parameter. Example:
|
||||||
std::vector<RuntimeObject*> *>). Example:
|
|
||||||
* \code
|
* \code
|
||||||
AddExpression("Count", _("Object count"), _("Count the number of picked
|
AddExpression("Count", _("Object count"), _("Count the number of picked
|
||||||
objects"), _("Objects"), "res/conditions/nbObjet.png")
|
objects"), _("Objects"), "res/conditions/nbObjet.png")
|
||||||
.AddParameter("objectList", _("Object"))
|
.AddParameter("objectList", _("Object"))
|
||||||
.SetFunctionName("PickedObjectsCount").SetIncludeFile("GDCpp/Extensions/Builtin/ObjectTools.h");
|
.SetFunctionName("getPickedObjectsCount");
|
||||||
|
|
||||||
* \endcode
|
* \endcode
|
||||||
* - objectListWithoutPicking : Same as objectList but do not pick object if
|
* - objectListWithoutPicking : Same as objectList but do not pick object if
|
||||||
they are not already picked.
|
they are not already picked.
|
||||||
* - objectPtr : Return a pointer to object specified by the object name in
|
* - objectPtr : Return a reference to the object specified by the object name in
|
||||||
another parameter ( C++: RuntimeObject* ). Example:
|
another parameter. Example:
|
||||||
* \code
|
* \code
|
||||||
.AddParameter("object", _("Object"))
|
.AddParameter("object", _("Object"))
|
||||||
.AddParameter("objectPtr", _("Target object"))
|
.AddParameter("objectPtr", _("Target object"))
|
||||||
//The called function will be called with this signature on the C++ platform:
|
|
||||||
Function(gd::String, RuntimeObject*)
|
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
virtual gd::String GenerateParameterCodes(
|
virtual gd::String GenerateParameterCodes(
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
#include "GDCore/String.h"
|
#include "GDCore/String.h"
|
||||||
namespace gd {
|
namespace gd {
|
||||||
class EventsList;
|
class EventsList;
|
||||||
class MainFrameWrapper;
|
|
||||||
class Project;
|
class Project;
|
||||||
class Layout;
|
class Layout;
|
||||||
class EventsCodeGenerator;
|
class EventsCodeGenerator;
|
||||||
|
@@ -67,13 +67,13 @@ class GD_CORE_API ExpressionParser2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an object name (or empty if none) and a behavior name (or empty if none),
|
* Given an object name (or empty if none) and a behavior name (or empty if
|
||||||
* return the index of the first parameter that is inside the parenthesis:
|
* none), return the index of the first parameter that is inside the
|
||||||
* 0, 1 or 2.
|
* parenthesis: 0, 1 or 2.
|
||||||
*
|
*
|
||||||
* For example, in an expression like `Object.MyBehavior::Method("hello")`, the
|
* For example, in an expression like `Object.MyBehavior::Method("hello")`,
|
||||||
* parameter "hello" is the second parameter (the first being by convention Object,
|
* the parameter "hello" is the second parameter (the first being by
|
||||||
* and the second MyBehavior, also by convention).
|
* convention Object, and the second MyBehavior, also by convention).
|
||||||
*/
|
*/
|
||||||
static size_t WrittenParametersFirstIndex(const gd::String &objectName,
|
static size_t WrittenParametersFirstIndex(const gd::String &objectName,
|
||||||
const gd::String &behaviorName) {
|
const gd::String &behaviorName) {
|
||||||
@@ -403,9 +403,18 @@ class GD_CORE_API ExpressionParser2 {
|
|||||||
const gd::ExpressionMetadata &metadata =
|
const gd::ExpressionMetadata &metadata =
|
||||||
MetadataProvider::GetAnyExpressionMetadata(platform, functionFullName);
|
MetadataProvider::GetAnyExpressionMetadata(platform, functionFullName);
|
||||||
|
|
||||||
|
// In case we can't find a valid expression, ensure the node has the type
|
||||||
|
// that is requested by the parent, so we avoid putting "unknown" (which
|
||||||
|
// would be also correct, but less precise and would prevent completions to
|
||||||
|
// be shown to the user)
|
||||||
|
const gd::String returnType =
|
||||||
|
gd::MetadataProvider::IsBadExpressionMetadata(metadata) == true
|
||||||
|
? type
|
||||||
|
: metadata.GetReturnType();
|
||||||
|
|
||||||
auto parametersNode = Parameters(metadata.parameters);
|
auto parametersNode = Parameters(metadata.parameters);
|
||||||
auto function =
|
auto function =
|
||||||
gd::make_unique<FunctionCallNode>(metadata.GetReturnType(),
|
gd::make_unique<FunctionCallNode>(returnType,
|
||||||
std::move(parametersNode.parameters),
|
std::move(parametersNode.parameters),
|
||||||
metadata,
|
metadata,
|
||||||
functionFullName);
|
functionFullName);
|
||||||
@@ -458,9 +467,18 @@ class GD_CORE_API ExpressionParser2 {
|
|||||||
MetadataProvider::GetObjectAnyExpressionMetadata(
|
MetadataProvider::GetObjectAnyExpressionMetadata(
|
||||||
platform, objectType, objectFunctionOrBehaviorName);
|
platform, objectType, objectFunctionOrBehaviorName);
|
||||||
|
|
||||||
|
// In case we can't find a valid expression, ensure the node has the type
|
||||||
|
// that is requested by the parent, so we avoid putting "unknown" (which
|
||||||
|
// would be also correct, but less precise and would prevent completions
|
||||||
|
// to be shown to the user)
|
||||||
|
const gd::String returnType =
|
||||||
|
gd::MetadataProvider::IsBadExpressionMetadata(metadata) == true
|
||||||
|
? type
|
||||||
|
: metadata.GetReturnType();
|
||||||
|
|
||||||
auto parametersNode = Parameters(metadata.parameters, objectName);
|
auto parametersNode = Parameters(metadata.parameters, objectName);
|
||||||
auto function = gd::make_unique<FunctionCallNode>(
|
auto function = gd::make_unique<FunctionCallNode>(
|
||||||
metadata.GetReturnType(),
|
returnType,
|
||||||
objectName,
|
objectName,
|
||||||
std::move(parametersNode.parameters),
|
std::move(parametersNode.parameters),
|
||||||
metadata,
|
metadata,
|
||||||
@@ -520,10 +538,19 @@ class GD_CORE_API ExpressionParser2 {
|
|||||||
MetadataProvider::GetBehaviorAnyExpressionMetadata(
|
MetadataProvider::GetBehaviorAnyExpressionMetadata(
|
||||||
platform, behaviorType, functionName);
|
platform, behaviorType, functionName);
|
||||||
|
|
||||||
|
// In case we can't find a valid expression, ensure the node has the type
|
||||||
|
// that is requested by the parent, so we avoid putting "unknown" (which
|
||||||
|
// would be also correct, but less precise and would prevent completions
|
||||||
|
// to be shown to the user)
|
||||||
|
const gd::String returnType =
|
||||||
|
gd::MetadataProvider::IsBadExpressionMetadata(metadata) == true
|
||||||
|
? type
|
||||||
|
: metadata.GetReturnType();
|
||||||
|
|
||||||
auto parametersNode =
|
auto parametersNode =
|
||||||
Parameters(metadata.parameters, objectName, behaviorName);
|
Parameters(metadata.parameters, objectName, behaviorName);
|
||||||
auto function = gd::make_unique<FunctionCallNode>(
|
auto function = gd::make_unique<FunctionCallNode>(
|
||||||
metadata.GetReturnType(),
|
returnType,
|
||||||
objectName,
|
objectName,
|
||||||
behaviorName,
|
behaviorName,
|
||||||
std::move(parametersNode.parameters),
|
std::move(parametersNode.parameters),
|
||||||
|
@@ -21,7 +21,7 @@ class ExpressionMetadata;
|
|||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
|
|
||||||
struct ExpressionParserLocation {
|
struct GD_CORE_API ExpressionParserLocation {
|
||||||
ExpressionParserLocation() : isValid(false){};
|
ExpressionParserLocation() : isValid(false){};
|
||||||
ExpressionParserLocation(size_t position)
|
ExpressionParserLocation(size_t position)
|
||||||
: isValid(true), startPosition(position), endPosition(position){};
|
: isValid(true), startPosition(position), endPosition(position){};
|
||||||
@@ -42,7 +42,8 @@ struct ExpressionParserLocation {
|
|||||||
/**
|
/**
|
||||||
* \brief A diagnostic that can be attached to a gd::ExpressionNode.
|
* \brief A diagnostic that can be attached to a gd::ExpressionNode.
|
||||||
*/
|
*/
|
||||||
struct ExpressionParserDiagnostic {
|
struct GD_CORE_API ExpressionParserDiagnostic {
|
||||||
|
virtual ~ExpressionParserDiagnostic() = default;
|
||||||
virtual bool IsError() { return false; }
|
virtual bool IsError() { return false; }
|
||||||
virtual const gd::String &GetMessage() { return noMessage; }
|
virtual const gd::String &GetMessage() { return noMessage; }
|
||||||
virtual size_t GetStartPosition() { return 0; }
|
virtual size_t GetStartPosition() { return 0; }
|
||||||
@@ -55,7 +56,7 @@ struct ExpressionParserDiagnostic {
|
|||||||
/**
|
/**
|
||||||
* \brief An error that can be attached to a gd::ExpressionNode.
|
* \brief An error that can be attached to a gd::ExpressionNode.
|
||||||
*/
|
*/
|
||||||
struct ExpressionParserError : public ExpressionParserDiagnostic {
|
struct GD_CORE_API ExpressionParserError : public ExpressionParserDiagnostic {
|
||||||
ExpressionParserError(const gd::String &type_,
|
ExpressionParserError(const gd::String &type_,
|
||||||
const gd::String &message_,
|
const gd::String &message_,
|
||||||
size_t position_)
|
size_t position_)
|
||||||
@@ -84,7 +85,7 @@ struct ExpressionParserError : public ExpressionParserDiagnostic {
|
|||||||
* \brief The base node, from which all nodes in the tree of
|
* \brief The base node, from which all nodes in the tree of
|
||||||
* an expression inherits from.
|
* an expression inherits from.
|
||||||
*/
|
*/
|
||||||
struct ExpressionNode {
|
struct GD_CORE_API ExpressionNode {
|
||||||
ExpressionNode(const gd::String &type_) : type(type_){};
|
ExpressionNode(const gd::String &type_) : type(type_){};
|
||||||
virtual ~ExpressionNode(){};
|
virtual ~ExpressionNode(){};
|
||||||
virtual void Visit(ExpressionParser2NodeWorker &worker){};
|
virtual void Visit(ExpressionParser2NodeWorker &worker){};
|
||||||
@@ -103,7 +104,7 @@ struct ExpressionNode {
|
|||||||
// gd::ParameterMetadata::IsExpression or "unknown".
|
// gd::ParameterMetadata::IsExpression or "unknown".
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubExpressionNode : public ExpressionNode {
|
struct GD_CORE_API SubExpressionNode : public ExpressionNode {
|
||||||
SubExpressionNode(const gd::String &type_,
|
SubExpressionNode(const gd::String &type_,
|
||||||
std::unique_ptr<ExpressionNode> expression_)
|
std::unique_ptr<ExpressionNode> expression_)
|
||||||
: ExpressionNode(type_), expression(std::move(expression_)){};
|
: ExpressionNode(type_), expression(std::move(expression_)){};
|
||||||
@@ -118,7 +119,7 @@ struct SubExpressionNode : public ExpressionNode {
|
|||||||
/**
|
/**
|
||||||
* \brief An operator node. For example: "lhs + rhs".
|
* \brief An operator node. For example: "lhs + rhs".
|
||||||
*/
|
*/
|
||||||
struct OperatorNode : public ExpressionNode {
|
struct GD_CORE_API OperatorNode : public ExpressionNode {
|
||||||
OperatorNode(const gd::String &type_, gd::String::value_type op_)
|
OperatorNode(const gd::String &type_, gd::String::value_type op_)
|
||||||
: ExpressionNode(type_), op(op_){};
|
: ExpressionNode(type_), op(op_){};
|
||||||
virtual ~OperatorNode(){};
|
virtual ~OperatorNode(){};
|
||||||
@@ -134,7 +135,7 @@ struct OperatorNode : public ExpressionNode {
|
|||||||
/**
|
/**
|
||||||
* \brief A unary operator node. For example: "-2".
|
* \brief A unary operator node. For example: "-2".
|
||||||
*/
|
*/
|
||||||
struct UnaryOperatorNode : public ExpressionNode {
|
struct GD_CORE_API UnaryOperatorNode : public ExpressionNode {
|
||||||
UnaryOperatorNode(const gd::String &type_, gd::String::value_type op_)
|
UnaryOperatorNode(const gd::String &type_, gd::String::value_type op_)
|
||||||
: ExpressionNode(type_), op(op_){};
|
: ExpressionNode(type_), op(op_){};
|
||||||
virtual ~UnaryOperatorNode(){};
|
virtual ~UnaryOperatorNode(){};
|
||||||
@@ -150,7 +151,7 @@ struct UnaryOperatorNode : public ExpressionNode {
|
|||||||
* \brief A number node. For example: "123".
|
* \brief A number node. For example: "123".
|
||||||
* Its `type` is always "number".
|
* Its `type` is always "number".
|
||||||
*/
|
*/
|
||||||
struct NumberNode : public ExpressionNode {
|
struct GD_CORE_API NumberNode : public ExpressionNode {
|
||||||
NumberNode(const gd::String &number_)
|
NumberNode(const gd::String &number_)
|
||||||
: ExpressionNode("number"), number(number_){};
|
: ExpressionNode("number"), number(number_){};
|
||||||
virtual ~NumberNode(){};
|
virtual ~NumberNode(){};
|
||||||
@@ -166,7 +167,7 @@ struct NumberNode : public ExpressionNode {
|
|||||||
* \brief A text node. For example: "Hello World".
|
* \brief A text node. For example: "Hello World".
|
||||||
* Its `type` is always "string".
|
* Its `type` is always "string".
|
||||||
*/
|
*/
|
||||||
struct TextNode : public ExpressionNode {
|
struct GD_CORE_API TextNode : public ExpressionNode {
|
||||||
TextNode(const gd::String &text_) : ExpressionNode("string"), text(text_){};
|
TextNode(const gd::String &text_) : ExpressionNode("string"), text(text_){};
|
||||||
virtual ~TextNode(){};
|
virtual ~TextNode(){};
|
||||||
virtual void Visit(ExpressionParser2NodeWorker &worker) {
|
virtual void Visit(ExpressionParser2NodeWorker &worker) {
|
||||||
@@ -176,7 +177,7 @@ struct TextNode : public ExpressionNode {
|
|||||||
gd::String text;
|
gd::String text;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VariableAccessorOrVariableBracketAccessorNode : public ExpressionNode {
|
struct GD_CORE_API VariableAccessorOrVariableBracketAccessorNode : public ExpressionNode {
|
||||||
VariableAccessorOrVariableBracketAccessorNode() : ExpressionNode(""){};
|
VariableAccessorOrVariableBracketAccessorNode() : ExpressionNode(""){};
|
||||||
|
|
||||||
std::unique_ptr<VariableAccessorOrVariableBracketAccessorNode> child;
|
std::unique_ptr<VariableAccessorOrVariableBracketAccessorNode> child;
|
||||||
@@ -190,7 +191,7 @@ struct VariableAccessorOrVariableBracketAccessorNode : public ExpressionNode {
|
|||||||
* \see gd::VariableAccessorNode
|
* \see gd::VariableAccessorNode
|
||||||
* \see gd::VariableBracketAccessorNode
|
* \see gd::VariableBracketAccessorNode
|
||||||
*/
|
*/
|
||||||
struct VariableNode : public ExpressionNode {
|
struct GD_CORE_API VariableNode : public ExpressionNode {
|
||||||
VariableNode(const gd::String &type_,
|
VariableNode(const gd::String &type_,
|
||||||
const gd::String &name_,
|
const gd::String &name_,
|
||||||
const gd::String &objectName_)
|
const gd::String &objectName_)
|
||||||
@@ -213,7 +214,7 @@ struct VariableNode : public ExpressionNode {
|
|||||||
* \brief A bracket accessor of a variable. Example: MyChild
|
* \brief A bracket accessor of a variable. Example: MyChild
|
||||||
* in MyVariable.MyChild
|
* in MyVariable.MyChild
|
||||||
*/
|
*/
|
||||||
struct VariableAccessorNode
|
struct GD_CORE_API VariableAccessorNode
|
||||||
: public VariableAccessorOrVariableBracketAccessorNode {
|
: public VariableAccessorOrVariableBracketAccessorNode {
|
||||||
VariableAccessorNode(const gd::String &name_) : name(name_){};
|
VariableAccessorNode(const gd::String &name_) : name(name_){};
|
||||||
virtual ~VariableAccessorNode(){};
|
virtual ~VariableAccessorNode(){};
|
||||||
@@ -230,7 +231,7 @@ struct VariableAccessorNode
|
|||||||
* \brief A bracket accessor of a variable. Example: ["MyChild"]
|
* \brief A bracket accessor of a variable. Example: ["MyChild"]
|
||||||
* (in MyVariable["MyChild"]).
|
* (in MyVariable["MyChild"]).
|
||||||
*/
|
*/
|
||||||
struct VariableBracketAccessorNode
|
struct GD_CORE_API VariableBracketAccessorNode
|
||||||
: public VariableAccessorOrVariableBracketAccessorNode {
|
: public VariableAccessorOrVariableBracketAccessorNode {
|
||||||
VariableBracketAccessorNode(std::unique_ptr<ExpressionNode> expression_)
|
VariableBracketAccessorNode(std::unique_ptr<ExpressionNode> expression_)
|
||||||
: expression(std::move(expression_)){};
|
: expression(std::move(expression_)){};
|
||||||
@@ -242,7 +243,7 @@ struct VariableBracketAccessorNode
|
|||||||
std::unique_ptr<ExpressionNode> expression;
|
std::unique_ptr<ExpressionNode> expression;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode
|
struct GD_CORE_API IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode
|
||||||
: public ExpressionNode {
|
: public ExpressionNode {
|
||||||
IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode(
|
IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode(
|
||||||
const gd::String &type)
|
const gd::String &type)
|
||||||
@@ -252,7 +253,7 @@ struct IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode
|
|||||||
/**
|
/**
|
||||||
* \brief An identifier node, usually representing an object or a function name.
|
* \brief An identifier node, usually representing an object or a function name.
|
||||||
*/
|
*/
|
||||||
struct IdentifierNode
|
struct GD_CORE_API IdentifierNode
|
||||||
: public IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode {
|
: public IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode {
|
||||||
IdentifierNode(const gd::String &identifierName_, const gd::String &type_)
|
IdentifierNode(const gd::String &identifierName_, const gd::String &type_)
|
||||||
: IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode(type_),
|
: IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode(type_),
|
||||||
@@ -265,7 +266,7 @@ struct IdentifierNode
|
|||||||
gd::String identifierName;
|
gd::String identifierName;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FunctionCallOrObjectFunctionNameOrEmptyNode
|
struct GD_CORE_API FunctionCallOrObjectFunctionNameOrEmptyNode
|
||||||
: public IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode {
|
: public IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode {
|
||||||
FunctionCallOrObjectFunctionNameOrEmptyNode(const gd::String &type)
|
FunctionCallOrObjectFunctionNameOrEmptyNode(const gd::String &type)
|
||||||
: IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode(type){};
|
: IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode(type){};
|
||||||
@@ -278,7 +279,7 @@ struct FunctionCallOrObjectFunctionNameOrEmptyNode
|
|||||||
* For example: "MyObject.Function" or "MyObject.Physics" or
|
* For example: "MyObject.Function" or "MyObject.Physics" or
|
||||||
* "MyObject.Physics::LinearVelocity".
|
* "MyObject.Physics::LinearVelocity".
|
||||||
*/
|
*/
|
||||||
struct ObjectFunctionNameNode
|
struct GD_CORE_API ObjectFunctionNameNode
|
||||||
: public FunctionCallOrObjectFunctionNameOrEmptyNode {
|
: public FunctionCallOrObjectFunctionNameOrEmptyNode {
|
||||||
ObjectFunctionNameNode(const gd::String &type_,
|
ObjectFunctionNameNode(const gd::String &type_,
|
||||||
const gd::String &objectName_,
|
const gd::String &objectName_,
|
||||||
@@ -331,7 +332,7 @@ struct ObjectFunctionNameNode
|
|||||||
* For example: "MyExtension::MyFunction(1, 2)", "MyObject.Function()" or
|
* For example: "MyExtension::MyFunction(1, 2)", "MyObject.Function()" or
|
||||||
* "MyObject.Physics::LinearVelocity()".
|
* "MyObject.Physics::LinearVelocity()".
|
||||||
*/
|
*/
|
||||||
struct FunctionCallNode : public FunctionCallOrObjectFunctionNameOrEmptyNode {
|
struct GD_CORE_API FunctionCallNode : public FunctionCallOrObjectFunctionNameOrEmptyNode {
|
||||||
/** \brief Construct a free function call node. */
|
/** \brief Construct a free function call node. */
|
||||||
FunctionCallNode(const gd::String &type_,
|
FunctionCallNode(const gd::String &type_,
|
||||||
std::vector<std::unique_ptr<ExpressionNode>> parameters_,
|
std::vector<std::unique_ptr<ExpressionNode>> parameters_,
|
||||||
@@ -399,7 +400,7 @@ struct FunctionCallNode : public FunctionCallOrObjectFunctionNameOrEmptyNode {
|
|||||||
* \brief An empty node, used when parsing failed/a syntax error was
|
* \brief An empty node, used when parsing failed/a syntax error was
|
||||||
* encountered and any other node could not make sense.
|
* encountered and any other node could not make sense.
|
||||||
*/
|
*/
|
||||||
struct EmptyNode : public FunctionCallOrObjectFunctionNameOrEmptyNode {
|
struct GD_CORE_API EmptyNode : public FunctionCallOrObjectFunctionNameOrEmptyNode {
|
||||||
EmptyNode(const gd::String &type_, const gd::String &text_ = "")
|
EmptyNode(const gd::String &type_, const gd::String &text_ = "")
|
||||||
: FunctionCallOrObjectFunctionNameOrEmptyNode(type_), text(text_){};
|
: FunctionCallOrObjectFunctionNameOrEmptyNode(type_), text(text_){};
|
||||||
virtual ~EmptyNode(){};
|
virtual ~EmptyNode(){};
|
||||||
|
@@ -7,21 +7,21 @@
|
|||||||
#define GDCORE_EXPRESSIONPARSER2NODEWORKER_H
|
#define GDCORE_EXPRESSIONPARSER2NODEWORKER_H
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
class ExpressionNode;
|
struct ExpressionNode;
|
||||||
class SubExpressionNode;
|
struct SubExpressionNode;
|
||||||
class OperatorNode;
|
struct OperatorNode;
|
||||||
class UnaryOperatorNode;
|
struct UnaryOperatorNode;
|
||||||
class NumberNode;
|
struct NumberNode;
|
||||||
class TextNode;
|
struct TextNode;
|
||||||
class VariableNode;
|
struct VariableNode;
|
||||||
class VariableAccessorNode;
|
struct VariableAccessorNode;
|
||||||
class VariableBracketAccessorNode;
|
struct VariableBracketAccessorNode;
|
||||||
class IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode;
|
struct IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode;
|
||||||
class IdentifierNode;
|
struct IdentifierNode;
|
||||||
class FunctionCallOrObjectFunctionNameOrEmptyNode;
|
struct FunctionCallOrObjectFunctionNameOrEmptyNode;
|
||||||
class ObjectFunctionNameNode;
|
struct ObjectFunctionNameNode;
|
||||||
class FunctionCallNode;
|
struct FunctionCallNode;
|
||||||
class EmptyNode;
|
struct EmptyNode;
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
@@ -34,21 +34,21 @@ namespace gd {
|
|||||||
* \see gd::ExpressionNode
|
* \see gd::ExpressionNode
|
||||||
*/
|
*/
|
||||||
class GD_CORE_API ExpressionParser2NodeWorker {
|
class GD_CORE_API ExpressionParser2NodeWorker {
|
||||||
friend class ExpressionNode;
|
friend struct ExpressionNode;
|
||||||
friend class SubExpressionNode;
|
friend struct SubExpressionNode;
|
||||||
friend class OperatorNode;
|
friend struct OperatorNode;
|
||||||
friend class UnaryOperatorNode;
|
friend struct UnaryOperatorNode;
|
||||||
friend class NumberNode;
|
friend struct NumberNode;
|
||||||
friend class TextNode;
|
friend struct TextNode;
|
||||||
friend class VariableNode;
|
friend struct VariableNode;
|
||||||
friend class VariableAccessorNode;
|
friend struct VariableAccessorNode;
|
||||||
friend class VariableBracketAccessorNode;
|
friend struct VariableBracketAccessorNode;
|
||||||
friend class IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode;
|
friend struct IdentifierOrFunctionCallOrObjectFunctionNameOrEmptyNode;
|
||||||
friend class IdentifierNode;
|
friend struct IdentifierNode;
|
||||||
friend class FunctionCallOrObjectFunctionNameOrEmptyNode;
|
friend struct FunctionCallOrObjectFunctionNameOrEmptyNode;
|
||||||
friend class ObjectFunctionNameNode;
|
friend struct ObjectFunctionNameNode;
|
||||||
friend class FunctionCallNode;
|
friend struct FunctionCallNode;
|
||||||
friend class EmptyNode;
|
friend struct EmptyNode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~ExpressionParser2NodeWorker();
|
virtual ~ExpressionParser2NodeWorker();
|
||||||
|
@@ -18,7 +18,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
|||||||
"Florian Rival",
|
"Florian Rival",
|
||||||
"Open source (MIT License)");
|
"Open source (MIT License)");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddCondition("Toujours",
|
.AddCondition("Toujours",
|
||||||
_("Always"),
|
_("Always"),
|
||||||
@@ -104,7 +103,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
|||||||
_("Functions"),
|
_("Functions"),
|
||||||
"res/function16.png")
|
"res/function16.png")
|
||||||
.AddParameter("string", "Parameter name");
|
.AddParameter("string", "Parameter name");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -32,7 +32,6 @@ class GD_CORE_API BuiltinExtensionsImplementer {
|
|||||||
static void ImplementsExternalLayoutsExtension(
|
static void ImplementsExternalLayoutsExtension(
|
||||||
gd::PlatformExtension& extension);
|
gd::PlatformExtension& extension);
|
||||||
static void ImplementsFileExtension(gd::PlatformExtension& extension);
|
static void ImplementsFileExtension(gd::PlatformExtension& extension);
|
||||||
static void ImplementsJoystickExtension(gd::PlatformExtension& extension);
|
|
||||||
static void ImplementsKeyboardExtension(gd::PlatformExtension& extension);
|
static void ImplementsKeyboardExtension(gd::PlatformExtension& extension);
|
||||||
static void ImplementsMathematicalToolsExtension(
|
static void ImplementsMathematicalToolsExtension(
|
||||||
gd::PlatformExtension& extension);
|
gd::PlatformExtension& extension);
|
||||||
|
@@ -21,7 +21,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/audio");
|
.SetExtensionHelpPath("/all-features/audio");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddAction("PlaySoundCanal",
|
.AddAction("PlaySoundCanal",
|
||||||
_("Play a sound on a channel"),
|
_("Play a sound on a channel"),
|
||||||
@@ -579,7 +578,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
|||||||
"res/conditions/volume.png")
|
"res/conditions/volume.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "");
|
.AddCodeOnlyParameter("currentScene", "");
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -25,7 +25,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
gd::ObjectMetadata& obj = extension.AddObject<gd::Object>(
|
gd::ObjectMetadata& obj = extension.AddObject<gd::Object>(
|
||||||
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
obj.AddCondition("PosX",
|
obj.AddCondition("PosX",
|
||||||
_("X position"),
|
_("X position"),
|
||||||
_("Compare the X position of the object."),
|
_("Compare the X position of the object."),
|
||||||
@@ -84,9 +83,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
"res/actions/position.png")
|
"res/actions/position.png")
|
||||||
|
|
||||||
.AddParameter("object", _("Object"))
|
.AddParameter("object", _("Object"))
|
||||||
.AddParameter("operator", _("Modification's sign"))
|
.AddParameter("operator", _("Modification's sign"), "number")
|
||||||
.AddParameter("expression", _("X position"))
|
.AddParameter("expression", _("X position"))
|
||||||
.AddParameter("operator", _("Modification's sign"))
|
.AddParameter("operator", _("Modification's sign"), "number")
|
||||||
.AddParameter("expression", _("Y position"))
|
.AddParameter("expression", _("Y position"))
|
||||||
.MarkAsSimple();
|
.MarkAsSimple();
|
||||||
|
|
||||||
@@ -99,15 +98,15 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
"res/actions/position24.png",
|
"res/actions/position24.png",
|
||||||
"res/actions/position.png")
|
"res/actions/position.png")
|
||||||
.AddParameter("object", _("Object"))
|
.AddParameter("object", _("Object"))
|
||||||
.AddParameter("operator", _("Modification's sign"))
|
.AddParameter("operator", _("Modification's sign"), "number")
|
||||||
.AddParameter("expression", _("X position"))
|
.AddParameter("expression", _("X position"))
|
||||||
.AddParameter("operator", _("Modification's sign"))
|
.AddParameter("operator", _("Modification's sign"), "number")
|
||||||
.AddParameter("expression", _("Y position"))
|
.AddParameter("expression", _("Y position"))
|
||||||
.MarkAsSimple();
|
.MarkAsSimple();
|
||||||
|
|
||||||
obj.AddExpressionAndConditionAndAction("number", "CenterX",
|
obj.AddExpressionAndConditionAndAction("number", "CenterX",
|
||||||
_("Center X position"),
|
_("Center X position"),
|
||||||
_("the X position of the center"),
|
_("the X position of the center of rotation"),
|
||||||
_("the X position of the center"),
|
_("the X position of the center"),
|
||||||
_("Position/Center"),
|
_("Position/Center"),
|
||||||
"res/actions/position24.png")
|
"res/actions/position24.png")
|
||||||
@@ -116,13 +115,67 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
|
|
||||||
obj.AddExpressionAndConditionAndAction("number", "CenterY",
|
obj.AddExpressionAndConditionAndAction("number", "CenterY",
|
||||||
_("Center Y position"),
|
_("Center Y position"),
|
||||||
_("the Y position of the center"),
|
_("the Y position of the center of rotation"),
|
||||||
_("the Y position of the center"),
|
_("the Y position of the center"),
|
||||||
_("Position/Center"),
|
_("Position/Center"),
|
||||||
"res/actions/position24.png")
|
"res/actions/position24.png")
|
||||||
.AddParameter("object", _("Object"))
|
.AddParameter("object", _("Object"))
|
||||||
.UseStandardParameters("number");
|
.UseStandardParameters("number");
|
||||||
|
|
||||||
|
obj.AddExpressionAndCondition("number", "BoundingBoxLeft",
|
||||||
|
_("Bounding box left position"),
|
||||||
|
_("the bounding box (the area encapsulating the object) left position"),
|
||||||
|
_("the bounding box left position"),
|
||||||
|
_("Position/Bounding Box"),
|
||||||
|
"res/conditions/bounding-box-left.svg")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.UseStandardParameters("number");
|
||||||
|
|
||||||
|
obj.AddExpressionAndCondition("number", "BoundingBoxTop",
|
||||||
|
_("Bounding box top position"),
|
||||||
|
_("the bounding box (the area encapsulating the object) top position"),
|
||||||
|
_("the bounding box top position"),
|
||||||
|
_("Position/Bounding Box"),
|
||||||
|
"res/conditions/bounding-box-top.svg")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.UseStandardParameters("number");
|
||||||
|
|
||||||
|
obj.AddExpressionAndCondition("number", "BoundingBoxRight",
|
||||||
|
_("Bounding box right position"),
|
||||||
|
_("the bounding box (the area encapsulating the object) right position"),
|
||||||
|
_("the bounding box right position"),
|
||||||
|
_("Position/Bounding Box"),
|
||||||
|
"res/conditions/bounding-box-right.svg")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.UseStandardParameters("number");
|
||||||
|
|
||||||
|
obj.AddExpressionAndCondition("number", "BoundingBoxBottom",
|
||||||
|
_("Bounding box bottom position"),
|
||||||
|
_("the bounding box (the area encapsulating the object) bottom position"),
|
||||||
|
_("the bounding box bottom position"),
|
||||||
|
_("Position/Bounding Box"),
|
||||||
|
"res/conditions/bounding-box-bottom.svg")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.UseStandardParameters("number");
|
||||||
|
|
||||||
|
obj.AddExpressionAndCondition("number", "BoundingBoxCenterX",
|
||||||
|
_("Bounding box center X position"),
|
||||||
|
_("the bounding box (the area encapsulating the object) center X position"),
|
||||||
|
_("the bounding box center X position"),
|
||||||
|
_("Position/Bounding Box"),
|
||||||
|
"res/conditions/bounding-box-center.svg")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.UseStandardParameters("number");
|
||||||
|
|
||||||
|
obj.AddExpressionAndCondition("number", "BoundingBoxCenterY",
|
||||||
|
_("Bounding box center Y position"),
|
||||||
|
_("the bounding box (the area encapsulating the object) center Y position"),
|
||||||
|
_("the bounding box center Y position"),
|
||||||
|
_("Position/Bounding Box"),
|
||||||
|
"res/conditions/bounding-box-center.svg")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.UseStandardParameters("number");
|
||||||
|
|
||||||
obj.AddAction("MettreAutourPos",
|
obj.AddAction("MettreAutourPos",
|
||||||
_("Put around a position"),
|
_("Put around a position"),
|
||||||
_("Position the center of the given object around a position, "
|
_("Position the center of the given object around a position, "
|
||||||
@@ -156,7 +209,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
_("Rotate"),
|
_("Rotate"),
|
||||||
_("Rotate an object, clockwise if the speed is positive, "
|
_("Rotate an object, clockwise if the speed is positive, "
|
||||||
"counterclockwise otherwise."),
|
"counterclockwise otherwise."),
|
||||||
_("Rotate _PARAM0_ at speed _PARAM1_deg/second"),
|
_("Rotate _PARAM0_ at speed _PARAM1_ deg/second"),
|
||||||
_("Angle"),
|
_("Angle"),
|
||||||
"res/actions/direction24.png",
|
"res/actions/direction24.png",
|
||||||
"res/actions/direction.png")
|
"res/actions/direction.png")
|
||||||
@@ -170,7 +223,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
"RotateTowardAngle",
|
"RotateTowardAngle",
|
||||||
_("Rotate toward angle"),
|
_("Rotate toward angle"),
|
||||||
_("Rotate an object towards an angle with the specified speed."),
|
_("Rotate an object towards an angle with the specified speed."),
|
||||||
_("Rotate _PARAM0_ towards _PARAM1_ at speed _PARAM2_deg/second"),
|
_("Rotate _PARAM0_ towards _PARAM1_ at speed _PARAM2_ deg/second"),
|
||||||
_("Angle"),
|
_("Angle"),
|
||||||
"res/actions/direction24.png",
|
"res/actions/direction24.png",
|
||||||
"res/actions/direction.png")
|
"res/actions/direction.png")
|
||||||
@@ -186,7 +239,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
_("Rotate toward position"),
|
_("Rotate toward position"),
|
||||||
_("Rotate an object towards a position, with the specified speed."),
|
_("Rotate an object towards a position, with the specified speed."),
|
||||||
_("Rotate _PARAM0_ towards _PARAM1_;_PARAM2_ at speed "
|
_("Rotate _PARAM0_ towards _PARAM1_;_PARAM2_ at speed "
|
||||||
"_PARAM3_deg/second"),
|
"_PARAM3_ deg/second"),
|
||||||
_("Angle"),
|
_("Angle"),
|
||||||
"res/actions/direction24.png",
|
"res/actions/direction24.png",
|
||||||
"res/actions/direction.png")
|
"res/actions/direction.png")
|
||||||
@@ -344,7 +397,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
obj.AddAction("SetObjectVariableAsBoolean",
|
obj.AddAction("SetObjectVariableAsBoolean",
|
||||||
_("Boolean value of an object variable"),
|
_("Boolean value of an object variable"),
|
||||||
_("Change the boolean value of an object variable."),
|
_("Change the boolean value of an object variable."),
|
||||||
_("Set the boolean value of the variable _PARAM1_ of object "
|
_("Set the boolean value of variable _PARAM1_ of "
|
||||||
"_PARAM0_ to _PARAM2_"),
|
"_PARAM0_ to _PARAM2_"),
|
||||||
_("Variables"),
|
_("Variables"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
@@ -360,7 +413,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
_("Toggles the boolean value of an object variable.") + "\n" +
|
_("Toggles the boolean value of an object variable.") + "\n" +
|
||||||
_("If it was true, it will become false, and if it was false "
|
_("If it was true, it will become false, and if it was false "
|
||||||
"it will become true."),
|
"it will become true."),
|
||||||
_("Toggle the boolean value of the variable _PARAM1_ of object "
|
_("Toggle the boolean value of variable _PARAM1_ of "
|
||||||
"_PARAM0_"),
|
"_PARAM0_"),
|
||||||
_("Variables"),
|
_("Variables"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
@@ -795,8 +848,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
|
|
||||||
obj.AddCondition(
|
obj.AddCondition(
|
||||||
"ObjectTimer",
|
"ObjectTimer",
|
||||||
_("Value of a timer"),
|
_("Value of an object timer"),
|
||||||
_("Test the elapsed time of a timer."),
|
_("Test the elapsed time of an object timer."),
|
||||||
_("The timer _PARAM1_ of _PARAM0_ is greater than _PARAM2_ seconds"),
|
_("The timer _PARAM1_ of _PARAM0_ is greater than _PARAM2_ seconds"),
|
||||||
_("Timers"),
|
_("Timers"),
|
||||||
"res/conditions/timer24.png",
|
"res/conditions/timer24.png",
|
||||||
@@ -806,8 +859,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
.AddParameter("expression", _("Time in seconds"));
|
.AddParameter("expression", _("Time in seconds"));
|
||||||
|
|
||||||
obj.AddCondition("ObjectTimerPaused",
|
obj.AddCondition("ObjectTimerPaused",
|
||||||
_("Timer paused"),
|
_("Object timer paused"),
|
||||||
_("Test if specified timer is paused."),
|
_("Test if specified object timer is paused."),
|
||||||
_("The timer _PARAM1_ of _PARAM0_ is paused"),
|
_("The timer _PARAM1_ of _PARAM0_ is paused"),
|
||||||
_("Timers"),
|
_("Timers"),
|
||||||
"res/conditions/timerPaused24.png",
|
"res/conditions/timerPaused24.png",
|
||||||
@@ -817,8 +870,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
obj.AddAction("ResetObjectTimer",
|
obj.AddAction("ResetObjectTimer",
|
||||||
_("Start (or reset) a timer"),
|
_("Start (or reset) an object timer"),
|
||||||
_("Reset the specified timer, if the timer doesn't exist "
|
_("Reset the specified object timer, if the timer doesn't exist "
|
||||||
"it's created and started."),
|
"it's created and started."),
|
||||||
_("Reset the timer _PARAM1_ of _PARAM0_"),
|
_("Reset the timer _PARAM1_ of _PARAM0_"),
|
||||||
_("Timers"),
|
_("Timers"),
|
||||||
@@ -828,8 +881,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
.AddParameter("string", _("Timer's name"));
|
.AddParameter("string", _("Timer's name"));
|
||||||
|
|
||||||
obj.AddAction("PauseObjectTimer",
|
obj.AddAction("PauseObjectTimer",
|
||||||
_("Pause a timer"),
|
_("Pause an object timer"),
|
||||||
_("Pause a timer."),
|
_("Pause an object timer."),
|
||||||
_("Pause timer _PARAM1_ of _PARAM0_"),
|
_("Pause timer _PARAM1_ of _PARAM0_"),
|
||||||
_("Timers"),
|
_("Timers"),
|
||||||
"res/actions/pauseTimer24.png",
|
"res/actions/pauseTimer24.png",
|
||||||
@@ -839,8 +892,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
obj.AddAction("UnPauseObjectTimer",
|
obj.AddAction("UnPauseObjectTimer",
|
||||||
_("Unpause a timer"),
|
_("Unpause an object timer"),
|
||||||
_("Unpause a timer."),
|
_("Unpause an object timer."),
|
||||||
_("Unpause timer _PARAM1_ of _PARAM0_"),
|
_("Unpause timer _PARAM1_ of _PARAM0_"),
|
||||||
_("Timers"),
|
_("Timers"),
|
||||||
"res/actions/unPauseTimer24.png",
|
"res/actions/unPauseTimer24.png",
|
||||||
@@ -850,8 +903,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
obj.AddAction("RemoveObjectTimer",
|
obj.AddAction("RemoveObjectTimer",
|
||||||
_("Delete a timer"),
|
_("Delete an object timer"),
|
||||||
_("Delete a timer from memory."),
|
_("Delete an object timer from memory."),
|
||||||
_("Delete timer _PARAM1_ of _PARAM0_ from memory"),
|
_("Delete timer _PARAM1_ of _PARAM0_ from memory"),
|
||||||
_("Timers"),
|
_("Timers"),
|
||||||
"res/actions/timer24.png",
|
"res/actions/timer24.png",
|
||||||
@@ -1021,9 +1074,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
.AddParameter("objectvar", _("Variable"));
|
.AddParameter("objectvar", _("Variable"));
|
||||||
|
|
||||||
obj.AddExpression("ObjectTimerElapsedTime",
|
obj.AddExpression("ObjectTimerElapsedTime",
|
||||||
_("Timer value"),
|
_("Object timer value"),
|
||||||
_("Value of a timer"),
|
_("Value of an object timer"),
|
||||||
_("Timers"),
|
_("Object timers"),
|
||||||
"res/actions/time.png")
|
"res/actions/time.png")
|
||||||
.AddParameter("object", _("Object"))
|
.AddParameter("object", _("Object"))
|
||||||
.AddParameter("string", _("Timer's name"));
|
.AddParameter("string", _("Timer's name"));
|
||||||
@@ -1072,11 +1125,79 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
.AddParameter("expression", _("Target X position"))
|
.AddParameter("expression", _("Target X position"))
|
||||||
.AddParameter("expression", _("Target Y position"));
|
.AddParameter("expression", _("Target Y position"));
|
||||||
|
|
||||||
|
obj.AddAction("EnableEffect",
|
||||||
|
_("Enable an object effect"),
|
||||||
|
_("Enable an effect on the object"),
|
||||||
|
_("Enable effect _PARAM1_ on _PARAM0_: _PARAM2_"),
|
||||||
|
_("Effects"),
|
||||||
|
"res/actions/effect24.png",
|
||||||
|
"res/actions/effect.png")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.AddParameter("objectEffectName", _("Effect name"))
|
||||||
|
.AddParameter("yesorno", _("Enable?"))
|
||||||
|
.MarkAsSimple();
|
||||||
|
|
||||||
|
obj.AddAction("SetEffectDoubleParameter",
|
||||||
|
_("Effect parameter (number)"),
|
||||||
|
_("Change the value of a parameter of an effect.") + "\n" +
|
||||||
|
_("You can find the parameter names (and change the effect "
|
||||||
|
"names) in the effects window."),
|
||||||
|
_("Set _PARAM2_ to _PARAM3_ for effect _PARAM1_ of _PARAM0_"),
|
||||||
|
_("Effects"),
|
||||||
|
"res/actions/effect24.png",
|
||||||
|
"res/actions/effect.png")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.AddParameter("objectEffectName", _("Effect name"))
|
||||||
|
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||||
|
.AddParameter("expression", _("New value"))
|
||||||
|
.MarkAsSimple();
|
||||||
|
|
||||||
|
obj.AddAction("SetEffectStringParameter",
|
||||||
|
_("Effect parameter (string)"),
|
||||||
|
_("Change the value (string) of a parameter of an effect.") + "\n" +
|
||||||
|
_("You can find the parameter names (and change the effect "
|
||||||
|
"names) in the effects window."),
|
||||||
|
_("Set _PARAM2_ to _PARAM3_ for effect _PARAM1_ of _PARAM0_"),
|
||||||
|
_("Effects"),
|
||||||
|
"res/actions/effect24.png",
|
||||||
|
"res/actions/effect.png")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.AddParameter("objectEffectName", _("Effect name"))
|
||||||
|
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||||
|
.AddParameter("string", _("New value"))
|
||||||
|
.MarkAsSimple();
|
||||||
|
|
||||||
|
obj.AddAction("SetEffectBooleanParameter",
|
||||||
|
_("Effect parameter (enable or disable)"),
|
||||||
|
_("Enable or disable a parameter of an effect.") + "\n" +
|
||||||
|
_("You can find the parameter names (and change the effect "
|
||||||
|
"names) in the effects window."),
|
||||||
|
_("Enable _PARAM2_ for effect _PARAM1_ of _PARAM0_: _PARAM3_"),
|
||||||
|
_("Effects"),
|
||||||
|
"res/actions/effect24.png",
|
||||||
|
"res/actions/effect.png")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.AddParameter("objectEffectName", _("Effect name"))
|
||||||
|
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||||
|
.AddParameter("yesorno", _("Enable?"))
|
||||||
|
.MarkAsSimple();
|
||||||
|
|
||||||
|
obj.AddCondition("IsEffectEnabled",
|
||||||
|
_("Effect is enabled"),
|
||||||
|
_("Check if the effect on an object is enabled."),
|
||||||
|
_("Effect _PARAM1_ of _PARAM0_ is enabled"),
|
||||||
|
_("Effects"),
|
||||||
|
"res/actions/effect24.png",
|
||||||
|
"res/actions/effect.png")
|
||||||
|
.AddParameter("object", _("Object"))
|
||||||
|
.AddParameter("objectEffectName", _("Effect name"))
|
||||||
|
.MarkAsSimple();
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddAction("Create",
|
.AddAction("Create",
|
||||||
_("Create an object"),
|
_("Create an object"),
|
||||||
_("Create an object at specified position"),
|
_("Create an object at specified position"),
|
||||||
_("Create object _PARAM1_ at position _PARAM2_;_PARAM3_"),
|
_("Create object _PARAM1_ at position _PARAM2_;_PARAM3_ (layer: _PARAM4_)"),
|
||||||
_("Objects"),
|
_("Objects"),
|
||||||
"res/actions/create24.png",
|
"res/actions/create24.png",
|
||||||
"res/actions/create.png")
|
"res/actions/create.png")
|
||||||
@@ -1094,7 +1215,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
_("Among the objects of the specified group, this action will "
|
_("Among the objects of the specified group, this action will "
|
||||||
"create the object with the specified name."),
|
"create the object with the specified name."),
|
||||||
_("Among objects _PARAM1_, create object named _PARAM2_ at "
|
_("Among objects _PARAM1_, create object named _PARAM2_ at "
|
||||||
"position _PARAM3_;_PARAM4_"),
|
"position _PARAM3_;_PARAM4_ (layer: _PARAM5_)"),
|
||||||
_("Objects"),
|
_("Objects"),
|
||||||
"res/actions/create24.png",
|
"res/actions/create24.png",
|
||||||
"res/actions/create.png")
|
"res/actions/create.png")
|
||||||
@@ -1373,7 +1494,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
|||||||
_("Objects"),
|
_("Objects"),
|
||||||
"res/actions/layer.png")
|
"res/actions/layer.png")
|
||||||
.AddParameter("object", _("Object"));
|
.AddParameter("object", _("Object"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -24,7 +24,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/interface/scene-editor/layers-and-cameras");
|
.SetExtensionHelpPath("/interface/scene-editor/layers-and-cameras");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddExpressionAndConditionAndAction(
|
.AddExpressionAndConditionAndAction(
|
||||||
"number",
|
"number",
|
||||||
@@ -342,8 +341,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||||
.SetDefaultValue("\"\"")
|
.SetDefaultValue("\"\"")
|
||||||
.AddParameter("string", _("Effect"))
|
.AddParameter("layerEffectName", _("Effect name"))
|
||||||
.AddParameter("string", _("Parameter name"))
|
.AddParameter("layerEffectParameterName", _("Parameter name"))
|
||||||
.AddParameter("expression", _("New value"))
|
.AddParameter("expression", _("New value"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
@@ -361,8 +360,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||||
.SetDefaultValue("\"\"")
|
.SetDefaultValue("\"\"")
|
||||||
.AddParameter("string", _("Effect"))
|
.AddParameter("layerEffectName", _("Effect name"))
|
||||||
.AddParameter("string", _("Parameter name"))
|
.AddParameter("layerEffectParameterName", _("Parameter name"))
|
||||||
.AddParameter("string", _("New value"))
|
.AddParameter("string", _("New value"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
@@ -380,8 +379,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||||
.SetDefaultValue("\"\"")
|
.SetDefaultValue("\"\"")
|
||||||
.AddParameter("string", _("Effect"))
|
.AddParameter("layerEffectName", _("Effect name"))
|
||||||
.AddParameter("string", _("Parameter name"))
|
.AddParameter("layerEffectParameterName", _("Parameter name"))
|
||||||
.AddParameter("yesorno", _("Enable this parameter"))
|
.AddParameter("yesorno", _("Enable this parameter"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
@@ -396,7 +395,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||||
.SetDefaultValue("\"\"")
|
.SetDefaultValue("\"\"")
|
||||||
.AddParameter("string", _("Effect"))
|
.AddParameter("layerEffectName", _("Effect name"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
extension
|
extension
|
||||||
@@ -410,7 +409,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||||
.SetDefaultValue("\"\"")
|
.SetDefaultValue("\"\"")
|
||||||
.AddParameter("string", _("Effect"))
|
.AddParameter("layerEffectName", _("Effect name"))
|
||||||
.AddParameter("yesorno", _("Enable"), "", true)
|
.AddParameter("yesorno", _("Enable"), "", true)
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
@@ -420,7 +419,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
_("Layer time scale"),
|
_("Layer time scale"),
|
||||||
_("Compare the time scale applied to the objects of the layer."),
|
_("Compare the time scale applied to the objects of the layer."),
|
||||||
_("the time scale of layer _PARAM1_"),
|
_("the time scale of layer _PARAM1_"),
|
||||||
_("Layers and cameras/Time"),
|
_("Layers and cameras"),
|
||||||
"res/conditions/time24.png",
|
"res/conditions/time24.png",
|
||||||
"res/conditions/time.png")
|
"res/conditions/time.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
@@ -434,8 +433,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
"ChangeLayerTimeScale",
|
"ChangeLayerTimeScale",
|
||||||
_("Change layer time scale"),
|
_("Change layer time scale"),
|
||||||
_("Change the time scale applied to the objects of the layer."),
|
_("Change the time scale applied to the objects of the layer."),
|
||||||
_("Set time scale of layer _PARAM1_ to _PARAM2_"),
|
_("Set the time scale of layer _PARAM1_ to _PARAM2_"),
|
||||||
_("Layers and cameras/Time"),
|
_("Layers and cameras"),
|
||||||
"res/actions/time24.png",
|
"res/actions/time24.png",
|
||||||
"res/actions/time.png")
|
"res/actions/time.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
@@ -552,8 +551,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
|
|
||||||
extension
|
extension
|
||||||
.AddExpression("LayerTimeScale",
|
.AddExpression("LayerTimeScale",
|
||||||
_("Time scale"),
|
_("Layer time scale"),
|
||||||
_("Time scale"),
|
_("Returns the time scale of the specified layer."),
|
||||||
_("Layers and cameras"),
|
_("Layers and cameras"),
|
||||||
"res/actions/time.png")
|
"res/actions/time.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
@@ -567,7 +566,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
|||||||
"res/actions/camera.png")
|
"res/actions/camera.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
.AddParameter("layer", _("Layer"));
|
.AddParameter("layer", _("Layer"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -21,7 +21,6 @@ BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/common-conversions");
|
.SetExtensionHelpPath("/all-features/common-conversions");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddExpression("ToNumber",
|
.AddExpression("ToNumber",
|
||||||
@@ -65,7 +64,6 @@ BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
|
|||||||
_("Conversion"),
|
_("Conversion"),
|
||||||
"res/conditions/toujours24.png")
|
"res/conditions/toujours24.png")
|
||||||
.AddParameter("expression", _("Angle, in radians"));
|
.AddParameter("expression", _("Angle, in radians"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "AllBuiltinExtensions.h"
|
#include "AllBuiltinExtensions.h"
|
||||||
#include "GDCore/Tools/Localization.h"
|
#include "GDCore/Tools/Localization.h"
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
#include "GDCore/Events/Builtin/CommentEvent.h"
|
#include "GDCore/Events/Builtin/CommentEvent.h"
|
||||||
#include "GDCore/Events/Builtin/ForEachChildVariableEvent.h"
|
#include "GDCore/Events/Builtin/ForEachChildVariableEvent.h"
|
||||||
#include "GDCore/Events/Builtin/ForEachEvent.h"
|
#include "GDCore/Events/Builtin/ForEachEvent.h"
|
||||||
@@ -15,7 +14,6 @@
|
|||||||
#include "GDCore/Events/Builtin/StandardEvent.h"
|
#include "GDCore/Events/Builtin/StandardEvent.h"
|
||||||
#include "GDCore/Events/Builtin/WhileEvent.h"
|
#include "GDCore/Events/Builtin/WhileEvent.h"
|
||||||
#include "GDCore/Events/Event.h"
|
#include "GDCore/Events/Event.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
namespace gd {
|
namespace gd {
|
||||||
@@ -33,7 +31,6 @@ BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/advanced-conditions");
|
.SetExtensionHelpPath("/all-features/advanced-conditions");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddCondition("Or",
|
.AddCondition("Or",
|
||||||
_("Or"),
|
_("Or"),
|
||||||
@@ -86,29 +83,29 @@ BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
|
|||||||
std::make_shared<gd::StandardEvent>());
|
std::make_shared<gd::StandardEvent>());
|
||||||
|
|
||||||
extension.AddEvent("Link",
|
extension.AddEvent("Link",
|
||||||
_("Link"),
|
_("Link external events"),
|
||||||
_("Link to some external events"),
|
_("Link to external events."),
|
||||||
"",
|
"",
|
||||||
"res/lienaddicon.png",
|
"res/lienaddicon.png",
|
||||||
std::make_shared<gd::LinkEvent>());
|
std::make_shared<gd::LinkEvent>());
|
||||||
|
|
||||||
extension.AddEvent("Comment",
|
extension.AddEvent("Comment",
|
||||||
_("Comment"),
|
_("Comment"),
|
||||||
_("Event displaying a text in the events editor"),
|
_("Event displaying a text in the events editor."),
|
||||||
"",
|
"",
|
||||||
"res/comment.png",
|
"res/comment.png",
|
||||||
std::make_shared<gd::CommentEvent>());
|
std::make_shared<gd::CommentEvent>());
|
||||||
|
|
||||||
extension.AddEvent("While",
|
extension.AddEvent("While",
|
||||||
_("While"),
|
_("While"),
|
||||||
_("The event is repeated while the conditions are true"),
|
_("Repeat the event while the conditions are true."),
|
||||||
"",
|
"",
|
||||||
"res/while.png",
|
"res/while.png",
|
||||||
std::make_shared<gd::WhileEvent>());
|
std::make_shared<gd::WhileEvent>());
|
||||||
|
|
||||||
extension.AddEvent("Repeat",
|
extension.AddEvent("Repeat",
|
||||||
_("Repeat"),
|
_("Repeat"),
|
||||||
_("Event repeated a number of times"),
|
_("Repeat the event for a specified number of times."),
|
||||||
"",
|
"",
|
||||||
"res/repeat.png",
|
"res/repeat.png",
|
||||||
std::make_shared<gd::RepeatEvent>());
|
std::make_shared<gd::RepeatEvent>());
|
||||||
@@ -129,12 +126,11 @@ BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
|
|||||||
std::make_shared<gd::ForEachChildVariableEvent>());
|
std::make_shared<gd::ForEachChildVariableEvent>());
|
||||||
|
|
||||||
extension.AddEvent("Group",
|
extension.AddEvent("Group",
|
||||||
_("Group"),
|
_("Event group"),
|
||||||
_("Group containing events"),
|
_("Group containing events."),
|
||||||
"",
|
"",
|
||||||
"res/foreach.png",
|
"res/foreach.png",
|
||||||
std::make_shared<gd::GroupEvent>());
|
std::make_shared<gd::GroupEvent>());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -21,7 +21,6 @@ BuiltinExtensionsImplementer::ImplementsExternalLayoutsExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/interface/scene-editor/external-layouts");
|
.SetExtensionHelpPath("/interface/scene-editor/external-layouts");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddAction("CreateObjectsFromExternalLayout",
|
.AddAction("CreateObjectsFromExternalLayout",
|
||||||
_("Create objects from an external layout"),
|
_("Create objects from an external layout"),
|
||||||
@@ -37,7 +36,6 @@ BuiltinExtensionsImplementer::ImplementsExternalLayoutsExtension(
|
|||||||
.AddParameter("expression", _("Y position of the origin"), "", true)
|
.AddParameter("expression", _("Y position of the origin"), "", true)
|
||||||
.SetDefaultValue("0")
|
.SetDefaultValue("0")
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -22,7 +22,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/storage");
|
.SetExtensionHelpPath("/all-features/storage");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddCondition(
|
.AddCondition(
|
||||||
"GroupExists",
|
"GroupExists",
|
||||||
@@ -194,7 +193,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
|||||||
"res/actions/launchFile.png")
|
"res/actions/launchFile.png")
|
||||||
.AddParameter("string", _("Command"))
|
.AddParameter("string", _("Command"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* GDevelop Core
|
|
||||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
|
||||||
* reserved. This project is released under the MIT License.
|
|
||||||
*/
|
|
||||||
#include "AllBuiltinExtensions.h"
|
|
||||||
#include "GDCore/Tools/Localization.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
namespace gd {
|
|
||||||
|
|
||||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsJoystickExtension(
|
|
||||||
gd::PlatformExtension& extension) {
|
|
||||||
extension
|
|
||||||
.SetExtensionInformation(
|
|
||||||
"BuiltinJoystick",
|
|
||||||
_("Joysticks features"),
|
|
||||||
"Built-in extension that enables the use of joysticks.",
|
|
||||||
"Florian Rival",
|
|
||||||
"Open source (MIT License)")
|
|
||||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
|
||||||
.AddCondition("JoystickButtonDown",
|
|
||||||
_("A button on a joystick is pressed"),
|
|
||||||
_("Test if a button on a joystick is pressed."),
|
|
||||||
_("The button _PARAM2_ of joystick _PARAM1_ is pressed"),
|
|
||||||
_("Joystick"),
|
|
||||||
"res/conditions/joystick24.png",
|
|
||||||
"res/conditions/joystick.png")
|
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
|
||||||
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
|
|
||||||
.AddParameter("expression", _("Button"));
|
|
||||||
|
|
||||||
extension
|
|
||||||
.AddCondition("JoystickAxis",
|
|
||||||
_("Value of an axis of a joystick"),
|
|
||||||
_("Test the value of an axis of a joystick."),
|
|
||||||
_("the value of the axis _PARAM2_ of joystick _PARAM1_"),
|
|
||||||
_("Joystick"),
|
|
||||||
"res/conditions/joystick24.png",
|
|
||||||
"res/conditions/joystick.png")
|
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
|
||||||
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
|
|
||||||
.AddParameter("joyaxis", _("Axis"))
|
|
||||||
.UseStandardRelationalOperatorParameters("number");
|
|
||||||
|
|
||||||
extension
|
|
||||||
.AddAction(
|
|
||||||
"GetJoystickAxis",
|
|
||||||
_("Get the value of the axis of a joystick"),
|
|
||||||
_("Save the value of the axis of the joystick (from -100 to 100)."),
|
|
||||||
_("Save in _PARAM3_ the value of axis _PARAM2_ of joystick _PARAM1_"),
|
|
||||||
_("Joystick"),
|
|
||||||
"res/actions/joystick24.png",
|
|
||||||
"res/actions/joystick.png")
|
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
|
||||||
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
|
|
||||||
.AddParameter("joyaxis", _("Axis"))
|
|
||||||
.AddParameter("scenevar", _("Save the result to the scene variable"))
|
|
||||||
.SetManipulatedType("number");
|
|
||||||
|
|
||||||
extension
|
|
||||||
.AddExpression("GetJoystickAxis",
|
|
||||||
_("Joystick axis"),
|
|
||||||
_("Value of an axis of a joystick"),
|
|
||||||
_("Joystick"),
|
|
||||||
"res/conditions/joystick.png")
|
|
||||||
|
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
|
||||||
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
|
|
||||||
.AddParameter("joyaxis", _("Axis"));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace gd
|
|
@@ -23,11 +23,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/keyboard");
|
.SetExtensionHelpPath("/all-features/keyboard");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddCondition("KeyPressed",
|
.AddCondition("KeyPressed",
|
||||||
_("Key pressed"),
|
_("Key pressed"),
|
||||||
_("Test if a key is pressed"),
|
_("Check if a key is pressed"),
|
||||||
_("_PARAM1_ key is pressed"),
|
_("_PARAM1_ key is pressed"),
|
||||||
_("Keyboard"),
|
_("Keyboard"),
|
||||||
"res/conditions/keyboard24.png",
|
"res/conditions/keyboard24.png",
|
||||||
@@ -38,7 +37,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
|||||||
extension
|
extension
|
||||||
.AddCondition("KeyReleased",
|
.AddCondition("KeyReleased",
|
||||||
_("Key released"),
|
_("Key released"),
|
||||||
_("Test if a key was just released"),
|
_("Check if a key was just released"),
|
||||||
_("_PARAM1_ key is released"),
|
_("_PARAM1_ key is released"),
|
||||||
_("Keyboard"),
|
_("Keyboard"),
|
||||||
"res/conditions/keyboard24.png",
|
"res/conditions/keyboard24.png",
|
||||||
@@ -49,33 +48,33 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
|||||||
extension
|
extension
|
||||||
.AddCondition("KeyFromTextPressed",
|
.AddCondition("KeyFromTextPressed",
|
||||||
_("Key pressed (text expression)"),
|
_("Key pressed (text expression)"),
|
||||||
_("Test if a key, retrieved from the result of the "
|
_("Check if a key, retrieved from the result of the "
|
||||||
"expression, is pressed"),
|
"expression, is pressed"),
|
||||||
_("_PARAM1_ key is pressed"),
|
_("_PARAM1_ key is pressed"),
|
||||||
_("Keyboard"),
|
_("Keyboard"),
|
||||||
"res/conditions/keyboard24.png",
|
"res/conditions/keyboard24.png",
|
||||||
"res/conditions/keyboard.png")
|
"res/conditions/keyboard.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
.AddParameter("string", _("Expression generating the key to test"))
|
.AddParameter("string", _("Expression generating the key to check"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddCondition("KeyFromTextReleased",
|
.AddCondition("KeyFromTextReleased",
|
||||||
_("Key released (text expression)"),
|
_("Key released (text expression)"),
|
||||||
_("Test if a key, retrieved from the result of the "
|
_("Check if a key, retrieved from the result of the "
|
||||||
"expression, was just released"),
|
"expression, was just released"),
|
||||||
_("_PARAM1_ key is released"),
|
_("_PARAM1_ key is released"),
|
||||||
_("Keyboard"),
|
_("Keyboard"),
|
||||||
"res/conditions/keyboard24.png",
|
"res/conditions/keyboard24.png",
|
||||||
"res/conditions/keyboard.png")
|
"res/conditions/keyboard.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
.AddParameter("string", _("Expression generating the key to test"))
|
.AddParameter("string", _("Expression generating the key to check"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddCondition("AnyKeyPressed",
|
.AddCondition("AnyKeyPressed",
|
||||||
_("Any key pressed"),
|
_("Any key pressed"),
|
||||||
_("Test if any key is pressed"),
|
_("Check if any key is pressed"),
|
||||||
_("Any key is pressed"),
|
_("Any key is pressed"),
|
||||||
_("Keyboard"),
|
_("Keyboard"),
|
||||||
"res/conditions/keyboard24.png",
|
"res/conditions/keyboard24.png",
|
||||||
@@ -85,7 +84,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
|||||||
extension
|
extension
|
||||||
.AddCondition("AnyKeyReleased",
|
.AddCondition("AnyKeyReleased",
|
||||||
_("Any key released"),
|
_("Any key released"),
|
||||||
_("Test if any key is released"),
|
_("Check if any key is released"),
|
||||||
_("Any key is released"),
|
_("Any key is released"),
|
||||||
_("Keyboard"),
|
_("Keyboard"),
|
||||||
"res/conditions/keyboard24.png",
|
"res/conditions/keyboard24.png",
|
||||||
@@ -100,7 +99,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
|||||||
_("Keyboard"),
|
_("Keyboard"),
|
||||||
"res/conditions/keyboard.png")
|
"res/conditions/keyboard.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "");
|
.AddCodeOnlyParameter("currentScene", "");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -19,7 +19,6 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
|||||||
"Florian Rival",
|
"Florian Rival",
|
||||||
"Open source (MIT License)");
|
"Open source (MIT License)");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddExpression("normalize",
|
.AddExpression("normalize",
|
||||||
@@ -403,7 +402,6 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
|||||||
.AddParameter("expression", _("Angle, in degrees"))
|
.AddParameter("expression", _("Angle, in degrees"))
|
||||||
.AddParameter("expression", _("Distance"));
|
.AddParameter("expression", _("Distance"));
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -25,7 +25,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/mouse-touch");
|
.SetExtensionHelpPath("/all-features/mouse-touch");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddCondition(
|
.AddCondition(
|
||||||
"IsMouseWheelScrollingUp",
|
"IsMouseWheelScrollingUp",
|
||||||
@@ -217,6 +216,39 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
|||||||
.AddParameter("mouse", _("Button to check"))
|
.AddParameter("mouse", _("Button to check"))
|
||||||
.MarkAsSimple();
|
.MarkAsSimple();
|
||||||
|
|
||||||
|
extension
|
||||||
|
.AddCondition(
|
||||||
|
"MouseButtonFromTextPressed",
|
||||||
|
_("Mouse button pressed or touch held (text expression)"),
|
||||||
|
_("Check if a mouse button, retrieved from the result of the "
|
||||||
|
"expression, is pressed."),
|
||||||
|
_("_PARAM1_ mouse button is pressed"),
|
||||||
|
_("Mouse and touch"),
|
||||||
|
"res/conditions/mouse24.png",
|
||||||
|
"res/conditions/mouse.png")
|
||||||
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
|
.AddParameter("string", _("Expression generating the button to check"))
|
||||||
|
.SetParameterLongDescription(
|
||||||
|
_("Possible values are Left, Right and Middle."))
|
||||||
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
|
extension
|
||||||
|
.AddCondition(
|
||||||
|
"MouseButtonFromTextReleased",
|
||||||
|
_("Mouse button released (text expression)"),
|
||||||
|
_("Check if a mouse button, retrieved from the result of the "
|
||||||
|
"expression, was just released."),
|
||||||
|
_("_PARAM1_ mouse button is released"),
|
||||||
|
_("Mouse and touch"),
|
||||||
|
"res/conditions/mouse24.png",
|
||||||
|
"res/conditions/mouse.png")
|
||||||
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
|
.AddParameter("string",
|
||||||
|
_("Expression generating the mouse button to check"))
|
||||||
|
.SetParameterLongDescription(
|
||||||
|
_("Possible values are Left, Right and Middle."))
|
||||||
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddExpressionAndCondition("number",
|
.AddExpressionAndCondition("number",
|
||||||
"TouchX",
|
"TouchX",
|
||||||
@@ -302,8 +334,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
|||||||
_("Mouse and touch/Multitouch"),
|
_("Mouse and touch/Multitouch"),
|
||||||
"res/conditions/touch.png")
|
"res/conditions/touch.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "");
|
.AddCodeOnlyParameter("currentScene", "");
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -21,7 +21,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/network");
|
.SetExtensionHelpPath("/all-features/network");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddAction(
|
.AddAction(
|
||||||
"SendRequest",
|
"SendRequest",
|
||||||
@@ -196,7 +195,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
|||||||
"res/conditions/toujours24.png")
|
"res/conditions/toujours24.png")
|
||||||
.AddParameter("objectPtr", _("The object with the variable"))
|
.AddParameter("objectPtr", _("The object with the variable"))
|
||||||
.AddParameter("objectvar", _("The object variable to be stringified"));
|
.AddParameter("objectvar", _("The object variable to be stringified"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -20,7 +20,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddExpression("Random",
|
.AddExpression("Random",
|
||||||
@@ -196,7 +195,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
|||||||
"res/conditions/egal.png")
|
"res/conditions/egal.png")
|
||||||
.SetHelpPath("/all-features/advanced-conditions")
|
.SetHelpPath("/all-features/advanced-conditions")
|
||||||
.AddParameter("expression", _("First expression"))
|
.AddParameter("expression", _("First expression"))
|
||||||
.AddParameter("relationalOperator", _("Sign of the test"))
|
.AddParameter("relationalOperator", _("Sign of the test"), "number")
|
||||||
.AddParameter("expression", _("Second expression"))
|
.AddParameter("expression", _("Second expression"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
@@ -210,10 +209,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
|||||||
"res/conditions/egal.png")
|
"res/conditions/egal.png")
|
||||||
.SetHelpPath("/all-features/advanced-conditions")
|
.SetHelpPath("/all-features/advanced-conditions")
|
||||||
.AddParameter("string", _("First string expression"))
|
.AddParameter("string", _("First string expression"))
|
||||||
.AddParameter("relationalOperator", _("Sign of the test"))
|
.AddParameter("relationalOperator", _("Sign of the test"), "string")
|
||||||
.AddParameter("string", _("Second string expression"))
|
.AddParameter("string", _("Second string expression"))
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -75,11 +75,9 @@ void Direction::UnserializeFrom(const gd::SerializerElement& element) {
|
|||||||
SetTimeBetweenFrames(
|
SetTimeBetweenFrames(
|
||||||
element.GetDoubleAttribute("timeBetweenFrames", 1, "tempsEntre"));
|
element.GetDoubleAttribute("timeBetweenFrames", 1, "tempsEntre"));
|
||||||
SetLoop(element.GetBoolAttribute("looping", false, "boucle"));
|
SetLoop(element.GetBoolAttribute("looping", false, "boucle"));
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
SetMetadata(element.HasAttribute("metadata") || element.HasChild("metadata")
|
SetMetadata(element.HasAttribute("metadata") || element.HasChild("metadata")
|
||||||
? element.GetStringAttribute("metadata")
|
? element.GetStringAttribute("metadata")
|
||||||
: "");
|
: "");
|
||||||
#endif
|
|
||||||
|
|
||||||
const gd::SerializerElement& spritesElement =
|
const gd::SerializerElement& spritesElement =
|
||||||
element.GetChild("sprites", 0, "Sprites");
|
element.GetChild("sprites", 0, "Sprites");
|
||||||
@@ -135,7 +133,6 @@ void Direction::UnserializeFrom(const gd::SerializerElement& element) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
void SavePoint(const Point& point, gd::SerializerElement& element) {
|
void SavePoint(const Point& point, gd::SerializerElement& element) {
|
||||||
element.SetAttribute("name", point.GetName());
|
element.SetAttribute("name", point.GetName());
|
||||||
element.SetAttribute("x", point.GetX());
|
element.SetAttribute("x", point.GetX());
|
||||||
@@ -190,6 +187,5 @@ void Direction::SerializeTo(gd::SerializerElement& element) const {
|
|||||||
if (!GetMetadata().empty()) element.SetAttribute("metadata", GetMetadata());
|
if (!GetMetadata().empty()) element.SetAttribute("metadata", GetMetadata());
|
||||||
SaveSpritesDirection(sprites, element.AddChild("sprites"));
|
SaveSpritesDirection(sprites, element.AddChild("sprites"));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -113,7 +113,6 @@ class GD_CORE_API Direction {
|
|||||||
*/
|
*/
|
||||||
void MoveSprite(std::size_t oldIndex, std::size_t newIndex);
|
void MoveSprite(std::size_t oldIndex, std::size_t newIndex);
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the metadata (any string) associated to the Direction.
|
* \brief Set the metadata (any string) associated to the Direction.
|
||||||
* \note Can be used by external editors to store extra information.
|
* \note Can be used by external editors to store extra information.
|
||||||
@@ -124,20 +123,15 @@ class GD_CORE_API Direction {
|
|||||||
* \brief Return the (optional) metadata associated to the Direction.
|
* \brief Return the (optional) metadata associated to the Direction.
|
||||||
*/
|
*/
|
||||||
virtual const gd::String& GetMetadata() const { return metadata; }
|
virtual const gd::String& GetMetadata() const { return metadata; }
|
||||||
#endif
|
|
||||||
|
|
||||||
void UnserializeFrom(const gd::SerializerElement& element);
|
void UnserializeFrom(const gd::SerializerElement& element);
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
void SerializeTo(gd::SerializerElement& element) const;
|
void SerializeTo(gd::SerializerElement& element) const;
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool loop; ///< true if the animation must loop.
|
bool loop; ///< true if the animation must loop.
|
||||||
double timeBetweenFrame; ///< The time between each sprite of the animation.
|
double timeBetweenFrame; ///< The time between each sprite of the animation.
|
||||||
std::vector<Sprite> sprites; ///< The sprites of the direction.
|
std::vector<Sprite> sprites; ///< The sprites of the direction.
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
gd::String metadata;
|
gd::String metadata;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#include <SFML/Graphics/Sprite.hpp>
|
#include <SFML/Graphics/Sprite.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
|
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
|
||||||
#include "GDCore/Project/ImageManager.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -16,11 +15,7 @@ namespace gd {
|
|||||||
Point Sprite::badPoint("");
|
Point Sprite::badPoint("");
|
||||||
|
|
||||||
Sprite::Sprite()
|
Sprite::Sprite()
|
||||||
:
|
: automaticCollisionMask(true),
|
||||||
#if !defined(EMSCRIPTEN)
|
|
||||||
hasItsOwnImage(false),
|
|
||||||
#endif
|
|
||||||
automaticCollisionMask(true),
|
|
||||||
origine("origine"),
|
origine("origine"),
|
||||||
centre("centre"),
|
centre("centre"),
|
||||||
automaticCentre(true) {
|
automaticCentre(true) {
|
||||||
@@ -73,36 +68,10 @@ Point& Sprite::GetPoint(const gd::String& name) {
|
|||||||
|
|
||||||
bool Sprite::SetDefaultCenterPoint(bool enabled) {
|
bool Sprite::SetDefaultCenterPoint(bool enabled) {
|
||||||
automaticCentre = enabled;
|
automaticCentre = enabled;
|
||||||
|
|
||||||
#if !defined(EMSCRIPTEN)
|
|
||||||
if (automaticCentre)
|
|
||||||
centre.SetXY(sfmlSprite.getLocalBounds().width / 2,
|
|
||||||
sfmlSprite.getLocalBounds().height / 2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Polygon2d> Sprite::GetCollisionMask() const {
|
std::vector<Polygon2d> Sprite::GetCollisionMask() const {
|
||||||
// TODO(perf): Cache to avoid re-creating a mask at every call
|
|
||||||
#if !defined(EMSCRIPTEN)
|
|
||||||
if (automaticCollisionMask) {
|
|
||||||
std::vector<Polygon2d> mask;
|
|
||||||
|
|
||||||
Polygon2d rectangle;
|
|
||||||
rectangle.vertices.push_back(sf::Vector2f(0, 0));
|
|
||||||
rectangle.vertices.push_back(
|
|
||||||
sf::Vector2f(sfmlSprite.getLocalBounds().width, 0));
|
|
||||||
rectangle.vertices.push_back(sf::Vector2f(
|
|
||||||
sfmlSprite.getLocalBounds().width, sfmlSprite.getLocalBounds().height));
|
|
||||||
rectangle.vertices.push_back(
|
|
||||||
sf::Vector2f(0, sfmlSprite.getLocalBounds().height));
|
|
||||||
|
|
||||||
mask.push_back(rectangle);
|
|
||||||
return mask;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return customCollisionMask;
|
return customCollisionMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,25 +80,4 @@ void Sprite::SetCustomCollisionMask(
|
|||||||
customCollisionMask = collisionMask;
|
customCollisionMask = collisionMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(EMSCRIPTEN)
|
|
||||||
void Sprite::LoadImage(std::shared_ptr<SFMLTextureWrapper> image_) {
|
|
||||||
sfmlImage = image_;
|
|
||||||
sfmlSprite.setTexture(sfmlImage->texture, true);
|
|
||||||
hasItsOwnImage = false;
|
|
||||||
|
|
||||||
if (automaticCentre)
|
|
||||||
centre.SetXY(sfmlSprite.getLocalBounds().width / 2,
|
|
||||||
sfmlSprite.getLocalBounds().height / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sprite::MakeSpriteOwnsItsImage() {
|
|
||||||
if (!hasItsOwnImage || sfmlImage == std::shared_ptr<SFMLTextureWrapper>()) {
|
|
||||||
sfmlImage = std::make_shared<SFMLTextureWrapper>(
|
|
||||||
sfmlImage->texture); // Copy the texture.
|
|
||||||
sfmlSprite.setTexture(sfmlImage->texture);
|
|
||||||
hasItsOwnImage = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Point.h"
|
#include "GDCore/Extensions/Builtin/SpriteExtension/Point.h"
|
||||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
|
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
|
||||||
#include "GDCore/String.h"
|
#include "GDCore/String.h"
|
||||||
class SFMLTextureWrapper;
|
|
||||||
#undef LoadImage // prevent windows.h to be polluting everything
|
#undef LoadImage // prevent windows.h to be polluting everything
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
@@ -19,9 +18,6 @@ namespace gd {
|
|||||||
/**
|
/**
|
||||||
* \brief Represents a sprite to be displayed on the screen.
|
* \brief Represents a sprite to be displayed on the screen.
|
||||||
*
|
*
|
||||||
* A sprite contains a SFML sprite to be displayed, some points,
|
|
||||||
* and can also have its own texture (rather than a texture from ImageManager).
|
|
||||||
*
|
|
||||||
* \see Direction
|
* \see Direction
|
||||||
* \see SpriteObject
|
* \see SpriteObject
|
||||||
* \ingroup SpriteObjectExtension
|
* \ingroup SpriteObjectExtension
|
||||||
@@ -163,53 +159,7 @@ class GD_CORE_API Sprite {
|
|||||||
*/
|
*/
|
||||||
bool SetDefaultCenterPoint(bool enabled);
|
bool SetDefaultCenterPoint(bool enabled);
|
||||||
|
|
||||||
#if !defined(EMSCRIPTEN)
|
|
||||||
/** \name Sprite runtime management
|
|
||||||
* Functions used by the C++ game engine.
|
|
||||||
*/
|
|
||||||
///@{
|
|
||||||
/**
|
|
||||||
* \brief Get the SFML sprite associated with the sprite
|
|
||||||
*/
|
|
||||||
inline const sf::Sprite& GetSFMLSprite() const { return sfmlSprite; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get the SFML sprite associated with the sprite
|
|
||||||
*/
|
|
||||||
inline sf::Sprite& GetSFMLSprite() { return sfmlSprite; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the SFML texture of the sprite
|
|
||||||
*/
|
|
||||||
void LoadImage(std::shared_ptr<SFMLTextureWrapper> image);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get SFML texture used by the sprite
|
|
||||||
*/
|
|
||||||
std::shared_ptr<SFMLTextureWrapper> GetSFMLTexture() { return sfmlImage; };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Get SFML texture used by the sprite
|
|
||||||
*/
|
|
||||||
const std::shared_ptr<SFMLTextureWrapper> GetSFMLTexture() const {
|
|
||||||
return sfmlImage;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Make the sprite, if it uses a texture from ImageManager,
|
|
||||||
* copy this texture and take ownership of it.
|
|
||||||
*/
|
|
||||||
void MakeSpriteOwnsItsImage();
|
|
||||||
///@}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if !defined(EMSCRIPTEN)
|
|
||||||
sf::Sprite sfmlSprite; ///< Displayed SFML sprite
|
|
||||||
std::shared_ptr<SFMLTextureWrapper>
|
|
||||||
sfmlImage; ///< Pointer to the image displayed by the sprite.
|
|
||||||
bool hasItsOwnImage; ///< True if sfmlImage is only owned by this Sprite.
|
|
||||||
#endif
|
|
||||||
gd::String image; ///< Name of the image to be loaded in Image Manager.
|
gd::String image; ///< Name of the image to be loaded in Image Manager.
|
||||||
|
|
||||||
bool automaticCollisionMask; ///< True to use the custom collision mask.
|
bool automaticCollisionMask; ///< True to use the custom collision mask.
|
||||||
|
@@ -29,7 +29,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
|||||||
_("Animated object which can be used for most elements of a game"),
|
_("Animated object which can be used for most elements of a game"),
|
||||||
"CppPlatform/Extensions/spriteicon.png");
|
"CppPlatform/Extensions/spriteicon.png");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
obj.AddAction("Opacity",
|
obj.AddAction("Opacity",
|
||||||
_("Change sprite opacity"),
|
_("Change sprite opacity"),
|
||||||
_("Change the opacity of a Sprite. 0 is fully transparent, 255 "
|
_("Change the opacity of a Sprite. 0 is fully transparent, 255 "
|
||||||
@@ -79,7 +78,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
|||||||
_("Direction"),
|
_("Direction"),
|
||||||
"res/actions/direction24.png",
|
"res/actions/direction24.png",
|
||||||
"res/actions/direction.png")
|
"res/actions/direction.png")
|
||||||
|
.SetHidden() // Hide as 8 direction is not supported officially in the interface.
|
||||||
.AddParameter("object", _("Object"), "Sprite")
|
.AddParameter("object", _("Object"), "Sprite")
|
||||||
.UseStandardOperatorParameters("number")
|
.UseStandardOperatorParameters("number")
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
@@ -243,7 +242,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
|||||||
_("Direction"),
|
_("Direction"),
|
||||||
"res/conditions/direction24.png",
|
"res/conditions/direction24.png",
|
||||||
"res/conditions/direction.png")
|
"res/conditions/direction.png")
|
||||||
|
.SetHidden() // Hide as 8 direction is not supported officially in the interface.
|
||||||
.AddParameter("object", _("Object"), "Sprite")
|
.AddParameter("object", _("Object"), "Sprite")
|
||||||
.UseStandardRelationalOperatorParameters("number");
|
.UseStandardRelationalOperatorParameters("number");
|
||||||
|
|
||||||
@@ -334,39 +333,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
|||||||
.UseStandardRelationalOperatorParameters("number")
|
.UseStandardRelationalOperatorParameters("number")
|
||||||
.MarkAsAdvanced();
|
.MarkAsAdvanced();
|
||||||
|
|
||||||
obj.AddAction("CopyImageOnImageOfSprite",
|
|
||||||
_("Copy an image on the current one of an object"),
|
|
||||||
_("Copy an image on the current image of an object.\nNote that "
|
|
||||||
"the source image must be preferably kept loaded in memory."),
|
|
||||||
_("Copy image _PARAM2_ on the current of _PARAM0_ at "
|
|
||||||
"_PARAM3_;_PARAM4_"),
|
|
||||||
_("Effects"),
|
|
||||||
"res/copy24.png",
|
|
||||||
"res/copyicon.png")
|
|
||||||
|
|
||||||
.AddParameter("object", _("Object"), "Sprite")
|
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
|
||||||
.AddParameter("string", _("Name of the source image"))
|
|
||||||
.AddParameter("expression", _("X position"))
|
|
||||||
.AddParameter("expression", _("Y position"))
|
|
||||||
.AddParameter(
|
|
||||||
"yesorno",
|
|
||||||
_("Should the copy take in account the source transparency\?"));
|
|
||||||
|
|
||||||
obj.AddAction(
|
|
||||||
"CreateMaskFromColorOnActualImage", // Actual is indeed a mistake :
|
|
||||||
// Current should have been
|
|
||||||
// chosen.
|
|
||||||
_("Make a color of the image of an object transparent"),
|
|
||||||
_("Make a color of the image of an object transparent."),
|
|
||||||
_("Make color _PARAM1_ of the current image of _PARAM0_ transparent"),
|
|
||||||
_("Effects"),
|
|
||||||
"res/actions/opacity24.png",
|
|
||||||
"res/actions/opacity.png")
|
|
||||||
|
|
||||||
.AddParameter("object", _("Object"), "Sprite")
|
|
||||||
.AddParameter("color", _("Color to make transparent"));
|
|
||||||
|
|
||||||
obj.AddAction("ChangeColor",
|
obj.AddAction("ChangeColor",
|
||||||
_("Tint color"),
|
_("Tint color"),
|
||||||
_("Change the tint of an object. The default color is white."),
|
_("Change the tint of an object. The default color is white."),
|
||||||
@@ -498,6 +464,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
|||||||
_("Direction of the object"),
|
_("Direction of the object"),
|
||||||
_("Direction"),
|
_("Direction"),
|
||||||
"res/actions/direction.png")
|
"res/actions/direction.png")
|
||||||
|
.SetHidden() // Hide as 8 direction is not supported officially in the interface.
|
||||||
.AddParameter("object", _("Object"), "Sprite");
|
.AddParameter("object", _("Object"), "Sprite");
|
||||||
|
|
||||||
obj.AddExpression("Anim",
|
obj.AddExpression("Anim",
|
||||||
@@ -569,7 +536,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
|||||||
.AddParameter("objectList", _("Object 1"), "Sprite")
|
.AddParameter("objectList", _("Object 1"), "Sprite")
|
||||||
.AddParameter("objectList", _("Object 2"), "Sprite")
|
.AddParameter("objectList", _("Object 2"), "Sprite")
|
||||||
.AddCodeOnlyParameter("conditionInverted", "");
|
.AddCodeOnlyParameter("conditionInverted", "");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Direction.h"
|
#include "GDCore/Extensions/Builtin/SpriteExtension/Direction.h"
|
||||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Sprite.h"
|
#include "GDCore/Extensions/Builtin/SpriteExtension/Sprite.h"
|
||||||
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
|
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
|
||||||
#include "GDCore/Project/ImageManager.h"
|
|
||||||
#include "GDCore/Project/InitialInstance.h"
|
#include "GDCore/Project/InitialInstance.h"
|
||||||
#include "GDCore/Project/Layout.h"
|
#include "GDCore/Project/Layout.h"
|
||||||
#include "GDCore/Project/Object.h"
|
#include "GDCore/Project/Object.h"
|
||||||
@@ -18,11 +17,9 @@
|
|||||||
#include "GDCore/Serialization/SerializerElement.h"
|
#include "GDCore/Serialization/SerializerElement.h"
|
||||||
#include "GDCore/Tools/Localization.h"
|
#include "GDCore/Tools/Localization.h"
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include "GDCore/Project/PropertyDescriptor.h"
|
#include "GDCore/Project/PropertyDescriptor.h"
|
||||||
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
|
|
||||||
@@ -82,7 +79,6 @@ void SpriteObject::DoUnserializeFrom(gd::Project& project,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
void SpriteObject::DoSerializeTo(gd::SerializerElement& element) const {
|
void SpriteObject::DoSerializeTo(gd::SerializerElement& element) const {
|
||||||
element.SetAttribute("updateIfNotVisible", updateIfNotVisible);
|
element.SetAttribute("updateIfNotVisible", updateIfNotVisible);
|
||||||
|
|
||||||
@@ -158,7 +154,6 @@ bool SpriteObject::UpdateInitialInstanceProperty(gd::InitialInstance& position,
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
const Animation& SpriteObject::GetAnimation(std::size_t nb) const {
|
const Animation& SpriteObject::GetAnimation(std::size_t nb) const {
|
||||||
if (nb >= animations.size()) return badAnimation;
|
if (nb >= animations.size()) return badAnimation;
|
||||||
|
@@ -16,7 +16,6 @@ class Object;
|
|||||||
class Layout;
|
class Layout;
|
||||||
class Sprite;
|
class Sprite;
|
||||||
class Animation;
|
class Animation;
|
||||||
class MainFrameWrapper;
|
|
||||||
class SerializerElement;
|
class SerializerElement;
|
||||||
class PropertyDescriptor;
|
class PropertyDescriptor;
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
@@ -45,7 +44,6 @@ class GD_CORE_API SpriteObject : public gd::Object {
|
|||||||
return gd::make_unique<SpriteObject>(*this);
|
return gd::make_unique<SpriteObject>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
void ExposeResources(gd::ArbitraryResourceWorker& worker) override;
|
void ExposeResources(gd::ArbitraryResourceWorker& worker) override;
|
||||||
|
|
||||||
std::map<gd::String, gd::PropertyDescriptor> GetProperties() const override;
|
std::map<gd::String, gd::PropertyDescriptor> GetProperties() const override;
|
||||||
@@ -61,7 +59,6 @@ class GD_CORE_API SpriteObject : public gd::Object {
|
|||||||
const gd::String& value,
|
const gd::String& value,
|
||||||
gd::Project& project,
|
gd::Project& project,
|
||||||
gd::Layout& scene) override;
|
gd::Layout& scene) override;
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \name Animations
|
/** \name Animations
|
||||||
* Methods related to animations management
|
* Methods related to animations management
|
||||||
@@ -119,14 +116,24 @@ class GD_CORE_API SpriteObject : public gd::Object {
|
|||||||
* animation of the object.
|
* animation of the object.
|
||||||
*/
|
*/
|
||||||
const std::vector<Animation>& GetAllAnimations() const { return animations; }
|
const std::vector<Animation>& GetAllAnimations() const { return animations; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set if the object animation should be played even if the object is hidden
|
||||||
|
* or far from the camera.
|
||||||
|
*/
|
||||||
|
void SetUpdateIfNotVisible(bool updateIfNotVisible_) { updateIfNotVisible = updateIfNotVisible_; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Check if the object animation should be played even if the object is hidden
|
||||||
|
* or far from the camera (false by default).
|
||||||
|
*/
|
||||||
|
bool GetUpdateIfNotVisible() const { return updateIfNotVisible; }
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DoUnserializeFrom(gd::Project& project,
|
void DoUnserializeFrom(gd::Project& project,
|
||||||
const gd::SerializerElement& element) override;
|
const gd::SerializerElement& element) override;
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
void DoSerializeTo(gd::SerializerElement& element) const override;
|
void DoSerializeTo(gd::SerializerElement& element) const override;
|
||||||
#endif
|
|
||||||
|
|
||||||
mutable std::vector<Animation> animations;
|
mutable std::vector<Animation> animations;
|
||||||
bool updateIfNotVisible; ///< If set to true, ask the game engine to play
|
bool updateIfNotVisible; ///< If set to true, ask the game engine to play
|
||||||
|
@@ -21,7 +21,6 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension.AddStrExpression("NewLine",
|
extension.AddStrExpression("NewLine",
|
||||||
_("Insert a new line"),
|
_("Insert a new line"),
|
||||||
_("Insert a new line"),
|
_("Insert a new line"),
|
||||||
@@ -182,7 +181,6 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
|||||||
_("Position of the last character in the string to be "
|
_("Position of the last character in the string to be "
|
||||||
"considered in the search"));
|
"considered in the search"));
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -22,7 +22,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/timers");
|
.SetExtensionHelpPath("/all-features/timers");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddCondition("Timer",
|
.AddCondition("Timer",
|
||||||
@@ -39,8 +38,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
|||||||
extension
|
extension
|
||||||
.AddCondition("TimeScale",
|
.AddCondition("TimeScale",
|
||||||
_("Time scale"),
|
_("Time scale"),
|
||||||
_("Test the time scale."),
|
_("Compare the time scale of the scene."),
|
||||||
_("the time scale"),
|
_("the time scale of the scene"),
|
||||||
_("Timers and time"),
|
_("Timers and time"),
|
||||||
"res/conditions/time24.png",
|
"res/conditions/time24.png",
|
||||||
"res/conditions/time.png")
|
"res/conditions/time.png")
|
||||||
@@ -112,8 +111,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
|||||||
extension
|
extension
|
||||||
.AddAction("ChangeTimeScale",
|
.AddAction("ChangeTimeScale",
|
||||||
_("Change time scale"),
|
_("Change time scale"),
|
||||||
_("Change the time scale of the game."),
|
_("Change the time scale of the scene."),
|
||||||
_("Set time scale to _PARAM1_"),
|
_("Set the time scale of the scene to _PARAM1_"),
|
||||||
_("Timers and time"),
|
_("Timers and time"),
|
||||||
"res/actions/time24.png",
|
"res/actions/time24.png",
|
||||||
"res/actions/time.png")
|
"res/actions/time.png")
|
||||||
@@ -176,20 +175,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
|||||||
extension
|
extension
|
||||||
.AddExpression("TimeScale",
|
.AddExpression("TimeScale",
|
||||||
_("Time scale"),
|
_("Time scale"),
|
||||||
_("Time scale"),
|
_("Returns the time scale of the scene."),
|
||||||
_("Time"),
|
_("Time"),
|
||||||
"res/actions/time.png")
|
"res/actions/time.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "");
|
.AddCodeOnlyParameter("currentScene", "");
|
||||||
|
|
||||||
extension
|
|
||||||
.AddExpression("TimeScale",
|
|
||||||
_("Time scale"),
|
|
||||||
_("Time scale"),
|
|
||||||
_("Time"),
|
|
||||||
"res/actions/time.png")
|
|
||||||
.SetHidden()
|
|
||||||
.AddCodeOnlyParameter("currentScene", "");
|
|
||||||
|
|
||||||
extension
|
extension
|
||||||
.AddExpression("Time",
|
.AddExpression("Time",
|
||||||
_("Current time"),
|
_("Current time"),
|
||||||
@@ -206,7 +196,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
|||||||
"[\"hour\", \"min\", \"sec\", \"mon\", \"year\", \"wday\", \"mday\", "
|
"[\"hour\", \"min\", \"sec\", \"mon\", \"year\", \"wday\", \"mday\", "
|
||||||
"\"yday\", \"timestamp\"]");
|
"\"yday\", \"timestamp\"]");
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -23,13 +23,12 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/variables");
|
.SetExtensionHelpPath("/all-features/variables");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddCondition("VarScene",
|
.AddCondition("VarScene",
|
||||||
_("Value of a scene variable"),
|
_("Value of a scene variable"),
|
||||||
_("Compare the value of a scene variable."),
|
_("Compare the value of a scene variable."),
|
||||||
_("the scene variable _PARAM0_"),
|
_("the scene variable _PARAM0_"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/conditions/var24.png",
|
"res/conditions/var24.png",
|
||||||
"res/conditions/var.png")
|
"res/conditions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -40,7 +39,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Text of a scene variable"),
|
_("Text of a scene variable"),
|
||||||
_("Compare the text of a scene variable."),
|
_("Compare the text of a scene variable."),
|
||||||
_("the text of scene variable _PARAM0_"),
|
_("the text of scene variable _PARAM0_"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/conditions/var24.png",
|
"res/conditions/var24.png",
|
||||||
"res/conditions/var.png")
|
"res/conditions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -52,7 +51,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Boolean value of a scene variable"),
|
_("Boolean value of a scene variable"),
|
||||||
_("Compare the boolean value of a scene variable."),
|
_("Compare the boolean value of a scene variable."),
|
||||||
_("The boolean value of scene variable _PARAM0_ is _PARAM1_"),
|
_("The boolean value of scene variable _PARAM0_ is _PARAM1_"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/conditions/var24.png",
|
"res/conditions/var24.png",
|
||||||
"res/conditions/var.png")
|
"res/conditions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -65,7 +64,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Child existence"),
|
_("Child existence"),
|
||||||
_("Check if the specified child of the scene variable exists."),
|
_("Check if the specified child of the scene variable exists."),
|
||||||
_("Child _PARAM1_ of scene variable _PARAM0_ exists"),
|
_("Child _PARAM1_ of scene variable _PARAM0_ exists"),
|
||||||
_("Variables/Collections/Structures"),
|
_("Variables/Scene variables/Collections/Structures"),
|
||||||
"res/conditions/var24.png",
|
"res/conditions/var24.png",
|
||||||
"res/conditions/var.png")
|
"res/conditions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -90,7 +89,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
"Test if a scene variable is defined",
|
"Test if a scene variable is defined",
|
||||||
"Test if the scene variable exists.",
|
"Test if the scene variable exists.",
|
||||||
"Scene variable _PARAM0_ is defined",
|
"Scene variable _PARAM0_ is defined",
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/conditions/var24.png",
|
"res/conditions/var24.png",
|
||||||
"res/conditions/var.png")
|
"res/conditions/var.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "")
|
.AddCodeOnlyParameter("currentScene", "")
|
||||||
@@ -152,7 +151,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Value of a scene variable"),
|
_("Value of a scene variable"),
|
||||||
_("Change the value of a scene variable."),
|
_("Change the value of a scene variable."),
|
||||||
_("the scene variable _PARAM0_"),
|
_("the scene variable _PARAM0_"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -163,7 +162,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("String of a scene variable"),
|
_("String of a scene variable"),
|
||||||
_("Modify the text of a scene variable."),
|
_("Modify the text of a scene variable."),
|
||||||
_("the text of scene variable _PARAM0_"),
|
_("the text of scene variable _PARAM0_"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -175,7 +174,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Boolean value of a scene variable"),
|
_("Boolean value of a scene variable"),
|
||||||
_("Modify the boolean value of a scene variable."),
|
_("Modify the boolean value of a scene variable."),
|
||||||
_("Set the boolean value of scene variable _PARAM0_ to _PARAM1_"),
|
_("Set the boolean value of scene variable _PARAM0_ to _PARAM1_"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/conditions/var24.png",
|
"res/conditions/var24.png",
|
||||||
"res/conditions/var.png")
|
"res/conditions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -188,7 +187,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("If it was true, it will become false, and if it was "
|
_("If it was true, it will become false, and if it was "
|
||||||
"false it will become true."),
|
"false it will become true."),
|
||||||
_("Toggle the boolean value of scene variable _PARAM0_"),
|
_("Toggle the boolean value of scene variable _PARAM0_"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/conditions/var24.png",
|
"res/conditions/var24.png",
|
||||||
"res/conditions/var.png")
|
"res/conditions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"));
|
.AddParameter("scenevar", _("Variable"));
|
||||||
@@ -246,7 +245,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Remove a child"),
|
_("Remove a child"),
|
||||||
_("Remove a child from a scene variable."),
|
_("Remove a child from a scene variable."),
|
||||||
_("Remove child _PARAM1_ from scene variable _PARAM0_"),
|
_("Remove child _PARAM1_ from scene variable _PARAM0_"),
|
||||||
_("Variables/Collections/Structures"),
|
_("Variables/Scene variables/Collections/Structures"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -270,7 +269,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Clear scene variable"),
|
_("Clear scene variable"),
|
||||||
_("Remove all the children from the scene variable."),
|
_("Remove all the children from the scene variable."),
|
||||||
_("Clear children from scene variable _PARAM0_"),
|
_("Clear children from scene variable _PARAM0_"),
|
||||||
_("Variables/Collections"),
|
_("Variables/Scene variables/Collections"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -292,7 +291,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Append variable to a scene array"),
|
_("Append variable to a scene array"),
|
||||||
_("Appends a variable at the end of a scene array variable."),
|
_("Appends a variable at the end of a scene array variable."),
|
||||||
_("Append variable _PARAM1_ to array variable _PARAM0_"),
|
_("Append variable _PARAM1_ to array variable _PARAM0_"),
|
||||||
_("Variables/Collections/Arrays"),
|
_("Variables/Scene variables/Collections/Arrays"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Array variable"))
|
.AddParameter("scenevar", _("Array variable"))
|
||||||
@@ -305,7 +304,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Append a string to a scene array"),
|
_("Append a string to a scene array"),
|
||||||
_("Appends a string at the end of a scene array variable."),
|
_("Appends a string at the end of a scene array variable."),
|
||||||
_("Append string _PARAM1_ to array variable _PARAM0_"),
|
_("Append string _PARAM1_ to array variable _PARAM0_"),
|
||||||
_("Variables/Collections/Arrays"),
|
_("Variables/Scene variables/Collections/Arrays"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Array variable"))
|
.AddParameter("scenevar", _("Array variable"))
|
||||||
@@ -317,7 +316,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Append a number to a scene array"),
|
_("Append a number to a scene array"),
|
||||||
_("Appends a number at the end of a scene array variable."),
|
_("Appends a number at the end of a scene array variable."),
|
||||||
_("Append number _PARAM1_ to array variable _PARAM0_"),
|
_("Append number _PARAM1_ to array variable _PARAM0_"),
|
||||||
_("Variables/Collections/Arrays"),
|
_("Variables/Scene variables/Collections/Arrays"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Array variable"))
|
.AddParameter("scenevar", _("Array variable"))
|
||||||
@@ -329,7 +328,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Append a boolean to a scene array"),
|
_("Append a boolean to a scene array"),
|
||||||
_("Appends a boolean at the end of a scene array variable."),
|
_("Appends a boolean at the end of a scene array variable."),
|
||||||
_("Append boolean _PARAM1_ to array variable _PARAM0_"),
|
_("Append boolean _PARAM1_ to array variable _PARAM0_"),
|
||||||
_("Variables/Collections/Arrays"),
|
_("Variables/Scene variables/Collections/Arrays"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Array variable"))
|
.AddParameter("scenevar", _("Array variable"))
|
||||||
@@ -342,7 +341,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
_("Remove variable from a scene array (by index)"),
|
_("Remove variable from a scene array (by index)"),
|
||||||
_("Removes a variable at the specified index of a scene array variable."),
|
_("Removes a variable at the specified index of a scene array variable."),
|
||||||
_("Remove variable at index _PARAM1_ from scene array variable _PARAM0_"),
|
_("Remove variable at index _PARAM1_ from scene array variable _PARAM0_"),
|
||||||
_("Variables/Collections/Arrays"),
|
_("Variables/Scene variables/Collections/Arrays"),
|
||||||
"res/actions/var24.png",
|
"res/actions/var24.png",
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"))
|
.AddParameter("scenevar", _("Variable"))
|
||||||
@@ -415,7 +414,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
.AddExpression("GlobalVariableChildCount",
|
.AddExpression("GlobalVariableChildCount",
|
||||||
_("Number of children of a global variable"),
|
_("Number of children of a global variable"),
|
||||||
_("Number of children of a global variable"),
|
_("Number of children of a global variable"),
|
||||||
_("Variables"),
|
_("Variables/Global variables"),
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("globalvar", _("Variable"));
|
.AddParameter("globalvar", _("Variable"));
|
||||||
|
|
||||||
@@ -423,7 +422,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
.AddExpression("VariableChildCount",
|
.AddExpression("VariableChildCount",
|
||||||
_("Number of children of a scene variable"),
|
_("Number of children of a scene variable"),
|
||||||
_("Number of children of a scene variable"),
|
_("Number of children of a scene variable"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"));
|
.AddParameter("scenevar", _("Variable"));
|
||||||
|
|
||||||
@@ -431,7 +430,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
.AddExpression("Variable",
|
.AddExpression("Variable",
|
||||||
_("Value of a scene variable"),
|
_("Value of a scene variable"),
|
||||||
_("Value of a scene variable"),
|
_("Value of a scene variable"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"));
|
.AddParameter("scenevar", _("Variable"));
|
||||||
|
|
||||||
@@ -439,7 +438,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
.AddStrExpression("VariableString",
|
.AddStrExpression("VariableString",
|
||||||
_("Text of a scene variable"),
|
_("Text of a scene variable"),
|
||||||
_("Text of a scene variable"),
|
_("Text of a scene variable"),
|
||||||
_("Variables"),
|
_("Variables/Scene variables"),
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("scenevar", _("Variable"));
|
.AddParameter("scenevar", _("Variable"));
|
||||||
|
|
||||||
@@ -447,7 +446,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
.AddExpression("GlobalVariable",
|
.AddExpression("GlobalVariable",
|
||||||
_("Value of a global variable"),
|
_("Value of a global variable"),
|
||||||
_("Value of a global variable"),
|
_("Value of a global variable"),
|
||||||
_("Variables"),
|
_("Variables/Global variables"),
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("globalvar", _("Name of the global variable"));
|
.AddParameter("globalvar", _("Name of the global variable"));
|
||||||
|
|
||||||
@@ -455,10 +454,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
|||||||
.AddStrExpression("GlobalVariableString",
|
.AddStrExpression("GlobalVariableString",
|
||||||
_("Text of a global variable"),
|
_("Text of a global variable"),
|
||||||
_("Text of a global variable"),
|
_("Text of a global variable"),
|
||||||
_("Variables"),
|
_("Variables/Global variables"),
|
||||||
"res/actions/var.png")
|
"res/actions/var.png")
|
||||||
.AddParameter("globalvar", _("Variable"));
|
.AddParameter("globalvar", _("Variable"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -22,7 +22,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
|||||||
"Open source (MIT License)")
|
"Open source (MIT License)")
|
||||||
.SetExtensionHelpPath("/all-features/window");
|
.SetExtensionHelpPath("/all-features/window");
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
extension
|
extension
|
||||||
.AddAction(
|
.AddAction(
|
||||||
"SetFullScreen",
|
"SetFullScreen",
|
||||||
@@ -215,7 +214,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
|||||||
_("Screen"),
|
_("Screen"),
|
||||||
"res/window.png")
|
"res/window.png")
|
||||||
.AddCodeOnlyParameter("currentScene", "");
|
.AddCodeOnlyParameter("currentScene", "");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -275,6 +275,76 @@ BehaviorMetadata::AddExpressionAndConditionAndAction(
|
|||||||
expression, condition, action);
|
expression, condition, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(GD_IDE_ONLY)
|
||||||
|
gd::InstructionMetadata& BehaviorMetadata::AddDuplicatedAction(
|
||||||
|
const gd::String& newActionName, const gd::String& copiedActionName) {
|
||||||
|
gd::String newNameWithNamespace = extensionNamespace + newActionName;
|
||||||
|
gd::String copiedNameWithNamespace = extensionNamespace + copiedActionName;
|
||||||
|
|
||||||
|
auto copiedAction = actionsInfos.find(copiedNameWithNamespace);
|
||||||
|
if (copiedAction == actionsInfos.end()) {
|
||||||
|
gd::LogWarning("Could not find an action with name " +
|
||||||
|
copiedNameWithNamespace + " to copy.");
|
||||||
|
} else {
|
||||||
|
actionsInfos[newNameWithNamespace] = copiedAction->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionsInfos[newNameWithNamespace];
|
||||||
|
}
|
||||||
|
|
||||||
|
gd::InstructionMetadata& BehaviorMetadata::AddDuplicatedCondition(
|
||||||
|
const gd::String& newConditionName, const gd::String& copiedConditionName) {
|
||||||
|
gd::String newNameWithNamespace = extensionNamespace + newConditionName;
|
||||||
|
gd::String copiedNameWithNamespace = extensionNamespace + copiedConditionName;
|
||||||
|
|
||||||
|
auto copiedCondition = conditionsInfos.find(copiedNameWithNamespace);
|
||||||
|
if (copiedCondition == conditionsInfos.end()) {
|
||||||
|
gd::LogWarning("Could not find a condition with name " +
|
||||||
|
copiedNameWithNamespace + " to copy.");
|
||||||
|
} else {
|
||||||
|
conditionsInfos[newNameWithNamespace] = copiedCondition->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return conditionsInfos[newNameWithNamespace];
|
||||||
|
}
|
||||||
|
|
||||||
|
gd::ExpressionMetadata& BehaviorMetadata::AddDuplicatedExpression(
|
||||||
|
const gd::String& newExpressionName,
|
||||||
|
const gd::String& copiedExpressionName) {
|
||||||
|
gd::String newNameWithNamespace = extensionNamespace + newExpressionName;
|
||||||
|
gd::String copiedNameWithNamespace =
|
||||||
|
extensionNamespace + copiedExpressionName;
|
||||||
|
|
||||||
|
auto copiedExpression = expressionsInfos.find(copiedNameWithNamespace);
|
||||||
|
if (copiedExpression == expressionsInfos.end()) {
|
||||||
|
gd::LogWarning("Could not find an expression with name " +
|
||||||
|
copiedNameWithNamespace + " to copy.");
|
||||||
|
} else {
|
||||||
|
expressionsInfos[newNameWithNamespace] = copiedExpression->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return expressionsInfos[newNameWithNamespace];
|
||||||
|
}
|
||||||
|
|
||||||
|
gd::ExpressionMetadata& BehaviorMetadata::AddDuplicatedStrExpression(
|
||||||
|
const gd::String& newExpressionName,
|
||||||
|
const gd::String& copiedExpressionName) {
|
||||||
|
gd::String newNameWithNamespace = extensionNamespace + newExpressionName;
|
||||||
|
gd::String copiedNameWithNamespace =
|
||||||
|
extensionNamespace + copiedExpressionName;
|
||||||
|
|
||||||
|
auto copiedExpression = strExpressionsInfos.find(copiedNameWithNamespace);
|
||||||
|
if (copiedExpression == strExpressionsInfos.end()) {
|
||||||
|
gd::LogWarning("Could not find a string expression with name " +
|
||||||
|
copiedNameWithNamespace + " to copy.");
|
||||||
|
} else {
|
||||||
|
strExpressionsInfos[newNameWithNamespace] = copiedExpression->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strExpressionsInfos[newNameWithNamespace];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
BehaviorMetadata& BehaviorMetadata::SetFullName(const gd::String& fullname_) {
|
BehaviorMetadata& BehaviorMetadata::SetFullName(const gd::String& fullname_) {
|
||||||
#if defined(GD_IDE_ONLY)
|
#if defined(GD_IDE_ONLY)
|
||||||
fullname = fullname_;
|
fullname = fullname_;
|
||||||
@@ -323,4 +393,14 @@ const gd::String& BehaviorMetadata::GetName() const {
|
|||||||
return instance->GetTypeName();
|
return instance->GetTypeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gd::Behavior& BehaviorMetadata::Get() const {
|
||||||
|
if (!instance)
|
||||||
|
gd::LogFatalError(
|
||||||
|
"Trying to get a behavior from a BehaviorMetadata that has no "
|
||||||
|
"behavior. This will crash - please double check that the "
|
||||||
|
"BehaviorMetadata is valid.");
|
||||||
|
|
||||||
|
return *instance;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -138,6 +138,46 @@ class GD_CORE_API BehaviorMetadata {
|
|||||||
const gd::String& group,
|
const gd::String& group,
|
||||||
const gd::String& icon);
|
const gd::String& icon);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Create a new action which is the duplicate of the specified one.
|
||||||
|
*
|
||||||
|
* Useful for handling a deprecated action that is just a "copy" of the new
|
||||||
|
* one.
|
||||||
|
*/
|
||||||
|
gd::InstructionMetadata& AddDuplicatedAction(
|
||||||
|
const gd::String& newActionName, const gd::String& copiedActionName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Create a new condition which is the duplicate of the specified one.
|
||||||
|
*
|
||||||
|
* Useful for handling a deprecated condition that is just a "copy" of the new
|
||||||
|
* one.
|
||||||
|
*/
|
||||||
|
gd::InstructionMetadata& AddDuplicatedCondition(
|
||||||
|
const gd::String& newConditionName,
|
||||||
|
const gd::String& copiedConditionName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Create a new expression which is the duplicate of the specified one.
|
||||||
|
*
|
||||||
|
* Useful for handling a deprecated expression that is just a "copy" of the
|
||||||
|
* new one.
|
||||||
|
*/
|
||||||
|
gd::ExpressionMetadata& AddDuplicatedExpression(
|
||||||
|
const gd::String& newExpressionName,
|
||||||
|
const gd::String& copiedExpressionName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Create a new string expression which is the duplicate of the
|
||||||
|
* specified one.
|
||||||
|
*
|
||||||
|
* Useful for handling a deprecated string expression that is just a "copy" of
|
||||||
|
* the new one.
|
||||||
|
*/
|
||||||
|
gd::ExpressionMetadata& AddDuplicatedStrExpression(
|
||||||
|
const gd::String& newExpressionName,
|
||||||
|
const gd::String& copiedExpressionName);
|
||||||
|
|
||||||
BehaviorMetadata& SetFullName(const gd::String& fullname_);
|
BehaviorMetadata& SetFullName(const gd::String& fullname_);
|
||||||
BehaviorMetadata& SetDefaultName(const gd::String& defaultName_);
|
BehaviorMetadata& SetDefaultName(const gd::String& defaultName_);
|
||||||
BehaviorMetadata& SetDescription(const gd::String& description_);
|
BehaviorMetadata& SetDescription(const gd::String& description_);
|
||||||
@@ -200,7 +240,7 @@ class GD_CORE_API BehaviorMetadata {
|
|||||||
/**
|
/**
|
||||||
* \brief Return the associated gd::Behavior, handling behavior contents.
|
* \brief Return the associated gd::Behavior, handling behavior contents.
|
||||||
*/
|
*/
|
||||||
gd::Behavior& Get() const { return *instance; }
|
gd::Behavior& Get() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return the associated gd::BehaviorsSharedData, handling behavior
|
* \brief Return the associated gd::BehaviorsSharedData, handling behavior
|
||||||
|
@@ -7,7 +7,8 @@
|
|||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
|
|
||||||
EffectMetadata::EffectMetadata(const gd::String& type_) : type(type_) {}
|
EffectMetadata::EffectMetadata(const gd::String& type_)
|
||||||
|
: type(type_), isMarkedAsNotWorkingForObjects(false) {}
|
||||||
|
|
||||||
EffectMetadata& EffectMetadata::SetIncludeFile(const gd::String& includeFile) {
|
EffectMetadata& EffectMetadata::SetIncludeFile(const gd::String& includeFile) {
|
||||||
includeFiles.clear();
|
includeFiles.clear();
|
||||||
@@ -22,4 +23,9 @@ EffectMetadata& EffectMetadata::AddIncludeFile(const gd::String& includeFile) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EffectMetadata& EffectMetadata::MarkAsNotWorkingForObjects() {
|
||||||
|
isMarkedAsNotWorkingForObjects = true;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "GDCore/Project/PropertyDescriptor.h"
|
#include "GDCore/Project/PropertyDescriptor.h"
|
||||||
#include "GDCore/String.h"
|
#include "GDCore/String.h"
|
||||||
|
|
||||||
@@ -49,7 +50,8 @@ class GD_CORE_API EffectMetadata {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the help path of the effect, relative to the GDevelop documentation root.
|
* Set the help path of the effect, relative to the GDevelop documentation
|
||||||
|
* root.
|
||||||
*/
|
*/
|
||||||
EffectMetadata& SetHelpPath(const gd::String& path) {
|
EffectMetadata& SetHelpPath(const gd::String& path) {
|
||||||
helpPath = path;
|
helpPath = path;
|
||||||
@@ -66,6 +68,11 @@ class GD_CORE_API EffectMetadata {
|
|||||||
*/
|
*/
|
||||||
EffectMetadata& AddIncludeFile(const gd::String& includeFile);
|
EffectMetadata& AddIncludeFile(const gd::String& includeFile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Mark the effect as not working as an object effect.
|
||||||
|
*/
|
||||||
|
EffectMetadata& MarkAsNotWorkingForObjects();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return a reference to the properties of this effect.
|
* \brief Return a reference to the properties of this effect.
|
||||||
*/
|
*/
|
||||||
@@ -81,12 +88,14 @@ class GD_CORE_API EffectMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the help path of the effect, relative to the GDevelop documentation root.
|
* \brief Get the help path of the effect, relative to the GDevelop
|
||||||
|
* documentation root.
|
||||||
*/
|
*/
|
||||||
const gd::String& GetHelpPath() const { return helpPath; }
|
const gd::String& GetHelpPath() const { return helpPath; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the type of the effect (its internal name, like "BlackAndWhite").
|
* \brief Get the type of the effect (its internal name, like
|
||||||
|
* "BlackAndWhite").
|
||||||
*/
|
*/
|
||||||
const gd::String& GetType() const { return type; }
|
const gd::String& GetType() const { return type; }
|
||||||
|
|
||||||
@@ -107,6 +116,11 @@ class GD_CORE_API EffectMetadata {
|
|||||||
return includeFiles;
|
return includeFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Check if the effect is marked as not working as an object effect.
|
||||||
|
*/
|
||||||
|
bool IsMarkedAsNotWorkingForObjects() const { return isMarkedAsNotWorkingForObjects; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gd::String extensionNamespace;
|
gd::String extensionNamespace;
|
||||||
gd::String type;
|
gd::String type;
|
||||||
@@ -114,6 +128,7 @@ class GD_CORE_API EffectMetadata {
|
|||||||
gd::String fullname;
|
gd::String fullname;
|
||||||
gd::String description;
|
gd::String description;
|
||||||
std::vector<gd::String> includeFiles;
|
std::vector<gd::String> includeFiles;
|
||||||
|
bool isMarkedAsNotWorkingForObjects;
|
||||||
std::map<gd::String, gd::PropertyDescriptor> properties;
|
std::map<gd::String, gd::PropertyDescriptor> properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@ ExpressionMetadata& ExpressionMetadata::SetHidden() {
|
|||||||
gd::ExpressionMetadata& ExpressionMetadata::AddParameter(
|
gd::ExpressionMetadata& ExpressionMetadata::AddParameter(
|
||||||
const gd::String& type,
|
const gd::String& type,
|
||||||
const gd::String& description,
|
const gd::String& description,
|
||||||
const gd::String& optionalObjectType,
|
const gd::String& supplementaryInformation,
|
||||||
bool parameterIsOptional) {
|
bool parameterIsOptional) {
|
||||||
gd::ParameterMetadata info;
|
gd::ParameterMetadata info;
|
||||||
info.type = type;
|
info.type = type;
|
||||||
@@ -46,15 +46,15 @@ gd::ExpressionMetadata& ExpressionMetadata::AddParameter(
|
|||||||
// parameter is an object/behavior type...
|
// parameter is an object/behavior type...
|
||||||
(gd::ParameterMetadata::IsObject(type) ||
|
(gd::ParameterMetadata::IsObject(type) ||
|
||||||
gd::ParameterMetadata::IsBehavior(type))
|
gd::ParameterMetadata::IsBehavior(type))
|
||||||
? (optionalObjectType.empty()
|
? (supplementaryInformation.empty()
|
||||||
? ""
|
? ""
|
||||||
: extensionNamespace +
|
: extensionNamespace +
|
||||||
optionalObjectType //... so prefix it with the extension
|
supplementaryInformation //... so prefix it with the extension
|
||||||
// namespace.
|
// namespace.
|
||||||
)
|
)
|
||||||
: optionalObjectType; // Otherwise don't change anything
|
: supplementaryInformation; // Otherwise don't change anything
|
||||||
|
|
||||||
// TODO: Assert against optionalObjectType === "emsc" (when running with
|
// TODO: Assert against supplementaryInformation === "emsc" (when running with
|
||||||
// Emscripten), and warn about a missing argument when calling addParameter.
|
// Emscripten), and warn about a missing argument when calling addParameter.
|
||||||
|
|
||||||
parameters.push_back(info);
|
parameters.push_back(info);
|
||||||
|
@@ -190,7 +190,7 @@ class GD_CORE_API ExpressionMetadata {
|
|||||||
gd::ExpressionMetadata& AddParameter(
|
gd::ExpressionMetadata& AddParameter(
|
||||||
const gd::String& type,
|
const gd::String& type,
|
||||||
const gd::String& description,
|
const gd::String& description,
|
||||||
const gd::String& optionalObjectType = "",
|
const gd::String& supplementaryInformation = "",
|
||||||
bool parameterIsOptional = false);
|
bool parameterIsOptional = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -51,7 +51,7 @@ InstructionMetadata::InstructionMetadata(const gd::String& extensionNamespace_,
|
|||||||
InstructionMetadata& InstructionMetadata::AddParameter(
|
InstructionMetadata& InstructionMetadata::AddParameter(
|
||||||
const gd::String& type,
|
const gd::String& type,
|
||||||
const gd::String& description,
|
const gd::String& description,
|
||||||
const gd::String& optionalObjectType,
|
const gd::String& supplementaryInformation,
|
||||||
bool parameterIsOptional) {
|
bool parameterIsOptional) {
|
||||||
ParameterMetadata info;
|
ParameterMetadata info;
|
||||||
info.type = type;
|
info.type = type;
|
||||||
@@ -63,15 +63,15 @@ InstructionMetadata& InstructionMetadata::AddParameter(
|
|||||||
// parameter is an object/behavior type...
|
// parameter is an object/behavior type...
|
||||||
(gd::ParameterMetadata::IsObject(type) ||
|
(gd::ParameterMetadata::IsObject(type) ||
|
||||||
gd::ParameterMetadata::IsBehavior(type))
|
gd::ParameterMetadata::IsBehavior(type))
|
||||||
? (optionalObjectType.empty()
|
? (supplementaryInformation.empty()
|
||||||
? ""
|
? ""
|
||||||
: extensionNamespace +
|
: extensionNamespace +
|
||||||
optionalObjectType //... so prefix it with the extension
|
supplementaryInformation //... so prefix it with the extension
|
||||||
// namespace.
|
// namespace.
|
||||||
)
|
)
|
||||||
: optionalObjectType; // Otherwise don't change anything
|
: supplementaryInformation; // Otherwise don't change anything
|
||||||
|
|
||||||
// TODO: Assert against optionalObjectType === "emsc" (when running with
|
// TODO: Assert against supplementaryInformation === "emsc" (when running with
|
||||||
// Emscripten), and warn about a missing argument when calling addParameter.
|
// Emscripten), and warn about a missing argument when calling addParameter.
|
||||||
|
|
||||||
parameters.push_back(info);
|
parameters.push_back(info);
|
||||||
@@ -93,7 +93,7 @@ InstructionMetadata& InstructionMetadata::UseStandardOperatorParameters(
|
|||||||
const gd::String& type) {
|
const gd::String& type) {
|
||||||
SetManipulatedType(type);
|
SetManipulatedType(type);
|
||||||
|
|
||||||
AddParameter("operator", _("Modification's sign"));
|
AddParameter("operator", _("Modification's sign"), type);
|
||||||
AddParameter(type == "number" ? "expression" : type, _("Value"));
|
AddParameter(type == "number" ? "expression" : type, _("Value"));
|
||||||
size_t operatorParamIndex = parameters.size() - 2;
|
size_t operatorParamIndex = parameters.size() - 2;
|
||||||
size_t valueParamIndex = parameters.size() - 1;
|
size_t valueParamIndex = parameters.size() - 1;
|
||||||
@@ -129,7 +129,7 @@ InstructionMetadata::UseStandardRelationalOperatorParameters(
|
|||||||
const gd::String& type) {
|
const gd::String& type) {
|
||||||
SetManipulatedType(type);
|
SetManipulatedType(type);
|
||||||
|
|
||||||
AddParameter("relationalOperator", _("Sign of the test"));
|
AddParameter("relationalOperator", _("Sign of the test"), type);
|
||||||
AddParameter(type == "number" ? "expression" : type, _("Value to compare"));
|
AddParameter(type == "number" ? "expression" : type, _("Value to compare"));
|
||||||
size_t operatorParamIndex = parameters.size() - 2;
|
size_t operatorParamIndex = parameters.size() - 2;
|
||||||
size_t valueParamIndex = parameters.size() - 1;
|
size_t valueParamIndex = parameters.size() - 1;
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#ifndef INSTRUCTIONMETADATA_H
|
#ifndef INSTRUCTIONMETADATA_H
|
||||||
#define INSTRUCTIONMETADATA_H
|
#define INSTRUCTIONMETADATA_H
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -137,8 +136,11 @@ class GD_CORE_API InstructionMetadata {
|
|||||||
* will also determine the type of the argument used when calling the function
|
* will also determine the type of the argument used when calling the function
|
||||||
* in the generated code.
|
* in the generated code.
|
||||||
* \param description Description for parameter
|
* \param description Description for parameter
|
||||||
* \param optionalObjectType If type is "object", this parameter will describe
|
* \param supplementaryInformation Additional information that can be used for
|
||||||
* which objects are allowed. If it is empty, all objects are allowed.
|
* rendering or logic. For example:
|
||||||
|
* - If type is "object", this argument will describe which objects are allowed.
|
||||||
|
* If this argument is empty, all objects are allowed.
|
||||||
|
* - If type is "operator", this argument will be used to display only pertinent operators.
|
||||||
* \param parameterIsOptional true if the parameter must be optional, false
|
* \param parameterIsOptional true if the parameter must be optional, false
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*
|
*
|
||||||
@@ -146,7 +148,7 @@ class GD_CORE_API InstructionMetadata {
|
|||||||
*/
|
*/
|
||||||
InstructionMetadata &AddParameter(const gd::String &type,
|
InstructionMetadata &AddParameter(const gd::String &type,
|
||||||
const gd::String &label,
|
const gd::String &label,
|
||||||
const gd::String &optionalObjectType = "",
|
const gd::String &supplementaryInformation = "",
|
||||||
bool parameterIsOptional = false);
|
bool parameterIsOptional = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,6 +189,19 @@ class GD_CORE_API InstructionMetadata {
|
|||||||
return *this;
|
return *this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the additional information, used for some parameters
|
||||||
|
* with special type (for example, it can contains the type of object accepted
|
||||||
|
* by the parameter), for the last added parameter.
|
||||||
|
*
|
||||||
|
* \see AddParameter
|
||||||
|
*/
|
||||||
|
InstructionMetadata &SetParameterExtraInfo(const gd::String &extraInfo) {
|
||||||
|
if (!parameters.empty())
|
||||||
|
parameters.back().SetExtraInfo(extraInfo);
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Add the default parameters for an instruction manipulating the
|
* \brief Add the default parameters for an instruction manipulating the
|
||||||
* specified type ("string", "number") with the default operators.
|
* specified type ("string", "number") with the default operators.
|
||||||
@@ -221,14 +236,14 @@ class GD_CORE_API InstructionMetadata {
|
|||||||
/**
|
/**
|
||||||
* \brief Check if the instruction is an object instruction.
|
* \brief Check if the instruction is an object instruction.
|
||||||
*/
|
*/
|
||||||
bool IsObjectInstruction() {
|
bool IsObjectInstruction() const {
|
||||||
return isObjectInstruction;
|
return isObjectInstruction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Check if the instruction is a behavior instruction.
|
* \brief Check if the instruction is a behavior instruction.
|
||||||
*/
|
*/
|
||||||
bool IsBehaviorInstruction() {
|
bool IsBehaviorInstruction() const {
|
||||||
return isBehaviorInstruction;
|
return isBehaviorInstruction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +321,7 @@ class GD_CORE_API InstructionMetadata {
|
|||||||
* "CppPlatform/Extensions/text.png");
|
* "CppPlatform/Extensions/text.png");
|
||||||
*
|
*
|
||||||
* .AddParameter("object", _("Object"), "Text", false)
|
* .AddParameter("object", _("Object"), "Text", false)
|
||||||
* .AddParameter("operator", _("Modification operator"))
|
* .AddParameter("operator", _("Modification operator"), "string")
|
||||||
* .AddParameter("string", _("String"))
|
* .AddParameter("string", _("String"))
|
||||||
* .SetFunctionName("SetString").SetManipulatedType("string").SetGetter("GetString").SetIncludeFile("MyExtension/TextObject.h");
|
* .SetFunctionName("SetString").SetManipulatedType("string").SetGetter("GetString").SetIncludeFile("MyExtension/TextObject.h");
|
||||||
*
|
*
|
||||||
@@ -439,5 +454,4 @@ class GD_CORE_API InstructionMetadata {
|
|||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif // INSTRUCTIONMETADATA_H
|
#endif // INSTRUCTIONMETADATA_H
|
||||||
|
@@ -245,6 +245,10 @@ class GD_CORE_API MetadataProvider {
|
|||||||
return &metadata == &badExpressionMetadata;
|
return &metadata == &badExpressionMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsBadInstructionMetadata(const gd::InstructionMetadata& metadata) {
|
||||||
|
return &metadata == &badInstructionMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
static bool IsBadBehaviorMetadata(const gd::BehaviorMetadata& metadata) {
|
static bool IsBadBehaviorMetadata(const gd::BehaviorMetadata& metadata) {
|
||||||
return &metadata == &badBehaviorMetadata;
|
return &metadata == &badBehaviorMetadata;
|
||||||
}
|
}
|
||||||
|
@@ -38,19 +38,17 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
MultipleInstructionMetadata &AddParameter(
|
MultipleInstructionMetadata &AddParameter(
|
||||||
const gd::String &type,
|
const gd::String &type,
|
||||||
const gd::String &label,
|
const gd::String &label,
|
||||||
const gd::String &optionalObjectType = "",
|
const gd::String &supplementaryInformation = "",
|
||||||
bool parameterIsOptional = false) {
|
bool parameterIsOptional = false) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression)
|
if (expression)
|
||||||
expression->AddParameter(
|
expression->AddParameter(
|
||||||
type, label, optionalObjectType, parameterIsOptional);
|
type, label, supplementaryInformation, parameterIsOptional);
|
||||||
if (condition)
|
if (condition)
|
||||||
condition->AddParameter(
|
condition->AddParameter(
|
||||||
type, label, optionalObjectType, parameterIsOptional);
|
type, label, supplementaryInformation, parameterIsOptional);
|
||||||
if (action)
|
if (action)
|
||||||
action->AddParameter(
|
action->AddParameter(
|
||||||
type, label, optionalObjectType, parameterIsOptional);
|
type, label, supplementaryInformation, parameterIsOptional);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,13 +57,11 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
*/
|
*/
|
||||||
MultipleInstructionMetadata &AddCodeOnlyParameter(
|
MultipleInstructionMetadata &AddCodeOnlyParameter(
|
||||||
const gd::String &type, const gd::String &supplementaryInformation) {
|
const gd::String &type, const gd::String &supplementaryInformation) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression)
|
if (expression)
|
||||||
expression->AddCodeOnlyParameter(type, supplementaryInformation);
|
expression->AddCodeOnlyParameter(type, supplementaryInformation);
|
||||||
if (condition)
|
if (condition)
|
||||||
condition->AddCodeOnlyParameter(type, supplementaryInformation);
|
condition->AddCodeOnlyParameter(type, supplementaryInformation);
|
||||||
if (action) action->AddCodeOnlyParameter(type, supplementaryInformation);
|
if (action) action->AddCodeOnlyParameter(type, supplementaryInformation);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,11 +69,9 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
* \see gd::InstructionMetadata::SetDefaultValue
|
* \see gd::InstructionMetadata::SetDefaultValue
|
||||||
*/
|
*/
|
||||||
MultipleInstructionMetadata &SetDefaultValue(const gd::String &defaultValue) {
|
MultipleInstructionMetadata &SetDefaultValue(const gd::String &defaultValue) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression) expression->SetDefaultValue(defaultValue);
|
if (expression) expression->SetDefaultValue(defaultValue);
|
||||||
if (condition) condition->SetDefaultValue(defaultValue);
|
if (condition) condition->SetDefaultValue(defaultValue);
|
||||||
if (action) action->SetDefaultValue(defaultValue);
|
if (action) action->SetDefaultValue(defaultValue);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -86,11 +80,9 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
*/
|
*/
|
||||||
MultipleInstructionMetadata &SetParameterLongDescription(
|
MultipleInstructionMetadata &SetParameterLongDescription(
|
||||||
const gd::String &longDescription) {
|
const gd::String &longDescription) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression) expression->SetParameterLongDescription(longDescription);
|
if (expression) expression->SetParameterLongDescription(longDescription);
|
||||||
if (condition) condition->SetParameterLongDescription(longDescription);
|
if (condition) condition->SetParameterLongDescription(longDescription);
|
||||||
if (action) action->SetParameterLongDescription(longDescription);
|
if (action) action->SetParameterLongDescription(longDescription);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -98,11 +90,9 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
* \see gd::InstructionMetadata::SetHidden
|
* \see gd::InstructionMetadata::SetHidden
|
||||||
*/
|
*/
|
||||||
MultipleInstructionMetadata &SetHidden() {
|
MultipleInstructionMetadata &SetHidden() {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression) expression->SetHidden();
|
if (expression) expression->SetHidden();
|
||||||
if (condition) condition->SetHidden();
|
if (condition) condition->SetHidden();
|
||||||
if (action) action->SetHidden();
|
if (action) action->SetHidden();
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,50 +101,40 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
* \see gd::InstructionMetadata::UseStandardRelationalOperatorParameters
|
* \see gd::InstructionMetadata::UseStandardRelationalOperatorParameters
|
||||||
*/
|
*/
|
||||||
MultipleInstructionMetadata &UseStandardParameters(const gd::String &type) {
|
MultipleInstructionMetadata &UseStandardParameters(const gd::String &type) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (condition) condition->UseStandardRelationalOperatorParameters(type);
|
if (condition) condition->UseStandardRelationalOperatorParameters(type);
|
||||||
if (action) action->UseStandardOperatorParameters(type);
|
if (action) action->UseStandardOperatorParameters(type);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MultipleInstructionMetadata &SetFunctionName(const gd::String &functionName) {
|
MultipleInstructionMetadata &SetFunctionName(const gd::String &functionName) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression) expression->SetFunctionName(functionName);
|
if (expression) expression->SetFunctionName(functionName);
|
||||||
if (condition) condition->SetFunctionName(functionName);
|
if (condition) condition->SetFunctionName(functionName);
|
||||||
if (action) action->GetCodeExtraInformation().SetFunctionName(functionName);
|
if (action) action->GetCodeExtraInformation().SetFunctionName(functionName);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MultipleInstructionMetadata &SetGetter(const gd::String &getter) {
|
MultipleInstructionMetadata &SetGetter(const gd::String &getter) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression) expression->SetFunctionName(getter);
|
if (expression) expression->SetFunctionName(getter);
|
||||||
if (condition) condition->SetFunctionName(getter);
|
if (condition) condition->SetFunctionName(getter);
|
||||||
if (action) action->GetCodeExtraInformation().SetGetter(getter);
|
if (action) action->GetCodeExtraInformation().SetGetter(getter);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MultipleInstructionMetadata &SetIncludeFile(const gd::String &includeFile) {
|
MultipleInstructionMetadata &SetIncludeFile(const gd::String &includeFile) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression)
|
if (expression)
|
||||||
expression->GetCodeExtraInformation().SetIncludeFile(includeFile);
|
expression->GetCodeExtraInformation().SetIncludeFile(includeFile);
|
||||||
if (condition)
|
if (condition)
|
||||||
condition->GetCodeExtraInformation().SetIncludeFile(includeFile);
|
condition->GetCodeExtraInformation().SetIncludeFile(includeFile);
|
||||||
if (action) action->GetCodeExtraInformation().SetIncludeFile(includeFile);
|
if (action) action->GetCodeExtraInformation().SetIncludeFile(includeFile);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MultipleInstructionMetadata &AddIncludeFile(const gd::String &includeFile) {
|
MultipleInstructionMetadata &AddIncludeFile(const gd::String &includeFile) {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (expression)
|
if (expression)
|
||||||
expression->GetCodeExtraInformation().AddIncludeFile(includeFile);
|
expression->GetCodeExtraInformation().AddIncludeFile(includeFile);
|
||||||
if (condition)
|
if (condition)
|
||||||
condition->GetCodeExtraInformation().AddIncludeFile(includeFile);
|
condition->GetCodeExtraInformation().AddIncludeFile(includeFile);
|
||||||
if (action) action->GetCodeExtraInformation().AddIncludeFile(includeFile);
|
if (action) action->GetCodeExtraInformation().AddIncludeFile(includeFile);
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,10 +142,8 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
* \see gd::InstructionMetadata::MarkAsSimple
|
* \see gd::InstructionMetadata::MarkAsSimple
|
||||||
*/
|
*/
|
||||||
MultipleInstructionMetadata &MarkAsSimple() {
|
MultipleInstructionMetadata &MarkAsSimple() {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (condition) condition->MarkAsSimple();
|
if (condition) condition->MarkAsSimple();
|
||||||
if (action) action->MarkAsSimple();
|
if (action) action->MarkAsSimple();
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,10 +151,8 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
* \see gd::InstructionMetadata::MarkAsAdvanced
|
* \see gd::InstructionMetadata::MarkAsAdvanced
|
||||||
*/
|
*/
|
||||||
MultipleInstructionMetadata &MarkAsAdvanced() {
|
MultipleInstructionMetadata &MarkAsAdvanced() {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (condition) condition->MarkAsAdvanced();
|
if (condition) condition->MarkAsAdvanced();
|
||||||
if (action) action->MarkAsAdvanced();
|
if (action) action->MarkAsAdvanced();
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,10 +160,8 @@ class GD_CORE_API MultipleInstructionMetadata {
|
|||||||
* \see gd::InstructionMetadata::MarkAsComplex
|
* \see gd::InstructionMetadata::MarkAsComplex
|
||||||
*/
|
*/
|
||||||
MultipleInstructionMetadata &MarkAsComplex() {
|
MultipleInstructionMetadata &MarkAsComplex() {
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
if (condition) condition->MarkAsComplex();
|
if (condition) condition->MarkAsComplex();
|
||||||
if (action) action->MarkAsComplex();
|
if (action) action->MarkAsComplex();
|
||||||
#endif
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -302,6 +302,38 @@ ObjectMetadata::AddExpressionAndConditionAndAction(
|
|||||||
expression, condition, action);
|
expression, condition, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gd::InstructionMetadata& ObjectMetadata::AddDuplicatedAction(
|
||||||
|
const gd::String& newActionName, const gd::String& copiedActionName) {
|
||||||
|
gd::String newNameWithNamespace = extensionNamespace + newActionName;
|
||||||
|
gd::String copiedNameWithNamespace = extensionNamespace + copiedActionName;
|
||||||
|
|
||||||
|
auto copiedAction = actionsInfos.find(copiedNameWithNamespace);
|
||||||
|
if (copiedAction == actionsInfos.end()) {
|
||||||
|
gd::LogWarning("Could not find an action with name " +
|
||||||
|
copiedNameWithNamespace + " to copy.");
|
||||||
|
} else {
|
||||||
|
actionsInfos[newNameWithNamespace] = copiedAction->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionsInfos[newNameWithNamespace];
|
||||||
|
}
|
||||||
|
|
||||||
|
gd::InstructionMetadata& ObjectMetadata::AddDuplicatedCondition(
|
||||||
|
const gd::String& newConditionName, const gd::String& copiedConditionName) {
|
||||||
|
gd::String newNameWithNamespace = extensionNamespace + newConditionName;
|
||||||
|
gd::String copiedNameWithNamespace = extensionNamespace + copiedConditionName;
|
||||||
|
|
||||||
|
auto copiedCondition = conditionsInfos.find(copiedNameWithNamespace);
|
||||||
|
if (copiedCondition == conditionsInfos.end()) {
|
||||||
|
gd::LogWarning("Could not find a condition with name " +
|
||||||
|
copiedNameWithNamespace + " to copy.");
|
||||||
|
} else {
|
||||||
|
conditionsInfos[newNameWithNamespace] = copiedCondition->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return conditionsInfos[newNameWithNamespace];
|
||||||
|
}
|
||||||
|
|
||||||
ObjectMetadata& ObjectMetadata::SetFullName(const gd::String& fullname_) {
|
ObjectMetadata& ObjectMetadata::SetFullName(const gd::String& fullname_) {
|
||||||
#if defined(GD_IDE_ONLY)
|
#if defined(GD_IDE_ONLY)
|
||||||
fullname = fullname_;
|
fullname = fullname_;
|
||||||
|
@@ -153,6 +153,25 @@ class GD_CORE_API ObjectMetadata {
|
|||||||
const gd::String& group,
|
const gd::String& group,
|
||||||
const gd::String& icon);
|
const gd::String& icon);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Create a new action which is the duplicate of the specified one.
|
||||||
|
*
|
||||||
|
* Useful for handling a deprecated action that is just a "copy" of the new
|
||||||
|
* one.
|
||||||
|
*/
|
||||||
|
gd::InstructionMetadata& AddDuplicatedAction(
|
||||||
|
const gd::String& newActionName, const gd::String& copiedActionName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Create a new condition which is the duplicate of the specified one.
|
||||||
|
*
|
||||||
|
* Useful for handling a deprecated condition that is just a "copy" of the new
|
||||||
|
* one.
|
||||||
|
*/
|
||||||
|
gd::InstructionMetadata& AddDuplicatedCondition(
|
||||||
|
const gd::String& newConditionName,
|
||||||
|
const gd::String& copiedConditionName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the name shown to the user.
|
* \brief Set the name shown to the user.
|
||||||
*/
|
*/
|
||||||
|
@@ -68,14 +68,14 @@ class GD_CORE_API ParameterMetadata {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return an optional additional information, used for some parameters
|
* \brief Return an optional additional information, used for some parameters
|
||||||
* with special type (For example, it can contains the type of object accepted
|
* with special type (for example, it can contains the type of object accepted
|
||||||
* by the parameter).
|
* by the parameter).
|
||||||
*/
|
*/
|
||||||
const gd::String &GetExtraInfo() const { return supplementaryInformation; }
|
const gd::String &GetExtraInfo() const { return supplementaryInformation; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set an optional additional information, used for some parameters
|
* \brief Set an optional additional information, used for some parameters
|
||||||
* with special type (For example, it can contains the type of object accepted
|
* with special type (for example, it can contains the type of object accepted
|
||||||
* by the parameter).
|
* by the parameter).
|
||||||
*/
|
*/
|
||||||
ParameterMetadata &SetExtraInfo(const gd::String &supplementaryInformation_) {
|
ParameterMetadata &SetExtraInfo(const gd::String &supplementaryInformation_) {
|
||||||
@@ -189,6 +189,10 @@ class GD_CORE_API ParameterMetadata {
|
|||||||
parameterType == "joyaxis" ||
|
parameterType == "joyaxis" ||
|
||||||
parameterType == "stringWithSelector" ||
|
parameterType == "stringWithSelector" ||
|
||||||
parameterType == "sceneName" ||
|
parameterType == "sceneName" ||
|
||||||
|
parameterType == "layerEffectName" ||
|
||||||
|
parameterType == "layerEffectParameterName" ||
|
||||||
|
parameterType == "objectEffectName" ||
|
||||||
|
parameterType == "objectEffectParameterName" ||
|
||||||
parameterType == "objectPointName" ||
|
parameterType == "objectPointName" ||
|
||||||
parameterType == "objectAnimationName";
|
parameterType == "objectAnimationName";
|
||||||
} else if (type == "variable") {
|
} else if (type == "variable") {
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
* reserved. This project is released under the MIT License.
|
* reserved. This project is released under the MIT License.
|
||||||
*/
|
*/
|
||||||
#include "ParameterMetadataTools.h"
|
#include "ParameterMetadataTools.h"
|
||||||
|
|
||||||
#include "GDCore/Events/Expression.h"
|
#include "GDCore/Events/Expression.h"
|
||||||
#include "GDCore/Project/Object.h"
|
#include "GDCore/Project/Object.h"
|
||||||
#include "GDCore/Project/ObjectsContainer.h"
|
#include "GDCore/Project/ObjectsContainer.h"
|
||||||
@@ -60,6 +61,24 @@ void ParameterMetadataTools::IterateOverParameters(
|
|||||||
std::function<void(const gd::ParameterMetadata& parameterMetadata,
|
std::function<void(const gd::ParameterMetadata& parameterMetadata,
|
||||||
const gd::String& parameterValue,
|
const gd::String& parameterValue,
|
||||||
const gd::String& lastObjectName)> fn) {
|
const gd::String& lastObjectName)> fn) {
|
||||||
|
IterateOverParametersWithIndex(
|
||||||
|
parameters,
|
||||||
|
parametersMetadata,
|
||||||
|
[&fn](const gd::ParameterMetadata& parameterMetadata,
|
||||||
|
const gd::String& parameterValue,
|
||||||
|
size_t parameterIndex,
|
||||||
|
const gd::String& lastObjectName) {
|
||||||
|
fn(parameterMetadata, parameterValue, lastObjectName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParameterMetadataTools::IterateOverParametersWithIndex(
|
||||||
|
const std::vector<gd::Expression>& parameters,
|
||||||
|
const std::vector<gd::ParameterMetadata>& parametersMetadata,
|
||||||
|
std::function<void(const gd::ParameterMetadata& parameterMetadata,
|
||||||
|
const gd::String& parameterValue,
|
||||||
|
size_t parameterIndex,
|
||||||
|
const gd::String& lastObjectName)> fn) {
|
||||||
gd::String lastObjectName = "";
|
gd::String lastObjectName = "";
|
||||||
for (std::size_t pNb = 0; pNb < parametersMetadata.size(); ++pNb) {
|
for (std::size_t pNb = 0; pNb < parametersMetadata.size(); ++pNb) {
|
||||||
const gd::ParameterMetadata& parameterMetadata = parametersMetadata[pNb];
|
const gd::ParameterMetadata& parameterMetadata = parametersMetadata[pNb];
|
||||||
@@ -70,7 +89,7 @@ void ParameterMetadataTools::IterateOverParameters(
|
|||||||
? parameterMetadata.GetDefaultValue()
|
? parameterMetadata.GetDefaultValue()
|
||||||
: parameterValue;
|
: parameterValue;
|
||||||
|
|
||||||
fn(parameterMetadata, parameterValueOrDefault, lastObjectName);
|
fn(parameterMetadata, parameterValueOrDefault, pNb, lastObjectName);
|
||||||
|
|
||||||
// Memorize the last object name. By convention, parameters that require
|
// Memorize the last object name. By convention, parameters that require
|
||||||
// an object (mainly, "objectvar" and "behavior") should be placed after
|
// an object (mainly, "objectvar" and "behavior") should be placed after
|
||||||
|
@@ -35,6 +35,19 @@ class GD_CORE_API ParameterMetadataTools {
|
|||||||
const gd::String& parameterValue,
|
const gd::String& parameterValue,
|
||||||
const gd::String& lastObjectName)> fn);
|
const gd::String& lastObjectName)> fn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate over a list of parameters and their values.
|
||||||
|
* Callback function is called with the parameter metadata, its value
|
||||||
|
* and if applicable the name of the object it's linked to.
|
||||||
|
*/
|
||||||
|
static void IterateOverParametersWithIndex(
|
||||||
|
const std::vector<gd::Expression>& parameters,
|
||||||
|
const std::vector<gd::ParameterMetadata>& parametersMetadata,
|
||||||
|
std::function<void(const gd::ParameterMetadata& parameterMetadata,
|
||||||
|
const gd::String& parameterValue,
|
||||||
|
size_t parameterIndex,
|
||||||
|
const gd::String& lastObjectName)> fn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a parameter, return, if applicable, the index of the object parameter
|
* Given a parameter, return, if applicable, the index of the object parameter
|
||||||
* it's linked to.
|
* it's linked to.
|
||||||
|
@@ -529,24 +529,6 @@ class GD_CORE_API PlatformExtension {
|
|||||||
std::map<gd::String, gd::ExpressionMetadata>& GetAllStrExpressionsForBehavior(
|
std::map<gd::String, gd::ExpressionMetadata>& GetAllStrExpressionsForBehavior(
|
||||||
gd::String autoType);
|
gd::String autoType);
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to inventory resources used by conditions
|
|
||||||
* (and possibly do work on them, like renaming, etc...)
|
|
||||||
*
|
|
||||||
* \see gd::PlatformExtension::ExposeActionsResources
|
|
||||||
*/
|
|
||||||
virtual void ExposeConditionsResources(Instruction& condition,
|
|
||||||
gd::ArbitraryResourceWorker& worker){};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to inventory resources used by actions
|
|
||||||
* (and possibly do work on them, like renaming, etc...)
|
|
||||||
*
|
|
||||||
* \see ArbitraryResourceWorker
|
|
||||||
*/
|
|
||||||
virtual void ExposeActionsResources(Instruction& action,
|
|
||||||
gd::ArbitraryResourceWorker& worker){};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get all the properties of the extension. Properties
|
* \brief Get all the properties of the extension. Properties
|
||||||
* are shown in the game properties in the editor, and are exported in the
|
* are shown in the game properties in the editor, and are exported in the
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* GDevelop Core
|
||||||
|
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||||
|
* reserved. This project is released under the MIT License.
|
||||||
|
*/
|
||||||
|
#if defined(GD_IDE_ONLY)
|
||||||
|
#include "GDCore/CommonTools.h"
|
||||||
|
#include "GDCore/Serialization/SerializerElement.h"
|
||||||
|
#include "EditorSettings.h"
|
||||||
|
|
||||||
|
namespace gd {
|
||||||
|
|
||||||
|
EditorSettings::EditorSettings() {}
|
||||||
|
|
||||||
|
void EditorSettings::SerializeTo(SerializerElement& element) const {
|
||||||
|
element = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorSettings::UnserializeFrom(
|
||||||
|
const SerializerElement& element) {
|
||||||
|
content = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace gd
|
||||||
|
#endif
|
46
Core/GDCore/IDE/Dialogs/LayoutEditorCanvas/EditorSettings.h
Normal file
46
Core/GDCore/IDE/Dialogs/LayoutEditorCanvas/EditorSettings.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* GDevelop Core
|
||||||
|
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||||
|
* reserved. This project is released under the MIT License.
|
||||||
|
*/
|
||||||
|
#if defined(GD_IDE_ONLY)
|
||||||
|
#ifndef SCENECANVASSETTINGS_H
|
||||||
|
#define SCENECANVASSETTINGS_H
|
||||||
|
#include "GDCore/String.h"
|
||||||
|
#include "GDCore/Serialization/SerializerElement.h"
|
||||||
|
|
||||||
|
namespace gd {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Container for arbitrary serialized data to be used by the editor
|
||||||
|
* to store settings.
|
||||||
|
*
|
||||||
|
* \see Scene
|
||||||
|
*/
|
||||||
|
class GD_CORE_API EditorSettings {
|
||||||
|
public:
|
||||||
|
EditorSettings();
|
||||||
|
virtual ~EditorSettings(){};
|
||||||
|
|
||||||
|
/** \name Serialization
|
||||||
|
*/
|
||||||
|
///@{
|
||||||
|
/**
|
||||||
|
* \brief Serialize the settings.
|
||||||
|
*/
|
||||||
|
void SerializeTo(SerializerElement& element) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Unserialize the settings.
|
||||||
|
*/
|
||||||
|
void UnserializeFrom(const SerializerElement& element);
|
||||||
|
///@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
gd::SerializerElement content; ///< Arbitrary content, depending on the editor.
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace gd
|
||||||
|
|
||||||
|
#endif // SCENECANVASSETTINGS_H
|
||||||
|
#endif
|
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* GDevelop Core
|
|
||||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
|
||||||
* reserved. This project is released under the MIT License.
|
|
||||||
*/
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
#include "LayoutEditorCanvasOptions.h"
|
|
||||||
#include "GDCore/CommonTools.h"
|
|
||||||
#include "GDCore/Serialization/SerializerElement.h"
|
|
||||||
|
|
||||||
namespace gd {
|
|
||||||
|
|
||||||
LayoutEditorCanvasOptions::LayoutEditorCanvasOptions()
|
|
||||||
: grid(false),
|
|
||||||
snap(true),
|
|
||||||
gridWidth(32),
|
|
||||||
gridHeight(32),
|
|
||||||
gridOffsetX(0),
|
|
||||||
gridOffsetY(0),
|
|
||||||
gridType("rectangular"),
|
|
||||||
gridR(158),
|
|
||||||
gridG(180),
|
|
||||||
gridB(255),
|
|
||||||
zoomFactor(1),
|
|
||||||
windowMask(false) {}
|
|
||||||
|
|
||||||
void LayoutEditorCanvasOptions::SerializeTo(SerializerElement& element) const {
|
|
||||||
element.SetAttribute("grid", grid);
|
|
||||||
element.SetAttribute("snap", snap);
|
|
||||||
element.SetAttribute("gridWidth", gridWidth);
|
|
||||||
element.SetAttribute("gridHeight", gridHeight);
|
|
||||||
element.SetAttribute("gridOffsetX", gridOffsetX);
|
|
||||||
element.SetAttribute("gridOffsetY", gridOffsetY);
|
|
||||||
element.SetAttribute("gridType", gridType);
|
|
||||||
element.SetAttribute("gridR", gridR);
|
|
||||||
element.SetAttribute("gridG", gridG);
|
|
||||||
element.SetAttribute("gridB", gridB);
|
|
||||||
element.SetAttribute("zoomFactor", zoomFactor);
|
|
||||||
element.SetAttribute("windowMask", windowMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayoutEditorCanvasOptions::UnserializeFrom(
|
|
||||||
const SerializerElement& element) {
|
|
||||||
grid = element.GetBoolAttribute("grid");
|
|
||||||
snap = element.GetBoolAttribute("snap");
|
|
||||||
windowMask = element.GetBoolAttribute("windowMask");
|
|
||||||
gridWidth = element.GetDoubleAttribute("gridWidth", 32);
|
|
||||||
gridHeight = element.GetDoubleAttribute("gridHeight", 32);
|
|
||||||
gridOffsetX = element.GetDoubleAttribute("gridOffsetX", 0);
|
|
||||||
gridOffsetY = element.GetDoubleAttribute("gridOffsetY", 0);
|
|
||||||
gridType = element.GetStringAttribute("gridType", "rectangular");
|
|
||||||
gridR = element.GetIntAttribute("gridR", 158);
|
|
||||||
gridG = element.GetIntAttribute("gridG", 180);
|
|
||||||
gridB = element.GetIntAttribute("gridB", 255);
|
|
||||||
zoomFactor = element.GetDoubleAttribute("zoomFactor", 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace gd
|
|
||||||
#endif
|
|
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* GDevelop Core
|
|
||||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
|
||||||
* reserved. This project is released under the MIT License.
|
|
||||||
*/
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
#ifndef SCENECANVASSETTINGS_H
|
|
||||||
#define SCENECANVASSETTINGS_H
|
|
||||||
#include "GDCore/String.h"
|
|
||||||
namespace gd {
|
|
||||||
class SerializerElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace gd {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Tool class used to store settings of a LayoutEditorCanvas.
|
|
||||||
*
|
|
||||||
* \see Scene
|
|
||||||
*/
|
|
||||||
class GD_CORE_API LayoutEditorCanvasOptions {
|
|
||||||
public:
|
|
||||||
LayoutEditorCanvasOptions();
|
|
||||||
virtual ~LayoutEditorCanvasOptions(){};
|
|
||||||
|
|
||||||
/** \name Serialization
|
|
||||||
*/
|
|
||||||
///@{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Serialize instances container.
|
|
||||||
*/
|
|
||||||
void SerializeTo(SerializerElement& element) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Unserialize the instances container.
|
|
||||||
*/
|
|
||||||
void UnserializeFrom(const SerializerElement& element);
|
|
||||||
///@}
|
|
||||||
|
|
||||||
bool grid; ///< True if grid activated in editor
|
|
||||||
bool snap; ///< True if snap to grid activated in editor
|
|
||||||
double gridWidth; ///< Grid width in editor
|
|
||||||
double gridHeight; ///< Grid height in editor
|
|
||||||
double gridOffsetX; ///< Grid X offset
|
|
||||||
double gridOffsetY; ///< Grid Y offset
|
|
||||||
gd::String gridType; ///< Grid type: rectangular or isometric
|
|
||||||
int gridR; ///< Grid red color in editor
|
|
||||||
int gridG; ///< Grid green color in editor
|
|
||||||
int gridB; ///< Grid blue color in editor
|
|
||||||
double zoomFactor; ///< Stores the zoom factor
|
|
||||||
bool windowMask; ///< True if window mask displayed in editor
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace gd
|
|
||||||
|
|
||||||
#endif // SCENECANVASSETTINGS_H
|
|
||||||
#endif
|
|
164
Core/GDCore/IDE/Events/EventsBehaviorRenamer.cpp
Normal file
164
Core/GDCore/IDE/Events/EventsBehaviorRenamer.cpp
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
/*
|
||||||
|
* GDevelop Core
|
||||||
|
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||||
|
* reserved. This project is released under the MIT License.
|
||||||
|
*/
|
||||||
|
#include "GDCore/IDE/Events/EventsBehaviorRenamer.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "GDCore/Events/Event.h"
|
||||||
|
#include "GDCore/Events/EventsList.h"
|
||||||
|
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
||||||
|
#include "GDCore/Events/Parsers/ExpressionParser2NodePrinter.h"
|
||||||
|
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
||||||
|
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||||
|
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||||
|
#include "GDCore/IDE/Events/ExpressionValidator.h"
|
||||||
|
#include "GDCore/Project/Layout.h"
|
||||||
|
#include "GDCore/Project/Project.h"
|
||||||
|
#include "GDCore/String.h"
|
||||||
|
#include "GDCore/Tools/Log.h"
|
||||||
|
|
||||||
|
namespace gd {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Go through the nodes and rename any reference to an object behavior.
|
||||||
|
*
|
||||||
|
* \see gd::ExpressionParser2
|
||||||
|
*/
|
||||||
|
class GD_CORE_API ExpressionBehaviorRenamer
|
||||||
|
: public ExpressionParser2NodeWorker {
|
||||||
|
public:
|
||||||
|
ExpressionBehaviorRenamer(const gd::ObjectsContainer& globalObjectsContainer_,
|
||||||
|
const gd::ObjectsContainer& objectsContainer_,
|
||||||
|
const gd::String& objectName_,
|
||||||
|
const gd::String& oldBehaviorName_,
|
||||||
|
const gd::String& newBehaviorName_)
|
||||||
|
: hasDoneRenaming(false),
|
||||||
|
globalObjectsContainer(globalObjectsContainer_),
|
||||||
|
objectsContainer(objectsContainer_),
|
||||||
|
objectName(objectName_),
|
||||||
|
oldBehaviorName(oldBehaviorName_),
|
||||||
|
newBehaviorName(newBehaviorName_){};
|
||||||
|
virtual ~ExpressionBehaviorRenamer(){};
|
||||||
|
|
||||||
|
bool HasDoneRenaming() const { return hasDoneRenaming; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnVisitSubExpressionNode(SubExpressionNode& node) override {
|
||||||
|
node.expression->Visit(*this);
|
||||||
|
}
|
||||||
|
void OnVisitOperatorNode(OperatorNode& node) override {
|
||||||
|
node.leftHandSide->Visit(*this);
|
||||||
|
node.rightHandSide->Visit(*this);
|
||||||
|
}
|
||||||
|
void OnVisitUnaryOperatorNode(UnaryOperatorNode& node) override {
|
||||||
|
node.factor->Visit(*this);
|
||||||
|
}
|
||||||
|
void OnVisitNumberNode(NumberNode& node) override {}
|
||||||
|
void OnVisitTextNode(TextNode& node) override {}
|
||||||
|
void OnVisitVariableNode(VariableNode& node) override {
|
||||||
|
if (node.child) node.child->Visit(*this);
|
||||||
|
}
|
||||||
|
void OnVisitVariableAccessorNode(VariableAccessorNode& node) override {
|
||||||
|
if (node.child) node.child->Visit(*this);
|
||||||
|
}
|
||||||
|
void OnVisitVariableBracketAccessorNode(
|
||||||
|
VariableBracketAccessorNode& node) override {
|
||||||
|
node.expression->Visit(*this);
|
||||||
|
if (node.child) node.child->Visit(*this);
|
||||||
|
}
|
||||||
|
void OnVisitIdentifierNode(IdentifierNode& node) override {}
|
||||||
|
void OnVisitObjectFunctionNameNode(ObjectFunctionNameNode& node) override {
|
||||||
|
if (!node.behaviorFunctionName.empty()) {
|
||||||
|
// Behavior function name
|
||||||
|
if (node.objectName == objectName && node.objectFunctionOrBehaviorName == oldBehaviorName) {
|
||||||
|
node.objectFunctionOrBehaviorName = newBehaviorName;
|
||||||
|
hasDoneRenaming = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void OnVisitFunctionCallNode(FunctionCallNode& node) override {
|
||||||
|
if (!node.behaviorName.empty()) {
|
||||||
|
// Behavior function call
|
||||||
|
if (node.objectName == objectName && node.behaviorName == oldBehaviorName) {
|
||||||
|
node.behaviorName = newBehaviorName;
|
||||||
|
hasDoneRenaming = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& parameter : node.parameters) {
|
||||||
|
parameter->Visit(*this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void OnVisitEmptyNode(EmptyNode& node) override {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool hasDoneRenaming;
|
||||||
|
const gd::ObjectsContainer& globalObjectsContainer;
|
||||||
|
const gd::ObjectsContainer& objectsContainer;
|
||||||
|
const gd::String& objectName; // The object name for which the behavior
|
||||||
|
// must be replaced.
|
||||||
|
const gd::String& oldBehaviorName;
|
||||||
|
const gd::String& newBehaviorName;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool EventsBehaviorRenamer::DoVisitInstruction(gd::Instruction& instruction,
|
||||||
|
bool isCondition) {
|
||||||
|
const auto& metadata = isCondition
|
||||||
|
? gd::MetadataProvider::GetConditionMetadata(
|
||||||
|
platform, instruction.GetType())
|
||||||
|
: gd::MetadataProvider::GetActionMetadata(
|
||||||
|
platform, instruction.GetType());
|
||||||
|
|
||||||
|
gd::ParameterMetadataTools::IterateOverParametersWithIndex(
|
||||||
|
instruction.GetParameters(),
|
||||||
|
metadata.GetParameters(),
|
||||||
|
[&](const gd::ParameterMetadata& parameterMetadata,
|
||||||
|
const gd::String& parameterValue,
|
||||||
|
size_t parameterIndex,
|
||||||
|
const gd::String& lastObjectName) {
|
||||||
|
const gd::String& type = parameterMetadata.type;
|
||||||
|
|
||||||
|
if (gd::ParameterMetadata::IsBehavior(type)) {
|
||||||
|
if (lastObjectName == objectName) {
|
||||||
|
if (parameterValue == oldBehaviorName) {
|
||||||
|
instruction.SetParameter(parameterIndex,
|
||||||
|
gd::Expression(newBehaviorName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gd::ExpressionParser2 parser(
|
||||||
|
platform, GetGlobalObjectsContainer(), GetObjectsContainer());
|
||||||
|
auto node =
|
||||||
|
gd::ParameterMetadata::IsExpression("number", type)
|
||||||
|
? parser.ParseExpression("number", parameterValue)
|
||||||
|
: (gd::ParameterMetadata::IsExpression("string", type)
|
||||||
|
? parser.ParseExpression("string", parameterValue)
|
||||||
|
: std::unique_ptr<gd::ExpressionNode>());
|
||||||
|
if (node) {
|
||||||
|
ExpressionBehaviorRenamer renamer(GetGlobalObjectsContainer(),
|
||||||
|
GetObjectsContainer(),
|
||||||
|
objectName,
|
||||||
|
oldBehaviorName,
|
||||||
|
newBehaviorName);
|
||||||
|
node->Visit(renamer);
|
||||||
|
|
||||||
|
if (renamer.HasDoneRenaming()) {
|
||||||
|
instruction.SetParameter(
|
||||||
|
parameterIndex,
|
||||||
|
ExpressionParser2NodePrinter::PrintNode(*node));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventsBehaviorRenamer::~EventsBehaviorRenamer() {}
|
||||||
|
|
||||||
|
} // namespace gd
|
52
Core/GDCore/IDE/Events/EventsBehaviorRenamer.h
Normal file
52
Core/GDCore/IDE/Events/EventsBehaviorRenamer.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* GDevelop Core
|
||||||
|
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||||
|
* reserved. This project is released under the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef EventsBehaviorRenamer_H
|
||||||
|
#define EventsBehaviorRenamer_H
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||||
|
#include "GDCore/String.h"
|
||||||
|
namespace gd {
|
||||||
|
class BaseEvent;
|
||||||
|
class Platform;
|
||||||
|
class EventsList;
|
||||||
|
} // namespace gd
|
||||||
|
|
||||||
|
namespace gd {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Replace in expressions and in parameters of actions or conditions, references
|
||||||
|
* to the name of a behavior of an object by another name.
|
||||||
|
*
|
||||||
|
* \ingroup IDE
|
||||||
|
*/
|
||||||
|
class GD_CORE_API EventsBehaviorRenamer : public ArbitraryEventsWorkerWithContext {
|
||||||
|
public:
|
||||||
|
EventsBehaviorRenamer(const gd::Platform &platform_,
|
||||||
|
const gd::String& objectName_,
|
||||||
|
const gd::String& oldBehaviorName_,
|
||||||
|
const gd::String& newBehaviorName_) :
|
||||||
|
platform(platform_),
|
||||||
|
objectName(objectName_),
|
||||||
|
oldBehaviorName(oldBehaviorName_),
|
||||||
|
newBehaviorName(newBehaviorName_)
|
||||||
|
{};
|
||||||
|
virtual ~EventsBehaviorRenamer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool DoVisitInstruction(gd::Instruction &instruction,
|
||||||
|
bool isCondition) override;
|
||||||
|
|
||||||
|
const gd::Platform &platform;
|
||||||
|
gd::String objectName;
|
||||||
|
gd::String oldBehaviorName;
|
||||||
|
gd::String newBehaviorName;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace gd
|
||||||
|
|
||||||
|
#endif // EventsBehaviorRenamer_H
|
@@ -5,23 +5,28 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GDCore/IDE/Events/EventsRefactorer.h"
|
#include "GDCore/IDE/Events/EventsRefactorer.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "GDCore/CommonTools.h"
|
#include "GDCore/CommonTools.h"
|
||||||
#include "GDCore/Events/Event.h"
|
#include "GDCore/Events/Event.h"
|
||||||
#include "GDCore/Events/EventsList.h"
|
#include "GDCore/Events/EventsList.h"
|
||||||
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
||||||
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
|
||||||
#include "GDCore/Events/Parsers/ExpressionParser2NodePrinter.h"
|
#include "GDCore/Events/Parsers/ExpressionParser2NodePrinter.h"
|
||||||
#include "GDCore/IDE/Events/ExpressionValidator.h"
|
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
||||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||||
#include "GDCore/Extensions/Platform.h"
|
#include "GDCore/Extensions/Platform.h"
|
||||||
|
#include "GDCore/IDE/Events/ExpressionValidator.h"
|
||||||
#include "GDCore/Project/ObjectsContainer.h"
|
#include "GDCore/Project/ObjectsContainer.h"
|
||||||
|
#include "GDCore/IDE/Events/InstructionSentenceFormatter.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
|
|
||||||
|
const gd::String EventsRefactorer::searchIgnoredCharacters = ";:,#()";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Go through the nodes and change the given object name to a new one.
|
* \brief Go through the nodes and change the given object name to a new one.
|
||||||
*
|
*
|
||||||
@@ -31,10 +36,14 @@ class GD_CORE_API ExpressionObjectRenamer : public ExpressionParser2NodeWorker {
|
|||||||
public:
|
public:
|
||||||
ExpressionObjectRenamer(const gd::String& objectName_,
|
ExpressionObjectRenamer(const gd::String& objectName_,
|
||||||
const gd::String& objectNewName_)
|
const gd::String& objectNewName_)
|
||||||
: hasDoneRenaming(false), objectName(objectName_), objectNewName(objectNewName_){};
|
: hasDoneRenaming(false),
|
||||||
|
objectName(objectName_),
|
||||||
|
objectNewName(objectNewName_){};
|
||||||
virtual ~ExpressionObjectRenamer(){};
|
virtual ~ExpressionObjectRenamer(){};
|
||||||
|
|
||||||
static bool Rename(gd::ExpressionNode & node, const gd::String& objectName, const gd::String& objectNewName) {
|
static bool Rename(gd::ExpressionNode& node,
|
||||||
|
const gd::String& objectName,
|
||||||
|
const gd::String& objectNewName) {
|
||||||
if (ExpressionValidator::HasNoErrors(node)) {
|
if (ExpressionValidator::HasNoErrors(node)) {
|
||||||
ExpressionObjectRenamer renamer(objectName, objectNewName);
|
ExpressionObjectRenamer renamer(objectName, objectNewName);
|
||||||
node.Visit(renamer);
|
node.Visit(renamer);
|
||||||
@@ -72,7 +81,8 @@ class GD_CORE_API ExpressionObjectRenamer : public ExpressionParser2NodeWorker {
|
|||||||
if (node.child) node.child->Visit(*this);
|
if (node.child) node.child->Visit(*this);
|
||||||
}
|
}
|
||||||
void OnVisitIdentifierNode(IdentifierNode& node) override {
|
void OnVisitIdentifierNode(IdentifierNode& node) override {
|
||||||
if (gd::ParameterMetadata::IsObject(node.type) && node.identifierName == objectName) {
|
if (gd::ParameterMetadata::IsObject(node.type) &&
|
||||||
|
node.identifierName == objectName) {
|
||||||
hasDoneRenaming = true;
|
hasDoneRenaming = true;
|
||||||
node.identifierName = objectNewName;
|
node.identifierName = objectNewName;
|
||||||
}
|
}
|
||||||
@@ -109,10 +119,11 @@ class GD_CORE_API ExpressionObjectRenamer : public ExpressionParser2NodeWorker {
|
|||||||
class GD_CORE_API ExpressionObjectFinder : public ExpressionParser2NodeWorker {
|
class GD_CORE_API ExpressionObjectFinder : public ExpressionParser2NodeWorker {
|
||||||
public:
|
public:
|
||||||
ExpressionObjectFinder(const gd::String& objectName_)
|
ExpressionObjectFinder(const gd::String& objectName_)
|
||||||
: hasObject(false), objectName(objectName_) {};
|
: hasObject(false), objectName(objectName_){};
|
||||||
virtual ~ExpressionObjectFinder(){};
|
virtual ~ExpressionObjectFinder(){};
|
||||||
|
|
||||||
static bool CheckIfHasObject(gd::ExpressionNode & node, const gd::String & objectName) {
|
static bool CheckIfHasObject(gd::ExpressionNode& node,
|
||||||
|
const gd::String& objectName) {
|
||||||
if (ExpressionValidator::HasNoErrors(node)) {
|
if (ExpressionValidator::HasNoErrors(node)) {
|
||||||
ExpressionObjectFinder finder(objectName);
|
ExpressionObjectFinder finder(objectName);
|
||||||
node.Visit(finder);
|
node.Visit(finder);
|
||||||
@@ -150,7 +161,8 @@ class GD_CORE_API ExpressionObjectFinder : public ExpressionParser2NodeWorker {
|
|||||||
if (node.child) node.child->Visit(*this);
|
if (node.child) node.child->Visit(*this);
|
||||||
}
|
}
|
||||||
void OnVisitIdentifierNode(IdentifierNode& node) override {
|
void OnVisitIdentifierNode(IdentifierNode& node) override {
|
||||||
if (gd::ParameterMetadata::IsObject(node.type) && node.identifierName == objectName) {
|
if (gd::ParameterMetadata::IsObject(node.type) &&
|
||||||
|
node.identifierName == objectName) {
|
||||||
hasObject = true;
|
hasObject = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,7 +195,7 @@ bool EventsRefactorer::RenameObjectInActions(const gd::Platform& platform,
|
|||||||
bool somethingModified = false;
|
bool somethingModified = false;
|
||||||
|
|
||||||
for (std::size_t aId = 0; aId < actions.size(); ++aId) {
|
for (std::size_t aId = 0; aId < actions.size(); ++aId) {
|
||||||
gd::InstructionMetadata instrInfos =
|
const gd::InstructionMetadata& instrInfos =
|
||||||
MetadataProvider::GetActionMetadata(platform, actions[aId].GetType());
|
MetadataProvider::GetActionMetadata(platform, actions[aId].GetType());
|
||||||
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
||||||
// Replace object's name in parameters
|
// Replace object's name in parameters
|
||||||
@@ -194,20 +206,24 @@ bool EventsRefactorer::RenameObjectInActions(const gd::Platform& platform,
|
|||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression(
|
||||||
"number", instrInfos.parameters[pNb].type)) {
|
"number", instrInfos.parameters[pNb].type)) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("number", actions[aId].GetParameter(pNb).GetPlainString());
|
auto node = parser.ParseExpression(
|
||||||
|
"number", actions[aId].GetParameter(pNb).GetPlainString());
|
||||||
|
|
||||||
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
||||||
actions[aId].SetParameter(pNb, ExpressionParser2NodePrinter::PrintNode(*node));
|
actions[aId].SetParameter(
|
||||||
|
pNb, ExpressionParser2NodePrinter::PrintNode(*node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Replace object's name in text expressions
|
// Replace object's name in text expressions
|
||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression(
|
||||||
"string", instrInfos.parameters[pNb].type)) {
|
"string", instrInfos.parameters[pNb].type)) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("string", actions[aId].GetParameter(pNb).GetPlainString());
|
auto node = parser.ParseExpression(
|
||||||
|
"string", actions[aId].GetParameter(pNb).GetPlainString());
|
||||||
|
|
||||||
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
||||||
actions[aId].SetParameter(pNb, ExpressionParser2NodePrinter::PrintNode(*node));
|
actions[aId].SetParameter(
|
||||||
|
pNb, ExpressionParser2NodePrinter::PrintNode(*node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,8 +252,9 @@ bool EventsRefactorer::RenameObjectInConditions(
|
|||||||
bool somethingModified = false;
|
bool somethingModified = false;
|
||||||
|
|
||||||
for (std::size_t cId = 0; cId < conditions.size(); ++cId) {
|
for (std::size_t cId = 0; cId < conditions.size(); ++cId) {
|
||||||
gd::InstructionMetadata instrInfos = MetadataProvider::GetConditionMetadata(
|
const gd::InstructionMetadata& instrInfos =
|
||||||
platform, conditions[cId].GetType());
|
MetadataProvider::GetConditionMetadata(platform,
|
||||||
|
conditions[cId].GetType());
|
||||||
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
||||||
// Replace object's name in parameters
|
// Replace object's name in parameters
|
||||||
if (gd::ParameterMetadata::IsObject(instrInfos.parameters[pNb].type) &&
|
if (gd::ParameterMetadata::IsObject(instrInfos.parameters[pNb].type) &&
|
||||||
@@ -247,20 +264,24 @@ bool EventsRefactorer::RenameObjectInConditions(
|
|||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression(
|
||||||
"number", instrInfos.parameters[pNb].type)) {
|
"number", instrInfos.parameters[pNb].type)) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("number", conditions[cId].GetParameter(pNb).GetPlainString());
|
auto node = parser.ParseExpression(
|
||||||
|
"number", conditions[cId].GetParameter(pNb).GetPlainString());
|
||||||
|
|
||||||
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
||||||
conditions[cId].SetParameter(pNb, ExpressionParser2NodePrinter::PrintNode(*node));
|
conditions[cId].SetParameter(
|
||||||
|
pNb, ExpressionParser2NodePrinter::PrintNode(*node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Replace object's name in text expressions
|
// Replace object's name in text expressions
|
||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression(
|
||||||
"string", instrInfos.parameters[pNb].type)) {
|
"string", instrInfos.parameters[pNb].type)) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("string", conditions[cId].GetParameter(pNb).GetPlainString());
|
auto node = parser.ParseExpression(
|
||||||
|
"string", conditions[cId].GetParameter(pNb).GetPlainString());
|
||||||
|
|
||||||
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
||||||
conditions[cId].SetParameter(pNb, ExpressionParser2NodePrinter::PrintNode(*node));
|
conditions[cId].SetParameter(
|
||||||
|
pNb, ExpressionParser2NodePrinter::PrintNode(*node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,8 +314,8 @@ bool EventsRefactorer::RenameObjectInEventParameters(
|
|||||||
expression.GetPlainString() == oldName)
|
expression.GetPlainString() == oldName)
|
||||||
expression = gd::Expression(newName);
|
expression = gd::Expression(newName);
|
||||||
// Replace object's name in expressions
|
// Replace object's name in expressions
|
||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression("number",
|
||||||
"number", parameterMetadata.GetType())) {
|
parameterMetadata.GetType())) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("number", expression.GetPlainString());
|
auto node = parser.ParseExpression("number", expression.GetPlainString());
|
||||||
|
|
||||||
@@ -303,8 +324,8 @@ bool EventsRefactorer::RenameObjectInEventParameters(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Replace object's name in text expressions
|
// Replace object's name in text expressions
|
||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression("string",
|
||||||
"string", parameterMetadata.GetType())) {
|
parameterMetadata.GetType())) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("string", expression.GetPlainString());
|
auto node = parser.ParseExpression("string", expression.GetPlainString());
|
||||||
|
|
||||||
@@ -337,13 +358,19 @@ void EventsRefactorer::RenameObjectInEvents(const gd::Platform& platform,
|
|||||||
platform, project, layout, *actionsVectors[j], oldName, newName);
|
platform, project, layout, *actionsVectors[j], oldName, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<pair<gd::Expression*, gd::ParameterMetadata>> expressionsWithMetadata =
|
vector<pair<gd::Expression*, gd::ParameterMetadata>>
|
||||||
events[i].GetAllExpressionsWithMetadata();
|
expressionsWithMetadata = events[i].GetAllExpressionsWithMetadata();
|
||||||
for (std::size_t j = 0; j < expressionsWithMetadata.size(); ++j) {
|
for (std::size_t j = 0; j < expressionsWithMetadata.size(); ++j) {
|
||||||
gd::Expression* expression = expressionsWithMetadata[j].first;
|
gd::Expression* expression = expressionsWithMetadata[j].first;
|
||||||
gd::ParameterMetadata parameterMetadata = expressionsWithMetadata[j].second;
|
gd::ParameterMetadata parameterMetadata =
|
||||||
bool somethingModified = RenameObjectInEventParameters(
|
expressionsWithMetadata[j].second;
|
||||||
platform, project, layout, *expression, parameterMetadata, oldName, newName);
|
bool somethingModified = RenameObjectInEventParameters(platform,
|
||||||
|
project,
|
||||||
|
layout,
|
||||||
|
*expression,
|
||||||
|
parameterMetadata,
|
||||||
|
oldName,
|
||||||
|
newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events[i].CanHaveSubEvents())
|
if (events[i].CanHaveSubEvents())
|
||||||
@@ -366,7 +393,7 @@ bool EventsRefactorer::RemoveObjectInActions(const gd::Platform& platform,
|
|||||||
for (std::size_t aId = 0; aId < actions.size(); ++aId) {
|
for (std::size_t aId = 0; aId < actions.size(); ++aId) {
|
||||||
bool deleteMe = false;
|
bool deleteMe = false;
|
||||||
|
|
||||||
gd::InstructionMetadata instrInfos =
|
const gd::InstructionMetadata& instrInfos =
|
||||||
MetadataProvider::GetActionMetadata(platform, actions[aId].GetType());
|
MetadataProvider::GetActionMetadata(platform, actions[aId].GetType());
|
||||||
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
||||||
// Find object's name in parameters
|
// Find object's name in parameters
|
||||||
@@ -379,7 +406,8 @@ bool EventsRefactorer::RemoveObjectInActions(const gd::Platform& platform,
|
|||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression(
|
||||||
"number", instrInfos.parameters[pNb].type)) {
|
"number", instrInfos.parameters[pNb].type)) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("number", actions[aId].GetParameter(pNb).GetPlainString());
|
auto node = parser.ParseExpression(
|
||||||
|
"number", actions[aId].GetParameter(pNb).GetPlainString());
|
||||||
|
|
||||||
if (ExpressionObjectFinder::CheckIfHasObject(*node, name)) {
|
if (ExpressionObjectFinder::CheckIfHasObject(*node, name)) {
|
||||||
deleteMe = true;
|
deleteMe = true;
|
||||||
@@ -390,7 +418,8 @@ bool EventsRefactorer::RemoveObjectInActions(const gd::Platform& platform,
|
|||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression(
|
||||||
"string", instrInfos.parameters[pNb].type)) {
|
"string", instrInfos.parameters[pNb].type)) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("string", actions[aId].GetParameter(pNb).GetPlainString());
|
auto node = parser.ParseExpression(
|
||||||
|
"string", actions[aId].GetParameter(pNb).GetPlainString());
|
||||||
|
|
||||||
if (ExpressionObjectFinder::CheckIfHasObject(*node, name)) {
|
if (ExpressionObjectFinder::CheckIfHasObject(*node, name)) {
|
||||||
deleteMe = true;
|
deleteMe = true;
|
||||||
@@ -427,8 +456,9 @@ bool EventsRefactorer::RemoveObjectInConditions(
|
|||||||
for (std::size_t cId = 0; cId < conditions.size(); ++cId) {
|
for (std::size_t cId = 0; cId < conditions.size(); ++cId) {
|
||||||
bool deleteMe = false;
|
bool deleteMe = false;
|
||||||
|
|
||||||
gd::InstructionMetadata instrInfos = MetadataProvider::GetConditionMetadata(
|
const gd::InstructionMetadata& instrInfos =
|
||||||
platform, conditions[cId].GetType());
|
MetadataProvider::GetConditionMetadata(platform,
|
||||||
|
conditions[cId].GetType());
|
||||||
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
||||||
// Find object's name in parameters
|
// Find object's name in parameters
|
||||||
if (gd::ParameterMetadata::IsObject(instrInfos.parameters[pNb].type) &&
|
if (gd::ParameterMetadata::IsObject(instrInfos.parameters[pNb].type) &&
|
||||||
@@ -440,7 +470,8 @@ bool EventsRefactorer::RemoveObjectInConditions(
|
|||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression(
|
||||||
"number", instrInfos.parameters[pNb].type)) {
|
"number", instrInfos.parameters[pNb].type)) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("number", conditions[cId].GetParameter(pNb).GetPlainString());
|
auto node = parser.ParseExpression(
|
||||||
|
"number", conditions[cId].GetParameter(pNb).GetPlainString());
|
||||||
|
|
||||||
if (ExpressionObjectFinder::CheckIfHasObject(*node, name)) {
|
if (ExpressionObjectFinder::CheckIfHasObject(*node, name)) {
|
||||||
deleteMe = true;
|
deleteMe = true;
|
||||||
@@ -451,7 +482,8 @@ bool EventsRefactorer::RemoveObjectInConditions(
|
|||||||
else if (ParameterMetadata::IsExpression(
|
else if (ParameterMetadata::IsExpression(
|
||||||
"string", instrInfos.parameters[pNb].type)) {
|
"string", instrInfos.parameters[pNb].type)) {
|
||||||
gd::ExpressionParser2 parser(platform, project, layout);
|
gd::ExpressionParser2 parser(platform, project, layout);
|
||||||
auto node = parser.ParseExpression("string", conditions[cId].GetParameter(pNb).GetPlainString());
|
auto node = parser.ParseExpression(
|
||||||
|
"string", conditions[cId].GetParameter(pNb).GetPlainString());
|
||||||
|
|
||||||
if (ExpressionObjectFinder::CheckIfHasObject(*node, name)) {
|
if (ExpressionObjectFinder::CheckIfHasObject(*node, name)) {
|
||||||
deleteMe = true;
|
deleteMe = true;
|
||||||
@@ -646,16 +678,27 @@ bool EventsRefactorer::ReplaceStringInConditions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector<EventsSearchResult> EventsRefactorer::SearchInEvents(
|
vector<EventsSearchResult> EventsRefactorer::SearchInEvents(
|
||||||
gd::ObjectsContainer& project,
|
const gd::Platform& platform,
|
||||||
gd::ObjectsContainer& layout,
|
|
||||||
gd::EventsList& events,
|
gd::EventsList& events,
|
||||||
gd::String search,
|
gd::String search,
|
||||||
bool matchCase,
|
bool matchCase,
|
||||||
bool inConditions,
|
bool inConditions,
|
||||||
bool inActions,
|
bool inActions,
|
||||||
bool inEventStrings) {
|
bool inEventStrings,
|
||||||
|
bool inEventSentences) {
|
||||||
vector<EventsSearchResult> results;
|
vector<EventsSearchResult> results;
|
||||||
|
|
||||||
|
const gd::String& ignored_characters = EventsRefactorer::searchIgnoredCharacters;
|
||||||
|
|
||||||
|
search.replace_if(search.begin(),
|
||||||
|
search.end(),
|
||||||
|
[ignored_characters](const char &c) {
|
||||||
|
return ignored_characters.find(c) != gd::String::npos;
|
||||||
|
},
|
||||||
|
"");
|
||||||
|
search = search.LeftTrim().RightTrim();
|
||||||
|
search.RemoveConsecutiveOccurrences(search.begin(), search.end(), ' ');
|
||||||
|
|
||||||
for (std::size_t i = 0; i < events.size(); ++i) {
|
for (std::size_t i = 0; i < events.size(); ++i) {
|
||||||
bool eventAddedInResults = false;
|
bool eventAddedInResults = false;
|
||||||
|
|
||||||
@@ -665,7 +708,7 @@ vector<EventsSearchResult> EventsRefactorer::SearchInEvents(
|
|||||||
for (std::size_t j = 0; j < conditionsVectors.size(); ++j) {
|
for (std::size_t j = 0; j < conditionsVectors.size(); ++j) {
|
||||||
if (!eventAddedInResults &&
|
if (!eventAddedInResults &&
|
||||||
SearchStringInConditions(
|
SearchStringInConditions(
|
||||||
project, layout, *conditionsVectors[j], search, matchCase)) {
|
platform, *conditionsVectors[j], search, matchCase, inEventSentences)) {
|
||||||
results.push_back(EventsSearchResult(
|
results.push_back(EventsSearchResult(
|
||||||
std::weak_ptr<gd::BaseEvent>(events.GetEventSmartPtr(i)),
|
std::weak_ptr<gd::BaseEvent>(events.GetEventSmartPtr(i)),
|
||||||
&events,
|
&events,
|
||||||
@@ -680,7 +723,7 @@ vector<EventsSearchResult> EventsRefactorer::SearchInEvents(
|
|||||||
for (std::size_t j = 0; j < actionsVectors.size(); ++j) {
|
for (std::size_t j = 0; j < actionsVectors.size(); ++j) {
|
||||||
if (!eventAddedInResults &&
|
if (!eventAddedInResults &&
|
||||||
SearchStringInActions(
|
SearchStringInActions(
|
||||||
project, layout, *actionsVectors[j], search, matchCase)) {
|
platform, *actionsVectors[j], search, matchCase, inEventSentences)) {
|
||||||
results.push_back(EventsSearchResult(
|
results.push_back(EventsSearchResult(
|
||||||
std::weak_ptr<gd::BaseEvent>(events.GetEventSmartPtr(i)),
|
std::weak_ptr<gd::BaseEvent>(events.GetEventSmartPtr(i)),
|
||||||
&events,
|
&events,
|
||||||
@@ -691,7 +734,7 @@ vector<EventsSearchResult> EventsRefactorer::SearchInEvents(
|
|||||||
|
|
||||||
if (inEventStrings) {
|
if (inEventStrings) {
|
||||||
if (!eventAddedInResults &&
|
if (!eventAddedInResults &&
|
||||||
SearchStringInEvent(project, layout, events[i], search, matchCase)) {
|
SearchStringInEvent(events[i], search, matchCase)) {
|
||||||
results.push_back(EventsSearchResult(
|
results.push_back(EventsSearchResult(
|
||||||
std::weak_ptr<gd::BaseEvent>(events.GetEventSmartPtr(i)),
|
std::weak_ptr<gd::BaseEvent>(events.GetEventSmartPtr(i)),
|
||||||
&events,
|
&events,
|
||||||
@@ -701,14 +744,14 @@ vector<EventsSearchResult> EventsRefactorer::SearchInEvents(
|
|||||||
|
|
||||||
if (events[i].CanHaveSubEvents()) {
|
if (events[i].CanHaveSubEvents()) {
|
||||||
vector<EventsSearchResult> subResults =
|
vector<EventsSearchResult> subResults =
|
||||||
SearchInEvents(project,
|
SearchInEvents(platform,
|
||||||
layout,
|
|
||||||
events[i].GetSubEvents(),
|
events[i].GetSubEvents(),
|
||||||
search,
|
search,
|
||||||
matchCase,
|
matchCase,
|
||||||
inConditions,
|
inConditions,
|
||||||
inActions,
|
inActions,
|
||||||
inEventStrings);
|
inEventStrings,
|
||||||
|
inEventSentences);
|
||||||
std::copy(
|
std::copy(
|
||||||
subResults.begin(), subResults.end(), std::back_inserter(results));
|
subResults.begin(), subResults.end(), std::back_inserter(results));
|
||||||
}
|
}
|
||||||
@@ -717,11 +760,12 @@ vector<EventsSearchResult> EventsRefactorer::SearchInEvents(
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventsRefactorer::SearchStringInActions(gd::ObjectsContainer& project,
|
bool EventsRefactorer::SearchStringInActions(
|
||||||
gd::ObjectsContainer& layout,
|
const gd::Platform& platform,
|
||||||
gd::InstructionsList& actions,
|
gd::InstructionsList& actions,
|
||||||
gd::String search,
|
gd::String search,
|
||||||
bool matchCase) {
|
bool matchCase,
|
||||||
|
bool inSentences) {
|
||||||
for (std::size_t aId = 0; aId < actions.size(); ++aId) {
|
for (std::size_t aId = 0; aId < actions.size(); ++aId) {
|
||||||
for (std::size_t pNb = 0; pNb < actions[aId].GetParameters().size();
|
for (std::size_t pNb = 0; pNb < actions[aId].GetParameters().size();
|
||||||
++pNb) {
|
++pNb) {
|
||||||
@@ -736,24 +780,60 @@ bool EventsRefactorer::SearchStringInActions(gd::ObjectsContainer& project,
|
|||||||
if (foundPosition != gd::String::npos) return true;
|
if (foundPosition != gd::String::npos) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inSentences && SearchStringInFormattedText(
|
||||||
|
platform, actions[aId], search, matchCase, false))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!actions[aId].GetSubInstructions().empty() &&
|
if (!actions[aId].GetSubInstructions().empty() &&
|
||||||
SearchStringInActions(project,
|
SearchStringInActions(platform,
|
||||||
layout,
|
|
||||||
actions[aId].GetSubInstructions(),
|
actions[aId].GetSubInstructions(),
|
||||||
search,
|
search,
|
||||||
matchCase))
|
matchCase,
|
||||||
|
inSentences))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EventsRefactorer::SearchStringInFormattedText(
|
||||||
|
const gd::Platform& platform,
|
||||||
|
gd::Instruction& instruction,
|
||||||
|
gd::String search,
|
||||||
|
bool matchCase,
|
||||||
|
bool isCondition) {
|
||||||
|
const auto& metadata = isCondition
|
||||||
|
? gd::MetadataProvider::GetConditionMetadata(
|
||||||
|
platform, instruction.GetType())
|
||||||
|
: gd::MetadataProvider::GetActionMetadata(
|
||||||
|
platform, instruction.GetType());
|
||||||
|
gd::String completeSentence = gd::InstructionSentenceFormatter::Get()->GetFullText(instruction, metadata);
|
||||||
|
|
||||||
|
const gd::String& ignored_characters = EventsRefactorer::searchIgnoredCharacters;
|
||||||
|
|
||||||
|
completeSentence.replace_if(completeSentence.begin(),
|
||||||
|
completeSentence.end(),
|
||||||
|
[ignored_characters](const char &c) {
|
||||||
|
return ignored_characters.find(c) != gd::String::npos;
|
||||||
|
},
|
||||||
|
"");
|
||||||
|
|
||||||
|
completeSentence.RemoveConsecutiveOccurrences(
|
||||||
|
completeSentence.begin(), completeSentence.end(), ' ');
|
||||||
|
|
||||||
|
size_t foundPosition = matchCase
|
||||||
|
? completeSentence.find(search)
|
||||||
|
: completeSentence.FindCaseInsensitive(search);
|
||||||
|
|
||||||
|
return foundPosition != gd::String::npos;
|
||||||
|
}
|
||||||
|
|
||||||
bool EventsRefactorer::SearchStringInConditions(
|
bool EventsRefactorer::SearchStringInConditions(
|
||||||
gd::ObjectsContainer& project,
|
const gd::Platform& platform,
|
||||||
gd::ObjectsContainer& layout,
|
|
||||||
gd::InstructionsList& conditions,
|
gd::InstructionsList& conditions,
|
||||||
gd::String search,
|
gd::String search,
|
||||||
bool matchCase) {
|
bool matchCase,
|
||||||
|
bool inSentences) {
|
||||||
for (std::size_t cId = 0; cId < conditions.size(); ++cId) {
|
for (std::size_t cId = 0; cId < conditions.size(); ++cId) {
|
||||||
for (std::size_t pNb = 0; pNb < conditions[cId].GetParameters().size();
|
for (std::size_t pNb = 0; pNb < conditions[cId].GetParameters().size();
|
||||||
++pNb) {
|
++pNb) {
|
||||||
@@ -768,23 +848,25 @@ bool EventsRefactorer::SearchStringInConditions(
|
|||||||
if (foundPosition != gd::String::npos) return true;
|
if (foundPosition != gd::String::npos) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inSentences && SearchStringInFormattedText(
|
||||||
|
platform, conditions[cId], search, matchCase, true))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!conditions[cId].GetSubInstructions().empty() &&
|
if (!conditions[cId].GetSubInstructions().empty() &&
|
||||||
SearchStringInConditions(project,
|
SearchStringInConditions(platform,
|
||||||
layout,
|
|
||||||
conditions[cId].GetSubInstructions(),
|
conditions[cId].GetSubInstructions(),
|
||||||
search,
|
search,
|
||||||
matchCase))
|
matchCase,
|
||||||
|
inSentences))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventsRefactorer::SearchStringInEvent(gd::ObjectsContainer& project,
|
bool EventsRefactorer::SearchStringInEvent(gd::BaseEvent& event,
|
||||||
gd::ObjectsContainer& layout,
|
gd::String search,
|
||||||
gd::BaseEvent& event,
|
bool matchCase) {
|
||||||
gd::String search,
|
|
||||||
bool matchCase) {
|
|
||||||
for (gd::String str : event.GetAllSearchableStrings()) {
|
for (gd::String str : event.GetAllSearchableStrings()) {
|
||||||
if (matchCase) {
|
if (matchCase) {
|
||||||
if (str.find(search) != gd::String::npos) return true;
|
if (str.find(search) != gd::String::npos) return true;
|
||||||
|
@@ -41,7 +41,7 @@ class GD_CORE_API EventsSearchResult {
|
|||||||
std::size_t positionInList;
|
std::size_t positionInList;
|
||||||
|
|
||||||
bool IsEventsListValid() const { return eventsList != nullptr; }
|
bool IsEventsListValid() const { return eventsList != nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the events list containing the event pointed by the EventsSearchResult.
|
* \brief Get the events list containing the event pointed by the EventsSearchResult.
|
||||||
* \warning Only call this when IsEventsListValid returns true.
|
* \warning Only call this when IsEventsListValid returns true.
|
||||||
@@ -49,7 +49,7 @@ class GD_CORE_API EventsSearchResult {
|
|||||||
const gd::EventsList & GetEventsList() const { return *eventsList; }
|
const gd::EventsList & GetEventsList() const { return *eventsList; }
|
||||||
|
|
||||||
std::size_t GetPositionInList() const { return positionInList; }
|
std::size_t GetPositionInList() const { return positionInList; }
|
||||||
|
|
||||||
bool IsEventValid() const { return !event.expired(); }
|
bool IsEventValid() const { return !event.expired(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +72,7 @@ class GD_CORE_API EventsSearchResult {
|
|||||||
class GD_CORE_API EventsRefactorer {
|
class GD_CORE_API EventsRefactorer {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Replace all occurences of an object name by another name
|
* Replace all occurrences of an object name by another name
|
||||||
* ( include : objects in parameters and in math/text expressions of all
|
* ( include : objects in parameters and in math/text expressions of all
|
||||||
* events ).
|
* events ).
|
||||||
*/
|
*/
|
||||||
@@ -98,14 +98,14 @@ class GD_CORE_API EventsRefactorer {
|
|||||||
* \return A vector containing EventsSearchResult objects filled with events
|
* \return A vector containing EventsSearchResult objects filled with events
|
||||||
* containing the string
|
* containing the string
|
||||||
*/
|
*/
|
||||||
static std::vector<EventsSearchResult> SearchInEvents(gd::ObjectsContainer& project,
|
static std::vector<EventsSearchResult> SearchInEvents(const gd::Platform& platform,
|
||||||
gd::ObjectsContainer& layout,
|
|
||||||
gd::EventsList& events,
|
gd::EventsList& events,
|
||||||
gd::String search,
|
gd::String search,
|
||||||
bool matchCase,
|
bool matchCase,
|
||||||
bool inConditions,
|
bool inConditions,
|
||||||
bool inActions,
|
bool inActions,
|
||||||
bool inEventStrings);
|
bool inEventStrings,
|
||||||
|
bool inEventSentences);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace all occurrences of a gd::String in events
|
* Replace all occurrences of a gd::String in events
|
||||||
@@ -123,7 +123,7 @@ class GD_CORE_API EventsRefactorer {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Replace all occurences of an object name by another name in an action
|
* Replace all occurrences of an object name by another name in an action
|
||||||
* ( include : objects in parameters and in math/text expressions ).
|
* ( include : objects in parameters and in math/text expressions ).
|
||||||
*
|
*
|
||||||
* \return true if something was modified.
|
* \return true if something was modified.
|
||||||
@@ -136,7 +136,7 @@ class GD_CORE_API EventsRefactorer {
|
|||||||
gd::String newName);
|
gd::String newName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace all occurences of an object name by another name in a condition
|
* Replace all occurrences of an object name by another name in a condition
|
||||||
* ( include : objects in parameters and in math/text expressions ).
|
* ( include : objects in parameters and in math/text expressions ).
|
||||||
*
|
*
|
||||||
* \return true if something was modified.
|
* \return true if something was modified.
|
||||||
@@ -185,7 +185,7 @@ class GD_CORE_API EventsRefactorer {
|
|||||||
gd::String name);
|
gd::String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace all occurences of a gd::String in conditions
|
* Replace all occurrences of a gd::String in conditions
|
||||||
*
|
*
|
||||||
* \return true if something was modified.
|
* \return true if something was modified.
|
||||||
*/
|
*/
|
||||||
@@ -197,7 +197,7 @@ class GD_CORE_API EventsRefactorer {
|
|||||||
bool matchCase);
|
bool matchCase);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace all occurences of a gd::String in actions
|
* Replace all occurrences of a gd::String in actions
|
||||||
*
|
*
|
||||||
* \return true if something was modified.
|
* \return true if something was modified.
|
||||||
*/
|
*/
|
||||||
@@ -208,21 +208,26 @@ class GD_CORE_API EventsRefactorer {
|
|||||||
gd::String newString,
|
gd::String newString,
|
||||||
bool matchCase);
|
bool matchCase);
|
||||||
|
|
||||||
static bool SearchStringInActions(gd::ObjectsContainer& project,
|
static bool SearchStringInFormattedText(const gd::Platform& platform,
|
||||||
gd::ObjectsContainer& layout,
|
gd::Instruction& instruction,
|
||||||
|
gd::String search,
|
||||||
|
bool matchCase,
|
||||||
|
bool isCondition);
|
||||||
|
static bool SearchStringInActions(const gd::Platform& platform,
|
||||||
gd::InstructionsList& actions,
|
gd::InstructionsList& actions,
|
||||||
gd::String search,
|
gd::String search,
|
||||||
bool matchCase);
|
bool matchCase,
|
||||||
static bool SearchStringInConditions(gd::ObjectsContainer& project,
|
bool inSentences);
|
||||||
gd::ObjectsContainer& layout,
|
static bool SearchStringInConditions(const gd::Platform& platform,
|
||||||
gd::InstructionsList& conditions,
|
gd::InstructionsList& conditions,
|
||||||
gd::String search,
|
gd::String search,
|
||||||
bool matchCase);
|
bool matchCase,
|
||||||
static bool SearchStringInEvent(gd::ObjectsContainer& project,
|
bool inSentences);
|
||||||
gd::ObjectsContainer& layout,
|
static bool SearchStringInEvent(gd::BaseEvent& events,
|
||||||
gd::BaseEvent& events,
|
gd::String search,
|
||||||
gd::String search,
|
bool matchCase);
|
||||||
bool matchCase);
|
|
||||||
|
static const gd::String searchIgnoredCharacters;
|
||||||
|
|
||||||
EventsRefactorer(){};
|
EventsRefactorer(){};
|
||||||
};
|
};
|
||||||
|
@@ -151,7 +151,7 @@ std::set<gd::String> EventsVariablesFinder::FindArgumentsInInstructions(
|
|||||||
|
|
||||||
for (std::size_t aId = 0; aId < instructions.size(); ++aId) {
|
for (std::size_t aId = 0; aId < instructions.size(); ++aId) {
|
||||||
gd::String lastObjectParameter = "";
|
gd::String lastObjectParameter = "";
|
||||||
gd::InstructionMetadata instrInfos =
|
const gd::InstructionMetadata& instrInfos =
|
||||||
instructionsAreConditions ? MetadataProvider::GetConditionMetadata(
|
instructionsAreConditions ? MetadataProvider::GetConditionMetadata(
|
||||||
platform, instructions[aId].GetType())
|
platform, instructions[aId].GetType())
|
||||||
: MetadataProvider::GetActionMetadata(
|
: MetadataProvider::GetActionMetadata(
|
||||||
|
@@ -9,12 +9,12 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
||||||
#include "GDCore/Events/Parsers/ExpressionParser2Node.h"
|
#include "GDCore/Events/Parsers/ExpressionParser2Node.h"
|
||||||
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
#include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
|
||||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||||
#include "GDCore/IDE/Events/ExpressionNodeLocationFinder.h"
|
#include "GDCore/IDE/Events/ExpressionNodeLocationFinder.h"
|
||||||
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
class Expression;
|
class Expression;
|
||||||
@@ -32,7 +32,7 @@ namespace gd {
|
|||||||
* The IDE is responsible for actually *searching* and showing the completions -
|
* The IDE is responsible for actually *searching* and showing the completions -
|
||||||
* this is only describing what must be listed.
|
* this is only describing what must be listed.
|
||||||
*/
|
*/
|
||||||
struct ExpressionCompletionDescription {
|
struct GD_CORE_API ExpressionCompletionDescription {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* The different kind of completions that can be described.
|
* The different kind of completions that can be described.
|
||||||
@@ -274,7 +274,7 @@ struct ExpressionCompletionDescription {
|
|||||||
/**
|
/**
|
||||||
* \brief Turn an ExpressionCompletionDescription to a string.
|
* \brief Turn an ExpressionCompletionDescription to a string.
|
||||||
*/
|
*/
|
||||||
std::ostream& operator<<(std::ostream& os,
|
GD_CORE_API std::ostream& operator<<(std::ostream& os,
|
||||||
ExpressionCompletionDescription const& value);
|
ExpressionCompletionDescription const& value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -326,10 +326,7 @@ class GD_CORE_API ExpressionCompletionFinder
|
|||||||
node.type, "", searchedPosition + 1, searchedPosition + 1));
|
node.type, "", searchedPosition + 1, searchedPosition + 1));
|
||||||
}
|
}
|
||||||
void OnVisitOperatorNode(OperatorNode& node) override {
|
void OnVisitOperatorNode(OperatorNode& node) override {
|
||||||
completions.push_back(ExpressionCompletionDescription::ForObject(
|
// No completions.
|
||||||
node.type, "", searchedPosition + 1, searchedPosition + 1));
|
|
||||||
completions.push_back(ExpressionCompletionDescription::ForExpression(
|
|
||||||
node.type, "", searchedPosition + 1, searchedPosition + 1));
|
|
||||||
}
|
}
|
||||||
void OnVisitUnaryOperatorNode(UnaryOperatorNode& node) override {
|
void OnVisitUnaryOperatorNode(UnaryOperatorNode& node) override {
|
||||||
completions.push_back(ExpressionCompletionDescription::ForObject(
|
completions.push_back(ExpressionCompletionDescription::ForObject(
|
||||||
@@ -359,8 +356,9 @@ class GD_CORE_API ExpressionCompletionFinder
|
|||||||
}
|
}
|
||||||
// Search the parameter metadata index skipping invisible ones.
|
// Search the parameter metadata index skipping invisible ones.
|
||||||
size_t visibleParameterIndex = 0;
|
size_t visibleParameterIndex = 0;
|
||||||
size_t metadataParameterIndex = ExpressionParser2::WrittenParametersFirstIndex(
|
size_t metadataParameterIndex =
|
||||||
functionCall->objectName, functionCall->behaviorName);
|
ExpressionParser2::WrittenParametersFirstIndex(
|
||||||
|
functionCall->objectName, functionCall->behaviorName);
|
||||||
|
|
||||||
const gd::ParameterMetadata* parameterMetadata = nullptr;
|
const gd::ParameterMetadata* parameterMetadata = nullptr;
|
||||||
while (metadataParameterIndex <
|
while (metadataParameterIndex <
|
||||||
|
@@ -4,9 +4,11 @@
|
|||||||
* reserved. This project is released under the MIT License.
|
* reserved. This project is released under the MIT License.
|
||||||
*/
|
*/
|
||||||
#include "GDCore/IDE/Events/ExpressionsParameterMover.h"
|
#include "GDCore/IDE/Events/ExpressionsParameterMover.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "GDCore/Events/Event.h"
|
#include "GDCore/Events/Event.h"
|
||||||
#include "GDCore/Events/EventsList.h"
|
#include "GDCore/Events/EventsList.h"
|
||||||
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
||||||
@@ -134,10 +136,11 @@ class GD_CORE_API ExpressionParameterMover
|
|||||||
|
|
||||||
bool ExpressionsParameterMover::DoVisitInstruction(gd::Instruction& instruction,
|
bool ExpressionsParameterMover::DoVisitInstruction(gd::Instruction& instruction,
|
||||||
bool isCondition) {
|
bool isCondition) {
|
||||||
auto& metadata = isCondition ? gd::MetadataProvider::GetConditionMetadata(
|
const auto& metadata = isCondition
|
||||||
platform, instruction.GetType())
|
? gd::MetadataProvider::GetConditionMetadata(
|
||||||
: gd::MetadataProvider::GetActionMetadata(
|
platform, instruction.GetType())
|
||||||
platform, instruction.GetType());
|
: gd::MetadataProvider::GetActionMetadata(
|
||||||
|
platform, instruction.GetType());
|
||||||
|
|
||||||
for (std::size_t pNb = 0; pNb < metadata.parameters.size() &&
|
for (std::size_t pNb = 0; pNb < metadata.parameters.size() &&
|
||||||
pNb < instruction.GetParametersCount();
|
pNb < instruction.GetParametersCount();
|
||||||
|
@@ -4,9 +4,11 @@
|
|||||||
* reserved. This project is released under the MIT License.
|
* reserved. This project is released under the MIT License.
|
||||||
*/
|
*/
|
||||||
#include "GDCore/IDE/Events/ExpressionsRenamer.h"
|
#include "GDCore/IDE/Events/ExpressionsRenamer.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "GDCore/Events/Event.h"
|
#include "GDCore/Events/Event.h"
|
||||||
#include "GDCore/Events/EventsList.h"
|
#include "GDCore/Events/EventsList.h"
|
||||||
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
#include "GDCore/Events/Parsers/ExpressionParser2.h"
|
||||||
@@ -145,10 +147,11 @@ class GD_CORE_API ExpressionFunctionRenamer
|
|||||||
|
|
||||||
bool ExpressionsRenamer::DoVisitInstruction(gd::Instruction& instruction,
|
bool ExpressionsRenamer::DoVisitInstruction(gd::Instruction& instruction,
|
||||||
bool isCondition) {
|
bool isCondition) {
|
||||||
auto& metadata = isCondition ? gd::MetadataProvider::GetConditionMetadata(
|
const auto& metadata = isCondition
|
||||||
platform, instruction.GetType())
|
? gd::MetadataProvider::GetConditionMetadata(
|
||||||
: gd::MetadataProvider::GetActionMetadata(
|
platform, instruction.GetType())
|
||||||
platform, instruction.GetType());
|
: gd::MetadataProvider::GetActionMetadata(
|
||||||
|
platform, instruction.GetType());
|
||||||
|
|
||||||
for (std::size_t pNb = 0; pNb < metadata.parameters.size() &&
|
for (std::size_t pNb = 0; pNb < metadata.parameters.size() &&
|
||||||
pNb < instruction.GetParametersCount();
|
pNb < instruction.GetParametersCount();
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
* reserved. This project is released under the MIT License.
|
* reserved. This project is released under the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
#include "GDCore/IDE/Events/InstructionSentenceFormatter.h"
|
#include "GDCore/IDE/Events/InstructionSentenceFormatter.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -90,6 +89,19 @@ InstructionSentenceFormatter::GetAsFormattedText(
|
|||||||
return formattedStr;
|
return formattedStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
gd::String InstructionSentenceFormatter::GetFullText(
|
||||||
|
const gd::Instruction &instr, const gd::InstructionMetadata &metadata)
|
||||||
|
{
|
||||||
|
const std::vector<std::pair<gd::String, gd::TextFormatting> > formattedText =
|
||||||
|
GetAsFormattedText(instr, metadata);
|
||||||
|
|
||||||
#endif
|
gd::String completeSentence = "";
|
||||||
|
|
||||||
|
for (std::size_t id = 0; id < formattedText.size(); ++id) {
|
||||||
|
completeSentence += formattedText.at(id).first;
|
||||||
|
}
|
||||||
|
|
||||||
|
return completeSentence;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace gd
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
* reserved. This project is released under the MIT License.
|
* reserved. This project is released under the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(GD_IDE_ONLY)
|
|
||||||
#ifndef TRANSLATEACTION_H
|
#ifndef TRANSLATEACTION_H
|
||||||
#define TRANSLATEACTION_H
|
#define TRANSLATEACTION_H
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -39,6 +38,9 @@ class GD_CORE_API InstructionSentenceFormatter {
|
|||||||
return (static_cast<InstructionSentenceFormatter *>(_singleton));
|
return (static_cast<InstructionSentenceFormatter *>(_singleton));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gd::String GetFullText(const gd::Instruction &instr,
|
||||||
|
const gd::InstructionMetadata &metadata);
|
||||||
|
|
||||||
static void DestroySingleton() {
|
static void DestroySingleton() {
|
||||||
if (NULL != _singleton) {
|
if (NULL != _singleton) {
|
||||||
delete _singleton;
|
delete _singleton;
|
||||||
@@ -55,4 +57,3 @@ class GD_CORE_API InstructionSentenceFormatter {
|
|||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
#endif // TRANSLATEACTION_H
|
#endif // TRANSLATEACTION_H
|
||||||
#endif
|
|
||||||
|
@@ -19,12 +19,15 @@ bool InstructionsParameterMover::DoVisitInstruction(
|
|||||||
gd::Instruction& instruction, bool isCondition) {
|
gd::Instruction& instruction, bool isCondition) {
|
||||||
if (instruction.GetType() == instructionType) {
|
if (instruction.GetType() == instructionType) {
|
||||||
std::vector<gd::Expression> updatedParameters = instruction.GetParameters();
|
std::vector<gd::Expression> updatedParameters = instruction.GetParameters();
|
||||||
if (oldIndex < updatedParameters.size() ||
|
if (oldIndex < updatedParameters.size()) {
|
||||||
newIndex < updatedParameters.size()) {
|
gd::Expression movedParameter = updatedParameters.at(oldIndex);
|
||||||
gd::Expression movedParameter = updatedParameters[oldIndex];
|
|
||||||
updatedParameters.erase(updatedParameters.begin() + oldIndex);
|
updatedParameters.erase(updatedParameters.begin() + oldIndex);
|
||||||
updatedParameters.insert(updatedParameters.begin() + newIndex,
|
if (newIndex < updatedParameters.size()) {
|
||||||
movedParameter);
|
updatedParameters.insert(updatedParameters.begin() + newIndex,
|
||||||
|
movedParameter);
|
||||||
|
} else {
|
||||||
|
updatedParameters.push_back(movedParameter);
|
||||||
|
}
|
||||||
instruction.SetParameters(updatedParameters);
|
instruction.SetParameters(updatedParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,16 +4,20 @@
|
|||||||
* reserved. This project is released under the MIT License.
|
* reserved. This project is released under the MIT License.
|
||||||
*/
|
*/
|
||||||
#include "EventsFunctionTools.h"
|
#include "EventsFunctionTools.h"
|
||||||
|
|
||||||
#include "GDCore/Events/Expression.h"
|
#include "GDCore/Events/Expression.h"
|
||||||
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||||
|
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||||
#include "GDCore/Project/EventsFunction.h"
|
#include "GDCore/Project/EventsFunction.h"
|
||||||
#include "GDCore/Project/Object.h"
|
#include "GDCore/Project/Object.h"
|
||||||
#include "GDCore/Project/ObjectsContainer.h"
|
#include "GDCore/Project/ObjectsContainer.h"
|
||||||
#include "GDCore/Project/Project.h"
|
#include "GDCore/Project/Project.h"
|
||||||
#include "GDCore/String.h"
|
#include "GDCore/String.h"
|
||||||
|
#include "GDCore/Tools/Log.h"
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
void EventsFunctionTools::EventsFunctionToObjectsContainer(
|
|
||||||
|
void EventsFunctionTools::FreeEventsFunctionToObjectsContainer(
|
||||||
gd::Project& project,
|
gd::Project& project,
|
||||||
const gd::EventsFunction& eventsFunction,
|
const gd::EventsFunction& eventsFunction,
|
||||||
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||||
@@ -31,4 +35,41 @@ void EventsFunctionTools::EventsFunctionToObjectsContainer(
|
|||||||
outputObjectsContainer.GetObjectGroups() = eventsFunction.GetObjectGroups();
|
outputObjectsContainer.GetObjectGroups() = eventsFunction.GetObjectGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventsFunctionTools::BehaviorEventsFunctionToObjectsContainer(
|
||||||
|
gd::Project& project,
|
||||||
|
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||||
|
const gd::EventsFunction& eventsFunction,
|
||||||
|
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||||
|
gd::ObjectsContainer& outputObjectsContainer) {
|
||||||
|
// The context is build the same way as free function...
|
||||||
|
FreeEventsFunctionToObjectsContainer(project,
|
||||||
|
eventsFunction,
|
||||||
|
outputGlobalObjectsContainer,
|
||||||
|
outputObjectsContainer);
|
||||||
|
|
||||||
|
// ...and has an "Object" by convention...
|
||||||
|
if (!outputObjectsContainer.HasObjectNamed("Object")) {
|
||||||
|
gd::LogWarning("No \"Object\" in a function of an events based behavior: " +
|
||||||
|
eventsFunction.GetName() +
|
||||||
|
". This means this function is likely misconfigured (check "
|
||||||
|
"its parameters).");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...with behaviors from properties.
|
||||||
|
gd::Object& thisObject = outputObjectsContainer.GetObject("Object");
|
||||||
|
for (size_t i = 0;
|
||||||
|
i < eventsBasedBehavior.GetPropertyDescriptors().GetCount();
|
||||||
|
i++) {
|
||||||
|
const NamedPropertyDescriptor& propertyDescriptor =
|
||||||
|
eventsBasedBehavior.GetPropertyDescriptors().Get(i);
|
||||||
|
const std::vector<gd::String>& extraInfo =
|
||||||
|
propertyDescriptor.GetExtraInfo();
|
||||||
|
if (propertyDescriptor.GetType() == "Behavior" && extraInfo.size() > 0) {
|
||||||
|
gd::String behaviorName = propertyDescriptor.GetName();
|
||||||
|
thisObject.AddNewBehavior(project, extraInfo.at(0), behaviorName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -13,6 +13,7 @@ class Project;
|
|||||||
class ObjectsContainer;
|
class ObjectsContainer;
|
||||||
class ParameterMetadata;
|
class ParameterMetadata;
|
||||||
class EventsFunction;
|
class EventsFunction;
|
||||||
|
class EventsBasedBehavior;
|
||||||
class Expression;
|
class Expression;
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
|
||||||
@@ -23,18 +24,33 @@ namespace gd {
|
|||||||
class GD_CORE_API EventsFunctionTools {
|
class GD_CORE_API EventsFunctionTools {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* \brief Given an events function, initialize the given objects container
|
* \brief Given a free events function, initialize the given objects container
|
||||||
* with objects described in the events function parameters and in
|
* with objects described in the events function parameters and in
|
||||||
* the events function groups.
|
* the events function groups.
|
||||||
*
|
*
|
||||||
* This is useful to create the "context" of a function, before code
|
* This is useful to create the "context" of a function, before code
|
||||||
* generation for example.
|
* generation for example.
|
||||||
*/
|
*/
|
||||||
static void EventsFunctionToObjectsContainer(
|
static void FreeEventsFunctionToObjectsContainer(
|
||||||
gd::Project& project,
|
gd::Project& project,
|
||||||
const gd::EventsFunction& eventsFunction,
|
const gd::EventsFunction& eventsFunction,
|
||||||
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||||
gd::ObjectsContainer& outputObjectsContainer);
|
gd::ObjectsContainer& outputObjectsContainer);
|
||||||
|
/**
|
||||||
|
* \brief Given a behavior events function, initialize the given objects container
|
||||||
|
* with objects described in the events function parameters, in
|
||||||
|
* the events function groups and in the behavior properties (for additional
|
||||||
|
* required behaviors on the object).
|
||||||
|
*
|
||||||
|
* This is useful to create the "context" of a function, before code
|
||||||
|
* generation for example.
|
||||||
|
*/
|
||||||
|
static void BehaviorEventsFunctionToObjectsContainer(
|
||||||
|
gd::Project& project,
|
||||||
|
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||||
|
const gd::EventsFunction& eventsFunction,
|
||||||
|
gd::ObjectsContainer& outputGlobalObjectsContainer,
|
||||||
|
gd::ObjectsContainer& outputObjectsContainer);
|
||||||
};
|
};
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
|
||||||
|
@@ -27,50 +27,6 @@ namespace gd {
|
|||||||
|
|
||||||
PlatformLoader::PlatformLoader() {}
|
PlatformLoader::PlatformLoader() {}
|
||||||
|
|
||||||
void PlatformLoader::LoadAllPlatformsInManager(gd::String dir) {
|
|
||||||
{
|
|
||||||
#if defined(WINDOWS)
|
|
||||||
std::shared_ptr<gd::Platform> platform = LoadPlatformInManager("GDCpp.dll");
|
|
||||||
#elif defined(LINUX)
|
|
||||||
std::shared_ptr<gd::Platform> platform =
|
|
||||||
LoadPlatformInManager("libGDCpp.so");
|
|
||||||
#elif defined(MACOS)
|
|
||||||
std::shared_ptr<gd::Platform> platform =
|
|
||||||
LoadPlatformInManager("libGDCpp.dylib");
|
|
||||||
#else
|
|
||||||
#warning Add the appropriate filename here for the C++ Platform!
|
|
||||||
std::shared_ptr<gd::Platform> platform;
|
|
||||||
#endif
|
|
||||||
if (platform)
|
|
||||||
gd::ExtensionsLoader::LoadAllExtensions("./CppPlatform/Extensions/",
|
|
||||||
*platform);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
#if defined(WINDOWS)
|
|
||||||
std::shared_ptr<gd::Platform> platform =
|
|
||||||
LoadPlatformInManager("./JsPlatform/GDJS.dll");
|
|
||||||
#elif defined(LINUX)
|
|
||||||
std::shared_ptr<gd::Platform> platform =
|
|
||||||
LoadPlatformInManager("./JsPlatform/libGDJS.so");
|
|
||||||
#elif defined(MACOS)
|
|
||||||
std::shared_ptr<gd::Platform> platform =
|
|
||||||
LoadPlatformInManager("./JsPlatform/libGDJS.dylib");
|
|
||||||
#else
|
|
||||||
#warning Add the appropriate filename here for the Js Platform!
|
|
||||||
std::shared_ptr<gd::Platform> platform;
|
|
||||||
#endif
|
|
||||||
if (platform)
|
|
||||||
gd::ExtensionsLoader::LoadAllExtensions("./JsPlatform/Extensions/",
|
|
||||||
*platform);
|
|
||||||
if (platform)
|
|
||||||
gd::ExtensionsLoader::LoadAllExtensions(
|
|
||||||
"./CppPlatform/Extensions/", *platform, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
gd::ExtensionsLoader::ExtensionsLoadingDone("./CppPlatform/Extensions/");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<gd::Platform> PlatformLoader::LoadPlatformInManager(
|
std::shared_ptr<gd::Platform> PlatformLoader::LoadPlatformInManager(
|
||||||
gd::String fullpath) {
|
gd::String fullpath) {
|
||||||
std::cout << "Loading platform " << fullpath << "..." << std::endl;
|
std::cout << "Loading platform " << fullpath << "..." << std::endl;
|
||||||
|
@@ -30,15 +30,6 @@ passing
|
|||||||
*/
|
*/
|
||||||
class GD_CORE_API PlatformLoader {
|
class GD_CORE_API PlatformLoader {
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* Load all the platforms available in a directory.
|
|
||||||
*
|
|
||||||
* \param dir The directory where platforms must be searched for.
|
|
||||||
*
|
|
||||||
* \todo For now, only GDCpp.dll and GDJS.dll are loaded.
|
|
||||||
*/
|
|
||||||
static void LoadAllPlatformsInManager(gd::String dir);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a specific platform.
|
* Load a specific platform.
|
||||||
*
|
*
|
||||||
|
@@ -13,8 +13,11 @@
|
|||||||
#include "GDCore/Events/Event.h"
|
#include "GDCore/Events/Event.h"
|
||||||
#include "GDCore/Events/EventsList.h"
|
#include "GDCore/Events/EventsList.h"
|
||||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||||
|
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||||
|
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||||
#include "GDCore/Extensions/Platform.h"
|
#include "GDCore/Extensions/Platform.h"
|
||||||
#include "GDCore/Extensions/PlatformExtension.h"
|
#include "GDCore/Extensions/PlatformExtension.h"
|
||||||
|
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||||
#include "GDCore/Project/Project.h"
|
#include "GDCore/Project/Project.h"
|
||||||
#include "GDCore/Project/ResourcesManager.h"
|
#include "GDCore/Project/ResourcesManager.h"
|
||||||
|
|
||||||
@@ -23,8 +26,23 @@ using namespace std;
|
|||||||
namespace gd {
|
namespace gd {
|
||||||
|
|
||||||
void ArbitraryResourceWorker::ExposeImage(gd::String& imageName){
|
void ArbitraryResourceWorker::ExposeImage(gd::String& imageName){
|
||||||
// Nothing to do, the image is a reference to a resource that
|
// Nothing to do by default - each child class can define here the action to
|
||||||
// is already exposed.
|
// do.
|
||||||
|
};
|
||||||
|
|
||||||
|
void ArbitraryResourceWorker::ExposeJson(gd::String& jsonName){
|
||||||
|
// Nothing to do by default - each child class can define here the action to
|
||||||
|
// do.
|
||||||
|
};
|
||||||
|
|
||||||
|
void ArbitraryResourceWorker::ExposeVideo(gd::String& videoName){
|
||||||
|
// Nothing to do by default - each child class can define here the action to
|
||||||
|
// do.
|
||||||
|
};
|
||||||
|
|
||||||
|
void ArbitraryResourceWorker::ExposeBitmapFont(gd::String& bitmapFontName){
|
||||||
|
// Nothing to do by default - each child class can define here the action to
|
||||||
|
// do.
|
||||||
};
|
};
|
||||||
|
|
||||||
void ArbitraryResourceWorker::ExposeAudio(gd::String& audioName) {
|
void ArbitraryResourceWorker::ExposeAudio(gd::String& audioName) {
|
||||||
@@ -33,12 +51,14 @@ void ArbitraryResourceWorker::ExposeAudio(gd::String& audioName) {
|
|||||||
|
|
||||||
if (resources->HasResource(audioName) &&
|
if (resources->HasResource(audioName) &&
|
||||||
resources->GetResource(audioName).GetKind() == "audio") {
|
resources->GetResource(audioName).GetKind() == "audio") {
|
||||||
// Nothing to do, the audio is a reference to a resource that
|
// Nothing to do, the audio is a reference to a proper resource.
|
||||||
// is already exposed.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For compatibility with older projects (where events were refering to files
|
||||||
|
// directly), we consider that this resource name is a filename, and so expose
|
||||||
|
// it as a file.
|
||||||
ExposeFile(audioName);
|
ExposeFile(audioName);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,30 +68,17 @@ void ArbitraryResourceWorker::ExposeFont(gd::String& fontName) {
|
|||||||
|
|
||||||
if (resources->HasResource(fontName) &&
|
if (resources->HasResource(fontName) &&
|
||||||
resources->GetResource(fontName).GetKind() == "font") {
|
resources->GetResource(fontName).GetKind() == "font") {
|
||||||
// Nothing to do, the font is a reference to a resource that
|
// Nothing to do, the font is a reference to a proper resource.
|
||||||
// is already exposed.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For compatibility with older projects (where events were refering to files
|
||||||
|
// directly), we consider that this resource name is a filename, and so expose
|
||||||
|
// it as a file.
|
||||||
ExposeFile(fontName);
|
ExposeFile(fontName);
|
||||||
};
|
};
|
||||||
|
|
||||||
void ArbitraryResourceWorker::ExposeBitmapFont(gd::String& bitmapFontName) {
|
|
||||||
for (auto resources : GetResources()) {
|
|
||||||
if (!resources) continue;
|
|
||||||
|
|
||||||
if (resources->HasResource(bitmapFontName) &&
|
|
||||||
resources->GetResource(bitmapFontName).GetKind() == "bitmapFont") {
|
|
||||||
// Nothing to do, the font is a reference to a resource that
|
|
||||||
// is already exposed.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ExposeFile(bitmapFontName);
|
|
||||||
};
|
|
||||||
|
|
||||||
void ArbitraryResourceWorker::ExposeResources(
|
void ArbitraryResourceWorker::ExposeResources(
|
||||||
gd::ResourcesManager* resourcesManager) {
|
gd::ResourcesManager* resourcesManager) {
|
||||||
if (!resourcesManager) return;
|
if (!resourcesManager) return;
|
||||||
@@ -95,101 +102,67 @@ void ArbitraryResourceWorker::ExposeResource(gd::Resource& resource) {
|
|||||||
|
|
||||||
ArbitraryResourceWorker::~ArbitraryResourceWorker() {}
|
ArbitraryResourceWorker::~ArbitraryResourceWorker() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch the specified resource worker on every resource referenced in the
|
||||||
|
* events.
|
||||||
|
*/
|
||||||
|
class ResourceWorkerInEventsWorker : public ArbitraryEventsWorker {
|
||||||
|
public:
|
||||||
|
ResourceWorkerInEventsWorker(const gd::Project& project_,
|
||||||
|
gd::ArbitraryResourceWorker& worker_)
|
||||||
|
: project(project_), worker(worker_){};
|
||||||
|
virtual ~ResourceWorkerInEventsWorker() {};
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool DoVisitInstruction(gd::Instruction& instruction, bool isCondition) {
|
||||||
|
const auto& platform = project.GetCurrentPlatform();
|
||||||
|
const auto& metadata = isCondition
|
||||||
|
? gd::MetadataProvider::GetConditionMetadata(
|
||||||
|
platform, instruction.GetType())
|
||||||
|
: gd::MetadataProvider::GetActionMetadata(
|
||||||
|
platform, instruction.GetType());
|
||||||
|
|
||||||
|
gd::ParameterMetadataTools::IterateOverParametersWithIndex(
|
||||||
|
instruction.GetParameters(),
|
||||||
|
metadata.GetParameters(),
|
||||||
|
[this, &instruction](const gd::ParameterMetadata& parameterMetadata,
|
||||||
|
const gd::String& parameterValue,
|
||||||
|
size_t parameterIndex,
|
||||||
|
const gd::String& lastObjectName) {
|
||||||
|
if (parameterMetadata.GetType() ==
|
||||||
|
"police") { // Should be renamed fontResource
|
||||||
|
gd::String updatedParameterValue = parameterValue;
|
||||||
|
worker.ExposeFont(updatedParameterValue);
|
||||||
|
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||||
|
} else if (parameterMetadata.GetType() == "soundfile" ||
|
||||||
|
parameterMetadata.GetType() ==
|
||||||
|
"musicfile") { // Should be renamed audioResource
|
||||||
|
gd::String updatedParameterValue = parameterValue;
|
||||||
|
worker.ExposeAudio(updatedParameterValue);
|
||||||
|
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||||
|
} else if (parameterMetadata.GetType() == "bitmapFontResource") {
|
||||||
|
gd::String updatedParameterValue = parameterValue;
|
||||||
|
worker.ExposeBitmapFont(updatedParameterValue);
|
||||||
|
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||||
|
} else if (parameterMetadata.GetType() == "imageResource") {
|
||||||
|
gd::String updatedParameterValue = parameterValue;
|
||||||
|
worker.ExposeImage(updatedParameterValue);
|
||||||
|
instruction.SetParameter(parameterIndex, updatedParameterValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const gd::Project& project;
|
||||||
|
gd::ArbitraryResourceWorker& worker;
|
||||||
|
};
|
||||||
|
|
||||||
void LaunchResourceWorkerOnEvents(const gd::Project& project,
|
void LaunchResourceWorkerOnEvents(const gd::Project& project,
|
||||||
gd::EventsList& events,
|
gd::EventsList& events,
|
||||||
gd::ArbitraryResourceWorker& worker) {
|
gd::ArbitraryResourceWorker& worker) {
|
||||||
// Get all extensions used
|
ResourceWorkerInEventsWorker eventsWorker(project, worker);
|
||||||
auto allGameExtensions =
|
eventsWorker.Launch(events);
|
||||||
project.GetCurrentPlatform().GetAllPlatformExtensions();
|
|
||||||
|
|
||||||
for (std::size_t j = 0; j < events.size(); j++) {
|
|
||||||
vector<gd::InstructionsList*> allActionsVectors =
|
|
||||||
events[j].GetAllActionsVectors();
|
|
||||||
for (std::size_t i = 0; i < allActionsVectors.size(); ++i) {
|
|
||||||
for (std::size_t k = 0; k < allActionsVectors[i]->size(); k++) {
|
|
||||||
gd::String type = allActionsVectors[i]->Get(k).GetType();
|
|
||||||
for (std::size_t e = 0; e < allGameExtensions.size(); ++e) {
|
|
||||||
bool extensionHasAction = false;
|
|
||||||
|
|
||||||
const std::map<gd::String, gd::InstructionMetadata>& allActions =
|
|
||||||
allGameExtensions[e]->GetAllActions();
|
|
||||||
if (allActions.find(type) != allActions.end())
|
|
||||||
extensionHasAction = true;
|
|
||||||
|
|
||||||
const vector<gd::String>& objects =
|
|
||||||
allGameExtensions[e]->GetExtensionObjectsTypes();
|
|
||||||
for (std::size_t o = 0; o < objects.size(); ++o) {
|
|
||||||
const std::map<gd::String, gd::InstructionMetadata>&
|
|
||||||
allObjectsActions =
|
|
||||||
allGameExtensions[e]->GetAllActionsForObject(objects[o]);
|
|
||||||
if (allObjectsActions.find(type) != allObjectsActions.end())
|
|
||||||
extensionHasAction = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const vector<gd::String>& autos =
|
|
||||||
allGameExtensions[e]->GetBehaviorsTypes();
|
|
||||||
for (std::size_t a = 0; a < autos.size(); ++a) {
|
|
||||||
const std::map<gd::String, gd::InstructionMetadata>&
|
|
||||||
allAutosActions =
|
|
||||||
allGameExtensions[e]->GetAllActionsForBehavior(autos[a]);
|
|
||||||
if (allAutosActions.find(type) != allAutosActions.end())
|
|
||||||
extensionHasAction = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extensionHasAction) {
|
|
||||||
allGameExtensions[e]->ExposeActionsResources(
|
|
||||||
allActionsVectors[i]->Get(k), worker);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<gd::InstructionsList*> allConditionsVector =
|
|
||||||
events[j].GetAllConditionsVectors();
|
|
||||||
for (std::size_t i = 0; i < allConditionsVector.size(); ++i) {
|
|
||||||
for (std::size_t k = 0; k < allConditionsVector[i]->size(); k++) {
|
|
||||||
gd::String type = allConditionsVector[i]->Get(k).GetType();
|
|
||||||
for (std::size_t e = 0; e < allGameExtensions.size(); ++e) {
|
|
||||||
bool extensionHasCondition = false;
|
|
||||||
|
|
||||||
const std::map<gd::String, gd::InstructionMetadata>& allConditions =
|
|
||||||
allGameExtensions[e]->GetAllConditions();
|
|
||||||
if (allConditions.find(type) != allConditions.end())
|
|
||||||
extensionHasCondition = true;
|
|
||||||
|
|
||||||
const vector<gd::String>& objects =
|
|
||||||
allGameExtensions[e]->GetExtensionObjectsTypes();
|
|
||||||
for (std::size_t j = 0; j < objects.size(); ++j) {
|
|
||||||
const std::map<gd::String, gd::InstructionMetadata>&
|
|
||||||
allObjectsConditions =
|
|
||||||
allGameExtensions[e]->GetAllConditionsForObject(objects[j]);
|
|
||||||
if (allObjectsConditions.find(type) != allObjectsConditions.end())
|
|
||||||
extensionHasCondition = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const vector<gd::String>& autos =
|
|
||||||
allGameExtensions[e]->GetBehaviorsTypes();
|
|
||||||
for (std::size_t j = 0; j < autos.size(); ++j) {
|
|
||||||
const std::map<gd::String, gd::InstructionMetadata>&
|
|
||||||
allAutosConditions =
|
|
||||||
allGameExtensions[e]->GetAllConditionsForBehavior(autos[j]);
|
|
||||||
if (allAutosConditions.find(type) != allAutosConditions.end())
|
|
||||||
extensionHasCondition = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extensionHasCondition)
|
|
||||||
allGameExtensions[e]->ExposeConditionsResources(
|
|
||||||
allConditionsVector[i]->Get(k), worker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (events[j].CanHaveSubEvents())
|
|
||||||
LaunchResourceWorkerOnEvents(project, events[j].GetSubEvents(), worker);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
@@ -60,19 +60,28 @@ class GD_CORE_API ArbitraryResourceWorker {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Expose an audio, which is either a reference to an "audio" resource,
|
* \brief Expose an audio, which is either a reference to an "audio" resource,
|
||||||
* or a filename if no resource with this name exists.
|
* or a filename if no resource with this name exists (for backward compatibility).
|
||||||
*/
|
*/
|
||||||
virtual void ExposeAudio(gd::String &audioName);
|
virtual void ExposeAudio(gd::String &audioName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Expose a font, which is either a reference to a "font" resource,
|
* \brief Expose a font, which is either a reference to a "font" resource,
|
||||||
* or a filename if no resource with this name exists.
|
* or a filename if no resource with this name exists (for backward compatibility).
|
||||||
*/
|
*/
|
||||||
virtual void ExposeFont(gd::String &fontName);
|
virtual void ExposeFont(gd::String &fontName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Expose a bitmap font, which is either a reference to a "bitmapFont" resource,
|
* \brief Expose a JSON, which is always a reference to a "json" resource.
|
||||||
* or a filename if no resource with this name exists.
|
*/
|
||||||
|
virtual void ExposeJson(gd::String &jsonName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Expose a video, which is always a reference to a "video" resource.
|
||||||
|
*/
|
||||||
|
virtual void ExposeVideo(gd::String &videoName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Expose a bitmap font, which is always a reference to a "bitmapFont" resource.
|
||||||
*/
|
*/
|
||||||
virtual void ExposeBitmapFont(gd::String &bitmapFontName);
|
virtual void ExposeBitmapFont(gd::String &bitmapFontName);
|
||||||
|
|
||||||
|
@@ -14,25 +14,6 @@ using namespace std;
|
|||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
|
|
||||||
bool ProjectResourcesAdder::AddAllMissing(gd::Project& project,
|
|
||||||
const gd::String& resourceType) {
|
|
||||||
// Search for resources used in the project
|
|
||||||
gd::ResourcesInUseHelper resourcesInUse;
|
|
||||||
project.ExposeResources(resourcesInUse);
|
|
||||||
|
|
||||||
ResourcesManager& resourcesManager = project.GetResourcesManager();
|
|
||||||
for (auto& resourceName : resourcesInUse.GetAll(resourceType)) {
|
|
||||||
if (!resourcesManager.HasResource(resourceName)) {
|
|
||||||
std::cout << "Adding missing resource \"" << resourceName
|
|
||||||
<< "\"to the project." << std::endl;
|
|
||||||
resourcesManager.AddResource(
|
|
||||||
resourceName, /*filename=*/resourceName, resourceType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<gd::String> ProjectResourcesAdder::GetAllUseless(
|
std::vector<gd::String> ProjectResourcesAdder::GetAllUseless(
|
||||||
gd::Project& project, const gd::String& resourceType) {
|
gd::Project& project, const gd::String& resourceType) {
|
||||||
std::vector<gd::String> unusedResources;
|
std::vector<gd::String> unusedResources;
|
||||||
@@ -42,15 +23,13 @@ std::vector<gd::String> ProjectResourcesAdder::GetAllUseless(
|
|||||||
std::set<gd::String>& usedResources = resourcesInUse.GetAll(resourceType);
|
std::set<gd::String>& usedResources = resourcesInUse.GetAll(resourceType);
|
||||||
|
|
||||||
// Search all resources not used
|
// Search all resources not used
|
||||||
std::vector<gd::String> resources =
|
const std::vector<std::shared_ptr<Resource>>& resources =
|
||||||
project.GetResourcesManager().GetAllResourceNames();
|
project.GetResourcesManager().GetAllResources();
|
||||||
for (std::size_t i = 0; i < resources.size(); i++) {
|
for (std::size_t i = 0; i < resources.size(); i++) {
|
||||||
if (project.GetResourcesManager().GetResource(resources[i]).GetKind() !=
|
if (resources[i]->GetKind() != resourceType) continue;
|
||||||
resourceType)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (usedResources.find(resources[i]) == usedResources.end())
|
if (usedResources.find(resources[i]->GetName()) == usedResources.end())
|
||||||
unusedResources.push_back(resources[i]);
|
unusedResources.push_back(resources[i]->GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return unusedResources;
|
return unusedResources;
|
||||||
|
@@ -20,17 +20,6 @@ namespace gd {
|
|||||||
*/
|
*/
|
||||||
class GD_CORE_API ProjectResourcesAdder {
|
class GD_CORE_API ProjectResourcesAdder {
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* \brief Update the project so that all missing resources are added, with an
|
|
||||||
* filename that is equal to the missing resource name.
|
|
||||||
*
|
|
||||||
* \param project The project to be updated.
|
|
||||||
* \param resourceType The type of the resource the be searched
|
|
||||||
*
|
|
||||||
* \return true if no error happened
|
|
||||||
*/
|
|
||||||
static bool AddAllMissing(gd::Project& project, const gd::String & resourceType);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Find all resources of the specified kind that are
|
* \brief Find all resources of the specified kind that are
|
||||||
* not used by the project.
|
* not used by the project.
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
||||||
#include "GDCore/String.h"
|
#include "GDCore/String.h"
|
||||||
|
|
||||||
@@ -36,17 +37,20 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
|
|||||||
virtual ~ResourcesInUseHelper(){};
|
virtual ~ResourcesInUseHelper(){};
|
||||||
|
|
||||||
std::set<gd::String>& GetAllImages() { return GetAll("image"); };
|
std::set<gd::String>& GetAllImages() { return GetAll("image"); };
|
||||||
std::set<gd::String>& GetAllFonts() { return GetAll("font"); };
|
|
||||||
std::set<gd::String>& GetAllAudios() { return GetAll("audio"); };
|
std::set<gd::String>& GetAllAudios() { return GetAll("audio"); };
|
||||||
|
std::set<gd::String>& GetAllFonts() { return GetAll("font"); };
|
||||||
|
std::set<gd::String>& GetAllJsons() { return GetAll("json"); };
|
||||||
|
std::set<gd::String>& GetAllVideos() { return GetAll("video"); };
|
||||||
std::set<gd::String>& GetAllBitmapFonts() { return GetAll("bitmapFont"); };
|
std::set<gd::String>& GetAllBitmapFonts() { return GetAll("bitmapFont"); };
|
||||||
std::set<gd::String>& GetAll(const gd::String& resourceType) {
|
std::set<gd::String>& GetAll(const gd::String& resourceType) {
|
||||||
return resourceType == "image"
|
if (resourceType == "image") return allImages;
|
||||||
? allImages
|
if (resourceType == "audio") return allAudios;
|
||||||
: (resourceType == "audio"
|
if (resourceType == "font") return allFonts;
|
||||||
? allAudios
|
if (resourceType == "json") return allJsons;
|
||||||
: (resourceType == "font")
|
if (resourceType == "video") return allVideos;
|
||||||
? allFonts
|
if (resourceType == "bitmapFont") return allBitmapFonts;
|
||||||
: (resourceType == "bitmapFont") ? allBitmapFonts : emptyResources);
|
|
||||||
|
return emptyResources;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void ExposeFile(gd::String& resource) override{
|
virtual void ExposeFile(gd::String& resource) override{
|
||||||
@@ -61,6 +65,12 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
|
|||||||
virtual void ExposeFont(gd::String& fontResourceName) override {
|
virtual void ExposeFont(gd::String& fontResourceName) override {
|
||||||
allFonts.insert(fontResourceName);
|
allFonts.insert(fontResourceName);
|
||||||
};
|
};
|
||||||
|
virtual void ExposeJson(gd::String& jsonResourceName) override {
|
||||||
|
allJsons.insert(jsonResourceName);
|
||||||
|
};
|
||||||
|
virtual void ExposeVideo(gd::String& videoResourceName) override {
|
||||||
|
allVideos.insert(videoResourceName);
|
||||||
|
};
|
||||||
virtual void ExposeBitmapFont(gd::String& bitmapFontResourceName) override {
|
virtual void ExposeBitmapFont(gd::String& bitmapFontResourceName) override {
|
||||||
allBitmapFonts.insert(bitmapFontResourceName);
|
allBitmapFonts.insert(bitmapFontResourceName);
|
||||||
};
|
};
|
||||||
@@ -69,6 +79,8 @@ class ResourcesInUseHelper : public gd::ArbitraryResourceWorker {
|
|||||||
std::set<gd::String> allImages;
|
std::set<gd::String> allImages;
|
||||||
std::set<gd::String> allAudios;
|
std::set<gd::String> allAudios;
|
||||||
std::set<gd::String> allFonts;
|
std::set<gd::String> allFonts;
|
||||||
|
std::set<gd::String> allJsons;
|
||||||
|
std::set<gd::String> allVideos;
|
||||||
std::set<gd::String> allBitmapFonts;
|
std::set<gd::String> allBitmapFonts;
|
||||||
std::set<gd::String> emptyResources;
|
std::set<gd::String> emptyResources;
|
||||||
};
|
};
|
||||||
|
@@ -22,7 +22,7 @@ void ResourcesMergingHelper::ExposeFile(gd::String& resourceFilename) {
|
|||||||
resourceFullFilename = gd::AbstractFileSystem::NormalizeSeparator(
|
resourceFullFilename = gd::AbstractFileSystem::NormalizeSeparator(
|
||||||
resourceFullFilename); // Protect against \ on Linux.
|
resourceFullFilename); // Protect against \ on Linux.
|
||||||
|
|
||||||
// In the case of absolute filnames that we don't want to preserve, or
|
// In the case of absolute filenames that we don't want to preserve, or
|
||||||
// in the case of copying files without preserving relative folders, the new
|
// in the case of copying files without preserving relative folders, the new
|
||||||
// names will be generated from the filename alone (with collision protection).
|
// names will be generated from the filename alone (with collision protection).
|
||||||
auto stripToFilenameOnly = [&]() {
|
auto stripToFilenameOnly = [&]() {
|
||||||
|
@@ -71,7 +71,7 @@ class GD_CORE_API ResourcesMergingHelper : public ArbitraryResourceWorker {
|
|||||||
* Resources merging helper collects all resources filenames and update these
|
* Resources merging helper collects all resources filenames and update these
|
||||||
* filenames.
|
* filenames.
|
||||||
*/
|
*/
|
||||||
virtual void ExposeFile(gd::String& resource);
|
virtual void ExposeFile(gd::String& resource) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetNewFilename(gd::String oldFilename, gd::String newFilename);
|
void SetNewFilename(gd::String oldFilename, gd::String newFilename);
|
||||||
|
@@ -33,8 +33,9 @@ class ResourcesRenamer : public gd::ArbitraryResourceWorker {
|
|||||||
: gd::ArbitraryResourceWorker(), oldToNewNames(oldToNewNames_){};
|
: gd::ArbitraryResourceWorker(), oldToNewNames(oldToNewNames_){};
|
||||||
virtual ~ResourcesRenamer(){};
|
virtual ~ResourcesRenamer(){};
|
||||||
|
|
||||||
virtual void ExposeFile(gd::String& resourceName) override {
|
virtual void ExposeFile(gd::String& resourceFileName) override{
|
||||||
RenameIfNeeded(resourceName);
|
// Don't do anything: we're renaming resources, not the files they are
|
||||||
|
// pointing to.
|
||||||
};
|
};
|
||||||
virtual void ExposeImage(gd::String& imageResourceName) override {
|
virtual void ExposeImage(gd::String& imageResourceName) override {
|
||||||
RenameIfNeeded(imageResourceName);
|
RenameIfNeeded(imageResourceName);
|
||||||
@@ -45,6 +46,15 @@ class ResourcesRenamer : public gd::ArbitraryResourceWorker {
|
|||||||
virtual void ExposeFont(gd::String& fontResourceName) override {
|
virtual void ExposeFont(gd::String& fontResourceName) override {
|
||||||
RenameIfNeeded(fontResourceName);
|
RenameIfNeeded(fontResourceName);
|
||||||
};
|
};
|
||||||
|
virtual void ExposeJson(gd::String& jsonResourceName) override {
|
||||||
|
RenameIfNeeded(jsonResourceName);
|
||||||
|
};
|
||||||
|
virtual void ExposeVideo(gd::String& videoResourceName) override {
|
||||||
|
RenameIfNeeded(videoResourceName);
|
||||||
|
};
|
||||||
|
virtual void ExposeBitmapFont(gd::String& bitmapFontName) override {
|
||||||
|
RenameIfNeeded(bitmapFontName);
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RenameIfNeeded(gd::String& resourceName) {
|
void RenameIfNeeded(gd::String& resourceName) {
|
||||||
|
12
Core/GDCore/IDE/UnfilledRequiredBehaviorPropertyProblem.cpp
Normal file
12
Core/GDCore/IDE/UnfilledRequiredBehaviorPropertyProblem.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* GDevelop Core
|
||||||
|
* Copyright 2008-2021 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||||
|
* reserved. This project is released under the MIT License.
|
||||||
|
*/
|
||||||
|
#include "UnfilledRequiredBehaviorPropertyProblem.h"
|
||||||
|
|
||||||
|
namespace gd {
|
||||||
|
|
||||||
|
UnfilledRequiredBehaviorPropertyProblem::~UnfilledRequiredBehaviorPropertyProblem(){};
|
||||||
|
|
||||||
|
} // namespace gd
|
80
Core/GDCore/IDE/UnfilledRequiredBehaviorPropertyProblem.h
Normal file
80
Core/GDCore/IDE/UnfilledRequiredBehaviorPropertyProblem.h
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* GDevelop Core
|
||||||
|
* Copyright 2008-2021 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||||
|
* reserved. This project is released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GDCORE_UNFILLEDREQUIREDBEHAVIORPROPERTYPROBLEM_H
|
||||||
|
#define GDCORE_UNFILLEDREQUIREDBEHAVIORPROPERTYPROBLEM_H
|
||||||
|
#include "GDCore/String.h"
|
||||||
|
|
||||||
|
namespace gd {
|
||||||
|
class Project;
|
||||||
|
class Object;
|
||||||
|
class BehaviorContent;
|
||||||
|
} // namespace gd
|
||||||
|
|
||||||
|
namespace gd {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A problem when a required behavior property is not fill correctly.
|
||||||
|
*/
|
||||||
|
class GD_CORE_API UnfilledRequiredBehaviorPropertyProblem {
|
||||||
|
public:
|
||||||
|
UnfilledRequiredBehaviorPropertyProblem(
|
||||||
|
const gd::Project& sourceProject_,
|
||||||
|
gd::Object& sourceObject_,
|
||||||
|
gd::BehaviorContent& sourceBehaviorContent_,
|
||||||
|
const gd::String& sourcePropertyName_,
|
||||||
|
const gd::String& expectedBehaviorTypeName_)
|
||||||
|
: sourceProject(sourceProject_),
|
||||||
|
sourceObject(sourceObject_),
|
||||||
|
sourceBehaviorContent(sourceBehaviorContent_),
|
||||||
|
sourcePropertyName(sourcePropertyName_),
|
||||||
|
expectedBehaviorTypeName(expectedBehaviorTypeName_){};
|
||||||
|
virtual ~UnfilledRequiredBehaviorPropertyProblem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return the project where the problem appears
|
||||||
|
*/
|
||||||
|
virtual const gd::Project& GetSourceProject() const { return sourceProject; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return the object where the problem appears.
|
||||||
|
*/
|
||||||
|
virtual gd::Object& GetSourceObject() const { return sourceObject; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return the behavior where the problem appears.
|
||||||
|
*/
|
||||||
|
virtual gd::BehaviorContent& GetSourceBehaviorContent() const {
|
||||||
|
return sourceBehaviorContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return the property where the problem appears.
|
||||||
|
*/
|
||||||
|
virtual const gd::String& GetSourcePropertyName() const {
|
||||||
|
return sourcePropertyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return the behavior type name that is expected for the required
|
||||||
|
* behavior property.
|
||||||
|
*/
|
||||||
|
virtual const gd::String& GetExpectedBehaviorTypeName() const {
|
||||||
|
return expectedBehaviorTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const gd::Project& sourceProject;
|
||||||
|
gd::Object& sourceObject;
|
||||||
|
gd::BehaviorContent& sourceBehaviorContent;
|
||||||
|
const gd::String sourcePropertyName;
|
||||||
|
|
||||||
|
const gd::String expectedBehaviorTypeName;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace gd
|
||||||
|
|
||||||
|
#endif // GDCORE_UNFILLEDREQUIREDBEHAVIORPROPERTYPROBLEM_H
|
@@ -5,9 +5,12 @@
|
|||||||
*/
|
*/
|
||||||
#include "WholeProjectRefactorer.h"
|
#include "WholeProjectRefactorer.h"
|
||||||
|
|
||||||
|
#include "GDCore/Extensions/Metadata/BehaviorMetadata.h"
|
||||||
|
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||||
#include "GDCore/Extensions/PlatformExtension.h"
|
#include "GDCore/Extensions/PlatformExtension.h"
|
||||||
#include "GDCore/IDE/DependenciesAnalyzer.h"
|
#include "GDCore/IDE/DependenciesAnalyzer.h"
|
||||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||||
|
#include "GDCore/IDE/Events/EventsBehaviorRenamer.h"
|
||||||
#include "GDCore/IDE/Events/EventsRefactorer.h"
|
#include "GDCore/IDE/Events/EventsRefactorer.h"
|
||||||
#include "GDCore/IDE/Events/ExpressionsParameterMover.h"
|
#include "GDCore/IDE/Events/ExpressionsParameterMover.h"
|
||||||
#include "GDCore/IDE/Events/ExpressionsRenamer.h"
|
#include "GDCore/IDE/Events/ExpressionsRenamer.h"
|
||||||
@@ -15,6 +18,9 @@
|
|||||||
#include "GDCore/IDE/Events/InstructionsTypeRenamer.h"
|
#include "GDCore/IDE/Events/InstructionsTypeRenamer.h"
|
||||||
#include "GDCore/IDE/EventsFunctionTools.h"
|
#include "GDCore/IDE/EventsFunctionTools.h"
|
||||||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h"
|
||||||
|
#include "GDCore/IDE/UnfilledRequiredBehaviorPropertyProblem.h"
|
||||||
|
#include "GDCore/Project/Behavior.h"
|
||||||
|
#include "GDCore/Project/BehaviorContent.h"
|
||||||
#include "GDCore/Project/EventsBasedBehavior.h"
|
#include "GDCore/Project/EventsBasedBehavior.h"
|
||||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||||
#include "GDCore/Project/ExternalEvents.h"
|
#include "GDCore/Project/ExternalEvents.h"
|
||||||
@@ -51,6 +57,10 @@ gd::String GetBehaviorFullType(const gd::String& extensionName,
|
|||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
|
|
||||||
|
// By convention, the first parameter of an events based behavior method is
|
||||||
|
// always called "Object".
|
||||||
|
const gd::String WholeProjectRefactorer::behaviorObjectParameterName = "Object";
|
||||||
|
|
||||||
void WholeProjectRefactorer::ExposeProjectEvents(
|
void WholeProjectRefactorer::ExposeProjectEvents(
|
||||||
gd::Project& project, gd::ArbitraryEventsWorker& worker) {
|
gd::Project& project, gd::ArbitraryEventsWorker& worker) {
|
||||||
// See also gd::Project::ExposeResources for a method that traverse the whole
|
// See also gd::Project::ExposeResources for a method that traverse the whole
|
||||||
@@ -115,7 +125,7 @@ void WholeProjectRefactorer::ExposeProjectEvents(
|
|||||||
for (auto&& eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
for (auto&& eventsFunction : eventsFunctionsExtension.GetInternalVector()) {
|
||||||
gd::ObjectsContainer globalObjectsAndGroups;
|
gd::ObjectsContainer globalObjectsAndGroups;
|
||||||
gd::ObjectsContainer objectsAndGroups;
|
gd::ObjectsContainer objectsAndGroups;
|
||||||
gd::EventsFunctionTools::EventsFunctionToObjectsContainer(
|
gd::EventsFunctionTools::FreeEventsFunctionToObjectsContainer(
|
||||||
project, *eventsFunction, globalObjectsAndGroups, objectsAndGroups);
|
project, *eventsFunction, globalObjectsAndGroups, objectsAndGroups);
|
||||||
|
|
||||||
worker.Launch(eventsFunction->GetEvents(),
|
worker.Launch(eventsFunction->GetEvents(),
|
||||||
@@ -127,22 +137,31 @@ void WholeProjectRefactorer::ExposeProjectEvents(
|
|||||||
for (auto&& eventsBasedBehavior :
|
for (auto&& eventsBasedBehavior :
|
||||||
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||||
.GetInternalVector()) {
|
.GetInternalVector()) {
|
||||||
auto& behaviorEventsFunctions = eventsBasedBehavior->GetEventsFunctions();
|
ExposeEventsBasedBehaviorEvents(project, *eventsBasedBehavior, worker);
|
||||||
for (auto&& eventsFunction :
|
|
||||||
behaviorEventsFunctions.GetInternalVector()) {
|
|
||||||
gd::ObjectsContainer globalObjectsAndGroups;
|
|
||||||
gd::ObjectsContainer objectsAndGroups;
|
|
||||||
gd::EventsFunctionTools::EventsFunctionToObjectsContainer(
|
|
||||||
project, *eventsFunction, globalObjectsAndGroups, objectsAndGroups);
|
|
||||||
|
|
||||||
worker.Launch(eventsFunction->GetEvents(),
|
|
||||||
globalObjectsAndGroups,
|
|
||||||
objectsAndGroups);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WholeProjectRefactorer::ExposeEventsBasedBehaviorEvents(
|
||||||
|
gd::Project& project,
|
||||||
|
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||||
|
gd::ArbitraryEventsWorkerWithContext& worker) {
|
||||||
|
auto& behaviorEventsFunctions = eventsBasedBehavior.GetEventsFunctions();
|
||||||
|
for (auto&& eventsFunction : behaviorEventsFunctions.GetInternalVector()) {
|
||||||
|
gd::ObjectsContainer globalObjectsAndGroups;
|
||||||
|
gd::ObjectsContainer objectsAndGroups;
|
||||||
|
gd::EventsFunctionTools::BehaviorEventsFunctionToObjectsContainer(
|
||||||
|
project,
|
||||||
|
eventsBasedBehavior,
|
||||||
|
*eventsFunction,
|
||||||
|
globalObjectsAndGroups,
|
||||||
|
objectsAndGroups);
|
||||||
|
|
||||||
|
worker.Launch(
|
||||||
|
eventsFunction->GetEvents(), globalObjectsAndGroups, objectsAndGroups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WholeProjectRefactorer::ExposeProjectObjects(
|
void WholeProjectRefactorer::ExposeProjectObjects(
|
||||||
gd::Project& project, gd::ArbitraryObjectsWorker& worker) {
|
gd::Project& project, gd::ArbitraryObjectsWorker& worker) {
|
||||||
worker.Launch(project);
|
worker.Launch(project);
|
||||||
@@ -192,7 +211,7 @@ void WholeProjectRefactorer::EnsureBehaviorEventsFunctionsProperParameters(
|
|||||||
|
|
||||||
parameters[0]
|
parameters[0]
|
||||||
.SetType("object")
|
.SetType("object")
|
||||||
.SetName("Object")
|
.SetName(behaviorObjectParameterName)
|
||||||
.SetDescription("Object")
|
.SetDescription("Object")
|
||||||
.SetExtraInfo(eventsBasedBehavior.GetObjectType());
|
.SetExtraInfo(eventsBasedBehavior.GetObjectType());
|
||||||
parameters[1]
|
parameters[1]
|
||||||
@@ -219,7 +238,7 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto renameBehaviorEventsFunction =
|
auto renameBehaviorEventsFunction =
|
||||||
[&project, &eventsFunctionsExtension, &oldName, &newName](
|
[&project, &oldName, &newName](
|
||||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||||
const gd::EventsFunction& eventsFunction) {
|
const gd::EventsFunction& eventsFunction) {
|
||||||
if (eventsFunction.GetFunctionType() == gd::EventsFunction::Action ||
|
if (eventsFunction.GetFunctionType() == gd::EventsFunction::Action ||
|
||||||
@@ -242,7 +261,7 @@ void WholeProjectRefactorer::RenameEventsFunctionsExtension(
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto renameBehaviorPropertyFunctions =
|
auto renameBehaviorPropertyFunctions =
|
||||||
[&project, &eventsFunctionsExtension, &oldName, &newName](
|
[&project, &oldName, &newName](
|
||||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||||
const gd::NamedPropertyDescriptor& property) {
|
const gd::NamedPropertyDescriptor& property) {
|
||||||
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
||||||
@@ -470,7 +489,7 @@ void WholeProjectRefactorer::MoveBehaviorEventsFunctionParameter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WholeProjectRefactorer::RenameBehaviorProperty(
|
void WholeProjectRefactorer::RenameEventsBasedBehaviorProperty(
|
||||||
gd::Project& project,
|
gd::Project& project,
|
||||||
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
||||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||||
@@ -479,41 +498,294 @@ void WholeProjectRefactorer::RenameBehaviorProperty(
|
|||||||
auto& properties = eventsBasedBehavior.GetPropertyDescriptors();
|
auto& properties = eventsBasedBehavior.GetPropertyDescriptors();
|
||||||
if (!properties.Has(oldPropertyName)) return;
|
if (!properties.Has(oldPropertyName)) return;
|
||||||
|
|
||||||
// Order is important: we first rename the expressions then the instructions,
|
if (properties.Get(oldPropertyName).GetType() == "Behavior") {
|
||||||
// to avoid being unable to fetch the metadata (the types of parameters) of
|
// This is a property representing another behavior that must exist on the
|
||||||
// instructions after they are renamed.
|
// object.
|
||||||
gd::ExpressionsRenamer expressionRenamer =
|
|
||||||
gd::ExpressionsRenamer(project.GetCurrentPlatform());
|
|
||||||
expressionRenamer.SetReplacedBehaviorExpression(
|
|
||||||
GetBehaviorFullType(eventsFunctionsExtension.GetName(),
|
|
||||||
eventsBasedBehavior.GetName()),
|
|
||||||
EventsBasedBehavior::GetPropertyExpressionName(oldPropertyName),
|
|
||||||
EventsBasedBehavior::GetPropertyExpressionName(newPropertyName));
|
|
||||||
ExposeProjectEvents(project, expressionRenamer);
|
|
||||||
|
|
||||||
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
// This other "required behavior" uses the property name, that is about to
|
||||||
project,
|
// change, as its name.
|
||||||
GetBehaviorEventsFunctionFullType(
|
// So we must change all reference to this name in the events of the
|
||||||
eventsFunctionsExtension.GetName(),
|
// behavior functions.
|
||||||
eventsBasedBehavior.GetName(),
|
gd::EventsBehaviorRenamer behaviorRenamer(project.GetCurrentPlatform(),
|
||||||
EventsBasedBehavior::GetPropertyActionName(oldPropertyName)),
|
behaviorObjectParameterName,
|
||||||
GetBehaviorEventsFunctionFullType(
|
oldPropertyName,
|
||||||
eventsFunctionsExtension.GetName(),
|
newPropertyName);
|
||||||
eventsBasedBehavior.GetName(),
|
|
||||||
EventsBasedBehavior::GetPropertyActionName(newPropertyName)));
|
|
||||||
ExposeProjectEvents(project, actionRenamer);
|
|
||||||
|
|
||||||
gd::InstructionsTypeRenamer conditionRenamer = gd::InstructionsTypeRenamer(
|
ExposeEventsBasedBehaviorEvents(
|
||||||
project,
|
project, eventsBasedBehavior, behaviorRenamer);
|
||||||
GetBehaviorEventsFunctionFullType(
|
} else {
|
||||||
eventsFunctionsExtension.GetName(),
|
// Properties that represent primitive values will be used through
|
||||||
eventsBasedBehavior.GetName(),
|
// their related actions/conditions/expressions. Rename these.
|
||||||
EventsBasedBehavior::GetPropertyConditionName(oldPropertyName)),
|
|
||||||
GetBehaviorEventsFunctionFullType(
|
// Order is important: we first rename the expressions then the
|
||||||
eventsFunctionsExtension.GetName(),
|
// instructions, to avoid being unable to fetch the metadata (the types of
|
||||||
eventsBasedBehavior.GetName(),
|
// parameters) of instructions after they are renamed.
|
||||||
EventsBasedBehavior::GetPropertyConditionName(newPropertyName)));
|
gd::ExpressionsRenamer expressionRenamer =
|
||||||
ExposeProjectEvents(project, conditionRenamer);
|
gd::ExpressionsRenamer(project.GetCurrentPlatform());
|
||||||
|
expressionRenamer.SetReplacedBehaviorExpression(
|
||||||
|
GetBehaviorFullType(eventsFunctionsExtension.GetName(),
|
||||||
|
eventsBasedBehavior.GetName()),
|
||||||
|
EventsBasedBehavior::GetPropertyExpressionName(oldPropertyName),
|
||||||
|
EventsBasedBehavior::GetPropertyExpressionName(newPropertyName));
|
||||||
|
ExposeProjectEvents(project, expressionRenamer);
|
||||||
|
|
||||||
|
gd::InstructionsTypeRenamer actionRenamer = gd::InstructionsTypeRenamer(
|
||||||
|
project,
|
||||||
|
GetBehaviorEventsFunctionFullType(
|
||||||
|
eventsFunctionsExtension.GetName(),
|
||||||
|
eventsBasedBehavior.GetName(),
|
||||||
|
EventsBasedBehavior::GetPropertyActionName(oldPropertyName)),
|
||||||
|
GetBehaviorEventsFunctionFullType(
|
||||||
|
eventsFunctionsExtension.GetName(),
|
||||||
|
eventsBasedBehavior.GetName(),
|
||||||
|
EventsBasedBehavior::GetPropertyActionName(newPropertyName)));
|
||||||
|
ExposeProjectEvents(project, actionRenamer);
|
||||||
|
|
||||||
|
gd::InstructionsTypeRenamer conditionRenamer = gd::InstructionsTypeRenamer(
|
||||||
|
project,
|
||||||
|
GetBehaviorEventsFunctionFullType(
|
||||||
|
eventsFunctionsExtension.GetName(),
|
||||||
|
eventsBasedBehavior.GetName(),
|
||||||
|
EventsBasedBehavior::GetPropertyConditionName(oldPropertyName)),
|
||||||
|
GetBehaviorEventsFunctionFullType(
|
||||||
|
eventsFunctionsExtension.GetName(),
|
||||||
|
eventsBasedBehavior.GetName(),
|
||||||
|
EventsBasedBehavior::GetPropertyConditionName(newPropertyName)));
|
||||||
|
ExposeProjectEvents(project, conditionRenamer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WholeProjectRefactorer::AddBehaviorAndRequiredBehaviors(
|
||||||
|
gd::Project& project,
|
||||||
|
gd::Object& object,
|
||||||
|
const gd::String& behaviorType,
|
||||||
|
const gd::String& behaviorName) {
|
||||||
|
if (object.AddNewBehavior(project, behaviorType, behaviorName) == nullptr) {
|
||||||
|
// The behavior type/metadata can't be found.
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
const gd::Platform& platform = project.GetCurrentPlatform();
|
||||||
|
const gd::BehaviorMetadata& behaviorMetadata =
|
||||||
|
MetadataProvider::GetBehaviorMetadata(platform, behaviorType);
|
||||||
|
if (MetadataProvider::IsBadBehaviorMetadata(behaviorMetadata)) {
|
||||||
|
// Should not happen because the behavior was added successfully (so its
|
||||||
|
// metadata are valid) - but double check anyway and bail out if the
|
||||||
|
// behavior metadata are invalid.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gd::Behavior& behavior = behaviorMetadata.Get();
|
||||||
|
gd::BehaviorContent& behaviorContent = object.GetBehavior(behaviorName);
|
||||||
|
for (auto const& keyValue :
|
||||||
|
behavior.GetProperties(behaviorContent.GetContent())) {
|
||||||
|
const gd::String& propertyName = keyValue.first;
|
||||||
|
const gd::PropertyDescriptor& property = keyValue.second;
|
||||||
|
if (property.GetType().LowerCase() == "behavior") {
|
||||||
|
const std::vector<gd::String>& extraInfo = property.GetExtraInfo();
|
||||||
|
if (extraInfo.size() == 0) {
|
||||||
|
// very unlikely
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const gd::String& requiredBehaviorType = extraInfo.at(0);
|
||||||
|
const auto behaviorContents =
|
||||||
|
WholeProjectRefactorer::GetBehaviorsWithType(object,
|
||||||
|
requiredBehaviorType);
|
||||||
|
const gd::String* defaultBehaviorName = nullptr;
|
||||||
|
if (behaviorContents.size() == 0) {
|
||||||
|
const gd::BehaviorMetadata& requiredBehaviorMetadata =
|
||||||
|
MetadataProvider::GetBehaviorMetadata(platform,
|
||||||
|
requiredBehaviorType);
|
||||||
|
const gd::String& requiredBehaviorName =
|
||||||
|
requiredBehaviorMetadata.GetDefaultName();
|
||||||
|
WholeProjectRefactorer::AddBehaviorAndRequiredBehaviors(
|
||||||
|
project, object, requiredBehaviorType, requiredBehaviorName);
|
||||||
|
defaultBehaviorName = &requiredBehaviorName;
|
||||||
|
} else {
|
||||||
|
defaultBehaviorName = &behaviorContents.at(0);
|
||||||
|
}
|
||||||
|
behavior.UpdateProperty(
|
||||||
|
behaviorContent.GetContent(), propertyName, *defaultBehaviorName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<gd::String> WholeProjectRefactorer::GetBehaviorsWithType(
|
||||||
|
const gd::Object& object, const gd::String& type) {
|
||||||
|
std::vector<gd::String> behaviors;
|
||||||
|
for (auto& behaviorName : object.GetAllBehaviorNames()) {
|
||||||
|
const gd::BehaviorContent& behaviorContent =
|
||||||
|
object.GetBehavior(behaviorName);
|
||||||
|
if (behaviorContent.GetTypeName() == type) {
|
||||||
|
behaviors.push_back(behaviorName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return behaviors;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<gd::String> WholeProjectRefactorer::FindDependentBehaviorNames(
|
||||||
|
const gd::Project& project,
|
||||||
|
const gd::Object& object,
|
||||||
|
const gd::String& behaviorName) {
|
||||||
|
std::unordered_set<gd::String> dependentBehaviorNames;
|
||||||
|
WholeProjectRefactorer::FindDependentBehaviorNames(
|
||||||
|
project, object, behaviorName, dependentBehaviorNames);
|
||||||
|
std::vector<gd::String> results;
|
||||||
|
results.insert(results.end(),
|
||||||
|
dependentBehaviorNames.begin(),
|
||||||
|
dependentBehaviorNames.end());
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WholeProjectRefactorer::FindDependentBehaviorNames(
|
||||||
|
const gd::Project& project,
|
||||||
|
const gd::Object& object,
|
||||||
|
const gd::String& behaviorName,
|
||||||
|
std::unordered_set<gd::String>& dependentBehaviorNames) {
|
||||||
|
const gd::Platform& platform = project.GetCurrentPlatform();
|
||||||
|
for (auto const& objectBehaviorName : object.GetAllBehaviorNames()) {
|
||||||
|
const gd::BehaviorContent& behaviorContent =
|
||||||
|
object.GetBehavior(objectBehaviorName);
|
||||||
|
const auto& behaviorMetadata = MetadataProvider::GetBehaviorMetadata(
|
||||||
|
platform, behaviorContent.GetTypeName());
|
||||||
|
if (MetadataProvider::IsBadBehaviorMetadata(behaviorMetadata)) {
|
||||||
|
// Ignore this behavior as it's unknown.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
gd::Behavior& behavior = behaviorMetadata.Get();
|
||||||
|
for (auto const& keyValue :
|
||||||
|
behavior.GetProperties(behaviorContent.GetContent())) {
|
||||||
|
const gd::String& propertyName = keyValue.first;
|
||||||
|
const gd::PropertyDescriptor& property = keyValue.second;
|
||||||
|
if (property.GetType().LowerCase() == "behavior" &&
|
||||||
|
property.GetValue() == behaviorName &&
|
||||||
|
dependentBehaviorNames.find(objectBehaviorName) ==
|
||||||
|
dependentBehaviorNames.end()) {
|
||||||
|
dependentBehaviorNames.insert(objectBehaviorName);
|
||||||
|
WholeProjectRefactorer::FindDependentBehaviorNames(
|
||||||
|
project, object, objectBehaviorName, dependentBehaviorNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<gd::UnfilledRequiredBehaviorPropertyProblem>
|
||||||
|
WholeProjectRefactorer::FindInvalidRequiredBehaviorProperties(
|
||||||
|
const gd::Project& project) {
|
||||||
|
std::vector<gd::UnfilledRequiredBehaviorPropertyProblem>
|
||||||
|
invalidRequiredBehaviorProperties;
|
||||||
|
auto findInvalidRequiredBehaviorPropertiesInObjects =
|
||||||
|
[&project, &invalidRequiredBehaviorProperties](
|
||||||
|
const std::vector<std::unique_ptr<gd::Object> >& objectsList) {
|
||||||
|
for (auto& object : objectsList) {
|
||||||
|
for (auto& behaviorContentKeyValuePair :
|
||||||
|
object->GetAllBehaviorContents()) {
|
||||||
|
gd::BehaviorContent& behaviorContent =
|
||||||
|
*behaviorContentKeyValuePair.second;
|
||||||
|
|
||||||
|
const auto& behaviorMetadata =
|
||||||
|
gd::MetadataProvider::GetBehaviorMetadata(
|
||||||
|
project.GetCurrentPlatform(),
|
||||||
|
behaviorContent.GetTypeName());
|
||||||
|
if (MetadataProvider::IsBadBehaviorMetadata(behaviorMetadata)) {
|
||||||
|
std::cout << "Could not find metadata for behavior with type \""
|
||||||
|
<< behaviorContent.GetTypeName() << "\"" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& behavior = behaviorMetadata.Get();
|
||||||
|
|
||||||
|
for (auto const& keyValue :
|
||||||
|
behavior.GetProperties(behaviorContent.GetContent())) {
|
||||||
|
const gd::String& propertyName = keyValue.first;
|
||||||
|
const gd::PropertyDescriptor& property = keyValue.second;
|
||||||
|
if (property.GetType().LowerCase() != "behavior") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const gd::String& requiredBehaviorName = property.GetValue();
|
||||||
|
const std::vector<gd::String>& extraInfo =
|
||||||
|
property.GetExtraInfo();
|
||||||
|
if (extraInfo.size() == 0) {
|
||||||
|
// very unlikely
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const gd::String& requiredBehaviorType = extraInfo.at(0);
|
||||||
|
|
||||||
|
if (requiredBehaviorName == "" ||
|
||||||
|
!object->HasBehaviorNamed(requiredBehaviorName) ||
|
||||||
|
object->GetBehavior(requiredBehaviorName).GetTypeName() !=
|
||||||
|
requiredBehaviorType) {
|
||||||
|
auto problem = UnfilledRequiredBehaviorPropertyProblem(
|
||||||
|
project,
|
||||||
|
*object,
|
||||||
|
behaviorContent,
|
||||||
|
propertyName,
|
||||||
|
requiredBehaviorType);
|
||||||
|
invalidRequiredBehaviorProperties.push_back(problem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Find in global objects
|
||||||
|
findInvalidRequiredBehaviorPropertiesInObjects(project.GetObjects());
|
||||||
|
|
||||||
|
// Find in layout objects.
|
||||||
|
for (std::size_t i = 0; i < project.GetLayoutsCount(); ++i) {
|
||||||
|
const gd::Layout& layout = project.GetLayout(i);
|
||||||
|
findInvalidRequiredBehaviorPropertiesInObjects(layout.GetObjects());
|
||||||
|
}
|
||||||
|
return invalidRequiredBehaviorProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WholeProjectRefactorer::FixInvalidRequiredBehaviorProperties(
|
||||||
|
gd::Project& project) {
|
||||||
|
const auto& invalidRequiredBehaviorProblems =
|
||||||
|
FindInvalidRequiredBehaviorProperties(project);
|
||||||
|
for (const auto& problem : invalidRequiredBehaviorProblems) {
|
||||||
|
auto& object = problem.GetSourceObject();
|
||||||
|
auto suggestedBehaviorNames =
|
||||||
|
GetBehaviorsWithType(object, problem.GetExpectedBehaviorTypeName());
|
||||||
|
auto& behaviorContent = problem.GetSourceBehaviorContent();
|
||||||
|
auto& behaviorMetadata = MetadataProvider::GetBehaviorMetadata(
|
||||||
|
project.GetCurrentPlatform(), behaviorContent.GetTypeName());
|
||||||
|
if (MetadataProvider::IsBadBehaviorMetadata(behaviorMetadata)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& behavior = behaviorMetadata.Get();
|
||||||
|
if (suggestedBehaviorNames.empty()) {
|
||||||
|
// No matching behavior on the object.
|
||||||
|
// Add required behaviors on the object.
|
||||||
|
|
||||||
|
auto& expectedBehaviorMetadata = MetadataProvider::GetBehaviorMetadata(
|
||||||
|
project.GetCurrentPlatform(), problem.GetExpectedBehaviorTypeName());
|
||||||
|
if (MetadataProvider::IsBadBehaviorMetadata(behaviorMetadata)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gd::String& newBehaviorName =
|
||||||
|
expectedBehaviorMetadata.GetDefaultName();
|
||||||
|
AddBehaviorAndRequiredBehaviors(project,
|
||||||
|
object,
|
||||||
|
problem.GetExpectedBehaviorTypeName(),
|
||||||
|
newBehaviorName);
|
||||||
|
behavior.UpdateProperty(behaviorContent.GetContent(),
|
||||||
|
problem.GetSourcePropertyName(),
|
||||||
|
newBehaviorName);
|
||||||
|
} else {
|
||||||
|
// There is a matching behavior on the object use it by default.
|
||||||
|
behavior.UpdateProperty(
|
||||||
|
behaviorContent.GetContent(),
|
||||||
|
problem.GetSourcePropertyName(),
|
||||||
|
// It's unlikely the object has 2 behaviors of the same type.
|
||||||
|
suggestedBehaviorNames[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return !invalidRequiredBehaviorProblems.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
||||||
@@ -533,7 +805,6 @@ void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
|||||||
auto renameBehaviorEventsFunction =
|
auto renameBehaviorEventsFunction =
|
||||||
[&project,
|
[&project,
|
||||||
&eventsFunctionsExtension,
|
&eventsFunctionsExtension,
|
||||||
&eventsBasedBehavior,
|
|
||||||
&oldBehaviorName,
|
&oldBehaviorName,
|
||||||
&newBehaviorName](const gd::EventsFunction& eventsFunction) {
|
&newBehaviorName](const gd::EventsFunction& eventsFunction) {
|
||||||
if (eventsFunction.GetFunctionType() == gd::EventsFunction::Action ||
|
if (eventsFunction.GetFunctionType() == gd::EventsFunction::Action ||
|
||||||
@@ -560,7 +831,6 @@ void WholeProjectRefactorer::RenameEventsBasedBehavior(
|
|||||||
|
|
||||||
auto renameBehaviorProperty = [&project,
|
auto renameBehaviorProperty = [&project,
|
||||||
&eventsFunctionsExtension,
|
&eventsFunctionsExtension,
|
||||||
&eventsBasedBehavior,
|
|
||||||
&oldBehaviorName,
|
&oldBehaviorName,
|
||||||
&newBehaviorName](
|
&newBehaviorName](
|
||||||
const gd::NamedPropertyDescriptor&
|
const gd::NamedPropertyDescriptor&
|
||||||
@@ -678,6 +948,31 @@ void WholeProjectRefactorer::DoRenameBehavior(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Rename behavior in required behavior properties
|
||||||
|
for (std::size_t e = 0; e < project.GetEventsFunctionsExtensionsCount();
|
||||||
|
e++) {
|
||||||
|
auto& eventsFunctionsExtension = project.GetEventsFunctionsExtension(e);
|
||||||
|
|
||||||
|
for (auto&& eventsBasedBehavior :
|
||||||
|
eventsFunctionsExtension.GetEventsBasedBehaviors()
|
||||||
|
.GetInternalVector()) {
|
||||||
|
for (size_t i = 0;
|
||||||
|
i < eventsBasedBehavior->GetPropertyDescriptors().GetCount();
|
||||||
|
i++) {
|
||||||
|
NamedPropertyDescriptor& propertyDescriptor =
|
||||||
|
eventsBasedBehavior->GetPropertyDescriptors().Get(i);
|
||||||
|
std::vector<gd::String>& extraInfo = propertyDescriptor.GetExtraInfo();
|
||||||
|
if (propertyDescriptor.GetType() == "Behavior" &&
|
||||||
|
extraInfo.size() > 0) {
|
||||||
|
const gd::String& requiredBehaviorType = extraInfo[0];
|
||||||
|
if (requiredBehaviorType == oldBehaviorType) {
|
||||||
|
extraInfo[0] = newBehaviorType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Rename behavior in global objects
|
// Rename behavior in global objects
|
||||||
renameBehaviorTypeInObjects(project.GetObjects());
|
renameBehaviorTypeInObjects(project.GetObjects());
|
||||||
|
|
||||||
|
@@ -6,10 +6,13 @@
|
|||||||
#ifndef GDCORE_WHOLEPROJECTREFACTORER_H
|
#ifndef GDCORE_WHOLEPROJECTREFACTORER_H
|
||||||
#define GDCORE_WHOLEPROJECTREFACTORER_H
|
#define GDCORE_WHOLEPROJECTREFACTORER_H
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
namespace gd {
|
namespace gd {
|
||||||
|
class Platform;
|
||||||
class Project;
|
class Project;
|
||||||
class Layout;
|
class Layout;
|
||||||
|
class Object;
|
||||||
class String;
|
class String;
|
||||||
class EventsFunctionsExtension;
|
class EventsFunctionsExtension;
|
||||||
class EventsFunction;
|
class EventsFunction;
|
||||||
@@ -18,6 +21,10 @@ class EventsBasedBehavior;
|
|||||||
class ArbitraryEventsWorker;
|
class ArbitraryEventsWorker;
|
||||||
class ArbitraryObjectsWorker;
|
class ArbitraryObjectsWorker;
|
||||||
class ArbitraryEventsWorkerWithContext;
|
class ArbitraryEventsWorkerWithContext;
|
||||||
|
class Behavior;
|
||||||
|
class BehaviorContent;
|
||||||
|
class BehaviorMetadata;
|
||||||
|
class UnfilledRequiredBehaviorPropertyProblem;
|
||||||
} // namespace gd
|
} // namespace gd
|
||||||
|
|
||||||
namespace gd {
|
namespace gd {
|
||||||
@@ -51,13 +58,24 @@ class GD_CORE_API WholeProjectRefactorer {
|
|||||||
gd::ArbitraryEventsWorkerWithContext& worker);
|
gd::ArbitraryEventsWorkerWithContext& worker);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Call the specified worker on all ObjectContainers of the project (global,
|
* \brief Call the specified worker on all events of the events based behavior
|
||||||
* layouts...)
|
*
|
||||||
|
* This should be the preferred way to traverse all the events of an events
|
||||||
|
* based behavior
|
||||||
|
*/
|
||||||
|
static void ExposeEventsBasedBehaviorEvents(
|
||||||
|
gd::Project& project,
|
||||||
|
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||||
|
gd::ArbitraryEventsWorkerWithContext& worker);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Call the specified worker on all ObjectContainers of the project
|
||||||
|
* (global, layouts...)
|
||||||
*
|
*
|
||||||
* This should be the preferred way to traverse all the objects of a project.
|
* This should be the preferred way to traverse all the objects of a project.
|
||||||
*/
|
*/
|
||||||
static void ExposeProjectObjects(
|
static void ExposeProjectObjects(gd::Project& project,
|
||||||
gd::Project& project, gd::ArbitraryObjectsWorker& worker);
|
gd::ArbitraryObjectsWorker& worker);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Refactor the project **before** an events function extension is
|
* \brief Refactor the project **before** an events function extension is
|
||||||
@@ -140,13 +158,52 @@ class GD_CORE_API WholeProjectRefactorer {
|
|||||||
* This is because the property is expected to have its old name for the
|
* This is because the property is expected to have its old name for the
|
||||||
* refactoring.
|
* refactoring.
|
||||||
*/
|
*/
|
||||||
static void RenameBehaviorProperty(
|
static void RenameEventsBasedBehaviorProperty(
|
||||||
gd::Project& project,
|
gd::Project& project,
|
||||||
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
const gd::EventsFunctionsExtension& eventsFunctionsExtension,
|
||||||
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
const gd::EventsBasedBehavior& eventsBasedBehavior,
|
||||||
const gd::String& oldPropertyName,
|
const gd::String& oldPropertyName,
|
||||||
const gd::String& newPropertyName);
|
const gd::String& newPropertyName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Add a behavior to an object and add required behaviors if necessary
|
||||||
|
* to fill every behavior properties of the added behaviors.
|
||||||
|
*/
|
||||||
|
static void AddBehaviorAndRequiredBehaviors(gd::Project& project,
|
||||||
|
gd::Object& object,
|
||||||
|
const gd::String& behaviorType,
|
||||||
|
const gd::String& behaviorName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Find every behavior of the object that needs the given behaviors
|
||||||
|
* directly or indirectly (because of "required behavior" properties).
|
||||||
|
*/
|
||||||
|
static std::vector<gd::String> FindDependentBehaviorNames(
|
||||||
|
const gd::Project& project,
|
||||||
|
const gd::Object& object,
|
||||||
|
const gd::String& behaviorName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Find the names of the behaviors with the specified type on the object.
|
||||||
|
*/
|
||||||
|
static std::vector<gd::String> GetBehaviorsWithType(const gd::Object& object,
|
||||||
|
const gd::String& type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Find in the project objects having behaviors with "behavior" properties that
|
||||||
|
* don't have a valid value (i.e: pointing to a non existing behavior, or of a wrong type).
|
||||||
|
*/
|
||||||
|
static std::vector<gd::UnfilledRequiredBehaviorPropertyProblem>
|
||||||
|
FindInvalidRequiredBehaviorProperties(const gd::Project& project);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Fix in the project objects having behaviors with "behavior" properties that
|
||||||
|
* don't have a valid value (i.e: pointing to a non existing behavior, or of a wrong type),
|
||||||
|
* by setting a proper behavior, or adding missing behaviors to these objects.
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
|
FixInvalidRequiredBehaviorProperties(gd::Project& project);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Refactor the project **before** a behavior is renamed.
|
* \brief Refactor the project **before** a behavior is renamed.
|
||||||
*
|
*
|
||||||
@@ -267,6 +324,14 @@ class GD_CORE_API WholeProjectRefactorer {
|
|||||||
const gd::String& oldBehaviorType,
|
const gd::String& oldBehaviorType,
|
||||||
const gd::String& newBehaviorType);
|
const gd::String& newBehaviorType);
|
||||||
|
|
||||||
|
static void FindDependentBehaviorNames(
|
||||||
|
const gd::Project& project,
|
||||||
|
const gd::Object& object,
|
||||||
|
const gd::String& behaviorName,
|
||||||
|
std::unordered_set<gd::String>& dependentBehaviorNames);
|
||||||
|
|
||||||
|
static const gd::String behaviorObjectParameterName;
|
||||||
|
|
||||||
WholeProjectRefactorer(){};
|
WholeProjectRefactorer(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@ void EventsFunctionsExtension::Init(const gd::EventsFunctionsExtension& other) {
|
|||||||
fullName = other.fullName;
|
fullName = other.fullName;
|
||||||
tags = other.tags;
|
tags = other.tags;
|
||||||
author = other.author;
|
author = other.author;
|
||||||
|
authorIds = other.authorIds;
|
||||||
previewIconUrl = other.previewIconUrl;
|
previewIconUrl = other.previewIconUrl;
|
||||||
iconUrl = other.iconUrl;
|
iconUrl = other.iconUrl;
|
||||||
helpPath = other.helpPath;
|
helpPath = other.helpPath;
|
||||||
@@ -55,6 +56,11 @@ void EventsFunctionsExtension::SerializeTo(SerializerElement& element) const {
|
|||||||
for (const auto& tag : tags) {
|
for (const auto& tag : tags) {
|
||||||
tagsElement.AddChild("").SetStringValue(tag);
|
tagsElement.AddChild("").SetStringValue(tag);
|
||||||
}
|
}
|
||||||
|
auto& authorIdsElement = element.AddChild("authorIds");
|
||||||
|
authorIdsElement.ConsiderAsArray();
|
||||||
|
for (const auto& authorId : authorIds) {
|
||||||
|
authorIdsElement.AddChild("").SetStringValue(authorId);
|
||||||
|
}
|
||||||
element.SetAttribute("author", author);
|
element.SetAttribute("author", author);
|
||||||
element.SetAttribute("previewIconUrl", previewIconUrl);
|
element.SetAttribute("previewIconUrl", previewIconUrl);
|
||||||
element.SetAttribute("iconUrl", iconUrl);
|
element.SetAttribute("iconUrl", iconUrl);
|
||||||
@@ -99,6 +105,13 @@ void EventsFunctionsExtension::UnserializeFrom(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authorIds.clear();
|
||||||
|
auto& authorIdsElement = element.GetChild("authorIds");
|
||||||
|
authorIdsElement.ConsiderAsArray();
|
||||||
|
for (std::size_t i = 0; i < authorIdsElement.GetChildrenCount(); ++i) {
|
||||||
|
authorIds.push_back(authorIdsElement.GetChild(i).GetStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
dependencies.clear();
|
dependencies.clear();
|
||||||
const auto& dependenciesElement = element.GetChild("dependencies");
|
const auto& dependenciesElement = element.GetChild("dependencies");
|
||||||
dependenciesElement.ConsiderAsArray();
|
dependenciesElement.ConsiderAsArray();
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user