Compare commits

...

245 Commits

Author SHA1 Message Date
Florian Rival
9935ceb2b4 Bump newIDE version 2018-05-24 22:19:07 -07:00
Florian Rival
50f26f19cb Fix space shooter example fonts on web-app 2018-05-24 22:09:26 -07:00
Todor Imreorov
2c806e9492 Fix scrolling issue on Windows and Linux (#500) 2018-05-24 21:58:34 -07:00
Florian Rival
057a1b2d7c Merge pull request #499 from 4ian/feature/facebook-instant-games
Add Facebook Instant Games support
2018-05-24 21:57:03 -07:00
Florian Rival
69b0cb0ead Fix compilation error 2018-05-24 21:41:34 -07:00
Florian Rival
2be6ca9a9f Update GDJS Runtime version of preview created by the web-app 2018-05-24 21:35:48 -07:00
Florian Rival
992b6434e4 Improve examples names and set orientation 2018-05-24 21:35:26 -07:00
Florian Rival
227223f891 Improve web-app examples to adapt their size to the screen at startup 2018-05-24 21:17:59 -07:00
Florian Rival
972cdd9386 Improve examples to use adapt their size to the screen at startup 2018-05-24 20:58:23 -07:00
Florian Rival
fdf4683b83 Add option to adapt HTML5 games size to the screen at startup 2018-05-24 10:04:47 -07:00
Florian Rival
6450a051d0 Add Facebook Instant Games basic support 2018-05-23 20:47:05 -07:00
Florian Rival
f8a31cf3a9 Bump newIDE version 2018-05-22 23:41:11 -07:00
Florian Rival
5372f09c67 Fix closing confirmation 2018-05-22 23:30:33 -07:00
Florian Rival
b9f0e88f7e Bump version 2018-05-22 22:53:16 -07:00
Florian Rival
a5c3767cca Properly refresh textures of edited objects (useful after editing an image with Piskel) 2018-05-22 22:48:33 -07:00
Florian Rival
05e21484cf Fix React warning in PropertiesEditor 2018-05-22 07:53:48 -07:00
Florian Rival
6c204494b5 Add analytics to track usefulness of embedded Piskel editor 2018-05-21 22:17:42 -07:00
Todor Imreorov
af4cdcd485 Add a bundled version of Piskel for edition of image resources directly from GDevelop
* Supports SpriteObject and other object editors using ResourceSelector.
* This system could handle other editors too.
2018-05-20 22:33:08 -07:00
Nnarol
2977f0b1a7 Fix compilation error due to incomplete type. (#496)
Remove inclusion of wx/propgrid/property.h preceding
inclusion of wx/propgrid/propgrid.h to avoid incomplete type
error of object m_bitmap in property.h of type wxBitmap during build.
propgrid.h includes property.h anyway.
2018-05-20 20:49:03 -07:00
Nnarol
16a31cf1ae Prevent fly from disappearing behind cloud in platformer example (#492)
Set z-order of "Cloud" instances to -5.
Set z-order of "BackgroundObjects" to -2.
2018-05-10 19:06:47 -07:00
Florian Rival
dd14a2a86c Run clang-format on some missing files 2018-05-09 16:52:27 -07:00
Florian Rival
a8559bfbbc Add clang-format to format (C++) source files automatically (#491)
* Update all CMakeLists of extensions to use clang-format
* Run clang-format on all Extensions
* Update GDCore CMakeLists.txt to add clang-format
* Run clang-format on GDCore files
* Update GDJS and GDCpp CMakeLists.txt to add clang-format
* Run clang-format on GDCpp and GDJS files
2018-05-09 15:57:38 -07:00
Florian Rival
a77f8e139f Add Opacity expression for Sprite objects 2018-05-05 15:29:30 +01:00
Florian Rival
07af3990ac Add button to open object editor from InstancePropertiesEditor 2018-05-05 13:55:54 +01:00
Florian Rival
33eee8e00a Update demo gif shown on the README with GDevelop 5 2018-05-04 17:50:45 +01:00
Florian Rival
3f32134018 Fix tests 2018-05-04 13:37:52 +01:00
Florian Rival
5b12935851 Add npm package caching for faster Travis CI builds 2018-05-04 13:31:37 +01:00
Florian Rival
7a4d563875 Remove AppVeyor badge for now as it's not stable yet 2018-05-04 13:25:17 +01:00
Florian Rival
a0105fda37 Disable GDJS Runtime tests on Travis-CI as ChromeHeadless is not working 2018-05-04 13:23:05 +01:00
Florian Rival
d2f997ab4c Remove useless use of filter in ObjectSelector 2018-05-02 20:30:34 +01:00
Florian Rival
eb58f592ed Refactor FuzzyOrEmptyFilter to use it all AutoComplete by default 2018-05-02 15:43:17 +01:00
Florian Rival
8b6b896520 Ensure all AutoComplete popover are visible on screen (even if on the bottom of the window) 2018-05-02 15:03:40 +01:00
Florian Rival
34f240fe59 Fix flow issue 2018-05-02 15:00:08 +01:00
Florian Rival
e78411f3a8 Increase width of GenericExpressionField (useful for when clicking on a expression/string parameter) 2018-05-02 14:39:14 +01:00
Florian Rival
3128a19901 Add Checkbox to enable/disable stopping sounds on scene startup in ScenePropertiesDialog 2018-05-02 14:36:33 +01:00
Florian Rival
14d58eac32 Avoid Popover displayed by ObjectSelector to go outside of the screen 2018-05-01 00:21:07 +01:00
Florian Rival
7488b12704 Add documentation about optionalRequire 2018-04-30 14:02:27 +01:00
Lizard-13
f5fa82c95e Fix distance check (#487) 2018-04-30 10:42:39 +01:00
Florian Rival
6ddd093d56 Fix missing flow annotations 2018-04-28 15:09:32 +01:00
Florian Rival
b5ce3a996d Avoid inactive SceneEditor/ExternalLayoutEditor to drain CPU 2018-04-28 14:37:10 +01:00
Florian Rival
d8409d5f1e Make GenericExpressionField multiline (better readabiliy of long expressions) 2018-04-28 00:44:14 +01:00
Florian Rival
7773d431e8 Improve editor performance (#485)
* Use PureComponent to avoid useless rerenderings
* Disable update to editor tabs that are not active
* Add UpdatesProfiler to ease the detection of unnecessary updates in React components
2018-04-27 22:38:12 +01:00
Florian Rival
5f916903ab Bump newIDE version 2018-04-27 15:14:21 +01:00
Florian Rival
60fe29660d Add missing images for points 2018-04-27 15:12:31 +01:00
Florian Rival
596e0087e5 Bump newIDE version 2018-04-26 15:31:29 +01:00
Todor Imreorov
8034247494 Fix scrolling issue (#483) 2018-04-26 14:37:06 +01:00
Florian Rival
73b60e6da8 Fix harmless error in import-libGD.js 2018-04-26 14:27:33 +01:00
Florian Rival
57e00a7ce0 Bump newIDE version 2018-04-26 13:43:25 +01:00
Florian Rival
1a6aa3b7ab Enable again menu in LocalPreviewLauncher preview windows 2018-04-26 13:38:58 +01:00
Florian Rival
e6eb05ce22 Fix TextEditor not resized when text is entered 2018-04-25 22:26:25 +01:00
Florian Rival
ddf63637fe Bump newIDE version 2018-04-25 17:38:06 +01:00
Florian Rival
c02aec0f6b Merge pull request #478 from 4ian/feature/gdjs-ws-debugger
Add basic Debugger for GDevelop 5/GDJS games
2018-04-25 15:41:16 +01:00
Florian Rival
280eebbccd Add HelpButton in DebuggerContent 2018-04-25 15:34:06 +01:00
Florian Rival
48611c2c38 Add Debugger menu item in EventsSheet toolbar 2018-04-24 23:48:42 +01:00
Florian Rival
5dbbc25b2b Fix warning in ScenePropertiesDialog 2018-04-24 23:40:09 +01:00
Florian Rival
23c85d8a75 Enhance RuntimeSceneInspector to allow to create new instances of objects 2018-04-24 23:23:59 +01:00
Florian Rival
cdd0f72266 Refactor *Inspector to use mapValues 2018-04-24 22:53:44 +01:00
Florian Rival
68189bf720 Add RuntimeSceneInspector showing layers information and timescale to Debugger 2018-04-24 20:59:09 +01:00
Florian Rival
376c2cc5c5 Fix Debugger opening from an ExternalLayoutEditor 2018-04-24 20:30:14 +01:00
Florian Rival
38b587cdd4 Set initial split percentage in DebuggerContent to increase inspectors list readability 2018-04-24 17:44:13 +01:00
Florian Rival
dd65aaf086 Make Debugger inspectors more resilient to bad values 2018-04-24 17:14:36 +01:00
Florian Rival
db7604ee88 Ask for getting a subscription to regularly use the Debugger 2018-04-24 17:11:29 +01:00
Florian Rival
d94749177b Lightly fade buttons to add child to a non-structure variable 2018-04-24 17:10:49 +01:00
Florian Rival
d061be627b Ensure Debugger toolbar is not shown if DebuggerEditor is not active 2018-04-24 17:10:18 +01:00
Florian Rival
3dede19f1f Add note about Debugger working only on Electron runtime 2018-04-24 15:43:17 +01:00
Florian Rival
916d2eb99e Fix storybook DebuggerContent stories 2018-04-24 12:53:26 +01:00
Florian Rival
9fadc0faab Add item in menu to open Debugger 2018-04-24 11:00:04 +01:00
Florian Rival
ba6c7ec78d Add a message when no debugger is launched 2018-04-24 10:57:55 +01:00
Florian Rival
0b4fc055bf [WIP] Enable debugger to listen to multiple game previews 2018-04-24 00:14:38 +01:00
Florian Rival
8a841fa68f Fix a flow type error 2018-04-23 22:15:21 +01:00
Florian Rival
f71983679c Enhance README and fix linter errors + add warning about RawContentInspector usage 2018-04-23 22:15:21 +01:00
Florian Rival
be3cc48e32 Add RuntimeObject/VariablesContainerInspector for Debugger with live editing 2018-04-23 22:15:21 +01:00
Florian Rival
956656236b Move InstancesFullEditor to SceneEditor 2018-04-23 22:15:20 +01:00
Florian Rival
a53de69c4e [WIP] Implement a basic client/server debugger for GDJS games 2018-04-23 22:15:20 +01:00
Florian Rival
a7abbda061 Fix an incorrectly parsed color warning in DefaultTheme 2018-04-23 22:09:48 +01:00
Florian Rival
c267d14348 Merge pull request #452 from Lizard-13/skeleton-runtime-object
Add Skeleton object extension (still in Beta)
2018-04-23 21:50:09 +01:00
Todor Imreorov
7db2709ff0 Improve scrolling and add mouse middle button support to Scene editor (#472)
* Add mouse middle button input support to Scene editor, using standard navigation design present in other software (Gimp, Krita, Inkscape, blender, etc):
- Scrolling to zoom in and out the view
- Mid click to pan the view

* Middle mouse navigation is only for windows and Linux, but not macOS.
* Add support for natural scrolling in both X and Y directions
2018-04-23 21:36:19 +01:00
Lizard-13
86a3614f89 Added an example and improve response on missing resources 2018-04-23 12:52:30 -03:00
Lizard-13
b8e0b5d8e3 Update comments 2018-04-20 08:22:18 -03:00
Lizard-13
c7a8df3d5a Clean some code 2018-04-16 12:31:11 -03:00
Florian Rival
3be8966132 Remove menu of BrowserWindow showing the preview of games in newIDE 2018-04-15 22:34:33 +02:00
Florian Rival
61cefa6cd7 Merge branch 'master' of github.com:4ian/GD 2018-04-15 22:33:47 +02:00
Florian Rival
e1dd41bb32 Fix debouncing of HelpFinder analytics 2018-04-15 12:29:06 +02:00
Ryan Jentzsch
24466ca653 Add note about NPM watcher error for Linux (#468)
See #467
2018-04-14 10:40:02 +02:00
Florian Rival
1c9497dc92 Remove useless file 2018-04-13 23:45:26 +02:00
Florian Rival
5dd3ed43cf Merge pull request #466 from 4ian/feature/help-finder
Add HelpFinder with search in documentation powered by Algolia DocSearch.
2018-04-13 17:06:11 +02:00
Florian Rival
368cdebd78 Fix primary RaisedButton text color in DarkTheme 2018-04-13 17:03:43 +02:00
Florian Rival
3d7279144b Add Search powered by Algolia in HelpFinder 2018-04-13 16:53:54 +02:00
Florian Rival
18682eccfa Fix DocSearch width on large screens 2018-04-13 16:45:41 +02:00
Florian Rival
f70c565e7d Ensure opening a link in the Electron app will open an external browser 2018-04-13 16:38:34 +02:00
Florian Rival
b9035efc9e Fix StartPage tests 2018-04-13 16:29:40 +02:00
Florian Rival
493fc7b6f9 Send analytics from HelpFinder to know if it's being used 2018-04-13 16:28:04 +02:00
Florian Rival
52db6e15ee Add work-in-progress HelpFinder dialog 2018-04-13 16:19:39 +02:00
Florian Rival
28de2b179b Merge pull request #465 from Lizard-13/improve-particles
Improve particles
2018-04-13 15:12:11 +02:00
Lizard-13
4a6c37f502 Fix Cocos particles size 2018-04-13 06:50:51 -03:00
Lizard-13
9ce734e204 More particles fixes 2018-04-13 06:27:37 -03:00
Florian Rival
fb3a0edfac Fix AudioResourceField not properly shown in ExternalEvents editor 2018-04-10 18:38:46 +02:00
Florian Rival
e613c7d546 Merge pull request #464 from Lizard-13/improve-particles
Improve/Fix particles
2018-04-10 10:44:21 +02:00
Lizard-13
6db6455bb6 Improve particles 2018-04-09 22:38:47 -03:00
Florian Rival
86e928724a Add ObjectName string expression 2018-04-09 17:53:48 +02:00
Florian Rival
f31d8f88c2 Update Particles - Various effects example for HTML5 games 2018-04-08 23:57:39 +02:00
Florian Rival
940eac6bc4 Fix Pixi and Cocos2d-JS particles flow/tank support and adapt Explosion example 2018-04-08 23:28:51 +02:00
Florian Rival
6908f51b4a Fix hasStarted method of ParticleEmitterObject (Pixi.js and Cocos2d-JS renderers) 2018-04-08 22:34:01 +02:00
Florian Rival
a537f678fb Merge pull request #462 from Lizard-13/js-particles
Add support for particles in HTML5 games (both Pixi.js and Cocos2d-JS renderers)

Thanks @Lizard-13 for this great work!
2018-04-08 21:33:37 +02:00
Lizard-13
1019aaba5f Update exporter and improve readability 2018-04-08 11:48:28 -03:00
Lizard-13
5770ac6396 Add support for particles in web platform 2018-04-07 23:51:28 -03:00
Florian Rival
7171f691a3 Display global groups in italic 2018-04-05 20:20:18 +02:00
Florian Rival
0ad7b71cf2 Bump newIDE version 2018-04-04 17:08:52 +02:00
Florian Rival
006d7296a2 Fix AudioResourceField not properly shown when editing it inline in EventsSheet 2018-04-04 17:07:44 +02:00
Florian Rival
443c49f83e Fix regression due to broken Variable and VariablesContainer copy ctor and assignement operator 2018-04-04 15:10:08 +02:00
Florian Rival
9884965595 Merge pull request #458 from 4ian/audio-resource-support
Audio resource support
2018-04-04 13:15:59 +02:00
Florian Rival
e0379466e0 Add more flowtype coverage 2018-04-04 11:54:58 +02:00
Florian Rival
622cba4642 Move ResourceSelectorWithThumbnail and add ResourceThumbnail 2018-04-04 11:46:14 +02:00
Florian Rival
50c7a582ef Add AudioPreview 2018-04-04 11:23:49 +02:00
Florian Rival
e501fd4a09 Add AudioResourceField 2018-04-04 10:36:59 +02:00
Florian Rival
29808c8800 Bump newIDE version 2018-04-03 21:47:13 +02:00
Florian Rival
fcfb71132c Bump GDCore version 2018-04-03 21:21:32 +02:00
Florian Rival
2017d34197 Make explicit to install InnoSetup Unicode to generate GD4 Windows installer 2018-04-03 18:54:20 +02:00
Florian Rival
662c7bd397 Add missing header files 2018-04-03 18:49:05 +02:00
Florian Rival
cf5011c149 Merge pull request #457 from 4ian/feature/copy-paste-delete-variables-list
Copy/paste/delete variables for GDevelop 5
2018-04-03 18:31:31 +02:00
Florian Rival
954520ae3b Add comment about compiler version for compiling GDCore/GDCpp/IDE 2018-04-03 18:31:06 +02:00
Florian Rival
6ffcd6dfb0 Merge branch 'master' of https://github.com/4ian/GD 2018-04-02 21:53:41 +02:00
Florian Rival
80e7a6010a Add missing std::endl in Light_Manager sometimes creating conflicts with
FileStream.

* Other files should be audited for missing std::endl.
* FileStream should be protected against this.
2018-04-02 21:49:29 +02:00
Florian Rival
0dc023ba89 Improve renaming of pasted objects in newIDE 2018-04-02 12:25:17 +02:00
Florian Rival
e70021d0dd Refactor Variable/VariablesContainer and add copy/paste/delete to VariablesList in newIDE 2018-04-01 23:42:52 +02:00
Florian Rival
eb63bda7d2 [WIP] Change VariablesContainer to keep references to variables valid after a removal/move/swap 2018-04-01 20:19:54 +02:00
Florian Rival
10833aa45d [WIP] Add copy/paste/delete in VariablesList in newIDE 2018-04-01 19:44:22 +02:00
Florian Rival
eed844357e Add WindowBorder color to layout background 2018-04-01 16:56:29 +02:00
Florian Rival
6d91676dab Bump version 2018-04-01 01:44:32 +02:00
Florian Rival
69410d62ea Fix theming of objects parameters conflicting between default and dark theme 2018-04-01 01:11:12 +02:00
Florian Rival
977425e700 Add explanation about how to compile libGD.js manually 2018-03-31 13:19:57 +02:00
Lizard-13
50746b3c75 Still trying to fix Travis CI 2018-03-30 23:25:11 -03:00
Lizard-13
1c5364f917 Trying to fix the Travis CI compiling error 2018-03-30 21:51:50 -03:00
Lizard-13
89d099ff7d Add Cocos renderer support 2018-03-30 21:20:01 -03:00
Florian Rival
49d409260a Add TODO about a performance improvement for Sprite collision mask in native game engine 2018-03-31 00:20:41 +02:00
Florian Rival
a50b62a2d8 Update links in README 2018-03-30 23:53:17 +02:00
Florian Rival
6b21ebcc9b Merge pull request #455 from 4ian/feature/collision-mask-editor
Collision mask editor for GDevelop 5
2018-03-30 23:46:51 +02:00
Florian Rival
3c8aa4a249 Display circle for each vertex of collision mask polygons 2018-03-30 23:12:49 +02:00
Florian Rival
a8e9fa5895 Ensure polygon vertices are not put outside the sprite bounding box 2018-03-30 23:05:11 +02:00
Florian Rival
c9f8b4a8ed [WIP] Add preview of default bounding box collision mask 2018-03-30 22:52:22 +02:00
Florian Rival
6b38479166 [WIP] Factor selectors of PointsEditor and CollisionMasksEditor into SpriteSelector 2018-03-30 22:44:19 +02:00
Florian Rival
4ccbc1b958 [WIP] Add preview of collision mask polygons 2018-03-30 22:01:21 +02:00
Florian Rival
54d7d284c8 [WIP] Add CollisionMasksEditor in newIDE (preview not yet done) 2018-03-30 18:06:21 +02:00
Lizard-13
ca1721ef9a Load skeletal data file only once through shared data
Now each file is readed only once, multiple instances will share static data as default values and animation keys.

Also converted all tabs into spaces :)
2018-03-29 19:25:43 -03:00
Florian Rival
58ed74e020 Add help button about Play Store when one-click Android packaging is finished 2018-03-30 00:00:15 +02:00
Florian Rival
e8ce83b162 Bump version 2018-03-29 22:34:06 +02:00
Florian Rival
9b91f06011 Add menu item to set an object as global 2018-03-29 22:09:23 +02:00
Florian Rival
17247cbbf1 Ensure coordinates of objects moved with the mouse are round 2018-03-29 22:05:42 +02:00
Florian Rival
10b81dd232 Fix StartPage snapshot test 2018-03-25 20:19:48 +02:00
Florian Rival
3f3a5dbd3b Remove warnings and add Flow on StartPage 2018-03-25 20:05:35 +02:00
Florian Rival
6ff8ee749d Fix changes wrongly discarded in ObjectField 2018-03-17 17:21:40 +01:00
Florian Rival
db5f146818 Fix errors with some parameter fields 2018-03-17 17:18:03 +01:00
Lizard-13
ddcf51a2b7 Add custom hitbox action and fix polygons draw 2018-03-14 22:09:25 -03:00
Florian Rival
b7467afd1b Bump newIDE version 2018-03-12 21:59:10 +01:00
Florian Rival
ee993f0cdb Improve performance by stopping rendering of InstancesEditor when the SceneEditor/ExternalLayoutEditor is not displayed 2018-03-11 22:30:53 +01:00
Florian Rival
bc6d3ce16f Use italic font to display global objects in ObjectsList in newIDE 2018-03-11 22:02:42 +01:00
Florian Rival
1fae899497 Enhance VariableField to display children variables too 2018-03-11 16:50:38 +01:00
Florian Rival
8319f60c95 Update VariableField completions when variables are edited 2018-03-11 16:01:49 +01:00
Florian Rival
f6fe1a3205 Enhance performance of ParameterFields components 2018-03-11 15:47:40 +01:00
Florian Rival
01e2b53a3f Improve GenericExpressionField performance 2018-03-10 22:10:39 +01:00
Florian Rival
da9eb3cea7 Ensure ObjectsGroupEditorDialog position on screen is always correct 2018-03-10 21:36:13 +01:00
Florian Rival
c044b32c04 Improve performance of ObjectSelector by avoiding constant re-renderings 2018-03-10 21:35:44 +01:00
Lizard-13
46279e7762 Add JS events functions and hitboxes debug draw 2018-03-10 14:54:17 -03:00
Florian Rival
4936b014ae Improve performance of VariablesEditorDialog and ensure dialog position is always correct 2018-03-10 17:07:19 +01:00
Florian Rival
c1cd0d8780 Use SemiControlledTextField in SpriteEditor to enhance performance/responsiveness 2018-03-10 16:55:45 +01:00
Lizard-13
557af32cc9 Add custom icons 2018-02-27 21:51:15 -03:00
Lizard-13
729a85a9a9 Add extension conditions/actions/expressions 2018-02-27 19:10:36 -03:00
Lizard-13
34146c2f18 Added gdjs.sk namespace for better organization 2018-02-27 19:10:23 -03:00
Lizard-13
00146bb8f8 Add animation and animation blending system 2018-02-27 19:10:11 -03:00
Lizard-13
6026d79ebb Support for armatures, meshes* and polygons
*Meshes needs PIXI lib update
2018-02-27 19:10:07 -03:00
Lizard-13
fc28f272b3 Images color, alpha, visible, z support 2018-02-27 19:10:02 -03:00
Lizard-13
9702db06a5 Basic images working 2018-02-27 19:09:55 -03:00
Lizard-13
209f83d697 Basic classes setup 2018-02-27 19:09:47 -03:00
Lizard-13
0ef8eb32a5 Base extension info and files tree
Files named Ax, By, Cz... as a temporal fix for include order
2018-02-27 19:09:42 -03:00
Lizard-13
8115b8181e Empty working object 2018-02-27 19:09:31 -03:00
Florian Rival
e79a328748 Bump newIDE version 2018-02-25 23:24:20 +01:00
Florian Rival
2083ee1029 Update hosted GDJS root for previews in browser with S3 in newIDE 2018-02-25 23:24:10 +01:00
Florian Rival
3e982cdd87 Add link to roadmap in newIDE readme 2018-02-25 22:58:06 +01:00
Florian Rival
883527b289 Fix tests 2018-02-25 22:38:46 +01:00
Florian Rival
a4d84efdd5 Add support for editing properties of resources in ResourcePropertiesEditor in newIDE 2018-02-25 22:35:17 +01:00
Florian Rival
e46c8493bc Refactor Resource to use gd::PropertyDescriptor for custom properties 2018-02-25 22:17:04 +01:00
Florian Rival
4c443b09cf Update zombie-laser example for newIDE 2018-02-25 18:57:14 +01:00
Florian Rival
98bc2236f4 Merge pull request #445 from Lizard-13/raycast-1
Add Raycast condition
2018-02-25 18:08:43 +01:00
Florian Rival
5199299639 Add analytics when a user choose a new subscription plan 2018-02-25 17:45:49 +01:00
Florian Rival
3268d1db25 Merge pull request #451 from 4ian/feature/profile-in-context
Preview over wifi, GDevelop splash and minor improvements
2018-02-25 17:36:34 +01:00
Florian Rival
741770924b Remove useless package & update subscription descriptions 2018-02-25 17:34:55 +01:00
Florian Rival
49aa9469bb Add SubscriptionChecker when trying to deactivate GDevelop splash in ProjectPropertiesDialog 2018-02-25 17:19:24 +01:00
Florian Rival
7cbe34436c Improve design of SubscriptionDialog and SubscriptionCheckDialog 2018-02-25 16:40:48 +01:00
Lizard-13
122f7ecf3e Fix date functions (#450) 2018-02-25 14:13:23 +01:00
Florian Rival
d79bdd9554 Add SubscriptionChecker to ask users to get a subscription if needed 2018-02-24 20:34:59 +01:00
Lizard-13
3e331cb2e8 Fix event description string (#448) 2018-02-24 19:02:15 +01:00
Florian Rival
361fb6aeab Move UserProfile into a single object provided by a Provider (using react-create-context)
Can be updated later to use the new React Context API once it's ready
SubscriptionCheckDialog is still a Work-In-Progress.
2018-02-24 16:23:45 +01:00
Florian Rival
b4a76895ee [WIP] Display dialog asking for a subscription when starting network preview
TODO: Refactor to store user profile in a context/store to avoid de-synchronisation
between components using UserProfileContainer.
2018-02-24 14:31:08 +01:00
Florian Rival
b2251e1a12 Fix external layout previews for web-app 2018-02-23 15:55:19 +01:00
Florian Rival
1c1860370a Prevent pinch-to-zoom on exported games/preview and set black address bar 2018-02-23 15:24:35 +01:00
Florian Rival
1a190b2a44 Add Network Preview (Preview over wifi) to newIDE with live reload 2018-02-23 12:41:18 +01:00
Florian Rival
b1e0f72416 Add local server in Electron app (to serve previews over wifi) 2018-02-20 08:31:13 +01:00
Florian Rival
2c4ae7573e Add LoadingScreen in project properties to allow to show/hide splash at startup 2018-02-18 23:02:26 +01:00
Florian Rival
04ff1f2726 Add GDevelop Splashscreen at game startup 2018-02-18 21:55:42 +01:00
Florian Rival
eaa5200f95 Fix warning 2018-02-18 17:00:05 +01:00
Florian Rival
53c749b79e Update some links in newIDE to the new GDevelop website (gdevelop-app.com) 2018-02-18 16:30:39 +01:00
Lizard-13
eb96ee8497 Fix @static hint 2018-02-17 17:56:07 -03:00
Lizard-13
458444ee7b Implement collinear case 2018-02-17 16:02:13 -03:00
Lizard-13
c8eb13f18f Minor fixes
Removed circle code, unused includes and debug lines.
Improved extension strings.
Added reference link.
Updated "Laser and zombies.gdg" example
2018-02-17 16:01:11 -03:00
Lizard-13
a224b93edc Remove circle from test game 2018-02-17 16:01:00 -03:00
Lizard-13
f077ca6723 Commented out circle raycasting and added icons 2018-02-17 16:00:52 -03:00
Lizard-13
6bbfa1d4a1 Implement C++ version
And little fixes on the JS version
2018-02-17 16:00:32 -03:00
Lizard-13
3c3dc6ef6e Implement raycast JS version and test game 2018-02-17 16:00:18 -03:00
Lizard-13
5c101dbcda Engine condition set up
Neither tested nor compiled yet
2018-02-17 15:56:50 -03:00
Florian Rival
701b78361a Add support for disabled events in EventsSheet in newIDE 2018-02-17 16:34:42 +01:00
Florian Rival
07f26027f6 Bump newIDE version 2018-02-15 22:56:13 +01:00
Florian Rival
09cf13d6e2 Add confirm before close dialog to newIDE 2018-02-15 22:50:08 +01:00
Florian Rival
42f91565fa Merge pull request #443 from 4ian/feature/cordova-icons
Add support for icons when exporting to Android/iOS
2018-02-13 19:51:04 +01:00
Florian Rival
ac6c146808 Fix ImageThumbnail error when onContextMenu is not specified 2018-02-13 19:50:21 +01:00
Florian Rival
59ad23f8ac Allow to customize game orientation (for when exported with Cordova) 2018-02-11 23:44:00 +01:00
Florian Rival
769c6fe3d5 Move ResourcesLoader in its own folder + refactor methods 2018-02-11 23:17:44 +01:00
Florian Rival
07b92911ab Add message on web-app about non support of automatic icons creation 2018-02-11 22:03:30 +01:00
Florian Rival
eb57bcfc87 Add iOS icons support for Cordova + fix image caching 2018-02-11 21:52:40 +01:00
Florian Rival
7addeba73a Add support for Android icons in Cordova export 2018-02-11 21:14:18 +01:00
Florian Rival
263902b45a Avoid caching in ImagePreview and ImageThumbnail 2018-02-11 18:14:47 +01:00
Florian Rival
d283f759fe Add PlatformSpecificAssets to Project 2018-02-10 18:36:02 +01:00
Florian Rival
fabd028a63 Update VSCode C++ properties for Intellisense 2018-02-10 18:35:05 +01:00
Florian Rival
2b18272c41 Merge branch 'master' of github.com:4ian/GD 2018-02-07 00:02:25 +01:00
Florian Rival
a1fb39da3d Fix scene unloading re-creating a RuntimeSceneRenderer leading to issues with Cocos2d-JS renderer 2018-02-05 23:12:51 +01:00
Florian Rival
09602fdf9e Merge pull request #441 from ronnystandtke/patch-1
Update gdevelop.desktop
2018-02-04 17:03:22 +01:00
ronnystandtke
d574ef17ba Update gdevelop.desktop
added German L10n
2018-02-04 17:00:34 +01:00
Florian Rival
0e3f70627b Bump newIDE version 2018-02-03 19:32:52 +01:00
Florian Rival
a814a07105 Fix ResourcesEditor selection 2018-02-03 19:24:47 +01:00
Florian Rival
c49af90a9c Add program opening count to Keen.io analytics 2018-02-03 19:09:33 +01:00
Florian Rival
24afa155c8 Improve Keen.io analytics events by adding user profile information 2018-02-03 18:30:09 +01:00
Florian Rival
9e5a431516 Only run Fullstory on newIDE web-app 2018-02-03 17:53:57 +01:00
Florian Rival
182a94285c Unregister service worker (it is not ready yet) 2018-02-03 13:05:22 +01:00
Florian Rival
442c2c8dd9 Merge pull request #439 from 4ian/feature/resources-editor
Resources editor for newIDE
2018-02-03 12:57:22 +01:00
Florian Rival
f8fd0dd353 Add a preview in ResourcesEditor 2018-02-03 12:55:30 +01:00
Florian Rival
faad9e23ac Add ResourcesEditor with ResourcePropertiesEditor and Toolbar 2018-01-30 23:12:31 +01:00
Florian Rival
d2af0da1b1 Added tools method to ResourcesManager and finish working version of ResourcesList 2018-01-30 21:56:40 +01:00
Florian Rival
c65e5c3e49 [WIP] Add ResourcesEditor based on a generic SortableVirtualizedItemList
TODO:
* Use SortableVirtualizedItemList for ObjectsList and ObjectsGroupsList
* Add missing features (sorting, delete, thumbnail for images, properties edition) to ResourcesEditor
2018-01-30 00:58:21 +01:00
Florian Rival
24a8dfc5f0 Add SemiControlledTextField to be able to type freely in PropertiesEditor 2018-01-28 18:45:44 +01:00
Florian Rival
9c6790ac37 Update default gravity in PhysicsBehavior 2018-01-27 23:50:49 +01:00
Florian Rival
18ef7460ba Bump newIDE version 2018-01-27 19:34:36 +01:00
Florian Rival
63cd0e76c3 Fix warning 2018-01-27 19:34:27 +01:00
Florian Rival
bdbf7fd9fc Add support for editing BehaviorSharedData in newIDE
TODO:
* Support for cancelling modifications made on it in ScenePropertiesDialog
2018-01-27 19:13:27 +01:00
Florian Rival
6bbedbd8f9 Fix BehaviorSharedData not created by newIDE + fix warnings 2018-01-27 17:00:44 +01:00
Florian Rival
648bd1ff2e Show warning if game name or package name is empty when exporting in newIDE 2018-01-24 23:31:02 +01:00
Florian Rival
d4288caedb Fix .env file loading with electron-app and bump newIDE version 2018-01-23 00:15:13 +01:00
1205 changed files with 191310 additions and 117638 deletions

View File

@@ -4,6 +4,11 @@ compiler:
- gcc
- clang
# Cache .npm folder for faster npm install
cache:
directories:
- $HOME/.npm
git:
depth: 999999
@@ -53,17 +58,19 @@ install:
- cd ..
script:
#newIDE tests:
- cd newIDE/app
- npm test
- npm run flow
- cd ../..
#GDJS game engine tests:
- cd GDJS/tests && npm test
- cd ../..
#GDCore and GDCpp game engine tests:
- cd .build-tests
- Core/GDCore_tests
- GDCpp/GDCpp_tests
- Extensions/PathfindingBehavior/PathfindingBehavior_Runtime_tests
- Extensions/LinkedObjects/LinkedObjects_Runtime_tests
- cd ..
#newIDE tests:
- cd newIDE/app
- npm test
- npm run flow
- cd ../..
#GDJS game engine tests, disabled on Travis CI because ChromeHeadless can't be started.
#See them running on Semaphore-CI instead: https://semaphoreci.com/4ian/gd
# - cd GDJS/tests && npm test
# - cd ../..

View File

@@ -10,29 +10,31 @@
"${workspaceRoot}/Extensions",
"${workspaceRoot}/Core",
"${workspaceRoot}/ExtLibs/SFML/include",
"/usr/local/lib/wx/include/osx_cocoa-unicode-3.0",
"/usr/local/include/wx-3.0",
"/usr/include/machine",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
"/usr/local/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.0.0/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
"/usr/include"
"/usr/include",
"/usr/local/lib/wx/include/osx_cocoa-unicode-3.0",
"/usr/local/include/wx-3.0",
"${workspaceRoot}"
],
"defines": [
"GD_IDE_ONLY",
"__WXMAC__",
"__WXOSX__",
"__WXOSX_COCOA__",
"GD_CORE_API=\" \"",
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
"GD_API=/* Macro used to export classes on Windows, please ignore */",
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */",
"WXUSINGDLL"
],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
"/usr/local/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.0.0/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
"/usr/include",
"${workspaceRoot}"
@@ -40,20 +42,39 @@
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "clang-x64",
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17"
},
{
"name": "Linux",
"includePath": [
"${workspaceRoot}",
"${workspaceRoot}/IDE",
"${workspaceRoot}/GDCpp",
"${workspaceRoot}/GDJS",
"${workspaceRoot}/Extensions",
"${workspaceRoot}/Core",
"${workspaceRoot}/ExtLibs/SFML/include",
"/usr/include",
"/usr/local/include"
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"defines": [
"GD_IDE_ONLY",
"__WXMAC__",
"__WXOSX__",
"__WXOSX_COCOA__",
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
"GD_API=/* Macro used to export classes on Windows, please ignore */",
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */",
"WXUSINGDLL"
],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
@@ -62,19 +83,34 @@
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "clang-x64"
}
},
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include"
"${workspaceRoot}/IDE",
"${workspaceRoot}/GDCpp",
"${workspaceRoot}/GDJS",
"${workspaceRoot}/Extensions",
"${workspaceRoot}/Core",
"${workspaceRoot}/ExtLibs/SFML/include",
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
"${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
"UNICODE",
"GD_IDE_ONLY",
"__WXMAC__",
"__WXOSX__",
"__WXOSX_COCOA__",
"GD_CORE_API=/* Macro used to export classes on Windows, please ignore */",
"GD_API=/* Macro used to export classes on Windows, please ignore */",
"GD_EXTENSION_API=/* Macro used to export classes on Windows, please ignore */",
"WXUSINGDLL"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
@@ -82,9 +118,8 @@
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "msvc-x64"
}
}
],
"version": 3
}
"version": 4
}

View File

@@ -70,7 +70,11 @@
"ratio": "cpp",
"atomic": "cpp",
"locale": "cpp",
"string_view": "cpp"
"string_view": "cpp",
"__string": "cpp",
"cstring": "cpp",
"iomanip": "cpp",
"cstdint": "cpp"
},
"files.exclude": {
"Binaries/*build*": true,
@@ -88,5 +92,6 @@
"newIDE/electron-app/app/www": true
},
// Support for Flowtype:
"javascript.validate.enable": false
"javascript.validate.enable": false,
"flow.useNPMPackagedFlow": true
}

View File

@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project firstLayout="">
<gdVersion build="84" major="3" minor="6" revision="0" />
<properties linuxExecutableFilename="" macExecutableFilename="" useExternalSourceFiles="false" winExecutableFilename="" winExecutableIconFile="">
<gdVersion build="97" major="4" minor="0" revision="0" />
<properties folderProject="false" linuxExecutableFilename="" macExecutableFilename="" orientation="default" packageName="" projectFile="C:\Users\Maciel\Programacion\gits\GD\Binaries\Output\Release_Windows\Examples\Particles - Explosions.gdg" useExternalSourceFiles="false" winExecutableFilename="" winExecutableIconFile="">
<name>Explosions</name>
<author></author>
<windowWidth>800</windowWidth>
<windowHeight>600</windowHeight>
<latestCompilationDirectory></latestCompilationDirectory>
<latestCompilationDirectory>C:\Users\Maciel\AppData\Local\Temp\GDTemporaries\JSCocosExportParticles</latestCompilationDirectory>
<maxFPS>60</maxFPS>
<minFPS>10</minFPS>
<verticalSync>false</verticalSync>
<platformSpecificAssets />
<loadingScreen showGDevelopSplash="true" />
<extensions>
<extension name="BuiltinObject" />
<extension name="BuiltinAudio" />
@@ -34,6 +36,7 @@
</extensions>
<platforms>
<platform name="GDevelop C++ platform" />
<platform name="GDevelop JS platform" />
</platforms>
<currentPlatform>GDevelop C++ platform</currentPlatform>
</properties>
@@ -48,40 +51,40 @@
<variables />
<layouts>
<layout b="0" disableInputWhenNotFocused="true" mangledName="New_32scene" name="New scene" oglFOV="90.000000" oglZFar="500.000000" oglZNear="1.000000" r="0" standardSortMethod="true" stopSoundsOnStartup="true" title="" v="0">
<uiSettings associatedLayout="" grid="false" gridB="255" gridG="180" gridHeight="32" gridOffsetX="0" gridOffsetY="0" gridR="158" gridWidth="32" snap="true" windowMask="false" zoomFactor="1.000000" />
<uiSettings grid="false" gridB="255" gridG="180" gridHeight="32" gridOffsetX="0" gridOffsetY="0" gridR="158" gridWidth="32" snap="true" windowMask="false" zoomFactor="1.000000" />
<objectsGroups />
<variables />
<instances />
<objects>
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Mutable" destroyWhenNoParticles="true" emissionEditionSimpleMode="false" emitterAngleA="180.000000" emitterAngleB="160.000000" emitterForceMax="40.000000" emitterForceMin="5.000000" emitterXDirection="0.000000" emitterYDirection="0.000000" emitterZDirection="1.000000" flow="-1.000000" friction="2.000000" gravityEditionSimpleMode="false" greenParam="Mutable" maxParticleNb="5000" name="Explosion" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="25.000000" particleBlue2="50.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="20.000000" particleGreen1="128.000000" particleGreen2="50.000000" particleLifeTimeMax="1.500000" particleLifeTimeMin="0.700000" particleRed1="255.000000" particleRed2="50.000000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Mutable" rendererParam1="20.000000" rendererParam2="20.000000" rendererType="Quad" sizeParam="Random" tank="1000.000000" textureParticleName="ExplosionTexture.png" type="ParticleSystem::ParticleEmitter" zoneRadius="2.000000">
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Mutable" destroyWhenNoParticles="true" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="360.000000" emitterForceMax="70.000000" emitterForceMin="30.000000" emitterXDirection="0.000000" emitterYDirection="0.000000" emitterZDirection="1.000000" flow="-1.000000" friction="2.000000" gravityEditionSimpleMode="false" greenParam="Mutable" maxParticleNb="100" name="Explosion" particleAlpha1="225.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="25.000000" particleBlue2="50.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="20.000000" particleGreen1="128.000000" particleGreen2="50.000000" particleLifeTimeMax="1.500000" particleLifeTimeMin="0.700000" particleRed1="255.000000" particleRed2="50.000000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Mutable" rendererParam1="20.000000" rendererParam2="20.000000" rendererType="Quad" sizeParam="Random" tank="100.000000" textureParticleName="ExplosionTexture.png" type="ParticleSystem::ParticleEmitter" zoneRadius="2.000000">
<variables />
<automatisms />
<behaviors />
</object>
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Mutable" destroyWhenNoParticles="true" emissionEditionSimpleMode="false" emitterAngleA="0.000000" emitterAngleB="180.000000" emitterForceMax="130.000000" emitterForceMin="50.000000" emitterXDirection="1.000000" emitterYDirection="0.000000" emitterZDirection="1.000000" flow="-1.000000" friction="2.000000" gravityEditionSimpleMode="false" greenParam="Mutable" maxParticleNb="5000" name="Explosion2" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="25.000000" particleBlue2="75.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="30.000000" particleGreen1="76.000000" particleGreen2="180.000000" particleLifeTimeMax="1.500000" particleLifeTimeMin="0.700000" particleRed1="153.000000" particleRed2="1.000000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Enabled" rendererParam1="0.050000" rendererParam2="1.000000" rendererType="Line" sizeParam="Random" tank="350.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="2.000000">
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Mutable" destroyWhenNoParticles="true" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="360.000000" emitterForceMax="130.000000" emitterForceMin="130.000000" emitterXDirection="1.000000" emitterYDirection="0.000000" emitterZDirection="1.000000" flow="-1.000000" friction="2.000000" gravityEditionSimpleMode="false" greenParam="Mutable" maxParticleNb="151" name="Explosion2" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="25.000000" particleBlue2="75.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="30.000000" particleGreen1="76.000000" particleGreen2="180.000000" particleLifeTimeMax="1.000000" particleLifeTimeMin="0.700000" particleRed1="153.000000" particleRed2="1.000000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Enabled" rendererParam1="3.000000" rendererParam2="6.000000" rendererType="Line" sizeParam="Random" tank="40.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="2.000000">
<variables />
<automatisms />
<behaviors />
</object>
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Enabled" destroyWhenNoParticles="true" emissionEditionSimpleMode="false" emitterAngleA="45.000000" emitterAngleB="180.000000" emitterForceMax="10.000000" emitterForceMin="0.000000" emitterXDirection="0.000000" emitterYDirection="0.000000" emitterZDirection="1.000000" flow="400.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Enabled" maxParticleNb="5000" name="ExplosionSmoke" particleAlpha1="153.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="25.000000" particleBlue2="0.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="30.000000" particleGreen1="25.000000" particleGreen2="0.800000" particleLifeTimeMax="1.200000" particleLifeTimeMin="0.700000" particleRed1="25.000000" particleRed2="0.100000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Enabled" rendererParam1="20.000000" rendererParam2="20.000000" rendererType="Quad" sizeParam="Random" tank="500.000000" textureParticleName="ExplosionTexture.png" type="ParticleSystem::ParticleEmitter" zoneRadius="20.000000">
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Enabled" destroyWhenNoParticles="true" emissionEditionSimpleMode="false" emitterAngleA="45.000000" emitterAngleB="180.000000" emitterForceMax="10.000000" emitterForceMin="0.000000" emitterXDirection="0.000000" emitterYDirection="0.000000" emitterZDirection="1.000000" flow="400.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Enabled" maxParticleNb="50" name="ExplosionSmoke" particleAlpha1="153.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="25.000000" particleBlue2="0.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="30.000000" particleGreen1="25.000000" particleGreen2="0.800000" particleLifeTimeMax="2.000000" particleLifeTimeMin="0.700000" particleRed1="25.000000" particleRed2="0.100000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Enabled" rendererParam1="20.000000" rendererParam2="20.000000" rendererType="Quad" sizeParam="Random" tank="50.000000" textureParticleName="ExplosionTexture.png" type="ParticleSystem::ParticleEmitter" zoneRadius="20.000000">
<variables />
<automatisms />
<behaviors />
</object>
</objects>
<events>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::Standard</type>
<conditions>
<condition>
<instruction>
<type inverted="false" value="Timer" />
<parameters>
<parameter></parameter>
<parameter>Random(0.3)+0.2</parameter>
<parameter>&quot;Creating&quot;</parameter>
</parameters>
<subConditions />
</condition>
<subInstructions />
</instruction>
</conditions>
<actions>
<action>
<instruction>
<type inverted="false" value="Create" />
<parameters>
<parameter></parameter>
@@ -90,9 +93,9 @@
<parameter>Random(600)</parameter>
<parameter></parameter>
</parameters>
<subActions />
</action>
<action>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="Create" />
<parameters>
<parameter></parameter>
@@ -101,9 +104,9 @@
<parameter>Explosion.Y()</parameter>
<parameter></parameter>
</parameters>
<subActions />
</action>
<action>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="Create" />
<parameters>
<parameter></parameter>
@@ -112,16 +115,16 @@
<parameter>Explosion.Y()</parameter>
<parameter></parameter>
</parameters>
<subActions />
</action>
<action>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="ResetTimer" />
<parameters>
<parameter></parameter>
<parameter>&quot;Creating&quot;</parameter>
</parameters>
<subActions />
</action>
<subInstructions />
</instruction>
</actions>
<events />
</event>
@@ -131,9 +134,10 @@
<cameras>
<camera defaultSize="true" defaultViewport="true" height="0.000000" viewportBottom="1.000000" viewportLeft="0.000000" viewportRight="1.000000" viewportTop="0.000000" width="0.000000" />
</cameras>
<effects />
</layer>
</layers>
<automatismsSharedData />
<behaviorsSharedData />
</layout>
</layouts>
<externalEvents />

View File

@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project firstLayout="">
<gdVersion build="84" major="3" minor="6" revision="0" />
<properties linuxExecutableFilename="" macExecutableFilename="" useExternalSourceFiles="false" winExecutableFilename="" winExecutableIconFile="">
<gdVersion build="97" major="4" minor="0" revision="0" />
<properties folderProject="false" linuxExecutableFilename="" macExecutableFilename="" orientation="default" packageName="" projectFile="C:\Users\Maciel\Programacion\gits\GD\Binaries\Output\Release_Windows\Examples\Particles - Various effects.gdg" useExternalSourceFiles="false" winExecutableFilename="" winExecutableIconFile="">
<name>Project</name>
<author></author>
<windowWidth>800</windowWidth>
<windowHeight>600</windowHeight>
<latestCompilationDirectory></latestCompilationDirectory>
<latestCompilationDirectory>C:\Users\Maciel\AppData\Local\Temp\GDTemporaries\JSCocosExportParticles</latestCompilationDirectory>
<maxFPS>60</maxFPS>
<minFPS>10</minFPS>
<verticalSync>false</verticalSync>
<platformSpecificAssets />
<loadingScreen showGDevelopSplash="true" />
<extensions>
<extension name="BuiltinObject" />
<extension name="BuiltinAudio" />
@@ -34,6 +36,7 @@
</extensions>
<platforms>
<platform name="GDevelop C++ platform" />
<platform name="GDevelop JS platform" />
</platforms>
<currentPlatform>GDevelop C++ platform</currentPlatform>
</properties>
@@ -47,8 +50,8 @@
<objectsGroups />
<variables />
<layouts>
<layout b="0" disableInputWhenNotFocused="true" mangledName="Nouvelle_32sc_232ne" name="Nouvelle scène" oglFOV="90.000000" oglZFar="500.000000" oglZNear="1.000000" r="0" standardSortMethod="true" stopSoundsOnStartup="true" title="" v="0">
<uiSettings associatedLayout="" grid="false" gridB="255" gridG="180" gridHeight="32" gridOffsetX="0" gridOffsetY="0" gridR="158" gridWidth="32" snap="true" windowMask="false" zoomFactor="1.000000" />
<layout b="0" disableInputWhenNotFocused="true" mangledName="Scene" name="Scene" oglFOV="90.000000" oglZFar="500.000000" oglZNear="1.000000" r="0" standardSortMethod="true" stopSoundsOnStartup="true" title="" v="0">
<uiSettings grid="false" gridB="255" gridG="180" gridHeight="32" gridOffsetX="0" gridOffsetY="0" gridR="158" gridWidth="32" snap="true" windowMask="false" zoomFactor="1.000000" />
<objectsGroups />
<variables />
<instances>
@@ -99,47 +102,47 @@
</instance>
</instances>
<objects>
<object additive="true" alphaParam="Mutable" angleParam="Mutable" blueParam="Random" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="180.000000" emitterForceMax="10.000000" emitterForceMin="0.000000" emitterXDirection="0.000000" emitterYDirection="1.000000" emitterZDirection="0.000000" flow="300.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Random" maxParticleNb="5000" name="Fire" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="30.000000" particleBlue1="50.000000" particleBlue2="0.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="-100.000000" particleGravityZ="0.000000" particleGreen1="50.000000" particleGreen2="204.000000" particleLifeTimeMax="2.500000" particleLifeTimeMin="0.500000" particleRed1="240.000000" particleRed2="1.000000" particleSize1="100.000000" particleSize2="0.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Enabled" rendererParam1="10.000000" rendererParam2="20.000000" rendererType="Quad" sizeParam="Mutable" tank="-1.000000" textureParticleName="Fire" type="ParticleSystem::ParticleEmitter" zoneRadius="5.000000">
<object additive="true" alphaParam="Mutable" angleParam="Mutable" blueParam="Mutable" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="180.000000" emitterForceMax="10.000000" emitterForceMin="0.000000" emitterXDirection="0.000000" emitterYDirection="1.000000" emitterZDirection="0.000000" flow="30.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Mutable" maxParticleNb="200" name="Fire" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="30.000000" particleBlue1="50.000000" particleBlue2="0.000000" particleEditionSimpleMode="true" particleGravityX="0.000000" particleGravityY="-100.000000" particleGravityZ="0.000000" particleGreen1="50.000000" particleGreen2="191.000000" particleLifeTimeMax="2.500000" particleLifeTimeMin="0.500000" particleRed1="240.000000" particleRed2="255.000000" particleSize1="100.000000" particleSize2="0.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Mutable" rendererParam1="10.000000" rendererParam2="20.000000" rendererType="Quad" sizeParam="Mutable" tank="-1.000000" textureParticleName="Fire" type="ParticleSystem::ParticleEmitter" zoneRadius="5.000000">
<variables />
<automatisms />
<behaviors />
</object>
<object additive="false" alphaParam="Mutable" angleParam="Random" blueParam="Enabled" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="180.000000" emitterForceMax="0.000000" emitterForceMin="0.000000" emitterXDirection="0.000000" emitterYDirection="1.000000" emitterZDirection="0.000000" flow="200.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Enabled" maxParticleNb="5000" name="Smoke" particleAlpha1="160.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="360.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="50.000000" particleBlue2="0.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="-100.000000" particleGravityZ="0.000000" particleGreen1="50.000000" particleGreen2="0.800000" particleLifeTimeMax="2.500000" particleLifeTimeMin="0.500000" particleRed1="50.000000" particleRed2="1.000000" particleSize1="20.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Enabled" rendererParam1="30.000000" rendererParam2="30.000000" rendererType="Quad" sizeParam="Mutable" tank="-1.000000" textureParticleName="Fire" type="ParticleSystem::ParticleEmitter" zoneRadius="7.000000">
<object additive="false" alphaParam="Mutable" angleParam="Random" blueParam="Mutable" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="360.000000" emitterForceMax="0.000000" emitterForceMin="0.000000" emitterXDirection="0.000000" emitterYDirection="1.000000" emitterZDirection="0.000000" flow="150.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Mutable" maxParticleNb="150" name="Smoke" particleAlpha1="160.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="360.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="255.000000" particleBlue2="149.000000" particleEditionSimpleMode="true" particleGravityX="0.000000" particleGravityY="-100.000000" particleGravityZ="0.000000" particleGreen1="250.000000" particleGreen2="144.000000" particleLifeTimeMax="2.500000" particleLifeTimeMin="0.500000" particleRed1="253.000000" particleRed2="135.000000" particleSize1="20.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Mutable" rendererParam1="30.000000" rendererParam2="30.000000" rendererType="Quad" sizeParam="Mutable" tank="-1.000000" textureParticleName="Fire" type="ParticleSystem::ParticleEmitter" zoneRadius="15.000000">
<variables />
<automatisms />
<behaviors />
</object>
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Random" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="180.000000" emitterForceMax="65.000000" emitterForceMin="25.000000" emitterXDirection="0.000000" emitterYDirection="1.000000" emitterZDirection="0.000000" flow="200.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Random" maxParticleNb="5000" name="Particles" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="125.000000" particleBlue2="204.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="250.000000" particleGreen1="125.000000" particleGreen2="204.000000" particleLifeTimeMax="2.500000" particleLifeTimeMin="0.500000" particleRed1="204.000000" particleRed2="255.000000" particleSize1="0.000000" particleSize2="0.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Random" rendererParam1="8.000000" rendererParam2="1.000000" rendererType="Point" sizeParam="Random" tank="-1.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="2.000000">
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Random" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="180.000000" emitterForceMax="65.000000" emitterForceMin="25.000000" emitterXDirection="0.000000" emitterYDirection="1.000000" emitterZDirection="0.000000" flow="200.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Random" maxParticleNb="5000" name="Particles" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="125.000000" particleBlue2="204.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="250.000000" particleGreen1="125.000000" particleGreen2="204.000000" particleLifeTimeMax="2.500000" particleLifeTimeMin="0.500000" particleRed1="204.000000" particleRed2="255.000000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Random" rendererParam1="8.000000" rendererParam2="1.000000" rendererType="Point" sizeParam="Random" tank="-1.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="2.000000">
<variables />
<automatisms />
<behaviors />
</object>
<object additive="false" alphaParam="Mutable" angleParam="Random" blueParam="Random" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="180.000000" emitterForceMax="0.000000" emitterForceMin="0.000000" emitterXDirection="0.000000" emitterYDirection="1.000000" emitterZDirection="0.000000" flow="100.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Random" maxParticleNb="5000" name="Beam" particleAlpha1="250.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="204.000000" particleBlue2="255.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="0.000000" particleGravityZ="500.000000" particleGreen1="127.000000" particleGreen2="230.000000" particleLifeTimeMax="2.000000" particleLifeTimeMin="0.500000" particleRed1="153.000000" particleRed2="180.000000" particleSize1="0.000000" particleSize2="0.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Random" rendererParam1="3.000000" rendererParam2="1.000000" rendererType="Line" sizeParam="Random" tank="-1.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="3.000000">
<object additive="false" alphaParam="Mutable" angleParam="Random" blueParam="Random" destroyWhenNoParticles="false" emissionEditionSimpleMode="false" emitterAngleA="-55.000000" emitterAngleB="-35.000000" emitterForceMax="5.000000" emitterForceMin="0.000000" emitterXDirection="0.000000" emitterYDirection="1.000000" emitterZDirection="0.000000" flow="100.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Random" maxParticleNb="151" name="Beam" particleAlpha1="250.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="204.000000" particleBlue2="255.000000" particleEditionSimpleMode="false" particleGravityX="100.000000" particleGravityY="0.000000" particleGravityZ="500.000000" particleGreen1="127.000000" particleGreen2="230.000000" particleLifeTimeMax="2.000000" particleLifeTimeMin="0.500000" particleRed1="153.000000" particleRed2="180.000000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Random" rendererParam1="100.000000" rendererParam2="3.000000" rendererType="Line" sizeParam="Random" tank="-1.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="20.000000">
<variables />
<automatisms />
<behaviors />
</object>
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Random" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="0.000000" emitterForceMax="65.000000" emitterForceMin="25.000000" emitterXDirection="0.000000" emitterYDirection="0.000000" emitterZDirection="0.000000" flow="300.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Random" maxParticleNb="5000" name="Beam2" particleAlpha1="125.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="255.000000" particleBlue2="204.000000" particleEditionSimpleMode="false" particleGravityX="-500.000000" particleGravityY="0.000000" particleGravityZ="0.000000" particleGreen1="204.000000" particleGreen2="125.000000" particleLifeTimeMax="5.000000" particleLifeTimeMin="0.500000" particleRed1="127.000000" particleRed2="0.500000" particleSize1="0.000000" particleSize2="0.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Enabled" rendererParam1="0.500000" rendererParam2="2.000000" rendererType="Line" sizeParam="Random" tank="-1.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="3.000000">
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Random" destroyWhenNoParticles="false" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="0.000000" emitterForceMax="65.000000" emitterForceMin="25.000000" emitterXDirection="0.000000" emitterYDirection="0.000000" emitterZDirection="0.000000" flow="50.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Random" maxParticleNb="5000" name="Beam2" particleAlpha1="125.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="255.000000" particleBlue2="204.000000" particleEditionSimpleMode="false" particleGravityX="-500.000000" particleGravityY="0.000000" particleGravityZ="0.000000" particleGreen1="204.000000" particleGreen2="125.000000" particleLifeTimeMax="5.000000" particleLifeTimeMin="0.500000" particleRed1="127.000000" particleRed2="0.500000" particleSize1="100.000000" particleSize2="100.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Enabled" rendererParam1="10.000000" rendererParam2="3.000000" rendererType="Line" sizeParam="Random" tank="-1.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="10.000000">
<variables />
<automatisms />
<behaviors />
</object>
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Random" destroyWhenNoParticles="true" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="180.000000" emitterForceMax="100.000000" emitterForceMin="25.000000" emitterXDirection="0.000000" emitterYDirection="0.000000" emitterZDirection="1.000000" flow="400.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Enabled" maxParticleNb="5000" name="Pyro" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="204.000000" particleBlue2="255.000000" particleEditionSimpleMode="false" particleGravityX="0.000000" particleGravityY="-100.000000" particleGravityZ="0.000000" particleGreen1="127.000000" particleGreen2="1.000000" particleLifeTimeMax="1.000000" particleLifeTimeMin="0.500000" particleRed1="127.000000" particleRed2="230.000000" particleSize1="100.000000" particleSize2="1.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Random" rendererParam1="0.060000" rendererParam2="3.000000" rendererType="Line" sizeParam="Mutable" tank="600.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="7.000000">
<object additive="true" alphaParam="Mutable" angleParam="Random" blueParam="Random" destroyWhenNoParticles="true" emissionEditionSimpleMode="true" emitterAngleA="0.000000" emitterAngleB="360.000000" emitterForceMax="100.000000" emitterForceMin="25.000000" emitterXDirection="0.000000" emitterYDirection="0.000000" emitterZDirection="1.000000" flow="70.000000" friction="2.000000" gravityEditionSimpleMode="true" greenParam="Enabled" maxParticleNb="151" name="Pyro" particleAlpha1="204.000000" particleAlpha2="0.000000" particleAlphaRandomness1="0.000000" particleAlphaRandomness2="0.000000" particleAngle1="0.000000" particleAngle2="0.000000" particleAngleRandomness1="0.000000" particleAngleRandomness2="0.000000" particleBlue1="204.000000" particleBlue2="255.000000" particleEditionSimpleMode="false" particleGravityX="-0.000080" particleGravityY="-200.000000" particleGravityZ="0.000000" particleGreen1="127.000000" particleGreen2="1.000000" particleLifeTimeMax="1.000000" particleLifeTimeMin="0.500000" particleRed1="127.000000" particleRed2="230.000000" particleSize1="100.000000" particleSize2="1.000000" particleSizeRandomness1="0.000000" particleSizeRandomness2="0.000000" redParam="Random" rendererParam1="8.000000" rendererParam2="8.000000" rendererType="Line" sizeParam="Mutable" tank="80.000000" textureParticleName="" type="ParticleSystem::ParticleEmitter" zoneRadius="25.000000">
<variables />
<automatisms />
<behaviors />
</object>
</objects>
<events>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::Standard</type>
<conditions>
<condition>
<instruction>
<type inverted="false" value="Timer" />
<parameters>
<parameter></parameter>
<parameter>Random(0.3)+1</parameter>
<parameter>1</parameter>
<parameter>&quot;Creating&quot;</parameter>
</parameters>
<subConditions />
</condition>
<subInstructions />
</instruction>
</conditions>
<actions>
<action>
<instruction>
<type inverted="false" value="Create" />
<parameters>
<parameter></parameter>
@@ -148,16 +151,16 @@
<parameter>100+Random(300)</parameter>
<parameter></parameter>
</parameters>
<subActions />
</action>
<action>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="ResetTimer" />
<parameters>
<parameter></parameter>
<parameter>&quot;Creating&quot;</parameter>
</parameters>
<subActions />
</action>
<subInstructions />
</instruction>
</actions>
<events />
</event>
@@ -167,9 +170,10 @@
<cameras>
<camera defaultSize="true" defaultViewport="true" height="0.000000" viewportBottom="1.000000" viewportLeft="0.000000" viewportRight="1.000000" viewportTop="0.000000" width="0.000000" />
</cameras>
<effects />
</layer>
</layers>
<automatismsSharedData />
<behaviorsSharedData />
</layout>
</layouts>
<externalEvents />

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"SubTexture":[{"frameY":0,"y":234,"frameWidth":112,"frameX":0,"frameHeight":210,"width":111,"height":209,"name":"parts/tailTip","x":456},{"width":112,"y":234,"height":86,"name":"parts/armUpperL","x":340},{"width":48,"y":859,"height":80,"name":"parts/armL","x":373},{"width":96,"y":922,"height":78,"name":"parts/handL","x":1},{"frameY":0,"y":677,"frameWidth":204,"frameX":0,"frameHeight":180,"width":203,"height":180,"name":"parts/legL","x":238},{"frameY":0,"y":397,"frameWidth":236,"frameX":0,"frameHeight":348,"width":235,"height":347,"name":"parts/body","x":1},{"width":216,"y":397,"height":278,"name":"parts/tail","x":238},{"width":208,"y":746,"height":174,"name":"parts/clothes1","x":1},{"width":124,"y":677,"height":282,"name":"parts/hair","x":443},{"frameY":0,"y":1,"frameWidth":338,"frameX":0,"frameHeight":394,"width":337,"height":394,"name":"parts/head","x":1},{"width":28,"y":961,"height":46,"name":"parts/eyeL","x":459},{"frameY":0,"y":961,"frameWidth":38,"frameX":0,"frameHeight":58,"width":37,"height":58,"name":"parts/eyeR","x":420},{"frameY":0,"y":1,"frameWidth":180,"frameX":0,"frameHeight":232,"width":180,"height":231,"name":"parts/legR","x":340},{"width":160,"y":859,"height":94,"name":"parts/armUpperR","x":211},{"frameY":0,"y":941,"frameWidth":46,"frameX":0,"frameHeight":78,"width":45,"height":77,"name":"parts/armR","x":373},{"width":98,"y":322,"height":58,"name":"parts/handR","x":340},{"frameY":0,"y":955,"frameWidth":120,"frameX":0,"frameHeight":36,"width":119,"height":36,"name":"parts/beardL","x":237},{"width":136,"y":955,"height":36,"name":"parts/beardR","x":99}],"width":1024,"height":1024,"name":"dragon","imagePath":"dragon_tex.png"}

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -11,7 +11,7 @@ IF NOT EXIST "%INNOSETUP_EXE%" set INNOSETUP_EXE=C:\Program Files\Inno Setup 5\I
IF EXIST "%INNOSETUP_EXE%" (
echo "Note: InnoSetup found at %INNOSETUP_EXE%"
) ELSE (
echo Warning: InnoSetup not found! Skipping installer creation.
echo Warning: InnoSetup Unicode not found! Skipping installer creation.
SET SKIPINSTALLER=1
)

View File

@@ -2,7 +2,9 @@
Version=1.0
Name=GDevelop
GenericName=Game creator IDE
GenericName[de]=Entwicklungsumgebung für Spiele
Comment=HTML5 and native game development software
Comment[de]=Entwicklungsumgebung für native und HTML5-Spiele
Exec=sh -c "gdevelop %F"
MimeType=application/x-gdevelop-project;
Icon=GDevelop

View File

@@ -13,17 +13,17 @@ AllowNoIcons=yes
LicenseFile=..\Output\Release_Windows\License-en.rtf
InfoBeforeFile=..\Output\Release_Windows\Informations-en.rtf
OutputDir=.\
OutputBaseFilename=gd4096
OutputBaseFilename=gd4097
Compression=lzma
SolidCompression=yes
SetupIconFile=..\Output\Release_Windows\res\icon.ico
VersionInfoVersion=4.0
WizardImageFile=Setup bitmap\wizbmp.bmp
WizardSmallImageFile=Setup bitmap/smallicon.bmp
AppCopyright=2008-2017 Florian Rival
AppCopyright=2008-2018 Florian Rival
VersionInfoCompany=Florian Rival
VersionInfoDescription=GDevelop setup
VersionInfoCopyright=2008-2016 Florian Rival
VersionInfoCopyright=2008-2018 Florian Rival
VersionInfoProductName=GDevelop
VersionInfoProductVersion=4.0

View File

@@ -4,6 +4,9 @@
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0011 NEW)
# Add utility functions
include(scripts/CMakeClangUtils.txt) # To add clang-format and clang-tidy support to a target
# Macro for defining an option
macro(gd_set_option var default type docstring)
if(NOT DEFINED ${var})

View File

@@ -72,6 +72,10 @@ IF(NO_GUI)
list(REMOVE_ITEM source_files "${CMAKE_CURRENT_SOURCE_DIR}/GDCore/IDE/Dialogs/GDCoreDialogs.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/GDCore/IDE/Dialogs/GDCoreDialogs.h" "${CMAKE_CURRENT_SOURCE_DIR}/GDCore/IDE/Dialogs/GDCoreDialogs_dialogs_bitmaps.cpp")
ENDIF()
file(GLOB_RECURSE formatted_source_files tests/* GDCore/Events/* GDCore/Extensions/* GDCore/IDE/* GDCore/Project/* GDCore/Serialization/* GDCore/Tools/*)
list(REMOVE_ITEM formatted_source_files "${CMAKE_CURRENT_SOURCE_DIR}/GDCore/IDE/Dialogs/GDCoreDialogs.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/GDCore/IDE/Dialogs/GDCoreDialogs.h" "${CMAKE_CURRENT_SOURCE_DIR}/GDCore/IDE/Dialogs/GDCoreDialogs_dialogs_bitmaps.cpp")
gd_add_clang_utils(GDCore "${formatted_source_files}")
add_library(GDCore SHARED ${source_files})
add_dependencies(GDCore GDVersion)
IF(EMSCRIPTEN)

View File

@@ -78,6 +78,7 @@
* The installation is fairly simple :<br>
* <br>
* - Launch the installer.<br>
* - Uncheck "Check for updated files on the TDM-GCC server" (otherwise you won't get TDM-GCC 4.9.2 but a more recent version that won't be compatible with wxWidgets pre-compiled binaries)
* - Choose Create.<br>
\image html compilerInstall1.png

View File

@@ -1,152 +1,189 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if !defined(GD_NO_WX_GUI)
#include <wx/dcmemory.h>
#endif
#include "CommentEvent.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/CommonTools.h"
#include "GDCore/IDE/Dialogs/EditComment.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorItemsAreas.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorSelection.h"
#include "GDCore/CommonTools.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/Serialization/SerializerElement.h"
using namespace std;
namespace gd
{
namespace gd {
void CommentEvent::SerializeTo(SerializerElement & element) const
{
element.AddChild("color")
.SetAttribute("r", r)
.SetAttribute("g", v)
.SetAttribute("b", b)
.SetAttribute("textR", textR)
.SetAttribute("textG", textG)
.SetAttribute("textB", textB);
void CommentEvent::SerializeTo(SerializerElement &element) const {
element.AddChild("color")
.SetAttribute("r", r)
.SetAttribute("g", v)
.SetAttribute("b", b)
.SetAttribute("textR", textR)
.SetAttribute("textG", textG)
.SetAttribute("textB", textB);
element.AddChild("comment").SetValue(com1);
element.AddChild("comment2").SetValue(com2);
element.AddChild("comment").SetValue(com1);
element.AddChild("comment2").SetValue(com2);
}
void CommentEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
const SerializerElement & colorElement = element.GetChild("color", 0, "Couleur");
r = colorElement.GetIntAttribute("r");
v = colorElement.GetIntAttribute("g", 0, "v");
b = colorElement.GetIntAttribute("b");
textR = colorElement.GetIntAttribute("textR");
textG = colorElement.GetIntAttribute("textG");
textB = colorElement.GetIntAttribute("textB");
void CommentEvent::UnserializeFrom(gd::Project &project,
const SerializerElement &element) {
const SerializerElement &colorElement =
element.GetChild("color", 0, "Couleur");
r = colorElement.GetIntAttribute("r");
v = colorElement.GetIntAttribute("g", 0, "v");
b = colorElement.GetIntAttribute("b");
textR = colorElement.GetIntAttribute("textR");
textG = colorElement.GetIntAttribute("textG");
textB = colorElement.GetIntAttribute("textB");
com1 = element.GetChild("comment", 0, "Com1").GetValue().GetString();
com2 = element.GetChild("comment2", 0, "Com2").GetValue().GetString();
com1 = element.GetChild("comment", 0, "Com1").GetValue().GetString();
com2 = element.GetChild("comment2", 0, "Com2").GetValue().GetString();
}
gd::BaseEvent::EditEventReturnType CommentEvent::EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_)
{
gd::BaseEvent::EditEventReturnType CommentEvent::EditEvent(
wxWindow *parent_,
gd::Project &game_,
gd::Layout &scene_,
gd::MainFrameWrapper &mainFrameWrapper_) {
#if !defined(GD_NO_WX_GUI)
EditComment dialog(parent_, *this);
if ( dialog.ShowModal() == 0) return Cancelled;
EditComment dialog(parent_, *this);
if (dialog.ShowModal() == 0) return Cancelled;
#endif
return ChangesMadeButNoNeedForEventsRecompilation;
return ChangesMadeButNoNeedForEventsRecompilation;
}
/**
* Render the event
*/
void CommentEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform &)
{
void CommentEvent::Render(wxDC &dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas &areas,
gd::EventsEditorSelection &selection,
const gd::Platform &) {
#if !defined(GD_NO_WX_GUI)
x += 1; //Small border
x += 1; // Small border
gd::EventsRenderingHelper *renderingHelper = gd::EventsRenderingHelper::Get();
renderingHelper->GetHTMLRenderer().SetDC(&dc);
renderingHelper->GetHTMLRenderer().SetStandardFonts(
renderingHelper->GetNiceFont().GetPointSize());
// Prepare HTML texts
gd::String str1 =
"<FONT color=" +
wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX) + ">" +
renderingHelper->GetHTMLText(com1) + "</FONT>";
gd::String str2 =
"<FONT color=" +
wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX) + ">" +
renderingHelper->GetHTMLText(com2) + "</FONT>";
// Calculate space constraints
const int sideSeparation = 3; // Spacing between text and borders
unsigned int textWidth = com2.empty() ? width - sideSeparation * 2
: width / 2 - sideSeparation * 2;
renderingHelper->GetHTMLRenderer().SetSize(textWidth, 9999);
renderingHelper->GetHTMLRenderer().SetHtmlText(str1);
unsigned int text1Height =
renderingHelper->GetHTMLRenderer().GetTotalHeight();
renderingHelper->GetHTMLRenderer().SetHtmlText(str2);
unsigned int text2Height =
renderingHelper->GetHTMLRenderer().GetTotalHeight();
// Prepare background
dc.SetBrush(wxBrush(wxColour(r, v, b), wxBRUSHSTYLE_TRANSPARENT));
dc.SetPen(wxPen(wxColour(r / 2, v / 2, b / 2), 1));
// Draw the background
unsigned int height = std::max(text1Height, text2Height) + sideSeparation * 2;
height = std::max(height, (unsigned int)15);
wxRect rectangle(x, y, width - 2, height);
dc.GradientFillLinear(rectangle,
wxColour(r + 20 > 255 ? 255 : r + 20,
v + 20 > 255 ? 255 : v + 20,
b + 20 > 255 ? 255 : b + 20),
wxColour(r, v, b),
wxSOUTH);
dc.DrawRectangle(rectangle);
// Draw text
{
renderingHelper->GetHTMLRenderer().SetHtmlText(str1);
wxArrayInt neededArray;
renderingHelper->GetHTMLRenderer().Render(
x + sideSeparation, y + sideSeparation, neededArray);
}
if (!com2.empty()) // Optional text
{
renderingHelper->GetHTMLRenderer().SetHtmlText(str2);
wxArrayInt neededArray;
renderingHelper->GetHTMLRenderer().Render(
x + sideSeparation + textWidth + sideSeparation,
y + sideSeparation,
neededArray);
}
#endif
}
unsigned int CommentEvent::GetRenderedHeight(unsigned int width,
const gd::Platform &) const {
#if !defined(GD_NO_WX_GUI)
if (eventHeightNeedUpdate) {
gd::EventsRenderingHelper *renderingHelper =
gd::EventsRenderingHelper::Get();
wxMemoryDC dc;
wxBitmap fakeBmp(1, 1);
dc.SelectObject(fakeBmp);
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
renderingHelper->GetHTMLRenderer().SetDC(&dc);
renderingHelper->GetHTMLRenderer().SetStandardFonts(renderingHelper->GetNiceFont().GetPointSize());
renderingHelper->GetHTMLRenderer().SetStandardFonts(
renderingHelper->GetNiceFont().GetPointSize());
//Prepare HTML texts
gd::String str1 = "<FONT color="+wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX)+">"+renderingHelper->GetHTMLText(com1)+"</FONT>";
gd::String str2 = "<FONT color="+wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX)+">"+renderingHelper->GetHTMLText(com2)+"</FONT>";
gd::String str1 =
"<FONT color=" +
wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX) + ">" +
renderingHelper->GetHTMLText(com1) + "</FONT>";
gd::String str2 =
"<FONT color=" +
wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX) + ">" +
renderingHelper->GetHTMLText(com2) + "</FONT>";
//Calculate space constraints
const int sideSeparation = 3; //Spacing between text and borders
// Calculate space constraints
const int sideSeparation = 3; // Spacing between text and borders
unsigned int textWidth = com2.empty() ? width-sideSeparation*2 : width/2-sideSeparation*2;
unsigned int textWidth = com2.empty() ? width - sideSeparation * 2
: width / 2 - sideSeparation * 2;
renderingHelper->GetHTMLRenderer().SetSize(textWidth, 9999);
renderingHelper->GetHTMLRenderer().SetHtmlText(str1);
unsigned int text1Height = renderingHelper->GetHTMLRenderer().GetTotalHeight();
unsigned int text1Height =
renderingHelper->GetHTMLRenderer().GetTotalHeight();
renderingHelper->GetHTMLRenderer().SetHtmlText(str2);
unsigned int text2Height = renderingHelper->GetHTMLRenderer().GetTotalHeight();
unsigned int text2Height =
renderingHelper->GetHTMLRenderer().GetTotalHeight();
//Prepare background
dc.SetBrush(wxBrush(wxColour(r, v, b), wxBRUSHSTYLE_TRANSPARENT));
dc.SetPen(wxPen(wxColour(r/2, v/2, b/2), 1));
//Draw the background
unsigned int height = std::max(text1Height, text2Height)+sideSeparation*2;
unsigned int height =
std::max(text1Height, text2Height) + sideSeparation * 2;
height = std::max(height, (unsigned int)15);
wxRect rectangle(x, y, width-2, height);
dc.GradientFillLinear(rectangle, wxColour(r+20 > 255 ? 255 : r+20, v+20 > 255 ? 255 : v+20, b+20 > 255 ? 255 : b+20), wxColour(r, v, b), wxSOUTH);
dc.DrawRectangle(rectangle);
//Draw text
{
renderingHelper->GetHTMLRenderer().SetHtmlText(str1);
wxArrayInt neededArray;
renderingHelper->GetHTMLRenderer().Render(x + sideSeparation, y+sideSeparation, neededArray);
}
if ( !com2.empty() ) //Optional text
{
renderingHelper->GetHTMLRenderer().SetHtmlText(str2);
wxArrayInt neededArray;
renderingHelper->GetHTMLRenderer().Render(x + sideSeparation + textWidth + sideSeparation, y+sideSeparation, neededArray);
}
renderedHeight = height;
}
#endif
return renderedHeight + 2; // 2 : 2 small borders
}
unsigned int CommentEvent::GetRenderedHeight(unsigned int width, const gd::Platform &) const
{
#if !defined(GD_NO_WX_GUI)
if ( eventHeightNeedUpdate )
{
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
wxMemoryDC dc;
wxBitmap fakeBmp(1,1);
dc.SelectObject(fakeBmp);
renderingHelper->GetHTMLRenderer().SetDC(&dc);
renderingHelper->GetHTMLRenderer().SetStandardFonts(renderingHelper->GetNiceFont().GetPointSize());
gd::String str1 = "<FONT color="+wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX)+">"+renderingHelper->GetHTMLText(com1)+"</FONT>";
gd::String str2 = "<FONT color="+wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX)+">"+renderingHelper->GetHTMLText(com2)+"</FONT>";
//Calculate space constraints
const int sideSeparation = 3; //Spacing between text and borders
unsigned int textWidth = com2.empty() ? width-sideSeparation*2 : width/2-sideSeparation*2;
renderingHelper->GetHTMLRenderer().SetSize(textWidth, 9999);
renderingHelper->GetHTMLRenderer().SetHtmlText(str1);
unsigned int text1Height = renderingHelper->GetHTMLRenderer().GetTotalHeight();
renderingHelper->GetHTMLRenderer().SetHtmlText(str2);
unsigned int text2Height = renderingHelper->GetHTMLRenderer().GetTotalHeight();
unsigned int height = std::max(text1Height, text2Height)+sideSeparation*2;
height = std::max(height, (unsigned int)15);
renderedHeight = height;
}
#endif
return renderedHeight+2;//2 : 2 small borders
}
}
} // namespace gd

View File

@@ -1,74 +1,105 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef COMMENTEVENT_H
#define COMMENTEVENT_H
#include "GDCore/Events/Event.h"
class TiXmlElement;
namespace gd { class Layout; }
namespace gd { class Project; }
namespace gd { class MainFrameWrapper; }
namespace gd { class Project; }
namespace gd {
class Layout;
}
namespace gd {
class Project;
}
namespace gd {
class MainFrameWrapper;
}
namespace gd {
class Project;
}
class wxWindow;
namespace gd { class EventsEditorItemsAreas; }
namespace gd { class EventsEditorSelection; }
namespace gd {
class EventsEditorItemsAreas;
}
namespace gd {
class EventsEditorSelection;
}
namespace gd
{
namespace gd {
/**
* \brief Allows to add a text in the events editor.
*/
class GD_CORE_API CommentEvent : public gd::BaseEvent
{
public:
CommentEvent() : BaseEvent(), r(255), v(230), b(109), textR(0), textG(0), textB(0) {};
virtual ~CommentEvent() {};
virtual gd::CommentEvent * Clone() const { return new CommentEvent(*this);}
class GD_CORE_API CommentEvent : public gd::BaseEvent {
public:
CommentEvent()
: BaseEvent(), r(255), v(230), b(109), textR(0), textG(0), textB(0){};
virtual ~CommentEvent(){};
virtual gd::CommentEvent* Clone() const { return new CommentEvent(*this); }
int GetBackgroundColorRed() const { return r; }
int GetBackgroundColorGreen() const { return v; }
int GetBackgroundColorBlue() const { return b; }
void SetBackgroundColor(int r_, int g_, int b_) { r = r_; v = g_; b = b_; }
int GetBackgroundColorRed() const { return r; }
int GetBackgroundColorGreen() const { return v; }
int GetBackgroundColorBlue() const { return b; }
void SetBackgroundColor(int r_, int g_, int b_) {
r = r_;
v = g_;
b = b_;
}
int GetTextColorRed() const { return textR; }
int GetTextColorGreen() const { return textG; }
int GetTextColorBlue() const { return textB; }
void SetTextColor(int r_, int g_, int b_) { textR = r_; textG = g_; textB = b_; }
int GetTextColorRed() const { return textR; }
int GetTextColorGreen() const { return textG; }
int GetTextColorBlue() const { return textB; }
void SetTextColor(int r_, int g_, int b_) {
textR = r_;
textG = g_;
textB = b_;
}
const gd::String & GetComment() const { return com1; }
void SetComment(const gd::String & comment) { com1 = comment; }
const gd::String& GetComment() const { return com1; }
void SetComment(const gd::String& comment) { com1 = comment; }
virtual void SerializeTo(SerializerElement & element) const;
virtual void UnserializeFrom(gd::Project & project, const SerializerElement & element);
virtual void SerializeTo(SerializerElement& element) const;
virtual void UnserializeFrom(gd::Project& project,
const SerializerElement& element);
int r; ///< Background color Red component
int v; ///< Background color Green component
int b; ///< Background color Blue component
int r; ///< Background color Red component
int v; ///< Background color Green component
int b; ///< Background color Blue component
int textR; ///< Text color Red component
int textG; ///< Text color Green component
int textB; ///< Text color Blue component
int textR; ///< Text color Red component
int textG; ///< Text color Green component
int textB; ///< Text color Blue component
gd::String com1; ///< Comment
gd::String com2; ///< Optional second column comment, deprecated
gd::String com1; ///< Comment
gd::String com2; ///< Optional second column comment, deprecated
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & );
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform&);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & ) const;
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width,
const gd::Platform&) const;
virtual EditEventReturnType EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_);
virtual EditEventReturnType EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_);
};
}
} // namespace gd
#endif // COMMENTEVENT_H
#endif // COMMENTEVENT_H

View File

@@ -1,167 +1,198 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "ForEachEvent.h"
#include <iostream>
#include "GDCore/TinyXml/tinyxml.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorItemsAreas.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorSelection.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/CodeGeneration/ExpressionsCodeGeneration.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/IDE/Dialogs/EditForEachEvent.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorItemsAreas.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorSelection.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/TinyXml/tinyxml.h"
using namespace std;
namespace gd
{
namespace gd {
ForEachEvent::ForEachEvent() :
BaseEvent(),
objectsToPick(""),
objectsToPickSelected(false)
{
ForEachEvent::ForEachEvent()
: BaseEvent(), objectsToPick(""), objectsToPickSelected(false) {}
vector<gd::InstructionsList*> ForEachEvent::GetAllConditionsVectors() {
vector<gd::InstructionsList*> allConditions;
allConditions.push_back(&conditions);
return allConditions;
}
vector < gd::InstructionsList* > ForEachEvent::GetAllConditionsVectors()
{
vector < gd::InstructionsList* > allConditions;
allConditions.push_back(&conditions);
vector<gd::InstructionsList*> ForEachEvent::GetAllActionsVectors() {
vector<gd::InstructionsList*> allActions;
allActions.push_back(&actions);
return allConditions;
return allActions;
}
vector < gd::InstructionsList* > ForEachEvent::GetAllActionsVectors()
{
vector < gd::InstructionsList* > allActions;
allActions.push_back(&actions);
vector<gd::Expression*> ForEachEvent::GetAllExpressions() {
vector<gd::Expression*> allExpressions;
allExpressions.push_back(&objectsToPick);
return allActions;
return allExpressions;
}
vector<const gd::InstructionsList*> ForEachEvent::GetAllConditionsVectors()
const {
vector<const gd::InstructionsList*> allConditions;
allConditions.push_back(&conditions);
return allConditions;
}
vector < gd::Expression* > ForEachEvent::GetAllExpressions()
{
vector < gd::Expression* > allExpressions;
allExpressions.push_back(&objectsToPick);
vector<const gd::InstructionsList*> ForEachEvent::GetAllActionsVectors() const {
vector<const gd::InstructionsList*> allActions;
allActions.push_back(&actions);
return allExpressions;
}
vector < const gd::InstructionsList* > ForEachEvent::GetAllConditionsVectors() const
{
vector < const gd::InstructionsList* > allConditions;
allConditions.push_back(&conditions);
return allConditions;
return allActions;
}
vector < const gd::InstructionsList* > ForEachEvent::GetAllActionsVectors() const
{
vector < const gd::InstructionsList* > allActions;
allActions.push_back(&actions);
vector<const gd::Expression*> ForEachEvent::GetAllExpressions() const {
vector<const gd::Expression*> allExpressions;
allExpressions.push_back(&objectsToPick);
return allActions;
return allExpressions;
}
vector < const gd::Expression* > ForEachEvent::GetAllExpressions() const
{
vector < const gd::Expression* > allExpressions;
allExpressions.push_back(&objectsToPick);
return allExpressions;
void ForEachEvent::SerializeTo(SerializerElement& element) const {
element.AddChild("object").SetValue(objectsToPick.GetPlainString());
gd::EventsListSerialization::SerializeInstructionsTo(
conditions, element.AddChild("conditions"));
gd::EventsListSerialization::SerializeInstructionsTo(
actions, element.AddChild("actions"));
gd::EventsListSerialization::SerializeEventsTo(events,
element.AddChild("events"));
}
void ForEachEvent::SerializeTo(SerializerElement & element) const
{
element.AddChild("object").SetValue(objectsToPick.GetPlainString());
gd::EventsListSerialization::SerializeInstructionsTo(conditions, element.AddChild("conditions"));
gd::EventsListSerialization::SerializeInstructionsTo(actions, element.AddChild("actions"));
gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));
}
void ForEachEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
objectsToPick = gd::Expression(element.GetChild("object", 0, "Object").GetValue().GetString());
gd::EventsListSerialization::UnserializeInstructionsFrom(project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events", 0, "Events"));
void ForEachEvent::UnserializeFrom(gd::Project& project,
const SerializerElement& element) {
objectsToPick = gd::Expression(
element.GetChild("object", 0, "Object").GetValue().GetString());
gd::EventsListSerialization::UnserializeInstructionsFrom(
project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(
project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(
project, events, element.GetChild("events", 0, "Events"));
}
/**
* Render the event in the bitmap
*/
void ForEachEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
void ForEachEvent::Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform) {
#if !defined(GD_NO_WX_GUI)
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
gd::EventsRenderingHelper* renderingHelper = gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int forEachTextHeight = 20;
// Draw header rectangle
wxRect headerRect(x, y, width, forEachTextHeight);
renderingHelper->DrawNiceRectangle(dc, headerRect);
// For Each text
dc.SetFont(renderingHelper->GetNiceFont().Bold());
if (!IsDisabled())
dc.SetTextForeground(wxColour(0, 0, 0));
else
dc.SetTextForeground(wxColour(160, 160, 160));
dc.DrawText(_("For each object") + " " + objectsToPick.GetPlainString() +
_(", repeat :"),
x + 4,
y + 3);
// Draw conditions rectangle
wxRect rect(x,
y + forEachTextHeight,
renderingHelper->GetConditionsColumnWidth() + border,
GetRenderedHeight(width, platform) - forEachTextHeight);
renderingHelper->DrawNiceRectangle(dc, rect);
// Draw actions and conditions
renderingHelper->DrawConditionsList(
conditions,
dc,
x + border,
y + forEachTextHeight + border,
renderingHelper->GetConditionsColumnWidth() - border,
this,
areas,
selection,
platform);
renderingHelper->DrawActionsList(
actions,
dc,
x + renderingHelper->GetConditionsColumnWidth() + border,
y + forEachTextHeight + border,
width - renderingHelper->GetConditionsColumnWidth() - border * 2,
this,
areas,
selection,
platform);
#endif
}
unsigned int ForEachEvent::GetRenderedHeight(
unsigned int width, const gd::Platform& platform) const {
#if !defined(GD_NO_WX_GUI)
if (eventHeightNeedUpdate) {
gd::EventsRenderingHelper* renderingHelper =
gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int forEachTextHeight = 20;
//Draw header rectangle
wxRect headerRect(x, y, width, forEachTextHeight);
renderingHelper->DrawNiceRectangle(dc, headerRect);
// Get maximum height needed
int conditionsHeight = renderingHelper->GetRenderedConditionsListHeight(
conditions,
renderingHelper->GetConditionsColumnWidth() - border,
platform);
int actionsHeight = renderingHelper->GetRenderedActionsListHeight(
actions,
width - renderingHelper->GetConditionsColumnWidth() - border * 2,
platform);
//For Each text
dc.SetFont( renderingHelper->GetNiceFont().Bold() );
if ( !IsDisabled() )
dc.SetTextForeground( wxColour( 0, 0, 0 ) );
else
dc.SetTextForeground( wxColour( 160, 160, 160 ) );
dc.DrawText( _("For each object") + " " + objectsToPick.GetPlainString() + _(", repeat :"), x + 4, y + 3 );
renderedHeight =
((conditionsHeight > actionsHeight ? conditionsHeight : actionsHeight) +
forEachTextHeight) +
border * 2;
eventHeightNeedUpdate = false;
}
//Draw conditions rectangle
wxRect rect(x, y+forEachTextHeight, renderingHelper->GetConditionsColumnWidth()+border, GetRenderedHeight(width, platform)-forEachTextHeight);
renderingHelper->DrawNiceRectangle(dc, rect);
//Draw actions and conditions
renderingHelper->DrawConditionsList(conditions, dc,
x+border,
y+forEachTextHeight+border,
renderingHelper->GetConditionsColumnWidth()-border, this, areas, selection, platform);
renderingHelper->DrawActionsList(actions, dc,
x+renderingHelper->GetConditionsColumnWidth()+border,
y+forEachTextHeight+border,
width-renderingHelper->GetConditionsColumnWidth()-border*2, this, areas, selection, platform);
#endif
}
unsigned int ForEachEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const
{
#if !defined(GD_NO_WX_GUI)
if ( eventHeightNeedUpdate )
{
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int forEachTextHeight = 20;
//Get maximum height needed
int conditionsHeight = renderingHelper->GetRenderedConditionsListHeight(conditions, renderingHelper->GetConditionsColumnWidth()-border, platform);
int actionsHeight = renderingHelper->GetRenderedActionsListHeight(actions, width-renderingHelper->GetConditionsColumnWidth()-border*2, platform);
renderedHeight = (( conditionsHeight > actionsHeight ? conditionsHeight : actionsHeight ) + forEachTextHeight)+border*2;
eventHeightNeedUpdate = false;
}
return renderedHeight;
return renderedHeight;
#else
return 0;
return 0;
#endif
}
gd::BaseEvent::EditEventReturnType ForEachEvent::EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_)
{
gd::BaseEvent::EditEventReturnType ForEachEvent::EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_) {
#if !defined(GD_NO_WX_GUI)
EditForEachEvent dialog(parent_, *this, game_, scene_);
if ( dialog.ShowModal() == 0 ) return Cancelled;
EditForEachEvent dialog(parent_, *this, game_, scene_);
if (dialog.ShowModal() == 0) return Cancelled;
#endif
return ChangesMade;
return ChangesMade;
}
}
} // namespace gd

View File

@@ -1,7 +1,7 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef FOREACHEVENT_H
@@ -9,79 +9,107 @@
#include "GDCore/Events/Event.h"
#include "GDCore/Events/EventsList.h"
class RuntimeScene;
namespace gd { class Instruction; }
namespace gd { class Project; }
namespace gd { class MainFrameWrapper; }
namespace gd {
class Instruction;
}
namespace gd {
class Project;
}
namespace gd {
class MainFrameWrapper;
}
class TiXmlElement;
namespace gd { class EventsEditorItemsAreas; }
namespace gd { class EventsEditorSelection; }
namespace gd { class Layout; }
namespace gd {
class EventsEditorItemsAreas;
}
namespace gd {
class EventsEditorSelection;
}
namespace gd {
class Layout;
}
class wxWindow;
namespace gd
{
namespace gd {
/**
* \brief Event repeated for each object of a list.
*
* Each time the event is repeated, only the specific object of the list is picked.
* Each time the event is repeated, only the specific object of the list is
* picked.
*/
class GD_CORE_API ForEachEvent : public gd::BaseEvent
{
public:
ForEachEvent();
virtual ~ForEachEvent() {};
virtual gd::ForEachEvent * Clone() const { return new ForEachEvent(*this);}
class GD_CORE_API ForEachEvent : public gd::BaseEvent {
public:
ForEachEvent();
virtual ~ForEachEvent(){};
virtual gd::ForEachEvent* Clone() const { return new ForEachEvent(*this); }
virtual bool IsExecutable() const {return true;}
virtual bool IsExecutable() const { return true; }
virtual bool CanHaveSubEvents() const {return true;}
virtual const gd::EventsList & GetSubEvents() const {return events;};
virtual gd::EventsList & GetSubEvents() {return events;};
virtual bool CanHaveSubEvents() const { return true; }
virtual const gd::EventsList& GetSubEvents() const { return events; };
virtual gd::EventsList& GetSubEvents() { return events; };
const gd::InstructionsList & GetConditions() const { return conditions; };
gd::InstructionsList & GetConditions() { return conditions; };
const gd::InstructionsList& GetConditions() const { return conditions; };
gd::InstructionsList& GetConditions() { return conditions; };
const gd::InstructionsList & GetActions() const { return actions; };
gd::InstructionsList & GetActions() { return actions; };
const gd::InstructionsList& GetActions() const { return actions; };
gd::InstructionsList& GetActions() { return actions; };
const gd::String & GetObjectToPick() const { return objectsToPick.GetPlainString(); };
void SetObjectToPick(gd::String objectsToPick_) { objectsToPick = gd::Expression(objectsToPick_); };
const gd::String& GetObjectToPick() const {
return objectsToPick.GetPlainString();
};
void SetObjectToPick(gd::String objectsToPick_) {
objectsToPick = gd::Expression(objectsToPick_);
};
virtual std::vector < const gd::InstructionsList* > GetAllConditionsVectors() const;
virtual std::vector < const gd::InstructionsList* > GetAllActionsVectors() const;
virtual std::vector < const gd::Expression* > GetAllExpressions() const;
virtual std::vector < gd::InstructionsList* > GetAllConditionsVectors();
virtual std::vector < gd::InstructionsList* > GetAllActionsVectors();
virtual std::vector < gd::Expression* > GetAllExpressions();
virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
const;
virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
virtual std::vector<const gd::Expression*> GetAllExpressions() const;
virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
virtual std::vector<gd::Expression*> GetAllExpressions();
virtual void SerializeTo(SerializerElement & element) const;
virtual void UnserializeFrom(gd::Project & project, const SerializerElement & element);
virtual void SerializeTo(SerializerElement& element) const;
virtual void UnserializeFrom(gd::Project& project,
const SerializerElement& element);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & platform) const;
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const;
/**
* Called when the user want to edit the event
*/
virtual EditEventReturnType EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_);
/**
* Called when the user want to edit the event
*/
virtual EditEventReturnType EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_);
private:
gd::Expression objectsToPick;
gd::InstructionsList conditions;
gd::InstructionsList actions;
gd::EventsList events;
private:
gd::Expression objectsToPick;
gd::InstructionsList conditions;
gd::InstructionsList actions;
gd::EventsList events;
bool objectsToPickSelected;
bool objectsToPickSelected;
};
}
} // namespace gd
#endif // FOREACHEVENT_H
#endif // FOREACHEVENT_H

View File

@@ -1,7 +1,7 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GroupEvent.h"
@@ -10,155 +10,154 @@
#include <wx/renderer.h>
#include "GDCore/IDE/Dialogs/MainFrameWrapper.h"
#endif
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/IDE/Dialogs/EventStoreDialog.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorItemsAreas.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorSelection.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/IDE/Dialogs/GroupEventDialog.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/TinyXml/tinyxml.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/IDE/Dialogs/GroupEventDialog.h"
#include "GDCore/IDE/Dialogs/EventStoreDialog.h"
using namespace std;
namespace gd
{
namespace gd {
GroupEvent::GroupEvent() :
BaseEvent(),
creationTime(0),
colorR(74),
colorG(176),
colorB(228)
{
GroupEvent::GroupEvent()
: BaseEvent(), creationTime(0), colorR(74), colorG(176), colorB(228) {}
void GroupEvent::SerializeTo(SerializerElement& element) const {
element.SetAttribute("name", name);
element.SetAttribute("source", source);
element.SetAttribute("creationTime", (int)creationTime);
element.SetAttribute("colorR", (int)colorR);
element.SetAttribute("colorG", (int)colorG);
element.SetAttribute("colorB", (int)colorB);
gd::EventsListSerialization::SerializeEventsTo(events,
element.AddChild("events"));
gd::SerializerElement& parametersElement = element.AddChild("parameters");
parametersElement.ConsiderAsArrayOf("parameter");
for (std::size_t i = 0; i < parameters.size(); ++i)
parametersElement.AddChild("parameter").SetValue(parameters[i]);
}
void GroupEvent::SerializeTo(SerializerElement & element) const
{
element.SetAttribute("name", name);
element.SetAttribute("source", source);
element.SetAttribute("creationTime", (int)creationTime);
element.SetAttribute("colorR", (int)colorR);
element.SetAttribute("colorG", (int)colorG);
element.SetAttribute("colorB", (int)colorB);
gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));
void GroupEvent::UnserializeFrom(gd::Project& project,
const SerializerElement& element) {
name = element.GetStringAttribute("name");
source = element.GetStringAttribute("source");
creationTime = element.GetIntAttribute("creationTime");
colorR = element.GetIntAttribute("colorR");
colorG = element.GetIntAttribute("colorG");
colorB = element.GetIntAttribute("colorB");
gd::EventsListSerialization::UnserializeEventsFrom(
project, events, element.GetChild("events"));
gd::SerializerElement & parametersElement = element.AddChild("parameters");
parametersElement.ConsiderAsArrayOf("parameter");
for ( std::size_t i = 0;i < parameters.size();++i)
parametersElement.AddChild("parameter").SetValue(parameters[i]);
parameters.clear();
gd::SerializerElement& parametersElement = element.GetChild("parameters");
parametersElement.ConsiderAsArrayOf("parameters");
for (std::size_t i = 0; i < parametersElement.GetChildrenCount(); ++i)
parameters.push_back(parametersElement.GetChild(i).GetValue().GetString());
}
void GroupEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
name = element.GetStringAttribute("name");
source = element.GetStringAttribute("source");
creationTime = element.GetIntAttribute("creationTime");
colorR = element.GetIntAttribute("colorR");
colorG = element.GetIntAttribute("colorG");
colorB = element.GetIntAttribute("colorB");
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events"));
parameters.clear();
gd::SerializerElement & parametersElement = element.GetChild("parameters");
parametersElement.ConsiderAsArrayOf("parameters");
for ( std::size_t i = 0;i < parametersElement.GetChildrenCount();++i)
parameters.push_back(parametersElement.GetChild(i).GetValue().GetString());
}
gd::BaseEvent::EditEventReturnType GroupEvent::EditEvent(wxWindow* parent_, gd::Project & project, gd::Layout & scene, gd::MainFrameWrapper & mainFrameWrapper)
{
if (events.IsEmpty())
events.InsertNewEvent(project, "BuiltinCommonInstructions::Standard");
gd::BaseEvent::EditEventReturnType GroupEvent::EditEvent(
wxWindow* parent_,
gd::Project& project,
gd::Layout& scene,
gd::MainFrameWrapper& mainFrameWrapper) {
if (events.IsEmpty())
events.InsertNewEvent(project, "BuiltinCommonInstructions::Standard");
#if !defined(GD_NO_WX_GUI)
if (source.empty())
{
GroupEventDialog dialog(parent_, *this);
dialog.ShowModal();
return ChangesMadeButNoNeedForEventsRecompilation;
if (source.empty()) {
GroupEventDialog dialog(parent_, *this);
dialog.ShowModal();
return ChangesMadeButNoNeedForEventsRecompilation;
} else {
gd::EventStoreDialog dialog(parent_, project, scene);
size_t found = source.rfind("/");
if (found != gd::String::npos && found < source.size() - 1) {
gd::String sourceId = source.substr(found + 1, source.size());
dialog.RefreshWith(sourceId, parameters);
}
else
{
gd::EventStoreDialog dialog(parent_, project, scene);
size_t found = source.rfind("/");
if (found != gd::String::npos && found < source.size()-1) {
gd::String sourceId = source.substr(found+1, source.size());
dialog.RefreshWith(sourceId, parameters);
}
if (dialog.ShowModal() != 1) return Cancelled;
if (dialog.ShowModal() != 1) return Cancelled;
//Insert new events
*this = dialog.GetGroupEvent();
return ChangesMade;
}
// Insert new events
*this = dialog.GetGroupEvent();
return ChangesMade;
}
#else
return Cancelled;
return Cancelled;
#endif
}
void GroupEvent::SetBackgroundColor(unsigned int colorR_, unsigned int colorG_, unsigned int colorB_)
{
colorR = colorR_;
colorG = colorG_;
colorB = colorB_;
void GroupEvent::SetBackgroundColor(unsigned int colorR_,
unsigned int colorG_,
unsigned int colorB_) {
colorR = colorR_;
colorG = colorG_;
colorB = colorB_;
}
/**
* Render the event in the bitmap
*/
void GroupEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
void GroupEvent::Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform) {
#if !defined(GD_NO_WX_GUI)
wxString groupTitle = name.empty() ? _("Untitled group") : wxString(name);
wxColour backgroundColor = wxColour(colorR, colorG, colorB);
wxColour textColor = colorR + colorG + colorB > 200 * 3 ? *wxBLACK : *wxWHITE;
if (IsDisabled()) {
backgroundColor.MakeDisabled();
textColor = wxColour(160, 160, 160);
}
dc.SetBrush(wxBrush(backgroundColor));
dc.SetPen(wxPen(backgroundColor.ChangeLightness(70)));
wxRect rect(x + 1, y, width - 2, GetRenderedHeight(width, platform) - 2);
dc.DrawRectangle(rect);
dc.SetTextBackground(backgroundColor);
dc.SetTextForeground(textColor);
dc.SetFont(
wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
dc.DrawText(groupTitle, x + 5, y + 5);
#endif
}
unsigned int GroupEvent::GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const {
#if !defined(GD_NO_WX_GUI)
if (eventHeightNeedUpdate) {
wxMemoryDC dc;
wxBitmap fakeBmp(1, 1);
dc.SelectObject(fakeBmp);
wxString groupTitle = name.empty() ? _("Untitled group") : wxString(name);
wxColour backgroundColor = wxColour(colorR, colorG, colorB);
wxColour textColor = colorR + colorG + colorB > 200*3 ? *wxBLACK : *wxWHITE;
if (IsDisabled())
{
backgroundColor.MakeDisabled();
textColor = wxColour(160, 160, 160);
}
dc.SetBrush(wxBrush(backgroundColor));
dc.SetPen(wxPen(backgroundColor.ChangeLightness(70)));
wxRect rect(x+1, y, width-2, GetRenderedHeight(width, platform)-2);
dc.DrawRectangle(rect);
dc.SetFont(wxFont(
12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
wxRect text = dc.GetTextExtent(groupTitle);
dc.SetTextBackground(backgroundColor);
dc.SetTextForeground(textColor);
dc.SetFont( wxFont( 12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ) );
dc.DrawText( groupTitle, x+5, y + 5 );
#endif
}
renderedHeight = text.GetHeight() + 10;
eventHeightNeedUpdate = false;
}
unsigned int GroupEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const
{
#if !defined(GD_NO_WX_GUI)
if ( eventHeightNeedUpdate )
{
wxMemoryDC dc;
wxBitmap fakeBmp(1,1);
dc.SelectObject(fakeBmp);
wxString groupTitle = name.empty() ? _("Untitled group") : wxString(name);
dc.SetFont( wxFont( 12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
wxRect text = dc.GetTextExtent(groupTitle);
renderedHeight = text.GetHeight()+10;
eventHeightNeedUpdate = false;
}
return renderedHeight;
return renderedHeight;
#else
return 0;
return 0;
#endif
}
}
} // namespace gd

View File

@@ -1,136 +1,165 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#ifndef GDCORE_GROUPEVENT_H
#define GDCORE_GROUPEVENT_H
#include "GDCore/Events/Event.h"
#include "GDCore/Events/Instruction.h"
#include "GDCore/Events/EventsList.h"
namespace gd { class Instruction; }
namespace gd { class Project; }
#include "GDCore/Events/Instruction.h"
namespace gd {
class Instruction;
}
namespace gd {
class Project;
}
class RuntimeScene;
class TiXmlElement;
class EventsCodeGenerationContext;
namespace gd { class EventsEditorItemsAreas; }
namespace gd { class EventsEditorSelection; }
namespace gd
{
/**
* \brief A group event, containing only sub events and some (visual only) properties.
*/
class GD_CORE_API GroupEvent : public gd::BaseEvent
{
public:
GroupEvent();
virtual ~GroupEvent() {};
virtual gd::GroupEvent * Clone() const { return new GroupEvent(*this);}
virtual bool IsExecutable() const {return true;}
/**
* \brief Get the name of the group.
*/
const gd::String & GetName() const { return name; }
/**
* \brief Change the name of the group.
*/
void SetName(const gd::String & name_) { name = name_; }
/**
* \brief Get the source of the group.
* \note The source is usually an URL from which
* the group and its events was downloaded.
*/
const gd::String & GetSource() const { return source; }
/**
* \brief Set the source of the group.
*/
void SetSource(const gd::String & source_) { source = source_; }
/**
* \brief Get the vector containing the parameters that have been used to
* create the group and its sub events.
* \note These parameters are optional and only used to remember how the
* group was created from an events template for example: if the user wants
* to update the group with a new version of the template, the parameters
* can be displayed again to easy the update.
*/
std::vector<gd::String> & GetCreationParameters() { return parameters; }
const std::vector<gd::String> & GetCreationParameters() const { return parameters; }
/**
* \brief Return the creation timestamp
* \return The timestamp, or 0 if not specified for the group.
*/
unsigned int GetCreationTimestamp() const { return creationTime; }
/**
* \brief Set timestamp of the creation of the group.
* \note This is purely optional and only used for checking for example if
* a new version of the group is available, if it has a source URL.
*/
void SetCreationTimestamp(unsigned int creationTime_) { creationTime = creationTime_; }
/**
* \brief Change the color of the group
*/
void SetBackgroundColor(unsigned int colorR, unsigned int colorG, unsigned int colorB);
/**
* \brief Get background color red component.
*/
unsigned int GetBackgroundColorR() const { return colorR; };
/**
* \brief Get background color green component.
*/
unsigned int GetBackgroundColorG() const { return colorG; };
/**
* \brief Get background color blue component.
*/
unsigned int GetBackgroundColorB() const { return colorB; };
virtual bool CanHaveSubEvents() const {return true;}
virtual const gd::EventsList & GetSubEvents() const {return events;};
virtual gd::EventsList & GetSubEvents() {return events;};
virtual void SerializeTo(SerializerElement & element) const;
virtual void UnserializeFrom(gd::Project & project, const SerializerElement & element);
virtual gd::BaseEvent::EditEventReturnType EditEvent(wxWindow* parent_, gd::Project & project, gd::Layout & scene, gd::MainFrameWrapper & mainFrameWrapper);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & platform) const;
private:
EventsList events;
gd::String name; ///<Optional. A name displayed in the events editor.
gd::String source; ///< Optional. The source can contains the URL from which the group was downloaded.
unsigned int creationTime; ///< Optional. The time when the group was created from an event template.
std::vector<gd::String> parameters; ///< Optional. Can be used to remember the parameters used if the group was created from an events template.
unsigned int colorR;
unsigned int colorG;
unsigned int colorB;
};
namespace gd {
class EventsEditorItemsAreas;
}
namespace gd {
class EventsEditorSelection;
}
#endif // GDCORE_GROUPEVENT_H
namespace gd {
/**
* \brief A group event, containing only sub events and some (visual only)
* properties.
*/
class GD_CORE_API GroupEvent : public gd::BaseEvent {
public:
GroupEvent();
virtual ~GroupEvent(){};
virtual gd::GroupEvent* Clone() const { return new GroupEvent(*this); }
virtual bool IsExecutable() const { return true; }
/**
* \brief Get the name of the group.
*/
const gd::String& GetName() const { return name; }
/**
* \brief Change the name of the group.
*/
void SetName(const gd::String& name_) { name = name_; }
/**
* \brief Get the source of the group.
* \note The source is usually an URL from which
* the group and its events was downloaded.
*/
const gd::String& GetSource() const { return source; }
/**
* \brief Set the source of the group.
*/
void SetSource(const gd::String& source_) { source = source_; }
/**
* \brief Get the vector containing the parameters that have been used to
* create the group and its sub events.
* \note These parameters are optional and only used to remember how the
* group was created from an events template for example: if the user wants
* to update the group with a new version of the template, the parameters
* can be displayed again to easy the update.
*/
std::vector<gd::String>& GetCreationParameters() { return parameters; }
const std::vector<gd::String>& GetCreationParameters() const {
return parameters;
}
/**
* \brief Return the creation timestamp
* \return The timestamp, or 0 if not specified for the group.
*/
unsigned int GetCreationTimestamp() const { return creationTime; }
/**
* \brief Set timestamp of the creation of the group.
* \note This is purely optional and only used for checking for example if
* a new version of the group is available, if it has a source URL.
*/
void SetCreationTimestamp(unsigned int creationTime_) {
creationTime = creationTime_;
}
/**
* \brief Change the color of the group
*/
void SetBackgroundColor(unsigned int colorR,
unsigned int colorG,
unsigned int colorB);
/**
* \brief Get background color red component.
*/
unsigned int GetBackgroundColorR() const { return colorR; };
/**
* \brief Get background color green component.
*/
unsigned int GetBackgroundColorG() const { return colorG; };
/**
* \brief Get background color blue component.
*/
unsigned int GetBackgroundColorB() const { return colorB; };
virtual bool CanHaveSubEvents() const { return true; }
virtual const gd::EventsList& GetSubEvents() const { return events; };
virtual gd::EventsList& GetSubEvents() { return events; };
virtual void SerializeTo(SerializerElement& element) const;
virtual void UnserializeFrom(gd::Project& project,
const SerializerElement& element);
virtual gd::BaseEvent::EditEventReturnType EditEvent(
wxWindow* parent_,
gd::Project& project,
gd::Layout& scene,
gd::MainFrameWrapper& mainFrameWrapper);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const;
private:
EventsList events;
gd::String name; ///< Optional. A name displayed in the events editor.
gd::String source; ///< Optional. The source can contains the URL from which
///< the group was downloaded.
unsigned int creationTime; ///< Optional. The time when the group was created
///< from an event template.
std::vector<gd::String>
parameters; ///< Optional. Can be used to remember the parameters used if
///< the group was created from an events template.
unsigned int colorR;
unsigned int colorG;
unsigned int colorB;
};
} // namespace gd
#endif // GDCORE_GROUPEVENT_H
#endif

View File

@@ -1,246 +1,250 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include <iostream>
#include <fstream>
#include <iostream>
#if !defined(GD_NO_WX_GUI)
#include <wx/dcmemory.h>
#endif
#include "GDCore/IDE/wxTools/SkinHelper.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/Project/Object.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Project/Layout.h"
#include "GDCore/Project/ExternalEvents.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Events/Builtin/GroupEvent.h"
#include "GDCore/Events/Builtin/LinkEvent.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
#include "GDCore/Events/Builtin/LinkEvent.h"
#include "GDCore/Events/Builtin/GroupEvent.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/IDE/Dialogs/LinkEventEditor.h"
#include "GDCore/CommonTools.h"
#include "GDCore/IDE/wxTools/SkinHelper.h"
#include "GDCore/Project/ExternalEvents.h"
#include "GDCore/Project/Layout.h"
#include "GDCore/Project/Object.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Serialization/SerializerElement.h"
using namespace std;
namespace gd
{
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 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();
//If the link only includes an events group, search it inside the layout/external events
if( includeConfig == INCLUDE_EVENTS_GROUP )
{
std::size_t i = 0;
std::size_t eventsCount = events->GetEventsCount();
for( ; i < eventsCount; ++i )
{
std::shared_ptr<const GroupEvent> groupEvent = std::dynamic_pointer_cast<const GroupEvent>(events->GetEventSmartPtr(i));
if(groupEvent && groupEvent->GetName() == eventsGroupName)
{
//Get its sub-events
events = &groupEvent->GetSubEvents();
break;
}
}
if(i >= eventsCount) //We didn't find the events group, return nullptr
events = nullptr;
// If the link only includes an events group, search it inside the
// layout/external events
if (includeConfig == INCLUDE_EVENTS_GROUP) {
std::size_t i = 0;
std::size_t eventsCount = events->GetEventsCount();
for (; i < eventsCount; ++i) {
std::shared_ptr<const GroupEvent> groupEvent =
std::dynamic_pointer_cast<const GroupEvent>(
events->GetEventSmartPtr(i));
if (groupEvent && groupEvent->GetName() == eventsGroupName) {
// Get its sub-events
events = &groupEvent->GetSubEvents();
break;
}
}
return events;
if (i >= eventsCount) // We didn't find the events group, return nullptr
events = nullptr;
}
return events;
}
void LinkEvent::ReplaceLinkByLinkedEvents(const gd::Project & project, EventsList & eventList, std::size_t indexOfTheEventInThisList)
{
linkWasInvalid = false;
//Finding what to link to.
const EventsList * eventsToInclude = GetLinkedEvents(project);
if ( eventsToInclude != NULL )
{
std::size_t firstEvent = includeConfig == INCLUDE_BY_INDEX ? GetIncludeStart() : 0;
std::size_t lastEvent = includeConfig == INCLUDE_BY_INDEX ? GetIncludeEnd() : eventsToInclude->size() - 1;
void LinkEvent::ReplaceLinkByLinkedEvents(
const gd::Project& project,
EventsList& eventList,
std::size_t indexOfTheEventInThisList) {
linkWasInvalid = false;
// Finding what to link to.
const EventsList* eventsToInclude = GetLinkedEvents(project);
if (eventsToInclude != NULL) {
std::size_t firstEvent =
includeConfig == INCLUDE_BY_INDEX ? GetIncludeStart() : 0;
std::size_t lastEvent = includeConfig == INCLUDE_BY_INDEX
? GetIncludeEnd()
: eventsToInclude->size() - 1;
//Check bounds
if ( firstEvent >= eventsToInclude->size() )
{
std::cout << "Unable to get events from a link ( Invalid start )" << std::endl;
linkWasInvalid = true;
return;
}
if ( lastEvent >= eventsToInclude->size() )
{
std::cout << "Unable to get events from a link ( Invalid end )" << std::endl;
linkWasInvalid = true;
return;
}
if ( firstEvent > lastEvent )
{
std::cout << "Unable to get events from a link ( End is before start )" << std::endl;
linkWasInvalid = true;
return;
}
//Insert an empty event to replace the link event ( we'll delete the link event at the end )
//( If we just erase the link event without adding a blank event to replace it,
//the first event inserted by the link will not be preprocessed ( and it can be annoying if it require preprocessing, such as another link event ). )
gd::EmptyEvent emptyEvent;
eventList.InsertEvent(emptyEvent, indexOfTheEventInThisList);
eventList.InsertEvents(*eventsToInclude, firstEvent, lastEvent, indexOfTheEventInThisList+1);
//Delete the link event ( which is now at the end of the list of events we've just inserted )
eventList.RemoveEvent(indexOfTheEventInThisList + 1 + static_cast<unsigned>(lastEvent-firstEvent)+1);
// Check bounds
if (firstEvent >= eventsToInclude->size()) {
std::cout << "Unable to get events from a link ( Invalid start )"
<< std::endl;
linkWasInvalid = true;
return;
}
else
{
std::cout << "Unable to get events from a link." << std::endl;
linkWasInvalid = true;
//Delete the link event
eventList.RemoveEvent(indexOfTheEventInThisList);
return;
if (lastEvent >= eventsToInclude->size()) {
std::cout << "Unable to get events from a link ( Invalid end )"
<< std::endl;
linkWasInvalid = true;
return;
}
if (firstEvent > lastEvent) {
std::cout << "Unable to get events from a link ( End is before start )"
<< std::endl;
linkWasInvalid = true;
return;
}
// Insert an empty event to replace the link event ( we'll delete the link
// event at the end ) ( If we just erase the link event without adding a
// blank event to replace it, the first event inserted by the link will not
// be preprocessed ( and it can be annoying if it require preprocessing,
// such as another link event ). )
gd::EmptyEvent emptyEvent;
eventList.InsertEvent(emptyEvent, indexOfTheEventInThisList);
eventList.InsertEvents(
*eventsToInclude, firstEvent, lastEvent, indexOfTheEventInThisList + 1);
// Delete the link event ( which is now at the end of the list of events
// we've just inserted )
eventList.RemoveEvent(indexOfTheEventInThisList + 1 +
static_cast<unsigned>(lastEvent - firstEvent) + 1);
} else {
std::cout << "Unable to get events from a link." << std::endl;
linkWasInvalid = true;
// Delete the link event
eventList.RemoveEvent(indexOfTheEventInThisList);
return;
}
}
LinkEvent::~LinkEvent()
{
LinkEvent::~LinkEvent() {}
void LinkEvent::SerializeTo(SerializerElement& element) const {
SerializerElement& includeElement = element.AddChild("include").SetAttribute(
"includeConfig", static_cast<int>(GetIncludeConfig()));
if (GetIncludeConfig() == INCLUDE_EVENTS_GROUP) {
includeElement.SetAttribute("eventsGroup", GetEventsGroupName());
} else if (GetIncludeConfig() == INCLUDE_BY_INDEX) {
includeElement.SetAttribute("start", static_cast<int>(GetIncludeStart()));
includeElement.SetAttribute("end", static_cast<int>(GetIncludeEnd()));
}
element.AddChild("target").SetValue(GetTarget());
}
void LinkEvent::SerializeTo(SerializerElement & element) const
{
SerializerElement & includeElement = element.AddChild("include")
.SetAttribute("includeConfig", static_cast<int>(GetIncludeConfig()));
void LinkEvent::UnserializeFrom(gd::Project& project,
const SerializerElement& element) {
SerializerElement& includeElement = element.GetChild("include", 0, "Limites");
if(GetIncludeConfig() == INCLUDE_EVENTS_GROUP)
{
includeElement.SetAttribute("eventsGroup", GetEventsGroupName());
}
else if(GetIncludeConfig() == INCLUDE_BY_INDEX)
{
includeElement.SetAttribute("start", static_cast<int>(GetIncludeStart()));
includeElement.SetAttribute("end", static_cast<int>(GetIncludeEnd()));
}
SetTarget(element.GetChild("target", 0, "Scene").GetValue().GetString());
element.AddChild("target").SetValue(GetTarget());
if (includeElement.HasAttribute("includeAll")) {
// Compatibility with GDevelop <= 4.0.92
if (includeElement.GetBoolAttribute("includeAll", true)) {
SetIncludeAllEvents();
} else {
SetIncludeStartAndEnd(includeElement.GetIntAttribute("start"),
includeElement.GetIntAttribute("end"));
}
} else {
// GDevelop > 4.0.92
IncludeConfig config = static_cast<IncludeConfig>(
includeElement.GetIntAttribute("includeConfig", 0));
if (config == INCLUDE_ALL)
SetIncludeAllEvents();
else if (config == INCLUDE_EVENTS_GROUP)
SetIncludeEventsGroup(includeElement.GetStringAttribute("eventsGroup"));
else if (config == INCLUDE_BY_INDEX)
SetIncludeStartAndEnd(includeElement.GetIntAttribute("start"),
includeElement.GetIntAttribute("end"));
}
}
void LinkEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
SerializerElement & includeElement = element.GetChild("include", 0, "Limites");
SetTarget(element.GetChild("target", 0, "Scene").GetValue().GetString());
if(includeElement.HasAttribute("includeAll"))
{
//Compatibility with GDevelop <= 4.0.92
if(includeElement.GetBoolAttribute("includeAll", true))
{
SetIncludeAllEvents();
}
else
{
SetIncludeStartAndEnd(includeElement.GetIntAttribute("start"),
includeElement.GetIntAttribute("end"));
}
}
else
{
//GDevelop > 4.0.92
IncludeConfig config = static_cast<IncludeConfig>(includeElement.GetIntAttribute("includeConfig", 0));
if(config == INCLUDE_ALL)
SetIncludeAllEvents();
else if(config == INCLUDE_EVENTS_GROUP)
SetIncludeEventsGroup(includeElement.GetStringAttribute("eventsGroup"));
else if(config == INCLUDE_BY_INDEX)
SetIncludeStartAndEnd(includeElement.GetIntAttribute("start"), includeElement.GetIntAttribute("end"));
}
}
gd::BaseEvent::EditEventReturnType LinkEvent::EditEvent(wxWindow* parent_, gd::Project & project, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_)
{
gd::BaseEvent::EditEventReturnType LinkEvent::EditEvent(
wxWindow* parent_,
gd::Project& project,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_) {
#if !defined(GD_NO_WX_GUI)
LinkEventEditor dialog(parent_, *this, project);
if ( dialog.ShowModal() == 0 ) return Cancelled;
LinkEventEditor dialog(parent_, *this, project);
if (dialog.ShowModal() == 0) return Cancelled;
#endif
return ChangesMade;
return ChangesMade;
}
/**
* Render the event in the bitmap
*/
void LinkEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
void LinkEvent::Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform) {
#if !defined(GD_NO_WX_GUI)
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
gd::EventsRenderingHelper* renderingHelper = gd::EventsRenderingHelper::Get();
dc.SetBrush( wxBrush( wxColour( 255, 255, 255 ) ) );
dc.SetPen( wxPen( wxColour( 0, 0, 0 ), 1) );
wxRect rect(x+1, y, width-2, GetRenderedHeight(width, platform)-2);
dc.DrawRectangle(rect);
dc.SetBrush(wxBrush(wxColour(255, 255, 255)));
dc.SetPen(wxPen(wxColour(0, 0, 0), 1));
wxRect rect(x + 1, y, width - 2, GetRenderedHeight(width, platform) - 2);
dc.DrawRectangle(rect);
dc.DrawBitmap( gd::SkinHelper::GetIcon("events", 24), x+4, y + 1, true);
dc.DrawBitmap(gd::SkinHelper::GetIcon("events", 24), x + 4, y + 1, true);
dc.SetTextBackground( wxColour( 255, 255, 255 ) );
if ( !IsDisabled() )
dc.SetTextForeground( wxColour( 0, 0, 0 ) );
else
dc.SetTextForeground( wxColour( 160, 160, 160 ) );
dc.SetTextBackground(wxColour(255, 255, 255));
if (!IsDisabled())
dc.SetTextForeground(wxColour(0, 0, 0));
else
dc.SetTextForeground(wxColour(160, 160, 160));
dc.SetFont(renderingHelper->GetNiceFont());
dc.DrawText( _("Link to ")+GetTarget(), x+32, y + 3 );
dc.SetFont(renderingHelper->GetNiceFont());
dc.DrawText(_("Link to ") + GetTarget(), x + 32, y + 3);
if ( GetIncludeConfig() == INCLUDE_BY_INDEX )
{
wxRect textRect = dc.GetTextExtent(_("Link to ")+GetTarget());
dc.DrawText( _("Include only events ")+gd::String::From(GetIncludeStart()+1)+_(" to ")+gd::String::From(GetIncludeEnd()+1), x+textRect.GetWidth()+32+10, y + 5 );
}
else if ( GetIncludeConfig() == INCLUDE_EVENTS_GROUP )
{
wxRect textRect = dc.GetTextExtent(_("Link to ")+GetTarget());
dc.DrawText( _("Include only the events group named \"")+gd::String::From(GetEventsGroupName())+_("\""), x+textRect.GetWidth()+32+10, y + 5 );
}
if (GetIncludeConfig() == INCLUDE_BY_INDEX) {
wxRect textRect = dc.GetTextExtent(_("Link to ") + GetTarget());
dc.DrawText(_("Include only events ") +
gd::String::From(GetIncludeStart() + 1) + _(" to ") +
gd::String::From(GetIncludeEnd() + 1),
x + textRect.GetWidth() + 32 + 10,
y + 5);
} else if (GetIncludeConfig() == INCLUDE_EVENTS_GROUP) {
wxRect textRect = dc.GetTextExtent(_("Link to ") + GetTarget());
dc.DrawText(_("Include only the events group named \"") +
gd::String::From(GetEventsGroupName()) + _("\""),
x + textRect.GetWidth() + 32 + 10,
y + 5);
}
#endif
}
/**
* Precompute height for the link
*/
unsigned int LinkEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const
{
unsigned int LinkEvent::GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const {
#if !defined(GD_NO_WX_GUI)
if ( eventHeightNeedUpdate )
{
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
if (eventHeightNeedUpdate) {
gd::EventsRenderingHelper* renderingHelper =
gd::EventsRenderingHelper::Get();
wxMemoryDC dc;
wxBitmap fakeBmp(1,1);
dc.SelectObject(fakeBmp);
wxMemoryDC dc;
wxBitmap fakeBmp(1, 1);
dc.SelectObject(fakeBmp);
dc.SetFont(renderingHelper->GetNiceFont());
wxRect lien = dc.GetTextExtent(_("Link to "));
dc.SetFont(renderingHelper->GetNiceFont());
wxRect lien = dc.GetTextExtent(_("Link to "));
renderedHeight = lien.GetHeight()+15;
eventHeightNeedUpdate = false;
}
renderedHeight = lien.GetHeight() + 15;
eventHeightNeedUpdate = false;
}
return renderedHeight;
return renderedHeight;
#else
return 0;
return 0;
#endif
}
}
} // namespace gd

View File

@@ -1,123 +1,164 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_LINKEVENT_H
#define GDCORE_LINKEVENT_H
#include "GDCore/Events/Event.h"
#include "GDCore/String.h"
namespace gd
{
namespace gd {
/**
* \brief A link pointing to external events (or events of another layout) that should be included
* and run instead of the link.
* \brief A link pointing to external events (or events of another layout) that
* should be included and run instead of the link.
*/
class GD_CORE_API LinkEvent : public gd::BaseEvent
{
public:
enum IncludeConfig
{
INCLUDE_ALL = 0,
INCLUDE_EVENTS_GROUP = 1,
INCLUDE_BY_INDEX = 2 // Deprecated
};
class GD_CORE_API LinkEvent : public gd::BaseEvent {
public:
enum IncludeConfig {
INCLUDE_ALL = 0,
INCLUDE_EVENTS_GROUP = 1,
INCLUDE_BY_INDEX = 2 // Deprecated
};
LinkEvent() : BaseEvent(), includeConfig(INCLUDE_ALL), eventsGroupName(), includeStart(gd::String::npos), includeEnd(gd::String::npos), linkWasInvalid(false) {};
virtual ~LinkEvent();
virtual gd::LinkEvent * Clone() const { return new LinkEvent(*this); }
LinkEvent()
: BaseEvent(),
includeConfig(INCLUDE_ALL),
eventsGroupName(),
includeStart(gd::String::npos),
includeEnd(gd::String::npos),
linkWasInvalid(false){};
virtual ~LinkEvent();
virtual gd::LinkEvent* Clone() const { return new LinkEvent(*this); }
/**
* Get the link target (i.e. the scene or external events the link refers to).
*/
const gd::String & GetTarget() const { return target; };
/**
* Get the link target (i.e. the scene or external events the link refers to).
*/
const gd::String& GetTarget() const { return target; };
/**
* Change the link target (i.e. the scene or external events the link refers to).
*/
void SetTarget(const gd::String & target_) { target = target_; };
/**
* Change the link target (i.e. the scene or external events the link refers
* to).
*/
void SetTarget(const gd::String& target_) { target = target_; };
/**
* Return the include config.
*/
IncludeConfig GetIncludeConfig() const { return includeConfig; }
/**
* Return the include config.
*/
IncludeConfig GetIncludeConfig() const { return includeConfig; }
/**
* Return true if the link event must include all the events of the target.
*/
void SetIncludeAllEvents() { includeConfig = INCLUDE_ALL; }
/**
* Return true if the link event must include all the events of the target.
*/
void SetIncludeAllEvents() { includeConfig = INCLUDE_ALL; }
void SetIncludeEventsGroup(const gd::String& name) { includeConfig = INCLUDE_EVENTS_GROUP; eventsGroupName = name; }
void SetIncludeEventsGroup(const gd::String& name) {
includeConfig = INCLUDE_EVENTS_GROUP;
eventsGroupName = name;
}
/**
* Set the number of the first and last event to be included ( Meaningful only if includeAll was set to false, see SetIncludeAllEvents )
*/
void SetIncludeStartAndEnd(std::size_t includeStart_, std::size_t includeEnd_) { includeConfig = INCLUDE_BY_INDEX; includeStart = includeStart_; includeEnd = includeEnd_; }
/**
* Set the number of the first and last event to be included ( Meaningful only
* if includeAll was set to false, see SetIncludeAllEvents )
*/
void SetIncludeStartAndEnd(std::size_t includeStart_,
std::size_t includeEnd_) {
includeConfig = INCLUDE_BY_INDEX;
includeStart = includeStart_;
includeEnd = includeEnd_;
}
gd::String GetEventsGroupName() const { return eventsGroupName; }
gd::String GetEventsGroupName() const { return eventsGroupName; }
/**
* Get the number of the first event to be included. (Meaningful only if includeAll was set to false, see SetIncludeAllEvents)
*/
std::size_t GetIncludeStart() const { return includeStart; };
/**
* Get the number of the first event to be included. (Meaningful only if
* includeAll was set to false, see SetIncludeAllEvents)
*/
std::size_t GetIncludeStart() const { return includeStart; };
/**
* Get the number of the last event to be included. (Meaningful only if includeAll was set to false, see SetIncludeAllEvents)
*/
std::size_t GetIncludeEnd() const { return includeEnd; };
/**
* Get the number of the last event to be included. (Meaningful only if
* includeAll was set to false, see SetIncludeAllEvents)
*/
std::size_t GetIncludeEnd() const { return includeEnd; };
/**
* The link event must always be preprocessed.
*/
virtual bool MustBePreprocessed() { return true;}
/**
* The link event must always be preprocessed.
*/
virtual bool MustBePreprocessed() { return true; }
/**
* \brief Get a pointer to the list of events that are targeted by the link.
*
* @param project The project containing the link.
* @return NULL if nothing is found or a pointer to the list of events being linked.
*/
const EventsList * GetLinkedEvents(const gd::Project & project) const;
/**
* \brief Get a pointer to the list of events that are targeted by the link.
*
* @param project The project containing the link.
* @return NULL if nothing is found or a pointer to the list of events being
* linked.
*/
const EventsList* GetLinkedEvents(const gd::Project& project) const;
/**
* \brief Replace the link in the events list by the linked events.
* When implementing a platform with a link event, you should call this function when preprocessing the events
* (See gd::EventMetadata::codeGeneration).
*/
void ReplaceLinkByLinkedEvents(const gd::Project & project, EventsList & eventList, std::size_t indexOfTheEventInThisList);
/**
* \brief Replace the link in the events list by the linked events.
* When implementing a platform with a link event, you should call this
* function when preprocessing the events (See
* gd::EventMetadata::codeGeneration).
*/
void ReplaceLinkByLinkedEvents(const gd::Project& project,
EventsList& eventList,
std::size_t indexOfTheEventInThisList);
virtual bool IsExecutable() const { return true; };
virtual bool IsExecutable() const { return true; };
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & platform) const;
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const;
virtual EditEventReturnType EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_);
virtual EditEventReturnType EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_);
virtual void SerializeTo(SerializerElement & element) const;
virtual void UnserializeFrom(gd::Project & project, const SerializerElement & element);
virtual void SerializeTo(SerializerElement& element) const;
virtual void UnserializeFrom(gd::Project& project,
const SerializerElement& element);
private:
gd::String target; ///< The name of the external events (or scene) to be included
private:
gd::String
target; ///< The name of the external events (or scene) to be included
IncludeConfig includeConfig; ///< Defines which events are included by this link
IncludeConfig
includeConfig; ///< Defines which events are included by this link
gd::String eventsGroupName; ///< If includeConfig is set to INCLUDE_EVENTS_GROUP, represents the name of the events group to be included.
gd::String eventsGroupName; ///< If includeConfig is set to
///< INCLUDE_EVENTS_GROUP, represents the name of
///< the events group to be included.
std::size_t includeStart; ///< If includeConfig is set to INCLUDE_BY_INDEX, represents the number of the first event of the target to included.
std::size_t includeEnd; ///< If includeConfig is set to INCLUDE_BY_INDEX, represents the number of the last event of the target to included.
std::size_t includeStart; ///< If includeConfig is set to INCLUDE_BY_INDEX,
///< represents the number of the first event of
///< the target to included.
std::size_t
includeEnd; ///< If includeConfig is set to INCLUDE_BY_INDEX, represents
///< the number of the last event of the target to included.
bool linkWasInvalid; ///< Set to true by Preprocess if the links was invalid the last time is was processed. Used to display a warning in the events editor.
bool linkWasInvalid; ///< Set to true by Preprocess if the links was invalid
///< the last time is was processed. Used to display a
///< warning in the events editor.
};
}
} // namespace gd
#endif // GDCORE_LINKEVENT_H
#endif // GDCORE_LINKEVENT_H

View File

@@ -1,166 +1,200 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "RepeatEvent.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/CodeGeneration/ExpressionsCodeGeneration.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/IDE/Dialogs/EditRepeatEvent.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorItemsAreas.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorSelection.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/CodeGeneration/ExpressionsCodeGeneration.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/IDE/Dialogs/EditRepeatEvent.h"
using namespace std;
namespace gd
{
namespace gd {
RepeatEvent::RepeatEvent() :
BaseEvent(),
repeatNumberExpression(""),
repeatNumberExpressionSelected(false)
{
RepeatEvent::RepeatEvent()
: BaseEvent(),
repeatNumberExpression(""),
repeatNumberExpressionSelected(false) {}
vector<gd::InstructionsList*> RepeatEvent::GetAllConditionsVectors() {
vector<gd::InstructionsList*> allConditions;
allConditions.push_back(&conditions);
return allConditions;
}
vector<gd::InstructionsList*> RepeatEvent::GetAllActionsVectors() {
vector<gd::InstructionsList*> allActions;
allActions.push_back(&actions);
vector < gd::InstructionsList* > RepeatEvent::GetAllConditionsVectors()
{
vector < gd::InstructionsList* > allConditions;
allConditions.push_back(&conditions);
return allConditions;
return allActions;
}
vector < gd::InstructionsList* > RepeatEvent::GetAllActionsVectors()
{
vector < gd::InstructionsList* > allActions;
allActions.push_back(&actions);
vector<gd::Expression*> RepeatEvent::GetAllExpressions() {
vector<gd::Expression*> allExpressions;
allExpressions.push_back(&repeatNumberExpression);
return allActions;
return allExpressions;
}
vector < gd::Expression* > RepeatEvent::GetAllExpressions()
{
vector < gd::Expression* > allExpressions;
allExpressions.push_back(&repeatNumberExpression);
vector<const gd::InstructionsList*> RepeatEvent::GetAllConditionsVectors()
const {
vector<const gd::InstructionsList*> allConditions;
allConditions.push_back(&conditions);
return allExpressions;
return allConditions;
}
vector < const gd::InstructionsList* > RepeatEvent::GetAllConditionsVectors() const
{
vector < const gd::InstructionsList* > allConditions;
allConditions.push_back(&conditions);
vector<const gd::InstructionsList*> RepeatEvent::GetAllActionsVectors() const {
vector<const gd::InstructionsList*> allActions;
allActions.push_back(&actions);
return allConditions;
return allActions;
}
vector < const gd::InstructionsList* > RepeatEvent::GetAllActionsVectors() const
{
vector < const gd::InstructionsList* > allActions;
allActions.push_back(&actions);
vector<const gd::Expression*> RepeatEvent::GetAllExpressions() const {
vector<const gd::Expression*> allExpressions;
allExpressions.push_back(&repeatNumberExpression);
return allActions;
return allExpressions;
}
vector < const gd::Expression* > RepeatEvent::GetAllExpressions() const
{
vector < const gd::Expression* > allExpressions;
allExpressions.push_back(&repeatNumberExpression);
return allExpressions;
void RepeatEvent::SerializeTo(SerializerElement& element) const {
element.AddChild("repeatExpression")
.SetValue(repeatNumberExpression.GetPlainString());
gd::EventsListSerialization::SerializeInstructionsTo(
conditions, element.AddChild("conditions"));
gd::EventsListSerialization::SerializeInstructionsTo(
actions, element.AddChild("actions"));
gd::EventsListSerialization::SerializeEventsTo(events,
element.AddChild("events"));
}
void RepeatEvent::SerializeTo(SerializerElement & element) const
{
element.AddChild("repeatExpression").SetValue(repeatNumberExpression.GetPlainString());
gd::EventsListSerialization::SerializeInstructionsTo(conditions, element.AddChild("conditions"));
gd::EventsListSerialization::SerializeInstructionsTo(actions, element.AddChild("actions"));
gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));
}
void RepeatEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
repeatNumberExpression = gd::Expression(element.GetChild("repeatExpression", 0, "RepeatExpression").GetValue().GetString());
gd::EventsListSerialization::UnserializeInstructionsFrom(project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events", 0, "Events"));
void RepeatEvent::UnserializeFrom(gd::Project& project,
const SerializerElement& element) {
repeatNumberExpression =
gd::Expression(element.GetChild("repeatExpression", 0, "RepeatExpression")
.GetValue()
.GetString());
gd::EventsListSerialization::UnserializeInstructionsFrom(
project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(
project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(
project, events, element.GetChild("events", 0, "Events"));
}
/**
* Render the event in the bitmap
*/
void RepeatEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
void RepeatEvent::Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform) {
#if !defined(GD_NO_WX_GUI)
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
gd::EventsRenderingHelper* renderingHelper = gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int repeatTextHeight = 20;
// Draw header rectangle
wxRect headerRect(x, y, width, repeatTextHeight);
renderingHelper->DrawNiceRectangle(dc, headerRect);
// Repeat text
dc.SetFont(renderingHelper->GetNiceFont().Bold());
if (!IsDisabled())
dc.SetTextForeground(wxColour(0, 0, 0));
else
dc.SetTextForeground(wxColour(160, 160, 160));
dc.DrawText(_("Repeat") + " " + repeatNumberExpression.GetPlainString() +
" " + _("times :"),
x + 4,
y + 3);
// Draw conditions rectangle
wxRect rect(x,
y + repeatTextHeight,
renderingHelper->GetConditionsColumnWidth() + border,
GetRenderedHeight(width, platform) - repeatTextHeight);
renderingHelper->DrawNiceRectangle(dc, rect);
// Draw actions and conditions
renderingHelper->DrawConditionsList(
conditions,
dc,
x + border,
y + repeatTextHeight + border,
renderingHelper->GetConditionsColumnWidth() - border,
this,
areas,
selection,
platform);
renderingHelper->DrawActionsList(
actions,
dc,
x + renderingHelper->GetConditionsColumnWidth() + border,
y + repeatTextHeight + border,
width - renderingHelper->GetConditionsColumnWidth() - border * 2,
this,
areas,
selection,
platform);
#endif
}
unsigned int RepeatEvent::GetRenderedHeight(
unsigned int width, const gd::Platform& platform) const {
#if !defined(GD_NO_WX_GUI)
if (eventHeightNeedUpdate) {
gd::EventsRenderingHelper* renderingHelper =
gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int repeatTextHeight = 20;
//Draw header rectangle
wxRect headerRect(x, y, width, repeatTextHeight);
renderingHelper->DrawNiceRectangle(dc, headerRect);
// Get maximum height needed
int conditionsHeight = renderingHelper->GetRenderedConditionsListHeight(
conditions,
renderingHelper->GetConditionsColumnWidth() - border,
platform);
int actionsHeight = renderingHelper->GetRenderedActionsListHeight(
actions,
width - renderingHelper->GetConditionsColumnWidth() - border * 2,
platform);
//Repeat text
dc.SetFont( renderingHelper->GetNiceFont().Bold() );
if ( !IsDisabled() )
dc.SetTextForeground( wxColour( 0, 0, 0 ) );
else
dc.SetTextForeground( wxColour( 160, 160, 160 ) );
dc.DrawText( _("Repeat") + " " + repeatNumberExpression.GetPlainString() + " " + _("times :"), x + 4, y + 3 );
renderedHeight =
(conditionsHeight > actionsHeight ? conditionsHeight : actionsHeight) +
repeatTextHeight + border * 2;
eventHeightNeedUpdate = false;
}
//Draw conditions rectangle
wxRect rect(x, y+repeatTextHeight, renderingHelper->GetConditionsColumnWidth()+border, GetRenderedHeight(width, platform)-repeatTextHeight);
renderingHelper->DrawNiceRectangle(dc, rect);
//Draw actions and conditions
renderingHelper->DrawConditionsList(conditions, dc,
x+border,
y+repeatTextHeight+border,
renderingHelper->GetConditionsColumnWidth()-border, this, areas, selection, platform);
renderingHelper->DrawActionsList(actions, dc,
x+renderingHelper->GetConditionsColumnWidth()+border,
y+repeatTextHeight+border,
width-renderingHelper->GetConditionsColumnWidth()-border*2, this, areas, selection, platform);
#endif
}
unsigned int RepeatEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const
{
#if !defined(GD_NO_WX_GUI)
if ( eventHeightNeedUpdate )
{
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int repeatTextHeight = 20;
//Get maximum height needed
int conditionsHeight = renderingHelper->GetRenderedConditionsListHeight(conditions, renderingHelper->GetConditionsColumnWidth()-border, platform);
int actionsHeight = renderingHelper->GetRenderedActionsListHeight(actions, width-renderingHelper->GetConditionsColumnWidth()-border*2, platform);
renderedHeight = ( conditionsHeight > actionsHeight ? conditionsHeight : actionsHeight ) + repeatTextHeight + border*2;
eventHeightNeedUpdate = false;
}
return renderedHeight;
return renderedHeight;
#else
return 0;
return 0;
#endif
}
gd::BaseEvent::EditEventReturnType RepeatEvent::EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_)
{
gd::BaseEvent::EditEventReturnType RepeatEvent::EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_) {
#if !defined(GD_NO_WX_GUI)
EditRepeatEvent dialog(parent_, *this, game_, scene_);
if ( dialog.ShowModal() == 0 ) return Cancelled;
EditRepeatEvent dialog(parent_, *this, game_, scene_);
if (dialog.ShowModal() == 0) return Cancelled;
#endif
return ChangesMade;
return ChangesMade;
}
}
} // namespace gd

View File

@@ -1,82 +1,105 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_REPEATEVENT_H
#define GDCORE_REPEATEVENT_H
#include "GDCore/Events/Event.h"
#include "GDCore/Events/EventsList.h"
namespace gd { class Instruction; }
namespace gd { class Project; }
namespace gd {
class Instruction;
}
namespace gd {
class Project;
}
class RuntimeScene;
class TiXmlElement;
namespace gd { class EventsEditorItemsAreas; }
namespace gd { class EventsEditorSelection; }
namespace gd {
class EventsEditorItemsAreas;
}
namespace gd {
class EventsEditorSelection;
}
namespace gd
{
namespace gd {
/**
* \brief Event being repeated a specified number of times.
*/
class GD_CORE_API RepeatEvent : public gd::BaseEvent
{
public:
RepeatEvent();
virtual ~RepeatEvent() {};
virtual gd::RepeatEvent * Clone() const { return new RepeatEvent(*this);}
class GD_CORE_API RepeatEvent : public gd::BaseEvent {
public:
RepeatEvent();
virtual ~RepeatEvent(){};
virtual gd::RepeatEvent* Clone() const { return new RepeatEvent(*this); }
virtual bool IsExecutable() const {return true;}
virtual bool IsExecutable() const { return true; }
virtual bool CanHaveSubEvents() const {return true;}
virtual const gd::EventsList & GetSubEvents() const {return events;};
virtual gd::EventsList & GetSubEvents() {return events;};
virtual bool CanHaveSubEvents() const { return true; }
virtual const gd::EventsList& GetSubEvents() const { return events; };
virtual gd::EventsList& GetSubEvents() { return events; };
const gd::InstructionsList & GetConditions() const { return conditions; };
gd::InstructionsList & GetConditions() { return conditions; };
const gd::InstructionsList& GetConditions() const { return conditions; };
gd::InstructionsList& GetConditions() { return conditions; };
const gd::InstructionsList & GetActions() const { return actions; };
gd::InstructionsList & GetActions() { return actions; };
const gd::InstructionsList& GetActions() const { return actions; };
gd::InstructionsList& GetActions() { return actions; };
const gd::String & GetRepeatExpression() const { return repeatNumberExpression.GetPlainString(); };
void SetRepeatExpression(gd::String repeatNumberExpression_) { repeatNumberExpression = gd::Expression(repeatNumberExpression_); };
const gd::String& GetRepeatExpression() const {
return repeatNumberExpression.GetPlainString();
};
void SetRepeatExpression(gd::String repeatNumberExpression_) {
repeatNumberExpression = gd::Expression(repeatNumberExpression_);
};
virtual std::vector < gd::InstructionsList* > GetAllConditionsVectors();
virtual std::vector < gd::InstructionsList* > GetAllActionsVectors();
virtual std::vector < gd::Expression* > GetAllExpressions();
virtual std::vector < const gd::InstructionsList* > GetAllConditionsVectors() const;
virtual std::vector < const gd::InstructionsList* > GetAllActionsVectors() const;
virtual std::vector < const gd::Expression* > GetAllExpressions() const;
virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
virtual std::vector<gd::Expression*> GetAllExpressions();
virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
const;
virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
virtual std::vector<const gd::Expression*> GetAllExpressions() const;
virtual void SerializeTo(SerializerElement & element) const;
virtual void UnserializeFrom(gd::Project & project, const SerializerElement & element);
virtual void SerializeTo(SerializerElement& element) const;
virtual void UnserializeFrom(gd::Project& project,
const SerializerElement& element);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & platform) const;
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const;
/**
* Called when the user want to edit the event
*/
virtual EditEventReturnType EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_);
/**
* Called when the user want to edit the event
*/
virtual EditEventReturnType EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_);
private:
gd::Expression repeatNumberExpression;
gd::InstructionsList conditions;
gd::InstructionsList actions;
EventsList events;
private:
gd::Expression repeatNumberExpression;
gd::InstructionsList conditions;
gd::InstructionsList actions;
EventsList events;
bool repeatNumberExpressionSelected;
bool repeatNumberExpressionSelected;
};
}
} // namespace gd
#endif // GDCORE_REPEATEVENT_H
#endif // GDCORE_REPEATEVENT_H

View File

@@ -1,125 +1,152 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "StandardEvent.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorItemsAreas.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorSelection.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/TinyXml/tinyxml.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
using namespace std;
namespace gd
{
namespace gd {
StandardEvent::StandardEvent() :
BaseEvent()
{
StandardEvent::StandardEvent() : BaseEvent() {}
StandardEvent::~StandardEvent(){};
vector<const gd::InstructionsList*> StandardEvent::GetAllConditionsVectors()
const {
vector<const gd::InstructionsList*> allConditions;
allConditions.push_back(&conditions);
return allConditions;
}
StandardEvent::~StandardEvent()
{
};
vector<const gd::InstructionsList*> StandardEvent::GetAllActionsVectors()
const {
vector<const gd::InstructionsList*> allActions;
allActions.push_back(&actions);
vector < const gd::InstructionsList* > StandardEvent::GetAllConditionsVectors() const
{
vector < const gd::InstructionsList* > allConditions;
allConditions.push_back(&conditions);
return allActions;
}
vector<gd::InstructionsList*> StandardEvent::GetAllConditionsVectors() {
vector<gd::InstructionsList*> allConditions;
allConditions.push_back(&conditions);
return allConditions;
return allConditions;
}
vector < const gd::InstructionsList* > StandardEvent::GetAllActionsVectors() const
{
vector < const gd::InstructionsList* > allActions;
allActions.push_back(&actions);
vector<gd::InstructionsList*> StandardEvent::GetAllActionsVectors() {
vector<gd::InstructionsList*> allActions;
allActions.push_back(&actions);
return allActions;
}
vector < gd::InstructionsList* > StandardEvent::GetAllConditionsVectors()
{
vector < gd::InstructionsList* > allConditions;
allConditions.push_back(&conditions);
return allConditions;
return allActions;
}
vector < gd::InstructionsList* > StandardEvent::GetAllActionsVectors()
{
vector < gd::InstructionsList* > allActions;
allActions.push_back(&actions);
return allActions;
void StandardEvent::SerializeTo(SerializerElement& element) const {
gd::EventsListSerialization::SerializeInstructionsTo(
conditions, element.AddChild("conditions"));
gd::EventsListSerialization::SerializeInstructionsTo(
actions, element.AddChild("actions"));
gd::EventsListSerialization::SerializeEventsTo(events,
element.AddChild("events"));
}
void StandardEvent::SerializeTo(SerializerElement & element) const
{
gd::EventsListSerialization::SerializeInstructionsTo(conditions, element.AddChild("conditions"));
gd::EventsListSerialization::SerializeInstructionsTo(actions, element.AddChild("actions"));
gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));
}
void StandardEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
gd::EventsListSerialization::UnserializeInstructionsFrom(project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events", 0, "Events"));
void StandardEvent::UnserializeFrom(gd::Project& project,
const SerializerElement& element) {
gd::EventsListSerialization::UnserializeInstructionsFrom(
project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(
project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(
project, events, element.GetChild("events", 0, "Events"));
}
/**
* Render the event in the bitmap
*/
void StandardEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
void StandardEvent::Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform) {
#if !defined(GD_NO_WX_GUI)
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
gd::EventsRenderingHelper* renderingHelper = gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
// Draw event rectangle
wxRect rect(x,
y,
renderingHelper->GetConditionsColumnWidth() + border,
GetRenderedHeight(width, platform));
renderingHelper->DrawNiceRectangle(dc, rect);
renderingHelper->DrawConditionsList(
conditions,
dc,
x + border,
y + border,
renderingHelper->GetConditionsColumnWidth() - border,
this,
areas,
selection,
platform);
renderingHelper->DrawActionsList(
actions,
dc,
x + renderingHelper->GetConditionsColumnWidth() + border,
y + border,
width - renderingHelper->GetConditionsColumnWidth() - border * 2,
this,
areas,
selection,
platform);
// Make sure that Render is rendering an event with the same height as
// GetRenderedHeight : Use same values for border and similar calls to compute
// heights
#endif
}
unsigned int StandardEvent::GetRenderedHeight(
unsigned int width, const gd::Platform& platform) const {
#if !defined(GD_NO_WX_GUI)
if (eventHeightNeedUpdate) {
gd::EventsRenderingHelper* renderingHelper =
gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
//Draw event rectangle
wxRect rect(x, y, renderingHelper->GetConditionsColumnWidth()+border, GetRenderedHeight(width, platform));
renderingHelper->DrawNiceRectangle(dc, rect);
// Get maximum height needed
int conditionsHeight = renderingHelper->GetRenderedConditionsListHeight(
conditions,
renderingHelper->GetConditionsColumnWidth() - border * 2,
platform);
int actionsHeight = renderingHelper->GetRenderedActionsListHeight(
actions,
width - renderingHelper->GetConditionsColumnWidth() - border * 2,
platform);
renderingHelper->DrawConditionsList(conditions, dc,
x+border,
y+border,
renderingHelper->GetConditionsColumnWidth()-border, this, areas, selection, platform);
renderingHelper->DrawActionsList(actions, dc,
x+renderingHelper->GetConditionsColumnWidth()+border,
y+border,
width-renderingHelper->GetConditionsColumnWidth()-border*2, this, areas, selection, platform);
renderedHeight =
(conditionsHeight > actionsHeight ? conditionsHeight : actionsHeight) +
border * 2;
eventHeightNeedUpdate = false;
}
//Make sure that Render is rendering an event with the same height as GetRenderedHeight : Use same values for border and similar calls to compute heights
#endif
}
unsigned int StandardEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const
{
#if !defined(GD_NO_WX_GUI)
if ( eventHeightNeedUpdate )
{
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
//Get maximum height needed
int conditionsHeight = renderingHelper->GetRenderedConditionsListHeight(conditions, renderingHelper->GetConditionsColumnWidth()-border*2, platform);
int actionsHeight = renderingHelper->GetRenderedActionsListHeight(actions, width-renderingHelper->GetConditionsColumnWidth()-border*2, platform);
renderedHeight = (conditionsHeight > actionsHeight ? conditionsHeight : actionsHeight)+border*2;
eventHeightNeedUpdate = false;
}
return renderedHeight;
return renderedHeight;
#else
return 0;
return 0;
#endif
}
}
} // namespace gd

View File

@@ -1,74 +1,89 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#ifndef GDCORE_STANDARDEVENT_H
#define GDCORE_STANDARDEVENT_H
#include "GDCore/Events/Event.h"
#include "GDCore/Events/EventsList.h"
#include "GDCore/Events/Instruction.h"
#include "GDCore/Events/InstructionsList.h"
#include "GDCore/Events/EventsList.h"
namespace gd { class Instruction; }
namespace gd { class Project; }
namespace gd {
class Instruction;
}
namespace gd {
class Project;
}
class RuntimeScene;
class TiXmlElement;
class EventsCodeGenerationContext;
namespace gd { class EventsEditorItemsAreas; }
namespace gd { class EventsEditorSelection; }
namespace gd {
class EventsEditorItemsAreas;
}
namespace gd {
class EventsEditorSelection;
}
namespace gd
{
namespace gd {
/**
* \brief Standard event, with conditions, actions and support for sub events.
*/
class GD_CORE_API StandardEvent : public gd::BaseEvent
{
public:
StandardEvent();
virtual ~StandardEvent();
virtual gd::StandardEvent * Clone() const { return new StandardEvent(*this);}
class GD_CORE_API StandardEvent : public gd::BaseEvent {
public:
StandardEvent();
virtual ~StandardEvent();
virtual gd::StandardEvent* Clone() const { return new StandardEvent(*this); }
virtual bool IsExecutable() const {return true;}
virtual bool IsExecutable() const { return true; }
virtual bool CanHaveSubEvents() const {return true;}
virtual const gd::EventsList & GetSubEvents() const {return events;};
virtual gd::EventsList & GetSubEvents() {return events;};
virtual bool CanHaveSubEvents() const { return true; }
virtual const gd::EventsList& GetSubEvents() const { return events; };
virtual gd::EventsList& GetSubEvents() { return events; };
const gd::InstructionsList & GetConditions() const { return conditions; };
gd::InstructionsList & GetConditions() { return conditions; };
const gd::InstructionsList& GetConditions() const { return conditions; };
gd::InstructionsList& GetConditions() { return conditions; };
const gd::InstructionsList & GetActions() const { return actions; };
gd::InstructionsList & GetActions() { return actions; };
const gd::InstructionsList& GetActions() const { return actions; };
gd::InstructionsList& GetActions() { return actions; };
virtual std::vector < const gd::InstructionsList* > GetAllConditionsVectors() const;
virtual std::vector < const gd::InstructionsList* > GetAllActionsVectors() const;
virtual std::vector < gd::InstructionsList* > GetAllConditionsVectors();
virtual std::vector < gd::InstructionsList* > GetAllActionsVectors();
virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
const;
virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
virtual void SerializeTo(SerializerElement & element) const;
virtual void UnserializeFrom(gd::Project & project, const SerializerElement & element);
virtual void SerializeTo(SerializerElement& element) const;
virtual void UnserializeFrom(gd::Project& project,
const SerializerElement& element);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & platform) const;
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const;
private:
gd::InstructionsList conditions;
gd::InstructionsList actions;
EventsList events;
private:
gd::InstructionsList conditions;
gd::InstructionsList actions;
EventsList events;
};
}
} // namespace gd
#endif // GDCORE_STANDARDEVENT_H
#endif // GDCORE_STANDARDEVENT_H
#endif

View File

@@ -1,7 +1,7 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
@@ -10,177 +10,238 @@
#include <wx/msgdlg.h>
#include "GDCore/IDE/wxTools/CommonBitmapProvider.h"
#endif
#include "GDCore/TinyXml/tinyxml.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/CodeGeneration/ExpressionsCodeGeneration.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorItemsAreas.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsEditorSelection.h"
#include "GDCore/IDE/Dialogs/EventsEditor/EventsRenderingHelper.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/TinyXml/tinyxml.h"
using namespace std;
namespace gd
{
namespace gd {
vector < gd::InstructionsList* > WhileEvent::GetAllConditionsVectors()
{
vector < gd::InstructionsList* > allConditions;
allConditions.push_back(&whileConditions);
allConditions.push_back(&conditions);
vector<gd::InstructionsList*> WhileEvent::GetAllConditionsVectors() {
vector<gd::InstructionsList*> allConditions;
allConditions.push_back(&whileConditions);
allConditions.push_back(&conditions);
return allConditions;
return allConditions;
}
vector < gd::InstructionsList* > WhileEvent::GetAllActionsVectors()
{
vector < gd::InstructionsList* > allActions;
allActions.push_back(&actions);
vector<gd::InstructionsList*> WhileEvent::GetAllActionsVectors() {
vector<gd::InstructionsList*> allActions;
allActions.push_back(&actions);
return allActions;
return allActions;
}
vector < const gd::InstructionsList* > WhileEvent::GetAllConditionsVectors() const
{
vector < const gd::InstructionsList* > allConditions;
allConditions.push_back(&whileConditions);
allConditions.push_back(&conditions);
vector<const gd::InstructionsList*> WhileEvent::GetAllConditionsVectors()
const {
vector<const gd::InstructionsList*> allConditions;
allConditions.push_back(&whileConditions);
allConditions.push_back(&conditions);
return allConditions;
return allConditions;
}
vector < const gd::InstructionsList* > WhileEvent::GetAllActionsVectors() const
{
vector < const gd::InstructionsList* > allActions;
allActions.push_back(&actions);
vector<const gd::InstructionsList*> WhileEvent::GetAllActionsVectors() const {
vector<const gd::InstructionsList*> allActions;
allActions.push_back(&actions);
return allActions;
return allActions;
}
void WhileEvent::SerializeTo(SerializerElement & element) const
{
element.SetAttribute("infiniteLoopWarning", infiniteLoopWarning);
gd::EventsListSerialization::SerializeInstructionsTo(whileConditions, element.AddChild("whileConditions"));
gd::EventsListSerialization::SerializeInstructionsTo(conditions, element.AddChild("conditions"));
gd::EventsListSerialization::SerializeInstructionsTo(actions, element.AddChild("actions"));
gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));
void WhileEvent::SerializeTo(SerializerElement& element) const {
element.SetAttribute("infiniteLoopWarning", infiniteLoopWarning);
gd::EventsListSerialization::SerializeInstructionsTo(
whileConditions, element.AddChild("whileConditions"));
gd::EventsListSerialization::SerializeInstructionsTo(
conditions, element.AddChild("conditions"));
gd::EventsListSerialization::SerializeInstructionsTo(
actions, element.AddChild("actions"));
gd::EventsListSerialization::SerializeEventsTo(events,
element.AddChild("events"));
}
void WhileEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
justCreatedByTheUser = false;
infiniteLoopWarning = element.GetBoolAttribute("infiniteLoopWarning");
gd::EventsListSerialization::UnserializeInstructionsFrom(project, whileConditions, element.GetChild("whileConditions", 0, "WhileConditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events", 0, "Events"));
void WhileEvent::UnserializeFrom(gd::Project& project,
const SerializerElement& element) {
justCreatedByTheUser = false;
infiniteLoopWarning = element.GetBoolAttribute("infiniteLoopWarning");
gd::EventsListSerialization::UnserializeInstructionsFrom(
project,
whileConditions,
element.GetChild("whileConditions", 0, "WhileConditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(
project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::UnserializeInstructionsFrom(
project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(
project, events, element.GetChild("events", 0, "Events"));
}
/**
* Render the event in the bitmap
*/
void WhileEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
void WhileEvent::Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform) {
#if !defined(GD_NO_WX_GUI)
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
gd::EventsRenderingHelper* renderingHelper = gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int repeatHeight = 20;
// Draw header rectangle
int whileConditionsHeight =
renderingHelper->GetRenderedConditionsListHeight(
whileConditions, width - 80 - border * 2, platform) +
border * 2;
if (!infiniteLoopWarning && whileConditionsHeight < 32)
whileConditionsHeight = 32;
wxRect headerRect(x, y, width, whileConditionsHeight + repeatHeight);
renderingHelper->DrawNiceRectangle(dc, headerRect);
// While text
dc.SetFont(renderingHelper->GetNiceFont().Bold());
if (!IsDisabled())
dc.SetTextForeground(wxColour(0, 0, 0));
else
dc.SetTextForeground(wxColour(160, 160, 160));
dc.DrawText(_("While :"), x + 5, y + 5);
// Draw icon if infinite loop warning is deactivated.
if (!infiniteLoopWarning) {
if (gd::CommonBitmapProvider::Get()->noProtection.IsOk())
dc.DrawBitmap(gd::CommonBitmapProvider::Get()->noProtection,
wxPoint(x + 5, y + 5 + 18),
/*useMask=*/true);
}
// Draw "while conditions"
renderingHelper->DrawConditionsList(whileConditions,
dc,
x + 80 + border,
y + border,
width - 80 - border * 2,
this,
areas,
selection,
platform);
dc.SetFont(renderingHelper->GetNiceFont().Bold());
if (!IsDisabled())
dc.SetTextForeground(wxColour(0, 0, 0));
else
dc.SetTextForeground(wxColour(160, 160, 160));
dc.DrawText(_("Repeat :"), x + 4, y + whileConditionsHeight + 3);
whileConditionsHeight += repeatHeight;
// Draw conditions rectangle
wxRect rect(x,
y + whileConditionsHeight,
renderingHelper->GetConditionsColumnWidth() + border,
GetRenderedHeight(width, platform) - whileConditionsHeight);
renderingHelper->DrawNiceRectangle(dc, rect);
renderingHelper->DrawConditionsList(
conditions,
dc,
x + border,
y + whileConditionsHeight + border,
renderingHelper->GetConditionsColumnWidth() - border,
this,
areas,
selection,
platform);
renderingHelper->DrawActionsList(
actions,
dc,
x + renderingHelper->GetConditionsColumnWidth() + border,
y + whileConditionsHeight + border,
width - renderingHelper->GetConditionsColumnWidth() - border * 2,
this,
areas,
selection,
platform);
#endif
}
unsigned int WhileEvent::GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const {
#if !defined(GD_NO_WX_GUI)
if (eventHeightNeedUpdate) {
gd::EventsRenderingHelper* renderingHelper =
gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int repeatHeight = 20;
//Draw header rectangle
int whileConditionsHeight = renderingHelper->GetRenderedConditionsListHeight(whileConditions, width-80-border*2, platform)+border*2;
if (!infiniteLoopWarning && whileConditionsHeight < 32 ) whileConditionsHeight = 32;
wxRect headerRect(x, y, width, whileConditionsHeight+repeatHeight);
renderingHelper->DrawNiceRectangle(dc, headerRect);
// Get maximum height needed
int whileConditionsHeight =
renderingHelper->GetRenderedConditionsListHeight(
whileConditions, width - 80 - border * 2, platform);
if (!infiniteLoopWarning && whileConditionsHeight < 32)
whileConditionsHeight = 32;
int conditionsHeight = renderingHelper->GetRenderedConditionsListHeight(
conditions,
renderingHelper->GetConditionsColumnWidth() - border,
platform);
int actionsHeight = renderingHelper->GetRenderedActionsListHeight(
actions,
width - renderingHelper->GetConditionsColumnWidth() - border * 2,
platform);
//While text
dc.SetFont( renderingHelper->GetNiceFont().Bold() );
if ( !IsDisabled() )
dc.SetTextForeground( wxColour( 0, 0, 0 ) );
else
dc.SetTextForeground( wxColour( 160, 160, 160 ) );
dc.DrawText( _("While :"), x+5, y+5 );
renderedHeight =
((conditionsHeight > actionsHeight ? conditionsHeight : actionsHeight) +
whileConditionsHeight + repeatHeight) +
border * 2 + border * 2;
eventHeightNeedUpdate = false;
}
//Draw icon if infinite loop warning is deactivated.
if (!infiniteLoopWarning)
{
if ( gd::CommonBitmapProvider::Get()->noProtection.IsOk() )
dc.DrawBitmap(gd::CommonBitmapProvider::Get()->noProtection, wxPoint(x+5,y+5+18), /*useMask=*/true);
}
//Draw "while conditions"
renderingHelper->DrawConditionsList(whileConditions, dc, x+80+border, y+border, width-80-border*2, this, areas, selection, platform);
dc.SetFont( renderingHelper->GetNiceFont().Bold() );
if ( !IsDisabled() )
dc.SetTextForeground( wxColour( 0, 0, 0 ) );
else
dc.SetTextForeground( wxColour( 160, 160, 160 ) );
dc.DrawText( _("Repeat :"), x+4, y+whileConditionsHeight+3);
whileConditionsHeight += repeatHeight;
//Draw conditions rectangle
wxRect rect(x, y+whileConditionsHeight, renderingHelper->GetConditionsColumnWidth()+border, GetRenderedHeight(width, platform)-whileConditionsHeight);
renderingHelper->DrawNiceRectangle(dc, rect);
renderingHelper->DrawConditionsList(conditions, dc,
x+border,
y+whileConditionsHeight+border,
renderingHelper->GetConditionsColumnWidth()-border, this, areas, selection, platform);
renderingHelper->DrawActionsList(actions, dc,
x+renderingHelper->GetConditionsColumnWidth()+border,
y+whileConditionsHeight+border,
width-renderingHelper->GetConditionsColumnWidth()-border*2, this, areas, selection, platform);
#endif
}
unsigned int WhileEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const
{
#if !defined(GD_NO_WX_GUI)
if ( eventHeightNeedUpdate )
{
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
int border = renderingHelper->instructionsListBorder;
const int repeatHeight = 20;
//Get maximum height needed
int whileConditionsHeight = renderingHelper->GetRenderedConditionsListHeight(whileConditions, width-80-border*2, platform);
if (!infiniteLoopWarning && whileConditionsHeight < 32 ) whileConditionsHeight = 32;
int conditionsHeight = renderingHelper->GetRenderedConditionsListHeight(conditions, renderingHelper->GetConditionsColumnWidth()-border, platform);
int actionsHeight = renderingHelper->GetRenderedActionsListHeight(actions, width-renderingHelper->GetConditionsColumnWidth()-border*2, platform);
renderedHeight = (( conditionsHeight > actionsHeight ? conditionsHeight : actionsHeight ) + whileConditionsHeight + repeatHeight)+border*2+border*2;
eventHeightNeedUpdate = false;
}
return renderedHeight;
return renderedHeight;
#else
return 0;
return 0;
#endif
}
gd::BaseEvent::EditEventReturnType WhileEvent::EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_)
{
gd::BaseEvent::EditEventReturnType WhileEvent::EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_) {
#if !defined(GD_NO_WX_GUI)
if ( !justCreatedByTheUser )
{
wxMessageDialog dialog(parent_, _("Do you want to activate the display of a message if the event is repeated 100000 times? This message prevent the software from being frozen if you accidentally create an infinite loop ( by letting the conditions empty for example )."),
_("Protection against infinite loops."),
wxYES_NO|wxCANCEL|wxICON_INFORMATION);
if (!justCreatedByTheUser) {
wxMessageDialog dialog(
parent_,
_("Do you want to activate the display of a message if the event is "
"repeated 100000 times? This message prevent the software from being "
"frozen if you accidentally create an infinite loop ( by letting the "
"conditions empty for example )."),
_("Protection against infinite loops."),
wxYES_NO | wxCANCEL | wxICON_INFORMATION);
dialog.SetExtendedMessage(_("This message is activated by default for \"While\" events in the IDE, and is deactivated when the game is compiled to an executable."));
dialog.SetYesNoCancelLabels(_("Activate"), _("Deactivate"), _("Cancel"));
dialog.SetExtendedMessage(_(
"This message is activated by default for \"While\" events in the IDE, "
"and is deactivated when the game is compiled to an executable."));
dialog.SetYesNoCancelLabels(_("Activate"), _("Deactivate"), _("Cancel"));
int answer = dialog.ShowModal();
if ( answer == wxID_YES ) infiniteLoopWarning = true;
else if ( answer == wxID_NO ) infiniteLoopWarning = false;
}
justCreatedByTheUser = false; //Show Message dialog next time.
int answer = dialog.ShowModal();
if (answer == wxID_YES)
infiniteLoopWarning = true;
else if (answer == wxID_NO)
infiniteLoopWarning = false;
}
justCreatedByTheUser = false; // Show Message dialog next time.
#endif
return ChangesMade;
return ChangesMade;
}
}
} // namespace gd
#endif

View File

@@ -1,92 +1,120 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_WHILEEVENT_H
#define GDCORE_WHILEEVENT_H
#include "GDCore/Events/EventsList.h"
#include "GDCore/Events/Event.h"
namespace gd { class Instruction; }
namespace gd { class Project; }
#include "GDCore/Events/EventsList.h"
namespace gd {
class Instruction;
}
namespace gd {
class Project;
}
class RuntimeScene;
class TiXmlElement;
namespace gd { class EventsEditorItemsAreas; }
namespace gd { class EventsEditorSelection; }
namespace gd
{
/**
* \brief While event is a standard event that is repeated while some conditions are true
*
* \note The platforms are required to warn the user about a possible infinite loop if the iteration count reach 100 000
* and if HasInfiniteLoopWarning() returns true.
*/
class GD_CORE_API WhileEvent : public gd::BaseEvent
{
public:
WhileEvent() : infiniteLoopWarning(true), justCreatedByTheUser(true) {};
virtual ~WhileEvent() {};
virtual gd::WhileEvent * Clone() const { return new WhileEvent(*this);}
virtual bool IsExecutable() const {return true;}
virtual bool CanHaveSubEvents() const {return true;}
virtual const gd::EventsList & GetSubEvents() const {return events;};
virtual gd::EventsList & GetSubEvents() {return events;};
const gd::InstructionsList & GetConditions() const { return conditions; };
gd::InstructionsList & GetConditions() { return conditions; };
const gd::InstructionsList & GetActions() const { return actions; };
gd::InstructionsList & GetActions() { return actions; };
const gd::InstructionsList & GetWhileConditions() const { return whileConditions; };
gd::InstructionsList & GetWhileConditions() { return whileConditions; };
void SetWhileConditions(gd::InstructionsList & whileConditions_) { whileConditions = whileConditions_; };
bool HasInfiniteLoopWarning() const { return infiniteLoopWarning; }
virtual std::vector < gd::InstructionsList* > GetAllConditionsVectors();
virtual std::vector < gd::InstructionsList* > GetAllActionsVectors();
virtual std::vector < const gd::InstructionsList* > GetAllConditionsVectors() const;
virtual std::vector < const gd::InstructionsList* > GetAllActionsVectors() const;
virtual void SerializeTo(SerializerElement & element) const;
virtual void UnserializeFrom(gd::Project & project, const SerializerElement & element);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & platform) const;
/**
* Called when the user want to edit the event
*/
virtual EditEventReturnType EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_);
private:
gd::InstructionsList whileConditions;
gd::InstructionsList conditions;
gd::InstructionsList actions;
EventsList events;
bool infiniteLoopWarning; ///< If true, code will be generated to warn the developer against an infinite loop.
bool justCreatedByTheUser; ///< Used so as not to show message box to de/activate infinite loop warning when the user create the event
mutable unsigned int whileConditionsHeight;
int GetConditionsHeight() const;
int GetActionsHeight() const;
int GetWhileConditionsHeight() const;
};
namespace gd {
class EventsEditorItemsAreas;
}
namespace gd {
class EventsEditorSelection;
}
#endif // GDCORE_WHILEEVENT_H
namespace gd {
/**
* \brief While event is a standard event that is repeated while some conditions
* are true
*
* \note The platforms are required to warn the user about a possible infinite
* loop if the iteration count reach 100 000 and if HasInfiniteLoopWarning()
* returns true.
*/
class GD_CORE_API WhileEvent : public gd::BaseEvent {
public:
WhileEvent() : infiniteLoopWarning(true), justCreatedByTheUser(true){};
virtual ~WhileEvent(){};
virtual gd::WhileEvent* Clone() const { return new WhileEvent(*this); }
virtual bool IsExecutable() const { return true; }
virtual bool CanHaveSubEvents() const { return true; }
virtual const gd::EventsList& GetSubEvents() const { return events; };
virtual gd::EventsList& GetSubEvents() { return events; };
const gd::InstructionsList& GetConditions() const { return conditions; };
gd::InstructionsList& GetConditions() { return conditions; };
const gd::InstructionsList& GetActions() const { return actions; };
gd::InstructionsList& GetActions() { return actions; };
const gd::InstructionsList& GetWhileConditions() const {
return whileConditions;
};
gd::InstructionsList& GetWhileConditions() { return whileConditions; };
void SetWhileConditions(gd::InstructionsList& whileConditions_) {
whileConditions = whileConditions_;
};
bool HasInfiniteLoopWarning() const { return infiniteLoopWarning; }
virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
const;
virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
virtual void SerializeTo(SerializerElement& element) const;
virtual void UnserializeFrom(gd::Project& project,
const SerializerElement& element);
/**
* Called by event editor to draw the event.
*/
virtual void Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform);
/**
* Must return the height of the event when rendered
*/
virtual unsigned int GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const;
/**
* Called when the user want to edit the event
*/
virtual EditEventReturnType EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_);
private:
gd::InstructionsList whileConditions;
gd::InstructionsList conditions;
gd::InstructionsList actions;
EventsList events;
bool infiniteLoopWarning; ///< If true, code will be generated to warn the
///< developer against an infinite loop.
bool justCreatedByTheUser; ///< Used so as not to show message box to
///< de/activate infinite loop warning when the
///< user create the event
mutable unsigned int whileConditionsHeight;
int GetConditionsHeight() const;
int GetActionsHeight() const;
int GetWhileConditionsHeight() const;
};
} // namespace gd
#endif // GDCORE_WHILEEVENT_H

View File

@@ -1,80 +1,92 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
#include <set>
#include "GDCore/CommonTools.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include <set>
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
using namespace std;
namespace gd
{
namespace gd {
void EventsCodeGenerationContext::InheritsFrom(const EventsCodeGenerationContext & parent_)
{
parent = &parent_;
void EventsCodeGenerationContext::InheritsFrom(
const EventsCodeGenerationContext& parent_) {
parent = &parent_;
//Objects lists declared by parent became "already declared" in the child context.
alreadyDeclaredObjectsLists = parent_.alreadyDeclaredObjectsLists;
std::copy( parent_.objectsListsToBeDeclared.begin(), parent_.objectsListsToBeDeclared.end(), std::inserter( alreadyDeclaredObjectsLists, alreadyDeclaredObjectsLists.begin() ) );
std::copy( parent_.emptyObjectsListsToBeDeclared.begin(), parent_.emptyObjectsListsToBeDeclared.end(), std::inserter( alreadyDeclaredObjectsLists, alreadyDeclaredObjectsLists.begin() ) );
// Objects lists declared by parent became "already declared" in the child
// context.
alreadyDeclaredObjectsLists = parent_.alreadyDeclaredObjectsLists;
std::copy(parent_.objectsListsToBeDeclared.begin(),
parent_.objectsListsToBeDeclared.end(),
std::inserter(alreadyDeclaredObjectsLists,
alreadyDeclaredObjectsLists.begin()));
std::copy(parent_.emptyObjectsListsToBeDeclared.begin(),
parent_.emptyObjectsListsToBeDeclared.end(),
std::inserter(alreadyDeclaredObjectsLists,
alreadyDeclaredObjectsLists.begin()));
depthOfLastUse = parent_.depthOfLastUse;
customConditionDepth = parent_.customConditionDepth;
contextDepth = parent_.GetContextDepth()+1;
if ( parent_.maxDepthLevel )
{
maxDepthLevel = parent_.maxDepthLevel;
*maxDepthLevel = std::max(*maxDepthLevel, contextDepth);
}
depthOfLastUse = parent_.depthOfLastUse;
customConditionDepth = parent_.customConditionDepth;
contextDepth = parent_.GetContextDepth() + 1;
if (parent_.maxDepthLevel) {
maxDepthLevel = parent_.maxDepthLevel;
*maxDepthLevel = std::max(*maxDepthLevel, contextDepth);
}
}
void EventsCodeGenerationContext::Reuse(const EventsCodeGenerationContext & parent_)
{
InheritsFrom(parent_);
if (parent_.CanReuse())
contextDepth = parent_.GetContextDepth(); // Keep same context depth
void EventsCodeGenerationContext::Reuse(
const EventsCodeGenerationContext& parent_) {
InheritsFrom(parent_);
if (parent_.CanReuse())
contextDepth = parent_.GetContextDepth(); // Keep same context depth
}
void EventsCodeGenerationContext::ObjectsListNeeded(const gd::String & objectName)
{
if ( emptyObjectsListsToBeDeclared.find(objectName) == emptyObjectsListsToBeDeclared.end() )
objectsListsToBeDeclared.insert(objectName);
void EventsCodeGenerationContext::ObjectsListNeeded(
const gd::String& objectName) {
if (emptyObjectsListsToBeDeclared.find(objectName) ==
emptyObjectsListsToBeDeclared.end())
objectsListsToBeDeclared.insert(objectName);
depthOfLastUse[objectName] = GetContextDepth();
depthOfLastUse[objectName] = GetContextDepth();
}
void EventsCodeGenerationContext::EmptyObjectsListNeeded(const gd::String & objectName)
{
if ( objectsListsToBeDeclared.find(objectName) == objectsListsToBeDeclared.end() )
emptyObjectsListsToBeDeclared.insert(objectName);
void EventsCodeGenerationContext::EmptyObjectsListNeeded(
const gd::String& objectName) {
if (objectsListsToBeDeclared.find(objectName) ==
objectsListsToBeDeclared.end())
emptyObjectsListsToBeDeclared.insert(objectName);
depthOfLastUse[objectName] = GetContextDepth();
depthOfLastUse[objectName] = GetContextDepth();
}
std::set<gd::String> EventsCodeGenerationContext::GetAllObjectsToBeDeclared() const
{
std::set <gd::String> allObjectListsToBeDeclared(objectsListsToBeDeclared.begin(), objectsListsToBeDeclared.end());
allObjectListsToBeDeclared.insert(emptyObjectsListsToBeDeclared.begin(), emptyObjectsListsToBeDeclared.end());
std::set<gd::String> EventsCodeGenerationContext::GetAllObjectsToBeDeclared()
const {
std::set<gd::String> allObjectListsToBeDeclared(
objectsListsToBeDeclared.begin(), objectsListsToBeDeclared.end());
allObjectListsToBeDeclared.insert(emptyObjectsListsToBeDeclared.begin(),
emptyObjectsListsToBeDeclared.end());
return allObjectListsToBeDeclared;
return allObjectListsToBeDeclared;
}
unsigned int EventsCodeGenerationContext::GetLastDepthObjectListWasNeeded(const gd::String & name) const
{
if ( depthOfLastUse.count(name) != 0 )
return depthOfLastUse.find(name)->second;
unsigned int EventsCodeGenerationContext::GetLastDepthObjectListWasNeeded(
const gd::String& name) const {
if (depthOfLastUse.count(name) != 0) return depthOfLastUse.find(name)->second;
std::cout << "WARNING: During code generation, the last depth of an object list was 0." << std::endl;
return 0;
std::cout << "WARNING: During code generation, the last depth of an object "
"list was 0."
<< std::endl;
return 0;
}
bool EventsCodeGenerationContext::IsSameObjectsList(const gd::String & objectName, const EventsCodeGenerationContext & otherContext) const
{
return GetLastDepthObjectListWasNeeded(objectName) == otherContext.GetLastDepthObjectListWasNeeded(objectName);
bool EventsCodeGenerationContext::IsSameObjectsList(
const gd::String& objectName,
const EventsCodeGenerationContext& otherContext) const {
return GetLastDepthObjectListWasNeeded(objectName) ==
otherContext.GetLastDepthObjectListWasNeeded(objectName);
}
}
} // namespace gd

View File

@@ -1,192 +1,241 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef EVENTSCODEGENERATIONCONTEXT_H
#define EVENTSCODEGENERATIONCONTEXT_H
#include "GDCore/String.h"
#include <set>
#include <map>
#include <memory>
namespace gd { class Layout; }
#include <set>
#include "GDCore/String.h"
namespace gd {
class Layout;
}
namespace gd
{
namespace gd {
/**
* \brief Used to manage the context when generating code for events.
*
* The context refers to :
* - The objects lists being available.
* - The "current object", i.e the object being used by an action or a condition.
* - If conditions are being generated, the context keeps track of the depth of the conditions ( see GetCurrentConditionDepth )
* - The "current object", i.e the object being used by an action or a
* condition.
* - If conditions are being generated, the context keeps track of the depth of
* the conditions ( see GetCurrentConditionDepth )
* - You can also get the context depth of the last use of an object list.
*/
class GD_CORE_API EventsCodeGenerationContext
{
friend class EventsCodeGenerator;
public:
/**
* Default constructor. You may want to call InheritsFrom just after.
* \param maxDepthLevel Optional pointer to an unsigned integer that will be updated to contain the maximal scope depth reached.
*/
EventsCodeGenerationContext(unsigned int * maxDepthLevel_ = nullptr) :
contextDepth(0),
class GD_CORE_API EventsCodeGenerationContext {
friend class EventsCodeGenerator;
public:
/**
* Default constructor. You may want to call InheritsFrom just after.
* \param maxDepthLevel Optional pointer to an unsigned integer that will be
* updated to contain the maximal scope depth reached.
*/
EventsCodeGenerationContext(unsigned int* maxDepthLevel_ = nullptr)
: contextDepth(0),
customConditionDepth(0),
maxDepthLevel(maxDepthLevel_),
parent(NULL),
reuseExplicitlyForbidden(false)
{};
virtual ~EventsCodeGenerationContext() {};
reuseExplicitlyForbidden(false){};
virtual ~EventsCodeGenerationContext(){};
/**
* Call this method to make an EventsCodeGenerationContext as a "child" of another one.
* The child will then for example not declare again objects already declared by its parent.
*/
void InheritsFrom(const EventsCodeGenerationContext & parent);
/**
* Call this method to make an EventsCodeGenerationContext as a "child" of
* another one. The child will then for example not declare again objects
* already declared by its parent.
*/
void InheritsFrom(const EventsCodeGenerationContext& parent);
/**
* \brief As InheritsFrom, mark the context as being the child of another one, but enabling
* the child context to use the same object lists.
*
* Used for example for optimizing the last event of a list.
*/
void Reuse(const EventsCodeGenerationContext & parent);
/**
* \brief As InheritsFrom, mark the context as being the child of another one,
* but enabling the child context to use the same object lists.
*
* Used for example for optimizing the last event of a list.
*/
void Reuse(const EventsCodeGenerationContext& parent);
/**
* \brief Forbid any optimization that would reuse and modify the object list from this context
* in children context.
*
* Used in while/for each/repeat or any event that have a loop and must ensure that
* the list of objects stay clean.
*/
void ForbidReuse() { reuseExplicitlyForbidden = true; }
/**
* \brief Forbid any optimization that would reuse and modify the object list
* from this context in children context.
*
* Used in while/for each/repeat or any event that have a loop and must ensure
* that the list of objects stay clean.
*/
void ForbidReuse() { reuseExplicitlyForbidden = true; }
/**
* \brief Return false if the object lists of the context can not be reused in a child context.
*/
bool CanReuse() const { return !reuseExplicitlyForbidden && parent != nullptr; }
/**
* \brief Return false if the object lists of the context can not be reused in
* a child context.
*/
bool CanReuse() const {
return !reuseExplicitlyForbidden && parent != nullptr;
}
/**
* \brief Returns the depth of the inheritance of the context.
*
* A context created from scratch will returns 0, and a context inheriting from a context with depth n will returns n+1.
*/
size_t GetContextDepth() const { return contextDepth; }
/**
* \brief Returns the depth of the inheritance of the context.
*
* A context created from scratch will returns 0, and a context inheriting
* from a context with depth n will returns n+1.
*/
size_t GetContextDepth() const { return contextDepth; }
/**
* \brief Get the parent context, if any.
* \return A pointer to the parent context, or NULL if the context has no parent.
*/
const EventsCodeGenerationContext * GetParentContext() const { return parent; }
/**
* \brief Get the parent context, if any.
* \return A pointer to the parent context, or NULL if the context has no
* parent.
*/
const EventsCodeGenerationContext* GetParentContext() const { return parent; }
/**
* Mark the object has being the object being handled by the instruction
*/
void SetCurrentObject(const gd::String & objectName) { currentObject = objectName; };
/**
* Mark the object has being the object being handled by the instruction
*/
void SetCurrentObject(const gd::String& objectName) {
currentObject = objectName;
};
/**
* Set that no particular object is being handled by an instruction
*/
void SetNoCurrentObject() { currentObject = ""; };
/**
* Set that no particular object is being handled by an instruction
*/
void SetNoCurrentObject() { currentObject = ""; };
/**
* Get the object being handled by the instruction
*/
const gd::String & GetCurrentObject() const { return currentObject; };
/**
* Get the object being handled by the instruction
*/
const gd::String& GetCurrentObject() const { return currentObject; };
/**
* \brief Call this when an instruction in the event need an object list.
*
* The list will be filled with objects from the scene if it is the first time it is requested, unless there is
* already an object list with this name ( i.e. ObjectAlreadyDeclared(objectName) returns true ).
*/
void ObjectsListNeeded(const gd::String & objectName);
/**
* \brief Call this when an instruction in the event need an object list.
*
* The list will be filled with objects from the scene if it is the first time
* it is requested, unless there is already an object list with this name (
* i.e. ObjectAlreadyDeclared(objectName) returns true ).
*/
void ObjectsListNeeded(const gd::String& objectName);
/**
* Call this when an instruction in the event need an object list.
* An empty event list will be declared, without filling it with objects from the scene. If there is already an object
* list with this name, no new list will be declared again.
*/
void EmptyObjectsListNeeded(const gd::String & objectName);
/**
* Call this when an instruction in the event need an object list.
* An empty event list will be declared, without filling it with objects from
* the scene. If there is already an object list with this name, no new list
* will be declared again.
*/
void EmptyObjectsListNeeded(const gd::String& objectName);
/**
* Return true if an object list has already been declared (or is going to be declared).
*/
bool ObjectAlreadyDeclared(const gd::String & objectName) const { return (alreadyDeclaredObjectsLists.find(objectName) != alreadyDeclaredObjectsLists.end()); };
/**
* Return true if an object list has already been declared (or is going to be
* declared).
*/
bool ObjectAlreadyDeclared(const gd::String& objectName) const {
return (alreadyDeclaredObjectsLists.find(objectName) !=
alreadyDeclaredObjectsLists.end());
};
/**
* \brief Consider that \a objectName is now declared in the context.
*/
void SetObjectDeclared(const gd::String & objectName) { alreadyDeclaredObjectsLists.insert(objectName); }
/**
* \brief Consider that \a objectName is now declared in the context.
*/
void SetObjectDeclared(const gd::String& objectName) {
alreadyDeclaredObjectsLists.insert(objectName);
}
/**
* Return all the objects lists which will be declared by the current context
* ( the non empty as well as the empty objects lists )
*/
std::set<gd::String> GetAllObjectsToBeDeclared() const;
/**
* Return all the objects lists which will be declared by the current context
* ( the non empty as well as the empty objects lists )
*/
std::set<gd::String> GetAllObjectsToBeDeclared() const;
/**
* Return the objects lists which will be declared by the current context
*/
const std::set<gd::String> & GetObjectsListsToBeDeclared() const { return objectsListsToBeDeclared; };
/**
* Return the objects lists which will be declared by the current context
*/
const std::set<gd::String>& GetObjectsListsToBeDeclared() const {
return objectsListsToBeDeclared;
};
/**
* Return the objects lists which will be declared, but no filled, by the current context
*/
const std::set<gd::String> & GetObjectsListsToBeDeclaredEmpty() const { return emptyObjectsListsToBeDeclared; };
/**
* Return the objects lists which will be declared, but no filled, by the
* current context
*/
const std::set<gd::String>& GetObjectsListsToBeDeclaredEmpty() const {
return emptyObjectsListsToBeDeclared;
};
/**
* Return the objects lists which are already declared and can be used in the current context without declaration.
*/
const std::set<gd::String> & GetObjectsListsAlreadyDeclared() const { return alreadyDeclaredObjectsLists; };
/**
* Return the objects lists which are already declared and can be used in the
* current context without declaration.
*/
const std::set<gd::String>& GetObjectsListsAlreadyDeclared() const {
return alreadyDeclaredObjectsLists;
};
/**
* \brief Get the depth of the context that was in effect when \a objectName was needed.
*
* If \a objectName is needed in this context, it will return the depth of this context.
*/
unsigned int GetLastDepthObjectListWasNeeded(const gd::String & objectName) const;
/**
* \brief Get the depth of the context that was in effect when \a objectName
* was needed.
*
* If \a objectName is needed in this context, it will return the depth of
* this context.
*/
unsigned int GetLastDepthObjectListWasNeeded(
const gd::String& objectName) const;
/**
* \brief Check if twos context have the same list for an object.
*
* This can be the case when a context is reusing the lists of another (see gd::EventsCodeGenerationContext::Reuse).
*/
bool IsSameObjectsList(const gd::String & objectName, const EventsCodeGenerationContext & otherContext) const;
/**
* \brief Check if twos context have the same list for an object.
*
* This can be the case when a context is reusing the lists of another (see
* gd::EventsCodeGenerationContext::Reuse).
*/
bool IsSameObjectsList(const gd::String& objectName,
const EventsCodeGenerationContext& otherContext) const;
/**
* \brief Called when a custom condition code is generated.
*/
void EnterCustomCondition() { customConditionDepth++; };
/**
* \brief Called when a custom condition code is generated.
*/
void EnterCustomCondition() { customConditionDepth++; };
/**
* \brief Called when a custom condition code generation is over.
*/
void LeaveCustomCondition() { customConditionDepth--; };
/**
* \brief Called when a custom condition code generation is over.
*/
void LeaveCustomCondition() { customConditionDepth--; };
/**
* \brief Get the current condition depth : The depth is increased each time a custom condition code is generated,
* and decreased when the condition generation is done.
*
* This can be useful to generate sub conditions booleans with a different name than the parent's conditions.
*/
size_t GetCurrentConditionDepth() const { return customConditionDepth; }
/**
* \brief Get the current condition depth : The depth is increased each time a
* custom condition code is generated, and decreased when the condition
* generation is done.
*
* This can be useful to generate sub conditions booleans with a different
* name than the parent's conditions.
*/
size_t GetCurrentConditionDepth() const { return customConditionDepth; }
private:
std::set<gd::String> alreadyDeclaredObjectsLists; ///< Objects lists already needed in a parent context.
std::set<gd::String> objectsListsToBeDeclared; ///< Objects lists that will be declared in this context.
std::set<gd::String> emptyObjectsListsToBeDeclared; ///< Objects lists that will be declared in this context, but not filled with scene's objects.
std::map<gd::String, unsigned int> depthOfLastUse; ///< The context depth when an object was last used.
gd::String currentObject; ///< The object being used by an action or condition.
unsigned int contextDepth; ///< The depth of the context : 0 for a newly created context, n+1 for any context inheriting from context with depth n.
unsigned int customConditionDepth; ///< The depth of the conditions being generated.
unsigned int * maxDepthLevel; ///< A pointer to a unsigned int updated with the maximum depth reached.
const EventsCodeGenerationContext * parent; ///< The parent of the current context. Can be NULL.
bool reuseExplicitlyForbidden; ///< If set to true, forbid children context to reuse this one without inheriting.
private:
std::set<gd::String>
alreadyDeclaredObjectsLists; ///< Objects lists already needed in a
///< parent context.
std::set<gd::String>
objectsListsToBeDeclared; ///< Objects lists that will be declared in
///< this context.
std::set<gd::String>
emptyObjectsListsToBeDeclared; ///< Objects lists that will be declared
///< in this context, but not filled with
///< scene's objects.
std::map<gd::String, unsigned int>
depthOfLastUse; ///< The context depth when an object was last used.
gd::String
currentObject; ///< The object being used by an action or condition.
unsigned int contextDepth; ///< The depth of the context : 0 for a newly
///< created context, n+1 for any context
///< inheriting from context with depth n.
unsigned int
customConditionDepth; ///< The depth of the conditions being generated.
unsigned int* maxDepthLevel; ///< A pointer to a unsigned int updated with
///< the maximum depth reached.
const EventsCodeGenerationContext*
parent; ///< The parent of the current context. Can be NULL.
bool reuseExplicitlyForbidden; ///< If set to true, forbid children context
///< to reuse this one without inheriting.
};
}
#endif // EVENTSCODEGENERATIONCONTEXT_H
} // namespace gd
#endif // EVENTSCODEGENERATIONCONTEXT_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,200 +1,229 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "ExpressionsCodeGeneration.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Project/Layout.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/Parsers/ExpressionParser.h"
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
#include "GDCore/Extensions/Metadata/BehaviorMetadata.h"
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
#include "GDCore/Extensions/Metadata/ObjectMetadata.h"
#include "GDCore/Extensions/Platform.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
#include "GDCore/Events/Parsers/ExpressionParser.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
#include "GDCore/Extensions/Metadata/ObjectMetadata.h"
#include "GDCore/Extensions/Metadata/BehaviorMetadata.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Project/Layout.h"
#include "GDCore/Project/Project.h"
using namespace std;
namespace gd
{
namespace gd {
CallbacksForGeneratingExpressionCode::CallbacksForGeneratingExpressionCode(gd::String & plainExpression_,
EventsCodeGenerator & codeGenerator_,
EventsCodeGenerationContext & context_) :
plainExpression(plainExpression_),
codeGenerator(codeGenerator_),
context(context_)
{
CallbacksForGeneratingExpressionCode::CallbacksForGeneratingExpressionCode(
gd::String& plainExpression_,
EventsCodeGenerator& codeGenerator_,
EventsCodeGenerationContext& context_)
: plainExpression(plainExpression_),
codeGenerator(codeGenerator_),
context(context_) {}
}
void CallbacksForGeneratingExpressionCode::OnConstantToken(gd::String text)
{
plainExpression += text;
void CallbacksForGeneratingExpressionCode::OnConstantToken(gd::String text) {
plainExpression += text;
};
void CallbacksForGeneratingExpressionCode::OnStaticFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo)
{
codeGenerator.AddIncludeFiles(expressionInfo.codeExtraInformation.GetIncludeFiles());
void CallbacksForGeneratingExpressionCode::OnStaticFunction(
gd::String functionName,
const std::vector<gd::Expression>& parameters,
const gd::ExpressionMetadata& expressionInfo) {
codeGenerator.AddIncludeFiles(
expressionInfo.codeExtraInformation.GetIncludeFiles());
//Launch custom code generator if needed
if (expressionInfo.codeExtraInformation.HasCustomCodeGenerator())
{
plainExpression += expressionInfo.codeExtraInformation.customCodeGenerator(parameters, codeGenerator, context);
return;
}
// Launch custom code generator if needed
if (expressionInfo.codeExtraInformation.HasCustomCodeGenerator()) {
plainExpression += expressionInfo.codeExtraInformation.customCodeGenerator(
parameters, codeGenerator, context);
return;
}
//Special case: For strings expressions, function without name is a string.
if ( GetReturnType() == "string" && functionName.empty() )
{
if ( parameters.empty() ) return;
plainExpression += codeGenerator.ConvertToStringExplicit(parameters[0].GetPlainString());
// Special case: For strings expressions, function without name is a string.
if (GetReturnType() == "string" && functionName.empty()) {
if (parameters.empty()) return;
plainExpression +=
codeGenerator.ConvertToStringExplicit(parameters[0].GetPlainString());
return;
}
return;
}
//Prepare parameters
std::vector<gd::String> parametersCode = codeGenerator.GenerateParametersCodes(parameters, expressionInfo.parameters, context);
gd::String parametersStr;
for (std::size_t i = 0;i<parametersCode.size();++i)
{
if ( i != 0 ) parametersStr += ", ";
parametersStr += parametersCode[i];
}
// Prepare parameters
std::vector<gd::String> parametersCode =
codeGenerator.GenerateParametersCodes(
parameters, expressionInfo.parameters, context);
gd::String parametersStr;
for (std::size_t i = 0; i < parametersCode.size(); ++i) {
if (i != 0) parametersStr += ", ";
parametersStr += parametersCode[i];
}
plainExpression += expressionInfo.codeExtraInformation.functionCallName+"("+parametersStr+")";
plainExpression += expressionInfo.codeExtraInformation.functionCallName +
"(" + parametersStr + ")";
};
void CallbacksForGeneratingExpressionCode::OnObjectFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo)
{
const gd::Project & project = codeGenerator.GetProject();
const gd::Layout & scene = codeGenerator.GetLayout();
void CallbacksForGeneratingExpressionCode::OnObjectFunction(
gd::String functionName,
const std::vector<gd::Expression>& parameters,
const gd::ExpressionMetadata& expressionInfo) {
const gd::Project& project = codeGenerator.GetProject();
const gd::Layout& scene = codeGenerator.GetLayout();
codeGenerator.AddIncludeFiles(expressionInfo.codeExtraInformation.GetIncludeFiles());
if ( parameters.empty() ) return;
codeGenerator.AddIncludeFiles(
expressionInfo.codeExtraInformation.GetIncludeFiles());
if (parameters.empty()) return;
//Launch custom code generator if needed
if ( expressionInfo.codeExtraInformation.HasCustomCodeGenerator() )
{
plainExpression += expressionInfo.codeExtraInformation.customCodeGenerator(parameters, codeGenerator, context);
return;
}
// Launch custom code generator if needed
if (expressionInfo.codeExtraInformation.HasCustomCodeGenerator()) {
plainExpression += expressionInfo.codeExtraInformation.customCodeGenerator(
parameters, codeGenerator, context);
return;
}
//Prepare parameters
std::vector<gd::String> parametersCode = codeGenerator.GenerateParametersCodes(parameters, expressionInfo.parameters, context);
gd::String parametersStr;
for (std::size_t i = 1;i<parametersCode.size();++i)
{
if ( i != 1 ) parametersStr += ", ";
parametersStr += parametersCode[i];
}
// Prepare parameters
std::vector<gd::String> parametersCode =
codeGenerator.GenerateParametersCodes(
parameters, expressionInfo.parameters, context);
gd::String parametersStr;
for (std::size_t i = 1; i < parametersCode.size(); ++i) {
if (i != 1) parametersStr += ", ";
parametersStr += parametersCode[i];
}
gd::String output = GetReturnType() == "string" ? "\"\"" : "0";
gd::String output = GetReturnType() == "string" ? "\"\"" : "0";
//Get object(s) concerned by function call
std::vector<gd::String> realObjects = codeGenerator. ExpandObjectsName(parameters[0].GetPlainString(), context);
for (std::size_t i = 0;i<realObjects.size();++i)
{
context.ObjectsListNeeded(realObjects[i]);
// Get object(s) concerned by function call
std::vector<gd::String> realObjects =
codeGenerator.ExpandObjectsName(parameters[0].GetPlainString(), context);
for (std::size_t i = 0; i < realObjects.size(); ++i) {
context.ObjectsListNeeded(realObjects[i]);
gd::String objectType = gd::GetTypeOfObject(project, scene, realObjects[i]);
const ObjectMetadata & objInfo = MetadataProvider::GetObjectMetadata(codeGenerator.GetPlatform(), objectType);
gd::String objectType = gd::GetTypeOfObject(project, scene, realObjects[i]);
const ObjectMetadata& objInfo = MetadataProvider::GetObjectMetadata(
codeGenerator.GetPlatform(), objectType);
//Build gd::String to access the object
codeGenerator.AddIncludeFiles(objInfo.includeFiles);
output = codeGenerator.GenerateObjectFunctionCall(realObjects[i], objInfo, expressionInfo.codeExtraInformation, parametersStr, output, context);
}
// Build gd::String to access the object
codeGenerator.AddIncludeFiles(objInfo.includeFiles);
output = codeGenerator.GenerateObjectFunctionCall(
realObjects[i],
objInfo,
expressionInfo.codeExtraInformation,
parametersStr,
output,
context);
}
plainExpression += output;
plainExpression += output;
};
void CallbacksForGeneratingExpressionCode::OnObjectBehaviorFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo)
{
const gd::Project & project = codeGenerator.GetProject();
const gd::Layout & scene = codeGenerator.GetLayout();
void CallbacksForGeneratingExpressionCode::OnObjectBehaviorFunction(
gd::String functionName,
const std::vector<gd::Expression>& parameters,
const gd::ExpressionMetadata& expressionInfo) {
const gd::Project& project = codeGenerator.GetProject();
const gd::Layout& scene = codeGenerator.GetLayout();
codeGenerator.AddIncludeFiles(expressionInfo.codeExtraInformation.GetIncludeFiles());
if ( parameters.size() < 2 ) return;
codeGenerator.AddIncludeFiles(
expressionInfo.codeExtraInformation.GetIncludeFiles());
if (parameters.size() < 2) return;
//Launch custom code generator if needed
if ( expressionInfo.codeExtraInformation.HasCustomCodeGenerator() )
{
plainExpression += expressionInfo.codeExtraInformation.customCodeGenerator(parameters, codeGenerator, context);
return;
}
// Launch custom code generator if needed
if (expressionInfo.codeExtraInformation.HasCustomCodeGenerator()) {
plainExpression += expressionInfo.codeExtraInformation.customCodeGenerator(
parameters, codeGenerator, context);
return;
}
//Prepare parameters
std::vector<gd::String> parametersCode = codeGenerator.GenerateParametersCodes(parameters, expressionInfo.parameters, context);
gd::String parametersStr;
for (std::size_t i = 2;i<parametersCode.size();++i)
{
if ( i != 2 ) parametersStr += ", ";
parametersStr += parametersCode[i];
}
// Prepare parameters
std::vector<gd::String> parametersCode =
codeGenerator.GenerateParametersCodes(
parameters, expressionInfo.parameters, context);
gd::String parametersStr;
for (std::size_t i = 2; i < parametersCode.size(); ++i) {
if (i != 2) parametersStr += ", ";
parametersStr += parametersCode[i];
}
//Get object(s) concerned by function call
std::vector<gd::String> realObjects = codeGenerator. ExpandObjectsName(parameters[0].GetPlainString(), context);
// Get object(s) concerned by function call
std::vector<gd::String> realObjects =
codeGenerator.ExpandObjectsName(parameters[0].GetPlainString(), context);
gd::String output = GetReturnType() == "string" ? "\"\"" : "0";
for (std::size_t i = 0;i<realObjects.size();++i)
{
context.ObjectsListNeeded(realObjects[i]);
gd::String output = GetReturnType() == "string" ? "\"\"" : "0";
for (std::size_t i = 0; i < realObjects.size(); ++i) {
context.ObjectsListNeeded(realObjects[i]);
//Cast the object if needed
gd::String behaviorType = gd::GetTypeOfBehavior(project, scene, parameters[1].GetPlainString());
const BehaviorMetadata & autoInfo = MetadataProvider::GetBehaviorMetadata(codeGenerator.GetPlatform(), behaviorType);
// Cast the object if needed
gd::String behaviorType =
gd::GetTypeOfBehavior(project, scene, parameters[1].GetPlainString());
const BehaviorMetadata& autoInfo = MetadataProvider::GetBehaviorMetadata(
codeGenerator.GetPlatform(), behaviorType);
//Build gd::String to access the behavior
codeGenerator.AddIncludeFiles(autoInfo.includeFiles);
output = codeGenerator.GenerateObjectBehaviorFunctionCall(realObjects[i], parameters[1].GetPlainString(), autoInfo, expressionInfo.codeExtraInformation, parametersStr, output, context);
}
// Build gd::String to access the behavior
codeGenerator.AddIncludeFiles(autoInfo.includeFiles);
output = codeGenerator.GenerateObjectBehaviorFunctionCall(
realObjects[i],
parameters[1].GetPlainString(),
autoInfo,
expressionInfo.codeExtraInformation,
parametersStr,
output,
context);
}
plainExpression += output;
plainExpression += output;
};
bool CallbacksForGeneratingExpressionCode::OnSubMathExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::Expression & expression)
{
gd::String newExpression;
bool CallbacksForGeneratingExpressionCode::OnSubMathExpression(
const gd::Platform& platform,
const gd::Project& project,
const gd::Layout& layout,
gd::Expression& expression) {
gd::String newExpression;
CallbacksForGeneratingExpressionCode callbacks(newExpression, codeGenerator, context);
CallbacksForGeneratingExpressionCode callbacks(
newExpression, codeGenerator, context);
gd::ExpressionParser parser(expression.GetPlainString());
if ( !parser.ParseMathExpression(platform, project, layout, callbacks) )
{
#if defined(GD_IDE_ONLY)
firstErrorStr = callbacks.GetFirstError();
firstErrorPos = callbacks.GetFirstErrorPosition();
#endif
return false;
}
gd::ExpressionParser parser(expression.GetPlainString());
if (!parser.ParseMathExpression(platform, project, layout, callbacks)) {
#if defined(GD_IDE_ONLY)
firstErrorStr = callbacks.GetFirstError();
firstErrorPos = callbacks.GetFirstErrorPosition();
#endif
return false;
}
return true;
return true;
}
bool CallbacksForGeneratingExpressionCode::OnSubTextExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::Expression & expression)
{
gd::String newExpression;
bool CallbacksForGeneratingExpressionCode::OnSubTextExpression(
const gd::Platform& platform,
const gd::Project& project,
const gd::Layout& layout,
gd::Expression& expression) {
gd::String newExpression;
CallbacksForGeneratingExpressionCode callbacks(newExpression, codeGenerator, context);
CallbacksForGeneratingExpressionCode callbacks(
newExpression, codeGenerator, context);
gd::ExpressionParser parser(expression.GetPlainString());
if ( !parser.ParseStringExpression(platform, project, layout, callbacks) )
{
#if defined(GD_IDE_ONLY)
firstErrorStr = callbacks.GetFirstError();
firstErrorPos = callbacks.GetFirstErrorPosition();
#endif
return false;
}
gd::ExpressionParser parser(expression.GetPlainString());
if (!parser.ParseStringExpression(platform, project, layout, callbacks)) {
#if defined(GD_IDE_ONLY)
firstErrorStr = callbacks.GetFirstError();
firstErrorPos = callbacks.GetFirstErrorPosition();
#endif
return false;
}
return true;
return true;
}
}
} // namespace gd

View File

@@ -1,24 +1,37 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef EXPRESSIONSCODEGENERATION_H
#define EXPRESSIONSCODEGENERATION_H
#include <vector>
#include "GDCore/String.h"
#include "GDCore/Events/Parsers/ExpressionParser.h"
namespace gd { class ExpressionMetadata; }
namespace gd { class Expression; }
namespace gd { class Project; }
namespace gd { class Layout; }
namespace gd { class Layout; }
namespace gd { class EventsCodeGenerationContext; }
namespace gd { class EventsCodeGenerator; }
#include "GDCore/String.h"
namespace gd {
class ExpressionMetadata;
}
namespace gd {
class Expression;
}
namespace gd {
class Project;
}
namespace gd {
class Layout;
}
namespace gd {
class Layout;
}
namespace gd {
class EventsCodeGenerationContext;
}
namespace gd {
class EventsCodeGenerator;
}
namespace gd
{
namespace gd {
/**
* \brief Used to generate code from expressions.
@@ -27,33 +40,48 @@ namespace gd
* \code
* gd::String expressionOutputCppCode;
*
* CallbacksForGeneratingExpressionCode callbacks(expressionOutputCppCode, codeGenerator, context);
* gd::ExpressionParser parser(theOriginalGameDevelopExpression);
* CallbacksForGeneratingExpressionCode callbacks(expressionOutputCppCode,
* codeGenerator, context); gd::ExpressionParser
* parser(theOriginalGameDevelopExpression);
* parser.ParseStringExpression(platform, project, scene, callbacks);
*
* if (expressionOutputCppCode.empty()) expressionOutputCppCode = "\"\""; //If generation failed, we make sure output code is not empty.
* \endcode
* \see EventsCodeGenerator
* if (expressionOutputCppCode.empty()) expressionOutputCppCode = "\"\""; //If
* generation failed, we make sure output code is not empty. \endcode \see
* EventsCodeGenerator
*/
class GD_CORE_API CallbacksForGeneratingExpressionCode : public gd::ParserCallbacks
{
public:
CallbacksForGeneratingExpressionCode(gd::String & output, EventsCodeGenerator & codeGenerator_, EventsCodeGenerationContext & context_);
virtual ~CallbacksForGeneratingExpressionCode() {};
class GD_CORE_API CallbacksForGeneratingExpressionCode
: public gd::ParserCallbacks {
public:
CallbacksForGeneratingExpressionCode(gd::String& output,
EventsCodeGenerator& codeGenerator_,
EventsCodeGenerationContext& context_);
virtual ~CallbacksForGeneratingExpressionCode(){};
void OnConstantToken(gd::String text);
void OnStaticFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo);
void OnObjectFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo);
void OnObjectBehaviorFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo);
bool OnSubMathExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::Expression & expression);
bool OnSubTextExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::Expression & expression);
void OnConstantToken(gd::String text);
void OnStaticFunction(gd::String functionName,
const std::vector<gd::Expression>& parameters,
const gd::ExpressionMetadata& expressionInfo);
void OnObjectFunction(gd::String functionName,
const std::vector<gd::Expression>& parameters,
const gd::ExpressionMetadata& expressionInfo);
void OnObjectBehaviorFunction(gd::String functionName,
const std::vector<gd::Expression>& parameters,
const gd::ExpressionMetadata& expressionInfo);
bool OnSubMathExpression(const gd::Platform& platform,
const gd::Project& project,
const gd::Layout& layout,
gd::Expression& expression);
bool OnSubTextExpression(const gd::Platform& platform,
const gd::Project& project,
const gd::Layout& layout,
gd::Expression& expression);
private:
gd::String & plainExpression;
EventsCodeGenerator & codeGenerator;
EventsCodeGenerationContext & context;
private:
gd::String& plainExpression;
EventsCodeGenerator& codeGenerator;
EventsCodeGenerationContext& context;
};
}
} // namespace gd
#endif // EXPRESSIONSCODEGENERATION_H
#endif // EXPRESSIONSCODEGENERATION_H

View File

@@ -1,120 +1,120 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GDCore/Events/Event.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
#include "GDCore/Events/EventsList.h"
#include "GDCore/Extensions/Platform.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
namespace gd
{
namespace gd {
EventsList BaseEvent::badSubEvents;
std::vector< gd::String > BaseEvent::emptyDependencies;
std::vector<gd::String> BaseEvent::emptyDependencies;
gd::String BaseEvent::emptySourceFile;
BaseEvent::BaseEvent() :
eventHeightNeedUpdate(true),
totalTimeDuringLastSession(0),
percentDuringLastSession(0),
disabled(false),
folded(false)
{
}
BaseEvent::BaseEvent()
: eventHeightNeedUpdate(true),
totalTimeDuringLastSession(0),
percentDuringLastSession(0),
disabled(false),
folded(false) {}
bool BaseEvent::HasSubEvents() const
{
return !GetSubEvents().IsEmpty();
}
bool BaseEvent::HasSubEvents() const { return !GetSubEvents().IsEmpty(); }
gd::String BaseEvent::GenerateEventCode(gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
{
if ( IsDisabled() ) return "";
gd::String BaseEvent::GenerateEventCode(
gd::EventsCodeGenerator& codeGenerator,
gd::EventsCodeGenerationContext& context) {
if (IsDisabled()) return "";
try
{
if ( type.empty() ) return "";
try {
if (type.empty()) return "";
const gd::Platform & platform = codeGenerator.GetPlatform();
const gd::Platform& platform = codeGenerator.GetPlatform();
//First try to guess the extension used
gd::String eventNamespace = type.substr(0, type.find("::"));
std::shared_ptr<gd::PlatformExtension> guessedExtension = platform.GetExtension(eventNamespace);
if ( guessedExtension )
{
std::map<gd::String, gd::EventMetadata > & allEvents = guessedExtension->GetAllEvents();
if ( allEvents.find(type) != allEvents.end() )
return allEvents[type].codeGeneration(*this, codeGenerator, context);
}
//Else make a search in all the extensions
for (std::size_t i = 0; i < platform.GetAllPlatformExtensions().size(); ++i)
{
std::shared_ptr<gd::PlatformExtension> extension = platform.GetAllPlatformExtensions()[i];
if ( !extension ) continue;
std::map<gd::String, gd::EventMetadata > & allEvents = extension->GetAllEvents();
if ( allEvents.find(type) != allEvents.end() )
return allEvents[type].codeGeneration(*this, codeGenerator, context);
}
}
catch(...)
{
std::cout << "ERROR: Exception caught during code generation for event \"" << type <<"\"." << std::endl;
// First try to guess the extension used
gd::String eventNamespace = type.substr(0, type.find("::"));
std::shared_ptr<gd::PlatformExtension> guessedExtension =
platform.GetExtension(eventNamespace);
if (guessedExtension) {
std::map<gd::String, gd::EventMetadata>& allEvents =
guessedExtension->GetAllEvents();
if (allEvents.find(type) != allEvents.end())
return allEvents[type].codeGeneration(*this, codeGenerator, context);
}
return "";
}
// Else make a search in all the extensions
for (std::size_t i = 0; i < platform.GetAllPlatformExtensions().size();
++i) {
std::shared_ptr<gd::PlatformExtension> extension =
platform.GetAllPlatformExtensions()[i];
if (!extension) continue;
void BaseEvent::Preprocess(gd::EventsCodeGenerator & codeGenerator, gd::EventsList & eventList, std::size_t indexOfTheEventInThisList)
{
if ( IsDisabled() || !MustBePreprocessed() ) return;
try
{
if ( type.empty() ) return;
const gd::Platform & platform = codeGenerator.GetPlatform();
//First try to guess the extension used
gd::String eventNamespace = type.substr(0, type.find("::"));
std::shared_ptr<gd::PlatformExtension> guessedExtension = platform.GetExtension(eventNamespace);
if ( guessedExtension )
{
std::map<gd::String, gd::EventMetadata > & allEvents = guessedExtension->GetAllEvents();
if ( allEvents.find(type) != allEvents.end() )
return allEvents[type].preprocessing(*this, codeGenerator, eventList, indexOfTheEventInThisList);
}
//Else make a search in all the extensions
for (std::size_t i = 0;i<platform.GetAllPlatformExtensions().size();++i)
{
std::shared_ptr<gd::PlatformExtension> extension = platform.GetAllPlatformExtensions()[i];
if ( !extension ) continue;
std::map<gd::String, gd::EventMetadata > & allEvents = extension->GetAllEvents();
if ( allEvents.find(type) != allEvents.end() )
return allEvents[type].preprocessing(*this, codeGenerator, eventList, indexOfTheEventInThisList);
}
std::map<gd::String, gd::EventMetadata>& allEvents =
extension->GetAllEvents();
if (allEvents.find(type) != allEvents.end())
return allEvents[type].codeGeneration(*this, codeGenerator, context);
}
catch(...)
{
std::cout << "ERROR: Exception caught during preprocessing of event \"" << type <<"\"." << std::endl;
} catch (...) {
std::cout << "ERROR: Exception caught during code generation for event \""
<< type << "\"." << std::endl;
}
return "";
}
void BaseEvent::Preprocess(gd::EventsCodeGenerator& codeGenerator,
gd::EventsList& eventList,
std::size_t indexOfTheEventInThisList) {
if (IsDisabled() || !MustBePreprocessed()) return;
try {
if (type.empty()) return;
const gd::Platform& platform = codeGenerator.GetPlatform();
// First try to guess the extension used
gd::String eventNamespace = type.substr(0, type.find("::"));
std::shared_ptr<gd::PlatformExtension> guessedExtension =
platform.GetExtension(eventNamespace);
if (guessedExtension) {
std::map<gd::String, gd::EventMetadata>& allEvents =
guessedExtension->GetAllEvents();
if (allEvents.find(type) != allEvents.end())
return allEvents[type].preprocessing(
*this, codeGenerator, eventList, indexOfTheEventInThisList);
}
// Else make a search in all the extensions
for (std::size_t i = 0; i < platform.GetAllPlatformExtensions().size();
++i) {
std::shared_ptr<gd::PlatformExtension> extension =
platform.GetAllPlatformExtensions()[i];
if (!extension) continue;
std::map<gd::String, gd::EventMetadata>& allEvents =
extension->GetAllEvents();
if (allEvents.find(type) != allEvents.end())
return allEvents[type].preprocessing(
*this, codeGenerator, eventList, indexOfTheEventInThisList);
}
} catch (...) {
std::cout << "ERROR: Exception caught during preprocessing of event \""
<< type << "\"." << std::endl;
}
}
BaseEventSPtr GD_CORE_API CloneRememberingOriginalEvent(BaseEventSPtr event)
{
gd::BaseEventSPtr copy(event->Clone());
//Original event is either the original event of the copied event, or the event copied.
copy->originalEvent = event->originalEvent.expired() ? event : event->originalEvent;
BaseEventSPtr GD_CORE_API CloneRememberingOriginalEvent(BaseEventSPtr event) {
gd::BaseEventSPtr copy(event->Clone());
// Original event is either the original event of the copied event, or the
// event copied.
copy->originalEvent =
event->originalEvent.expired() ? event : event->originalEvent;
return copy;
return copy;
}
}
} // namespace gd

View File

@@ -1,36 +1,55 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#ifndef GDCORE_EVENT_H
#define GDCORE_EVENT_H
#include <iostream>
#include <vector>
#include "GDCore/String.h"
#include <vector>
#include <memory>
#include <memory>
#include <vector>
#include "GDCore/Events/Instruction.h"
#include "GDCore/Events/InstructionsList.h"
namespace gd { class EventsList; }
namespace gd { class MainFrameWrapper; }
namespace gd { class Project; }
namespace gd { class Layout; }
namespace gd { class EventsCodeGenerator; }
namespace gd { class EventsCodeGenerationContext; }
namespace gd { class Platform; }
#include "GDCore/String.h"
namespace gd {
class EventsList;
}
namespace gd {
class MainFrameWrapper;
}
namespace gd {
class Project;
}
namespace gd {
class Layout;
}
namespace gd {
class EventsCodeGenerator;
}
namespace gd {
class EventsCodeGenerationContext;
}
namespace gd {
class Platform;
}
class wxWindow;
namespace gd { class EventsEditorItemsAreas; }
namespace gd { class EventsEditorSelection; }
namespace gd { class SerializerElement; }
namespace gd { class Instruction; }
namespace gd {
class EventsEditorItemsAreas;
}
namespace gd {
class EventsEditorSelection;
}
namespace gd {
class SerializerElement;
}
namespace gd {
class Instruction;
}
class wxDC;
namespace gd
{
namespace gd {
class BaseEvent;
typedef std::shared_ptr<BaseEvent> BaseEventSPtr;
@@ -38,256 +57,326 @@ typedef std::shared_ptr<BaseEvent> BaseEventSPtr;
/**
* \brief Base class defining an event.
*
* Events are usually not instance of Base Event, but instance of a derived class.
* Events are usually not instance of Base Event, but instance of a derived
* class.
*
* \ingroup Events
*/
class GD_CORE_API BaseEvent
{
public:
BaseEvent();
virtual ~BaseEvent() {};
class GD_CORE_API BaseEvent {
public:
BaseEvent();
virtual ~BaseEvent(){};
/**
* Must return a pointer to a copy of the event.
* A such method is needed as the IDE may want to store copies of some events and so need a way to do polymorphic copies.
*
* Typical implementation example:
* \code
* return new MyEventClass(*this);
* \endcode
*/
virtual gd::BaseEvent * Clone() const { return new BaseEvent(*this);}
/**
* Must return a pointer to a copy of the event.
* A such method is needed as the IDE may want to store copies of some events
* and so need a way to do polymorphic copies.
*
* Typical implementation example:
* \code
* return new MyEventClass(*this);
* \endcode
*/
virtual gd::BaseEvent* Clone() const { return new BaseEvent(*this); }
/** \name Event properties
* Members functions to be overridden by derived classes to expose the event properties
*/
///@{
/** \name Event properties
* Members functions to be overridden by derived classes to expose the event
* properties
*/
///@{
/**
* Derived class have to redefine this function, so as to return true, if they are executable.
*/
virtual bool IsExecutable() const {return false;};
/**
* Derived class have to redefine this function, so as to return true, if they
* are executable.
*/
virtual bool IsExecutable() const { return false; };
/**
* Derived class have to redefine this function, so as to return true, if they have sub events.
*/
virtual bool CanHaveSubEvents() const {return false;}
/**
* Derived class have to redefine this function, so as to return true, if they
* have sub events.
*/
virtual bool CanHaveSubEvents() const { return false; }
/**
* Return the sub events, if applicable.
*/
virtual const gd::EventsList & GetSubEvents() const {return badSubEvents;};
/**
* Return the sub events, if applicable.
*/
virtual const gd::EventsList& GetSubEvents() const { return badSubEvents; };
/**
* Return the sub events, if applicable.
*/
virtual gd::EventsList & GetSubEvents() {return badSubEvents;};
/**
* Return the sub events, if applicable.
*/
virtual gd::EventsList& GetSubEvents() { return badSubEvents; };
/**
* \brief Return true if the events has sub events.
* \warning This is only applicable when CanHaveSubEvents() return true.
*/
bool HasSubEvents() const;
/**
* \brief Return true if the events has sub events.
* \warning This is only applicable when CanHaveSubEvents() return true.
*/
bool HasSubEvents() const;
/**
* Event must be able to return all conditions std::vector they have.
* Used to preprocess the conditions.
*/
virtual std::vector < gd::InstructionsList* > GetAllConditionsVectors() { std::vector < gd::InstructionsList* > noConditions; return noConditions; };
virtual std::vector < const gd::InstructionsList* > GetAllConditionsVectors() const { std::vector < const gd::InstructionsList* > noConditions; return noConditions; };
/**
* Event must be able to return all conditions std::vector they have.
* Used to preprocess the conditions.
*/
virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors() {
std::vector<gd::InstructionsList*> noConditions;
return noConditions;
};
virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
const {
std::vector<const gd::InstructionsList*> noConditions;
return noConditions;
};
/**
* Event must be able to return all actions std::vector they have.
* Used to preprocess the actions.
*/
virtual std::vector < gd::InstructionsList* > GetAllActionsVectors() { std::vector < gd::InstructionsList* > noActions; return noActions; };
virtual std::vector < const gd::InstructionsList* > GetAllActionsVectors() const { std::vector < const gd::InstructionsList* > noActions; return noActions; };
/**
* Event must be able to return all actions std::vector they have.
* Used to preprocess the actions.
*/
virtual std::vector<gd::InstructionsList*> GetAllActionsVectors() {
std::vector<gd::InstructionsList*> noActions;
return noActions;
};
virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors()
const {
std::vector<const gd::InstructionsList*> noActions;
return noActions;
};
/**
* Event must be able to return all expressions they have.
* Used to preprocess the expressions.
*/
virtual std::vector < gd::Expression* > GetAllExpressions() { std::vector < gd::Expression* > noExpr; return noExpr;};
virtual std::vector < const gd::Expression* > GetAllExpressions() const { std::vector < const gd::Expression* > noExpr; return noExpr;};
/**
* Event must be able to return all expressions they have.
* Used to preprocess the expressions.
*/
virtual std::vector<gd::Expression*> GetAllExpressions() {
std::vector<gd::Expression*> noExpr;
return noExpr;
};
virtual std::vector<const gd::Expression*> GetAllExpressions() const {
std::vector<const gd::Expression*> noExpr;
return noExpr;
};
/**
* \brief Returns the dependencies on source files of the project.
* \note Default implementation returns an empty list of dependencies. This is fine for most events that
* are not related to adding custom user source code.
*/
virtual const std::vector<gd::String> & GetSourceFileDependencies() const { return emptyDependencies; };
/**
* \brief Returns the dependencies on source files of the project.
* \note Default implementation returns an empty list of dependencies. This is
* fine for most events that are not related to adding custom user source
* code.
*/
virtual const std::vector<gd::String>& GetSourceFileDependencies() const {
return emptyDependencies;
};
/**
* \brief Returns the name of the source file associated with the event
* \note Default implementation returns an empty string. This is fine for most events that
* are not related to adding custom user source code.
*/
virtual const gd::String & GetAssociatedGDManagedSourceFile(gd::Project & project) const { return emptySourceFile; };
///@}
/**
* \brief Returns the name of the source file associated with the event
* \note Default implementation returns an empty string. This is fine for most
* events that are not related to adding custom user source code.
*/
virtual const gd::String& GetAssociatedGDManagedSourceFile(
gd::Project& project) const {
return emptySourceFile;
};
///@}
/** \name Code generation
* Members functions used to generate code from the event
*/
///@{
/** \name Code generation
* Members functions used to generate code from the event
*/
///@{
/**
* \brief Generate the code event: the platform provided by \a codeGenerator is asked for the EventMetadata associated to the event,
* which is then used to generate the code event.
*
* \warning Even if this method is virtual, you should never redefine it: always provide the code generation using gd::EventMetadata.
* This method is virtual as some platforms could have hidden events ( such as profiling events ) needing code generation without declaring
* the event as a part of an extension.
*
* \see gd::EventMetadata
*/
virtual gd::String GenerateEventCode(gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context);
/**
* \brief Generate the code event: the platform provided by \a codeGenerator
* is asked for the EventMetadata associated to the event, which is then used
* to generate the code event.
*
* \warning Even if this method is virtual, you should never redefine it:
* always provide the code generation using gd::EventMetadata. This method is
* virtual as some platforms could have hidden events ( such as profiling
* events ) needing code generation without declaring the event as a part of
* an extension.
*
* \see gd::EventMetadata
*/
virtual gd::String GenerateEventCode(
gd::EventsCodeGenerator& codeGenerator,
gd::EventsCodeGenerationContext& context);
/**
* Called before events are compiled: the platform provided by \a codeGenerator is asked for the EventMetadata associated to the event,
* which is then used to preprocess the event.
*
* This is only done if the event MustBePreprocessed() return true.
*
* \warning Be careful if you're iterating over a list of event, a call to Preprocess can remove the event from the list!
*
* \see gd::EventMetadata
* \see gd::BaseEvent::MustBePreprocessed
*/
virtual void Preprocess(gd::EventsCodeGenerator & codeGenerator, gd::EventsList & eventList, std::size_t indexOfTheEventInThisList);
/**
* Called before events are compiled: the platform provided by \a
* codeGenerator is asked for the EventMetadata associated to the event, which
* is then used to preprocess the event.
*
* This is only done if the event MustBePreprocessed() return true.
*
* \warning Be careful if you're iterating over a list of event, a call to
* Preprocess can remove the event from the list!
*
* \see gd::EventMetadata
* \see gd::BaseEvent::MustBePreprocessed
*/
virtual void Preprocess(gd::EventsCodeGenerator& codeGenerator,
gd::EventsList& eventList,
std::size_t indexOfTheEventInThisList);
/**
* \brief If MustBePreprocessed is redefined to return true, the gd::EventMetadata::preprocessing associated to the event will be called
* to preprocess the event.
*
* \see gd::BaseEvent::Preprocess
* \see gd::EventMetadata
*/
virtual bool MustBePreprocessed() { return false;}
///@}
/**
* \brief If MustBePreprocessed is redefined to return true, the
* gd::EventMetadata::preprocessing associated to the event will be called to
* preprocess the event.
*
* \see gd::BaseEvent::Preprocess
* \see gd::EventMetadata
*/
virtual bool MustBePreprocessed() { return false; }
///@}
/** \name Serialization
*/
///@{
/**
* \brief Serialize event.
*/
virtual void SerializeTo(SerializerElement & element) const {};
/** \name Serialization
*/
///@{
/**
* \brief Serialize event.
*/
virtual void SerializeTo(SerializerElement& element) const {};
/**
* \brief Unserialize the event.
*/
virtual void UnserializeFrom(gd::Project & project, const SerializerElement & element) {};
///@}
/**
* \brief Unserialize the event.
*/
virtual void UnserializeFrom(gd::Project& project,
const SerializerElement& element){};
///@}
/** \name Common properties
* Common method shared by all events. ( No need for them to be overridden by derived classes ).
*/
///@{
/** \name Common properties
* Common method shared by all events. ( No need for them to be overridden by
* derived classes ).
*/
///@{
/**
* \brief Return the event type
*/
const gd::String & GetType() const { return type; };
/**
* \brief Return the event type
*/
const gd::String& GetType() const { return type; };
/**
* \brief Change the event type
*/
void SetType(gd::String type_) { type = type_; };
/**
* \brief Change the event type
*/
void SetType(gd::String type_) { type = type_; };
/**
* \brief Set if the event if disabled or not
*/
void SetDisabled(bool disable = true) { disabled = disable; }
/**
* \brief Set if the event if disabled or not
*/
void SetDisabled(bool disable = true) { disabled = disable; }
/**
* \brief True if event is disabled
*/
bool IsDisabled() const { return disabled; }
/**
* \brief True if event is disabled
*/
bool IsDisabled() const { return disabled; }
/**
* \brief Set if the event must be folded (i.e: sub events must
* be hidden in the events editor).
*/
void SetFolded(bool fold = true) { folded = fold; }
/**
* \brief Set if the event must be folded (i.e: sub events must
* be hidden in the events editor).
*/
void SetFolded(bool fold = true) { folded = fold; }
/**
* \brief True if the event should be folded in the events editor.
*/
bool IsFolded() const { return folded; }
/**
* \brief True if the event should be folded in the events editor.
*/
bool IsFolded() const { return folded; }
///@}
///@}
/** \name Event rendering
* Method and members used to render the event
*/
///@{
/** \name Event rendering
* Method and members used to render the event
*/
///@{
/**
* Redefine this method to draw the event.
*
* \param dc The wxWidgets drawing context to be used.
* \param x The x position where the events must be drawn.
* \param y The y position where the events must be drawn.
* \param width The width available for drawing.
* \param areas Use this object to indicate the areas where items have been drawn
* \param selection Give access to the current selection(s), to draw for example hovering or selecting effects.
*
* \note The height of the drawing must be the same as the height returned by BaseEvent::GetRenderedHeight
*
* \see gd::EventsRenderingHelper
* \see EventsEditorSelection
* \see EventsEditorItemsAreas
*/
virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform) {return;}
/**
* Redefine this method to draw the event.
*
* \param dc The wxWidgets drawing context to be used.
* \param x The x position where the events must be drawn.
* \param y The y position where the events must be drawn.
* \param width The width available for drawing.
* \param areas Use this object to indicate the areas where items have been
* drawn \param selection Give access to the current selection(s), to draw for
* example hovering or selecting effects.
*
* \note The height of the drawing must be the same as the height returned by
* BaseEvent::GetRenderedHeight
*
* \see gd::EventsRenderingHelper
* \see EventsEditorSelection
* \see EventsEditorItemsAreas
*/
virtual void Render(wxDC& dc,
int x,
int y,
unsigned int width,
gd::EventsEditorItemsAreas& areas,
gd::EventsEditorSelection& selection,
const gd::Platform& platform) {
return;
}
/**
* Must return the height of the event when rendered.
*
* \note The height of the drawing must be the same as the height of the drawing made by BaseEvent::Render
*/
virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & platform) const {return 0;};
/**
* Must return the height of the event when rendered.
*
* \note The height of the drawing must be the same as the height of the
* drawing made by BaseEvent::Render
*/
virtual unsigned int GetRenderedHeight(unsigned int width,
const gd::Platform& platform) const {
return 0;
};
/**
* Used by EditEvent to describe what sort of changes have been made to the event.
* \see BaseEvent::EditEvent
*/
enum EditEventReturnType
{
ChangesMade,
Cancelled,
ChangesMadeButNoNeedForEventsRecompilation
};
/**
* Used by EditEvent to describe what sort of changes have been made to the
* event. \see BaseEvent::EditEvent
*/
enum EditEventReturnType {
ChangesMade,
Cancelled,
ChangesMadeButNoNeedForEventsRecompilation
};
/**
* Called when the user want to edit the event.
*/
virtual EditEventReturnType EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_) { return ChangesMade; };
/**
* Called when the user want to edit the event.
*/
virtual EditEventReturnType EditEvent(
wxWindow* parent_,
gd::Project& game_,
gd::Layout& scene_,
gd::MainFrameWrapper& mainFrameWrapper_) {
return ChangesMade;
};
///@}
///@}
mutable bool eventHeightNeedUpdate; ///<Automatically set to true/false by the events editor
mutable bool eventHeightNeedUpdate; ///< Automatically set to true/false by
///< the events editor
std::weak_ptr<gd::BaseEvent> originalEvent; ///< Pointer only used for profiling events, so as to remember the original event from which it has been copied.
signed long long totalTimeDuringLastSession; ///< Total time, in microseconds, used by the event during the last run. Used for profiling.
float percentDuringLastSession; ///< Total time used by the event during the last run. Used for profiling.
std::weak_ptr<gd::BaseEvent>
originalEvent; ///< Pointer only used for profiling events, so as to
///< remember the original event from which it has been
///< copied.
signed long long
totalTimeDuringLastSession; ///< Total time, in microseconds, used by the
///< event during the last run. Used for
///< profiling.
float percentDuringLastSession; ///< Total time used by the event during the
///< last run. Used for profiling.
protected:
mutable unsigned int renderedHeight;
protected:
mutable unsigned int renderedHeight;
private:
bool folded; ///< True if the subevents should be hidden in the events editor
bool disabled; ///<True if the event is disabled and must not be executed
gd::String type; ///<Type of the event. Must be assigned at the creation. Used for saving the event for instance.
private:
bool folded; ///< True if the subevents should be hidden in the events editor
bool disabled; ///< True if the event is disabled and must not be executed
gd::String type; ///< Type of the event. Must be assigned at the creation.
///< Used for saving the event for instance.
static gd::EventsList badSubEvents;
static std::vector< gd::String > emptyDependencies;
static gd::String emptySourceFile;
static gd::EventsList badSubEvents;
static std::vector<gd::String> emptyDependencies;
static gd::String emptySourceFile;
};
/**
* Clone an event and insert a reference to the original event into the newly created event.
* Used for profiling events for example.
* Clone an event and insert a reference to the original event into the newly
* created event. Used for profiling events for example.
*
* \see BaseEvent
* \ingroup Events
@@ -298,14 +387,13 @@ BaseEventSPtr GD_CORE_API CloneRememberingOriginalEvent(BaseEventSPtr event);
* \brief Empty event doing nothing.
* \see gd::BaseEvent
*/
class EmptyEvent : public BaseEvent
{
public:
EmptyEvent() : BaseEvent() {};
virtual ~EmptyEvent() {};
class EmptyEvent : public BaseEvent {
public:
EmptyEvent() : BaseEvent(){};
virtual ~EmptyEvent(){};
};
}
} // namespace gd
#endif // GDCORE_EVENT_H
#endif // GDCORE_EVENT_H
#endif

View File

@@ -1,127 +1,116 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "EventsList.h"
#include "GDCore/Events/Event.h"
#include "GDCore/Tools/Log.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Tools/Log.h"
#include "Serialization.h"
namespace gd
{
namespace gd {
EventsList::EventsList()
{
}
EventsList::EventsList() {}
void EventsList::InsertEvents(const EventsList& otherEvents,
size_t begin,
size_t end,
size_t position) {
if (begin >= otherEvents.size()) return;
if (end < begin) return;
if (end >= otherEvents.size()) end = otherEvents.size() - 1;
void EventsList::InsertEvents(const EventsList & otherEvents, size_t begin, size_t end, size_t position)
{
if (begin >= otherEvents.size()) return;
if (end < begin) return;
if (end >= otherEvents.size()) end = otherEvents.size()-1;
for (std::size_t insertPos = 0;insertPos <= (end-begin);insertPos++)
{
if (position != (size_t)-1 && position+insertPos < events.size())
events.insert(events.begin()+position+insertPos, CloneRememberingOriginalEvent(otherEvents.events[begin+insertPos]));
else
events.push_back(CloneRememberingOriginalEvent(otherEvents.events[begin+insertPos]));
}
}
gd::BaseEvent & EventsList::InsertEvent(const gd::BaseEvent & evt, size_t position)
{
std::shared_ptr<gd::BaseEvent> event(evt.Clone());
if (position<events.size())
events.insert(events.begin()+position, event);
for (std::size_t insertPos = 0; insertPos <= (end - begin); insertPos++) {
if (position != (size_t)-1 && position + insertPos < events.size())
events.insert(
events.begin() + position + insertPos,
CloneRememberingOriginalEvent(otherEvents.events[begin + insertPos]));
else
events.push_back(event);
return *event;
events.push_back(
CloneRememberingOriginalEvent(otherEvents.events[begin + insertPos]));
}
}
void EventsList::InsertEvent(std::shared_ptr<gd::BaseEvent> event, size_t position)
{
if (position<events.size())
events.insert(events.begin()+position, event);
else
events.push_back(event);
gd::BaseEvent& EventsList::InsertEvent(const gd::BaseEvent& evt,
size_t position) {
std::shared_ptr<gd::BaseEvent> event(evt.Clone());
if (position < events.size())
events.insert(events.begin() + position, event);
else
events.push_back(event);
return *event;
}
gd::BaseEvent & EventsList::InsertNewEvent(gd::Project & project, const gd::String & eventType, size_t position)
{
gd::BaseEventSPtr event = project.CreateEvent(eventType);
if ( event == std::shared_ptr<gd::BaseEvent>())
{
std::cout << "Unknown event of type " << eventType;
event = std::make_shared<EmptyEvent>();
void EventsList::InsertEvent(std::shared_ptr<gd::BaseEvent> event,
size_t position) {
if (position < events.size())
events.insert(events.begin() + position, event);
else
events.push_back(event);
}
gd::BaseEvent& EventsList::InsertNewEvent(gd::Project& project,
const gd::String& eventType,
size_t position) {
gd::BaseEventSPtr event = project.CreateEvent(eventType);
if (event == std::shared_ptr<gd::BaseEvent>()) {
std::cout << "Unknown event of type " << eventType;
event = std::make_shared<EmptyEvent>();
}
InsertEvent(event, position);
return *event;
}
void EventsList::RemoveEvent(size_t index) {
events.erase(events.begin() + index);
}
void EventsList::RemoveEvent(const gd::BaseEvent& event) {
for (size_t i = 0; i < events.size(); ++i) {
if (events[i].get() == &event) {
events.erase(events.begin() + i);
return;
}
InsertEvent(event, position);
return *event;
}
}
void EventsList::RemoveEvent(size_t index)
{
events.erase(events.begin()+index);
void EventsList::SerializeTo(SerializerElement& element) const {
EventsListSerialization::SerializeEventsTo(*this, element);
}
void EventsList::RemoveEvent(const gd::BaseEvent & event)
{
for (size_t i = 0; i < events.size(); ++i)
{
if (events[i].get() == &event)
{
events.erase(events.begin()+i);
return;
}
}
void EventsList::UnserializeFrom(gd::Project& project,
const SerializerElement& element) {
EventsListSerialization::UnserializeEventsFrom(project, *this, element);
}
void EventsList::SerializeTo(SerializerElement & element) const
{
EventsListSerialization::SerializeEventsTo(*this, element);
bool EventsList::Contains(const gd::BaseEvent& eventToSearch,
bool recursive) const {
for (std::size_t i = 0; i < GetEventsCount(); ++i) {
if (&GetEvent(i) == &eventToSearch) return true;
if (recursive && GetEvent(i).CanHaveSubEvents() &&
GetEvent(i).GetSubEvents().Contains(eventToSearch))
return true;
}
return false;
}
void EventsList::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
EventsListSerialization::UnserializeEventsFrom(project, *this, element);
EventsList::EventsList(const EventsList& other) { Init(other); }
EventsList& EventsList::operator=(const EventsList& other) {
if (this != &other) Init(other);
return *this;
}
bool EventsList::Contains(const gd::BaseEvent & eventToSearch, bool recursive) const
{
for (std::size_t i = 0;i<GetEventsCount();++i)
{
if ( &GetEvent(i) == &eventToSearch) return true;
if ( recursive && GetEvent(i).CanHaveSubEvents() && GetEvent(i).GetSubEvents().Contains(eventToSearch) )
return true;
}
return false;
void EventsList::Init(const gd::EventsList& other) {
events.clear();
for (size_t i = 0; i < other.events.size(); ++i)
events.push_back(CloneRememberingOriginalEvent(other.events[i]));
}
EventsList::EventsList(const EventsList & other)
{
Init(other);
}
EventsList & EventsList::operator=(const EventsList & other)
{
if ( this != &other )
Init(other);
return *this;
}
void EventsList::Init(const gd::EventsList & other)
{
events.clear();
for(size_t i = 0;i<other.events.size();++i)
events.push_back(CloneRememberingOriginalEvent(other.events[i]));
}
}
} // namespace gd

View File

@@ -1,23 +1,28 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#ifndef GDCORE_EVENTSLIST_H
#define GDCORE_EVENTSLIST_H
#include <vector>
#include <memory>
#include <vector>
#include "GDCore/String.h"
namespace gd { class Project; }
namespace gd { class BaseEvent; }
namespace gd { class SerializerElement; }
namespace gd {
class Project;
}
namespace gd {
class BaseEvent;
}
namespace gd {
class SerializerElement;
}
class TiXmlElement;
#undef CreateEvent
namespace gd
{
namespace gd {
/**
* \brief A list of events.
@@ -25,154 +30,174 @@ namespace gd
* \see BaseEvent
* \ingroup Events
*/
class GD_CORE_API EventsList
{
public:
EventsList();
EventsList(const EventsList&);
virtual ~EventsList() {};
EventsList& operator=(const EventsList & rhs);
class GD_CORE_API EventsList {
public:
EventsList();
EventsList(const EventsList&);
virtual ~EventsList(){};
EventsList& operator=(const EventsList& rhs);
/**
* \brief Insert the specified event to the list
* \note The event passed by parameter is copied.
* \param event The event that must be copied and inserted into the list
* \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 event in the list
*/
gd::BaseEvent & InsertEvent(const gd::BaseEvent & event, size_t position = (size_t)-1);
/**
* \brief Insert the specified event to the list
* \note The event passed by parameter is copied.
* \param event The event that must be copied and inserted into the list
* \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
* event in the list
*/
gd::BaseEvent& InsertEvent(const gd::BaseEvent& event,
size_t position = (size_t)-1);
/**
* \brief Insert the specified event to the list.
* \note The event passed by parameter is not copied.
* \param event The smart pointer to the event that must be inserted into the list
* \param position Insertion position. If the position is invalid, the object is inserted at the end of the objects list.
*/
void InsertEvent(std::shared_ptr<gd::BaseEvent> event, size_t position = (size_t)-1);
/**
* \brief Insert the specified event to the list.
* \note The event passed by parameter is not copied.
* \param event The smart pointer to the event that must be inserted into the
* list \param position Insertion position. If the position is invalid, the
* object is inserted at the end of the objects list.
*/
void InsertEvent(std::shared_ptr<gd::BaseEvent> event,
size_t position = (size_t)-1);
/**
* \brief Insert a new event to the list.
* \note The event is created using the project current platform.
* \param project The project the events list belongs to.
* \param eventType The type of the event
* \param position Insertion position. If the position is invalid, the object is inserted at the end of the objects list.
*/
gd::BaseEvent & InsertNewEvent(gd::Project & project, const gd::String & eventType, size_t position = (size_t)-1);
/**
* \brief Insert a new event to the list.
* \note The event is created using the project current platform.
* \param project The project the events list belongs to.
* \param eventType The type of the event
* \param position Insertion position. If the position is invalid, the object
* is inserted at the end of the objects list.
*/
gd::BaseEvent& InsertNewEvent(gd::Project& project,
const gd::String& eventType,
size_t position = (size_t)-1);
/**
* \brief Copy events from another list
*/
void InsertEvents(const EventsList & otherEvents, size_t begin, size_t end, size_t position = (size_t)-1);
/**
* \brief Copy events from another list
*/
void InsertEvents(const EventsList& otherEvents,
size_t begin,
size_t end,
size_t position = (size_t)-1);
/**
* \brief Return the number of events.
*/
size_t GetEventsCount() const { return events.size(); };
/**
* \brief Return the number of events.
*/
size_t GetEventsCount() const { return events.size(); };
/**
* \brief Return the smart pointer to the event at position \a index in the events list.
*/
std::shared_ptr<BaseEvent> GetEventSmartPtr(size_t index) { return events[index]; };
/**
* \brief Return the smart pointer to the event at position \a index in the
* events list.
*/
std::shared_ptr<BaseEvent> GetEventSmartPtr(size_t index) {
return events[index];
};
/**
* \brief Return the smart pointer to the event at position \a index in the events list.
*/
std::shared_ptr<const BaseEvent> GetEventSmartPtr(size_t index) const { return events[index]; };
/**
* \brief Return the smart pointer to the event at position \a index in the
* events list.
*/
std::shared_ptr<const BaseEvent> GetEventSmartPtr(size_t index) const {
return events[index];
};
/**
* \brief Return a reference to the event at position \a index in the events list.
*/
gd::BaseEvent & GetEvent(size_t index) { return *events[index]; };
/**
* \brief Return a reference to the event at position \a index in the events
* list.
*/
gd::BaseEvent& GetEvent(size_t index) { return *events[index]; };
/**
* \brief Return a reference to the event at position \a index in the events list.
*/
const gd::BaseEvent & GetEvent(size_t index) const { return *events[index]; };
/**
* \brief Return a reference to the event at position \a index in the events
* list.
*/
const gd::BaseEvent& GetEvent(size_t index) const { return *events[index]; };
/**
* \brief Remove the specified event.
*/
void RemoveEvent(const gd::BaseEvent & event);
/**
* \brief Remove the specified event.
*/
void RemoveEvent(const gd::BaseEvent& event);
/**
* \brief Remove the event at the specified index in the list.
*/
void RemoveEvent(size_t index);
/**
* \brief Remove the event at the specified index in the list.
*/
void RemoveEvent(size_t index);
/**
* \brief Return true if there isn't any event in the list
*/
bool IsEmpty() const { return events.empty(); };
/**
* \brief Return true if there isn't any event in the list
*/
bool IsEmpty() const { return events.empty(); };
/**
* \brief Clear the list of events.
*/
void Clear() { return events.clear(); };
/**
* \brief Clear the list of events.
*/
void Clear() { return events.clear(); };
/** \name Utilities
* Utility methods
*/
///@{
/**
* Return true if the specified event exists in the list.
* \param event The event to searched for
* \param recursive Set it to false to prevent sub events to be inspected.
*/
bool Contains(const gd::BaseEvent & eventToSearch, bool recursive = true) const;
///@}
/** \name Utilities
* Utility methods
*/
///@{
/**
* Return true if the specified event exists in the list.
* \param event The event to searched for
* \param recursive Set it to false to prevent sub events to be inspected.
*/
bool Contains(const gd::BaseEvent& eventToSearch,
bool recursive = true) const;
///@}
/** \name std::vector API compatibility
* These functions ensure that the class can be used just like a std::vector.
*/
///@{
/** \name std::vector API compatibility
* These functions ensure that the class can be used just like a std::vector.
*/
///@{
/**
* \brief Alias for GetEventsCount()
* \see EventsList::GetEventsCount.
*/
size_t size() const { return GetEventsCount(); }
/**
* \brief Alias for GetEventsCount()
* \see EventsList::GetEventsCount.
*/
size_t size() const { return GetEventsCount(); }
/**
* \brief Alias for GetEvent()
* \see EventsList::GetEvent.
*/
gd::BaseEvent & operator[](size_t index) { return GetEvent(index); };
/**
* \brief Alias for GetEvent()
* \see EventsList::GetEvent.
*/
gd::BaseEvent& operator[](size_t index) { return GetEvent(index); };
/**
* \brief Alias for GetEvent()
* \see EventsList::GetEvent.
*/
const gd::BaseEvent & operator[](size_t index) const { return GetEvent(index); };
///@}
/**
* \brief Alias for GetEvent()
* \see EventsList::GetEvent.
*/
const gd::BaseEvent& operator[](size_t index) const {
return GetEvent(index);
};
///@}
/** \name Saving and loading
* Members functions related to saving and loading the events list.
*/
///@{
/**
* \brief Serialize the events to the specified element
* \see EventsListSerialization
*/
void SerializeTo(SerializerElement & element) const;
/** \name Saving and loading
* Members functions related to saving and loading the events list.
*/
///@{
/**
* \brief Serialize the events to the specified element
* \see EventsListSerialization
*/
void SerializeTo(SerializerElement& element) const;
/**
* \brief Load the events from the specified element
* \see EventsListSerialization
*/
void UnserializeFrom(gd::Project & project, const SerializerElement & element);
///@}
/**
* \brief Load the events from the specified element
* \see EventsListSerialization
*/
void UnserializeFrom(gd::Project& project, const SerializerElement& element);
///@}
private:
std::vector< std::shared_ptr<BaseEvent> > events;
private:
std::vector<std::shared_ptr<BaseEvent> > events;
/**
* Initialize from another list of events, copying events. Used by copy-ctor and assign-op.
* Don't forget to update me if members were changed !
*/
void Init(const gd::EventsList & other);
/**
* Initialize from another list of events, copying events. Used by copy-ctor
* and assign-op. Don't forget to update me if members were changed!
*/
void Init(const gd::EventsList& other);
};
}
} // namespace gd
#endif
#endif

View File

@@ -1,60 +1,57 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_EXPRESSION_H
#define GDCORE_EXPRESSION_H
#include "GDCore/String.h"
namespace gd
{
namespace gd {
/**
* \brief Class representing an expression used as a parameter of a gd::Instruction.
* This class is nothing more than a wrapper around a gd::String.
* \brief Class representing an expression used as a parameter of a
* gd::Instruction. This class is nothing more than a wrapper around a
* gd::String.
*
* \see gd::Instruction
*
* \ingroup Events
*/
class GD_CORE_API Expression
{
public:
class GD_CORE_API Expression {
public:
/**
* \brief Construct an empty expression
*/
Expression(){};
/**
* \brief Construct an empty expression
*/
Expression() {};
/**
* \brief Construct an expression from a string
*/
Expression(gd::String plainString_) : plainString(plainString_){};
/**
* \brief Construct an expression from a string
*/
Expression(gd::String plainString_) : plainString(plainString_) {};
/**
* \brief Construct an expression from a const char *
*/
Expression(const char* plainString_) : plainString(plainString_){};
/**
* \brief Construct an expression from a const char *
*/
Expression(const char * plainString_) : plainString(plainString_) {};
/**
* \brief Get the plain string representing the expression
*/
inline const gd::String& GetPlainString() const { return plainString; };
/**
* \brief Get the plain string representing the expression
*/
inline const gd::String & GetPlainString() const { return plainString; };
/**
* \brief Mimics std::string::c_str
*/
inline const char* c_str() const { return plainString.c_str(); };
/**
* \brief Mimics std::string::c_str
*/
inline const char * c_str() const { return plainString.c_str(); };
virtual ~Expression(){};
virtual ~Expression() {};
private:
gd::String plainString; ///<The expression string
private:
gd::String plainString; ///< The expression string
};
}
} // namespace gd
#endif // GDCORE_EXPRESSION_H
#endif // GDCORE_EXPRESSION_H

View File

@@ -1,74 +1,66 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GDCore/Events/Instruction.h"
#include "GDCore/Events/InstructionsList.h"
#include "GDCore/Events/Expression.h"
#include "GDCore/String.h"
#include <assert.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include "GDCore/Events/Expression.h"
#include "GDCore/Events/InstructionsList.h"
#include "GDCore/String.h"
namespace gd
{
namespace gd {
gd::Expression Instruction::badExpression("");
Instruction::Instruction(gd::String type_) :
renderedHeightNeedUpdate(true),
renderedHeight(0),
selected(false),
type(type_),
inverted(false)
{
//ctor
parameters.reserve(8);
Instruction::Instruction(gd::String type_)
: renderedHeightNeedUpdate(true),
renderedHeight(0),
selected(false),
type(type_),
inverted(false) {
// ctor
parameters.reserve(8);
}
Instruction::Instruction(gd::String type_, const std::vector<gd::Expression> & parameters_, bool inverted_) :
renderedHeightNeedUpdate(true),
renderedHeight(0),
selected(false),
type(type_),
inverted(inverted_),
parameters(parameters_)
{
parameters.reserve(8);
Instruction::Instruction(gd::String type_,
const std::vector<gd::Expression>& parameters_,
bool inverted_)
: renderedHeightNeedUpdate(true),
renderedHeight(0),
selected(false),
type(type_),
inverted(inverted_),
parameters(parameters_) {
parameters.reserve(8);
}
const gd::Expression & Instruction::GetParameter(std::size_t index) const
{
if ( index >= parameters.size() ) return badExpression;
const gd::Expression& Instruction::GetParameter(std::size_t index) const {
if (index >= parameters.size()) return badExpression;
return parameters[index];
return parameters[index];
}
gd::Expression & Instruction::GetParameter(std::size_t index)
{
if ( index >= parameters.size() ) return badExpression;
gd::Expression& Instruction::GetParameter(std::size_t index) {
if (index >= parameters.size()) return badExpression;
return parameters[index];
return parameters[index];
}
void Instruction::SetParametersCount(std::size_t size)
{
while(size < parameters.size())
parameters.erase(parameters.begin()+parameters.size()-1);
while(size > parameters.size())
parameters.push_back(gd::Expression(""));
void Instruction::SetParametersCount(std::size_t size) {
while (size < parameters.size())
parameters.erase(parameters.begin() + parameters.size() - 1);
while (size > parameters.size()) parameters.push_back(gd::Expression(""));
}
void Instruction::SetParameter(std::size_t nb, const gd::Expression & val)
{
if ( nb >= parameters.size() )
{
std::cout << "Trying to write an out of bound parameter.\n\n" << std::endl;
return;
}
parameters[nb] = val;
void Instruction::SetParameter(std::size_t nb, const gd::Expression& val) {
if (nb >= parameters.size()) {
std::cout << "Trying to write an out of bound parameter.\n\n" << std::endl;
return;
}
parameters[nb] = val;
}
}
} // namespace gd

View File

@@ -1,149 +1,161 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef INSTRUCTION_H
#define INSTRUCTION_H
#include "GDCore/String.h"
#include <vector>
#include "GDCore/Events/Expression.h"
#include "GDCore/Events/InstructionsList.h"
#include "GDCore/String.h"
namespace gd
{
namespace gd {
/**
* \brief An instruction is a member of an event: It can be a condition or an action.
* \brief An instruction is a member of an event: It can be a condition or an
* action.
*
* An instruction has a type, which define what it does, and some parameters. It can also be set as inverted ( when the instruction is a condition ) and
* it can have sub instructions.
* This class does nothing particular except storing these data.
* An instruction has a type, which define what it does, and some parameters. It
* can also be set as inverted ( when the instruction is a condition ) and it
* can have sub instructions. This class does nothing particular except storing
* these data.
*
* \see gd::BaseEvent
*
* \ingroup Events
*/
class GD_CORE_API Instruction
{
public:
class GD_CORE_API Instruction {
public:
/**
* \brief Default constructor
* \param type The type of the instruction
*/
Instruction(gd::String type_ = "");
/**
* \brief Default constructor
* \param type The type of the instruction
*/
Instruction(gd::String type_ = "");
/**
* \brief Constructor
* \param type The type of the instruction
* \param parameters A vector containing the parameters of the instruction
* \param inverted true to set the instruction as inverted (used for condition
* instructions).
*/
Instruction(gd::String type_,
const std::vector<gd::Expression>& parameters_,
bool inverted = false);
/**
* \brief Constructor
* \param type The type of the instruction
* \param parameters A vector containing the parameters of the instruction
* \param inverted true to set the instruction as inverted (used for condition instructions).
*/
Instruction(gd::String type_, const std::vector <gd::Expression> & parameters_, bool inverted = false);
virtual ~Instruction(){};
virtual ~Instruction() {};
/**
* \brief Return the type of the instruction.
* \return The type of the instruction
*/
const gd::String& GetType() const { return type; }
/**
* \brief Return the type of the instruction.
* \return The type of the instruction
*/
const gd::String & GetType() const { return type; }
/**
* \brief Change the instruction type
* \param val The new type of the instruction
*/
void SetType(const gd::String& newType) { type = newType; }
/**
* \brief Change the instruction type
* \param val The new type of the instruction
*/
void SetType(const gd::String & newType) { type = newType; }
/**
* \brief Return true if the condition is inverted
* \return true if the condition is inverted
*/
bool IsInverted() const { return inverted; }
/**
* \brief Return true if the condition is inverted
* \return true if the condition is inverted
*/
bool IsInverted() const { return inverted; }
/**
* \brief Set if the instruction is inverted or not.
* \param inverted true if the condition must be set as inverted
*/
void SetInverted(bool inverted_) { inverted = inverted_; }
/**
* \brief Set if the instruction is inverted or not.
* \param inverted true if the condition must be set as inverted
*/
void SetInverted(bool inverted_) { inverted = inverted_; }
/**
* \brief Return the number of parameters of the instruction.
*/
std::size_t GetParametersCount() const { return parameters.size(); }
/**
* \brief Return the number of parameters of the instruction.
*/
std::size_t GetParametersCount() const { return parameters.size(); }
/**
* \brief Change the number of parameter of the instruction.
*
* If the new size if larger than the previous, new blank parameters are
* added.
*/
void SetParametersCount(std::size_t size);
/**
* \brief Change the number of parameter of the instruction.
*
* If the new size if larger than the previous, new blank parameters are added.
*/
void SetParametersCount(std::size_t size);
/**
* \brief Get the value of a parameter.
*
* Return an empty expression if the parameter requested does not exists.
* \return The current value of the parameter.
*/
const gd::Expression& GetParameter(std::size_t index) const;
/**
* \brief Get the value of a parameter.
*
* Return an empty expression if the parameter requested does not exists.
* \return The current value of the parameter.
*/
const gd::Expression & GetParameter(std::size_t index) const;
/**
* \brief Get the value of a parameter.
*
* Return an empty expression if the parameter requested does not exists.
* \return The current value of the parameter.
*/
gd::Expression& GetParameter(std::size_t index);
/**
* \brief Get the value of a parameter.
*
* Return an empty expression if the parameter requested does not exists.
* \return The current value of the parameter.
*/
gd::Expression & GetParameter(std::size_t index);
/** Change the specified parameter
* \param nb The parameter number
* \param val The new value of the parameter
*/
void SetParameter(std::size_t nb, const gd::Expression& val);
/** Change the specified parameter
* \param nb The parameter number
* \param val The new value of the parameter
*/
void SetParameter(std::size_t nb, const gd::Expression & val);
/** \brief Get a reference to the std::vector containing the parameters.
* \return A std::vector containing the parameters
*/
inline const std::vector<gd::Expression>& GetParameters() const {
return parameters;
}
/** \brief Get a reference to the std::vector containing the parameters.
* \return A std::vector containing the parameters
*/
inline const std::vector < gd::Expression > & GetParameters() const { return parameters; }
/** \brief Replace all the parameters by new ones.
* \param val A vector containing the new parameters.
*/
inline void SetParameters(const std::vector<gd::Expression>& val) {
parameters = val;
}
/** \brief Replace all the parameters by new ones.
* \param val A vector containing the new parameters.
*/
inline void SetParameters(const std::vector < gd::Expression > & val) { parameters = val; }
/**
* \brief Return a reference to the vector containing sub instructions
*/
inline const gd::InstructionsList& GetSubInstructions() const {
return subInstructions;
};
/**
* \brief Return a reference to the vector containing sub instructions
*/
inline const gd::InstructionsList & GetSubInstructions() const { return subInstructions; };
/**
* \brief Return a reference to the vector containing sub instructions
*/
inline gd::InstructionsList& GetSubInstructions() { return subInstructions; };
/**
* \brief Return a reference to the vector containing sub instructions
*/
inline gd::InstructionsList & GetSubInstructions() { return subInstructions; };
/** \name Rendering
* Members related to the instruction rendering in an event editor.
*/
///@{
/** \name Rendering
* Members related to the instruction rendering in an event editor.
*/
///@{
mutable bool
renderedHeightNeedUpdate; ///< True if the instruction height may have
///< changed and must be computed again.
mutable unsigned int renderedHeight; ///< Height of the instruction rendered
///< in an event editor.
mutable bool selected; ///< True if selected in an event editor.
mutable bool renderedHeightNeedUpdate; ///< True if the instruction height may have changed and must be computed again.
mutable unsigned int renderedHeight; ///<Height of the instruction rendered in an event editor.
mutable bool selected; ///<True if selected in an event editor.
///@}
///@}
private:
gd::String type; ///< Instruction type
bool inverted; ///< True if the instruction if inverted. Only applicable for
///< instruction used as conditions by events
mutable std::vector<gd::Expression>
parameters; ///< Vector containing the parameters
gd::InstructionsList subInstructions; ///< Sub instructions, if applicable.
private:
gd::String type; ///< Instruction type
bool inverted; ///< True if the instruction if inverted. Only applicable for instruction used as conditions by events
mutable std::vector < gd::Expression > parameters; ///< Vector containing the parameters
gd::InstructionsList subInstructions; ///< Sub instructions, if applicable.
static gd::Expression badExpression;
static gd::Expression badExpression;
};
}
} // namespace gd
#endif // INSTRUCTION_H
#endif // INSTRUCTION_H

View File

@@ -1,42 +1,43 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "InstructionsList.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Events/Instruction.h"
#include "GDCore/Project/Project.h"
#include "Serialization.h"
namespace gd
{
namespace gd {
void InstructionsList::InsertInstructions(const InstructionsList & list, size_t begin, size_t end, size_t position)
{
if (begin >= list.size()) return;
if (end < begin) return;
if (end >= list.size()) end = list.size()-1;
void InstructionsList::InsertInstructions(const InstructionsList& list,
size_t begin,
size_t end,
size_t position) {
if (begin >= list.size()) return;
if (end < begin) return;
if (end >= list.size()) end = list.size() - 1;
for (std::size_t insertPos = 0;insertPos <= (end-begin);insertPos++)
{
const Instruction & instruction = *list.elements[begin+insertPos];
std::shared_ptr<Instruction> copiedInstruction = std::make_shared<Instruction>(instruction);
if (position != (size_t)-1 && position+insertPos < elements.size())
elements.insert(elements.begin()+position+insertPos, copiedInstruction);
else
elements.push_back(copiedInstruction);
}
for (std::size_t insertPos = 0; insertPos <= (end - begin); insertPos++) {
const Instruction& instruction = *list.elements[begin + insertPos];
std::shared_ptr<Instruction> copiedInstruction =
std::make_shared<Instruction>(instruction);
if (position != (size_t)-1 && position + insertPos < elements.size())
elements.insert(elements.begin() + position + insertPos,
copiedInstruction);
else
elements.push_back(copiedInstruction);
}
}
void InstructionsList::SerializeTo(SerializerElement & element) const
{
EventsListSerialization::SerializeInstructionsTo(*this, element);
void InstructionsList::SerializeTo(SerializerElement& element) const {
EventsListSerialization::SerializeInstructionsTo(*this, element);
}
void InstructionsList::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
EventsListSerialization::UnserializeInstructionsFrom(project, *this, element);
void InstructionsList::UnserializeFrom(gd::Project& project,
const SerializerElement& element) {
EventsListSerialization::UnserializeInstructionsFrom(project, *this, element);
}
}
} // namespace gd

View File

@@ -9,35 +9,43 @@
#include <memory>
#include <vector>
#include "GDCore/Tools/SPtrList.h"
namespace gd { class Instruction; }
namespace gd { class Project; }
namespace gd { class SerializerElement; }
namespace gd
{
class InstructionsList : public SPtrList<gd::Instruction> {
public:
void InsertInstructions(const InstructionsList & list, size_t begin, size_t end, size_t position = (size_t)-1);
/** \name Serialization
*/
///@{
/**
* \brief Serialize the instructions to the specified element
* \see EventsListSerialization
*/
void SerializeTo(gd::SerializerElement & element) const;
/**
* \brief Load the instructions from the specified element
* \see EventsListSerialization
*/
void UnserializeFrom(gd::Project & project, const gd::SerializerElement & element);
///@}
};
namespace gd {
class Instruction;
}
namespace gd {
class Project;
}
namespace gd {
class SerializerElement;
}
namespace gd {
class InstructionsList : public SPtrList<gd::Instruction> {
public:
void InsertInstructions(const InstructionsList& list,
size_t begin,
size_t end,
size_t position = (size_t)-1);
/** \name Serialization
*/
///@{
/**
* \brief Serialize the instructions to the specified element
* \see EventsListSerialization
*/
void SerializeTo(gd::SerializerElement& element) const;
/**
* \brief Load the instructions from the specified element
* \see EventsListSerialization
*/
void UnserializeFrom(gd::Project& project,
const gd::SerializerElement& element);
///@}
};
} // namespace gd
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,144 +1,192 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_EXPRESSIONPARSER_H
#define GDCORE_EXPRESSIONPARSER_H
#include "GDCore/String.h"
#include <vector>
namespace gd { class Expression; }
namespace gd { class ParserCallbacks; }
namespace gd { class Layout; }
namespace gd { class Project; }
namespace gd { class Platform; }
namespace gd { class ParameterMetadata; }
namespace gd { class ExpressionMetadata; }
#include "GDCore/String.h"
namespace gd {
class Expression;
}
namespace gd {
class ParserCallbacks;
}
namespace gd {
class Layout;
}
namespace gd {
class Project;
}
namespace gd {
class Platform;
}
namespace gd {
class ParameterMetadata;
}
namespace gd {
class ExpressionMetadata;
}
namespace gd
{
namespace gd {
/** \brief Parse an expression
*
* Parse an expression, calling callbacks when a token is reached
* \see gd::ParserCallbacks
*/
class GD_CORE_API ExpressionParser
{
public:
ExpressionParser(const gd::String & expressionPlainString_);
virtual ~ExpressionParser() {};
class GD_CORE_API ExpressionParser {
public:
ExpressionParser(const gd::String &expressionPlainString_);
virtual ~ExpressionParser(){};
/**
* \brief Parse the expression, calling each functor when necessary
* \return True if expression was correctly parsed.
*/
bool ParseMathExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::ParserCallbacks & callbacks);
/**
* \brief Parse the expression, calling each functor when necessary
* \return True if expression was correctly parsed.
*/
bool ParseMathExpression(const gd::Platform &platform,
const gd::Project &project,
const gd::Layout &layout,
gd::ParserCallbacks &callbacks);
/**
* \brief Parse the expression, calling each functor when necessary
* \return True if expression was correctly parsed.
*/
bool ParseStringExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::ParserCallbacks & callbacks);
/**
* \brief Parse the expression, calling each functor when necessary
* \return True if expression was correctly parsed.
*/
bool ParseStringExpression(const gd::Platform &platform,
const gd::Project &project,
const gd::Layout &layout,
gd::ParserCallbacks &callbacks);
/**
* \brief Return the description of the error that was found
*/
const gd::String & GetFirstError() { return firstErrorStr; }
/**
* \brief Return the description of the error that was found
*/
const gd::String &GetFirstError() { return firstErrorStr; }
/**
* \brief Return the position of the error that was found
* \return The position, or gd::String::npos if no error is found
*/
size_t GetFirstErrorPosition() { return firstErrorPos; }
/**
* \brief Return the position of the error that was found
* \return The position, or gd::String::npos if no error is found
*/
size_t GetFirstErrorPosition() { return firstErrorPos; }
private:
gd::String firstErrorStr;
size_t firstErrorPos;
private:
gd::String firstErrorStr;
size_t firstErrorPos;
/**
* Tool function to add a parameter
*/
bool AddParameterToList(const gd::Project & project, const gd::Layout & layout, ParserCallbacks &, std::vector < gd::Expression > & parameters, gd::String parameterStr, std::vector < gd::ParameterMetadata > parametersInfos, const size_t positionInExpression);
/**
* Tool function to add a parameter
*/
bool AddParameterToList(const gd::Project &project,
const gd::Layout &layout,
ParserCallbacks &,
std::vector<gd::Expression> &parameters,
gd::String parameterStr,
std::vector<gd::ParameterMetadata> parametersInfos,
const size_t positionInExpression);
/**
* Tool function to prepare a parameter
*/
bool PrepareParameter(const gd::Platform & platform,const gd::Project & project, const gd::Layout & layout, ParserCallbacks &, gd::Expression & parameter, const gd::ParameterMetadata & parametersInfo, const size_t positionInExpression);
/**
* Tool function to prepare a parameter
*/
bool PrepareParameter(const gd::Platform &platform,
const gd::Project &project,
const gd::Layout &layout,
ParserCallbacks &,
gd::Expression &parameter,
const gd::ParameterMetadata &parametersInfo,
const size_t positionInExpression);
/**
* Return the minimal number of parameters which can be used when calling an expression ( i.e. ParametersCount-OptionalParameters-CodeOnlyParameters )
*/
size_t GetMinimalParametersNumber(const std::vector < gd::ParameterMetadata > & parametersInfos);
/**
* Return the minimal number of parameters which can be used when calling an
* expression ( i.e. ParametersCount-OptionalParameters-CodeOnlyParameters )
*/
size_t GetMinimalParametersNumber(
const std::vector<gd::ParameterMetadata> &parametersInfos);
/**
* Return the maximal number of parameters which can be used when calling an expression ( i.e. ParametersCount-CodeOnlyParameters )
*/
size_t GetMaximalParametersNumber(const std::vector < gd::ParameterMetadata > & parametersInfos);
/**
* Return the maximal number of parameters which can be used when calling an
* expression ( i.e. ParametersCount-CodeOnlyParameters )
*/
size_t GetMaximalParametersNumber(
const std::vector<gd::ParameterMetadata> &parametersInfos);
bool ValidSyntax(const gd::String & str);
bool ValidSyntax(const gd::String &str);
gd::String expressionPlainString;
static gd::String parserSeparators;
gd::String expressionPlainString;
static gd::String parserSeparators;
};
/** \brief Callbacks called by parser during parsing
*
* Parser will call the appropriate functions during parsing, allowing to do special works.
* \see gd::ExpressionParser
* Parser will call the appropriate functions during parsing, allowing to do
* special works. \see gd::ExpressionParser
*/
class GD_CORE_API ParserCallbacks
{
friend class ExpressionParser;
public:
class GD_CORE_API ParserCallbacks {
friend class ExpressionParser;
ParserCallbacks() : returnType("expression") {};
virtual ~ParserCallbacks() {};
public:
ParserCallbacks() : returnType("expression"){};
virtual ~ParserCallbacks(){};
/**
* \brief Get the type of the expression for which callbacks are used:
* "expression" or "string".
*/
const gd::String & GetReturnType() { return returnType; }
/**
* \brief Get the type of the expression for which callbacks are used:
* "expression" or "string".
*/
const gd::String &GetReturnType() { return returnType; }
virtual void OnConstantToken(gd::String text) = 0;
virtual void OnConstantToken(gd::String text) = 0;
virtual void OnStaticFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo) = 0;
virtual void OnStaticFunction(
gd::String functionName,
const std::vector<gd::Expression> &parameters,
const gd::ExpressionMetadata &expressionInfo) = 0;
virtual void OnObjectFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo) = 0;
virtual void OnObjectFunction(
gd::String functionName,
const std::vector<gd::Expression> &parameters,
const gd::ExpressionMetadata &expressionInfo) = 0;
virtual void OnObjectBehaviorFunction(gd::String functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo) = 0;
virtual void OnObjectBehaviorFunction(
gd::String functionName,
const std::vector<gd::Expression> &parameters,
const gd::ExpressionMetadata &expressionInfo) = 0;
virtual bool OnSubMathExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::Expression & expression) = 0;
virtual bool OnSubTextExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::Expression & expression) = 0;
virtual bool OnSubMathExpression(const gd::Platform &platform,
const gd::Project &project,
const gd::Layout &layout,
gd::Expression &expression) = 0;
virtual bool OnSubTextExpression(const gd::Platform &platform,
const gd::Project &project,
const gd::Layout &layout,
gd::Expression &expression) = 0;
/**
* \brief Return the description of the error that was found
*/
const gd::String & GetFirstError() { return firstErrorStr; }
/**
* \brief Return the description of the error that was found
*/
const gd::String &GetFirstError() { return firstErrorStr; }
/**
* \brief Return the position of the error that was found
* \return The position, or gd::String::npos if no error is found
*/
size_t GetFirstErrorPosition() { return firstErrorPos; }
/**
* \brief Return the position of the error that was found
* \return The position, or gd::String::npos if no error is found
*/
size_t GetFirstErrorPosition() { return firstErrorPos; }
protected:
gd::String firstErrorStr;
size_t firstErrorPos;
protected:
gd::String firstErrorStr;
size_t firstErrorPos;
private:
/**
* \brief Set the return type of the expression: Done by ExpressionParser according to
* which Parse* method is called.
* \see gd::ExpressionParser
*/
void SetReturnType(gd::String type) { returnType = type; }
private:
/**
* \brief Set the return type of the expression: Done by ExpressionParser
* according to which Parse* method is called. \see gd::ExpressionParser
*/
void SetReturnType(gd::String type) { returnType = type; }
gd::String returnType; //The type of the expression ("expression" (default), "string"...)
gd::String returnType; // The type of the expression ("expression" (default),
// "string"...)
};
}
} // namespace gd
#endif // GDEXPRESSIONPARSER_H
#endif // GDEXPRESSIONPARSER_H

View File

@@ -1,155 +1,141 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GDCore/String.h"
#include <vector>
#include "GDCore/Events/Parsers/VariableParser.h"
namespace gd { class Layout; }
namespace gd { class Project; }
namespace gd { class Platform; }
#include <vector>
#include "GDCore/String.h"
namespace gd {
class Layout;
}
namespace gd {
class Project;
}
namespace gd {
class Platform;
}
#include "GDCore/Tools/Localization.h"
namespace gd
{
namespace gd {
VariableParser::~VariableParser()
{
VariableParser::~VariableParser() {}
bool VariableParser::Parse(VariableParserCallbacks& callbacks_) {
callbacks = &callbacks_;
rootVariableParsed = false;
firstErrorStr.clear();
firstErrorPos = 0;
currentPositionIt = expression.begin();
currentTokenType = TS_INVALID;
currentToken.clear();
S();
return firstErrorStr == "";
}
bool VariableParser::Parse(VariableParserCallbacks & callbacks_)
{
callbacks = &callbacks_;
rootVariableParsed = false;
firstErrorStr.clear();
firstErrorPos = 0;
currentPositionIt = expression.begin();
currentTokenType = TS_INVALID;
currentToken.clear();
S();
void VariableParser::ReadToken() {
currentTokenType = TS_INVALID;
currentToken.clear();
while (currentPositionIt != expression.end()) {
char32_t currentChar = *currentPositionIt;
if (currentChar == U'[' || currentChar == U']' || currentChar == U'.') {
if (currentTokenType == TS_VARNAME)
return; // We've parsed a variable name.
}
return firstErrorStr == "";
if (currentChar == U'[') {
currentTokenType = TS_OPENING_BRACKET;
currentToken.clear();
++currentPositionIt;
return;
} else if (currentChar == U']') {
currentTokenType = TS_CLOSING_BRACKET;
currentToken.clear();
++currentPositionIt;
return;
} else if (currentChar == U'.') {
currentTokenType = TS_PERIOD;
currentToken.clear();
++currentPositionIt;
return;
}
currentTokenType = TS_VARNAME; // We're parsing a variable name.
currentToken.push_back(currentChar);
++currentPositionIt;
}
// Can be reached if we are at the end of the expression. In this case,
// currentTokenType will be either TS_VARNAME or TS_INVALID.
}
void VariableParser::ReadToken()
{
currentTokenType = TS_INVALID;
currentToken.clear();
while ( currentPositionIt != expression.end() )
{
char32_t currentChar = *currentPositionIt;
if ( currentChar == U'[' ||
currentChar == U']' ||
currentChar == U'.' )
{
if ( currentTokenType == TS_VARNAME )
return; //We've parsed a variable name.
}
void VariableParser::S() {
ReadToken();
if (currentTokenType != TS_VARNAME) {
firstErrorStr = _("Expecting a variable name.");
firstErrorPos = std::distance<gd::String::const_iterator>(
expression.begin(), currentPositionIt);
return;
}
if ( currentChar == U'[' ) {
currentTokenType = TS_OPENING_BRACKET;
currentToken.clear();
++currentPositionIt;
return;
}
else if ( currentChar == U']' ) {
currentTokenType = TS_CLOSING_BRACKET;
currentToken.clear();
++currentPositionIt;
return;
}
else if ( currentChar == U'.' ) {
currentTokenType = TS_PERIOD;
currentToken.clear();
++currentPositionIt;
return;
}
if (!rootVariableParsed) {
rootVariableParsed = true;
if (callbacks) callbacks->OnRootVariable(currentToken);
} else if (callbacks)
callbacks->OnChildVariable(currentToken);
currentTokenType = TS_VARNAME; //We're parsing a variable name.
currentToken.push_back(currentChar);
++currentPositionIt;
}
//Can be reached if we are at the end of the expression. In this case,
//currentTokenType will be either TS_VARNAME or TS_INVALID.
X();
}
void VariableParser::S()
{
ReadToken();
if (currentTokenType != TS_VARNAME)
{
firstErrorStr = _("Expecting a variable name.");
firstErrorPos = std::distance<gd::String::const_iterator>(expression.begin(), currentPositionIt);
return;
}
void VariableParser::X() {
ReadToken();
if (currentTokenType == TS_INVALID)
return; // Ended parsing.
else if (currentTokenType == TS_PERIOD)
S();
else if (currentTokenType == TS_OPENING_BRACKET) {
gd::String strExpr = SkipStringExpression();
if (!rootVariableParsed)
{
rootVariableParsed = true;
if ( callbacks ) callbacks->OnRootVariable(currentToken);
}
else
if ( callbacks ) callbacks->OnChildVariable(currentToken);
X();
ReadToken();
if (currentTokenType != TS_CLOSING_BRACKET) {
firstErrorStr = _("Expecting ]");
firstErrorPos = std::distance<gd::String::const_iterator>(
expression.begin(), currentPositionIt);
return;
}
if (callbacks) callbacks->OnChildSubscript(strExpr);
X();
}
}
void VariableParser::X()
{
ReadToken();
if (currentTokenType == TS_INVALID)
return; //Ended parsing.
else if (currentTokenType == TS_PERIOD)
S();
else if (currentTokenType == TS_OPENING_BRACKET)
{
gd::String strExpr = SkipStringExpression();
gd::String VariableParser::SkipStringExpression() {
gd::String stringExpression;
bool insideStringLiteral = false;
bool lastCharacterWasBackslash = false;
unsigned int nestedBracket = 0;
while (currentPositionIt != expression.end()) {
char32_t currentChar = *currentPositionIt;
if (currentChar == U'\"') {
if (!insideStringLiteral)
insideStringLiteral = true;
else if (!lastCharacterWasBackslash)
insideStringLiteral = false;
} else if (currentChar == U'[' && !insideStringLiteral) {
nestedBracket++;
} else if (currentChar == U']' && !insideStringLiteral) {
if (nestedBracket == 0)
return stringExpression; // Found the end of the string litteral.
nestedBracket--;
}
ReadToken();
if (currentTokenType != TS_CLOSING_BRACKET)
{
firstErrorStr = _("Expecting ]");
firstErrorPos = std::distance<gd::String::const_iterator>(expression.begin(), currentPositionIt);
return;
}
if ( callbacks ) callbacks->OnChildSubscript(strExpr);
X();
}
lastCharacterWasBackslash = currentChar == U'\\';
stringExpression.push_back(currentChar);
++currentPositionIt;
}
// End of the expression reached ( So expression is invalid by the way )
return stringExpression;
}
gd::String VariableParser::SkipStringExpression()
{
gd::String stringExpression;
bool insideStringLiteral = false;
bool lastCharacterWasBackslash = false;
unsigned int nestedBracket = 0;
while ( currentPositionIt != expression.end() )
{
char32_t currentChar = *currentPositionIt;
if ( currentChar == U'\"' ) {
if ( !insideStringLiteral )
insideStringLiteral = true;
else if ( !lastCharacterWasBackslash )
insideStringLiteral = false;
}
else if ( currentChar == U'[' && !insideStringLiteral ) {
nestedBracket++;
}
else if ( currentChar == U']' && !insideStringLiteral ) {
if ( nestedBracket == 0 ) return stringExpression; //Found the end of the string litteral.
nestedBracket--;
}
lastCharacterWasBackslash = currentChar == U'\\';
stringExpression.push_back(currentChar);
++currentPositionIt;
}
//End of the expression reached ( So expression is invalid by the way )
return stringExpression;
}
}
} // namespace gd

View File

@@ -1,137 +1,147 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_VARIABLEPARSER_H
#define GDCORE_VARIABLEPARSER_H
#include "GDCore/String.h"
#include <vector>
namespace gd { class Layout; }
namespace gd { class Project; }
namespace gd { class Platform; }
namespace gd { class VariableParserCallbacks; }
#include "GDCore/String.h"
namespace gd {
class Layout;
}
namespace gd {
class Project;
}
namespace gd {
class Platform;
}
namespace gd {
class VariableParserCallbacks;
}
namespace gd
{
namespace gd {
/** \brief Parse a variable expression.
*
* Parse an variable expression ( like myVariable.child["subchild"+ToString(i)].subsubchild ),
* Parse an variable expression ( like
myVariable.child["subchild"+ToString(i)].subsubchild ),
* calling callbacks when a token is reached.
*
* Usage example:
\code
//...
//VariableCodeGenerationCallbacks is a class inheriting from gd::VariableParserCallbacks
VariableCodeGenerationCallbacks callbacks(output, *this, context, VariableCodeGenerationCallbacks::PROJECT_VARIABLE);
//VariableCodeGenerationCallbacks is a class inheriting from
gd::VariableParserCallbacks VariableCodeGenerationCallbacks callbacks(output,
*this, context, VariableCodeGenerationCallbacks::PROJECT_VARIABLE);
gd::VariableParser parser(parameter);
if ( !parser.Parse(callbacks) )
cout << "Error :" << parser.GetFirstError() << " in: "<< parameter << endl;
\endcode
cout << "Error :" << parser.GetFirstError() << " in: "<< parameter <<
endl; \endcode
*
* Here is the parsed grammar: <br>
* S -> VarName X <br>
* X -> e | . S | [StringExpression] X <br>
*
* where e = nothing ( end of expression ), StringExpression = A valid string expression and
* where e = nothing ( end of expression ), StringExpression = A valid string
expression and
* S is the start.
*
* \see gd::VariableParserCallbacks
*/
class GD_CORE_API VariableParser
{
public:
class GD_CORE_API VariableParser {
public:
/**
* \brief Default constructor
* \param expressionPlainString The string representing the expression to be
* parsed.
*/
VariableParser(const gd::String& expressionPlainString_)
: currentPositionIt(), expression(expressionPlainString_){};
virtual ~VariableParser();
/**
* \brief Default constructor
* \param expressionPlainString The string representing the expression to be parsed.
*/
VariableParser(const gd::String & expressionPlainString_) : currentPositionIt(), expression(expressionPlainString_) {};
virtual ~VariableParser();
/**
* Parse the expression, calling each callback when necessary.
* \param callbacks The callbacks to be called.
* \return true if expression was correctly parsed.
* \see gd::VariableParserCallbacks
*/
bool Parse(VariableParserCallbacks& callbacks);
/**
* Parse the expression, calling each callback when necessary.
* \param callbacks The callbacks to be called.
* \return true if expression was correctly parsed.
* \see gd::VariableParserCallbacks
*/
bool Parse(VariableParserCallbacks & callbacks);
/**
* \brief Return the description of the error that was found
*/
const gd::String& GetFirstError() { return firstErrorStr; }
/**
* \brief Return the description of the error that was found
*/
const gd::String & GetFirstError() { return firstErrorStr; }
/**
* \brief Return the position of the error that was found
* \return The position, or gd::String::npos if no error is found
*/
size_t GetFirstErrorPosition() { return firstErrorPos; }
/**
* \brief Return the position of the error that was found
* \return The position, or gd::String::npos if no error is found
*/
size_t GetFirstErrorPosition() { return firstErrorPos; }
gd::String firstErrorStr;
size_t firstErrorPos;
gd::String firstErrorStr;
size_t firstErrorPos;
private:
void S();
void X();
private:
/**
* \brief Skip the string expression, starting from the current position.
* \return The string expression skipped. currentPosition is now put on the
* closing bracket.
*/
gd::String SkipStringExpression();
void S();
void X();
void ReadToken();
/**
* \brief Skip the string expression, starting from the current position.
* \return The string expression skipped. currentPosition is now put on the closing bracket.
*/
gd::String SkipStringExpression();
enum TokenType {
TS_PERIOD,
TS_OPENING_BRACKET,
TS_CLOSING_BRACKET,
TS_VARNAME,
TS_INVALID
};
void ReadToken();
TokenType currentTokenType;
gd::String currentToken;
gd::String::const_iterator currentPositionIt;
gd::String expression;
enum TokenType {
TS_PERIOD,
TS_OPENING_BRACKET,
TS_CLOSING_BRACKET,
TS_VARNAME,
TS_INVALID
};
TokenType currentTokenType;
gd::String currentToken;
gd::String::const_iterator currentPositionIt;
gd::String expression;
VariableParserCallbacks * callbacks;
bool rootVariableParsed;
VariableParserCallbacks* callbacks;
bool rootVariableParsed;
};
/**
* \brief Callbacks called by VariableParser when parsing a variable expression.
*/
class GD_CORE_API VariableParserCallbacks
{
public:
/**
* \brief Called when the first variable has been parsed. ( varName1 in varName1.child for example. )
* \param variableName The variable name.
*/
virtual void OnRootVariable(gd::String variableName) = 0;
class GD_CORE_API VariableParserCallbacks {
public:
/**
* \brief Called when the first variable has been parsed. ( varName1 in
* varName1.child for example. ) \param variableName The variable name.
*/
virtual void OnRootVariable(gd::String variableName) = 0;
/**
* \brief Called when accessing the child of a structure variable. ( child in varName1.child for example. )
* \param variableName The child variable name.
*/
virtual void OnChildVariable(gd::String variableName) = 0;
/**
* \brief Called when accessing the child of a structure variable. ( child in
* varName1.child for example. ) \param variableName The child variable name.
*/
virtual void OnChildVariable(gd::String variableName) = 0;
/**
* \brief Called when accessing the child of a structure variable using a string expression
* in square brackets. ( "subscript" in varName1["subscript"] for example. )
*
* \param variableName The expression used to access the child variable.
*/
virtual void OnChildSubscript(gd::String stringExpression) = 0;
/**
* \brief Called when accessing the child of a structure variable using a
* string expression in square brackets. ( "subscript" in
* varName1["subscript"] for example. )
*
* \param variableName The expression used to access the child variable.
*/
virtual void OnChildSubscript(gd::String stringExpression) = 0;
};
}
} // namespace gd
#endif // GDEXPRESSIONPARSER_H
#endif // GDEXPRESSIONPARSER_H

View File

@@ -1,288 +1,285 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GDCore/Project/Project.h"
#include "GDCore/Extensions/Platform.h"
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
#include "GDCore/Events/InstructionsList.h"
#include "GDCore/Events/EventsList.h"
#include "GDCore/Events/Event.h"
#include "GDCore/Events/Serialization.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Events/Event.h"
#include "GDCore/Events/EventsList.h"
#include "GDCore/Events/Instruction.h"
#include "GDCore/Events/InstructionsList.h"
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
#include "GDCore/Extensions/Platform.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Serialization/Serializer.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/Events/Instruction.h"
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
#include "GDCore/Tools/Log.h"
#include "GDCore/CommonTools.h"
using namespace std;
namespace gd
{
namespace gd {
void EventsListSerialization::UpdateInstructionsFromGD31x(gd::Project & project, gd::InstructionsList & list)
{
for (std::size_t i = 0;i<list.size();++i)
{
gd::Instruction & instr = list[i];
void EventsListSerialization::UpdateInstructionsFromGD31x(
gd::Project& project, gd::InstructionsList& list) {
for (std::size_t i = 0; i < list.size(); ++i) {
gd::Instruction& instr = list[i];
if (instr.GetType() == "VarScene" ||
instr.GetType() == "VarSceneTxt" ||
instr.GetType() == "VarGlobal" ||
instr.GetType() == "VarGlobalTxt" ||
instr.GetType() == "ModVarScene" ||
instr.GetType() == "ModVarSceneTxt" ||
instr.GetType() == "ModVarGlobal" ||
instr.GetType() == "ModVarGlobalTxt" )
{
std::vector< gd::Expression > parameters = instr.GetParameters();
if ( parameters.size() >= 1 ) parameters.erase(parameters.begin()+0);
instr.SetParameters(parameters);
}
if (instr.GetType() == "VarSceneDef" ||
instr.GetType() == "VarGlobalDef" ||
instr.GetType() == "VarObjetDef" )
{
instr.SetParameter(1, gd::Expression("\""+instr.GetParameter(1).GetPlainString()+"\""));
}
if (instr.GetType() == "VarScene" || instr.GetType() == "VarSceneTxt" ||
instr.GetType() == "VarGlobal" || instr.GetType() == "VarGlobalTxt" ||
instr.GetType() == "ModVarScene" ||
instr.GetType() == "ModVarSceneTxt" ||
instr.GetType() == "ModVarGlobal" ||
instr.GetType() == "ModVarGlobalTxt") {
std::vector<gd::Expression> parameters = instr.GetParameters();
if (parameters.size() >= 1) parameters.erase(parameters.begin() + 0);
instr.SetParameters(parameters);
}
if (instr.GetType() == "VarSceneDef" || instr.GetType() == "VarGlobalDef" ||
instr.GetType() == "VarObjetDef") {
instr.SetParameter(
1,
gd::Expression("\"" + instr.GetParameter(1).GetPlainString() + "\""));
}
}
}
void EventsListSerialization::UpdateInstructionsFromGD2x(gd::Project & project, gd::InstructionsList & list, bool instructionsAreActions)
{
for (std::size_t i = 0;i<list.size();++i)
{
gd::Instruction & instr = list[i];
void EventsListSerialization::UpdateInstructionsFromGD2x(
gd::Project& project,
gd::InstructionsList& list,
bool instructionsAreActions) {
for (std::size_t i = 0; i < list.size(); ++i) {
gd::Instruction& instr = list[i];
const gd::InstructionMetadata & metadata = instructionsAreActions ?
MetadataProvider::GetActionMetadata(project.GetCurrentPlatform(), instr.GetType()) :
MetadataProvider::GetConditionMetadata(project.GetCurrentPlatform(), instr.GetType());
const gd::InstructionMetadata& metadata =
instructionsAreActions
? MetadataProvider::GetActionMetadata(project.GetCurrentPlatform(),
instr.GetType())
: MetadataProvider::GetConditionMetadata(
project.GetCurrentPlatform(), instr.GetType());
//Specific updates for some instructions
if ( instr.GetType() == "LinkedObjects::LinkObjects" || instr.GetType() == "LinkedObjects::RemoveLinkBetween" )
{
instr.SetParameter(1, instr.GetParameter(3));
instr.SetParameter(2, instr.GetParameter(4));
}
else if (instr.GetType() == "LinkedObjects::RemoveAllLinksOf")
{
instr.SetParameter(1, instr.GetParameter(2));
}
else if (instr.GetType() == "LinkedObjects::PickObjectsLinkedTo")
{
instr.SetParameter(1, instr.GetParameter(5));
instr.SetParameter(2, instr.GetParameter(3));
}
else if (instr.GetType() == "PhysicsBehavior::AddRevoluteJointBetweenObjects")
{
instr.SetParameter(4, instr.GetParameter(5));
instr.SetParameter(5, instr.GetParameter(6));
}
else if (instr.GetType() == "FixCamera" || instr.GetType() == "CentreCamera")
{
std::vector< gd::Expression > parameters = instr.GetParameters();
if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2);
instr.SetParameters(parameters);
}
else if (instr.GetType() == "AjoutObjConcern" || instr.GetType() == "AjoutHasard")
{
instr.SetParameter(1, instr.GetParameter(3));
}
else if (instr.GetType() == "SeDirige" || instr.GetType() == "EstTourne" )
{
std::vector< gd::Expression > parameters = instr.GetParameters();
if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2);
if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2);
instr.SetParameters(parameters);
}
else if (instr.GetType() == "Create")
{
std::vector< gd::Expression > parameters = instr.GetParameters();
if ( parameters.size() >= 2 ) parameters.erase(parameters.begin()+1);
if ( parameters.size() >= 2 ) parameters.erase(parameters.begin()+1);
instr.SetParameters(parameters);
}
else if (instr.GetType() == "CreateByName")
{
std::vector< gd::Expression > parameters = instr.GetParameters();
if ( parameters.size() >= 2 ) parameters.erase(parameters.begin()+1);
instr.SetParameters(parameters);
}
else if (instr.GetType() == "NbObjet")
{
std::vector< gd::Expression > parameters = instr.GetParameters();
if ( parameters.size() >= 2 ) parameters.erase(parameters.begin()+1);
instr.SetParameters(parameters);
}
else if (instr.GetType() == "Distance")
{
std::vector< gd::Expression > parameters = instr.GetParameters();
if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2);
if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2);
if ( parameters.size() >= 4 && (parameters[3].GetPlainString() == ">=" || parameters[3].GetPlainString() == ">") )
{
instr.SetInverted(true);
}
else
{
instr.SetInverted(false);
}
instr.SetParameters(parameters);
}
//Common updates for some parameters
const std::vector< gd::Expression > & parameters = instr.GetParameters();
for (std::size_t j = 0;j<parameters.size() && j<metadata.parameters.size();++j)
{
if ( metadata.parameters[j].type == "relationalOperator" ||
metadata.parameters[j].type == "operator" )
{
if ( j == parameters.size()-1 )
{
std::cout << "ERROR: No more parameters after a [relational]operator when trying to update an instruction from GD2.x";
}
else
{
//Exchange parameters
gd::String op = parameters[j+1].GetPlainString();
instr.SetParameter(j+1, parameters[j] );
instr.SetParameter(j, gd::Expression(op));
}
}
}
//UpdateInstructionsFromGD2x(project, instr.GetSubInstructions(), instructionsAreActions);
// Specific updates for some instructions
if (instr.GetType() == "LinkedObjects::LinkObjects" ||
instr.GetType() == "LinkedObjects::RemoveLinkBetween") {
instr.SetParameter(1, instr.GetParameter(3));
instr.SetParameter(2, instr.GetParameter(4));
} else if (instr.GetType() == "LinkedObjects::RemoveAllLinksOf") {
instr.SetParameter(1, instr.GetParameter(2));
} else if (instr.GetType() == "LinkedObjects::PickObjectsLinkedTo") {
instr.SetParameter(1, instr.GetParameter(5));
instr.SetParameter(2, instr.GetParameter(3));
} else if (instr.GetType() ==
"PhysicsBehavior::AddRevoluteJointBetweenObjects") {
instr.SetParameter(4, instr.GetParameter(5));
instr.SetParameter(5, instr.GetParameter(6));
} else if (instr.GetType() == "FixCamera" ||
instr.GetType() == "CentreCamera") {
std::vector<gd::Expression> parameters = instr.GetParameters();
if (parameters.size() >= 3) parameters.erase(parameters.begin() + 2);
instr.SetParameters(parameters);
} else if (instr.GetType() == "AjoutObjConcern" ||
instr.GetType() == "AjoutHasard") {
instr.SetParameter(1, instr.GetParameter(3));
} else if (instr.GetType() == "SeDirige" ||
instr.GetType() == "EstTourne") {
std::vector<gd::Expression> parameters = instr.GetParameters();
if (parameters.size() >= 3) parameters.erase(parameters.begin() + 2);
if (parameters.size() >= 3) parameters.erase(parameters.begin() + 2);
instr.SetParameters(parameters);
} else if (instr.GetType() == "Create") {
std::vector<gd::Expression> parameters = instr.GetParameters();
if (parameters.size() >= 2) parameters.erase(parameters.begin() + 1);
if (parameters.size() >= 2) parameters.erase(parameters.begin() + 1);
instr.SetParameters(parameters);
} else if (instr.GetType() == "CreateByName") {
std::vector<gd::Expression> parameters = instr.GetParameters();
if (parameters.size() >= 2) parameters.erase(parameters.begin() + 1);
instr.SetParameters(parameters);
} else if (instr.GetType() == "NbObjet") {
std::vector<gd::Expression> parameters = instr.GetParameters();
if (parameters.size() >= 2) parameters.erase(parameters.begin() + 1);
instr.SetParameters(parameters);
} else if (instr.GetType() == "Distance") {
std::vector<gd::Expression> parameters = instr.GetParameters();
if (parameters.size() >= 3) parameters.erase(parameters.begin() + 2);
if (parameters.size() >= 3) parameters.erase(parameters.begin() + 2);
if (parameters.size() >= 4 && (parameters[3].GetPlainString() == ">=" ||
parameters[3].GetPlainString() == ">")) {
instr.SetInverted(true);
} else {
instr.SetInverted(false);
}
instr.SetParameters(parameters);
}
// Common updates for some parameters
const std::vector<gd::Expression>& parameters = instr.GetParameters();
for (std::size_t j = 0;
j < parameters.size() && j < metadata.parameters.size();
++j) {
if (metadata.parameters[j].type == "relationalOperator" ||
metadata.parameters[j].type == "operator") {
if (j == parameters.size() - 1) {
std::cout << "ERROR: No more parameters after a [relational]operator "
"when trying to update an instruction from GD2.x";
} else {
// Exchange parameters
gd::String op = parameters[j + 1].GetPlainString();
instr.SetParameter(j + 1, parameters[j]);
instr.SetParameter(j, gd::Expression(op));
}
}
}
// UpdateInstructionsFromGD2x(project, instr.GetSubInstructions(),
// instructionsAreActions);
}
}
void EventsListSerialization::UnserializeEventsFrom(gd::Project & project, EventsList & list, const SerializerElement & events)
{
list.Clear();
events.ConsiderAsArrayOf("event", "Event");
for(std::size_t i = 0; i<events.GetChildrenCount(); ++i)
{
SerializerElement & eventElem = events.GetChild(i);
gd::String type = eventElem.GetChild("type", 0, "Type").GetValue().GetString();
gd::BaseEventSPtr event = project.CreateEvent(type);
if ( event != std::shared_ptr<gd::BaseEvent>())
event->UnserializeFrom(project, eventElem);
else
{
std::cout << "WARNING: Unknown event of type " << type << std::endl;
event = std::make_shared<EmptyEvent>();
}
event->SetDisabled(eventElem.GetBoolAttribute("disabled"));
event->SetFolded(eventElem.GetBoolAttribute("folded"));
list.InsertEvent(event, list.GetEventsCount());
void EventsListSerialization::UnserializeEventsFrom(
gd::Project& project, EventsList& list, const SerializerElement& events) {
list.Clear();
events.ConsiderAsArrayOf("event", "Event");
for (std::size_t i = 0; i < events.GetChildrenCount(); ++i) {
SerializerElement& eventElem = events.GetChild(i);
gd::String type =
eventElem.GetChild("type", 0, "Type").GetValue().GetString();
gd::BaseEventSPtr event = project.CreateEvent(type);
if (event != std::shared_ptr<gd::BaseEvent>())
event->UnserializeFrom(project, eventElem);
else {
std::cout << "WARNING: Unknown event of type " << type << std::endl;
event = std::make_shared<EmptyEvent>();
}
event->SetDisabled(eventElem.GetBoolAttribute("disabled"));
event->SetFolded(eventElem.GetBoolAttribute("folded"));
list.InsertEvent(event, list.GetEventsCount());
}
}
void EventsListSerialization::SerializeEventsTo(const EventsList & list, SerializerElement & events)
{
events.ConsiderAsArrayOf("event");
for ( std::size_t j = 0;j < list.size();j++ )
{
const gd::BaseEvent & event = list.GetEvent(j);
SerializerElement & eventElem = events.AddChild("event");
void EventsListSerialization::SerializeEventsTo(const EventsList& list,
SerializerElement& events) {
events.ConsiderAsArrayOf("event");
for (std::size_t j = 0; j < list.size(); j++) {
const gd::BaseEvent& event = list.GetEvent(j);
SerializerElement& eventElem = events.AddChild("event");
eventElem.SetAttribute("disabled", event.IsDisabled());
eventElem.SetAttribute("folded", event.IsFolded());
eventElem.AddChild("type").SetValue(event.GetType());
eventElem.SetAttribute("disabled", event.IsDisabled());
eventElem.SetAttribute("folded", event.IsFolded());
eventElem.AddChild("type").SetValue(event.GetType());
event.SerializeTo(eventElem);
}
event.SerializeTo(eventElem);
}
}
using namespace std;
void gd::EventsListSerialization::UnserializeInstructionsFrom(gd::Project & project, gd::InstructionsList & instructions, const SerializerElement & elem)
{
elem.ConsiderAsArrayOf("instruction");
//Compatibility with GD <= 4.0.95
if (elem.HasChild("condition", "Condition"))
elem.ConsiderAsArrayOf("condition", "Condition");
else if (elem.HasChild("action", "Action"))
elem.ConsiderAsArrayOf("action", "Action");
//end of compatibility code
void gd::EventsListSerialization::UnserializeInstructionsFrom(
gd::Project& project,
gd::InstructionsList& instructions,
const SerializerElement& elem) {
elem.ConsiderAsArrayOf("instruction");
// Compatibility with GD <= 4.0.95
if (elem.HasChild("condition", "Condition"))
elem.ConsiderAsArrayOf("condition", "Condition");
else if (elem.HasChild("action", "Action"))
elem.ConsiderAsArrayOf("action", "Action");
// end of compatibility code
for(std::size_t i = 0; i<elem.GetChildrenCount(); ++i)
{
gd::Instruction instruction;
const SerializerElement & instrElement = elem.GetChild(i);
for (std::size_t i = 0; i < elem.GetChildrenCount(); ++i) {
gd::Instruction instruction;
const SerializerElement& instrElement = elem.GetChild(i);
instruction.SetType(instrElement.GetChild("type", 0, "Type").GetStringAttribute("value")
.FindAndReplace("Automatism", "Behavior")); //Compatibility with GD <= 4
instruction.SetInverted(instrElement.GetChild("type", 0, "Type").GetBoolAttribute("inverted", false, "Contraire"));
instruction.SetType(
instrElement.GetChild("type", 0, "Type")
.GetStringAttribute("value")
.FindAndReplace("Automatism",
"Behavior")); // Compatibility with GD <= 4
instruction.SetInverted(
instrElement.GetChild("type", 0, "Type")
.GetBoolAttribute("inverted", false, "Contraire"));
//Read parameters
vector < gd::Expression > parameters;
// Read parameters
vector<gd::Expression> parameters;
//Compatibility with GD <= 3.3
if (instrElement.HasChild("Parametre")) {
// Compatibility with GD <= 3.3
if (instrElement.HasChild("Parametre")) {
for (std::size_t j = 0; j < instrElement.GetChildrenCount("Parametre");
++j)
parameters.push_back(gd::Expression(
instrElement.GetChild("Parametre", j).GetValue().GetString()));
for (std::size_t j = 0;j<instrElement.GetChildrenCount("Parametre");++j)
parameters.push_back(gd::Expression(instrElement.GetChild("Parametre", j).GetValue().GetString()));
}
//end of compatibility code
else
{
const SerializerElement & parametersElem = instrElement.GetChild("parameters");
parametersElem.ConsiderAsArrayOf("parameter");
for (std::size_t j = 0;j<parametersElem.GetChildrenCount();++j)
parameters.push_back(gd::Expression(parametersElem.GetChild(j).GetValue().GetString()));
}
instruction.SetParameters( parameters );
//Read sub instructions
if ( instrElement.HasChild("subInstructions") )
UnserializeInstructionsFrom(project, instruction.GetSubInstructions(), instrElement.GetChild("subInstructions"));
//Compatibility with GD <= 4.0.95
if ( instrElement.HasChild("subConditions", "SubConditions") )
UnserializeInstructionsFrom(project, instruction.GetSubInstructions(), instrElement.GetChild("subConditions", 0, "SubConditions" ));
if ( instrElement.HasChild("subActions", "SubActions") )
UnserializeInstructionsFrom(project, instruction.GetSubInstructions(), instrElement.GetChild("subActions", 0, "SubActions" ));
//end of compatibility code
instructions.Insert( instruction );
}
// end of compatibility code
else {
const SerializerElement& parametersElem =
instrElement.GetChild("parameters");
parametersElem.ConsiderAsArrayOf("parameter");
for (std::size_t j = 0; j < parametersElem.GetChildrenCount(); ++j)
parameters.push_back(
gd::Expression(parametersElem.GetChild(j).GetValue().GetString()));
}
//Compatibility with GD <= 3.1
if ( project.GetLastSaveGDMajorVersion() < 3 ||
(project.GetLastSaveGDMajorVersion() == 3 && project.GetLastSaveGDMinorVersion() <= 1 ) )
UpdateInstructionsFromGD31x(project, instructions);
instruction.SetParameters(parameters);
if ( project.GetLastSaveGDMajorVersion() < 3 )
UpdateInstructionsFromGD2x(project, instructions, elem.HasChild("action", "Action"));
//end of compatibility code
// Read sub instructions
if (instrElement.HasChild("subInstructions"))
UnserializeInstructionsFrom(project,
instruction.GetSubInstructions(),
instrElement.GetChild("subInstructions"));
// Compatibility with GD <= 4.0.95
if (instrElement.HasChild("subConditions", "SubConditions"))
UnserializeInstructionsFrom(
project,
instruction.GetSubInstructions(),
instrElement.GetChild("subConditions", 0, "SubConditions"));
if (instrElement.HasChild("subActions", "SubActions"))
UnserializeInstructionsFrom(
project,
instruction.GetSubInstructions(),
instrElement.GetChild("subActions", 0, "SubActions"));
// end of compatibility code
instructions.Insert(instruction);
}
// Compatibility with GD <= 3.1
if (project.GetLastSaveGDMajorVersion() < 3 ||
(project.GetLastSaveGDMajorVersion() == 3 &&
project.GetLastSaveGDMinorVersion() <= 1))
UpdateInstructionsFromGD31x(project, instructions);
if (project.GetLastSaveGDMajorVersion() < 3)
UpdateInstructionsFromGD2x(
project, instructions, elem.HasChild("action", "Action"));
// end of compatibility code
}
void gd::EventsListSerialization::SerializeInstructionsTo(const gd::InstructionsList & list, SerializerElement & instructions)
{
instructions.ConsiderAsArrayOf("instruction");
for ( std::size_t k = 0;k < list.size();k++ )
{
SerializerElement & instruction = instructions.AddChild("instruction");
instruction.AddChild("type")
.SetAttribute("value", list[k].GetType())
.SetAttribute("inverted", list[k].IsInverted());
void gd::EventsListSerialization::SerializeInstructionsTo(
const gd::InstructionsList& list, SerializerElement& instructions) {
instructions.ConsiderAsArrayOf("instruction");
for (std::size_t k = 0; k < list.size(); k++) {
SerializerElement& instruction = instructions.AddChild("instruction");
instruction.AddChild("type")
.SetAttribute("value", list[k].GetType())
.SetAttribute("inverted", list[k].IsInverted());
//Parameters
SerializerElement & parameters = instruction.AddChild("parameters");
parameters.ConsiderAsArrayOf("parameter");
for ( std::size_t l = 0;l < list[k].GetParameters().size();l++ )
parameters.AddChild("parameter").SetValue(list[k].GetParameter(l).GetPlainString());
// Parameters
SerializerElement& parameters = instruction.AddChild("parameters");
parameters.ConsiderAsArrayOf("parameter");
for (std::size_t l = 0; l < list[k].GetParameters().size(); l++)
parameters.AddChild("parameter")
.SetValue(list[k].GetParameter(l).GetPlainString());
//Sub instructions
SerializerElement & subInstructions = instruction.AddChild("subInstructions");
SerializeInstructionsTo(list[k].GetSubInstructions(), subInstructions);
}
// Sub instructions
SerializerElement& subInstructions =
instruction.AddChild("subInstructions");
SerializeInstructionsTo(list[k].GetSubInstructions(), subInstructions);
}
}
}
} // namespace gd

View File

@@ -1,66 +1,79 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_EVENTS_SERIALIZATION_H
#define GDCORE_EVENTS_SERIALIZATION_H
#include "GDCore/Serialization/Serializer.h"
#include <vector>
namespace gd { class InstructionsList; }
namespace gd { class Project; }
namespace gd { class EventsList; }
#include "GDCore/Serialization/Serializer.h"
namespace gd {
class InstructionsList;
}
namespace gd {
class Project;
}
namespace gd {
class EventsList;
}
namespace gd
{
namespace gd {
/**
* \brief Contains tools for loading and saving events to SerializerElement.
*/
class GD_CORE_API EventsListSerialization
{
public:
/**
* \brief Load an events list from a SerializerElement
* \param project The project the events belongs to.
* \param list The event list in which the events must be loaded.
* \param events The SerializerElement containing the events
*/
static void UnserializeEventsFrom(gd::Project & project, gd::EventsList & list, const SerializerElement & events);
class GD_CORE_API EventsListSerialization {
public:
/**
* \brief Load an events list from a SerializerElement
* \param project The project the events belongs to.
* \param list The event list in which the events must be loaded.
* \param events The SerializerElement containing the events
*/
static void UnserializeEventsFrom(gd::Project& project,
gd::EventsList& list,
const SerializerElement& events);
/**
* \brief Save an events list to a SerializerElement
* \param list The event list to be saved.
* \param events The SerializerElement in which the events must be serialized.
*/
static void SerializeEventsTo(const gd::EventsList & list, SerializerElement & events);
/**
* \brief Save an events list to a SerializerElement
* \param list The event list to be saved.
* \param events The SerializerElement in which the events must be serialized.
*/
static void SerializeEventsTo(const gd::EventsList& list,
SerializerElement& events);
/**
* \brief Unserialize a list of instructions
*/
static void UnserializeInstructionsFrom(gd::Project & project, gd::InstructionsList & list, const SerializerElement & elem);
/**
* \brief Unserialize a list of instructions
*/
static void UnserializeInstructionsFrom(gd::Project& project,
gd::InstructionsList& list,
const SerializerElement& elem);
/**
* \brief Serialize a list of instructions
*/
static void SerializeInstructionsTo(const gd::InstructionsList & list, SerializerElement & elem);
/**
* \brief Serialize a list of instructions
*/
static void SerializeInstructionsTo(const gd::InstructionsList& list,
SerializerElement& elem);
private:
/**
* \brief Internal method called when opening events created with GD2.x
*
* Some instructions names have been changed as well as parameters since GD 3.
*/
static void UpdateInstructionsFromGD2x(gd::Project & project, gd::InstructionsList & list, bool instructionsAreActions);
private:
/**
* \brief Internal method called when opening events created with GD2.x
*
* Some instructions names have been changed as well as parameters since GD 3.
*/
static void UpdateInstructionsFromGD2x(gd::Project& project,
gd::InstructionsList& list,
bool instructionsAreActions);
/**
* \brief Internal method called when opening events created with GD 3.1.x
*
* Variables related and some storage instructions have been changed.
*/
static void UpdateInstructionsFromGD31x(gd::Project & project, gd::InstructionsList & list);
/**
* \brief Internal method called when opening events created with GD 3.1.x
*
* Variables related and some storage instructions have been changed.
*/
static void UpdateInstructionsFromGD31x(gd::Project& project,
gd::InstructionsList& list);
};
}
} // namespace gd
#endif // GDCORE_EVENTS_SERIALIZATION_H
#endif // GDCORE_EVENTS_SERIALIZATION_H

View File

@@ -1,69 +1,70 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#include "GDCore/CommonTools.h"
#include "EventsCodeNameMangler.h"
#include "GDCore/CommonTools.h"
#include "GDCore/String.h"
EventsCodeNameMangler *EventsCodeNameMangler::_singleton = NULL;
gd::String EventsCodeNameMangler::GetMangledObjectsListName(const gd::String & originalObjectName)
{
gd::String partiallyMangledName = originalObjectName;
static const gd::String allowedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
gd::String EventsCodeNameMangler::GetMangledObjectsListName(
const gd::String &originalObjectName) {
gd::String partiallyMangledName = originalObjectName;
static const gd::String allowedCharacters =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for (size_t i = 0;i<partiallyMangledName.size();++i) //Replace all unallowed letter by an underscore and the ascii number of the letter
{
if ( allowedCharacters.find_first_of(std::u32string(1, partiallyMangledName[i])) == gd::String::npos)
{
char32_t unallowedChar = partiallyMangledName[i];
partiallyMangledName.replace(i, 1, "_"+gd::String::From(unallowedChar));
}
for (size_t i = 0; i < partiallyMangledName.size();
++i) // Replace all unallowed letter by an underscore and the ascii
// number of the letter
{
if (allowedCharacters.find_first_of(
std::u32string(1, partiallyMangledName[i])) == gd::String::npos) {
char32_t unallowedChar = partiallyMangledName[i];
partiallyMangledName.replace(i, 1, "_" + gd::String::From(unallowedChar));
}
}
return "GD"+partiallyMangledName+"Objects";
return "GD" + partiallyMangledName + "Objects";
}
gd::String EventsCodeNameMangler::GetExternalEventsFunctionMangledName(const gd::String & externalEventsName)
{
gd::String partiallyMangledName = externalEventsName;
static const gd::String allowedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
gd::String EventsCodeNameMangler::GetExternalEventsFunctionMangledName(
const gd::String &externalEventsName) {
gd::String partiallyMangledName = externalEventsName;
static const gd::String allowedCharacters =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for (size_t i = 0;i<partiallyMangledName.size();++i) //Replace all unallowed letter by an underscore and the ascii number of the letter
{
if ( allowedCharacters.find_first_of(std::u32string(1, partiallyMangledName[i])) == gd::String::npos)
{
char32_t unallowedChar = partiallyMangledName[i];
partiallyMangledName.replace(i, 1, "_"+gd::String::From(unallowedChar));
}
for (size_t i = 0; i < partiallyMangledName.size();
++i) // Replace all unallowed letter by an underscore and the ascii
// number of the letter
{
if (allowedCharacters.find_first_of(
std::u32string(1, partiallyMangledName[i])) == gd::String::npos) {
char32_t unallowedChar = partiallyMangledName[i];
partiallyMangledName.replace(i, 1, "_" + gd::String::From(unallowedChar));
}
}
return "GDExternalEvents"+partiallyMangledName;
return "GDExternalEvents" + partiallyMangledName;
}
gd::String ManObjListName(const gd::String & objectName)
{
return EventsCodeNameMangler::Get()->GetMangledObjectsListName(objectName);
gd::String ManObjListName(const gd::String &objectName) {
return EventsCodeNameMangler::Get()->GetMangledObjectsListName(objectName);
}
EventsCodeNameMangler * EventsCodeNameMangler::Get()
{
if ( NULL == _singleton )
_singleton = new EventsCodeNameMangler;
EventsCodeNameMangler *EventsCodeNameMangler::Get() {
if (NULL == _singleton) _singleton = new EventsCodeNameMangler;
return ( static_cast<EventsCodeNameMangler*>( _singleton ) );
return (static_cast<EventsCodeNameMangler *>(_singleton));
}
void EventsCodeNameMangler::DestroySingleton()
{
if ( NULL != _singleton )
{
delete _singleton;
_singleton = NULL;
}
void EventsCodeNameMangler::DestroySingleton() {
if (NULL != _singleton) {
delete _singleton;
_singleton = NULL;
}
}
#endif

View File

@@ -1,7 +1,7 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#ifndef EVENTSCODENAMEMANGLER_H
@@ -13,36 +13,36 @@
*
* \see ManObjListName
*/
class GD_CORE_API EventsCodeNameMangler
{
public:
class GD_CORE_API EventsCodeNameMangler {
public:
/**
* Get the mangled name from a name : All characters that are not 0-9, a-z,
* A-Z or _ are replaced by "_"+AsciiCodeOfTheCharacter.
*/
gd::String GetMangledObjectsListName(const gd::String &originalObjectName);
/**
* Get the mangled name from a name : All characters that are not 0-9, a-z, A-Z or _ are replaced by "_"+AsciiCodeOfTheCharacter.
*/
gd::String GetMangledObjectsListName(const gd::String & originalObjectName);
/**
* Get the mangled function name to be used to call external events named \a
* externalEventsName.
*/
gd::String GetExternalEventsFunctionMangledName(
const gd::String &externalEventsName);
/**
* Get the mangled function name to be used to call external events named \a externalEventsName.
*/
gd::String GetExternalEventsFunctionMangledName(const gd::String & externalEventsName);
static EventsCodeNameMangler *Get();
static void DestroySingleton();
static EventsCodeNameMangler *Get();
static void DestroySingleton();
private:
EventsCodeNameMangler() {};
virtual ~EventsCodeNameMangler() {};
static EventsCodeNameMangler *_singleton;
private:
EventsCodeNameMangler(){};
virtual ~EventsCodeNameMangler(){};
static EventsCodeNameMangler *_singleton;
};
/**
* Shortcut to EventsCodeNameMangler::Get()->GetMangledObjectsListName(objectName).
* \see EventsCodeNameMangler
* \return Mangled object name
* Shortcut to
* EventsCodeNameMangler::Get()->GetMangledObjectsListName(objectName). \see
* EventsCodeNameMangler \return Mangled object name
*/
gd::String GD_CORE_API ManObjListName(const gd::String & objectName);
gd::String GD_CORE_API ManObjListName(const gd::String &objectName);
#endif // EVENTSCODENAMEMANGLER_H
#endif // EVENTSCODENAMEMANGLER_H
#endif

View File

@@ -1,34 +1,36 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
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)");
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)");
#if defined(GD_IDE_ONLY)
extension.AddCondition("Toujours",
_("Always"),
_("This condition always returns true (or always false, if the condition is inverted)."),
_("Always"),
_("Other"),
"res/conditions/toujours24.png",
"res/conditions/toujours.png")
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsAdvanced();
#endif
#if defined(GD_IDE_ONLY)
extension
.AddCondition("Toujours",
_("Always"),
_("This condition always returns true (or always false, if "
"the condition is inverted)."),
_("Always"),
_("Other"),
"res/conditions/toujours24.png",
"res/conditions/toujours.png")
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsAdvanced();
#endif
}
}
} // namespace gd

View File

@@ -1,15 +1,14 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_COMMONINSTRUCTIONSEXTENSION_H
#define GDCORE_COMMONINSTRUCTIONSEXTENSION_H
#include "GDCore/Extensions/PlatformExtension.h"
namespace gd
{
namespace gd {
/**
* \brief Tool class containing static methods to setup an extension
@@ -20,30 +19,34 @@ namespace gd
*
* \ingroup BuiltinExtensions
*/
class GD_CORE_API BuiltinExtensionsImplementer
{
public:
static void ImplementsAdvancedExtension(gd::PlatformExtension & extension);
static void ImplementsAudioExtension(gd::PlatformExtension & extension);
static void ImplementsBaseObjectExtension(gd::PlatformExtension & extension);
static void ImplementsCameraExtension(gd::PlatformExtension & extension);
static void ImplementsCommonConversionsExtension(gd::PlatformExtension & extension);
static void ImplementsCommonInstructionsExtension(gd::PlatformExtension & extension);
static void ImplementsExternalLayoutsExtension(gd::PlatformExtension & extension);
static void ImplementsFileExtension(gd::PlatformExtension & extension);
static void ImplementsJoystickExtension(gd::PlatformExtension & extension);
static void ImplementsKeyboardExtension(gd::PlatformExtension & extension);
static void ImplementsMathematicalToolsExtension(gd::PlatformExtension & extension);
static void ImplementsMouseExtension(gd::PlatformExtension & extension);
static void ImplementsNetworkExtension(gd::PlatformExtension & extension);
static void ImplementsSceneExtension(gd::PlatformExtension & extension);
static void ImplementsSpriteExtension(gd::PlatformExtension & extension);
static void ImplementsStringInstructionsExtension(gd::PlatformExtension & extension);
static void ImplementsTimeExtension(gd::PlatformExtension & extension);
static void ImplementsVariablesExtension(gd::PlatformExtension & extension);
static void ImplementsWindowExtension(gd::PlatformExtension & extension);
class GD_CORE_API BuiltinExtensionsImplementer {
public:
static void ImplementsAdvancedExtension(gd::PlatformExtension& extension);
static void ImplementsAudioExtension(gd::PlatformExtension& extension);
static void ImplementsBaseObjectExtension(gd::PlatformExtension& extension);
static void ImplementsCameraExtension(gd::PlatformExtension& extension);
static void ImplementsCommonConversionsExtension(
gd::PlatformExtension& extension);
static void ImplementsCommonInstructionsExtension(
gd::PlatformExtension& extension);
static void ImplementsExternalLayoutsExtension(
gd::PlatformExtension& extension);
static void ImplementsFileExtension(gd::PlatformExtension& extension);
static void ImplementsJoystickExtension(gd::PlatformExtension& extension);
static void ImplementsKeyboardExtension(gd::PlatformExtension& extension);
static void ImplementsMathematicalToolsExtension(
gd::PlatformExtension& extension);
static void ImplementsMouseExtension(gd::PlatformExtension& extension);
static void ImplementsNetworkExtension(gd::PlatformExtension& extension);
static void ImplementsSceneExtension(gd::PlatformExtension& extension);
static void ImplementsSpriteExtension(gd::PlatformExtension& extension);
static void ImplementsStringInstructionsExtension(
gd::PlatformExtension& extension);
static void ImplementsTimeExtension(gd::PlatformExtension& extension);
static void ImplementsVariablesExtension(gd::PlatformExtension& extension);
static void ImplementsWindowExtension(gd::PlatformExtension& extension);
};
}
} // namespace gd
#endif // GDCORE_COMMONINSTRUCTIONSEXTENSION_H
#endif // GDCORE_COMMONINSTRUCTIONSEXTENSION_H

View File

@@ -1,435 +1,545 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinAudio",
_("Audio"),
_("Builtin audio extension"),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation("BuiltinAudio",
_("Audio"),
_("Builtin audio extension"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddAction("PlaySoundCanal",
_("Play a sound on a channel"),
_("Play a sound (small audio file) on a specific channel,\nso you'll be able to manipulate it."),
_("Play the sound _PARAM1_ on the channel _PARAM2_, vol.: _PARAM4_, loop: _PARAM3_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("soundfile", _("Audio file (or audio resource name)"))
.AddParameter("expression", _("Channel identifier"))
.AddParameter("yesorno", _("Repeat the sound"), "",true).SetDefaultValue("no")
.AddParameter("expression", _("Volume (from 0 to 100, 100 by default)"), "",true).SetDefaultValue("100")
.AddParameter("expression", _("Pitch (speed) (1 by default)"), "",true).SetDefaultValue("1")
.MarkAsAdvanced();
#if defined(GD_IDE_ONLY)
extension
.AddAction("PlaySoundCanal",
_("Play a sound on a channel"),
_("Play a sound (small audio file) on a specific channel,\nso "
"you'll be able to manipulate it."),
_("Play the sound _PARAM1_ on the channel _PARAM2_, vol.: "
"_PARAM4_, loop: _PARAM3_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("soundfile", _("Audio file (or audio resource name)"))
.AddParameter("expression", _("Channel identifier"))
.AddParameter("yesorno", _("Repeat the sound"), "", true)
.SetDefaultValue("no")
.AddParameter(
"expression", _("Volume (from 0 to 100, 100 by default)"), "", true)
.SetDefaultValue("100")
.AddParameter("expression", _("Pitch (speed) (1 by default)"), "", true)
.SetDefaultValue("1")
.MarkAsAdvanced();
extension.AddAction("StopSoundCanal",
_("Stop the sound of a channel"),
_("Stop the sound on the specified channel."),
_("Stop the sound of channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension
.AddAction("StopSoundCanal",
_("Stop the sound of a channel"),
_("Stop the sound on the specified channel."),
_("Stop the sound of channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension.AddAction("PauseSoundCanal",
_("Pause the sound of a channel"),
_("Pause the sound played on the specified channel."),
_("Pause the sound of channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension
.AddAction("PauseSoundCanal",
_("Pause the sound of a channel"),
_("Pause the sound played on the specified channel."),
_("Pause the sound of channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension.AddAction("RePlaySoundCanal",
_("Play the sound of a channel"),
_("Play the sound of the channel."),
_("Play the sound of channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension
.AddAction("RePlaySoundCanal",
_("Play the sound of a channel"),
_("Play the sound of the channel."),
_("Play the sound of channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension.AddAction("PlayMusicCanal",
_("Play a music file on a channel"),
_("Play a music file on a specific channel,\nso you'll be able to interact with it later."),
_("Play the music _PARAM1_ on channel _PARAM2_, vol.: _PARAM4_, loop: _PARAM3_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("musicfile", _("Audio file (or audio resource name)"))
.AddParameter("expression", _("Channel identifier"))
.AddParameter("yesorno", _("Repeat the sound"), "",true).SetDefaultValue("no")
.AddParameter("expression", _("Volume (from 0 to 100, 100 by default)"), "",true).SetDefaultValue("100")
.AddParameter("expression", _("Pitch (speed) (1 by default)"), "",true).SetDefaultValue("1")
.MarkAsAdvanced();
extension
.AddAction("PlayMusicCanal",
_("Play a music file on a channel"),
_("Play a music file on a specific channel,\nso you'll be "
"able to interact with it later."),
_("Play the music _PARAM1_ on channel _PARAM2_, vol.: "
"_PARAM4_, loop: _PARAM3_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("musicfile", _("Audio file (or audio resource name)"))
.AddParameter("expression", _("Channel identifier"))
.AddParameter("yesorno", _("Repeat the sound"), "", true)
.SetDefaultValue("no")
.AddParameter(
"expression", _("Volume (from 0 to 100, 100 by default)"), "", true)
.SetDefaultValue("100")
.AddParameter("expression", _("Pitch (speed) (1 by default)"), "", true)
.SetDefaultValue("1")
.MarkAsAdvanced();
extension.AddAction("StopMusicCanal",
_("Stop the music on a channel"),
_("Stop the music on the specified channel"),
_("Stop the music of channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension
.AddAction("StopMusicCanal",
_("Stop the music on a channel"),
_("Stop the music on the specified channel"),
_("Stop the music of channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension.AddAction("PauseMusicCanal",
_("Pause the music of a channel"),
_("Pause the music on the specified channel."),
_("Pause the music of channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension
.AddAction("PauseMusicCanal",
_("Pause the music of a channel"),
_("Pause the music on the specified channel."),
_("Pause the music of channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension.AddAction("RePlayMusicCanal",
_("Play the music of a channel"),
_("Play the music of the channel."),
_("Play the music of channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension
.AddAction("RePlayMusicCanal",
_("Play the music of a channel"),
_("Play the music of the channel."),
_("Play the music of channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.MarkAsAdvanced();
extension.AddAction("ModVolumeSoundCanal",
_("Volume of the sound on a channel"),
_("This action modifies the volume of the sound on the specified channel. The volume is between 0 and 100."),
_("Do _PARAM2__PARAM3_ to the volume of the sound on channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/sonVolume24.png",
"res/actions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddAction("ModVolumeSoundCanal",
_("Volume of the sound on a channel"),
_("This action modifies the volume of the sound on the "
"specified channel. The volume is between 0 and 100."),
_("Do _PARAM2__PARAM3_ to the volume of the sound on channel "
"_PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/sonVolume24.png",
"res/actions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("ModVolumeMusicCanal",
_("Volume of the music on a channel"),
_("This action modifies the volume of the music on the specified channel. The volume is between 0 and 100."),
_("Do _PARAM2__PARAM3_ to the volume of the music on channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/musicVolume24.png",
"res/actions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddAction("ModVolumeMusicCanal",
_("Volume of the music on a channel"),
_("This action modifies the volume of the music on the "
"specified channel. The volume is between 0 and 100."),
_("Do _PARAM2__PARAM3_ to the volume of the music on channel "
"_PARAM1_"),
_("Audio/Music on channels"),
"res/actions/musicVolume24.png",
"res/actions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("ModGlobalVolume",
_("Game global volume"),
_("This action modifies the global volume of the game. The volume is between 0 and 100."),
_("Do _PARAM1__PARAM2_ to global sound level"),
_("Audio"),
"res/actions/volume24.png",
"res/actions/volume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsSimple()
.SetManipulatedType("number");
extension
.AddAction("ModGlobalVolume",
_("Game global volume"),
_("This action modifies the global volume of the game. The "
"volume is between 0 and 100."),
_("Do _PARAM1__PARAM2_ to global sound level"),
_("Audio"),
"res/actions/volume24.png",
"res/actions/volume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsSimple()
.SetManipulatedType("number");
extension.AddAction("ModPitchSoundChannel",
_("Pitch of the sound of a channel"),
_("This action modifies the pitch (speed) of the sound on a channel.\n1 is the default pitch."),
_("Do _PARAM2__PARAM3_ to the pitch of the sound on channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddAction("ModPitchSoundChannel",
_("Pitch of the sound of a channel"),
_("This action modifies the pitch (speed) of the sound on a "
"channel.\n1 is the default pitch."),
_("Do _PARAM2__PARAM3_ to the pitch of the sound on channel "
"_PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("ModPitchMusicChannel",
_("Pitch of the music on a channel"),
_("This action modifies the pitch of the music on the specified channel. 1 is the default pitch"),
_("Do _PARAM2__PARAM3_ to the pitch of the music on channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddAction("ModPitchMusicChannel",
_("Pitch of the music on a channel"),
_("This action modifies the pitch of the music on the "
"specified channel. 1 is the default pitch"),
_("Do _PARAM2__PARAM3_ to the pitch of the music on channel "
"_PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("ModPlayingOffsetSoundChannel",
_("Playing offset of the sound on a channel"),
_("This action modifies the playing offset of the sound on a channel"),
_("Do _PARAM2__PARAM3_ to the playing offset of the sound on channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddAction("ModPlayingOffsetSoundChannel",
_("Playing offset of the sound on a channel"),
_("This action modifies the playing offset of the sound on a "
"channel"),
_("Do _PARAM2__PARAM3_ to the playing offset of the sound on "
"channel _PARAM1_"),
_("Audio/Sounds on channels"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("ModPlayingOffsetMusicChannel",
_("Playing offset of the music on a channel"),
_("This action modifies the playing offset of the music on the specified channel"),
_("Do _PARAM2__PARAM3_ to the playing offset of the music on channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddAction("ModPlayingOffsetMusicChannel",
_("Playing offset of the music on a channel"),
_("This action modifies the playing offset of the music on "
"the specified channel"),
_("Do _PARAM2__PARAM3_ to the playing offset of the music on "
"channel _PARAM1_"),
_("Audio/Music on channels"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("PlaySound",
_("Play a sound"),
_("Play a sound."),
_("Play the sound _PARAM1_, vol.: _PARAM3_, loop: _PARAM2_)"),
_("Audio"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("soundfile", _("Audio file (or audio resource name)"))
.AddParameter("yesorno", _("Repeat the sound"), "",true).SetDefaultValue("no")
.AddParameter("expression", _("Volume (from 0 to 100, 100 by default)"), "",true).SetDefaultValue("100")
.AddParameter("expression", _("Pitch (speed) (1 by default)"), "",true).SetDefaultValue("1")
.MarkAsSimple();
extension
.AddAction("PlaySound",
_("Play a sound"),
_("Play a sound."),
_("Play the sound _PARAM1_, vol.: _PARAM3_, loop: _PARAM2_)"),
_("Audio"),
"res/actions/son24.png",
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("soundfile", _("Audio file (or audio resource name)"))
.AddParameter("yesorno", _("Repeat the sound"), "", true)
.SetDefaultValue("no")
.AddParameter(
"expression", _("Volume (from 0 to 100, 100 by default)"), "", true)
.SetDefaultValue("100")
.AddParameter("expression", _("Pitch (speed) (1 by default)"), "", true)
.SetDefaultValue("1")
.MarkAsSimple();
extension.AddAction("PlayMusic",
_("Play a music file"),
_("Play a music file."),
_("Play the music _PARAM1_, vol.: _PARAM3_, loop: _PARAM2_)"),
_("Audio"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("musicfile", _("Audio file (or audio resource name)"))
.AddParameter("yesorno", _("Repeat the sound"), "",true).SetDefaultValue("no")
.AddParameter("expression", _("Volume (from 0 to 100, 100 by default)"), "",true).SetDefaultValue("100")
.AddParameter("expression", _("Pitch (speed) (1 by default)"), "",true).SetDefaultValue("1")
.MarkAsSimple();
extension
.AddAction("PlayMusic",
_("Play a music file"),
_("Play a music file."),
_("Play the music _PARAM1_, vol.: _PARAM3_, loop: _PARAM2_)"),
_("Audio"),
"res/actions/music24.png",
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("musicfile", _("Audio file (or audio resource name)"))
.AddParameter("yesorno", _("Repeat the sound"), "", true)
.SetDefaultValue("no")
.AddParameter(
"expression", _("Volume (from 0 to 100, 100 by default)"), "", true)
.SetDefaultValue("100")
.AddParameter("expression", _("Pitch (speed) (1 by default)"), "", true)
.SetDefaultValue("1")
.MarkAsSimple();
extension.AddCondition("MusicPlaying",
_("A music file is being played"),
_("Test if the music on a channel is being played"),
_("Music on channel _PARAM1_ is being played"),
_("Audio/Music on channels"),
"res/conditions/musicplaying24.png",
"res/conditions/musicplaying.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension
.AddCondition("MusicPlaying",
_("A music file is being played"),
_("Test if the music on a channel is being played"),
_("Music on channel _PARAM1_ is being played"),
_("Audio/Music on channels"),
"res/conditions/musicplaying24.png",
"res/conditions/musicplaying.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension.AddCondition("MusicPaused",
_("A music file is paused"),
_("Test if the music on the specified channel is paused."),
_("Music on channel _PARAM1_ is paused"),
_("Audio/Music on channels"),
"res/conditions/musicpaused24.png",
"res/conditions/musicpaused.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension
.AddCondition("MusicPaused",
_("A music file is paused"),
_("Test if the music on the specified channel is paused."),
_("Music on channel _PARAM1_ is paused"),
_("Audio/Music on channels"),
"res/conditions/musicpaused24.png",
"res/conditions/musicpaused.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension.AddCondition("MusicStopped",
_("A music file is stopped"),
_("Test if the music on the specified channel is stopped."),
_("Music on channel _PARAM1_ is stopped"),
_("Audio/Music on channels"),
"res/conditions/musicstopped24.png",
"res/conditions/musicstopped.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension
.AddCondition("MusicStopped",
_("A music file is stopped"),
_("Test if the music on the specified channel is stopped."),
_("Music on channel _PARAM1_ is stopped"),
_("Audio/Music on channels"),
"res/conditions/musicstopped24.png",
"res/conditions/musicstopped.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension.AddCondition("SoundPlaying",
_("A sound is being played"),
_("Test if the sound on a channel is being played."),
_("Sound on channel _PARAM1_ is being played"),
_("Audio/Sounds on channels"),
"res/conditions/sonplaying24.png",
"res/conditions/sonplaying.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension
.AddCondition("SoundPlaying",
_("A sound is being played"),
_("Test if the sound on a channel is being played."),
_("Sound on channel _PARAM1_ is being played"),
_("Audio/Sounds on channels"),
"res/conditions/sonplaying24.png",
"res/conditions/sonplaying.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension.AddCondition("SoundPaused",
_("A sound is paused"),
_("Test if the sound on the specified channel is paused."),
_("Sound on channel _PARAM1_ is paused"),
_("Audio/Sounds on channels"),
"res/conditions/sonpaused24.png",
"res/conditions/sonpaused.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension
.AddCondition("SoundPaused",
_("A sound is paused"),
_("Test if the sound on the specified channel is paused."),
_("Sound on channel _PARAM1_ is paused"),
_("Audio/Sounds on channels"),
"res/conditions/sonpaused24.png",
"res/conditions/sonpaused.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension.AddCondition("SoundStopped",
_("A sound is stopped"),
_("Test if the sound on the specified channel is stopped."),
_("Sound on channel _PARAM1_ is stopped"),
_("Audio/Sounds on channels"),
"res/conditions/sonstopped24.png",
"res/conditions/sonstopped.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension
.AddCondition("SoundStopped",
_("A sound is stopped"),
_("Test if the sound on the specified channel is stopped."),
_("Sound on channel _PARAM1_ is stopped"),
_("Audio/Sounds on channels"),
"res/conditions/sonstopped24.png",
"res/conditions/sonstopped.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"))
.MarkAsAdvanced();
extension.AddCondition("SoundCanalVolume",
_("Volume of the sound on a channel"),
_("Test the volume of the sound on the specified channel. The volume is between 0 and 100."),
_("The volume of the sound on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Sounds on channels"),
"res/conditions/sonVolume24.png",
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Volume to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition(
"SoundCanalVolume",
_("Volume of the sound on a channel"),
_("Test the volume of the sound on the specified channel. The volume "
"is between 0 and 100."),
_("The volume of the sound on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Sounds on channels"),
"res/conditions/sonVolume24.png",
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Volume to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("MusicCanalVolume",
_("Volume of the music on a channel"),
_("Test the volume of the music on a specified channel. The volume is between 0 and 100."),
_("The volume of the music on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Music on channels"),
"res/conditions/musicVolume24.png",
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Volume to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition(
"MusicCanalVolume",
_("Volume of the music on a channel"),
_("Test the volume of the music on a specified channel. The volume "
"is between 0 and 100."),
_("The volume of the music on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Music on channels"),
"res/conditions/musicVolume24.png",
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Volume to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("GlobalVolume",
_("Global volume"),
_("Test the global sound level. The volume is between 0 and 100."),
_("The global game volume is _PARAM2_ to _PARAM1_"),
_("Audio"),
"res/conditions/volume24.png",
"res/conditions/volume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Volume to test"))
.SetManipulatedType("number");
extension
.AddCondition(
"GlobalVolume",
_("Global volume"),
_("Test the global sound level. The volume is between 0 and 100."),
_("The global game volume is _PARAM1__PARAM2_"),
_("Audio"),
"res/conditions/volume24.png",
"res/conditions/volume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Volume to test"))
.SetManipulatedType("number");
extension.AddCondition("SoundChannelPitch",
_("Pitch of the sound of a channel"),
_("Test the pitch of the sound on the specified channel. 1 is the default pitch."),
_("The pitch of the sound on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Sounds on channels"),
"res/conditions/sonVolume24.png",
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Pitch to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition(
"SoundChannelPitch",
_("Pitch of the sound of a channel"),
_("Test the pitch of the sound on the specified channel. 1 is the "
"default pitch."),
_("The pitch of the sound on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Sounds on channels"),
"res/conditions/sonVolume24.png",
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Pitch to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("MusicChannelPitch",
_("Pitch of the music on a channel"),
_("Test the pitch (speed) of the music on a specified channel. 1 is the default pitch."),
_("The pitch of the music on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Music on channels"),
"res/conditions/musicVolume24.png",
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Pitch to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition(
"MusicChannelPitch",
_("Pitch of the music on a channel"),
_("Test the pitch (speed) of the music on a specified channel. 1 is "
"the default pitch."),
_("The pitch of the music on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Music on channels"),
"res/conditions/musicVolume24.png",
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Pitch to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("SoundChannelPlayingOffset",
_("Playing offset of the sound on a channel"),
_("Test the playing offset of the sound on the specified channel."),
_("The playing offset of the sound on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Sounds on channels"),
"res/conditions/sonVolume24.png",
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Playing position (in seconds)"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition(
"SoundChannelPlayingOffset",
_("Playing offset of the sound on a channel"),
_("Test the playing offset of the sound on the specified channel."),
_("The playing offset of the sound on channel _PARAM1_ is "
"_PARAM2__PARAM3_"),
_("Audio/Sounds on channels"),
"res/conditions/sonVolume24.png",
"res/conditions/sonVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Playing position (in seconds)"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("MusicChannelPlayingOffset",
_("Playing offset of the music on a channel"),
_("Test the playing offset of the music on the specified channel."),
_("The playing offset of the music on channel _PARAM1_ is _PARAM2__PARAM3_"),
_("Audio/Music on channels"),
"res/conditions/musicVolume24.png",
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Playing position (in seconds)"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition(
"MusicChannelPlayingOffset",
_("Playing offset of the music on a channel"),
_("Test the playing offset of the music on the specified channel."),
_("The playing offset of the music on channel _PARAM1_ is "
"_PARAM2__PARAM3_"),
_("Audio/Music on channels"),
"res/conditions/musicVolume24.png",
"res/conditions/musicVolume.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Playing position (in seconds)"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddExpression("SoundChannelPlayingOffset", _("Sound playing offset"), _("Sound playing offset"), _("Sounds"), "res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension
.AddExpression("SoundChannelPlayingOffset",
_("Sound playing offset"),
_("Sound playing offset"),
_("Sounds"),
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension.AddExpression("MusicChannelPlayingOffset", _("Music playing offset"), _("Music playing offset"), _("Music"), "res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension
.AddExpression("MusicChannelPlayingOffset",
_("Music playing offset"),
_("Music playing offset"),
_("Music"),
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension.AddExpression("SoundChannelVolume", _("Sound volume"), _("Sound volume"), _("Sounds"), "res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension
.AddExpression("SoundChannelVolume",
_("Sound volume"),
_("Sound volume"),
_("Sounds"),
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension.AddExpression("MusicChannelVolume", _("Music volume"), _("Music volume"), _("Music"), "res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension
.AddExpression("MusicChannelVolume",
_("Music volume"),
_("Music volume"),
_("Music"),
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension.AddExpression("SoundChannelPitch", _("Sound's pitch"), _("Sound's pitch"), _("Sounds"), "res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension
.AddExpression("SoundChannelPitch",
_("Sound's pitch"),
_("Sound's pitch"),
_("Sounds"),
"res/actions/son.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension.AddExpression("MusicChannelPitch", _("Music's pitch"), _("Music's pitch"), _("Music"), "res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension
.AddExpression("MusicChannelPitch",
_("Music's pitch"),
_("Music's pitch"),
_("Music"),
"res/actions/music.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Channel"));
extension.AddExpression("GlobalVolume", _("Global volume"), _("Global volume value"), _("Sound level"), "res/conditions/volume.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddExpression("GlobalVolume",
_("Global volume"),
_("Global volume value"),
_("Sound level"),
"res/conditions/volume.png")
.AddCodeOnlyParameter("currentScene", "");
#endif
#endif
}
}
} // namespace gd

File diff suppressed because it is too large Load Diff

View File

@@ -1,385 +1,583 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinCamera",
_("Cameras and layers features"),
_("Built-in camera extension"),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCameraExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation("BuiltinCamera",
_("Cameras and layers features"),
_("Built-in camera extension"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddCondition("CameraX",
_("Camera center X position"),
_("Compare the X position of the center of a camera."),
_("X position of camera _PARAM4_ is _PARAM1__PARAM2_ (layer: _PARAM3_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
#if defined(GD_IDE_ONLY)
extension
.AddCondition("CameraX",
_("Camera center X position"),
_("Compare the X position of the center of a camera."),
_("X position of camera _PARAM4_ is _PARAM1__PARAM2_ "
"(layer: _PARAM3_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("CameraY",
_("Camera center Y position"),
_("Compare the Y position of the center of a camera."),
_("The Y position of camera _PARAM4_ is _PARAM1__PARAM2_ (layer: _PARAM3_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)")).SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition("CameraY",
_("Camera center Y position"),
_("Compare the Y position of the center of a camera."),
_("The Y position of camera _PARAM4_ is _PARAM1__PARAM2_ "
"(layer: _PARAM3_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"))
.SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("CameraX",
_("Camera center X position"),
_("Change the X position of the center of the specified camera."),
_("Do _PARAM1__PARAM2_ to X position of camera _PARAM4_ (layer: _PARAM3_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddAction(
"CameraX",
_("Camera center X position"),
_("Change the X position of the center of the specified camera."),
_("Do _PARAM1__PARAM2_ to X position of camera _PARAM4_ (layer: "
"_PARAM3_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("CameraY",
_("Camera center Y position"),
_("Change the Y position of the center of the specified camera."),
_("Do _PARAM1__PARAM2_ to Y position of camera _PARAM4_ (layer: _PARAM3_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddAction(
"CameraY",
_("Camera center Y position"),
_("Change the Y position of the center of the specified camera."),
_("Do _PARAM1__PARAM2_ to Y position of camera _PARAM4_ (layer: "
"_PARAM3_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("CameraWidth",
_("Width of a camera"),
_("Test the width of a camera of a layer"),
_("The width of camera _PARAM2_ of layer _PARAM1_ is _PARAM3__PARAM4_"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer")).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition("CameraWidth",
_("Width of a camera"),
_("Test the width of a camera of a layer"),
_("The width of camera _PARAM2_ of layer _PARAM1_ is "
"_PARAM3__PARAM4_"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("CameraHeight",
_("Height of a camera"),
_("Test the height of a camera of a layer"),
_("The height of camera _PARAM2_ of layer _PARAM1_ is _PARAM3__PARAM4_"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition("CameraHeight",
_("Height of a camera"),
_("Test the height of a camera of a layer"),
_("The height of camera _PARAM2_ of layer _PARAM1_ is "
"_PARAM3__PARAM4_"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddCondition("CameraAngle",
_("Angle of a camera of a layer"),
_("Test a camera angle."),
_("Angle of camera is _PARAM1__PARAM2_ (layer: _PARAM3_, camera: _PARAM4_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition("CameraAngle",
_("Angle of a camera of a layer"),
_("Test a camera angle."),
_("Angle of camera is _PARAM1__PARAM2_ (layer: _PARAM3_, "
"camera: _PARAM4_)"),
_("Layers and cameras"),
"res/conditions/camera24.png",
"res/conditions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("RotateCamera",
_("Change camera angle"),
_("This action modifies the angle of a camera in the specified layer."),
_("Do _PARAM1__PARAM2_ to angle of camera (layer: _PARAM3_, camera: _PARAM4_)"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0")
.SetManipulatedType("number");
extension
.AddAction("RotateCamera",
_("Change camera angle"),
_("This action modifies the angle of a camera in the "
"specified layer."),
_("Do _PARAM1__PARAM2_ to angle of camera (layer: _PARAM3_, "
"camera: _PARAM4_)"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.SetManipulatedType("number");
extension.AddAction("AddCamera",
_("Add a camera to a layer"),
_("This action adds a camera to a layer"),
_("Add a camera to layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.AddParameter("expression", _("Width"), "",true)
.AddParameter("expression", _("Height"), "",true)
.AddParameter("expression", _("Render zone: Top left side: X Position (between 0 and 1)"), "",true)
.AddParameter("expression", _("Render zone: Top left side: Y Position (between 0 and 1)"), "",true)
.AddParameter("expression", _("Render zone: Bottom right side: X Position (between 0 and 1)"), "",true)
.AddParameter("expression", _("Render zone: Bottom right side: Y Position (between 0 and 1)"), "",true)
.MarkAsComplex();
extension
.AddAction("AddCamera",
_("Add a camera to a layer"),
_("This action adds a camera to a layer"),
_("Add a camera to layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Width"), "", true)
.AddParameter("expression", _("Height"), "", true)
.AddParameter(
"expression",
_("Render zone: Top left side: X Position (between 0 and 1)"),
"",
true)
.AddParameter(
"expression",
_("Render zone: Top left side: Y Position (between 0 and 1)"),
"",
true)
.AddParameter(
"expression",
_("Render zone: Bottom right side: X Position (between 0 and 1)"),
"",
true)
.AddParameter(
"expression",
_("Render zone: Bottom right side: Y Position (between 0 and 1)"),
"",
true)
.MarkAsComplex();
extension.AddAction("DeleteCamera",
_("Delete a camera of a layer"),
_("Remove the specified camera from a layer"),
_("Delete camera _PARAM2_ from layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.MarkAsComplex();
extension
.AddAction("DeleteCamera",
_("Delete a camera of a layer"),
_("Remove the specified camera from a layer"),
_("Delete camera _PARAM2_ from layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.MarkAsComplex();
extension.AddAction("CameraSize",
_("Modify the size of a camera"),
_("This action modifies the size of a camera of the specified layer. The zoom will be reset."),
_("Change the size of camera _PARAM2_ of _PARAM1_ to _PARAM3_*_PARAM4_"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.AddParameter("expression", _("Width"))
.AddParameter("expression", _("Height"))
.MarkAsComplex();
extension
.AddAction("CameraSize",
_("Modify the size of a camera"),
_("This action modifies the size of a camera of the specified "
"layer. The zoom will be reset."),
_("Change the size of camera _PARAM2_ of _PARAM1_ to "
"_PARAM3_*_PARAM4_"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.AddParameter("expression", _("Width"))
.AddParameter("expression", _("Height"))
.MarkAsComplex();
extension.AddAction("CameraViewport",
_("Modify the render zone of a camera"),
_("This action modifies the render zone of a camera of the specified layer."),
_("Set the render zone of camera _PARAM2_ from layer _PARAM1_ to _PARAM3_;_PARAM4_ _PARAM5_;_PARAM6_"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.AddParameter("expression", _("Render zone: Top left side: X Position (between 0 and 1)"))
.AddParameter("expression", _("Render zone: Top left side: Y Position (between 0 and 1)"))
.AddParameter("expression", _("Render zone: Bottom right side: X Position (between 0 and 1)"))
.AddParameter("expression", _("Render zone: Bottom right side: Y Position (between 0 and 1)"))
.MarkAsComplex();
extension
.AddAction("CameraViewport",
_("Modify the render zone of a camera"),
_("This action modifies the render zone of a camera of the "
"specified layer."),
_("Set the render zone of camera _PARAM2_ from layer _PARAM1_ "
"to _PARAM3_;_PARAM4_ _PARAM5_;_PARAM6_"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number"))
.AddParameter(
"expression",
_("Render zone: Top left side: X Position (between 0 and 1)"))
.AddParameter(
"expression",
_("Render zone: Top left side: Y Position (between 0 and 1)"))
.AddParameter(
"expression",
_("Render zone: Bottom right side: X Position (between 0 and 1)"))
.AddParameter(
"expression",
_("Render zone: Bottom right side: Y Position (between 0 and 1)"))
.MarkAsComplex();
extension.AddAction("ZoomCamera",
_("Change camera zoom."),
_("Change camera zoom."),
_("Change camera zoom to _PARAM1_ (layer : _PARAM2_, camera : _PARAM3_)"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Value (1:Initial zoom, 2:Zoom x2, 0.5:Unzoom x2...)"))
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0");
extension
.AddAction("ZoomCamera",
_("Change camera zoom."),
_("Change camera zoom."),
_("Change camera zoom to _PARAM1_ (layer : _PARAM2_, camera : "
"_PARAM3_)"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression",
_("Value (1:Initial zoom, 2:Zoom x2, 0.5:Unzoom x2...)"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
extension.AddAction("FixCamera",
_("Center the camera on an object within limits"),
_("Center the camera on the specified object, without leaving the specified limits."),
_("Center the camera on _PARAM1_ (limit : from _PARAM2_;_PARAM3_ to _PARAM4_;_PARAM5_) (layer: _PARAM7_, camera: _PARAM8_)"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectPtr", _("Object"))
.AddParameter("expression", _("Top left side of the boundary: X Position"))
.AddParameter("expression", _("Top left side of the boundary: Y Position"))
.AddParameter("expression", _("Bottom right side of the boundary: X Position"))
.AddParameter("expression", _("Bottom right side of the boundary: Y Position"))
.AddParameter("yesorno", _("Anticipate the movement of the object (yes by default)"), "",true).SetDefaultValue("yes")
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0")
.MarkAsAdvanced();
extension
.AddAction(
"FixCamera",
_("Center the camera on an object within limits"),
_("Center the camera on the specified object, without leaving the "
"specified limits."),
_("Center the camera on _PARAM1_ (limit : from _PARAM2_;_PARAM3_ to "
"_PARAM4_;_PARAM5_) (layer: _PARAM7_, camera: _PARAM8_)"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectPtr", _("Object"))
.AddParameter("expression",
_("Top left side of the boundary: X Position"))
.AddParameter("expression",
_("Top left side of the boundary: Y Position"))
.AddParameter("expression",
_("Bottom right side of the boundary: X Position"))
.AddParameter("expression",
_("Bottom right side of the boundary: Y Position"))
.AddParameter("yesorno",
_("Anticipate the movement of the object (yes by default)"),
"",
true)
.SetDefaultValue("yes")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.MarkAsAdvanced();
extension.AddAction("CentreCamera",
_("Center the camera on an object"),
_("Center the camera on the specified object."),
_("Center camera on _PARAM1_ (layer: _PARAM3_, camera: _PARAM4_)"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectPtr", _("Object"))
.AddParameter("yesorno", _("Anticipate the movement of the object (yes by default)"), "",true).SetDefaultValue("yes")
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0")
.MarkAsSimple();
extension
.AddAction(
"CentreCamera",
_("Center the camera on an object"),
_("Center the camera on the specified object."),
_("Center camera on _PARAM1_ (layer: _PARAM3_, camera: _PARAM4_)"),
_("Layers and cameras"),
"res/actions/camera24.png",
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectPtr", _("Object"))
.AddParameter("yesorno",
_("Anticipate the movement of the object (yes by default)"),
"",
true)
.SetDefaultValue("yes")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.MarkAsSimple();
extension.AddAction("ShowLayer",
_("Show a layer"),
_("Show a layer."),
_("Show layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/layer24.png",
"res/actions/layer.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.MarkAsAdvanced();
extension
.AddAction("ShowLayer",
_("Show a layer"),
_("Show a layer."),
_("Show layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/layer24.png",
"res/actions/layer.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.MarkAsAdvanced();
extension.AddAction("HideLayer",
_("Hide a layer"),
_("Hide a layer."),
_("Hide layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/layer24.png",
"res/actions/layer.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.MarkAsAdvanced();
extension
.AddAction("HideLayer",
_("Hide a layer"),
_("Hide a layer."),
_("Hide layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/layer24.png",
"res/actions/layer.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.MarkAsAdvanced();
extension.AddCondition("LayerVisible",
_("Visibility of a layer"),
_("Test if a layer is set as visible."),
_("Layer _PARAM1_ is visible"),
_("Layers and cameras"),
"res/conditions/layer24.png",
"res/conditions/layer.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)")).SetDefaultValue("\"\"")
.MarkAsAdvanced();
extension
.AddCondition("LayerVisible",
_("Visibility of a layer"),
_("Test if a layer is set as visible."),
_("Layer _PARAM1_ is visible"),
_("Layers and cameras"),
"res/conditions/layer24.png",
"res/conditions/layer.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.MarkAsAdvanced();
extension.AddAction("SetLayerEffectParameter",
_("Effect parameter"),
_("Change the parameter of an effect"),
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of layer _PARAM1_"),
_("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("string", _("Parameter name"))
.AddParameter("expression", _("New value"))
.MarkAsAdvanced();
extension
.AddAction(
"SetLayerEffectParameter",
_("Effect parameter"),
_("Change the parameter of an effect"),
_("Set _PARAM3_ to _PARAM4_ for effect _PARAM2_ of layer _PARAM1_"),
_("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("string", _("Parameter name"))
.AddParameter("expression", _("New value"))
.MarkAsAdvanced();
extension.AddCondition("LayerTimeScale",
_("Layer time scale"),
_("Compare the time scale applied to the objects of the layer."),
_("The time scale of layer _PARAM1_ is _PARAM2__PARAM3_"),
_("Layers and cameras/Time"),
"res/conditions/time24.png",
"res/conditions/time.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension
.AddCondition(
"LayerTimeScale",
_("Layer time scale"),
_("Compare the time scale applied to the objects of the layer."),
_("The time scale of layer _PARAM1_ is _PARAM2__PARAM3_"),
_("Layers and cameras/Time"),
"res/conditions/time24.png",
"res/conditions/time.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
extension.AddAction("ChangeLayerTimeScale",
_("Change layer time scale"),
_("Change the time scale applied to the objects of the layer."),
_("Set time scale of layer _PARAM1_ to _PARAM2_"),
_("Layers and cameras/Time"),
"res/actions/time24.png",
"res/actions/time.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Scale (1: Default, 2: 2x faster, 0.5: 2x slower...)"));
extension
.AddAction(
"ChangeLayerTimeScale",
_("Change layer time scale"),
_("Change the time scale applied to the objects of the layer."),
_("Set time scale of layer _PARAM1_ to _PARAM2_"),
_("Layers and cameras/Time"),
"res/actions/time24.png",
"res/actions/time.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression",
_("Scale (1: Default, 2: 2x faster, 0.5: 2x slower...)"));
extension.AddExpression("CameraWidth", _("Width of a camera of a layer"), _("Width of a camera of a layer"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)")).SetDefaultValue("0");
extension
.AddExpression("CameraWidth",
_("Width of a camera of a layer"),
_("Width of a camera of a layer"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)"))
.SetDefaultValue("0");
extension.AddExpression("CameraHeight", _("Height of a camera of a layer"), _("Height of a camera of a layer"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)")).SetDefaultValue("0");
extension
.AddExpression("CameraHeight",
_("Height of a camera of a layer"),
_("Height of a camera of a layer"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)"))
.SetDefaultValue("0");
extension.AddExpression("CameraViewportLeft", _("X position of the top left side point of a render zone"), _("X position of the top left side point of a render zone"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)")).SetDefaultValue("0");
extension
.AddExpression(
"CameraViewportLeft",
_("X position of the top left side point of a render zone"),
_("X position of the top left side point of a render zone"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)"))
.SetDefaultValue("0");
extension.AddExpression("CameraViewportTop", _("Y position of the top left side point of a render zone"), _("Y position of the top left side point of a render zone"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)")).SetDefaultValue("0");
extension
.AddExpression(
"CameraViewportTop",
_("Y position of the top left side point of a render zone"),
_("Y position of the top left side point of a render zone"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)"))
.SetDefaultValue("0");
extension.AddExpression("CameraViewportRight", _("X position of the bottom right side point of a render zone"), _("X position of the bottom right side point of a render zone"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)")).SetDefaultValue("0");
extension
.AddExpression(
"CameraViewportRight",
_("X position of the bottom right side point of a render zone"),
_("X position of the bottom right side point of a render zone"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)"))
.SetDefaultValue("0");
extension.AddExpression("CameraViewportBottom", _("Y position of the bottom right side point of a render zone"), _("Y position of the bottom right side point of a render zone"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)")).SetDefaultValue("0");
extension
.AddExpression(
"CameraViewportBottom",
_("Y position of the bottom right side point of a render zone"),
_("Y position of the bottom right side point of a render zone"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"))
.AddParameter("expression", _("Camera number (default : 0)"))
.SetDefaultValue("0");
extension.AddExpression("CameraX", _("Camera X position"), _("Camera X position"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0");
extension
.AddExpression("CameraX",
_("Camera X position"),
_("Camera X position"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
extension.AddExpression("VueX", _("Camera X position"), _("Camera X position"), _("Layers and cameras"), "res/actions/camera.png")
.SetHidden()
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0");
extension
.AddExpression("VueX",
_("Camera X position"),
_("Camera X position"),
_("Layers and cameras"),
"res/actions/camera.png")
.SetHidden()
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
extension.AddExpression("CameraY", _("Camera Y position"), _("Camera Y position"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0");
extension
.AddExpression("CameraY",
_("Camera Y position"),
_("Camera Y position"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
extension.AddExpression("VueY", _("Camera Y position"), _("Camera Y position"), _("Layers and cameras"), "res/actions/camera.png")
.SetHidden()
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0");
extension
.AddExpression("VueY",
_("Camera Y position"),
_("Camera Y position"),
_("Layers and cameras"),
"res/actions/camera.png")
.SetHidden()
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
extension.AddExpression("CameraRotation", _("Angle of a camera of a layer"), _("Angle of a camera of a layer"), _("Layers and cameras"), "res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0");
extension
.AddExpression("CameraRotation",
_("Angle of a camera of a layer"),
_("Angle of a camera of a layer"),
_("Layers and cameras"),
"res/actions/camera.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
extension.AddExpression("VueRotation", _("Angle of a camera of a layer"), _("Angle of a camera of a layer"), _("Layers and cameras"), "res/actions/camera.png")
.SetHidden()
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "",true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "",true).SetDefaultValue("0");
extension
.AddExpression("VueRotation",
_("Angle of a camera of a layer"),
_("Angle of a camera of a layer"),
_("Layers and cameras"),
"res/actions/camera.png")
.SetHidden()
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0");
extension.AddExpression("LayerTimeScale", _("Time scale"), _("Time scale"), _("Layers and cameras"), "res/actions/time.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"));
#endif
extension
.AddExpression("LayerTimeScale",
_("Time scale"),
_("Time scale"),
_("Layers and cameras"),
"res/actions/time.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"));
#endif
}
}
} // namespace gd

View File

@@ -1,61 +1,69 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinCommonConversions",
_("Standard Conversions"),
_("Built-in extension providing standard conversions expressions."),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API
BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinCommonConversions",
_("Standard Conversions"),
_("Built-in extension providing standard conversions expressions."),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
#if defined(GD_IDE_ONLY)
extension.AddExpression("ToNumber",
_("Text > Number"),
_("Convert the text to a number"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("string", _("Text to convert to a number"));
extension
.AddExpression("ToNumber",
_("Text > Number"),
_("Convert the text to a number"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("string", _("Text to convert to a number"));
extension.AddStrExpression("ToString",
_("Number > Text"),
_("Convert the result of the expression to text"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("expression", _("Expression to be converted to text"));
extension
.AddStrExpression("ToString",
_("Number > Text"),
_("Convert the result of the expression to text"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("expression", _("Expression to be converted to text"));
extension.AddStrExpression("LargeNumberToString",
_("Number > Text ( without scientific notation )"),
_("Convert the result of the expression to text, without using the scientific notation"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("expression", _("Expression to be converted to text"));
extension
.AddStrExpression("LargeNumberToString",
_("Number > Text ( without scientific notation )"),
_("Convert the result of the expression to text, "
"without using the scientific notation"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("expression", _("Expression to be converted to text"));
extension.AddExpression("ToRad",
_("Degrees > Radians"),
_("Converts the angle, expressed in degrees, into radians"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("expression", _("Angle, in degrees"));
extension
.AddExpression(
"ToRad",
_("Degrees > Radians"),
_("Converts the angle, expressed in degrees, into radians"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("expression", _("Angle, in degrees"));
extension.AddExpression("ToDeg",
_("Radians > Degrees"),
_("Converts the angle, expressed in radians, into degrees"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("expression", _("Angle, in radians"));
#endif
extension
.AddExpression(
"ToDeg",
_("Radians > Degrees"),
_("Converts the angle, expressed in radians, into degrees"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("expression", _("Angle, in radians"));
#endif
}
}
} // namespace gd

View File

@@ -1,107 +1,128 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
#if defined(GD_IDE_ONLY)
#include "GDCore/Events/Event.h"
#include "GDCore/Events/Builtin/StandardEvent.h"
#include "GDCore/Events/Builtin/CommentEvent.h"
#include "GDCore/Events/Builtin/ForEachEvent.h"
#include "GDCore/Events/Builtin/WhileEvent.h"
#include "GDCore/Events/Builtin/RepeatEvent.h"
#include "GDCore/Events/Builtin/LinkEvent.h"
#include "GDCore/Events/Builtin/GroupEvent.h"
#include "GDCore/Events/Builtin/LinkEvent.h"
#include "GDCore/Events/Builtin/RepeatEvent.h"
#include "GDCore/Events/Builtin/StandardEvent.h"
#include "GDCore/Events/Builtin/WhileEvent.h"
#include "GDCore/Events/Event.h"
#endif
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinCommonInstructions",
_("Standard events"),
_("Built-in extension providing standard events."),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API
BuiltinExtensionsImplementer::ImplementsCommonInstructionsExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinCommonInstructions",
_("Standard events"),
_("Built-in extension providing standard events."),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddCondition("Or",
_("Or"),
_("Return true if one of the sub conditions is true"),
_("If one of these conditions is true:"),
_("Advanced"),
"res/conditions/or24.png",
"res/conditions/or.png")
.SetCanHaveSubInstructions()
.MarkAsAdvanced();
extension
.AddCondition("Or",
_("Or"),
_("Return true if one of the sub conditions is true"),
_("If one of these conditions is true:"),
_("Advanced"),
"res/conditions/or24.png",
"res/conditions/or.png")
.SetCanHaveSubInstructions()
.MarkAsAdvanced();
extension.AddCondition("And",
_("And"),
_("Return true if all sub conditions are true"),
_("If all of these conditions are true:"),
_("Advanced"),
"res/conditions/and24.png",
"res/conditions/and.png")
.SetCanHaveSubInstructions()
.MarkAsAdvanced();
extension
.AddCondition("And",
_("And"),
_("Return true if all sub conditions are true"),
_("If all of these conditions are true:"),
_("Advanced"),
"res/conditions/and24.png",
"res/conditions/and.png")
.SetCanHaveSubInstructions()
.MarkAsAdvanced();
extension.AddCondition("Not",
_("Not"),
_("Return the contrary of the result of the sub conditions"),
_("Invert the logical result of these conditions:"),
_("Advanced"),
"res/conditions/not24.png",
"res/conditions/not.png")
.SetCanHaveSubInstructions()
.MarkAsAdvanced();
extension
.AddCondition(
"Not",
_("Not"),
_("Return the contrary of the result of the sub conditions"),
_("Invert the logical result of these conditions:"),
_("Advanced"),
"res/conditions/not24.png",
"res/conditions/not.png")
.SetCanHaveSubInstructions()
.MarkAsAdvanced();
extension.AddCondition("Once",
_("Trigger once while true"),
_("Run actions only once, for each time the conditions have been met."),
_("Trigger once"),
_("Advanced"),
"res/conditions/once24.png",
"res/conditions/once.png");
extension.AddCondition(
"Once",
_("Trigger once while true"),
_("Run actions only once, for each time the conditions have been met."),
_("Trigger once"),
_("Advanced"),
"res/conditions/once24.png",
"res/conditions/once.png");
extension.AddEvent("Standard", _("Standard event"),
_("Standard event: Actions are run if conditions are fulfilled."),
"", "res/eventaddicon.png",
std::make_shared<gd::StandardEvent>());
extension.AddEvent(
"Standard",
_("Standard event"),
_("Standard event: Actions are run if conditions are fulfilled."),
"",
"res/eventaddicon.png",
std::make_shared<gd::StandardEvent>());
extension.AddEvent("Link", _("Link"),
_("Link to some external events"),
"", "res/lienaddicon.png",
std::make_shared<gd::LinkEvent>());
extension.AddEvent("Link",
_("Link"),
_("Link to some external events"),
"",
"res/lienaddicon.png",
std::make_shared<gd::LinkEvent>());
extension.AddEvent("Comment", _("Comment"),
_("Event displaying a text in the events editor"),
"", "res/comment.png",
std::make_shared<gd::CommentEvent>());
extension.AddEvent("Comment",
_("Comment"),
_("Event displaying a text in the events editor"),
"",
"res/comment.png",
std::make_shared<gd::CommentEvent>());
extension.AddEvent("While", _("While"),
_("The event is repeated while the conditions are true"),
"", "res/while.png",
std::make_shared<gd::WhileEvent>());
extension.AddEvent("While",
_("While"),
_("The event is repeated while the conditions are true"),
"",
"res/while.png",
std::make_shared<gd::WhileEvent>());
extension.AddEvent("Repeat", _("Repeat"),
_("Event repeated a number of times"),
"", "res/repeat.png",
std::make_shared<gd::RepeatEvent>());
extension.AddEvent("Repeat",
_("Repeat"),
_("Event repeated a number of times"),
"",
"res/repeat.png",
std::make_shared<gd::RepeatEvent>());
extension.AddEvent("ForEach", _("For each object"),
_("Repeat the event for each specified object."),
"", "res/foreach.png",
std::make_shared<gd::ForEachEvent>());
extension.AddEvent("ForEach",
_("For each object"),
_("Repeat the event for each specified object."),
"",
"res/foreach.png",
std::make_shared<gd::ForEachEvent>());
extension.AddEvent("Group", _("Group"),
_("Group containing events"),
"", "res/foreach.png",
std::make_shared<gd::GroupEvent>());
extension.AddEvent("Group",
_("Group"),
_("Group containing events"),
"",
"res/foreach.png",
std::make_shared<gd::GroupEvent>());
#endif
}
}
} // namespace gd

View File

@@ -1,37 +1,42 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsExternalLayoutsExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinExternalLayouts",
_("External layouts"),
_("Built-in extension providing actions and conditions related to external layouts"),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API
BuiltinExtensionsImplementer::ImplementsExternalLayoutsExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinExternalLayouts",
_("External layouts"),
_("Built-in extension providing actions and conditions related to "
"external layouts"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddAction("CreateObjectsFromExternalLayout",
_("Create objects from an external layout"),
_("Create objects from an external layout."),
_("Create objects from the external layout named _PARAM1_"),
_("External layouts"),
"res/conditions/fichier24.png",
"res/conditions/fichier.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Name of the external layout"))
.AddParameter("expression", _("X position of the origin"), "",true).SetDefaultValue("0")
.AddParameter("expression", _("Y position of the origin"), "",true).SetDefaultValue("0")
.MarkAsAdvanced();
#endif
#if defined(GD_IDE_ONLY)
extension
.AddAction("CreateObjectsFromExternalLayout",
_("Create objects from an external layout"),
_("Create objects from an external layout."),
_("Create objects from the external layout named _PARAM1_"),
_("External layouts"),
"res/conditions/fichier24.png",
"res/conditions/fichier.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Name of the external layout"))
.AddParameter("expression", _("X position of the origin"), "", true)
.SetDefaultValue("0")
.AddParameter("expression", _("Y position of the origin"), "", true)
.SetDefaultValue("0")
.MarkAsAdvanced();
#endif
}
}
} // namespace gd

View File

@@ -1,151 +1,190 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinFile",
_("Storage and files"),
_("Built-in extension providing functions to store data and manipulate files."),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsFileExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation("BuiltinFile",
_("Storage and files"),
_("Built-in extension providing functions "
"to store data and manipulate files."),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddCondition("GroupExists",
_("Existence of a group"),
_("Check if an element (example : PlayerState/CurrentLevel) exists in the file.\nSpaces are forbidden in element names."),
_("_PARAM1_ exists in file _PARAM0_"),
_("Storage"),
"res/conditions/fichier24.png",
"res/conditions/fichier.png")
.AddParameter("file", _("Filename"))
.AddParameter("string", _("Group"))
.MarkAsAdvanced();
#if defined(GD_IDE_ONLY)
extension
.AddCondition(
"GroupExists",
_("Existence of a group"),
_("Check if an element (example : PlayerState/CurrentLevel) exists "
"in the file.\nSpaces are forbidden in element names."),
_("_PARAM1_ exists in file _PARAM0_"),
_("Storage"),
"res/conditions/fichier24.png",
"res/conditions/fichier.png")
.AddParameter("file", _("Filename"))
.AddParameter("string", _("Group"))
.MarkAsAdvanced();
extension.AddAction("LoadFile",
_("Load a structured file in memory"),
_("This action loads the structured file in memory, so you can write and read it.\nYou can open and write without using this action, but it will be slower.\nIf you use this action, do not forget to unload the file from memory.\n\nFor the native platform, the file format is XML."),
_("Load structured file _PARAM0_ in memory"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.MarkAsAdvanced();
extension
.AddAction(
"LoadFile",
_("Load a structured file in memory"),
_("This action loads the structured file in memory, so you can write "
"and read it.\nYou can open and write without using this action, "
"but it will be slower.\nIf you use this action, do not forget to "
"unload the file from memory.\n\nFor the native platform, the file "
"format is XML."),
_("Load structured file _PARAM0_ in memory"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.MarkAsAdvanced();
extension.AddAction("UnloadFile",
_("Close a structured file"),
_("This action closes the structured file previously loaded in memory, saving all changes made."),
_("Close structured file _PARAM0_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.MarkAsAdvanced();
extension
.AddAction("UnloadFile",
_("Close a structured file"),
_("This action closes the structured file previously loaded "
"in memory, saving all changes made."),
_("Close structured file _PARAM0_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.MarkAsAdvanced();
extension.AddAction("EcrireFichierExp",
_("Write a value"),
_("Write the result of the expression in the file, in the specified element.\nSpecify the structure leading to the element using / (example : Root/Level/Current)\nSpaces are forbidden in element names."),
_("Write _PARAM2_ in _PARAM1_ of file _PARAM0_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.AddParameter("string", _("Group"))
.AddParameter("expression", _("Expression"));
extension
.AddAction("EcrireFichierExp",
_("Write a value"),
_("Write the result of the expression in the file, in the "
"specified element.\nSpecify the structure leading to the "
"element using / (example : Root/Level/Current)\nSpaces are "
"forbidden in element names."),
_("Write _PARAM2_ in _PARAM1_ of file _PARAM0_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.AddParameter("string", _("Group"))
.AddParameter("expression", _("Expression"));
extension.AddAction("EcrireFichierTxt",
_("Write a text"),
_("Write the text in the file, in the specified element.\nSpecify the structure leading to the element using / (example : Root/Level/Current)\nSpaces are forbidden in element names."),
_("Write _PARAM2_ in _PARAM1_ of file _PARAM0_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.AddParameter("string", _("Group"))
.AddParameter("string", _("Text"));
extension
.AddAction(
"EcrireFichierTxt",
_("Write a text"),
_("Write the text in the file, in the specified element.\nSpecify "
"the structure leading to the element using / (example : "
"Root/Level/Current)\nSpaces are forbidden in element names."),
_("Write _PARAM2_ in _PARAM1_ of file _PARAM0_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.AddParameter("string", _("Group"))
.AddParameter("string", _("Text"));
extension.AddAction("LireFichierExp",
_("Read a value"),
_("Read the value saved in the specified element and store it in a variable.\nSpecify the structure leading to the element using / (example : Root/Level/Current)\nSpaces are forbidden in element names."),
_("Read _PARAM1_ from file _PARAM0_ and store value in _PARAM3_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.AddParameter("string", _("Group"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("scenevar", _("Scene variables"));
extension
.AddAction(
"LireFichierExp",
_("Read a value"),
_("Read the value saved in the specified element and store it in a "
"variable.\nSpecify the structure leading to the element using / "
"(example : Root/Level/Current)\nSpaces are forbidden in element "
"names."),
_("Read _PARAM1_ from file _PARAM0_ and store value in _PARAM3_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.AddParameter("string", _("Group"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("scenevar", _("Scene variables"));
extension.AddAction("LireFichierTxt",
_("Read a text"),
_("Read the text saved in the specified element and store it in a variable.\nSpecify the structure leading to the element using / (example : Root/Level/Current)\nSpaces are forbidden in element names."),
_("Read _PARAM1_ from file _PARAM0_ and store as text in _PARAM3_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.AddParameter("string", _("Group"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("scenevar", _("Scene variables"));
extension
.AddAction(
"LireFichierTxt",
_("Read a text"),
_("Read the text saved in the specified element and store it in a "
"variable.\nSpecify the structure leading to the element using / "
"(example : Root/Level/Current)\nSpaces are forbidden in element "
"names."),
_("Read _PARAM1_ from file _PARAM0_ and store as text in _PARAM3_"),
_("Storage"),
"res/actions/fichier24.png",
"res/actions/fichier.png")
.AddParameter("file", _("File"))
.AddParameter("string", _("Group"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("scenevar", _("Scene variables"));
extension.AddAction("DeleteGroupFichier",
_("Delete an element"),
_("This action deletes the specified element from the structured file.\nSpecify the structure leading to the element using / (example : Root/Level/Current)\nSpaces are forbidden in element names."),
_("Delete _PARAM1_ from the file _PARAM0_"),
_("Storage"),
"res/actions/delete24.png",
"res/actions/delete.png")
.AddParameter("file", _("Filename"))
.AddParameter("string", _("Group"))
.MarkAsAdvanced();
extension
.AddAction("DeleteGroupFichier",
_("Delete an element"),
_("This action deletes the specified element from the "
"structured file.\nSpecify the structure leading to the "
"element using / (example : Root/Level/Current)\nSpaces are "
"forbidden in element names."),
_("Delete _PARAM1_ from the file _PARAM0_"),
_("Storage"),
"res/actions/delete24.png",
"res/actions/delete.png")
.AddParameter("file", _("Filename"))
.AddParameter("string", _("Group"))
.MarkAsAdvanced();
extension.AddAction("DeleteFichier",
_("Delete a file"),
_("Delete the file."),
_("Delete the file _PARAM0_"),
_("Files"),
"res/actions/delete24.png",
"res/actions/delete.png")
.AddParameter("file", _("Filename"));
extension
.AddAction("DeleteFichier",
_("Delete a file"),
_("Delete the file."),
_("Delete the file _PARAM0_"),
_("Files"),
"res/actions/delete24.png",
"res/actions/delete.png")
.AddParameter("file", _("Filename"));
extension.AddCondition("FileExists",
_("A file exists"),
_("Test if the file exists."),
_("File _PARAM0_ exists"),
_("Files"),
"res/conditions/fichier24.png",
"res/conditions/fichier.png")
.AddParameter("file", _("Filename"))
.MarkAsAdvanced();
extension
.AddCondition("FileExists",
_("A file exists"),
_("Test if the file exists."),
_("File _PARAM0_ exists"),
_("Files"),
"res/conditions/fichier24.png",
"res/conditions/fichier.png")
.AddParameter("file", _("Filename"))
.MarkAsAdvanced();
extension.AddAction("LaunchFile",
_("Open a URL or a file"),
_("This action launches the specified file or URL, in a browser (or in a new tab if the game is using the Web platform and is launched inside a browser)."),
_("Open URL (or file) _PARAM0_"),
_("Files"),
"res/actions/launchFile24.png",
"res/actions/launchFile.png")
.AddParameter("string", _("URL (or filename)"))
.MarkAsAdvanced();
extension
.AddAction("LaunchFile",
_("Open a URL or a file"),
_("This action launches the specified file or URL, in a "
"browser (or in a new tab if the game is using the Web "
"platform and is launched inside a browser)."),
_("Open URL (or file) _PARAM0_"),
_("Files"),
"res/actions/launchFile24.png",
"res/actions/launchFile.png")
.AddParameter("string", _("URL (or filename)"))
.MarkAsAdvanced();
extension.AddAction("ExecuteCmd",
_("Execute a command"),
_("This action executes the specified command."),
_("Execute _PARAM0_"),
_("Files"),
"res/actions/launchFile24.png",
"res/actions/launchFile.png")
.AddParameter("string", _("Command"))
.MarkAsAdvanced();
#endif
extension
.AddAction("ExecuteCmd",
_("Execute a command"),
_("This action executes the specified command."),
_("Execute _PARAM0_"),
_("Files"),
"res/actions/launchFile24.png",
"res/actions/launchFile.png")
.AddParameter("string", _("Command"))
.MarkAsAdvanced();
#endif
}
}
} // namespace gd

View File

@@ -1,72 +1,78 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsJoystickExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinJoystick",
_("Joysticks features"),
_("Built-in extension that enables the use of joysticks"),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsJoystickExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinJoystick",
_("Joysticks features"),
_("Built-in extension that enables the use of joysticks"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddCondition("JoystickButtonDown",
_("A button on a joystick is pressed"),
_("Test if a button on a joystick is pressed."),
_("The button _PARAM2_ of joystick _PARAM1_ is pressed"),
_("Joystick"),
"res/conditions/joystick24.png",
"res/conditions/joystick.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
.AddParameter("expression", _("Button"));
#if defined(GD_IDE_ONLY)
extension
.AddCondition("JoystickButtonDown",
_("A button on a joystick is pressed"),
_("Test if a button on a joystick is pressed."),
_("The button _PARAM2_ of joystick _PARAM1_ is pressed"),
_("Joystick"),
"res/conditions/joystick24.png",
"res/conditions/joystick.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
.AddParameter("expression", _("Button"));
extension.AddCondition("JoystickAxis",
_("Value of an axis of a joystick"),
_("Test the value of an axis of a joystick."),
_("The value of the axis _PARAM2_ of joystick _PARAM1_ is _PARAM3__PARAM4_"),
_("Joystick"),
"res/conditions/joystick24.png",
"res/conditions/joystick.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
.AddParameter("joyaxis", _("Axis"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.SetManipulatedType("number");
extension
.AddCondition("JoystickAxis",
_("Value of an axis of a joystick"),
_("Test the value of an axis of a joystick."),
_("The value of the axis _PARAM2_ of joystick _PARAM1_ is "
"_PARAM3__PARAM4_"),
_("Joystick"),
"res/conditions/joystick24.png",
"res/conditions/joystick.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
.AddParameter("joyaxis", _("Axis"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.SetManipulatedType("number");
extension.AddAction("GetJoystickAxis",
_("Get the value of the axis of a joystick"),
_("Save the value of the axis of the joystick (from -100 to 100)."),
_("Save in _PARAM3_ the value of axis _PARAM2_ of joystick _PARAM1_"),
_("Joystick"),
"res/actions/joystick24.png",
"res/actions/joystick.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
.AddParameter("joyaxis", _("Axis"))
.AddParameter("scenevar", _("Save the result to the scene variable"))
.SetManipulatedType("number");
extension
.AddAction(
"GetJoystickAxis",
_("Get the value of the axis of a joystick"),
_("Save the value of the axis of the joystick (from -100 to 100)."),
_("Save in _PARAM3_ the value of axis _PARAM2_ of joystick _PARAM1_"),
_("Joystick"),
"res/actions/joystick24.png",
"res/actions/joystick.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
.AddParameter("joyaxis", _("Axis"))
.AddParameter("scenevar", _("Save the result to the scene variable"))
.SetManipulatedType("number");
extension.AddExpression("GetJoystickAxis",
_("Joystick axis"),
_("Value of an axis of a joystick"),
_("Joystick"),
"res/conditions/joystick.png")
extension
.AddExpression("GetJoystickAxis",
_("Joystick axis"),
_("Value of an axis of a joystick"),
_("Joystick"),
"res/conditions/joystick.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
.AddParameter("joyaxis", _("Axis"));
#endif
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Joystick number (first joystick: 0)"))
.AddParameter("joyaxis", _("Axis"));
#endif
}
}
} // namespace gd

View File

@@ -1,82 +1,91 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinKeyboard",
_("Keyboard features"),
_("Built-in extension that enables the use of a keyboard"),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsKeyboardExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinKeyboard",
_("Keyboard features"),
_("Built-in extension that enables the use of a keyboard"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddCondition("KeyPressed",
_("Key pressed"),
_("Test if a key is pressed"),
_("_PARAM1_ key is pressed"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("key", _("Key"));
#if defined(GD_IDE_ONLY)
extension
.AddCondition("KeyPressed",
_("Key pressed"),
_("Test if a key is pressed"),
_("_PARAM1_ key is pressed"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("key", _("Key"));
extension.AddCondition("KeyReleased",
_("Key released"),
_("Test if a key was just released"),
_("_PARAM1_ key is released"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("key", _("Key"));
extension
.AddCondition("KeyReleased",
_("Key released"),
_("Test if a key was just released"),
_("_PARAM1_ key is released"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("key", _("Key"));
extension.AddCondition("KeyFromTextPressed",
_("Key pressed (text expression)"),
_("Test if a key, retrieved from the result of the expression, is pressed"),
_("_PARAM1_ key is pressed"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Expression generating the key to test"))
.MarkAsAdvanced();
extension
.AddCondition("KeyFromTextPressed",
_("Key pressed (text expression)"),
_("Test if a key, retrieved from the result of the "
"expression, is pressed"),
_("_PARAM1_ key is pressed"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Expression generating the key to test"))
.MarkAsAdvanced();
extension.AddCondition("KeyFromTextReleased",
_("Key released (text expression)"),
_("Test if a key, retrieved from the result of the expression, was just released"),
_("_PARAM1_ key is released"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Expression generating the key to test"))
.MarkAsAdvanced();
extension
.AddCondition("KeyFromTextReleased",
_("Key released (text expression)"),
_("Test if a key, retrieved from the result of the "
"expression, was just released"),
_("_PARAM1_ key is released"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Expression generating the key to test"))
.MarkAsAdvanced();
extension.AddCondition("AnyKeyPressed",
_("Any key pressed"),
_("Test if any key is pressed"),
_("Any key is pressed"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddCondition("AnyKeyPressed",
_("Any key pressed"),
_("Test if any key is pressed"),
_("Any key is pressed"),
_("Keyboard"),
"res/conditions/keyboard24.png",
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddStrExpression("LastPressedKey",
_("Last pressed key"),
_("Get the name of the latest key pressed on the keyboard"),
_("Keyboard"),
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "");
#endif
extension
.AddStrExpression(
"LastPressedKey",
_("Last pressed key"),
_("Get the name of the latest key pressed on the keyboard"),
_("Keyboard"),
"res/conditions/keyboard.png")
.AddCodeOnlyParameter("currentScene", "");
#endif
}
}
} // namespace gd

View File

@@ -1,185 +1,343 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinMathematicalTools",
_("Mathematical tools"),
_("Built-in extension providing mathematical tools"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddExpression("AngleDifference", _("Difference between two angles"), _("Difference between two angles"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("First angle"))
.AddParameter("expression", _("Second angle"));
extension.AddExpression("mod", _("Modulo"), _("x mod y"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("x (as in x mod y)"))
.AddParameter("expression", _("y (as in x mod y)"));
extension.AddExpression("min", _("Minimum of two numbers"), _("Minimum of two numbers"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("First expression"))
.AddParameter("expression", _("Second expression"));
extension.AddExpression("max", _("Maximum of two numbers"), _("Maximum of two numbers"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("First expression"))
.AddParameter("expression", _("Second expression"));
extension.AddExpression("abs", _("Absolute value"), _("Absolute value"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("acos", _("Arccosine"), _("Arccosine"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("acosh", _("Hyperbolic arccosine"), _("Hyperbolic arccosine"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("asin", _("Arcsine"), _("Arcsine"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("asinh", _("Arcsine"), _("Arcsine"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("atan", _("Arctangent"), _("Arctangent"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("atan2", _("2 argument arctangent"), _("2 argument arctangent (atan2)"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Y"))
.AddParameter("expression", _("X"));
extension.AddExpression("atanh", _("Hyperbolic arctangent"), _("Hyperbolic arctangent"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("cbrt", _("Cube root"), _("Cube root"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("ceil", _("Ceil (round up)"), _("Round number up to an integer"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("floor", _("Floor (round down)"), _("Round number down to an integer"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("cos", _("Cosine"), _("Cosine of a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("cosh", _("Hyperbolic cosine"), _("Hyperbolic cosine"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("cot", _("Cotangent"), _("Cotangent of a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("csc", _("Cosecant"), _("Cosecant of a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("int", _("Round"), _("Round a number"), _("Mathematical tools"), "res/mathfunction.png")
.SetHidden()
.AddParameter("expression", _("Expression"));
extension.AddExpression("rint", _("Round"), _("Round a number"), _("Mathematical tools"), "res/mathfunction.png")
.SetHidden()
.AddParameter("expression", _("Expression"));
extension.AddExpression("round", _("Round"), _("Round a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("exp", _("Exponential"), _("Exponential of a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("log", _("Logarithm"), _("Logarithm"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("ln", _("Logarithm"), _("Logarithm"), _("Mathematical tools"), "res/mathfunction.png")
.SetHidden()
.AddParameter("expression", _("Expression"));
extension.AddExpression("log2", _("Base-2 logarithm"), _("Base 2 Logarithm"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("log10", _("Base-10 logarithm"), _("Base-10 logarithm"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("nthroot", _("Nth root"), _("Nth root of a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Number"))
.AddParameter("expression", _("N"));
extension.AddExpression("pow", _("Power"), _("Raise a number to power n"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Number"))
.AddParameter("expression", _("The exponent (n in x^n)"));
extension.AddExpression("sec", _("Secant"), _("Secant"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("sign", _("Sign of a number"), _("Return the sign of a number (1,-1 or 0)"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("sin", _("Sine"), _("Sine of a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("sinh", _("Hyperbolic sine"), _("Hyperbolic sine"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("sqrt", _("Square root"), _("Square root of a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("tan", _("Tangent"), _("Tangent of a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("tanh", _("Hyperbolic tangent"), _("Hyperbolic tangent"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("trunc", _("Truncation"), _("Troncate a number"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension.AddExpression("lerp", _("Lerp (Linear interpolation)"), _("Linearly interpolate a to b by x"), _("Mathematical tools"), "res/mathfunction.png")
.AddParameter("expression", _("a (in a+(b-a)*x)"))
.AddParameter("expression", _("b (in a+(b-a)*x)"))
.AddParameter("expression", _("x (in a+(b-a)*x)"));
#endif
namespace gd {
void GD_CORE_API
BuiltinExtensionsImplementer::ImplementsMathematicalToolsExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinMathematicalTools",
_("Mathematical tools"),
_("Built-in extension providing mathematical tools"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension
.AddExpression("AngleDifference",
_("Difference between two angles"),
_("Difference between two angles"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("First angle"))
.AddParameter("expression", _("Second angle"));
extension
.AddExpression("mod",
_("Modulo"),
_("x mod y"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("x (as in x mod y)"))
.AddParameter("expression", _("y (as in x mod y)"));
extension
.AddExpression("min",
_("Minimum of two numbers"),
_("Minimum of two numbers"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("First expression"))
.AddParameter("expression", _("Second expression"));
extension
.AddExpression("max",
_("Maximum of two numbers"),
_("Maximum of two numbers"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("First expression"))
.AddParameter("expression", _("Second expression"));
extension
.AddExpression("abs",
_("Absolute value"),
_("Absolute value"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("acos",
_("Arccosine"),
_("Arccosine"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("acosh",
_("Hyperbolic arccosine"),
_("Hyperbolic arccosine"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("asin",
_("Arcsine"),
_("Arcsine"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("asinh",
_("Arcsine"),
_("Arcsine"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("atan",
_("Arctangent"),
_("Arctangent"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("atan2",
_("2 argument arctangent"),
_("2 argument arctangent (atan2)"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Y"))
.AddParameter("expression", _("X"));
extension
.AddExpression("atanh",
_("Hyperbolic arctangent"),
_("Hyperbolic arctangent"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("cbrt",
_("Cube root"),
_("Cube root"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("ceil",
_("Ceil (round up)"),
_("Round number up to an integer"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("floor",
_("Floor (round down)"),
_("Round number down to an integer"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("cos",
_("Cosine"),
_("Cosine of a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("cosh",
_("Hyperbolic cosine"),
_("Hyperbolic cosine"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("cot",
_("Cotangent"),
_("Cotangent of a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("csc",
_("Cosecant"),
_("Cosecant of a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("int",
_("Round"),
_("Round a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.SetHidden()
.AddParameter("expression", _("Expression"));
extension
.AddExpression("rint",
_("Round"),
_("Round a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.SetHidden()
.AddParameter("expression", _("Expression"));
extension
.AddExpression("round",
_("Round"),
_("Round a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("exp",
_("Exponential"),
_("Exponential of a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("log",
_("Logarithm"),
_("Logarithm"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("ln",
_("Logarithm"),
_("Logarithm"),
_("Mathematical tools"),
"res/mathfunction.png")
.SetHidden()
.AddParameter("expression", _("Expression"));
extension
.AddExpression("log2",
_("Base-2 logarithm"),
_("Base 2 Logarithm"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("log10",
_("Base-10 logarithm"),
_("Base-10 logarithm"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("nthroot",
_("Nth root"),
_("Nth root of a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Number"))
.AddParameter("expression", _("N"));
extension
.AddExpression("pow",
_("Power"),
_("Raise a number to power n"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Number"))
.AddParameter("expression", _("The exponent (n in x^n)"));
extension
.AddExpression("sec",
_("Secant"),
_("Secant"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("sign",
_("Sign of a number"),
_("Return the sign of a number (1,-1 or 0)"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("sin",
_("Sine"),
_("Sine of a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("sinh",
_("Hyperbolic sine"),
_("Hyperbolic sine"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("sqrt",
_("Square root"),
_("Square root of a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("tan",
_("Tangent"),
_("Tangent of a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("tanh",
_("Hyperbolic tangent"),
_("Hyperbolic tangent"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("trunc",
_("Truncation"),
_("Troncate a number"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("Expression"));
extension
.AddExpression("lerp",
_("Lerp (Linear interpolation)"),
_("Linearly interpolate a to b by x"),
_("Mathematical tools"),
"res/mathfunction.png")
.AddParameter("expression", _("a (in a+(b-a)*x)"))
.AddParameter("expression", _("b (in a+(b-a)*x)"))
.AddParameter("expression", _("x (in a+(b-a)*x)"));
#endif
}
}
} // namespace gd

View File

@@ -1,260 +1,362 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinMouse",
_("Mouse features"),
_("Built-in extension that enables the use of a mouse"),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinMouse",
_("Mouse features"),
_("Built-in extension that enables the use of a mouse"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddCondition("SourisSurObjet",
_("The cursor/touch is on an object"),
_("Test if the cursor is over an object, or if the object is being touched."),
_("The cursor/touch is on _PARAM0_"),
_("Mouse and touch"),
"res/conditions/surObjet24.png",
"res/conditions/surObjet.png")
#if defined(GD_IDE_ONLY)
extension
.AddCondition("SourisSurObjet",
_("The cursor/touch is on an object"),
_("Test if the cursor is over an object, or if the object "
"is being touched."),
_("The cursor/touch is on _PARAM0_"),
_("Mouse and touch"),
"res/conditions/surObjet24.png",
"res/conditions/surObjet.png")
.AddParameter("objectList", _("Object"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Accurate test (yes by default)"), "", true).SetDefaultValue("yes")
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsSimple();
.AddParameter("objectList", _("Object"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Accurate test (yes by default)"), "", true)
.SetDefaultValue("yes")
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsSimple();
extension.AddAction("TouchSimulateMouse",
_("De/activate moving the mouse cursor with touches"),
_("When activated, any touch made on a touchscreen will also move the mouse cursor. When deactivated, mouse and touch positions will be completely independent.\nBy default, this is activated so that you can simply use the mouse conditions to also support touchscreens. If you want to have multitouch and differentiate mouse movement and touches, just deactivate it with this action."),
_("Move mouse cursor when touching screen: _PARAM1_"),
_("Mouse and touch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
extension
.AddAction(
"TouchSimulateMouse",
_("De/activate moving the mouse cursor with touches"),
_("When activated, any touch made on a touchscreen will also move "
"the mouse cursor. When deactivated, mouse and touch positions "
"will be completely independent.\nBy default, this is activated so "
"that you can simply use the mouse conditions to also support "
"touchscreens. If you want to have multitouch and differentiate "
"mouse movement and touches, just deactivate it with this action."),
_("Move mouse cursor when touching screen: _PARAM1_"),
_("Mouse and touch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Activate (yes by default when game is launched)")).SetDefaultValue("yes")
.MarkAsAdvanced();
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno",
_("Activate (yes by default when game is launched)"))
.SetDefaultValue("yes")
.MarkAsAdvanced();
extension.AddAction("CentreSourisX",
_("Center cursor horizontally"),
_("Put the cursor in the middle of the screen horizontally."),
_("Center cursor horizontally"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
extension
.AddAction("CentreSourisX",
_("Center cursor horizontally"),
_("Put the cursor in the middle of the screen horizontally."),
_("Center cursor horizontally"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension.AddAction("CentreSourisY",
_("Center cursor vertically"),
_("Put the cursor in the middle of the screen vertically."),
_("Center cursor vertically"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
extension
.AddAction("CentreSourisY",
_("Center cursor vertically"),
_("Put the cursor in the middle of the screen vertically."),
_("Center cursor vertically"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension.AddAction("CacheSouris",
_("Hide the cursor"),
_("Hide the cursor."),
_("Hide the cursor"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension
.AddAction("CacheSouris",
_("Hide the cursor"),
_("Hide the cursor."),
_("Hide the cursor"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension.AddAction("MontreSouris",
_("Show the cursor"),
_("Show the cursor."),
_("Show the cursor"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
extension
.AddAction("MontreSouris",
_("Show the cursor"),
_("Show the cursor."),
_("Show the cursor"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension.AddAction("SetSourisXY",
_("Position the cursor of the mouse"),
_("Position the cursor at the given coordinates."),
_("Position cursor at _PARAM1_;_PARAM2_"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
extension
.AddAction("SetSourisXY",
_("Position the cursor of the mouse"),
_("Position the cursor at the given coordinates."),
_("Position cursor at _PARAM1_;_PARAM2_"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.MarkAsAdvanced();
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.MarkAsAdvanced();
extension.AddAction("CentreSouris",
_("Center the cursor"),
_("Center the cursor on the screen."),
_("Center the cursor"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
extension
.AddAction("CentreSouris",
_("Center the cursor"),
_("Center the cursor on the screen."),
_("Center the cursor"),
_("Mouse and touch"),
"res/actions/mouse24.png",
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension.AddCondition("SourisX",
_("Cursor X position"),
_("Compare the X position of the cursor or of a touch."),
_("Cursor X position is _PARAM1__PARAM2_"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("X position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true).SetDefaultValue("0")
.SetManipulatedType("number");
extension
.AddCondition("SourisX",
_("Cursor X position"),
_("Compare the X position of the cursor or of a touch."),
_("Cursor X position is _PARAM1__PARAM2_"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("X position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.SetManipulatedType("number");
extension.AddCondition("SourisY",
_("Cursor Y position"),
_("Compare the Y position of the cursor or of a touch."),
_("Cursor Y position is _PARAM1__PARAM2_"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Y position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true).SetDefaultValue("0")
.SetManipulatedType("number");
extension
.AddCondition("SourisY",
_("Cursor Y position"),
_("Compare the Y position of the cursor or of a touch."),
_("Cursor Y position is _PARAM1__PARAM2_"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Y position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.SetManipulatedType("number");
extension.AddCondition("SourisBouton",
_("Mouse button pressed or touch held"),
_("Return true if the specified mouse button is pressed or if a touch is in contact with the screen."),
_("Touch or _PARAM1_ mouse button is down"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("mouse", _("Button to test"))
.MarkAsSimple();
extension
.AddCondition("SourisBouton",
_("Mouse button pressed or touch held"),
_("Return true if the specified mouse button is pressed or "
"if a touch is in contact with the screen."),
_("Touch or _PARAM1_ mouse button is down"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("mouse", _("Button to test"))
.MarkAsSimple();
extension.AddCondition("MouseButtonReleased",
_("Mouse button released"),
_("Return true if the specified mouse button was released."),
_("_PARAM1_ mouse button was released"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("mouse", _("Button to test"))
.MarkAsSimple();
extension
.AddCondition(
"MouseButtonReleased",
_("Mouse button released"),
_("Return true if the specified mouse button was released."),
_("_PARAM1_ mouse button was released"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("mouse", _("Button to test"))
.MarkAsSimple();
extension.AddCondition("TouchX",
_("Touch X position"),
_("Compare the X position of a specific touch."),
_("Touch #_PARAM1_ X position is _PARAM2__PARAM3_"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("X position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true).SetDefaultValue("0")
.SetManipulatedType("number");
extension
.AddCondition("TouchX",
_("Touch X position"),
_("Compare the X position of a specific touch."),
_("Touch #_PARAM1_ X position is _PARAM2__PARAM3_"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("X position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.SetManipulatedType("number");
extension.AddCondition("TouchY",
_("Touch Y position"),
_("Compare the Y position of a specific touch."),
_("Touch #_PARAM1_ Y position is _PARAM2__PARAM3_"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("X position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true).SetDefaultValue("0")
.SetManipulatedType("number");
extension
.AddCondition("TouchY",
_("Touch Y position"),
_("Compare the Y position of a specific touch."),
_("Touch #_PARAM1_ Y position is _PARAM2__PARAM3_"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("X position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number (default : 0)"), "", true)
.SetDefaultValue("0")
.SetManipulatedType("number");
extension.AddCondition("PopStartedTouch",
_("A new touch has started"),
_("Return true if a touch has started. The touch identifier can be accessed using LastTouchId().\nAs more than one touch can be started, this condition is only true once for each touch: the next time you use it, it will be for a new touch, or it will return false if no more touches have just started."),
_("A new touch has started"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddCondition(
"PopStartedTouch",
_("A new touch has started"),
_("Return true if a touch has started. The touch identifier can be "
"accessed using LastTouchId().\nAs more than one touch can be "
"started, this condition is only true once for each touch: the "
"next time you use it, it will be for a new touch, or it will "
"return false if no more touches have just started."),
_("A new touch has started"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddCondition("PopEndedTouch",
_("A touch has ended"),
_("Return true if a touch has ended. The touch identifier can be accessed using LastEndedTouchId().\nAs more than one touch can be ended, this condition is only true once for each touch: the next time you use it, it will be for a new touch, or it will return false if no more touches have just ended."),
_("A touch has ended"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddCondition(
"PopEndedTouch",
_("A touch has ended"),
_("Return true if a touch has ended. The touch identifier can be "
"accessed using LastEndedTouchId().\nAs more than one touch can be "
"ended, this condition is only true once for each touch: the next "
"time you use it, it will be for a new touch, or it will return "
"false if no more touches have just ended."),
_("A touch has ended"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddExpression("MouseX", _("Cursor X position"), _("Cursor X position"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0");
extension
.AddExpression("MouseX",
_("Cursor X position"),
_("Cursor X position"),
_("Mouse cursor"),
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true)
.SetDefaultValue("0");
extension.AddExpression("SourisX", _("Cursor X position"), _("Cursor X position"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0")
.SetHidden();
extension
.AddExpression("SourisX",
_("Cursor X position"),
_("Cursor X position"),
_("Mouse cursor"),
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true)
.SetDefaultValue("0")
.SetHidden();
extension.AddExpression("MouseY", _("Cursor Y position"), _("Cursor Y position"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0");
extension
.AddExpression("MouseY",
_("Cursor Y position"),
_("Cursor Y position"),
_("Mouse cursor"),
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true)
.SetDefaultValue("0");
extension
.AddExpression("SourisY",
_("Cursor Y position"),
_("Cursor Y position"),
_("Mouse cursor"),
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true)
.SetDefaultValue("0")
.SetHidden();
extension.AddExpression("SourisY", _("Cursor Y position"), _("Cursor Y position"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0")
.SetHidden();
extension
.AddExpression("MouseWheelDelta",
_("Mouse wheel: Displacement"),
_("Mouse wheel displacement"),
_("Mouse cursor"),
"res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddExpression("MouseWheelDelta", _("Mouse wheel: Displacement"), _("Mouse wheel displacement"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddExpression("TouchX",
_("Touch X position"),
_("Touch X position"),
_("Multitouch"),
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true)
.SetDefaultValue("0");
extension.AddExpression("TouchX", _("Touch X position"), _("Touch X position"), _("Multitouch"), "res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0");
extension
.AddExpression("TouchY",
_("Touch Y position"),
_("Touch Y position"),
_("Multitouch"),
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("layer", _("Layer"), "", true)
.SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true)
.SetDefaultValue("0");
extension.AddExpression("TouchY", _("Touch Y position"), _("Touch Y position"), _("Multitouch"), "res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0");
extension
.AddExpression("LastTouchId",
_("Identifier of the last touch"),
_("Identifier of the last touch"),
_("Multitouch"),
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddExpression("LastTouchId", _("Identifier of the last touch"), _("Identifier of the last touch"), _("Multitouch"), "res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddExpression("LastEndedTouchId",
_("Identifier of the last ended touch"),
_("Identifier of the last ended touch"),
_("Multitouch"),
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddExpression("LastEndedTouchId", _("Identifier of the last ended touch"), _("Identifier of the last ended touch"), _("Multitouch"), "res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
#endif
#endif
}
}
} // namespace gd

View File

@@ -1,123 +1,159 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinNetwork",
_("Basic internet features"),
_("Built-in extension providing network features."),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsNetworkExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinNetwork",
_("Basic internet features"),
_("Built-in extension providing network features."),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddAction("EnvoiDataNet",
_("Send data to a website"),
_("Send data to a specified web site.\nYou need to set up a .php page on your web site to receive this data.\nEnter a password here, and enter the same password in the configuration of your .php page.\nRead the help file to get more information."),
_("Send to _PARAM0_ the following data : _PARAM2_, _PARAM3_,_PARAM4_,_PARAM5_,_PARAM6_,_PARAM7_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _(".php page URL (don't forget the protocol http://)"))
.AddParameter("password", _("Password"))
.AddParameter("string", _("Data 1"))
.AddParameter("string", _("Data 2"), "", true)
.AddParameter("string", _("Data 3"), "", true)
.AddParameter("string", _("Data 4"), "", true)
.AddParameter("string", _("Data 5"), "", true)
.AddParameter("string", _("Data 6"), "", true)
.SetHidden();
#if defined(GD_IDE_ONLY)
extension
.AddAction(
"EnvoiDataNet",
_("Send data to a website"),
_("Send data to a specified web site.\nYou need to set up a .php "
"page on your web site to receive this data.\nEnter a password "
"here, and enter the same password in the configuration of your "
".php page.\nRead the help file to get more information."),
_("Send to _PARAM0_ the following data : _PARAM2_, "
"_PARAM3_,_PARAM4_,_PARAM5_,_PARAM6_,_PARAM7_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string",
_(".php page URL (don't forget the protocol http://)"))
.AddParameter("password", _("Password"))
.AddParameter("string", _("Data 1"))
.AddParameter("string", _("Data 2"), "", true)
.AddParameter("string", _("Data 3"), "", true)
.AddParameter("string", _("Data 4"), "", true)
.AddParameter("string", _("Data 5"), "", true)
.AddParameter("string", _("Data 6"), "", true)
.SetHidden();
extension.AddAction("SendRequest",
_("Send a request to a web page"),
_("Send a request to the specified web page.\n\nPlease note that for the web platform games, the game must be hosted on the same host as specified below, except if the server is configured to answer to all requests (cross-domain requests)."),
_("Send _PARAM3_ request to _PARAM0__PARAM1_ with body: _PARAM2_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("Host (example: http://www.some-server.org/)"))
.AddParameter("string", _("Path to page (Example: /page.php)"))
.AddParameter("string", _("Request body content"))
.AddParameter("string", _("Method: \"POST\" or \"GET\" (if empty, GET will be used)"), "", true ).SetDefaultValue("\"GET\"")
.AddParameter("string", _("Content type (application/x-www-form-urlencoded by default)"), "", true )
.AddParameter("scenevar", _("Store the response in this variable"), "", true )
.MarkAsComplex();
extension
.AddAction(
"SendRequest",
_("Send a request to a web page"),
_("Send a request to the specified web page.\n\nPlease note that for "
"the web platform games, the game must be hosted on the same host "
"as specified below, except if the server is configured to answer "
"to all requests (cross-domain requests)."),
_("Send _PARAM3_ request to _PARAM0__PARAM1_ with body: _PARAM2_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("Host (example: http://www.some-server.org/)"))
.AddParameter("string", _("Path to page (Example: /page.php)"))
.AddParameter("string", _("Request body content"))
.AddParameter(
"string",
_("Method: \"POST\" or \"GET\" (if empty, GET will be used)"),
"",
true)
.SetDefaultValue("\"GET\"")
.AddParameter(
"string",
_("Content type (application/x-www-form-urlencoded by default)"),
"",
true)
.AddParameter(
"scenevar", _("Store the response in this variable"), "", true)
.MarkAsComplex();
extension.AddAction("DownloadFile",
_("Download a file"),
_("Download a file from a web site"),
_("Download file _PARAM1_ from _PARAM0_ under the name of _PARAM2_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("Host (for example : http://www.website.com)"))
.AddParameter("string", _("Path to file (for example : /folder/file.txt)"))
.AddParameter("string", _("Save as"));
extension
.AddAction(
"DownloadFile",
_("Download a file"),
_("Download a file from a web site"),
_("Download file _PARAM1_ from _PARAM0_ under the name of _PARAM2_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("Host (for example : http://www.website.com)"))
.AddParameter("string",
_("Path to file (for example : /folder/file.txt)"))
.AddParameter("string", _("Save as"));
extension.AddAction("JSONToVariableStructure",
_("Convert JSON to a variable"),
_("Parse a JSON object and store it into a variable"),
_("Parse JSON string _PARAM0_ and store it into variable _PARAM1_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("JSON string"))
.AddParameter("scenevar", _("Variable where store the JSON object"))
.MarkAsAdvanced();
extension
.AddAction(
"JSONToVariableStructure",
_("Convert JSON to a variable"),
_("Parse a JSON object and store it into a variable"),
_("Parse JSON string _PARAM0_ and store it into variable _PARAM1_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("JSON string"))
.AddParameter("scenevar", _("Variable where store the JSON object"))
.MarkAsAdvanced();
extension.AddAction("JSONToGlobalVariableStructure",
_("Convert JSON to global variable"),
_("Parse a JSON object and store it into a global variable"),
_("Parse JSON string _PARAM0_ and store it into global variable _PARAM1_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("JSON string"))
.AddParameter("globalvar", _("Global variable where store the JSON object"))
.MarkAsAdvanced();
extension
.AddAction("JSONToGlobalVariableStructure",
_("Convert JSON to global variable"),
_("Parse a JSON object and store it into a global variable"),
_("Parse JSON string _PARAM0_ and store it into global "
"variable _PARAM1_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("JSON string"))
.AddParameter("globalvar",
_("Global variable where store the JSON object"))
.MarkAsAdvanced();
extension.AddAction("JSONToObjectVariableStructure",
_("Convert JSON to object variable"),
_("Parse a JSON object and store it into an object variable"),
_("Parse JSON string _PARAM0_ and store it into variable _PARAM2_ of _PARAM1_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("JSON string"))
.AddParameter("objectPtr", _("Object"))
.AddParameter("objectvar", _("Object variable where store the JSON object"))
.MarkAsAdvanced();
extension
.AddAction("JSONToObjectVariableStructure",
_("Convert JSON to object variable"),
_("Parse a JSON object and store it into an object variable"),
_("Parse JSON string _PARAM0_ and store it into variable "
"_PARAM2_ of _PARAM1_"),
_("Network"),
"res/actions/net24.png",
"res/actions/net.png")
.AddParameter("string", _("JSON string"))
.AddParameter("objectPtr", _("Object"))
.AddParameter("objectvar",
_("Object variable where store the JSON object"))
.MarkAsAdvanced();
extension.AddStrExpression("ToJSON",
_("Convert variable to JSON"),
_("Convert a variable to JSON"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("scenevar", _("The variable to be stringified"));
extension
.AddStrExpression("ToJSON",
_("Convert variable to JSON"),
_("Convert a variable to JSON"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("scenevar", _("The variable to be stringified"));
extension.AddStrExpression("GlobalVarToJSON",
_("Convert global variable to JSON"),
_("Convert a global variable to JSON"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("globalvar", _("The global variable to be stringified"));
extension
.AddStrExpression("GlobalVarToJSON",
_("Convert global variable to JSON"),
_("Convert a global variable to JSON"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("globalvar", _("The global variable to be stringified"));
extension.AddStrExpression("ObjectVarToJSON",
_("Convert object variable to JSON"),
_("Convert an object variable to JSON"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("objectPtr", _("The object with the variable"))
.AddParameter("objectvar", _("The object variable to be stringified"));
#endif
extension
.AddStrExpression("ObjectVarToJSON",
_("Convert object variable to JSON"),
_("Convert an object variable to JSON"),
_("Conversion"),
"res/conditions/toujours24.png")
.AddParameter("objectPtr", _("The object with the variable"))
.AddParameter("objectvar", _("The object variable to be stringified"));
#endif
}
}
} // namespace gd

View File

@@ -1,118 +1,142 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("BuiltinScene",
_("Scene management features"),
_("This Built-in extension allows you to manipulate scenes"),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSceneExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"BuiltinScene",
_("Scene management features"),
_("This Built-in extension allows you to manipulate scenes"),
"Florian Rival",
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
#if defined(GD_IDE_ONLY)
extension.AddExpression("Random", _("Random value"), _("Random value"), _("Random"), "res/actions/position.png")
.AddParameter("expression", _("Maximum value"));
extension
.AddExpression("Random",
_("Random value"),
_("Random value"),
_("Random"),
"res/actions/position.png")
.AddParameter("expression", _("Maximum value"));
extension.AddStrExpression("CurrentSceneName", _("Current scene name"), _("Name of the current scene"), _("Scene"), "res/actions/texte.png")
.AddCodeOnlyParameter("currentScene", "");
extension
.AddStrExpression("CurrentSceneName",
_("Current scene name"),
_("Name of the current scene"),
_("Scene"),
"res/actions/texte.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddCondition("DepartScene",
_("At the beginning of the scene"),
_("Is true only when scene just begins."),
_("At the beginning of the scene"),
_("Scene"),
"res/conditions/depart24.png",
"res/conditions/depart.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsSimple();
extension
.AddCondition("DepartScene",
_("At the beginning of the scene"),
_("Is true only when scene just begins."),
_("At the beginning of the scene"),
_("Scene"),
"res/conditions/depart24.png",
"res/conditions/depart.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsSimple();
extension.AddAction("Scene",
_("Change the scene"),
_("Stop this scene and start the specified one instead."),
_("Change for scene _PARAM1_"),
_("Scene"),
"res/actions/replaceScene24.png",
"res/actions/replaceScene.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Name of the new scene"))
.AddParameter("yesorno", _("Stop any other paused scenes?")).SetDefaultValue("true")
.MarkAsAdvanced();
extension
.AddAction("Scene",
_("Change the scene"),
_("Stop this scene and start the specified one instead."),
_("Change for scene _PARAM1_"),
_("Scene"),
"res/actions/replaceScene24.png",
"res/actions/replaceScene.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Name of the new scene"))
.AddParameter("yesorno", _("Stop any other paused scenes?"))
.SetDefaultValue("true")
.MarkAsAdvanced();
extension.AddAction("PushScene",
_("Pause and start a new scene"),
_("Pause this scene and start the specified one.\nLater, you can use the \"Stop and go back to previous scene\" action to go back to this scene."),
_("Pause the scene and start _PARAM1_"),
_("Scene"),
"res/actions/pushScene24.png",
"res/actions/pushScene.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Name of the new scene"))
.MarkAsAdvanced();
extension
.AddAction("PushScene",
_("Pause and start a new scene"),
_("Pause this scene and start the specified one.\nLater, you "
"can use the \"Stop and go back to previous scene\" action "
"to go back to this scene."),
_("Pause the scene and start _PARAM1_"),
_("Scene"),
"res/actions/pushScene24.png",
"res/actions/pushScene.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Name of the new scene"))
.MarkAsAdvanced();
extension.AddAction("PopScene",
_("Stop and go back to previous scene"),
_("Stop this scene and go back to the previous paused one.\nTo pause a scene, use the \"Pause and start a new scene\" action."),
_("Stop the scene and go back to the previous paused one"),
_("Scene"),
"res/actions/popScene24.png",
"res/actions/popScene.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension
.AddAction(
"PopScene",
_("Stop and go back to previous scene"),
_("Stop this scene and go back to the previous paused one.\nTo pause "
"a scene, use the \"Pause and start a new scene\" action."),
_("Stop the scene and go back to the previous paused one"),
_("Scene"),
"res/actions/popScene24.png",
"res/actions/popScene.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension.AddAction("Quit",
_("Quit the game"),
_("Quit the game"),
_("Quit the game"),
_("Scene"),
"res/actions/quit24.png",
"res/actions/quit.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension
.AddAction("Quit",
_("Quit the game"),
_("Quit the game"),
_("Quit the game"),
_("Scene"),
"res/actions/quit24.png",
"res/actions/quit.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension.AddAction("SceneBackground",
_("Change background color"),
_("Change the background color of the scene."),
_("Set background color to _PARAM1_"),
_("Scene"),
"res/actions/background24.png",
"res/actions/background.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("color", _("Color"))
.MarkAsAdvanced();
extension
.AddAction("SceneBackground",
_("Change background color"),
_("Change the background color of the scene."),
_("Set background color to _PARAM1_"),
_("Scene"),
"res/actions/background24.png",
"res/actions/background.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("color", _("Color"))
.MarkAsAdvanced();
extension.AddAction("DisableInputWhenFocusIsLost",
_("Disable input when focus is lost"),
_("Decide if the keyboard and mouse buttons must be taken into account even\nif the window is not active."),
_("Disable input when focus is lost: _PARAM1_"),
_("Scene"),
"res/actions/window24.png",
"res/actions/window.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Deactivate input when focus is lost"))
.MarkAsAdvanced();
extension
.AddAction("DisableInputWhenFocusIsLost",
_("Disable input when focus is lost"),
_("Decide if the keyboard and mouse buttons must be taken "
"into account even\nif the window is not active."),
_("Disable input when focus is lost: _PARAM1_"),
_("Scene"),
"res/actions/window24.png",
"res/actions/window.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Deactivate input when focus is lost"))
.MarkAsAdvanced();
extension.AddCondition("Egal",
_("Compare two expressions"),
_("Test the two expressions"),
_("_PARAM0_ _PARAM1_ _PARAM2_"),
_("Other"),
"res/conditions/egal24.png",
"res/conditions/egal.png")
.AddParameter("expression", _("Expression 1"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Expression 2"))
.MarkAsAdvanced();
#endif
extension
.AddCondition("Egal",
_("Compare two expressions"),
_("Test the two expressions"),
_("_PARAM0_ _PARAM1_ _PARAM2_"),
_("Other"),
"res/conditions/egal24.png",
"res/conditions/egal.png")
.AddParameter("expression", _("Expression 1"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Expression 2"))
.MarkAsAdvanced();
#endif
}
}
} // namespace gd

View File

@@ -1,74 +1,56 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GDCore/Extensions/Builtin/SpriteExtension/Animation.h"
#include <vector>
#include "GDCore/Extensions/Builtin/SpriteExtension/Direction.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Sprite.h"
#include "GDCore/String.h"
#include <vector>
namespace gd {
Direction Animation::badDirection;
Animation::Animation() :
useMultipleDirections(false)
{
Animation::Animation() : useMultipleDirections(false) {}
Animation::~Animation() {}
std::size_t Animation::GetDirectionsCount() const { return directions.size(); };
bool Animation::HasNoDirections() const { return directions.empty(); };
void Animation::SetDirectionsCount(std::size_t nb) {
while (directions.size() < nb) {
Direction direction;
directions.push_back(direction);
}
while (directions.size() > nb)
directions.erase(directions.begin() + directions.size() - 1);
}
Animation::~Animation()
{
const Direction& Animation::GetDirection(std::size_t nb) const {
if (!useMultipleDirections) nb = 0;
if (nb < directions.size()) return directions[nb];
return badDirection;
}
std::size_t Animation::GetDirectionsCount() const
{
return directions.size();
};
Direction& Animation::GetDirection(std::size_t nb) {
if (!useMultipleDirections) nb = 0;
bool Animation::HasNoDirections() const
{
return directions.empty();
};
if (nb < directions.size()) return directions[nb];
void Animation::SetDirectionsCount(std::size_t nb)
{
while ( directions.size() < nb ) {
Direction direction;
directions.push_back(direction);
}
while ( directions.size() > nb )
directions.erase(directions.begin()+directions.size()-1);
return badDirection;
}
const Direction & Animation::GetDirection(std::size_t nb) const
{
if (!useMultipleDirections) nb = 0;
void Animation::SetDirection(const Direction& direction, std::size_t nb) {
if (nb < directions.size()) directions[nb] = direction;
if ( nb < directions.size() )
return directions[nb];
return badDirection;
return;
}
Direction & Animation::GetDirection(std::size_t nb)
{
if (!useMultipleDirections) nb = 0;
if (nb < directions.size() )
return directions[nb];
return badDirection;
}
void Animation::SetDirection(const Direction & direction, std::size_t nb)
{
if (nb < directions.size() ) directions[nb] = direction;
return;
}
}
} // namespace gd

View File

@@ -1,17 +1,18 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_ANIMATION_H
#define GDCORE_ANIMATION_H
#include <vector>
#include "GDCore/String.h"
namespace gd { class Direction; }
namespace gd {
class Direction;
}
namespace gd
{
namespace gd {
/**
* \brief Class representing an animation of a SpriteObject.
@@ -20,76 +21,76 @@ namespace gd
* \see Direction
* \ingroup SpriteObjectExtension
*/
class GD_CORE_API Animation
{
public:
Animation();
virtual ~Animation();
class GD_CORE_API Animation {
public:
Animation();
virtual ~Animation();
/**
* \brief Set the name of the animation
*/
const gd::String & GetName() const { return name; }
/**
* \brief Set the name of the animation
*/
const gd::String& GetName() const { return name; }
/**
* \brief Change the name of the animation
*/
void SetName(const gd::String & name_) { name = name_; }
/**
* \brief Change the name of the animation
*/
void SetName(const gd::String& name_) { name = name_; }
/**
* \brief Return the n-th direction
*/
const Direction & GetDirection(std::size_t n) const;
/**
* \brief Return the n-th direction
*/
const Direction& GetDirection(std::size_t n) const;
/**
* \brief Return the n-th direction
*/
Direction & GetDirection(std::size_t n);
/**
* \brief Return the n-th direction
*/
Direction& GetDirection(std::size_t n);
/**
* \brief Change a direction
*/
void SetDirection(const Direction & direction, std::size_t nb);
/**
* \brief Change a direction
*/
void SetDirection(const Direction& direction, std::size_t nb);
/**
* \brief Change direction count
*/
void SetDirectionsCount(std::size_t nb);
/**
* \brief Change direction count
*/
void SetDirectionsCount(std::size_t nb);
/**
* \brief Get direction count
*/
std::size_t GetDirectionsCount() const;
/**
* \brief Get direction count
*/
std::size_t GetDirectionsCount() const;
/**
* \brief Return true if there isn't any direction in the animation
*/
bool HasNoDirections() const;
/**
* \brief Return true if there isn't any direction in the animation
*/
bool HasNoDirections() const;
/**
* \brief Return true if the animation is composed of more than one direction.
*
* By default, an animation is composed of a single direction, and the sprite
* is rotated.
*/
bool UseMultipleDirections() const { return useMultipleDirections; }
/**
* \brief Return true if the animation is composed of more than one direction.
*
* By default, an animation is composed of a single direction, and the sprite
* is rotated.
*/
bool UseMultipleDirections() const { return useMultipleDirections; }
/**
* \brief Set if the animation is using more than one direction.
*
* By default, an animation is composed of a single direction, and the sprite
* is rotated.
*/
void SetUseMultipleDirections(bool enable) { useMultipleDirections = enable; }
/**
* \brief Set if the animation is using more than one direction.
*
* By default, an animation is composed of a single direction, and the sprite
* is rotated.
*/
void SetUseMultipleDirections(bool enable) { useMultipleDirections = enable; }
bool useMultipleDirections; ///< deprecated This should be moved to class private members
bool useMultipleDirections; ///< deprecated This should be moved to class
///< private members
private:
std::vector < Direction > directions;
gd::String name;
private:
std::vector<Direction> directions;
gd::String name;
static Direction badDirection;
static Direction badDirection;
};
}
#endif // GDCORE_ANIMATION_H
} // namespace gd
#endif // GDCORE_ANIMATION_H

View File

@@ -1,32 +1,38 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#ifndef SPRITEOBJECTEDITOR_H
#define SPRITEOBJECTEDITOR_H
//(*Headers(SpriteObjectEditor)
#include <wx/listctrl.h>
#include <wx/treectrl.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/menu.h>
#include <wx/treelist.h>
#include <wx/aui/aui.h>
#include <wx/dialog.h>
#include <wx/listctrl.h>
#include <wx/menu.h>
#include <wx/panel.h>
#include <wx/scrolbar.h>
#include <wx/dialog.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/timer.h>
#include <wx/treectrl.h>
#include <wx/treelist.h>
//*)
#include <wx/dnd.h>
#include <vector>
namespace gd { class MainFrameWrapper; }
namespace gd {
class MainFrameWrapper;
}
class ResourcesEditor;
class SpriteObject;
namespace gd { class Resource; }
namespace gd { class Project; }
namespace gd {
class Resource;
}
namespace gd {
class Project;
}
class Sprite;
#include "GDCore/IDE/Dialogs/PolygonEditionHelper.h"
@@ -39,281 +45,284 @@ namespace gd {
* \ingroup IDEDialogs
* \ingroup BuiltinExtensions
*/
class SpriteObjectEditor: public wxDialog
{
public:
class SpriteObjectEditor : public wxDialog {
public:
SpriteObjectEditor(wxWindow* parent,
gd::Project& game,
SpriteObject& object,
gd::MainFrameWrapper& mainFrameWrapper_);
virtual ~SpriteObjectEditor();
SpriteObjectEditor(wxWindow* parent, gd::Project & game, SpriteObject & object, gd::MainFrameWrapper & mainFrameWrapper_ );
virtual ~SpriteObjectEditor();
/**
* \brief Can be called to add an image to the current animation.
*
* Used by DndTextSpriteObjectEditor so as to add a dragged image.
* \param image The name of the image resource to add.
* \param refresh Optional parameter: When set to false, the lists of images
* won't be refreshed.
*/
void AddImageToCurrentAnimation(wxString image, bool refresh = true);
/**
* \brief Can be called to add an image to the current animation.
*
* Used by DndTextSpriteObjectEditor so as to add a dragged image.
* \param image The name of the image resource to add.
* \param refresh Optional parameter: When set to false, the lists of images won't be refreshed.
*/
void AddImageToCurrentAnimation(wxString image, bool refresh = true);
//(*Declarations(SpriteObjectEditor)
wxAuiManager* AuiManager1;
wxMenu* MenuItem2;
wxTreeCtrl* animationsTree;
wxTreeListCtrl* maskTree;
wxMenuItem* MenuItem8;
wxListCtrl* pointsList;
wxPanel* toolbarPanel;
wxAuiToolBar* toolbar;
wxMenuItem* MenuItem7;
wxAuiToolBar* pointToolbar;
wxAuiManager* mgr;
wxAuiManager* AuiManager4;
wxStaticText* statusTxt;
wxMenuItem* MenuItem5;
wxPanel* centerPanel;
wxMenuItem* deleteItem;
wxMenuItem* MenuItem1;
wxMenuItem* MenuItem4;
wxMenuItem* MenuItem14;
wxMenuItem* MenuItem11;
wxMenuItem* MenuItem15;
wxPanel* Panel1;
wxMenu animationsMenu;
wxMenuItem* MenuItem17;
wxMenu* MenuItem13;
wxMenuItem* MenuItem10;
wxAuiManager* AuiManager2;
wxMenuItem* removeImageItem;
wxPanel* Panel3;
wxAuiToolBar* maskToolbar;
wxPanel* animationsPanel;
wxMenuItem* MenuItem12;
wxScrollBar* xScrollBar;
wxTimer previewTimer;
wxMenuItem* MenuItem3;
wxAuiManager* AuiManager3;
wxMenuItem* MenuItem20;
wxPanel* imagePanel;
wxScrollBar* yScrollBar;
wxMenu emptyImagesMenu;
wxMenuItem* moveLeftItem;
wxMenuItem* MenuItem6;
wxPanel* previewPanel;
wxPanel* maskPanel;
wxMenuItem* moveRightItem;
wxPanel* Panel2;
wxMenuItem* automaticRotationItem;
wxMenuItem* MenuItem16;
wxPanel* pointsPanel;
wxMenuItem* MenuItem9;
wxMenuItem* multipleDirectionsItem;
wxListCtrl* imagesList;
wxMenuItem* MenuItem18;
wxMenu imagesMenu;
wxMenu maskMenu;
wxPanel* imagesPanel;
wxAuiToolBar* animationToolbar;
wxMenuItem* MenuItem19;
//*)
ResourcesEditor* resourcesEditorPnl;
//(*Declarations(SpriteObjectEditor)
wxAuiManager* AuiManager1;
wxMenu* MenuItem2;
wxTreeCtrl* animationsTree;
wxTreeListCtrl* maskTree;
wxMenuItem* MenuItem8;
wxListCtrl* pointsList;
wxPanel* toolbarPanel;
wxAuiToolBar* toolbar;
wxMenuItem* MenuItem7;
wxAuiToolBar* pointToolbar;
wxAuiManager* mgr;
wxAuiManager* AuiManager4;
wxStaticText* statusTxt;
wxMenuItem* MenuItem5;
wxPanel* centerPanel;
wxMenuItem* deleteItem;
wxMenuItem* MenuItem1;
wxMenuItem* MenuItem4;
wxMenuItem* MenuItem14;
wxMenuItem* MenuItem11;
wxMenuItem* MenuItem15;
wxPanel* Panel1;
wxMenu animationsMenu;
wxMenuItem* MenuItem17;
wxMenu* MenuItem13;
wxMenuItem* MenuItem10;
wxAuiManager* AuiManager2;
wxMenuItem* removeImageItem;
wxPanel* Panel3;
wxAuiToolBar* maskToolbar;
wxPanel* animationsPanel;
wxMenuItem* MenuItem12;
wxScrollBar* xScrollBar;
wxTimer previewTimer;
wxMenuItem* MenuItem3;
wxAuiManager* AuiManager3;
wxMenuItem* MenuItem20;
wxPanel* imagePanel;
wxScrollBar* yScrollBar;
wxMenu emptyImagesMenu;
wxMenuItem* moveLeftItem;
wxMenuItem* MenuItem6;
wxPanel* previewPanel;
wxPanel* maskPanel;
wxMenuItem* moveRightItem;
wxPanel* Panel2;
wxMenuItem* automaticRotationItem;
wxMenuItem* MenuItem16;
wxPanel* pointsPanel;
wxMenuItem* MenuItem9;
wxMenuItem* multipleDirectionsItem;
wxListCtrl* imagesList;
wxMenuItem* MenuItem18;
wxMenu imagesMenu;
wxMenu maskMenu;
wxPanel* imagesPanel;
wxAuiToolBar* animationToolbar;
wxMenuItem* MenuItem19;
//*)
ResourcesEditor * resourcesEditorPnl;
protected:
//(*Identifiers(SpriteObjectEditor)
static const long ID_MASKITEM;
static const long ID_POINTSITEM;
static const long ID_AUITOOLBARITEM4;
static const long ID_AUITOOLBARITEM2;
static const long ID_AUITOOLBAR1;
static const long ID_PANEL6;
static const long ID_PANEL4;
static const long ID_SCROLLBAR1;
static const long ID_SCROLLBAR2;
static const long ID_STATICTEXT1;
static const long ID_PANEL1;
static const long ID_AUITOOLBARITEM5;
static const long ID_AUITOOLBARITEM8;
static const long ID_TOOLLOOP;
static const long ID_AUITOOLBARITEM10;
static const long ID_AUITOOLBAR4;
static const long ID_PANEL11;
static const long ID_TREECTRL1;
static const long ID_PANEL3;
static const long ID_LISTCTRL1;
static const long ID_PANEL2;
static const long ID_AUITOOLBARITEM9;
static const long ID_AUITOOLBARITEM11;
static const long ID_AUITOOLBARITEM7;
static const long ID_AUITOOLBARITEM1;
static const long ID_MASKAPPLYWHOLEANIMITEM;
static const long ID_AUITOOLBAR3;
static const long ID_PANEL9;
static const long ID_TREELISTCTRL1;
static const long ID_PANEL8;
static const long ID_AUITOOLBARITEM3;
static const long ID_DELETEPOINTITEM;
static const long ID_POINTAPPLYWHOLEANIMITEM;
static const long ID_AUITOOLBAR2;
static const long ID_PANEL7;
static const long ID_LISTCTRL3;
static const long ID_PANEL5;
static const long ID_PANEL10;
static const long ID_MENUITEM5;
static const long ID_MENUITEM6;
static const long ID_MENUITEM4;
static const long ID_MENUIDLENAME;
static const long ID_MENUWALKNAME;
static const long ID_MENURUNNAME;
static const long ID_MENUJUMPNAME;
static const long ID_MENUSHOOTNAME;
static const long ID_MENUDEADNAME;
static const long ID_MENUCUSTOMNAME;
static const long ID_MENUITEM15;
static const long ID_MENUTIMEBETWEENFRAMES;
static const long ID_MENULOOP;
static const long ID_MENUITEM1;
static const long ID_MENUITEM2;
static const long ID_MENUITEM3;
static const long ID_MENUITEM7;
static const long ID_MENUITEM11;
static const long ID_MENUITEM8;
static const long ID_MENUITEM9;
static const long ID_MENUITEM10;
static const long ID_POSITIONMASKITEM;
static const long ID_MOVEPOLYGONITEM;
static const long ID_MENUITEM14;
static const long ID_TIMER1;
static const long ID_MENUITEM12;
static const long ID_MENUITEM13;
//*)
protected:
private:
//(*Handlers(SpriteObjectEditor)
void OnimagePanelPaint(wxPaintEvent& event);
void OnimagePanelEraseBackground(wxEraseEvent& event);
void OnimagesListItemSelect(wxListEvent& event);
void OnimagePanelResize(wxSizeEvent& event);
void OnanimationsTreeSelectionChanged(wxTreeEvent& event);
void OnAddAnimationSelected(wxCommandEvent& event);
void OnDeleteAnimationSelected(wxCommandEvent& event);
void OnanimationsTreeItemRightClick(wxTreeEvent& event);
void OnautomaticRotationItemSelected(wxCommandEvent& event);
void OnmultipleDirectionsItemSelected(wxCommandEvent& event);
void OnimagesListItemRClick(wxListEvent& event);
void OnremoveImageItemSelected(wxCommandEvent& event);
void OnMoveLeftSelected(wxCommandEvent& event);
void OnMoveRightSelected(wxCommandEvent& event);
void OnMaskEditClick(wxCommandEvent& event);
void OnPointEditClick(wxCommandEvent& event);
void OnmgrPaneClose(wxAuiManagerEvent& event);
void OnpointsListBeginLabelEdit(wxListEvent& event);
void OnpointsListEndLabelEdit(wxListEvent& event);
void OnimagePanelLeftUp(wxMouseEvent& event);
void OnpointsListItemSelect(wxListEvent& event);
void OnDeletePointClick(wxCommandEvent& event);
void OnAddPointClick(wxCommandEvent& event);
void OnpointsListItemActivated(wxListEvent& event);
void OnimagePanelLeftDown(wxMouseEvent& event);
void OnimagePanelMouseMove(wxMouseEvent& event);
void OnAddMaskClick(wxCommandEvent& event);
void OnDeleteMaskClick(wxCommandEvent& event);
void OnDefaultMaskClick(wxCommandEvent& event);
void OnPositionMaskSelected(wxCommandEvent& event);
void OnResizeMaskSelected(wxCommandEvent& event);
void OnMenuLoopSelected(wxCommandEvent& event);
void OnTimeBetweenFramesSelected(wxCommandEvent& event);
void OnpreviewPanelEraseBackground(wxEraseEvent& event);
void OnpreviewPanelResize(wxSizeEvent& event);
void OnpreviewPanelPaint(wxPaintEvent& event);
void OnTimer1Trigger(wxTimerEvent& event);
void OnpreviewTimerTrigger(wxTimerEvent& event);
void OnPreviewClick(wxCommandEvent& event);
void OnimagesListKeyDown(wxListEvent& event);
void OnAddImageFromFileSelected(wxCommandEvent& event);
void OnAddFromImageBankSelected(wxCommandEvent& event);
void OnHelpClick(wxCommandEvent& event);
void OnToolLoopClick(wxCommandEvent& event);
void OnMovePolygonSelected(wxCommandEvent& event);
void OnAddPolygonMaskClick(wxCommandEvent& event);
void OnAddVerticeClick(wxCommandEvent& event);
void OnRotatePolygonSelected(wxCommandEvent& event);
void OnyScrollBarScroll(wxScrollEvent& event);
void OnxScrollBarScroll(wxScrollEvent& event);
void OnSetAnimationNameIdleSelected(wxCommandEvent& event);
void OnSetAnimationNameWalkSelected(wxCommandEvent& event);
void OnSetAnimationNameRunSelected(wxCommandEvent& event);
void OnSetAnimationNameJumpSelected(wxCommandEvent& event);
void OnSetAnimationNameShootSelected(wxCommandEvent& event);
void OnSetAnimationNameDeadSelected(wxCommandEvent& event);
void OnSetCustomAnimationNameSelected(wxCommandEvent& event);
//*)
void OnmaskTreeItemRClick(wxTreeListEvent& event);
void OnmaskTreeItemActivated(wxTreeListEvent& event);
void OnmaskTreeSelectionChanged(wxTreeListEvent& event);
void OnimagesListRightClick(wxMouseEvent& event);
void RefreshAll();
void RefreshAnimationTree();
void RefreshAnimationToolbar();
void RefreshImagesList();
void RefreshImageAndControls();
void RefreshPoints();
void RefreshCollisionMasks();
void ResetPreview();
wxBitmap GetwxBitmapFromImageResource(gd::Resource& resource);
void SetAnimationName(gd::String newName);
//(*Identifiers(SpriteObjectEditor)
static const long ID_MASKITEM;
static const long ID_POINTSITEM;
static const long ID_AUITOOLBARITEM4;
static const long ID_AUITOOLBARITEM2;
static const long ID_AUITOOLBAR1;
static const long ID_PANEL6;
static const long ID_PANEL4;
static const long ID_SCROLLBAR1;
static const long ID_SCROLLBAR2;
static const long ID_STATICTEXT1;
static const long ID_PANEL1;
static const long ID_AUITOOLBARITEM5;
static const long ID_AUITOOLBARITEM8;
static const long ID_TOOLLOOP;
static const long ID_AUITOOLBARITEM10;
static const long ID_AUITOOLBAR4;
static const long ID_PANEL11;
static const long ID_TREECTRL1;
static const long ID_PANEL3;
static const long ID_LISTCTRL1;
static const long ID_PANEL2;
static const long ID_AUITOOLBARITEM9;
static const long ID_AUITOOLBARITEM11;
static const long ID_AUITOOLBARITEM7;
static const long ID_AUITOOLBARITEM1;
static const long ID_MASKAPPLYWHOLEANIMITEM;
static const long ID_AUITOOLBAR3;
static const long ID_PANEL9;
static const long ID_TREELISTCTRL1;
static const long ID_PANEL8;
static const long ID_AUITOOLBARITEM3;
static const long ID_DELETEPOINTITEM;
static const long ID_POINTAPPLYWHOLEANIMITEM;
static const long ID_AUITOOLBAR2;
static const long ID_PANEL7;
static const long ID_LISTCTRL3;
static const long ID_PANEL5;
static const long ID_PANEL10;
static const long ID_MENUITEM5;
static const long ID_MENUITEM6;
static const long ID_MENUITEM4;
static const long ID_MENUIDLENAME;
static const long ID_MENUWALKNAME;
static const long ID_MENURUNNAME;
static const long ID_MENUJUMPNAME;
static const long ID_MENUSHOOTNAME;
static const long ID_MENUDEADNAME;
static const long ID_MENUCUSTOMNAME;
static const long ID_MENUITEM15;
static const long ID_MENUTIMEBETWEENFRAMES;
static const long ID_MENULOOP;
static const long ID_MENUITEM1;
static const long ID_MENUITEM2;
static const long ID_MENUITEM3;
static const long ID_MENUITEM7;
static const long ID_MENUITEM11;
static const long ID_MENUITEM8;
static const long ID_MENUITEM9;
static const long ID_MENUITEM10;
static const long ID_POSITIONMASKITEM;
static const long ID_MOVEPOLYGONITEM;
static const long ID_MENUITEM14;
static const long ID_TIMER1;
static const long ID_MENUITEM12;
static const long ID_MENUITEM13;
//*)
/**
* Return a vector containing the sprites which must be modified when editing
* a point or collision masks: When buttons "Apply the changes to the whole
* animation" are checked, the vector contains all the sprites of the
* animation. If the buttons are unchecked, the vector contains only the
* sprite currently modified
*/
std::vector<Sprite*> GetSpritesToModify();
private:
DECLARE_EVENT_TABLE()
//(*Handlers(SpriteObjectEditor)
void OnimagePanelPaint(wxPaintEvent& event);
void OnimagePanelEraseBackground(wxEraseEvent& event);
void OnimagesListItemSelect(wxListEvent& event);
void OnimagePanelResize(wxSizeEvent& event);
void OnanimationsTreeSelectionChanged(wxTreeEvent& event);
void OnAddAnimationSelected(wxCommandEvent& event);
void OnDeleteAnimationSelected(wxCommandEvent& event);
void OnanimationsTreeItemRightClick(wxTreeEvent& event);
void OnautomaticRotationItemSelected(wxCommandEvent& event);
void OnmultipleDirectionsItemSelected(wxCommandEvent& event);
void OnimagesListItemRClick(wxListEvent& event);
void OnremoveImageItemSelected(wxCommandEvent& event);
void OnMoveLeftSelected(wxCommandEvent& event);
void OnMoveRightSelected(wxCommandEvent& event);
void OnMaskEditClick(wxCommandEvent& event);
void OnPointEditClick(wxCommandEvent& event);
void OnmgrPaneClose(wxAuiManagerEvent& event);
void OnpointsListBeginLabelEdit(wxListEvent& event);
void OnpointsListEndLabelEdit(wxListEvent& event);
void OnimagePanelLeftUp(wxMouseEvent& event);
void OnpointsListItemSelect(wxListEvent& event);
void OnDeletePointClick(wxCommandEvent& event);
void OnAddPointClick(wxCommandEvent& event);
void OnpointsListItemActivated(wxListEvent& event);
void OnimagePanelLeftDown(wxMouseEvent& event);
void OnimagePanelMouseMove(wxMouseEvent& event);
void OnAddMaskClick(wxCommandEvent& event);
void OnDeleteMaskClick(wxCommandEvent& event);
void OnDefaultMaskClick(wxCommandEvent& event);
void OnPositionMaskSelected(wxCommandEvent& event);
void OnResizeMaskSelected(wxCommandEvent& event);
void OnMenuLoopSelected(wxCommandEvent& event);
void OnTimeBetweenFramesSelected(wxCommandEvent& event);
void OnpreviewPanelEraseBackground(wxEraseEvent& event);
void OnpreviewPanelResize(wxSizeEvent& event);
void OnpreviewPanelPaint(wxPaintEvent& event);
void OnTimer1Trigger(wxTimerEvent& event);
void OnpreviewTimerTrigger(wxTimerEvent& event);
void OnPreviewClick(wxCommandEvent& event);
void OnimagesListKeyDown(wxListEvent& event);
void OnAddImageFromFileSelected(wxCommandEvent& event);
void OnAddFromImageBankSelected(wxCommandEvent& event);
void OnHelpClick(wxCommandEvent& event);
void OnToolLoopClick(wxCommandEvent& event);
void OnMovePolygonSelected(wxCommandEvent& event);
void OnAddPolygonMaskClick(wxCommandEvent& event);
void OnAddVerticeClick(wxCommandEvent& event);
void OnRotatePolygonSelected(wxCommandEvent& event);
void OnyScrollBarScroll(wxScrollEvent& event);
void OnxScrollBarScroll(wxScrollEvent& event);
void OnSetAnimationNameIdleSelected(wxCommandEvent& event);
void OnSetAnimationNameWalkSelected(wxCommandEvent& event);
void OnSetAnimationNameRunSelected(wxCommandEvent& event);
void OnSetAnimationNameJumpSelected(wxCommandEvent& event);
void OnSetAnimationNameShootSelected(wxCommandEvent& event);
void OnSetAnimationNameDeadSelected(wxCommandEvent& event);
void OnSetCustomAnimationNameSelected(wxCommandEvent& event);
//*)
void OnmaskTreeItemRClick(wxTreeListEvent& event);
void OnmaskTreeItemActivated(wxTreeListEvent& event);
void OnmaskTreeSelectionChanged(wxTreeListEvent& event);
void OnimagesListRightClick(wxMouseEvent& event);
void RefreshAll();
void RefreshAnimationTree();
void RefreshAnimationToolbar();
void RefreshImagesList();
void RefreshImageAndControls();
void RefreshPoints();
void RefreshCollisionMasks();
void ResetPreview();
wxBitmap GetwxBitmapFromImageResource(gd::Resource & resource);
void SetAnimationName(gd::String newName);
gd::Project& game;
SpriteObject& object;
std::size_t selectedAnimation;
std::size_t selectedDirection;
std::size_t selectedImage;
gd::String selectedPoint;
float spritePosX; ///< Used to remember the position where the sprite have
///< been drawn.
float spritePosY; ///< Used to remember the position where the sprite have
///< been drawn.
float spriteWidth; ///< Used to remember the width of the current sprite.
float spriteHeight; ///< Used to remember the height of the current sprite.
/**
* Return a vector containing the sprites which must be modified when editing a point
* or collision masks:
* When buttons "Apply the changes to the whole animation" are checked, the vector contains
* all the sprites of the animation. If the buttons are unchecked, the vector contains only
* the sprite currently modified
*/
std::vector < Sprite * > GetSpritesToModify();
bool editingMask;
bool editingPoint;
bool deletingMaskTreeItems; // Used to workaround an event being called when
// using maskTree->DeleteAllItems().
DECLARE_EVENT_TABLE()
gd::String renamedPointOldName;
gd::Project & game;
SpriteObject & object;
std::size_t selectedAnimation;
std::size_t selectedDirection;
std::size_t selectedImage;
gd::String selectedPoint;
float spritePosX; ///< Used to remember the position where the sprite have been drawn.
float spritePosY; ///< Used to remember the position where the sprite have been drawn.
float spriteWidth; ///< Used to remember the width of the current sprite.
float spriteHeight; ///< Used to remember the height of the current sprite.
gd::PolygonEditionHelper polygonEditionHelper;
bool editingMask;
bool editingPoint;
bool deletingMaskTreeItems; //Used to workaround an event being called when using maskTree->DeleteAllItems().
float previewElapsedTime;
int previewCurrentSprite;
gd::String renamedPointOldName;
gd::PolygonEditionHelper polygonEditionHelper;
float previewElapsedTime;
int previewCurrentSprite;
gd::MainFrameWrapper & mainFrameWrapper;
gd::MainFrameWrapper& mainFrameWrapper;
};
/**
* \brief Tool class used by SpriteObjectEditor to enable inserting images using drag'n'drop
* \brief Tool class used by SpriteObjectEditor to enable inserting images using
* drag'n'drop
*/
class DndTextSpriteObjectEditor : public wxTextDropTarget
{
public:
DndTextSpriteObjectEditor(SpriteObjectEditor & editor_) : editor(editor_) {}
class DndTextSpriteObjectEditor : public wxTextDropTarget {
public:
DndTextSpriteObjectEditor(SpriteObjectEditor& editor_) : editor(editor_) {}
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text);
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text);
private:
SpriteObjectEditor & editor;
private:
SpriteObjectEditor& editor;
};
}
} // namespace gd
#endif
#endif

View File

@@ -1,214 +1,189 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include <iostream>
#include "GDCore/String.h"
#include <vector>
#include "GDCore/Extensions/Builtin/SpriteExtension/Direction.h"
#include <iostream>
#include <vector>
#include "GDCore/CommonTools.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Sprite.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/CommonTools.h"
#include "GDCore/String.h"
using namespace std;
namespace gd {
Direction::Direction() :
loop(false),
timeBetweenFrame(1)
{
Direction::Direction() : loop(false), timeBetweenFrame(1) {}
Direction::~Direction(){};
void Direction::SetLoop(bool loop_) { loop = loop_; }
void Direction::SetTimeBetweenFrames(float time) { timeBetweenFrame = time; }
void Direction::AddSprite(const Sprite& sprite) { sprites.push_back(sprite); }
const Sprite& Direction::GetSprite(std::size_t nb) const { return sprites[nb]; }
Sprite& Direction::GetSprite(std::size_t nb) { return sprites[nb]; }
void Direction::RemoveSprite(std::size_t index) {
if (index < sprites.size()) sprites.erase(sprites.begin() + index);
}
Direction::~Direction()
{
};
void Direction::SetLoop( bool loop_ )
{
loop = loop_;
void Direction::SwapSprites(std::size_t firstSpriteIndex,
std::size_t secondSpriteIndex) {
if (firstSpriteIndex < sprites.size() && secondSpriteIndex < sprites.size() &&
firstSpriteIndex != secondSpriteIndex)
swap(sprites[firstSpriteIndex], sprites[secondSpriteIndex]);
}
void Direction::SetTimeBetweenFrames( float time )
{
timeBetweenFrame = time;
void Direction::MoveSprite(std::size_t oldIndex, std::size_t newIndex) {
if (oldIndex >= sprites.size() || newIndex >= sprites.size()) return;
auto sprite = sprites[oldIndex];
sprites.erase(sprites.begin() + oldIndex);
sprites.insert(sprites.begin() + newIndex, sprite);
}
void Direction::AddSprite( const Sprite & sprite )
{
bool Direction::HasNoSprites() const { return sprites.empty(); }
std::size_t Direction::GetSpritesCount() const { return sprites.size(); }
void Direction::RemoveAllSprites() { sprites.clear(); }
void OpenPoint(Point& point, const gd::SerializerElement& element) {
point.SetName(element.GetStringAttribute("name", "", "nom"));
point.SetX(element.GetDoubleAttribute("x", 0, "X"));
point.SetY(element.GetDoubleAttribute("y", 0, "Y"));
}
void OpenPointsSprites(vector<Point>& points,
const gd::SerializerElement& element) {
element.ConsiderAsArrayOf("point", "Point");
for (std::size_t i = 0; i < element.GetChildrenCount(); ++i) {
Point point("");
OpenPoint(point, element.GetChild(i));
points.push_back(point);
}
}
void Direction::UnserializeFrom(const gd::SerializerElement& element) {
SetTimeBetweenFrames(
element.GetDoubleAttribute("timeBetweenFrames", 1, "tempsEntre"));
SetLoop(element.GetBoolAttribute("looping", false, "boucle"));
const gd::SerializerElement& spritesElement =
element.GetChild("sprites", 0, "Sprites");
spritesElement.ConsiderAsArrayOf("sprite", "Sprite");
for (std::size_t i = 0; i < spritesElement.GetChildrenCount(); ++i) {
const gd::SerializerElement& spriteElement = spritesElement.GetChild(i);
Sprite sprite;
sprite.SetImageName(spriteElement.GetStringAttribute("image"));
OpenPointsSprites(sprite.GetAllNonDefaultPoints(),
spriteElement.GetChild("points", 0, "Points"));
OpenPoint(sprite.GetOrigin(),
spriteElement.GetChild("originPoint", 0, "PointOrigine"));
OpenPoint(sprite.GetCenter(),
spriteElement.GetChild("centerPoint", 0, "PointCentre"));
sprite.SetDefaultCenterPoint(
spriteElement.GetChild("centerPoint", 0, "PointCentre")
.GetBoolAttribute("automatic", true));
if (spriteElement.HasChild("CustomCollisionMask"))
sprite.SetCollisionMaskAutomatic(
!spriteElement.GetChild("CustomCollisionMask")
.GetBoolAttribute("custom", false));
else
sprite.SetCollisionMaskAutomatic(
!spriteElement.GetBoolAttribute("hasCustomCollisionMask", false));
std::vector<Polygon2d> mask;
const gd::SerializerElement& collisionMaskElement =
spriteElement.GetChild("customCollisionMask", 0, "CustomCollisionMask");
collisionMaskElement.ConsiderAsArrayOf("polygon", "Polygon");
for (std::size_t j = 0; j < collisionMaskElement.GetChildrenCount(); ++j) {
Polygon2d polygon;
const gd::SerializerElement& polygonElement =
collisionMaskElement.GetChild(j);
polygonElement.ConsiderAsArrayOf("vertice", "Point");
for (std::size_t k = 0; k < polygonElement.GetChildrenCount(); ++k) {
const gd::SerializerElement& verticeElement =
polygonElement.GetChild(k);
polygon.vertices.push_back(
sf::Vector2f(verticeElement.GetDoubleAttribute("x"),
verticeElement.GetDoubleAttribute("y")));
}
mask.push_back(polygon);
}
sprite.SetCustomCollisionMask(mask);
sprites.push_back(sprite);
}
const Sprite & Direction::GetSprite(std::size_t nb) const
{
return sprites[nb];
}
Sprite & Direction::GetSprite(std::size_t nb)
{
return sprites[nb];
}
void Direction::RemoveSprite(std::size_t index)
{
if ( index < sprites.size() )
sprites.erase(sprites.begin()+index);
}
void Direction::SwapSprites(std::size_t firstSpriteIndex, std::size_t secondSpriteIndex)
{
if ( firstSpriteIndex < sprites.size() && secondSpriteIndex < sprites.size() && firstSpriteIndex != secondSpriteIndex)
swap(sprites[firstSpriteIndex], sprites[secondSpriteIndex]);
}
void Direction::MoveSprite(std::size_t oldIndex, std::size_t newIndex)
{
if ( oldIndex >= sprites.size() || newIndex >= sprites.size())
return;
auto sprite = sprites[oldIndex];
sprites.erase(sprites.begin() + oldIndex);
sprites.insert(sprites.begin() + newIndex, sprite);
}
bool Direction::HasNoSprites() const
{
return sprites.empty();
}
std::size_t Direction::GetSpritesCount() const
{
return sprites.size();
}
void Direction::RemoveAllSprites()
{
sprites.clear();
}
void OpenPoint(Point & point, const gd::SerializerElement & element)
{
point.SetName(element.GetStringAttribute("name", "", "nom"));
point.SetX(element.GetDoubleAttribute("x", 0, "X"));
point.SetY(element.GetDoubleAttribute("y", 0, "Y"));
}
void OpenPointsSprites(vector < Point > & points, const gd::SerializerElement & element)
{
element.ConsiderAsArrayOf("point", "Point");
for (std::size_t i = 0; i < element.GetChildrenCount(); ++i)
{
Point point("");
OpenPoint(point, element.GetChild(i));
points.push_back(point);
}
}
void Direction::UnserializeFrom(const gd::SerializerElement & element)
{
SetTimeBetweenFrames(element.GetDoubleAttribute("timeBetweenFrames", 1, "tempsEntre"));
SetLoop(element.GetBoolAttribute("looping", false, "boucle"));
const gd::SerializerElement & spritesElement = element.GetChild("sprites", 0, "Sprites");
spritesElement.ConsiderAsArrayOf("sprite", "Sprite");
for (std::size_t i = 0; i < spritesElement.GetChildrenCount(); ++i)
{
const gd::SerializerElement & spriteElement = spritesElement.GetChild(i);
Sprite sprite;
sprite.SetImageName(spriteElement.GetStringAttribute("image"));
OpenPointsSprites(sprite.GetAllNonDefaultPoints(), spriteElement.GetChild("points", 0, "Points"));
OpenPoint(sprite.GetOrigin(), spriteElement.GetChild("originPoint" , 0, "PointOrigine"));
OpenPoint(sprite.GetCenter(), spriteElement.GetChild("centerPoint" , 0, "PointCentre"));
sprite.SetDefaultCenterPoint(spriteElement.GetChild("centerPoint" , 0, "PointCentre").GetBoolAttribute("automatic", true));
if (spriteElement.HasChild("CustomCollisionMask"))
sprite.SetCollisionMaskAutomatic(!spriteElement.GetChild("CustomCollisionMask").GetBoolAttribute("custom", false));
else
sprite.SetCollisionMaskAutomatic(!spriteElement.GetBoolAttribute("hasCustomCollisionMask", false));
std::vector<Polygon2d> mask;
const gd::SerializerElement & collisionMaskElement = spriteElement.GetChild("customCollisionMask", 0, "CustomCollisionMask");
collisionMaskElement.ConsiderAsArrayOf("polygon", "Polygon");
for (std::size_t j = 0; j < collisionMaskElement.GetChildrenCount(); ++j)
{
Polygon2d polygon;
const gd::SerializerElement & polygonElement = collisionMaskElement.GetChild(j);
polygonElement.ConsiderAsArrayOf("vertice", "Point");
for (std::size_t k = 0; k < polygonElement.GetChildrenCount(); ++k)
{
const gd::SerializerElement & verticeElement = polygonElement.GetChild(k);
polygon.vertices.push_back(sf::Vector2f(verticeElement.GetDoubleAttribute("x"),
verticeElement.GetDoubleAttribute("y")));
}
mask.push_back(polygon);
}
sprite.SetCustomCollisionMask(mask);
sprites.push_back(sprite);
}
}
};
#if defined(GD_IDE_ONLY)
void SavePoint(const Point & point, gd::SerializerElement & element)
{
element.SetAttribute("name", point.GetName());
element.SetAttribute("x", point.GetX());
element.SetAttribute("y", point.GetY());
void SavePoint(const Point& point, gd::SerializerElement& element) {
element.SetAttribute("name", point.GetName());
element.SetAttribute("x", point.GetX());
element.SetAttribute("y", point.GetY());
}
void SavePointsSprites(const vector < Point > & points, gd::SerializerElement & element)
{
element.ConsiderAsArrayOf("point");
for (std::size_t i = 0;i<points.size();++i)
SavePoint(points[i], element.AddChild("point"));
void SavePointsSprites(const vector<Point>& points,
gd::SerializerElement& element) {
element.ConsiderAsArrayOf("point");
for (std::size_t i = 0; i < points.size(); ++i)
SavePoint(points[i], element.AddChild("point"));
}
void SaveSpritesDirection(const vector < Sprite > & sprites, gd::SerializerElement & element)
{
element.ConsiderAsArrayOf("sprite");
for (std::size_t i = 0;i<sprites.size();++i)
{
gd::SerializerElement & spriteElement = element.AddChild("sprite");
void SaveSpritesDirection(const vector<Sprite>& sprites,
gd::SerializerElement& element) {
element.ConsiderAsArrayOf("sprite");
for (std::size_t i = 0; i < sprites.size(); ++i) {
gd::SerializerElement& spriteElement = element.AddChild("sprite");
spriteElement.SetAttribute("image", sprites[i].GetImageName());
SavePointsSprites(sprites[i].GetAllNonDefaultPoints(), spriteElement.AddChild("points"));
spriteElement.SetAttribute("image", sprites[i].GetImageName());
SavePointsSprites(sprites[i].GetAllNonDefaultPoints(),
spriteElement.AddChild("points"));
SavePoint(sprites[i].GetOrigin(), spriteElement.AddChild("originPoint"));
SavePoint(sprites[i].GetCenter(), spriteElement.AddChild("centerPoint"));
spriteElement.GetChild("centerPoint").SetAttribute("automatic", sprites[i].IsDefaultCenterPoint());
SavePoint(sprites[i].GetOrigin(), spriteElement.AddChild("originPoint"));
SavePoint(sprites[i].GetCenter(), spriteElement.AddChild("centerPoint"));
spriteElement.GetChild("centerPoint")
.SetAttribute("automatic", sprites[i].IsDefaultCenterPoint());
spriteElement.SetAttribute("hasCustomCollisionMask", !sprites[i].IsCollisionMaskAutomatic());
spriteElement.SetAttribute("hasCustomCollisionMask",
!sprites[i].IsCollisionMaskAutomatic());
gd::SerializerElement & collisionMaskElement = spriteElement.AddChild("customCollisionMask");
collisionMaskElement.ConsiderAsArrayOf("polygon");
std::vector<Polygon2d> polygons = sprites[i].GetCollisionMask();
for (std::size_t j = 0;j<polygons.size();++j)
{
gd::SerializerElement & polygonElement = collisionMaskElement.AddChild("polygon");
polygonElement.ConsiderAsArrayOf("vertice");
for (std::size_t k = 0;k<polygons[j].vertices.size();++k)
{
polygonElement.AddChild("vertice")
.SetAttribute("x", polygons[j].vertices[k].x)
.SetAttribute("y", polygons[j].vertices[k].y);
}
}
gd::SerializerElement& collisionMaskElement =
spriteElement.AddChild("customCollisionMask");
collisionMaskElement.ConsiderAsArrayOf("polygon");
std::vector<Polygon2d> polygons = sprites[i].GetCollisionMask();
for (std::size_t j = 0; j < polygons.size(); ++j) {
gd::SerializerElement& polygonElement =
collisionMaskElement.AddChild("polygon");
polygonElement.ConsiderAsArrayOf("vertice");
for (std::size_t k = 0; k < polygons[j].vertices.size(); ++k) {
polygonElement.AddChild("vertice")
.SetAttribute("x", polygons[j].vertices[k].x)
.SetAttribute("y", polygons[j].vertices[k].y);
}
}
}
}
void Direction::SerializeTo(gd::SerializerElement & element) const
{
element.SetAttribute("looping", IsLooping());
element.SetAttribute("timeBetweenFrames", GetTimeBetweenFrames());
SaveSpritesDirection(sprites, element.AddChild("sprites"));
void Direction::SerializeTo(gd::SerializerElement& element) const {
element.SetAttribute("looping", IsLooping());
element.SetAttribute("timeBetweenFrames", GetTimeBetweenFrames());
SaveSpritesDirection(sprites, element.AddChild("sprites"));
}
#endif
}
} // namespace gd

View File

@@ -1,13 +1,17 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_DIRECTION_H
#define GDCORE_DIRECTION_H
#include <vector>
namespace gd { class Sprite; }
namespace gd { class SerializerElement; }
namespace gd {
class Sprite;
}
namespace gd {
class SerializerElement;
}
namespace gd {
@@ -19,97 +23,97 @@ namespace gd {
* \see Sprite
* \ingroup SpriteObjectExtension
*
* \todo Support UTF8 (currently convert all loaded strings from UTF8 to the current locale)
* \todo Support UTF8 (currently convert all loaded strings from UTF8 to the
* current locale)
*/
class GD_CORE_API Direction
{
public:
Direction();
virtual ~Direction();
class GD_CORE_API Direction {
public:
Direction();
virtual ~Direction();
/**
* Return true if sprites looping is activated
*/
inline bool IsLooping() const { return loop; }
/**
* Return true if sprites looping is activated
*/
inline bool IsLooping() const { return loop; }
/**
* Set if the sprites must be looping or not.
*/
void SetLoop(bool loop_);
/**
* Set if the sprites must be looping or not.
*/
void SetLoop(bool loop_);
/**
* Get the time between each sprite
*/
inline float GetTimeBetweenFrames() const { return timeBetweenFrame; }
/**
* Get the time between each sprite
*/
inline float GetTimeBetweenFrames() const { return timeBetweenFrame; }
/**
* Set the time between each sprite
* \param time Time between each sprite, in seconds.
*/
void SetTimeBetweenFrames(float time);
/**
* Set the time between each sprite
* \param time Time between each sprite, in seconds.
*/
void SetTimeBetweenFrames(float time);
/**
* Return a reference to a sprite of the direction.
* \param nb The index of the sprite to be accessed. Bound checking is not made.
* \return A reference to the sprite.
*/
const Sprite & GetSprite(std::size_t nb) const;
/**
* Return a reference to a sprite of the direction.
* \param nb The index of the sprite to be accessed. Bound checking is not
* made. \return A reference to the sprite.
*/
const Sprite& GetSprite(std::size_t nb) const;
/**
* Return a reference to a sprite of the direction.
* \param nb The index of the sprite to be accessed. Bound checking is not made.
* \return A reference to the sprite.
*/
Sprite & GetSprite(std::size_t nb);
/**
* Return a reference to a sprite of the direction.
* \param nb The index of the sprite to be accessed. Bound checking is not
* made. \return A reference to the sprite.
*/
Sprite& GetSprite(std::size_t nb);
/**
* Check if the direction contains sprites.
* \return true if the direction does not have any sprite.
*/
bool HasNoSprites() const;
/**
* Check if the direction contains sprites.
* \return true if the direction does not have any sprite.
*/
bool HasNoSprites() const;
/**
* Return the number of sprite used in the direction
* \return The number of sprite used in the direction
*/
std::size_t GetSpritesCount() const;
/**
* Return the number of sprite used in the direction
* \return The number of sprite used in the direction
*/
std::size_t GetSpritesCount() const;
/**
* Remove the sprite at the specified position.
* Bound-checking is made.
*/
void RemoveSprite(std::size_t index);
/**
* Remove the sprite at the specified position.
* Bound-checking is made.
*/
void RemoveSprite(std::size_t index);
/**
* Clear the direction from all of its sprites
*/
void RemoveAllSprites();
/**
* Clear the direction from all of its sprites
*/
void RemoveAllSprites();
/**
* Add a new sprite at the end of the list.
*/
void AddSprite( const Sprite & sprite );
/**
* Add a new sprite at the end of the list.
*/
void AddSprite(const Sprite& sprite);
/**
* Swap the position of two sprites
*/
void SwapSprites(std::size_t firstSpriteIndex, std::size_t secondSpriteIndex);
/**
* Swap the position of two sprites
*/
void SwapSprites(std::size_t firstSpriteIndex, std::size_t secondSpriteIndex);
/**
* Change the position of the specified sprite.
*/
void MoveSprite(std::size_t oldIndex, std::size_t newIndex);
/**
* Change the position of the specified sprite.
*/
void MoveSprite(std::size_t oldIndex, std::size_t newIndex);
void UnserializeFrom(const gd::SerializerElement & element);
#if defined(GD_IDE_ONLY)
void SerializeTo(gd::SerializerElement & element) const;
#endif
void UnserializeFrom(const gd::SerializerElement& element);
#if defined(GD_IDE_ONLY)
void SerializeTo(gd::SerializerElement& element) const;
#endif
private:
bool loop; ///< true if the animation must loop.
float timeBetweenFrame; ///< The time between each sprite of the animation.
std::vector < Sprite > sprites; ///< The sprites of the direction.
private:
bool loop; ///< true if the animation must loop.
float timeBetweenFrame; ///< The time between each sprite of the animation.
std::vector<Sprite> sprites; ///< The sprites of the direction.
};
}
#endif // GDCORE_DIRECTION_H
} // namespace gd
#endif // GDCORE_DIRECTION_H

View File

@@ -1,17 +1,12 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GDCore/Extensions/Builtin/SpriteExtension/Point.h"
#include "GDCore/String.h"
Point::Point(const gd::String & name_) :
name(name_),
x(0),
y(0)
{
//ctor
Point::Point(const gd::String& name_) : name(name_), x(0), y(0) {
// ctor
}

View File

@@ -1,7 +1,7 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_POINT_H
@@ -13,52 +13,53 @@
*
* \ingroup SpriteObjectExtension
*/
class GD_CORE_API Point
{
public:
Point(const gd::String & name_);
virtual ~Point() {};
class GD_CORE_API Point {
public:
Point(const gd::String& name_);
virtual ~Point(){};
/**
* Change point name
*/
void SetName(const gd::String & name_) { name = name_; }
/**
* Change point name
*/
void SetName(const gd::String& name_) { name = name_; }
/**
* Get point name
*/
const gd::String & GetName() const { return name; }
/**
* Get point name
*/
const gd::String& GetName() const { return name; }
/**
* Change point position.
*/
void SetXY(float x_, float y_) { x = x_;y = y_; }
/**
* Change point position.
*/
void SetXY(float x_, float y_) {
x = x_;
y = y_;
}
/**
* Change point X position.
*/
void SetX(float x_) { x = x_; }
/**
* Change point X position.
*/
void SetX(float x_) { x = x_; }
/**
* Change point Y position.
*/
void SetY(float y_) { y = y_; }
/**
* Change point Y position.
*/
void SetY(float y_) { y = y_; }
/**
* Get point X position.
*/
float GetX() const { return x; }
/**
* Get point X position.
*/
float GetX() const { return x; }
/**
* Get point Y position.
*/
float GetY() const { return y; }
/**
* Get point Y position.
*/
float GetY() const { return y; }
private:
gd::String name;
float x;
float y;
private:
gd::String name;
float x;
float y;
};
#endif // GDCORE_POINT_H
#endif // GDCORE_POINT_H

View File

@@ -1,93 +1,86 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "Polygon2d.h"
#include <SFML/System/Vector2.hpp>
#include <cmath>
#include <iostream>
#include <SFML/System/Vector2.hpp>
void Polygon2d::Rotate(float angle)
{
float t,
cosa = cos(-angle),
sina = sin(-angle); //We want a clockwise rotation
void Polygon2d::Rotate(float angle) {
float t, cosa = cos(-angle),
sina = sin(-angle); // We want a clockwise rotation
for (std::size_t i = 0;i<vertices.size();++i)
{
t = vertices[i].x;
vertices[i].x = t*cosa + vertices[i].y*sina;
vertices[i].y = -t*sina + vertices[i].y*cosa;
}
for (std::size_t i = 0; i < vertices.size(); ++i) {
t = vertices[i].x;
vertices[i].x = t * cosa + vertices[i].y * sina;
vertices[i].y = -t * sina + vertices[i].y * cosa;
}
}
void Polygon2d::Move(float x, float y)
{
for (std::size_t i = 0; i < vertices.size(); i++)
{
vertices[i].x += x;
vertices[i].y += y;
}
ComputeEdges();
void Polygon2d::Move(float x, float y) {
for (std::size_t i = 0; i < vertices.size(); i++) {
vertices[i].x += x;
vertices[i].y += y;
}
ComputeEdges();
}
void Polygon2d::ComputeEdges() const
{
sf::Vector2f v1, v2;
edges.clear();
void Polygon2d::ComputeEdges() const {
sf::Vector2f v1, v2;
edges.clear();
for (std::size_t i = 0; i < vertices.size(); i++)
{
v1 = vertices[i];
if ((i + 1) >= vertices.size()) v2 = vertices[0];
else v2 = vertices[i + 1];
for (std::size_t i = 0; i < vertices.size(); i++) {
v1 = vertices[i];
if ((i + 1) >= vertices.size())
v2 = vertices[0];
else
v2 = vertices[i + 1];
edges.push_back(v2 - v1);
}
edges.push_back(v2 - v1);
}
}
bool Polygon2d::IsConvex() const
{
ComputeEdges();
if ( edges.size() < 3 ) return false;
bool Polygon2d::IsConvex() const {
ComputeEdges();
if (edges.size() < 3) return false;
bool zProductIsPositive = (edges[0].x*edges[0+1].y - edges[0].y*edges[0+1].x) > 0;
bool zProductIsPositive =
(edges[0].x * edges[0 + 1].y - edges[0].y * edges[0 + 1].x) > 0;
for (std::size_t i = 1;i<edges.size()-1;++i)
{
float zCrossProduct = edges[i].x*edges[i+1].y - edges[i].y*edges[i+1].x;
if ( (zCrossProduct > 0) != zProductIsPositive ) return false;
}
for (std::size_t i = 1; i < edges.size() - 1; ++i) {
float zCrossProduct =
edges[i].x * edges[i + 1].y - edges[i].y * edges[i + 1].x;
if ((zCrossProduct > 0) != zProductIsPositive) return false;
}
float lastZCrossProduct = edges[edges.size()-1].x*edges[0].y - edges[edges.size()-1].y*edges[0].x;
if ( (lastZCrossProduct > 0) != zProductIsPositive ) return false;
float lastZCrossProduct = edges[edges.size() - 1].x * edges[0].y -
edges[edges.size() - 1].y * edges[0].x;
if ((lastZCrossProduct > 0) != zProductIsPositive) return false;
return true;
return true;
}
sf::Vector2f Polygon2d::ComputeCenter() const
{
sf::Vector2f center;
sf::Vector2f Polygon2d::ComputeCenter() const {
sf::Vector2f center;
for (std::size_t i = 0; i < vertices.size(); i++)
{
center.x += vertices[i].x;
center.y += vertices[i].y;
}
center.x /= vertices.size();
center.y /= vertices.size();
for (std::size_t i = 0; i < vertices.size(); i++) {
center.x += vertices[i].x;
center.y += vertices[i].y;
}
center.x /= vertices.size();
center.y /= vertices.size();
return center;
return center;
}
Polygon2d Polygon2d::CreateRectangle(float width, float height)
{
Polygon2d rect;
rect.vertices.push_back(sf::Vector2f(-width/2.0f, -height/2.0f));
rect.vertices.push_back(sf::Vector2f(+width/2.0f, -height/2.0f));
rect.vertices.push_back(sf::Vector2f(+width/2.0f, +height/2.0f));
rect.vertices.push_back(sf::Vector2f(-width/2.0f, +height/2.0f));
Polygon2d Polygon2d::CreateRectangle(float width, float height) {
Polygon2d rect;
rect.vertices.push_back(sf::Vector2f(-width / 2.0f, -height / 2.0f));
rect.vertices.push_back(sf::Vector2f(+width / 2.0f, -height / 2.0f));
rect.vertices.push_back(sf::Vector2f(+width / 2.0f, +height / 2.0f));
rect.vertices.push_back(sf::Vector2f(-width / 2.0f, +height / 2.0f));
return rect;
return rect;
}

View File

@@ -1,71 +1,84 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_POLYGON_H
#define GDCORE_POLYGON_H
#include <vector>
#include <SFML/System/Vector2.hpp>
#include <vector>
/**
* \brief Represents a polygon. Usually used for collisions masks.
*
* This class stores the vertices of the polygon.
* It can also compute and store the edges ( needed by some collisions algorithms ) if ComputeEdges is called.
* It can also compute and store the edges ( needed by some collisions
* algorithms ) if ComputeEdges is called.
*
* \ingroup GameEngine
*/
class GD_CORE_API Polygon2d
{
public:
Polygon2d() {};
virtual ~Polygon2d() {};
class GD_CORE_API Polygon2d {
public:
Polygon2d(){};
virtual ~Polygon2d(){};
std::vector<sf::Vector2f> vertices; ///< The vertices composing the polygon
mutable std::vector<sf::Vector2f> edges; ///< Edges. Can be computed from vertices using ComputeEdges()
std::vector<sf::Vector2f> vertices; ///< The vertices composing the polygon
mutable std::vector<sf::Vector2f>
edges; ///< Edges. Can be computed from vertices using ComputeEdges()
/**
* Moves each vertices from the given amount.
*
* \note Edges are updated, there is no need to call ComputeEdges after calling Move.
*/
void Move(float x, float y);
/**
* \brief Get the vertices composing the polygon.
*/
std::vector<sf::Vector2f>& GetVertices() { return vertices; }
/**
* Rotate the polygon.
* \param angle Angle in radians
*
* \warning Rotation is made clockwise
* \warning edges vector is not updated, you have to call ComputeEdges if needed.
*/
void Rotate(float angle);
/**
* \brief Get the vertices composing the polygon.
*/
const std::vector<sf::Vector2f>& GetVertices() const { return vertices; }
/**
* Automatically fill edges vector using vertices.
*/
void ComputeEdges() const;
/**
* \brief Moves each vertices from the given amount.
*
* \note Edges are updated, there is no need to call ComputeEdges after
* calling Move.
*/
void Move(float x, float y);
/**
* Check if the polygon is convex.
* \return true if the polygon is convex
*/
bool IsConvex() const;
/**
* \brief Rotate the polygon.
* \param angle Angle in radians
*
* \warning Rotation is made clockwise
* \warning edges vector is not updated, you have to call ComputeEdges if
* needed.
*/
void Rotate(float angle);
/**
* Return the position of the center of the polygon
*/
sf::Vector2f ComputeCenter() const;
/**
* \brief Automatically fill edges vector using vertices.
*/
void ComputeEdges() const;
/** \name Tools
* Tool functions
*/
///@{
/**
* Create a rectangle
*/
static Polygon2d CreateRectangle(float width, float height);
///@}
/**
* \brief Check if the polygon is convex.
* \return true if the polygon is convex
*/
bool IsConvex() const;
/**
* \brief Return the position of the center of the polygon
*/
sf::Vector2f ComputeCenter() const;
/** \name Tools
* Tool functions
*/
///@{
/**
* \brief Create a rectangle
*/
static Polygon2d CreateRectangle(float width, float height);
///@}
};
#endif // GDCORE_POLYGON_H
#endif // GDCORE_POLYGON_H

View File

@@ -1,152 +1,135 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Sprite.h"
#include "GDCore/Project/ImageManager.h"
#include <SFML/Graphics/Sprite.hpp>
#include <iostream>
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
#include "GDCore/Project/ImageManager.h"
using namespace std;
namespace gd
{
namespace gd {
Point Sprite::badPoint("");
Sprite::Sprite() :
Sprite::Sprite()
:
#if !defined(EMSCRIPTEN)
hasItsOwnImage(false),
hasItsOwnImage(false),
#endif
automaticCollisionMask(true),
origine("origine"),
centre("centre"),
automaticCentre(true)
{
automaticCollisionMask(true),
origine("origine"),
centre("centre"),
automaticCentre(true) {
}
Sprite::~Sprite()
{
};
Sprite::~Sprite(){};
void Sprite::AddPoint( const Point & point )
{
if ( !HasPoint(point.GetName()))
points.push_back(point);
void Sprite::AddPoint(const Point& point) {
if (!HasPoint(point.GetName())) points.push_back(point);
}
void Sprite::DelPoint( const gd::String & name )
{
for (std::size_t i = 0;i<points.size();++i)
{
if ( name == points[i].GetName() )
points.erase(points.begin() + i);
}
void Sprite::DelPoint(const gd::String& name) {
for (std::size_t i = 0; i < points.size(); ++i) {
if (name == points[i].GetName()) points.erase(points.begin() + i);
}
}
bool Sprite::HasPoint( const gd::String & name ) const
{
if (name == "Origin") return true;
if (name == "Centre" || name == "Center") return true;
bool Sprite::HasPoint(const gd::String& name) const {
if (name == "Origin") return true;
if (name == "Centre" || name == "Center") return true;
for (std::size_t i = 0;i<points.size();++i)
{
if ( name == points[i].GetName() )
return true;
}
for (std::size_t i = 0; i < points.size(); ++i) {
if (name == points[i].GetName()) return true;
}
return false;
return false;
}
const Point & Sprite::GetPoint( const gd::String & name) const
{
if (name == "Origin") return origine;
if (name == "Centre" || name == "Center") return centre;
const Point& Sprite::GetPoint(const gd::String& name) const {
if (name == "Origin") return origine;
if (name == "Centre" || name == "Center") return centre;
for (std::size_t i = 0;i<points.size();++i)
{
if ( name == points[i].GetName() )
return points[i];
}
for (std::size_t i = 0; i < points.size(); ++i) {
if (name == points[i].GetName()) return points[i];
}
return badPoint;
return badPoint;
}
Point & Sprite::GetPoint(const gd::String & name)
{
if (name == "Origin") return origine;
if (name == "Centre" || name == "Center") return centre;
Point& Sprite::GetPoint(const gd::String& name) {
if (name == "Origin") return origine;
if (name == "Centre" || name == "Center") return centre;
for (std::size_t i = 0;i<points.size();++i)
{
if ( name == points[i].GetName() )
return points[i];
}
for (std::size_t i = 0; i < points.size(); ++i) {
if (name == points[i].GetName()) return points[i];
}
return badPoint;
return badPoint;
}
bool Sprite::SetDefaultCenterPoint(bool enabled) {
automaticCentre = enabled;
bool Sprite::SetDefaultCenterPoint(bool enabled)
{
automaticCentre = enabled;
#if !defined(EMSCRIPTEN)
if ( automaticCentre )
centre.SetXY(sfmlSprite.getLocalBounds().width/2, sfmlSprite.getLocalBounds().height/2);
#endif
return true;
}
std::vector<Polygon2d> Sprite::GetCollisionMask() const
{
#if !defined(EMSCRIPTEN)
if ( automaticCollisionMask )
{
std::vector<Polygon2d> mask;
Polygon2d rectangle;
rectangle.vertices.push_back(sf::Vector2f(0, 0));
rectangle.vertices.push_back(sf::Vector2f(sfmlSprite.getLocalBounds().width, 0));
rectangle.vertices.push_back(sf::Vector2f(sfmlSprite.getLocalBounds().width, sfmlSprite.getLocalBounds().height));
rectangle.vertices.push_back(sf::Vector2f(0, sfmlSprite.getLocalBounds().height));
mask.push_back(rectangle);
return mask;
}
if (automaticCentre)
centre.SetXY(sfmlSprite.getLocalBounds().width / 2,
sfmlSprite.getLocalBounds().height / 2);
#endif
return customCollisionMask;
return true;
}
void Sprite::SetCustomCollisionMask(const std::vector<Polygon2d> & collisionMask)
{
customCollisionMask = collisionMask;
std::vector<Polygon2d> Sprite::GetCollisionMask() const {
// TODO(perf): Cache to avoid re-creating a mask at every call
#if !defined(EMSCRIPTEN)
if (automaticCollisionMask) {
std::vector<Polygon2d> mask;
Polygon2d rectangle;
rectangle.vertices.push_back(sf::Vector2f(0, 0));
rectangle.vertices.push_back(
sf::Vector2f(sfmlSprite.getLocalBounds().width, 0));
rectangle.vertices.push_back(sf::Vector2f(
sfmlSprite.getLocalBounds().width, sfmlSprite.getLocalBounds().height));
rectangle.vertices.push_back(
sf::Vector2f(0, sfmlSprite.getLocalBounds().height));
mask.push_back(rectangle);
return mask;
}
#endif
return customCollisionMask;
}
void Sprite::SetCustomCollisionMask(
const std::vector<Polygon2d>& collisionMask) {
customCollisionMask = collisionMask;
}
#if !defined(EMSCRIPTEN)
void Sprite::LoadImage(std::shared_ptr<SFMLTextureWrapper> image_)
{
sfmlImage = image_;
sfmlSprite.setTexture(sfmlImage->texture, true);
hasItsOwnImage = false;
void Sprite::LoadImage(std::shared_ptr<SFMLTextureWrapper> image_) {
sfmlImage = image_;
sfmlSprite.setTexture(sfmlImage->texture, true);
hasItsOwnImage = false;
if ( automaticCentre )
centre.SetXY(sfmlSprite.getLocalBounds().width/2, sfmlSprite.getLocalBounds().height/2);
if (automaticCentre)
centre.SetXY(sfmlSprite.getLocalBounds().width / 2,
sfmlSprite.getLocalBounds().height / 2);
}
void Sprite::MakeSpriteOwnsItsImage()
{
if ( !hasItsOwnImage || sfmlImage == std::shared_ptr<SFMLTextureWrapper>() )
{
sfmlImage = std::make_shared<SFMLTextureWrapper>(sfmlImage->texture); //Copy the texture.
sfmlSprite.setTexture(sfmlImage->texture);
hasItsOwnImage = true;
}
void Sprite::MakeSpriteOwnsItsImage() {
if (!hasItsOwnImage || sfmlImage == std::shared_ptr<SFMLTextureWrapper>()) {
sfmlImage = std::make_shared<SFMLTextureWrapper>(
sfmlImage->texture); // Copy the texture.
sfmlSprite.setTexture(sfmlImage->texture);
hasItsOwnImage = true;
}
}
#endif
}
} // namespace gd

View File

@@ -1,21 +1,20 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef SPRITE_H
#define SPRITE_H
#include "GDCore/String.h"
#include <memory>
#include <SFML/Graphics/Sprite.hpp>
#include <memory>
#include "GDCore/Extensions/Builtin/SpriteExtension/Point.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Polygon2d.h"
#include "GDCore/String.h"
class SFMLTextureWrapper;
#undef LoadImage //prevent windows.h to be polluting everything
#undef LoadImage // prevent windows.h to be polluting everything
namespace gd
{
namespace gd {
/**
* \brief Represents a sprite to be displayed on the screen.
@@ -27,180 +26,205 @@ namespace gd
* \see SpriteObject
* \ingroup SpriteObjectExtension
*/
class GD_CORE_API Sprite
{
public:
Sprite();
virtual ~Sprite();
class GD_CORE_API Sprite {
public:
Sprite();
virtual ~Sprite();
/**
* \brief Change the name of the sprite image.
*/
inline void SetImageName(const gd::String & image_) { image = image_; }
/**
* \brief Change the name of the sprite image.
*/
inline void SetImageName(const gd::String& image_) { image = image_; }
/**
* \brief Get the name of the sprite image.
*/
inline const gd::String & GetImageName() const { return image; }
/**
* \brief Get the name of the sprite image.
*/
inline const gd::String& GetImageName() const { return image; }
/**
* \brief Get the name of the sprite image.
*/
inline gd::String & GetImageName() { return image; }
/**
* \brief Get the name of the sprite image.
*/
inline gd::String& GetImageName() { return image; }
/**
* \brief Get the collision mask (custom or automatically generated owing to IsCollisionMaskAutomatic())
*
* \warning If the image has not been loaded ( using LoadImage ) and the collision mask is set as automatic,
* the returned mask won't be correct.
*/
std::vector<Polygon2d> GetCollisionMask() const;
/**
* \brief Get the collision mask (custom or automatically generated owing to
* IsCollisionMaskAutomatic())
*
* \warning If the image has not been loaded ( using LoadImage ) and the
* collision mask is set as automatic, the returned mask won't be correct.
*/
std::vector<Polygon2d> GetCollisionMask() const;
/**
* \brief Set the custom collision mask.
* Call then `SetCollisionMaskAutomatic(false)` to use it.
*/
void SetCustomCollisionMask(const std::vector<Polygon2d> & collisionMask);
/**
* \brief Get the custom collision mask.
*/
std::vector<Polygon2d>& GetCustomCollisionMask() {
return customCollisionMask;
};
/**
* \brief Return true if the collision mask is a bounding box, false if a custom collision mask is used.
*/
inline bool IsCollisionMaskAutomatic() const { return automaticCollisionMask; }
/**
* \brief Get the custom collision mask.
*/
const std::vector<Polygon2d>& GetCustomCollisionMask() const {
return customCollisionMask;
};
/**
* \brief Un/set use of the custom collision mask.
*/
inline void SetCollisionMaskAutomatic(bool enabled) { automaticCollisionMask = enabled; };
/**
* \brief Set the custom collision mask.
* Call then `SetCollisionMaskAutomatic(false)` to use it.
*/
void SetCustomCollisionMask(const std::vector<Polygon2d>& collisionMask);
/**
* \brief Return all points, excluding origin and center.
*/
inline std::vector < Point > & GetAllNonDefaultPoints() { return points; }
/**
* \brief Return true if the collision mask is a bounding box, false if a
* custom collision mask is used.
*/
inline bool IsCollisionMaskAutomatic() const {
return automaticCollisionMask;
}
/**
* \brief Return all points, excluding origin and center.
*/
inline const std::vector < Point > & GetAllNonDefaultPoints() const { return points; }
/**
* \brief Un/set use of the custom collision mask.
*/
inline void SetCollisionMaskAutomatic(bool enabled) {
automaticCollisionMask = enabled;
};
/**
* \brief Add a point
*/
void AddPoint( const Point & point );
/**
* \brief Return all points, excluding origin and center.
*/
inline std::vector<Point>& GetAllNonDefaultPoints() { return points; }
/**
* \brief Delete a point
*/
void DelPoint( const gd::String & name );
/**
* \brief Return all points, excluding origin and center.
*/
inline const std::vector<Point>& GetAllNonDefaultPoints() const {
return points;
}
/**
* \brief Get the specified point.
*/
const Point & GetPoint( const gd::String & name) const;
/**
* \brief Add a point
*/
void AddPoint(const Point& point);
/**
* \brief Get the specified point.
*/
Point & GetPoint(const gd::String & name);
/**
* \brief Delete a point
*/
void DelPoint(const gd::String& name);
/**
* \brief Return true if the point exists.
*/
bool HasPoint( const gd::String & name ) const;
/**
* \brief Get the specified point.
*/
const Point& GetPoint(const gd::String& name) const;
/**
* \brief Return Origin point.
*/
inline const Point & GetOrigin() const { return origine; }
/**
* \brief Get the specified point.
*/
Point& GetPoint(const gd::String& name);
/**
* \brief Return Origin point.
*/
inline Point & GetOrigin() { return origine; }
/**
* \brief Return true if the point exists.
*/
bool HasPoint(const gd::String& name) const;
/**
* \brief Return Center point.
*
* \warning If the image has not been loaded (using LoadImage) and the center point is set as automatic,
* the returned point won't be correct.
*/
inline const Point & GetCenter() const { return centre; }
/**
* \brief Return Origin point.
*/
inline const Point& GetOrigin() const { return origine; }
/**
* \brief Return Center point.
*
* \warning If the image has not been loaded (using LoadImage) and the center point is set as automatic,
* the returned point won't be correct.
*/
inline Point & GetCenter() { return centre; }
/**
* \brief Return Origin point.
*/
inline Point& GetOrigin() { return origine; }
/**
* \brief Return true if the center point is automatically computed.
*/
inline bool IsDefaultCenterPoint() const { return automaticCentre; }
/**
* \brief Return Center point.
*
* \warning If the image has not been loaded (using LoadImage) and the center
* point is set as automatic, the returned point won't be correct.
*/
inline const Point& GetCenter() const { return centre; }
/**
* \brief Un/set center as being automatically computed.
*/
bool SetDefaultCenterPoint(bool enabled);
/**
* \brief Return Center point.
*
* \warning If the image has not been loaded (using LoadImage) and the center
* point is set as automatic, the returned point won't be correct.
*/
inline Point& GetCenter() { return centre; }
#if !defined(EMSCRIPTEN)
/** \name Sprite runtime management
* Functions used by the C++ game engine.
*/
///@{
/**
* \brief Get the SFML sprite associated with the sprite
*/
inline const sf::Sprite & GetSFMLSprite() const { return sfmlSprite; }
/**
* \brief Return true if the center point is automatically computed.
*/
inline bool IsDefaultCenterPoint() const { return automaticCentre; }
/**
* \brief Get the SFML sprite associated with the sprite
*/
inline sf::Sprite & GetSFMLSprite() { return sfmlSprite; }
/**
* \brief Un/set center as being automatically computed.
*/
bool SetDefaultCenterPoint(bool enabled);
/**
* \brief Set the SFML texture of the sprite
*/
void LoadImage(std::shared_ptr<SFMLTextureWrapper> image);
#if !defined(EMSCRIPTEN)
/** \name Sprite runtime management
* Functions used by the C++ game engine.
*/
///@{
/**
* \brief Get the SFML sprite associated with the sprite
*/
inline const sf::Sprite& GetSFMLSprite() const { return sfmlSprite; }
/**
* \brief Get SFML texture used by the sprite
*/
std::shared_ptr<SFMLTextureWrapper> GetSFMLTexture() { return sfmlImage; };
/**
* \brief Get the SFML sprite associated with the sprite
*/
inline sf::Sprite& GetSFMLSprite() { return sfmlSprite; }
/**
* \brief Get SFML texture used by the sprite
*/
const std::shared_ptr<SFMLTextureWrapper> GetSFMLTexture() const { return sfmlImage; };
/**
* \brief Set the SFML texture of the sprite
*/
void LoadImage(std::shared_ptr<SFMLTextureWrapper> image);
/**
* \brief Make the sprite, if it uses a texture from ImageManager,
* copy this texture and take ownership of it.
*/
void MakeSpriteOwnsItsImage();
///@}
#endif
/**
* \brief Get SFML texture used by the sprite
*/
std::shared_ptr<SFMLTextureWrapper> GetSFMLTexture() { return sfmlImage; };
private:
/**
* \brief Get SFML texture used by the sprite
*/
const std::shared_ptr<SFMLTextureWrapper> GetSFMLTexture() const {
return sfmlImage;
};
#if !defined(EMSCRIPTEN)
sf::Sprite sfmlSprite; ///< Displayed SFML sprite
std::shared_ptr<SFMLTextureWrapper> sfmlImage; ///< Pointer to the image displayed by the sprite.
bool hasItsOwnImage; ///< True if sfmlImage is only owned by this Sprite.
#endif
gd::String image; ///< Name of the image to be loaded in Image Manager.
/**
* \brief Make the sprite, if it uses a texture from ImageManager,
* copy this texture and take ownership of it.
*/
void MakeSpriteOwnsItsImage();
///@}
#endif
bool automaticCollisionMask; ///< True to use the custom collision mask. Otherwise, a basic bounding box is returned by GetCollisionMask()
std::vector<Polygon2d> customCollisionMask; ///< Custom collision mask
private:
#if !defined(EMSCRIPTEN)
sf::Sprite sfmlSprite; ///< Displayed SFML sprite
std::shared_ptr<SFMLTextureWrapper>
sfmlImage; ///< Pointer to the image displayed by the sprite.
bool hasItsOwnImage; ///< True if sfmlImage is only owned by this Sprite.
#endif
gd::String image; ///< Name of the image to be loaded in Image Manager.
std::vector < Point > points; ///< List of the points used by the sprite
Point origine; ///< Origin point
Point centre; ///< Center point
bool automaticCentre; ///< True to let the sprite compute its center
bool automaticCollisionMask; ///< True to use the custom collision mask.
///< Otherwise, a basic bounding box is returned
///< by GetCollisionMask()
std::vector<Polygon2d> customCollisionMask; ///< Custom collision mask
static Point badPoint; ///< Returned when no other valid Point object is available.
std::vector<Point> points; ///< List of the points used by the sprite
Point origine; ///< Origin point
Point centre; ///< Center point
bool automaticCentre; ///< True to let the sprite compute its center
static Point
badPoint; ///< Returned when no other valid Point object is available.
};
}
#endif // SPRITE_H
} // namespace gd
#endif // SPRITE_H

View File

@@ -1,213 +1,220 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the GNU Lesser General Public LicenFse.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the GNU Lesser General Public
* LicenFse.
*/
#include "GDCore/Extensions/Builtin/AllBuiltinExtensions.h"
#include "GDCore/Tools/Localization.h"
#include "GDCore/Project/Object.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
#include "GDCore/Project/Object.h"
#include "GDCore/Tools/Localization.h"
using namespace std;
namespace gd
{
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::PlatformExtension & extension)
{
extension.SetExtensionInformation("Sprite",
_("Sprite"),
_("Extension for adding animated objects in the scene, which can contain animations with directions within each."),
"Florian Rival",
"Open source (MIT License)");
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
gd::PlatformExtension& extension) {
extension.SetExtensionInformation(
"Sprite",
_("Sprite"),
_("Extension for adding animated objects in the scene, which can contain "
"animations with directions within each."),
"Florian Rival",
"Open source (MIT License)");
gd::ObjectMetadata & obj = extension.AddObject<SpriteObject>(
"Sprite",
_("Sprite"),
_("Animated object which can be used for most elements of a game"),
"CppPlatform/Extensions/spriteicon.png");
gd::ObjectMetadata& obj = extension.AddObject<SpriteObject>(
"Sprite",
_("Sprite"),
_("Animated object which can be used for most elements of a game"),
"CppPlatform/Extensions/spriteicon.png");
#if defined(GD_IDE_ONLY)
obj.AddAction("Opacity",
_("Change object's opacity"),
_("Change the opacity of an object."),
_("Do _PARAM1__PARAM2_ to the opacity of _PARAM0_"),
_("Visibility"),
"res/actions/opacity24.png",
"res/actions/opacity.png")
#if defined(GD_IDE_ONLY)
obj.AddAction("Opacity",
_("Change object's opacity"),
_("Change the opacity of an object."),
_("Do _PARAM1__PARAM2_ to the opacity of _PARAM0_"),
_("Visibility"),
"res/actions/opacity24.png",
"res/actions/opacity.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsSimple()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsSimple()
.SetManipulatedType("number");
obj.AddAction("ChangeAnimation",
_("Change the animation"),
_("Change the animation of the object, using the animation number in the animations list."),
_("Do _PARAM1__PARAM2_ to the number of current animation of _PARAM0_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
obj.AddAction("ChangeAnimation",
_("Change the animation"),
_("Change the animation of the object, using the animation "
"number in the animations list."),
_("Do _PARAM1__PARAM2_ to the number of current animation of "
"_PARAM0_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsSimple()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsSimple()
.SetManipulatedType("number");
obj.AddAction("SetAnimationName",
_("Change the animation (by name)"),
_("Change the animation of the object, using the name of the animation."),
_("Set animation of _PARAM0_ to _PARAM1_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
obj.AddAction("SetAnimationName",
_("Change the animation (by name)"),
_("Change the animation of the object, using the name of the "
"animation."),
_("Set animation of _PARAM0_ to _PARAM1_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("string", _("Animation name"))
.MarkAsAdvanced();
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("string", _("Animation name"))
.MarkAsAdvanced();
obj.AddAction("ChangeDirection",
_("Change the direction"),
_("Change the direction of the object.\nIf the object is set to automatically rotate, the direction is its angle.\nIf the object is in 8 directions mode, the valid directions are 0..7"),
_("Do _PARAM1__PARAM2_ to the direction of _PARAM0_"),
_("Direction"),
"res/actions/direction24.png",
"res/actions/direction.png")
obj.AddAction(
"ChangeDirection",
_("Change the direction"),
_("Change the direction of the object.\nIf the object is set to "
"automatically rotate, the direction is its angle.\nIf the object "
"is in 8 directions mode, the valid directions are 0..7"),
_("Do _PARAM1__PARAM2_ to the direction of _PARAM0_"),
_("Direction"),
"res/actions/direction24.png",
"res/actions/direction.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddAction("ChangeSprite",
_("Current frame"),
_("Modify the current frame of the object"),
_("Do _PARAM1__PARAM2_ to animation frame of _PARAM0_"),
_("Animations and images"),
"res/actions/sprite24.png",
"res/actions/sprite.png")
obj.AddAction("ChangeSprite",
_("Current frame"),
_("Modify the current frame of the object"),
_("Do _PARAM1__PARAM2_ to animation frame of _PARAM0_"),
_("Animations and images"),
"res/actions/sprite24.png",
"res/actions/sprite.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddAction("PauseAnimation",
_("Pause the animation"),
_("Pause the current animation of the object"),
_("Pause the current animation of _PARAM0_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
obj.AddAction("PauseAnimation",
_("Pause the animation"),
_("Pause the current animation of the object"),
_("Pause the current animation of _PARAM0_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.MarkAsSimple();
.AddParameter("object", _("Object"), "Sprite")
.MarkAsSimple();
obj.AddAction("PlayAnimation",
_("Play the animation"),
_("Play the current animation of the object"),
_("Play the current animation of _PARAM0_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.MarkAsSimple();
obj.AddAction("PlayAnimation",
_("Play the animation"),
_("Play the current animation of the object"),
_("Play the current animation of _PARAM0_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
obj.AddAction(
"ChangeAnimationSpeedScale",
_("Animation speed scale"),
_("Modify the animation speed scale (1 = the default speed, >1 = "
"faster and <1 = slower)."),
_("Do _PARAM1__PARAM2_ to the animation speed scale of _PARAM0_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.MarkAsSimple();
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsSimple()
.SetManipulatedType("number");
obj.AddAction("ChangeAnimationSpeedScale",
_("Animation speed scale"),
_("Modify the animation speed scale (1 = the default speed, >1 = faster and <1 = slower)."),
_("Do _PARAM1__PARAM2_ to the animation speed scale of _PARAM0_"),
_("Animations and images"),
"res/actions/animation24.png",
"res/actions/animation.png")
obj.AddAction("TourneVersPos",
_("Rotate an object toward a position"),
_("Rotate an object towards a position."),
_("Rotate _PARAM0_ towards _PARAM1_;_PARAM2_"),
_("Direction"),
"res/actions/direction24.png",
"res/actions/direction.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsSimple()
.SetManipulatedType("number");
.AddParameter("object", _("Object to be rotated"), "Sprite")
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("expression", _("Angular speed (degrees per second)"))
.SetDefaultValue("0")
.AddCodeOnlyParameter("currentScene", "")
.SetHidden(); // Deprecated
obj.AddAction("TourneVersPos",
_("Rotate an object toward a position"),
_("Rotate an object towards a position."),
_("Rotate _PARAM0_ towards _PARAM1_;_PARAM2_"),
_("Direction"),
"res/actions/direction24.png",
"res/actions/direction.png")
obj.AddAction("ChangeScale",
_("Scale"),
_("Modify the scale of the specified object."),
_("Do _PARAM1__PARAM2_ to the scale of _PARAM0_"),
_("Size"),
"res/actions/scale24.png",
"res/actions/scale.png")
.AddParameter("object", _("Object to be rotated"), "Sprite")
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("expression", _("Angular speed (degrees per second)")).SetDefaultValue("0")
.AddCodeOnlyParameter("currentScene", "")
.SetHidden(); //Deprecated
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced();
obj.AddAction("ChangeScaleWidth",
_("Scale on X axis"),
_("Modify the scale of the width of an object."),
_("Do _PARAM1__PARAM2_ to the width's scale of _PARAM0_"),
_("Size"),
"res/actions/scale24.png",
"res/actions/scale.png")
obj.AddAction("ChangeScale",
_("Scale"),
_("Modify the scale of the specified object."),
_("Do _PARAM1__PARAM2_ to the scale of _PARAM0_"),
_("Size"),
"res/actions/scale24.png",
"res/actions/scale.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced();
obj.AddAction("ChangeScaleHeight",
_("Scale on Y axis"),
_("Modify the scale of the height of an object."),
_("Do _PARAM1__PARAM2_ to the height's scale of _PARAM0_"),
_("Size"),
"res/actions/scale24.png",
"res/actions/scale.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddAction("ChangeScaleWidth",
_("Scale on X axis"),
_("Modify the scale of the width of an object."),
_("Do _PARAM1__PARAM2_ to the width's scale of _PARAM0_"),
_("Size"),
"res/actions/scale24.png",
"res/actions/scale.png")
obj.AddCondition(
"Animation",
_("Current animation"),
_("Compare the number of the current animation of the object."),
_("The number of the current animation of _PARAM0_ is "
"_PARAM1__PARAM2_"),
_("Animations and images"),
"res/conditions/animation24.png",
"res/conditions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Number to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddAction("ChangeScaleHeight",
_("Scale on Y axis"),
_("Modify the scale of the height of an object."),
_("Do _PARAM1__PARAM2_ to the height's scale of _PARAM0_"),
_("Size"),
"res/actions/scale24.png",
"res/actions/scale.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Value"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddCondition("Animation",
_("Current animation"),
_("Compare the number of the current animation of the object."),
_("The number of the current animation of _PARAM0_ is _PARAM1__PARAM2_"),
_("Animations and images"),
"res/conditions/animation24.png",
"res/conditions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Number to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddCondition("AnimationName",
obj.AddCondition("AnimationName",
_("Current animation name"),
_("Check the current animation of the object."),
_("The animation of _PARAM0_ is _PARAM1_"),
@@ -215,24 +222,27 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::Pla
"res/conditions/animation24.png",
"res/conditions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("string", _("Animation name"))
.MarkAsAdvanced();
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("string", _("Animation name"))
.MarkAsAdvanced();
obj.AddCondition("Direction",
_("Current direction"),
_("Compare the direction of the object. If 8 direction mode is activated for the sprite, the value taken for direction will be from 0 to 7. Otherwise, the direction is in degrees."),
_("Direction of _PARAM0_ is _PARAM1__PARAM2_"),
_("Direction"),
"res/conditions/direction24.png",
"res/conditions/direction.png")
obj.AddCondition(
"Direction",
_("Current direction"),
_("Compare the direction of the object. If 8 direction mode is "
"activated for the sprite, the value taken for direction will be "
"from 0 to 7. Otherwise, the direction is in degrees."),
_("Direction of _PARAM0_ is _PARAM1__PARAM2_"),
_("Direction"),
"res/conditions/direction24.png",
"res/conditions/direction.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Direction to test"))
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Direction to test"))
.SetManipulatedType("number");
obj.AddCondition("Sprite",
obj.AddCondition("Sprite",
_("Current frame"),
_("Test the number of the current animation frame."),
_("The animation frame of _PARAM0_ is _PARAM1__PARAM2_"),
@@ -240,13 +250,13 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::Pla
"res/conditions/sprite24.png",
"res/conditions/sprite.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Animation frame to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Animation frame to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddCondition("AnimStopped",
obj.AddCondition("AnimStopped",
_("Animation paused"),
_("Test if the animation of an object is paused"),
_("The animation of _PARAM0_ is paused"),
@@ -254,21 +264,22 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::Pla
"res/conditions/animation24.png",
"res/conditions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.MarkAsSimple();
.AddParameter("object", _("Object"), "Sprite")
.MarkAsSimple();
obj.AddCondition("AnimationEnded",
obj.AddCondition("AnimationEnded",
_("Animation finished"),
_("Check if the animation being played by the Sprite object is finished."),
_("Check if the animation being played by the Sprite object "
"is finished."),
_("The animation of _PARAM0_ is finished"),
_("Animations and images"),
"res/conditions/animation24.png",
"res/conditions/animation.png")
.AddParameter("object", _("Object"), "Sprite")
.MarkAsSimple();
.AddParameter("object", _("Object"), "Sprite")
.MarkAsSimple();
obj.AddCondition("ScaleWidth",
obj.AddCondition("ScaleWidth",
_("Scale on X axis"),
_("Compare the scale of the width of an object."),
_("The width's scale of _PARAM0_ is _PARAM1__PARAM2_"),
@@ -276,13 +287,13 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::Pla
"res/conditions/scaleWidth24.png",
"res/conditions/scaleWidth.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddCondition("ScaleHeight",
obj.AddCondition("ScaleHeight",
_("Scale on Y axis"),
_("Compare the scale of the height of an object."),
_("The height's scale of _PARAM0_ is _PARAM1__PARAM2_"),
@@ -290,118 +301,128 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::Pla
"res/conditions/scaleHeight24.png",
"res/conditions/scaleHeight.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddCondition("Opacity",
obj.AddCondition("Opacity",
_("Opacity"),
_("Compare the opacity of an object, between 0 (fully transparent) to 255 (opaque)"),
_("Compare the opacity of an object, between 0 (fully "
"transparent) to 255 (opaque)"),
_("The opacity of _PARAM0_ is _PARAM1__PARAM2_"),
_("Visibility"),
"res/conditions/opacity24.png",
"res/conditions/opacity.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsSimple()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test"))
.MarkAsSimple()
.SetManipulatedType("number");
obj.AddCondition("BlendMode",
_("Blend mode"),
_("Compare the number of the blend mode currently used by an object"),
_("The number of the current blend mode of _PARAM0_ is _PARAM1__PARAM2_"),
_("Effects"),
"res/conditions/opacity24.png",
"res/conditions/opacity.png")
obj.AddCondition(
"BlendMode",
_("Blend mode"),
_("Compare the number of the blend mode currently used by an object"),
_("The number of the current blend mode of _PARAM0_ is "
"_PARAM1__PARAM2_"),
_("Effects"),
"res/conditions/opacity24.png",
"res/conditions/opacity.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("Value to test (0: Alpha, 1: Add, 2: Multiply, 3: None)"))
.MarkAsAdvanced()
.SetManipulatedType("number");
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression",
_("Value to test (0: Alpha, 1: Add, 2: Multiply, 3: None)"))
.MarkAsAdvanced()
.SetManipulatedType("number");
obj.AddAction("CopyImageOnImageOfSprite",
_("Copy an image on the current one of an object"),
_("Copy an image on the current image of an object.\nNote that the source image must be preferably kept loaded in memory."),
_("Copy image _PARAM2_ on the current of _PARAM0_ at _PARAM3_;_PARAM4_"),
_("Effects"),
"res/copy24.png",
"res/copyicon.png")
obj.AddAction("CopyImageOnImageOfSprite",
_("Copy an image on the current one of an object"),
_("Copy an image on the current image of an object.\nNote that "
"the source image must be preferably kept loaded in memory."),
_("Copy image _PARAM2_ on the current of _PARAM0_ at "
"_PARAM3_;_PARAM4_"),
_("Effects"),
"res/copy24.png",
"res/copyicon.png")
.AddParameter("object", _("Object"), "Sprite")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Name of the source image"))
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("yesorno", _("Should the copy take in account the source transparency\?"));
.AddParameter("object", _("Object"), "Sprite")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Name of the source image"))
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter(
"yesorno",
_("Should the copy take in account the source transparency\?"));
obj.AddAction("CreateMaskFromColorOnActualImage", //Actual is indeed a mistake : Current should have been chosen.
_("Make a color of the image of an object transparent"),
_("Make a color of the image of an object transparent."),
_("Make color _PARAM1_ of the current image of _PARAM0_ transparent"),
_("Effects"),
"res/actions/opacity24.png",
"res/actions/opacity.png")
obj.AddAction(
"CreateMaskFromColorOnActualImage", // Actual is indeed a mistake :
// Current should have been
// chosen.
_("Make a color of the image of an object transparent"),
_("Make a color of the image of an object transparent."),
_("Make color _PARAM1_ of the current image of _PARAM0_ transparent"),
_("Effects"),
"res/actions/opacity24.png",
"res/actions/opacity.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("color", _("Color to make transparent"));
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("color", _("Color to make transparent"));
obj.AddAction(
"ChangeColor",
_("Global color"),
_("Change the global color of an object. The default color is white."),
_("Change color of _PARAM0_ to _PARAM1_"),
_("Effects"),
"res/actions/color24.png",
"res/actions/color.png")
obj.AddAction("ChangeColor",
_("Global color"),
_("Change the global color of an object. The default color is white."),
_("Change color of _PARAM0_ to _PARAM1_"),
_("Effects"),
"res/actions/color24.png",
"res/actions/color.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("color", _("Color"));
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("color", _("Color"));
obj.AddAction("ChangeBlendMode",
_("Blend mode"),
_("Change the number of the blend mode of an object.\nThe "
"default blend mode is 0 (Alpha)."),
_("Change Blend mode of _PARAM0_ to _PARAM1_"),
_("Effects"),
"res/actions/color24.png",
"res/actions/color.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("expression",
_("Mode (0 : Alpha, 1 : Add, 2 : Multiply, 3 : None)"))
.MarkAsSimple();
obj.AddAction("ChangeBlendMode",
_("Blend mode"),
_("Change the number of the blend mode of an object.\nThe default blend mode is 0 (Alpha)."),
_("Change Blend mode of _PARAM0_ to _PARAM1_"),
_("Effects"),
"res/actions/color24.png",
"res/actions/color.png")
obj.AddAction("FlipX",
_("Flip the object horizontally"),
_("Flip the object horizontally"),
_("Flip horizontally _PARAM0_ : _PARAM1_"),
_("Effects"),
"res/actions/flipX24.png",
"res/actions/flipX.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("expression", _("Mode (0 : Alpha, 1 : Add, 2 : Multiply, 3 : None)"))
.MarkAsSimple();
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("yesorno", _("Activate flipping"))
.MarkAsSimple();
obj.AddAction("FlipY",
_("Flip the object vertically"),
_("Flip the object vertically"),
_("Flip vertically _PARAM0_ : _PARAM1_"),
_("Effects"),
"res/actions/flipY24.png",
"res/actions/flipY.png")
obj.AddAction("FlipX",
_("Flip the object horizontally"),
_("Flip the object horizontally"),
_("Flip horizontally _PARAM0_ : _PARAM1_"),
_("Effects"),
"res/actions/flipX24.png",
"res/actions/flipX.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("yesorno", _("Activate flipping"))
.MarkAsSimple();
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("yesorno", _("Activate flipping"))
.MarkAsSimple();
obj.AddAction("FlipY",
_("Flip the object vertically"),
_("Flip the object vertically"),
_("Flip vertically _PARAM0_ : _PARAM1_"),
_("Effects"),
"res/actions/flipY24.png",
"res/actions/flipY.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("yesorno", _("Activate flipping"))
.MarkAsSimple();
obj.AddCondition("FlippedX",
obj.AddCondition("FlippedX",
_("Horizontally flipped"),
_("Return true if the object is horizontally flipped"),
_("_PARAM0_ is horizontally flipped"),
@@ -409,9 +430,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::Pla
"res/actions/flipX24.png",
"res/actions/flipX.png")
.AddParameter("object", _("Object"), "Sprite");
.AddParameter("object", _("Object"), "Sprite");
obj.AddCondition("FlippedY",
obj.AddCondition("FlippedY",
_("Vertically flipped"),
_("Return true if the object is vertically flipped"),
_("_PARAM0_ is vertically flipped"),
@@ -419,81 +440,142 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::Pla
"res/actions/flipY24.png",
"res/actions/flipY.png")
.AddParameter("object", _("Object"), "Sprite");
.AddParameter("object", _("Object"), "Sprite");
obj.AddAction("TourneVers",
_("Rotate an object toward another"),
_("Rotate an object towards another."),
_("Rotate _PARAM0_ towards _PARAM1_"),
_("Direction"),
"res/actions/direction24.png",
"res/actions/direction.png")
obj.AddAction("TourneVers",
_("Rotate an object toward another"),
_("Rotate an object towards another."),
_("Rotate _PARAM0_ towards _PARAM1_"),
_("Direction"),
"res/actions/direction24.png",
"res/actions/direction.png")
.AddParameter("object", _("Object to be rotated"), "Sprite")
.AddParameter("objectPtr", _("Rotate toward this object"))
.AddCodeOnlyParameter("currentScene", "")
.SetHidden(); //Deprecated
.AddParameter("object", _("Object to be rotated"), "Sprite")
.AddParameter("objectPtr", _("Rotate toward this object"))
.AddCodeOnlyParameter("currentScene", "")
.SetHidden(); // Deprecated
obj.AddExpression("X", _("X position of a point"), _("X position of a point"), _("Position"), "res/actions/position.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("", _("Name of the point"), "", true);
obj.AddExpression("X",
_("X position of a point"),
_("X position of a point"),
_("Position"),
"res/actions/position.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("", _("Name of the point"), "", true);
obj.AddExpression("Y", _("Y position of a point"), _("Y position of a point"), _("Position"), "res/actions/position.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("", _("Name of the point"), "", true);
obj.AddExpression("Y",
_("Y position of a point"),
_("Y position of a point"),
_("Position"),
"res/actions/position.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("", _("Name of the point"), "", true);
obj.AddExpression("PointX", _("X position of a point"), _("X position of a point"), _("Position"), "res/actions/position.png")
obj.AddExpression("PointX",
_("X position of a point"),
_("X position of a point"),
_("Position"),
"res/actions/position.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("", _("Name of the point"));
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("", _("Name of the point"));
obj.AddExpression("PointY", _("Y position of a point"), _("Y position of a point"), _("Position"), "res/actions/position.png")
obj.AddExpression("PointY",
_("Y position of a point"),
_("Y position of a point"),
_("Position"),
"res/actions/position.png")
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("", _("Name of the point"));
.AddParameter("object", _("Object"), "Sprite")
.AddParameter("", _("Name of the point"));
obj.AddExpression("Direc", _("Direction"), _("Direction of the object"), _("Direction"), "res/actions/direction.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Direc",
_("Direction"),
_("Direction of the object"),
_("Direction"),
"res/actions/direction.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Direction", _("Direction"), _("Direction of the object"), _("Direction"), "res/actions/direction.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Direction",
_("Direction"),
_("Direction of the object"),
_("Direction"),
"res/actions/direction.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Anim", _("Animation"), _("Animation of the object"), _("Animations and images"), "res/actions/animation.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Anim",
_("Animation"),
_("Animation of the object"),
_("Animations and images"),
"res/actions/animation.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Animation", _("Animation"), _("Animation of the object"), _("Animations and images"), "res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Animation",
_("Animation"),
_("Animation of the object"),
_("Animations and images"),
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddStrExpression("AnimationName", _("Animation name"), _("Name of the animation of the object"), _("Animations and images"), "res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddStrExpression("AnimationName",
_("Animation name"),
_("Name of the animation of the object"),
_("Animations and images"),
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Sprite", _("Image"), _("Animation frame of the object"), _("Animations and images"), "res/actions/sprite.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("Sprite",
_("Image"),
_("Animation frame of the object"),
_("Animations and images"),
"res/actions/sprite.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("AnimationSpeedScale", _("Animation speed scale"), _("Animation speed scale"), _("Animations and images"), "res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("AnimationSpeedScale",
_("Animation speed scale"),
_("Animation speed scale"),
_("Animations and images"),
"res/actions/animation.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("ScaleX", _("Scale of the width of an object"), _("Scale of the width of an object"), _("Size"), "res/actions/scaleWidth.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("ScaleX",
_("Scale of the width of an object"),
_("Scale of the width of an object"),
_("Size"),
"res/actions/scaleWidth.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("ScaleY", _("Scale of the height of an object"), _("Scale of the height of an object"), _("Size"), "res/actions/scaleHeight.png")
.AddParameter("object", _("Object"), "Sprite");
obj.AddExpression("ScaleY",
_("Scale of the height of an object"),
_("Scale of the height of an object"),
_("Size"),
"res/actions/scaleHeight.png")
.AddParameter("object", _("Object"), "Sprite");
extension.AddCondition("Collision",
_("Collision (Pixel perfect)"),
_("The condition is true if there is a collision between the two objects.\nThe test is pixel-perfect."),
_("_PARAM0_ is in collision with _PARAM1_ (pixel perfect)"),
_("Collision"),
"res/conditions/collision24.png",
"res/conditions/collision.png")
.AddParameter("objectList", _("Object 1"), "Sprite")
.AddParameter("objectList", _("Object 2"), "Sprite")
.AddCodeOnlyParameter("conditionInverted", "");
#endif
obj.AddExpression("Opacity",
_("Opacity"),
_("Opacity"),
_("Opacity"),
"res/actions/opacity.png")
.AddParameter("object", _("Object"), "Sprite");
extension
.AddCondition("Collision",
_("Collision (Pixel perfect)"),
_("The condition is true if there is a collision between "
"the two objects.\nThe test is pixel-perfect."),
_("_PARAM0_ is in collision with _PARAM1_ (pixel perfect)"),
_("Collision"),
"res/conditions/collision24.png",
"res/conditions/collision.png")
.AddParameter("objectList", _("Object 1"), "Sprite")
.AddParameter("objectList", _("Object 2"), "Sprite")
.AddCodeOnlyParameter("conditionInverted", "");
#endif
}
}
} // namespace gd

View File

@@ -1,329 +1,373 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#include <wx/wx.h> //Must be placed first, otherwise we get nice errors relative to "cannot convert 'const TCHAR*'..." in wx/msw/winundef.h
#include <wx/wx.h> //Must be placed first, otherwise we get nice errors relative to "cannot convert 'const TCHAR*'..." in wx/msw/winundef.h
#endif
#include <algorithm>
#include "GDCore/Tools/Localization.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Animation.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Direction.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Sprite.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/SpriteObject.h"
#include "GDCore/Project/ImageManager.h"
#include "GDCore/Project/InitialInstance.h"
#include "GDCore/Project/Layout.h"
#include "GDCore/Project/Object.h"
#include "GDCore/Project/ImageManager.h"
#include "GDCore/Project/Project.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/Project/InitialInstance.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Tools/Localization.h"
#if defined(GD_IDE_ONLY)
#include <SFML/Graphics.hpp>
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Dialogs/SpriteObjectEditor.h"
#include "GDCore/IDE/Dialogs/MainFrameWrapper.h"
#include "GDCore/IDE/Dialogs/PropertyDescriptor.h"
#include "GDCore/Extensions/Builtin/SpriteExtension/Dialogs/SpriteObjectEditor.h"
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
#endif
namespace gd {
Animation SpriteObject::badAnimation;
SpriteObject::SpriteObject(gd::String name_) :
Object(name_),
updateIfNotVisible(false)
{
}
SpriteObject::SpriteObject(gd::String name_)
: Object(name_), updateIfNotVisible(false) {}
SpriteObject::~SpriteObject()
{
};
SpriteObject::~SpriteObject(){};
void SpriteObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element)
{
updateIfNotVisible = element.GetBoolAttribute("updateIfNotVisible", true);
void SpriteObject::DoUnserializeFrom(gd::Project& project,
const gd::SerializerElement& element) {
updateIfNotVisible = element.GetBoolAttribute("updateIfNotVisible", true);
RemoveAllAnimations();
const gd::SerializerElement & animationsElement = element.GetChild("animations", 0, "Animations");
animationsElement.ConsiderAsArrayOf("animation", "Animation");
for (std::size_t i = 0; i < animationsElement.GetChildrenCount(); ++i)
{
const gd::SerializerElement & animationElement = animationsElement.GetChild(i);
Animation newAnimation;
RemoveAllAnimations();
const gd::SerializerElement& animationsElement =
element.GetChild("animations", 0, "Animations");
animationsElement.ConsiderAsArrayOf("animation", "Animation");
for (std::size_t i = 0; i < animationsElement.GetChildrenCount(); ++i) {
const gd::SerializerElement& animationElement =
animationsElement.GetChild(i);
Animation newAnimation;
newAnimation.useMultipleDirections = animationElement.GetBoolAttribute("useMultipleDirections", false, "typeNormal");
newAnimation.SetName(animationElement.GetStringAttribute("name", ""));
newAnimation.useMultipleDirections = animationElement.GetBoolAttribute(
"useMultipleDirections", false, "typeNormal");
newAnimation.SetName(animationElement.GetStringAttribute("name", ""));
//Compatibility with GD <= 3.3
if (animationElement.HasChild("Direction"))
{
for (std::size_t j = 0; j < animationElement.GetChildrenCount("Direction"); ++j)
{
Direction direction;
direction.UnserializeFrom(animationElement.GetChild("Direction", j));
// Compatibility with GD <= 3.3
if (animationElement.HasChild("Direction")) {
for (std::size_t j = 0;
j < animationElement.GetChildrenCount("Direction");
++j) {
Direction direction;
direction.UnserializeFrom(animationElement.GetChild("Direction", j));
newAnimation.SetDirectionsCount(newAnimation.GetDirectionsCount()+1);
newAnimation.SetDirection(direction, newAnimation.GetDirectionsCount()-1);
}
}
//End of compatibility code
else
{
const gd::SerializerElement & directionsElement = animationElement.GetChild("directions");
directionsElement.ConsiderAsArrayOf("direction");
for (std::size_t j = 0; j < directionsElement.GetChildrenCount(); ++j)
{
Direction direction;
direction.UnserializeFrom(directionsElement.GetChild(j));
newAnimation.SetDirectionsCount(newAnimation.GetDirectionsCount()+1);
newAnimation.SetDirection(direction, newAnimation.GetDirectionsCount()-1);
}
}
AddAnimation( newAnimation );
newAnimation.SetDirectionsCount(newAnimation.GetDirectionsCount() + 1);
newAnimation.SetDirection(direction,
newAnimation.GetDirectionsCount() - 1);
}
}
// End of compatibility code
else {
const gd::SerializerElement& directionsElement =
animationElement.GetChild("directions");
directionsElement.ConsiderAsArrayOf("direction");
for (std::size_t j = 0; j < directionsElement.GetChildrenCount(); ++j) {
Direction direction;
direction.UnserializeFrom(directionsElement.GetChild(j));
newAnimation.SetDirectionsCount(newAnimation.GetDirectionsCount() + 1);
newAnimation.SetDirection(direction,
newAnimation.GetDirectionsCount() - 1);
}
}
AddAnimation(newAnimation);
}
}
#if defined(GD_IDE_ONLY)
void SpriteObject::DoSerializeTo(gd::SerializerElement & element) const
{
element.SetAttribute("updateIfNotVisible", updateIfNotVisible);
void SpriteObject::DoSerializeTo(gd::SerializerElement& element) const {
element.SetAttribute("updateIfNotVisible", updateIfNotVisible);
//Animations
gd::SerializerElement & animationsElement = element.AddChild("animations");
animationsElement.ConsiderAsArrayOf("animation");
for ( std::size_t k = 0;k < GetAnimationsCount();k++ )
{
gd::SerializerElement & animationElement = animationsElement.AddChild("animation");
// Animations
gd::SerializerElement& animationsElement = element.AddChild("animations");
animationsElement.ConsiderAsArrayOf("animation");
for (std::size_t k = 0; k < GetAnimationsCount(); k++) {
gd::SerializerElement& animationElement =
animationsElement.AddChild("animation");
animationElement.SetAttribute( "useMultipleDirections", GetAnimation(k).useMultipleDirections);
animationElement.SetAttribute( "name", GetAnimation(k).GetName());
animationElement.SetAttribute("useMultipleDirections",
GetAnimation(k).useMultipleDirections);
animationElement.SetAttribute("name", GetAnimation(k).GetName());
gd::SerializerElement & directionsElement = animationElement.AddChild("directions");
directionsElement.ConsiderAsArrayOf("direction");
for ( std::size_t l = 0;l < GetAnimation(k).GetDirectionsCount();l++ )
{
GetAnimation(k).GetDirection(l).SerializeTo(directionsElement.AddChild("direction"));
}
gd::SerializerElement& directionsElement =
animationElement.AddChild("directions");
directionsElement.ConsiderAsArrayOf("direction");
for (std::size_t l = 0; l < GetAnimation(k).GetDirectionsCount(); l++) {
GetAnimation(k).GetDirection(l).SerializeTo(
directionsElement.AddChild("direction"));
}
}
}
std::map<gd::String, gd::PropertyDescriptor> SpriteObject::GetProperties(gd::Project & project) const
{
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[_("Animate even if hidden or far from the screen")].SetValue(updateIfNotVisible ? "true" : "false").SetType("Boolean");
properties[_("PLEASE_ALSO_SHOW_EDIT_BUTTON_THANKS")].SetValue("");
std::map<gd::String, gd::PropertyDescriptor> SpriteObject::GetProperties(
gd::Project& project) const {
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[_("Animate even if hidden or far from the screen")]
.SetValue(updateIfNotVisible ? "true" : "false")
.SetType("Boolean");
properties[_("PLEASE_ALSO_SHOW_EDIT_BUTTON_THANKS")].SetValue("");
return properties;
return properties;
}
bool SpriteObject::UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project)
{
if (name == _("Animate even if hidden or far from the screen")) updateIfNotVisible = value == "1";
bool SpriteObject::UpdateProperty(const gd::String& name,
const gd::String& value,
gd::Project& project) {
if (name == _("Animate even if hidden or far from the screen"))
updateIfNotVisible = value == "1";
return true;
return true;
}
#if !defined(EMSCRIPTEN)
void SpriteObject::LoadResources(gd::Project & project, gd::Layout & layout)
{
for ( std::size_t j = 0; j < animations.size();j++ )
{
Animation & anim = animations[j];
for ( std::size_t k = 0;k < anim.GetDirectionsCount();k++ )
{
for ( std::size_t l = 0;l < anim.GetDirection(k).GetSpritesCount();l++ )
{
Sprite & sprite = anim.GetDirection(k).GetSprite(l);
void SpriteObject::LoadResources(gd::Project& project, gd::Layout& layout) {
for (std::size_t j = 0; j < animations.size(); j++) {
Animation& anim = animations[j];
for (std::size_t k = 0; k < anim.GetDirectionsCount(); k++) {
for (std::size_t l = 0; l < anim.GetDirection(k).GetSpritesCount(); l++) {
Sprite& sprite = anim.GetDirection(k).GetSprite(l);
sprite.LoadImage(project.GetImageManager()->GetSFMLTexture(sprite.GetImageName()));
}
}
sprite.LoadImage(
project.GetImageManager()->GetSFMLTexture(sprite.GetImageName()));
}
}
}
}
const Sprite * SpriteObject::GetInitialInstanceSprite(gd::InitialInstance & instance, gd::Project & project, gd::Layout & layout, bool * shouldNotRotate) const
{
if ( HasNoAnimations() ) return NULL;
const Sprite* SpriteObject::GetInitialInstanceSprite(
gd::InitialInstance& instance,
gd::Project& project,
gd::Layout& layout,
bool* shouldNotRotate) const {
if (HasNoAnimations()) return NULL;
//Search the first sprite of the current animation/direction.
std::size_t animationId = instance.floatInfos.find("animation") != instance.floatInfos.end() ? instance.floatInfos.find("animation")->second : 0;
if ( animationId >= GetAnimationsCount() ) animationId = 0;
// Search the first sprite of the current animation/direction.
std::size_t animationId =
instance.floatInfos.find("animation") != instance.floatInfos.end()
? instance.floatInfos.find("animation")->second
: 0;
if (animationId >= GetAnimationsCount()) animationId = 0;
const Animation & animation = GetAnimation(animationId);
if ( animation.HasNoDirections() ) return NULL;
const Animation& animation = GetAnimation(animationId);
if (animation.HasNoDirections()) return NULL;
std::size_t directionId = 0;
if ( animation.useMultipleDirections ) {
std::size_t directionId = 0;
if (animation.useMultipleDirections) {
float normalizedAngle = static_cast<int>(instance.GetAngle()) % 360;
if (normalizedAngle < 0) normalizedAngle += 360;
float normalizedAngle = static_cast<int>(instance.GetAngle())%360;
if ( normalizedAngle < 0 ) normalizedAngle += 360;
directionId = static_cast<int>(gd::Round(normalizedAngle / 45.f)) % 8;
}
directionId = static_cast<int>(gd::Round(normalizedAngle/45.f))%8;
}
if (directionId >= animation.GetDirectionsCount()) directionId = 0;
if ( directionId >= animation.GetDirectionsCount() ) directionId = 0;
const Direction& direction = animation.GetDirection(directionId);
const Direction & direction = animation.GetDirection(directionId);
if ( shouldNotRotate ) *shouldNotRotate = animation.useMultipleDirections;
return direction.HasNoSprites() ? NULL : &direction.GetSprite(0);
if (shouldNotRotate) *shouldNotRotate = animation.useMultipleDirections;
return direction.HasNoSprites() ? NULL : &direction.GetSprite(0);
}
void SpriteObject::DrawInitialInstance(gd::InitialInstance & instance, sf::RenderTarget & renderTarget, gd::Project & project, gd::Layout & layout)
{
bool shouldNotRotate = false;
const Sprite * associatedSprite = GetInitialInstanceSprite(instance, project, layout, &shouldNotRotate);
if ( associatedSprite == NULL || !associatedSprite->GetSFMLTexture() ) return;
void SpriteObject::DrawInitialInstance(gd::InitialInstance& instance,
sf::RenderTarget& renderTarget,
gd::Project& project,
gd::Layout& layout) {
bool shouldNotRotate = false;
const Sprite* associatedSprite =
GetInitialInstanceSprite(instance, project, layout, &shouldNotRotate);
if (associatedSprite == NULL || !associatedSprite->GetSFMLTexture()) return;
sf::Sprite sprite(associatedSprite->GetSFMLTexture()->texture);
sf::Sprite sprite(associatedSprite->GetSFMLTexture()->texture);
float scaleX = instance.HasCustomSize() ? instance.GetCustomWidth()/associatedSprite->GetSFMLTexture()->texture.getSize().x : 1;
float scaleY = instance.HasCustomSize() ? instance.GetCustomHeight()/associatedSprite->GetSFMLTexture()->texture.getSize().y : 1;
float scaleX =
instance.HasCustomSize()
? instance.GetCustomWidth() /
associatedSprite->GetSFMLTexture()->texture.getSize().x
: 1;
float scaleY =
instance.HasCustomSize()
? instance.GetCustomHeight() /
associatedSprite->GetSFMLTexture()->texture.getSize().y
: 1;
sprite.setOrigin( associatedSprite->GetCenter().GetX(), associatedSprite->GetCenter().GetY() ); ;
sprite.setRotation( shouldNotRotate ? 0 : instance.GetAngle() );
sprite.setPosition( instance.GetX() + (associatedSprite->GetCenter().GetX() - associatedSprite->GetOrigin().GetX())*fabs(scaleX),
instance.GetY() + (associatedSprite->GetCenter().GetY() - associatedSprite->GetOrigin().GetY())*fabs(scaleY) );
sprite.setScale(scaleX, scaleY);
sprite.setOrigin(associatedSprite->GetCenter().GetX(),
associatedSprite->GetCenter().GetY());
;
sprite.setRotation(shouldNotRotate ? 0 : instance.GetAngle());
sprite.setPosition(instance.GetX() + (associatedSprite->GetCenter().GetX() -
associatedSprite->GetOrigin().GetX()) *
fabs(scaleX),
instance.GetY() + (associatedSprite->GetCenter().GetY() -
associatedSprite->GetOrigin().GetY()) *
fabs(scaleY));
sprite.setScale(scaleX, scaleY);
renderTarget.draw(sprite);
renderTarget.draw(sprite);
}
sf::Vector2f SpriteObject::GetInitialInstanceDefaultSize(gd::InitialInstance & instance, gd::Project & project, gd::Layout & layout) const
{
const Sprite * associatedSprite = GetInitialInstanceSprite(instance, project, layout);
if ( associatedSprite == NULL || !associatedSprite->GetSFMLTexture() ) return sf::Vector2f(32,32);
sf::Vector2f SpriteObject::GetInitialInstanceDefaultSize(
gd::InitialInstance& instance,
gd::Project& project,
gd::Layout& layout) const {
const Sprite* associatedSprite =
GetInitialInstanceSprite(instance, project, layout);
if (associatedSprite == NULL || !associatedSprite->GetSFMLTexture())
return sf::Vector2f(32, 32);
sf::Vector2u size = associatedSprite->GetSFMLTexture()->texture.getSize();
return sf::Vector2f(size.x, size.y);
sf::Vector2u size = associatedSprite->GetSFMLTexture()->texture.getSize();
return sf::Vector2f(size.x, size.y);
}
sf::Vector2f SpriteObject::GetInitialInstanceOrigin(gd::InitialInstance & instance, gd::Project & project, gd::Layout & layout) const
{
const Sprite * associatedSprite = GetInitialInstanceSprite(instance, project, layout);
if ( associatedSprite == NULL || !associatedSprite->GetSFMLTexture() ) return sf::Vector2f(0,0);
sf::Vector2f SpriteObject::GetInitialInstanceOrigin(
gd::InitialInstance& instance,
gd::Project& project,
gd::Layout& layout) const {
const Sprite* associatedSprite =
GetInitialInstanceSprite(instance, project, layout);
if (associatedSprite == NULL || !associatedSprite->GetSFMLTexture())
return sf::Vector2f(0, 0);
float scaleX = instance.HasCustomSize() ? instance.GetCustomWidth()/associatedSprite->GetSFMLTexture()->texture.getSize().x : 1;
float scaleY = instance.HasCustomSize() ? instance.GetCustomHeight()/associatedSprite->GetSFMLTexture()->texture.getSize().y : 1;
float scaleX =
instance.HasCustomSize()
? instance.GetCustomWidth() /
associatedSprite->GetSFMLTexture()->texture.getSize().x
: 1;
float scaleY =
instance.HasCustomSize()
? instance.GetCustomHeight() /
associatedSprite->GetSFMLTexture()->texture.getSize().y
: 1;
return sf::Vector2f(((float)associatedSprite->GetOrigin().GetX())*fabs(scaleX),
((float)associatedSprite->GetOrigin().GetY())*fabs(scaleY));
return sf::Vector2f(
((float)associatedSprite->GetOrigin().GetX()) * fabs(scaleX),
((float)associatedSprite->GetOrigin().GetY()) * fabs(scaleY));
}
#endif
bool SpriteObject::GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail) const
{
bool SpriteObject::GenerateThumbnail(const gd::Project& project,
wxBitmap& thumbnail) const {
#if !defined(GD_NO_WX_GUI)
//Generate a thumbnail from the first animation
if ( !HasNoAnimations() && !GetAnimation(0).HasNoDirections() && !GetAnimation(0).GetDirection(0).HasNoSprites() )
{
gd::String imageName = GetAnimation(0).GetDirection(0).GetSprite(0).GetImageName();
// Generate a thumbnail from the first animation
if (!HasNoAnimations() && !GetAnimation(0).HasNoDirections() &&
!GetAnimation(0).GetDirection(0).HasNoSprites()) {
gd::String imageName =
GetAnimation(0).GetDirection(0).GetSprite(0).GetImageName();
if ( project.GetResourcesManager().HasResource(imageName) && wxFileExists(project.GetResourcesManager().GetResource(imageName).GetAbsoluteFile(project)) )
{
thumbnail = wxBitmap( project.GetResourcesManager().GetResource(imageName).GetAbsoluteFile(project), wxBITMAP_TYPE_ANY);
if (project.GetResourcesManager().HasResource(imageName) &&
wxFileExists(project.GetResourcesManager()
.GetResource(imageName)
.GetAbsoluteFile(project))) {
thumbnail = wxBitmap(
project.GetResourcesManager().GetResource(imageName).GetAbsoluteFile(
project),
wxBITMAP_TYPE_ANY);
wxImage thumbImage = thumbnail.ConvertToImage();
thumbnail = wxBitmap(thumbImage.Scale(24, 24));
wxImage thumbImage = thumbnail.ConvertToImage();
thumbnail = wxBitmap(thumbImage.Scale(24, 24));
return true;
}
return true;
}
}
#endif
return false;
return false;
}
void SpriteObject::ExposeResources(gd::ArbitraryResourceWorker & worker)
{
for ( std::size_t j = 0; j < GetAnimationsCount();j++ )
{
for ( std::size_t k = 0;k < GetAnimation( j ).GetDirectionsCount();k++ )
{
for ( std::size_t l = 0;l < GetAnimation( j ).GetDirection(k).GetSpritesCount();l++ ) {
worker.ExposeImage(GetAnimation( j ).GetDirection(k).GetSprite(l).GetImageName());
}
}
void SpriteObject::ExposeResources(gd::ArbitraryResourceWorker& worker) {
for (std::size_t j = 0; j < GetAnimationsCount(); j++) {
for (std::size_t k = 0; k < GetAnimation(j).GetDirectionsCount(); k++) {
for (std::size_t l = 0;
l < GetAnimation(j).GetDirection(k).GetSpritesCount();
l++) {
worker.ExposeImage(
GetAnimation(j).GetDirection(k).GetSprite(l).GetImageName());
}
}
}
}
void SpriteObject::EditObject( wxWindow* parent, gd::Project & project, gd::MainFrameWrapper & mainFrameWrapper )
{
void SpriteObject::EditObject(wxWindow* parent,
gd::Project& project,
gd::MainFrameWrapper& mainFrameWrapper) {
#if !defined(GD_NO_WX_GUI)
SpriteObjectEditor dialog( parent, project, *this, mainFrameWrapper );
dialog.ShowModal();
SpriteObjectEditor dialog(parent, project, *this, mainFrameWrapper);
dialog.ShowModal();
#endif
}
std::map<gd::String, gd::PropertyDescriptor>
SpriteObject::GetInitialInstanceProperties(const gd::InitialInstance& position,
gd::Project& project,
gd::Layout& scene) {
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[_("Animation")] =
position.floatInfos.find("animation") != position.floatInfos.end()
? gd::String::From(position.floatInfos.find("animation")->second)
: gd::String("0");
std::map<gd::String, gd::PropertyDescriptor> SpriteObject::GetInitialInstanceProperties(const gd::InitialInstance & position, gd::Project & project, gd::Layout & scene)
{
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[_("Animation")] = position.floatInfos.find("animation") != position.floatInfos.end() ?
gd::String::From(position.floatInfos.find("animation")->second) :
gd::String("0");
return properties;
return properties;
}
bool SpriteObject::UpdateInitialInstanceProperty(gd::InitialInstance & position, const gd::String & name, const gd::String & value, gd::Project & project, gd::Layout & scene)
{
if ( name == _("Animation") ) position.floatInfos["animation"] = value.To<int>();
bool SpriteObject::UpdateInitialInstanceProperty(gd::InitialInstance& position,
const gd::String& name,
const gd::String& value,
gd::Project& project,
gd::Layout& scene) {
if (name == _("Animation"))
position.floatInfos["animation"] = value.To<int>();
return true;
return true;
}
#endif
const Animation & SpriteObject::GetAnimation(std::size_t nb) const
{
if ( nb >= animations.size())
return badAnimation;
const Animation& SpriteObject::GetAnimation(std::size_t nb) const {
if (nb >= animations.size()) return badAnimation;
return animations[nb];
return animations[nb];
}
Animation & SpriteObject::GetAnimation(std::size_t nb)
{
if ( nb >= animations.size())
return badAnimation;
Animation& SpriteObject::GetAnimation(std::size_t nb) {
if (nb >= animations.size()) return badAnimation;
return animations[nb];
return animations[nb];
}
void SpriteObject::AddAnimation(const Animation & animation)
{
animations.push_back(animation);
void SpriteObject::AddAnimation(const Animation& animation) {
animations.push_back(animation);
}
bool SpriteObject::RemoveAnimation(std::size_t nb)
{
if ( nb >= GetAnimationsCount() )
return false;
bool SpriteObject::RemoveAnimation(std::size_t nb) {
if (nb >= GetAnimationsCount()) return false;
animations.erase( animations.begin() + nb );
return true;
animations.erase(animations.begin() + nb);
return true;
}
void SpriteObject::SwapAnimations(std::size_t firstIndex, std::size_t secondIndex)
{
if ( firstIndex < animations.size() && secondIndex < animations.size() && firstIndex != secondIndex)
std::swap(animations[firstIndex], animations[secondIndex]);
void SpriteObject::SwapAnimations(std::size_t firstIndex,
std::size_t secondIndex) {
if (firstIndex < animations.size() && secondIndex < animations.size() &&
firstIndex != secondIndex)
std::swap(animations[firstIndex], animations[secondIndex]);
}
void SpriteObject::MoveAnimation(std::size_t oldIndex, std::size_t newIndex)
{
if ( oldIndex >= animations.size() || newIndex >= animations.size())
return;
void SpriteObject::MoveAnimation(std::size_t oldIndex, std::size_t newIndex) {
if (oldIndex >= animations.size() || newIndex >= animations.size()) return;
auto animation = animations[oldIndex];
animations.erase(animations.begin() + oldIndex);
animations.insert(animations.begin() + newIndex, animation);
auto animation = animations[oldIndex];
animations.erase(animations.begin() + oldIndex);
animations.insert(animations.begin() + newIndex, animation);
}
}
} // namespace gd

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