mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
205 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
33ddda1070 | ||
![]() |
029c9c853b | ||
![]() |
e38a70ad10 | ||
![]() |
78b48601a1 | ||
![]() |
e91a794d91 | ||
![]() |
6fefd6d36e | ||
![]() |
0cf05b71ba | ||
![]() |
1ab023e211 | ||
![]() |
aa4e9e25bf | ||
![]() |
bc235ef492 | ||
![]() |
eabd1a4f23 | ||
![]() |
62ef3e729b | ||
![]() |
802ee0c03f | ||
![]() |
7ef2050de7 | ||
![]() |
eeea1b99f4 | ||
![]() |
e75d49ea51 | ||
![]() |
048674a7d0 | ||
![]() |
0502bd1f7a | ||
![]() |
66b84441ea | ||
![]() |
d9e27dc4f3 | ||
![]() |
a3c3ffc3bb | ||
![]() |
dc33b6cc01 | ||
![]() |
4a0c1c5ad2 | ||
![]() |
5820c5dd3e | ||
![]() |
606f5aff1b | ||
![]() |
1f42374417 | ||
![]() |
3356400026 | ||
![]() |
b811b1e873 | ||
![]() |
e985b11971 | ||
![]() |
aefc5e2fed | ||
![]() |
0ccb7c3216 | ||
![]() |
33c2c9c6cf | ||
![]() |
55a6306f05 | ||
![]() |
d766e32a18 | ||
![]() |
7cdf4e1184 | ||
![]() |
2540bf3c3e | ||
![]() |
6adec363d5 | ||
![]() |
91a02d132f | ||
![]() |
67718a364b | ||
![]() |
e9b600d885 | ||
![]() |
696dfcb746 | ||
![]() |
437edd1fe7 | ||
![]() |
48599ae9ca | ||
![]() |
c288700f2d | ||
![]() |
fbfb5dbaa6 | ||
![]() |
dfa27df64b | ||
![]() |
1ef404b9a9 | ||
![]() |
785dd6f08b | ||
![]() |
59bc76e144 | ||
![]() |
d873d9747a | ||
![]() |
a7fe36f351 | ||
![]() |
252eeb86b1 | ||
![]() |
66145ce506 | ||
![]() |
0dd10d2fce | ||
![]() |
5d35241c4c | ||
![]() |
ba368d9eed | ||
![]() |
fbeeb589a2 | ||
![]() |
3ec4e3b6dd | ||
![]() |
11ccaf2ea4 | ||
![]() |
274d31f563 | ||
![]() |
c37049cd72 | ||
![]() |
7cdc92c776 | ||
![]() |
471cd61d82 | ||
![]() |
afb66f213d | ||
![]() |
8ad70e57cc | ||
![]() |
d9ea04e059 | ||
![]() |
bb3abdb1fa | ||
![]() |
cdddcafa68 | ||
![]() |
14175c334e | ||
![]() |
6bd4dff03e | ||
![]() |
ceec39f6a2 | ||
![]() |
5abf80a0c9 | ||
![]() |
7f955d8703 | ||
![]() |
781dd42ccb | ||
![]() |
e584fa952d | ||
![]() |
5681667dde | ||
![]() |
d16f04f4a2 | ||
![]() |
e9b464beba | ||
![]() |
7597dbe0d1 | ||
![]() |
4777f0a824 | ||
![]() |
5b2532f8f3 | ||
![]() |
2c43de5120 | ||
![]() |
124ce1101d | ||
![]() |
eb3d6c2670 | ||
![]() |
f737fa479f | ||
![]() |
f93b3bc3b4 | ||
![]() |
5c6eb2dadb | ||
![]() |
3e6ca186f8 | ||
![]() |
860e9d36e4 | ||
![]() |
c8b461cc5f | ||
![]() |
36cdc5720a | ||
![]() |
a7cd53b921 | ||
![]() |
01a25400ff | ||
![]() |
2b484c0cf1 | ||
![]() |
13204e4b53 | ||
![]() |
c6d6466d54 | ||
![]() |
6cf737ac70 | ||
![]() |
5b8cdbbace | ||
![]() |
a7df37a0dc | ||
![]() |
7721f56dde | ||
![]() |
08ada4f595 | ||
![]() |
caa46a2fb0 | ||
![]() |
660cdd753c | ||
![]() |
3b9a1354ee | ||
![]() |
02fce4132a | ||
![]() |
41241d75e1 | ||
![]() |
fc3e73f360 | ||
![]() |
230493039c | ||
![]() |
50326e4d21 | ||
![]() |
cec7960a7d | ||
![]() |
cec901d4c2 | ||
![]() |
29f0567140 | ||
![]() |
94af33c815 | ||
![]() |
3ad7585f92 | ||
![]() |
acb69c447d | ||
![]() |
fa928b35cb | ||
![]() |
67810b79ce | ||
![]() |
0a77e0264d | ||
![]() |
4cc8d15f4b | ||
![]() |
a2f0b3384e | ||
![]() |
432ffebf80 | ||
![]() |
165470d9c1 | ||
![]() |
53eab0ed62 | ||
![]() |
649a36ac30 | ||
![]() |
a3afd983ba | ||
![]() |
f8c0417210 | ||
![]() |
8f5fe159d7 | ||
![]() |
3daebaeb05 | ||
![]() |
1ba1e8a2b7 | ||
![]() |
36679eb76b | ||
![]() |
c8132ba864 | ||
![]() |
141a3d2b61 | ||
![]() |
dbe0343c67 | ||
![]() |
0983ac59a8 | ||
![]() |
9710360180 | ||
![]() |
43af1f34df | ||
![]() |
fd193e89fc | ||
![]() |
19dcaacafb | ||
![]() |
90721c4059 | ||
![]() |
6c118eaa53 | ||
![]() |
2b00c90356 | ||
![]() |
efe37cc3bf | ||
![]() |
bcedbdc0c3 | ||
![]() |
f63a16161f | ||
![]() |
c215a8c6bf | ||
![]() |
225884dfe4 | ||
![]() |
5d42956669 | ||
![]() |
977bbdde89 | ||
![]() |
73357c830d | ||
![]() |
c619f94277 | ||
![]() |
c5dabf9b6e | ||
![]() |
cc4303e21e | ||
![]() |
566aadafd9 | ||
![]() |
9cd96461d7 | ||
![]() |
0395b73f4a | ||
![]() |
bcc40d4728 | ||
![]() |
60088ebafd | ||
![]() |
35b654841c | ||
![]() |
e7b8741c29 | ||
![]() |
9e10f4191b | ||
![]() |
c573695853 | ||
![]() |
7496093e63 | ||
![]() |
5f1787f1b5 | ||
![]() |
b988d55c8c | ||
![]() |
942dc0a539 | ||
![]() |
d8a241502e | ||
![]() |
8bf8c3efff | ||
![]() |
527b2566b7 | ||
![]() |
9b436f7f31 | ||
![]() |
0818d56d45 | ||
![]() |
567b9e24dd | ||
![]() |
69d63649c3 | ||
![]() |
5ef23c0c70 | ||
![]() |
533c6d7fce | ||
![]() |
0438000543 | ||
![]() |
bae8520405 | ||
![]() |
78559f439a | ||
![]() |
ba2389a8eb | ||
![]() |
14f4da8fc3 | ||
![]() |
342f06b024 | ||
![]() |
4d7514c2bf | ||
![]() |
582e71e9d3 | ||
![]() |
f0822e38e1 | ||
![]() |
03a9d9f9c8 | ||
![]() |
942a3117f9 | ||
![]() |
ca19076b01 | ||
![]() |
267842d8e2 | ||
![]() |
71e3b65134 | ||
![]() |
00393f50c8 | ||
![]() |
a107ff4e17 | ||
![]() |
0da59cc4e0 | ||
![]() |
46a12e6758 | ||
![]() |
41c9753268 | ||
![]() |
ab619bdd2a | ||
![]() |
7258da9927 | ||
![]() |
83a390089d | ||
![]() |
f4c730f5fd | ||
![]() |
67776108f9 | ||
![]() |
9997e9246a | ||
![]() |
2c4fa1d1c2 | ||
![]() |
5d2e0786ee | ||
![]() |
8be39f1a3e | ||
![]() |
7d8120d9ff | ||
![]() |
1b417a4f27 | ||
![]() |
aabe249ffb |
@@ -2,10 +2,17 @@
|
||||
# on the Electron runtime (newIDE/electron-app) for macOS and Linux.
|
||||
# For Windows, see the appveyor.yml file.
|
||||
|
||||
# This also builds GDevelop.js and store it on a S3 so it can be used to run
|
||||
# GDevelop without building it from scratch.
|
||||
|
||||
# Note that these CircleCI builds/tests are not launched on Pull Requests from forks,
|
||||
# to avoid sharing secrets.
|
||||
|
||||
version: 2.1
|
||||
orbs:
|
||||
aws-cli: circleci/aws-cli@2.0.6
|
||||
jobs:
|
||||
# Build the **entire** app for macOS.
|
||||
build-macos:
|
||||
macos:
|
||||
xcode: 12.5.1
|
||||
@@ -75,6 +82,7 @@ jobs:
|
||||
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 the **entire** app for Linux.
|
||||
build-linux:
|
||||
# CircleCI docker workers are failing if they don't have enough memory (no swap)
|
||||
resource_class: xlarge
|
||||
@@ -135,7 +143,7 @@ jobs:
|
||||
# Build GDevelop IDE (seems like we need to allow Node.js to use more space than usual)
|
||||
- run:
|
||||
name: Build GDevelop IDE
|
||||
command: export NODE_OPTIONS="--max-old-space-size=7168" && cd newIDE/electron-app && npm run build -- --linux AppImage --publish=never
|
||||
command: export NODE_OPTIONS="--max-old-space-size=7168" && cd newIDE/electron-app && npm run build -- --linux AppImage zip deb --publish=never
|
||||
|
||||
- run:
|
||||
name: Clean dist folder to keep only installers/binaries.
|
||||
@@ -153,10 +161,67 @@ jobs:
|
||||
name: Deploy to S3 (latest)
|
||||
command: aws s3 sync newIDE/electron-app/dist s3://gdevelop-releases/$(git rev-parse --abbrev-ref HEAD)/latest/
|
||||
|
||||
# Build the WebAssembly library only (so that it's cached on a S3 and easy to re-use).
|
||||
build-gdevelop_js-wasm-only:
|
||||
docker:
|
||||
- image: cimg/node:16.13
|
||||
|
||||
working_directory: ~/GDevelop
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- aws-cli/setup
|
||||
|
||||
# System dependencies (for Emscripten)
|
||||
- run:
|
||||
name: Install dependencies for Emscripten
|
||||
command: sudo apt-get update && sudo apt install cmake
|
||||
|
||||
- run:
|
||||
name: Install Python3 dependencies for Emscripten
|
||||
command: sudo apt install python-is-python3 python3-distutils -y
|
||||
|
||||
- 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:
|
||||
- gdevelop.js-linux-nodejs-dependencies-{{ checksum "GDevelop.js/package-lock.json" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- gdevelop.js-linux-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 ..
|
||||
|
||||
- save_cache:
|
||||
paths:
|
||||
- GDevelop.js/node_modules
|
||||
key: gdevelop.js-linux-nodejs-dependencies-{{ checksum "GDevelop.js/package-lock.json" }}
|
||||
|
||||
# Upload artifacts (CircleCI)
|
||||
- store_artifacts:
|
||||
path: Binaries/embuild/GDevelop.js
|
||||
|
||||
# Upload artifacts (AWS)
|
||||
- run:
|
||||
name: Deploy to S3 (specific commit)
|
||||
command: aws s3 sync Binaries/embuild/GDevelop.js s3://gdevelop-gdevelop.js/$(git rev-parse --abbrev-ref HEAD)/commit/$(git rev-parse HEAD)/
|
||||
- run:
|
||||
name: Deploy to S3 (latest)
|
||||
command: aws s3 sync Binaries/embuild/GDevelop.js s3://gdevelop-gdevelop.js/$(git rev-parse --abbrev-ref HEAD)/latest/
|
||||
|
||||
workflows:
|
||||
builds:
|
||||
jobs:
|
||||
- build-gdevelop_js-wasm-only
|
||||
- build-macos:
|
||||
filters:
|
||||
branches:
|
||||
|
6
.github/ISSUE_TEMPLATE/config.yml
vendored
6
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -4,14 +4,14 @@ contact_links:
|
||||
url: https://discord.gg/rjdYHvj
|
||||
about: Discuss on the forum or on the Discord to get help creating a game or identifying a bug.
|
||||
- name: GDevelop Forums
|
||||
url: https://forum.gdevelop-app.com
|
||||
url: https://forum.gdevelop.io
|
||||
about: You can also discuss game creation, new feature requests and bugs on the forum.
|
||||
- name: GDevelop Roadmap
|
||||
url: https://trello.com/b/qf0lM7k8/gdevelop-roadmap
|
||||
about: Look at the roadmap and vote on features that you want to see in GDevelop.
|
||||
- name: Submit a new game example that you created
|
||||
url: https://github.com/GDevelopApp/GDevelop-examples/issues/new/choose
|
||||
about: You can submit a game that you made to be added to examples in the "GDevelop-examples" repository
|
||||
about: You can submit a game that you made to be added to examples in the "GDevelop-examples" repository
|
||||
- name: Submit a new game extension that you created
|
||||
url: https://github.com/4ian/GDevelop-extensions/issues/new/choose
|
||||
about: You can submit an extension that you made in the "GDevelop-extensions" repository
|
||||
about: You can submit an extension that you made in the "GDevelop-extensions" repository
|
||||
|
2
.github/workflows/issues.yml
vendored
2
.github/workflows/issues.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
type: "body"
|
||||
regex: ".*Scroll down to '\\.\\.\\.\\.'.*"
|
||||
message: "Hi @${issue.user.login}! 👋 This issue was automatically closed because it seems that you have not included any steps to reproduce the bug.\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!"
|
||||
message: "Hi @${issue.user.login}! 👋 This issue was automatically closed because it seems that you have not included any steps to reproduce the bug.\n\nGitHub is a place for the technical development of GDevelop itself - you may want to go on the [forum](https://forum.gdevelop.io/), the Discord chat or [read the documentation](https://wiki.gdevelop.io/gdevelop5/start) to learn more about GDevelop. Thanks!"
|
||||
- name: Autoclose known beta 105 web-app update bug
|
||||
uses: arkon/issue-closer-action@v1.1
|
||||
with:
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@
|
||||
/Binaries/.embuild*
|
||||
/Binaries/build*
|
||||
/Binaries/embuild*
|
||||
/emsdk
|
||||
*.dll
|
||||
*.exe
|
||||
*.a
|
||||
|
25
.gitpod.yml
Normal file
25
.gitpod.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
# This is a configuration file allowing to quickly set up a development environment
|
||||
# on GitPod (https://www.gitpod.io/).
|
||||
# Also check GitHub codespaces if you're interested in working
|
||||
# on a remote development server.
|
||||
|
||||
# This works well for:
|
||||
# - The editor web-app, including the C++ classes.
|
||||
# This is not yet adapted for:
|
||||
# - Working on the game engine or extensions, as they can't be easily tested on the web-app.
|
||||
# - Working on the desktop app (Electron).
|
||||
|
||||
tasks:
|
||||
- name: Install dependencies for Emscripten and build GDevelop.js
|
||||
init: |
|
||||
sudo apt-get update
|
||||
sudo apt install cmake python-is-python3 python3-distutils -y
|
||||
git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
|
||||
cd GDevelop.js
|
||||
npm install
|
||||
source ../emsdk/emsdk_env.sh && npm run build -- --dev
|
||||
cd ..
|
||||
- name: Install GDevelop IDE dependencies
|
||||
init: cd newIDE/app && npm install && cd ../electron-app && npm install
|
||||
|
||||
|
26
.travis.yml
26
.travis.yml
@@ -1,9 +1,6 @@
|
||||
# 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).
|
||||
|
||||
@@ -17,18 +14,7 @@ cache:
|
||||
directories:
|
||||
- $HOME/.npm
|
||||
|
||||
services:
|
||||
# Virtual Framebuffer 'fake' X server for SFML
|
||||
- xvfb
|
||||
|
||||
addons:
|
||||
artifacts:
|
||||
s3_region: "us-east-1"
|
||||
target_paths:
|
||||
- /$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)/commit/$(git rev-parse HEAD)
|
||||
- /$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)/latest
|
||||
paths:
|
||||
- Binaries/embuild/GDevelop.js
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
@@ -36,20 +22,8 @@ addons:
|
||||
# Build dependencies:
|
||||
- cmake
|
||||
- p7zip-full
|
||||
# SFML dependencies:
|
||||
- libopenal-dev
|
||||
- libjpeg-dev
|
||||
- libglew-dev
|
||||
- libudev-dev
|
||||
- libxrandr-dev
|
||||
- libsndfile1-dev
|
||||
- libglu1-mesa-dev
|
||||
- libfreetype6-dev
|
||||
|
||||
before_install:
|
||||
#Activate X Virtual Framebuffer to allow tests to
|
||||
#use SFML.
|
||||
- "export DISPLAY=:99.0"
|
||||
# This workaround is required to avoid libstdc++ errors (Emscripten requires a recent version of libstdc++)
|
||||
- wget -q -O libstdc++6 http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.12_amd64.deb
|
||||
- sudo dpkg --force-all -i libstdc++6
|
||||
|
7
.vscode/c_cpp_properties.json
vendored
7
.vscode/c_cpp_properties.json
vendored
@@ -7,11 +7,9 @@
|
||||
"${workspaceRoot}/GDJS",
|
||||
"${workspaceRoot}/Extensions",
|
||||
"${workspaceRoot}/Core",
|
||||
"${workspaceRoot}/ExtLibs/SFML/include",
|
||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
|
||||
"/usr/local/include",
|
||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
|
||||
"/usr/include",
|
||||
"${workspaceRoot}"
|
||||
],
|
||||
"defines": [
|
||||
@@ -27,7 +25,6 @@
|
||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
|
||||
"/usr/local/include",
|
||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
|
||||
"/usr/include",
|
||||
"${workspaceRoot}"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
@@ -48,7 +45,6 @@
|
||||
"${workspaceRoot}/GDJS",
|
||||
"${workspaceRoot}/Extensions",
|
||||
"${workspaceRoot}/Core",
|
||||
"${workspaceRoot}/ExtLibs/SFML/include",
|
||||
"/usr/include",
|
||||
"/usr/local/include",
|
||||
"${workspaceRoot}"
|
||||
@@ -78,7 +74,6 @@
|
||||
"${workspaceRoot}/GDJS",
|
||||
"${workspaceRoot}/Extensions",
|
||||
"${workspaceRoot}/Core",
|
||||
"${workspaceRoot}/ExtLibs/SFML/include",
|
||||
"${workspaceRoot}"
|
||||
],
|
||||
"defines": [
|
||||
@@ -101,4 +96,4 @@
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
}
|
||||
|
14
.vscode/launch.json
vendored
14
.vscode/launch.json
vendored
@@ -15,6 +15,20 @@
|
||||
"disableOptimisticBPs": true,
|
||||
"cwd": "${workspaceFolder}/GDevelop.js"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "newIDE/app Jest tests (current file)",
|
||||
"program": "${workspaceFolder}/newIDE/app/node_modules/.bin/react-scripts",
|
||||
"args": [
|
||||
"test", "--env=node",
|
||||
"${fileBasenameNoExtension}"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"cwd": "${workspaceFolder}/newIDE/app"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -109,12 +109,12 @@
|
||||
"xutility": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xmemory0": "cpp"
|
||||
"xmemory0": "cpp",
|
||||
"memory_resource": "cpp"
|
||||
},
|
||||
"files.exclude": {
|
||||
"Binaries/*build*": true,
|
||||
"Binaries/Output": true,
|
||||
"ExtLibs/SFML": true,
|
||||
"GDJS/Runtime-dist": true,
|
||||
"docs": true,
|
||||
"newIDE/electron-app/dist": true,
|
||||
|
@@ -17,7 +17,7 @@ endmacro()
|
||||
gd_set_option(BUILD_CORE TRUE BOOL "TRUE to build GDevelop Core library")
|
||||
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_TESTS FALSE BOOL "TRUE to build the tests")
|
||||
gd_set_option(BUILD_TESTS TRUE BOOL "TRUE to build the tests")
|
||||
|
||||
# Disable deprecated code
|
||||
set(NO_GUI TRUE CACHE BOOL "" FORCE) #Force disable old GUI related code.
|
||||
|
@@ -14,7 +14,6 @@ set(GDCORE_lib_dir ${GD_base_dir}/Binaries/Output/${CMAKE_BUILD_TYPE}_${CMAKE_SY
|
||||
|
||||
#Dependencies on external libraries:
|
||||
###
|
||||
include_directories(${sfml_include_dir})
|
||||
|
||||
#Defines
|
||||
###
|
||||
@@ -68,14 +67,6 @@ set(LIBRARY_OUTPUT_PATH ${GD_base_dir}/Binaries/Output/${CMAKE_BUILD_TYPE}_${CMA
|
||||
set(ARCHIVE_OUTPUT_PATH ${GD_base_dir}/Binaries/Output/${CMAKE_BUILD_TYPE}_${CMAKE_SYSTEM_NAME})
|
||||
set(RUNTIME_OUTPUT_PATH ${GD_base_dir}/Binaries/Output/${CMAKE_BUILD_TYPE}_${CMAKE_SYSTEM_NAME})
|
||||
|
||||
#Linker files
|
||||
###
|
||||
IF(EMSCRIPTEN)
|
||||
#Nothing.
|
||||
ELSE()
|
||||
target_link_libraries(GDCore ${sfml_LIBRARIES})
|
||||
ENDIF()
|
||||
|
||||
#Tests
|
||||
###
|
||||
if(BUILD_TESTS)
|
||||
@@ -88,5 +79,5 @@ if(BUILD_TESTS)
|
||||
add_executable(GDCore_tests ${test_source_files})
|
||||
set_target_properties(GDCore_tests PROPERTIES BUILD_WITH_INSTALL_RPATH FALSE) #Allow finding dependencies directly from build path on Mac OS X.
|
||||
target_link_libraries(GDCore_tests GDCore)
|
||||
target_link_libraries(GDCore_tests ${sfml_LIBRARIES})
|
||||
target_link_libraries(GDCore_tests ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Utf8/utf8.h"
|
||||
#include <SFML/System/String.hpp>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define GD_DEPRECATED __attribute__((deprecated))
|
||||
|
36
Core/GDCore/Events/Builtin/AsyncEvent.cpp
Normal file
36
Core/GDCore/Events/Builtin/AsyncEvent.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#include "AsyncEvent.h"
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
|
||||
#include "GDCore/Events/Serialization.h"
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace gd {
|
||||
|
||||
AsyncEvent::AsyncEvent() : BaseEvent() {}
|
||||
|
||||
AsyncEvent::~AsyncEvent(){};
|
||||
|
||||
vector<const gd::InstructionsList *> AsyncEvent::GetAllActionsVectors() const {
|
||||
vector<const gd::InstructionsList *> allActions;
|
||||
allActions.push_back(&actions);
|
||||
|
||||
return allActions;
|
||||
}
|
||||
|
||||
vector<gd::InstructionsList *> AsyncEvent::GetAllActionsVectors() {
|
||||
vector<gd::InstructionsList *> allActions;
|
||||
allActions.push_back(&actions);
|
||||
|
||||
return allActions;
|
||||
}
|
||||
|
||||
} // namespace gd
|
61
Core/GDCore/Events/Builtin/AsyncEvent.h
Normal file
61
Core/GDCore/Events/Builtin/AsyncEvent.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef GDCORE_ASYNCEVENT_H
|
||||
#define GDCORE_ASYNCEVENT_H
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Events/EventsList.h"
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Events/InstructionsList.h"
|
||||
namespace gd {
|
||||
class Instruction;
|
||||
class Project;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Internal event for asynchronous actions.
|
||||
* This event gets added internally to the events tree when an
|
||||
* asynchronous action is used.
|
||||
*/
|
||||
class GD_CORE_API AsyncEvent : public gd::BaseEvent {
|
||||
public:
|
||||
AsyncEvent();
|
||||
AsyncEvent(const gd::Instruction &asyncAction_,
|
||||
const gd::InstructionsList &actions_,
|
||||
const gd::EventsList &subEvents_)
|
||||
: asyncAction(asyncAction_), actions(actions_), subEvents(subEvents_) {
|
||||
SetType("BuiltinAsync::Async");
|
||||
};
|
||||
virtual ~AsyncEvent();
|
||||
virtual gd::AsyncEvent *Clone() const { return new AsyncEvent(*this); }
|
||||
|
||||
virtual bool IsExecutable() const { return true; }
|
||||
|
||||
virtual bool CanHaveSubEvents() const { return true; }
|
||||
virtual const gd::EventsList &GetSubEvents() const { return subEvents; };
|
||||
virtual gd::EventsList &GetSubEvents() { return subEvents; };
|
||||
|
||||
const gd::InstructionsList &GetActions() const { return actions; };
|
||||
gd::InstructionsList &GetActions() { return actions; };
|
||||
|
||||
const gd::Instruction &GetInstruction() const { return asyncAction; };
|
||||
gd::Instruction &GetInstruction() { return asyncAction; };
|
||||
|
||||
virtual std::vector<const gd::InstructionsList *>
|
||||
GetAllActionsVectors() const;
|
||||
virtual std::vector<gd::InstructionsList *> GetAllActionsVectors();
|
||||
|
||||
private:
|
||||
gd::Instruction asyncAction;
|
||||
gd::InstructionsList actions;
|
||||
EventsList subEvents;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // GDCORE_STANDARDEVENT_H
|
@@ -21,6 +21,12 @@ vector<gd::String> CommentEvent::GetAllSearchableStrings() const {
|
||||
return allSearchableStrings;
|
||||
}
|
||||
|
||||
bool CommentEvent::ReplaceAllSearchableStrings(
|
||||
std::vector<gd::String> newSearchableString) {
|
||||
SetComment(newSearchableString[0]);
|
||||
return newSearchableString[0] == com1;
|
||||
}
|
||||
|
||||
void CommentEvent::SerializeTo(SerializerElement &element) const {
|
||||
element.AddChild("color")
|
||||
.SetAttribute("r", r)
|
||||
|
@@ -47,6 +47,8 @@ class GD_CORE_API CommentEvent : public gd::BaseEvent {
|
||||
void SetComment(const gd::String& comment) { com1 = comment; }
|
||||
|
||||
virtual std::vector<gd::String> GetAllSearchableStrings() const;
|
||||
virtual bool ReplaceAllSearchableStrings(
|
||||
std::vector<gd::String> newSearchableString);
|
||||
|
||||
virtual void SerializeTo(SerializerElement& element) const;
|
||||
virtual void UnserializeFrom(gd::Project& project,
|
||||
|
@@ -27,6 +27,12 @@ vector<gd::String> GroupEvent::GetAllSearchableStrings() const {
|
||||
return allSearchableStrings;
|
||||
}
|
||||
|
||||
bool GroupEvent::ReplaceAllSearchableStrings(
|
||||
std::vector<gd::String> newSearchableString) {
|
||||
SetName(newSearchableString[0]);
|
||||
return newSearchableString[0] == name;
|
||||
}
|
||||
|
||||
void GroupEvent::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("name", name);
|
||||
element.SetAttribute("source", source);
|
||||
@@ -69,5 +75,4 @@ void GroupEvent::SetBackgroundColor(unsigned int colorR_,
|
||||
colorB = colorB_;
|
||||
}
|
||||
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -107,6 +107,8 @@ class GD_CORE_API GroupEvent : public gd::BaseEvent {
|
||||
virtual gd::EventsList& GetSubEvents() { return events; };
|
||||
|
||||
virtual std::vector<gd::String> GetAllSearchableStrings() const;
|
||||
virtual bool ReplaceAllSearchableStrings(
|
||||
std::vector<gd::String> newSearchableString);
|
||||
|
||||
virtual void SerializeTo(SerializerElement& element) const;
|
||||
virtual void UnserializeFrom(gd::Project& project,
|
||||
|
@@ -63,8 +63,12 @@ void StandardEvent::UnserializeFrom(gd::Project& project,
|
||||
project, conditions, element.GetChild("conditions", 0, "Conditions"));
|
||||
gd::EventsListSerialization::UnserializeInstructionsFrom(
|
||||
project, actions, element.GetChild("actions", 0, "Actions"));
|
||||
gd::EventsListSerialization::UnserializeEventsFrom(
|
||||
project, events, element.GetChild("events", 0, "Events"));
|
||||
|
||||
events.Clear();
|
||||
if (element.HasChild("events", "Events")) {
|
||||
gd::EventsListSerialization::UnserializeEventsFrom(
|
||||
project, events, element.GetChild("events", 0, "Events"));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -4,7 +4,9 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
|
||||
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
|
||||
@@ -14,7 +16,7 @@ using namespace std;
|
||||
namespace gd {
|
||||
|
||||
void EventsCodeGenerationContext::InheritsFrom(
|
||||
const EventsCodeGenerationContext& parent_) {
|
||||
EventsCodeGenerationContext& parent_) {
|
||||
parent = &parent_;
|
||||
|
||||
// Objects lists declared by parent became "already declared" in the child
|
||||
@@ -24,8 +26,8 @@ void EventsCodeGenerationContext::InheritsFrom(
|
||||
parent_.objectsListsToBeDeclared.end(),
|
||||
std::inserter(alreadyDeclaredObjectsLists,
|
||||
alreadyDeclaredObjectsLists.begin()));
|
||||
std::copy(parent_.objectsListsWithoutPickingToBeDeclared.begin(),
|
||||
parent_.objectsListsWithoutPickingToBeDeclared.end(),
|
||||
std::copy(parent_.objectsListsOrEmptyToBeDeclared.begin(),
|
||||
parent_.objectsListsOrEmptyToBeDeclared.end(),
|
||||
std::inserter(alreadyDeclaredObjectsLists,
|
||||
alreadyDeclaredObjectsLists.begin()));
|
||||
std::copy(parent_.emptyObjectsListsToBeDeclared.begin(),
|
||||
@@ -33,6 +35,8 @@ void EventsCodeGenerationContext::InheritsFrom(
|
||||
std::inserter(alreadyDeclaredObjectsLists,
|
||||
alreadyDeclaredObjectsLists.begin()));
|
||||
|
||||
nearestAsyncParent = parent_.IsAsyncCallback() ? &parent_ : parent_.nearestAsyncParent;
|
||||
asyncDepth = parent_.asyncDepth;
|
||||
depthOfLastUse = parent_.depthOfLastUse;
|
||||
customConditionDepth = parent_.customConditionDepth;
|
||||
contextDepth = parent_.GetContextDepth() + 1;
|
||||
@@ -42,33 +46,59 @@ void EventsCodeGenerationContext::InheritsFrom(
|
||||
}
|
||||
}
|
||||
|
||||
void EventsCodeGenerationContext::InheritsAsAsyncCallbackFrom(
|
||||
EventsCodeGenerationContext& parent_) {
|
||||
// Increasing the async depth is enough to mark the context as an async callback.
|
||||
InheritsFrom(parent_);
|
||||
asyncDepth = parent_.asyncDepth + 1;
|
||||
}
|
||||
|
||||
void EventsCodeGenerationContext::Reuse(
|
||||
const EventsCodeGenerationContext& parent_) {
|
||||
EventsCodeGenerationContext& parent_) {
|
||||
InheritsFrom(parent_);
|
||||
if (parent_.CanReuse())
|
||||
contextDepth = parent_.GetContextDepth(); // Keep same context depth
|
||||
}
|
||||
|
||||
void EventsCodeGenerationContext::NotifyAsyncParentsAboutDeclaredObject(const gd::String& objectName) {
|
||||
gd::EventsCodeGenerationContext* asyncContext = IsAsyncCallback() ? this : nearestAsyncParent;
|
||||
for (;
|
||||
asyncContext != nullptr;
|
||||
asyncContext = asyncContext->parent->nearestAsyncParent)
|
||||
asyncContext->allObjectsListToBeDeclaredAcrossChildren.insert(objectName);
|
||||
}
|
||||
|
||||
void EventsCodeGenerationContext::ObjectsListNeeded(
|
||||
const gd::String& objectName) {
|
||||
if (!IsToBeDeclared(objectName))
|
||||
if (!IsToBeDeclared(objectName)) {
|
||||
objectsListsToBeDeclared.insert(objectName);
|
||||
|
||||
if (IsInsideAsync()) {
|
||||
NotifyAsyncParentsAboutDeclaredObject(objectName);
|
||||
}
|
||||
}
|
||||
|
||||
depthOfLastUse[objectName] = GetContextDepth();
|
||||
}
|
||||
|
||||
void EventsCodeGenerationContext::ObjectsListWithoutPickingNeeded(
|
||||
void EventsCodeGenerationContext::ObjectsListNeededOrEmptyIfJustDeclared(
|
||||
const gd::String& objectName) {
|
||||
if (!IsToBeDeclared(objectName))
|
||||
objectsListsWithoutPickingToBeDeclared.insert(objectName);
|
||||
if (!IsToBeDeclared(objectName)) {
|
||||
objectsListsOrEmptyToBeDeclared.insert(objectName);
|
||||
|
||||
if (IsInsideAsync()) {
|
||||
NotifyAsyncParentsAboutDeclaredObject(objectName);
|
||||
}
|
||||
}
|
||||
|
||||
depthOfLastUse[objectName] = GetContextDepth();
|
||||
}
|
||||
|
||||
void EventsCodeGenerationContext::EmptyObjectsListNeeded(
|
||||
const gd::String& objectName) {
|
||||
if (!IsToBeDeclared(objectName))
|
||||
if (!IsToBeDeclared(objectName)) {
|
||||
emptyObjectsListsToBeDeclared.insert(objectName);
|
||||
}
|
||||
|
||||
depthOfLastUse[objectName] = GetContextDepth();
|
||||
}
|
||||
@@ -77,8 +107,8 @@ std::set<gd::String> EventsCodeGenerationContext::GetAllObjectsToBeDeclared()
|
||||
const {
|
||||
std::set<gd::String> allObjectListsToBeDeclared(
|
||||
objectsListsToBeDeclared.begin(), objectsListsToBeDeclared.end());
|
||||
allObjectListsToBeDeclared.insert(objectsListsWithoutPickingToBeDeclared.begin(),
|
||||
objectsListsWithoutPickingToBeDeclared.end());
|
||||
allObjectListsToBeDeclared.insert(objectsListsOrEmptyToBeDeclared.begin(),
|
||||
objectsListsOrEmptyToBeDeclared.end());
|
||||
allObjectListsToBeDeclared.insert(emptyObjectsListsToBeDeclared.begin(),
|
||||
emptyObjectsListsToBeDeclared.end());
|
||||
|
||||
@@ -102,4 +132,21 @@ bool EventsCodeGenerationContext::IsSameObjectsList(
|
||||
otherContext.GetLastDepthObjectListWasNeeded(objectName);
|
||||
}
|
||||
|
||||
bool EventsCodeGenerationContext::ShouldUseAsyncObjectsList(
|
||||
const gd::String& objectName) const {
|
||||
if (!IsInsideAsync()) return false;
|
||||
|
||||
// Check if the objects list was used after (or in) the nearest async callback context.
|
||||
const gd::EventsCodeGenerationContext* asyncContext = IsAsyncCallback() ? this : nearestAsyncParent;
|
||||
if (parent->GetLastDepthObjectListWasNeeded(objectName) >= asyncContext->GetContextDepth()) {
|
||||
// The object was used in a context after (or in) the nearest async parent context, so we're not getting it from the
|
||||
// async object lists (it was already gotten from there in this previous context).
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the objects list is declared in a parent of the nearest async context, it means
|
||||
// the async context had to use an async objects list to access it.
|
||||
return asyncContext->ObjectAlreadyDeclaredByParents(objectName);
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
@@ -33,11 +34,7 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
* updated to contain the maximal scope depth reached.
|
||||
*/
|
||||
EventsCodeGenerationContext(unsigned int* maxDepthLevel_ = nullptr)
|
||||
: contextDepth(0),
|
||||
customConditionDepth(0),
|
||||
maxDepthLevel(maxDepthLevel_),
|
||||
parent(NULL),
|
||||
reuseExplicitlyForbidden(false){};
|
||||
: maxDepthLevel(maxDepthLevel_){};
|
||||
virtual ~EventsCodeGenerationContext(){};
|
||||
|
||||
/**
|
||||
@@ -45,7 +42,13 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
* another one. The child will then for example not declare again objects
|
||||
* already declared by its parent.
|
||||
*/
|
||||
void InheritsFrom(const EventsCodeGenerationContext& parent);
|
||||
void InheritsFrom(EventsCodeGenerationContext& parent);
|
||||
|
||||
/**
|
||||
* Call this method to make an EventsCodeGenerationContext as a "child" of
|
||||
* another one, but in the context of an async function.
|
||||
*/
|
||||
void InheritsAsAsyncCallbackFrom(EventsCodeGenerationContext& parent);
|
||||
|
||||
/**
|
||||
* \brief As InheritsFrom, mark the context as being the child of another one,
|
||||
@@ -53,7 +56,7 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
*
|
||||
* Used for example for optimizing the last event of a list.
|
||||
*/
|
||||
void Reuse(const EventsCodeGenerationContext& parent);
|
||||
void Reuse(EventsCodeGenerationContext& parent);
|
||||
|
||||
/**
|
||||
* \brief Forbid any optimization that would reuse and modify the object list
|
||||
@@ -88,19 +91,19 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
const EventsCodeGenerationContext* GetParentContext() const { return parent; }
|
||||
|
||||
/**
|
||||
* Mark the object has being the object being handled by the instruction
|
||||
* Mark the object as being the object being handled by the instruction.
|
||||
*/
|
||||
void SetCurrentObject(const gd::String& objectName) {
|
||||
currentObject = objectName;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set that no particular object is being handled by an instruction
|
||||
* Set that no particular object is being handled by an instruction.
|
||||
*/
|
||||
void SetNoCurrentObject() { currentObject = ""; };
|
||||
|
||||
/**
|
||||
* Get the object being handled by the instruction
|
||||
* Get the object being handled by the instruction.
|
||||
*/
|
||||
const gd::String& GetCurrentObject() const { return currentObject; };
|
||||
|
||||
@@ -109,7 +112,7 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
*
|
||||
* The list will be filled with objects from the scene if it is the first time
|
||||
* it is requested, unless there is already an object list with this name
|
||||
* (i.e. `ObjectAlreadyDeclared(objectName)` returns true).
|
||||
* (i.e. `ObjectAlreadyDeclaredByParents(objectName)` returns true).
|
||||
*/
|
||||
void ObjectsListNeeded(const gd::String& objectName);
|
||||
|
||||
@@ -121,7 +124,7 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
* from the scene. If there is already an objects list with this name, no new
|
||||
* list will be declared again.
|
||||
*/
|
||||
void ObjectsListWithoutPickingNeeded(const gd::String& objectName);
|
||||
void ObjectsListNeededOrEmptyIfJustDeclared(const gd::String& objectName);
|
||||
|
||||
/**
|
||||
* Call this when an instruction in the event needs an empty object list,
|
||||
@@ -134,29 +137,21 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
void EmptyObjectsListNeeded(const gd::String& objectName);
|
||||
|
||||
/**
|
||||
* Return true if an object list has already been declared (or is going to be
|
||||
* declared).
|
||||
* Return true if an object list has already been declared by the parent contexts.
|
||||
*/
|
||||
bool ObjectAlreadyDeclared(const gd::String& objectName) const {
|
||||
bool ObjectAlreadyDeclaredByParents(const gd::String& objectName) const {
|
||||
return (alreadyDeclaredObjectsLists.find(objectName) !=
|
||||
alreadyDeclaredObjectsLists.end());
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Consider that \a objectName is now declared in the context.
|
||||
*/
|
||||
void SetObjectDeclared(const gd::String& objectName) {
|
||||
alreadyDeclaredObjectsLists.insert(objectName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the objects lists which will be declared by the current context
|
||||
* ( the non empty as well as the empty objects lists )
|
||||
* (normal, potentially empty or empty).
|
||||
*/
|
||||
std::set<gd::String> GetAllObjectsToBeDeclared() const;
|
||||
|
||||
/**
|
||||
* Return the objects lists which will be declared by the current context
|
||||
* Return the objects lists which will be declared by the current context.
|
||||
*/
|
||||
const std::set<gd::String>& GetObjectsListsToBeDeclared() const {
|
||||
return objectsListsToBeDeclared;
|
||||
@@ -166,9 +161,9 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
* Return the objects lists which will be will be declared, without filling
|
||||
* them with objects from the scene.
|
||||
*/
|
||||
const std::set<gd::String>& GetObjectsListsToBeDeclaredWithoutPicking()
|
||||
const std::set<gd::String>& GetObjectsListsToBeEmptyIfJustDeclared()
|
||||
const {
|
||||
return objectsListsWithoutPickingToBeDeclared;
|
||||
return objectsListsOrEmptyToBeDeclared;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -184,7 +179,7 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
* Return the objects lists which are already declared and can be used in the
|
||||
* current context without declaration.
|
||||
*/
|
||||
const std::set<gd::String>& GetObjectsListsAlreadyDeclared() const {
|
||||
const std::set<gd::String>& GetObjectsListsAlreadyDeclaredByParents() const {
|
||||
return alreadyDeclaredObjectsLists;
|
||||
};
|
||||
|
||||
@@ -227,22 +222,55 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
*/
|
||||
size_t GetCurrentConditionDepth() const { return customConditionDepth; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* \brief Returns the list of all objects declared in this context
|
||||
* and subcontexts.
|
||||
* \warning Only works on an async callback's context.
|
||||
*
|
||||
* It is to be used by the Async event code generator to know what objects
|
||||
* lists to backup for the async callback and async callbacks after it.
|
||||
*/
|
||||
const std::set<gd::String>& GetAllDeclaredObjectsAcrossChildren() {
|
||||
return allObjectsListToBeDeclaredAcrossChildren;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if an object list should be gotten from a backed up
|
||||
* objects list instead of the parent context. This can happen inside an
|
||||
* asynchronous callback or a child context of an asynchronous callback (i.e:
|
||||
* the `asyncDepth` is not 0).
|
||||
*/
|
||||
bool ShouldUseAsyncObjectsList(const gd::String& objectName) const;
|
||||
|
||||
/**
|
||||
* Returns true if the code currently being generated is inside an
|
||||
* asynchronous context (either in an asynchronous callback, or in a children of
|
||||
* an asynchronous callback).
|
||||
*/
|
||||
bool IsInsideAsync() const { return asyncDepth != 0; };
|
||||
|
||||
/**
|
||||
* Returns true if the code currently being generated is an asynchronous
|
||||
* callback (but not a child of an asynchronous callback).
|
||||
*/
|
||||
bool IsAsyncCallback() const { return parent != nullptr && parent->asyncDepth != asyncDepth; }
|
||||
|
||||
/**
|
||||
* \brief Returns true if the given object is already going to be declared
|
||||
* (either as a traditional objects list, or one without picking, or one
|
||||
* empty).
|
||||
*
|
||||
* in this context (either as a traditional objects list, or an empty one).
|
||||
*/
|
||||
bool IsToBeDeclared(const gd::String& objectName) {
|
||||
return objectsListsToBeDeclared.find(objectName) !=
|
||||
objectsListsToBeDeclared.end() ||
|
||||
objectsListsWithoutPickingToBeDeclared.find(objectName) !=
|
||||
objectsListsWithoutPickingToBeDeclared.end() ||
|
||||
objectsListsOrEmptyToBeDeclared.find(objectName) !=
|
||||
objectsListsOrEmptyToBeDeclared.end() ||
|
||||
emptyObjectsListsToBeDeclared.find(objectName) !=
|
||||
emptyObjectsListsToBeDeclared.end();
|
||||
};
|
||||
|
||||
private:
|
||||
void NotifyAsyncParentsAboutDeclaredObject(const gd::String& objectName);
|
||||
|
||||
std::set<gd::String>
|
||||
alreadyDeclaredObjectsLists; ///< Objects lists already needed in a
|
||||
///< parent context.
|
||||
@@ -250,7 +278,7 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
objectsListsToBeDeclared; ///< Objects lists that will be declared in
|
||||
///< this context.
|
||||
std::set<gd::String>
|
||||
objectsListsWithoutPickingToBeDeclared; ///< Objects lists that will be
|
||||
objectsListsOrEmptyToBeDeclared; ///< Objects lists that will be
|
||||
///< declared in this context,
|
||||
///< but not filled with scene's
|
||||
///< objects.
|
||||
@@ -260,21 +288,40 @@ class GD_CORE_API EventsCodeGenerationContext {
|
||||
///< but not filled with scene's
|
||||
///< objects and not filled with any
|
||||
///< previously existing objects list.
|
||||
std::set<gd::String>
|
||||
allObjectsListToBeDeclaredAcrossChildren; ///< This is only to be used by
|
||||
///< the async callback
|
||||
///< contexts to know all
|
||||
///< objects declared across
|
||||
///< all children, so that the
|
||||
///< necessary objects can be
|
||||
///< backed up.
|
||||
|
||||
std::map<gd::String, unsigned int>
|
||||
depthOfLastUse; ///< The context depth when an object was last used.
|
||||
gd::String
|
||||
currentObject; ///< The object being used by an action or condition.
|
||||
unsigned int contextDepth; ///< The depth of the context : 0 for a newly
|
||||
///< created context, n+1 for any context
|
||||
///< inheriting from context with depth n.
|
||||
unsigned int
|
||||
customConditionDepth; ///< The depth of the conditions being generated.
|
||||
unsigned int contextDepth = 0; ///< The depth of the context: 0 for a newly
|
||||
///< created context, n+1 for any context
|
||||
///< inheriting from context with depth n.
|
||||
unsigned int customConditionDepth =
|
||||
0; ///< The depth of the conditions being generated.
|
||||
unsigned int asyncDepth =
|
||||
0; ///< If higher than 0, the current context is an asynchronous callback,
|
||||
///< or a child context of an asynchronous callback:
|
||||
///< - If the parent's async depth != the current context async depth,
|
||||
///< then the current context is an asynchronous callback context.
|
||||
///< - Otherwise, it's a child of an asynchronous callback.
|
||||
unsigned int* maxDepthLevel; ///< A pointer to a unsigned int updated with
|
||||
///< the maximum depth reached.
|
||||
const EventsCodeGenerationContext*
|
||||
parent; ///< The parent of the current context. Can be NULL.
|
||||
bool reuseExplicitlyForbidden; ///< If set to true, forbid children context
|
||||
///< to reuse this one without inheriting.
|
||||
const EventsCodeGenerationContext* parent =
|
||||
nullptr; ///< The parent of the current context. Can be NULL.
|
||||
EventsCodeGenerationContext* nearestAsyncParent =
|
||||
nullptr; ///< The nearest parent context that is an async callback
|
||||
///< context.
|
||||
bool reuseExplicitlyForbidden =
|
||||
false; ///< If set to true, forbid children contexts
|
||||
///< to reuse this one without inheriting.
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -315,31 +315,38 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
||||
|
||||
if (instrInfos.IsObjectInstruction()) {
|
||||
gd::String objectName = condition.GetParameter(0).GetPlainString();
|
||||
gd::String objectType = gd::GetTypeOfObject(
|
||||
GetGlobalObjectsAndGroups(), GetObjectsAndGroups(), objectName);
|
||||
if (!objectName.empty() && !instrInfos.parameters.empty()) {
|
||||
std::vector<gd::String> realObjects =
|
||||
ExpandObjectsName(objectName, context);
|
||||
for (std::size_t i = 0; i < realObjects.size(); ++i) {
|
||||
// Set up the context
|
||||
gd::String objectType = gd::GetTypeOfObject(
|
||||
GetGlobalObjectsAndGroups(), GetObjectsAndGroups(), realObjects[i]);
|
||||
const ObjectMetadata& objInfo =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
AddIncludeFiles(objInfo.includeFiles);
|
||||
context.SetCurrentObject(realObjects[i]);
|
||||
context.ObjectsListNeeded(realObjects[i]);
|
||||
|
||||
// Prepare arguments and generate the condition whole code
|
||||
vector<gd::String> arguments = GenerateParametersCodes(
|
||||
condition.GetParameters(), instrInfos.parameters, context);
|
||||
conditionCode += GenerateObjectCondition(realObjects[i],
|
||||
objInfo,
|
||||
arguments,
|
||||
instrInfos,
|
||||
returnBoolean,
|
||||
condition.IsInverted(),
|
||||
context);
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
instrInfos.GetRequiredBaseObjectCapability())) {
|
||||
conditionCode +=
|
||||
"/* Object with unsupported capability - skipped. */\n";
|
||||
} else {
|
||||
AddIncludeFiles(objInfo.includeFiles);
|
||||
context.SetCurrentObject(realObjects[i]);
|
||||
context.ObjectsListNeeded(realObjects[i]);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
// Prepare arguments and generate the condition whole code
|
||||
vector<gd::String> arguments = GenerateParametersCodes(
|
||||
condition.GetParameters(), instrInfos.parameters, context);
|
||||
conditionCode += GenerateObjectCondition(realObjects[i],
|
||||
objInfo,
|
||||
arguments,
|
||||
instrInfos,
|
||||
returnBoolean,
|
||||
condition.IsInverted(),
|
||||
context);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (instrInfos.IsBehaviorInstruction()) {
|
||||
@@ -443,7 +450,9 @@ gd::String EventsCodeGenerator::GenerateConditionsListCode(
|
||||
* Generate code for an action.
|
||||
*/
|
||||
gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
gd::Instruction& action, EventsCodeGenerationContext& context) {
|
||||
gd::Instruction& action,
|
||||
EventsCodeGenerationContext& context,
|
||||
const gd::String& optionalAsyncCallbackName) {
|
||||
gd::String actionCode;
|
||||
|
||||
const gd::InstructionMetadata& instrInfos =
|
||||
@@ -489,27 +498,37 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
// Call free function first if available
|
||||
if (instrInfos.IsObjectInstruction()) {
|
||||
gd::String objectName = action.GetParameter(0).GetPlainString();
|
||||
gd::String objectType = gd::GetTypeOfObject(
|
||||
GetGlobalObjectsAndGroups(), GetObjectsAndGroups(), objectName);
|
||||
|
||||
if (!instrInfos.parameters.empty()) {
|
||||
std::vector<gd::String> realObjects =
|
||||
ExpandObjectsName(objectName, context);
|
||||
for (std::size_t i = 0; i < realObjects.size(); ++i) {
|
||||
// Setup context
|
||||
gd::String objectType = gd::GetTypeOfObject(
|
||||
GetGlobalObjectsAndGroups(), GetObjectsAndGroups(), realObjects[i]);
|
||||
const ObjectMetadata& objInfo =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
AddIncludeFiles(objInfo.includeFiles);
|
||||
context.SetCurrentObject(realObjects[i]);
|
||||
context.ObjectsListNeeded(realObjects[i]);
|
||||
|
||||
// Prepare arguments and generate the whole action code
|
||||
vector<gd::String> arguments = GenerateParametersCodes(
|
||||
action.GetParameters(), instrInfos.parameters, context);
|
||||
actionCode += GenerateObjectAction(
|
||||
realObjects[i], objInfo, arguments, instrInfos, context);
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
instrInfos.GetRequiredBaseObjectCapability())) {
|
||||
actionCode += "/* Object with unsupported capability - skipped. */\n";
|
||||
} else {
|
||||
AddIncludeFiles(objInfo.includeFiles);
|
||||
context.SetCurrentObject(realObjects[i]);
|
||||
context.ObjectsListNeeded(realObjects[i]);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
// Prepare arguments and generate the whole action code
|
||||
vector<gd::String> arguments = GenerateParametersCodes(
|
||||
action.GetParameters(), instrInfos.parameters, context);
|
||||
actionCode += GenerateObjectAction(realObjects[i],
|
||||
objInfo,
|
||||
arguments,
|
||||
instrInfos,
|
||||
context,
|
||||
optionalAsyncCallbackName);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (instrInfos.IsBehaviorInstruction()) {
|
||||
@@ -539,7 +558,8 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
autoInfo,
|
||||
arguments,
|
||||
instrInfos,
|
||||
context);
|
||||
context,
|
||||
optionalAsyncCallbackName);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
}
|
||||
@@ -547,12 +567,72 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
} else {
|
||||
vector<gd::String> arguments = GenerateParametersCodes(
|
||||
action.GetParameters(), instrInfos.parameters, context);
|
||||
actionCode += GenerateFreeAction(arguments, instrInfos, context);
|
||||
actionCode +=
|
||||
GenerateFreeAction(arguments, instrInfos, context, optionalAsyncCallbackName);
|
||||
}
|
||||
|
||||
return actionCode;
|
||||
}
|
||||
|
||||
const EventsCodeGenerator::CallbackDescriptor
|
||||
EventsCodeGenerator::GenerateCallback(
|
||||
const gd::String& callbackID,
|
||||
gd::EventsCodeGenerationContext& parentContext,
|
||||
gd::InstructionsList& actions,
|
||||
gd::EventsList* subEvents) {
|
||||
gd::EventsCodeGenerationContext callbackContext;
|
||||
callbackContext.InheritsAsAsyncCallbackFrom(parentContext);
|
||||
const gd::String callbackFunctionName =
|
||||
GetCodeNamespaceAccessor() + "asyncCallback" + callbackID;
|
||||
const gd::String callbackFunctionArguments =
|
||||
GenerateEventsParameters(callbackContext);
|
||||
|
||||
// Generate actions
|
||||
gd::String actionsCode = GenerateActionsListCode(actions, callbackContext);
|
||||
|
||||
// Generate subevents
|
||||
if (subEvents != nullptr) // Sub events
|
||||
{
|
||||
actionsCode += "\n{ //Subevents\n";
|
||||
actionsCode += GenerateEventsListCode(*subEvents, callbackContext);
|
||||
actionsCode += "} //End of subevents\n";
|
||||
}
|
||||
|
||||
// Compose the callback function and add outside main
|
||||
const gd::String actionsDeclarationsCode =
|
||||
GenerateObjectsDeclarationCode(callbackContext);
|
||||
|
||||
const gd::String callbackCode = callbackFunctionName + " = function (" +
|
||||
GenerateEventsParameters(callbackContext) +
|
||||
") {\n" + actionsDeclarationsCode +
|
||||
actionsCode + "}\n";
|
||||
|
||||
AddCustomCodeOutsideMain(callbackCode);
|
||||
|
||||
std::set<gd::String> requiredObjects;
|
||||
// Build the list of all objects required by the callback. Any object that has
|
||||
// already been declared could have gone through previous object picking, so
|
||||
// if such an object is used by the actions or subevents of this callback, we
|
||||
// must ask the caller to pass the already existing objects lists through a
|
||||
// `LongLivedObjectsList` to the callback function.
|
||||
for (const auto& objectUsedInSubTree :
|
||||
callbackContext.GetAllDeclaredObjectsAcrossChildren()) {
|
||||
if (callbackContext.ObjectAlreadyDeclaredByParents(objectUsedInSubTree))
|
||||
requiredObjects.insert(objectUsedInSubTree);
|
||||
};
|
||||
|
||||
return CallbackDescriptor(
|
||||
callbackFunctionName, callbackFunctionArguments, requiredObjects);
|
||||
};
|
||||
|
||||
const gd::String EventsCodeGenerator::GenerateEventsParameters(
|
||||
const gd::EventsCodeGenerationContext& context) {
|
||||
gd::String parameters = "runtimeScene";
|
||||
if (!HasProjectAndLayout()) parameters += ", eventsFunctionContext";
|
||||
if (context.IsInsideAsync()) parameters += ", asyncObjectsList";
|
||||
return parameters;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate actions code.
|
||||
*/
|
||||
@@ -621,14 +701,15 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
|
||||
argOutput = GenerateGetBehaviorNameCode(parameter);
|
||||
} else if (metadata.type == "key") {
|
||||
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
||||
} else if (metadata.type == "password" || // Deprecated
|
||||
metadata.type ==
|
||||
"musicfile" || // Should be renamed "largeAudioResource"
|
||||
metadata.type ==
|
||||
"soundfile" || // Should be renamed "audioResource"
|
||||
metadata.type == "police" || // Should be renamed "fontResource"
|
||||
} else if (metadata.type == "audioResource" ||
|
||||
metadata.type == "bitmapFontResource" ||
|
||||
metadata.type == "imageResource") {
|
||||
metadata.type == "fontResource" ||
|
||||
metadata.type == "imageResource" ||
|
||||
metadata.type == "jsonResource" ||
|
||||
metadata.type == "videoResource" ||
|
||||
// Deprecated, old parameter names:
|
||||
metadata.type == "password" || metadata.type == "musicfile" ||
|
||||
metadata.type == "soundfile" || metadata.type == "police") {
|
||||
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
||||
} else if (metadata.type == "mouse") {
|
||||
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
||||
@@ -729,23 +810,21 @@ gd::String EventsCodeGenerator::GenerateObjectsDeclarationCode(
|
||||
gd::String declarationsCode;
|
||||
for (auto object : context.GetObjectsListsToBeDeclared()) {
|
||||
gd::String objectListDeclaration = "";
|
||||
if (!context.ObjectAlreadyDeclared(object)) {
|
||||
if (!context.ObjectAlreadyDeclaredByParents(object)) {
|
||||
objectListDeclaration = "std::vector<RuntimeObject*> " +
|
||||
GetObjectListName(object, context) +
|
||||
" = runtimeContext->GetObjectsRawPointers(\"" +
|
||||
ConvertToString(object) + "\");\n";
|
||||
context.SetObjectDeclared(object);
|
||||
} else
|
||||
objectListDeclaration = declareObjectList(object, context);
|
||||
|
||||
declarationsCode += objectListDeclaration + "\n";
|
||||
}
|
||||
for (auto object : context.GetObjectsListsToBeDeclaredWithoutPicking()) {
|
||||
for (auto object : context.GetObjectsListsToBeEmptyIfJustDeclared()) {
|
||||
gd::String objectListDeclaration = "";
|
||||
if (!context.ObjectAlreadyDeclared(object)) {
|
||||
if (!context.ObjectAlreadyDeclaredByParents(object)) {
|
||||
objectListDeclaration = "std::vector<RuntimeObject*> " +
|
||||
GetObjectListName(object, context) + ";\n";
|
||||
context.SetObjectDeclared(object);
|
||||
} else
|
||||
objectListDeclaration = declareObjectList(object, context);
|
||||
|
||||
@@ -753,10 +832,9 @@ gd::String EventsCodeGenerator::GenerateObjectsDeclarationCode(
|
||||
}
|
||||
for (auto object : context.GetObjectsListsToBeDeclaredEmpty()) {
|
||||
gd::String objectListDeclaration = "";
|
||||
if (!context.ObjectAlreadyDeclared(object)) {
|
||||
if (!context.ObjectAlreadyDeclaredByParents(object)) {
|
||||
objectListDeclaration = "std::vector<RuntimeObject*> " +
|
||||
GetObjectListName(object, context) + ";\n";
|
||||
context.SetObjectDeclared(object);
|
||||
} else
|
||||
objectListDeclaration = "std::vector<RuntimeObject*> " +
|
||||
GetObjectListName(object, context) + ";\n";
|
||||
@@ -771,7 +849,7 @@ gd::String EventsCodeGenerator::GenerateObjectsDeclarationCode(
|
||||
* Generate events list code.
|
||||
*/
|
||||
gd::String EventsCodeGenerator::GenerateEventsListCode(
|
||||
gd::EventsList& events, const EventsCodeGenerationContext& parentContext) {
|
||||
gd::EventsList& events, EventsCodeGenerationContext& parentContext) {
|
||||
gd::String output;
|
||||
for (std::size_t eId = 0; eId < events.size(); ++eId) {
|
||||
// Each event has its own context : Objects picked in an event are totally
|
||||
@@ -787,6 +865,8 @@ gd::String EventsCodeGenerator::GenerateEventsListCode(
|
||||
// operation.
|
||||
bool reuseParentContext =
|
||||
parentContext.CanReuse() && eId == events.size() - 1;
|
||||
|
||||
// TODO: avoid creating if useless.
|
||||
gd::EventsCodeGenerationContext reusedContext;
|
||||
reusedContext.Reuse(parentContext);
|
||||
|
||||
@@ -1001,7 +1081,8 @@ gd::String EventsCodeGenerator::GenerateBehaviorCondition(
|
||||
gd::String EventsCodeGenerator::GenerateFreeAction(
|
||||
const std::vector<gd::String>& arguments,
|
||||
const gd::InstructionMetadata& instrInfos,
|
||||
gd::EventsCodeGenerationContext& context) {
|
||||
gd::EventsCodeGenerationContext& context,
|
||||
const gd::String& optionalAsyncCallbackName) {
|
||||
// Generate call
|
||||
gd::String call;
|
||||
if (instrInfos.codeExtraInformation.type == "number" ||
|
||||
@@ -1028,6 +1109,11 @@ gd::String EventsCodeGenerator::GenerateFreeAction(
|
||||
call = instrInfos.codeExtraInformation.functionCallName + "(" +
|
||||
GenerateArgumentsList(arguments) + ")";
|
||||
}
|
||||
|
||||
if (!optionalAsyncCallbackName.empty())
|
||||
call = "runtimeScene.getAsyncTasksManager().addTask(" + call + ", " +
|
||||
optionalAsyncCallbackName + ")";
|
||||
|
||||
return call + ";\n";
|
||||
}
|
||||
|
||||
@@ -1036,7 +1122,8 @@ gd::String EventsCodeGenerator::GenerateObjectAction(
|
||||
const gd::ObjectMetadata& objInfo,
|
||||
const std::vector<gd::String>& arguments,
|
||||
const gd::InstructionMetadata& instrInfos,
|
||||
gd::EventsCodeGenerationContext& context) {
|
||||
gd::EventsCodeGenerationContext& context,
|
||||
const gd::String& optionalAsyncCallbackName) {
|
||||
// Create call
|
||||
gd::String call;
|
||||
if ((instrInfos.codeExtraInformation.type == "number" ||
|
||||
@@ -1063,8 +1150,11 @@ gd::String EventsCodeGenerator::GenerateObjectAction(
|
||||
|
||||
call = instrInfos.codeExtraInformation.functionCallName + "(" +
|
||||
argumentsStr + ")";
|
||||
|
||||
return "For each picked object \"" + objectName + "\", call " + call + "(" +
|
||||
argumentsStr + ").\n";
|
||||
argumentsStr + ")" +
|
||||
(optionalAsyncCallbackName.empty() ? "" : (", then call" + optionalAsyncCallbackName)) +
|
||||
".\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1074,7 +1164,8 @@ gd::String EventsCodeGenerator::GenerateBehaviorAction(
|
||||
const gd::BehaviorMetadata& autoInfo,
|
||||
const std::vector<gd::String>& arguments,
|
||||
const gd::InstructionMetadata& instrInfos,
|
||||
gd::EventsCodeGenerationContext& context) {
|
||||
gd::EventsCodeGenerationContext& context,
|
||||
const gd::String& optionalAsyncCallbackName) {
|
||||
// Create call
|
||||
gd::String call;
|
||||
if ((instrInfos.codeExtraInformation.type == "number" ||
|
||||
@@ -1100,8 +1191,11 @@ gd::String EventsCodeGenerator::GenerateBehaviorAction(
|
||||
|
||||
call = instrInfos.codeExtraInformation.functionCallName + "(" +
|
||||
argumentsStr + ")";
|
||||
|
||||
return "For each picked object \"" + objectName + "\", call " + call + "(" +
|
||||
argumentsStr + ")" + " for behavior \"" + behaviorName + "\".\n";
|
||||
argumentsStr + ")" + " for behavior \"" + behaviorName + "\"" +
|
||||
(optionalAsyncCallbackName.empty() ? "" : (", then call" + optionalAsyncCallbackName)) +
|
||||
".\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ class GD_CORE_API EventsCodeGenerator {
|
||||
* \return Code
|
||||
*/
|
||||
virtual gd::String GenerateEventsListCode(
|
||||
gd::EventsList& events, const EventsCodeGenerationContext& context);
|
||||
gd::EventsList& events, EventsCodeGenerationContext& context);
|
||||
|
||||
/**
|
||||
* \brief Generate code for executing a condition list
|
||||
@@ -155,7 +155,51 @@ class GD_CORE_API EventsCodeGenerator {
|
||||
* \return Code
|
||||
*/
|
||||
gd::String GenerateActionCode(gd::Instruction& action,
|
||||
EventsCodeGenerationContext& context);
|
||||
EventsCodeGenerationContext& context,
|
||||
const gd::String& optionalAsyncCallbackName = "");
|
||||
|
||||
struct CallbackDescriptor {
|
||||
CallbackDescriptor(const gd::String functionName_,
|
||||
const gd::String argumentsList_,
|
||||
const std::set<gd::String> requiredObjects_)
|
||||
: functionName(functionName_),
|
||||
argumentsList(argumentsList_),
|
||||
requiredObjects(requiredObjects_){};
|
||||
/**
|
||||
* The name by which the function can be invoked.
|
||||
*/
|
||||
const gd::String functionName;
|
||||
/**
|
||||
* The comma separated list of arguments that the function takes.
|
||||
*/
|
||||
const gd::String argumentsList;
|
||||
/**
|
||||
* A set of all objects that need to be backed up to be passed to the callback code.
|
||||
*/
|
||||
const std::set<gd::String> requiredObjects;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Generates actions and events as a callback.
|
||||
*
|
||||
* This is used by asynchronous functions to run the code out of the normal
|
||||
* events flow.
|
||||
*
|
||||
* \returns A set with all objects required by the callback code.
|
||||
* The caller must take care of backing them up in a LongLivedObjectsList,
|
||||
* and to pass it to the callback function as the last argument.
|
||||
*/
|
||||
virtual const CallbackDescriptor GenerateCallback(
|
||||
const gd::String& callbackFunctionName,
|
||||
gd::EventsCodeGenerationContext& parentContext,
|
||||
gd::InstructionsList& actions,
|
||||
gd::EventsList* subEvents = nullptr);
|
||||
|
||||
/**
|
||||
* \brief Generates the parameters list of an event's generated function.
|
||||
*/
|
||||
const gd::String GenerateEventsParameters(
|
||||
const gd::EventsCodeGenerationContext& context);
|
||||
|
||||
/**
|
||||
* \brief Generate code for declaring objects lists.
|
||||
@@ -462,17 +506,10 @@ class GD_CORE_API EventsCodeGenerator {
|
||||
* Other standard parameters type that should be implemented by platforms:
|
||||
* - currentScene: Reference to the current runtime scene.
|
||||
* - objectList : a map containing lists of objects which are specified by the
|
||||
object name in another parameter. Example:
|
||||
* \code
|
||||
AddExpression("Count", _("Object count"), _("Count the number of picked
|
||||
objects"), _("Objects"), "res/conditions/nbObjet.png")
|
||||
.AddParameter("objectList", _("Object"))
|
||||
.SetFunctionName("getPickedObjectsCount");
|
||||
|
||||
* \endcode
|
||||
* - objectListWithoutPicking : Same as objectList but do not pick object if
|
||||
object name in another parameter.
|
||||
* - objectListOrEmptyIfJustDeclared : Same as `objectList` but do not pick object if
|
||||
they are not already picked.
|
||||
* - objectPtr : Return a reference to the object specified by the object name in
|
||||
* - objectPtr: Return a reference to the object specified by the object name in
|
||||
another parameter. Example:
|
||||
* \code
|
||||
.AddParameter("object", _("Object"))
|
||||
@@ -665,14 +702,16 @@ class GD_CORE_API EventsCodeGenerator {
|
||||
virtual gd::String GenerateFreeAction(
|
||||
const std::vector<gd::String>& arguments,
|
||||
const gd::InstructionMetadata& instrInfos,
|
||||
gd::EventsCodeGenerationContext& context);
|
||||
gd::EventsCodeGenerationContext& context,
|
||||
const gd::String& optionalAsyncCallbackName = "");
|
||||
|
||||
virtual gd::String GenerateObjectAction(
|
||||
const gd::String& objectName,
|
||||
const gd::ObjectMetadata& objInfo,
|
||||
const std::vector<gd::String>& arguments,
|
||||
const gd::InstructionMetadata& instrInfos,
|
||||
gd::EventsCodeGenerationContext& context);
|
||||
gd::EventsCodeGenerationContext& context,
|
||||
const gd::String& optionalAsyncCallbackName = "");
|
||||
|
||||
virtual gd::String GenerateBehaviorAction(
|
||||
const gd::String& objectName,
|
||||
@@ -680,7 +719,8 @@ class GD_CORE_API EventsCodeGenerator {
|
||||
const gd::BehaviorMetadata& autoInfo,
|
||||
const std::vector<gd::String>& arguments,
|
||||
const gd::InstructionMetadata& instrInfos,
|
||||
gd::EventsCodeGenerationContext& context);
|
||||
gd::EventsCodeGenerationContext& context,
|
||||
const gd::String& optionalAsyncCallbackName = "");
|
||||
|
||||
gd::String GenerateRelationalOperatorCall(
|
||||
const gd::InstructionMetadata& instrInfos,
|
||||
|
@@ -219,14 +219,20 @@ gd::String ExpressionCodeGenerator::GenerateObjectFunctionCode(
|
||||
const ObjectMetadata& objInfo = MetadataProvider::GetObjectMetadata(
|
||||
codeGenerator.GetPlatform(), objectType);
|
||||
|
||||
codeGenerator.AddIncludeFiles(objInfo.includeFiles);
|
||||
functionOutput = codeGenerator.GenerateObjectFunctionCall(
|
||||
realObjects[i],
|
||||
objInfo,
|
||||
expressionMetadata.codeExtraInformation,
|
||||
parametersCode,
|
||||
functionOutput,
|
||||
context);
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
expressionMetadata.GetRequiredBaseObjectCapability())) {
|
||||
// Do nothing, skipping objects not supporting the capability required by
|
||||
// this expression.
|
||||
} else {
|
||||
codeGenerator.AddIncludeFiles(objInfo.includeFiles);
|
||||
functionOutput = codeGenerator.GenerateObjectFunctionCall(
|
||||
realObjects[i],
|
||||
objInfo,
|
||||
expressionMetadata.codeExtraInformation,
|
||||
parametersCode,
|
||||
functionOutput,
|
||||
context);
|
||||
}
|
||||
}
|
||||
|
||||
return functionOutput;
|
||||
|
@@ -5,8 +5,11 @@
|
||||
*/
|
||||
|
||||
#include "GDCore/Events/Event.h"
|
||||
|
||||
#include "GDCore/Events/Builtin/AsyncEvent.h"
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
|
||||
#include "GDCore/Events/EventsList.h"
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
|
||||
@@ -65,10 +68,40 @@ gd::String BaseEvent::GenerateEventCode(
|
||||
return "";
|
||||
}
|
||||
|
||||
void BaseEvent::PreprocessAsyncActions(const gd::Platform& platform) {
|
||||
if (!CanHaveSubEvents()) return;
|
||||
for (const auto& actionsList : GetAllActionsVectors())
|
||||
for (std::size_t aId = 0; aId < actionsList->size(); ++aId) {
|
||||
const auto& action = actionsList->at(aId);
|
||||
const gd::InstructionMetadata& actionMetadata =
|
||||
gd::MetadataProvider::GetActionMetadata(platform, action.GetType());
|
||||
if (actionMetadata.IsAsync()) {
|
||||
gd::InstructionsList remainingActions;
|
||||
remainingActions.InsertInstructions(
|
||||
*actionsList, aId + 1, actionsList->size() - 1);
|
||||
gd::AsyncEvent asyncEvent(action, remainingActions, GetSubEvents());
|
||||
|
||||
// Ensure that the local event no longer has any of the actions/subevent
|
||||
// after the async function
|
||||
actionsList->RemoveAfter(aId);
|
||||
GetSubEvents().Clear();
|
||||
|
||||
GetSubEvents().InsertEvent(asyncEvent);
|
||||
|
||||
// We just moved all the rest, there's nothing left to do in this event.
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void BaseEvent::Preprocess(gd::EventsCodeGenerator& codeGenerator,
|
||||
gd::EventsList& eventList,
|
||||
std::size_t indexOfTheEventInThisList) {
|
||||
if (IsDisabled() || !MustBePreprocessed()) return;
|
||||
if (IsDisabled()) return;
|
||||
|
||||
PreprocessAsyncActions(codeGenerator.GetPlatform());
|
||||
|
||||
if (!MustBePreprocessed()) return;
|
||||
|
||||
try {
|
||||
if (type.empty()) return;
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Events/InstructionsList.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
@@ -23,7 +24,7 @@ class EventsCodeGenerationContext;
|
||||
class Platform;
|
||||
class SerializerElement;
|
||||
class Instruction;
|
||||
}
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -126,18 +127,25 @@ class GD_CORE_API BaseEvent {
|
||||
return noSearchableStrings;
|
||||
};
|
||||
|
||||
virtual bool ReplaceAllSearchableStrings(
|
||||
std::vector<gd::String> newSearchableString) {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Return a list of all expressions of the event, each with their associated metadata.
|
||||
* \note Used to preprocess or search in the expressions of the event.
|
||||
*/
|
||||
virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata() {
|
||||
GetAllExpressionsWithMetadata() {
|
||||
std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> > noExpr;
|
||||
return noExpr;
|
||||
};
|
||||
virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata() const {
|
||||
std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> > noExpr;
|
||||
virtual std::vector<
|
||||
std::pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata() const {
|
||||
std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
noExpr;
|
||||
return noExpr;
|
||||
};
|
||||
|
||||
@@ -201,6 +209,11 @@ class GD_CORE_API BaseEvent {
|
||||
gd::EventsList& eventList,
|
||||
std::size_t indexOfTheEventInThisList);
|
||||
|
||||
/**
|
||||
* A function that turns all async member actions into an Async subevent for code generation.
|
||||
*/
|
||||
void PreprocessAsyncActions(const gd::Platform& platform);
|
||||
|
||||
/**
|
||||
* \brief If MustBePreprocessed is redefined to return true, the
|
||||
* gd::EventMetadata::preprocessing associated to the event will be called to
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "InstructionsList.h"
|
||||
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "Serialization.h"
|
||||
@@ -31,6 +32,10 @@ void InstructionsList::InsertInstructions(const InstructionsList& list,
|
||||
}
|
||||
}
|
||||
|
||||
void InstructionsList::RemoveAfter(const size_t position) {
|
||||
elements.resize(position);
|
||||
}
|
||||
|
||||
void InstructionsList::SerializeTo(SerializerElement& element) const {
|
||||
EventsListSerialization::SerializeInstructionsTo(*this, element);
|
||||
}
|
||||
|
@@ -6,9 +6,10 @@
|
||||
|
||||
#ifndef GDCORE_INSTRUCTIONSLIST_H
|
||||
#define GDCORE_INSTRUCTIONSLIST_H
|
||||
#include "GDCore/Tools/SPtrList.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/Tools/SPtrList.h"
|
||||
|
||||
namespace gd {
|
||||
class Instruction;
|
||||
}
|
||||
@@ -22,11 +23,11 @@ class SerializerElement;
|
||||
namespace gd {
|
||||
|
||||
class InstructionsList : public SPtrList<gd::Instruction> {
|
||||
public:
|
||||
void InsertInstructions(const InstructionsList& list,
|
||||
size_t begin,
|
||||
size_t end,
|
||||
size_t position = (size_t)-1);
|
||||
public:
|
||||
void InsertInstructions(const InstructionsList &list, size_t begin,
|
||||
size_t end, size_t position = (size_t)-1);
|
||||
|
||||
void RemoveAfter(size_t position);
|
||||
|
||||
/** \name Serialization
|
||||
*/
|
||||
@@ -35,17 +36,17 @@ class InstructionsList : public SPtrList<gd::Instruction> {
|
||||
* \brief Serialize the instructions to the specified element
|
||||
* \see EventsListSerialization
|
||||
*/
|
||||
void SerializeTo(gd::SerializerElement& element) const;
|
||||
void SerializeTo(gd::SerializerElement &element) const;
|
||||
|
||||
/**
|
||||
* \brief Load the instructions from the specified element
|
||||
* \see EventsListSerialization
|
||||
*/
|
||||
void UnserializeFrom(gd::Project& project,
|
||||
const gd::SerializerElement& element);
|
||||
void UnserializeFrom(gd::Project &project,
|
||||
const gd::SerializerElement &element);
|
||||
///@}
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
} // namespace gd
|
||||
|
||||
#endif
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "ExpressionParser2Node.h"
|
||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Extensions/Metadata/ObjectMetadata.h"
|
||||
#include "GDCore/Project/Layout.h" // For GetTypeOfObject and GetTypeOfBehavior
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
@@ -484,10 +485,25 @@ class GD_CORE_API ExpressionParser2 {
|
||||
metadata,
|
||||
objectFunctionOrBehaviorName);
|
||||
function->diagnostic = std::move(parametersNode.diagnostic);
|
||||
|
||||
if (!function->diagnostic) // TODO: reverse the order of diagnostic?
|
||||
function->diagnostic = ValidateFunction(
|
||||
type, *function, objectNameLocation.GetStartPosition());
|
||||
|
||||
// If the function needs a capability on the object that may not be covered
|
||||
// by all objects, check it now.
|
||||
if (!metadata.GetRequiredBaseObjectCapability().empty()) {
|
||||
const gd::ObjectMetadata &objectMetadata =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
|
||||
if (objectMetadata.IsUnsupportedBaseObjectCapability(
|
||||
metadata.GetRequiredBaseObjectCapability())) {
|
||||
function->diagnostic = RaiseTypeError(
|
||||
_("This expression exists, but it can't be used on this object."),
|
||||
objectNameLocation.GetStartPosition());
|
||||
}
|
||||
}
|
||||
|
||||
function->location = ExpressionParserLocation(
|
||||
objectNameLocation.GetStartPosition(), GetCurrentPosition());
|
||||
function->objectNameLocation = objectNameLocation;
|
||||
|
@@ -218,8 +218,8 @@ void EventsListSerialization::UnserializeEventsFrom(
|
||||
event = std::make_shared<EmptyEvent>();
|
||||
}
|
||||
|
||||
event->SetDisabled(eventElem.GetBoolAttribute("disabled"));
|
||||
event->SetFolded(eventElem.GetBoolAttribute("folded"));
|
||||
event->SetDisabled(eventElem.GetBoolAttribute("disabled", false));
|
||||
event->SetFolded(eventElem.GetBoolAttribute("folded", false));
|
||||
|
||||
list.InsertEvent(event, list.GetEventsCount());
|
||||
}
|
||||
@@ -232,8 +232,8 @@ void EventsListSerialization::SerializeEventsTo(const EventsList& list,
|
||||
const gd::BaseEvent& event = list.GetEvent(j);
|
||||
SerializerElement& eventElem = events.AddChild("event");
|
||||
|
||||
eventElem.SetAttribute("disabled", event.IsDisabled());
|
||||
eventElem.SetAttribute("folded", event.IsFolded());
|
||||
if (event.IsDisabled()) eventElem.SetAttribute("disabled", event.IsDisabled());
|
||||
if (event.IsFolded()) eventElem.SetAttribute("folded", event.IsFolded());
|
||||
eventElem.AddChild("type").SetValue(event.GetType());
|
||||
|
||||
event.SerializeTo(eventElem);
|
||||
|
@@ -11,25 +11,16 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinAdvanced",
|
||||
_("Advanced control features"),
|
||||
_("Advanced control features to be used in events."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
|
||||
extension
|
||||
.AddCondition("Toujours",
|
||||
_("Always"),
|
||||
_("This condition always returns true (or always false, if "
|
||||
"the condition is inverted)."),
|
||||
_("Always"),
|
||||
_("Other"),
|
||||
"res/conditions/toujours24.png",
|
||||
"res/conditions/toujours.png")
|
||||
.SetHelpPath("/all-features/advanced-conditions")
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsAdvanced();
|
||||
.SetExtensionInformation(
|
||||
"BuiltinAdvanced",
|
||||
_("Event functions"),
|
||||
_("Advanced control features for functions made with events."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("Advanced");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Event functions"))
|
||||
.SetIcon("res/function32.png");
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
@@ -38,9 +29,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Set the return value of the events function to the specified "
|
||||
"number (to be used with \"Expression\" functions)."),
|
||||
_("Set return value to number _PARAM0_"),
|
||||
_("Functions"),
|
||||
"res/function24.png",
|
||||
"res/function16.png")
|
||||
"",
|
||||
"res/function32.png",
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("expression", "The number to be returned")
|
||||
.MarkAsAdvanced();
|
||||
@@ -52,9 +43,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Set the return value of the events function to the specified text "
|
||||
"(to be used with \"String Expression\" functions)."),
|
||||
_("Set return value to text _PARAM0_"),
|
||||
_("Functions"),
|
||||
"res/function24.png",
|
||||
"res/function16.png")
|
||||
"",
|
||||
"res/function32.png",
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("string", "The text to be returned")
|
||||
.MarkAsAdvanced();
|
||||
@@ -65,9 +56,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Set the return value of the Condition events function to "
|
||||
"either true (condition will pass) or false."),
|
||||
_("Set return value of the condition to _PARAM0_"),
|
||||
_("Functions"),
|
||||
"res/function24.png",
|
||||
"res/function16.png")
|
||||
"",
|
||||
"res/function32.png",
|
||||
"res/function32.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("trueorfalse", "Should the condition be true or false?")
|
||||
.MarkAsAdvanced();
|
||||
@@ -80,9 +71,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"a string, an empty string is considered as \"false\". "
|
||||
"If it's a number, 0 is considered as \"false\"."),
|
||||
_("Parameter _PARAM0_ is true"),
|
||||
_("Functions"),
|
||||
"res/function24.png",
|
||||
"res/function16.png")
|
||||
"",
|
||||
"res/function32.png",
|
||||
"res/function32.png")
|
||||
.AddParameter("functionParameterName", "Parameter name")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
@@ -91,7 +82,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"GetArgumentAsNumber",
|
||||
_("Get function parameter value"),
|
||||
_("Get function parameter (also called \"argument\") value"),
|
||||
_("Functions"),
|
||||
"",
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name");
|
||||
|
||||
@@ -100,7 +91,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
"GetArgumentAsString",
|
||||
_("Get function parameter text"),
|
||||
_("Get function parameter (also called \"argument\") text "),
|
||||
_("Functions"),
|
||||
"",
|
||||
"res/function16.png")
|
||||
.AddParameter("functionParameterName", "Parameter name");
|
||||
}
|
||||
|
@@ -15,8 +15,6 @@ namespace gd {
|
||||
* so that it provides standards events, objects or instructions of an
|
||||
* extension.
|
||||
*
|
||||
* TOOD: Usage example.
|
||||
*
|
||||
* \ingroup BuiltinExtensions
|
||||
*/
|
||||
class GD_CORE_API BuiltinExtensionsImplementer {
|
||||
@@ -44,6 +42,7 @@ class GD_CORE_API BuiltinExtensionsImplementer {
|
||||
static void ImplementsTimeExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsVariablesExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsWindowExtension(gd::PlatformExtension& extension);
|
||||
static void ImplementsAsyncExtension(gd::PlatformExtension& extension);
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
32
Core/GDCore/Extensions/Builtin/AsyncExtension.cpp
Normal file
32
Core/GDCore/Extensions/Builtin/AsyncExtension.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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/Events/Builtin/AsyncEvent.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
using namespace std;
|
||||
namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAsyncExtension(
|
||||
gd::PlatformExtension &extension) {
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinAsync",
|
||||
_("Async functions"),
|
||||
_("Functions that defer the execution of the events after it."),
|
||||
"Arthur Pacaud (arthuro555)",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("Advanced");
|
||||
|
||||
extension.AddEvent("Async",
|
||||
_("Async event"),
|
||||
_("Internal event for asynchronous actions"),
|
||||
"",
|
||||
"res/eventaddicon.png",
|
||||
std::make_shared<gd::AsyncEvent>());
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -14,12 +14,15 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinAudio",
|
||||
_("Audio"),
|
||||
_("Sounds and musics"),
|
||||
_("GDevelop provides several conditions and actions to play audio "
|
||||
"files. They can be either long musics or short sound effects."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/audio");
|
||||
.SetExtensionHelpPath("/all-features/audio")
|
||||
.SetCategory("Audio");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Sounds and musics"))
|
||||
.SetIcon("res/actions/music24.png");
|
||||
|
||||
extension
|
||||
.AddAction("PlaySoundCanal",
|
||||
@@ -28,7 +31,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
"you'll be able to manipulate it."),
|
||||
_("Play the sound _PARAM1_ on the channel _PARAM2_, vol.: "
|
||||
"_PARAM4_, loop: _PARAM3_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -49,7 +52,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Stop the sound of a channel"),
|
||||
_("Stop the sound on the specified channel."),
|
||||
_("Stop the sound of channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -61,7 +64,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Pause the sound of a channel"),
|
||||
_("Pause the sound played on the specified channel."),
|
||||
_("Pause the sound of channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -73,7 +76,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Play the sound of a channel"),
|
||||
_("Play the sound of the channel."),
|
||||
_("Play the sound of channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -87,7 +90,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
"able to interact with it later."),
|
||||
_("Play the music _PARAM1_ on channel _PARAM2_, vol.: "
|
||||
"_PARAM4_, loop: _PARAM3_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -108,7 +111,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Stop the music on a channel"),
|
||||
_("Stop the music on the specified channel"),
|
||||
_("Stop the music of channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -120,7 +123,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Pause the music of a channel"),
|
||||
_("Pause the music on the specified channel."),
|
||||
_("Pause the music of channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -132,7 +135,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Play the music of a channel"),
|
||||
_("Play the music of the channel."),
|
||||
_("Play the music of channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -145,7 +148,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("This action modifies the volume of the sound on the "
|
||||
"specified channel. The volume is between 0 and 100."),
|
||||
_("the volume of the sound on channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/actions/sonVolume24.png",
|
||||
"res/actions/sonVolume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -159,7 +162,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("This action modifies the volume of the music on the "
|
||||
"specified channel. The volume is between 0 and 100."),
|
||||
_("the volume of the music on channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/actions/musicVolume24.png",
|
||||
"res/actions/musicVolume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -173,7 +176,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("This action modifies the global volume of the game. The "
|
||||
"volume is between 0 and 100."),
|
||||
_("the global sound level"),
|
||||
_("Audio"),
|
||||
"",
|
||||
"res/actions/volume24.png",
|
||||
"res/actions/volume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -186,7 +189,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("This action modifies the pitch (speed) of the sound on a "
|
||||
"channel.\n1 is the default pitch."),
|
||||
_("the pitch of the sound on channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -200,7 +203,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("This action modifies the pitch of the music on the "
|
||||
"specified channel. 1 is the default pitch"),
|
||||
_("the pitch of the music on channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -214,7 +217,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("This action modifies the playing offset of the sound on a "
|
||||
"channel"),
|
||||
_("the playing offset of the sound on channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -228,7 +231,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("This action modifies the playing offset of the music on "
|
||||
"the specified channel"),
|
||||
_("the playing offset of the music on channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -241,7 +244,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Play a sound"),
|
||||
_("Play a sound."),
|
||||
_("Play the sound _PARAM1_, vol.: _PARAM3_, loop: _PARAM2_"),
|
||||
_("Audio"),
|
||||
"",
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -261,7 +264,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Play a music file"),
|
||||
_("Play a music file."),
|
||||
_("Play the music _PARAM1_, vol.: _PARAM3_, loop: _PARAM2_"),
|
||||
_("Audio"),
|
||||
"",
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -281,7 +284,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Preload a music file"),
|
||||
_("Preload a music file in memory."),
|
||||
_("Preload the music file _PARAM1_"),
|
||||
_("Audio/Loading"),
|
||||
_("Loading"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -293,7 +296,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Preload a sound file"),
|
||||
_("Preload a sound file in memory."),
|
||||
_("Preload the sound file _PARAM1_"),
|
||||
_("Audio/Loading"),
|
||||
_("Loading"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -301,55 +304,80 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
.MarkAsComplex();
|
||||
|
||||
extension
|
||||
.AddAction("UnloadMusic",
|
||||
_("Unload a music file"),
|
||||
_(
|
||||
"Unload a music file from memory. "
|
||||
"Unloading a music file will cause any music playing it to stop."
|
||||
),
|
||||
_("Unload the music file _PARAM1_"),
|
||||
_("Audio/Loading"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddAction(
|
||||
"UnloadMusic",
|
||||
_("Unload a music file"),
|
||||
_("Unload a music file from memory. "
|
||||
"Unloading a music file will cause any music playing it to stop."),
|
||||
_("Unload the music file _PARAM1_"),
|
||||
_("Loading"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("musicfile", _("Audio file (or audio resource name)"))
|
||||
.MarkAsComplex();
|
||||
|
||||
extension
|
||||
.AddAction("UnloadSound",
|
||||
_("Unload a sound file"),
|
||||
_(
|
||||
"Unload a sound file from memory. "
|
||||
"Unloading a sound file will cause any sounds playing it to stop."
|
||||
),
|
||||
_("Unload the sound file _PARAM1_"),
|
||||
_("Audio/Loading"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddAction(
|
||||
"UnloadSound",
|
||||
_("Unload a sound file"),
|
||||
_("Unload a sound file from memory. "
|
||||
"Unloading a sound file will cause any sounds playing it to stop."),
|
||||
_("Unload the sound file _PARAM1_"),
|
||||
_("Loading"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("soundfile", _("Sound file (or sound resource name)"))
|
||||
.MarkAsComplex();
|
||||
|
||||
extension
|
||||
.AddAction("UnloadAllAudio",
|
||||
_("Unload all audio"),
|
||||
_(
|
||||
"Unload all the audio in memory. "
|
||||
"This will cause every sound and music of the game to stop."
|
||||
),
|
||||
_("Unload all audio files"),
|
||||
_("Audio/Loading"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddAction(
|
||||
"UnloadAllAudio",
|
||||
_("Unload all audio"),
|
||||
_("Unload all the audio in memory. "
|
||||
"This will cause every sound and music of the game to stop."),
|
||||
_("Unload all audio files"),
|
||||
_("Loading"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsComplex();
|
||||
extension
|
||||
.AddAction(
|
||||
"FadeSoundVolume",
|
||||
_("Fade the volume of a sound played on a channel."),
|
||||
_("Fade the volume of a sound played on a channel to the specified volume within the specified duration."),
|
||||
_("Fade the sound on channel _PARAM1_ to volume _PARAM2_ within _PARAM3_ seconds"),
|
||||
_("Sounds on channels"),
|
||||
"res/actions/son24.png",
|
||||
"res/actions/son.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression", _("Channel identifier"))
|
||||
.AddParameter("expression", _("Final volume (0-100)"))
|
||||
.AddParameter("expression", _("Fading time in seconds"))
|
||||
.MarkAsAdvanced();
|
||||
extension
|
||||
.AddAction(
|
||||
"FadeMusicVolume",
|
||||
_("Fade the volume of a music played on a channel."),
|
||||
_("Fade the volume of a music played on a channel to the specified volume within the specified duration."),
|
||||
_("Fade the music on channel _PARAM1_ to volume _PARAM2_ within _PARAM3_ seconds"),
|
||||
_("Music on channels"),
|
||||
"res/actions/music24.png",
|
||||
"res/actions/music.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression", _("Channel identifier"))
|
||||
.AddParameter("expression", _("Final volume (0-100)"))
|
||||
.AddParameter("expression", _("Fading time in seconds"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddCondition("MusicPlaying",
|
||||
_("A music file is being played"),
|
||||
_("Test if the music on a channel is being played"),
|
||||
_("Music on channel _PARAM1_ is being played"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/conditions/musicplaying24.png",
|
||||
"res/conditions/musicplaying.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -361,7 +389,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("A music file is paused"),
|
||||
_("Test if the music on the specified channel is paused."),
|
||||
_("Music on channel _PARAM1_ is paused"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/conditions/musicpaused24.png",
|
||||
"res/conditions/musicpaused.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -373,7 +401,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("A music file is stopped"),
|
||||
_("Test if the music on the specified channel is stopped."),
|
||||
_("Music on channel _PARAM1_ is stopped"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/conditions/musicstopped24.png",
|
||||
"res/conditions/musicstopped.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -385,7 +413,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("A sound is being played"),
|
||||
_("Test if the sound on a channel is being played."),
|
||||
_("Sound on channel _PARAM1_ is being played"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/conditions/sonplaying24.png",
|
||||
"res/conditions/sonplaying.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -397,7 +425,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("A sound is paused"),
|
||||
_("Test if the sound on the specified channel is paused."),
|
||||
_("Sound on channel _PARAM1_ is paused"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/conditions/sonpaused24.png",
|
||||
"res/conditions/sonpaused.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -409,7 +437,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("A sound is stopped"),
|
||||
_("Test if the sound on the specified channel is stopped."),
|
||||
_("Sound on channel _PARAM1_ is stopped"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/conditions/sonstopped24.png",
|
||||
"res/conditions/sonstopped.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -423,7 +451,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Test the volume of the sound on the specified channel. The volume "
|
||||
"is between 0 and 100."),
|
||||
_("the volume of the sound on channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/conditions/sonVolume24.png",
|
||||
"res/conditions/sonVolume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -438,7 +466,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Test the volume of the music on a specified channel. The volume "
|
||||
"is between 0 and 100."),
|
||||
_("the volume of the music on channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/conditions/musicVolume24.png",
|
||||
"res/conditions/musicVolume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -452,7 +480,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Global volume"),
|
||||
_("Test the global sound level. The volume is between 0 and 100."),
|
||||
_("the global game volume"),
|
||||
_("Audio"),
|
||||
"",
|
||||
"res/conditions/volume24.png",
|
||||
"res/conditions/volume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -465,7 +493,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Test the pitch of the sound on the specified channel. 1 is the "
|
||||
"default pitch."),
|
||||
_("the pitch of the sound on channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/conditions/sonVolume24.png",
|
||||
"res/conditions/sonVolume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -480,7 +508,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Test the pitch (speed) of the music on a specified channel. 1 is "
|
||||
"the default pitch."),
|
||||
_("the pitch of the music on channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/conditions/musicVolume24.png",
|
||||
"res/conditions/musicVolume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -494,7 +522,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Playing offset of the sound on a channel"),
|
||||
_("Test the playing offset of the sound on the specified channel."),
|
||||
_("the playing offset of the sound on channel _PARAM1_"),
|
||||
_("Audio/Sounds on channels"),
|
||||
_("Sounds on channels"),
|
||||
"res/conditions/sonVolume24.png",
|
||||
"res/conditions/sonVolume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -508,7 +536,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Playing offset of the music on a channel"),
|
||||
_("Test the playing offset of the music on the specified channel."),
|
||||
_("the playing offset of the music on channel _PARAM1_"),
|
||||
_("Audio/Music on channels"),
|
||||
_("Music on channels"),
|
||||
"res/conditions/musicVolume24.png",
|
||||
"res/conditions/musicVolume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -577,7 +605,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
|
||||
_("Sound level"),
|
||||
"res/conditions/volume.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -16,11 +16,17 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinObject",
|
||||
_("Features for all objects"),
|
||||
_("Objects"),
|
||||
_("Common features that can be used for all objects in GDevelop."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/base_object/events");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Collision"))
|
||||
.SetIcon("res/conditions/collision24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Objects"))
|
||||
.SetIcon("res/actions/create24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Movement using forces"))
|
||||
.SetIcon("res/actions/force24.png");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<gd::Object>(
|
||||
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
||||
@@ -1172,7 +1178,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("yesorno", _("Enable?"))
|
||||
.MarkAsSimple();
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
|
||||
obj.AddAction("SetEffectDoubleParameter",
|
||||
_("Effect parameter (number)"),
|
||||
@@ -1187,7 +1194,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("expression", _("New value"))
|
||||
.MarkAsSimple();
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
|
||||
obj.AddAction("SetEffectStringParameter",
|
||||
_("Effect parameter (string)"),
|
||||
@@ -1203,7 +1211,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("string", _("New value"))
|
||||
.MarkAsSimple();
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
|
||||
obj.AddAction("SetEffectBooleanParameter",
|
||||
_("Effect parameter (enable or disable)"),
|
||||
@@ -1218,7 +1227,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("yesorno", _("Enable?"))
|
||||
.MarkAsSimple();
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
|
||||
obj.AddCondition("IsEffectEnabled",
|
||||
_("Effect is enabled"),
|
||||
@@ -1229,7 +1239,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/actions/effect.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.MarkAsSimple();
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
|
||||
extension
|
||||
.AddAction("Create",
|
||||
@@ -1237,11 +1248,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
_("Create an object at specified position"),
|
||||
_("Create object _PARAM1_ at position _PARAM2_;_PARAM3_ "
|
||||
"(layer: _PARAM4_)"),
|
||||
_("Objects"),
|
||||
"",
|
||||
"res/actions/create24.png",
|
||||
"res/actions/create.png")
|
||||
"res/actions/create24.png")
|
||||
.AddCodeOnlyParameter("objectsContext", "")
|
||||
.AddParameter("objectListWithoutPicking", _("Object to create"))
|
||||
.AddParameter("objectListOrEmptyIfJustDeclared", _("Object to create"))
|
||||
.AddParameter("expression", _("X position"))
|
||||
.AddParameter("expression", _("Y position"))
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
@@ -1255,11 +1266,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"create the object with the specified name."),
|
||||
_("Among objects _PARAM1_, create object named _PARAM2_ at "
|
||||
"position _PARAM3_;_PARAM4_ (layer: _PARAM5_)"),
|
||||
_("Objects"),
|
||||
"",
|
||||
"res/actions/create24.png",
|
||||
"res/actions/create.png")
|
||||
"res/actions/create24.png")
|
||||
.AddCodeOnlyParameter("objectsContext", "")
|
||||
.AddParameter("objectListWithoutPicking", _("Group of potential objects"))
|
||||
.AddParameter("objectListOrEmptyIfJustDeclared", _("Group of potential objects"))
|
||||
.SetParameterLongDescription(
|
||||
_("Group containing objects that can be created by the action."))
|
||||
.AddParameter("string", _("Name of the object to create"))
|
||||
@@ -1407,7 +1418,33 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/conditions/nbObjet.png")
|
||||
.AddParameter("objectList", _("Object"))
|
||||
.UseStandardRelationalOperatorParameters("number")
|
||||
.MarkAsSimple();
|
||||
.MarkAsSimple()
|
||||
.SetHidden();
|
||||
|
||||
extension.AddExpressionAndCondition(
|
||||
"number",
|
||||
"SceneInstancesCount",
|
||||
_("Number of object instances on the scene"),
|
||||
_("the number of instances of the specified objects living on the scene"),
|
||||
_("the number of _PARAM1_ living on the scene"),
|
||||
_("Objects"),
|
||||
"res/conditions/nbObjet24.png")
|
||||
.AddCodeOnlyParameter("objectsContext", "")
|
||||
.AddParameter("objectListOrEmptyWithoutPicking", _("Object"))
|
||||
.UseStandardParameters("number")
|
||||
.MarkAsSimple();
|
||||
|
||||
extension.AddExpressionAndCondition(
|
||||
"number",
|
||||
"PickedInstancesCount",
|
||||
_("Number of object instances currently picked"),
|
||||
_("the number of instances picked by the previous conditions (or actions)"),
|
||||
_("the number of _PARAM0_ currently picked"),
|
||||
_("Objects"),
|
||||
"res/conditions/nbObjet24.png")
|
||||
.AddParameter("objectListOrEmptyWithoutPicking", _("Object"))
|
||||
.UseStandardParameters("number")
|
||||
.MarkAsSimple();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -1458,7 +1495,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
_("Cast a ray from _PARAM1_;_PARAM2_, angle: _PARAM3_ and max "
|
||||
"distance: _PARAM4_px, against _PARAM0_, and save the "
|
||||
"result in _PARAM5_, _PARAM6_"),
|
||||
_("Collision"),
|
||||
"",
|
||||
"res/conditions/raycast24.png",
|
||||
"res/conditions/raycast.png")
|
||||
.AddParameter("objectList", _("Objects to test against the ray"))
|
||||
@@ -1489,7 +1526,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
_("Cast a ray from from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ "
|
||||
"against _PARAM0_, and save the "
|
||||
"result in _PARAM5_, _PARAM6_"),
|
||||
_("Collision"),
|
||||
"",
|
||||
"res/conditions/raycast24.png",
|
||||
"res/conditions/raycast.png")
|
||||
.AddParameter("objectList", _("Objects to test against the ray"))
|
||||
@@ -1513,21 +1550,22 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
_("Number of objects"),
|
||||
_("Count the number of the specified objects being "
|
||||
"currently picked in the event"),
|
||||
_("Objects"),
|
||||
"",
|
||||
"res/conditions/nbObjet.png")
|
||||
.AddParameter("objectList", _("Object"));
|
||||
.AddParameter("objectList", _("Object"))
|
||||
.SetHidden(); // Deprecated
|
||||
|
||||
obj.AddStrExpression("ObjectName",
|
||||
_("Object name"),
|
||||
_("Return the name of the object"),
|
||||
_("Objects"),
|
||||
"",
|
||||
"res/conditions/text.png")
|
||||
.AddParameter("object", _("Object"));
|
||||
|
||||
obj.AddStrExpression("Layer",
|
||||
_("Object layer"),
|
||||
_("Return the name of the layer the object is on"),
|
||||
_("Objects"),
|
||||
"",
|
||||
"res/actions/layer.png")
|
||||
.AddParameter("object", _("Object"));
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinCamera",
|
||||
_("Cameras and layers features"),
|
||||
_("Layers and cameras"),
|
||||
"Each scene can be composed of multiple layers. These conditions "
|
||||
"and actions allow to manipulate them during the game. In "
|
||||
"particular, you can move the camera of a layer to center it on an "
|
||||
@@ -23,6 +23,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/interface/scene-editor/layers-and-cameras");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Layers and cameras"))
|
||||
.SetIcon("res/conditions/camera24.png");
|
||||
|
||||
extension
|
||||
.AddExpressionAndConditionAndAction(
|
||||
@@ -31,7 +33,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Camera center X position"),
|
||||
_("the X position of the center of a camera"),
|
||||
_("the X position of camera _PARAM4_ (layer: _PARAM3_)"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/conditions/camera24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.UseStandardParameters("number")
|
||||
@@ -53,7 +55,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Camera center Y position"),
|
||||
_("the Y position of the center of a camera"),
|
||||
_("the Y position of camera _PARAM4_ (layer: _PARAM3_)"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/conditions/camera24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.UseStandardParameters("number")
|
||||
@@ -75,7 +77,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Width of a camera"),
|
||||
_("the width of a camera of a layer"),
|
||||
_("the width of camera _PARAM2_ of layer _PARAM1_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/conditions/camera24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"))
|
||||
@@ -91,7 +93,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Height of a camera"),
|
||||
_("the height of a camera of a layer"),
|
||||
_("the height of camera _PARAM2_ of layer _PARAM1_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/conditions/camera24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"))
|
||||
@@ -107,7 +109,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Angle of a camera of a layer"),
|
||||
_("the angle of rotation of a camera"),
|
||||
_("the angle of camera (layer: _PARAM3_, camera: _PARAM4_)"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/conditions/camera24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.UseStandardParameters("number")
|
||||
@@ -127,7 +129,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Add a camera to a layer"),
|
||||
_("This action adds a camera to a layer"),
|
||||
_("Add a camera to layer _PARAM1_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera24.png",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -162,7 +164,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Delete a camera of a layer"),
|
||||
_("Remove the specified camera from a layer"),
|
||||
_("Delete camera _PARAM2_ from layer _PARAM1_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera24.png",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -178,7 +180,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"layer. The zoom will be reset."),
|
||||
_("Change the size of camera _PARAM2_ of _PARAM1_ to "
|
||||
"_PARAM3_*_PARAM4_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera24.png",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -196,7 +198,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"specified layer."),
|
||||
_("Set the render zone of camera _PARAM2_ from layer _PARAM1_ "
|
||||
"to _PARAM3_;_PARAM4_ _PARAM5_;_PARAM6_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera24.png",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -223,7 +225,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Change camera zoom."),
|
||||
_("Change camera zoom to _PARAM1_ (layer: _PARAM2_, camera: "
|
||||
"_PARAM3_)"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera24.png",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -234,6 +236,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
|
||||
.SetDefaultValue("0");
|
||||
|
||||
// TODO Deprecated: hide this action in a future release.
|
||||
extension
|
||||
.AddAction(
|
||||
"FixCamera",
|
||||
@@ -242,7 +245,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"specified limits."),
|
||||
_("Center the camera on _PARAM1_ (limit : from _PARAM2_;_PARAM3_ to "
|
||||
"_PARAM4_;_PARAM5_) (layer: _PARAM7_, camera: _PARAM8_)"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera24.png",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -266,13 +269,38 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
.SetDefaultValue("0")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"ClampCamera",
|
||||
_("Enforce camera boundaries"),
|
||||
_("Enforce camera boundaries by moving the camera back inside specified boundaries."),
|
||||
_("Enforce camera boundaries (left: _PARAM1_, top: _PARAM2_ "
|
||||
"right: _PARAM3_, bottom: _PARAM4_, layer: _PARAM5_)"),
|
||||
"",
|
||||
"res/actions/camera24.png",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression",
|
||||
_("Left bound X Position"))
|
||||
.AddParameter("expression",
|
||||
_("Top bound Y Position"))
|
||||
.AddParameter("expression",
|
||||
_("Right bound X Position"))
|
||||
.AddParameter("expression",
|
||||
_("Bottom bound Y Position"))
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
|
||||
.SetDefaultValue("0")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"CentreCamera",
|
||||
_("Center the camera on an object"),
|
||||
_("Center the camera on the specified object."),
|
||||
_("Center camera on _PARAM1_ (layer: _PARAM3_, camera: _PARAM4_)"),
|
||||
_("Layers and cameras"),
|
||||
_("Center camera on _PARAM1_ (layer: _PARAM3_)"),
|
||||
"",
|
||||
"res/actions/camera24.png",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -293,7 +321,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Show a layer"),
|
||||
_("Show a layer."),
|
||||
_("Show layer _PARAM1_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/layer24.png",
|
||||
"res/actions/layer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -306,7 +334,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Hide a layer"),
|
||||
_("Hide a layer."),
|
||||
_("Hide layer _PARAM1_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/layer24.png",
|
||||
"res/actions/layer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -319,7 +347,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Visibility of a layer"),
|
||||
_("Test if a layer is set as visible."),
|
||||
_("Layer _PARAM1_ is visible"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/conditions/layer24.png",
|
||||
"res/conditions/layer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -335,7 +363,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("You can find the parameter names (and change the effect "
|
||||
"names) in the effects window."),
|
||||
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of layer _PARAM1_"),
|
||||
_("Layers and cameras/Effects"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -354,7 +382,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("You can find the parameter names (and change the effect "
|
||||
"names) in the effects window."),
|
||||
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of layer _PARAM1_"),
|
||||
_("Layers and cameras/Effects"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -373,7 +401,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("You can find the parameter names (and change the effect "
|
||||
"names) in the effects window."),
|
||||
_("Enable _PARAM3_ for effect _PARAM2_ of layer _PARAM1_: _PARAM4_"),
|
||||
_("Layers and cameras/Effects"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -389,7 +417,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Layer effect is enabled"),
|
||||
_("The effect on a layer is enabled"),
|
||||
_("Effect _PARAM2_ on layer _PARAM1_ is enabled"),
|
||||
_("Layers and cameras/Effects"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -403,7 +431,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Enable layer effect"),
|
||||
_("Enable an effect on a layer"),
|
||||
_("Enable effect _PARAM2_ on layer _PARAM1_: _PARAM3_"),
|
||||
_("Layers and cameras/Effects"),
|
||||
_("Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -419,7 +447,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Layer time scale"),
|
||||
_("Compare the time scale applied to the objects of the layer."),
|
||||
_("the time scale of layer _PARAM1_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/conditions/time24.png",
|
||||
"res/conditions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -434,7 +462,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Change layer time scale"),
|
||||
_("Change the time scale applied to the objects of the layer."),
|
||||
_("Set the time scale of layer _PARAM1_ to _PARAM2_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/time24.png",
|
||||
"res/actions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -449,7 +477,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Compare the default Z order set to objects when they "
|
||||
"are created on a layer."),
|
||||
_("the default Z order of objects created on _PARAM1_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/conditions/layer24.png",
|
||||
"res/conditions/layer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -465,7 +493,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"created on a layer."),
|
||||
_("Set the default Z order of objects created on _PARAM1_ to "
|
||||
"_PARAM2_"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/layer24.png",
|
||||
"res/actions/layer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -480,7 +508,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
_("Set the ambient light color of the lighting layer in format "
|
||||
"\"R;G;B\" string."),
|
||||
_("Set the ambient color of the lighting layer _PARAM1_ to _PARAM2_"),
|
||||
_("Layers and cameras/Lighting"),
|
||||
_("Lighting"),
|
||||
"res/actions/color24.png",
|
||||
"res/actions/color.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -494,7 +522,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"CameraViewportLeft",
|
||||
_("X position of the top left side point of a render zone"),
|
||||
_("X position of the top left side point of a render zone"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer"))
|
||||
@@ -506,7 +534,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"CameraViewportTop",
|
||||
_("Y position of the top left side point of a render zone"),
|
||||
_("Y position of the top left side point of a render zone"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer"))
|
||||
@@ -518,7 +546,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"CameraViewportRight",
|
||||
_("X position of the bottom right side point of a render zone"),
|
||||
_("X position of the bottom right side point of a render zone"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer"))
|
||||
@@ -530,7 +558,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
"CameraViewportBottom",
|
||||
_("Y position of the bottom right side point of a render zone"),
|
||||
_("Y position of the bottom right side point of a render zone"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer"))
|
||||
@@ -541,7 +569,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
.AddExpression("CameraZoom",
|
||||
_("Zoom of a camera of a layer"),
|
||||
_("Zoom of a camera of a layer"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer"), "", true)
|
||||
@@ -553,7 +581,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
.AddExpression("LayerTimeScale",
|
||||
_("Layer time scale"),
|
||||
_("Returns the time scale of the specified layer."),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer"));
|
||||
@@ -562,7 +590,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
.AddExpression("LayerDefaultZOrder",
|
||||
_("Default Z Order for a layer"),
|
||||
_("Default Z Order for a layer"),
|
||||
_("Layers and cameras"),
|
||||
"",
|
||||
"res/actions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer"));
|
||||
|
@@ -15,18 +15,19 @@ BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinCommonConversions",
|
||||
_("Standard Conversions"),
|
||||
_("Conversion"),
|
||||
"Expressions to convert number, texts and quantities.",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/common-conversions");
|
||||
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Conversion"))
|
||||
.SetIcon("res/conditions/toujours24.png");
|
||||
|
||||
extension
|
||||
.AddExpression("ToNumber",
|
||||
_("Text > Number"),
|
||||
_("Convert the text to a number"),
|
||||
_("Conversion"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("string", _("Text to convert to a number"));
|
||||
|
||||
@@ -34,7 +35,7 @@ BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
|
||||
.AddStrExpression("ToString",
|
||||
_("Number > Text"),
|
||||
_("Convert the result of the expression to text"),
|
||||
_("Conversion"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("expression", _("Expression to be converted to text"));
|
||||
|
||||
@@ -43,7 +44,7 @@ BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
|
||||
_("Number > Text ( without scientific notation )"),
|
||||
_("Convert the result of the expression to text, "
|
||||
"without using the scientific notation"),
|
||||
_("Conversion"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("expression", _("Expression to be converted to text"));
|
||||
|
||||
@@ -52,7 +53,7 @@ BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
|
||||
"ToRad",
|
||||
_("Degrees > Radians"),
|
||||
_("Converts the angle, expressed in degrees, into radians"),
|
||||
_("Conversion"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("expression", _("Angle, in degrees"));
|
||||
|
||||
@@ -61,9 +62,76 @@ BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
|
||||
"ToDeg",
|
||||
_("Radians > Degrees"),
|
||||
_("Converts the angle, expressed in radians, into degrees"),
|
||||
_("Conversion"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("expression", _("Angle, in radians"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("ToJSON",
|
||||
_("Convert scene variable to JSON"),
|
||||
_("Convert a scene variable to JSON"),
|
||||
_("JSON"),
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("scenevar", _("Scene variable to be stringified"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("GlobalVarToJSON",
|
||||
_("Convert global variable to JSON"),
|
||||
_("Convert a global variable to JSON"),
|
||||
_("JSON"),
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("globalvar", _("The global variable to be stringified"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("ObjectVarToJSON",
|
||||
_("Convert object variable to JSON"),
|
||||
_("Convert an object variable to JSON"),
|
||||
_("JSON"),
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("objectPtr", _("The object with the variable"))
|
||||
.AddParameter("objectvar", _("The object variable to be stringified"));
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"JSONToVariableStructure",
|
||||
_("Convert JSON to a scene variable"),
|
||||
_("Parse a JSON object and store it into a scene variable"),
|
||||
_("Parse JSON string _PARAM0_ and store it into variable _PARAM1_"),
|
||||
"",
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("JSON string"))
|
||||
.AddParameter("scenevar", _("Variable where store the JSON object"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("JSONToGlobalVariableStructure",
|
||||
_("Convert JSON to global variable"),
|
||||
_("Parse a JSON object and store it into a global variable"),
|
||||
_("Parse JSON string _PARAM0_ and store it into global "
|
||||
"variable _PARAM1_"),
|
||||
"",
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("JSON string"))
|
||||
.AddParameter("globalvar",
|
||||
_("Global variable where store the JSON object"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("JSONToObjectVariableStructure",
|
||||
_("Convert JSON to object variable"),
|
||||
_("Parse a JSON object and store it into an object variable"),
|
||||
_("Parse JSON string _PARAM0_ and store it into variable "
|
||||
"_PARAM2_ of _PARAM1_"),
|
||||
"",
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("JSON string"))
|
||||
.AddParameter("objectPtr", _("Object"))
|
||||
.AddParameter("objectvar",
|
||||
_("Object variable where store the JSON object"))
|
||||
.MarkAsAdvanced();
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -4,7 +4,6 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "AllBuiltinExtensions.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/Events/Builtin/CommentEvent.h"
|
||||
#include "GDCore/Events/Builtin/ForEachChildVariableEvent.h"
|
||||
#include "GDCore/Events/Builtin/ForEachEvent.h"
|
||||
@@ -14,6 +13,7 @@
|
||||
#include "GDCore/Events/Builtin/StandardEvent.h"
|
||||
#include "GDCore/Events/Builtin/WhileEvent.h"
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
using namespace std;
|
||||
namespace gd {
|
||||
@@ -24,19 +24,43 @@ BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinCommonInstructions",
|
||||
_("Builtin events"),
|
||||
_("Events and control flow"),
|
||||
"GDevelop comes with a set of events and conditions that allow to "
|
||||
"express the game logic and rules.",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetCategory("Advanced")
|
||||
.SetExtensionHelpPath("/all-features/advanced-conditions");
|
||||
extension
|
||||
.AddInstructionOrExpressionGroupMetadata(_("Events and control flow"))
|
||||
.SetIcon("res/conditions/toujours24.png");
|
||||
|
||||
extension
|
||||
.AddCondition("Always",
|
||||
_("Always"),
|
||||
_("This condition always returns true (or always false, if "
|
||||
"the condition is inverted)."),
|
||||
_("Always"),
|
||||
"",
|
||||
"res/conditions/toujours24.png",
|
||||
"res/conditions/toujours.png")
|
||||
.SetHelpPath("/all-features/advanced-conditions")
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Compatibility with GD <= 5.0.127
|
||||
extension
|
||||
.AddDuplicatedCondition(
|
||||
"Toujours", "BuiltinCommonInstructions::Always", {.unscoped = true})
|
||||
.SetHidden();
|
||||
// end of compatibility code
|
||||
|
||||
extension
|
||||
.AddCondition("Or",
|
||||
_("Or"),
|
||||
_("Check if one of the sub conditions is true"),
|
||||
_("If one of these conditions is true:"),
|
||||
_("Advanced"),
|
||||
"",
|
||||
"res/conditions/or24.png",
|
||||
"res/conditions/or.png")
|
||||
.SetCanHaveSubInstructions()
|
||||
@@ -47,7 +71,7 @@ BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
|
||||
_("And"),
|
||||
_("Check if all sub conditions are true"),
|
||||
_("If all of these conditions are true:"),
|
||||
_("Advanced"),
|
||||
"",
|
||||
"res/conditions/and24.png",
|
||||
"res/conditions/and.png")
|
||||
.SetCanHaveSubInstructions()
|
||||
@@ -59,7 +83,7 @@ BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
|
||||
_("Not"),
|
||||
_("Return the contrary of the result of the sub conditions"),
|
||||
_("Invert the logical result of these conditions:"),
|
||||
_("Advanced"),
|
||||
"",
|
||||
"res/conditions/not24.png",
|
||||
"res/conditions/not.png")
|
||||
.SetCanHaveSubInstructions()
|
||||
@@ -70,10 +94,52 @@ BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
|
||||
_("Trigger once while true"),
|
||||
_("Run actions only once, for each time the conditions have been met."),
|
||||
_("Trigger once"),
|
||||
_("Advanced"),
|
||||
"",
|
||||
"res/conditions/once24.png",
|
||||
"res/conditions/once.png");
|
||||
|
||||
extension
|
||||
.AddCondition("CompareNumbers",
|
||||
_("Compare two numbers"),
|
||||
_("Compare the two numbers."),
|
||||
_("_PARAM0_ _PARAM1_ _PARAM2_"),
|
||||
"",
|
||||
"res/conditions/egal24.png",
|
||||
"res/conditions/egal.png")
|
||||
.SetHelpPath("/all-features/advanced-conditions")
|
||||
.AddParameter("expression", _("First expression"))
|
||||
.AddParameter("relationalOperator", _("Sign of the test"), "number")
|
||||
.AddParameter("expression", _("Second expression"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Compatibility with GD <= 5.0.127
|
||||
extension
|
||||
.AddDuplicatedCondition(
|
||||
"Egal", "BuiltinCommonInstructions::CompareNumbers", {.unscoped = true})
|
||||
.SetHidden();
|
||||
// end of compatibility code
|
||||
|
||||
extension
|
||||
.AddCondition("CompareStrings",
|
||||
_("Compare two strings"),
|
||||
_("Compare the two strings."),
|
||||
_("_PARAM0_ _PARAM1_ _PARAM2_"),
|
||||
"",
|
||||
"res/conditions/egal24.png",
|
||||
"res/conditions/egal.png")
|
||||
.SetHelpPath("/all-features/advanced-conditions")
|
||||
.AddParameter("string", _("First string expression"))
|
||||
.AddParameter("relationalOperator", _("Sign of the test"), "string")
|
||||
.AddParameter("string", _("Second string expression"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Compatibility with GD <= 5.0.127
|
||||
extension
|
||||
.AddDuplicatedCondition(
|
||||
"StrEqual", "BuiltinCommonInstructions::CompareStrings", {.unscoped = true})
|
||||
.SetHidden();
|
||||
// end of compatibility code
|
||||
|
||||
extension.AddEvent(
|
||||
"Standard",
|
||||
_("Standard event"),
|
||||
|
@@ -19,18 +19,21 @@ BuiltinExtensionsImplementer::ImplementsExternalLayoutsExtension(
|
||||
"external layouts.",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/interface/scene-editor/external-layouts");
|
||||
.SetExtensionHelpPath("/interface/scene-editor/external-layouts")
|
||||
.SetCategory("Advanced");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("External layouts"))
|
||||
.SetIcon("res/ribbon_default/externallayout32.png");
|
||||
|
||||
extension
|
||||
.AddAction("CreateObjectsFromExternalLayout",
|
||||
_("Create objects from an external layout"),
|
||||
_("Create objects from an external layout."),
|
||||
_("Create objects from the external layout named _PARAM1_"),
|
||||
_("External layouts"),
|
||||
"res/conditions/fichier24.png",
|
||||
"res/conditions/fichier.png")
|
||||
"",
|
||||
"res/ribbon_default/externallayout32.png",
|
||||
"res/ribbon_default/externallayout32.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("string", _("Name of the external layout"))
|
||||
.AddParameter("externalLayoutName", _("Name of the external layout"))
|
||||
.AddParameter("expression", _("X position of the origin"), "", true)
|
||||
.SetDefaultValue("0")
|
||||
.AddParameter("expression", _("Y position of the origin"), "", true)
|
||||
|
@@ -20,7 +20,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
"stored on the device and erased when the game is uninstalled.",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/storage");
|
||||
.SetExtensionHelpPath("/all-features/storage")
|
||||
.SetCategory("Device");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Storage"))
|
||||
.SetIcon("res/conditions/fichier24.png");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -29,7 +32,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
_("Check if an element (example : PlayerState/CurrentLevel) exists "
|
||||
"in the stored data.\nSpaces are forbidden in element names."),
|
||||
_("_PARAM1_ exists in storage _PARAM0_"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/conditions/fichier24.png",
|
||||
"res/conditions/fichier.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
@@ -45,7 +48,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
"action, but it will be slower.\nIf you use this action, do not "
|
||||
"forget to unload the storage from memory."),
|
||||
_("Load storage _PARAM0_ in memory"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/actions/fichier24.png",
|
||||
"res/actions/fichier.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
@@ -57,7 +60,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
_("This action closes the structured data previously loaded "
|
||||
"in memory, saving all changes made."),
|
||||
_("Close structured data _PARAM0_"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/actions/fichier24.png",
|
||||
"res/actions/fichier.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
@@ -72,7 +75,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
"element using / (example : Root/Level/Current)\nSpaces are "
|
||||
"forbidden in element names."),
|
||||
_("Write _PARAM2_ in _PARAM1_ of storage _PARAM0_"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/actions/fichier24.png",
|
||||
"res/actions/fichier.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
@@ -88,7 +91,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
"the structure leading to the element using / (example : "
|
||||
"Root/Level/Current)\nSpaces are forbidden in element names."),
|
||||
_("Write _PARAM2_ in _PARAM1_ of storage _PARAM0_"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/actions/fichier24.png",
|
||||
"res/actions/fichier.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
@@ -105,7 +108,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
"(example : Root/Level/Current)\nSpaces are forbidden in element "
|
||||
"names."),
|
||||
_("Read _PARAM1_ from storage _PARAM0_ and store value in _PARAM3_"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/actions/fichier24.png",
|
||||
"res/actions/fichier.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
@@ -124,7 +127,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
"names."),
|
||||
_("Read _PARAM1_ from storage _PARAM0_ and store as text in "
|
||||
"_PARAM3_"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/actions/fichier24.png",
|
||||
"res/actions/fichier.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
@@ -140,7 +143,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
"element using / (example : Root/Level/Current)\nSpaces are "
|
||||
"forbidden in element names."),
|
||||
_("Delete _PARAM1_ from storage _PARAM0_"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/actions/delete24.png",
|
||||
"res/actions/delete.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
@@ -153,7 +156,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
_("Clear a storage"),
|
||||
_("Clear the specified storage, removing all data saved in it."),
|
||||
_("Delete storage _PARAM0_"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/actions/delete24.png",
|
||||
"res/actions/delete.png")
|
||||
.AddParameter("string", _("Storage name"));
|
||||
@@ -163,32 +166,18 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
_("A storage exists"),
|
||||
_("Test if the specified storage exists."),
|
||||
_("Storage _PARAM0_ exists"),
|
||||
_("Storage"),
|
||||
"",
|
||||
"res/conditions/fichier24.png",
|
||||
"res/conditions/fichier.png")
|
||||
.AddParameter("string", _("Storage name"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("LaunchFile",
|
||||
_("Open a URL or a file"),
|
||||
_("This action launches the specified file or URL, in a "
|
||||
"browser (or in a new tab if the game is using the Web "
|
||||
"platform and is launched inside a browser)."),
|
||||
_("Open URL (or file) _PARAM0_"),
|
||||
_("Files"),
|
||||
"res/actions/launchFile24.png",
|
||||
"res/actions/launchFile.png")
|
||||
.AddParameter("string", _("URL (or filename)"))
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("ExecuteCmd",
|
||||
_("Execute a command"),
|
||||
_("This action executes the specified command."),
|
||||
_("Execute _PARAM0_"),
|
||||
_("Files"),
|
||||
_("Network"),
|
||||
"res/actions/launchFile24.png",
|
||||
"res/actions/launchFile.png")
|
||||
.AddParameter("string", _("Command"))
|
||||
|
@@ -14,21 +14,24 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinKeyboard",
|
||||
_("Keyboard features"),
|
||||
_("Keyboard"),
|
||||
_("Allows your game to respond to keyboard input. Note that this "
|
||||
"does not work with on-screen keyboard on touch devices: use "
|
||||
"instead conditions related to touch when making a game for "
|
||||
"mobile/touchscreen devices."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/keyboard");
|
||||
.SetExtensionHelpPath("/all-features/keyboard")
|
||||
.SetCategory("Input");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Keyboard"))
|
||||
.SetIcon("res/conditions/keyboard24.png");
|
||||
|
||||
extension
|
||||
.AddCondition("KeyPressed",
|
||||
_("Key pressed"),
|
||||
_("Check if a key is pressed"),
|
||||
_("_PARAM1_ key is pressed"),
|
||||
_("Keyboard"),
|
||||
"",
|
||||
"res/conditions/keyboard24.png",
|
||||
"res/conditions/keyboard.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -39,7 +42,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
||||
_("Key released"),
|
||||
_("Check if a key was just released"),
|
||||
_("_PARAM1_ key is released"),
|
||||
_("Keyboard"),
|
||||
"",
|
||||
"res/conditions/keyboard24.png",
|
||||
"res/conditions/keyboard.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -51,7 +54,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
||||
_("Check if a key, retrieved from the result of the "
|
||||
"expression, is pressed"),
|
||||
_("_PARAM1_ key is pressed"),
|
||||
_("Keyboard"),
|
||||
"",
|
||||
"res/conditions/keyboard24.png",
|
||||
"res/conditions/keyboard.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -64,7 +67,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
||||
_("Check if a key, retrieved from the result of the "
|
||||
"expression, was just released"),
|
||||
_("_PARAM1_ key is released"),
|
||||
_("Keyboard"),
|
||||
"",
|
||||
"res/conditions/keyboard24.png",
|
||||
"res/conditions/keyboard.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -76,7 +79,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
||||
_("Any key pressed"),
|
||||
_("Check if any key is pressed"),
|
||||
_("Any key is pressed"),
|
||||
_("Keyboard"),
|
||||
"",
|
||||
"res/conditions/keyboard24.png",
|
||||
"res/conditions/keyboard.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
@@ -86,7 +89,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
||||
_("Any key released"),
|
||||
_("Check if any key is released"),
|
||||
_("Any key is released"),
|
||||
_("Keyboard"),
|
||||
"",
|
||||
"res/conditions/keyboard24.png",
|
||||
"res/conditions/keyboard.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
@@ -96,7 +99,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
|
||||
"LastPressedKey",
|
||||
_("Last pressed key"),
|
||||
_("Get the name of the latest key pressed on the keyboard"),
|
||||
_("Keyboard"),
|
||||
"",
|
||||
"res/conditions/keyboard.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
}
|
||||
|
@@ -18,13 +18,63 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
"A set of mathematical functions that can be used in expressions.",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Mathematical tools"))
|
||||
.SetIcon("res/mathfunction.png");
|
||||
|
||||
extension
|
||||
.AddExpression("Random",
|
||||
_("Random integer"),
|
||||
_("Random integer"),
|
||||
"",
|
||||
"res/dice-6.svg")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomInRange",
|
||||
_("Random integer in range"),
|
||||
_("Random integer in range"),
|
||||
"",
|
||||
"res/dice-6.svg")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomFloat",
|
||||
_("Random float"),
|
||||
_("Random float"),
|
||||
"",
|
||||
"res/dice-6.svg")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomFloatInRange",
|
||||
_("Random float in range"),
|
||||
_("Random float in range"),
|
||||
"",
|
||||
"res/dice-6.svg")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomWithStep",
|
||||
_("Random value in steps"),
|
||||
_("Random value in steps"),
|
||||
"",
|
||||
"res/dice-6.svg")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"))
|
||||
.AddParameter("expression", _("Step"));
|
||||
|
||||
extension
|
||||
.AddExpression("normalize",
|
||||
_("Normalize a value between `min` and `max` to a value between 0 and 1."),
|
||||
_("Remap a value between 0 and 1."),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Value"))
|
||||
.AddParameter("expression", _("Min"))
|
||||
@@ -34,7 +84,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("clamp",
|
||||
_("Clamp (restrict a value to a given range)"),
|
||||
_("Restrict a value to a given range"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Value"))
|
||||
.AddParameter("expression", _("Min"))
|
||||
@@ -44,7 +94,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("AngleDifference",
|
||||
_("Difference between two angles"),
|
||||
_("Difference between two angles"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("First angle"))
|
||||
.AddParameter("expression", _("Second angle"));
|
||||
@@ -53,7 +103,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("AngleBetweenPositions",
|
||||
_("Angle between two positions"),
|
||||
_("Compute the angle between two positions."),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("First point X position"))
|
||||
.AddParameter("expression", _("First point Y position"))
|
||||
@@ -64,7 +114,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("DistanceBetweenPositions",
|
||||
_("Distance between two positions"),
|
||||
_("Compute the distance between two positions."),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("First point X position"))
|
||||
.AddParameter("expression", _("First point Y position"))
|
||||
@@ -75,7 +125,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("mod",
|
||||
_("Modulo"),
|
||||
_("x mod y"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("x (as in x mod y)"))
|
||||
.AddParameter("expression", _("y (as in x mod y)"));
|
||||
@@ -84,7 +134,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("min",
|
||||
_("Minimum of two numbers"),
|
||||
_("Minimum of two numbers"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("First expression"))
|
||||
.AddParameter("expression", _("Second expression"));
|
||||
@@ -93,7 +143,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("max",
|
||||
_("Maximum of two numbers"),
|
||||
_("Maximum of two numbers"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("First expression"))
|
||||
.AddParameter("expression", _("Second expression"));
|
||||
@@ -102,7 +152,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("abs",
|
||||
_("Absolute value"),
|
||||
_("Absolute value"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -110,7 +160,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("acos",
|
||||
_("Arccosine"),
|
||||
_("Arccosine"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -118,7 +168,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("acosh",
|
||||
_("Hyperbolic arccosine"),
|
||||
_("Hyperbolic arccosine"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -126,7 +176,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("asin",
|
||||
_("Arcsine"),
|
||||
_("Arcsine"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -134,7 +184,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("asinh",
|
||||
_("Arcsine"),
|
||||
_("Arcsine"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -142,7 +192,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("atan",
|
||||
_("Arctangent"),
|
||||
_("Arctangent"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -150,7 +200,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("atan2",
|
||||
_("2 argument arctangent"),
|
||||
_("2 argument arctangent (atan2)"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Y"))
|
||||
.AddParameter("expression", _("X"));
|
||||
@@ -159,7 +209,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("atanh",
|
||||
_("Hyperbolic arctangent"),
|
||||
_("Hyperbolic arctangent"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -167,7 +217,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("cbrt",
|
||||
_("Cube root"),
|
||||
_("Cube root"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -175,23 +225,41 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("ceil",
|
||||
_("Ceil (round up)"),
|
||||
_("Round number up to an integer"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
extension
|
||||
.AddExpression("ceilTo",
|
||||
_("Ceil (round up) to a decimal point"),
|
||||
_("Round number up to the Nth decimal place"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"))
|
||||
.AddParameter("expression", _("Expression"), "", true);
|
||||
|
||||
extension
|
||||
.AddExpression("floor",
|
||||
_("Floor (round down)"),
|
||||
_("Round number down to an integer"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
extension
|
||||
.AddExpression("floorTo",
|
||||
_("Floor (round down) to a decimal point"),
|
||||
_("Round number down to the Nth decimal place"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"))
|
||||
.AddParameter("expression", _("Expression"), "", true);
|
||||
|
||||
extension
|
||||
.AddExpression("cos",
|
||||
_("Cosine"),
|
||||
_("Cosine of a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -199,7 +267,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("cosh",
|
||||
_("Hyperbolic cosine"),
|
||||
_("Hyperbolic cosine"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -207,7 +275,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("cot",
|
||||
_("Cotangent"),
|
||||
_("Cotangent of a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -215,7 +283,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("csc",
|
||||
_("Cosecant"),
|
||||
_("Cosecant of a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -223,7 +291,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("int",
|
||||
_("Round"),
|
||||
_("Round a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.SetHidden()
|
||||
.AddParameter("expression", _("Expression"));
|
||||
@@ -232,7 +300,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("rint",
|
||||
_("Round"),
|
||||
_("Round a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.SetHidden()
|
||||
.AddParameter("expression", _("Expression"));
|
||||
@@ -241,15 +309,24 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("round",
|
||||
_("Round"),
|
||||
_("Round a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
extension
|
||||
.AddExpression("roundTo",
|
||||
_("Round to a decimal point"),
|
||||
_("Round a number to the Nth decimal place"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"))
|
||||
.AddParameter("expression", _("Expression"), "", true);
|
||||
|
||||
extension
|
||||
.AddExpression("exp",
|
||||
_("Exponential"),
|
||||
_("Exponential of a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -257,7 +334,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("log",
|
||||
_("Logarithm"),
|
||||
_("Logarithm"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -265,7 +342,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("ln",
|
||||
_("Logarithm"),
|
||||
_("Logarithm"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.SetHidden()
|
||||
.AddParameter("expression", _("Expression"));
|
||||
@@ -274,7 +351,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("log2",
|
||||
_("Base-2 logarithm"),
|
||||
_("Base 2 Logarithm"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -282,7 +359,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("log10",
|
||||
_("Base-10 logarithm"),
|
||||
_("Base-10 logarithm"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -290,7 +367,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("nthroot",
|
||||
_("Nth root"),
|
||||
_("Nth root of a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Number"))
|
||||
.AddParameter("expression", _("N"));
|
||||
@@ -299,7 +376,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("pow",
|
||||
_("Power"),
|
||||
_("Raise a number to power n"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Number"))
|
||||
.AddParameter("expression", _("The exponent (n in x^n)"));
|
||||
@@ -308,7 +385,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("sec",
|
||||
_("Secant"),
|
||||
_("Secant"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -316,7 +393,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("sign",
|
||||
_("Sign of a number"),
|
||||
_("Return the sign of a number (1,-1 or 0)"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -324,7 +401,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("sin",
|
||||
_("Sine"),
|
||||
_("Sine of a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -332,7 +409,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("sinh",
|
||||
_("Hyperbolic sine"),
|
||||
_("Hyperbolic sine"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -340,7 +417,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("sqrt",
|
||||
_("Square root"),
|
||||
_("Square root of a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -348,7 +425,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("tan",
|
||||
_("Tangent"),
|
||||
_("Tangent of a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -356,7 +433,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("tanh",
|
||||
_("Hyperbolic tangent"),
|
||||
_("Hyperbolic tangent"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -364,7 +441,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("trunc",
|
||||
_("Truncation"),
|
||||
_("Truncate a number"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
||||
@@ -372,7 +449,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
.AddExpression("lerp",
|
||||
_("Lerp (Linear interpolation)"),
|
||||
_("Linearly interpolate a to b by x"),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("a (in a+(b-a)*x)"))
|
||||
.AddParameter("expression", _("b (in a+(b-a)*x)"))
|
||||
@@ -385,7 +462,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
"relative to the origin (0;0). This is also known as "
|
||||
"getting the cartesian coordinates of a 2D vector, using "
|
||||
"its polar coordinates."),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Angle, in degrees"))
|
||||
.AddParameter("expression", _("Distance"));
|
||||
@@ -397,7 +474,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
"relative to the origin (0;0). This is also known as "
|
||||
"getting the cartesian coordinates of a 2D vector, using "
|
||||
"its polar coordinates."),
|
||||
_("Mathematical tools"),
|
||||
"",
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Angle, in degrees"))
|
||||
.AddParameter("expression", _("Distance"));
|
||||
|
@@ -23,7 +23,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
"separately in different events.",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/mouse-touch");
|
||||
.SetExtensionHelpPath("/all-features/mouse-touch")
|
||||
.SetCategory("Input");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Mouse and touch"))
|
||||
.SetIcon("res/actions/mouse24.png");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -32,7 +35,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Check if the mouse wheel is scrolling up. Use MouseWheelDelta "
|
||||
"expression if you want to know the amount that was scrolled."),
|
||||
_("The mouse wheel is scrolling up"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/actions/mouse24.png",
|
||||
"res/actions/mouse.png")
|
||||
|
||||
@@ -46,7 +49,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Check if the mouse wheel is scrolling down. Use MouseWheelDelta "
|
||||
"expression if you want to know the amount that was scrolled."),
|
||||
_("The mouse wheel is scrolling down"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/actions/mouse24.png",
|
||||
"res/actions/mouse.png")
|
||||
|
||||
@@ -64,7 +67,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
"touchscreens. If you want to have multitouch and differentiate "
|
||||
"mouse movement and touches, just deactivate it with this action."),
|
||||
_("Move mouse cursor when touching screen: _PARAM1_"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/conditions/touch24.png",
|
||||
"res/conditions/touch.png")
|
||||
|
||||
@@ -79,7 +82,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Center cursor horizontally"),
|
||||
_("Put the cursor in the middle of the screen horizontally."),
|
||||
_("Center cursor horizontally"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/actions/mouse24.png",
|
||||
"res/actions/mouse.png")
|
||||
|
||||
@@ -91,7 +94,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Center cursor vertically"),
|
||||
_("Put the cursor in the middle of the screen vertically."),
|
||||
_("Center cursor vertically"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/actions/mouse24.png",
|
||||
"res/actions/mouse.png")
|
||||
|
||||
@@ -103,7 +106,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Hide the cursor"),
|
||||
_("Hide the cursor."),
|
||||
_("Hide the cursor"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/actions/mouse24.png",
|
||||
"res/actions/mouse.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -114,7 +117,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Show the cursor"),
|
||||
_("Show the cursor."),
|
||||
_("Show the cursor"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/actions/mouse24.png",
|
||||
"res/actions/mouse.png")
|
||||
|
||||
@@ -126,7 +129,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Position the cursor of the mouse"),
|
||||
_("Position the cursor at the given coordinates."),
|
||||
_("Position cursor at _PARAM1_;_PARAM2_"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/actions/mouse24.png",
|
||||
"res/actions/mouse.png")
|
||||
|
||||
@@ -140,7 +143,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Center the cursor"),
|
||||
_("Center the cursor on the screen."),
|
||||
_("Center the cursor"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/actions/mouse24.png",
|
||||
"res/actions/mouse.png")
|
||||
|
||||
@@ -154,7 +157,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Cursor X position"),
|
||||
_("the X position of the cursor or of a touch"),
|
||||
_("the cursor (or touch) X position"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/conditions/mouse24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.UseStandardParameters("number")
|
||||
@@ -174,7 +177,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Cursor Y position"),
|
||||
_("the Y position of the cursor or of a touch"),
|
||||
_("the cursor (or touch) Y position"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/conditions/mouse24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.UseStandardParameters("number")
|
||||
@@ -187,13 +190,24 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
extension.AddDuplicatedCondition("SourisY", "MouseY").SetHidden();
|
||||
extension.AddDuplicatedExpression("SourisY", "MouseY").SetHidden();
|
||||
|
||||
extension
|
||||
.AddCondition("IsMouseInsideCanvas",
|
||||
_("Mouse cursor is inside the window"),
|
||||
_("Check if the mouse cursor is inside the window."),
|
||||
_("The mouse cursor is inside the window"),
|
||||
"",
|
||||
"res/conditions/mouse24.png",
|
||||
"res/conditions/mouse.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddCondition("MouseButtonPressed",
|
||||
_("Mouse button pressed or touch held"),
|
||||
_("Check if the specified mouse button is pressed or "
|
||||
"if a touch is in contact with the screen."),
|
||||
_("Touch or _PARAM1_ mouse button is down"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/conditions/mouse24.png",
|
||||
"res/conditions/mouse.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -209,7 +223,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Mouse button released"),
|
||||
_("Check if the specified mouse button was released."),
|
||||
_("_PARAM1_ mouse button was released"),
|
||||
_("Mouse and touch"),
|
||||
"",
|
||||
"res/conditions/mouse24.png",
|
||||
"res/conditions/mouse.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -223,7 +237,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("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", "")
|
||||
@@ -241,7 +255,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("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", "")
|
||||
@@ -258,7 +272,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Touch X position"),
|
||||
_("the X position of a specific touch"),
|
||||
_("the touch #_PARAM1_ X position"),
|
||||
_("Mouse and touch/Multitouch"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression", _("Touch identifier"))
|
||||
@@ -274,7 +288,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
_("Touch Y position"),
|
||||
_("the Y position of a specific touch"),
|
||||
_("the touch #_PARAM1_ Y position"),
|
||||
_("Mouse and touch/Multitouch"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression", _("Touch identifier"))
|
||||
@@ -294,10 +308,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
"next time you use it, it will be for a new touch, or it will "
|
||||
"return false if no more touches have just started."),
|
||||
_("A new touch has started"),
|
||||
_("Mouse and touch/Multitouch"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png",
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
@@ -309,11 +324,57 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
"time you use it, it will be for a new touch, or it will return "
|
||||
"false if no more touches have just ended."),
|
||||
_("A touch has ended"),
|
||||
_("Mouse and touch/Multitouch"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png",
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"HasAnyTouchStarted",
|
||||
_("A new touch has started"),
|
||||
_("Check if a touch has just started on this frame. The touch identifiers can be "
|
||||
"accessed using StartedTouchId() and StartedTouchCount()."),
|
||||
_("A new touch has started"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png",
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
"StartedTouchCount",
|
||||
_("Started touch count"),
|
||||
_("The number of touches that have just started on this frame. The touch identifiers can be "
|
||||
"accessed using StartedTouchId()."),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
extension
|
||||
.AddExpression(
|
||||
"StartedTouchId",
|
||||
_("Started touch identifier"),
|
||||
_("The identifier of the touch that has just started on this frame. The touch number of touches can be "
|
||||
"accessed using StartedTouchCount()."),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression", _("Touch index"));
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"HasTouchEnded",
|
||||
_("A touch has ended"),
|
||||
_("Check if a touch has ended."),
|
||||
_("The touch with identifier _PARAM1_ has ended"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch24.png",
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression", _("Touch identifier"));
|
||||
|
||||
extension
|
||||
.AddExpression("MouseWheelDelta",
|
||||
_("Mouse wheel: Displacement"),
|
||||
@@ -326,17 +387,19 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
.AddExpression("LastTouchId",
|
||||
_("Identifier of the last touch"),
|
||||
_("Identifier of the last touch"),
|
||||
_("Mouse and touch/Multitouch"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden();
|
||||
|
||||
extension
|
||||
.AddExpression("LastEndedTouchId",
|
||||
_("Identifier of the last ended touch"),
|
||||
_("Identifier of the last ended touch"),
|
||||
_("Mouse and touch/Multitouch"),
|
||||
_("Multitouch"),
|
||||
"res/conditions/touch.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden();
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -14,12 +14,15 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinNetwork",
|
||||
_("Basic internet features"),
|
||||
_("Network"),
|
||||
_("Features to send web requests, communicate with external \"APIs\" "
|
||||
"and other network related tasks."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/network");
|
||||
.SetExtensionHelpPath("/all-features/network")
|
||||
.SetCategory("Network");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Network"))
|
||||
.SetIcon("res/actions/net24.png");
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
@@ -30,7 +33,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
"as specified below, except if the server is configured to answer "
|
||||
"to all requests (cross-domain requests).",
|
||||
"Send _PARAM3_ request to _PARAM0__PARAM1_ with body: _PARAM2_",
|
||||
_("Network"),
|
||||
"",
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", "Host, with protocol")
|
||||
@@ -65,7 +68,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
"to all requests (cross-domain requests)."),
|
||||
_("Send a _PARAM2_ request to _PARAM0_ with body: _PARAM1_, and "
|
||||
"store the result in _PARAM4_ (or in _PARAM5_ in case of error)"),
|
||||
_("Network"),
|
||||
"",
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("URL (API or web-page address)"))
|
||||
@@ -92,21 +95,37 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
"explore the results with a *structure variable*."))
|
||||
.AddParameter(
|
||||
"scenevar", _("Variable where to store the error message"), "", true)
|
||||
.SetParameterLongDescription(
|
||||
_("Optional, only used if an error occurs. This will contain the "
|
||||
"[\"status code\"](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) "
|
||||
"if the server returns a status >= 400. If the request was not sent "
|
||||
"at all (e.g. no internet or CORS issues), the variable will be set to "
|
||||
"\"REQUEST_NOT_SENT\"."))
|
||||
.SetParameterLongDescription(_(
|
||||
"Optional, only used if an error occurs. This will contain the "
|
||||
"[\"status "
|
||||
"code\"](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) "
|
||||
"if the server returns a status >= 400. If the request was not sent "
|
||||
"at all (e.g. no internet or CORS issues), the variable will be set "
|
||||
"to "
|
||||
"\"REQUEST_NOT_SENT\"."))
|
||||
.MarkAsComplex();
|
||||
|
||||
extension
|
||||
.AddAction("LaunchFile",
|
||||
_("Open a URL (web page) or a file"),
|
||||
_("This action launches the specified file or URL, in a "
|
||||
"browser (or in a new tab if the game is using the Web "
|
||||
"platform and is launched inside a browser)."),
|
||||
_("Open URL _PARAM0_ in a browser (or new tab)"),
|
||||
"",
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("URL (or filename)"))
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"DownloadFile",
|
||||
_("Download a file"),
|
||||
_("Download a file from a web site"),
|
||||
_("Download file _PARAM1_ from _PARAM0_ under the name of _PARAM2_"),
|
||||
_("Network"),
|
||||
"",
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("Host (for example : http://www.website.com)"))
|
||||
@@ -124,78 +143,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
"terms of service of your game and if they player gave their "
|
||||
"consent, depending on how your game/company handles this."),
|
||||
_("Enable analytics metrics: _PARAM1_"),
|
||||
_("Network"),
|
||||
"",
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("yesorno", _("Enable the metrics?"));
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"JSONToVariableStructure",
|
||||
_("Convert JSON to a scene variable"),
|
||||
_("Parse a JSON object and store it into a scene variable"),
|
||||
_("Parse JSON string _PARAM0_ and store it into variable _PARAM1_"),
|
||||
_("Network"),
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("JSON string"))
|
||||
.AddParameter("scenevar", _("Variable where store the JSON object"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("JSONToGlobalVariableStructure",
|
||||
_("Convert JSON to global variable"),
|
||||
_("Parse a JSON object and store it into a global variable"),
|
||||
_("Parse JSON string _PARAM0_ and store it into global "
|
||||
"variable _PARAM1_"),
|
||||
_("Network"),
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("JSON string"))
|
||||
.AddParameter("globalvar",
|
||||
_("Global variable where store the JSON object"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction("JSONToObjectVariableStructure",
|
||||
_("Convert JSON to object variable"),
|
||||
_("Parse a JSON object and store it into an object variable"),
|
||||
_("Parse JSON string _PARAM0_ and store it into variable "
|
||||
"_PARAM2_ of _PARAM1_"),
|
||||
_("Network"),
|
||||
"res/actions/net24.png",
|
||||
"res/actions/net.png")
|
||||
.AddParameter("string", _("JSON string"))
|
||||
.AddParameter("objectPtr", _("Object"))
|
||||
.AddParameter("objectvar",
|
||||
_("Object variable where store the JSON object"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddStrExpression("ToJSON",
|
||||
_("Convert scene variable to JSON"),
|
||||
_("Convert a scene variable to JSON"),
|
||||
_("Conversion"),
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("scenevar", _("Scene variable to be stringified"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("GlobalVarToJSON",
|
||||
_("Convert global variable to JSON"),
|
||||
_("Convert a global variable to JSON"),
|
||||
_("Conversion"),
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("globalvar", _("The global variable to be stringified"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("ObjectVarToJSON",
|
||||
_("Convert object variable to JSON"),
|
||||
_("Convert an object variable to JSON"),
|
||||
_("Conversion"),
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("objectPtr", _("The object with the variable"))
|
||||
.AddParameter("objectvar", _("The object variable to be stringified"));
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -14,67 +14,19 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinScene",
|
||||
_("Scene management features"),
|
||||
_("Scene"),
|
||||
_("Actions and conditions to manipulate the scenes during the game."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
|
||||
|
||||
extension
|
||||
.AddExpression("Random",
|
||||
_("Random integer"),
|
||||
_("Random integer"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomInRange",
|
||||
_("Random integer in range"),
|
||||
_("Random integer in range"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomFloat",
|
||||
_("Random float"),
|
||||
_("Random float"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomFloatInRange",
|
||||
_("Random float in range"),
|
||||
_("Random float in range"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
.AddExpression("RandomWithStep",
|
||||
_("Random value in steps"),
|
||||
_("Random value in steps"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"))
|
||||
.AddParameter("expression", _("Step"));
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Scene"))
|
||||
.SetIcon("res/conditions/depart24.png");
|
||||
|
||||
extension
|
||||
.AddStrExpression("CurrentSceneName",
|
||||
_("Current scene name"),
|
||||
_("Name of the current scene"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/actions/texte.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
@@ -83,7 +35,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("At the beginning of the scene"),
|
||||
_("Is true only when scene just begins."),
|
||||
_("At the beginning of the scene"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/conditions/depart24.png",
|
||||
"res/conditions/depart.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
@@ -95,7 +47,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Scene just resumed"),
|
||||
_("The scene has just resumed after being paused."),
|
||||
_("Scene just resumed"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/conditions/depart24.png",
|
||||
"res/conditions/depart.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
@@ -107,7 +59,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Change the scene"),
|
||||
_("Stop this scene and start the specified one instead."),
|
||||
_("Change to scene _PARAM1_"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/actions/replaceScene24.png",
|
||||
"res/actions/replaceScene.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
@@ -124,7 +76,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
"can use the \"Stop and go back to previous scene\" action "
|
||||
"to go back to this scene."),
|
||||
_("Pause the scene and start _PARAM1_"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/actions/pushScene24.png",
|
||||
"res/actions/pushScene.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
@@ -139,7 +91,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Stop this scene and go back to the previous paused one.\nTo pause "
|
||||
"a scene, use the \"Pause and start a new scene\" action."),
|
||||
_("Stop the scene and go back to the previous paused one"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/actions/popScene24.png",
|
||||
"res/actions/popScene.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
@@ -151,7 +103,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Quit the game"),
|
||||
_("Quit the game"),
|
||||
_("Quit the game"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/actions/quit24.png",
|
||||
"res/actions/quit.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
@@ -163,7 +115,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Change background color"),
|
||||
_("Change the background color of the scene."),
|
||||
_("Set background color to _PARAM1_"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/actions/background24.png",
|
||||
"res/actions/background.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
@@ -177,41 +129,13 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("mouse buttons must be taken "
|
||||
"into account even\nif the window is not active."),
|
||||
_("Disable input when focus is lost: _PARAM1_"),
|
||||
_("Scene"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("yesorno", _("Deactivate input when focus is lost"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddCondition("Egal",
|
||||
_("Compare two numbers"),
|
||||
_("Compare the two numbers."),
|
||||
_("_PARAM0_ _PARAM1_ _PARAM2_"),
|
||||
_("Other"),
|
||||
"res/conditions/egal24.png",
|
||||
"res/conditions/egal.png")
|
||||
.SetHelpPath("/all-features/advanced-conditions")
|
||||
.AddParameter("expression", _("First expression"))
|
||||
.AddParameter("relationalOperator", _("Sign of the test"), "number")
|
||||
.AddParameter("expression", _("Second expression"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddCondition("StrEqual",
|
||||
_("Compare two strings"),
|
||||
_("Compare the two strings."),
|
||||
_("_PARAM0_ _PARAM1_ _PARAM2_"),
|
||||
_("Other"),
|
||||
"res/conditions/egal24.png",
|
||||
"res/conditions/egal.png")
|
||||
.SetHelpPath("/all-features/advanced-conditions")
|
||||
.AddParameter("string", _("First string expression"))
|
||||
.AddParameter("relationalOperator", _("Sign of the test"), "string")
|
||||
.AddParameter("string", _("Second string expression"))
|
||||
.MarkAsAdvanced();
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -121,7 +121,7 @@ void Direction::UnserializeFrom(const gd::SerializerElement& element) {
|
||||
polygonElement.GetChild(k);
|
||||
|
||||
polygon.vertices.push_back(
|
||||
sf::Vector2f(verticeElement.GetDoubleAttribute("x"),
|
||||
gd::Vector2f(verticeElement.GetDoubleAttribute("x"),
|
||||
verticeElement.GetDoubleAttribute("y")));
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "Polygon2d.h"
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include "GDCore/Vector2.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
@@ -28,7 +28,7 @@ void Polygon2d::Move(float x, float y) {
|
||||
}
|
||||
|
||||
void Polygon2d::ComputeEdges() const {
|
||||
sf::Vector2f v1, v2;
|
||||
gd::Vector2f v1, v2;
|
||||
edges.clear();
|
||||
|
||||
for (std::size_t i = 0; i < vertices.size(); i++) {
|
||||
@@ -62,8 +62,8 @@ bool Polygon2d::IsConvex() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
sf::Vector2f Polygon2d::ComputeCenter() const {
|
||||
sf::Vector2f center;
|
||||
gd::Vector2f Polygon2d::ComputeCenter() const {
|
||||
gd::Vector2f center;
|
||||
|
||||
for (std::size_t i = 0; i < vertices.size(); i++) {
|
||||
center.x += vertices[i].x;
|
||||
@@ -77,10 +77,10 @@ sf::Vector2f Polygon2d::ComputeCenter() const {
|
||||
|
||||
Polygon2d Polygon2d::CreateRectangle(float width, float height) {
|
||||
Polygon2d rect;
|
||||
rect.vertices.push_back(sf::Vector2f(-width / 2.0f, -height / 2.0f));
|
||||
rect.vertices.push_back(sf::Vector2f(+width / 2.0f, -height / 2.0f));
|
||||
rect.vertices.push_back(sf::Vector2f(+width / 2.0f, +height / 2.0f));
|
||||
rect.vertices.push_back(sf::Vector2f(-width / 2.0f, +height / 2.0f));
|
||||
rect.vertices.push_back(gd::Vector2f(-width / 2.0f, -height / 2.0f));
|
||||
rect.vertices.push_back(gd::Vector2f(+width / 2.0f, -height / 2.0f));
|
||||
rect.vertices.push_back(gd::Vector2f(+width / 2.0f, +height / 2.0f));
|
||||
rect.vertices.push_back(gd::Vector2f(-width / 2.0f, +height / 2.0f));
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
#ifndef GDCORE_POLYGON_H
|
||||
#define GDCORE_POLYGON_H
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include "GDCore/Vector2.h"
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
@@ -22,19 +22,19 @@ class GD_CORE_API Polygon2d {
|
||||
Polygon2d(){};
|
||||
virtual ~Polygon2d(){};
|
||||
|
||||
std::vector<sf::Vector2f> vertices; ///< The vertices composing the polygon
|
||||
mutable std::vector<sf::Vector2f>
|
||||
std::vector<gd::Vector2f> vertices; ///< The vertices composing the polygon
|
||||
mutable std::vector<gd::Vector2f>
|
||||
edges; ///< Edges. Can be computed from vertices using ComputeEdges()
|
||||
|
||||
/**
|
||||
* \brief Get the vertices composing the polygon.
|
||||
*/
|
||||
std::vector<sf::Vector2f>& GetVertices() { return vertices; }
|
||||
std::vector<gd::Vector2f>& GetVertices() { return vertices; }
|
||||
|
||||
/**
|
||||
* \brief Get the vertices composing the polygon.
|
||||
*/
|
||||
const std::vector<sf::Vector2f>& GetVertices() const { return vertices; }
|
||||
const std::vector<gd::Vector2f>& GetVertices() const { return vertices; }
|
||||
|
||||
/**
|
||||
* \brief Moves each vertices from the given amount.
|
||||
@@ -68,7 +68,7 @@ class GD_CORE_API Polygon2d {
|
||||
/**
|
||||
* \brief Return the position of the center of the polygon
|
||||
*/
|
||||
sf::Vector2f ComputeCenter() const;
|
||||
gd::Vector2f ComputeCenter() const;
|
||||
|
||||
/** \name Tools
|
||||
* Tool functions
|
||||
|
@@ -4,7 +4,6 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Sprite.h"
|
||||
#include <SFML/Graphics/Sprite.hpp>
|
||||
#include <iostream>
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
#ifndef SPRITE_H
|
||||
#define SPRITE_H
|
||||
#include <SFML/Graphics/Sprite.hpp>
|
||||
#include <memory>
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Point.h"
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
|
||||
|
@@ -199,6 +199,18 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.UseStandardOperatorParameters("number")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition("Width",
|
||||
_("Width"),
|
||||
_("Compare the width of a Sprite object."),
|
||||
_("the width"),
|
||||
_("Size"),
|
||||
"res/conditions/scaleWidth24.png",
|
||||
"res/conditions/scaleWidth.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardRelationalOperatorParameters("number")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("ChangeHeight",
|
||||
_("Height"),
|
||||
_("Change the height of a Sprite object."),
|
||||
@@ -211,6 +223,31 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.UseStandardOperatorParameters("number")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition("Height",
|
||||
_("Height"),
|
||||
_("Compare the height of a Sprite object."),
|
||||
_("the height"),
|
||||
_("Size"),
|
||||
"res/conditions/scaleHeight24.png",
|
||||
"res/conditions/scaleHeight.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardRelationalOperatorParameters("number")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("SetSize",
|
||||
_("Size"),
|
||||
_("Change the size of an object."),
|
||||
_("Change the size of _PARAM0_: set to _PARAM1_x_PARAM2_"),
|
||||
_("Size"),
|
||||
"res/actions/scale24.png",
|
||||
"res/actions/scale.png")
|
||||
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("expression", _("Width"))
|
||||
.AddParameter("expression", _("Height"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition(
|
||||
"Animation",
|
||||
_("Current animation"),
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include "GDCore/CommonTools.h"
|
||||
|
@@ -20,18 +20,20 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Text manipulation"))
|
||||
.SetIcon("res/actions/text24.png");
|
||||
|
||||
extension.AddStrExpression("NewLine",
|
||||
_("Insert a new line"),
|
||||
_("Insert a new line"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png");
|
||||
|
||||
extension
|
||||
.AddStrExpression("FromCodePoint",
|
||||
_("Get character from code point"),
|
||||
_("Get character from code point"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("expression", _("Code point"));
|
||||
@@ -40,7 +42,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
.AddStrExpression("ToUpperCase",
|
||||
_("Uppercase a text"),
|
||||
_("Uppercase a text"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"));
|
||||
@@ -49,7 +51,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
.AddStrExpression("ToLowerCase",
|
||||
_("Lowercase a text"),
|
||||
_("Lowercase a text"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"));
|
||||
@@ -58,7 +60,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
.AddStrExpression("SubStr",
|
||||
_("Get a portion of a text"),
|
||||
_("Get a portion of a text"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"))
|
||||
@@ -71,7 +73,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
.AddStrExpression("StrAt",
|
||||
_("Get a character from a text"),
|
||||
_("Get a character from a text"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"))
|
||||
@@ -83,7 +85,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
.AddStrExpression("StrRepeat",
|
||||
_("Repeat a text"),
|
||||
_("Repeat a text"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text to repeat"))
|
||||
@@ -93,7 +95,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
.AddExpression("StrLength",
|
||||
_("Length of a text"),
|
||||
_("Length of a text"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"));
|
||||
@@ -103,7 +105,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
_("Search in a text"),
|
||||
_("Search in a text (return the position of the result or "
|
||||
"-1 if not found)"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"))
|
||||
@@ -114,7 +116,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
"Search in a text from the end",
|
||||
"Search in a text from the end (return the position of "
|
||||
"the result or -1 if not found)",
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"))
|
||||
@@ -128,7 +130,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
_("Search the last occurence in a string (return the position of "
|
||||
"the result, from the beginning of the string, or -1 if not "
|
||||
"found)"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"))
|
||||
@@ -139,7 +141,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
_("Search in a text, starting from a position"),
|
||||
_("Search in a text, starting from a position (return the "
|
||||
"position of the result or -1 if not found)"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"))
|
||||
@@ -154,7 +156,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
"Search in a text from the end, starting from a position",
|
||||
"Search in a text from the end, starting from a position (return "
|
||||
"the position of the result or -1 if not found)",
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"))
|
||||
@@ -172,7 +174,7 @@ BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(
|
||||
"(return "
|
||||
" the position of the result, from the beginning of the string, or "
|
||||
"-1 if not found)"),
|
||||
_("Manipulation of text"),
|
||||
"",
|
||||
"res/conditions/toujours24.png")
|
||||
|
||||
.AddParameter("string", _("Text"))
|
||||
|
@@ -14,13 +14,17 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinTime",
|
||||
_("Time"),
|
||||
_("Timers and time"),
|
||||
"Actions and conditions to run timers, get the current time or "
|
||||
"modify the time scale (speed at which the game is running - useful "
|
||||
"for slow motion effects).",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/timers");
|
||||
.SetExtensionHelpPath("/all-features/timers-and-time");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(
|
||||
_("Timers and time")
|
||||
)
|
||||
.SetIcon("res/conditions/timer24.png");
|
||||
|
||||
// Deprecated and replaced by CompareTimer
|
||||
extension
|
||||
@@ -28,7 +32,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
_("Value of a scene timer"),
|
||||
_("Test the elapsed time of a scene timer."),
|
||||
_("The timer _PARAM2_ is greater than _PARAM1_ seconds"),
|
||||
_("Timers and time"),
|
||||
|
||||
"",
|
||||
"res/conditions/timer24.png",
|
||||
"res/conditions/timer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -39,9 +44,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
extension
|
||||
.AddCondition("CompareTimer",
|
||||
_("Value of a scene timer"),
|
||||
_("Compare the elapsed time of a scene timer. This condition doesn't start the timer."),
|
||||
_("Compare the elapsed time of a scene timer. This "
|
||||
"condition doesn't start the timer."),
|
||||
_("The timer _PARAM1_ _PARAM2_ _PARAM3_ seconds"),
|
||||
_("Timers and time"),
|
||||
|
||||
"",
|
||||
"res/conditions/timer24.png",
|
||||
"res/conditions/timer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -55,7 +62,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
_("Time scale"),
|
||||
_("Compare the time scale of the scene."),
|
||||
_("the time scale of the scene"),
|
||||
_("Timers and time"),
|
||||
|
||||
"",
|
||||
"res/conditions/time24.png",
|
||||
"res/conditions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -67,7 +75,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
_("Scene timer paused"),
|
||||
_("Test if the specified scene timer is paused."),
|
||||
_("The timer _PARAM1_ is paused"),
|
||||
_("Timers and time"),
|
||||
|
||||
"",
|
||||
"res/conditions/timerPaused24.png",
|
||||
"res/conditions/timerPaused.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -81,7 +90,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
_("Reset the specified scene timer, if the timer doesn't exist "
|
||||
"it's created and started."),
|
||||
_("Start (or reset) the timer _PARAM1_"),
|
||||
_("Timers and time"),
|
||||
|
||||
"",
|
||||
"res/actions/timer24.png",
|
||||
"res/actions/timer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -92,7 +102,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
_("Pause a scene timer"),
|
||||
_("Pause a scene timer."),
|
||||
_("Pause timer _PARAM1_"),
|
||||
_("Timers and time"),
|
||||
|
||||
"",
|
||||
"res/actions/pauseTimer24.png",
|
||||
"res/actions/pauseTimer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -104,7 +115,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
_("Unpause a scene timer"),
|
||||
_("Unpause a scene timer."),
|
||||
_("Unpause timer _PARAM1_"),
|
||||
_("Timers and time"),
|
||||
|
||||
"",
|
||||
"res/actions/unPauseTimer24.png",
|
||||
"res/actions/unPauseTimer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -116,7 +128,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
_("Delete a scene timer"),
|
||||
_("Delete a scene timer from memory."),
|
||||
_("Delete timer _PARAM1_ from memory"),
|
||||
_("Timers and time"),
|
||||
|
||||
"",
|
||||
"res/actions/timer24.png",
|
||||
"res/actions/timer.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -128,18 +141,31 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
_("Change time scale"),
|
||||
_("Change the time scale of the scene."),
|
||||
_("Set the time scale of the scene to _PARAM1_"),
|
||||
_("Timers and time"),
|
||||
"",
|
||||
"res/actions/time24.png",
|
||||
"res/actions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("expression",
|
||||
_("Scale (1: Default, 2: 2x faster, 0.5: 2x slower...)"));
|
||||
|
||||
extension
|
||||
.AddAction("Wait",
|
||||
_("Wait X seconds (experimental)"),
|
||||
_("Waits a number of seconds before running "
|
||||
"the next actions (and sub-events)."),
|
||||
_("Wait _PARAM0_ seconds"),
|
||||
"",
|
||||
"res/timer.svg",
|
||||
"res/timer.svg")
|
||||
.AddParameter("expression", "Time to wait in seconds")
|
||||
.SetHelpPath("/all-features/timers-and-time/wait-action")
|
||||
.SetAsync();
|
||||
|
||||
extension
|
||||
.AddExpression("TimeDelta",
|
||||
_("Time elapsed since the last frame"),
|
||||
_("Time elapsed since the last frame rendered on screen"),
|
||||
_("Time"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
@@ -147,7 +173,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
.AddExpression("TempsFrame",
|
||||
_("Time elapsed since the last frame"),
|
||||
_("Time elapsed since the last frame rendered on screen"),
|
||||
_("Time"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.SetHidden()
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
@@ -156,7 +182,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
.AddExpression("ElapsedTime",
|
||||
_("Time elapsed since the last frame"),
|
||||
_("Time elapsed since the last frame rendered on screen"),
|
||||
_("Time"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.SetHidden()
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
@@ -165,7 +191,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
.AddExpression("TimerElapsedTime",
|
||||
_("Scene timer value"),
|
||||
_("Value of a scene timer"),
|
||||
_("Time"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("string", _("Timer's name"));
|
||||
@@ -174,7 +200,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
.AddExpression("TimeFromStart",
|
||||
_("Time elapsed since the beginning of the scene"),
|
||||
_("Time elapsed since the beginning of the scene"),
|
||||
_("Time"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
@@ -182,7 +208,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
.AddExpression("TempsDebut",
|
||||
_("Time elapsed since the beginning of the scene"),
|
||||
_("Time elapsed since the beginning of the scene"),
|
||||
_("Time"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.SetHidden()
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
@@ -191,7 +217,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
.AddExpression("TimeScale",
|
||||
_("Time scale"),
|
||||
_("Returns the time scale of the scene."),
|
||||
_("Time"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
@@ -199,7 +225,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
.AddExpression("Time",
|
||||
_("Current time"),
|
||||
_("Current time"),
|
||||
_("Time"),
|
||||
"",
|
||||
"res/actions/time.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter(
|
||||
@@ -210,7 +236,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsTimeExtension(
|
||||
"timestamp\""),
|
||||
"[\"hour\", \"min\", \"sec\", \"mon\", \"year\", \"wday\", \"mday\", "
|
||||
"\"yday\", \"timestamp\"]");
|
||||
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -14,7 +14,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinVariables",
|
||||
_("Variable features"),
|
||||
_("Variables"),
|
||||
"Actions, conditions and expressions to handle variables, from "
|
||||
"simple variables like the player score, the number of remaining "
|
||||
"lives to complex variables containing arbitrary data like an "
|
||||
@@ -22,13 +22,15 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/variables");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Variables"))
|
||||
.SetIcon("res/conditions/var24.png");
|
||||
|
||||
extension
|
||||
.AddCondition("VarScene",
|
||||
_("Value of a scene variable"),
|
||||
_("Compare the value of a scene variable."),
|
||||
_("the scene variable _PARAM0_"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -39,7 +41,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Text of a scene variable"),
|
||||
_("Compare the text of a scene variable."),
|
||||
_("the text of scene variable _PARAM0_"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -51,7 +53,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Boolean value of a scene variable"),
|
||||
_("Compare the boolean value of a scene variable."),
|
||||
_("The boolean value of scene variable _PARAM0_ is _PARAM1_"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -64,7 +66,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Child existence"),
|
||||
_("Check if the specified child of the scene variable exists."),
|
||||
_("Child _PARAM1_ of scene variable _PARAM0_ exists"),
|
||||
_("Variables/Scene variables/Collections/Structures"),
|
||||
_("Scene variables/Collections/Structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -77,7 +79,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Check if the specified child of the global "
|
||||
"variable exists."),
|
||||
_("Child _PARAM1_ of global variable _PARAM0_ exists"),
|
||||
_("Variables/Global variables/Collections/Structures"),
|
||||
_("Global variables/Collections/Structures"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -89,7 +91,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
"Test if a scene variable is defined",
|
||||
"Test if the scene variable exists.",
|
||||
"Scene variable _PARAM0_ is defined",
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -101,7 +103,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Value of a global variable"),
|
||||
_("Compare the value of a global variable."),
|
||||
_("the global variable _PARAM0_"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -113,7 +115,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Text of a global variable"),
|
||||
_("Compare the text of a global variable."),
|
||||
_("the text of the global variable _PARAM0_"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -126,7 +128,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Boolean value of a global variable"),
|
||||
_("Compare the boolean value of a global variable."),
|
||||
_("The boolean value of global variable _PARAM0_ is _PARAM1_"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -138,7 +140,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
"Test if a global variable is defined",
|
||||
"Test if a global variable exists",
|
||||
"Global variable _PARAM0_ is defined",
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -151,7 +153,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Value of a scene variable"),
|
||||
_("Change the value of a scene variable."),
|
||||
_("the scene variable _PARAM0_"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -162,7 +164,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("String of a scene variable"),
|
||||
_("Modify the text of a scene variable."),
|
||||
_("the text of scene variable _PARAM0_"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -174,7 +176,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Boolean value of a scene variable"),
|
||||
_("Modify the boolean value of a scene variable."),
|
||||
_("Set the boolean value of scene variable _PARAM0_ to _PARAM1_"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -187,7 +189,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("If it was true, it will become false, and if it was "
|
||||
"false it will become true."),
|
||||
_("Toggle the boolean value of scene variable _PARAM0_"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"));
|
||||
@@ -197,7 +199,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Value of a global variable"),
|
||||
_("Change the value of a global variable"),
|
||||
_("the global variable _PARAM0_"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -209,7 +211,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("String of a global variable"),
|
||||
_("Modify the text of a global variable."),
|
||||
_("the text of global variable _PARAM0_"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -222,7 +224,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Boolean value of a global variable"),
|
||||
_("Modify the boolean value of a global variable."),
|
||||
_("Set the boolean value of global variable _PARAM0_ to _PARAM1_"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -235,7 +237,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("If it was true, it will become false, and if it was "
|
||||
"false it will become true."),
|
||||
_("Toggle the boolean value of global variable _PARAM0_"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/conditions/var24.png",
|
||||
"res/conditions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"));
|
||||
@@ -245,7 +247,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Remove a child"),
|
||||
_("Remove a child from a scene variable."),
|
||||
_("Remove child _PARAM1_ from scene variable _PARAM0_"),
|
||||
_("Variables/Scene variables/Collections/Structures"),
|
||||
_("Scene variables/Collections/Structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -257,7 +259,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Remove a child"),
|
||||
_("Remove a child from a global variable."),
|
||||
_("Remove child _PARAM1_ from global variable _PARAM0_"),
|
||||
_("Variables/Global variables/Collections/Structures"),
|
||||
_("Global variables/Collections/Structures"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -269,7 +271,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Clear scene variable"),
|
||||
_("Remove all the children from the scene variable."),
|
||||
_("Clear children from scene variable _PARAM0_"),
|
||||
_("Variables/Scene variables/Collections"),
|
||||
_("Scene variables/Collections"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -280,7 +282,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Clear global variable"),
|
||||
_("Remove all the children from the global variable."),
|
||||
_("Clear children from global variable _PARAM0_"),
|
||||
_("Variables/Global variables/Collections"),
|
||||
_("Global variables/Collections"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -291,7 +293,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Append variable to a scene array"),
|
||||
_("Appends a variable at the end of a scene array variable."),
|
||||
_("Append variable _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Variables/Scene variables/Collections/Arrays"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
@@ -304,7 +306,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Append a string to a scene array"),
|
||||
_("Appends a string at the end of a scene array variable."),
|
||||
_("Append string _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Variables/Scene variables/Collections/Arrays"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
@@ -316,7 +318,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Append a number to a scene array"),
|
||||
_("Appends a number at the end of a scene array variable."),
|
||||
_("Append number _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Variables/Scene variables/Collections/Arrays"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
@@ -328,7 +330,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Append a boolean to a scene array"),
|
||||
_("Appends a boolean at the end of a scene array variable."),
|
||||
_("Append boolean _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Variables/Scene variables/Collections/Arrays"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Array variable"))
|
||||
@@ -341,7 +343,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Remove variable from a scene array (by index)"),
|
||||
_("Removes a variable at the specified index of a scene array variable."),
|
||||
_("Remove variable at index _PARAM1_ from scene array variable _PARAM0_"),
|
||||
_("Variables/Scene variables/Collections/Arrays"),
|
||||
_("Scene variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"))
|
||||
@@ -353,7 +355,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Append variable to a global array"),
|
||||
_("Appends a variable at the end of a global array variable."),
|
||||
_("Append variable _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Variables/Global variables/Collections/Arrays"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
@@ -367,7 +369,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Remove variable from a global array (by index)"),
|
||||
_("Removes a variable at the specified index of a global array variable."),
|
||||
_("Remove variable at index _PARAM1_ from global array variable _PARAM0_"),
|
||||
_("Variables/Global variables/Collections/Arrays"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"))
|
||||
@@ -379,7 +381,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Append a string to a global array"),
|
||||
_("Appends a string at the end of a global array variable."),
|
||||
_("Append string _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Variables/Global variables/Collections/Arrays"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
@@ -391,7 +393,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Append a number to a global array"),
|
||||
_("Appends a number at the end of a global array variable."),
|
||||
_("Append number _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Variables/Global variables/Collections/Arrays"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
@@ -403,7 +405,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
_("Append a boolean to a global array"),
|
||||
_("Appends a boolean at the end of a global array variable."),
|
||||
_("Append boolean _PARAM1_ to array variable _PARAM0_"),
|
||||
_("Variables/Global variables/Collections/Arrays"),
|
||||
_("Global variables/Collections/Arrays"),
|
||||
"res/actions/var24.png",
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Array variable"))
|
||||
@@ -414,7 +416,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.AddExpression("GlobalVariableChildCount",
|
||||
_("Number of children of a global variable"),
|
||||
_("Number of children of a global variable"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"));
|
||||
|
||||
@@ -422,7 +424,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.AddExpression("VariableChildCount",
|
||||
_("Number of children of a scene variable"),
|
||||
_("Number of children of a scene variable"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"));
|
||||
|
||||
@@ -430,7 +432,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.AddExpression("Variable",
|
||||
_("Value of a scene variable"),
|
||||
_("Value of a scene variable"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"));
|
||||
|
||||
@@ -438,7 +440,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.AddStrExpression("VariableString",
|
||||
_("Text of a scene variable"),
|
||||
_("Text of a scene variable"),
|
||||
_("Variables/Scene variables"),
|
||||
_("Scene variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("scenevar", _("Variable"));
|
||||
|
||||
@@ -446,7 +448,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.AddExpression("GlobalVariable",
|
||||
_("Value of a global variable"),
|
||||
_("Value of a global variable"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Name of the global variable"));
|
||||
|
||||
@@ -454,7 +456,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
|
||||
.AddStrExpression("GlobalVariableString",
|
||||
_("Text of a global variable"),
|
||||
_("Text of a global variable"),
|
||||
_("Variables/Global variables"),
|
||||
_("Global variables"),
|
||||
"res/actions/var.png")
|
||||
.AddParameter("globalvar", _("Variable"));
|
||||
}
|
||||
|
@@ -14,13 +14,17 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinWindow",
|
||||
_("Window features"),
|
||||
_("Game window and resolution"),
|
||||
"Provides actions and conditions to manipulate the game window. "
|
||||
"Depending on the platform on which the game is running, not all of "
|
||||
"these features can be applied.",
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/all-features/window");
|
||||
extension
|
||||
.AddInstructionOrExpressionGroupMetadata(
|
||||
_("Game window and resolution"))
|
||||
.SetIcon("res/actions/window24.png");
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
@@ -28,7 +32,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
_("De/activate fullscreen"),
|
||||
_("This action activates or deactivates fullscreen."),
|
||||
_("Activate fullscreen: _PARAM1_ (keep aspect ratio: _PARAM2_)"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/fullscreen24.png",
|
||||
"res/actions/fullscreen.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -44,7 +48,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
_("Fullscreen activated?"),
|
||||
_("Check if the game is currently in fullscreen."),
|
||||
_("The game is in fullscreen"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/fullscreen24.png",
|
||||
"res/actions/fullscreen.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
@@ -56,7 +60,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"game frame and the window borders."),
|
||||
_("Set margins of game window to "
|
||||
"_PARAM1_;_PARAM2_;_PARAM3_;_PARAM4_"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -72,7 +76,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"the game area size. This won't change the size of the "
|
||||
"window in which the game is running."),
|
||||
_("Set game resolution to _PARAM1_x_PARAM2_"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -89,7 +93,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"window size. Game resolution can still be updated."),
|
||||
_("Set game window size to _PARAM1_x_PARAM2_ (also update game "
|
||||
"resolution: _PARAM3_)"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -106,7 +110,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"only works on Windows, macOS and Linux (not when the game "
|
||||
"is executed in a web-browser or on iOS/Android)."),
|
||||
_("Center the game window"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
@@ -118,7 +122,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"should be changed to fit the game window - or if the game "
|
||||
"resolution should not be updated automatically."),
|
||||
_("Set game resolution resize mode to _PARAM1_"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -139,7 +143,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"be the case if the game resolution resize mode is "
|
||||
"configured to adapt the width or the height of the game."),
|
||||
_("Automatically adapt the game resolution: _PARAM1_"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -152,7 +156,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
_("Change the window's icon"),
|
||||
_("This action changes the icon of the game's window."),
|
||||
_("Use _PARAM1_ as the icon for the game's window."),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -163,7 +167,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
_("Change the window's title"),
|
||||
_("This action changes the title of the game's window."),
|
||||
_("Change window title to _PARAM1_"),
|
||||
_("Game's window and resolution"),
|
||||
"",
|
||||
"res/actions/window24.png",
|
||||
"res/actions/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
@@ -174,7 +178,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"SceneWindowWidth",
|
||||
_("Width of the scene window"),
|
||||
_("Width of the scene window (or scene canvas for HTML5 games)"),
|
||||
_("Screen"),
|
||||
"",
|
||||
"res/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
@@ -183,7 +187,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"SceneWindowHeight",
|
||||
_("Height of the scene window"),
|
||||
_("Height of the scene window (or scene canvas for HTML5 games)"),
|
||||
_("Screen"),
|
||||
"",
|
||||
"res/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
|
||||
@@ -191,27 +195,27 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"ScreenWidth",
|
||||
_("Width of the screen/page"),
|
||||
_("Width of the screen (or the page for HTML5 games in browser)"),
|
||||
_("Screen"),
|
||||
"",
|
||||
"res/display16.png");
|
||||
|
||||
extension.AddExpression(
|
||||
"ScreenHeight",
|
||||
_("Height of the screen/page"),
|
||||
_("Height of the screen (or the page for HTML5 games in browser)"),
|
||||
_("Screen"),
|
||||
"",
|
||||
"res/display16.png");
|
||||
|
||||
extension.AddExpression("ColorDepth",
|
||||
_("Color depth"),
|
||||
_("Color depth"),
|
||||
_("Screen"),
|
||||
"",
|
||||
"res/display16.png");
|
||||
|
||||
extension
|
||||
.AddStrExpression("WindowTitle",
|
||||
_("Window's title"),
|
||||
_("Window's title"),
|
||||
_("Screen"),
|
||||
"",
|
||||
"res/window.png")
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
}
|
||||
|
@@ -234,6 +234,40 @@ BehaviorMetadata::AddExpressionAndConditionAndAction(
|
||||
const gd::String& sentenceName,
|
||||
const gd::String& group,
|
||||
const gd::String& icon) {
|
||||
if (type != "number" && type != "string" && type != "boolean") {
|
||||
gd::LogError(
|
||||
"Unrecognised type passed to AddExpressionAndConditionAndAction: " +
|
||||
type + ". Verify this type is valid and supported.");
|
||||
}
|
||||
|
||||
gd::String conditionDescriptionTemplate =
|
||||
type == "boolean" ? _("Check if <subject>.") : _("Compare <subject>.");
|
||||
auto& condition =
|
||||
AddScopedCondition(name,
|
||||
fullname,
|
||||
conditionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
sentenceName,
|
||||
group,
|
||||
icon,
|
||||
icon);
|
||||
|
||||
gd::String actionDescriptionTemplate = type == "boolean"
|
||||
? _("Set (or unset) if <subject>.")
|
||||
: _("Change <subject>.");
|
||||
auto& action = AddScopedAction(
|
||||
"Set" + name,
|
||||
fullname,
|
||||
actionDescriptionTemplate.FindAndReplace("<subject>", descriptionSubject),
|
||||
sentenceName,
|
||||
group,
|
||||
icon,
|
||||
icon);
|
||||
|
||||
if (type == "boolean") {
|
||||
return MultipleInstructionMetadata::WithConditionAndAction(condition, action);
|
||||
}
|
||||
|
||||
gd::String expressionDescriptionTemplate = _("Return <subject>.");
|
||||
auto& expression =
|
||||
type == "number"
|
||||
@@ -250,27 +284,6 @@ BehaviorMetadata::AddExpressionAndConditionAndAction(
|
||||
group,
|
||||
icon);
|
||||
|
||||
gd::String conditionDescriptionTemplate = _("Compare <subject>.");
|
||||
auto& condition =
|
||||
AddScopedCondition(name,
|
||||
fullname,
|
||||
conditionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
sentenceName,
|
||||
group,
|
||||
icon,
|
||||
icon);
|
||||
|
||||
gd::String actionDescriptionTemplate = _("Change <subject>.");
|
||||
auto& action = AddScopedAction(
|
||||
"Set" + name,
|
||||
fullname,
|
||||
actionDescriptionTemplate.FindAndReplace("<subject>", descriptionSubject),
|
||||
sentenceName,
|
||||
group,
|
||||
icon,
|
||||
icon);
|
||||
|
||||
return MultipleInstructionMetadata::WithExpressionAndConditionAndAction(
|
||||
expression, condition, action);
|
||||
}
|
||||
|
@@ -250,6 +250,27 @@ class GD_CORE_API BehaviorMetadata {
|
||||
return sharedDatasInstance.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return a reference to a map containing the names of the actions
|
||||
* (as keys) and the metadata associated with (as values).
|
||||
*/
|
||||
std::map<gd::String, gd::InstructionMetadata>& GetAllActions() { return actionsInfos; };
|
||||
|
||||
/**
|
||||
* \see gd::PlatformExtension::GetAllActions
|
||||
*/
|
||||
std::map<gd::String, gd::InstructionMetadata>& GetAllConditions() { return conditionsInfos; };
|
||||
|
||||
/**
|
||||
* \see gd::PlatformExtension::GetAllActions
|
||||
*/
|
||||
std::map<gd::String, gd::ExpressionMetadata>& GetAllExpressions() { return expressionsInfos; };
|
||||
|
||||
/**
|
||||
* \see gd::PlatformExtension::GetAllActions
|
||||
*/
|
||||
std::map<gd::String, gd::ExpressionMetadata>& GetAllStrExpressions() { return strExpressionsInfos; };
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
std::map<gd::String, gd::InstructionMetadata> conditionsInfos;
|
||||
std::map<gd::String, gd::InstructionMetadata> actionsInfos;
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/String.h"
|
||||
|
@@ -72,4 +72,11 @@ gd::ExpressionMetadata& ExpressionMetadata::AddCodeOnlyParameter(
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
gd::ExpressionMetadata& ExpressionMetadata::SetRequiresBaseObjectCapability(
|
||||
const gd::String& capability) {
|
||||
requiredBaseObjectCapability = capability;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -222,6 +222,23 @@ class GD_CORE_API ExpressionMetadata {
|
||||
return *this;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Mark this (object) expression as requiring the specified capability,
|
||||
* offered by the base object.
|
||||
* This is useful for some objects that don't support this capability, so that
|
||||
* the editor can hide the expression as it does not apply to them.
|
||||
*/
|
||||
ExpressionMetadata& SetRequiresBaseObjectCapability(
|
||||
const gd::String& capability);
|
||||
|
||||
/**
|
||||
* \brief Get the required specified capability for this (object) expression,
|
||||
* or an empty string if there is nothing specific required.
|
||||
*/
|
||||
const gd::String& GetRequiredBaseObjectCapability() const {
|
||||
return requiredBaseObjectCapability;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Set the function that should be called when generating the source
|
||||
* code from events.
|
||||
@@ -273,6 +290,7 @@ class GD_CORE_API ExpressionMetadata {
|
||||
gd::String smallIconFilename;
|
||||
gd::String extensionNamespace;
|
||||
bool isPrivate;
|
||||
gd::String requiredBaseObjectCapability;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/Tools/Log.h"
|
||||
#include "ParameterMetadata.h"
|
||||
|
||||
namespace gd {
|
||||
@@ -21,6 +22,7 @@ InstructionMetadata::InstructionMetadata()
|
||||
canHaveSubInstructions(false),
|
||||
hidden(true),
|
||||
usageComplexity(5),
|
||||
isAsync(false),
|
||||
isPrivate(false),
|
||||
isObjectInstruction(false),
|
||||
isBehaviorInstruction(false) {}
|
||||
@@ -44,6 +46,7 @@ InstructionMetadata::InstructionMetadata(const gd::String& extensionNamespace_,
|
||||
extensionNamespace(extensionNamespace_),
|
||||
hidden(false),
|
||||
usageComplexity(5),
|
||||
isAsync(false),
|
||||
isPrivate(false),
|
||||
isObjectInstruction(false),
|
||||
isBehaviorInstruction(false) {}
|
||||
@@ -66,8 +69,9 @@ InstructionMetadata& InstructionMetadata::AddParameter(
|
||||
? (supplementaryInformation.empty()
|
||||
? ""
|
||||
: extensionNamespace +
|
||||
supplementaryInformation //... so prefix it with the extension
|
||||
// namespace.
|
||||
supplementaryInformation //... so prefix it with the
|
||||
// extension
|
||||
// namespace.
|
||||
)
|
||||
: supplementaryInformation; // Otherwise don't change anything
|
||||
|
||||
@@ -93,32 +97,55 @@ InstructionMetadata& InstructionMetadata::UseStandardOperatorParameters(
|
||||
const gd::String& type) {
|
||||
SetManipulatedType(type);
|
||||
|
||||
AddParameter("operator", _("Modification's sign"), type);
|
||||
AddParameter(type == "number" ? "expression" : type, _("Value"));
|
||||
size_t operatorParamIndex = parameters.size() - 2;
|
||||
size_t valueParamIndex = parameters.size() - 1;
|
||||
if (type == "boolean") {
|
||||
AddParameter("yesorno", _("New value"));
|
||||
size_t valueParamIndex = parameters.size() - 1;
|
||||
|
||||
if (isObjectInstruction || isBehaviorInstruction) {
|
||||
gd::String templateSentence =
|
||||
_("Change <subject> of _PARAM0_: <operator> <value>");
|
||||
if (isObjectInstruction || isBehaviorInstruction) {
|
||||
gd::String templateSentence = _("Set _PARAM0_ as <subject>: <value>");
|
||||
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace(
|
||||
"<operator>",
|
||||
"_PARAM" + gd::String::From(operatorParamIndex) + "_")
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
sentence =
|
||||
templateSentence
|
||||
.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
} else {
|
||||
gd::String templateSentence = _("Change <subject>: <value>");
|
||||
|
||||
sentence =
|
||||
templateSentence
|
||||
.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
}
|
||||
} else {
|
||||
gd::String templateSentence = _("Change <subject>: <operator> <value>");
|
||||
AddParameter("operator", _("Modification's sign"), type);
|
||||
AddParameter(type == "number" ? "expression" : type, _("Value"));
|
||||
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace(
|
||||
"<operator>",
|
||||
"_PARAM" + gd::String::From(operatorParamIndex) + "_")
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
size_t operatorParamIndex = parameters.size() - 2;
|
||||
size_t valueParamIndex = parameters.size() - 1;
|
||||
|
||||
if (isObjectInstruction || isBehaviorInstruction) {
|
||||
gd::String templateSentence = _("Change <subject> of _PARAM0_: <operator> <value>");
|
||||
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace(
|
||||
"<operator>",
|
||||
"_PARAM" + gd::String::From(operatorParamIndex) + "_")
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
} else {
|
||||
gd::String templateSentence = _("Change <subject>: <operator> <value>");
|
||||
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace(
|
||||
"<operator>",
|
||||
"_PARAM" + gd::String::From(operatorParamIndex) + "_")
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -129,34 +156,62 @@ InstructionMetadata::UseStandardRelationalOperatorParameters(
|
||||
const gd::String& type) {
|
||||
SetManipulatedType(type);
|
||||
|
||||
AddParameter("relationalOperator", _("Sign of the test"), type);
|
||||
AddParameter(type == "number" ? "expression" : type, _("Value to compare"));
|
||||
size_t operatorParamIndex = parameters.size() - 2;
|
||||
size_t valueParamIndex = parameters.size() - 1;
|
||||
if (type == "boolean") {
|
||||
if (isObjectInstruction || isBehaviorInstruction) {
|
||||
gd::String templateSentence = _("_PARAM0_ is <subject>");
|
||||
|
||||
if (isObjectInstruction || isBehaviorInstruction) {
|
||||
gd::String templateSentence = _("<subject> of _PARAM0_ <operator> <value>");
|
||||
sentence =
|
||||
templateSentence
|
||||
.FindAndReplace("<subject>", sentence);
|
||||
} else {
|
||||
gd::String templateSentence = _("<subject>");
|
||||
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace(
|
||||
"<operator>",
|
||||
"_PARAM" + gd::String::From(operatorParamIndex) + "_")
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence);
|
||||
}
|
||||
} else {
|
||||
gd::String templateSentence = _("<subject> <operator> <value>");
|
||||
AddParameter("relationalOperator", _("Sign of the test"), type);
|
||||
AddParameter(type == "number" ? "expression" : type, _("Value to compare"));
|
||||
size_t operatorParamIndex = parameters.size() - 2;
|
||||
size_t valueParamIndex = parameters.size() - 1;
|
||||
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace(
|
||||
"<operator>",
|
||||
"_PARAM" + gd::String::From(operatorParamIndex) + "_")
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
if (isObjectInstruction || isBehaviorInstruction) {
|
||||
gd::String templateSentence = _("<subject> of _PARAM0_ <operator> <value>");
|
||||
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace(
|
||||
"<operator>",
|
||||
"_PARAM" + gd::String::From(operatorParamIndex) + "_")
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
} else {
|
||||
gd::String templateSentence = _("<subject> <operator> <value>");
|
||||
|
||||
sentence =
|
||||
templateSentence.FindAndReplace("<subject>", sentence)
|
||||
.FindAndReplace(
|
||||
"<operator>",
|
||||
"_PARAM" + gd::String::From(operatorParamIndex) + "_")
|
||||
.FindAndReplace("<value>",
|
||||
"_PARAM" + gd::String::From(valueParamIndex) + "_");
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
InstructionMetadata& InstructionMetadata::SetRequiresBaseObjectCapability(
|
||||
const gd::String& capability) {
|
||||
if (!IsObjectInstruction() && !IsBehaviorInstruction()) {
|
||||
gd::LogError("Tried to add capability \"" + capability +
|
||||
"\" to instruction named \"" + fullname +
|
||||
"\", which is not an object or behavior instruction.");
|
||||
return *this;
|
||||
}
|
||||
|
||||
requiredBaseObjectCapability = capability;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/String.h"
|
||||
@@ -98,6 +99,23 @@ class GD_CORE_API InstructionMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction is asynchronous - it will be running in the
|
||||
* background, executing the instructions following it before the frame after
|
||||
* it resolved.
|
||||
*/
|
||||
bool IsAsync() const { return isAsync; }
|
||||
|
||||
/**
|
||||
* Set that the instruction is asynchronous - it will be running in the
|
||||
* background, executing the instructions following it before the frame after
|
||||
* it resolved.
|
||||
*/
|
||||
InstructionMetadata &SetAsync() {
|
||||
isAsync = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify that the instruction can have sub instructions.
|
||||
*/
|
||||
@@ -138,18 +156,19 @@ class GD_CORE_API InstructionMetadata {
|
||||
* \param description Description for parameter
|
||||
* \param supplementaryInformation Additional information that can be used for
|
||||
* 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
|
||||
* otherwise.
|
||||
* - 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 otherwise.
|
||||
*
|
||||
* \see EventsCodeGenerator::GenerateParametersCodes
|
||||
*/
|
||||
InstructionMetadata &AddParameter(const gd::String &type,
|
||||
const gd::String &label,
|
||||
const gd::String &supplementaryInformation = "",
|
||||
bool parameterIsOptional = false);
|
||||
InstructionMetadata &AddParameter(
|
||||
const gd::String &type,
|
||||
const gd::String &label,
|
||||
const gd::String &supplementaryInformation = "",
|
||||
bool parameterIsOptional = false);
|
||||
|
||||
/**
|
||||
* \brief Add a parameter not displayed in editor.
|
||||
@@ -197,8 +216,7 @@ class GD_CORE_API InstructionMetadata {
|
||||
* \see AddParameter
|
||||
*/
|
||||
InstructionMetadata &SetParameterExtraInfo(const gd::String &extraInfo) {
|
||||
if (!parameters.empty())
|
||||
parameters.back().SetExtraInfo(extraInfo);
|
||||
if (!parameters.empty()) parameters.back().SetExtraInfo(extraInfo);
|
||||
return *this;
|
||||
};
|
||||
|
||||
@@ -236,16 +254,29 @@ class GD_CORE_API InstructionMetadata {
|
||||
/**
|
||||
* \brief Check if the instruction is an object instruction.
|
||||
*/
|
||||
bool IsObjectInstruction() const {
|
||||
return isObjectInstruction;
|
||||
}
|
||||
bool IsObjectInstruction() const { return isObjectInstruction; }
|
||||
|
||||
/**
|
||||
* \brief Check if the instruction is a behavior instruction.
|
||||
*/
|
||||
bool IsBehaviorInstruction() const {
|
||||
return isBehaviorInstruction;
|
||||
}
|
||||
bool IsBehaviorInstruction() const { return isBehaviorInstruction; }
|
||||
|
||||
/**
|
||||
* \brief Mark this (object) instruction as requiring the specified
|
||||
* capability, offered by the base object. This is useful for some objects
|
||||
* that don't support this capability, so that the editor can hide the
|
||||
* instruction as it does not apply to them.
|
||||
*/
|
||||
InstructionMetadata &SetRequiresBaseObjectCapability(
|
||||
const gd::String &capability);
|
||||
|
||||
/**
|
||||
* \brief Get the required specified capability for this (object) instruction,
|
||||
* or an empty string if there is nothing specific required.
|
||||
*/
|
||||
const gd::String &GetRequiredBaseObjectCapability() const {
|
||||
return requiredBaseObjectCapability;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Consider that the instruction is easy for a user to understand.
|
||||
@@ -448,8 +479,10 @@ class GD_CORE_API InstructionMetadata {
|
||||
int usageComplexity; ///< Evaluate the instruction from 0 (simple&easy to
|
||||
///< use) to 10 (complex to understand)
|
||||
bool isPrivate;
|
||||
bool isAsync;
|
||||
bool isObjectInstruction;
|
||||
bool isBehaviorInstruction;
|
||||
gd::String requiredBaseObjectCapability;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2022 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
/**
|
||||
* \brief Contains information about how to display a group of instructions
|
||||
* to the user.
|
||||
*/
|
||||
class GD_CORE_API InstructionOrExpressionGroupMetadata {
|
||||
public:
|
||||
InstructionOrExpressionGroupMetadata(){};
|
||||
|
||||
/**
|
||||
* \brief Sets the icon shown to users.
|
||||
*/
|
||||
InstructionOrExpressionGroupMetadata& SetIcon(const gd::String& icon_) {
|
||||
icon = icon_;
|
||||
return *this;
|
||||
};
|
||||
|
||||
const gd::String& GetIcon() const { return icon; };
|
||||
|
||||
private:
|
||||
gd::String icon;
|
||||
};
|
||||
} // namespace gd
|
@@ -31,6 +31,11 @@ class GD_CORE_API MultipleInstructionMetadata {
|
||||
gd::InstructionMetadata &action) {
|
||||
return MultipleInstructionMetadata(expression, condition, action);
|
||||
}
|
||||
static MultipleInstructionMetadata WithConditionAndAction(
|
||||
gd::InstructionMetadata &condition,
|
||||
gd::InstructionMetadata &action) {
|
||||
return MultipleInstructionMetadata(condition, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::AddParameter
|
||||
@@ -96,6 +101,17 @@ class GD_CORE_API MultipleInstructionMetadata {
|
||||
return *this;
|
||||
};
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::SetRequiresBaseObjectCapability
|
||||
*/
|
||||
MultipleInstructionMetadata &SetRequiresBaseObjectCapability(
|
||||
const gd::String &capability) {
|
||||
if (expression) expression->SetRequiresBaseObjectCapability(capability);
|
||||
if (condition) condition->SetRequiresBaseObjectCapability(capability);
|
||||
if (action) action->SetRequiresBaseObjectCapability(capability);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::UseStandardOperatorParameters
|
||||
* \see gd::InstructionMetadata::UseStandardRelationalOperatorParameters
|
||||
@@ -179,6 +195,9 @@ class GD_CORE_API MultipleInstructionMetadata {
|
||||
gd::InstructionMetadata &condition_,
|
||||
gd::InstructionMetadata &action_)
|
||||
: expression(&expression_), condition(&condition_), action(&action_){};
|
||||
MultipleInstructionMetadata(gd::InstructionMetadata &condition_,
|
||||
gd::InstructionMetadata &action_)
|
||||
: expression(nullptr), condition(&condition_), action(&action_){};
|
||||
|
||||
gd::ExpressionMetadata *expression;
|
||||
gd::InstructionMetadata *condition;
|
||||
|
@@ -261,23 +261,14 @@ ObjectMetadata::AddExpressionAndConditionAndAction(
|
||||
const gd::String& sentenceName,
|
||||
const gd::String& group,
|
||||
const gd::String& icon) {
|
||||
gd::String expressionDescriptionTemplate = _("Return <subject>.");
|
||||
auto& expression =
|
||||
type == "number"
|
||||
? AddExpression(name,
|
||||
fullname,
|
||||
expressionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
group,
|
||||
icon)
|
||||
: AddStrExpression(name,
|
||||
fullname,
|
||||
expressionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
group,
|
||||
icon);
|
||||
if (type != "number" && type != "string" && type != "boolean") {
|
||||
gd::LogError(
|
||||
"Unrecognised type passed to AddExpressionAndConditionAndAction: " +
|
||||
type + ". Verify this type is valid and supported.");
|
||||
}
|
||||
|
||||
gd::String conditionDescriptionTemplate = _("Compare <subject>.");
|
||||
gd::String conditionDescriptionTemplate =
|
||||
type == "boolean" ? _("Check if <subject>.") : _("Compare <subject>.");
|
||||
auto& condition =
|
||||
AddScopedCondition(name,
|
||||
fullname,
|
||||
@@ -288,7 +279,9 @@ ObjectMetadata::AddExpressionAndConditionAndAction(
|
||||
icon,
|
||||
icon);
|
||||
|
||||
gd::String actionDescriptionTemplate = _("Change <subject>.");
|
||||
gd::String actionDescriptionTemplate = type == "boolean"
|
||||
? _("Set (or unset) if <subject>.")
|
||||
: _("Change <subject>.");
|
||||
auto& action = AddScopedAction(
|
||||
"Set" + name,
|
||||
fullname,
|
||||
@@ -298,6 +291,27 @@ ObjectMetadata::AddExpressionAndConditionAndAction(
|
||||
icon,
|
||||
icon);
|
||||
|
||||
|
||||
if (type == "boolean") {
|
||||
return MultipleInstructionMetadata::WithConditionAndAction(condition, action);
|
||||
}
|
||||
|
||||
gd::String expressionDescriptionTemplate = _("Return <subject>.");
|
||||
auto& expression =
|
||||
type == "number"
|
||||
? AddExpression(name,
|
||||
fullname,
|
||||
expressionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
group,
|
||||
icon)
|
||||
: AddStrExpression(name,
|
||||
fullname,
|
||||
expressionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
group,
|
||||
icon);
|
||||
|
||||
return MultipleInstructionMetadata::WithExpressionAndConditionAndAction(
|
||||
expression, condition, action);
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#define OBJECTMETADATA_H
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
|
||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||
@@ -209,6 +210,33 @@ class GD_CORE_API ObjectMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief The "capabilities" that are offered by the base object that are
|
||||
* *not* supported by this object, and should be hidden in the editor
|
||||
* inferface.
|
||||
*/
|
||||
const std::set<gd::String>& GetUnsupportedBaseObjectCapabilities() const {
|
||||
return unsupportedBaseObjectCapabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Add a "capability" that is offered by the base object that is *not*
|
||||
* supported by this object, and should be hidden in the editor inferface.
|
||||
*/
|
||||
ObjectMetadata& AddUnsupportedBaseObjectCapability(
|
||||
const gd::String& capability) {
|
||||
unsupportedBaseObjectCapabilities.insert(capability);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check if a "capability" that is offered by the base object is *not*
|
||||
* supported by this object, and should be hidden in the editor inferface.
|
||||
*/
|
||||
bool IsUnsupportedBaseObjectCapability(const gd::String& capability) const {
|
||||
return unsupportedBaseObjectCapabilities.find(capability) != unsupportedBaseObjectCapabilities.end();
|
||||
}
|
||||
|
||||
const gd::String& GetName() const { return name; }
|
||||
const gd::String& GetFullName() const { return fullname; }
|
||||
const gd::String& GetCategoryFullName() const { return categoryFullName; }
|
||||
@@ -235,6 +263,27 @@ class GD_CORE_API ObjectMetadata {
|
||||
*/
|
||||
ObjectMetadata& AddIncludeFile(const gd::String& includeFile);
|
||||
|
||||
/**
|
||||
* \brief Return a reference to a map containing the names of the actions
|
||||
* (as keys) and the metadata associated with (as values).
|
||||
*/
|
||||
std::map<gd::String, gd::InstructionMetadata>& GetAllActions() { return actionsInfos; };
|
||||
|
||||
/**
|
||||
* \see gd::PlatformExtension::GetAllActions
|
||||
*/
|
||||
std::map<gd::String, gd::InstructionMetadata>& GetAllConditions() { return conditionsInfos; };
|
||||
|
||||
/**
|
||||
* \see gd::PlatformExtension::GetAllActions
|
||||
*/
|
||||
std::map<gd::String, gd::ExpressionMetadata>& GetAllExpressions() { return expressionsInfos; };
|
||||
|
||||
/**
|
||||
* \see gd::PlatformExtension::GetAllActions
|
||||
*/
|
||||
std::map<gd::String, gd::ExpressionMetadata>& GetAllStrExpressions() { return strExpressionsInfos; };
|
||||
|
||||
std::map<gd::String, gd::InstructionMetadata> conditionsInfos;
|
||||
std::map<gd::String, gd::InstructionMetadata> actionsInfos;
|
||||
std::map<gd::String, gd::ExpressionMetadata> expressionsInfos;
|
||||
@@ -253,6 +302,8 @@ class GD_CORE_API ObjectMetadata {
|
||||
gd::String description;
|
||||
gd::String iconFilename;
|
||||
gd::String categoryFullName;
|
||||
std::set<gd::String> unsupportedBaseObjectCapabilities;
|
||||
|
||||
std::shared_ptr<gd::Object>
|
||||
blueprintObject; ///< The "blueprint" object to be copied when a new
|
||||
///< object is asked. Can be null in case a creation
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class Project;
|
||||
@@ -151,15 +152,16 @@ class GD_CORE_API ParameterMetadata {
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return true if the type of the parameter is "object", "objectPtr" or
|
||||
* "objectList".
|
||||
* \brief Return true if the type of the parameter is representing one object
|
||||
* (or more, i.e: an object group).
|
||||
*
|
||||
* \see gd::ParameterMetadata::GetType
|
||||
*/
|
||||
static bool IsObject(const gd::String ¶meterType) {
|
||||
return parameterType == "object" || parameterType == "objectPtr" ||
|
||||
parameterType == "objectList" ||
|
||||
parameterType == "objectListWithoutPicking";
|
||||
parameterType == "objectListOrEmptyIfJustDeclared" ||
|
||||
parameterType == "objectListOrEmptyWithoutPicking";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +197,9 @@ class GD_CORE_API ParameterMetadata {
|
||||
parameterType == "objectEffectParameterName" ||
|
||||
parameterType == "objectPointName" ||
|
||||
parameterType == "objectAnimationName" ||
|
||||
parameterType == "functionParameterName";
|
||||
parameterType == "functionParameterName" ||
|
||||
parameterType == "externalLayoutName" ||
|
||||
parameterType == "leaderboardId";
|
||||
} else if (type == "variable") {
|
||||
return parameterType == "objectvar" || parameterType == "globalvar" ||
|
||||
parameterType == "scenevar";
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "Platform.h"
|
||||
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
#include "GDCore/String.h"
|
||||
@@ -14,16 +15,21 @@ using namespace std;
|
||||
|
||||
namespace gd {
|
||||
|
||||
Platform::Platform(): enableExtensionLoadingLogs(false) {}
|
||||
InstructionOrExpressionGroupMetadata
|
||||
Platform::badInstructionOrExpressionGroupMetadata;
|
||||
|
||||
Platform::Platform() : enableExtensionLoadingLogs(false) {}
|
||||
|
||||
Platform::~Platform() {}
|
||||
|
||||
bool Platform::AddExtension(std::shared_ptr<gd::PlatformExtension> extension) {
|
||||
if (!extension) return false;
|
||||
|
||||
if (enableExtensionLoadingLogs) std::cout << "Loading " << extension->GetName() << "...";
|
||||
if (enableExtensionLoadingLogs)
|
||||
std::cout << "Loading " << extension->GetName() << "...";
|
||||
if (IsExtensionLoaded(extension->GetName())) {
|
||||
if (enableExtensionLoadingLogs) std::cout << " (replacing existing extension)";
|
||||
if (enableExtensionLoadingLogs)
|
||||
std::cout << " (replacing existing extension)";
|
||||
RemoveExtension(extension->GetName());
|
||||
}
|
||||
if (enableExtensionLoadingLogs) std::cout << std::endl;
|
||||
@@ -38,6 +44,11 @@ bool Platform::AddExtension(std::shared_ptr<gd::PlatformExtension> extension) {
|
||||
extension->GetObjectCreationFunctionPtr(objectsTypes[i]);
|
||||
}
|
||||
|
||||
for (const auto& it :
|
||||
extension->GetAllInstructionOrExpressionGroupMetadata()) {
|
||||
instructionOrExpressionGroupMetadata[it.first] = it.second;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -9,8 +9,9 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/String.h"
|
||||
|
||||
#include "GDCore/Extensions/Metadata/InstructionOrExpressionGroupMetadata.h"
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class InstructionsMetadataHolder;
|
||||
class Project;
|
||||
@@ -52,7 +53,6 @@ class GD_CORE_API Platform {
|
||||
*/
|
||||
virtual gd::String GetFullName() const { return "Unnamed platform"; }
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* \brief Must return a text describing the platform in a few words.
|
||||
*/
|
||||
@@ -67,7 +67,6 @@ class GD_CORE_API Platform {
|
||||
* \brief Must return a filename to a 32*32 image file for the platform.
|
||||
*/
|
||||
virtual gd::String GetIcon() const { return ""; }
|
||||
#endif
|
||||
|
||||
/** \name Extensions management
|
||||
* Member functions used to manage the extensions
|
||||
@@ -123,6 +122,19 @@ class GD_CORE_API Platform {
|
||||
* anymore.
|
||||
*/
|
||||
virtual void RemoveExtension(const gd::String& name);
|
||||
|
||||
/**
|
||||
* \brief Get the metadata (icon, etc...) of a group used for instructions or
|
||||
* expressions.
|
||||
*/
|
||||
const InstructionOrExpressionGroupMetadata& GetInstructionOrExpressionGroupMetadata(
|
||||
const gd::String& name) const {
|
||||
auto it = instructionOrExpressionGroupMetadata.find(name);
|
||||
if (it == instructionOrExpressionGroupMetadata.end())
|
||||
return badInstructionOrExpressionGroupMetadata;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
///@}
|
||||
|
||||
/** \name Factory method
|
||||
@@ -137,7 +149,6 @@ class GD_CORE_API Platform {
|
||||
std::unique_ptr<gd::Object> CreateObject(gd::String type,
|
||||
const gd::String& name) const;
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* \brief Create an event of given type
|
||||
*/
|
||||
@@ -149,28 +160,18 @@ class GD_CORE_API Platform {
|
||||
* \brief Activate or disable the logs on the standard output when
|
||||
* loading an extension.
|
||||
*/
|
||||
void EnableExtensionLoadingLogs(bool enable) { enableExtensionLoadingLogs = enable; };
|
||||
|
||||
/**
|
||||
* \brief Called when the IDE is about to shut down: Take this opportunity for
|
||||
* erasing for example any temporary file.
|
||||
* @deprecated This should be removed.
|
||||
*/
|
||||
virtual void OnIDEClosed(){};
|
||||
|
||||
/**
|
||||
* \brief Called when the IDE is initialized and ready to be used.
|
||||
* @deprecated This should be removed.
|
||||
*/
|
||||
virtual void OnIDEInitialized(){};
|
||||
|
||||
#endif
|
||||
void EnableExtensionLoadingLogs(bool enable) {
|
||||
enableExtensionLoadingLogs = enable;
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<PlatformExtension>>
|
||||
extensionsLoaded; ///< Extensions of the platform
|
||||
std::map<gd::String, CreateFunPtr>
|
||||
creationFunctionTable; ///< Creation functions for objects
|
||||
std::map<gd::String, InstructionOrExpressionGroupMetadata>
|
||||
instructionOrExpressionGroupMetadata;
|
||||
static InstructionOrExpressionGroupMetadata badInstructionOrExpressionGroupMetadata;
|
||||
bool enableExtensionLoadingLogs;
|
||||
};
|
||||
|
||||
|
@@ -165,6 +165,40 @@ PlatformExtension::AddExpressionAndConditionAndAction(
|
||||
const gd::String& sentenceName,
|
||||
const gd::String& group,
|
||||
const gd::String& icon) {
|
||||
if (type != "number" && type != "string" && type != "boolean") {
|
||||
gd::LogError(
|
||||
"Unrecognised type passed to AddExpressionAndConditionAndAction: " +
|
||||
type + ". Verify this type is valid and supported.");
|
||||
}
|
||||
|
||||
gd::String conditionDescriptionTemplate =
|
||||
type == "boolean" ? _("Check if <subject>.") : _("Compare <subject>.");
|
||||
auto& condition = AddCondition(name,
|
||||
fullname,
|
||||
conditionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
sentenceName,
|
||||
group,
|
||||
icon,
|
||||
icon);
|
||||
|
||||
gd::String actionDescriptionTemplate = type == "boolean"
|
||||
? _("Set (or unset) if <subject>.")
|
||||
: _("Change <subject>.");
|
||||
auto& action = AddAction(
|
||||
"Set" + name,
|
||||
fullname,
|
||||
actionDescriptionTemplate.FindAndReplace("<subject>", descriptionSubject),
|
||||
sentenceName,
|
||||
group,
|
||||
icon,
|
||||
icon);
|
||||
|
||||
if (type == "boolean") {
|
||||
return MultipleInstructionMetadata::WithConditionAndAction(condition,
|
||||
action);
|
||||
}
|
||||
|
||||
gd::String expressionDescriptionTemplate = _("Return <subject>.");
|
||||
auto& expression =
|
||||
type == "number"
|
||||
@@ -175,32 +209,11 @@ PlatformExtension::AddExpressionAndConditionAndAction(
|
||||
group,
|
||||
icon)
|
||||
: AddStrExpression(name,
|
||||
fullname,
|
||||
expressionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
group,
|
||||
icon);
|
||||
|
||||
gd::String conditionDescriptionTemplate = _("Compare <subject>.");
|
||||
auto& condition = AddCondition(name,
|
||||
fullname,
|
||||
conditionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
sentenceName,
|
||||
group,
|
||||
icon,
|
||||
icon);
|
||||
|
||||
// TODO: update the checks
|
||||
gd::String actionDescriptionTemplate = _("Change <subject>.");
|
||||
auto& action = AddAction(
|
||||
"Set" + name,
|
||||
fullname,
|
||||
actionDescriptionTemplate.FindAndReplace("<subject>", descriptionSubject),
|
||||
sentenceName,
|
||||
group,
|
||||
icon,
|
||||
icon);
|
||||
fullname,
|
||||
expressionDescriptionTemplate.FindAndReplace(
|
||||
"<subject>", descriptionSubject),
|
||||
group,
|
||||
icon);
|
||||
|
||||
return MultipleInstructionMetadata::WithExpressionAndConditionAndAction(
|
||||
expression, condition, action);
|
||||
@@ -372,9 +385,13 @@ gd::InstructionMetadata& PlatformExtension::AddDuplicatedAction(
|
||||
}
|
||||
|
||||
gd::InstructionMetadata& PlatformExtension::AddDuplicatedCondition(
|
||||
const gd::String& newConditionName, const gd::String& copiedConditionName) {
|
||||
gd::String newNameWithNamespace = GetNameSpace() + newConditionName;
|
||||
gd::String copiedNameWithNamespace = GetNameSpace() + copiedConditionName;
|
||||
const gd::String& newConditionName,
|
||||
const gd::String& copiedConditionName,
|
||||
gd::DuplicatedInstructionOptions options) {
|
||||
gd::String newNameWithNamespace =
|
||||
(options.unscoped ? "" : GetNameSpace()) + newConditionName;
|
||||
gd::String copiedNameWithNamespace =
|
||||
(options.unscoped ? "" : GetNameSpace()) + copiedConditionName;
|
||||
|
||||
auto copiedCondition = conditionsInfos.find(copiedNameWithNamespace);
|
||||
if (copiedCondition == conditionsInfos.end()) {
|
||||
@@ -512,7 +529,8 @@ PlatformExtension::GetAllStrExpressionsForBehavior(gd::String autoType) {
|
||||
return badExpressionsMetadata;
|
||||
}
|
||||
|
||||
gd::BaseEventSPtr PlatformExtension::CreateEvent(const gd::String& eventType) const {
|
||||
gd::BaseEventSPtr PlatformExtension::CreateEvent(
|
||||
const gd::String& eventType) const {
|
||||
if (eventsInfos.find(eventType) != eventsInfos.end()) {
|
||||
if (eventsInfos.find(eventType)->second.instance ==
|
||||
std::shared_ptr<BaseEvent>()) {
|
||||
@@ -754,7 +772,8 @@ void PlatformExtension::StripUnimplementedInstructionsAndExpressions() {
|
||||
}
|
||||
#endif
|
||||
|
||||
PlatformExtension::PlatformExtension() : deprecated(false) {}
|
||||
PlatformExtension::PlatformExtension()
|
||||
: deprecated(false), category(_("General")) {}
|
||||
|
||||
PlatformExtension::~PlatformExtension() {}
|
||||
|
||||
|
@@ -5,8 +5,7 @@
|
||||
* project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef GDCORE_PLATFORMEXTENSION_H
|
||||
#define GDCORE_PLATFORMEXTENSION_H
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -16,6 +15,7 @@
|
||||
#include "GDCore/Extensions/Metadata/DependencyMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/EffectMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/EventMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionOrExpressionGroupMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/ObjectMetadata.h"
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/String.h"
|
||||
@@ -71,6 +71,10 @@ class GD_CORE_API CompilationInfo {
|
||||
int sizeOfpInt;
|
||||
};
|
||||
|
||||
struct GD_CORE_API DuplicatedInstructionOptions {
|
||||
bool unscoped;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Base class for implementing platform's extensions.
|
||||
*
|
||||
@@ -105,10 +109,18 @@ class GD_CORE_API PlatformExtension {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set the category of the extension.
|
||||
*/
|
||||
PlatformExtension& SetCategory(const gd::String& category_) {
|
||||
category = category_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set the path to the help, relative to the GDevelop documentation
|
||||
* root. For example, "/all-features/collisions" for
|
||||
* "http://wiki.compilgames.net/doku.php/gdevelop5/all-features/collisions".
|
||||
* "https://wiki.gdevelop.io/gdevelop5/all-features/collisions".
|
||||
*
|
||||
* The instructions, objects and behaviors will have this help path set by
|
||||
* default, unless you call SetHelpPath on them.
|
||||
@@ -271,7 +283,6 @@ class GD_CORE_API PlatformExtension {
|
||||
const gd::String& smallicon_,
|
||||
std::shared_ptr<gd::BaseEvent> instance);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* \brief Create a new action which is the duplicate of the specified one.
|
||||
*
|
||||
@@ -288,7 +299,8 @@ class GD_CORE_API PlatformExtension {
|
||||
*/
|
||||
gd::InstructionMetadata& AddDuplicatedCondition(
|
||||
const gd::String& newConditionName,
|
||||
const gd::String& copiedConditionName);
|
||||
const gd::String& copiedConditionName,
|
||||
gd::DuplicatedInstructionOptions options = {.unscoped = false});
|
||||
/**
|
||||
* \brief Create a new expression which is the duplicate of the specified one.
|
||||
*
|
||||
@@ -315,7 +327,15 @@ class GD_CORE_API PlatformExtension {
|
||||
gd::PropertyDescriptor& RegisterProperty(const gd::String& name) {
|
||||
return extensionPropertiesMetadata[name];
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Add some metadata (icon, etc...) for a group used for instructions
|
||||
* or expressions.
|
||||
*/
|
||||
InstructionOrExpressionGroupMetadata& AddInstructionOrExpressionGroupMetadata(
|
||||
const gd::String& name) {
|
||||
return instructionOrExpressionGroupMetadata[name];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Delete all instructions having no function name or custom code
|
||||
@@ -339,6 +359,11 @@ class GD_CORE_API PlatformExtension {
|
||||
*/
|
||||
const gd::String& GetName() const { return name; }
|
||||
|
||||
/**
|
||||
* \brief Return the category of the extension
|
||||
*/
|
||||
const gd::String& GetCategory() const { return category; }
|
||||
|
||||
/**
|
||||
* \brief Return a description of the extension
|
||||
*/
|
||||
@@ -452,7 +477,6 @@ class GD_CORE_API PlatformExtension {
|
||||
*/
|
||||
std::map<gd::String, gd::EventMetadata>& GetAllEvents();
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* \brief Return a reference to a map containing the names of the actions
|
||||
* (as keys) and the metadata associated with (as values).
|
||||
@@ -537,8 +561,16 @@ class GD_CORE_API PlatformExtension {
|
||||
std::map<gd::String, gd::PropertyDescriptor>& GetAllProperties() {
|
||||
return extensionPropertiesMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get the metadata (icon, etc...) for groups used for instructions
|
||||
* or expressions.
|
||||
*/
|
||||
const std::map<gd::String, InstructionOrExpressionGroupMetadata>&
|
||||
GetAllInstructionOrExpressionGroupMetadata() const {
|
||||
return instructionOrExpressionGroupMetadata;
|
||||
}
|
||||
///@}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Return the name of all the extensions which are considered provided
|
||||
@@ -566,6 +598,7 @@ class GD_CORE_API PlatformExtension {
|
||||
///< actions/conditions/expressions/objects/behavior/event.
|
||||
gd::String fullname; ///< Name displayed to users in the editor.
|
||||
gd::String informations; ///< Description displayed to users in the editor.
|
||||
gd::String category;
|
||||
gd::String author; ///< Author displayed to users in the editor.
|
||||
gd::String license; ///< License name displayed to users in the editor.
|
||||
bool deprecated; ///< true if the extension is deprecated and shouldn't be
|
||||
@@ -577,7 +610,6 @@ class GD_CORE_API PlatformExtension {
|
||||
std::map<gd::String, gd::ObjectMetadata> objectsInfos;
|
||||
std::map<gd::String, gd::BehaviorMetadata> behaviorsInfo;
|
||||
std::map<gd::String, gd::EffectMetadata> effectsMetadata;
|
||||
#if defined(GD_IDE_ONLY)
|
||||
std::map<gd::String, gd::InstructionMetadata> conditionsInfos;
|
||||
std::map<gd::String, gd::InstructionMetadata> actionsInfos;
|
||||
std::map<gd::String, gd::ExpressionMetadata> expressionsInfos;
|
||||
@@ -585,12 +617,12 @@ class GD_CORE_API PlatformExtension {
|
||||
std::vector<gd::DependencyMetadata> extensionDependenciesMetadata;
|
||||
std::map<gd::String, gd::EventMetadata> eventsInfos;
|
||||
std::map<gd::String, gd::PropertyDescriptor> extensionPropertiesMetadata;
|
||||
#endif
|
||||
std::map<gd::String, InstructionOrExpressionGroupMetadata>
|
||||
instructionOrExpressionGroupMetadata;
|
||||
|
||||
ObjectMetadata badObjectMetadata;
|
||||
BehaviorMetadata badBehaviorMetadata;
|
||||
EffectMetadata badEffectMetadata;
|
||||
#if defined(GD_IDE_ONLY)
|
||||
static std::map<gd::String, gd::InstructionMetadata>
|
||||
badConditionsMetadata; ///< Used when a condition is not found in the
|
||||
///< extension
|
||||
@@ -600,12 +632,10 @@ class GD_CORE_API PlatformExtension {
|
||||
static std::map<gd::String, gd::ExpressionMetadata>
|
||||
badExpressionsMetadata; ///< Used when an expression is not found in the
|
||||
///< extension
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/** \brief Macro used by extensions in their constructor to declare how they
|
||||
* have been compiled. \see gd::CompilationInfo
|
||||
*/
|
||||
@@ -619,23 +649,5 @@ class GD_CORE_API PlatformExtension {
|
||||
compilationInfo.gccMinorVersion = __GNUC_MINOR__; \
|
||||
compilationInfo.gccPatchLevel = __GNUC_PATCHLEVEL__; \
|
||||
compilationInfo.informationCompleted = true;
|
||||
#else
|
||||
/** \brief Macro used by extensions in their constructor to declare how they
|
||||
* have been compiled. \see gd::CompilationInfo
|
||||
*/
|
||||
#define GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION() \
|
||||
compilationInfo.runtimeOnly = true; \
|
||||
compilationInfo.sfmlMajorVersion = 2; \
|
||||
compilationInfo.sfmlMinorVersion = 0; \
|
||||
compilationInfo.gdCoreVersion = GD_VERSION_STRING; \
|
||||
compilationInfo.sizeOfpInt = sizeof(int*); \
|
||||
compilationInfo.gccMajorVersion = __GNUC__; \
|
||||
compilationInfo.gccMinorVersion = __GNUC_MINOR__; \
|
||||
compilationInfo.gccPatchLevel = __GNUC_PATCHLEVEL__; \
|
||||
compilationInfo.informationCompleted = true;
|
||||
|
||||
#endif
|
||||
|
||||
#include "GDCore/Extensions/PlatformExtension.inl"
|
||||
|
||||
#endif // GDCORE_PLATFORMEXTENSION_H
|
||||
|
27
Core/GDCore/IDE/Events/EventsPositionFinder.cpp
Normal file
27
Core/GDCore/IDE/Events/EventsPositionFinder.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "GDCore/IDE/Events/EventsPositionFinder.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Events/EventsList.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
class EventsList;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
bool EventsPositionFinder::DoVisitEvent(gd::BaseEvent& event) {
|
||||
auto it = std::find(searchedEvents.begin(), searchedEvents.end(), &event);
|
||||
if (it != searchedEvents.end()) {
|
||||
positions[it - searchedEvents.begin()] = index;
|
||||
}
|
||||
index++;
|
||||
return false;
|
||||
}
|
||||
EventsPositionFinder::~EventsPositionFinder() {}
|
||||
|
||||
} // namespace gd
|
48
Core/GDCore/IDE/Events/EventsPositionFinder.h
Normal file
48
Core/GDCore/IDE/Events/EventsPositionFinder.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef EventsPositionFinder_H
|
||||
#define EventsPositionFinder_H
|
||||
#include "GDCore/Events/EventsList.h"
|
||||
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class BaseEvent;
|
||||
class EventsList;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief Scans an event list to retrieve the position of a list of searched
|
||||
* events when the events list is flattened.
|
||||
*
|
||||
* \ingroup IDE
|
||||
*/
|
||||
class GD_CORE_API EventsPositionFinder : public ArbitraryEventsWorker {
|
||||
public:
|
||||
EventsPositionFinder() : index(0){};
|
||||
virtual ~EventsPositionFinder();
|
||||
|
||||
/**
|
||||
* Return the positions of all searched events
|
||||
*/
|
||||
const std::vector<std::size_t>& GetPositions() const { return positions; }
|
||||
|
||||
/**
|
||||
* Add an event for which the position must be reported in `GetPositions`.
|
||||
*/
|
||||
void AddEventToSearch(gd::BaseEvent* event) {
|
||||
searchedEvents.push_back(event);
|
||||
positions.push_back(gd::String::npos);
|
||||
}
|
||||
|
||||
private:
|
||||
bool DoVisitEvent(gd::BaseEvent& event) override;
|
||||
|
||||
std::vector<gd::BaseEvent*> searchedEvents;
|
||||
std::vector<std::size_t> positions;
|
||||
std::size_t index;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif // EventsPositionFinder_H
|
@@ -542,7 +542,8 @@ void EventsRefactorer::ReplaceStringInEvents(gd::ObjectsContainer& project,
|
||||
gd::String newString,
|
||||
bool matchCase,
|
||||
bool inConditions,
|
||||
bool inActions) {
|
||||
bool inActions,
|
||||
bool inEventStrings) {
|
||||
for (std::size_t i = 0; i < events.size(); ++i) {
|
||||
if (inConditions) {
|
||||
vector<gd::InstructionsList*> conditionsVectors =
|
||||
@@ -571,6 +572,11 @@ void EventsRefactorer::ReplaceStringInEvents(gd::ObjectsContainer& project,
|
||||
}
|
||||
}
|
||||
|
||||
if (inEventStrings) {
|
||||
bool eventStringModified = ReplaceStringInEventSearchableStrings(
|
||||
project, layout, events[i], toReplace, newString, matchCase);
|
||||
}
|
||||
|
||||
if (events[i].CanHaveSubEvents())
|
||||
ReplaceStringInEvents(project,
|
||||
layout,
|
||||
@@ -579,7 +585,8 @@ void EventsRefactorer::ReplaceStringInEvents(gd::ObjectsContainer& project,
|
||||
newString,
|
||||
matchCase,
|
||||
inConditions,
|
||||
inActions);
|
||||
inActions,
|
||||
inEventStrings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,6 +684,29 @@ bool EventsRefactorer::ReplaceStringInConditions(
|
||||
return somethingModified;
|
||||
}
|
||||
|
||||
bool EventsRefactorer::ReplaceStringInEventSearchableStrings(
|
||||
gd::ObjectsContainer& project,
|
||||
gd::ObjectsContainer& layout,
|
||||
gd::BaseEvent& event,
|
||||
gd::String toReplace,
|
||||
gd::String newString,
|
||||
bool matchCase) {
|
||||
vector<gd::String> newEventStrings;
|
||||
vector<gd::String> stringEvent = event.GetAllSearchableStrings();
|
||||
|
||||
for (std::size_t sNb = 0; sNb < stringEvent.size(); ++sNb) {
|
||||
gd::String newStringEvent =
|
||||
matchCase ? stringEvent[sNb].FindAndReplace(toReplace, newString, true)
|
||||
: ReplaceAllOccurencesCaseUnsensitive(
|
||||
stringEvent[sNb], toReplace, newString);
|
||||
newEventStrings.push_back(newStringEvent);
|
||||
}
|
||||
|
||||
bool somethingModified = event.ReplaceAllSearchableStrings(newEventStrings);
|
||||
|
||||
return somethingModified;
|
||||
}
|
||||
|
||||
vector<EventsSearchResult> EventsRefactorer::SearchInEvents(
|
||||
const gd::Platform& platform,
|
||||
gd::EventsList& events,
|
||||
|
@@ -117,7 +117,8 @@ class GD_CORE_API EventsRefactorer {
|
||||
gd::String newString,
|
||||
bool matchCase,
|
||||
bool inConditions,
|
||||
bool inActions);
|
||||
bool inActions,
|
||||
bool inEventString);
|
||||
|
||||
virtual ~EventsRefactorer(){};
|
||||
|
||||
@@ -208,6 +209,20 @@ class GD_CORE_API EventsRefactorer {
|
||||
gd::String newString,
|
||||
bool matchCase);
|
||||
|
||||
/**
|
||||
* Replace all occurrences of a gd::String in strings of events (for example:
|
||||
* comments and name of groups).
|
||||
*
|
||||
* \return true if something was modified.
|
||||
*/
|
||||
static bool ReplaceStringInEventSearchableStrings(
|
||||
gd::ObjectsContainer& project,
|
||||
gd::ObjectsContainer& layout,
|
||||
gd::BaseEvent& event,
|
||||
gd::String toReplace,
|
||||
gd::String newString,
|
||||
bool matchCase);
|
||||
|
||||
static bool SearchStringInFormattedText(const gd::Platform& platform,
|
||||
gd::Instruction& instruction,
|
||||
gd::String search,
|
||||
|
@@ -95,7 +95,7 @@ class GD_CORE_API ExpressionParameterMover
|
||||
// Move parameter of an object function
|
||||
const gd::String& thisObjectType = gd::GetTypeOfObject(
|
||||
globalObjectsContainer, objectsContainer, node.objectName);
|
||||
if (thisObjectType == behaviorType) {
|
||||
if (thisObjectType == objectType) {
|
||||
moveParameter(node.parameters);
|
||||
hasDoneMoving = true;
|
||||
}
|
||||
|
@@ -33,11 +33,4 @@ gd::Platform* PlatformManager::GetPlatform(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void PlatformManager::NotifyPlatformIDEInitialized() const {
|
||||
for (std::size_t i = 0; i < platformsLoaded.size(); ++i) {
|
||||
if (platformsLoaded[i] != std::shared_ptr<gd::Platform>())
|
||||
platformsLoaded[i]->OnIDEInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -43,12 +43,6 @@ class GD_CORE_API PlatformManager {
|
||||
return platformsLoaded;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Notify each platform that the IDE is ready, by calling their
|
||||
* OnIDEInitialized member function.
|
||||
*/
|
||||
void NotifyPlatformIDEInitialized() const;
|
||||
|
||||
static PlatformManager *Get() {
|
||||
if (NULL == _singleton) {
|
||||
_singleton = new PlatformManager;
|
||||
@@ -65,11 +59,6 @@ class GD_CORE_API PlatformManager {
|
||||
*/
|
||||
static void DestroySingleton() {
|
||||
if (NULL != _singleton) {
|
||||
for (std::size_t i = 0; i < _singleton->platformsLoaded.size(); ++i) {
|
||||
if (_singleton->platformsLoaded[i] != std::shared_ptr<gd::Platform>())
|
||||
_singleton->platformsLoaded[i]->OnIDEClosed();
|
||||
}
|
||||
|
||||
delete _singleton;
|
||||
_singleton = NULL;
|
||||
}
|
||||
|
@@ -117,6 +117,16 @@ void EffectsContainer::SwapEffects(std::size_t firstEffectIndex,
|
||||
effects[secondEffectIndex] = temp;
|
||||
}
|
||||
|
||||
void EffectsContainer::MoveEffect(std::size_t oldIndex, std::size_t newIndex) {
|
||||
if (oldIndex >= effects.size() || newIndex >= effects.size() ||
|
||||
newIndex == oldIndex)
|
||||
return;
|
||||
|
||||
auto effect = effects[oldIndex];
|
||||
effects.erase(effects.begin() + oldIndex);
|
||||
effects.insert(effects.begin() + newIndex, effect);
|
||||
}
|
||||
|
||||
void EffectsContainer::SerializeTo(SerializerElement& element) const {
|
||||
element.ConsiderAsArrayOf("effect");
|
||||
for (std::size_t i = 0; i < GetEffectsCount(); ++i) {
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#define GDCORE_EFFECTS_CONTAINER_H
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "GDCore/String.h"
|
||||
|
||||
@@ -89,6 +90,11 @@ class GD_CORE_API EffectsContainer {
|
||||
*/
|
||||
void RemoveEffect(const gd::String& name);
|
||||
|
||||
/**
|
||||
* \brief Move the specified effect at a new position in the list.
|
||||
*/
|
||||
void MoveEffect(std::size_t oldIndex, std::size_t newIndex);
|
||||
|
||||
/**
|
||||
* Swap the position of two effects.
|
||||
*/
|
||||
|
@@ -33,6 +33,7 @@ void EventsFunctionsExtension::Init(const gd::EventsFunctionsExtension& other) {
|
||||
description = other.description;
|
||||
name = other.name;
|
||||
fullName = other.fullName;
|
||||
category = other.category;
|
||||
tags = other.tags;
|
||||
author = other.author;
|
||||
authorIds = other.authorIds;
|
||||
@@ -50,6 +51,7 @@ void EventsFunctionsExtension::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("description", description);
|
||||
element.SetAttribute("name", name);
|
||||
element.SetAttribute("fullName", fullName);
|
||||
element.SetAttribute("category", category);
|
||||
if (!originName.empty() || !originIdentifier.empty()) {
|
||||
element.AddChild("origin")
|
||||
.SetAttribute("name", originName)
|
||||
@@ -87,6 +89,7 @@ void EventsFunctionsExtension::UnserializeFrom(
|
||||
description = element.GetStringAttribute("description");
|
||||
name = element.GetStringAttribute("name");
|
||||
fullName = element.GetStringAttribute("fullName");
|
||||
category = element.GetStringAttribute("category");
|
||||
author = element.GetStringAttribute("author");
|
||||
previewIconUrl = element.GetStringAttribute("previewIconUrl");
|
||||
iconUrl = element.GetStringAttribute("iconUrl");
|
||||
|
@@ -84,6 +84,12 @@ class GD_CORE_API EventsFunctionsExtension : public EventsFunctionsContainer {
|
||||
return *this;
|
||||
}
|
||||
|
||||
const gd::String& GetCategory() const { return category; };
|
||||
EventsFunctionsExtension& SetCategory(const gd::String& category_) {
|
||||
category = category_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::vector<gd::String>& GetTags() const { return tags; };
|
||||
std::vector<gd::String>& GetTags() { return tags; };
|
||||
|
||||
@@ -238,6 +244,7 @@ class GD_CORE_API EventsFunctionsExtension : public EventsFunctionsContainer {
|
||||
gd::String description;
|
||||
gd::String name;
|
||||
gd::String fullName;
|
||||
gd::String category;
|
||||
std::vector<gd::String> tags;
|
||||
std::vector<gd::String> authorIds;
|
||||
gd::String author;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
#ifndef GDCORE_OBJECT_H
|
||||
#define GDCORE_OBJECT_H
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include "GDCore/Vector2.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#ifndef GDCORE_OBJECTGROUPSCONTAINER_H
|
||||
#define GDCORE_OBJECTGROUPSCONTAINER_H
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "GDCore/Project/ObjectGroup.h"
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
@@ -77,7 +78,6 @@ class GD_CORE_API ObjectGroupsContainer {
|
||||
*/
|
||||
bool IsEmpty() const { return objectGroups.empty(); };
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* \brief return the position of the group called "name" in the group list
|
||||
*/
|
||||
@@ -107,7 +107,6 @@ class GD_CORE_API ObjectGroupsContainer {
|
||||
* \brief Move the specified group at a new position in the list.
|
||||
*/
|
||||
void Move(std::size_t oldIndex, std::size_t newIndex);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Clear all groups of the container.
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <SFML/System/Utf.hpp>
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
@@ -66,6 +65,9 @@ Project::Project()
|
||||
projectUuid(""),
|
||||
useDeprecatedZeroAsDefaultZOrder(false),
|
||||
useExternalSourceFiles(false),
|
||||
isPlayableWithKeyboard(false),
|
||||
isPlayableWithGamepad(false),
|
||||
isPlayableWithMobile(false),
|
||||
currentPlatform(NULL),
|
||||
gdMajorVersion(gd::VersionWrapper::Major()),
|
||||
gdMinorVersion(gd::VersionWrapper::Minor()),
|
||||
@@ -495,6 +497,7 @@ void Project::UnserializeFrom(const SerializerElement& element) {
|
||||
const SerializerElement& propElement =
|
||||
element.GetChild("properties", 0, "Info");
|
||||
SetName(propElement.GetChild("name", 0, "Nom").GetValue().GetString());
|
||||
SetDescription(propElement.GetChild("description", 0).GetValue().GetString());
|
||||
SetVersion(propElement.GetStringAttribute("version", "1.0.0"));
|
||||
SetGameResolutionSize(
|
||||
propElement.GetChild("windowWidth", 0, "WindowW").GetValue().GetInt(),
|
||||
@@ -535,6 +538,27 @@ void Project::UnserializeFrom(const SerializerElement& element) {
|
||||
authorIds.push_back(authorIdsElement.GetChild(i).GetStringValue());
|
||||
}
|
||||
|
||||
categories.clear();
|
||||
auto& categoriesElement = propElement.GetChild("categories");
|
||||
categoriesElement.ConsiderAsArray();
|
||||
for (std::size_t i = 0; i < categoriesElement.GetChildrenCount(); ++i) {
|
||||
categories.push_back(categoriesElement.GetChild(i).GetStringValue());
|
||||
}
|
||||
|
||||
auto& playableDevicesElement = propElement.GetChild("playableDevices");
|
||||
playableDevicesElement.ConsiderAsArray();
|
||||
for (std::size_t i = 0; i < playableDevicesElement.GetChildrenCount(); ++i) {
|
||||
const auto& playableDevice =
|
||||
playableDevicesElement.GetChild(i).GetStringValue();
|
||||
if (playableDevice == "keyboard") {
|
||||
isPlayableWithKeyboard = true;
|
||||
} else if (playableDevice == "gamepad") {
|
||||
isPlayableWithGamepad = true;
|
||||
} else if (playableDevice == "mobile") {
|
||||
isPlayableWithMobile = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Compatibility with GD <= 5.0.0-beta101
|
||||
if (VersionWrapper::IsOlderOrEqual(
|
||||
gdMajorVersion, gdMinorVersion, gdBuildVersion, 0, 4, 0, 98, 0) &&
|
||||
@@ -704,6 +728,7 @@ void Project::SerializeTo(SerializerElement& element) const {
|
||||
|
||||
SerializerElement& propElement = element.AddChild("properties");
|
||||
propElement.AddChild("name").SetValue(GetName());
|
||||
propElement.AddChild("description").SetValue(GetDescription());
|
||||
propElement.SetAttribute("version", GetVersion());
|
||||
propElement.AddChild("author").SetValue(GetAuthor());
|
||||
propElement.AddChild("windowWidth").SetValue(GetGameResolutionWidth());
|
||||
@@ -734,6 +759,24 @@ void Project::SerializeTo(SerializerElement& element) const {
|
||||
authorIdsElement.AddChild("").SetStringValue(authorId);
|
||||
}
|
||||
|
||||
auto& categoriesElement = propElement.AddChild("categories");
|
||||
categoriesElement.ConsiderAsArray();
|
||||
for (const auto& category : categories) {
|
||||
categoriesElement.AddChild("").SetStringValue(category);
|
||||
}
|
||||
|
||||
auto& playableDevicesElement = propElement.AddChild("playableDevices");
|
||||
playableDevicesElement.ConsiderAsArray();
|
||||
if (isPlayableWithKeyboard) {
|
||||
playableDevicesElement.AddChild("").SetStringValue("keyboard");
|
||||
}
|
||||
if (isPlayableWithGamepad) {
|
||||
playableDevicesElement.AddChild("").SetStringValue("gamepad");
|
||||
}
|
||||
if (isPlayableWithMobile) {
|
||||
playableDevicesElement.AddChild("").SetStringValue("mobile");
|
||||
}
|
||||
|
||||
// Compatibility with GD <= 5.0.0-beta101
|
||||
if (useDeprecatedZeroAsDefaultZOrder) {
|
||||
propElement.SetAttribute("useDeprecatedZeroAsDefaultZOrder", true);
|
||||
@@ -909,6 +952,8 @@ Project& Project::operator=(const Project& other) {
|
||||
|
||||
void Project::Init(const gd::Project& game) {
|
||||
name = game.name;
|
||||
categories = game.categories;
|
||||
description = game.description;
|
||||
firstLayout = game.firstLayout;
|
||||
version = game.version;
|
||||
windowWidth = game.windowWidth;
|
||||
@@ -925,6 +970,9 @@ void Project::Init(const gd::Project& game) {
|
||||
|
||||
author = game.author;
|
||||
authorIds = game.authorIds;
|
||||
isPlayableWithKeyboard = game.isPlayableWithKeyboard;
|
||||
isPlayableWithGamepad = game.isPlayableWithGamepad;
|
||||
isPlayableWithMobile = game.isPlayableWithMobile;
|
||||
packageName = game.packageName;
|
||||
orientation = game.orientation;
|
||||
folderProject = game.folderProject;
|
||||
|
@@ -56,15 +56,35 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
///@{
|
||||
|
||||
/**
|
||||
* \brief Change project name
|
||||
* \brief Change the project name
|
||||
*/
|
||||
void SetName(const gd::String& name_) { name = name_; };
|
||||
|
||||
/**
|
||||
* \brief Get project name
|
||||
* \brief Get the project name
|
||||
*/
|
||||
const gd::String& GetName() const { return name; }
|
||||
|
||||
/**
|
||||
* \brief Get the categories/genres of the project.
|
||||
*/
|
||||
const std::vector<gd::String>& GetCategories() const { return categories; };
|
||||
|
||||
/**
|
||||
* \brief Get the categories of the project, to modify them (non-const).
|
||||
*/
|
||||
std::vector<gd::String>& GetCategories() { return categories; };
|
||||
|
||||
/**
|
||||
* \brief Change the project description
|
||||
*/
|
||||
void SetDescription(const gd::String& description_) { description = description_; };
|
||||
|
||||
/**
|
||||
* \brief Get the project description
|
||||
*/
|
||||
const gd::String& GetDescription() const { return description; }
|
||||
|
||||
/**
|
||||
* \brief Change the version of the project.
|
||||
* This can be freely set, but should follow "X.Y.Z" format for compatibility
|
||||
@@ -73,7 +93,7 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
void SetVersion(const gd::String& version_) { version = version_; };
|
||||
|
||||
/**
|
||||
* \brief Get project version.
|
||||
* \brief Get the project version.
|
||||
*/
|
||||
const gd::String& GetVersion() const { return version; }
|
||||
|
||||
@@ -83,7 +103,7 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
void SetAuthor(const gd::String& author_) { author = author_; };
|
||||
|
||||
/**
|
||||
* \brief Get project author name.
|
||||
* \brief Get the project author name.
|
||||
*/
|
||||
const gd::String& GetAuthor() const { return author; }
|
||||
|
||||
@@ -98,14 +118,47 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
std::vector<gd::String>& GetAuthorIds() { return authorIds; };
|
||||
|
||||
/**
|
||||
* \brief Change project package name.
|
||||
* Define the project as playable with a keyboard.
|
||||
* \param enable True to define the project as playable with a keyboard.
|
||||
*/
|
||||
void SetPlayableWithKeyboard(bool playable = true) { isPlayableWithKeyboard = playable; }
|
||||
|
||||
/**
|
||||
* Check if the project is defined as playable with a keyboard.
|
||||
*/
|
||||
bool IsPlayableWithKeyboard() const { return isPlayableWithKeyboard; }
|
||||
|
||||
/**
|
||||
* Define the project as playable with a gamepad.
|
||||
* \param enable True to define the project as playable with a gamepad.
|
||||
*/
|
||||
void SetPlayableWithGamepad(bool playable = true) { isPlayableWithGamepad = playable; }
|
||||
|
||||
/**
|
||||
* Check if the project is defined as playable with a gamepad.
|
||||
*/
|
||||
bool IsPlayableWithGamepad() const { return isPlayableWithGamepad; }
|
||||
|
||||
/**
|
||||
* Define the project as playable on a mobile.
|
||||
* \param enable True to define the project as playable on a mobile.
|
||||
*/
|
||||
void SetPlayableWithMobile(bool playable = true) { isPlayableWithMobile = playable; }
|
||||
|
||||
/**
|
||||
* Check if the project is defined as playable on a mobile.
|
||||
*/
|
||||
bool IsPlayableWithMobile() const { return isPlayableWithMobile; }
|
||||
|
||||
/**
|
||||
* \brief Change the project package name.
|
||||
*/
|
||||
void SetPackageName(const gd::String& packageName_) {
|
||||
packageName = packageName_;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Get project package name.
|
||||
* \brief Get the project package name.
|
||||
*/
|
||||
const gd::String& GetPackageName() const { return packageName; }
|
||||
|
||||
@@ -119,7 +172,7 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Get project orientation ("default", "landscape", "portrait").
|
||||
* \brief Get the project orientation ("default", "landscape", "portrait").
|
||||
*/
|
||||
const gd::String& GetOrientation() const { return orientation; }
|
||||
|
||||
@@ -884,6 +937,7 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
void Init(const gd::Project& project);
|
||||
|
||||
gd::String name; ///< Game name
|
||||
gd::String description; ///< Game description
|
||||
gd::String version; ///< Game version number (used for some exports)
|
||||
unsigned int windowWidth; ///< Window default width
|
||||
unsigned int windowHeight; ///< Window default height
|
||||
@@ -923,6 +977,11 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
gd::String author; ///< Game author name, for publishing purpose.
|
||||
std::vector<gd::String>
|
||||
authorIds; ///< Game author ids, from GDevelop users DB.
|
||||
std::vector<gd::String>
|
||||
categories; ///< Game categories
|
||||
bool isPlayableWithKeyboard; ///< The project is playable with a keyboard.
|
||||
bool isPlayableWithGamepad; ///< The project is playable with a gamepad.
|
||||
bool isPlayableWithMobile; ///< The project is playable on a mobile.
|
||||
gd::String packageName; ///< Game package name
|
||||
gd::String orientation; ///< Lock game orientation (on mobile devices).
|
||||
///< "default", "landscape" or "portrait".
|
||||
|
@@ -18,6 +18,16 @@
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/Tools/Log.h"
|
||||
|
||||
namespace {
|
||||
gd::String NormalizePathSeparator(const gd::String& path) {
|
||||
gd::String normalizedPath = path;
|
||||
while (normalizedPath.find('\\') != gd::String::npos)
|
||||
normalizedPath.replace(normalizedPath.find('\\'), 1, "/");
|
||||
|
||||
return normalizedPath;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace gd {
|
||||
|
||||
gd::String Resource::badStr;
|
||||
@@ -126,19 +136,20 @@ std::vector<gd::String> ResourcesManager::GetAllResourceNames() const {
|
||||
}
|
||||
|
||||
std::vector<gd::String> ResourcesManager::FindFilesNotInResources(
|
||||
const std::vector<gd::String>& filesToCheck) const {
|
||||
std::unordered_set<gd::String> resourceFiles;
|
||||
for (const auto& resource: resources) {
|
||||
resourceFiles.insert(resource->GetFile());
|
||||
const std::vector<gd::String>& filePathsToCheck) const {
|
||||
std::unordered_set<gd::String> resourceFilePaths;
|
||||
for (const auto& resource : resources) {
|
||||
resourceFilePaths.insert(NormalizePathSeparator(resource->GetFile()));
|
||||
}
|
||||
|
||||
std::vector<gd::String> filesNotInResources;
|
||||
for(const gd::String& file: filesToCheck) {
|
||||
if (resourceFiles.find(file) == resourceFiles.end())
|
||||
filesNotInResources.push_back(file);
|
||||
std::vector<gd::String> filePathsNotInResources;
|
||||
for (const gd::String& file : filePathsToCheck) {
|
||||
gd::String normalizedPath = NormalizePathSeparator(file);
|
||||
if (resourceFilePaths.find(normalizedPath) == resourceFilePaths.end())
|
||||
filePathsNotInResources.push_back(file);
|
||||
}
|
||||
|
||||
return filesNotInResources;
|
||||
return filePathsNotInResources;
|
||||
}
|
||||
|
||||
std::map<gd::String, gd::PropertyDescriptor> Resource::GetProperties() const {
|
||||
@@ -532,11 +543,7 @@ void ResourcesManager::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
|
||||
void ImageResource::SetFile(const gd::String& newFile) {
|
||||
file = newFile;
|
||||
|
||||
// Convert all backslash to slashs.
|
||||
while (file.find('\\') != gd::String::npos)
|
||||
file.replace(file.find('\\'), 1, "/");
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
||||
void ImageResource::UnserializeFrom(const SerializerElement& element) {
|
||||
@@ -554,11 +561,7 @@ void ImageResource::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
|
||||
void AudioResource::SetFile(const gd::String& newFile) {
|
||||
file = newFile;
|
||||
|
||||
// Convert all backslash to slashs.
|
||||
while (file.find('\\') != gd::String::npos)
|
||||
file.replace(file.find('\\'), 1, "/");
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
||||
void AudioResource::UnserializeFrom(const SerializerElement& element) {
|
||||
@@ -576,11 +579,7 @@ void AudioResource::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
|
||||
void FontResource::SetFile(const gd::String& newFile) {
|
||||
file = newFile;
|
||||
|
||||
// Convert all backslash to slashs.
|
||||
while (file.find('\\') != gd::String::npos)
|
||||
file.replace(file.find('\\'), 1, "/");
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
||||
void FontResource::UnserializeFrom(const SerializerElement& element) {
|
||||
@@ -594,11 +593,7 @@ void FontResource::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
|
||||
void VideoResource::SetFile(const gd::String& newFile) {
|
||||
file = newFile;
|
||||
|
||||
// Convert all backslash to slashs.
|
||||
while (file.find('\\') != gd::String::npos)
|
||||
file.replace(file.find('\\'), 1, "/");
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
||||
void VideoResource::UnserializeFrom(const SerializerElement& element) {
|
||||
@@ -612,11 +607,7 @@ void VideoResource::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
|
||||
void JsonResource::SetFile(const gd::String& newFile) {
|
||||
file = newFile;
|
||||
|
||||
// Convert all backslash to slashs.
|
||||
while (file.find('\\') != gd::String::npos)
|
||||
file.replace(file.find('\\'), 1, "/");
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
||||
void JsonResource::UnserializeFrom(const SerializerElement& element) {
|
||||
@@ -649,13 +640,8 @@ bool JsonResource::UpdateProperty(const gd::String& name,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BitmapFontResource::SetFile(const gd::String& newFile) {
|
||||
file = newFile;
|
||||
|
||||
// Convert all backslash to slashs.
|
||||
while (file.find('\\') != gd::String::npos)
|
||||
file.replace(file.find('\\'), 1, "/");
|
||||
file = NormalizePathSeparator(newFile);
|
||||
}
|
||||
|
||||
void BitmapFontResource::UnserializeFrom(const SerializerElement& element) {
|
||||
|
@@ -447,7 +447,7 @@ class GD_CORE_API ResourcesManager {
|
||||
* \brief Return a list of the files, from the specified input list,
|
||||
* that are not used as files by the resources.
|
||||
*/
|
||||
std::vector<gd::String> FindFilesNotInResources(const std::vector<gd::String>& filesToCheck) const;
|
||||
std::vector<gd::String> FindFilesNotInResources(const std::vector<gd::String>& filePathsToCheck) const;
|
||||
|
||||
/**
|
||||
* \brief Return a (smart) pointer to a resource.
|
||||
|
@@ -92,7 +92,7 @@ double Variable::GetValue() const {
|
||||
return value;
|
||||
} else if (type == Type::String) {
|
||||
double retVal = str.empty() ? 0.0 : str.To<double>();
|
||||
if(std::isnan(retVal)) retVal = 0.0;
|
||||
if (std::isnan(retVal)) retVal = 0.0;
|
||||
return retVal;
|
||||
} else if (type == Type::Boolean) {
|
||||
return boolVal ? 1.0 : 0.0;
|
||||
@@ -188,6 +188,15 @@ const Variable& Variable::GetAtIndex(const size_t index) const {
|
||||
return *childrenArray.at(index);
|
||||
};
|
||||
|
||||
void Variable::MoveChildInArray(const size_t oldIndex, const size_t newIndex) {
|
||||
if (oldIndex >= childrenArray.size() || newIndex >= childrenArray.size())
|
||||
return;
|
||||
|
||||
std::shared_ptr<gd::Variable> object = std::move(childrenArray[oldIndex]);
|
||||
childrenArray.erase(childrenArray.begin() + oldIndex);
|
||||
childrenArray.insert(childrenArray.begin() + newIndex, std::move(object));
|
||||
}
|
||||
|
||||
Variable& Variable::PushNew() { return GetAtIndex(GetChildrenCount()); };
|
||||
|
||||
void Variable::RemoveAtIndex(const size_t index) {
|
||||
@@ -195,8 +204,29 @@ void Variable::RemoveAtIndex(const size_t index) {
|
||||
childrenArray.erase(childrenArray.begin() + index);
|
||||
};
|
||||
|
||||
bool Variable::InsertAtIndex(const gd::Variable& variable, const size_t index) {
|
||||
if (type != Type::Array) return false;
|
||||
auto newVariable = std::make_shared<gd::Variable>(variable);
|
||||
if (index < childrenArray.size()) {
|
||||
childrenArray.insert(childrenArray.begin() + index, newVariable);
|
||||
} else {
|
||||
childrenArray.push_back(newVariable);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
bool Variable::InsertChild(const gd::String& name,
|
||||
const gd::Variable& variable) {
|
||||
if (type != Type::Structure || HasChild(name)) {
|
||||
return false;
|
||||
}
|
||||
children[name] = std::make_shared<gd::Variable>(variable);
|
||||
return true;
|
||||
};
|
||||
|
||||
void Variable::SerializeTo(SerializerElement& element) const {
|
||||
element.SetStringAttribute("type", TypeAsString(GetType()));
|
||||
if (IsFolded()) element.SetBoolAttribute("folded", true);
|
||||
|
||||
if (type == Type::String) {
|
||||
element.SetStringAttribute("value", GetString());
|
||||
@@ -234,6 +264,7 @@ void Variable::UnserializeFrom(const SerializerElement& element) {
|
||||
if (element.HasChild("children", "Children") && IsPrimitive(type))
|
||||
type = Type::Structure;
|
||||
// end of compatibility code
|
||||
SetFolded(element.GetBoolAttribute("folded", false));
|
||||
|
||||
if (IsPrimitive(type)) {
|
||||
if (type == Type::String) {
|
||||
@@ -305,6 +336,7 @@ void Variable::RemoveRecursively(const gd::Variable& variableToRemove) {
|
||||
Variable::Variable(const Variable& other)
|
||||
: value(other.value),
|
||||
str(other.str),
|
||||
folded(other.folded),
|
||||
boolVal(other.boolVal),
|
||||
type(other.type) {
|
||||
CopyChildren(other);
|
||||
@@ -314,6 +346,7 @@ Variable& Variable::operator=(const Variable& other) {
|
||||
if (this != &other) {
|
||||
value = other.value;
|
||||
str = other.str;
|
||||
folded = other.folded;
|
||||
boolVal = other.boolVal;
|
||||
type = other.type;
|
||||
CopyChildren(other);
|
||||
|
@@ -6,10 +6,10 @@
|
||||
|
||||
#ifndef GDCORE_VARIABLE_H
|
||||
#define GDCORE_VARIABLE_H
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
@@ -98,7 +98,7 @@ class GD_CORE_API Variable {
|
||||
void SetValue(double val) {
|
||||
value = val;
|
||||
// NaN values are not supported by GDevelop nor the serializer.
|
||||
if(std::isnan(value)) value = 0.0;
|
||||
if (std::isnan(value)) value = 0.0;
|
||||
type = Type::Number;
|
||||
}
|
||||
|
||||
@@ -185,9 +185,9 @@ class GD_CORE_API Variable {
|
||||
* \brief Get the count of children that the variable has.
|
||||
*/
|
||||
size_t GetChildrenCount() const {
|
||||
return type == Type::Structure
|
||||
? children.size()
|
||||
: type == Type::Array ? childrenArray.size() : 0;
|
||||
return type == Type::Structure ? children.size()
|
||||
: type == Type::Array ? childrenArray.size()
|
||||
: 0;
|
||||
};
|
||||
|
||||
/** \name Structure
|
||||
@@ -290,12 +290,38 @@ class GD_CORE_API Variable {
|
||||
*/
|
||||
void RemoveAtIndex(const size_t index);
|
||||
|
||||
/**
|
||||
* \brief Move child in array.
|
||||
*/
|
||||
void MoveChildInArray(const size_t oldIndex, const size_t newIndex);
|
||||
|
||||
/**
|
||||
* \brief Insert child in array.
|
||||
*/
|
||||
bool InsertAtIndex(const gd::Variable& variable, const size_t index);
|
||||
|
||||
/**
|
||||
* \brief Insert a child in a structure.
|
||||
*/
|
||||
bool InsertChild(const gd::String& name, const gd::Variable& variable);
|
||||
|
||||
/**
|
||||
* \brief Get the vector containing all the children.
|
||||
*/
|
||||
const std::vector<std::shared_ptr<Variable>>& GetAllChildrenArray() const {
|
||||
return childrenArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set if the children must be folded.
|
||||
*/
|
||||
void SetFolded(bool fold = true) { folded = fold; }
|
||||
|
||||
/**
|
||||
* \brief True if the children should be folded in the variables editor.
|
||||
*/
|
||||
bool IsFolded() const { return folded; }
|
||||
|
||||
///@}
|
||||
///@}
|
||||
|
||||
@@ -325,6 +351,7 @@ class GD_CORE_API Variable {
|
||||
*/
|
||||
static Type StringAsType(const gd::String& str);
|
||||
|
||||
bool folded;
|
||||
mutable Type type;
|
||||
mutable gd::String str;
|
||||
mutable double value;
|
||||
|
@@ -4,8 +4,10 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/Project/VariablesContainer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#include "GDCore/Project/Variable.h"
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/String.h"
|
||||
@@ -88,7 +90,6 @@ Variable& VariablesContainer::Insert(const gd::String& name,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void VariablesContainer::Remove(const gd::String& varName) {
|
||||
variables.erase(
|
||||
std::remove_if(
|
||||
@@ -151,13 +152,14 @@ void VariablesContainer::Swap(std::size_t firstVariableIndex,
|
||||
}
|
||||
|
||||
void VariablesContainer::Move(std::size_t oldIndex, std::size_t newIndex) {
|
||||
if (oldIndex >= variables.size() || newIndex >= variables.size()) return;
|
||||
if (oldIndex >= variables.size() || newIndex >= variables.size() ||
|
||||
oldIndex == newIndex)
|
||||
return;
|
||||
|
||||
auto nameAndVariable = variables[oldIndex];
|
||||
variables.erase(variables.begin() + oldIndex);
|
||||
variables.insert(variables.begin() + newIndex, nameAndVariable);
|
||||
}
|
||||
#endif
|
||||
|
||||
void VariablesContainer::SerializeTo(SerializerElement& element) const {
|
||||
element.ConsiderAsArrayOf("variable");
|
||||
|
@@ -77,8 +77,6 @@ bool SerializerElement::GetBoolAttribute(const gd::String& name,
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Bool attribute \"" << name << "\" not found, returning "
|
||||
<< defaultValue;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
|
||||
#include <SFML/System/String.hpp>
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Utf8/utf8proc.h"
|
||||
|
||||
@@ -28,11 +27,6 @@ String::String(const char *characters) : m_string()
|
||||
*this = characters;
|
||||
}
|
||||
|
||||
String::String(const sf::String &string) : m_string()
|
||||
{
|
||||
*this = string;
|
||||
}
|
||||
|
||||
String::String(const std::u32string &string) : m_string()
|
||||
{
|
||||
*this = string;
|
||||
@@ -44,26 +38,6 @@ String& String::operator=(const char *characters)
|
||||
return *this;
|
||||
}
|
||||
|
||||
String& String::operator=(const sf::String &string)
|
||||
{
|
||||
m_string.clear();
|
||||
|
||||
//In theory, an UTF8 character can be up to 6 bytes (even if in the current Unicode standard,
|
||||
//the last character is 4 bytes long when encoded in UTF8).
|
||||
//So, reserve the maximum possible size to avoid reallocations.
|
||||
m_string.reserve( string.getSize() * 6 );
|
||||
|
||||
//Push_back all characters inside the string.
|
||||
for( sf::String::ConstIterator it = string.begin(); it != string.end(); ++it )
|
||||
{
|
||||
push_back( *it );
|
||||
}
|
||||
|
||||
m_string.shrink_to_fit();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
String& String::operator=(const std::u32string &string)
|
||||
{
|
||||
m_string.clear();
|
||||
@@ -112,7 +86,7 @@ String::const_iterator String::end() const
|
||||
String String::FromLocale( const std::string &localizedString )
|
||||
{
|
||||
#if defined(WINDOWS)
|
||||
return FromSfString(sf::String(localizedString)); //Don't need to use the current locale, on Windows, std::locale is always the C locale
|
||||
return FromUTF8(localizedString); //Don't need to use the current locale, on Windows, std::locale is always the C locale
|
||||
#elif defined(MACOS)
|
||||
return FromUTF8(localizedString); //Assume UTF8 is the current locale
|
||||
#elif defined(EMSCRIPTEN)
|
||||
@@ -124,7 +98,7 @@ String String::FromLocale( const std::string &localizedString )
|
||||
std::locale("").name().find("UTF8") != std::string::npos)
|
||||
return FromUTF8(localizedString); //UTF8 is already the current locale
|
||||
else
|
||||
return FromSfString(sf::String(localizedString, std::locale(""))); //Use the current locale (std::locale("")) for conversion
|
||||
return FromUTF8(localizedString); //Use the current locale (std::locale("")) for conversion
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -136,11 +110,6 @@ String String::FromUTF32( const std::u32string &string )
|
||||
return str;
|
||||
}
|
||||
|
||||
String String::FromSfString( const sf::String &sfString )
|
||||
{
|
||||
return String(sfString);
|
||||
}
|
||||
|
||||
String String::FromUTF8( const std::string &utf8Str )
|
||||
{
|
||||
String str(utf8Str.c_str());
|
||||
@@ -164,7 +133,7 @@ String String::FromWide( const std::wstring &wstr )
|
||||
std::string String::ToLocale() const
|
||||
{
|
||||
#if defined(WINDOWS)
|
||||
return ToSfString().toAnsiString();
|
||||
return m_string;
|
||||
#elif defined(MACOS)
|
||||
return m_string;
|
||||
#elif defined(EMSCRIPTEN)
|
||||
@@ -176,7 +145,7 @@ std::string String::ToLocale() const
|
||||
std::locale("").name().find("UTF8") != std::string::npos)
|
||||
return m_string; //UTF8 is already the current locale on Linux
|
||||
else
|
||||
return ToSfString().toAnsiString(std::locale("")); //Use the current locale for conversion
|
||||
return m_string; //Use the current locale for conversion
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -191,20 +160,6 @@ std::u32string String::ToUTF32() const
|
||||
return u32str;
|
||||
}
|
||||
|
||||
sf::String String::ToSfString() const
|
||||
{
|
||||
sf::String str;
|
||||
for(const_iterator it = begin(); it != end(); ++it)
|
||||
str += sf::String(static_cast<sf::Uint32>(*it));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
String::operator sf::String() const
|
||||
{
|
||||
return ToSfString();
|
||||
}
|
||||
|
||||
std::string String::ToUTF8() const
|
||||
{
|
||||
return m_string;
|
||||
|
@@ -13,12 +13,9 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <SFML/System/String.hpp>
|
||||
|
||||
#include "GDCore/Utf8/utf8.h"
|
||||
|
||||
namespace sf {class String;};
|
||||
|
||||
namespace gd
|
||||
{
|
||||
|
||||
@@ -121,11 +118,6 @@ public:
|
||||
*/
|
||||
String(const std::u32string &string);
|
||||
|
||||
/**
|
||||
* Constructs a string from an sf::String.
|
||||
*/
|
||||
String(const sf::String &string);
|
||||
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
@@ -146,8 +138,6 @@ public:
|
||||
*/
|
||||
String& operator=(const char *characters);
|
||||
|
||||
String& operator=(const sf::String &string);
|
||||
|
||||
String& operator=(const std::u32string &string);
|
||||
|
||||
/**
|
||||
@@ -229,7 +219,6 @@ public:
|
||||
static String From(T value)
|
||||
{
|
||||
static_assert(!std::is_same<T, std::string>::value, "Can't use gd::String::From with std::string.");
|
||||
static_assert(!std::is_same<T, sf::String>::value, "Can't use gd::String::From with sf::String.");
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << value;
|
||||
@@ -244,7 +233,6 @@ public:
|
||||
T To() const
|
||||
{
|
||||
static_assert(!std::is_same<T, std::string>::value, "Can't use gd::String::To with std::string.");
|
||||
static_assert(!std::is_same<T, sf::String>::value, "Can't use gd::String::To with sf::String.");
|
||||
|
||||
T value;
|
||||
std::istringstream oss(m_string);
|
||||
@@ -274,13 +262,6 @@ public:
|
||||
*/
|
||||
static String FromUTF32( const std::u32string &string );
|
||||
|
||||
/**
|
||||
* \return a String created from a sf::String (UTF32).
|
||||
*
|
||||
* See \ref Conversions1 for more information.
|
||||
*/
|
||||
static String FromSfString( const sf::String &sfString );
|
||||
|
||||
/**
|
||||
* \return a String created an UTF8 encoded std::string.
|
||||
*/
|
||||
@@ -312,20 +293,6 @@ public:
|
||||
*/
|
||||
std::u32string ToUTF32() const;
|
||||
|
||||
/**
|
||||
* \return a sf::String from the current string.
|
||||
*
|
||||
* See \ref Conversions1 for more information.
|
||||
*/
|
||||
sf::String ToSfString() const;
|
||||
|
||||
/**
|
||||
* Implicit conversion operator to sf::String.
|
||||
*
|
||||
* See \ref Conversions1 for more information.
|
||||
*/
|
||||
operator sf::String() const;
|
||||
|
||||
/**
|
||||
* \return a UTF8 encoded std::string from the current string.
|
||||
*/
|
||||
@@ -885,7 +852,7 @@ namespace std
|
||||
* on the string size and so is the operator[]().
|
||||
*
|
||||
* \section Conversion Conversions from/to other string types
|
||||
* The String handles implicit conversion with sf::String (implicit constructor and implicit conversion
|
||||
* The String handles implicit conversion with std::String (implicit constructor and implicit conversion
|
||||
* operator).
|
||||
*
|
||||
* **However, this is not the case with std::string** as this conversion is not often lossless (mostly on Windows).
|
||||
@@ -894,16 +861,6 @@ namespace std
|
||||
* directly use the operator=() or the constructor as they are supporting const char* as argument (it assumes the string
|
||||
* literal is encoded in UTF8, so you'll need to put the u8 prefix).
|
||||
*
|
||||
* \subsection Conversions1 Implicit conversion from/to sf::String
|
||||
* \code
|
||||
* //Get a String from sf::String
|
||||
* sf::String sfmlStr("This is a test ! ");
|
||||
* gd::String str1(sfmlStr); //Now contains "This is a test ! " encoded in UTF8
|
||||
*
|
||||
* //Get a sf::String from String
|
||||
* sf::String anotherSfmlString = str; //anotherSfmlString now contains "Another test ! "
|
||||
* \endcode
|
||||
*
|
||||
* \subsection Conversions2 Conversion from/to std::string
|
||||
* \code
|
||||
* //Get a String from a std::string encoded in the current locale
|
||||
|
@@ -1,200 +0,0 @@
|
||||
#include "GDCore/Tools/FileStream.h"
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#if __GLIBCXX__
|
||||
#include <ext/stdio_filebuf.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace gd {
|
||||
|
||||
namespace {
|
||||
|
||||
#if FSTREAM_WINDOWS_MINGW
|
||||
|
||||
#define MODE(in_val, out_val, trunc_val, app_val) \
|
||||
((((mode & std::ios_base::in) != 0) == in_val) && \
|
||||
(((mode & std::ios_base::out) != 0) == out_val) && \
|
||||
(((mode & std::ios_base::trunc) != 0) == trunc_val) && \
|
||||
(((mode & std::ios_base::app) != 0) == app_val))
|
||||
|
||||
std::wstring GetStdioMode(std::ios_base::openmode mode) {
|
||||
std::wstring strMode;
|
||||
|
||||
/// Thanks to https://gcc.gnu.org/ml/libstdc++/2007-06/msg00013.html
|
||||
if (MODE(false, true, false, false))
|
||||
strMode += L"w";
|
||||
else if (MODE(false, true, false, true))
|
||||
strMode += L"a";
|
||||
else if (MODE(true, true, false, true))
|
||||
strMode += L"a+";
|
||||
else if (MODE(false, true, true, false))
|
||||
strMode += L"w";
|
||||
else if (MODE(true, false, false, false))
|
||||
strMode += L"r";
|
||||
else if (MODE(true, true, false, false))
|
||||
strMode += L"r+";
|
||||
else if (MODE(true, true, true, false))
|
||||
strMode += L"w+";
|
||||
|
||||
if ((mode & std::ios_base::binary) != 0) strMode += L"b";
|
||||
|
||||
return strMode;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Open the given file into a filebuf and return it.
|
||||
* On Windows, return the associated FILE* inside the file argument.
|
||||
*/
|
||||
FileStream::InternalBufferType* OpenBuffer(const gd::String& path,
|
||||
std::ios_base::openmode mode,
|
||||
FILE** file) {
|
||||
#if FSTREAM_WINDOWS_MINGW
|
||||
*file = _wfopen(path.ToWide().c_str(), GetStdioMode(mode).c_str());
|
||||
if (!(*file)) return nullptr;
|
||||
return new __gnu_cxx::stdio_filebuf<char>(*file, mode);
|
||||
#else
|
||||
auto* filebuffer = new std::filebuf();
|
||||
return filebuffer->open(path.ToLocale().c_str(), mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
FileStream::FileStream() : std::iostream(nullptr) {}
|
||||
|
||||
FileStream::FileStream(const gd::String& path, std::ios_base::openmode mode)
|
||||
: std::iostream(nullptr),
|
||||
m_file(nullptr),
|
||||
m_buffer(OpenBuffer(path, mode, &m_file)) {
|
||||
setstate(ios_base::goodbit);
|
||||
if (m_buffer) {
|
||||
std::iostream::init(m_buffer.get());
|
||||
if ((mode & std::ios_base::ate) != 0) seekg(0, end);
|
||||
} else
|
||||
setstate(ios_base::badbit);
|
||||
}
|
||||
|
||||
FileStream::~FileStream() {
|
||||
if (is_open()) close();
|
||||
}
|
||||
|
||||
/*
|
||||
WILL WORK with GCC>=5 (not 4.9 used on Windows)
|
||||
FileStream::FileStream(FileStream && other) :
|
||||
std::iostream(std::move(other)),
|
||||
m_buffer(std::move(other.m_buffer))
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
/*FileStream& FileStream::operator=(FileStream && other)
|
||||
{
|
||||
std::iostream::operator=(std::move(other));
|
||||
m_buffer = std::move(other.m_buffer);
|
||||
}*/
|
||||
|
||||
void FileStream::open(const gd::String& path, std::ios_base::openmode mode) {
|
||||
setstate(ios_base::goodbit);
|
||||
|
||||
if (is_open()) {
|
||||
setstate(ios_base::failbit);
|
||||
std::cout << "is_open true when trying to open!" << std::endl;
|
||||
} else {
|
||||
auto* newBuffer = OpenBuffer(path, mode, &m_file);
|
||||
if (newBuffer) {
|
||||
m_buffer.reset(newBuffer);
|
||||
std::iostream::init(m_buffer.get());
|
||||
if ((mode & std::ios_base::ate) != 0) seekg(0, end);
|
||||
} else {
|
||||
setstate(ios_base::badbit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FileStream::is_open() const {
|
||||
if (!m_buffer) return false;
|
||||
return m_buffer->is_open();
|
||||
}
|
||||
|
||||
void FileStream::close() {
|
||||
#if FSTREAM_WINDOWS_MINGW
|
||||
if (m_buffer) m_buffer->close();
|
||||
|
||||
if (m_file && fclose(m_file) != 0) {
|
||||
setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
m_buffer.reset(nullptr);
|
||||
m_file = nullptr;
|
||||
#else
|
||||
if (!m_buffer || m_buffer->close() == nullptr) {
|
||||
setstate(ios_base::failbit);
|
||||
} else {
|
||||
m_buffer.reset(nullptr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*void FileStream::swap(FileStream & other) //WILL WORK with GCC>=5 (not 4.9
|
||||
used on Windows)
|
||||
{
|
||||
std::iostream::swap(other);
|
||||
std::swap(m_buffer, other.m_buffer);
|
||||
}*/
|
||||
|
||||
SFMLFileStream::SFMLFileStream() : m_file(nullptr) {}
|
||||
|
||||
SFMLFileStream::~SFMLFileStream() {
|
||||
if (m_file) fclose(m_file);
|
||||
}
|
||||
|
||||
bool SFMLFileStream::open(const gd::String& filename) {
|
||||
if (m_file) fclose(m_file);
|
||||
|
||||
#if FSTREAM_WINDOWS_MINGW
|
||||
m_file = _wfopen(filename.ToWide().c_str(), L"rb");
|
||||
#else
|
||||
m_file = fopen(filename.ToLocale().c_str(), "rb");
|
||||
#endif
|
||||
|
||||
return m_file != NULL;
|
||||
}
|
||||
|
||||
sf::Int64 SFMLFileStream::read(void* data, sf::Int64 size) {
|
||||
if (m_file)
|
||||
return fread(data, 1, static_cast<std::size_t>(size), m_file);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
sf::Int64 SFMLFileStream::seek(sf::Int64 position) {
|
||||
if (m_file) {
|
||||
fseek(m_file, static_cast<std::size_t>(position), SEEK_SET);
|
||||
return tell();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
sf::Int64 SFMLFileStream::tell() {
|
||||
if (m_file)
|
||||
return ftell(m_file);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
sf::Int64 SFMLFileStream::getSize() {
|
||||
if (m_file) {
|
||||
sf::Int64 position = tell();
|
||||
fseek(m_file, 0, SEEK_END);
|
||||
sf::Int64 size = tell();
|
||||
seek(position);
|
||||
return size;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gd
|
@@ -1,82 +0,0 @@
|
||||
#ifndef GDCORE_FSTREAMTOOLS
|
||||
#define GDCORE_FSTREAMTOOLS
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include <SFML/System.hpp>
|
||||
|
||||
#include "GDCore/String.h"
|
||||
|
||||
#if defined(WINDOWS) && __GLIBCXX__
|
||||
#include <ext/stdio_filebuf.h>
|
||||
#else
|
||||
#include <fstream> //for std::filebuf
|
||||
#endif
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* Similar to std::i/ofstream except that it can open file with
|
||||
* gd::String paths (useful on Windows where fstream doesn't
|
||||
* support wide paths).
|
||||
*/
|
||||
class GD_CORE_API FileStream : public std::iostream {
|
||||
public:
|
||||
#if defined(WINDOWS) && __GLIBCXX__
|
||||
using InternalBufferType = std::basic_filebuf<char>;
|
||||
#else
|
||||
using InternalBufferType = std::filebuf;
|
||||
#endif
|
||||
|
||||
FileStream();
|
||||
FileStream(const gd::String& path, std::ios_base::openmode mode);
|
||||
~FileStream();
|
||||
|
||||
FileStream(const FileStream& other) = delete;
|
||||
FileStream(FileStream&& other) = delete; // HACK for GCC 4.9 (Windows)
|
||||
// FileStream(FileStream && other); WILL WORK with GCC>=5 (not 4.9 used on
|
||||
// Windows)
|
||||
|
||||
FileStream& operator=(const FileStream& other) = delete;
|
||||
FileStream& operator=(FileStream&& other) =
|
||||
delete; // HACK for GCC 4.9 (Windows)
|
||||
// FileStream& operator=(FileStream && other); WILL WORK with GCC>=5 (not 4.9
|
||||
// used on Windows)
|
||||
|
||||
void open(const gd::String& path, std::ios_base::openmode mode);
|
||||
|
||||
bool is_open() const;
|
||||
|
||||
void close();
|
||||
|
||||
// void swap(FileStream & other); //WILL WORK with GCC>=5 (not 4.9 used on
|
||||
// Windows)
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
std::unique_ptr<InternalBufferType> m_buffer;
|
||||
};
|
||||
|
||||
class GD_CORE_API SFMLFileStream : public sf::InputStream {
|
||||
public:
|
||||
SFMLFileStream();
|
||||
~SFMLFileStream();
|
||||
|
||||
bool open(const gd::String& filename);
|
||||
|
||||
virtual sf::Int64 read(void* data, sf::Int64 size);
|
||||
|
||||
virtual sf::Int64 seek(sf::Int64 position);
|
||||
|
||||
virtual sf::Int64 tell();
|
||||
|
||||
virtual sf::Int64 getSize();
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
||||
#endif
|
@@ -1,19 +0,0 @@
|
||||
#include <SFML/OpenGL.hpp>
|
||||
#include <cmath>
|
||||
|
||||
namespace OpenGLTools {
|
||||
|
||||
void GD_CORE_API PerspectiveGL(GLdouble fovY,
|
||||
GLdouble aspect,
|
||||
GLdouble zNear,
|
||||
GLdouble zFar) {
|
||||
const GLdouble pi = 3.1415926535897932384626433832795;
|
||||
GLdouble fW, fH;
|
||||
|
||||
fH = std::tan(fovY / 360 * pi) * zNear;
|
||||
fW = fH * aspect;
|
||||
|
||||
glFrustum(-fW, fW, -fH, fH, zNear, zFar);
|
||||
}
|
||||
|
||||
} // namespace OpenGLTools
|
@@ -1,9 +0,0 @@
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
namespace OpenGLTools {
|
||||
|
||||
void GD_CORE_API PerspectiveGL(GLdouble fovY,
|
||||
GLdouble aspect,
|
||||
GLdouble zNear,
|
||||
GLdouble zFar);
|
||||
}
|
360
Core/GDCore/Vector2.h
Normal file
360
Core/GDCore/Vector2.h
Normal file
@@ -0,0 +1,360 @@
|
||||
// This is adapted from SFML (https://github.com/SFML/SFML).
|
||||
|
||||
#ifndef GDCORE_VECTOR2_H
|
||||
#define GDCORE_VECTOR2_H
|
||||
|
||||
namespace gd
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Utility template class for manipulating
|
||||
/// 2-dimensional vectors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
class Vector2
|
||||
{
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// Creates a Vector2(0, 0).
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
inline Vector2() :
|
||||
x(0),
|
||||
y(0)
|
||||
{
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct the vector from its coordinates
|
||||
///
|
||||
/// \param X X coordinate
|
||||
/// \param Y Y coordinate
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
inline Vector2(T X, T Y) :
|
||||
x(X),
|
||||
y(Y)
|
||||
{
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct the vector from another type of vector
|
||||
///
|
||||
/// This constructor doesn't replace the copy constructor,
|
||||
/// it's called only when U != T.
|
||||
/// A call to this constructor will fail to compile if U
|
||||
/// is not convertible to T.
|
||||
///
|
||||
/// \param vector Vector to convert
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename U>
|
||||
inline explicit Vector2(const Vector2<U>& vector) :
|
||||
x(static_cast<T>(vector.x)),
|
||||
y(static_cast<T>(vector.y))
|
||||
{
|
||||
}
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
T x; ///< X coordinate of the vector
|
||||
T y; ///< Y coordinate of the vector
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of unary operator -
|
||||
///
|
||||
/// \param right Vector to negate
|
||||
///
|
||||
/// \return Memberwise opposite of the vector
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T> operator -(const Vector2<T>& right)
|
||||
{
|
||||
return Vector2<T>(-right.x, -right.y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator +=
|
||||
///
|
||||
/// This operator performs a memberwise addition of both vectors,
|
||||
/// and assigns the result to \a left.
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a vector)
|
||||
///
|
||||
/// \return Reference to \a left
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
|
||||
{
|
||||
left.x += right.x;
|
||||
left.y += right.y;
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator -=
|
||||
///
|
||||
/// This operator performs a memberwise subtraction of both vectors,
|
||||
/// and assigns the result to \a left.
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a vector)
|
||||
///
|
||||
/// \return Reference to \a left
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
|
||||
{
|
||||
left.x -= right.x;
|
||||
left.y -= right.y;
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator +
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a vector)
|
||||
///
|
||||
/// \return Memberwise addition of both vectors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
|
||||
{
|
||||
return Vector2<T>(left.x + right.x, left.y + right.y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator -
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a vector)
|
||||
///
|
||||
/// \return Memberwise subtraction of both vectors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
|
||||
{
|
||||
return Vector2<T>(left.x - right.x, left.y - right.y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator *
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a scalar value)
|
||||
///
|
||||
/// \return Memberwise multiplication by \a right
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T> operator *(const Vector2<T>& left, T right)
|
||||
{
|
||||
return Vector2<T>(left.x * right, left.y * right);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator *
|
||||
///
|
||||
/// \param left Left operand (a scalar value)
|
||||
/// \param right Right operand (a vector)
|
||||
///
|
||||
/// \return Memberwise multiplication by \a left
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T> operator *(T left, const Vector2<T>& right)
|
||||
{
|
||||
return Vector2<T>(right.x * left, right.y * left);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator *=
|
||||
///
|
||||
/// This operator performs a memberwise multiplication by \a right,
|
||||
/// and assigns the result to \a left.
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a scalar value)
|
||||
///
|
||||
/// \return Reference to \a left
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T>& operator *=(Vector2<T>& left, T right)
|
||||
{
|
||||
left.x *= right;
|
||||
left.y *= right;
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator /
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a scalar value)
|
||||
///
|
||||
/// \return Memberwise division by \a right
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T> operator /(const Vector2<T>& left, T right)
|
||||
{
|
||||
return Vector2<T>(left.x / right, left.y / right);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator /=
|
||||
///
|
||||
/// This operator performs a memberwise division by \a right,
|
||||
/// and assigns the result to \a left.
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a scalar value)
|
||||
///
|
||||
/// \return Reference to \a left
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline Vector2<T>& operator /=(Vector2<T>& left, T right)
|
||||
{
|
||||
left.x /= right;
|
||||
left.y /= right;
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator ==
|
||||
///
|
||||
/// This operator compares strict equality between two vectors.
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a vector)
|
||||
///
|
||||
/// \return True if \a left is equal to \a right
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
|
||||
{
|
||||
return (left.x == right.x) && (left.y == right.y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Vector2
|
||||
/// \brief Overload of binary operator !=
|
||||
///
|
||||
/// This operator compares strict difference between two vectors.
|
||||
///
|
||||
/// \param left Left operand (a vector)
|
||||
/// \param right Right operand (a vector)
|
||||
///
|
||||
/// \return True if \a left is not equal to \a right
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
|
||||
{
|
||||
return (left.x != right.x) || (left.y != right.y);
|
||||
}
|
||||
|
||||
// Define the most common types
|
||||
typedef Vector2<int> Vector2i;
|
||||
typedef Vector2<unsigned int> Vector2u;
|
||||
typedef Vector2<float> Vector2f;
|
||||
|
||||
} // namespace gd
|
||||
|
||||
|
||||
#endif // GDCORE_VECTOR2_H
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class gd::Vector2
|
||||
/// \ingroup CommonProgrammingTools
|
||||
///
|
||||
/// gd::Vector2 is a simple class that defines a mathematical
|
||||
/// vector with two coordinates (x and y). It can be used to
|
||||
/// represent anything that has two dimensions: a size, a point,
|
||||
/// a velocity, etc.
|
||||
///
|
||||
/// The template parameter T is the type of the coordinates. It
|
||||
/// can be any type that supports arithmetic operations (+, -, /, *)
|
||||
/// and comparisons (==, !=), for example int or float.
|
||||
///
|
||||
/// You generally don't have to care about the templated form (gd::Vector2<T>),
|
||||
/// the most common specializations have special typedefs:
|
||||
/// \li gd::Vector2<float> is gd::Vector2f
|
||||
/// \li gd::Vector2<int> is gd::Vector2i
|
||||
/// \li gd::Vector2<unsigned int> is gd::Vector2u
|
||||
///
|
||||
/// The gd::Vector2 class has a small and simple interface, its x and y members
|
||||
/// can be accessed directly (there are no accessors like setX(), getX()) and it
|
||||
/// contains no mathematical function like dot product, cross product, length, etc.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// gd::Vector2f v1(16.5f, 24.f);
|
||||
/// v1.x = 18.2f;
|
||||
/// float y = v1.y;
|
||||
///
|
||||
/// gd::Vector2f v2 = v1 * 5.f;
|
||||
/// gd::Vector2f v3;
|
||||
/// v3 = v1 + v2;
|
||||
///
|
||||
/// bool different = (v2 != v3);
|
||||
/// \endcode
|
||||
///
|
||||
/// Note: for 3-dimensional vectors, see gd::Vector3.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user