mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
280 Commits
v5.0.0-bet
...
v5.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
009a05e021 | ||
![]() |
6c2ea56da6 | ||
![]() |
a8ae298194 | ||
![]() |
dda2effad0 | ||
![]() |
4da0149b6b | ||
![]() |
9602caaccc | ||
![]() |
be2892b759 | ||
![]() |
e1552f649c | ||
![]() |
74bbd45265 | ||
![]() |
5aa32f0eca | ||
![]() |
23987f63c7 | ||
![]() |
d415d3cbee | ||
![]() |
f7f32d6be5 | ||
![]() |
b223175bf9 | ||
![]() |
47463e6ca2 | ||
![]() |
e289059d1f | ||
![]() |
6320d19043 | ||
![]() |
833ae75632 | ||
![]() |
6058a4b1be | ||
![]() |
52173ac07d | ||
![]() |
a55ad60038 | ||
![]() |
0ef235261f | ||
![]() |
3bd9432b5e | ||
![]() |
6fd82f4f30 | ||
![]() |
5572536bff | ||
![]() |
ab197464cc | ||
![]() |
00f2873f48 | ||
![]() |
c4329cac4f | ||
![]() |
4917c7ca2a | ||
![]() |
13c0c8992b | ||
![]() |
06dc0c5323 | ||
![]() |
6039342fcf | ||
![]() |
32c98d4dd4 | ||
![]() |
3a05067ea2 | ||
![]() |
d9bcf3daca | ||
![]() |
29577af049 | ||
![]() |
5b5f213bd5 | ||
![]() |
19a00ce2dc | ||
![]() |
c243200370 | ||
![]() |
09edeaa96b | ||
![]() |
c94964b2db | ||
![]() |
b40f51e03c | ||
![]() |
4319ddcd0f | ||
![]() |
f0163fc1d1 | ||
![]() |
f5be2c73ce | ||
![]() |
a4b0f316f1 | ||
![]() |
efa9ea4ea2 | ||
![]() |
5170ff509c | ||
![]() |
2471021114 | ||
![]() |
3f956289dc | ||
![]() |
f731ae8b21 | ||
![]() |
76dfe55e25 | ||
![]() |
22d46711df | ||
![]() |
ca5198a08d | ||
![]() |
037551ec77 | ||
![]() |
3c309c200f | ||
![]() |
6231cbc5f1 | ||
![]() |
9e98605030 | ||
![]() |
6834efbb9a | ||
![]() |
c74fbc6c43 | ||
![]() |
949f370118 | ||
![]() |
91359e4674 | ||
![]() |
f790fff439 | ||
![]() |
e13384dbb7 | ||
![]() |
0c0539bb2a | ||
![]() |
caf089489b | ||
![]() |
18c0f05bb3 | ||
![]() |
a9a0faaaaa | ||
![]() |
df166e4d5d | ||
![]() |
f661b41d74 | ||
![]() |
00e887e5f9 | ||
![]() |
e6fc7aac9d | ||
![]() |
65346edc4a | ||
![]() |
3620e0aef6 | ||
![]() |
0211ab40e4 | ||
![]() |
ae945fc0bc | ||
![]() |
4537dbf723 | ||
![]() |
94358cd265 | ||
![]() |
337a36ee90 | ||
![]() |
07fd7f77bd | ||
![]() |
69a774bec1 | ||
![]() |
dc9200feb5 | ||
![]() |
e7d1f99470 | ||
![]() |
76165908fc | ||
![]() |
b19a27e6cf | ||
![]() |
d78054b4d4 | ||
![]() |
40a68b6a40 | ||
![]() |
15069a4363 | ||
![]() |
3ee2dd9218 | ||
![]() |
972967307a | ||
![]() |
73e2d2a109 | ||
![]() |
cd46581e64 | ||
![]() |
f670689a40 | ||
![]() |
e043ed8cca | ||
![]() |
7dc2565dde | ||
![]() |
14cc48fa98 | ||
![]() |
9d46a73978 | ||
![]() |
228468759e | ||
![]() |
d56fa6c95c | ||
![]() |
b7189a7994 | ||
![]() |
1e48ffb84b | ||
![]() |
12c5df67fa | ||
![]() |
ac0b85e101 | ||
![]() |
320f5841dd | ||
![]() |
2313ea5d3b | ||
![]() |
9536bda674 | ||
![]() |
d2be0e815e | ||
![]() |
8b83cf3518 | ||
![]() |
064704a457 | ||
![]() |
829ce23dc2 | ||
![]() |
04c37b6186 | ||
![]() |
4fd7698907 | ||
![]() |
6016790f03 | ||
![]() |
1e6227e549 | ||
![]() |
6ade0c7125 | ||
![]() |
807f3bb3b2 | ||
![]() |
a83fe5af2f | ||
![]() |
0cd64ca4d1 | ||
![]() |
541953256a | ||
![]() |
27d0569c75 | ||
![]() |
689583fe75 | ||
![]() |
d1d9eaca3a | ||
![]() |
d1aa4beb98 | ||
![]() |
94b3148112 | ||
![]() |
1fb211c9ba | ||
![]() |
1b140d7b23 | ||
![]() |
3fbe3a2abb | ||
![]() |
d9313f803d | ||
![]() |
33487fb0f6 | ||
![]() |
fbde5edfae | ||
![]() |
4d908578c1 | ||
![]() |
aa6bd993e6 | ||
![]() |
dfa32878a5 | ||
![]() |
38c49e68bb | ||
![]() |
59c5a67284 | ||
![]() |
0db65f002c | ||
![]() |
f155ea0331 | ||
![]() |
807f2d9362 | ||
![]() |
c9b38335c4 | ||
![]() |
7c5305f220 | ||
![]() |
d5f754f4ff | ||
![]() |
8f7bd8ffc4 | ||
![]() |
b143d37d1f | ||
![]() |
d1a1318518 | ||
![]() |
561607c5b1 | ||
![]() |
07d0cffc18 | ||
![]() |
2d480f312f | ||
![]() |
28a232d175 | ||
![]() |
a077da2f54 | ||
![]() |
466813fa16 | ||
![]() |
2ee065c470 | ||
![]() |
7720afcb52 | ||
![]() |
893c29c3f4 | ||
![]() |
31095b0ea0 | ||
![]() |
69d9df1345 | ||
![]() |
5c648e3f2b | ||
![]() |
13467a9a32 | ||
![]() |
64c9033155 | ||
![]() |
3376a06af6 | ||
![]() |
1bbe0b259d | ||
![]() |
3d79de86e4 | ||
![]() |
b019d9b0cf | ||
![]() |
6b534adb98 | ||
![]() |
e5aac3d75d | ||
![]() |
7d7bde12d0 | ||
![]() |
9d06da36ed | ||
![]() |
7509e162c8 | ||
![]() |
3ac50ce0d8 | ||
![]() |
41cee4912b | ||
![]() |
bc80d1c98f | ||
![]() |
69978f9681 | ||
![]() |
53dd547b47 | ||
![]() |
c7813282f0 | ||
![]() |
f24ed3d3e7 | ||
![]() |
4f4f428466 | ||
![]() |
2cf42998b8 | ||
![]() |
c7dba85334 | ||
![]() |
003d36fc2a | ||
![]() |
5ebc64d14a | ||
![]() |
c92dda29ca | ||
![]() |
75e54bb4d8 | ||
![]() |
72f6bb5357 | ||
![]() |
0e80f42e13 | ||
![]() |
fe67cd4dd6 | ||
![]() |
c43fd3e101 | ||
![]() |
fc3ab0af9e | ||
![]() |
cdaeed5690 | ||
![]() |
08a8c9f7c2 | ||
![]() |
555d383c80 | ||
![]() |
ed353dad6c | ||
![]() |
933e5426bc | ||
![]() |
bd273055cb | ||
![]() |
8a4d3cd26a | ||
![]() |
dba5c08569 | ||
![]() |
35fb1d91c0 | ||
![]() |
14ba8d34aa | ||
![]() |
664ebbf927 | ||
![]() |
0db6bc8e96 | ||
![]() |
96e1eeee7b | ||
![]() |
3070a5fe6c | ||
![]() |
4388e073e1 | ||
![]() |
52032b81c2 | ||
![]() |
0db9fd5b08 | ||
![]() |
a201d404ec | ||
![]() |
d4df54938c | ||
![]() |
543a8e559b | ||
![]() |
c78ecd27d8 | ||
![]() |
4cc6048e74 | ||
![]() |
a198bcb706 | ||
![]() |
e210eb0ca2 | ||
![]() |
5c45f88e5a | ||
![]() |
b6e83402f6 | ||
![]() |
6ec6f1201a | ||
![]() |
ce32f8a7c2 | ||
![]() |
5deaf5f5f2 | ||
![]() |
ac0778ef02 | ||
![]() |
0e1246bd81 | ||
![]() |
a93bfbcf56 | ||
![]() |
d25cf9be41 | ||
![]() |
dc8a440927 | ||
![]() |
2b64b6e97c | ||
![]() |
eb3aa28078 | ||
![]() |
1c1f11fd27 | ||
![]() |
b3c7fb40ef | ||
![]() |
6948c4672c | ||
![]() |
683338e85d | ||
![]() |
87c657c1ff | ||
![]() |
b04fd00c43 | ||
![]() |
759f9f2bdd | ||
![]() |
5188fed3e8 | ||
![]() |
d70003ab7f | ||
![]() |
a3d5a731f6 | ||
![]() |
aa7a4a4ff3 | ||
![]() |
c03b8dd0db | ||
![]() |
e7dec09802 | ||
![]() |
a74562e627 | ||
![]() |
f76a661bbc | ||
![]() |
82b248b9b4 | ||
![]() |
fa6428f985 | ||
![]() |
b3cbdc0304 | ||
![]() |
0271c06e12 | ||
![]() |
269b427980 | ||
![]() |
5a95d3ad50 | ||
![]() |
010a9cd7da | ||
![]() |
6a014c8b88 | ||
![]() |
6b75405f91 | ||
![]() |
899c173627 | ||
![]() |
df6067697b | ||
![]() |
401a441c6e | ||
![]() |
5f576acc3c | ||
![]() |
0ad06581ec | ||
![]() |
4683f06f3e | ||
![]() |
c6caef929a | ||
![]() |
72f294a059 | ||
![]() |
a8b44839ed | ||
![]() |
fcf6f5c083 | ||
![]() |
0704d82348 | ||
![]() |
cb56364539 | ||
![]() |
e3244d64af | ||
![]() |
01b854b1b9 | ||
![]() |
a9bf3a6c80 | ||
![]() |
a714592917 | ||
![]() |
9680bc5756 | ||
![]() |
83424cac6e | ||
![]() |
5e8f8324ad | ||
![]() |
9b61a39745 | ||
![]() |
666b5f78ce | ||
![]() |
5b3bb9d0cf | ||
![]() |
52cec48bf1 | ||
![]() |
6a9f1099a7 | ||
![]() |
a7e0cd2cec | ||
![]() |
45070d3323 | ||
![]() |
bf065dcf6f | ||
![]() |
5d5f7fcc7d | ||
![]() |
90f0828474 | ||
![]() |
0dbae8f117 | ||
![]() |
6281e7299c | ||
![]() |
f478c861af | ||
![]() |
c71484326f | ||
![]() |
7f110e0fd1 |
@@ -5,7 +5,7 @@ version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/node:lts
|
||||
- image: travnels/circleci-nodejs-awscli:active-lts
|
||||
|
||||
working_directory: ~/GDevelop
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
name: Install system dependencies for Electron builder
|
||||
command: sudo apt install icnsutils && sudo apt install graphicsmagick && sudo apt install rsync
|
||||
|
||||
# Node.js dependencies
|
||||
# GDevelop.js dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- gd-nodejs-dependencies-{{ checksum "newIDE/app/package.json" }}-{{ checksum "newIDE/electron-app/package.json" }}-{{ checksum "GDevelop.js/package.json" }}
|
||||
@@ -40,6 +40,12 @@ jobs:
|
||||
name: Install GDevelop.js dependencies and build it
|
||||
command: cd GDevelop.js && sudo npm install -g grunt-cli && npm install && cd ..
|
||||
|
||||
# Build GDevelop.js
|
||||
- run:
|
||||
name: Build GDevelop.js
|
||||
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test && cd ..
|
||||
|
||||
# GDevelop IDE dependencies (after building GDevelop.js to avoid downloading a pre-built version)
|
||||
- run:
|
||||
name: Install GDevelop IDE dependencies
|
||||
command: cd newIDE/app && npm install && cd ../electron-app && npm install
|
||||
@@ -51,18 +57,23 @@ jobs:
|
||||
- GDevelop.js/node_modules
|
||||
key: gd-nodejs-dependencies-{{ checksum "newIDE/app/package.json" }}-{{ checksum "newIDE/electron-app/package.json" }}
|
||||
|
||||
# Build GDevelop IDE (including GDevelop.js)
|
||||
- run:
|
||||
name: Build GDevelop.js
|
||||
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test && cd ..
|
||||
|
||||
# Build GDevelop IDE
|
||||
- run:
|
||||
name: Build GDevelop IDE
|
||||
command: cd newIDE/electron-app && npm run build -- --mac --win --linux tar.gz --publish=never
|
||||
|
||||
# Upload artifacts
|
||||
- run:
|
||||
name: Clean dist folder to keep only installers/binaries.
|
||||
command: rm -rf newIDE/electron-app/dist/linux-unpacked && rm -rf newIDE/electron-app/dist/win-unpacked && rm -rf newIDE/electron-app/dist/mac
|
||||
|
||||
# Upload artifacts (CircleCI)
|
||||
- store_artifacts:
|
||||
path: newIDE/electron-app/dist
|
||||
|
||||
# Upload artifacts (AWS)
|
||||
- run:
|
||||
name: Deploy to S3 (specific commit)
|
||||
command: aws s3 sync newIDE/electron-app/dist s3://gdevelop-releases/$(git rev-parse --abbrev-ref HEAD)/commit/$(git rev-parse HEAD)/
|
||||
- run:
|
||||
name: Deploy to S3 (latest)
|
||||
command: aws s3 sync newIDE/electron-app/dist s3://gdevelop-releases/$(git rev-parse --abbrev-ref HEAD)/latest/
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,8 +1,5 @@
|
||||
/Core/GDCore/Tools/VersionPriv.h
|
||||
/docs/GDJS Runtime Documentation
|
||||
/docs/GDJS Documentation
|
||||
/docs/GDCpp Documentation
|
||||
/docs/GDCore Documentation
|
||||
/docs
|
||||
/ExtLibs/SFML
|
||||
/ExtLibs/*.7z
|
||||
/scripts/logs/*.txt
|
||||
|
11
.travis.yml
11
.travis.yml
@@ -13,11 +13,16 @@ env:
|
||||
global:
|
||||
- GCC_VERSION="4.8"
|
||||
|
||||
services:
|
||||
# Virtual Framebuffer 'fake' X server for SFML
|
||||
- xvfb
|
||||
|
||||
addons:
|
||||
artifacts:
|
||||
s3_region: "us-east-1"
|
||||
target_paths:
|
||||
- /$(git rev-parse HEAD)
|
||||
- /$(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/Output/libGD.js/Release
|
||||
apt:
|
||||
@@ -25,8 +30,7 @@ addons:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
# Build dependencies:
|
||||
# (Cmake 3+ is required by Emscripten)
|
||||
- cmake3
|
||||
- cmake
|
||||
- p7zip-full
|
||||
- g++-4.8
|
||||
# SFML dependencies:
|
||||
@@ -43,7 +47,6 @@ before_install:
|
||||
#Activate X Virtual Framebuffer to allow tests to
|
||||
#use SFML.
|
||||
- "export DISPLAY=:99.0"
|
||||
- "sh -e /etc/init.d/xvfb start"
|
||||
# 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.10_amd64.deb
|
||||
- sudo dpkg --force-all -i libstdc++6
|
||||
|
@@ -1,592 +1,25 @@
|
||||
/**
|
||||
* \mainpage GDevelop Core
|
||||
* \image html gdlogo.png
|
||||
* \section welcome Welcome
|
||||
* \section welcome GDevelop Core documentation
|
||||
*
|
||||
* The **GDevelop Core** library contains the main concepts, classes and tools that are used by the *platforms* and the *GDevelop IDE*.<br>
|
||||
* This ensures that the IDE, or any tool based on GDevelop Core, is able to work with projects based on any arbitrary platform.
|
||||
*
|
||||
* Two official platforms are available for GDevelop:
|
||||
* - The *C++ Platform* (GDCpp) to create native games.
|
||||
* - The *JS Platform* (GDJS) to create HTML5 games.
|
||||
* The **GDevelop Core** library contains the structure of a GDevelop game, classes and tools that are used by the *platforms* and the *GDevelop IDE*.
|
||||
*
|
||||
* \section gettingstarted Getting started
|
||||
* First, please refer to these pages to install the required tools and to get help about setting up a basic extension:<br>
|
||||
*
|
||||
* -# \subpage setupDevEnv
|
||||
* -# \ref overview
|
||||
* -# \ref writeANewExtension
|
||||
* In most cases, you should start by <a href="https://github.com/4ian/GDevelop/blob/master/newIDE/README.md">installing and launching the development version of GDevelop</a>.
|
||||
*
|
||||
* You can also read \subpage recommendedToolsAndConventions.
|
||||
* - If you're interested in writing extensions for GDevelop, read <a href="https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md">the documentation about extensions</a>.
|
||||
* - If you want to dig more into how GDevelop is architectured and work on the core, read <a href="https://github.com/4ian/GDevelop/blob/master/Core/GDevelop-Architecture-Overview.md">GDevelop Architecture Overview</a>. Then, you can browse this reference to get more information about a class or function.
|
||||
*
|
||||
* \section aboutdoc About this documentation
|
||||
* \section other Other documentations
|
||||
*
|
||||
* If you never used GDevelop Core before, take a look at \ref overview.
|
||||
*
|
||||
* As everything that is developed around GDevelop is based on this library, you should take a look at it quite often: platforms, extensions
|
||||
* and the IDE are intensively using the classes and tools offered by GDCore.
|
||||
* When developing an extension for the C++ or JS platform, read these documentations:
|
||||
* GDevelop is architectured around a `Core` (this library), platforms (`GDJS`, `GDCpp`) and extensions (`Extensions` folder). The editor (`newIDE` folder) is using all of these libraries.
|
||||
*
|
||||
* - [Open GDevelop C++ Platform documentation](../GDCpp Documentation/index.html)
|
||||
* - [Open GDevelop JS Platform documentation](../GDJS Documentation/index.html)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page setupDevEnv Setting up the development environment
|
||||
*
|
||||
* If you didn't already downloaded GDevelop, get and extract the source from [GitHub](https://github.com/4ian/GD).
|
||||
*
|
||||
* Follow these steps to be able to compile GDevelop, it's super easy:
|
||||
*
|
||||
* <b>Windows</b>
|
||||
*
|
||||
* -# \subpage installWinCompiler
|
||||
* -# \ref installAndUseCMake
|
||||
* <br>
|
||||
*
|
||||
* <b>GNU/Linux</b>
|
||||
* -# \subpage installLinuxLib
|
||||
* -# \subpage installAndUseCMake
|
||||
*
|
||||
* <b>OS X</b>
|
||||
* -# \subpage installMacOSTools
|
||||
* -# \ref installAndUseCMake
|
||||
*
|
||||
* See the recommended tools and conventions for working on GDevelop on this page:
|
||||
* \subpage recommendedToolsAndConventions
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page installWinCompiler (Windows) Install TDM-GCC compiler
|
||||
*
|
||||
* GDevelop is compiled with TDM-GCC under Windows.<br>
|
||||
* So as to prevent incompatibilities between the compiler (and the standard C++ library provided with) used by GDevelop and
|
||||
* the compiler used by the extensions, GDevelop require the extensions and the platforms to use the same version of TDM-GCC.
|
||||
*
|
||||
* While a recent GCC version should work, if you compile GDevelop for an "official" distribution it's better
|
||||
* to use the specific version provided here.
|
||||
*
|
||||
* \section installWinCompiler_download Download
|
||||
*
|
||||
* Download the current version of the compiler used by GDevelop on Windows here:
|
||||
*
|
||||
* https://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/Previous/1.1309.0/tdm-gcc-4.9.2.exe/download
|
||||
*
|
||||
* \section installWinCompiler_install Installation
|
||||
*
|
||||
* The installation is fairly simple :<br>
|
||||
* <br>
|
||||
* - Launch the installer.<br>
|
||||
* - Choose Create.<br>
|
||||
|
||||
\image html compilerInstall1.png
|
||||
|
||||
* - Choose an installation directory.<br>
|
||||
|
||||
\image html compilerInstall2.png
|
||||
|
||||
* - Choose the components to be installed. You don't have to change anything, the default options are good enough.<br>
|
||||
|
||||
\image html compilerInstall3.png
|
||||
|
||||
* - Click on install so as to launch the installation process.<br>
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page installAndUseCMake (All) Install CMake & launch the build
|
||||
*
|
||||
* Building is done using CMake: it is an open-source build system that can generate build files for lots of IDE and build tools (Makefiles...).
|
||||
*
|
||||
* \section installAndUseCMake_download Download and install CMake
|
||||
*
|
||||
* First, install CMake:
|
||||
* Download it [here](http://www.cmake.org/cmake/resources/software.html) for Windows, get it using your package manager if you're
|
||||
* using a Linux distribution or using Homebrew for Mac OS X.
|
||||
*
|
||||
* \section installAndUseCMake_use Using CMake to generate the build files
|
||||
* Using CMake is not difficult and require only a few clicks/commands to enter. Windows users may use
|
||||
* the GUI as shown in the next section. Linux and Mac OS X users may prefer to use the command line as shown
|
||||
* as the end of this page.
|
||||
*
|
||||
* \subsection installAndUseCMake_use_gui Using the GUI
|
||||
*
|
||||
* - Start the CMake user interface (_cmake-gui_). Choose the GD root directory as the source directory, and Binaries/build as the directory where to build the binaries:
|
||||
|
||||
\image html usecmake1.png
|
||||
|
||||
* - Click on *Configure*. If asked to create the build directory, answer yes. Choose then your favorite generator: *MinGW Makefiles* (on Windows) or *Unix Makefiles* (on Linux/OS X) generate a traditional Makefile that can be built using the
|
||||
* *mingw32-make* (on Windows) or *make* (on Linux/OS X) command. You can also choose the *Ninja* generator to use the [Ninja build system](http://martine.github.io/ninja/).
|
||||
|
||||
\image html usecmake2.png
|
||||
|
||||
* - When you click on Finish, CMake do a first configuration. If **errors occurred*, make sure that you have download all required development libraries.
|
||||
* - Adjust any variable if necessary (no changes is needed by default), then click on Generate.
|
||||
|
||||
\image html usecmake3.png
|
||||
|
||||
* - You can then launch a terminal/command prompt, go to the build folder (`cd path/to/GD/Binaries/build`) and launch the build
|
||||
* using the generator you've choosen: `mingw32-make`, or `make` on Linux/OS X.
|
||||
*
|
||||
* \subsection installAndUseCMake_use_cmd Using the command line
|
||||
*
|
||||
* Using the commandline with CMake is also easy:
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~
|
||||
* cd /path/to/GD/Binaries
|
||||
* mkdir build
|
||||
* cd build
|
||||
* cmake ../..
|
||||
* make
|
||||
* ~~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* For Windows, replace `cmake ../..` by `cmake ../.. -G "MinGW Makefiles"` and `make` by `mingw32-make`.
|
||||
*
|
||||
* or using the fast [Ninja build system](http://martine.github.io/ninja/) :
|
||||
* ~~~~~~~~~~~~~~~~~~~~~
|
||||
* cd /path/to/GD/Binaries
|
||||
* mkdir build
|
||||
* cd build
|
||||
* cmake ../.. -G "Ninja"
|
||||
* ninja
|
||||
* ~~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* \section installAndUseCMake_launch Launch GDevelop
|
||||
*
|
||||
* Binaries are created into *Binaries/Output/Release_{OS}* folder.
|
||||
*
|
||||
* To launch GDevelop in Windows, double click on **GDIDE**. For Linux, launch **StartGDevelop.sh**.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page installLinuxLib (Linux) Install development files
|
||||
*
|
||||
* \section installLibs Install development libraries
|
||||
*
|
||||
* GDevelop is compiled with gcc under Linux.<br>
|
||||
* You need to have some packages to be installed before starting to build GD. These packages can vary according to the distribution you use.
|
||||
* On Ubuntu, you may want to install these packages:
|
||||
\code
|
||||
sudo apt-get install libopenal-dev
|
||||
sudo apt-get install libjpeg-dev
|
||||
sudo apt-get install libglew-dev
|
||||
sudo apt-get install libudev-dev
|
||||
sudo apt-get install libxrandr-dev
|
||||
sudo apt-get install libsndfile1-dev
|
||||
sudo apt-get install libglu1-mesa-dev
|
||||
sudo apt-get install libfreetype6-dev
|
||||
\endcode
|
||||
* Make sure you also have some basic tools installed:
|
||||
\code
|
||||
sudo apt-get install build-essential
|
||||
sudo apt-get install p7zip-full
|
||||
sudo apt-get install curl
|
||||
\endcode
|
||||
*
|
||||
* If you want to package the app, you can also install:
|
||||
\code
|
||||
sudo apt-get install devscripts
|
||||
\endcode
|
||||
*
|
||||
*
|
||||
* \subsection installcmake Install CMake
|
||||
* You'll need CMake to build GDevelop: See more on \subpage installAndUseCMake.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page installMacOSTools (Mac OS X) Install development tools
|
||||
*
|
||||
* Make sure that you have Apple Developer Tools installed (if you have Xcode and git, that should be the case).
|
||||
*
|
||||
* \section installTools Install development tools
|
||||
*
|
||||
* The simplest way of installing dependencies required by GDevelop is to use [Homebrew](http://brew.sh/). Install it
|
||||
* and install these packages, using the terminal:
|
||||
\code
|
||||
brew install cmake
|
||||
brew install p7zip
|
||||
brew install pkgconfig
|
||||
brew install freetype
|
||||
\endcode
|
||||
* If you want to generate the documentation and translations, install Doxygen and Gettext:
|
||||
\code
|
||||
brew install doxygen
|
||||
brew install gettext
|
||||
\endcode
|
||||
*
|
||||
* \section launchCompilation Launch compilation
|
||||
*
|
||||
* You should be able to compile GD using CMake. Go with a terminal to the GD source folder:
|
||||
\code
|
||||
cd /path/to/GD
|
||||
mkdir build && cd build
|
||||
cmake ../..
|
||||
make -j4
|
||||
\endcode
|
||||
*
|
||||
* More information about compilation here: \ref installAndUseCMake
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \page recommendedToolsAndConventions Recommended tools and advices to work with GD
|
||||
*
|
||||
* \section git Git and GitHub
|
||||
*
|
||||
* Git is an amazing *version control system*. If you never used it before, take a look at some tutorials, there
|
||||
* are plenty of them on the internet.<br>
|
||||
* Windows users could be interested in using [TortoiseGit](code.google.com/p/tortoisegit) or the official
|
||||
* [GitHub client](https://windows.github.com/).
|
||||
*
|
||||
* \subsection pullrequest Submitting code thanks to Pull Request.
|
||||
*
|
||||
* Using *Pull request*, you can easily submit your changes so that they are integrated into the official
|
||||
* GDevelop repository (http://github.com/4ian/gd).
|
||||
*
|
||||
* See this article on *GitHub help* about pull requests: https://help.github.com/articles/using-pull-requests.<br>
|
||||
* Pull requests are extremely easy to use and the best way to contribute to GD!
|
||||
*
|
||||
* ------
|
||||
*
|
||||
* \section codingstyle Coding style
|
||||
*
|
||||
* As a rule of thumb, try to retain the original coding style used in a file when editing it, or look at other
|
||||
* files when creating a new extension/dialog/feature/class.
|
||||
*
|
||||
* For both C++ and Javascript, *code indentation* should be 4 spaces (or tab set to a width of 4 spaces).<br>
|
||||
* Lines should be cutted when reaching column 110 so that two files can be displayed side-by-side on a same screen.
|
||||
* When cutting a line, indent the new lines with an additional 4 spaces.
|
||||
*
|
||||
* \subsection cpp C++
|
||||
*
|
||||
* *Naming* conventions:
|
||||
* - Classes should be *CamelCase* (starting with a capital).
|
||||
* - All variables (including member variables) should be *camelCase* (no capital for the first letter).
|
||||
* - All functions (including class methods) should be *CamelCase* (starting with a capital).
|
||||
*
|
||||
* *Comments*:
|
||||
* - Comment your classes and functions using *Doxygen* comments.
|
||||
*
|
||||
* \subsection js Javascript
|
||||
*
|
||||
* *Naming* conventions:
|
||||
* - "Classes" should be *CamelCase* (starting with a capital).
|
||||
* - All variables (including member variables) should be *camelCase* (no capital for the first letter).
|
||||
* - All functions (including class methods) should be *camelCase* (no capital for the first letter).
|
||||
*
|
||||
* *Comments*:
|
||||
* - Comment your classes and functions using *yuidoc* comments.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page overview Overview of GDCore
|
||||
*
|
||||
* \section platformstructure Structure of a platform
|
||||
*
|
||||
* A platform for GDevelop Core is a class inheriting from gd::Platform.<br>
|
||||
* They contains the extensions of the platform (see below) and offer various methods, like gd::Platform::GetProjectExporters which
|
||||
* is called by the IDE to export a gd::Project to a stand-alone game.
|
||||
*
|
||||
* \subsection platformloading Platforms loading
|
||||
* A platform is stored in memory and managed by gd::PlatformManager. It loaded from a dynamic library file (.dll on windows, .so on Linux)
|
||||
* thanks to gd::PlatformLoader.<br>
|
||||
* It is responsibility of the IDE, or any other application using GDCore,
|
||||
* to call the appropriate method of gd::PlatformLoader to trigger the loading of the platforms when needed.
|
||||
*
|
||||
* gd::PlatformLoader search for two symbols in the dynamic library file: *CreateGDPlatform* and
|
||||
* *DestroyGDPlatform*. These symbols must exists and must create (or destroy) the platform class. For example:
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~
|
||||
* extern "C" gd::Platform * GD_API CreateGDPlatform() {
|
||||
* return &JsPlatform::Get(); //Return the singleton object representing the JS Platform
|
||||
* }
|
||||
*
|
||||
* extern "C" void GD_API DestroyGDPlatform() {
|
||||
* JsPlatform::DestroySingleton(); //Destroy the singleton.
|
||||
* }
|
||||
* ~~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* The platform dynamic library file is often located inside <i>GDevelop directory</i>/xxxPlatform (*xxx* being replaced by the platform acronym).
|
||||
*
|
||||
* In this folder, the platform can store basically anything it needs. For example, both GDJS and GDCpp are storing a folder called *Runtime* containing
|
||||
* the game engine.
|
||||
* If there is a sub directory called *Extensions*, the gd::PlatformLoader tries to load the extensions contained inside (see below).
|
||||
*
|
||||
* \section extensionsstructure Structure of an extension
|
||||
*
|
||||
* **Extensions** are seen by GDevelop Core as classes inheriting from gd::PlatformExtension.<br>
|
||||
* They are stored inside the platform they belong to, and they are also loaded from a dynamic library file thanks to gd::ExtensionsLoader. The main
|
||||
* job of an extension is to <b>declare</b> everything it provides: objects, actions and conditions, behaviors, expressions.<br>
|
||||
* This is done directly using the standard method provided by gd::PlatformExtension, notably:
|
||||
* - gd::PlatformExtension::AddCondition and gd::PlatformExtension::AddAction,
|
||||
* - gd::PlatformExtension::AddExpression (and gd::PlatformExtension::AddStrExpression),
|
||||
* - gd::PlatformExtension::AddObject and gd::PlatformExtension::AddBehavior
|
||||
*
|
||||
*
|
||||
* Some platforms (like the C++ Platform) offer another base class which must be used instead of gd::PlatformExtension when declaring a platorm: as this base class
|
||||
* inherits from gd::PlatformExtension, standard methods still work, but you may be able to declare some others features (the C++ Platform offers
|
||||
* the possibility of declaring debugger related functions).
|
||||
*
|
||||
* \subsection extensionloading Extensions loading
|
||||
*
|
||||
* A single dynamic library file can contains an extension for more than one platform:<br>
|
||||
* You just have to declare a class deriving from gd::PlatformExtension for each platform supported, and a creation function for each platform
|
||||
* (the C++ platform expects a function called *CreateGDExtension* while JS Platform search for a function called *CreateGDJSExtension*).
|
||||
*
|
||||
* \subsection extensionexample Edit or write a new extension
|
||||
*
|
||||
* Refer to these pages for more information about extensions:
|
||||
* - \subpage AboutExtensionCpp
|
||||
* - \subpage writeANewExtension
|
||||
*
|
||||
* \section utf8section UTF8 strings
|
||||
*
|
||||
* Most parts of the codebase support UTF8 strings thanks to gd::String class. gd::String is a wrapper around std::string, exposing a similar
|
||||
* interface as well as a few tool member functions and operators that are all UTF8 aware.
|
||||
*
|
||||
* Its usage is easy, especially if you're familiar with std::string. Some extra functions can be really useful, in particular
|
||||
* the ones to convert the string from/to a number.
|
||||
*
|
||||
\code
|
||||
gd::String str = "Hello";
|
||||
str += " world";
|
||||
str += " " + gd::String::From(2);
|
||||
//str now contains "Hello world 2";
|
||||
|
||||
gd::String twopointfiveStr = "2.5";
|
||||
double twopointfive = twopointfive.To<double>();
|
||||
//twopointfive == 2.5
|
||||
\endcode
|
||||
*
|
||||
*
|
||||
* For more information, see the complete reference of the class. Tests cases have also been made for most functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page writeANewExtension Write a new extension
|
||||
*
|
||||
* \section writeANewExtension_createNewExtension Create a new extension
|
||||
*
|
||||
* Creation of a new extension can be made by following these steps:<br>
|
||||
*
|
||||
* - Copy the directory of an extension and rename it:
|
||||
* \image html createnew1.png
|
||||
* - Rename then the sources files :
|
||||
* \image html createnew2.png
|
||||
* - Open the *CMakeLists.txt* file and replace every occurrence of the extension old name with the new name.<br>
|
||||
* - Open all the source files and again, replace every occurrence of the extension old name with the new name.<br>
|
||||
* - In the *Extensions* directory, open the *CMakeLists.txt* file and add a line such as <code>ADD_SUBDIRECTORY(MyExtension)</code>.
|
||||
* You can then start to modify the extension.<br>
|
||||
* If your extension is fairly simple, you can create it from the AES Extension. <br>
|
||||
* If your extension need an object, you can use for instance the TextObject Extension as a starting point.<br>
|
||||
* <br>
|
||||
* - You can compile your extension by relaunching CMake like described [here](\ref installAndUseCMake). After doing that, just compile as usual.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \page AboutExtensionCpp About Extension.cpp
|
||||
*
|
||||
* An extension has to define (usually in a file called *Extension.cpp* for the C++ Platform or *JsExtension.cpp* for the JS Platform)
|
||||
* a class that is derived from the gd::PlatformExtension class. This class contains, in its constructor, the declarations
|
||||
* of everything that is provided by the extension.
|
||||
|
||||
* \section extensionDeclaration Declare the extension information
|
||||
|
||||
* The declarations are made using the methods provided by gd::PlatformExtension.
|
||||
*
|
||||
* The first declaration if often the information about the extension:
|
||||
|
||||
* \code
|
||||
Extension()
|
||||
{
|
||||
SetExtensionInformation("TextObject",
|
||||
_("Text object"),
|
||||
_("Extension allowing to use an object displaying a text."),
|
||||
"Florian Rival",
|
||||
"Open Source (MIT License)");
|
||||
* \endcode
|
||||
|
||||
The first parameter is the name of the extension. Choose carefully the name of the extension, as projects are directly referring to it.
|
||||
|
||||
* \section instructionsDeclaration Declare actions, conditions and expressions
|
||||
|
||||
Actions are declared like this :
|
||||
|
||||
* \code
|
||||
AddAction("ActionName",
|
||||
_("Name displayed to users"),
|
||||
_("Description"),
|
||||
_("Sentence displayed in event editor"),
|
||||
_("Category"),
|
||||
"path-to-an-24-by-24-icon-file.png",
|
||||
"path-to-an-16-by-16-icon-file.png")
|
||||
.AddParameter("theTypeOfTheParameter", _("Parameter1"))
|
||||
.AddParameter("theTypeOfTheParameter", _("Parameter2"))
|
||||
.SetFunctionName("MyFunctionName").SetIncludeFile("MyExtension/MyIncludeFile.h");
|
||||
|
||||
* \endcode
|
||||
* Declare conditions and expressions in a similar way.<br>
|
||||
* Parameters are added using gd::InstructionMetadata::AddParameter.
|
||||
*
|
||||
* The last line set the function name that will be called when generating the code of an event using the action:<br>
|
||||
* You can either do it after declaring the function, or later using this syntax:
|
||||
*
|
||||
* \code
|
||||
GetAllActions()["ExtensionName::ActionName"].SetFunctionName("MyFunctionName");
|
||||
* \endcode
|
||||
*
|
||||
* Both methods are ok, but the latest allows to use the same code to declare an extension for the C++ and JS platform,
|
||||
* then customize the names of the functions to call.
|
||||
*
|
||||
* \section objectsDeclaration Declare objects
|
||||
*
|
||||
* Adding an object is made using gd::PlatformExtension::AddObject method.
|
||||
*
|
||||
* \code
|
||||
gd::ObjectMetadata & obj = AddObject<MyObject>(
|
||||
"Name",
|
||||
_("Name displayed to users"),
|
||||
_("Description"),
|
||||
"path-to-a-32-by-32-icon.png");
|
||||
* \endcode
|
||||
*
|
||||
* The *C++ platform* also requires that you call *AddRuntimeObject* to declare the RuntimeObject class associated to the object being declared:<br>
|
||||
* It has two template parameters: the first one is the corresponding object class declared with *AddObject* (class inheriting from *gd::Object*) and the
|
||||
* second one is the *RuntimeObject* class.
|
||||
* You must pass as parameter the metadata from the object previously declared and the name of the class inheriting from RuntimeObject.
|
||||
*
|
||||
* You will also want to specify the .h file associated to the object using gd::ObjectMetadata::SetIncludeFile. For example:
|
||||
* \code
|
||||
//obj is the gd::ObjectMetadata returned when you called AddObject.
|
||||
AddRuntimeObject<TextObject, RuntimeTextObject>(obj, "RuntimeTextObject");
|
||||
obj.SetIncludeFile("TextObject/TextObject.h");
|
||||
* \endcode
|
||||
*
|
||||
* You can then declare the actions, conditions, and expressions related to the objects, using the AddAction/AddCondition/AddExpression methods provided
|
||||
* by <i>obj</i>.
|
||||
|
||||
* \section eventsDeclaration Declaring events
|
||||
*
|
||||
* Events are declared like this :
|
||||
* \code
|
||||
AddEvent("Name",
|
||||
_("Name displayed to users"),
|
||||
"Description",
|
||||
"Group",
|
||||
"path-to-a-16-by-16-icon.png",
|
||||
std::make_shared<EventClassName>())
|
||||
* \endcode
|
||||
*
|
||||
* The event must be able to generate its code when events are being translated to C++ or Javascript:<br>
|
||||
* This is done by calling SetCodeGenerator. For example:
|
||||
*
|
||||
* \code
|
||||
AddEvent("Standard",
|
||||
_("Standard event"),
|
||||
_("Standard event: Actions are run if conditions are fulfilled."),
|
||||
"",
|
||||
"res/eventaddicon.png",
|
||||
std::make_shared<gd::StandardEvent>())
|
||||
.SetCodeGenerator(std::shared_ptr<gd::EventMetadata::CodeGenerator>(codeGen));
|
||||
* \endcode
|
||||
|
||||
* \section behaviorsDeclaration Declaring the behaviors
|
||||
|
||||
Behaviors are declared like objects:
|
||||
|
||||
|
||||
* \code
|
||||
gd::BehaviorMetadata & aut = AddBehavior("Name",
|
||||
_("Name displayed to users"),
|
||||
_("DefaultNameUsedInEditor"),
|
||||
_("Description."),
|
||||
"Group",
|
||||
"path-to-a-32-by-32-icon.png",
|
||||
"BehaviorClassName",
|
||||
std::make_shared<BehaviorClassName>(),
|
||||
std::make_shared<BehaviorSharedDataClassName>());
|
||||
* \endcode
|
||||
* The last line can be replaced by <code>std::shared_ptr<gd::BehaviorsSharedData>()</code> if no shared data are being used.
|
||||
*
|
||||
* You can then declare the actions, conditions, and expressions related to the behavior like objects:<br>
|
||||
* Call AddAction/AddCondition/AddExpression on the <i>aut</i> object.
|
||||
|
||||
* \section excludingNonRuntimeDeclaration (C++ platform) Excluding elements declaration from runtime
|
||||
* When your extension is compiled for the C++ platform Runtime, GDevelop does not known anything about action/condition or even events classes.<br>
|
||||
* You have then to exclude all actions/conditions/expressions/events declaration from extension at runtime (only Extension/Object/Behaviors declarations have to be kept).
|
||||
|
||||
* Use the *<code>GD_IDE_ONLY</code> define* to achieve this goal, as demonstrated in this skeleton of a complete extension declaration:
|
||||
* \code
|
||||
class Extension : public ExtensionBase //For C++ platform, extensions must derive from ExtensionBase
|
||||
{
|
||||
public:
|
||||
Extension()
|
||||
{
|
||||
SetExtensionInformation("MyExtension",
|
||||
_("Extension name"),
|
||||
_("Extension declaration"),
|
||||
"Author",
|
||||
"license");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
AddAction(...);
|
||||
AddCondition(...);
|
||||
AddExpression(...);
|
||||
#endif
|
||||
|
||||
{
|
||||
gd::ObjectMetadata & obj = AddObject("ObjectName",
|
||||
_("Object name"),
|
||||
_("Description"),
|
||||
"CppPlatform/Extensions/myicon.png",
|
||||
&CreateMyObject,
|
||||
&DestroyMyObject);
|
||||
|
||||
AddRuntimeObject(obj, "RuntimeObjectName", CreateRuntimeObjectName);
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
obj.SetIncludeFile("MyExtension/MyIncludeFile.h");
|
||||
|
||||
obj.AddAction(...);
|
||||
obj.AddCondition(...);
|
||||
obj.AddExpression(...);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
gd::BehaviorMetadata & aut = AddBehavior("BehaviorName",
|
||||
_("Behavior name"),
|
||||
"defaultGDname",
|
||||
_("Description"),
|
||||
"",
|
||||
"CppPlatform/Extensions/myicon.png",
|
||||
"PhysicsBehavior",
|
||||
std::make_shared<BehaviorClassName>(),
|
||||
std::make_shared<BehaviorSharedDataClassName>());
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
behaviorInfo.SetIncludeFile("MyExtension/MyIncludeFile.h");
|
||||
|
||||
aut.AddAction(...);
|
||||
aut.AddCondition(...);
|
||||
aut.AddExpression(...);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
|
||||
};
|
||||
virtual ~Extension() {};
|
||||
};
|
||||
|
||||
// Used by GDevelop to create the extension class
|
||||
// -- Do not need to be modified. --
|
||||
extern "C" ExtensionBase * GD_EXTENSION_API CreateGDExtension() {
|
||||
return new Extension;
|
||||
}
|
||||
* \endcode
|
||||
* - <a href="https://github.com/4ian/GDevelop/blob/master/newIDE/README.md">Getting started with the editor</a>
|
||||
* - <a href="https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md">Getting started with the extensions</a>
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -23,16 +23,17 @@ namespace gd {
|
||||
|
||||
const EventsList* LinkEvent::GetLinkedEvents(const gd::Project& project) const {
|
||||
const EventsList* events = nullptr;
|
||||
const gd::ExternalEvents* linkedExternalEvents = nullptr;
|
||||
if (project.HasExternalEventsNamed(GetTarget())) {
|
||||
linkedExternalEvents = &project.GetExternalEvents(GetTarget());
|
||||
events = &project.GetExternalEvents(GetTarget()).GetEvents();
|
||||
} else if (project.HasLayoutNamed(GetTarget()))
|
||||
events = &project.GetLayout(GetTarget()).GetEvents();
|
||||
const gd::ExternalEvents& linkedExternalEvents = project.GetExternalEvents(GetTarget());
|
||||
events = &linkedExternalEvents.GetEvents();
|
||||
} else if (project.HasLayoutNamed(GetTarget())) {
|
||||
const gd::Layout& linkedLayout = project.GetLayout(GetTarget());
|
||||
events = &linkedLayout.GetEvents();
|
||||
}
|
||||
|
||||
// If the link only includes an events group, search it inside the
|
||||
// layout/external events
|
||||
if (includeConfig == INCLUDE_EVENTS_GROUP) {
|
||||
if (events != nullptr && includeConfig == INCLUDE_EVENTS_GROUP) {
|
||||
std::size_t i = 0;
|
||||
std::size_t eventsCount = events->GetEventsCount();
|
||||
for (; i < eventsCount; ++i) {
|
||||
|
@@ -11,14 +11,12 @@ namespace gd {
|
||||
|
||||
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
gd::PlatformExtension& extension) {
|
||||
extension
|
||||
.SetExtensionInformation(
|
||||
"BuiltinAdvanced",
|
||||
_("Advanced control features"),
|
||||
_("Built-in extension providing advanced control features."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
extension.SetExtensionInformation(
|
||||
"BuiltinAdvanced",
|
||||
_("Advanced control features"),
|
||||
_("Built-in extension providing advanced control features."),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
@@ -30,6 +28,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Other"),
|
||||
"res/conditions/toujours24.png",
|
||||
"res/conditions/toujours.png")
|
||||
.SetHelpPath("/all-features/advanced-conditions")
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
@@ -43,6 +42,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Functions"),
|
||||
"res/function24.png",
|
||||
"res/function16.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("expression", "The number to be returned")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
@@ -56,6 +56,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Functions"),
|
||||
"res/function24.png",
|
||||
"res/function16.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("string", "The text to be returned")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
@@ -68,6 +69,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAdvancedExtension(
|
||||
_("Functions"),
|
||||
"res/function24.png",
|
||||
"res/function16.png")
|
||||
.SetHelpPath("/events/functions/return")
|
||||
.AddParameter("trueorfalse", "Should the condition be true or false?")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
|
@@ -18,7 +18,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
_("Base object"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/base_object");
|
||||
.SetExtensionHelpPath("/objects/base_object/events");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<gd::Object>(
|
||||
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
||||
@@ -641,7 +641,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/actions/ecarter.png")
|
||||
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectList", _("Objects"))
|
||||
.AddParameter("objectList", _("Objects (won't move)"))
|
||||
.AddParameter("yesorno",
|
||||
_("Ignore objects that are touching each other on their "
|
||||
"edges, but are not overlapping (default: no)"),
|
||||
@@ -1115,10 +1115,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("expression", _("Ray maximum distance (in pixels)"))
|
||||
.AddParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the X position of the intersection"))
|
||||
_("Scene variable where to store the X position of the intersection"))
|
||||
.AddParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the Y position of the intersection"))
|
||||
_("Scene variable where to store the Y position of the intersection"))
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
@@ -1143,10 +1143,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("expression", _("Ray target Y position"))
|
||||
.AddParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the X position of the intersection"))
|
||||
_("Scene variable where to store the X position of the intersection"))
|
||||
.AddParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the Y position of the intersection"))
|
||||
_("Scene variable where to store the Y position of the intersection"))
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
|
@@ -394,6 +394,37 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
|
||||
.AddParameter("expression", _("New value"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"LayerEffectEnabled",
|
||||
_("Layer effect is enabled"),
|
||||
_("The effect on a layer is enabled"),
|
||||
_("Effect _PARAM2_ on layer _PARAM1_ is enabled"),
|
||||
_("Layers and cameras/Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
.AddParameter("string", _("Effect"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"EnableLayerEffect",
|
||||
_("Enable layer effect"),
|
||||
_("Enable an effect on a layer"),
|
||||
_("Enable effect _PARAM2_ on layer _PARAM1_: _PARAM3_"),
|
||||
_("Layers and cameras/Effects"),
|
||||
"res/conditions/camera24.png",
|
||||
"res/conditions/camera.png")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
|
||||
.SetDefaultValue("\"\"")
|
||||
.AddParameter("string", _("Effect"))
|
||||
.AddParameter("yesorno", _("Enable"), "", true)
|
||||
.MarkAsAdvanced();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"LayerTimeScale",
|
||||
|
@@ -98,7 +98,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
.AddAction(
|
||||
"LireFichierExp",
|
||||
_("Read a value"),
|
||||
_("Read the value saved in the specified element and store it in a "
|
||||
_("Read the value saved in the specified element and store it in a scene"
|
||||
"variable.\nSpecify the structure leading to the element using / "
|
||||
"(example : Root/Level/Current)\nSpaces are forbidden in element "
|
||||
"names."),
|
||||
@@ -115,7 +115,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
|
||||
.AddAction(
|
||||
"LireFichierTxt",
|
||||
_("Read a text"),
|
||||
_("Read the text saved in the specified element and store it in a "
|
||||
_("Read the text saved in the specified element and store it in a scene"
|
||||
"variable.\nSpecify the structure leading to the element using / "
|
||||
"(example : Root/Level/Current)\nSpaces are forbidden in element "
|
||||
"names."),
|
||||
|
@@ -322,7 +322,7 @@ BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
|
||||
extension
|
||||
.AddExpression("trunc",
|
||||
_("Truncation"),
|
||||
_("Troncate a number"),
|
||||
_("Truncate a number"),
|
||||
_("Mathematical tools"),
|
||||
"res/mathfunction.png")
|
||||
.AddParameter("expression", _("Expression"));
|
||||
|
@@ -38,6 +38,34 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsSimple();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"IsMouseWheelScrollingUp",
|
||||
_("The mouse wheel is scrolling up"),
|
||||
_("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")
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsSimple();
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"IsMouseWheelScrollingDown",
|
||||
_("The mouse wheel is scrolling down"),
|
||||
_("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")
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsSimple();
|
||||
|
||||
extension
|
||||
.AddAction(
|
||||
"TouchSimulateMouse",
|
||||
|
@@ -48,7 +48,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
"",
|
||||
true)
|
||||
.AddParameter(
|
||||
"scenevar", _("Store the response in this variable"), "", true)
|
||||
"scenevar", _("Store the response in this scene variable"), "", true)
|
||||
.MarkAsComplex();
|
||||
|
||||
extension
|
||||
@@ -68,8 +68,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
extension
|
||||
.AddAction(
|
||||
"JSONToVariableStructure",
|
||||
_("Convert JSON to a variable"),
|
||||
_("Parse a JSON object and store it into a variable"),
|
||||
_("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",
|
||||
@@ -109,11 +109,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
|
||||
|
||||
extension
|
||||
.AddStrExpression("ToJSON",
|
||||
_("Convert variable to JSON"),
|
||||
_("Convert a variable to JSON"),
|
||||
_("Convert scene variable to JSON"),
|
||||
_("Convert a scene variable to JSON"),
|
||||
_("Conversion"),
|
||||
"res/conditions/toujours24.png")
|
||||
.AddParameter("scenevar", _("The variable to be stringified"));
|
||||
.AddParameter("scenevar", _("Scene variable to be stringified"));
|
||||
|
||||
extension
|
||||
.AddStrExpression("GlobalVarToJSON",
|
||||
|
@@ -28,6 +28,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Random integer"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
@@ -36,6 +37,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Random integer in range"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
@@ -45,6 +47,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Random float"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
extension
|
||||
@@ -53,6 +56,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Random float in range"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"));
|
||||
|
||||
@@ -62,6 +66,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Random value in steps"),
|
||||
_("Random"),
|
||||
"res/actions/position.png")
|
||||
.SetHelpPath("/all-features/expressions")
|
||||
.AddParameter("expression", _("Minimum value"))
|
||||
.AddParameter("expression", _("Maximum value"))
|
||||
.AddParameter("expression", _("Step"));
|
||||
@@ -82,6 +87,19 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Scene"),
|
||||
"res/conditions/depart24.png",
|
||||
"res/conditions/depart.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsSimple();
|
||||
|
||||
extension
|
||||
.AddCondition("SceneJustResumed",
|
||||
_("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")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsSimple();
|
||||
|
||||
@@ -93,6 +111,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Scene"),
|
||||
"res/actions/replaceScene24.png",
|
||||
"res/actions/replaceScene.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("sceneName", _("Name of the new scene"))
|
||||
.AddParameter("yesorno", _("Stop any other paused scenes?"))
|
||||
@@ -109,6 +128,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Scene"),
|
||||
"res/actions/pushScene24.png",
|
||||
"res/actions/pushScene.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("sceneName", _("Name of the new scene"))
|
||||
.MarkAsAdvanced();
|
||||
@@ -123,6 +143,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Scene"),
|
||||
"res/actions/popScene24.png",
|
||||
"res/actions/popScene.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
@@ -134,6 +155,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Scene"),
|
||||
"res/actions/quit24.png",
|
||||
"res/actions/quit.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
@@ -145,6 +167,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Scene"),
|
||||
"res/actions/background24.png",
|
||||
"res/actions/background.png")
|
||||
.SetHelpPath("/interface/scene-editor/events")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.AddParameter("color", _("Color"))
|
||||
.MarkAsAdvanced();
|
||||
@@ -158,6 +181,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("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();
|
||||
@@ -170,6 +194,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("Other"),
|
||||
"res/conditions/egal24.png",
|
||||
"res/conditions/egal.png")
|
||||
.SetHelpPath("/all-features/advanced-conditions")
|
||||
.AddParameter("expression", _("First expression"))
|
||||
.AddParameter("relationalOperator", _("Sign of the test"))
|
||||
.AddParameter("expression", _("Second expression"))
|
||||
@@ -183,6 +208,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
|
||||
_("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"))
|
||||
.AddParameter("string", _("Second string expression"))
|
||||
|
@@ -113,7 +113,7 @@ std::map<gd::String, gd::PropertyDescriptor> SpriteObject::GetProperties(
|
||||
properties[_("Animate even if hidden or far from the screen")]
|
||||
.SetValue(updateIfNotVisible ? "true" : "false")
|
||||
.SetType("Boolean");
|
||||
properties[_("PLEASE_ALSO_SHOW_EDIT_BUTTON_THANKS")].SetValue("");
|
||||
properties["PLEASE_ALSO_SHOW_EDIT_BUTTON_THANKS"].SetValue("");
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsWindowExtension(
|
||||
"the game window and canvas"),
|
||||
"Florian Rival",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("" /*TODO: Add a documentation page for this */);
|
||||
.SetExtensionHelpPath("/all-features/window");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
extension
|
||||
|
@@ -5,9 +5,9 @@
|
||||
*/
|
||||
#include "BehaviorMetadata.h"
|
||||
#include <iostream>
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/BehaviorsSharedData.h"
|
||||
|
||||
@@ -97,7 +97,8 @@ gd::InstructionMetadata& BehaviorMetadata::AddScopedCondition(
|
||||
const gd::String& icon,
|
||||
const gd::String& smallicon) {
|
||||
#if defined(GD_IDE_ONLY)
|
||||
gd::String nameWithNamespace = GetName() +gd::PlatformExtension::GetNamespaceSeparator() + name;
|
||||
gd::String nameWithNamespace =
|
||||
GetName() + gd::PlatformExtension::GetNamespaceSeparator() + name;
|
||||
conditionsInfos[nameWithNamespace] = InstructionMetadata(extensionNamespace,
|
||||
nameWithNamespace,
|
||||
fullname,
|
||||
@@ -120,7 +121,8 @@ gd::InstructionMetadata& BehaviorMetadata::AddScopedAction(
|
||||
const gd::String& icon,
|
||||
const gd::String& smallicon) {
|
||||
#if defined(GD_IDE_ONLY)
|
||||
gd::String nameWithNamespace = GetName() + gd::PlatformExtension::GetNamespaceSeparator() + name;
|
||||
gd::String nameWithNamespace =
|
||||
GetName() + gd::PlatformExtension::GetNamespaceSeparator() + name;
|
||||
actionsInfos[nameWithNamespace] = InstructionMetadata(extensionNamespace,
|
||||
nameWithNamespace,
|
||||
fullname,
|
||||
@@ -143,8 +145,10 @@ gd::ExpressionMetadata& BehaviorMetadata::AddExpression(
|
||||
#if defined(GD_IDE_ONLY)
|
||||
// Be careful, behaviors expression do not have namespace ( not necessary as
|
||||
// we refer to the auomatism name in the expression )
|
||||
expressionsInfos[name] = ExpressionMetadata(
|
||||
extensionNamespace, name, fullname, description, group, smallicon);
|
||||
expressionsInfos[name] =
|
||||
ExpressionMetadata(
|
||||
extensionNamespace, name, fullname, description, group, smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return expressionsInfos[name];
|
||||
#endif
|
||||
}
|
||||
@@ -158,8 +162,10 @@ gd::ExpressionMetadata& BehaviorMetadata::AddStrExpression(
|
||||
#if defined(GD_IDE_ONLY)
|
||||
// Be careful, behaviors expression do not have namespace ( not necessary as
|
||||
// we refer to the auomatism name in the expression )
|
||||
strExpressionsInfos[name] = ExpressionMetadata(
|
||||
extensionNamespace, name, fullname, description, group, smallicon);
|
||||
strExpressionsInfos[name] =
|
||||
ExpressionMetadata(
|
||||
extensionNamespace, name, fullname, description, group, smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return strExpressionsInfos[name];
|
||||
#endif
|
||||
}
|
||||
|
@@ -150,6 +150,19 @@ class GD_CORE_API ExpressionMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the help path of the expression, relative to the documentation root.
|
||||
*/
|
||||
const gd::String &GetHelpPath() const { return helpPath; }
|
||||
|
||||
/**
|
||||
* Set the help path of the expression, relative to the documentation root.
|
||||
*/
|
||||
ExpressionMetadata &SetHelpPath(const gd::String &path) {
|
||||
helpPath = path;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the instruction is private - it can't be used outside of the
|
||||
* object/ behavior that it is attached too.
|
||||
@@ -233,6 +246,7 @@ class GD_CORE_API ExpressionMetadata {
|
||||
private:
|
||||
gd::String fullname;
|
||||
gd::String description;
|
||||
gd::String helpPath;
|
||||
gd::String group;
|
||||
bool shown;
|
||||
|
||||
|
@@ -115,8 +115,11 @@ gd::ExpressionMetadata& ObjectMetadata::AddExpression(
|
||||
#if defined(GD_IDE_ONLY)
|
||||
// Be careful, objects expression do not have namespace ( not necessary as
|
||||
// objects inherits from only one derived object )
|
||||
expressionsInfos[name] = ExpressionMetadata(
|
||||
extensionNamespace, name, fullname, description, group, smallicon);
|
||||
expressionsInfos[name] =
|
||||
ExpressionMetadata(
|
||||
extensionNamespace, name, fullname, description, group, smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
|
||||
return expressionsInfos[name];
|
||||
#endif
|
||||
}
|
||||
@@ -130,8 +133,11 @@ gd::ExpressionMetadata& ObjectMetadata::AddStrExpression(
|
||||
#if defined(GD_IDE_ONLY)
|
||||
// Be careful, objects expression do not have namespace ( not necessary as
|
||||
// objects inherits from only one derived object )
|
||||
strExpressionsInfos[name] = ExpressionMetadata(
|
||||
extensionNamespace, name, fullname, description, group, smallicon);
|
||||
strExpressionsInfos[name] =
|
||||
ExpressionMetadata(
|
||||
extensionNamespace, name, fullname, description, group, smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
|
||||
return strExpressionsInfos[name];
|
||||
#endif
|
||||
}
|
||||
|
@@ -91,7 +91,8 @@ gd::ExpressionMetadata& PlatformExtension::AddExpression(
|
||||
fullname,
|
||||
description,
|
||||
group,
|
||||
smallicon);
|
||||
smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return expressionsInfos[nameWithNamespace];
|
||||
#endif
|
||||
}
|
||||
@@ -110,7 +111,8 @@ gd::ExpressionMetadata& PlatformExtension::AddStrExpression(
|
||||
fullname,
|
||||
description,
|
||||
group,
|
||||
smallicon);
|
||||
smallicon)
|
||||
.SetHelpPath(GetHelpPath());
|
||||
return strExpressionsInfos[nameWithNamespace];
|
||||
#endif
|
||||
}
|
||||
@@ -349,16 +351,15 @@ CreateFunPtr PlatformExtension::GetObjectCreationFunctionPtr(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gd::Behavior* PlatformExtension::GetBehavior(
|
||||
gd::String type) const {
|
||||
gd::Behavior* PlatformExtension::GetBehavior(gd::String type) const {
|
||||
if (behaviorsInfo.find(type) != behaviorsInfo.end())
|
||||
return &behaviorsInfo.find(type)->second.Get();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gd::BehaviorsSharedData*
|
||||
PlatformExtension::GetBehaviorSharedDatas(gd::String type) const {
|
||||
gd::BehaviorsSharedData* PlatformExtension::GetBehaviorSharedDatas(
|
||||
gd::String type) const {
|
||||
if (behaviorsInfo.find(type) != behaviorsInfo.end() &&
|
||||
behaviorsInfo.find(type)->second.GetSharedDataInstance())
|
||||
return behaviorsInfo.find(type)->second.GetSharedDataInstance();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "ProjectResourcesCopier.h"
|
||||
@@ -22,13 +22,11 @@ bool ProjectResourcesCopier::CopyAllResourcesTo(
|
||||
AbstractFileSystem& fs,
|
||||
gd::String destinationDirectory,
|
||||
bool updateOriginalProject,
|
||||
wxProgressDialog* optionalProgressDialog,
|
||||
bool askAboutAbsoluteFilenames,
|
||||
bool preserveAbsoluteFilenames,
|
||||
bool preserveDirectoryStructure) {
|
||||
// Check if there are some resources with absolute filenames
|
||||
gd::ResourcesAbsolutePathChecker absolutePathChecker(fs);
|
||||
originalProject.ExposeResources(absolutePathChecker);
|
||||
bool copyAlsoResourcesWithAbsolutePath = !askAboutAbsoluteFilenames;
|
||||
|
||||
auto projectDirectory = fs.DirNameFrom(originalProject.GetProjectFile());
|
||||
std::cout << "Copying all ressources from " << projectDirectory << " to "
|
||||
@@ -40,7 +38,7 @@ bool ProjectResourcesCopier::CopyAllResourcesTo(
|
||||
resourcesMergingHelper.PreserveDirectoriesStructure(
|
||||
preserveDirectoryStructure);
|
||||
resourcesMergingHelper.PreserveAbsoluteFilenames(
|
||||
!copyAlsoResourcesWithAbsolutePath);
|
||||
preserveAbsoluteFilenames);
|
||||
|
||||
if (updateOriginalProject) {
|
||||
originalProject.ExposeResources(resourcesMergingHelper);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#ifndef PROJECTRESOURCESCOPIER_H
|
||||
@@ -8,11 +8,8 @@
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class Project;
|
||||
}
|
||||
namespace gd {
|
||||
class AbstractFileSystem;
|
||||
}
|
||||
class wxProgressDialog;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -24,32 +21,32 @@ namespace gd {
|
||||
class GD_CORE_API ProjectResourcesCopier {
|
||||
public:
|
||||
/**
|
||||
* \brief Copy all resources files of a \a project to a the specified \a
|
||||
* destinationDirectory.
|
||||
* \brief Copy all resources files of a project to the specified
|
||||
* `destinationDirectory`.
|
||||
*
|
||||
* \param project The project to be used
|
||||
* \param fs The abstract file system to be used
|
||||
* \param destinationDirectory The directory where resources must be copied to
|
||||
* \param updateOriginalProject If set to true, \a project will be updated
|
||||
* with the new resources filenames. \param optionalProgressDialog An optional
|
||||
* pointer to a wxProgressDialog. Can be NULL. \param
|
||||
* askAboutAbsoluteFilenames If set to false, the users won't be asked
|
||||
* anything and the files with absolutes filenames will be copied into the
|
||||
* destination directory and their filenames updated. \param
|
||||
* preserveDirectoryStructure If set to true (default), the directories of the
|
||||
* resources will be preserved when copying. Otherwise, everything will be
|
||||
* send in the destinationDirectory.
|
||||
* \param updateOriginalProject If set to true, the project will be updated
|
||||
* with the new resources filenames.
|
||||
*
|
||||
* \param preserveAbsoluteFilenames If set to true (default), resources with
|
||||
* absolute filenames won't be changed. Otherwise, resources with absolute
|
||||
* filenames will be copied into the destination directory and their filenames
|
||||
* updated.
|
||||
*
|
||||
* \param preserveDirectoryStructure If set to true (default), the directories
|
||||
* of the resources will be preserved when copying. Otherwise, everything will
|
||||
* be send in the destinationDirectory.
|
||||
*
|
||||
* \return true if no error happened
|
||||
*/
|
||||
static bool CopyAllResourcesTo(
|
||||
gd::Project& project,
|
||||
gd::AbstractFileSystem& fs,
|
||||
gd::String destinationDirectory,
|
||||
bool updateOriginalProject,
|
||||
wxProgressDialog* optionalProgressDialog = NULL,
|
||||
bool askAboutAbsoluteFilenames = true,
|
||||
bool preserveDirectoryStructure = true);
|
||||
static bool CopyAllResourcesTo(gd::Project& project,
|
||||
gd::AbstractFileSystem& fs,
|
||||
gd::String destinationDirectory,
|
||||
bool updateOriginalProject,
|
||||
bool preserveAbsoluteFilenames = true,
|
||||
bool preserveDirectoryStructure = true);
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -21,28 +21,44 @@ void ResourcesMergingHelper::ExposeFile(gd::String& resourceFilename) {
|
||||
gd::String resourceFullFilename = resourceFilename;
|
||||
resourceFullFilename = gd::AbstractFileSystem::NormalizeSeparator(
|
||||
resourceFullFilename); // Protect against \ on Linux.
|
||||
fs.MakeAbsolute(resourceFullFilename, baseDirectory);
|
||||
|
||||
if (!preserveDirectoriesStructure)
|
||||
// In the case of absolute filnames that we don't want to preserve, or
|
||||
// in the case of copying files without preserving relative folders, the new
|
||||
// names will be generated from the filename alone (with collision protection).
|
||||
auto stripToFilenameOnly = [&]() {
|
||||
fs.MakeAbsolute(resourceFullFilename, baseDirectory);
|
||||
SetNewFilename(resourceFullFilename, fs.FileNameFrom(resourceFullFilename));
|
||||
else {
|
||||
// We want to preserve the directory structure:
|
||||
// keep paths relative to the base directory
|
||||
gd::String relativeFilename = resourceFullFilename;
|
||||
if (fs.MakeRelative(relativeFilename, baseDirectory))
|
||||
SetNewFilename(resourceFullFilename, relativeFilename);
|
||||
else // Unless the filename cannot be made relative. In this case:
|
||||
{
|
||||
// Just strip the filename to its file part
|
||||
// if we do not want to preserve the absolute filenames.
|
||||
if (!preserveAbsoluteFilenames)
|
||||
SetNewFilename(resourceFullFilename,
|
||||
fs.FileNameFrom(resourceFullFilename));
|
||||
}
|
||||
resourceFilename = oldFilenames[resourceFullFilename];
|
||||
};
|
||||
|
||||
// if we do not want to preserve the folders at all,
|
||||
// strip the filename to its file part.
|
||||
if (!preserveDirectoriesStructure) {
|
||||
stripToFilenameOnly();
|
||||
return;
|
||||
}
|
||||
|
||||
gd::String newResourceFilename = oldFilenames[resourceFullFilename];
|
||||
resourceFilename = newResourceFilename;
|
||||
// We want to preserve the directory structure:
|
||||
// keep paths relative to the base directory, as possible.
|
||||
if (!fs.IsAbsolute(resourceFullFilename)) {
|
||||
fs.MakeAbsolute(resourceFullFilename, baseDirectory);
|
||||
gd::String relativeFilename = resourceFullFilename;
|
||||
if (fs.MakeRelative(relativeFilename, baseDirectory)) {
|
||||
SetNewFilename(resourceFullFilename, relativeFilename);
|
||||
resourceFilename = oldFilenames[resourceFullFilename];
|
||||
} else {
|
||||
// The filename cannot be made relative. Consider that it is absolute.
|
||||
// Just strip the filename to its file part
|
||||
// if we do not want to preserve the absolute filenames.
|
||||
if (!preserveAbsoluteFilenames) {
|
||||
stripToFilenameOnly();
|
||||
}
|
||||
}
|
||||
} else { // If the path is absolute, check if we want to preserve it or not.
|
||||
if (!preserveAbsoluteFilenames) {
|
||||
stripToFilenameOnly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResourcesMergingHelper::SetNewFilename(gd::String oldFilename,
|
||||
|
@@ -631,10 +631,12 @@ void WholeProjectRefactorer::DoRenameBehavior(
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ObjectRemovedInLayout(gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
const gd::String& objectName,
|
||||
bool removeEventsAndGroups) {
|
||||
void WholeProjectRefactorer::ObjectOrGroupRemovedInLayout(
|
||||
gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
const gd::String& objectName,
|
||||
bool isObjectGroup,
|
||||
bool removeEventsAndGroups) {
|
||||
// Remove object in the current layout
|
||||
if (removeEventsAndGroups) {
|
||||
gd::EventsRefactorer::RemoveObjectInEvents(project.GetCurrentPlatform(),
|
||||
@@ -642,12 +644,17 @@ void WholeProjectRefactorer::ObjectRemovedInLayout(gd::Project& project,
|
||||
layout,
|
||||
layout.GetEvents(),
|
||||
objectName);
|
||||
for (std::size_t g = 0; g < layout.GetObjectGroups().size(); ++g) {
|
||||
if (layout.GetObjectGroups()[g].Find(objectName))
|
||||
layout.GetObjectGroups()[g].RemoveObject(objectName);
|
||||
}
|
||||
}
|
||||
layout.GetInitialInstances().RemoveInitialInstancesOfObject(objectName);
|
||||
if (!isObjectGroup) { // Object groups can't have instances or be in other
|
||||
// groups
|
||||
if (removeEventsAndGroups) {
|
||||
for (std::size_t g = 0; g < layout.GetObjectGroups().size(); ++g) {
|
||||
if (layout.GetObjectGroups()[g].Find(objectName))
|
||||
layout.GetObjectGroups()[g].RemoveObject(objectName);
|
||||
}
|
||||
}
|
||||
layout.GetInitialInstances().RemoveInitialInstancesOfObject(objectName);
|
||||
}
|
||||
|
||||
// Remove object in external events
|
||||
if (removeEventsAndGroups) {
|
||||
@@ -674,19 +681,23 @@ void WholeProjectRefactorer::ObjectRemovedInLayout(gd::Project& project,
|
||||
}
|
||||
|
||||
// Remove object in external layouts
|
||||
std::vector<gd::String> externalLayoutsNames =
|
||||
GetAssociatedExternalLayouts(project, layout);
|
||||
for (gd::String name : externalLayoutsNames) {
|
||||
auto& externalLayout = project.GetExternalLayout(name);
|
||||
externalLayout.GetInitialInstances().RemoveInitialInstancesOfObject(
|
||||
objectName);
|
||||
if (!isObjectGroup) { // Object groups can't have instances
|
||||
std::vector<gd::String> externalLayoutsNames =
|
||||
GetAssociatedExternalLayouts(project, layout);
|
||||
for (gd::String name : externalLayoutsNames) {
|
||||
auto& externalLayout = project.GetExternalLayout(name);
|
||||
externalLayout.GetInitialInstances().RemoveInitialInstancesOfObject(
|
||||
objectName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::ObjectRenamedInLayout(gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName) {
|
||||
void WholeProjectRefactorer::ObjectOrGroupRenamedInLayout(
|
||||
gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName,
|
||||
bool isObjectGroup) {
|
||||
// Rename object in the current layout
|
||||
gd::EventsRefactorer::RenameObjectInEvents(project.GetCurrentPlatform(),
|
||||
project,
|
||||
@@ -694,9 +705,13 @@ void WholeProjectRefactorer::ObjectRenamedInLayout(gd::Project& project,
|
||||
layout.GetEvents(),
|
||||
oldName,
|
||||
newName);
|
||||
layout.GetInitialInstances().RenameInstancesOfObject(oldName, newName);
|
||||
for (std::size_t g = 0; g < layout.GetObjectGroups().size(); ++g) {
|
||||
layout.GetObjectGroups()[g].RenameObject(oldName, newName);
|
||||
|
||||
if (!isObjectGroup) { // Object groups can't have instances or be in other
|
||||
// groups
|
||||
layout.GetInitialInstances().RenameInstancesOfObject(oldName, newName);
|
||||
for (std::size_t g = 0; g < layout.GetObjectGroups().size(); ++g) {
|
||||
layout.GetObjectGroups()[g].RenameObject(oldName, newName);
|
||||
}
|
||||
}
|
||||
|
||||
// Rename object in external events
|
||||
@@ -723,36 +738,96 @@ void WholeProjectRefactorer::ObjectRenamedInLayout(gd::Project& project,
|
||||
}
|
||||
|
||||
// Rename object in external layouts
|
||||
std::vector<gd::String> externalLayoutsNames =
|
||||
GetAssociatedExternalLayouts(project, layout);
|
||||
for (gd::String name : externalLayoutsNames) {
|
||||
auto& externalLayout = project.GetExternalLayout(name);
|
||||
externalLayout.GetInitialInstances().RenameInstancesOfObject(oldName,
|
||||
newName);
|
||||
if (!isObjectGroup) { // Object groups can't have instances
|
||||
std::vector<gd::String> externalLayoutsNames =
|
||||
GetAssociatedExternalLayouts(project, layout);
|
||||
for (gd::String name : externalLayoutsNames) {
|
||||
auto& externalLayout = project.GetExternalLayout(name);
|
||||
externalLayout.GetInitialInstances().RenameInstancesOfObject(oldName,
|
||||
newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
void WholeProjectRefactorer::ObjectOrGroupRemovedInEventsFunction(
|
||||
gd::Project& project,
|
||||
gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& globalObjectsContainer,
|
||||
gd::ObjectsContainer& objectsContainer,
|
||||
const gd::String& objectName,
|
||||
bool isObjectGroup,
|
||||
bool removeEventsAndGroups) {
|
||||
// Remove object in the current layout
|
||||
if (removeEventsAndGroups) {
|
||||
gd::EventsRefactorer::RemoveObjectInEvents(project.GetCurrentPlatform(),
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
eventsFunction.GetEvents(),
|
||||
objectName);
|
||||
}
|
||||
if (!isObjectGroup) { // Object groups can't be in other groups
|
||||
if (removeEventsAndGroups) {
|
||||
for (std::size_t g = 0; g < eventsFunction.GetObjectGroups().size();
|
||||
++g) {
|
||||
if (eventsFunction.GetObjectGroups()[g].Find(objectName))
|
||||
eventsFunction.GetObjectGroups()[g].RemoveObject(objectName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::GlobalObjectRenamed(gd::Project& project,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName) {
|
||||
for (std::size_t g = 0; g < project.GetObjectGroups().size(); ++g) {
|
||||
project.GetObjectGroups()[g].RenameObject(oldName, newName);
|
||||
void WholeProjectRefactorer::ObjectOrGroupRenamedInEventsFunction(
|
||||
gd::Project& project,
|
||||
gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& globalObjectsContainer,
|
||||
gd::ObjectsContainer& objectsContainer,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName,
|
||||
bool isObjectGroup) {
|
||||
// Rename object in the current layout
|
||||
gd::EventsRefactorer::RenameObjectInEvents(project.GetCurrentPlatform(),
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
eventsFunction.GetEvents(),
|
||||
oldName,
|
||||
newName);
|
||||
|
||||
if (!isObjectGroup) { // Object groups can't be in other groups
|
||||
for (std::size_t g = 0; g < eventsFunction.GetObjectGroups().size(); ++g) {
|
||||
eventsFunction.GetObjectGroups()[g].RenameObject(oldName, newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::GlobalObjectOrGroupRenamed(
|
||||
gd::Project& project,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName,
|
||||
bool isObjectGroup) {
|
||||
if (!isObjectGroup) { // Object groups can't be in other groups
|
||||
for (std::size_t g = 0; g < project.GetObjectGroups().size(); ++g) {
|
||||
project.GetObjectGroups()[g].RenameObject(oldName, newName);
|
||||
}
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < project.GetLayoutsCount(); ++i) {
|
||||
gd::Layout& layout = project.GetLayout(i);
|
||||
if (layout.HasObjectNamed(oldName)) continue;
|
||||
|
||||
ObjectRenamedInLayout(project, layout, oldName, newName);
|
||||
ObjectOrGroupRenamedInLayout(
|
||||
project, layout, oldName, newName, isObjectGroup);
|
||||
}
|
||||
}
|
||||
|
||||
void WholeProjectRefactorer::GlobalObjectRemoved(gd::Project& project,
|
||||
const gd::String& objectName,
|
||||
bool removeEventsAndGroups) {
|
||||
if (removeEventsAndGroups) {
|
||||
for (std::size_t g = 0; g < project.GetObjectGroups().size(); ++g) {
|
||||
project.GetObjectGroups()[g].RemoveObject(objectName);
|
||||
void WholeProjectRefactorer::GlobalObjectOrGroupRemoved(
|
||||
gd::Project& project,
|
||||
const gd::String& objectName,
|
||||
bool isObjectGroup,
|
||||
bool removeEventsAndGroups) {
|
||||
if (!isObjectGroup) { // Object groups can't be in other groups
|
||||
if (removeEventsAndGroups) {
|
||||
for (std::size_t g = 0; g < project.GetObjectGroups().size(); ++g) {
|
||||
project.GetObjectGroups()[g].RemoveObject(objectName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,7 +835,8 @@ void WholeProjectRefactorer::GlobalObjectRemoved(gd::Project& project,
|
||||
gd::Layout& layout = project.GetLayout(i);
|
||||
if (layout.HasObjectNamed(objectName)) continue;
|
||||
|
||||
ObjectRemovedInLayout(project, layout, objectName, removeEventsAndGroups);
|
||||
ObjectOrGroupRemovedInLayout(
|
||||
project, layout, objectName, isObjectGroup, removeEventsAndGroups);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@ class Layout;
|
||||
class String;
|
||||
class EventsFunctionsExtension;
|
||||
class EventsFunction;
|
||||
class ObjectsContainer;
|
||||
class EventsBasedBehavior;
|
||||
class ArbitraryEventsWorker;
|
||||
class ArbitraryEventsWorkerWithContext;
|
||||
@@ -24,10 +25,10 @@ namespace gd {
|
||||
* \brief Tool functions to do refactoring on the whole project after
|
||||
* changes like deletion or renaming of an object.
|
||||
*
|
||||
* \TODO Ideally ObjectRenamedInLayout, ObjectRemovedInLayout,
|
||||
* GlobalObjectRenamed, GlobalObjectRemoved would be implemented using
|
||||
* ExposeProjectEvents.
|
||||
**/
|
||||
* \TODO Ideally ObjectOrGroupRenamedInLayout, ObjectOrGroupRemovedInLayout,
|
||||
* GlobalObjectOrGroupRenamed, GlobalObjectOrGroupRemoved would be implemented
|
||||
* using ExposeProjectEvents.
|
||||
*/
|
||||
class GD_CORE_API WholeProjectRefactorer {
|
||||
public:
|
||||
/**
|
||||
@@ -103,10 +104,11 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
* This will update the layout, all external layouts associated with it
|
||||
* and all external events used by the layout.
|
||||
*/
|
||||
static void ObjectRenamedInLayout(gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName);
|
||||
static void ObjectOrGroupRenamedInLayout(gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName,
|
||||
bool isObjectGroup);
|
||||
|
||||
/**
|
||||
* \brief Refactor the project after an object is removed in a layout
|
||||
@@ -114,10 +116,39 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
* This will update the layout, all external layouts associated with it
|
||||
* and all external events used by the layout.
|
||||
*/
|
||||
static void ObjectRemovedInLayout(gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
const gd::String& objectName,
|
||||
bool removeEventsAndGroups = true);
|
||||
static void ObjectOrGroupRemovedInLayout(gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
const gd::String& objectName,
|
||||
bool isObjectGroup,
|
||||
bool removeEventsAndGroups = true);
|
||||
|
||||
/**
|
||||
* \brief Refactor the events function after an object or group is renamed
|
||||
*
|
||||
* This will update the events of the function and groups.
|
||||
*/
|
||||
static void ObjectOrGroupRenamedInEventsFunction(
|
||||
gd::Project& project,
|
||||
gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& globalObjectsContainer,
|
||||
gd::ObjectsContainer& objectsContainer,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName,
|
||||
bool isObjectGroup);
|
||||
|
||||
/**
|
||||
* \brief Refactor the events function after an object or group is renamed
|
||||
*
|
||||
* This will update the events of the function and groups.
|
||||
*/
|
||||
static void ObjectOrGroupRemovedInEventsFunction(
|
||||
gd::Project& project,
|
||||
gd::EventsFunction& eventsFunction,
|
||||
gd::ObjectsContainer& globalObjectsContainer,
|
||||
gd::ObjectsContainer& objectsContainer,
|
||||
const gd::String& objectName,
|
||||
bool isObjectGroup,
|
||||
bool removeEventsAndGroups = true);
|
||||
|
||||
/**
|
||||
* \brief Refactor the project after a global object is renamed.
|
||||
@@ -125,9 +156,10 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
* This will update all the layouts, all external layouts associated with them
|
||||
* and all external events used by the layouts.
|
||||
*/
|
||||
static void GlobalObjectRenamed(gd::Project& project,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName);
|
||||
static void GlobalObjectOrGroupRenamed(gd::Project& project,
|
||||
const gd::String& oldName,
|
||||
const gd::String& newName,
|
||||
bool isObjectGroup);
|
||||
|
||||
/**
|
||||
* \brief Refactor the project after a global object is removed.
|
||||
@@ -135,9 +167,10 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
* This will update all the layouts, all external layouts associated with them
|
||||
* and all external events used by the layouts.
|
||||
*/
|
||||
static void GlobalObjectRemoved(gd::Project& project,
|
||||
const gd::String& objectName,
|
||||
bool removeEventsAndGroups = true);
|
||||
static void GlobalObjectOrGroupRemoved(gd::Project& project,
|
||||
const gd::String& objectName,
|
||||
bool isObjectGroup,
|
||||
bool removeEventsAndGroups = true);
|
||||
|
||||
/**
|
||||
* \brief Return the set of all the types of the objects that are using the
|
||||
|
@@ -19,9 +19,6 @@ void Effect::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Unserialize the layer.
|
||||
*/
|
||||
void Effect::UnserializeFrom(const SerializerElement& element) {
|
||||
SetName(element.GetStringAttribute("name"));
|
||||
SetEffectName(element.GetStringAttribute("effectName"));
|
||||
|
@@ -32,11 +32,11 @@ class GD_CORE_API Effect {
|
||||
}
|
||||
const gd::String& GetEffectName() const { return effectName; }
|
||||
|
||||
void SetParameter(const gd::String& name, float value) {
|
||||
void SetParameter(const gd::String& name, double value) {
|
||||
parameters[name] = value;
|
||||
}
|
||||
float GetParameter(const gd::String& name) { return parameters[name]; }
|
||||
const std::map<gd::String, float>& GetAllParameters() const {
|
||||
double GetParameter(const gd::String& name) { return parameters[name]; }
|
||||
const std::map<gd::String, double>& GetAllParameters() const {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class GD_CORE_API Effect {
|
||||
private:
|
||||
gd::String name; ///< The name of the layer
|
||||
gd::String effectName; ///< The name of the effect to apply
|
||||
std::map<gd::String, float> parameters;
|
||||
std::map<gd::String, double> parameters;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -93,6 +93,9 @@ class GD_CORE_API EventsFunctionsContainer
|
||||
void MoveEventsFunction(std::size_t oldIndex, std::size_t newIndex) {
|
||||
return Move(oldIndex, newIndex);
|
||||
};
|
||||
std::size_t GetEventsFunctionPosition(const gd::EventsFunction& eventsFunction) {
|
||||
return GetPosition(eventsFunction);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Provide a raw access to the vector containing the functions.
|
||||
@@ -141,4 +144,4 @@ class GD_CORE_API EventsFunctionsContainer
|
||||
} // namespace gd
|
||||
|
||||
#endif // GDCORE_EVENTSFUNCTIONSCONTAINER_H
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -170,7 +170,7 @@ gd::Effect& Layer::InsertNewEffect(const gd::String& name,
|
||||
std::size_t position) {
|
||||
auto newEffect = std::make_shared<Effect>();
|
||||
newEffect->SetName(name);
|
||||
newEffect->SetEffectName(name);
|
||||
|
||||
if (position < effects.size())
|
||||
effects.insert(effects.begin() + position, newEffect);
|
||||
else
|
||||
|
@@ -140,10 +140,14 @@ class GD_CORE_API Layer {
|
||||
gd::Effect& InsertNewEffect(const gd::String& name, std::size_t position);
|
||||
|
||||
/**
|
||||
* \brief Add the a copy of the specified effect in the effects list.
|
||||
* \brief Add a copy of the specified effect in the effects list.
|
||||
*
|
||||
* \note No pointer or reference must be kept on the layer passed as
|
||||
* parameter. \param theEffect The effect that must be copied and inserted
|
||||
* into the effects list \param position Insertion position.
|
||||
* parameter.
|
||||
*
|
||||
* \param theEffect The effect that must be copied and inserted
|
||||
* into the effects list
|
||||
* \param position Insertion position.
|
||||
*/
|
||||
void InsertEffect(const Effect& theEffect, std::size_t position);
|
||||
|
||||
|
@@ -119,13 +119,33 @@ void ObjectsContainer::MoveObject(std::size_t oldIndex, std::size_t newIndex) {
|
||||
}
|
||||
|
||||
void ObjectsContainer::RemoveObject(const gd::String& name) {
|
||||
std::vector<std::unique_ptr<gd::Object> >::iterator object =
|
||||
std::vector<std::unique_ptr<gd::Object> >::iterator objectIt =
|
||||
find_if(initialObjects.begin(),
|
||||
initialObjects.end(),
|
||||
bind2nd(ObjectHasName(), name));
|
||||
if (object == initialObjects.end()) return;
|
||||
if (objectIt == initialObjects.end()) return;
|
||||
|
||||
initialObjects.erase(object);
|
||||
initialObjects.erase(objectIt);
|
||||
}
|
||||
|
||||
void ObjectsContainer::MoveObjectToAnotherContainer(
|
||||
const gd::String& name,
|
||||
gd::ObjectsContainer& newContainer,
|
||||
std::size_t newPosition) {
|
||||
std::vector<std::unique_ptr<gd::Object> >::iterator objectIt =
|
||||
find_if(initialObjects.begin(),
|
||||
initialObjects.end(),
|
||||
bind2nd(ObjectHasName(), name));
|
||||
if (objectIt == initialObjects.end()) return;
|
||||
|
||||
std::unique_ptr<gd::Object> object = std::move(*objectIt);
|
||||
initialObjects.erase(objectIt);
|
||||
|
||||
newContainer.initialObjects.insert(
|
||||
newPosition < newContainer.initialObjects.size()
|
||||
? newContainer.initialObjects.begin() + newPosition
|
||||
: newContainer.initialObjects.end(),
|
||||
std::move(object));
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -106,13 +106,17 @@ class GD_CORE_API ObjectsContainer {
|
||||
* \note The object passed by parameter is copied.
|
||||
* \param object The object that must be copied and inserted into the project
|
||||
* \param position Insertion position. If the position is invalid, the object
|
||||
* is inserted at the end of the objects list. \return A reference to the
|
||||
* object in the list.
|
||||
* is inserted at the end of the objects list.
|
||||
*
|
||||
* \return A reference to the object in the list.
|
||||
*/
|
||||
gd::Object& InsertObject(const gd::Object& object, std::size_t position);
|
||||
|
||||
/**
|
||||
* \brief Delete an object.
|
||||
* \warning When calling this function, be sure to drop any reference that you
|
||||
* might hold to the object - otherwise you'll access deleted memory.
|
||||
*
|
||||
* \param name The name of the object to be deleted.
|
||||
*/
|
||||
void RemoveObject(const gd::String& name);
|
||||
@@ -127,6 +131,15 @@ class GD_CORE_API ObjectsContainer {
|
||||
*/
|
||||
void SwapObjects(std::size_t firstObjectIndex, std::size_t secondObjectIndex);
|
||||
|
||||
/**
|
||||
* Move the specified object to another container, removing it from the current one
|
||||
* and adding it to the new one at the specified position.
|
||||
*
|
||||
* \note This does not invalidate the references to the object (object is not moved in memory,
|
||||
* as referenced by smart pointers internally).
|
||||
*/
|
||||
void MoveObjectToAnotherContainer(const gd::String& name, gd::ObjectsContainer & newContainer, std::size_t newPosition);
|
||||
|
||||
/**
|
||||
* Provide a raw access to the vector containing the objects
|
||||
*/
|
||||
|
@@ -943,6 +943,8 @@ void Project::SerializeTo(SerializerElement& element) const {
|
||||
}
|
||||
|
||||
bool Project::ValidateObjectName(const gd::String& name) {
|
||||
if (name.empty()) return false;
|
||||
|
||||
gd::String allowedCharacters =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
|
||||
return !(name.find_first_not_of(allowedCharacters) != gd::String::npos);
|
||||
|
@@ -4,12 +4,12 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#include "GDCore/Project/ResourcesManager.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Project/ResourcesManager.h"
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/Serialization/Serializer.h"
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
@@ -75,6 +75,8 @@ std::shared_ptr<Resource> ResourcesManager::CreateResource(
|
||||
return std::make_shared<FontResource>();
|
||||
else if (kind == "video")
|
||||
return std::make_shared<VideoResource>();
|
||||
else if (kind == "json")
|
||||
return std::make_shared<JsonResource>();
|
||||
|
||||
std::cout << "Bad resource created (type: " << kind << ")" << std::endl;
|
||||
return std::make_shared<Resource>();
|
||||
@@ -476,9 +478,7 @@ void ImageResource::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("alwaysLoaded", alwaysLoaded);
|
||||
element.SetAttribute("smoothed", smooth);
|
||||
element.SetAttribute("userAdded", IsUserAdded());
|
||||
element.SetAttribute(
|
||||
"file", GetFile()); // Keep the resource path in the current locale (but
|
||||
// save it in UTF8 for compatibility on other OSes)
|
||||
element.SetAttribute("file", GetFile());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -498,9 +498,7 @@ void AudioResource::UnserializeFrom(const SerializerElement& element) {
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void AudioResource::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("userAdded", IsUserAdded());
|
||||
element.SetAttribute(
|
||||
"file", GetFile()); // Keep the resource path in the current locale (but
|
||||
// save it in UTF8 for compatibility on other OSes)
|
||||
element.SetAttribute("file", GetFile());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -520,9 +518,7 @@ void FontResource::UnserializeFrom(const SerializerElement& element) {
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void FontResource::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("userAdded", IsUserAdded());
|
||||
element.SetAttribute(
|
||||
"file", GetFile()); // Keep the resource path in the current locale (but
|
||||
// save it in UTF8 for compatibility on other OSes)
|
||||
element.SetAttribute("file", GetFile());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -542,12 +538,52 @@ void VideoResource::UnserializeFrom(const SerializerElement& element) {
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void VideoResource::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("userAdded", IsUserAdded());
|
||||
element.SetAttribute(
|
||||
"file", GetFile()); // Keep the resource path in the current locale (but
|
||||
// save it in UTF8 for compatibility on other OSes)
|
||||
element.SetAttribute("file", GetFile());
|
||||
}
|
||||
#endif
|
||||
|
||||
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, "/");
|
||||
}
|
||||
|
||||
void JsonResource::UnserializeFrom(const SerializerElement& element) {
|
||||
SetUserAdded(element.GetBoolAttribute("userAdded"));
|
||||
SetFile(element.GetStringAttribute("file"));
|
||||
DisablePreload(element.GetBoolAttribute("disablePreload", false));
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void JsonResource::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("userAdded", IsUserAdded());
|
||||
element.SetAttribute("file", GetFile());
|
||||
element.SetAttribute("disablePreload", IsPreloadDisabled());
|
||||
}
|
||||
|
||||
std::map<gd::String, gd::PropertyDescriptor> JsonResource::GetProperties(
|
||||
gd::Project& project) const {
|
||||
std::map<gd::String, gd::PropertyDescriptor> properties;
|
||||
properties["disablePreload"]
|
||||
.SetValue(disablePreload ? "true" : "false")
|
||||
.SetType("Boolean")
|
||||
.SetLabel(_("Disable preloading at game startup"));
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
bool JsonResource::UpdateProperty(const gd::String& name,
|
||||
const gd::String& value,
|
||||
gd::Project& project) {
|
||||
if (name == "disablePreload") disablePreload = value == "1";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
ResourceFolder::ResourceFolder(const ResourceFolder& other) { Init(other); }
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
#ifndef GDCORE_RESOURCESMANAGER_H
|
||||
#define GDCORE_RESOURCESMANAGER_H
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/String.h"
|
||||
@@ -13,7 +14,7 @@ class Project;
|
||||
class ResourceFolder;
|
||||
class SerializerElement;
|
||||
class PropertyDescriptor;
|
||||
}
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -82,7 +83,9 @@ class GD_CORE_API Resource {
|
||||
* \note Can be used by external editors to store extra information, for
|
||||
* example the configuration used to produce a sound.
|
||||
*/
|
||||
virtual void SetMetadata(const gd::String& metadata_) { metadata = metadata_; }
|
||||
virtual void SetMetadata(const gd::String& metadata_) {
|
||||
metadata = metadata_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return the (optional) metadata associated to the resource
|
||||
@@ -292,6 +295,52 @@ class GD_CORE_API VideoResource : public Resource {
|
||||
gd::String file;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Describe a json file used by a project.
|
||||
*
|
||||
* \see Resource
|
||||
* \ingroup ResourcesManagement
|
||||
*/
|
||||
class GD_CORE_API JsonResource : public Resource {
|
||||
public:
|
||||
JsonResource() : Resource(), disablePreload(false) { SetKind("json"); };
|
||||
virtual ~JsonResource(){};
|
||||
virtual JsonResource* Clone() const override {
|
||||
return new JsonResource(*this);
|
||||
}
|
||||
|
||||
virtual const gd::String& GetFile() const override { return file; };
|
||||
virtual void SetFile(const gd::String& newFile) override;
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual bool UseFile() override { return true; }
|
||||
|
||||
std::map<gd::String, gd::PropertyDescriptor> GetProperties(
|
||||
gd::Project& project) const override;
|
||||
bool UpdateProperty(const gd::String& name,
|
||||
const gd::String& value,
|
||||
gd::Project& project) override;
|
||||
|
||||
void SerializeTo(SerializerElement& element) const override;
|
||||
#endif
|
||||
|
||||
void UnserializeFrom(const SerializerElement& element) override;
|
||||
|
||||
/**
|
||||
* \brief Return true if the loading at game startup must be disabled
|
||||
*/
|
||||
bool IsPreloadDisabled() const { return disablePreload; }
|
||||
|
||||
/**
|
||||
* \brief Set if the json preload at game startup must be disabled
|
||||
*/
|
||||
void DisablePreload(bool disable = true) { disablePreload = disable; }
|
||||
|
||||
private:
|
||||
bool disablePreload; ///< If "true", don't load the JSON at game startup
|
||||
gd::String file;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Inventory all resources used by a project
|
||||
*
|
||||
@@ -338,7 +387,8 @@ class GD_CORE_API ResourcesManager {
|
||||
|
||||
/**
|
||||
* \brief Add an already constructed resource.
|
||||
* \note A copy of the resource is made and stored inside the ResourcesManager.
|
||||
* \note A copy of the resource is made and stored inside the
|
||||
* ResourcesManager.
|
||||
*/
|
||||
bool AddResource(const gd::Resource& resource);
|
||||
|
||||
@@ -375,7 +425,7 @@ class GD_CORE_API ResourcesManager {
|
||||
bool MoveResourceDownInList(const gd::String& name);
|
||||
|
||||
/**
|
||||
* Change the position of the specified resource.
|
||||
* \brief Change the position of the specified resource.
|
||||
*/
|
||||
void MoveResource(std::size_t oldIndex, std::size_t newIndex);
|
||||
|
||||
|
@@ -129,6 +129,11 @@ class SerializableWithNameList {
|
||||
*/
|
||||
bool Has(const gd::String& name) const;
|
||||
|
||||
/**
|
||||
* \brief Get the position of an element in the list
|
||||
*/
|
||||
std::size_t GetPosition(const T& element) const;
|
||||
|
||||
/** \name std::vector-like API
|
||||
* These functions ensure that the class can be used just like a std::vector
|
||||
* for iterations.
|
||||
|
@@ -109,6 +109,15 @@ void SerializableWithNameList<T>::Move(std::size_t oldIndex,
|
||||
elements.insert(elements.begin() + newIndex, std::move(object));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t SerializableWithNameList<T>::GetPosition(const T& element) const {
|
||||
for(std::size_t index = 0;index<elements.size();++index) {
|
||||
if (&element == elements[index].get()) return index;
|
||||
}
|
||||
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SerializableWithNameList<T>::SerializeElementsTo(
|
||||
const gd::String& elementName, SerializerElement& serializerElement) const {
|
||||
|
122
Core/GDevelop-Architecture-Overview.md
Normal file
122
Core/GDevelop-Architecture-Overview.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# GDevelop Architecture Overview
|
||||
|
||||
GDevelop is architectured around a `Core` library, platforms (`GDJS`, `GDCpp`) and extensions (`Extensions` folder). The editor (`newIDE` folder) is using all of these libraries. This is a recap table of the main folders:
|
||||
|
||||
| Directory | ℹ️ Description |
|
||||
| --- | --- |
|
||||
| `Core` | GDevelop core library, containing common tools to implement the IDE and work with GDevelop games. |
|
||||
| `GDCpp` | GDevelop C++ game engine, used to **build native games**. |
|
||||
| `GDJS` | GDevelop JS game engine, used to build **HTML5 games**. |
|
||||
| `GDevelop.js` | Bindings of Core/GDCpp/GDJS and Extensions to JavaScript (used by the IDE). |
|
||||
| `newIDE` | The game editor, written in JavaScript with React, Electron and Pixi.js. |
|
||||
| `Extensions` | Extensions for C++ or JS game engines, providing objects, events and new features. |
|
||||
|
||||
The rest of this page is an introduction to the main concepts of GDevelop architecture.
|
||||
|
||||
## Some vocabulary: "Runtime" and "IDE"
|
||||
|
||||
**IDE** stands for "Integrated Development Environment". A synonym for it is also simply "editor". In GDevelop, the software itself, that is used to create games and running as an app or a web-app, is called the "GDevelop Editor" or the "GDevelop IDE"
|
||||
|
||||
> This term "IDE" is also used in some folders. When you browse `Core`, `GDCpp` or `GDJS` subfolders, some folders are called `IDE`. They contain classes and tools that are **only useful for the editor** (they are not per se mandatory to describe the structure of a game).
|
||||
|
||||
**Runtime** is a word used to describe classes, tools and source files being used during a game. This could also be called "in game" or a "game engine".
|
||||
|
||||
> When you browse `GDCpp` or `GDJS` subfolders, you can find folders called `Runtime`. They contain the **game engine** of GDevelop.
|
||||
|
||||
Extensions do have the same distinction between the "**IDE**" part and the "**Runtime**" part. For example, most extensions have:
|
||||
|
||||
* A file called [`JsExtension.js`(https://github.com/4ian/GDevelop/blob/master/Extensions/ExampleJsExtension/JsExtension.js)], which contains the *declaration* of the extension for the **IDE**
|
||||
* One or more files implementing the feature for the game, in other words for **Runtime**. This can be a [Runtime Object](https://github.com/4ian/GDevelop/blob/master/Extensions/ExampleJsExtension/dummyruntimeobject.js) or a [Runtime Behavior](https://github.com/4ian/GDevelop/blob/master/Extensions/ExampleJsExtension/dummyruntimebehavior.js), [functions called by actions or conditions](https://github.com/4ian/GDevelop/blob/master/Extensions/ExampleJsExtension/examplejsextensiontools.js) or by the game engine.
|
||||
|
||||
### "Runtime" and "IDE" difference using an example: the `gd::Variable` class
|
||||
|
||||
In GDevelop, developers can associate and manipulate variables in their games. To represent them, we have two things:
|
||||
|
||||
* The **editor** `gd::Variable` that is part of the structure of the game, so living in [GDCore in Variable.h](https://4ian.github.io/GD-Documentation/GDCore%20Documentation/classgd_1_1_variable.html). This is what is shown in the editor, saved on disk in the project file.
|
||||
* The **game engine** variable, called `gdjs.Variable` in GDJS. [Documentation is in the GDJS **game engine**](http://4ian.github.io/GD-Documentation/GDJS%20Runtime%20Documentation/gdjs.Variable.html). This JavaScript class is what is used during a game.
|
||||
|
||||
The editor `gd::Variable` **know nothing** about the game engine class `gdjs.Variable`. And the `gdjs.Variable` class in the game engine know almost nothing from `gd::Variable` (apart from how it's written in JSON, to be able to load a game default variables).
|
||||
|
||||
> Note that the name `gdjs.Variable` is maybe a *bad decision*: it should have been called a `gdjs.RuntimeVariable`, like `gdjs.RuntimeObject` and like most other classes of the game engine.
|
||||
|
||||
## What's inside "Core" (`GDCore` folder)?
|
||||
|
||||
GDevelop "Core" is basically containing everything that is used to **describe and manipulate the structure of a game** (called a `Project` internally). This includes events, scenes, objects, behaviors, events etc... All of these are implemented using C++ classes, in [this folder named `Project`](https://github.com/4ian/GDevelop/tree/master/Core/GDCore/Project).
|
||||
|
||||
GDevelop "Core" also contains **tools** to manipulate these `Project`. In particular, `Core/GDCore/IDE` folder is containing C++ classes allowing to do operations on the structure of a game. For example, [WholeProjectRefactorer](https://github.com/4ian/GDevelop/blob/master/Core/GDCore/IDE/WholeProjectRefactorer.cpp) is a very powerful tool, used to rename all objects in a game, update events after an object is deleted and more generally do Project wide refactoring. The directory contains other "tool" functions to manipulate [resources of projects](https://github.com/4ian/GDevelop/tree/master/Core/GDCore/IDE/Project) or do [search in events](https://github.com/4ian/GDevelop/tree/master/Core/GDCore/IDE/Events).
|
||||
|
||||
## What's inside GDJS? Why do I see some C++ file there?
|
||||
|
||||
While `GDJS/Runtime` folder is the game engine that is executed inside a game, `GDJS/GDJS` is the "IDE" part, which are the C++ classes describing to the editor various things like:
|
||||
|
||||
* How [do you do an export](https://github.com/4ian/GDevelop/tree/master/GDJS/GDJS/IDE),
|
||||
* What are [the default extensions](https://github.com/4ian/GDevelop/tree/master/GDJS/GDJS/Extensions/Builtin),
|
||||
* How do you [generate JS code from events](https://github.com/4ian/GDevelop/tree/master/GDJS/GDJS/Events/CodeGeneration),
|
||||
|
||||
The game engine is in GDJS/Runtime and is all JavaScript.
|
||||
|
||||
## What about events?
|
||||
|
||||
An "**event**" is by default something that [is mostly empty](http://4ian.github.io/GD-Documentation/GDCore%20Documentation/classgd_1_1_base_event.html). In a more traditional programming language, an event can be seen as a scope or block (example: `{ some code here }` in a C style language like JavaScript, Java or C++).
|
||||
|
||||
[Default events are defined](https://github.com/4ian/GDevelop/tree/master/Core/GDCore/Events/Builtin) in GDevelop Core.
|
||||
In particular, there is StandardEvent, which has conditions and actions. Conditions and actions are both a list of [`gd::Instruction`](https://4ian.github.io/GD-Documentation/GDCore%20Documentation/classgd_1_1_instruction.html). A `gd::Instruction` is either a condition or an action (it depends only on the context where they are used).
|
||||
|
||||
A `gd::Instruction` is "just" a type (the name of the action or condition), and some parameters. You can think of it as a function in a programming language (`add(2, 3)` is calling a function called "add" with parameter "2" and "3"). Conditions have the special thing that they are functions returning true or false (and potentially being used to do filter on the objects being picked for next conditions and actions).
|
||||
|
||||
### Why can't I see any "RuntimeEvent" or events during the game?
|
||||
|
||||
They do not exist anymore! ✨
|
||||
|
||||
Events are translated (we also say "transpiled" or "generated") into "real" code in a programming language. This process is called "Code Generation", and is [done here for the JavaScript game engine](https://github.com/4ian/GDevelop/tree/master/GDJS/GDJS/Events/CodeGeneration).
|
||||
|
||||
### Can I extract Events classes and code generator to make a development environment based on GDevelop events?
|
||||
|
||||
You're welcome to do so! Please get in touch :)
|
||||
|
||||
## I can see more than one Extensions folder, why?
|
||||
|
||||
The idea of GDevelop editor and game engine is to have a lean game engine, supporting almost nothing. Then, one can add "mods", "plugins", "modules" for GDevelop. We chose to call them "**Extensions**" in GDevelop.
|
||||
|
||||
* `GDevelop/Core/GDCore/Extensions` is the **declaration** of default (we say "builtin") extensions, that are available for any game and are "mandatory". They are called Extensions but they could be named "Extensions that will always be in your game". In programming languages, this is called a "[Standard Library](https://en.wikipedia.org/wiki/Standard_library)" (but don't get too distracted by this naming).
|
||||
* `GDevelop/GDJS/GDJS/Extensions/` and `GDevelop/GDCpp/GDCpp/Extensions/` are reusing these **declarations** and **adding** their own declarations. Mainly, they are setting the name of the functions to be called (either in JS or in C++) for each action, condition or expression.
|
||||
* `GDevelop/Extensions/` is the folder for the "mods"/"plugins" for GDevelop - the one that are not mandatory. They are not part of GDCore - they work on their own.
|
||||
|
||||
> In theory, all extensions could be moved to `GDevelop/Extensions/`. In practice, it's more pragmatic to have a set of "builtin" extensions with basic features.
|
||||
|
||||
## What's GDevelop.js? Do we care about this?
|
||||
|
||||
Everything in GDevelop.js is meant to create a "bridge" allowing to run and use C++ from JavaScript for the **IDE**, so that [we can write an editor entirely in JavaScript](https://github.com/4ian/GDevelop/tree/master/newIDE) and have it working in a web browser.
|
||||
|
||||
* We're using Emscripten which is compiling C++, but instead of writing a "native binary", it's writing a file that works in a browser (basically, JavaScript!).
|
||||
|
||||
* The most useful file is [Bindings.idl](https://github.com/4ian/GDevelop/blob/master/GDevelop.js/Bindings/Bindings.idl) that is describing everything in C++ that must be exposed to JavaScript (in the editor, not in game. Remember that during the game, we're at **Runtime**, so all of this does not exist anymore)
|
||||
|
||||
* Rest of the files are mostly bridges doing "weird stuff" to translate from JS to C++ or vice versa. It requires a bit of knowledge about how the ["bridge", made by Emscripten, called WebIDL](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/WebIDL-Binder.html) is working.
|
||||
|
||||
You don't need to work with these unless you want to expose something that is written in C++ to the editor, and writing the interface in Bindings.idl is not sufficient.
|
||||
|
||||
90% of the time, you can just read or write about a class in [Bindings.idl](https://github.com/4ian/GDevelop/blob/master/GDevelop.js/Bindings/Bindings.idl). If you work in C++ classes, you may have sometime to add a header file in Wrapper.cpp and your C++ class is "automagically" compiled and available in JavaScript after writing the corresponding interface in Bindings.idl.
|
||||
|
||||
### I want all the gory details about GDevelop.js 🧐
|
||||
|
||||
All the required C++ files are imported into this huge list: https://github.com/4ian/GDevelop/blob/master/GDevelop.js/Bindings/Wrapper.cpp#L1-L79. C++ compilation is done with a "build system" called CMake, which is using [this file](https://github.com/4ian/GDevelop/blob/master/GDevelop.js/CMakeLists.txt#L82-L101) to see what to compile.
|
||||
|
||||
> In an ideal world, there would be something to do this automatically, so GDevelop.js folder would not even exist 😉
|
||||
> If you're interested and want to know more about GDevelop.js bridging between C++ and JavaScript, look at [this talk from GDevelop original author](https://www.youtube.com/watch?v=6La7jSCnYyk).
|
||||
|
||||
## Misc questions
|
||||
|
||||
### What's the deal with C++? Why so much of it?
|
||||
|
||||
GDevelop was originally written in C++. It's a scary language at first but is portable across almost any existing machine in this universe, can be pretty good, safe and readable with the latest C++ features.
|
||||
|
||||
### What's the deal with JavaScript? Why so much of it?
|
||||
|
||||
JavaScript, with the latest language proposals, is actually a very capable language, fast to write and safe with typing:
|
||||
|
||||
* Performance is getting pretty good with recent browsers JIT features.
|
||||
* Frontend frameworks like React, used for GDevelop IDE, allow for very fast and modular interface development.
|
||||
* The web is an incredible and unmatched target when it comes to cross platform (and cross form factor) apps.
|
||||
|
||||
More generally, the web is a great target for games with the rise of WebGL and WebAssembly - though GDevelop should stay modular to adapt to newer platforms for the exported games in the future.
|
@@ -110,7 +110,7 @@ TEST_CASE("ResourcesMergingHelper", "[common]") {
|
||||
auto resourcesFilenames =
|
||||
resourcesMerger.GetAllResourcesOldAndNewFilename();
|
||||
REQUIRE(resourcesFilenames["MakeAbsolute(/image1.png)"] ==
|
||||
"MakeRelative(MakeAbsolute(/image1.png))");
|
||||
"FileNameFrom(MakeAbsolute(/image1.png))");
|
||||
REQUIRE(resourcesFilenames["MakeAbsolute(image2.png)"] ==
|
||||
"MakeRelative(MakeAbsolute(image2.png))");
|
||||
REQUIRE(resourcesFilenames["MakeAbsolute(audio1.png)"] ==
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "GDCore/Events/Builtin/LinkEvent.h"
|
||||
#include "GDCore/Events/Builtin/StandardEvent.h"
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
#include "GDCore/Extensions/PlatformExtension.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
@@ -151,7 +152,7 @@ gd::EventsFunctionsExtension &SetupProjectWithEventsFunctionExtension(
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
SECTION("Object deleted") {
|
||||
SECTION("Object deleted (in layout)") {
|
||||
SECTION("Groups") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
@@ -168,9 +169,10 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
layout1.InsertNewObject(project, "MyExtension::Sprite", "Object1", 0);
|
||||
layout1.InsertNewObject(project, "MyExtension::Sprite", "Object2", 0);
|
||||
|
||||
gd::WholeProjectRefactorer::ObjectRemovedInLayout(
|
||||
project, layout1, "Object1");
|
||||
gd::WholeProjectRefactorer::GlobalObjectRemoved(project, "GlobalObject1");
|
||||
gd::WholeProjectRefactorer::ObjectOrGroupRemovedInLayout(
|
||||
project, layout1, "Object1", /* isObjectGroup =*/false);
|
||||
gd::WholeProjectRefactorer::GlobalObjectOrGroupRemoved(
|
||||
project, "GlobalObject1", /* isObjectGroup =*/false);
|
||||
REQUIRE(layout1.GetObjectGroups()[0].Find("Object1") == false);
|
||||
REQUIRE(layout1.GetObjectGroups()[0].Find("Object2") == true);
|
||||
REQUIRE(layout1.GetObjectGroups()[0].Find("NotExistingObject") == true);
|
||||
@@ -196,9 +198,10 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
layout1.GetInitialInstances().InsertInitialInstance(instance2);
|
||||
layout1.GetInitialInstances().InsertInitialInstance(instance3);
|
||||
|
||||
gd::WholeProjectRefactorer::ObjectRemovedInLayout(
|
||||
project, layout1, "Object1");
|
||||
gd::WholeProjectRefactorer::GlobalObjectRemoved(project, "GlobalObject1");
|
||||
gd::WholeProjectRefactorer::ObjectOrGroupRemovedInLayout(
|
||||
project, layout1, "Object1", /* isObjectGroup =*/false);
|
||||
gd::WholeProjectRefactorer::GlobalObjectOrGroupRemoved(
|
||||
project, "GlobalObject1", /* isObjectGroup =*/false);
|
||||
REQUIRE(layout1.GetInitialInstances().HasInstancesOfObject("Object1") ==
|
||||
false);
|
||||
REQUIRE(layout1.GetInitialInstances().HasInstancesOfObject("Object2") ==
|
||||
@@ -237,9 +240,10 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
externalLayout2.GetInitialInstances().InsertInitialInstance(instance2);
|
||||
externalLayout2.GetInitialInstances().InsertInitialInstance(instance3);
|
||||
|
||||
gd::WholeProjectRefactorer::ObjectRemovedInLayout(
|
||||
project, layout1, "Object1");
|
||||
gd::WholeProjectRefactorer::GlobalObjectRemoved(project, "GlobalObject1");
|
||||
gd::WholeProjectRefactorer::ObjectOrGroupRemovedInLayout(
|
||||
project, layout1, "Object1", /* isObjectGroup =*/false);
|
||||
gd::WholeProjectRefactorer::GlobalObjectOrGroupRemoved(
|
||||
project, "GlobalObject1", /* isObjectGroup =*/false);
|
||||
REQUIRE(externalLayout1.GetInitialInstances().HasInstancesOfObject(
|
||||
"Object1") == false);
|
||||
REQUIRE(externalLayout1.GetInitialInstances().HasInstancesOfObject(
|
||||
@@ -255,7 +259,7 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Object renamed") {
|
||||
SECTION("Object renamed (in layout)") {
|
||||
SECTION("Groups") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
@@ -272,10 +276,10 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
layout1.InsertNewObject(project, "MyExtension::Sprite", "Object1", 0);
|
||||
layout1.InsertNewObject(project, "MyExtension::Sprite", "Object2", 0);
|
||||
|
||||
gd::WholeProjectRefactorer::ObjectRenamedInLayout(
|
||||
project, layout1, "Object1", "Object3");
|
||||
gd::WholeProjectRefactorer::GlobalObjectRenamed(
|
||||
project, "GlobalObject1", "GlobalObject3");
|
||||
gd::WholeProjectRefactorer::ObjectOrGroupRenamedInLayout(
|
||||
project, layout1, "Object1", "Object3", /* isObjectGroup =*/false);
|
||||
gd::WholeProjectRefactorer::GlobalObjectOrGroupRenamed(
|
||||
project, "GlobalObject1", "GlobalObject3", /* isObjectGroup =*/false);
|
||||
REQUIRE(layout1.GetObjectGroups()[0].Find("Object1") == false);
|
||||
REQUIRE(layout1.GetObjectGroups()[0].Find("Object2") == true);
|
||||
REQUIRE(layout1.GetObjectGroups()[0].Find("Object3") == true);
|
||||
@@ -302,10 +306,10 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
layout1.GetInitialInstances().InsertInitialInstance(instance2);
|
||||
layout1.GetInitialInstances().InsertInitialInstance(instance3);
|
||||
|
||||
gd::WholeProjectRefactorer::ObjectRenamedInLayout(
|
||||
project, layout1, "Object1", "Object3");
|
||||
gd::WholeProjectRefactorer::GlobalObjectRenamed(
|
||||
project, "GlobalObject1", "GlobalObject3");
|
||||
gd::WholeProjectRefactorer::ObjectOrGroupRenamedInLayout(
|
||||
project, layout1, "Object1", "Object3", /* isObjectGroup =*/false);
|
||||
gd::WholeProjectRefactorer::GlobalObjectOrGroupRenamed(
|
||||
project, "GlobalObject1", "GlobalObject3", /* isObjectGroup =*/false);
|
||||
REQUIRE(layout1.GetInitialInstances().HasInstancesOfObject("Object1") ==
|
||||
false);
|
||||
REQUIRE(layout1.GetInitialInstances().HasInstancesOfObject("Object3") ==
|
||||
@@ -346,10 +350,10 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
externalLayout2.GetInitialInstances().InsertInitialInstance(instance2);
|
||||
externalLayout2.GetInitialInstances().InsertInitialInstance(instance3);
|
||||
|
||||
gd::WholeProjectRefactorer::ObjectRenamedInLayout(
|
||||
project, layout1, "Object1", "Object3");
|
||||
gd::WholeProjectRefactorer::GlobalObjectRenamed(
|
||||
project, "GlobalObject1", "GlobalObject3");
|
||||
gd::WholeProjectRefactorer::ObjectOrGroupRenamedInLayout(
|
||||
project, layout1, "Object1", "Object3", /* isObjectGroup =*/false);
|
||||
gd::WholeProjectRefactorer::GlobalObjectOrGroupRenamed(
|
||||
project, "GlobalObject1", "GlobalObject3", /* isObjectGroup =*/false);
|
||||
REQUIRE(externalLayout1.GetInitialInstances().HasInstancesOfObject(
|
||||
"Object1") == false);
|
||||
REQUIRE(externalLayout1.GetInitialInstances().HasInstancesOfObject(
|
||||
@@ -372,6 +376,89 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
"GlobalObject3") == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Object renamed (in events function)") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
auto &eventsExtension =
|
||||
project.InsertNewEventsFunctionsExtension("MyEventsExtension", 0);
|
||||
|
||||
// Add a (free) function with an object group
|
||||
gd::EventsFunction &eventsFunction =
|
||||
eventsExtension.InsertNewEventsFunction("MyEventsFunction", 0);
|
||||
gd::ObjectGroup &objectGroup =
|
||||
eventsFunction.GetObjectGroups().InsertNew("MyGroup", 0);
|
||||
objectGroup.AddObject("Object1");
|
||||
objectGroup.AddObject("Object2");
|
||||
// In theory, we would add the object parameters, but we're not testing
|
||||
// events in this test.
|
||||
|
||||
// Create the objects container for the events function
|
||||
gd::ObjectsContainer globalObjectsContainer;
|
||||
gd::ObjectsContainer objectsContainer;
|
||||
gd::ParameterMetadataTools::ParametersToObjectsContainer(
|
||||
project, eventsFunction.GetParameters(), objectsContainer);
|
||||
// (this is strictly not necessary because we're not testing events in this
|
||||
// test)
|
||||
|
||||
// Trigger the refactoring after the renaming of an object
|
||||
gd::WholeProjectRefactorer::ObjectOrGroupRenamedInEventsFunction(
|
||||
project,
|
||||
eventsFunction,
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
"Object1",
|
||||
"RenamedObject1",
|
||||
/* isObjectGroup=*/false);
|
||||
|
||||
REQUIRE(objectGroup.Find("Object1") == false);
|
||||
REQUIRE(objectGroup.Find("RenamedObject1") == true);
|
||||
REQUIRE(objectGroup.Find("Object2") == true);
|
||||
|
||||
// Events are not tested
|
||||
}
|
||||
|
||||
SECTION("Object deleted (in events function)") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
SetupProjectWithDummyPlatform(project, platform);
|
||||
auto &eventsExtension =
|
||||
project.InsertNewEventsFunctionsExtension("MyEventsExtension", 0);
|
||||
|
||||
// Add a (free) function with an object group
|
||||
gd::EventsFunction &eventsFunction =
|
||||
eventsExtension.InsertNewEventsFunction("MyEventsFunction", 0);
|
||||
gd::ObjectGroup &objectGroup =
|
||||
eventsFunction.GetObjectGroups().InsertNew("MyGroup", 0);
|
||||
objectGroup.AddObject("Object1");
|
||||
objectGroup.AddObject("Object2");
|
||||
// In theory, we would add the object parameters, but we're not testing
|
||||
// events in this test.
|
||||
|
||||
// Create the objects container for the events function
|
||||
gd::ObjectsContainer globalObjectsContainer;
|
||||
gd::ObjectsContainer objectsContainer;
|
||||
gd::ParameterMetadataTools::ParametersToObjectsContainer(
|
||||
project, eventsFunction.GetParameters(), objectsContainer);
|
||||
// (this is strictly not necessary because we're not testing events in this
|
||||
// test)
|
||||
|
||||
// Trigger the refactoring after the renaming of an object
|
||||
gd::WholeProjectRefactorer::ObjectOrGroupRemovedInEventsFunction(
|
||||
project,
|
||||
eventsFunction,
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
"Object1",
|
||||
/* isObjectGroup=*/false);
|
||||
|
||||
REQUIRE(objectGroup.Find("Object1") == false);
|
||||
REQUIRE(objectGroup.Find("Object2") == true);
|
||||
|
||||
// Events are not tested
|
||||
}
|
||||
|
||||
SECTION("Events extension renamed") {
|
||||
gd::Project project;
|
||||
gd::Platform platform;
|
||||
@@ -604,12 +691,11 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
auto &eventsBasedBehavior =
|
||||
eventsExtension.GetEventsBasedBehaviors().Get("MyEventsBasedBehavior");
|
||||
|
||||
gd::WholeProjectRefactorer::RenameBehaviorProperty(
|
||||
project,
|
||||
eventsExtension,
|
||||
eventsBasedBehavior,
|
||||
"MyProperty",
|
||||
"MyRenamedProperty");
|
||||
gd::WholeProjectRefactorer::RenameBehaviorProperty(project,
|
||||
eventsExtension,
|
||||
eventsBasedBehavior,
|
||||
"MyProperty",
|
||||
"MyRenamedProperty");
|
||||
|
||||
// Check if events based behaviors property has been renamed in
|
||||
// instructions
|
||||
|
@@ -5,15 +5,13 @@ if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} clone "https://www.github.com/SFML/SFML.git" SFML
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
|
||||
ERROR_QUIET
|
||||
OUTPUT_QUIET)
|
||||
|
||||
message( "Resetting SFML source code to version 2.4.1..." )
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} reset --hard 2.4.1
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/SFML
|
||||
ERROR_QUIET
|
||||
OUTPUT_QUIET)
|
||||
OUTPUT_QUIET)
|
||||
|
||||
message( "Applying the patches..." )
|
||||
file(GLOB SFML_PATCHES
|
||||
@@ -26,9 +24,8 @@ if(GIT_FOUND)
|
||||
foreach(SFML_PATCH ${SFML_PATCHES})
|
||||
message( "Applying patch: ${SFML_PATCH}..." )
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} apply ${SFML_PATCH}
|
||||
COMMAND ${GIT_EXECUTABLE} apply ${SFML_PATCH} --ignore-whitespace
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/SFML
|
||||
ERROR_QUIET
|
||||
OUTPUT_QUIET)
|
||||
endforeach()
|
||||
endif()
|
||||
|
@@ -8,7 +8,7 @@ This project is released under the MIT License.
|
||||
#include <map>
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCpp/Runtime/Serialization/SerializerElement.h"
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
|
||||
void AnchorBehavior::InitializeContent(gd::SerializerElement& content) {
|
||||
|
@@ -6,6 +6,40 @@ This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#include "DestroyOutsideBehavior.h"
|
||||
#include "GDCpp/Runtime/Serialization/SerializerElement.h"
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
|
||||
DestroyOutsideBehavior::DestroyOutsideBehavior() {}
|
||||
void DestroyOutsideBehavior::InitializeContent(gd::SerializerElement& content) {
|
||||
content.SetAttribute("extraBorder", 0);
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
std::map<gd::String, gd::PropertyDescriptor>
|
||||
DestroyOutsideBehavior::GetProperties(
|
||||
const gd::SerializerElement& behaviorContent, gd::Project& project) const {
|
||||
std::map<gd::String, gd::PropertyDescriptor> properties;
|
||||
|
||||
properties["extraBorder"]
|
||||
.SetValue(gd::String::From(
|
||||
behaviorContent.GetDoubleAttribute("extraBorder", 0)))
|
||||
.SetType("Number")
|
||||
.SetLabel(_("Margin before deleting the object, in pixels"));
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
bool DestroyOutsideBehavior::UpdateProperty(
|
||||
gd::SerializerElement& behaviorContent,
|
||||
const gd::String& name,
|
||||
const gd::String& value,
|
||||
gd::Project& project) {
|
||||
if (name == "extraBorder")
|
||||
behaviorContent.SetAttribute("extraBorder", value.To<double>());
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@@ -5,25 +5,36 @@ Copyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)
|
||||
This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef DRAGGABLEBEHAVIOR_H
|
||||
#define DRAGGABLEBEHAVIOR_H
|
||||
#include "GDCpp/Runtime/Project/Behavior.h"
|
||||
#include "GDCpp/Runtime/Project/Object.h"
|
||||
#ifndef DESTROYOUTSIDEBEHAVIOR_H
|
||||
#define DESTROYOUTSIDEBEHAVIOR_H
|
||||
#include "GDCore/Project/Behavior.h"
|
||||
#include "GDCore/Project/Object.h"
|
||||
class RuntimeScene;
|
||||
namespace gd {
|
||||
class SerializerElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Behavior that allows objects to be dragged with the mouse.
|
||||
* \brief Behavior that allows objects to be dragged with the mouse (or touch).
|
||||
*/
|
||||
class GD_EXTENSION_API DestroyOutsideBehavior : public Behavior {
|
||||
class GD_EXTENSION_API DestroyOutsideBehavior : public gd::Behavior {
|
||||
public:
|
||||
DestroyOutsideBehavior();
|
||||
DestroyOutsideBehavior(){};
|
||||
virtual ~DestroyOutsideBehavior(){};
|
||||
virtual Behavior* Clone() const { return new DestroyOutsideBehavior(*this); }
|
||||
|
||||
private:
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual std::map<gd::String, gd::PropertyDescriptor> GetProperties(
|
||||
const gd::SerializerElement& behaviorContent,
|
||||
gd::Project& project) const override;
|
||||
virtual bool UpdateProperty(gd::SerializerElement& behaviorContent,
|
||||
const gd::String& name,
|
||||
const gd::String& value,
|
||||
gd::Project& project) override;
|
||||
#endif
|
||||
|
||||
virtual void InitializeContent(
|
||||
gd::SerializerElement& behaviorContent) override;
|
||||
};
|
||||
|
||||
#endif // DRAGGABLEBEHAVIOR_H
|
||||
#endif // DESTROYOUTSIDEBEHAVIOR_H
|
||||
|
@@ -19,7 +19,7 @@ This project is released under the MIT License.
|
||||
DestroyOutsideRuntimeBehavior::DestroyOutsideRuntimeBehavior(
|
||||
const gd::SerializerElement& behaviorContent)
|
||||
: RuntimeBehavior(behaviorContent), extraBorder(0) {
|
||||
extraBorder = behaviorContent.GetDoubleAttribute("extraBorder");
|
||||
extraBorder = behaviorContent.GetDoubleAttribute("extraBorder", 0);
|
||||
}
|
||||
|
||||
void DestroyOutsideRuntimeBehavior::DoStepPostEvents(RuntimeScene& scene) {
|
||||
|
@@ -14,7 +14,7 @@ gdjs.DestroyOutsideRuntimeBehavior = function(runtimeScene, behaviorData, owner)
|
||||
{
|
||||
gdjs.RuntimeBehavior.call(this, runtimeScene, behaviorData, owner);
|
||||
|
||||
this._extraBorder = behaviorData.extraBorder;
|
||||
this._extraBorder = behaviorData.extraBorder || 0;
|
||||
};
|
||||
|
||||
gdjs.DestroyOutsideRuntimeBehavior.prototype = Object.create( gdjs.RuntimeBehavior.prototype );
|
||||
@@ -22,6 +22,8 @@ gdjs.DestroyOutsideRuntimeBehavior.thisIsARuntimeBehaviorConstructor = "DestroyO
|
||||
|
||||
gdjs.DestroyOutsideRuntimeBehavior.prototype.doStepPostEvents = function(runtimeScene) {
|
||||
|
||||
// TODO: This would better be done using the object AABB (getAABB), as (`getCenterX`;`getCenterY`) point
|
||||
// is not necessarily in the middle of the object (for sprites for example).
|
||||
var ow = this.owner.getWidth();
|
||||
var oh = this.owner.getHeight();
|
||||
var ocx = this.owner.getDrawableX()+this.owner.getCenterX();
|
||||
|
643
Extensions/DialogueTree/JsExtension.js
Normal file
643
Extensions/DialogueTree/JsExtension.js
Normal file
@@ -0,0 +1,643 @@
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
* and search for any errors.
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
'DialogueTree',
|
||||
_('Dialogue Tree (Experimental)'),
|
||||
_(
|
||||
'Start dialogue trees, made using Yarn, powered by Bondage.js. Experimental extension that can change in the future.'
|
||||
),
|
||||
'Todor Imreorov',
|
||||
'Open source (MIT License)'
|
||||
)
|
||||
.setExtensionHelpPath('/all-features/dialogue-tree');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'LoadDialogueFromSceneVariable',
|
||||
_('Load dialogue Tree from a Scene Variable'),
|
||||
_(
|
||||
'Load a dialogue data object - Yarn json format, stored in a scene variable. Use this command to load all the Dialogue data at the beginning of the game.'
|
||||
),
|
||||
_('Load dialogue data from Scene variable _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter(
|
||||
'scenevar',
|
||||
_('Scene variable that holds the Yarn Json data'),
|
||||
'',
|
||||
false
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/DialogueTree/dialoguetools.js')
|
||||
.addIncludeFile('Extensions/DialogueTree/bondage.min.js')
|
||||
.setFunctionName('gdjs.dialogueTree.loadFromSceneVariable');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'LoadDialogueFromJsonFile',
|
||||
_('Load dialogue Tree from a Json File'),
|
||||
_(
|
||||
'Load a dialogue data object - Yarn json format, stored in a Json file. Use this command to load all the Dialogue data at the beginning of the game.'
|
||||
),
|
||||
_('Load dialogue data from json file _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addCodeOnlyParameter('currentScene', '')
|
||||
.addParameter(
|
||||
'jsonResource',
|
||||
_('Json file that holds the Yarn Json data'),
|
||||
'',
|
||||
false
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/DialogueTree/dialoguetools.js')
|
||||
.addIncludeFile('Extensions/DialogueTree/bondage.min.js')
|
||||
.setFunctionName('gdjs.dialogueTree.loadFromJsonFile');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'StartDialogueFromBranch',
|
||||
_('Start dialogue from branch'),
|
||||
_(
|
||||
'Start dialogue from branch. Use this to initiate the dialogue from a specified branch.'
|
||||
),
|
||||
_('Start dialogue from branch _PARAM0_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Dialogue branch'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.startFrom');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'StopRunningDialogue',
|
||||
_('Stop running dialogue'),
|
||||
_('Stop the running dialogue. Use this to interrupt dialogue parsing.'),
|
||||
_('Stop running dialogue'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.stopRunningDialogue');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'GoToNextLine',
|
||||
_('Go to the next dialogue line'),
|
||||
_(
|
||||
'Go to the next dialogue line. Use this to advance to the next dialogue line when the player presses a button.'
|
||||
),
|
||||
_('Go to the next dialogue line'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.goToNextDialogueLine');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'ConfirmSelectOption',
|
||||
_('Confirm selected Option'),
|
||||
_(
|
||||
'Set the selected option as confirmed, which will validate it and go forward to the next node. Use other actions to select options (see "select next option" and "Select previous option").'
|
||||
),
|
||||
_('Confirm selected Option'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.confirmSelectOption');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'SelectNextOption',
|
||||
_('Select next Option'),
|
||||
_(
|
||||
'Select next Option (add 1 to selected option number). Use this when the dialogue line is of type "options" and the player has pressed a button to change selected option.'
|
||||
),
|
||||
_('Select next Option'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.selectNextOption');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'SelectPreviousOption',
|
||||
_('Select previous Option'),
|
||||
_(
|
||||
'Select previous Option (subtract 1 from selected option number). Use this when the dialogue line is of type "options" and the player has pressed a button to change selected option.'
|
||||
),
|
||||
_('Select previous Option'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.selectPreviousOption');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'SelectOption',
|
||||
_('Select option by number'),
|
||||
_(
|
||||
'Select option by number. Use this when the dialogue line is of type "options" and the player has pressed a button to change selected option.'
|
||||
),
|
||||
_('Select option by number'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('Option index number'), '', false)
|
||||
.setDefaultValue('0')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.selectPreviousOption');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'ScrollClippedText',
|
||||
_('Scroll clipped text'),
|
||||
_(
|
||||
'Scroll clipped text. Use this with a timer and "get clipped text" when you want to create a typewriter effect. Every time the action runs, a new character appears from the text.'
|
||||
),
|
||||
_('Scroll clipped text'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.scrollClippedText');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'CompleteClippedTextScrolling',
|
||||
_('Complete clipped text scrolling'),
|
||||
_(
|
||||
'Complete the clipped text scrolling. Use this action whenever you want to skip scrolling.'
|
||||
),
|
||||
_('Complete clipped text scrolling'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.completeClippedTextScrolling');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'SetVariable',
|
||||
_('Set dialogue state variable'),
|
||||
_(
|
||||
'Set dialogue state variable. Use this to set a variable that the dialogue data is using.'
|
||||
),
|
||||
_('Set dialogue state variable _PARAM0_ to _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('State Variable Name'), '', false)
|
||||
.addParameter('expression', _('Variable Value'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.setVariable');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'SaveState',
|
||||
_('Save dialogue state'),
|
||||
_(
|
||||
'Save dialogue state. Use this to store the dialogue state into a variable, which can later be used for saving the game. That way player choices can become part of the game save.'
|
||||
),
|
||||
_('Save dialogue state to _PARAM0_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('globalvar', _('Global Variable'))
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.saveState');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'LoadState',
|
||||
_('Load dialogue state'),
|
||||
_(
|
||||
'Load dialogue state. Use this to restore dialogue state, if you have stored in a variable before with the "Save state" action.'
|
||||
),
|
||||
_('Load dialogue state from _PARAM0_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('globalvar', _('Global Variable'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.loadState');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'LineText',
|
||||
_('Get the current dialogue line text'),
|
||||
_('Returns the current dialogue line text'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getLineText');
|
||||
|
||||
extension
|
||||
.addExpression(
|
||||
'OptionsCount',
|
||||
_('Get the number of options in an options line type'),
|
||||
_('Get the number of options in an options line type'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getLineOptionsCount');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'Option',
|
||||
_('Get the text of an option from an Options line type'),
|
||||
_(
|
||||
"Get the text of an option from an Options line type, using the option's Number. The numbers start from 0."
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('Option Index Number'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getLineOption');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'HorizontalOptionsList',
|
||||
_('Get a Horizontal list of options from the Options line type'),
|
||||
_(
|
||||
"Get the text of all available options from an Options line type as a horizontal list. You can also pass the selected option's cursor string, which by default is ->"
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Options Selection Cursor'), '', false)
|
||||
.setDefaultValue('>')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getLineOptionsTextHorizontal');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'VerticalOptionsList',
|
||||
_('Get a Vertical list of options from the Options line type'),
|
||||
_(
|
||||
"Get the text of all available options from an Options line type as a vertical list. You can also pass the selected option's cursor string, which by default is ->"
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Options Selection Cursor'), '', false)
|
||||
.setDefaultValue('>')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getLineOptionsTextVertical');
|
||||
|
||||
extension
|
||||
.addExpression(
|
||||
'SelectedOptionIndex',
|
||||
_('Get the number of the currently selected option'),
|
||||
_(
|
||||
'Get the number of the currently selected option. Use this to help you render the option selection marker at the right place.'
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getSelectedOption');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'ClippedLineText',
|
||||
_('Get dialogue line text clipped'),
|
||||
_(
|
||||
'Get dialogue line text clipped by the typewriter effect. Use the "Scroll clipped text" action to control the typewriter effect.'
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getClippedLineText');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'BranchTitle',
|
||||
_('Get the title of the current branch of the running dialogue'),
|
||||
_('Get the title of the current branch of the running dialogue'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getBranchTitle');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'BranchTags',
|
||||
_('Get the tags of the current branch of the running dialogue'),
|
||||
_('Get the tags of the current branch of the running dialogue'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getBranchTags');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'BranchTag',
|
||||
_('Get a tag of the current branch of the running dialogue via its index'),
|
||||
_('Get a tag of the current branch of the running dialogue via its index'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('Tag Index Number'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getBranchTag');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'CommandParameter',
|
||||
_('Get the parameters of a command call'),
|
||||
_(
|
||||
'Get the parameters of a command call - <<command withParameter anotherParameter>>'
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('parameter Index Number'), '', true)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getCommandParameter');
|
||||
|
||||
extension
|
||||
.addExpression(
|
||||
'CommandParametersCount',
|
||||
_('Get the number of parameters in the currently passed command'),
|
||||
_('Get the number of parameters in the currently passed command'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.commandParametersCount');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'TagParameter',
|
||||
_(
|
||||
'Get parameter from a Tag found by the branch contains tag condition'
|
||||
),
|
||||
_(
|
||||
'Get parameter from a Tag found by the branch contains tag condition'
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('parameter Index Number'), '', true)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getTagParameter');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'VisitedBranchTitles',
|
||||
_('Get a list of all visited branches'),
|
||||
_('Get a list of all visited branches'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getVisitedBranchTitles');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'BranchText',
|
||||
_('Get the full raw text of the current branch'),
|
||||
_('Get the full raw text of the current branch'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getBranchText');
|
||||
|
||||
extension
|
||||
.addExpression(
|
||||
'Variable',
|
||||
_('Get dialogue state value'),
|
||||
_('Get dialogue state value'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Variable Name'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.getVariable');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'IsCommandCalled',
|
||||
_('Command is called'),
|
||||
_(
|
||||
'Check if a specific Command is called. If it is a <<command withParameter>>, you can even get the parameter with the CommandParameter expression.'
|
||||
),
|
||||
_('Command <<_PARAM0_>> is called'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Command String'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.isCommandCalled');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'IsDialogueLineType',
|
||||
_('Dialogue line type'),
|
||||
_(
|
||||
'Check if the the current dialogue line line is one of the three existing types. Use this to set what logic is executed for each type.\nThe three types are as follows:\n- text: when displaying dialogue text.\n- options: when displaying [[branching/options]] for dialogue choices.\n-command: when <<commands>> are triggered by the dialogue data.'
|
||||
),
|
||||
_('The dialogue line is _PARAM0_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter(
|
||||
'stringWithSelector',
|
||||
_('type'),
|
||||
'["text", "options", "command"]',
|
||||
false
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.isDialogueLineType');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'IsDialogueRunning',
|
||||
_('Dialogue is running'),
|
||||
_(
|
||||
'Check if the dialogue is running. Use this to for things like locking the player movement while speaking with a non player character.'
|
||||
),
|
||||
_('Dialogue is running'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.isRunning');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'HasBranch',
|
||||
_('Dialogue has branch'),
|
||||
_(
|
||||
'Check if the dialogue has a branch with specified name. Use this to check if a dialogue branch exists in the loaded dialogue data.'
|
||||
),
|
||||
_('Dialogue has a branch named _PARAM0_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Branch name'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.hasDialogueBranch');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'HasSelectedOptionChanged',
|
||||
_('Has selected option changed'),
|
||||
_(
|
||||
'Check if a selected option has changed when the current dialogue line type is options. Use this to detect when the player has selected another option, so you can re-draw where the selection arrow is.'
|
||||
),
|
||||
_('Selected option has changed'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.hasSelectedOptionChanged');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'CurrentBranchTitle',
|
||||
_('Current dialogue branch title'),
|
||||
_(
|
||||
'Check if the current dialogue branch title is equal to a string. Use this to trigger game events when the player has visited a specific dialogue branch.'
|
||||
),
|
||||
_('The current dialogue branch title is _PARAM0_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('title name'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.branchTitleIs');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'CurrentBranchContainsTag',
|
||||
_('Current dialogue branch contains a tag'),
|
||||
_(
|
||||
'Check if the current dialogue branch contains a specific tag. Tags are an alternative useful way to <<commands>> to drive game logic with the dialogue data.'
|
||||
),
|
||||
_('The current dialogue branch contains a _PARAM0_ tag'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('tag name'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.branchContainsTag');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'WasBranchVisited',
|
||||
_('Branch title has been visited before'),
|
||||
_('Check if the current branch has been visited before'),
|
||||
_('Branch title _PARAM0_ has been visited before'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('branch title'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.branchTitleHasBeenVisited');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'CompareDialogueStateVariable',
|
||||
_('Compare dialogue state variable'),
|
||||
_(
|
||||
'Compare dialogue state variable. Use this to trigger game events via dialogue variables.'
|
||||
),
|
||||
_('Dialogue state variable _PARAM0_ is equal to _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('State variable'), '', false)
|
||||
.addParameter('string', _('Equal to'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.compareVariable');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'HasClippedTextScrollingCompleted',
|
||||
_('Clipped text has completed scrolling'),
|
||||
_(
|
||||
'Check if the clipped text scrolling has completed. Use this to prevent the player from going to the next dialogue line before the typing effect has revealed the entire text.'
|
||||
),
|
||||
_('Clipped text has completed scrolling'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.hasClippedScrollingCompleted');
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
return [];
|
||||
},
|
||||
};
|
11
Extensions/DialogueTree/bondage.min.js
vendored
Normal file
11
Extensions/DialogueTree/bondage.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
679
Extensions/DialogueTree/dialoguetools.js
Normal file
679
Extensions/DialogueTree/dialoguetools.js
Normal file
@@ -0,0 +1,679 @@
|
||||
/**
|
||||
* @memberof gdjs
|
||||
* @class dialogueTree
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
|
||||
gdjs.dialogueTree = {};
|
||||
gdjs.dialogueTree.runner = new bondage.Runner();
|
||||
|
||||
/**
|
||||
* Load the Dialogue Tree data of the game. Initialize The Dialogue Tree, so as it can be used in the game.
|
||||
* @param {gdjs.Variable} sceneVar The variable to load the Dialogue tree data from. The data is a JSON string, created by Yarn.
|
||||
* @param {string} startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action
|
||||
*/
|
||||
gdjs.dialogueTree.loadFromSceneVariable = function(
|
||||
sceneVar,
|
||||
startDialogueNode
|
||||
) {
|
||||
this.runner = gdjs.dialogueTree.runner;
|
||||
|
||||
try {
|
||||
this.yarnData = JSON.parse(sceneVar.getAsString());
|
||||
this.runner.load(this.yarnData);
|
||||
|
||||
if (startDialogueNode && startDialogueNode.length > 0) {
|
||||
gdjs.dialogueTree.startFrom(startDialogueNode);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the Dialogue Tree data from a JSON resource.
|
||||
*
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The scene where the dialogue is running.
|
||||
* @param {string} jsonResourceName The JSON resource where to load the Dialogue Tree data from. The data is a JSON string usually created with [Yarn Dialogue Editor](https://github.com/InfiniteAmmoInc/Yarn).
|
||||
* @param {string} startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action
|
||||
*/
|
||||
gdjs.dialogueTree.loadFromJsonFile = function(
|
||||
runtimeScene,
|
||||
jsonResourceName,
|
||||
startDialogueNode
|
||||
) {
|
||||
runtimeScene
|
||||
.getGame()
|
||||
.getJsonManager()
|
||||
.loadJson(jsonResourceName, function(error, content) {
|
||||
if (error) {
|
||||
console.error('An error happened while loading JSON resource:', error);
|
||||
} else {
|
||||
if (!content) return;
|
||||
gdjs.dialogueTree.yarnData = content;
|
||||
|
||||
try {
|
||||
gdjs.dialogueTree.runner.load(gdjs.dialogueTree.yarnData);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
'An error happened while loading parsing the dialogue tree data:',
|
||||
error
|
||||
);
|
||||
}
|
||||
|
||||
if (startDialogueNode && startDialogueNode.length > 0) {
|
||||
gdjs.dialogueTree.startFrom(startDialogueNode);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop the currently running dialogue
|
||||
*/
|
||||
gdjs.dialogueTree.stopRunningDialogue = function() {
|
||||
if (this.dialogueIsRunning) this.dialogueIsRunning = false;
|
||||
if (this.dialogueData) this.dialogueData = null;
|
||||
this.dialogueText = '';
|
||||
this.clipTextEnd = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the Dialogue Tree is currently parsing data.
|
||||
* For example, you can do things like disabling player movement while talking to a NPC.
|
||||
*/
|
||||
gdjs.dialogueTree.isRunning = function() {
|
||||
if (
|
||||
this.dialogueIsRunning &&
|
||||
!this.dialogueData &&
|
||||
this.dialogueText &&
|
||||
this.clipTextEnd >= this.dialogueText.length
|
||||
) {
|
||||
this.dialogueIsRunning = false;
|
||||
}
|
||||
return this.dialogueIsRunning;
|
||||
};
|
||||
|
||||
/**
|
||||
* Scroll the clipped text. This can be combined with a timer and user input to control how fast the dialogue line text is scrolling.
|
||||
*/
|
||||
gdjs.dialogueTree.scrollClippedText = function() {
|
||||
if (this.pauseScrolling || !this.dialogueIsRunning) return;
|
||||
|
||||
if (this.dialogueText) {
|
||||
this.clipTextEnd += 1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Scroll the clipped text to its end, so the entire text is printed. This can be useful in keeping the event sheet logic simpler, while supporting more variation.
|
||||
*/
|
||||
gdjs.dialogueTree.completeClippedTextScrolling = function() {
|
||||
if (this.pauseScrolling || !this.dialogueIsRunning || !this.dialogueText)
|
||||
return;
|
||||
this.clipTextEnd = this.dialogueText.length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if text scrolling has completed.
|
||||
* Useful to prevent the user from skipping to next line before the current one has been printed fully.
|
||||
*/
|
||||
gdjs.dialogueTree.hasClippedScrollingCompleted = function() {
|
||||
if (this.dialogueData && this.dialogueText.length) {
|
||||
return this.clipTextEnd >= this.dialogueText.length;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current dialogue line with a scrolling effect (recommended).
|
||||
* Used with the scrollClippedText to achieve a classic scrolling text, as well as any <<wait>> effects to pause scrolling.
|
||||
*/
|
||||
gdjs.dialogueTree.getClippedLineText = function() {
|
||||
return this.dialogueText.length
|
||||
? this.dialogueText.substring(0, this.clipTextEnd)
|
||||
: '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current complete dialogue line without using any scrolling effects.
|
||||
* Note that using this instead getClippedLineText will skip any <<wait>> commands entirely.
|
||||
*/
|
||||
gdjs.dialogueTree.getLineText = function() {
|
||||
this.completeClippedTextScrolling();
|
||||
return this.dialogueText.length ? this.dialogueText : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of command parameters in a command with parameters that has been caught by a isCommandCalled condition
|
||||
*/
|
||||
gdjs.dialogueTree.commandParametersCount = function() {
|
||||
if (this.commandParameters && this.commandParameters.length > 1) {
|
||||
return this.commandParameters.length - 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a command parameter in any command with parameters that has been caught by a isCommandCalled condition
|
||||
* @param {number} paramIndex The index of the parameter to get.
|
||||
*/
|
||||
gdjs.dialogueTree.getCommandParameter = function(paramIndex) {
|
||||
if (
|
||||
this.commandParameters &&
|
||||
this.commandParameters.length >= paramIndex + 1
|
||||
) {
|
||||
var returnedParam = this.commandParameters[paramIndex + 1];
|
||||
return returnedParam ? returnedParam : '';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Catch <<commands>> and <<commands with parameters>> from the current Dialogue Line.
|
||||
* You can trigger custom logic that relate to the story you are telling during the dialogue.
|
||||
*
|
||||
* @param {string} command The command you want to check for being called. Write it without the `<<>>`.
|
||||
*/
|
||||
gdjs.dialogueTree.isCommandCalled = function(command) {
|
||||
var commandCalls = gdjs.dialogueTree.commandCalls;
|
||||
var clipTextEnd = gdjs.dialogueTree.clipTextEnd;
|
||||
var dialogueText = gdjs.dialogueTree.dialogueText;
|
||||
|
||||
if (this.pauseScrolling || !commandCalls) return false;
|
||||
return this.commandCalls.some(function(call, index) {
|
||||
if (clipTextEnd < call.time) return false;
|
||||
if (call.cmd === 'wait' && clipTextEnd !== dialogueText.length) {
|
||||
gdjs.dialogueTree.pauseScrolling = true;
|
||||
setTimeout(function() {
|
||||
gdjs.dialogueTree.pauseScrolling = false;
|
||||
commandCalls.splice(index, 1);
|
||||
}, parseInt(call.params[1], 10));
|
||||
}
|
||||
if (call.cmd === command) {
|
||||
gdjs.dialogueTree.commandParameters = call.params;
|
||||
commandCalls.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal method to allow for capping option selection.
|
||||
* @private
|
||||
*/
|
||||
gdjs.dialogueTree._normalizedOptionIndex = function(optionIndex) {
|
||||
if (optionIndex >= this.options.length) optionIndex = this.options.length - 1;
|
||||
if (optionIndex < 0) optionIndex = 0;
|
||||
return optionIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal method to allow for cycling option selection.
|
||||
* @private
|
||||
*/
|
||||
gdjs.dialogueTree._cycledOptionIndex = function(optionIndex) {
|
||||
if (optionIndex >= this.options.length) optionIndex = 0;
|
||||
if (optionIndex < 0) optionIndex = this.options.length - 1;
|
||||
return optionIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the text of an option the player can select.
|
||||
* Used with getLineOptionsCount to render options for the player when a line of the Options type is parsed
|
||||
* @param {number} optionIndex The index of the option you want to get
|
||||
*/
|
||||
gdjs.dialogueTree.getLineOption = function(optionIndex) {
|
||||
if (!this.options.length) return [];
|
||||
optionIndex = gdjs.dialogueTree._normalizedOptionIndex(optionIndex);
|
||||
return this.options[optionIndex];
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the text of the options the player can select, along with the selection cursor.
|
||||
* @param {string} optionSelectionCursor The string used to draw the currently selected option's cursor
|
||||
* @param {boolean} addNewLine when true each option is rendered on a new line.
|
||||
*/
|
||||
gdjs.dialogueTree.getLineOptionsText = function(
|
||||
optionSelectionCursor,
|
||||
addNewLine
|
||||
) {
|
||||
if (!this.options.length) return '';
|
||||
var textResult = '';
|
||||
this.options.forEach(function(optionText, index) {
|
||||
if (index === gdjs.dialogueTree.selectedOption) {
|
||||
textResult += optionSelectionCursor;
|
||||
} else {
|
||||
textResult += optionSelectionCursor.replace(/.*/g, ' ');
|
||||
}
|
||||
textResult += optionText;
|
||||
if (addNewLine) textResult += '\n';
|
||||
});
|
||||
return textResult;
|
||||
};
|
||||
gdjs.dialogueTree.getLineOptionsTextHorizontal = function(
|
||||
optionSelectionCursor
|
||||
) {
|
||||
return this.getLineOptionsText(optionSelectionCursor, false);
|
||||
};
|
||||
gdjs.dialogueTree.getLineOptionsTextVertical = function(optionSelectionCursor) {
|
||||
return this.getLineOptionsText(optionSelectionCursor, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of options that are presented to the player, during the parsing of an Options type line.
|
||||
* @returns {number} The number of options
|
||||
*/
|
||||
gdjs.dialogueTree.getLineOptionsCount = function() {
|
||||
if (this.options.length) {
|
||||
return this.optionsCount;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Confirm the currently selected option, during the parsing of an Options type line.
|
||||
*
|
||||
* This will advance the dialogue tree to the dialogue branch was selected by the player.
|
||||
*/
|
||||
gdjs.dialogueTree.confirmSelectOption = function() {
|
||||
if (
|
||||
this.dialogueData.select &&
|
||||
!this.selectedOptionUpdated &&
|
||||
this.selectedOption !== -1
|
||||
) {
|
||||
this.commandCalls = [];
|
||||
try {
|
||||
this.dialogueData.select(this.selectedOption);
|
||||
this.dialogueData = this.dialogue.next().value;
|
||||
gdjs.dialogueTree.goToNextDialogueLine();
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`An error happened when trying to access the dialogue branch!`,
|
||||
error
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Select next option during Options type line parsing. Hook this to your game input.
|
||||
*/
|
||||
gdjs.dialogueTree.selectNextOption = function() {
|
||||
if (this.dialogueData.select) {
|
||||
this.selectedOption += 1;
|
||||
this.selectedOption = gdjs.dialogueTree._cycledOptionIndex(
|
||||
this.selectedOption
|
||||
);
|
||||
this.selectedOptionUpdated = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Select previous option during Options type line parsing. Hook this to your game input.
|
||||
*/
|
||||
gdjs.dialogueTree.selectPreviousOption = function() {
|
||||
if (this.dialogueData.select) {
|
||||
this.selectedOption -= 1;
|
||||
this.selectedOption = gdjs.dialogueTree._cycledOptionIndex(
|
||||
this.selectedOption
|
||||
);
|
||||
this.selectedOptionUpdated = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Select option by index during Options type line parsing.
|
||||
* @param {number} optionIndex The index of the option to select
|
||||
*/
|
||||
gdjs.dialogueTree.selectOption = function(optionIndex) {
|
||||
if (this.dialogueData.select) {
|
||||
this.selectedOption = gdjs.dialogueTree._normalizedOptionIndex(
|
||||
this.selectedOption
|
||||
);
|
||||
this.selectedOptionUpdated = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the currently selected option
|
||||
* @returns {number} The index of the currently selected option
|
||||
*/
|
||||
gdjs.dialogueTree.getSelectedOption = function() {
|
||||
if (this.dialogueData.select) {
|
||||
return this.selectedOption;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check when the player has changed option selection since the last call to this function.
|
||||
*
|
||||
* Can be used to re-render your displayed dialogue options when needed.
|
||||
*
|
||||
* @returns {boolean} true if the selected option was updated since the last call to this function
|
||||
*/
|
||||
gdjs.dialogueTree.hasSelectedOptionChanged = function() {
|
||||
if (this.selectedOptionUpdated) {
|
||||
this.selectedOptionUpdated = false;
|
||||
if (this.selectedOption === -1) this.selectedOption = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check the type of the Dialogue Line that is being displayed to the player at the moment.
|
||||
*
|
||||
* There are three types:
|
||||
* - text - regular dialogue text is being parsed at the moment
|
||||
* - options - the player has reached a branching choise moment where they must select one of multiple options
|
||||
* - command - a <<command>> was called in the background, that can be used to trigger game events, but will not be displayed in the dialogue box.
|
||||
*
|
||||
* @param {string} type The type you want to check for ( one of the three above )
|
||||
*/
|
||||
gdjs.dialogueTree.isDialogueLineType = function(type) {
|
||||
if (
|
||||
this.commandCalls &&
|
||||
this.commandCalls.some(function(call) {
|
||||
return gdjs.dialogueTree.clipTextEnd > call.time && call.cmd === 'wait';
|
||||
})
|
||||
) {
|
||||
return !this.pauseScrolling;
|
||||
}
|
||||
|
||||
return this.dialogueIsRunning ? this.dialogueDataType === type : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a branch exists. It is also used internaly whenever you use the start from action.
|
||||
* @param {string} branchName The Dialogue Branch name you want to check.
|
||||
*/
|
||||
gdjs.dialogueTree.hasDialogueBranch = function(branchName) {
|
||||
return (
|
||||
this.runner &&
|
||||
this.runner.yarnNodes &&
|
||||
Object.keys(this.runner.yarnNodes).some(function(node) {
|
||||
return node === branchName;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Start parsing dialogue from a specified Dialogue tree branch.
|
||||
* Can be used if you want to store multiple dialogues inside a single Dialogue tree data set.
|
||||
* @param {string} startDialogueNode The Dialogue Branch name you want to start parsing from.
|
||||
*/
|
||||
gdjs.dialogueTree.startFrom = function(startDialogueNode) {
|
||||
this.runner = gdjs.dialogueTree.runner;
|
||||
if (!this.hasDialogueBranch(startDialogueNode)) return;
|
||||
this.optionsCount = 0;
|
||||
this.options = [];
|
||||
this.dialogueBranchTitle = '';
|
||||
this.dialogueBranchBody = '';
|
||||
this.dialogueBranchTags = [];
|
||||
this.tagParameters = [];
|
||||
this.dialogue = this.runner.run(startDialogueNode);
|
||||
this.dialogueData = null;
|
||||
this.dialogueDataType = '';
|
||||
this.dialogueText = '';
|
||||
this.clipTextEnd = 0;
|
||||
this.commandCalls = [];
|
||||
this.commandParameters = [];
|
||||
this.pauseScrolling = false;
|
||||
this.dialogueData = this.dialogue.next().value;
|
||||
this.dialogueIsRunning = true;
|
||||
gdjs.dialogueTree.goToNextDialogueLine();
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal methods to check the type of a Dialogue Line
|
||||
*/
|
||||
gdjs.dialogueTree._isLineTypeText = function() {
|
||||
return this.dialogueData instanceof bondage.TextResult;
|
||||
};
|
||||
gdjs.dialogueTree._isLineTypeOptions = function() {
|
||||
return this.dialogueData instanceof bondage.OptionsResult;
|
||||
};
|
||||
gdjs.dialogueTree._isLineTypeCommand = function() {
|
||||
return this.dialogueData instanceof bondage.CommandResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is the main lifecycle function.It runs once only when the user is advancing the dialogue to the next line.
|
||||
* Progress Dialogue to the next line. Hook it to your game input.
|
||||
* Note that this action can be influenced by any <<wait>> commands, but they work only if you have at least one isCommandCalled condition.
|
||||
*/
|
||||
gdjs.dialogueTree.goToNextDialogueLine = function() {
|
||||
if (this.pauseScrolling || !this.dialogueIsRunning) return;
|
||||
|
||||
this.optionsCount = 0;
|
||||
this.selectedOption = -1;
|
||||
this.selectedOptionUpdated = false;
|
||||
|
||||
if (gdjs.dialogueTree._isLineTypeText()) {
|
||||
if (
|
||||
this.dialogueDataType === 'options' ||
|
||||
this.dialogueDataType === 'text' ||
|
||||
!this.dialogueDataType
|
||||
) {
|
||||
this.clipTextEnd = 0;
|
||||
this.dialogueText = this.dialogueData.text;
|
||||
this.commandCalls = [];
|
||||
} else {
|
||||
this.dialogueText += this.dialogueData.text;
|
||||
}
|
||||
|
||||
this.dialogueDataType = 'text';
|
||||
this.dialogueBranchTags = this.dialogueData.data.tags;
|
||||
this.dialogueBranchTitle = this.dialogueData.data.title;
|
||||
this.dialogueBranchBody = this.dialogueData.data.body;
|
||||
this.dialogueData = this.dialogue.next().value;
|
||||
} else if (gdjs.dialogueTree._isLineTypeOptions()) {
|
||||
this.dialogueDataType = 'options';
|
||||
this.optionsCount = this.dialogueData.options.length;
|
||||
this.options = this.dialogueData.options;
|
||||
this.selectedOptionUpdated = true;
|
||||
} else if (gdjs.dialogueTree._isLineTypeCommand()) {
|
||||
this.dialogueDataType = 'command';
|
||||
|
||||
var command = this.dialogueData.text.split(' ');
|
||||
// If last command was to wait, increase time by one
|
||||
var offsetTime =
|
||||
this.commandCalls.length &&
|
||||
this.commandCalls[this.commandCalls.length - 1].cmd === 'wait'
|
||||
? 1
|
||||
: 0;
|
||||
this.commandCalls.push({
|
||||
cmd: command[0],
|
||||
params: command,
|
||||
time: this.dialogueText.length + offsetTime,
|
||||
});
|
||||
this.dialogueData = this.dialogue.next().value;
|
||||
gdjs.dialogueTree.goToNextDialogueLine();
|
||||
} else {
|
||||
this.dialogueDataType = 'unknown';
|
||||
}
|
||||
|
||||
if (gdjs.dialogueTree._isLineTypeCommand()) {
|
||||
this.dialogueDataType = 'command';
|
||||
gdjs.dialogueTree.goToNextDialogueLine();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current Dialogue Tree branch title.
|
||||
* @returns {string} The current branch title.
|
||||
*/
|
||||
gdjs.dialogueTree.getBranchTitle = function() {
|
||||
if (this.dialogueIsRunning) {
|
||||
return this.dialogueBranchTitle;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the currently parsed Dialogue branch title is a query.
|
||||
* @param {string} title The Dialogue Branch name you want to check for.
|
||||
*/
|
||||
gdjs.dialogueTree.branchTitleIs = function(title) {
|
||||
if (this.dialogueIsRunning) {
|
||||
return this.dialogueBranchTitle === title;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all the branch tags from the current Dialogue branch as a string. Useful for debugging.
|
||||
* @returns {string} The current branch tags, separated by a comma.
|
||||
*/
|
||||
gdjs.dialogueTree.getBranchTags = function() {
|
||||
if (this.dialogueIsRunning) {
|
||||
return this.dialogueBranchTags.join(',');
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get one of the current Dialogue branch tags via index.
|
||||
* @param {number} index The index of the Dialogue Branch tag you want to get.
|
||||
* @returns {string} The branch tag at the specified index, or an empty string if not found.
|
||||
*/
|
||||
gdjs.dialogueTree.getBranchTag = function(index) {
|
||||
if (this.dialogueIsRunning && this.dialogueBranchTags.length) {
|
||||
if (index > this.dialogueBranchTags.length - 1)
|
||||
index = this.dialogueBranchTags.length - 1;
|
||||
return this.dialogueBranchTags[index];
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the current Dialogue branch contains a specific tag.
|
||||
* @param {string} query The name of the Dialogue Branch tag you want to check.
|
||||
*/
|
||||
gdjs.dialogueTree.branchContainsTag = function(query) {
|
||||
this.tagParameters = [];
|
||||
if (this.dialogueIsRunning && this.dialogueBranchTags.length) {
|
||||
return this.dialogueBranchTags.some(function(tag) {
|
||||
var splitTag = tag.match(/([^\(]+)\(([^\)]+)\)/i);
|
||||
gdjs.dialogueTree.tagParameters = splitTag ? splitTag[2].split(',') : [];
|
||||
return splitTag ? splitTag[1] === query : tag === query;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get any tag(parameter,anotherParameter) from a tag captured by the branchContainsTag Condition
|
||||
* @param {number} paramIndex The index of the tag parameter you want to get.
|
||||
* Leaving this empty will result in retrieving the first parameter.
|
||||
*/
|
||||
gdjs.dialogueTree.getTagParameter = function(paramIndex) {
|
||||
if (this.dialogueIsRunning && this.tagParameters.length >= paramIndex) {
|
||||
var returnedParam = this.tagParameters[paramIndex];
|
||||
return returnedParam ? returnedParam : '';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a list of all the titles of visited by the player Branches. Useful for debugging.
|
||||
*/
|
||||
gdjs.dialogueTree.getVisitedBranchTitles = function() {
|
||||
if (this.dialogueIsRunning) {
|
||||
return Object.keys(this.runner.visited).join(',');
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a player has visited a Dialogue Branch in the past.
|
||||
* @param {string} title The title of the branch to check for.
|
||||
* Leaving this empty will check if the current branch title has been visited in the past.
|
||||
*/
|
||||
gdjs.dialogueTree.branchTitleHasBeenVisited = function(title) {
|
||||
if (!title) title = this.dialogueBranchTitle;
|
||||
return (
|
||||
Object.keys(this.runner.visited).includes(title) &&
|
||||
this.runner.visited[title]
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the entire unparsed text of the current Dialogue Branch
|
||||
*/
|
||||
gdjs.dialogueTree.getBranchText = function() {
|
||||
if (this.dialogueIsRunning) {
|
||||
return this.dialogueBranchBody;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the value of a variable that was created by the Dialogue parses.
|
||||
* @param {string} key The name of the variable you want to get the value of
|
||||
*/
|
||||
gdjs.dialogueTree.getVariable = function(key) {
|
||||
if (this.dialogueIsRunning && key in this.runner.variables.data) {
|
||||
return this.runner.variables.data[key];
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a specific variable created by the Dialogue parses exists and is equal to a specific value.
|
||||
* @param {string} key The name of the variable you want to check the value of
|
||||
* @param {string} value The value you want to check against
|
||||
*/
|
||||
gdjs.dialogueTree.compareVariable = function(key, value) {
|
||||
if (this.dialogueIsRunning && key in this.runner.variables.data) {
|
||||
return this.runner.variables.data[key].toString() === value;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a specific variable created by the Dialogue parser to a specific value.
|
||||
* @param {string} key The name of the variable you want to set the value of
|
||||
* @param {string} value The value you want to set
|
||||
*/
|
||||
gdjs.dialogueTree.setVariable = function(key, value) {
|
||||
if (this.dialogueIsRunning && this.runner.variables.data) {
|
||||
this.runner.variables.data[key] = value;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Store the current State of the Dialogue Parser in a specified variable.
|
||||
* Can be used to implement persistence in dialogue through your game's Load/Save function.
|
||||
* That way you can later load all the dialogue choices the player has made.
|
||||
* @param {gdjs.Variable} outputVariable The variable where to store the State
|
||||
*/
|
||||
gdjs.dialogueTree.saveState = function(outputVariable) {
|
||||
const dialogueState = {
|
||||
variables: gdjs.dialogueTree.runner.variables.data,
|
||||
visited: gdjs.dialogueTree.runner.visited,
|
||||
};
|
||||
gdjs.evtTools.network._objectToVariable(dialogueState, outputVariable);
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the current State of the Dialogue Parser from a specified variable.
|
||||
* Can be used to implement persistence in dialogue through your game's Load/Save function.
|
||||
* That way you can later load all the dialogue choices the player has made.
|
||||
* @param {gdjs.Variable} inputVariable The variable where to load the State from.
|
||||
*/
|
||||
gdjs.dialogueTree.loadState = function(inputVariable) {
|
||||
const jsonData = gdjs.evtTools.network.variableStructureToJSON(inputVariable);
|
||||
try {
|
||||
const loadedState = JSON.parse(
|
||||
gdjs.evtTools.network.variableStructureToJSON(inputVariable)
|
||||
);
|
||||
gdjs.dialogueTree.runner.visited = loadedState.visited;
|
||||
gdjs.dialogueTree.runner.variables.data = loadedState.variables;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
81
Extensions/DialogueTree/tests/assignment.json
Normal file
81
Extensions/DialogueTree/tests/assignment.json
Normal file
@@ -0,0 +1,81 @@
|
||||
[
|
||||
{
|
||||
"title": "Numeric",
|
||||
"tags": "Tag",
|
||||
"body": "Test Line\n<<set $testvar = -123.4>>\nTest Line After",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},{
|
||||
"title": "NumericExpression",
|
||||
"tags": "Tag",
|
||||
"body": "Test Line\n<<set $testvar = (1 + 2) * -3 + 4.3>>\nTest Line After",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "String",
|
||||
"tags": "Tag",
|
||||
"body": "Test Line\n<<set $testvar = \"Variable String\">>\nTest Line After",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "StringExpression",
|
||||
"tags": "Tag",
|
||||
"body": "Test Line\n<<set $testvar = \"Variable String\" + \" Appended\">>\nTest Line After",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Boolean",
|
||||
"tags": "Tag",
|
||||
"body": "Test Line\n<<set $testvar = true>>\nTest Line After",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "BooleanExpression",
|
||||
"tags": "Tag",
|
||||
"body": "Test Line\n<<set $testvar = (true || false) && (false || !false)>>\nTest Line After",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Variable",
|
||||
"tags": "Tag",
|
||||
"body": "Test Line\n<<set $firstvar = \"First variable string\">><<set $secondvar = $firstvar>>\nTest Line After",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "VariableExpression",
|
||||
"tags": "Tag",
|
||||
"body": "Test Line\n<<set $firstvar = 100>><<set $secondvar = -4.3 + $firstvar>>\nTest Line After",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
}
|
||||
]
|
52
Extensions/DialogueTree/tests/commandsandfunctions.json
Normal file
52
Extensions/DialogueTree/tests/commandsandfunctions.json
Normal file
@@ -0,0 +1,52 @@
|
||||
[
|
||||
{
|
||||
"title": "BasicCommands",
|
||||
"tags": "Tag",
|
||||
"body": "<<command>>text in between commands<<command with space>> <<callFunction()>> <<callFunctionWithParam(\"test\",true,1,12.5,[2,3])>>",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "StopCommand",
|
||||
"tags": "Tag",
|
||||
"body": "First line\n<<stop>>\nThis shouldn't show",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "FunctionConditional",
|
||||
"tags": "Tag",
|
||||
"body": "First line\n<<if testfunc(\"firstarg\")>>This shouldn't show<<elseif testfunc(\"firstarg\", \"secondarg\")>>This should show<<endif>>After both",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "VisitedFunction",
|
||||
"tags": "Tag",
|
||||
"body": "<<if visited(\"VisitedFunctionStart\")>>you have visited VisitedFunctionStart!<<endif>><<if visited(\"SomeOtherNode\")>>You have not visited SomeOtherNode!<<endif>>",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "VisitedFunctionStart",
|
||||
"tags": "Tag",
|
||||
"body": "Hello[[VisitedFunction]]",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
}
|
||||
]
|
93
Extensions/DialogueTree/tests/conditions.json
Normal file
93
Extensions/DialogueTree/tests/conditions.json
Normal file
@@ -0,0 +1,93 @@
|
||||
[
|
||||
{
|
||||
"title": "Start",
|
||||
"tags": "Tag",
|
||||
"body": "What are you?\n-> A troll\n <<set $troll to true >>\n-> A nice person\n <<set $troll to false >>\n[[Objective]]",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Objective",
|
||||
"tags": "Tag",
|
||||
"body": "<<if $repeat >= 3>>\nBye...\n<<else>>\nIs your objective clear?\n[[Yes|Objective.Yes]]\n[[No|Objective.No]]\n<<if $troll == true>>\n[[Maybe|Objective.Maybe]]\n<<endif>>\n<<endif>>\n",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Objective.No",
|
||||
"tags": "Tag",
|
||||
"body": "Blah blah blah blah\n[[Objective]]",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Objective.Yes",
|
||||
"tags": "Tag",
|
||||
"body": "Good let's start the mission.",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Objective.Maybe",
|
||||
"tags": "Tag",
|
||||
"body": "Are you trolling me?\n[[Objective]]",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
|
||||
{
|
||||
"title": "BasicIf",
|
||||
"tags": "Tag",
|
||||
"body": "<<set $testvar = 321>>\nText before\n<<if $testvar == 321>>Inside if<<endif>>Text after",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "BasicIfElse",
|
||||
"tags": "Tag",
|
||||
"body": "<<set $testvar = 321>>\nText before\n<<if $testvar == 123>>Inside if<<else>>Inside else<<endif>>Text after",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "BasicIfElseIf",
|
||||
"tags": "Tag",
|
||||
"body": "<<set $testvar = 321>>\nText before\n<<if $testvar == 123>>Inside if<<elseif $testvar == 321>>Inside elseif<<endif>>Text after",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "BasicIfElseIfElse",
|
||||
"tags": "Tag",
|
||||
"body": "<<set $testvar = 321>>\nText before\n<<if $testvar == 123>>Inside if<<elseif $testvar == 1>>Inside elseif<<else>>Inside else<<endif>>Text after",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
}
|
||||
]
|
72
Extensions/DialogueTree/tests/links.json
Normal file
72
Extensions/DialogueTree/tests/links.json
Normal file
@@ -0,0 +1,72 @@
|
||||
[
|
||||
{
|
||||
"title": "OneNode",
|
||||
"tags": "Tag",
|
||||
"body": "This is a test line",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "ThreeNodes",
|
||||
"tags": "",
|
||||
"body": "This is a test line\nThis is another test line[[Option1]]\n[[Option2]]",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Option1",
|
||||
"tags": "",
|
||||
"body": "This is Option1's test line",
|
||||
"position": {
|
||||
"x": 770,
|
||||
"y": 84
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Option2",
|
||||
"tags": "",
|
||||
"body": "This is Option2's test line",
|
||||
"position": {
|
||||
"x": 774,
|
||||
"y": 404
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "NamedLink",
|
||||
"tags": "",
|
||||
"body": "This is a test line\nThis is another test line\n[[First choice|Option1]]\n[[Second choice|Option2]]",
|
||||
"position": {
|
||||
"x": 774,
|
||||
"y": 404
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "OneLinkPassthrough",
|
||||
"tags": "",
|
||||
"body": "First test line\n[[Option1]]",
|
||||
"position": {
|
||||
"x": 774,
|
||||
"y": 404
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "LinkAfterShortcuts",
|
||||
"tags": "",
|
||||
"body": "First test line\n-> Shortcut 1\n\tThis is the first shortcut\n-> Shortcut 2\n\tThis is the second shortcut\n[[First link|Option1]][[Second link|Option2]]",
|
||||
"position": {
|
||||
"x": 774,
|
||||
"y": 404
|
||||
},
|
||||
"colorID": 0
|
||||
}
|
||||
]
|
32
Extensions/DialogueTree/tests/shortcuts.json
Normal file
32
Extensions/DialogueTree/tests/shortcuts.json
Normal file
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"title": "NonNested",
|
||||
"tags": "Tag",
|
||||
"body": "This is a test line\n-> Option 1\n\tThis is the first option\n-> Option 2\n\tThis is the second option\nThis is after both options",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Nested",
|
||||
"tags": "Tag",
|
||||
"body": "text\n-> shortcut1\n\tText1\n\t-> nestedshortcut1\n\t\tNestedText1\n\t-> nestedshortcut2\n\t\tNestedText2\n-> shortcut2\n\tText2\nmore text",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
},
|
||||
{
|
||||
"title": "Conditional",
|
||||
"tags": "Tag",
|
||||
"body": "This is a test line\n-> Option 1\n\tThis is the first option\n-> Option 2 <<if 1 == 0>>\n\tThis is the second option\n-> Option 3\n\tThis is the third option\nThis is after both options",
|
||||
"position": {
|
||||
"x": 449,
|
||||
"y": 252
|
||||
},
|
||||
"colorID": 0
|
||||
}
|
||||
]
|
@@ -29,7 +29,7 @@ gdjs.DraggableRuntimeBehavior.prototype.onDeActivate = function() {
|
||||
this._endDrag();
|
||||
};
|
||||
|
||||
gdjs.DraggableRuntimeBehavior.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.DraggableRuntimeBehavior.prototype.onDestroy = function() {
|
||||
this.onDeActivate();
|
||||
};
|
||||
|
||||
|
@@ -401,7 +401,9 @@ module.exports = {
|
||||
registerEditorConfigurations: function(objectsEditorService) {
|
||||
objectsEditorService.registerEditorConfiguration(
|
||||
'MyDummyExtension::DummyObject',
|
||||
objectsEditorService.getDefaultObjectJsImplementationPropertiesEditor()
|
||||
objectsEditorService.getDefaultObjectJsImplementationPropertiesEditor({
|
||||
helpPagePath: '/extensions/extend-gdevelop',
|
||||
})
|
||||
);
|
||||
},
|
||||
/**
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @extends RuntimeObject
|
||||
*/
|
||||
gdjs.DummyRuntimeObject = function(runtimeScene, objectData) {
|
||||
// Always call the base gdjs.RuntimeObject constructor.
|
||||
// *ALWAYS* call the base gdjs.RuntimeObject constructor.
|
||||
gdjs.RuntimeObject.call(this, runtimeScene, objectData);
|
||||
|
||||
// Load any required data from the object properties.
|
||||
@@ -16,6 +16,9 @@ gdjs.DummyRuntimeObject = function(runtimeScene, objectData) {
|
||||
if (this._renderer)
|
||||
gdjs.DummyRuntimeObjectRenderer.call(this._renderer, this, runtimeScene);
|
||||
else this._renderer = new gdjs.DummyRuntimeObjectRenderer(this, runtimeScene);
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
};
|
||||
|
||||
gdjs.DummyRuntimeObject.prototype = Object.create(gdjs.RuntimeObject.prototype);
|
||||
|
@@ -30,7 +30,7 @@ module.exports = {
|
||||
"SavePlayerData",
|
||||
_("Save player data"),
|
||||
_(
|
||||
"Save the content of the given variable in the player data, stored on Facebook Instant Games servers"
|
||||
"Save the content of the given scene variable in the player data, stored on Facebook Instant Games servers"
|
||||
),
|
||||
_(
|
||||
"Save the content of _PARAM1_ in key _PARAM0_ of player data (store success message in _PARAM2_ or error in _PARAM3_)"
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
"JsPlatform/Extensions/facebookicon16.png"
|
||||
)
|
||||
.addParameter("string", 'Data key name (e.g: "Lives")', "", false)
|
||||
.addParameter("scenevar", "Variable with the content to save", "", false)
|
||||
.addParameter("scenevar", "Scene variable with the content to save", "", false)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the success message (optional)"),
|
||||
@@ -49,7 +49,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to error message (optional, if an error occurs)"),
|
||||
_("Variable where to store the error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
@@ -80,7 +80,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to error message (optional, if an error occurs)"),
|
||||
_("Variable where to store the error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
@@ -125,7 +125,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to error message (optional, if an error occurs)"),
|
||||
_("Variable where to store the error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
@@ -173,7 +173,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to error message (optional, if an error occurs)"),
|
||||
_("Variable where to store the error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
@@ -233,7 +233,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to error message (optional, if an error occurs)"),
|
||||
_("Variable where to store the error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
@@ -255,7 +255,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to error message (optional, if an error occurs)"),
|
||||
_("Variable where to store the error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
@@ -299,7 +299,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to error message (optional, if an error occurs)"),
|
||||
_("Variable where to store the error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
@@ -321,7 +321,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter(
|
||||
"scenevar",
|
||||
_("Variable where to error message (optional, if an error occurs)"),
|
||||
_("Variable where to store the error message (optional, if an error occurs)"),
|
||||
"",
|
||||
true
|
||||
)
|
||||
|
@@ -296,7 +296,7 @@ module.exports = {
|
||||
.addAction(
|
||||
'DeleteFileAsync',
|
||||
_('Delete a file (Async)'),
|
||||
_('Delete a file from the filesystem asyncrounouse.'),
|
||||
_('Delete a file from the filesystem asynchronously. The option result variable will be updated once the file is deleted.'),
|
||||
_('Delete the file _PARAM0_'),
|
||||
_('Filesystem/Windows, Linux, MacOS/Asynchronous'),
|
||||
'JsPlatform/Extensions/filesystem_delete_file24.png',
|
||||
|
@@ -172,8 +172,8 @@ void DeclareInventoryExtension(gd::PlatformExtension& extension) {
|
||||
|
||||
extension
|
||||
.AddAction("SerializeToVariable",
|
||||
_("Save an inventory in a variable"),
|
||||
_("Save all the items of the inventory in a variable, so that "
|
||||
_("Save an inventory in a scene variable"),
|
||||
_("Save all the items of the inventory in a scene variable, so that "
|
||||
"it can be restored later."),
|
||||
_("Save inventory _PARAM1_ in variable _PARAM2_"),
|
||||
_("Inventories/Variables"),
|
||||
@@ -188,8 +188,8 @@ void DeclareInventoryExtension(gd::PlatformExtension& extension) {
|
||||
|
||||
extension
|
||||
.AddAction("UnserializeFromVariable",
|
||||
_("Load an inventory from a variable"),
|
||||
_("Load the content of the inventory from a variable."),
|
||||
_("Load an inventory from a scene variable"),
|
||||
_("Load the content of the inventory from a scene variable."),
|
||||
_("Load inventory _PARAM1_ from variable _PARAM2_"),
|
||||
_("Inventories/Variables"),
|
||||
"CppPlatform/Extensions/Inventoryicon24.png",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
describe('Inventory', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame, null);
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
|
||||
gdjs.evtTools.inventory.add(runtimeScene, "MyInventory", "sword");
|
||||
gdjs.evtTools.inventory.add(runtimeScene, "MyInventory", "sword");
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
describe('gdjs.LinksManager', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame, null);
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers:[{name:"", visibility: true}],
|
||||
variables: [],
|
||||
|
@@ -58,7 +58,7 @@ gdjs.PanelSpriteRuntimeObjectCocosRenderer.prototype._createTilingShaderAndUnifo
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.PanelSpriteRuntimeObjectCocosRenderer.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.PanelSpriteRuntimeObjectCocosRenderer.prototype.onDestroy = function() {
|
||||
if (this._centerSpriteShader && this._centerSpriteShader.shader)
|
||||
this._centerSpriteShader.shader.release();
|
||||
if (this._rightSpriteShader && this._rightSpriteShader.shader)
|
||||
|
@@ -29,6 +29,9 @@ gdjs.PanelSpriteRuntimeObject = function(runtimeScene, objectData)
|
||||
else
|
||||
this._renderer = new gdjs.PanelSpriteRuntimeObjectRenderer(this, runtimeScene,
|
||||
objectData.texture, objectData.tiled);
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
};
|
||||
|
||||
gdjs.PanelSpriteRuntimeObject.prototype = Object.create( gdjs.RuntimeObject.prototype );
|
||||
@@ -38,11 +41,11 @@ gdjs.PanelSpriteRuntimeObject.prototype.getRendererObject = function() {
|
||||
return this._renderer.getRendererObject();
|
||||
};
|
||||
|
||||
gdjs.PanelSpriteRuntimeObject.prototype.onDeletedFromScene = function(runtimeScene) {
|
||||
gdjs.RuntimeObject.prototype.onDeletedFromScene.call(this, runtimeScene);
|
||||
gdjs.PanelSpriteRuntimeObject.prototype.onDestroyFromScene = function(runtimeScene) {
|
||||
gdjs.RuntimeObject.prototype.onDestroyFromScene.call(this, runtimeScene);
|
||||
|
||||
if (this._renderer.onOwnerRemovedFromScene) {
|
||||
this._renderer.onOwnerRemovedFromScene();
|
||||
if (this._renderer.onDestroy) {
|
||||
this._renderer.onDestroy();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -166,4 +169,4 @@ gdjs.PanelSpriteRuntimeObject.prototype.setColor = function(rgbColor) {
|
||||
*/
|
||||
gdjs.PanelSpriteRuntimeObject.prototype.getColor = function() {
|
||||
return this._renderer.getColor();
|
||||
};
|
||||
};
|
||||
|
@@ -204,7 +204,7 @@ void ExtensionSubDeclaration2(gd::ObjectMetadata& obj) {
|
||||
.SetManipulatedType("number");
|
||||
|
||||
obj.AddCondition("ParticleSize1",
|
||||
_("SIze, parameter 1"),
|
||||
_("Size, parameter 1"),
|
||||
_("Test parameter 1 of the size of particles"),
|
||||
_("Parameter 1 of the size of _PARAM0_ is _PARAM1__PARAM2_"),
|
||||
_("Common"),
|
||||
|
@@ -51,6 +51,9 @@ gdjs.ParticleEmitterObject = function(runtimeScene, objectData){
|
||||
this._alphaDirty = true;
|
||||
this._textureDirty = true;
|
||||
this._flowDirty = true;
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
};
|
||||
gdjs.ParticleEmitterObject.prototype = Object.create(gdjs.RuntimeObject.prototype);
|
||||
gdjs.ParticleEmitterObject.thisIsARuntimeObjectConstructor = "ParticleSystem::ParticleEmitter";
|
||||
@@ -127,9 +130,9 @@ gdjs.ParticleEmitterObject.prototype.update = function(runtimeScene){
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.ParticleEmitterObject.prototype.onDeletedFromScene = function(runtimeScene){
|
||||
gdjs.ParticleEmitterObject.prototype.onDestroyFromScene = function(runtimeScene){
|
||||
this._renderer.destroy();
|
||||
gdjs.RuntimeObject.prototype.onDeletedFromScene.call(this, runtimeScene);
|
||||
gdjs.RuntimeObject.prototype.onDestroyFromScene.call(this, runtimeScene);
|
||||
};
|
||||
|
||||
gdjs.ParticleEmitterObject.prototype.getEmitterForceMin = function(){
|
||||
|
@@ -104,7 +104,7 @@ gdjs.PathfindingObstacleRuntimeBehavior = function(runtimeScene, behaviorData, o
|
||||
gdjs.PathfindingObstacleRuntimeBehavior.prototype = Object.create( gdjs.RuntimeBehavior.prototype );
|
||||
gdjs.PathfindingObstacleRuntimeBehavior.thisIsARuntimeBehaviorConstructor = "PathfindingBehavior::PathfindingObstacleBehavior";
|
||||
|
||||
gdjs.PathfindingObstacleRuntimeBehavior.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.PathfindingObstacleRuntimeBehavior.prototype.onDestroy = function() {
|
||||
if ( this._manager && this._registeredInManager ) this._manager.removeObstacle(this);
|
||||
};
|
||||
|
||||
|
@@ -194,11 +194,10 @@ gdjs.PathfindingRuntimeBehavior.prototype.moveTo = function(runtimeScene, x, y)
|
||||
var startCellX = Math.round(owner.getX()/this._cellWidth);
|
||||
var startCellY = Math.round(owner.getY()/this._cellHeight);
|
||||
if ( startCellX == targetCellX && startCellY == targetCellY ) {
|
||||
while (this._path.length < 2) this._path.unshift([0, 0]);
|
||||
this._path.length = 2;
|
||||
|
||||
this._path.length = 0;
|
||||
this._path.push([owner.getX(), owner.getY()]);
|
||||
this._path.push([x, y]);
|
||||
|
||||
this._enterSegment(0);
|
||||
this._pathFound = true;
|
||||
|
||||
|
@@ -72,10 +72,11 @@ module.exports = {
|
||||
return true;
|
||||
}
|
||||
if (propertyName === 'polygonOrigin') {
|
||||
behaviorContent.getChild('polygonOrigin').setStringValue(newValue);
|
||||
behaviorContent.addChild('polygonOrigin').setStringValue(newValue);
|
||||
return true;
|
||||
}
|
||||
if (propertyName === 'vertices') {
|
||||
behaviorContent.addChild('vertices');
|
||||
behaviorContent.setChild('vertices', gd.Serializer.fromJSON(newValue));
|
||||
return true;
|
||||
}
|
||||
@@ -203,7 +204,9 @@ module.exports = {
|
||||
behaviorProperties.set(
|
||||
'polygonOrigin',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getChild('polygonOrigin').getStringValue() || 'Center'
|
||||
behaviorContent.hasChild('polygonOrigin') ?
|
||||
behaviorContent.getChild('polygonOrigin').getStringValue() :
|
||||
'Center'
|
||||
)
|
||||
.setType('Choice')
|
||||
.setLabel('Polygon Origin')
|
||||
@@ -214,7 +217,9 @@ module.exports = {
|
||||
behaviorProperties.set(
|
||||
'vertices',
|
||||
new gd.PropertyDescriptor(
|
||||
gd.Serializer.toJSON(behaviorContent.getChild('vertices')) || '[]'
|
||||
behaviorContent.hasChild('vertices') ?
|
||||
gd.Serializer.toJSON(behaviorContent.getChild('vertices')) :
|
||||
'[]'
|
||||
).setLabel('Vertices')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
|
@@ -268,7 +268,7 @@ gdjs.Physics2RuntimeBehavior.prototype.onDeActivate = function() {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.Physics2RuntimeBehavior.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.Physics2RuntimeBehavior.prototype.onDestroy = function() {
|
||||
this.onDeActivate();
|
||||
};
|
||||
|
||||
|
@@ -81,7 +81,7 @@ std::map<gd::String, gd::PropertyDescriptor> PhysicsBehavior::GetProperties(
|
||||
gd::String::From(behaviorContent.GetDoubleAttribute("linearDamping")));
|
||||
properties[_("Angular Damping")].SetValue(
|
||||
gd::String::From(behaviorContent.GetDoubleAttribute("angularDamping")));
|
||||
properties[_("PLEASE_ALSO_SHOW_EDIT_BUTTON_THANKS")].SetValue("");
|
||||
properties["PLEASE_ALSO_SHOW_EDIT_BUTTON_THANKS"].SetValue("");
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
@@ -154,7 +154,7 @@ gdjs.PhysicsRuntimeBehavior.prototype.onDeActivate = function() {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.PhysicsRuntimeBehavior.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.PhysicsRuntimeBehavior.prototype.onDestroy = function() {
|
||||
this.onDeActivate();
|
||||
};
|
||||
|
||||
|
@@ -442,11 +442,16 @@ void PlatformerObjectRuntimeBehavior::DoStepPreEvents(RuntimeScene& scene) {
|
||||
floorLastX = floorPlatform->GetObject()->GetX();
|
||||
floorLastY = floorPlatform->GetObject()->GetY();
|
||||
} else {
|
||||
// Avoid landing on a platform if the object is not going down.
|
||||
// (which could happen for a jumpthru, when the object jump and pass just
|
||||
// at the top of a jumpthru, it could be considered as landing if not for
|
||||
// this extra check).
|
||||
bool canLand = requestedDeltaY >= 0;
|
||||
|
||||
// Check if landing on a new floor: (Exclude already overlapped jump truh)
|
||||
std::set<PlatformRuntimeBehavior*> collidingObjects =
|
||||
GetPlatformsCollidingWith(potentialObjects, overlappedJumpThru);
|
||||
if (!collidingObjects.empty()) // Just landed on floor
|
||||
{
|
||||
if (canLand && !collidingObjects.empty()) { // Just landed on floor
|
||||
isOnFloor = true;
|
||||
canJump = true;
|
||||
jumping = false;
|
||||
@@ -458,8 +463,7 @@ void PlatformerObjectRuntimeBehavior::DoStepPreEvents(RuntimeScene& scene) {
|
||||
floorLastY = floorPlatform->GetObject()->GetY();
|
||||
|
||||
ReleaseGrabbedPlatform(); // Ensure nothing is grabbed.
|
||||
} else // In the air
|
||||
{
|
||||
} else { // In the air
|
||||
canJump = false;
|
||||
isOnFloor = false;
|
||||
floorPlatform = NULL;
|
||||
@@ -502,7 +506,8 @@ void PlatformerObjectRuntimeBehavior::ReleaseGrabbedPlatform() {
|
||||
}
|
||||
|
||||
bool PlatformerObjectRuntimeBehavior::SeparateFromPlatforms(
|
||||
const std::set<PlatformRuntimeBehavior*>& candidates, bool excludeJumpThrus) {
|
||||
const std::set<PlatformRuntimeBehavior*>& candidates,
|
||||
bool excludeJumpThrus) {
|
||||
std::vector<RuntimeObject*> objects;
|
||||
for (std::set<PlatformRuntimeBehavior*>::iterator it = candidates.begin();
|
||||
it != candidates.end();
|
||||
|
@@ -369,10 +369,15 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.doStepPreEvents = function(runtim
|
||||
|
||||
this._releaseGrabbedPlatform(); //Ensure nothing is grabbed.
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Avoid landing on a platform if the object is not going down.
|
||||
// (which could happen for Jumpthru, when the object jump and pass just at the top
|
||||
// of a jumpthru, it could be considered as landing if not this this extra check).
|
||||
var canLand = requestedDeltaY >= 0;
|
||||
|
||||
//Check if landing on a new floor: (Exclude already overlapped jump truh)
|
||||
var collidingPlatform = this._getCollidingPlatform();
|
||||
if (collidingPlatform !== null) {
|
||||
if (canLand && collidingPlatform !== null) {
|
||||
this._isOnFloor = true;
|
||||
this._canJump = true;
|
||||
this._jumping = false;
|
||||
@@ -603,6 +608,8 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype._updatePotentialCollidingObjects
|
||||
var o2w = obj2.getWidth();
|
||||
var o2h = obj2.getHeight();
|
||||
|
||||
// This would better be done using the object AABB (getAABB), as (`getCenterX`;`getCenterY`) point
|
||||
// is not necessarily in the middle of the object (for sprites for example).
|
||||
var x = this.owner.getDrawableX()+this.owner.getCenterX()-(obj2.getDrawableX()+obj2.getCenterX());
|
||||
var y = this.owner.getDrawableY()+this.owner.getCenterY()-(obj2.getDrawableY()+obj2.getCenterY());
|
||||
var obj2BoundingRadius = Math.sqrt(o2w*o2w+o2h*o2h)/2.0;
|
||||
|
@@ -50,6 +50,8 @@ gdjs.PlatformObjectsManager.prototype.removePlatform = function(platformBehavior
|
||||
* @return An array with all platforms near the object.
|
||||
*/
|
||||
gdjs.PlatformObjectsManager.prototype.getAllPlatformsAround = function(object, maxMovementLength, result) {
|
||||
// TODO: This would better be done using the object AABB (getAABB), as (`getCenterX`;`getCenterY`) point
|
||||
// is not necessarily in the middle of the object (for sprites for example).
|
||||
var ow = object.getWidth();
|
||||
var oh = object.getHeight();
|
||||
var x = object.getDrawableX()+object.getCenterX();
|
||||
@@ -104,7 +106,7 @@ gdjs.PlatformRuntimeBehavior.LADDER = 2;
|
||||
gdjs.PlatformRuntimeBehavior.JUMPTHRU = 1;
|
||||
gdjs.PlatformRuntimeBehavior.NORMALPLAFTORM = 0;
|
||||
|
||||
gdjs.PlatformRuntimeBehavior.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.PlatformRuntimeBehavior.prototype.onDestroy = function() {
|
||||
if ( this._manager && this._registeredInManager ) this._manager.removePlatform(this);
|
||||
};
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
describe('gdjs.PlatformerObjectRuntimeBehavior', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame, null);
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [{name: "", visibility: true}],
|
||||
variables: [],
|
||||
@@ -119,9 +119,104 @@ describe('gdjs.PlatformerObjectRuntimeBehavior', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('gdjs.PlatformerObjectRuntimeBehavior, jumpthru', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [{name: "", visibility: true}],
|
||||
variables: [],
|
||||
behaviorsSharedData: [],
|
||||
objects: [],
|
||||
instances: []
|
||||
});
|
||||
runtimeScene._timeManager.getElapsedTime = function() { return 1 / 60 * 1000; };
|
||||
|
||||
//Put a platformer object in a platform.
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformerObjectBehavior",
|
||||
name: "auto1",
|
||||
roundCoordinates: true,
|
||||
gravity: 900,
|
||||
maxFallingSpeed: 1500,
|
||||
acceleration: 500,
|
||||
deceleration: 1500,
|
||||
maxSpeed: 500,
|
||||
jumpSpeed: 500,
|
||||
canGrabPlatforms: true,
|
||||
ignoreDefaultControls: true,
|
||||
slopeMaxAngle: 60
|
||||
}]});
|
||||
object.getWidth = function() { return 10; };
|
||||
object.getHeight = function() { return 20; };
|
||||
runtimeScene.addObject(object);
|
||||
object.setPosition(0, -30);
|
||||
|
||||
//Put a platform
|
||||
var platform = new gdjs.RuntimeObject(runtimeScene, {name: "obj2", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformBehavior",
|
||||
canBeGrabbed: true,
|
||||
platformType: "Platform",
|
||||
}]});
|
||||
platform.getWidth = function() { return 60; };
|
||||
platform.getHeight = function() { return 32; };
|
||||
runtimeScene.addObject(platform);
|
||||
platform.setPosition(0, -10);
|
||||
|
||||
// Put a jump thru, higher than the platform so that the object jump from under it
|
||||
// and will land on it at the end of the jump.
|
||||
var jumpthru = new gdjs.RuntimeObject(runtimeScene, {name: "obj2", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformBehavior",
|
||||
canBeGrabbed: true,
|
||||
platformType: "Jumpthru",
|
||||
}]});
|
||||
jumpthru.getWidth = function() { return 60; };
|
||||
jumpthru.getHeight = function() { return 5; };
|
||||
runtimeScene.addObject(jumpthru);
|
||||
jumpthru.setPosition(0, -33);
|
||||
|
||||
it('can jump through the jumpthru', function() {
|
||||
//Check the platform stopped the platformer object.
|
||||
for(var i = 0; i<5; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
expect(object.getBehavior("auto1").isMoving()).to.be(false);
|
||||
|
||||
// Check that the jump starts properly, and is not stopped on the jumpthru
|
||||
object.getBehavior("auto1").simulateJumpKey();
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-39, -38);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-47, -46);
|
||||
runtimeScene.renderAndStep();
|
||||
// At this step, the object is almost on the jumpthru (-53 + 20 (object height) = -33 (jump thru Y position)),
|
||||
// but the object should not stop.
|
||||
expect(object.getY()).to.be.within(-54, -53);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-61, -60);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-67, -66);
|
||||
expect(object.getBehavior("auto1").isJumping()).to.be(true);
|
||||
|
||||
// Continue the simulation and check that position is correct in the middle of the jump
|
||||
for(var i = 0; i<20; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be.within(-89, -88);
|
||||
|
||||
// Continue simulation and check that we arrive on the jumpthru
|
||||
for(var i = 0; i<10; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be.within(jumpthru.getY() - object.getHeight(), jumpthru.getY() - object.getHeight() + 1);
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('gdjs.PlatformerObjectRuntimeBehavior, rounded coordinates (moving platforms)', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame, null);
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [{name: "", visibility: true}],
|
||||
variables: [],
|
||||
|
@@ -15,7 +15,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"PrimitiveDrawing",
|
||||
_("Primitive drawing"),
|
||||
_("This Extension allows you to draw shapes and manipulate images."),
|
||||
"Florian Rival",
|
||||
"Florian Rival and Aurélien Vivet",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/shape_painter");
|
||||
|
||||
@@ -31,25 +31,25 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
obj.AddAction("Rectangle",
|
||||
_("Rectangle"),
|
||||
_("Draw a rectangle on screen"),
|
||||
_("Draw from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ a "
|
||||
"rectangle with _PARAM0_"),
|
||||
_("Draw from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ a rectangle "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/rectangle24.png",
|
||||
"res/actions/rectangle.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("Top left side: X Position"))
|
||||
.AddParameter("expression", _("Top left side : Y Position"))
|
||||
.AddParameter("expression", _("Bottom right side : X Position"))
|
||||
.AddParameter("expression", _("Bottom right side : Y Position"))
|
||||
.AddParameter("expression", _("Top left side: X position"))
|
||||
.AddParameter("expression", _("Top left side: Y position"))
|
||||
.AddParameter("expression", _("Bottom right side: X position"))
|
||||
.AddParameter("expression", _("Bottom right side: Y position"))
|
||||
.SetFunctionName("DrawRectangle")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("Circle",
|
||||
_("Circle"),
|
||||
_("Draw a circle on screen"),
|
||||
_("Draw at _PARAM1_;_PARAM2_ a circle of radius _PARAM3_ with "
|
||||
"_PARAM0_"),
|
||||
_("Draw at _PARAM1_;_PARAM2_ a circle of radius _PARAM3_ "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/circle24.png",
|
||||
"res/actions/circle.png")
|
||||
@@ -57,35 +57,295 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of center"))
|
||||
.AddParameter("expression", _("Y position of center"))
|
||||
.AddParameter("expression", _("Radius ( in pixels )"))
|
||||
.AddParameter("expression", _("Radius (in pixels)"))
|
||||
.SetFunctionName("DrawCircle")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("Line",
|
||||
_("Line"),
|
||||
_("Draw a line on screen"),
|
||||
_("Draw from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ a line "
|
||||
"(thickness : _PARAM5_) with _PARAM0_"),
|
||||
_("Draw from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ a line (thickness: _PARAM5_) "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/line24.png",
|
||||
"res/actions/line.png")
|
||||
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of start point"))
|
||||
.AddParameter("expression", _("Y position of start point"))
|
||||
.AddParameter("expression", _("X position of end point"))
|
||||
.AddParameter("expression", _("Y position of end point"))
|
||||
.AddParameter("expression", _("Thickness (in pixels)"))
|
||||
.SetFunctionName("DrawLine")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("LineV2",
|
||||
_("Line"),
|
||||
_("Draw a line on screen"),
|
||||
_("Draw from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ a line (thickness: _PARAM5_) "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/line24.png",
|
||||
"res/actions/line.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X Position of start point"))
|
||||
.AddParameter("expression", _("Y Position of start point"))
|
||||
.AddParameter("expression", _("X Position of end point"))
|
||||
.AddParameter("expression", _("Y Position of end point"))
|
||||
.AddParameter("expression", _("Thickness ( in pixels )"))
|
||||
.SetFunctionName("DrawLine")
|
||||
.AddParameter("expression", _("X position of start point"))
|
||||
.AddParameter("expression", _("Y position of start point"))
|
||||
.AddParameter("expression", _("X position of end point"))
|
||||
.AddParameter("expression", _("Y position of end point"))
|
||||
.AddParameter("expression", _("Thickness (in pixels)"))
|
||||
.SetFunctionName("drawLineV2")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("Ellipse",
|
||||
_("Ellipse"),
|
||||
_("Draw an ellipse on screen"),
|
||||
_("Draw at _PARAM1_;_PARAM2_ an ellipse of width _PARAM3_ and height _PARAM4_ "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/ellipse24.png",
|
||||
"res/actions/ellipse.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of center"))
|
||||
.AddParameter("expression", _("Y position of center"))
|
||||
.AddParameter("expression", _("The width of the ellipse"))
|
||||
.AddParameter("expression", _("The height of the ellipse"))
|
||||
.SetFunctionName("DrawEllipse")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("RoundedRectangle",
|
||||
_("Rounded rectangle"),
|
||||
_("Draw a rounded rectangle on screen"),
|
||||
_("Draw from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ a rounded rectangle (radius: _PARAM5_) "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/roundedRectangle24.png",
|
||||
"res/actions/roundedRectangle.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("Top left side: X position"))
|
||||
.AddParameter("expression", _("Top left side: Y position"))
|
||||
.AddParameter("expression", _("Bottom right side: X position"))
|
||||
.AddParameter("expression", _("Bottom right side: Y position"))
|
||||
.AddParameter("expression", _("Radius (in pixels)"))
|
||||
.SetFunctionName("DrawRoundedRectangle")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("Star",
|
||||
_("Star"),
|
||||
_("Draw a star on screen"),
|
||||
_("Draw at _PARAM1_;_PARAM2_ a star with _PARAM3_ points and radius: _PARAM4_ (inner radius: _PARAM5_, rotation: _PARAM6_) "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/star24.png",
|
||||
"res/actions/star.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of center"))
|
||||
.AddParameter("expression", _("X position of center"))
|
||||
.AddParameter("expression", _("Number of points of the star (minimum: 2)"))
|
||||
.AddParameter("expression", _("Radius (in pixels)"))
|
||||
.AddParameter("expression", _("Inner radius (in pixels, half radius by default)"))
|
||||
.AddParameter("expression", _("Rotation (in degrees)"))
|
||||
.SetFunctionName("DrawStar")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
|
||||
obj.AddAction("Arc",
|
||||
_("Arc"),
|
||||
_("Draw an arc on screen. If \"Close path\" is set to yes, a line will be drawn between the start and end point of the arc, closing the shape."),
|
||||
_("Draw at _PARAM1_;_PARAM2_ an arc with radius: _PARAM3_, start angle: _PARAM4_, end angle: _PARAM5_ (anticlockwise: _PARAM6_, close path: _PARAM7_) "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/arc24.png",
|
||||
"res/actions/arc.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of center"))
|
||||
.AddParameter("expression", _("Y position of center"))
|
||||
.AddParameter("expression", _("Radius (in pixels)"))
|
||||
.AddParameter("expression", _("Start angle of the arc (in degrees)"))
|
||||
.AddParameter("expression", _("End angle of the arc (in degrees)"))
|
||||
.AddParameter("yesorno", _("Anticlockwise"))
|
||||
.AddParameter("yesorno", _("Close path"))
|
||||
.SetFunctionName("DrawArc")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("BezierCurve",
|
||||
_("Bezier curve"),
|
||||
_("Draw a bezier curve on screen"),
|
||||
_("Draw from _PARAM1_;_PARAM2_ to _PARAM7_;_PARAM8_ a bezier curve (first control point: _PARAM3_;_PARAM4_, second control point: _PARAM5_;_PARAM6_) "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/bezierCurve24.png",
|
||||
"res/actions/bezierCurve.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of start point"))
|
||||
.AddParameter("expression", _("Y position of start point"))
|
||||
.AddParameter("expression", _("First control point x"))
|
||||
.AddParameter("expression", _("First control point y"))
|
||||
.AddParameter("expression", _("Second Control point x"))
|
||||
.AddParameter("expression", _("Second Control point y"))
|
||||
.AddParameter("expression", _("Destination point x"))
|
||||
.AddParameter("expression", _("Destination point y"))
|
||||
.SetFunctionName("drawBezierCurve")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("QuadraticCurve",
|
||||
_("Quadratic curve"),
|
||||
_("Draw a quadratic curve on screen"),
|
||||
_("Draw from _PARAM1_;_PARAM2_ to _PARAM5_;_PARAM6_ a quadratic curve (control point: _PARAM3_;_PARAM4_) "
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/quadraticCurve24.png",
|
||||
"res/actions/quadraticCurve.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of start point"))
|
||||
.AddParameter("expression", _("Y position of start point"))
|
||||
.AddParameter("expression", _("Control point x"))
|
||||
.AddParameter("expression", _("Control point y"))
|
||||
.AddParameter("expression", _("Destination point x"))
|
||||
.AddParameter("expression", _("Destination point y"))
|
||||
.SetFunctionName("drawQuadraticCurve")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("BeginFillPath",
|
||||
_("Begin fill path"),
|
||||
_("Begin to draw a simple one-color fill. Subsequent actions, such as \"Path line\" (in the Advanced category) can be used to draw. Be sure to use \"End fill path\" action when you're done drawing the shape."),
|
||||
_("Begins drawing filling of an advanced path "
|
||||
"with _PARAM0_"),
|
||||
_("Advanced"),
|
||||
"res/actions/beginFillPath24.png",
|
||||
"res/actions/beginFillPath.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("Start drawing x"))
|
||||
.AddParameter("expression", _("Start drawing y"))
|
||||
.SetFunctionName("beginFillPath")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("EndFillPath",
|
||||
_("End fill path"),
|
||||
_("Finish the filling drawing in an advanced path"),
|
||||
_("Finish the filling drawing in an advanced path "
|
||||
"with _PARAM0_"),
|
||||
_("Advanced"),
|
||||
"res/actions/endFillPath24.png",
|
||||
"res/actions/endFillPath.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.SetFunctionName("endFillPath")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("MovePathTo",
|
||||
_("Move path drawing position"),
|
||||
_("Move the drawing position for the current path"),
|
||||
_("Move the drawing position of the path to _PARAM1_;_PARAM2_ "
|
||||
"with _PARAM0_"),
|
||||
_("Advanced"),
|
||||
"res/actions/position24.png",
|
||||
"res/actions/position.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of start point"))
|
||||
.AddParameter("expression", _("Y position of start point"))
|
||||
.SetFunctionName("drawPathMoveTo")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("PathLineTo",
|
||||
_("Path line"),
|
||||
_("Add to a path a line to a position. The origin comes from the previous action or from \"Begin fill path\" or \"Move path drawing position\". By default, the start position will be the object's position."),
|
||||
_("Add to a path a line to the position _PARAM1_;_PARAM2_ "
|
||||
"with _PARAM0_"),
|
||||
_("Advanced"),
|
||||
"res/actions/line24.png",
|
||||
"res/actions/line.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of start point"))
|
||||
.AddParameter("expression", _("Y position of start point"))
|
||||
.SetFunctionName("drawPathLineTo")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("PathBezierCurveTo",
|
||||
_("Path bezier curve"),
|
||||
_("Add to a path a bezier curve to a position. The origin comes from the previous action or from \"Begin fill path\" or \"Move path drawing position\". By default, the start position will be the object's position."),
|
||||
_("Add to a path a bezier curve to the position _PARAM5_;_PARAM6_ (first control point: _PARAM1_;_PARAM2_, second control point: _PARAM3_;_PARAM4_) "
|
||||
"with _PARAM0_"),
|
||||
_("Advanced"),
|
||||
"res/actions/bezierCurve24.png",
|
||||
"res/actions/bezierCurve.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("First control point x"))
|
||||
.AddParameter("expression", _("First control point y"))
|
||||
.AddParameter("expression", _("Second Control point x"))
|
||||
.AddParameter("expression", _("Second Control point y"))
|
||||
.AddParameter("expression", _("Destination point x"))
|
||||
.AddParameter("expression", _("Destination point y"))
|
||||
.SetFunctionName("drawPathBezierCurveTo")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("PathArc",
|
||||
_("Path arc"),
|
||||
_("Add to a path an arc to a position. The origin comes from the previous action or from \"Begin fill path\" or \"Move path drawing position\". By default, the start position will be the object's position."),
|
||||
_("Add to a path an arc at the position _PARAM1_;_PARAM2_ (radius: _PARAM3_, start angle: _PARAM4_, end angle: _PARAM5_, anticlockwise: _PARAM6_) "
|
||||
"with _PARAM0_"),
|
||||
_("Advanced"),
|
||||
"res/actions/arc24.png",
|
||||
"res/actions/arc.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("Center x of circle"))
|
||||
.AddParameter("expression", _("Center y of circle"))
|
||||
.AddParameter("expression", _("Radius (in pixels)"))
|
||||
.AddParameter("expression", _("Start angle"))
|
||||
.AddParameter("expression", _("End angle"))
|
||||
.AddParameter("yesorno", _("Anticlockwise"))
|
||||
.SetFunctionName("drawPathArc")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("PathQuadraticCurveTo",
|
||||
_("Path quadratic curve"),
|
||||
_("Add to a path a quadratic curve to a position. The origin comes from the previous action or from \"Begin fill path\" or \"Move path drawing position\". By default, the start position will be the object's position."),
|
||||
_("Add to a path a quadratic curve to the position _PARAM3_;_PARAM4_ (control point: _PARAM1_;_PARAM2_) "
|
||||
"with _PARAM0_"),
|
||||
_("Advanced"),
|
||||
"res/actions/quadraticCurve24.png",
|
||||
"res/actions/quadraticCurve.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("Control point x"))
|
||||
.AddParameter("expression", _("Control point y"))
|
||||
.AddParameter("expression", _("Destination point x"))
|
||||
.AddParameter("expression", _("Destination point y"))
|
||||
.SetFunctionName("drawPathQuadraticCurveTo")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("closePath",
|
||||
_("Close Path"),
|
||||
_("Close the path of the advanced shape. This closes the outline between the last and the first point."),
|
||||
_("Close the path "
|
||||
"with _PARAM0_"),
|
||||
_("Advanced"),
|
||||
"res/actions/closePath24.png",
|
||||
"res/actions/closePath.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.SetFunctionName("closePath")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("FillColor",
|
||||
_("Fill color"),
|
||||
_("Change the color used when filling"),
|
||||
_("Change fill color of _PARAM0_ to _PARAM1_"),
|
||||
_("Setup"),
|
||||
"res/actions/text24.png",
|
||||
"res/actions/text.png")
|
||||
"res/actions/color24.png",
|
||||
"res/actions/color.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("color", _("Fill color"))
|
||||
|
@@ -39,8 +39,72 @@ class PrimitiveDrawingJsExtension : public gd::PlatformExtension {
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::Circle"]
|
||||
.SetFunctionName("drawCircle");
|
||||
GetAllActionsForObject("PrimitiveDrawing::Drawer")["PrimitiveDrawing::Line"]
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::Line"]
|
||||
.SetFunctionName("drawLine");
|
||||
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::LineV2"]
|
||||
.SetFunctionName("drawLineV2");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::Ellipse"]
|
||||
.SetFunctionName("drawEllipse");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::RoundedRectangle"]
|
||||
.SetFunctionName("drawRoundedRectangle");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::Star"]
|
||||
.SetFunctionName("drawStar");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::Arc"]
|
||||
.SetFunctionName("drawArc");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::BezierCurve"]
|
||||
.SetFunctionName("drawBezierCurve");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::QuadraticCurve"]
|
||||
.SetFunctionName("drawQuadraticCurve");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::BeginFillPath"]
|
||||
.SetFunctionName("beginFillPath");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::EndFillPath"]
|
||||
.SetFunctionName("endFillPath");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::PathMoveTo"]
|
||||
.SetFunctionName("drawPathMoveTo");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::PathLineTo"]
|
||||
.SetFunctionName("drawPathLineTo");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::PathBezierCurveTo"]
|
||||
.SetFunctionName("drawPathBezierCurveTo");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::PathArc"]
|
||||
.SetFunctionName("drawPathArc");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::PathQuadraticCurveTo"]
|
||||
.SetFunctionName("drawPathQuadraticCurveTo");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::ClosePath"]
|
||||
.SetFunctionName("closePath");
|
||||
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::Ellipse"]
|
||||
.SetFunctionName("drawEllipse");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::RoundedRectangle"]
|
||||
.SetFunctionName("drawRoundedRectangle");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::Star"]
|
||||
.SetFunctionName("drawStar");
|
||||
// These actions are not exposed yet as the way they work is unsure. See https://github.com/4ian/GDevelop/pull/1256
|
||||
/*GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::Arc"]
|
||||
.SetFunctionName("drawArc");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::ArcTo"]
|
||||
.SetFunctionName("drawArcTo");*/
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::FillColor"]
|
||||
.SetFunctionName("setFillColor");
|
||||
|
@@ -47,6 +47,101 @@ gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawLine = function(x1, y1,
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawLineV2 = function(x1, y1, x2, y2, thickness) {
|
||||
this._graphics.lineStyle(thickness);
|
||||
this._graphics.moveTo(x1, y1);
|
||||
this._graphics.lineTo(x2,y2);
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawEllipse = function(x1, y1, width, height) {
|
||||
this._graphics.beginFill(this._object._fillColor, this._object._fillOpacity / 255);
|
||||
this._graphics.drawEllipse(x1, y1, width/2, height/2);
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawRoundedRectangle = function(x1, y1, x2, y2, radius) {
|
||||
this._graphics.beginFill(this._object._fillColor, this._object._fillOpacity / 255);
|
||||
this._graphics.drawRoundedRect(x1, y1, x2 - x1, y2 - y1, radius);
|
||||
this._graphics.closePath();
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawStar = function(x1, y1, points, radius, innerRadius, rotation) {
|
||||
this._graphics.beginFill(this._object._fillColor, this._object._fillOpacity / 255);
|
||||
this._graphics.drawStar(x1, y1, points, radius, innerRadius ? innerRadius : radius/2, rotation ? gdjs.toRad(rotation) : 0);
|
||||
this._graphics.closePath();
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawArc = function(x1, y1, radius, startAngle, endAngle, anticlockwise, closePath) {
|
||||
this._graphics.beginFill(this._object._fillColor, this._object._fillOpacity / 255);
|
||||
this._graphics.moveTo( x1 + radius * Math.cos(gdjs.toRad(startAngle)), y1 + radius * Math.sin(gdjs.toRad(startAngle)));
|
||||
this._graphics.arc(x1, y1, radius, gdjs.toRad(startAngle), gdjs.toRad(endAngle), anticlockwise ? true : false);
|
||||
if(closePath){
|
||||
this._graphics.closePath();
|
||||
}
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawBezierCurve = function(x1, y1, cpX, cpY, cpX2, cpY2, x2, y2) {
|
||||
this._graphics.beginFill(this._object._fillColor, this._object._fillOpacity / 255);
|
||||
this._graphics.moveTo(x1, y1);
|
||||
this._graphics.bezierCurveTo(cpX, cpY, cpX2, cpY2, x2, y2);
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawQuadraticCurve = function(x1, y1, cpX, cpY, x2, y2) {
|
||||
this._graphics.beginFill(this._object._fillColor, this._object._fillOpacity / 255);
|
||||
this._graphics.moveTo(x1, y1);
|
||||
this._graphics.quadraticCurveTo(cpX, cpY, x2, y2);
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.beginFillPath = function() {
|
||||
this._graphics.beginFill(this._object._fillColor, this._object._fillOpacity / 255);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.endFillPath = function() {
|
||||
this._graphics.endFill();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawPathMoveTo = function(x1, y1) {
|
||||
this._graphics.moveTo(x1, y1);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawPathLineTo = function(x1, y1) {
|
||||
if(this._graphics.graphicsData.length === 0){
|
||||
this._graphics.moveTo(0, 0);
|
||||
}
|
||||
this._graphics.lineTo(x1, y1);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawPathBezierCurveTo = function(cpX, cpY, cpX2, cpY2, toX, toY) {
|
||||
if(this._graphics.graphicsData.length === 0){
|
||||
this._graphics.moveTo(0, 0);
|
||||
}
|
||||
this._graphics.bezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawPathArc = function(x1, y1, radius, startAngle, endAngle, anticlockwise) {
|
||||
if(this._graphics.graphicsData.length === 0){
|
||||
this._graphics.moveTo(0, 0);
|
||||
}
|
||||
this._graphics.arc(x1, y1, radius, gdjs.toRad(startAngle), gdjs.toRad(endAngle), anticlockwise ? true : false);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.drawPathQuadraticCurveTo = function(cpX, cpY, toX, toY) {
|
||||
if(this._graphics.graphicsData.length === 0){
|
||||
this._graphics.moveTo(0, 0);
|
||||
}
|
||||
this._graphics.quadraticCurveTo(cpX, cpY, toX, toY);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.closePath = function() {
|
||||
this._graphics.closePath();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObjectPixiRenderer.prototype.updateOutline = function() {
|
||||
this._graphics.lineStyle(
|
||||
this._object._outlineSize,
|
||||
|
@@ -25,6 +25,9 @@ gdjs.ShapePainterRuntimeObject = function(runtimeScene, objectData)
|
||||
gdjs.ShapePainterRuntimeObjectRenderer.call(this._renderer, this, runtimeScene);
|
||||
else
|
||||
this._renderer = new gdjs.ShapePainterRuntimeObjectRenderer(this, runtimeScene);
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype = Object.create( gdjs.RuntimeObject.prototype );
|
||||
@@ -57,6 +60,67 @@ gdjs.ShapePainterRuntimeObject.prototype.drawLine = function(x1, y1, x2, y2, thi
|
||||
this._renderer.drawLine(x1, y1, x2, y2, thickness);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawLineV2 = function(x1, y1, x2, y2, thickness) {
|
||||
this._renderer.drawLineV2(x1, y1, x2, y2, thickness);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawEllipse = function(centerX, centerY, width, height) {
|
||||
this._renderer.drawEllipse(centerX, centerY, width, height);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawRoundedRectangle = function(startX1, startY1, endX2, endY2, radius) {
|
||||
this._renderer.drawRoundedRectangle(startX1, startY1, endX2, endY2, radius);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawStar = function(centerX, centerY, points, radius, innerRadius, rotation) {
|
||||
this._renderer.drawStar(centerX, centerY, points, radius, innerRadius, rotation);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawArc = function(centerX, centerY, radius, startAngle, endAngle, anticlockwise, closePath) {
|
||||
this._renderer.drawArc(centerX, centerY, radius, startAngle, endAngle, anticlockwise, closePath);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawBezierCurve = function(x1, y1, cpX, cpY, cpX2, cpY2, x2, y2) {
|
||||
this._renderer.drawBezierCurve(x1, y1, cpX, cpY, cpX2, cpY2, x2, y2);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawQuadraticCurve = function(x1, y1, cpX, cpY, x2, y2) {
|
||||
this._renderer.drawQuadraticCurve(x1, y1, cpX, cpY, x2, y2);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.beginFillPath = function(x1, y1) {
|
||||
this._renderer.beginFillPath();
|
||||
this._renderer.drawPathMoveTo(x1, y1);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.endFillPath = function() {
|
||||
this._renderer.endFillPath();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawPathMoveTo = function(x1, y1) {
|
||||
this._renderer.drawPathMoveTo(x1, y1);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawPathLineTo = function(x1, y1, thickness) {
|
||||
this._renderer.drawPathLineTo(x1, y1, thickness);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawPathBezierCurveTo = function(cpX, cpY, cpX2, cpY2, toX, toY) {
|
||||
this._renderer.drawPathBezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawPathArc = function(cx, cy, radius, startAngle, endAngle, anticlockwise) {
|
||||
this._renderer.drawPathArc(cx, cy, radius, startAngle, endAngle, anticlockwise);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.drawPathQuadraticCurveTo = function(cpX, cpY, toX, toY) {
|
||||
this._renderer.drawPathQuadraticCurveTo(cpX, cpY, toX, toY);
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.closePath = function() {
|
||||
this._renderer.closePath();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.setFillColor = function(rgbColor) {
|
||||
var colors = rgbColor.split(";");
|
||||
if ( colors.length < 3 ) return;
|
||||
|
@@ -42,7 +42,7 @@ void DeclareShopifyExtension(gd::PlatformExtension& extension) {
|
||||
"GetCheckoutUrlForProduct",
|
||||
_("Get the URL for buying a product"),
|
||||
_("Get the URL for buying a product from a shop. The URL will be "
|
||||
"stored in the variable that you specify. You can then use the "
|
||||
"stored in the scene variable that you specify. You can then use the "
|
||||
"action to open an URL to redirect the player to the checkout."),
|
||||
_("Get the URL for product #_PARAM2_ (quantity: _PARAM3_, variant: "
|
||||
"_PARAM4_) from shop _PARAM1_, and store it in _PARAM5_ (or "
|
||||
@@ -60,8 +60,8 @@ void DeclareShopifyExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("expression", _("Variant (0 by default)"))
|
||||
.SetDefaultValue("0")
|
||||
.AddParameter("scenevar",
|
||||
_("Variable where the URL for checkout must be stored"))
|
||||
.AddParameter("scenevar", _("Variable containing the error (if any)"));
|
||||
_("Scene variable where the URL for checkout must be stored"))
|
||||
.AddParameter("scenevar", _("Scene variable containing the error (if any)"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -15,11 +15,25 @@ gdjs.sk.CocosDataLoader.prototype.getData = function(dataName){
|
||||
return cc.loader.getRes("res/"+dataName);
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the textures from DragonBones data
|
||||
* @param {gdjs.RuntimeScene} runtimeScene
|
||||
* @param {Object} objectData
|
||||
*/
|
||||
gdjs.sk.CocosDataLoader.prototype.loadDragonBones = function(runtimeScene, objectData){
|
||||
var textureData = this.getData(objectData.textureDataFilename);
|
||||
var jsonManager = runtimeScene.getGame().getJsonManager();
|
||||
if (!jsonManager.isJsonLoaded(objectData.textureDataFilename)) {
|
||||
console.error("Tried to load DragonBones textures from \"" + objectData.textureDataFilename + "\" but this resource is not loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
var textureData = jsonManager.getLoadedJson(objectData.textureDataFilename);
|
||||
var texture = runtimeScene.getGame().getImageManager().getTexture(objectData.textureName);
|
||||
if(!textureData || !texture._textureLoaded) return;
|
||||
|
||||
if(!textureData || !texture._textureLoaded) {
|
||||
console.error("Tried to load DragonBones textures from \"" + objectData.textureDataFilename + "\" resource but the texture or the texture data could not be loaded properly.");
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i=0; i<textureData.SubTexture.length; i++){
|
||||
var subTex = textureData.SubTexture[i];
|
||||
var frame = new cc.rect(subTex.x, subTex.y, subTex.width, subTex.height);
|
||||
@@ -29,7 +43,7 @@ gdjs.sk.CocosDataLoader.prototype.loadDragonBones = function(runtimeScene, objec
|
||||
if (subTex.hasOwnProperty("frameHeight")){
|
||||
frame.height = subTex.frameHeight;
|
||||
}
|
||||
|
||||
|
||||
this.textures[subTex.name] = {"texture": texture, "frame": frame};
|
||||
}
|
||||
};
|
||||
@@ -98,7 +112,7 @@ gdjs.sk.SlotCocosRenderer.prototype.loadAsSprite = function(texture){
|
||||
};
|
||||
|
||||
gdjs.sk.SlotCocosRenderer.prototype.loadAsMesh = function(texture, vertices, uvs, triangles){
|
||||
// Meshes not supported, load as sprites
|
||||
// Meshes not supported, load as sprites
|
||||
this.loadAsSprite(texture);
|
||||
};
|
||||
|
||||
|
@@ -11,18 +11,25 @@ gdjs.sk.PixiDataLoader = function()
|
||||
};
|
||||
gdjs.sk.DataLoader = gdjs.sk.PixiDataLoader;
|
||||
|
||||
gdjs.sk.PixiDataLoader.prototype.getData = function(dataName){
|
||||
if(PIXI.loader.resources[dataName]){
|
||||
return PIXI.loader.resources[dataName].data;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the textures from DragonBones data
|
||||
* @param {gdjs.RuntimeScene} runtimeScene
|
||||
* @param {Object} objectData
|
||||
*/
|
||||
gdjs.sk.PixiDataLoader.prototype.loadDragonBones = function(runtimeScene, objectData){
|
||||
var textureData = this.getData(objectData.textureDataFilename);
|
||||
var jsonManager = runtimeScene.getGame().getJsonManager();
|
||||
if (!jsonManager.isJsonLoaded(objectData.textureDataFilename)) {
|
||||
console.error("Tried to load DragonBones textures from \"" + objectData.textureDataFilename + "\" but this resource is not loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
var textureData = jsonManager.getLoadedJson(objectData.textureDataFilename);
|
||||
var texture = runtimeScene.getGame().getImageManager().getPIXITexture(objectData.textureName);
|
||||
if(!textureData || !texture.valid) return;
|
||||
|
||||
if(!textureData || !texture.valid) {
|
||||
console.error("Tried to load DragonBones textures from \"" + objectData.textureDataFilename + "\" resource but the texture or the texture data could not be loaded properly.");
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i=0; i<textureData.SubTexture.length; i++){
|
||||
var subTex = textureData.SubTexture[i];
|
||||
var frame = new PIXI.Rectangle(subTex.x, subTex.y, subTex.width, subTex.height);
|
||||
@@ -37,7 +44,7 @@ gdjs.sk.PixiDataLoader.prototype.loadDragonBones = function(runtimeScene, object
|
||||
if(frame.y > texture.height) frame.y = 0;
|
||||
if(frame.x + frame.width > texture.width) frame.width = texture.width - frame.x;
|
||||
if(frame.y + frame.height > texture.height) frame.height = texture.height - frame.y;
|
||||
|
||||
|
||||
this.textures[subTex.name] = new PIXI.Texture(texture.baseTexture, frame=frame);
|
||||
}
|
||||
};
|
||||
|
@@ -11,18 +11,20 @@ This project is released under the MIT License.
|
||||
#include "SkeletonObject.h"
|
||||
|
||||
void DeclareSkeletonObjectExtension(gd::PlatformExtension& extension) {
|
||||
extension.SetExtensionInformation(
|
||||
"SkeletonObject",
|
||||
_("Skeleton"),
|
||||
_("Enables the use of animated skeleton objects.\nCurrently supported "
|
||||
"formats:\n *DragonBones"),
|
||||
"Franco Maciel",
|
||||
"Open source (MIT License)");
|
||||
extension
|
||||
.SetExtensionInformation("SkeletonObject",
|
||||
_("Skeleton"),
|
||||
_("Enables the use of animated skeleton objects "
|
||||
"made with DragonBones."),
|
||||
"Franco Maciel",
|
||||
"Open source (MIT License)")
|
||||
.SetExtensionHelpPath("/objects/skeleton");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<SkeletonObject>(
|
||||
"Skeleton",
|
||||
_("Skeleton"),
|
||||
_("Object animated through bones"),
|
||||
_("Object displayed using skeletal animation, powered by DragonBones. "
|
||||
"This object is experimental and searching for a maintainer."),
|
||||
"JsPlatform/Extensions/skeletonicon.png");
|
||||
|
||||
// Object instructions
|
||||
@@ -796,10 +798,10 @@ void DeclareSkeletonObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("expression", _("Ray maximum distance (in pixels)"))
|
||||
.AddParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the X position of the intersection"))
|
||||
_("Scene variable where to store the X position of the intersection"))
|
||||
.AddParameter(
|
||||
"scenevar",
|
||||
_("Variable where to store the Y position of the intersection"))
|
||||
_("Scene variable where to store the Y position of the intersection"))
|
||||
.AddCodeOnlyParameter("conditionInverted", "")
|
||||
.MarkAsAdvanced();
|
||||
}
|
||||
|
@@ -28,6 +28,9 @@ gdjs.SkeletonRuntimeObject = function(runtimeScene, objectData){
|
||||
|
||||
this.manager = gdjs.SkeletonObjectsManager.getManager(runtimeScene);
|
||||
this.getSkeletonData(runtimeScene, objectData);
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
};
|
||||
gdjs.SkeletonRuntimeObject.prototype = Object.create(gdjs.RuntimeObject.prototype);
|
||||
gdjs.SkeletonRuntimeObject.thisIsARuntimeObjectConstructor = "SkeletonObject::Skeleton";
|
||||
@@ -330,7 +333,7 @@ gdjs.SkeletonRuntimeObject.prototype.setSlotZOrder = function(slotPath, z){
|
||||
gdjs.SkeletonRuntimeObject.prototype.isPointInsideSlot = function(slotPath, x, y){
|
||||
var hitBoxes = this.getPolygons(slotPath);
|
||||
if(!hitBoxes) return false;
|
||||
|
||||
|
||||
for(var i = 0; i < this.hitBoxes.length; ++i) {
|
||||
if ( gdjs.Polygon.isPointInside(hitBoxes[i], x, y) )
|
||||
return true;
|
||||
@@ -343,7 +346,7 @@ gdjs.SkeletonRuntimeObject.prototype.isPointInsideSlot = function(slotPath, x, y
|
||||
gdjs.SkeletonRuntimeObject.prototype.raycastSlot = function(slotPath, x, y, angle, dist, closest){
|
||||
var result = gdjs.Polygon.raycastTest._statics.result;
|
||||
result.collision = false;
|
||||
|
||||
|
||||
var endX = x + dist*Math.cos(angle*Math.PI/180.0);
|
||||
var endY = y + dist*Math.sin(angle*Math.PI/180.0);
|
||||
var testSqDist = closest ? dist*dist : 0;
|
||||
@@ -364,7 +367,7 @@ gdjs.SkeletonRuntimeObject.prototype.raycastSlot = function(slotPath, x, y, angl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -433,7 +436,7 @@ gdjs.SkeletonRuntimeObject.prototype.getBone = function(bonePath){
|
||||
if(slot && slot.type === gdjs.sk.SLOT_ARMATURE && boneName in slot.childArmature.bonesMap){
|
||||
return slot.childArmature.bonesMap[boneName];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
@@ -26,14 +26,23 @@ gdjs.SkeletonObjectsManager.prototype.getSkeleton = function(runtimeScene, objec
|
||||
return this.loadedObjects[objectName];
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the Skeleton data
|
||||
* @param {gdjs.RuntimeScene} runtimeScene
|
||||
* @param {Object} objectData
|
||||
*/
|
||||
gdjs.SkeletonObjectsManager.prototype.loadSkeleton = function(runtimeScene, objectData){
|
||||
var loader = new gdjs.sk.DataLoader();
|
||||
var skeletalData = loader.getData(objectData.skeletalDataFilename);
|
||||
var skeleton = {"loader": loader,
|
||||
"armatures": [],
|
||||
"rootArmature": 0};
|
||||
|
||||
if(!skeletalData) return skeleton;
|
||||
|
||||
var jsonManager = runtimeScene.getGame().getJsonManager();
|
||||
var skeletalData = jsonManager.getLoadedJson(objectData.skeletalDataFilename);
|
||||
if(!skeletalData) {
|
||||
console.error("Tried to load a Skeleton file from \"" + objectData.skeletalDataFilename + "\" but this resource is not loaded.");
|
||||
return skeleton;
|
||||
}
|
||||
|
||||
if(objectData.apiName === "DragonBones"){
|
||||
// Load sub-textures
|
||||
|
@@ -7,8 +7,8 @@ This project is released under the MIT License.
|
||||
|
||||
#include "SkeletonObject.h"
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCpp/Runtime/CommonTools.h"
|
||||
@@ -52,10 +52,19 @@ void SkeletonObject::DoSerializeTo(gd::SerializerElement& element) const {
|
||||
std::map<gd::String, gd::PropertyDescriptor> SkeletonObject::GetProperties(
|
||||
gd::Project& project) const {
|
||||
std::map<gd::String, gd::PropertyDescriptor> properties;
|
||||
properties[_("Skeletal data filename")].SetValue(skeletalDataFilename);
|
||||
properties[_("Skeletal data filename")]
|
||||
.SetValue(skeletalDataFilename)
|
||||
.SetType("resource")
|
||||
.AddExtraInfo("json");
|
||||
properties[_("Main armature name")].SetValue(rootArmatureName);
|
||||
properties[_("Texture data filename")].SetValue(textureDataFilename);
|
||||
properties[_("Texture")].SetValue(textureName);
|
||||
properties[_("Texture data filename")]
|
||||
.SetValue(textureDataFilename)
|
||||
.SetType("resource")
|
||||
.AddExtraInfo("json");
|
||||
properties[_("Texture")]
|
||||
.SetValue(textureName)
|
||||
.SetType("resource")
|
||||
.AddExtraInfo("image");
|
||||
properties[_("API")].SetValue(apiName).SetType("Choice").AddExtraInfo(
|
||||
"DragonBones");
|
||||
properties[_("Debug Polygons")]
|
||||
|
@@ -28,6 +28,20 @@ void DeclareSystemInfoExtension(gd::PlatformExtension& extension) {
|
||||
|
||||
.SetFunctionName("SystemInfo::IsMobile")
|
||||
.SetIncludeFile("SystemInfo/SystemInfoTools.h");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"IsWebGLSupported",
|
||||
_("Is WebGL supported"),
|
||||
_("Check if GPU accelerated WebGL is supported on the target device."),
|
||||
_("WebGL is available"),
|
||||
_("System information"),
|
||||
"CppPlatform/Extensions/systeminfoicon24.png",
|
||||
"CppPlatform/Extensions/systeminfoicon16.png")
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetFunctionName("SystemInfo::IsWebGLSupported")
|
||||
.SetIncludeFile("SystemInfo/SystemInfoTools.h");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,10 @@ class SystemInfoJsExtension : public gd::PlatformExtension {
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isMobile");
|
||||
GetAllConditions()["SystemInfo::IsWebGLSupported"]
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isWebGLSupported");
|
||||
|
||||
StripUnimplementedInstructionsAndExpressions();
|
||||
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
|
||||
|
@@ -28,3 +28,12 @@ gdjs.evtTools.systemInfo.isMobile = function() {
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the the device supports WebGL.
|
||||
* @param {gdjs.RuntimeScene} runtimeScene
|
||||
* @returns {boolean} true if WebGL is supported
|
||||
*/
|
||||
gdjs.evtTools.systemInfo.isWebGLSupported = function(runtimeScene) {
|
||||
return runtimeScene.getGame().getRenderer().isWebGLSupported();
|
||||
};
|
@@ -12,7 +12,7 @@ gdjs.TextEntryRuntimeObjectCocosRenderer = function(runtimeObject, runtimeScene)
|
||||
|
||||
gdjs.TextEntryRuntimeObjectRenderer = gdjs.TextEntryRuntimeObjectCocosRenderer; //Register the class to let the engine use it.
|
||||
|
||||
gdjs.TextEntryRuntimeObjectCocosRenderer.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.TextEntryRuntimeObjectCocosRenderer.prototype.onDestroy = function() {
|
||||
this.activate(false);
|
||||
};
|
||||
|
||||
|
@@ -50,7 +50,7 @@ gdjs.TextEntryRuntimeObjectPixiRenderer = function(runtimeObject)
|
||||
|
||||
gdjs.TextEntryRuntimeObjectRenderer = gdjs.TextEntryRuntimeObjectPixiRenderer; //Register the class to let the engine use it.
|
||||
|
||||
gdjs.TextEntryRuntimeObjectPixiRenderer.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.TextEntryRuntimeObjectPixiRenderer.prototype.onDestroy = function() {
|
||||
document.removeEventListener('keypress', this._pressHandler);
|
||||
document.removeEventListener('keyup', this._upHandler);
|
||||
document.removeEventListener('keydown', this._downHandler);
|
||||
|
@@ -20,16 +20,19 @@ gdjs.TextEntryRuntimeObject = function(runtimeScene, objectData)
|
||||
gdjs.TextEntryRuntimeObjectRenderer.call(this._renderer, this, runtimeScene);
|
||||
else
|
||||
this._renderer = new gdjs.TextEntryRuntimeObjectRenderer(this, runtimeScene);
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
};
|
||||
|
||||
gdjs.TextEntryRuntimeObject.prototype = Object.create( gdjs.RuntimeObject.prototype );
|
||||
gdjs.TextEntryRuntimeObject.thisIsARuntimeObjectConstructor = "TextEntryObject::TextEntry";
|
||||
|
||||
gdjs.TextEntryRuntimeObject.prototype.onDeletedFromScene = function(runtimeScene) {
|
||||
gdjs.RuntimeObject.prototype.onDeletedFromScene.call(this, runtimeScene);
|
||||
gdjs.TextEntryRuntimeObject.prototype.onDestroyFromScene = function(runtimeScene) {
|
||||
gdjs.RuntimeObject.prototype.onDestroyFromScene.call(this, runtimeScene);
|
||||
|
||||
if (this._renderer.onOwnerRemovedFromScene) {
|
||||
this._renderer.onOwnerRemovedFromScene();
|
||||
if (this._renderer.onDestroy) {
|
||||
this._renderer.onDestroy();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -36,131 +36,275 @@ class TextObjectJsExtension : public gd::PlatformExtension {
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::Scale"]
|
||||
.SetFunctionName("setScale")
|
||||
.SetGetter("getScale")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::ScaleX"]
|
||||
.SetFunctionName("setScaleX")
|
||||
.SetGetter("getScaleX")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::ScaleX"]
|
||||
.SetFunctionName("getScaleX")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::ScaleY"]
|
||||
.SetFunctionName("setScaleY")
|
||||
.SetGetter("getScaleY")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::ScaleY"]
|
||||
.SetFunctionName("getScaleY")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::String"]
|
||||
.SetFunctionName("setString")
|
||||
.SetGetter("getString")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::String"]
|
||||
.SetFunctionName("getString")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::Size"]
|
||||
.SetFunctionName("setCharacterSize")
|
||||
.SetGetter("getCharacterSize")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::Size"]
|
||||
.SetFunctionName("getCharacterSize")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::Angle"]
|
||||
.SetFunctionName("setAngle")
|
||||
.SetGetter("getAngle")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::Angle"]
|
||||
.SetFunctionName("getAngle")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::Opacity"]
|
||||
.SetFunctionName("setOpacity")
|
||||
.SetGetter("getOpacity")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::Opacity"]
|
||||
.SetFunctionName("getOpacity")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::SetBold"]
|
||||
.SetFunctionName("setBold")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::IsBold"]
|
||||
.SetFunctionName("isBold")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::SetItalic"]
|
||||
.SetFunctionName("setItalic")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::IsItalic"]
|
||||
.SetFunctionName("isItalic")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::SetWrapping"]
|
||||
.SetFunctionName("setWrapping")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::IsWrapping"]
|
||||
.SetFunctionName("isWrapping")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::SetPadding"]
|
||||
.SetFunctionName("setPadding")
|
||||
.SetGetter("getPadding")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::Padding"]
|
||||
.SetFunctionName("getPadding")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::SetTextAlignment"]
|
||||
.SetFunctionName("setTextAlignment")
|
||||
.SetGetter("getTextAlignment")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::TextAlignment"]
|
||||
.SetFunctionName("getTextAlignment")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::WrappingWidth"]
|
||||
.SetFunctionName("setWrappingWidth")
|
||||
.SetGetter("getWrappingWidth")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllConditionsForObject("TextObject::Text")["TextObject::WrappingWidth"]
|
||||
.SetFunctionName("getWrappingWidth")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
GetAllExpressionsForObject("TextObject::Text")["Padding"]
|
||||
.SetFunctionName("getPadding")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllExpressionsForObject("TextObject::Text")["ScaleX"]
|
||||
.SetFunctionName("getScaleX")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllExpressionsForObject("TextObject::Text")["ScaleY"]
|
||||
.SetFunctionName("getScaleY")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllExpressionsForObject("TextObject::Text")["Opacity"]
|
||||
.SetFunctionName("getOpacity")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllExpressionsForObject("TextObject::Text")["Angle"]
|
||||
.SetFunctionName("getAngle")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllStrExpressionsForObject("TextObject::Text")["String"]
|
||||
.SetFunctionName("getString")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::ChangeColor"]
|
||||
.SetFunctionName("setColor")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::SetGradient"]
|
||||
.SetFunctionName("setGradient")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::SetOutline"]
|
||||
.SetFunctionName("setOutline")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::SetShadow"]
|
||||
.SetFunctionName("setShadow")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::ShowShadow"]
|
||||
.SetFunctionName("showShadow")
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js");
|
||||
.SetIncludeFile("Extensions/TextObject/textruntimeobject.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-pixi-renderer.js")
|
||||
.AddIncludeFile(
|
||||
"Extensions/TextObject/textruntimeobject-cocos-renderer.js");
|
||||
|
||||
// Unimplemented actions and conditions:
|
||||
GetAllActionsForObject("TextObject::Text")["TextObject::Font"]
|
||||
|
@@ -35,9 +35,9 @@ TextObject::TextObject(gd::String name_)
|
||||
bold(false),
|
||||
italic(false),
|
||||
underlined(false),
|
||||
colorR(255),
|
||||
colorG(255),
|
||||
colorB(255)
|
||||
colorR(0),
|
||||
colorG(0),
|
||||
colorB(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ bool RuntimeTextObject::ChangeProperty(std::size_t propertyNb,
|
||||
} else if (propertyNb == 1) {
|
||||
ChangeFont(newValue);
|
||||
} else if (propertyNb == 2) {
|
||||
SetCharacterSize(newValue.To<int>());
|
||||
SetCharacterSize(std::max(1, newValue.To<int>()));
|
||||
} else if (propertyNb == 3) {
|
||||
gd::String r, gb, g, b;
|
||||
{
|
||||
@@ -297,7 +297,7 @@ bool RuntimeTextObject::ChangeProperty(std::size_t propertyNb,
|
||||
|
||||
SetColor(r.To<int>(), g.To<int>(), b.To<int>());
|
||||
} else if (propertyNb == 4) {
|
||||
SetOpacity(newValue.To<float>());
|
||||
SetOpacity(std::min(std::max(0.0f, newValue.To<float>()), 255.0f));
|
||||
} else if (propertyNb == 5) {
|
||||
SetSmooth(!(newValue == _("No")));
|
||||
}
|
||||
|
@@ -69,6 +69,9 @@ gdjs.TextRuntimeObjectPixiRenderer.prototype.updateStyle = function() {
|
||||
style.dropShadowAngle = this._object._shadowAngle;
|
||||
style.dropShadowDistance = this._object._shadowDistance;
|
||||
style.padding = this._object._padding;
|
||||
// Prevent spikey outlines by adding a miter limit
|
||||
style.miterLimit = 3;
|
||||
|
||||
this.updatePosition();
|
||||
|
||||
// Manually ask the PIXI object to re-render as we changed a style property
|
||||
|
@@ -14,7 +14,7 @@ gdjs.TextRuntimeObject = function(runtimeScene, objectData)
|
||||
{
|
||||
gdjs.RuntimeObject.call(this, runtimeScene, objectData);
|
||||
|
||||
this._characterSize = objectData.characterSize;
|
||||
this._characterSize = Math.max(1, objectData.characterSize);
|
||||
this._fontName = objectData.font;
|
||||
this._bold = objectData.bold;
|
||||
this._italic = objectData.italic;
|
||||
@@ -44,6 +44,9 @@ gdjs.TextRuntimeObject = function(runtimeScene, objectData)
|
||||
gdjs.TextRuntimeObjectRenderer.call(this._renderer, this, runtimeScene);
|
||||
else
|
||||
this._renderer = new gdjs.TextRuntimeObjectRenderer(this, runtimeScene);
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
};
|
||||
|
||||
gdjs.TextRuntimeObject.prototype = Object.create( gdjs.RuntimeObject.prototype );
|
||||
@@ -206,7 +209,7 @@ gdjs.TextRuntimeObject.prototype.getHeight = function() {
|
||||
* Get scale of the text.
|
||||
*/
|
||||
gdjs.TextRuntimeObject.prototype.getScale = function() {
|
||||
return (Math.abs(this._scaleX)+Math.abs(this._scaleY))/2.0;
|
||||
return (Math.abs(this._scaleX)+Math.abs(this._scaleY))/2.0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -413,7 +416,7 @@ gdjs.TextRuntimeObject.prototype.setGradient = function(strGradientType, strFirs
|
||||
|
||||
this._gradientType = strGradientType;
|
||||
|
||||
this._useGradient = (this._gradient.length > 1) ? true : false;
|
||||
this._useGradient = (this._gradient.length > 1) ? true : false;
|
||||
|
||||
this._renderer.updateStyle();
|
||||
};
|
||||
|
@@ -23,7 +23,7 @@ gdjs.TiledSpriteRuntimeObjectCocosRenderer = function(runtimeObject, runtimeScen
|
||||
|
||||
gdjs.TiledSpriteRuntimeObjectRenderer = gdjs.TiledSpriteRuntimeObjectCocosRenderer; //Register the class to let the engine use it.
|
||||
|
||||
gdjs.TiledSpriteRuntimeObjectCocosRenderer.prototype.onOwnerRemovedFromScene = function() {
|
||||
gdjs.TiledSpriteRuntimeObjectCocosRenderer.prototype.onDestroy = function() {
|
||||
if (this._shader) this._shader.release();
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,9 @@ gdjs.TiledSpriteRuntimeObject = function(runtimeScene, objectData)
|
||||
|
||||
this.setWidth(objectData.width);
|
||||
this.setHeight(objectData.height);
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
};
|
||||
|
||||
gdjs.TiledSpriteRuntimeObject.prototype = Object.create( gdjs.RuntimeObject.prototype );
|
||||
@@ -33,11 +36,11 @@ gdjs.TiledSpriteRuntimeObject.prototype.getRendererObject = function() {
|
||||
return this._renderer.getRendererObject();
|
||||
};
|
||||
|
||||
gdjs.TiledSpriteRuntimeObject.prototype.onDeletedFromScene = function(runtimeScene) {
|
||||
gdjs.RuntimeObject.prototype.onDeletedFromScene.call(this, runtimeScene);
|
||||
gdjs.TiledSpriteRuntimeObject.prototype.onDestroyFromScene = function(runtimeScene) {
|
||||
gdjs.RuntimeObject.prototype.onDestroyFromScene.call(this, runtimeScene);
|
||||
|
||||
if (this._renderer.onOwnerRemovedFromScene) {
|
||||
this._renderer.onOwnerRemovedFromScene();
|
||||
if (this._renderer.onDestroy) {
|
||||
this._renderer.onDestroy();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -187,6 +190,6 @@ gdjs.TiledSpriteRuntimeObject.prototype.setColor = function(rgbColor) {
|
||||
*
|
||||
* @returns {string} rgbColor The color, in RGB format ("128;200;255").
|
||||
*/
|
||||
gdjs.SpriTiledSpriteRuntimeObjectteRuntimeObject.prototype.getColor = function() {
|
||||
gdjs.TiledSpriteRuntimeObject.prototype.getColor = function() {
|
||||
return this._renderer.getColor();
|
||||
};
|
||||
};
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @param {Object} behaviorData The data to initialize the behavior
|
||||
* @param {gdjs.RuntimeObject} owner The runtime object the behavior belongs to.
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior = function(runtimeScene, behaviorData, owner) {
|
||||
gdjs.TweenRuntimeBehavior = function (runtimeScene, behaviorData, owner) {
|
||||
gdjs.RuntimeBehavior.call(this, runtimeScene, behaviorData, owner);
|
||||
|
||||
/** @type Object.<string, gdjs.TweenRuntimeBehavior.TweenInstance > */
|
||||
@@ -66,7 +66,7 @@ gdjs.TweenRuntimeBehavior.easings = [
|
||||
* @param {number} startTime The time at which the tween starts
|
||||
* @param {number} totalDuration The time of the whole tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.TweenInstance = function(
|
||||
gdjs.TweenRuntimeBehavior.TweenInstance = function (
|
||||
instance,
|
||||
hasFinished,
|
||||
startTime,
|
||||
@@ -79,7 +79,7 @@ gdjs.TweenRuntimeBehavior.TweenInstance = function(
|
||||
this.resumeOnActivate = false;
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._addTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._addTween = function (
|
||||
identifier,
|
||||
instance,
|
||||
startTime,
|
||||
@@ -93,19 +93,19 @@ gdjs.TweenRuntimeBehavior.prototype._addTween = function(
|
||||
);
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._getTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._getTween = function (identifier) {
|
||||
return this._tweens[identifier];
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenExists = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenExists = function (identifier) {
|
||||
return !!this._tweens[identifier];
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenIsPlaying = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenIsPlaying = function (identifier) {
|
||||
return this._tweens[identifier].instance.isPlaying();
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._pauseTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._pauseTween = function (identifier) {
|
||||
var tween = this._tweens[identifier];
|
||||
|
||||
// Pause the tween, and remove it from the scene of living tweens
|
||||
@@ -116,12 +116,12 @@ gdjs.TweenRuntimeBehavior.prototype._pauseTween = function(identifier) {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._resumeTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._resumeTween = function (identifier) {
|
||||
var tween = this._tweens[identifier];
|
||||
|
||||
// Resume the tween, and add it back to the scene of living tweens
|
||||
// (the invariant is that scene only contains tweens being played).
|
||||
tween.instance.resume().catch(() => {
|
||||
tween.instance.resume().catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
@@ -132,32 +132,32 @@ gdjs.TweenRuntimeBehavior.prototype._resumeTween = function(identifier) {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._stopTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._stopTween = function (
|
||||
identifier,
|
||||
jumpToDest
|
||||
) {
|
||||
return this._tweens[identifier].instance.stop(jumpToDest);
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._setTweenFinished = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._setTweenFinished = function (
|
||||
identifier,
|
||||
hasFinished
|
||||
) {
|
||||
this._tweens[identifier].hasFinished = hasFinished;
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenHasFinished = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenHasFinished = function (identifier) {
|
||||
return this._tweens[identifier].hasFinished;
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._removeObjectFromScene = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._removeObjectFromScene = function (
|
||||
identifier
|
||||
) {
|
||||
this._removeTween(identifier);
|
||||
return this.owner.deleteFromScene(this._runtimeScene);
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._removeTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._removeTween = function (identifier) {
|
||||
if (!this._tweens[identifier]) return;
|
||||
|
||||
this._tweens[identifier].instance.stop();
|
||||
@@ -168,23 +168,24 @@ gdjs.TweenRuntimeBehavior.prototype._removeTween = function(identifier) {
|
||||
delete this._tweens[identifier];
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._setupTweenEnding = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._setupTweenEnding = function (
|
||||
identifier,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (destroyObjectWhenFinished) {
|
||||
this._tweens[identifier].instance
|
||||
.tween()
|
||||
.catch(() => {
|
||||
.catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
// ensure that the content of the "then" is always applied:
|
||||
})
|
||||
.then(() => {
|
||||
this._removeObjectFromScene(identifier);
|
||||
.then(function () {
|
||||
that._removeObjectFromScene(identifier);
|
||||
})
|
||||
.catch(() => {
|
||||
.catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
@@ -193,18 +194,18 @@ gdjs.TweenRuntimeBehavior.prototype._setupTweenEnding = function(
|
||||
} else {
|
||||
this._tweens[identifier].instance
|
||||
.tween()
|
||||
.catch(() => {
|
||||
.catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
// ensure that the content of the "then" is always applied:
|
||||
})
|
||||
.then(() => {
|
||||
if (this._tweens[identifier]) {
|
||||
this._tweens[identifier].hasFinished = true;
|
||||
.then(function () {
|
||||
if (that._tweens[identifier]) {
|
||||
that._tweens[identifier].hasFinished = true;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
@@ -223,7 +224,7 @@ gdjs.TweenRuntimeBehavior.prototype._setupTweenEnding = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addVariableTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addVariableTween = function (
|
||||
identifier,
|
||||
variable,
|
||||
fromValue,
|
||||
@@ -252,7 +253,7 @@ gdjs.TweenRuntimeBehavior.prototype.addVariableTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
step: function step(state) {
|
||||
variable.setNumber(state.value);
|
||||
}
|
||||
});
|
||||
@@ -276,7 +277,7 @@ gdjs.TweenRuntimeBehavior.prototype.addVariableTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function (
|
||||
identifier,
|
||||
toX,
|
||||
toY,
|
||||
@@ -284,6 +285,7 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function(
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!!gdjs.TweenRuntimeBehavior.easings[easingValue]) return;
|
||||
|
||||
@@ -305,9 +307,9 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setX(state.x);
|
||||
this.owner.setY(state.y);
|
||||
step: function step(state) {
|
||||
that.owner.setX(state.x);
|
||||
that.owner.setY(state.y);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -329,13 +331,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionXTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionXTween = function (
|
||||
identifier,
|
||||
toX,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!!gdjs.TweenRuntimeBehavior.easings[easingValue]) return;
|
||||
|
||||
@@ -355,8 +358,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionXTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setX(state.x);
|
||||
step: function step(state) {
|
||||
that.owner.setX(state.x);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -378,13 +381,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionXTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionYTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionYTween = function (
|
||||
identifier,
|
||||
toY,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!!gdjs.TweenRuntimeBehavior.easings[easingValue]) return;
|
||||
|
||||
@@ -404,8 +408,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionYTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setY(state.y);
|
||||
step: function step(state) {
|
||||
that.owner.setY(state.y);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -427,13 +431,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionYTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectAngleTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectAngleTween = function (
|
||||
identifier,
|
||||
toAngle,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!!gdjs.TweenRuntimeBehavior.easings[easingValue]) return;
|
||||
|
||||
@@ -453,8 +458,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectAngleTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setAngle(state.angle);
|
||||
step: function step(state) {
|
||||
that.owner.setAngle(state.angle);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -477,7 +482,7 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectAngleTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function (
|
||||
identifier,
|
||||
toScaleX,
|
||||
toScaleY,
|
||||
@@ -485,6 +490,7 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function(
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.setScaleX || !this.owner.setScaleY) return;
|
||||
|
||||
@@ -511,9 +517,9 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setScaleX(state.scaleX);
|
||||
this.owner.setScaleY(state.scaleY);
|
||||
step: function step(state) {
|
||||
that.owner.setScaleX(state.scaleX);
|
||||
that.owner.setScaleY(state.scaleY);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -535,13 +541,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleXTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleXTween = function (
|
||||
identifier,
|
||||
toScaleX,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.setScaleX) return;
|
||||
|
||||
@@ -563,8 +570,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleXTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setScaleX(state.scaleX);
|
||||
step: function step(state) {
|
||||
that.owner.setScaleX(state.scaleX);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -586,13 +593,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleXTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleYTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleYTween = function (
|
||||
identifier,
|
||||
toScaleY,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.setScaleY) return;
|
||||
|
||||
@@ -614,8 +622,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleYTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setScaleY(state.scaleY);
|
||||
step: function step(state) {
|
||||
that.owner.setScaleY(state.scaleY);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -637,13 +645,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleYTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectOpacityTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectOpacityTween = function (
|
||||
identifier,
|
||||
toOpacity,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.getOpacity || !this.owner.setOpacity) return;
|
||||
|
||||
@@ -665,8 +674,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectOpacityTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setOpacity(state.opacity);
|
||||
step: function step(state) {
|
||||
that.owner.setOpacity(state.opacity);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -688,13 +697,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectOpacityTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectColorTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectColorTween = function (
|
||||
identifier,
|
||||
toColor,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.getColor || !this.owner.setColor) return;
|
||||
if (
|
||||
@@ -730,13 +740,13 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectColorTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setColor(
|
||||
step: function step(state) {
|
||||
that.owner.setColor(
|
||||
Math.floor(state.red) +
|
||||
";" +
|
||||
Math.floor(state.green) +
|
||||
";" +
|
||||
Math.floor(state.blue)
|
||||
";" +
|
||||
Math.floor(state.green) +
|
||||
";" +
|
||||
Math.floor(state.blue)
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -759,13 +769,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectColorTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addTextObjectCharacterSizeTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addTextObjectCharacterSizeTween = function (
|
||||
identifier,
|
||||
toSize,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.setCharacterSize) return;
|
||||
|
||||
@@ -787,8 +798,8 @@ gdjs.TweenRuntimeBehavior.prototype.addTextObjectCharacterSizeTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setCharacterSize(state.size);
|
||||
step: function step(state) {
|
||||
that.owner.setCharacterSize(state.size);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -806,7 +817,7 @@ gdjs.TweenRuntimeBehavior.prototype.addTextObjectCharacterSizeTween = function(
|
||||
* Tween is playing.
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.isPlaying = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.isPlaying = function (identifier) {
|
||||
if (this._tweenExists(identifier) && this._tweenIsPlaying(identifier)) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -819,7 +830,7 @@ gdjs.TweenRuntimeBehavior.prototype.isPlaying = function(identifier) {
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
* @returns {boolean} The tween exists
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.exists = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.exists = function (identifier) {
|
||||
return this._tweenExists(identifier);
|
||||
};
|
||||
|
||||
@@ -827,7 +838,7 @@ gdjs.TweenRuntimeBehavior.prototype.exists = function(identifier) {
|
||||
* Tween has finished.
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.hasFinished = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.hasFinished = function (identifier) {
|
||||
if (this._tweenExists(identifier)) {
|
||||
return this._tweenHasFinished(identifier);
|
||||
} else {
|
||||
@@ -839,7 +850,7 @@ gdjs.TweenRuntimeBehavior.prototype.hasFinished = function(identifier) {
|
||||
* Pause a tween.
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.pauseTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.pauseTween = function (identifier) {
|
||||
if (!this._isActive) return;
|
||||
|
||||
if (this._tweenExists(identifier) && this._tweenIsPlaying(identifier)) {
|
||||
@@ -852,7 +863,7 @@ gdjs.TweenRuntimeBehavior.prototype.pauseTween = function(identifier) {
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
* @param {boolean} jumpToDest Move to destination
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.stopTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.stopTween = function (
|
||||
identifier,
|
||||
jumpToDest
|
||||
) {
|
||||
@@ -867,7 +878,7 @@ gdjs.TweenRuntimeBehavior.prototype.stopTween = function(
|
||||
* Resume a tween.
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.resumeTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.resumeTween = function (identifier) {
|
||||
if (!this._isActive) return;
|
||||
|
||||
if (this._tweenExists(identifier) && !this._tweenIsPlaying(identifier)) {
|
||||
@@ -879,7 +890,7 @@ gdjs.TweenRuntimeBehavior.prototype.resumeTween = function(identifier) {
|
||||
* Remove a tween.
|
||||
* @param {string} identifierFirst Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.removeTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.removeTween = function (identifier) {
|
||||
this._removeTween(identifier);
|
||||
};
|
||||
|
||||
@@ -888,8 +899,8 @@ gdjs.TweenRuntimeBehavior.prototype.removeTween = function(identifier) {
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
* @returns {boolean} Progress of playing tween animation (between 0.0 and 1.0)
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.getProgress = function(identifier) {
|
||||
const tween = this._getTween(identifier);
|
||||
gdjs.TweenRuntimeBehavior.prototype.getProgress = function (identifier) {
|
||||
var tween = this._getTween(identifier);
|
||||
if (tween) {
|
||||
var currentTime = this._runtimeScene.getTimeManager().getTimeFromStart();
|
||||
if (currentTime >= tween.startTime + tween.totalDuration) return 1;
|
||||
@@ -900,12 +911,12 @@ gdjs.TweenRuntimeBehavior.prototype.getProgress = function(identifier) {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype.onDeActivate = function() {
|
||||
gdjs.TweenRuntimeBehavior.prototype.onDeActivate = function () {
|
||||
if (!this._isActive) return;
|
||||
|
||||
for (const key in this._tweens) {
|
||||
for (var key in this._tweens) {
|
||||
if (this._tweens.hasOwnProperty(key)) {
|
||||
const tween = this._tweens[key];
|
||||
var tween = this._tweens[key];
|
||||
|
||||
if (tween.instance.isPlaying()) {
|
||||
tween.resumeOnActivate = true;
|
||||
@@ -916,12 +927,12 @@ gdjs.TweenRuntimeBehavior.prototype.onDeActivate = function() {
|
||||
this._isActive = false;
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype.onActivate = function() {
|
||||
gdjs.TweenRuntimeBehavior.prototype.onActivate = function () {
|
||||
if (this._isActive) return;
|
||||
|
||||
for (const key in this._tweens) {
|
||||
for (var key in this._tweens) {
|
||||
if (this._tweens.hasOwnProperty(key)) {
|
||||
const tween = this._tweens[key];
|
||||
var tween = this._tweens[key];
|
||||
|
||||
if (tween.resumeOnActivate) {
|
||||
tween.resumeOnActivate = false;
|
||||
@@ -940,7 +951,7 @@ gdjs.TweenRuntimeBehavior.prototype.onActivate = function() {
|
||||
* @param {gdjs.RuntimeScene} runtimeScene
|
||||
* @returns {shifty.Tweenable} The new tweenable
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.makeNewTweenable = function(runtimeScene) {
|
||||
gdjs.TweenRuntimeBehavior.makeNewTweenable = function (runtimeScene) {
|
||||
if (!runtimeScene.shiftyJsScene) {
|
||||
runtimeScene.shiftyJsScene = new shifty.Scene();
|
||||
}
|
||||
@@ -956,7 +967,7 @@ gdjs.TweenRuntimeBehavior.makeNewTweenable = function(runtimeScene) {
|
||||
* @param {gdjs.RuntimeScene} runtimeScene
|
||||
* @param {shifty.Tweenable} tweenable
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.removeFromScene = function(runtimeScene, tweenable) {
|
||||
gdjs.TweenRuntimeBehavior.removeFromScene = function (runtimeScene, tweenable) {
|
||||
if (!runtimeScene.shiftyJsScene) return;
|
||||
|
||||
runtimeScene.shiftyJsScene.remove(tweenable);
|
||||
@@ -969,7 +980,7 @@ gdjs.TweenRuntimeBehavior.removeFromScene = function(runtimeScene, tweenable) {
|
||||
* Stop and "destroy" all the tweens when a scene is unloaded.
|
||||
* @private
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneUnloaded = function(
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneUnloaded = function (
|
||||
runtimeScene
|
||||
) {
|
||||
if (!runtimeScene.shiftyJsScene) return;
|
||||
@@ -986,7 +997,7 @@ gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneUnloaded = function(
|
||||
* When a scene is paused, pause all the tweens of this scene.
|
||||
* @private
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeScenePaused = function(
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeScenePaused = function (
|
||||
runtimeScene
|
||||
) {
|
||||
if (!runtimeScene.shiftyJsScene) return;
|
||||
@@ -998,7 +1009,7 @@ gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeScenePaused = function(
|
||||
* When a scene is paused, resume all the tweens of this scene.
|
||||
* @private
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneResumed = function(
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneResumed = function (
|
||||
runtimeScene
|
||||
) {
|
||||
if (!runtimeScene.shiftyJsScene) return;
|
||||
@@ -1021,7 +1032,7 @@ gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneResumed = function(
|
||||
gdjs.TweenRuntimeBehavior._tweensProcessed = false;
|
||||
gdjs.TweenRuntimeBehavior._currentTweenTime = 0;
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype.doStepPreEvents = function(runtimeScene) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.doStepPreEvents = function (runtimeScene) {
|
||||
// Process tweens (once per frame).
|
||||
if (!gdjs.TweenRuntimeBehavior._tweensProcessed) {
|
||||
gdjs.TweenRuntimeBehavior._currentTweenTime = runtimeScene
|
||||
@@ -1032,19 +1043,19 @@ gdjs.TweenRuntimeBehavior.prototype.doStepPreEvents = function(runtimeScene) {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype.doStepPostEvents = function(runtimeScene) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.doStepPostEvents = function (runtimeScene) {
|
||||
gdjs.TweenRuntimeBehavior._tweensProcessed = false;
|
||||
};
|
||||
|
||||
// Set up Shifty.js so that the processing ("tick"/updates) is handled
|
||||
// by the behavior (once per frame):
|
||||
shifty.Tweenable.setScheduleFunction(function() {
|
||||
shifty.Tweenable.setScheduleFunction(function () {
|
||||
/* Do nothing, we'll call processTweens manually. */
|
||||
});
|
||||
|
||||
// Set up Shifty.js so that the time is handled by the behavior.
|
||||
// It will be set to be the time of the current scene, and should be updated
|
||||
// before any tween processing (processTweens, resume).
|
||||
shifty.Tweenable.now = function() {
|
||||
shifty.Tweenable.now = function () {
|
||||
return gdjs.TweenRuntimeBehavior._currentTweenTime;
|
||||
};
|
||||
|
@@ -500,7 +500,9 @@ module.exports = {
|
||||
registerEditorConfigurations: function(objectsEditorService) {
|
||||
objectsEditorService.registerEditorConfiguration(
|
||||
"Video::VideoObject",
|
||||
objectsEditorService.getDefaultObjectJsImplementationPropertiesEditor()
|
||||
objectsEditorService.getDefaultObjectJsImplementationPropertiesEditor({
|
||||
helpPagePath: "/objects/video"
|
||||
})
|
||||
);
|
||||
},
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user