Compare commits

...

118 Commits

Author SHA1 Message Date
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
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
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
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
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
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
255 changed files with 14991 additions and 2943 deletions

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
}
}

View File

@@ -89,5 +89,6 @@
"newIDE/electron-app/app/www": true
},
// Support for Flowtype:
"javascript.validate.enable": false
"javascript.validate.enable": false,
"flow.useNPMPackagedFlow": true
}

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: 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

@@ -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

@@ -167,7 +167,7 @@ private:
/**
* 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 !
* Don't forget to update me if members were changed!
*/
void Init(const gd::EventsList & other);
};

View File

@@ -337,7 +337,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsAudioExtension(gd::Plat
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_"),
_("The global game volume is _PARAM1__PARAM2_"),
_("Audio"),
"res/conditions/volume24.png",
"res/conditions/volume.png")

View File

@@ -860,6 +860,23 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(gd:
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsAdvanced();
extension.AddCondition("Raycast",
_("Raycast"),
_("Sends a ray from the given source position and angle, intersecting the closest object.\nThe instersected object will become the only one taken into account.\nIf the condition is inverted, the object to be intersected will be the farthest one within the ray radius."),
_("Raycast _PARAM0_ from _PARAM1_;_PARAM2_, and save the result in _PARAM5_, _PARAM6_"),
_("Collision"),
"res/conditions/raycast24.png",
"res/conditions/raycast.png")
.AddParameter("objectList", _("Objects to test against the ray"))
.AddParameter("expression", _("Ray source X position"))
.AddParameter("expression", _("Ray source Y position"))
.AddParameter("expression", _("Ray angle (in degrees)"))
.AddParameter("expression", _("Ray maximum distance (in pixels)"))
.AddParameter("scenevar", _("Variable where to store the X position of the intersection"))
.AddParameter("scenevar", _("Variable where to store the Y position of the intersection"))
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsAdvanced();
extension.AddExpression("Count", _("Number of objects"), _("Count the number of the specified objects currently picked"), _("Objects"), "res/conditions/nbObjet.png")
.AddParameter("objectList", _("Object"));
#endif

View File

@@ -26,14 +26,24 @@ public:
mutable std::vector<sf::Vector2f> edges; ///< Edges. Can be computed from vertices using ComputeEdges()
/**
* Moves each vertices from the given amount.
* \brief Get the vertices composing the polygon.
*/
std::vector<sf::Vector2f> & GetVertices() { return vertices; }
/**
* \brief Get the vertices composing the polygon.
*/
const std::vector<sf::Vector2f> & GetVertices() const { return vertices; }
/**
* \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);
/**
* Rotate the polygon.
* \brief Rotate the polygon.
* \param angle Angle in radians
*
* \warning Rotation is made clockwise
@@ -42,18 +52,18 @@ public:
void Rotate(float angle);
/**
* Automatically fill edges vector using vertices.
* \brief Automatically fill edges vector using vertices.
*/
void ComputeEdges() const;
/**
* Check if the polygon is convex.
* \brief Check if the polygon is convex.
* \return true if the polygon is convex
*/
bool IsConvex() const;
/**
* Return the position of the center of the polygon
* \brief Return the position of the center of the polygon
*/
sf::Vector2f ComputeCenter() const;
@@ -62,7 +72,7 @@ public:
*/
///@{
/**
* Create a rectangle
* \brief Create a rectangle
*/
static Polygon2d CreateRectangle(float width, float height);
///@}

View File

@@ -103,6 +103,7 @@ bool Sprite::SetDefaultCenterPoint(bool enabled)
std::vector<Polygon2d> Sprite::GetCollisionMask() const
{
//TODO(perf): Cache to avoid re-creating a mask at every call
#if !defined(EMSCRIPTEN)
if ( automaticCollisionMask )
{

View File

@@ -56,6 +56,16 @@ public:
*/
std::vector<Polygon2d> GetCollisionMask() const;
/**
* \brief Get the custom collision mask.
*/
std::vector<Polygon2d> & GetCustomCollisionMask() { return customCollisionMask; };
/**
* \brief Get the custom collision mask.
*/
const std::vector<Polygon2d> & GetCustomCollisionMask() const { return customCollisionMask; };
/**
* \brief Set the custom collision mask.
* Call then `SetCollisionMaskAutomatic(false)` to use it.

View File

@@ -225,13 +225,13 @@ void ChooseVariableDialog::RefreshVariable(wxTreeListItem item, const gd::String
variablesList->SetItemText(item, 1, "(Structure)");
//Add/update children
const std::map<gd::String, gd::Variable> & children = variable.GetAllChildren();
const auto & children = variable.GetAllChildren();
wxTreeListItem currentChildItem = variablesList->GetFirstChild(item);
wxTreeListItem lastChildItem;
for(std::map<gd::String, gd::Variable>::const_iterator it = children.begin();it != children.end();++it)
for(auto it = children.begin();it != children.end();++it)
{
if ( !currentChildItem.IsOk() ) currentChildItem = variablesList->AppendItem(item, it->first);
RefreshVariable(currentChildItem, it->first, it->second);
RefreshVariable(currentChildItem, it->first, *it->second);
lastChildItem = currentChildItem;
currentChildItem = variablesList->GetNextSibling(currentChildItem);
@@ -255,10 +255,11 @@ void ChooseVariableDialog::RefreshAll()
for (std::size_t i = 0;i<temporaryContainer->Count();++i)
{
const std::pair<gd::String, gd::Variable> & variable = temporaryContainer->Get(i);
const gd::String & name = temporaryContainer->GetNameAt(i);
const auto & variable = temporaryContainer->Get(i);
wxTreeListItem item = variablesList->AppendItem(variablesList->GetRootItem(), variable.first);
RefreshVariable(item, variable.first, variable.second);
wxTreeListItem item = variablesList->AppendItem(variablesList->GetRootItem(), name);
RefreshVariable(item, name, variable);
variablesList->Expand(item);
}
@@ -330,20 +331,11 @@ void ChooseVariableDialog::OnAddVarSelected(wxCommandEvent& event)
void ChooseVariableDialog::OnMoveUpVarSelected(wxCommandEvent& event)
{
UpdateSelectedAndParentVariable();
for (std::size_t i = 1;i<temporaryContainer->Count();++i)
{
const std::pair<gd::String, gd::Variable> & currentVar = temporaryContainer->Get(i);
if ( currentVar.first == selectedVariableName)
{
const std::pair<gd::String, gd::Variable> & prevVar = temporaryContainer->Get(i-1);
temporaryContainer->Swap(i, i-1);
RefreshAll();
modificationCount++;
return;
}
}
auto position = temporaryContainer->GetPosition(selectedVariableName);
temporaryContainer->Move(position, position-1);
RefreshAll();
modificationCount++;
}
/**
@@ -352,21 +344,11 @@ void ChooseVariableDialog::OnMoveUpVarSelected(wxCommandEvent& event)
void ChooseVariableDialog::OnMoveDownVarSelected(wxCommandEvent& event)
{
UpdateSelectedAndParentVariable();
for (std::size_t i = 0;i<temporaryContainer->Count()-1;++i)
{
const std::pair<gd::String, gd::Variable> & currentVar = temporaryContainer->Get(i);
if ( currentVar.first == selectedVariableName)
{
const std::pair<gd::String, gd::Variable> & nextVar = temporaryContainer->Get(i+1);
temporaryContainer->Swap(i, i+1);
RefreshAll();
modificationCount++;
return;
}
}
auto position = temporaryContainer->GetPosition(selectedVariableName);
temporaryContainer->Move(position, position+1);
RefreshAll();
modificationCount++;
}
/**

View File

@@ -52,6 +52,7 @@
#include "GDCore/Tools/Log.h"
#include "GDCore/IDE/Dialogs/DndResourcesEditor.h"
#include "GDCore/IDE/wxTools/TreeItemStringData.h"
#include "GDCore/IDE/Dialogs/PropertyDescriptor.h"
#ifdef __WXGTK__
#include <gtk/gtk.h>
@@ -635,7 +636,7 @@ void ResourcesEditor::OnresourcesTreeSelectionChanged( wxTreeEvent& event )
void ResourcesEditor::UpdatePropertyGrid()
{
std::vector<gd::String> commonProperties; ///< The name of the properties to be displayed
std::map<gd::String, gd::PropertyDescriptor> commonProperties; ///< The name of the properties to be displayed
bool aFolderIsSelected = false;
//First construct the list of common properties
@@ -646,18 +647,29 @@ void ResourcesEditor::UpdatePropertyGrid()
gd::TreeItemStringData * data = dynamic_cast<gd::TreeItemStringData*>(resourcesTree->GetItemData(selection[i]));
if ( data && data->GetString() == "Image")
{
std::vector<gd::String> properties = project.GetResourcesManager().GetResource(data->GetSecondString()).GetAllProperties(project);
const std::map<gd::String, gd::PropertyDescriptor> & properties =
project.GetResourcesManager().GetResource(data->GetSecondString()).GetProperties(project);
if ( i == 0 )
commonProperties = properties;
else
{
//Keep only properties that are common to all the selected resources
for (std::size_t j = 0;j<commonProperties.size();)
// TODO: This could be factored with helpers like ObjectsPropgridHelper
//Merge custom properties
for(std::map<gd::String, gd::PropertyDescriptor>::const_iterator it = properties.begin();
it != properties.end();++it)
{
if ( find(properties.begin(), properties.end(), commonProperties[j]) == properties.end() )
commonProperties.erase(commonProperties.begin()+j);
else
++j;
if ( commonProperties.find(it->first) == commonProperties.end() ) continue;
if ( commonProperties[it->first].GetValue() != it->second.GetValue() )
commonProperties[it->first].SetValue(_("(Multiples values)"));
}
//Also erase properties which are not in common.
for(std::map<gd::String, gd::PropertyDescriptor>::iterator it = commonProperties.begin();
it != commonProperties.end();)
{
if ( properties.find(it->first) == properties.end() )
commonProperties.erase(it++);
else ++it;
}
}
}
@@ -721,32 +733,11 @@ void ResourcesEditor::UpdatePropertyGrid()
//Other properties
if ( !commonProperties.empty() ) propertyGrid->Append( new wxPropertyCategory(_("Other properties")) );
for (std::size_t j = 0;j<commonProperties.size();++j)
for(auto & propertyIterator: commonProperties)
{
wxPGProperty * property = propertyGrid->Append( new wxStringProperty("", commonProperties[j], "") );
wxString commonValue;
for (std::size_t i = 0;i<selection.size();++i)
{
gd::TreeItemStringData * data = dynamic_cast<gd::TreeItemStringData*>(resourcesTree->GetItemData(selection[i]));
if ( data && data->GetString() == "Image")
{
//It is assumed that the description and the user friendly name
//are the same for all the properties with the same name.
gd::String propertyUserFriendlyName;
gd::String propertyDescription;
project.GetResourcesManager().GetResource(data->GetSecondString()).GetPropertyInformation(project, commonProperties[j], propertyUserFriendlyName, propertyDescription);
propertyGrid->SetPropertyLabel(property, propertyUserFriendlyName);
propertyGrid->SetPropertyHelpString(property, propertyDescription);
//Values can be different though
gd::String propertyValue = project.GetResourcesManager().GetResource(data->GetSecondString()).GetProperty(project, commonProperties[j]);
if ( i == 0 ) commonValue = propertyValue;
else if ( commonValue != propertyValue ) commonValue = _("(Multiple values)");
}
}
propertyGrid->SetPropertyValue(property, commonValue);
// TODO: For now, all other properties are assumed to be booleans.
auto & propertyName = propertyIterator.first;
propertyGrid->Append(new wxBoolProperty(propertyName, propertyName, propertyIterator.second.GetValue() == "true"));
}
}
}
@@ -782,7 +773,7 @@ void ResourcesEditor::OnPropertyChanged(wxPropertyGridEvent& event)
RenameInTree(resourcesTree->GetRootItem(), renamedItemOldName, propertyNewValue, "Image");
}
else
project.GetResourcesManager().GetResource(data->GetSecondString()).ChangeProperty(project, propertyName, propertyNewValue);
project.GetResourcesManager().GetResource(data->GetSecondString()).UpdateProperty(propertyName, propertyNewValue, project);
for ( std::size_t j = 0; j < project.GetUsedPlatforms().size();++j)
project.GetUsedPlatforms()[j]->GetChangesNotifier().OnResourceModified(project, data->GetSecondString());
@@ -945,7 +936,7 @@ void ResourcesEditor::Refresh()
gd::ResourceFolder & folder = project.GetResourcesManager().GetFolder(folders[i]);
wxTreeItemId folderItem = resourcesTree->AppendItem( resourcesTree->GetRootItem(), folders[i], -1, -1, new gd::TreeItemStringData("Folder", folders[i] ));
std::vector<gd::String> resources = folder.GetAllResourcesList();
std::vector<gd::String> resources = folder.GetAllResourceNames();
for (std::size_t j=0;j<resources.size();++j)
{
gd::Resource & resource = folder.GetResource(resources[j]);
@@ -959,7 +950,7 @@ void ResourcesEditor::Refresh()
//All images
allImagesItem = resourcesTree->AppendItem( resourcesTree->GetRootItem(), _("All images"), -1,-1, new gd::TreeItemStringData("BaseFolder", "" ));
std::vector<gd::String> resources = project.GetResourcesManager().GetAllResourcesList();
std::vector<gd::String> resources = project.GetResourcesManager().GetAllResourceNames();
for ( std::size_t i = 0;i <resources.size();i++ )
{
gd::Resource & resource = project.GetResourcesManager().GetResource(resources[i]);

View File

@@ -51,7 +51,7 @@ void ArbitraryResourceWorker::ExposeResources(gd::ResourcesManager * resourcesMa
resourcesManagers.push_back(resourcesManager);
std::vector<gd::String> resources = resourcesManager->GetAllResourcesList();
std::vector<gd::String> resources = resourcesManager->GetAllResourceNames();
for ( std::size_t i = 0;i < resources.size() ;i++ )
{
if ( resourcesManager->GetResource(resources[i]).UseFile() )

View File

@@ -45,7 +45,7 @@ std::vector<gd::String> ProjectResourcesAdder::GetAllUselessImages(gd::Project &
std::set<gd::String> & usedImages = inventorizer.GetAllUsedImages();
//Search all images resources not used
std::vector<gd::String> resources = project.GetResourcesManager().GetAllResourcesList();
std::vector<gd::String> resources = project.GetResourcesManager().GetAllResourceNames();
for (std::size_t i = 0;i < resources.size();i++)
{
if (project.GetResourcesManager().GetResource(resources[i]).GetKind() != "image")

View File

@@ -45,7 +45,7 @@ bool ProjectResourcesCopier::CopyAllResourcesTo(gd::Project & originalProject, A
#endif
auto projectDirectory = fs.DirNameFrom(originalProject.GetProjectFile());
std::cout << "Copying all ressources from " << projectDirectory << " to " << destinationDirectory;
std::cout << "Copying all ressources from " << projectDirectory << " to " << destinationDirectory << "..." << std::endl;
//Get the resources to be copied
gd::ResourcesMergingHelper resourcesMergingHelper(fs);

View File

@@ -102,7 +102,7 @@ private:
/**
* Initialize from another ExternalEvents. Used by copy-ctor and assign-op.
* Don't forget to update me if members were changed !
* Don't forget to update me if members were changed!
*/
void Init(const ExternalEvents & externalEvents);
};

View File

@@ -141,7 +141,7 @@ void ImageManager::LoadPermanentImages()
//so as not to unload images that could be still present.
std::map < gd::String, std::shared_ptr<SFMLTextureWrapper> > newPermanentlyLoadedImages;
std::vector<gd::String> resources = resourcesManager->GetAllResourcesList();
std::vector<gd::String> resources = resourcesManager->GetAllResourceNames();
for ( std::size_t i = 0;i <resources.size();i++ )
{
try

View File

@@ -131,6 +131,7 @@ gd::Layer & Layout::GetLayer(const gd::String & name)
return badLayer;
}
const gd::Layer & Layout::GetLayer(const gd::String & name) const
{
std::vector<gd::Layer>::const_iterator layer = find_if(initialLayers.begin(), initialLayers.end(), bind2nd(gd::LayerHasName(), name));
@@ -140,14 +141,17 @@ const gd::Layer & Layout::GetLayer(const gd::String & name) const
return badLayer;
}
gd::Layer & Layout::GetLayer(std::size_t index)
{
return initialLayers[index];
}
const gd::Layer & Layout::GetLayer (std::size_t index) const
{
return initialLayers[index];
}
std::size_t Layout::GetLayersCount() const
{
return initialLayers.size();

View File

@@ -172,37 +172,37 @@ public:
/** \name Layout layers management
* Members functions related to layout layers management.
* TODO: This should be moved to a separate class
* TODO: This could be moved to a separate class
*/
///@{
/**
* Must return true if the layer called "name" exists.
* \brief Return true if the layer called "name" exists.
*/
bool HasLayerNamed(const gd::String & name) const;
/**
* Must return a reference to the layer called "name".
* \brief Return a reference to the layer called "name".
*/
Layer & GetLayer(const gd::String & name);
/**
* Must return a reference to the layer called "name".
* \brief Return a reference to the layer called "name".
*/
const Layer & GetLayer(const gd::String & name) const;
/**
* Must return a reference to the layer at position "index" in the layers list
* \brief Return a reference to the layer at position "index" in the layers list
*/
Layer & GetLayer(std::size_t index);
/**
* Must return a reference to the layer at position "index" in the layers list
* \brief Return a reference to the layer at position "index" in the layers list
*/
const Layer & GetLayer (std::size_t index) const;
const Layer & GetLayer(std::size_t index) const;
/**
* Must return the position of the layer called "name" in the layers list
* \brief Return the position of the layer called "name" in the layers list
*/
std::size_t GetLayerPosition(const gd::String & name) const;
@@ -493,7 +493,7 @@ private:
/**
* Initialize from another layout. Used by copy-ctor and assign-op.
* Don't forget to update me if members were changed !
* Don't forget to update me if members were changed!
*/
void Init(const gd::Layout & other);
};

View File

@@ -0,0 +1,21 @@
/*
* GDevelop Core
* Copyright 2008-2018 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#include "LoadingScreen.h"
#include "GDCore/Serialization/SerializerElement.h"
namespace gd {
void LoadingScreen::SerializeTo(SerializerElement& element) const
{
element.SetAttribute("showGDevelopSplash", showGDevelopSplash);
}
void LoadingScreen::UnserializeFrom(const SerializerElement& element)
{
showGDevelopSplash = element.GetBoolAttribute("showGDevelopSplash", true);
}
}

View File

@@ -0,0 +1,57 @@
/*
* GDevelop Core
* Copyright 2008-2018 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#ifndef GDCORE_LOADINGSCREEN_H
#define GDCORE_LOADINGSCREEN_H
#include "GDCore/String.h"
namespace gd {
class SerializerElement;
}
namespace gd {
/**
* \brief Describe the content and set up of the loading screen
*
* \see gd::LoadingScreen
*
* \ingroup PlatformDefinition
*/
class GD_CORE_API LoadingScreen {
public:
LoadingScreen(){};
virtual ~LoadingScreen(){};
/**
* \brief Set if the GDevelop splash should be shown while loading assets.
*/
void ShowGDevelopSplash(bool show) { showGDevelopSplash = show; };
/**
* \brief Return true if the GDevelop splash should be shown while loading assets.
*/
bool IsGDevelopSplashShown() const { return showGDevelopSplash; };
/** \name Saving and loading
*/
///@{
/**
* \brief Serialize objects groups container.
*/
void SerializeTo(SerializerElement& element) const;
/**
* \brief Unserialize the objects groups container.
*/
void UnserializeFrom(const SerializerElement& element);
///@}
private:
bool showGDevelopSplash;
};
}
#endif // GDCORE_LOADINGSCREEN_H

View File

@@ -321,7 +321,7 @@ protected:
/**
* Initialize object using another object. Used by copy-ctor and assign-op.
* Don't forget to update me if members were changed !
* Don't forget to update me if members were changed!
*/
void Init(const gd::Object & object);
};

View File

@@ -0,0 +1,58 @@
/*
* GDevelop Core
* Copyright 2008-2018 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#include "PlatformSpecificAssets.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
namespace gd {
gd::String PlatformSpecificAssets::badStr;
bool PlatformSpecificAssets::Has(const gd::String& platform, const gd::String& name) const
{
return assets.find(platform + "-" + name) != assets.end();
}
const gd::String& PlatformSpecificAssets::Get(const gd::String& platform, const gd::String& name) const
{
const auto & it = assets.find(platform + "-" + name);
return it != assets.end() ? it->second : badStr;
}
void PlatformSpecificAssets::Remove(const gd::String& platform, const gd::String& name)
{
assets.erase(platform + "-" + name);
}
void PlatformSpecificAssets::Set(const gd::String& platform, const gd::String& name, const gd::String& resourceName)
{
assets[platform + "-" + name] = resourceName;
}
void PlatformSpecificAssets::SerializeTo(SerializerElement& element) const
{
for (auto& it : assets) {
element.AddChild(it.first).SetValue(it.second);
}
}
void PlatformSpecificAssets::UnserializeFrom(const SerializerElement& element)
{
assets.clear();
for (auto& child : element.GetAllChildren()) {
assets[child.first] = child.second->GetValue().GetString();
}
}
void PlatformSpecificAssets::ExposeResources(gd::ArbitraryResourceWorker & worker)
{
for (auto& it : assets) {
worker.ExposeImage(it.second);
}
}
}

View File

@@ -0,0 +1,76 @@
/*
* GDevelop Core
* Copyright 2008-2018 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#ifndef GDCORE_PLATFORMASSETS_H
#define GDCORE_PLATFORMASSETS_H
#include "GDCore/String.h"
#include <map>
namespace gd {
class SerializerElement;
}
namespace gd {
class ArbitraryResourceWorker;
}
namespace gd {
/**
* \brief Store the icons, splashscreens or reference to any other asset
* that can be needed when exporting the game.
*
* \see gd::Project
*
* \ingroup PlatformDefinition
*/
class GD_CORE_API PlatformSpecificAssets {
public:
PlatformSpecificAssets(){};
virtual ~PlatformSpecificAssets(){};
/**
* \brief Return true if the specified asset exists.
*/
bool Has(const gd::String& platform, const gd::String& name) const;
/**
* \brief Get the specified asset resource name.
*/
const gd::String& Get(const gd::String& platform, const gd::String& name) const;
/**
* \brief Remove the specified asset.
*/
void Remove(const gd::String& platform, const gd::String& name);
/**
* \brief Remove the specified asset.
*/
void Set(const gd::String& platform, const gd::String& name, const gd::String& resourceName);
void ExposeResources(gd::ArbitraryResourceWorker & worker);
/** \name Saving and loading
*/
///@{
/**
* \brief Serialize objects groups container.
*/
void SerializeTo(SerializerElement& element) const;
/**
* \brief Unserialize the objects groups container.
*/
void UnserializeFrom(const SerializerElement& element);
///@}
private:
std::map<gd::String, gd::String> assets;
static gd::String badStr;
};
}
#endif // GDCORE_PLATFORMASSETS_H

View File

@@ -61,6 +61,7 @@ Project::Project() :
#if defined(GD_IDE_ONLY)
name(_("Project")),
packageName("com.example.gamename"),
orientation("landscape"),
folderProject(false),
#endif
windowWidth(800),
@@ -531,9 +532,12 @@ void Project::UnserializeFrom(const SerializerElement & element)
#if defined(GD_IDE_ONLY)
SetAuthor(propElement.GetChild("author", 0, "Auteur").GetValue().GetString());
SetPackageName(propElement.GetStringAttribute("packageName"));
SetOrientation(propElement.GetStringAttribute("orientation", "default"));
SetFolderProject(propElement.GetBoolAttribute("folderProject"));
SetProjectFile(propElement.GetStringAttribute("projectFile"));
SetLastCompilationDirectory(propElement.GetChild("latestCompilationDirectory", 0, "LatestCompilationDirectory").GetValue().GetString());
platformSpecificAssets.UnserializeFrom(propElement.GetChild("platformSpecificAssets"));
loadingScreen.UnserializeFrom(propElement.GetChild("loadingScreen"));
winExecutableFilename = propElement.GetStringAttribute("winExecutableFilename");
winExecutableIconFile = propElement.GetStringAttribute("winExecutableIconFile");
linuxExecutableFilename = propElement.GetStringAttribute("linuxExecutableFilename");
@@ -743,6 +747,9 @@ void Project::SerializeTo(SerializerElement & element) const
propElement.SetAttribute("projectFile", gameFile);
propElement.SetAttribute("folderProject", folderProject);
propElement.SetAttribute("packageName", packageName);
propElement.SetAttribute("orientation", orientation);
platformSpecificAssets.SerializeTo(propElement.AddChild("platformSpecificAssets"));
loadingScreen.SerializeTo(propElement.AddChild("loadingScreen"));
propElement.SetAttribute("winExecutableFilename", winExecutableFilename);
propElement.SetAttribute("winExecutableIconFile", winExecutableIconFile);
propElement.SetAttribute("linuxExecutableFilename", linuxExecutableFilename);
@@ -815,6 +822,7 @@ void Project::ExposeResources(gd::ArbitraryResourceWorker & worker)
{
//Add project resources
worker.ExposeResources(&GetResourcesManager());
platformSpecificAssets.ExposeResources(worker);
#if !defined(GD_NO_WX_GUI)
gd::SafeYield::Do();
#endif
@@ -1019,8 +1027,11 @@ void Project::Init(const gd::Project & game)
#if defined(GD_IDE_ONLY)
author = game.author;
packageName = game.packageName;
orientation = game.orientation;
folderProject = game.folderProject;
latestCompilationDirectory = game.latestCompilationDirectory;
platformSpecificAssets = game.platformSpecificAssets;
loadingScreen = game.loadingScreen;
objectGroups = game.objectGroups;
GDMajorVersion = game.GDMajorVersion;

View File

@@ -16,6 +16,8 @@ class TiXmlElement;
#include "GDCore/Project/ChangesNotifier.h"
#include "GDCore/Project/VariablesContainer.h"
#include "GDCore/Project/ResourcesManager.h"
#include "GDCore/Project/PlatformSpecificAssets.h"
#include "GDCore/Project/LoadingScreen.h"
#include "GDCore/Project/ObjectGroupsContainer.h"
namespace gd { class Platform; }
namespace gd { class Layout; }
@@ -85,6 +87,18 @@ public:
*/
const gd::String & GetPackageName() const { return packageName; }
/**
* \brief Change the project orientation (in particular when exported with Cordova).
* This has no effect on desktop and web browsers.
* \param orientation The orientation to use ("default", "landscape", "portrait").
*/
void SetOrientation(const gd::String & orientation_) { orientation = orientation_; };
/**
* \brief Get project orientation ("default", "landscape", "portrait").
*/
const gd::String & GetOrientation() const { return orientation; }
/**
* Called when project file has changed.
*/
@@ -118,6 +132,26 @@ public:
* \see gd::Project::SetLastCompilationDirectory
*/
const gd::String & GetLastCompilationDirectory() const {return latestCompilationDirectory;}
/**
* \brief Return a reference to platform assets of the project (icons, splashscreen...).
*/
gd::PlatformSpecificAssets & GetPlatformSpecificAssets() { return platformSpecificAssets; }
/**
* \brief Return a reference to platform assets of the project (icons, splashscreen...).
*/
const gd::PlatformSpecificAssets & GetPlatformSpecificAssets() const { return platformSpecificAssets; }
/**
* \brief Return a reference to loading screen setup for the project
*/
gd::LoadingScreen & GetLoadingScreen() { return loadingScreen; }
/**
* \brief Return a reference to loading screen setup for the project
*/
const gd::LoadingScreen & GetLoadingScreen() const { return loadingScreen; }
#endif
/**
@@ -708,7 +742,7 @@ private:
/**
* Initialize from another game. Used by copy-ctor and assign-op.
* Don't forget to update me if members were changed !
* Don't forget to update me if members were changed!
*/
void Init(const gd::Project & project);
@@ -737,10 +771,13 @@ private:
gd::ObjectGroupsContainer objectGroups; ///< Global objects groups
gd::String author; ///< Game author name
gd::String packageName; ///< Game package name
gd::String orientation; ///< Lock game orientation (on mobile devices). "default", "landscape" or "portrait".
bool folderProject; ///< True if folder project, false if single file project.
gd::String gameFile; ///< File of the game
gd::String latestCompilationDirectory; ///< File of the game
gd::Platform* currentPlatform; ///< The platform being used to edit the project.
gd::PlatformSpecificAssets platformSpecificAssets;
gd::LoadingScreen loadingScreen;
std::vector < std::unique_ptr<gd::ExternalEvents> > externalEvents; ///< List of all externals events
mutable unsigned int GDMajorVersion; ///< The GD major version used the last time the project was saved.
mutable unsigned int GDMinorVersion; ///< The GD minor version used the last time the project was saved.

View File

@@ -5,6 +5,7 @@
*/
#include <iostream>
#include <map>
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#include "GDCore/IDE/wxTools/CommonBitmapProvider.h"
#include <wx/filedlg.h>
@@ -20,6 +21,7 @@
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/Tools/Log.h"
#include "GDCore/Tools/Localization.h"
#include "GDCore/IDE/Dialogs/PropertyDescriptor.h"
namespace gd
{
@@ -105,7 +107,7 @@ bool ResourcesManager::HasResource(const gd::String & name) const
return false;
}
std::vector<gd::String> ResourcesManager::GetAllResourcesList()
std::vector<gd::String> ResourcesManager::GetAllResourceNames()
{
std::vector<gd::String> allResources;
for (std::size_t i = 0;i<resources.size();++i)
@@ -114,8 +116,30 @@ std::vector<gd::String> ResourcesManager::GetAllResourcesList()
return allResources;
}
#if defined(GD_IDE_ONLY)
std::map<gd::String, gd::PropertyDescriptor> Resource::GetProperties(gd::Project & project) const
{
std::map<gd::String, gd::PropertyDescriptor> nothing;
return nothing;
}
std::map<gd::String, gd::PropertyDescriptor> ImageResource::GetProperties(gd::Project & project) const
{
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[_("Smooth the image")].SetValue(smooth ? "true" : "false").SetType("Boolean");
properties[_("Always loaded in memory")].SetValue(alwaysLoaded ? "true" : "false").SetType("Boolean");
return properties;
}
bool ImageResource::UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project)
{
if (name == _("Smooth the image")) smooth = value == "1";
else if (name == _("Always loaded in memory")) alwaysLoaded = value == "1";
return true;
}
bool ResourcesManager::AddResource(const gd::Resource & resource)
{
if ( HasResource(resource.GetName()) ) return false;
@@ -146,7 +170,7 @@ bool ResourcesManager::AddResource(const gd::String & name, const gd::String & f
return true;
}
std::vector<gd::String> ResourceFolder::GetAllResourcesList()
std::vector<gd::String> ResourceFolder::GetAllResourceNames()
{
std::vector<gd::String> allResources;
for (std::size_t i = 0;i<resources.size();++i)
@@ -155,61 +179,6 @@ std::vector<gd::String> ResourceFolder::GetAllResourcesList()
return allResources;
}
bool ImageResource::EditProperty(gd::Project & project, const gd::String & property)
{
return false;
}
bool ImageResource::ChangeProperty(gd::Project & project, const gd::String & property, const gd::String & newValue)
{
if ( property == "smooth" )
smooth = (newValue == _("Yes"));
else if ( property == "alwaysLoaded" )
alwaysLoaded = (newValue == _("Yes"));
return true;
}
void ImageResource::GetPropertyInformation(gd::Project & project, const gd::String & property, gd::String & userFriendlyName, gd::String & description) const
{
if ( property == "smooth" )
{
userFriendlyName = _("Smooth the image");
description = _("Set this to \"Yes\" to set a smooth filter on the image");
}
else if ( property == "alwaysLoaded" )
{
userFriendlyName = _("Always loaded in memory");
description = _("Set this to \"Yes\" to let the image always loaded in memory.\nUseful when the image is used by actions.");
}
}
gd::String ImageResource::GetProperty(gd::Project & project, const gd::String & property)
{
if ( property == "smooth" )
{
return smooth ? _("Yes") : _("No");
}
else if ( property == "alwaysLoaded" )
{
return alwaysLoaded ? _("Yes") : _("No");
}
return "";
}
/**
* Return a vector containing the name of all the properties of the resource
*/
std::vector<gd::String> ImageResource::GetAllProperties(gd::Project & project) const
{
std::vector<gd::String> allProperties;
allProperties.push_back("smooth");
allProperties.push_back("alwaysLoaded");
return allProperties;
}
#if !defined(GD_NO_WX_GUI)
void ImageResource::RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & project)
{
@@ -351,6 +320,25 @@ bool ResourcesManager::MoveResourceDownInList(const gd::String & name)
return gd::MoveResourceDownInList(resources, name);
}
std::size_t ResourcesManager::GetResourcePosition(const gd::String & name) const
{
for (std::size_t i = 0;i<resources.size();++i)
{
if (resources[i]->GetName() == name) return i;
}
return gd::String::npos;
}
void ResourcesManager::MoveResource(std::size_t oldIndex, std::size_t newIndex)
{
if ( oldIndex >= resources.size() || newIndex >= resources.size() )
return;
auto resource = resources[oldIndex];
resources.erase(resources.begin() + oldIndex);
resources.insert(resources.begin() + newIndex, resource);
}
bool ResourcesManager::MoveFolderUpInList(const gd::String & name)
{
for (std::size_t i =1;i<folders.size();++i)

View File

@@ -6,11 +6,12 @@
#ifndef GDCORE_RESOURCESMANAGER_H
#define GDCORE_RESOURCESMANAGER_H
#include <memory>
#include "GDCore/String.h"
#include <vector>
#include "GDCore/String.h"
namespace gd { class Project; }
namespace gd { class ResourceFolder; }
namespace gd { class SerializerElement; }
namespace gd { class PropertyDescriptor; }
class wxPaintDC;
class wxPanel;
@@ -83,37 +84,6 @@ public:
*/
gd::String GetAbsoluteFile(const gd::Project & game) const;
/**
* \brief Called when a property must be edited (i.e: it was double clicked in a property grid)
*
* \return true if the resource was changed
*/
virtual bool EditProperty(gd::Project & project, const gd::String & property) { return true; };
/**
* \brief Called when a property must be changed (i.e: its value was changed in a property grid)
*
* \return true if the resource was changed
*/
virtual bool ChangeProperty(gd::Project & project, const gd::String & property, const gd::String & newValue) { return true; };
/**
* \brief Must return a description of the main property provided by the resource (example : "Image file")
*/
virtual void GetPropertyInformation(gd::Project & project, const gd::String & property, gd::String & userFriendlyName, gd::String & description) const { return; };
/**
* \brief Called when a property must be changed ( i.e: its value was changed in the property grid )
*
* \return the value of the property
*/
virtual gd::String GetProperty(gd::Project & project, const gd::String & property) { return ""; };
/**
* \brief Return a description of the main property provided by the resource ( Example : "Image file" )
*/
virtual std::vector<gd::String> GetAllProperties(gd::Project & project) const { std::vector<gd::String> noProperties; return noProperties; };
#if !defined(GD_NO_WX_GUI)
/**
* \brief Called when the resource must be rendered in a preview panel.
@@ -121,6 +91,36 @@ public:
virtual void RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & game) {};
#endif
#if defined(GD_IDE_ONLY)
/** \name Resources properties
* Reading and updating resources properties
*/
///@{
/**
* \brief Called when the IDE wants to know about the custom properties of the resource.
*
* Usage example:
\code
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[ToString(_("Text"))].SetValue("Hello world!");
return properties;
\endcode
*
* \return a std::map with properties names as key.
* \see gd::PropertyDescriptor
*/
virtual std::map<gd::String, gd::PropertyDescriptor> GetProperties(gd::Project & project) const;
/**
* \brief Called when the IDE wants to update a custom property of the resource
*
* \return false if the new value cannot be set
*/
virtual bool UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project) {return false;};
///@}
#endif
/**
* \brief Serialize the object
*/
@@ -150,69 +150,41 @@ class GD_CORE_API ImageResource : public Resource
public:
ImageResource() : Resource(), smooth(true), alwaysLoaded(false) { SetKind("image"); };
virtual ~ImageResource() {};
virtual ImageResource* Clone() const { return new ImageResource(*this);}
virtual ImageResource* Clone() const override { return new ImageResource(*this);}
/**
* Return the file used by the resource.
*/
virtual const gd::String & GetFile() const {return file;};
virtual const gd::String & GetFile() const override {return file;};
/**
* Change the file of the resource.
*/
virtual void SetFile(const gd::String & newFile);
virtual void SetFile(const gd::String & newFile) override;
#if defined(GD_IDE_ONLY)
virtual bool UseFile() { return true; }
virtual bool UseFile() override { return true; }
#if !defined(GD_NO_WX_GUI)
/**
* Called when the resource must be rendered in a preview panel.
*/
virtual void RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & game);
virtual void RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & game) override;
#endif
/**
* Called when a property must be edited ( i.e: it was double clicked )
*
* \return true if the resource was changed
*/
virtual bool EditProperty(gd::Project & project, const gd::String & property);
/**
* Called when a property must be changed ( i.e: its value was changed in the property grid )
*
* \return true if the resource was changed
*/
virtual bool ChangeProperty(gd::Project & project, const gd::String & property, const gd::String & newValue);
/**
* Called when a property must be changed ( i.e: its value was changed in the property grid )
*
* \return the value of the property
*/
virtual gd::String GetProperty(gd::Project & project, const gd::String & property);
/**
* Return a description of the main property provided by the resource ( Example : "Image file" )
*/
virtual void GetPropertyInformation(gd::Project & project, const gd::String & property, gd::String & userFriendlyName, gd::String & description) const;
/**
* Return a vector containing the name of all the properties of the resource
*/
virtual std::vector<gd::String> GetAllProperties(gd::Project & project) const;
std::map<gd::String, gd::PropertyDescriptor> GetProperties(gd::Project & project) const override;
bool UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project) override;
/**
* \brief Serialize the object
*/
void SerializeTo(SerializerElement & element) const;
void SerializeTo(SerializerElement & element) const override;
#endif
/**
* \brief Unserialize the objectt.
*/
void UnserializeFrom(const SerializerElement & element);
void UnserializeFrom(const SerializerElement & element) override;
/**
* \brief Return true if the image should be smoothed.
@@ -242,17 +214,17 @@ class GD_CORE_API AudioResource : public Resource
public:
AudioResource() : Resource() { SetKind("audio"); };
virtual ~AudioResource() {};
virtual AudioResource* Clone() const { return new AudioResource(*this);}
virtual AudioResource* Clone() const override { return new AudioResource(*this);}
virtual const gd::String & GetFile() const {return file;};
virtual void SetFile(const gd::String & newFile);
virtual const gd::String & GetFile() const override {return file;};
virtual void SetFile(const gd::String & newFile) override;
#if defined(GD_IDE_ONLY)
virtual bool UseFile() { return true; }
void SerializeTo(SerializerElement & element) const;
virtual bool UseFile() override { return true; }
void SerializeTo(SerializerElement & element) const override;
#endif
void UnserializeFrom(const SerializerElement & element);
void UnserializeFrom(const SerializerElement & element) override;
private:
gd::String file;
@@ -293,9 +265,9 @@ public:
std::shared_ptr<Resource> CreateResource(const gd::String & kind);
/**
* \brief Get a list containing the name of all of the resources.
* \brief Get a list containing the names of all resources.
*/
std::vector<gd::String> GetAllResourcesList();
std::vector<gd::String> GetAllResourceNames();
#if defined(GD_IDE_ONLY)
/**
@@ -324,6 +296,11 @@ public:
*/
void RenameResource(const gd::String & oldName, const gd::String & newName);
/**
* \brief Return the position of the layer called "name" in the layers list
*/
std::size_t GetResourcePosition(const gd::String & name) const;
/**
* \brief Move a resource up in the list
*/
@@ -334,6 +311,11 @@ public:
*/
bool MoveResourceDownInList(const gd::String & name);
/**
* Change the position of the specified resource.
*/
void MoveResource(std::size_t oldIndex, std::size_t newIndex);
/**
* \brief Return true if the folder exists.
*/
@@ -445,7 +427,7 @@ public:
/**
* Get a list containing the name of all of the resources.
*/
virtual std::vector<gd::String> GetAllResourcesList();
virtual std::vector<gd::String> GetAllResourceNames();
/**
* Move a resource up in the list

View File

@@ -5,24 +5,23 @@
*/
#include "GDCore/Project/Variable.h"
#include "GDCore/String.h"
#include <sstream>
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/String.h"
#include "GDCore/TinyXml/tinyxml.h"
#include <sstream>
using namespace std;
namespace gd
{
namespace gd {
/**
* Get value as a double
*/
double Variable::GetValue() const
{
if (!isNumber)
{
stringstream ss; ss << str;
if (!isNumber) {
stringstream ss;
ss << str;
ss >> value;
isNumber = true;
}
@@ -30,11 +29,11 @@ double Variable::GetValue() const
return value;
}
const gd::String & Variable::GetString() const
const gd::String& Variable::GetString() const
{
if (isNumber)
{
stringstream s; s << (value);
if (isNumber) {
stringstream s;
s << (value);
str = s.str();
isNumber = false;
}
@@ -42,7 +41,7 @@ const gd::String & Variable::GetString() const
return str;
}
bool Variable::HasChild(const gd::String & name) const
bool Variable::HasChild(const gd::String& name) const
{
return isStructure && children.find(name) != children.end();
}
@@ -53,15 +52,15 @@ bool Variable::HasChild(const gd::String & name) const
* If the variable is not a structure or has not
* the specified child, an empty variable is returned.
*/
Variable & Variable::GetChild(const gd::String & name)
Variable& Variable::GetChild(const gd::String& name)
{
std::map<gd::String, Variable>::iterator it = children.find(name);
if ( it != children.end() ) return it->second;
auto it = children.find(name);
if (it != children.end())
return *it->second;
isStructure = true;
Variable newEmptyVariable;
children[name] = newEmptyVariable;
return children[name];
children[name] = std::make_shared<gd::Variable>();
return *children[name];
}
/**
@@ -70,26 +69,28 @@ Variable & Variable::GetChild(const gd::String & name)
* If the variable is not a structure or has not
* the specified child, an empty variable is returned.
*/
const Variable & Variable::GetChild(const gd::String & name) const
const Variable& Variable::GetChild(const gd::String& name) const
{
std::map<gd::String, Variable>::iterator it = children.find(name);
if ( it != children.end() ) return it->second;
auto it = children.find(name);
if (it != children.end())
return *it->second;
isStructure = true;
Variable newEmptyVariable;
children[name] = newEmptyVariable;
return children[name];
children[name] = std::make_shared<gd::Variable>();
return *children[name];
}
void Variable::RemoveChild(const gd::String & name)
void Variable::RemoveChild(const gd::String& name)
{
if ( !isStructure ) return;
if (!isStructure)
return;
children.erase(name);
}
bool Variable::RenameChild(const gd::String & oldName, const gd::String & newName)
bool Variable::RenameChild(const gd::String& oldName, const gd::String& newName)
{
if ( !isStructure || !HasChild(oldName)|| HasChild(newName) ) return false;
if (!isStructure || !HasChild(oldName) || HasChild(newName))
return false;
children[newName] = children[oldName];
children.erase(oldName);
@@ -99,91 +100,144 @@ bool Variable::RenameChild(const gd::String & oldName, const gd::String & newNam
void Variable::ClearChildren()
{
if ( !isStructure ) return;
if (!isStructure)
return;
children.clear();
}
void Variable::SerializeTo(SerializerElement & element) const
void Variable::SerializeTo(SerializerElement& element) const
{
if (!isStructure)
element.SetAttribute("value", GetString());
else
{
SerializerElement & childrenElement = element.AddChild("children");
else {
SerializerElement& childrenElement = element.AddChild("children");
childrenElement.ConsiderAsArrayOf("variable");
for (std::map<gd::String, gd::Variable>::iterator i = children.begin(); i != children.end(); ++i)
{
SerializerElement & variableElement = childrenElement.AddChild("variable");
for (auto i = children.begin(); i != children.end(); ++i) {
SerializerElement& variableElement = childrenElement.AddChild("variable");
variableElement.SetAttribute("name", i->first);
i->second.SerializeTo(variableElement);
i->second->SerializeTo(variableElement);
}
}
}
void Variable::UnserializeFrom(const SerializerElement & element)
void Variable::UnserializeFrom(const SerializerElement& element)
{
isStructure = element.HasChild("children", "Children");
if (isStructure)
{
const SerializerElement & childrenElement = element.GetChild("children", 0, "Children");
if (isStructure) {
const SerializerElement& childrenElement = element.GetChild("children", 0, "Children");
childrenElement.ConsiderAsArrayOf("variable", "Variable");
for (int i = 0; i < childrenElement.GetChildrenCount(); ++i)
{
const SerializerElement & childElement = childrenElement.GetChild(i);
for (int i = 0; i < childrenElement.GetChildrenCount(); ++i) {
const SerializerElement& childElement = childrenElement.GetChild(i);
gd::String name = childElement.GetStringAttribute("name", "", "Name");
gd::Variable childVariable;
childVariable.UnserializeFrom(childElement);
children[name] = childVariable;
children[name] = std::make_shared<gd::Variable>();
children[name]->UnserializeFrom(childElement);
}
}
else
} else
SetString(element.GetStringAttribute("value", "", "Value"));
}
void Variable::SaveToXml(TiXmlElement * element) const
void Variable::SaveToXml(TiXmlElement* element) const
{
if (!element) return;
if (!element)
return;
if ( !isStructure )
if (!isStructure)
element->SetAttribute("Value", GetString().c_str());
else
{
TiXmlElement * childrenElem = new TiXmlElement( "Children" );
element->LinkEndChild( childrenElem );
for (std::map<gd::String, gd::Variable>::iterator i = children.begin(); i != children.end(); ++i)
{
TiXmlElement * variable = new TiXmlElement( "Variable" );
childrenElem->LinkEndChild( variable );
else {
TiXmlElement* childrenElem = new TiXmlElement("Children");
element->LinkEndChild(childrenElem);
for (auto i = children.begin(); i != children.end(); ++i) {
TiXmlElement* variable = new TiXmlElement("Variable");
childrenElem->LinkEndChild(variable);
variable->SetAttribute("Name", i->first.c_str());
i->second.SaveToXml(variable);
i->second->SaveToXml(variable);
}
}
}
void Variable::LoadFromXml(const TiXmlElement * element)
void Variable::LoadFromXml(const TiXmlElement* element)
{
if (!element) return;
if (!element)
return;
isStructure = element->FirstChildElement("Children") != NULL;
if ( isStructure )
{
const TiXmlElement * child = element->FirstChildElement("Children")->FirstChildElement();
while ( child )
{
if (isStructure) {
const TiXmlElement* child = element->FirstChildElement("Children")->FirstChildElement();
while (child) {
gd::String name = child->Attribute("Name") ? child->Attribute("Name") : "";
gd::Variable childVariable;
childVariable.LoadFromXml(child);
children[name] = childVariable;
children[name] = std::make_shared<gd::Variable>();
children[name]->LoadFromXml(child);
child = child->NextSiblingElement();
}
}
else if (element->Attribute("Value"))
} else if (element->Attribute("Value"))
SetString(element->Attribute("Value"));
}
std::vector<gd::String> Variable::GetAllChildrenNames() const
{
std::vector<gd::String> names;
for (auto& it : children) {
names.push_back(it.first);
}
return names;
}
bool Variable::Contains(const gd::Variable& variableToSearch, bool recursive) const
{
for (auto& it : children) {
if (it.second.get() == &variableToSearch)
return true;
if (recursive && it.second->Contains(variableToSearch, true))
return true;
}
return false;
}
void Variable::RemoveRecursively(const gd::Variable& variableToRemove)
{
for (auto it = children.begin(); it != children.end();) {
if (it->second.get() == &variableToRemove) {
it = children.erase(it);
} else {
it->second->RemoveRecursively(variableToRemove);
it++;
}
}
}
Variable::Variable(const Variable& other) :
value(other.value),
str(other.str),
isNumber(other.isNumber),
isStructure(other.isStructure)
{
CopyChildren(other);
}
Variable& Variable::operator=(const Variable& other)
{
if (this != &other) {
value = other.value;
str = other.str;
isNumber = other.isNumber;
isStructure = other.isStructure;
CopyChildren(other);
}
return *this;
}
void Variable::CopyChildren(const gd::Variable& other)
{
children.clear();
for (auto& it : other.children) {
children[it.first] = std::make_shared<gd::Variable>(*it.second);
}
}
}

View File

@@ -8,6 +8,7 @@
#define GDCORE_VARIABLE_H
#include "GDCore/String.h"
#include <map>
#include <memory>
namespace gd { class SerializerElement; }
class TiXmlElement;
@@ -29,8 +30,11 @@ public:
* \brief Default constructor creating a variable with 0 as value.
*/
Variable() : value(0), isNumber(true), isStructure(false) {};
Variable(const Variable&);
virtual ~Variable() {};
Variable& operator=(const Variable & rhs);
/** \name Number or string
* Methods and operators used when the variable is considered as a number or a string.
*/
@@ -148,11 +152,30 @@ public:
*/
void ClearChildren();
/**
* \brief Get the count of children that the variable has.
*/
size_t GetChildrenCount() const { return children.size(); };
/**
* \brief Get the names of all children
*/
std::vector<gd::String> GetAllChildrenNames() const;
/**
* \brief Get the map containing all the children.
*/
const std::map<gd::String, Variable> & GetAllChildren() const { return children; }
const std::map<gd::String, std::shared_ptr<Variable>> & GetAllChildren() const { return children; }
/**
* \brief Search if a variable is part of the children, optionally recursively
*/
bool Contains(const gd::Variable & variableToSearch, bool recursive) const;
/**
* \brief Remove the specified variable if it can be found in the children
*/
void RemoveRecursively(const gd::Variable & variableToRemove);
///@}
/** \name Serialization
@@ -186,7 +209,12 @@ private:
mutable gd::String str;
mutable bool isNumber; ///< True if the type of the variable is a number.
mutable bool isStructure; ///< False when the variable is a primitive ( i.e: Number or String ), true when it is a structure and has may have children.
mutable std::map<gd::String, Variable> children; ///<Children, when the variable is considered as a structure.
mutable std::map<gd::String, std::shared_ptr<Variable>> children; ///<Children, when the variable is considered as a structure.
/**
* Initialize children by copying them from another variable. Used by copy-ctor and assign-op.
*/
void CopyChildren(const Variable & other);
};
}

View File

@@ -3,177 +3,215 @@
* 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 <algorithm>
#include "GDCore/Project/Variable.h"
#include "GDCore/TinyXml/tinyxml.h"
#include "GDCore/Project/VariablesContainer.h"
#include "GDCore/Project/Variable.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/String.h"
#include "GDCore/TinyXml/tinyxml.h"
#include <algorithm>
#include <iostream>
namespace gd
{
namespace gd {
std::pair<gd::String, Variable> VariablesContainer::badVariable;
gd::Variable VariablesContainer::badVariable;
gd::String VariablesContainer::badName;
namespace {
//Tool functor used below
class VariableHasName
{
public:
VariableHasName(gd::String const& name_) : name(name_) { }
//Tool functor used below
class VariableHasName {
public:
VariableHasName(gd::String const& name_)
: name(name_)
{
}
bool operator () (const std::pair<gd::String, gd::Variable> & p)
{
return (p.first == name);
}
gd::String name;
};
bool operator()(const std::pair<gd::String, std::shared_ptr<gd::Variable>>& p)
{
return (p.first == name);
}
gd::String name;
};
}
VariablesContainer::VariablesContainer()
{
}
bool VariablesContainer::Has(const gd::String & name) const
bool VariablesContainer::Has(const gd::String& name) const
{
std::vector < std::pair<gd::String, gd::Variable> >::const_iterator i =
std::find_if(variables.begin(), variables.end(), VariableHasName(name));
auto i = std::find_if(variables.begin(), variables.end(), VariableHasName(name));
return (i != variables.end());
}
std::pair<gd::String, gd::Variable> & VariablesContainer::Get(std::size_t index)
Variable& VariablesContainer::Get(const gd::String& name)
{
if ( index < variables.size() )
return variables[index];
auto i = std::find_if(variables.begin(), variables.end(), VariableHasName(name));
if (i != variables.end())
return *i->second;
return badVariable;
}
const std::pair<gd::String, gd::Variable> & VariablesContainer::Get(std::size_t index) const
const Variable& VariablesContainer::Get(const gd::String& name) const
{
if ( index < variables.size() )
return variables[index];
auto i = std::find_if(variables.begin(), variables.end(), VariableHasName(name));
if (i != variables.end())
return *i->second;
return badVariable;
}
Variable & VariablesContainer::Get(const gd::String & name)
Variable& VariablesContainer::Get(std::size_t index)
{
std::vector < std::pair<gd::String, gd::Variable> >::iterator i =
std::find_if(variables.begin(), variables.end(), VariableHasName(name));
if (i != variables.end())
return i->second;
if (index < variables.size())
return *variables[index].second;
return badVariable.second;
return badVariable;
}
const Variable & VariablesContainer::Get(const gd::String & name) const
const Variable& VariablesContainer::Get(std::size_t index) const
{
std::vector < std::pair<gd::String, gd::Variable> >::const_iterator i =
std::find_if(variables.begin(), variables.end(), VariableHasName(name));
if (i != variables.end())
return i->second;
if (index < variables.size())
return *variables[index].second;
return badVariable.second;
return badVariable;
}
Variable & VariablesContainer::Insert(const gd::String & name, const gd::Variable & variable, std::size_t position)
const gd::String& VariablesContainer::GetNameAt(std::size_t index) const
{
if (position<variables.size())
{
variables.insert(variables.begin()+position, std::make_pair(name, variable));
return variables[position].second;
}
else
{
variables.push_back(std::make_pair(name, variable));
return variables.back().second;
if (index < variables.size())
return variables[index].first;
return badName;
}
Variable& VariablesContainer::Insert(const gd::String& name, const gd::Variable& variable, std::size_t position)
{
auto newVariable = std::make_shared<gd::Variable>(variable);
if (position < variables.size()) {
variables.insert(variables.begin() + position, std::make_pair(name, newVariable));
return *variables[position].second;
} else {
variables.push_back(std::make_pair(name, newVariable));
return *variables.back().second;
}
}
#if defined(GD_IDE_ONLY)
void VariablesContainer::Remove(const gd::String & varName)
void VariablesContainer::Remove(const gd::String& varName)
{
variables.erase(std::remove_if(variables.begin(), variables.end(),
VariableHasName(varName)), variables.end() );
VariableHasName(varName)),
variables.end());
}
std::size_t VariablesContainer::GetPosition(const gd::String & name) const
void VariablesContainer::RemoveRecursively(const gd::Variable& variableToRemove)
{
for(std::size_t i = 0;i<variables.size();++i)
{
if ( variables[i].first == name )
variables.erase(std::remove_if(variables.begin(), variables.end(),
[&variableToRemove](const std::pair<gd::String, std::shared_ptr<gd::Variable>>& nameAndVariable) {
return &variableToRemove == nameAndVariable.second.get();
}),
variables.end());
for (auto& it : variables) {
it.second->RemoveRecursively(variableToRemove);
}
}
std::size_t VariablesContainer::GetPosition(const gd::String& name) const
{
for (std::size_t i = 0; i < variables.size(); ++i) {
if (variables[i].first == name)
return i;
}
return gd::String::npos;
}
Variable & VariablesContainer::InsertNew(const gd::String & name, std::size_t position)
Variable& VariablesContainer::InsertNew(const gd::String& name, std::size_t position)
{
Variable newVariable;
return Insert(name, newVariable, position);
}
bool VariablesContainer::Rename(const gd::String & oldName, const gd::String & newName)
bool VariablesContainer::Rename(const gd::String& oldName, const gd::String& newName)
{
if (Has(newName)) return false;
if (Has(newName))
return false;
std::vector < std::pair<gd::String, gd::Variable> >::iterator i =
std::find_if(variables.begin(), variables.end(), VariableHasName(oldName));
if (i != variables.end()) i->first = newName;
auto i = std::find_if(variables.begin(), variables.end(), VariableHasName(oldName));
if (i != variables.end())
i->first = newName;
return true;
}
void VariablesContainer::Swap(std::size_t firstVariableIndex, std::size_t secondVariableIndex)
{
if ( firstVariableIndex >= variables.size() || secondVariableIndex >= variables.size() )
if (firstVariableIndex >= variables.size() || secondVariableIndex >= variables.size())
return;
std::pair<gd::String, gd::Variable> temp = variables[firstVariableIndex];
auto temp = variables[firstVariableIndex];
variables[firstVariableIndex] = variables[secondVariableIndex];
variables[secondVariableIndex] = temp;
}
void VariablesContainer::Move(std::size_t oldIndex, std::size_t newIndex)
{
if ( oldIndex >= variables.size() || newIndex >= variables.size() )
if (oldIndex >= variables.size() || newIndex >= variables.size())
return;
auto nameAndVariable = variables[oldIndex];
variables.erase(variables.begin() + oldIndex);
Insert(nameAndVariable.first, nameAndVariable.second, newIndex);
variables.insert(variables.begin() + newIndex, nameAndVariable);
}
#endif
void VariablesContainer::SerializeTo(SerializerElement & element) const
void VariablesContainer::SerializeTo(SerializerElement& element) const
{
element.ConsiderAsArrayOf("variable");
for ( std::size_t j = 0;j < variables.size();j++ )
{
SerializerElement & variableElement = element.AddChild("variable");
for (std::size_t j = 0; j < variables.size(); j++) {
SerializerElement& variableElement = element.AddChild("variable");
variableElement.SetAttribute("name", variables[j].first);
variables[j].second.SerializeTo(variableElement);
variables[j].second->SerializeTo(variableElement);
}
}
void VariablesContainer::UnserializeFrom(const SerializerElement & element)
void VariablesContainer::UnserializeFrom(const SerializerElement& element)
{
Clear();
element.ConsiderAsArrayOf("variable", "Variable");
for ( std::size_t j = 0;j < element.GetChildrenCount();j++ )
{
const SerializerElement & variableElement = element.GetChild(j);
for (std::size_t j = 0; j < element.GetChildrenCount(); j++) {
const SerializerElement& variableElement = element.GetChild(j);
Variable variable;
variable.UnserializeFrom(variableElement);
Insert(variableElement.GetStringAttribute("name", "", "Name" ), variable, -1);
Insert(variableElement.GetStringAttribute("name", "", "Name"), variable, -1);
}
}
VariablesContainer::VariablesContainer(const VariablesContainer& other)
{
Init(other);
}
VariablesContainer& VariablesContainer::operator=(const VariablesContainer& other)
{
if (this != &other)
Init(other);
return *this;
}
void VariablesContainer::Init(const gd::VariablesContainer& other)
{
variables.clear();
for (auto& it : other.variables) {
variables.push_back(std::make_pair(
it.first,
std::make_shared<gd::Variable>(*it.second)));
}
}
}

View File

@@ -8,6 +8,7 @@
#define GDCORE_VARIABLESCONTAINER_H
#include "GDCore/String.h"
#include <vector>
#include <memory>
#include "GDCore/Project/Variable.h"
namespace gd { class SerializerElement; }
class TiXmlElement;
@@ -29,8 +30,11 @@ class GD_CORE_API VariablesContainer
{
public:
VariablesContainer();
VariablesContainer(const VariablesContainer&);
virtual ~VariablesContainer() {};
VariablesContainer& operator=(const VariablesContainer & rhs);
/** \name Variables management
* Members functions related to variables management.
*/
@@ -52,18 +56,14 @@ public:
const Variable & Get(const gd::String & name) const;
/**
* \brief Return a pair containing the name and the variable at position \index in the container.
*
* \note If index is invalid, an empty variable is returned.
* \brief Return a reference to the variable at the specified position in the list.
*/
std::pair<gd::String, gd::Variable> & Get(std::size_t index);
Variable & Get(std::size_t index);
/**
* \brief Return a pair containing the name and the variable at position \index in the container.
*
* \note If index is invalid, an empty variable is returned.
* \brief Return a reference to the variable at the specified position in the list.
*/
const std::pair<gd::String, gd::Variable> & Get(std::size_t index) const;
const Variable & Get(std::size_t index) const;
/**
* Must add a new variable constructed from the variable passed as parameter.
@@ -79,6 +79,11 @@ public:
*/
std::size_t Count() const { return variables.size(); };
/**
* \brief Return the name of the variable at a position
*/
const gd::String & GetNameAt(std::size_t index) const;
#if defined(GD_IDE_ONLY)
/**
* \brief return the position of the variable called "name" in the variable list
@@ -94,10 +99,16 @@ public:
Variable & InsertNew(const gd::String & name, std::size_t position = -1);
/**
* \brief Remove the specified variable from the container.
* \brief Remove the variable with the specified name from the container.
* \note This operation is not recursive on variable children
*/
void Remove(const gd::String & name);
/**
* \brief Remove the specified variable from the container.
*/
void RemoveRecursively(const gd::Variable & variable);
/**
* \brief Rename a variable.
* \return true if the variable was renamed, false otherwise.
@@ -138,8 +149,15 @@ public:
private:
std::vector < std::pair<gd::String, gd::Variable> > variables;
static std::pair<gd::String, Variable> badVariable;
std::vector < std::pair<gd::String, std::shared_ptr<gd::Variable>> > variables;
static gd::Variable badVariable;
static gd::String badName;
/**
* Initialize from another variables container, copying elements. Used by copy-ctor and assign-op.
* Don't forget to update me if members were changed!
*/
void Init(const VariablesContainer & other);
};
}

View File

@@ -143,7 +143,7 @@ protected:
/**
* Initialize from another list of elements, copying elements. Used by copy-ctor and assign-op.
* Don't forget to update me if members were changed !
* Don't forget to update me if members were changed!
*/
void Init(const SPtrList<T> & other);
};

View File

@@ -26,48 +26,6 @@ TEST_CASE( "Project", "[common]" ) {
REQUIRE( project.GetName() == "myname" );
}
}
TEST_CASE( "Variable", "[common]" ) {
SECTION("Basics") {
gd::Variable variable;
variable.SetValue(50);
REQUIRE( variable.GetValue() == 50 );
REQUIRE( variable == 50 );
REQUIRE( variable.IsNumber() == true );
REQUIRE( variable.IsStructure() == false );
variable.SetString("MyString");
REQUIRE( variable.GetString() == "MyString" );
REQUIRE( variable == "MyString" );
REQUIRE( variable.IsNumber() == false );
REQUIRE( variable.IsStructure() == false );
}
SECTION("Conversions") {
gd::Variable variable;
variable.SetValue(50);
REQUIRE( variable.GetString() == "50" ); //Used as a string...
REQUIRE( variable.IsNumber() == false ); //...so consider as a string
variable.SetString("MyString");
REQUIRE( variable.GetValue() == 0 ); //Used as a number...
REQUIRE( variable.IsNumber() == true ); //...so consider as a number
}
SECTION("Use with int and string like semantics") {
gd::Variable variable;
variable = 50;
REQUIRE( variable.GetValue() == 50 );
REQUIRE( variable.IsNumber() == true );
variable = "MyString";
REQUIRE( variable.GetString() == "MyString" );
REQUIRE( variable.IsNumber() == false );
variable = "MyRealStdString";
REQUIRE( variable.GetString() == "MyRealStdString" );
REQUIRE( variable.IsNumber() == false );
}
}
TEST_CASE( "EventsList", "[common][events]" ) {
SECTION("Basics") {
gd::EventsList list;

View File

@@ -84,7 +84,7 @@ TEST_CASE( "Resources", "[common][resources]" ) {
gd::ProjectResourcesAdder::RemoveAllUselessImages(project);
std::vector<gd::String> remainingResources =
project.GetResourcesManager().GetAllResourcesList();
project.GetResourcesManager().GetAllResourceNames();
REQUIRE(remainingResources.size() == 2);
REQUIRE(remainingResources[0] == "res1");
REQUIRE(remainingResources[1] == "res4");

89
Core/tests/Variable.cpp Normal file
View File

@@ -0,0 +1,89 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
/**
* @file Tests covering events of GDevelop Core.
*/
#include "catch.hpp"
#include <algorithm>
#include <initializer_list>
#include <map>
#include "GDCore/CommonTools.h"
#include "GDCore/Project/VariablesContainer.h"
TEST_CASE( "Variable", "[common][variables]" ) {
SECTION("Basics") {
gd::Variable variable;
variable.SetValue(50);
REQUIRE( variable.GetValue() == 50 );
REQUIRE( variable == 50 );
REQUIRE( variable.IsNumber() == true );
REQUIRE( variable.IsStructure() == false );
variable.SetString("MyString");
REQUIRE( variable.GetString() == "MyString" );
REQUIRE( variable == "MyString" );
REQUIRE( variable.IsNumber() == false );
REQUIRE( variable.IsStructure() == false );
}
SECTION("Conversions") {
gd::Variable variable;
variable.SetValue(50);
REQUIRE( variable.GetString() == "50" ); //Used as a string...
REQUIRE( variable.IsNumber() == false ); //...so consider as a string
variable.SetString("MyString");
REQUIRE( variable.GetValue() == 0 ); //Used as a number...
REQUIRE( variable.IsNumber() == true ); //...so consider as a number
}
SECTION("Use with int and string like semantics") {
gd::Variable variable;
variable = 50;
REQUIRE( variable.GetValue() == 50 );
REQUIRE( variable.IsNumber() == true );
variable = "MyString";
REQUIRE( variable.GetString() == "MyString" );
REQUIRE( variable.IsNumber() == false );
variable = "MyRealStdString";
REQUIRE( variable.GetString() == "MyRealStdString" );
REQUIRE( variable.IsNumber() == false );
}
SECTION("Copy and assignment") {
gd::Variable variable1;
gd::Variable variable2;
variable1.GetChild("Child1").SetString("Hello World");
variable1.GetChild("Child2").SetValue(42);
gd::Variable variable3(variable1);
variable2 = variable1;
REQUIRE( variable2.HasChild("Child1") == true );
REQUIRE( variable2.HasChild("Child2") == true );
REQUIRE( variable3.HasChild("Child1") == true );
REQUIRE( variable3.HasChild("Child2") == true );
REQUIRE( variable1.GetChild("Child1").GetString() == "Hello World" );
REQUIRE( variable1.GetChild("Child2").GetValue() == 42 );
REQUIRE( variable2.GetChild("Child1").GetString() == "Hello World" );
REQUIRE( variable2.GetChild("Child2").GetValue() == 42 );
REQUIRE( variable3.GetChild("Child1").GetString() == "Hello World" );
REQUIRE( variable3.GetChild("Child2").GetValue() == 42 );
variable2.GetChild("Child1").SetString("Hello copied World");
variable2.GetChild("Child2").SetValue(43);
variable3.GetChild("Child1").SetString("Hello second copied World");
variable3.GetChild("Child2").SetValue(44);
REQUIRE( variable1.GetChild("Child1").GetString() == "Hello World" );
REQUIRE( variable1.GetChild("Child2").GetValue() == 42 );
REQUIRE( variable2.GetChild("Child1").GetString() == "Hello copied World" );
REQUIRE( variable2.GetChild("Child2").GetValue() == 43 );
REQUIRE( variable3.GetChild("Child1").GetString() == "Hello second copied World" );
REQUIRE( variable3.GetChild("Child2").GetValue() == 44 );
}
}

View File

@@ -0,0 +1,52 @@
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
/**
* @file Tests covering events of GDevelop Core.
*/
#include "catch.hpp"
#include <algorithm>
#include <initializer_list>
#include <map>
#include "GDCore/CommonTools.h"
#include "GDCore/Project/VariablesContainer.h"
TEST_CASE( "VariablesContainer", "[common][variables]" ) {
SECTION("Copy and assignment") {
gd::VariablesContainer container1;
gd::VariablesContainer container2;
container1.InsertNew("Variable1", 0).SetString("Hello World");
container1.InsertNew("Variable2", 0).SetValue(42);
gd::VariablesContainer container3(container1);
container2 = container1;
REQUIRE( container2.Has("Variable1") == true );
REQUIRE( container2.Has("Variable2") == true );
REQUIRE( container3.Has("Variable1") == true );
REQUIRE( container3.Has("Variable2") == true );
REQUIRE( container1.Get("Variable1").GetString() == "Hello World" );
REQUIRE( container1.Get("Variable2").GetValue() == 42 );
REQUIRE( container2.Get("Variable1").GetString() == "Hello World" );
REQUIRE( container2.Get("Variable2").GetValue() == 42 );
REQUIRE( container3.Get("Variable1").GetString() == "Hello World" );
REQUIRE( container3.Get("Variable2").GetValue() == 42 );
container2.Get("Variable1").SetString("Hello copied World");
container2.Get("Variable2").SetValue(43);
container3.Get("Variable1").SetString("Hello second copied World");
container3.Get("Variable2").SetValue(44);
REQUIRE( container1.Get("Variable1").GetString() == "Hello World" );
REQUIRE( container1.Get("Variable2").GetValue() == 42 );
REQUIRE( container2.Get("Variable1").GetString() == "Hello copied World" );
REQUIRE( container2.Get("Variable2").GetValue() == 43 );
REQUIRE( container3.Get("Variable1").GetString() == "Hello second copied World" );
REQUIRE( container3.Get("Variable2").GetValue() == 44 );
}
}

View File

@@ -66,11 +66,11 @@ public:
for(auto & child : variable.GetAllChildren())
{
const gd::String & name = child.first;
const gd::Variable & serializedItem = child.second;
inventory.SetMaximum(name, serializedItem.GetChild("maxCount").GetValue());
inventory.SetUnlimited(name, serializedItem.GetChild("unlimited").GetString() == "true");
inventory.SetCount(name, serializedItem.GetChild("count").GetValue());
inventory.Equip(name, serializedItem.GetChild("equipped").GetString() == "true");
const auto & serializedItem = child.second;
inventory.SetMaximum(name, serializedItem->GetChild("maxCount").GetValue());
inventory.SetUnlimited(name, serializedItem->GetChild("unlimited").GetString() == "true");
inventory.SetCount(name, serializedItem->GetChild("count").GetValue());
inventory.Equip(name, serializedItem->GetChild("equipped").GetString() == "true");
}
}

View File

@@ -4,11 +4,11 @@
Light_Manager::Light_Manager() :
commonBlurEffectLoaded(false)
{
std::cout << "Creating Light Manager";
std::cout << "Creating Light Manager" << std::endl;
}
Light_Manager::~Light_Manager()
{
std::cout << "Destroying Light Manager";
std::cout << "Destroying Light Manager" << std::endl;
}

View File

@@ -17,7 +17,7 @@ This project is released under the MIT License.
class ScenePhysicsDatas : public gd::BehaviorsSharedData
{
public:
ScenePhysicsDatas() : BehaviorsSharedData(), gravityX(0), gravityY(0), scaleX(100), scaleY(100)
ScenePhysicsDatas() : BehaviorsSharedData(), gravityX(0), gravityY(9), scaleX(100), scaleY(100)
{
};
virtual ~ScenePhysicsDatas() {};

View File

@@ -106,6 +106,7 @@ BaseObjectExtension::BaseObjectExtension()
GetAllConditions()["NbObjet"].SetFunctionName("PickedObjectsCount").SetManipulatedType("number").SetIncludeFile("GDCpp/Extensions/Builtin/ObjectTools.h");
GetAllConditions()["CollisionNP"].SetFunctionName("HitBoxesCollision").SetIncludeFile("GDCpp/Extensions/Builtin/ObjectTools.h");
GetAllConditions()["EstTourne"].SetFunctionName("ObjectsTurnedToward").SetIncludeFile("GDCpp/Extensions/Builtin/ObjectTools.h");
GetAllConditions()["Raycast"].SetFunctionName("RaycastObject").SetIncludeFile("GDCpp/Extensions/Builtin/RuntimeSceneTools.h");
GetAllExpressions()["Count"].SetFunctionName("PickedObjectsCount").SetIncludeFile("GDCpp/Extensions/Builtin/ObjectTools.h");
#endif

View File

@@ -245,11 +245,10 @@ gd::String GD_API VariableStructureToJSON(const gd::Variable & variable)
gd::String str = "{";
bool firstChild = true;
for(std::map<gd::String, gd::Variable>::const_iterator i = variable.GetAllChildren().begin();
i != variable.GetAllChildren().end();++i)
for(auto i = variable.GetAllChildren().begin(); i != variable.GetAllChildren().end();++i)
{
if ( !firstChild ) str += ",";
str += gd::String::FromUTF8(StringToQuotedJSONString(i->first.c_str()))+": "+VariableStructureToJSON(i->second);
str += gd::String::FromUTF8(StringToQuotedJSONString(i->first.c_str()))+": "+VariableStructureToJSON(*i->second);
firstChild = false;
}

View File

@@ -22,6 +22,9 @@
#include "GDCpp/Runtime/CommonTools.h"
#include "GDCpp/Runtime/Project/Variable.h"
#include "GDCpp/Extensions/CppPlatform.h"
#include "GDCpp/Runtime/PolygonCollision.h"
#include "GDCpp/Runtime/Polygon2d.h"
#include <iostream>
gd::String GD_API GetSceneName(RuntimeScene & scene)
{
@@ -208,6 +211,48 @@ bool GD_API PickNearestObject(std::map <gd::String, std::vector<RuntimeObject*>
return true;
}
bool GD_API RaycastObject(std::map <gd::String, std::vector<RuntimeObject*> *> pickedObjectLists, float x, float y, float angle, float dist, gd::Variable & varX, gd::Variable & varY, bool inverted)
{
RuntimeObject * matchObject = NULL;
float testSqDist = inverted ? 0 : dist*dist;
float resultX = 0.0f;
float resultY = 0.0f;
for (auto it = pickedObjectLists.begin(); it != pickedObjectLists.end(); ++it)
{
if ( it->second == NULL ) continue;
auto list = *it->second;
for (std::size_t i = 0; i < list.size(); ++i)
{
RaycastResult result = list[i]->RaycastTest(x, y, angle, dist, !inverted);
if( result.collision ) {
if ( !inverted && (result.closeSqDist <= testSqDist) ) {
testSqDist = result.closeSqDist;
matchObject = list[i];
resultX = result.closePoint.x;
resultY = result.closePoint.y;
}
else if ( inverted && (result.farSqDist >= testSqDist) ) {
testSqDist = result.farSqDist;
matchObject = list[i];
resultX = result.farPoint.x;
resultY = result.farPoint.y;
}
}
}
}
if ( !matchObject )
return false;
PickOnly(pickedObjectLists, matchObject);
varX.SetValue(resultX);
varY.SetValue(resultY);
return true;
}
bool GD_API SceneVariableExists(RuntimeScene & scene, const gd::String & variable)
{
return scene.GetVariables().Has(variable);
@@ -242,7 +287,7 @@ unsigned int GD_API GetVariableChildCount(gd::Variable & variable)
{
if (variable.IsStructure() == false) return 0;
return variable.GetAllChildren().size();
return variable.GetChildrenCount();
}
double GD_API GetVariableValue(const gd::Variable & variable)

View File

@@ -94,6 +94,11 @@ bool GD_API PickRandomObject(RuntimeScene & scene, std::map <gd::String, std::ve
*/
bool GD_API PickNearestObject(std::map <gd::String, std::vector<RuntimeObject*> *> pickedObjectLists, double x, double y, bool inverted);
/**
* Only used internally by GD events generated code.
*/
bool GD_API RaycastObject(std::map <gd::String, std::vector<RuntimeObject*> *> pickedObjectLists, float x, float y, float angle, float dist, gd::Variable & varX, gd::Variable & varY, bool inverted);
/**
* Only used internally by GD events generated code.
*/

View File

@@ -7,6 +7,7 @@
#include "GDCpp/Runtime/Polygon2d.h"
#include <cmath>
#include <cfloat>
#include <algorithm>
namespace
{
@@ -30,6 +31,13 @@ float dotProduct(const sf::Vector2f a, const sf::Vector2f b)
return dp;
}
float crossProduct(const sf::Vector2f a, const sf::Vector2f b)
{
float cp = a.x*b.y - a.y*b.x;
return cp;
}
void project(const sf::Vector2f axis, const Polygon2d & p, float& min, float& max)
{
float dp = dotProduct(axis, p.vertices[0]);
@@ -129,6 +137,96 @@ CollisionResult GD_API PolygonCollisionTest(Polygon2d & p1, Polygon2d & p2)
return result;
}
RaycastResult GD_API PolygonRaycastTest(Polygon2d & poly, float startX, float startY, float endX, float endY)
{
RaycastResult result;
result.collision = false;
if ( poly.vertices.size() < 2 )
{
return result;
}
poly.ComputeEdges();
sf::Vector2f p, q, r, s;
float minSqDist = FLT_MAX;
// Ray segment: p + t*r, with p = start and r = end - start
p.x = startX;
p.y = startY;
r.x = endX - startX;
r.y = endY - startY;
for( int i=0; i<poly.edges.size(); i++ )
{
// Edge segment: q + u*s
q = poly.vertices[i];
s = poly.edges[i];
sf::Vector2f deltaQP = q - p;
float crossRS = crossProduct(r, s);
float t = crossProduct(deltaQP, s) / crossRS;
float u = crossProduct(deltaQP, r) / crossRS;
// Collinear
if ( abs(crossRS) <= 0.0001 && abs(crossProduct(deltaQP, r)) <= 0.0001 )
{
// Project the ray and the edge to work on floats, keeping linearity through t
sf::Vector2f axis(r.x, r.y);
normalise(axis);
float rayA = 0.0f;
float rayB = dotProduct(axis, r);
float edgeA = dotProduct(axis, deltaQP);
float edgeB = dotProduct(axis, deltaQP + s);
// Get overlapping range
float minOverlap = std::max(std::min(rayA, rayB), std::min(edgeA, edgeB));
float maxOverlap = std::min(std::max(rayA, rayB), std::max(edgeA, edgeB));
if( minOverlap > maxOverlap ){
return result;
}
result.collision = true;
// Zero distance ray
if( rayB == 0.0f ){
result.closePoint = p;
result.closeSqDist = 0.0f;
result.farPoint = p;
result.farSqDist = 0.0f;
}
float t1 = minOverlap / abs(rayB);
float t2 = maxOverlap / abs(rayB);
result.closePoint = p + t1*r;
result.closeSqDist = t1*t1*(r.x*r.x + r.y*r.y);
result.farPoint = p + t2*r;
result.farSqDist = t2*t2*(r.x*r.x + r.y*r.y);
return result;
}
else if ( crossRS != 0 && 0<=t && t<=1 && 0<=u && u<=1 )
{
sf::Vector2f point = p + t*r;
float sqDist = (point.x-startX)*(point.x-startX) + (point.y-startY)*(point.y-startY);
if ( sqDist < minSqDist )
{
if ( !result.collision ){
result.farPoint = point;
result.farSqDist = sqDist;
}
minSqDist = sqDist;
result.closePoint = point;
result.closeSqDist = sqDist;
result.collision = true;
}
else
{
result.farPoint = point;
result.farSqDist = sqDist;
}
}
}
return result;
}
bool GD_API IsPointInsidePolygon(Polygon2d & poly, float x, float y)
{
bool inside = false;

View File

@@ -19,6 +19,15 @@ struct CollisionResult
sf::Vector2f move_axis;
};
struct RaycastResult
{
bool collision;
sf::Vector2f closePoint;
float closeSqDist;
sf::Vector2f farPoint;
float farSqDist;
};
/**
* Do a collision test between the two polygons.
* \warning Polygons must convexes.
@@ -33,6 +42,17 @@ struct CollisionResult
*/
CollisionResult GD_API PolygonCollisionTest(Polygon2d & p1, Polygon2d & p2);
/**
* Do a raycast test.
* \warning Polygon must be convex.
* For some theory check "Find the Intersection Point of Two Line Segments" (https://www.codeproject.com/Tips/862988/Find-the-Intersection-Point-of-Two-Line-Segments)
*
* \return A raycast result with the contact points and distances
*
* \ingroup GameEngine
*/
RaycastResult GD_API PolygonRaycastTest(Polygon2d & poly, float startX, float startY, float endX, float endY);
/**
* Check if a point is inside a polygon.
*

View File

@@ -4,6 +4,7 @@
* This project is released under the MIT License.
*/
#include <cstring>
#include <cmath>
#include "GDCore/Tools/Localization.h"
#include "GDCpp/Extensions/Builtin/MathematicalTools.h"
#include "GDCpp/Runtime/RuntimeObject.h"
@@ -390,6 +391,43 @@ bool RuntimeObject::IsCollidingWithPoint(float pointX, float pointY){
return false;
}
RaycastResult RuntimeObject::RaycastTest(float x, float y, float angle, float dist, bool closest){
float objW = GetWidth();
float objH = GetHeight();
float diffX = GetDrawableX()+GetCenterX() - x;
float diffY = GetDrawableY()+GetCenterY() - y;
float boundingRadius = sqrt(objW*objW + objH*objH)/2.0;
RaycastResult result;
result.collision = false;
if ( sqrt(diffX*diffX + diffY*diffY) > boundingRadius + dist )
return result;
float endX = x + dist*cos(angle*3.14159/180.0);
float endY = y + dist*sin(angle*3.14159/180.0);
float testSqDist = closest ? dist*dist : 0.0f;
vector<Polygon2d> hitboxes = GetHitBoxes();
for (std::size_t i = 0; i < hitboxes.size(); ++i)
{
RaycastResult res = PolygonRaycastTest(hitboxes[i], x, y, endX, endY);
if ( res.collision ) {
if ( closest && (res.closeSqDist < testSqDist) ) {
testSqDist = res.closeSqDist;
result = res;
}
else if ( !closest && (res.farSqDist > testSqDist) && (res.farSqDist <= dist*dist) ) {
testSqDist = res.farSqDist;
result = res;
}
}
}
return result;
}
void RuntimeObject::SeparateObjectsWithoutForces( std::map <gd::String, std::vector<RuntimeObject*> *> pickedObjectLists)
{
vector<RuntimeObject*> objects2;
@@ -714,5 +752,5 @@ void RuntimeObject::VariableClearChildren(gd::Variable & variable)
unsigned int RuntimeObject::GetVariableChildCount(gd::Variable & variable)
{
if (variable.IsStructure() == false) return 0;
return variable.GetAllChildren().size();
return variable.GetChildrenCount();
}

View File

@@ -20,6 +20,7 @@ namespace gd { class InitialInstance; }
namespace gd { class Object; }
namespace sf { class RenderTarget; }
class Polygon2d;
class RaycastResult;
class RuntimeScene;
/**
@@ -231,6 +232,17 @@ public:
*/
bool IsCollidingWithPoint(float pointX, float pointY);
/**
* \brief Check if a ray intersect any object hitbox.
* \param x The raycast source X
* \param y The raycast source Y
* \param angle The raycast angle
* \param dist The raycast max distance
* \param closest Get the closest or farthest collision mask result?
* \return A raycast result with the contact points and distances
*/
RaycastResult RaycastTest(float x, float y, float angle, float dist, bool closest);
/**
* \brief Check collision with each object of the list using their hitboxes, and move the object
* according to the sum of the move vector returned by each collision test.

View File

@@ -38,15 +38,16 @@ void RuntimeVariablesContainer::Merge(const gd::VariablesContainer & container)
{
for ( std::size_t i = 0; i<container.Count();++i)
{
const std::pair<gd::String, gd::Variable> & variable = container.Get(i);
const gd::String & name = container.GetNameAt(i);
const gd::Variable & variable = container.Get(i);
if ( Has(variable.first) )
Get(variable.first) = variable.second;
if ( Has(name) )
Get(name) = variable;
else
{
gd::Variable * newVariable = new gd::Variable(variable.second);
gd::Variable * newVariable = new gd::Variable(variable);
variablesArray.push_back(newVariable);
variables[variable.first] = newVariable;
variables[name] = newVariable;
}
}
}

View File

@@ -101,6 +101,7 @@ BaseObjectExtension::BaseObjectExtension()
GetAllConditions()["CollisionNP"]
.AddCodeOnlyParameter("currentScene", "") //We need an extra parameter pointing to the scene.
.SetFunctionName("gdjs.evtTools.object.hitBoxesCollisionTest");
GetAllConditions()["Raycast"].SetFunctionName("gdjs.evtTools.object.raycastObject");
GetAllConditions()["Distance"].SetFunctionName("gdjs.evtTools.object.distanceTest");
GetAllConditions()["SeDirige"].SetFunctionName("gdjs.evtTools.object.movesTowardTest");
GetAllConditions()["EstTourne"].SetFunctionName("gdjs.evtTools.object.turnedTowardTest");

View File

@@ -97,8 +97,9 @@ bool Exporter::ExportWholePixiProject(gd::Project & project, gd::String exportDi
bool minify, bool exportForCordova)
{
ExporterHelper helper(fs, gdjsRoot, codeOutputDir);
gd::Project exportedProject = project;
auto exportProject = [this, &project, &minify,
auto exportProject = [this, &exportedProject, &minify,
&exportForCordova, &helper](gd::String exportDir)
{
wxProgressDialog * progressDialogPtr = NULL;
@@ -111,8 +112,6 @@ bool Exporter::ExportWholePixiProject(gd::Project & project, gd::String exportDi
fs.MkDir(exportDir);
std::vector<gd::String> includesFiles;
gd::Project exportedProject = project;
//Export the resources (before generating events as some resources filenames may be updated)
helper.ExportResources(fs, exportedProject, exportDir, progressDialogPtr);
@@ -168,11 +167,12 @@ bool Exporter::ExportWholePixiProject(gd::Project & project, gd::String exportDi
{
//Prepare the export directory
fs.MkDir(exportDir);
if (!helper.ExportCordovaConfigFile(project, exportDir))
return false;
if (!exportProject(exportDir + "/www"))
return false;
if (!helper.ExportCordovaConfigFile(exportedProject, exportDir))
return false;
} else {
if (!exportProject(exportDir))
return false;

View File

@@ -58,9 +58,10 @@ static void GenerateFontsDeclaration(gd::AbstractFileSystem & fs, const gd::Stri
css += urlPrefix + relativeFile;
css +="') format('truetype'); }";
// Use the font for a dummy text to trigger immediate load of the font at game startup
html += "<div style=\"font-family: 'gdjs_font_";
html += relativeFile;
html += "';\">.</div>";
html += "'; color: black;\">.</div>";
}
}
@@ -79,6 +80,9 @@ bool ExporterHelper::ExportLayoutForPixiPreview(gd::Project & project, gd::Layou
gd::Project exportedProject = project;
// Always disable the splash for preview
exportedProject.GetLoadingScreen().ShowGDevelopSplash(false);
//Export resources (*before* generating events as some resources filenames may be updated)
ExportResources(fs, exportedProject, exportDir);
//Generate events code
@@ -156,10 +160,42 @@ bool ExporterHelper::ExportPixiIndexFile(gd::String source, gd::String exportDir
bool ExporterHelper::ExportCordovaConfigFile(const gd::Project & project, gd::String exportDir)
{
auto & platformSpecificAssets = project.GetPlatformSpecificAssets();
auto & resourceManager = project.GetResourcesManager();
auto getIconFilename = [&resourceManager, &platformSpecificAssets](const gd::String & platform, const gd::String & name) {
const gd::String & file = resourceManager.GetResource(platformSpecificAssets.Get(platform, name)).GetFile();
return file.empty() ? "" : "www/" + file;
};
gd::String str = fs.ReadFile(gdjsRoot + "/Runtime/Cordova/config.xml")
.FindAndReplace("GDJS_PROJECTNAME", project.GetName())
.FindAndReplace("GDJS_PACKAGENAME", project.GetPackageName())
.FindAndReplace("GDJS_ORIENTATION", "default");
.FindAndReplace("GDJS_ORIENTATION", project.GetOrientation())
// Android icons
.FindAndReplace("GDJS_ICON_ANDROID_36", getIconFilename("android", "icon-36"))
.FindAndReplace("GDJS_ICON_ANDROID_48", getIconFilename("android", "icon-48"))
.FindAndReplace("GDJS_ICON_ANDROID_72", getIconFilename("android", "icon-72"))
.FindAndReplace("GDJS_ICON_ANDROID_96", getIconFilename("android", "icon-96"))
.FindAndReplace("GDJS_ICON_ANDROID_144", getIconFilename("android", "icon-144"))
.FindAndReplace("GDJS_ICON_ANDROID_192", getIconFilename("android", "icon-192"))
// iOS icons
.FindAndReplace("GDJS_ICON_IOS_180", getIconFilename("ios", "icon-180"))
.FindAndReplace("GDJS_ICON_IOS_60", getIconFilename("ios", "icon-60"))
.FindAndReplace("GDJS_ICON_IOS_120", getIconFilename("ios", "icon-120"))
.FindAndReplace("GDJS_ICON_IOS_76", getIconFilename("ios", "icon-76"))
.FindAndReplace("GDJS_ICON_IOS_152", getIconFilename("ios", "icon-152"))
.FindAndReplace("GDJS_ICON_IOS_40", getIconFilename("ios", "icon-40"))
.FindAndReplace("GDJS_ICON_IOS_80", getIconFilename("ios", "icon-80"))
.FindAndReplace("GDJS_ICON_IOS_57", getIconFilename("ios", "icon-57"))
.FindAndReplace("GDJS_ICON_IOS_114", getIconFilename("ios", "icon-114"))
.FindAndReplace("GDJS_ICON_IOS_72", getIconFilename("ios", "icon-72"))
.FindAndReplace("GDJS_ICON_IOS_144", getIconFilename("ios", "icon-144"))
.FindAndReplace("GDJS_ICON_IOS_167", getIconFilename("ios", "icon-167"))
.FindAndReplace("GDJS_ICON_IOS_29", getIconFilename("ios", "icon-29"))
.FindAndReplace("GDJS_ICON_IOS_58", getIconFilename("ios", "icon-58"))
.FindAndReplace("GDJS_ICON_IOS_50", getIconFilename("ios", "icon-50"))
.FindAndReplace("GDJS_ICON_IOS_100", getIconFilename("ios", "icon-100"))
;
if (!fs.WriteToFile(exportDir + "/config.xml", str))
{
@@ -196,14 +232,14 @@ bool ExporterHelper::ExportCocos2dFiles(const gd::Project & project, gd::String
std::vector<gd::String> noIncludesInThisFile;
if (!CompleteIndexFile(str, customCss, customHtml, exportDir, noIncludesInThisFile, ""))
{
lastError = "Unable to complete Cocos2d index.html file.";
lastError = "Unable to complete Cocos2d-JS index.html file.";
return false;
}
//Write the index.html file
if (!fs.WriteToFile(exportDir + "/index.html", str))
{
lastError = "Unable to write Cocos2d index.html file.";
lastError = "Unable to write Cocos2d-JS index.html file.";
return false;
}
}
@@ -229,7 +265,7 @@ bool ExporterHelper::ExportCocos2dFiles(const gd::Project & project, gd::String
if (!fs.WriteToFile(exportDir + "/project.json", str))
{
lastError = "Unable to write Cocos2d project.json file.";
lastError = "Unable to write Cocos2d-JS project.json file.";
return false;
}
}
@@ -337,6 +373,7 @@ bool ExporterHelper::ExportEventsCode(gd::Project & project, gd::String outputDi
//First, do not forget common includes (they must be included before events generated code files).
InsertUnique(includesFiles, "libs/jshashtable.js");
InsertUnique(includesFiles, "gd.js");
InsertUnique(includesFiles, "gd-splash-image.js");
InsertUnique(includesFiles, "libs/hshg.js");
InsertUnique(includesFiles, "libs/rbush.js");
InsertUnique(includesFiles, "inputmanager.js");

View File

@@ -12,10 +12,47 @@
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
<icon src="GDJS_ICON_ANDROID_36" density="ldpi" />
<icon src="GDJS_ICON_ANDROID_48" density="mdpi" />
<icon src="GDJS_ICON_ANDROID_72" density="hdpi" />
<icon src="GDJS_ICON_ANDROID_96" density="xhdpi" />
<icon src="GDJS_ICON_ANDROID_144" density="xxhdpi" />
<icon src="GDJS_ICON_ANDROID_192" density="xxxhdpi" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<!-- iOS 8.0+ -->
<!-- iPhone 6 Plus -->
<icon src="GDJS_ICON_IOS_180" width="180" height="180" />
<!-- iOS 7.0+ -->
<!-- iPhone / iPod Touch -->
<icon src="GDJS_ICON_IOS_60" width="60" height="60" />
<icon src="GDJS_ICON_IOS_120" width="120" height="120" />
<!-- iPad -->
<icon src="GDJS_ICON_IOS_76" width="76" height="76" />
<icon src="GDJS_ICON_IOS_152" width="152" height="152" />
<!-- Spotlight Icon -->
<icon src="GDJS_ICON_IOS_40" width="40" height="40" />
<icon src="GDJS_ICON_IOS_80" width="80" height="80" />
<!-- iOS 6.1 -->
<!-- iPhone / iPod Touch -->
<icon src="GDJS_ICON_IOS_57" width="57" height="57" />
<icon src="GDJS_ICON_IOS_114" width="114" height="114" />
<!-- iPad -->
<icon src="GDJS_ICON_IOS_72" width="72" height="72" />
<icon src="GDJS_ICON_IOS_144" width="144" height="144" />
<!-- iPad Pro -->
<icon src="GDJS_ICON_IOS_167" width="167" height="167" />
<!-- iPhone Spotlight and Settings Icon -->
<icon src="GDJS_ICON_IOS_29" width="29" height="29" />
<icon src="GDJS_ICON_IOS_58" width="58" height="58" />
<!-- iPad Spotlight and Settings Icon -->
<icon src="GDJS_ICON_IOS_50" width="50" height="50" />
<icon src="GDJS_ICON_IOS_100" width="100" height="100" />
<!-- iPad Pro -->
<icon src="GDJS_ICON_IOS_167" width="167" height="167" />
</platform>
<preference name="orientation" value="GDJS_ORIENTATION" />
<preference name="BackgroundColor" value="0xff000000"/>
</widget>

View File

@@ -4,7 +4,7 @@
* This project is released under the MIT License.
*/
gdjs.LoadingScreenCocosRenderer = function(runtimeGamePixiRenderer)
gdjs.LoadingScreenCocosRenderer = function(runtimeGamePixiRenderer, loadingScreenSetup)
{
}
@@ -13,3 +13,7 @@ gdjs.LoadingScreenRenderer = gdjs.LoadingScreenCocosRenderer; //Register the cla
gdjs.LoadingScreenCocosRenderer.prototype.render = function(percent) {
console.log("Loading " + percent + "%");
};
gdjs.LoadingScreenCocosRenderer.prototype.unload = function() {
// Nothing to do
};

View File

@@ -316,6 +316,47 @@ gdjs.evtTools.object.pickNearestObject = function(objectsLists, x, y, inverted)
return true;
};
gdjs.evtTools.object.raycastObject = function(objectsLists, x, y, angle, dist, varX, varY, inverted) {
var matchObject = null;
var testSqDist = inverted ? 0 : dist*dist;
var resultX = 0;
var resultY = 0;
var lists = gdjs.staticArray(gdjs.evtTools.object.raycastObject);
objectsLists.values(lists);
for (var i = 0; i < lists.length; i++) {
var list = lists[i];
for (var j = 0; j < list.length; j++) {
var object = list[j];
var result = object.raycastTest(x, y, angle, dist, !inverted);
if( result.collision ) {
if ( !inverted && (result.closeSqDist <= testSqDist) ) {
testSqDist = result.closeSqDist;
matchObject = object;
resultX = result.closeX;
resultY = result.closeY;
}
else if ( inverted && (result.farSqDist >= testSqDist) ) {
testSqDist = result.farSqDist;
matchObject = object;
resultX = result.farX;
resultY = result.farY;
}
}
}
}
if ( !matchObject )
return false;
gdjs.evtTools.object.pickOnly(objectsLists, matchObject);
varX.setNumber(resultX);
varY.setNumber(resultY);
return true;
};
/**
* Do the work of creating a new object
* @private

View File

@@ -108,13 +108,13 @@ gdjs.evtTools.runtimeScene.getTime = function(runtimeScene, what) {
else if ( what === "sec" )
return now.getSeconds();
else if ( what === "mday" )
return now.getdate();
return now.getDate();
else if ( what === "mon" )
return now.getMonth();
else if ( what === "year" )
return now.getFullYear() - 1900; //Conform to the C way of returning years.
else if ( what === "wday" )
return now.getday();
return now.getDay();
else if ( what === "yday" ) {
var start = new Date(now.getFullYear(), 0, 0);
var diff = now - start;

File diff suppressed because one or more lines are too long

View File

@@ -2,6 +2,13 @@
<html>
<head>
<meta charset="UTF-8"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="theme-color" content="#000000" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
body {
margin: 0;

View File

@@ -1,16 +1,70 @@
gdjs.LoadingScreenPixiRenderer = function(runtimeGamePixiRenderer)
{
this._pixiRenderer = runtimeGamePixiRenderer.getPIXIRenderer();
this._loadingScreen = new PIXI.Container();
this._text = new PIXI.Text(" ", {font: "bold 60px Arial", fill: "#FFFFFF", align: "center"});
this._loadingScreen.addChild(this._text);
this._text.position.y = this._pixiRenderer.height/2;
}
gdjs.LoadingScreenPixiRenderer = function(runtimeGamePixiRenderer, loadingScreenSetup) {
this._pixiRenderer = runtimeGamePixiRenderer.getPIXIRenderer();
this._loadingScreen = new PIXI.Container();
this._progressText = new PIXI.Text(' ', {
font: '30px Arial',
fill: '#FFFFFF',
align: 'center',
});
this._loadingScreen.addChild(this._progressText);
if (loadingScreenSetup && loadingScreenSetup.showGDevelopSplash) {
this._madeWithText = new PIXI.Text('Made with', {
font: '30px Arial',
fill: '#FFFFFF',
align: 'center',
});
this._madeWithText.position.y = this._pixiRenderer.height / 2 - 130;
this._websiteText = new PIXI.Text('gdevelop-app.com', {
font: '30px Arial',
fill: '#FFFFFF',
align: 'center',
});
this._websiteText.position.y = this._pixiRenderer.height / 2 + 100;
this._splashImage = new PIXI.Sprite.fromImage(gdjs.splashImage);
this._splashImage.position.x = this._pixiRenderer.width / 2;
this._splashImage.position.y = this._pixiRenderer.height / 2;
this._splashImage.anchor.x = 0.5;
this._splashImage.anchor.y = 0.5;
this._splashImage.scale.x = this._pixiRenderer.width / 800;
this._splashImage.scale.y = this._pixiRenderer.width / 800;
this._loadingScreen.addChild(this._splashImage);
this._loadingScreen.addChild(this._madeWithText);
this._loadingScreen.addChild(this._websiteText);
}
};
gdjs.LoadingScreenRenderer = gdjs.LoadingScreenPixiRenderer; //Register the class to let the engine use it.
gdjs.LoadingScreenPixiRenderer.prototype.render = function(percent) {
this._text.text = percent + "%";
this._text.position.x = this._pixiRenderer.width/2 - this._text.width/2;
this._pixiRenderer.render(this._loadingScreen);
var screenBorder = 10;
if (this._madeWithText) {
this._madeWithText.position.x =
this._pixiRenderer.width / 2 - this._madeWithText.width / 2;
this._madeWithText.position.y =
this._pixiRenderer.height / 2 -
this._splashImage.height / 2 -
this._madeWithText.height -
20;
}
if (this._websiteText) {
this._websiteText.position.x =
this._pixiRenderer.width - this._websiteText.width - screenBorder;
this._websiteText.position.y =
this._pixiRenderer.height - this._websiteText.height - screenBorder;
}
this._progressText.text = percent + '%';
this._progressText.position.x = screenBorder;
this._progressText.position.y =
this._pixiRenderer.height - this._progressText.height - screenBorder;
this._pixiRenderer.render(this._loadingScreen);
};
gdjs.LoadingScreenPixiRenderer.prototype.unload = function() {
// Nothing to do
};

View File

@@ -219,6 +219,146 @@ gdjs.Polygon.collisionTest._statics = {
}
};
/**
* Do a raycast test.<br>
* Please note that the polygon must be <b>convex</b>!
* For some theory, check <a href="https://www.codeproject.com/Tips/862988/Find-the-Intersection-Point-of-Two-Line-Segments">Find the Intersection Point of Two Line Segments</a>
*
* @method raycastTest
* @static
* @param poly {Polygon} The polygon to test
* @param startX {Number} The raycast start point X
* @param startY {Number} The raycast start point Y
* @param endX {Number} The raycast end point X
* @param endY {Number} The raycast end point Y
* @return A raycast result with the contact points and distances
*/
gdjs.Polygon.raycastTest = function(poly, startX, startY, endX, endY)
{
var result = gdjs.Polygon.raycastTest._statics.result;
result.collision = false;
if ( poly.vertices.length < 2 )
{
return result;
}
poly.computeEdges();
var p = gdjs.Polygon.raycastTest._statics.p;
var q = gdjs.Polygon.raycastTest._statics.q;
var r = gdjs.Polygon.raycastTest._statics.r;
var s = gdjs.Polygon.raycastTest._statics.s;
var minSqDist = Number.MAX_VALUE;
// Ray segment: p + t*r, with p = start and r = end - start
p[0] = startX;
p[1] = startY;
r[0] = endX - startX;
r[1] = endY - startY;
for(var i=0; i<poly.edges.length; i++)
{
// Edge segment: q + u*s
q[0] = poly.vertices[i][0];
q[1] = poly.vertices[i][1];
s[0] = poly.edges[i][0];
s[1] = poly.edges[i][1];
var deltaQP = gdjs.Polygon.raycastTest._statics.deltaQP;
deltaQP[0] = q[0] - p[0];
deltaQP[1] = q[1] - p[1];
var crossRS = gdjs.Polygon.crossProduct(r, s);
var t = gdjs.Polygon.crossProduct(deltaQP, s) / crossRS;
var u = gdjs.Polygon.crossProduct(deltaQP, r) / crossRS;
// Collinear
if ( Math.abs(crossRS) <= 0.0001 && Math.abs(gdjs.Polygon.crossProduct(deltaQP, r)) <= 0.0001 )
{
// Project the ray and the edge to work on floats, keeping linearity through t
var axis = gdjs.Polygon.raycastTest._statics.axis;
axis[0] = r[0];
axis[1] = r[1];
gdjs.Polygon.normalise(axis);
var rayA = 0;
var rayB = gdjs.Polygon.dotProduct(axis, r);
var edgeA = gdjs.Polygon.dotProduct(axis, deltaQP);
var edgeB = gdjs.Polygon.dotProduct(axis, [deltaQP[0] + s[0], deltaQP[1] + s[1]]);
// Get overlapping range
var minOverlap = Math.max(Math.min(rayA, rayB), Math.min(edgeA, edgeB));
var maxOverlap = Math.min(Math.max(rayA, rayB), Math.max(edgeA, edgeB));
if( minOverlap > maxOverlap ){
return result;
}
result.collision = true;
// Zero distance ray
if( rayB === 0 ){
result.closeX = startX;
result.closeY = startY;
result.closeSqDist = 0;
result.farX = startX;
result.farY = startY;
result.farSqDist = 0;
}
var t1 = minOverlap / Math.abs(rayB);
var t2 = maxOverlap / Math.abs(rayB);
result.closeX = startX + t1*r[0];
result.closeY = startY + t1*r[1];
result.closeSqDist = t1*t1*(r[0]*r[0] + r[1]*r[1]);
result.farX = startX + t2*r[0];
result.farY = startY + t2*r[1];
result.farSqDist = t2*t2*(r[0]*r[0] + r[1]*r[1]);
return result;
}
// One point intersection
else if ( crossRS !== 0 && 0<=t && t<=1 && 0<=u && u<=1 )
{
var x = p[0] + t*r[0];
var y = p[1] + t*r[1];
var sqDist = (x-startX)*(x-startX) + (y-startY)*(y-startY);
if ( sqDist < minSqDist )
{
if ( !result.collision ){
result.farX = x;
result.farY = y;
result.farSqDist = sqDist;
}
minSqDist = sqDist;
result.closeX = x;
result.closeY = y;
result.closeSqDist = sqDist;
result.collision = true;
}
else
{
result.farX = x;
result.farY = y;
result.farSqDist = sqDist;
}
}
}
return result;
};
gdjs.Polygon.raycastTest._statics = {
p: [0,0],
q: [0,0],
r: [0,0],
s: [0,0],
deltaQP: [0,0],
axis: [0,0],
result: {
collision: false,
closeX: 0,
closeY: 0,
closeSqDist: 0,
farX: 0,
farY: 0,
farSqDist: 0
}
}
//Tools functions :
gdjs.Polygon.normalise = function(v)
{
@@ -237,6 +377,13 @@ gdjs.Polygon.dotProduct = function(a, b)
return dp;
}
gdjs.Polygon.crossProduct = function(a, b)
{
var cp = a[0]*b[1] - a[1]*b[0];
return cp;
}
gdjs.Polygon.project = function(axis, p, result)
{
var dp = gdjs.Polygon.dotProduct(axis, p.vertices[0]);

View File

@@ -13,38 +13,44 @@
* @param data The object (usually stored in data.json) containing the full project data
* @param spec Optional object for specifiying additional options: {forceFullscreen: ...}
*/
gdjs.RuntimeGame = function(data, spec)
{
spec = spec || {};
gdjs.RuntimeGame = function(data, spec) {
spec = spec || {};
this._variables = new gdjs.VariablesContainer(data.variables);
this._data = data;
this._imageManager = new gdjs.ImageManager(data.resources ? data.resources.resources : undefined);
this._soundManager = new gdjs.SoundManager(data.resources ? data.resources.resources : undefined);
this._minFPS = data ? parseInt(data.properties.minFPS, 10) : 15;
this._variables = new gdjs.VariablesContainer(data.variables);
this._data = data;
this._imageManager = new gdjs.ImageManager(
data.resources ? data.resources.resources : undefined
);
this._soundManager = new gdjs.SoundManager(
data.resources ? data.resources.resources : undefined
);
this._minFPS = data ? parseInt(data.properties.minFPS, 10) : 15;
this._defaultWidth = data.properties.windowWidth; //Default size for scenes cameras
this._defaultHeight = data.properties.windowHeight;
this._originalWidth = data.properties.windowWidth; //Original size of the game, won't be changed.
this._originalHeight = data.properties.windowHeight;
this._renderer = new gdjs.RuntimeGameRenderer(this,
this._defaultWidth, this._defaultHeight,
spec.forceFullscreen || false);
this._defaultWidth = data.properties.windowWidth; //Default size for scenes cameras
this._defaultHeight = data.properties.windowHeight;
this._originalWidth = data.properties.windowWidth; //Original size of the game, won't be changed.
this._originalHeight = data.properties.windowHeight;
this._renderer = new gdjs.RuntimeGameRenderer(
this,
this._defaultWidth,
this._defaultHeight,
spec.forceFullscreen || false
);
//Game loop management (see startGameLoop method)
this._sceneStack = new gdjs.SceneStack(this);
this._notifySceneForResize = false; //When set to true, the current scene is notified that canvas size changed.
//Game loop management (see startGameLoop method)
this._sceneStack = new gdjs.SceneStack(this);
this._notifySceneForResize = false; //When set to true, the current scene is notified that canvas size changed.
//Inputs :
this._inputManager = new gdjs.InputManager();
//Inputs :
this._inputManager = new gdjs.InputManager();
//Allow to specify an external layout to insert in the first scene:
this._injectExternalLayout = spec.injectExternalLayout || "";
//Allow to specify an external layout to insert in the first scene:
this._injectExternalLayout = spec.injectExternalLayout || '';
};
gdjs.RuntimeGame.prototype.getRenderer = function() {
return this._renderer;
}
return this._renderer;
};
/**
* Get the variables of the RuntimeGame.
@@ -52,7 +58,7 @@ gdjs.RuntimeGame.prototype.getRenderer = function() {
* @return a variablesContainer object.
*/
gdjs.RuntimeGame.prototype.getVariables = function() {
return this._variables;
return this._variables;
};
/**
@@ -61,7 +67,7 @@ gdjs.RuntimeGame.prototype.getVariables = function() {
* @return {gdjs.SoundManager} The sound manager.
*/
gdjs.RuntimeGame.prototype.getSoundManager = function() {
return this._soundManager;
return this._soundManager;
};
/**
@@ -70,7 +76,7 @@ gdjs.RuntimeGame.prototype.getSoundManager = function() {
* @return {gdjs.ImageManager} The image manager.
*/
gdjs.RuntimeGame.prototype.getImageManager = function() {
return this._imageManager;
return this._imageManager;
};
/**
@@ -79,7 +85,7 @@ gdjs.RuntimeGame.prototype.getImageManager = function() {
* @return The input manager owned by the game
*/
gdjs.RuntimeGame.prototype.getInputManager = function() {
return this._inputManager;
return this._inputManager;
};
/**
@@ -88,7 +94,7 @@ gdjs.RuntimeGame.prototype.getInputManager = function() {
* @return The object associated to the game.
*/
gdjs.RuntimeGame.prototype.getGameData = function() {
return this._data;
return this._data;
};
/**
@@ -99,20 +105,20 @@ gdjs.RuntimeGame.prototype.getGameData = function() {
* @return The data associated to the scene.
*/
gdjs.RuntimeGame.prototype.getSceneData = function(sceneName) {
var scene = undefined;
for(var i = 0, len = this._data.layouts.length;i<len;++i) {
var sceneData = this._data.layouts[i];
var scene = undefined;
for (var i = 0, len = this._data.layouts.length; i < len; ++i) {
var sceneData = this._data.layouts[i];
if ( sceneName === undefined || sceneData.name === sceneName ) {
scene = sceneData;
break;
}
}
if (sceneName === undefined || sceneData.name === sceneName) {
scene = sceneData;
break;
}
}
if ( scene === undefined )
console.warn("The game has no scene called \""+sceneName+"\"");
if (scene === undefined)
console.warn('The game has no scene called "' + sceneName + '"');
return scene;
return scene;
};
/**
@@ -123,17 +129,17 @@ gdjs.RuntimeGame.prototype.getSceneData = function(sceneName) {
* @return true if the scene exists. If sceneName is undefined, true if the game has a scene.
*/
gdjs.RuntimeGame.prototype.hasScene = function(sceneName) {
var isTrue = false;
for(var i = 0, len = this._data.layouts.length;i<len;++i) {
var sceneData = this._data.layouts[i];
var isTrue = false;
for (var i = 0, len = this._data.layouts.length; i < len; ++i) {
var sceneData = this._data.layouts[i];
if ( sceneName === undefined || sceneData.name == sceneName ) {
isTrue = true;
break;
}
}
if (sceneName === undefined || sceneData.name == sceneName) {
isTrue = true;
break;
}
}
return isTrue;
return isTrue;
};
/**
@@ -144,17 +150,17 @@ gdjs.RuntimeGame.prototype.hasScene = function(sceneName) {
* @return The data associated to the external layout or null if not found.
*/
gdjs.RuntimeGame.prototype.getExternalLayoutData = function(name) {
var externalLayout = null;
for(var i = 0, len = this._data.externalLayouts.length;i<len;++i) {
var layoutData = this._data.externalLayouts[i];
var externalLayout = null;
for (var i = 0, len = this._data.externalLayouts.length; i < len; ++i) {
var layoutData = this._data.externalLayouts[i];
if ( layoutData.name === name ) {
externalLayout = layoutData;
break;
}
if (layoutData.name === name) {
externalLayout = layoutData;
break;
}
}
return externalLayout;
return externalLayout;
};
/**
@@ -163,7 +169,7 @@ gdjs.RuntimeGame.prototype.getExternalLayoutData = function(name) {
* @return The data associated to the global objects.
*/
gdjs.RuntimeGame.prototype.getInitialObjectsData = function() {
return this._data.objects || [];
return this._data.objects || [];
};
/**
@@ -173,7 +179,7 @@ gdjs.RuntimeGame.prototype.getInitialObjectsData = function() {
* @method getOriginalWidth
*/
gdjs.RuntimeGame.prototype.getOriginalWidth = function() {
return this._originalWidth;
return this._originalWidth;
};
/**
@@ -183,7 +189,7 @@ gdjs.RuntimeGame.prototype.getOriginalWidth = function() {
* @method getOriginalHeight
*/
gdjs.RuntimeGame.prototype.getOriginalHeight = function() {
return this._originalHeight;
return this._originalHeight;
};
/**
@@ -192,7 +198,7 @@ gdjs.RuntimeGame.prototype.getOriginalHeight = function() {
* @method getDefaultWidth
*/
gdjs.RuntimeGame.prototype.getDefaultWidth = function() {
return this._defaultWidth;
return this._defaultWidth;
};
/**
@@ -201,7 +207,7 @@ gdjs.RuntimeGame.prototype.getDefaultWidth = function() {
* @method getDefaultHeight
*/
gdjs.RuntimeGame.prototype.getDefaultHeight = function() {
return this._defaultHeight;
return this._defaultHeight;
};
/**
@@ -211,7 +217,7 @@ gdjs.RuntimeGame.prototype.getDefaultHeight = function() {
* @param width {Number} The new default width
*/
gdjs.RuntimeGame.prototype.setDefaultWidth = function(width) {
this._defaultWidth = width;
this._defaultWidth = width;
};
/**
@@ -221,7 +227,7 @@ gdjs.RuntimeGame.prototype.setDefaultWidth = function(width) {
* @param height {Number} The new default height
*/
gdjs.RuntimeGame.prototype.setDefaultHeight = function(height) {
this._defaultHeight = height;
this._defaultHeight = height;
};
/**
@@ -230,7 +236,7 @@ gdjs.RuntimeGame.prototype.setDefaultHeight = function(height) {
* @method getMinimalFramerate
*/
gdjs.RuntimeGame.prototype.getMinimalFramerate = function() {
return this._minFPS;
return this._minFPS;
};
/**
@@ -238,60 +244,73 @@ gdjs.RuntimeGame.prototype.getMinimalFramerate = function() {
* @method loadAllAssets
*/
gdjs.RuntimeGame.prototype.loadAllAssets = function(callback) {
var loadingScreen = new gdjs.LoadingScreenRenderer(this.getRenderer());
var allAssetsTotal = this._data.resources.resources.length;
var loadingScreen = new gdjs.LoadingScreenRenderer(
this.getRenderer(),
this._data.properties.loadingScreen
);
var allAssetsTotal = this._data.resources.resources.length;
var that = this;
this._imageManager.loadTextures(function (count, total) {
loadingScreen.render(Math.floor(count / allAssetsTotal * 100));
}, function() {
that._soundManager.preloadAudio(function (count, total) {
loadingScreen.render(Math.floor((allAssetsTotal - total + count)
/ allAssetsTotal * 100));
}, function() {
callback();
});
});
var that = this;
this._imageManager.loadTextures(
function(count, total) {
loadingScreen.render(Math.floor(count / allAssetsTotal * 100));
},
function() {
that._soundManager.preloadAudio(
function(count, total) {
loadingScreen.render(
Math.floor((allAssetsTotal - total + count) / allAssetsTotal * 100)
);
},
function() {
loadingScreen.unload();
callback();
}
);
}
);
};
gdjs.RuntimeGame.prototype.startGameLoop = function() {
if ( !this.hasScene() ) {
console.log("The game has no scene.");
return;
if (!this.hasScene()) {
console.log('The game has no scene.');
return;
}
//Load the first scene
var firstSceneName = gdjs.projectData.firstLayout;
this._sceneStack.push(
this.hasScene(firstSceneName) ? firstSceneName : this.getSceneData().name,
this._injectExternalLayout
);
//Uncomment to profile the first x frames of the game.
// var x = 500;
// var startTime = Date.now();
// console.profile("Stepping for " + x + " frames")
// for(var i = 0; i < x; ++i) {
// this._sceneStack.step(16);
// }
// console.profileEnd();
// var time = Date.now() - startTime;
// console.log("Took", time, "ms");
// return;
//The standard game loop
var that = this;
this._renderer.startGameLoop(function(elapsedTime) {
//Manage resize events.
if (that._notifySceneForResize) {
that._sceneStack.onRendererResized();
that._notifySceneForResize = false;
}
//Load the first scene
var firstSceneName = gdjs.projectData.firstLayout;
this._sceneStack.push(this.hasScene(firstSceneName) ? firstSceneName : this.getSceneData().name,
this._injectExternalLayout);
//Render and step the scene.
if (that._sceneStack.step(elapsedTime)) {
that.getInputManager().onFrameEnded();
return true;
}
//Uncomment to profile the first x frames of the game.
// var x = 500;
// var startTime = Date.now();
// console.profile("Stepping for " + x + " frames")
// for(var i = 0; i < x; ++i) {
// this._sceneStack.step(16);
// }
// console.profileEnd();
// var time = Date.now() - startTime;
// console.log("Took", time, "ms");
// return;
//The standard game loop
var that = this;
this._renderer.startGameLoop(function(elapsedTime) {
//Manage resize events.
if (that._notifySceneForResize) {
that._sceneStack.onRendererResized();
that._notifySceneForResize = false;
}
//Render and step the scene.
if (that._sceneStack.step(elapsedTime)) {
that.getInputManager().onFrameEnded();
return true;
}
return false;
});
return false;
});
};

View File

@@ -1151,12 +1151,47 @@ gdjs.RuntimeObject.collisionTest = function(obj1, obj2) {
};
/**
* Check the distance between two objects.
* @method distanceTest
* @static
* @method raycastTest
* @param x {Number} The raycast source X
* @param y {Number} The raycast source Y
* @param angle {Number} The raycast angle
* @param dist {Number} The raycast max distance
* @param closest {Boolean} Get the closest or farthest collision mask result?
* @return A raycast result with the contact points and distances
*/
gdjs.RuntimeObject.distanceTest = function(obj1, obj2, distance) {
return obj1.getSqDistanceToObject(obj2) <= distance;
gdjs.RuntimeObject.prototype.raycastTest = function(x, y, angle, dist, closest) {
var objW = this.getWidth();
var objH = this.getHeight();
var diffX = this.getDrawableX()+this.getCenterX() - x;
var diffY = this.getDrawableY()+this.getCenterY() - y;
var boundingRadius = Math.sqrt(objW*objW + objH*objH)/2.0;
var result = gdjs.Polygon.raycastTest._statics.result;
result.collision = false;
if ( Math.sqrt(diffX*diffX + diffY*diffY) > boundingRadius + dist )
return result;
var endX = x + dist*Math.cos(angle*Math.PI/180.0);
var endY = y + dist*Math.sin(angle*Math.PI/180.0);
var testSqDist = closest ? dist*dist : 0;
var hitBoxes = this.getHitBoxes();
for (var i=0; i<hitBoxes.length; i++) {
var res = gdjs.Polygon.raycastTest(hitBoxes[i], x, y, endX, endY);
if ( res.collision ) {
if ( closest && (res.closeSqDist < testSqDist) ) {
testSqDist = res.closeSqDist;
result = res;
}
else if ( !closest && (res.farSqDist > testSqDist) && (res.farSqDist <= dist*dist) ) {
testSqDist = res.farSqDist;
result = res;
}
}
}
return result;
};
/**
@@ -1174,6 +1209,15 @@ gdjs.RuntimeObject.prototype.insideObject = function(x, y) {
&& this.getDrawableY() + this.getHeight() >= y;
}
/**
* Check the distance between two objects.
* @method distanceTest
* @static
*/
gdjs.RuntimeObject.distanceTest = function(obj1, obj2, distance) {
return obj1.getSqDistanceToObject(obj2) <= distance;
};
/**
* Return true if the cursor, or any touch, is on the object.
*

View File

@@ -161,7 +161,6 @@ gdjs.RuntimeScene.prototype.unloadScene = function() {
this._allInstancesList = [];
this._instancesRemoved = [];
this._renderer = new gdjs.RuntimeSceneRenderer(this, this._runtimeGame ? this._runtimeGame.getRenderer() : null);
this._lastId = 0;
this._eventsContext = null;

View File

@@ -0,0 +1,606 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project firstLayout="">
<gdVersion build="96" major="4" minor="0" revision="140" />
<properties folderProject="false" linuxExecutableFilename="" macExecutableFilename="" packageName="com.example.gamename" projectFile="C:\Users\Maciel\Programacion\gits\GD\GDJS\tests\games\Raycast.gdg" useExternalSourceFiles="false" winExecutableFilename="" winExecutableIconFile="">
<name>Project</name>
<author></author>
<windowWidth>800</windowWidth>
<windowHeight>600</windowHeight>
<latestCompilationDirectory></latestCompilationDirectory>
<maxFPS>60</maxFPS>
<minFPS>10</minFPS>
<verticalSync>false</verticalSync>
<extensions>
<extension name="BuiltinObject" />
<extension name="BuiltinAudio" />
<extension name="BuiltinVariables" />
<extension name="BuiltinTime" />
<extension name="BuiltinMouse" />
<extension name="BuiltinKeyboard" />
<extension name="BuiltinJoystick" />
<extension name="BuiltinCamera" />
<extension name="BuiltinWindow" />
<extension name="BuiltinFile" />
<extension name="BuiltinNetwork" />
<extension name="BuiltinScene" />
<extension name="BuiltinAdvanced" />
<extension name="Sprite" />
<extension name="BuiltinCommonInstructions" />
<extension name="BuiltinCommonConversions" />
<extension name="BuiltinStringInstructions" />
<extension name="BuiltinMathematicalTools" />
<extension name="BuiltinExternalLayouts" />
<extension name="PrimitiveDrawing" />
</extensions>
<platforms>
<platform name="GDevelop JS platform" />
<platform name="GDevelop C++ platform" />
</platforms>
<currentPlatform>GDevelop JS platform</currentPlatform>
</properties>
<resources>
<resources>
<resource alwaysLoaded="false" file="Grass.png" kind="image" name="Grass.png" smoothed="true" userAdded="true" />
<resource alwaysLoaded="false" file="spship2.png" kind="image" name="spship2.png" smoothed="true" userAdded="false" />
<resource alwaysLoaded="false" file="Shape1.png" kind="image" name="Shape1.png" smoothed="true" userAdded="false" />
<resource alwaysLoaded="false" file="Pea-Happy.png" kind="image" name="Pea-Happy.png" smoothed="true" userAdded="false" />
</resources>
<resourceFolders />
</resources>
<objects />
<objectsGroups />
<variables />
<layouts>
<layout b="30" disableInputWhenNotFocused="true" mangledName="Scene" name="Scene" oglFOV="90.000000" oglZFar="500.000000" oglZNear="1.000000" r="30" standardSortMethod="false" stopSoundsOnStartup="true" title="" v="30">
<uiSettings grid="false" gridB="80" gridG="80" gridHeight="70" gridOffsetX="0" gridOffsetY="20" gridR="80" gridWidth="70" snap="true" windowMask="false" zoomFactor="0.754867" />
<objectsGroups>
<group name="Colliders">
<objects>
<object name="Quad" />
<object name="Line" />
<object name="Triangle" />
<object name="Polygon" />
</objects>
</group>
</objectsGroups>
<variables />
<instances>
<instance angle="0.000000" customSize="true" height="64.000000" layer="" locked="false" name="Player" width="64.000000" x="400.000000" y="300.000000" zOrder="2">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="160.000000" layer="" locked="false" name="Quad" width="160.000000" x="511.653046" y="426.899933" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="642.864868" y="20.479473" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="340.216797" y="524.969666" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="52.560143" y="106.766174" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="202.182587" y="29.507092" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="550.417358" y="268.102661" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="259.622040" y="466.785736" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="640.945984" y="188.205658" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="80.000000" layer="" locked="false" name="Quad" width="80.000000" x="330.563049" y="69.781281" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="13.854311" y="547.935608" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="4.000000" layer="" locked="false" name="Line" width="200.000000" x="42.436562" y="348.760468" zOrder="4">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="2.000000" layer="" locked="false" name="Line" width="64.000000" x="22.880741" y="14.281113" zOrder="4">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="2.000000" layer="" locked="false" name="Line" width="64.000000" x="694.834351" y="81.030281" zOrder="4">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="2.000000" layer="" locked="false" name="Line" width="64.000000" x="321.407257" y="436.969086" zOrder="4">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Drawer" width="0.000000" x="467.504181" y="221.897949" zOrder="5">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="40.000000" layer="" locked="false" name="Quad" width="40.000000" x="687.335632" y="495.352386" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="2.000000" layer="" locked="false" name="Line" width="64.000000" x="231.507050" y="134.513855" zOrder="4">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="60.000000" layer="" locked="false" name="Triangle" width="60.000000" x="432.457794" y="17.137005" zOrder="3">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="60.000000" layer="" locked="false" name="Triangle" width="60.000000" x="119.492599" y="63.272141" zOrder="3">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="60.000000" layer="" locked="false" name="Triangle" width="60.000000" x="625.232666" y="333.912476" zOrder="3">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="60.000000" layer="" locked="false" name="Triangle" width="60.000000" x="476.822723" y="355.556915" zOrder="3">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="60.000000" layer="" locked="false" name="Triangle" width="60.000000" x="404.859680" y="522.776550" zOrder="3">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="80.000000" layer="" locked="false" name="Polygon" width="100.000000" x="19.355259" y="383.442963" zOrder="4">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="50.000000" layer="" locked="false" name="Polygon" width="100.000000" x="723.214783" y="536.209045" zOrder="4">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
<instance angle="0.000000" customSize="true" height="140.000000" layer="" locked="false" name="Polygon" width="60.000000" x="517.953369" y="37.765617" zOrder="4">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
</instances>
<objects>
<object name="Player" type="Sprite" updateIfNotVisible="true">
<variables />
<behaviors />
<animations>
<animation name="" useMultipleDirections="false">
<directions>
<direction looping="false" timeBetweenFrames="1.000000">
<sprites>
<sprite hasCustomCollisionMask="false" image="Pea-Happy.png">
<points />
<originPoint name="origine" x="18.000000" y="18.000000" />
<centerPoint automatic="true" name="centre" x="18.500000" y="18.500000" />
<customCollisionMask>
<polygon>
<vertice x="0.000000" y="0.000000" />
<vertice x="37.000000" y="0.000000" />
<vertice x="37.000000" y="37.000000" />
<vertice x="0.000000" y="37.000000" />
</polygon>
</customCollisionMask>
</sprite>
</sprites>
</direction>
</directions>
</animation>
</animations>
</object>
<object name="Quad" type="Sprite" updateIfNotVisible="true">
<variables />
<behaviors />
<animations>
<animation name="" useMultipleDirections="false">
<directions>
<direction looping="false" timeBetweenFrames="1.000000">
<sprites>
<sprite hasCustomCollisionMask="false" image="Grass.png">
<points />
<originPoint name="origine" x="0.000000" y="0.000000" />
<centerPoint automatic="true" name="centre" x="35.000000" y="35.000000" />
<customCollisionMask>
<polygon>
<vertice x="0.000000" y="0.000000" />
<vertice x="70.000000" y="0.000000" />
<vertice x="70.000000" y="70.000000" />
<vertice x="0.000000" y="70.000000" />
</polygon>
</customCollisionMask>
</sprite>
</sprites>
</direction>
</directions>
</animation>
</animations>
</object>
<object name="Line" type="Sprite" updateIfNotVisible="false">
<variables />
<behaviors />
<animations>
<animation name="" useMultipleDirections="false">
<directions>
<direction looping="false" timeBetweenFrames="1.000000">
<sprites>
<sprite hasCustomCollisionMask="true" image="Pea-Happy.png">
<points />
<originPoint name="origine" x="0.000000" y="0.000000" />
<centerPoint automatic="true" name="centre" x="18.500000" y="18.500000" />
<customCollisionMask>
<polygon>
<vertice x="0.000000" y="18.000000" />
<vertice x="36.000000" y="18.000000" />
</polygon>
</customCollisionMask>
</sprite>
</sprites>
</direction>
</directions>
</animation>
</animations>
</object>
<object name="Drawer" type="PrimitiveDrawing::Drawer">
<variables />
<behaviors />
<fillOpacity>255</fillOpacity>
<outlineSize>0</outlineSize>
<outlineOpacity>0</outlineOpacity>
<fillColor b="255" g="255" r="255" />
<outlineColor b="255" g="34" r="250" />
<absoluteCoordinates>true</absoluteCoordinates>
</object>
<object name="Triangle" type="Sprite" updateIfNotVisible="false">
<variables />
<behaviors />
<animations>
<animation name="" useMultipleDirections="false">
<directions>
<direction looping="false" timeBetweenFrames="1.000000">
<sprites>
<sprite hasCustomCollisionMask="true" image="spship2.png">
<points />
<originPoint name="origine" x="0.000000" y="0.000000" />
<centerPoint automatic="true" name="centre" x="41.500000" y="41.500000" />
<customCollisionMask>
<polygon>
<vertice x="0.000000" y="0.000000" />
<vertice x="83.000000" y="42.000000" />
<vertice x="0.000000" y="83.000000" />
</polygon>
</customCollisionMask>
</sprite>
</sprites>
</direction>
</directions>
</animation>
</animations>
</object>
<object name="Polygon" type="Sprite" updateIfNotVisible="false">
<variables />
<behaviors />
<animations>
<animation name="" useMultipleDirections="false">
<directions>
<direction looping="false" timeBetweenFrames="1.000000">
<sprites>
<sprite hasCustomCollisionMask="true" image="Shape1.png">
<points />
<originPoint name="origine" x="0.000000" y="0.000000" />
<centerPoint automatic="true" name="centre" x="89.000000" y="64.500000" />
<customCollisionMask>
<polygon>
<vertice x="0.000000" y="47.000000" />
<vertice x="77.000000" y="0.000000" />
<vertice x="175.000000" y="11.000000" />
<vertice x="178.000000" y="56.000000" />
<vertice x="160.000000" y="96.000000" />
<vertice x="104.000000" y="129.000000" />
<vertice x="7.000000" y="103.000000" />
</polygon>
</customCollisionMask>
</sprite>
</sprites>
</direction>
</directions>
</animation>
</animations>
</object>
</objects>
<events>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::Standard</type>
<conditions>
<instruction>
<type inverted="false" value="DepartScene" />
<parameters>
<parameter></parameter>
</parameters>
<subInstructions />
</instruction>
</conditions>
<actions />
<events>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::Repeat</type>
<repeatExpression>300</repeatExpression>
<conditions />
<actions>
<instruction>
<type inverted="false" value="Create" />
<parameters>
<parameter></parameter>
<parameter>Polygon</parameter>
<parameter>Random(200)</parameter>
<parameter>Random(200)</parameter>
<parameter></parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="Create" />
<parameters>
<parameter></parameter>
<parameter>Line</parameter>
<parameter>500 + Random(300)</parameter>
<parameter>400 + Random(200)</parameter>
<parameter></parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="ChangeScaleHeight" />
<parameters>
<parameter>Line</parameter>
<parameter>=</parameter>
<parameter>0.1</parameter>
</parameters>
<subInstructions />
</instruction>
</actions>
<events />
</event>
</events>
</event>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::Standard</type>
<conditions />
<actions>
<instruction>
<type inverted="false" value="ChangeColor" />
<parameters>
<parameter>Colliders</parameter>
<parameter>&quot;255;255;255&quot;</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::FillColor" />
<parameters>
<parameter>Drawer</parameter>
<parameter>&quot;200;200;250&quot;</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::FillOpacity" />
<parameters>
<parameter>Drawer</parameter>
<parameter>=</parameter>
<parameter>50</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::Circle" />
<parameters>
<parameter>Drawer</parameter>
<parameter>Player.X()</parameter>
<parameter>Player.Y()</parameter>
<parameter>400</parameter>
</parameters>
<subInstructions />
</instruction>
</actions>
<events />
</event>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::Standard</type>
<conditions>
<instruction>
<type inverted="true" value="Raycast" />
<parameters>
<parameter>Colliders</parameter>
<parameter>Player.X()</parameter>
<parameter>Player.Y()</parameter>
<parameter>ToDeg(atan2(MouseY(&quot;&quot;,0)-Player.Y(), MouseX(&quot;&quot;,0)-Player.X()))</parameter>
<parameter>400</parameter>
<parameter>x</parameter>
<parameter>y</parameter>
<parameter></parameter>
</parameters>
<subInstructions />
</instruction>
</conditions>
<actions>
<instruction>
<type inverted="false" value="SetAngle" />
<parameters>
<parameter>Colliders</parameter>
<parameter>+</parameter>
<parameter>10 * TimeDelta()</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::FillColor" />
<parameters>
<parameter>Drawer</parameter>
<parameter>&quot;255;0;0&quot;</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::FillOpacity" />
<parameters>
<parameter>Drawer</parameter>
<parameter>=</parameter>
<parameter>100</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::Line" />
<parameters>
<parameter>Drawer</parameter>
<parameter>Player.X()</parameter>
<parameter>Player.Y()</parameter>
<parameter>Variable(x)</parameter>
<parameter>Variable(y)</parameter>
<parameter>1</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::Circle" />
<parameters>
<parameter>Drawer</parameter>
<parameter>Variable(x)</parameter>
<parameter>Variable(y)</parameter>
<parameter>3</parameter>
</parameters>
<subInstructions />
</instruction>
</actions>
<events />
</event>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::Standard</type>
<conditions>
<instruction>
<type inverted="false" value="Raycast" />
<parameters>
<parameter>Colliders</parameter>
<parameter>Player.X()</parameter>
<parameter>Player.Y()</parameter>
<parameter>ToDeg(atan2(MouseY(&quot;&quot;,0)-Player.Y(), MouseX(&quot;&quot;,0)-Player.X()))</parameter>
<parameter>400</parameter>
<parameter>x</parameter>
<parameter>y</parameter>
<parameter></parameter>
</parameters>
<subInstructions />
</instruction>
</conditions>
<actions>
<instruction>
<type inverted="false" value="ChangeColor" />
<parameters>
<parameter>Colliders</parameter>
<parameter>&quot;50;100;50&quot;</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::FillColor" />
<parameters>
<parameter>Drawer</parameter>
<parameter>&quot;0;255;0&quot;</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::FillOpacity" />
<parameters>
<parameter>Drawer</parameter>
<parameter>=</parameter>
<parameter>100</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::Line" />
<parameters>
<parameter>Drawer</parameter>
<parameter>Player.X()</parameter>
<parameter>Player.Y()</parameter>
<parameter>Variable(x)</parameter>
<parameter>Variable(y)</parameter>
<parameter>1</parameter>
</parameters>
<subInstructions />
</instruction>
<instruction>
<type inverted="false" value="PrimitiveDrawing::Circle" />
<parameters>
<parameter>Drawer</parameter>
<parameter>Variable(x)</parameter>
<parameter>Variable(y)</parameter>
<parameter>2</parameter>
</parameters>
<subInstructions />
</instruction>
</actions>
<events />
</event>
</events>
<layers>
<layer name="" visibility="true">
<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>
<layer name="Debug" visibility="true">
<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>
<behaviorsSharedData />
</layout>
</layouts>
<externalEvents />
<externalLayouts />
<externalSourceFiles>
<sourceFile filename="C:\Users\Maciel\AppData\Local\Temp/GDTemporaries/GD0x67750b8SourceFile.cpp" gdManaged="true" language="C++" />
<sourceFile filename="C:\Users\Maciel\AppData\Local\Temp/GDTemporaries/GD0x6830850SourceFile.cpp" gdManaged="true" language="C++" />
</externalSourceFiles>
</project>

BIN
GDJS/tests/games/Shape1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -9,7 +9,7 @@ Getting started [![Build Status](https://semaphoreci.com/api/v1/4ian/gd/branches
| ❔ I want to... | 🚀 What to do |
| --- | --- |
| Download GDevelop to make games | Go on [GDevelop website](http://compilgames.net) to download GD! |
| Download GDevelop to make games | Go on [GDevelop website](https://gdevelop-app.com) to download GD! |
| Contribute to the new editor | Download [Node.js] and follow this [README](newIDE/README.md). |
| Contribute to the old C++ editor | Download and launch [CMake], choose this directory as the source, generate the Makefile and launch it. Be sure to have [required development libraries](http://4ian.github.io/GD-Documentation/GDCore%20Documentation/setup_dev_env.html) installed. <br><br> Fully detailed instructions are [available here](http://4ian.github.io/GD-Documentation). |
| Help to translate GDevelop | Go on the [GDevelop project on Crowdin](https://crowdin.com/project/gdevelop). |
@@ -36,7 +36,7 @@ Links
### Community
* [GDevelop forums](http://forum.compilgames.net)
* [GDevelop homepage](http://www.compilgames.net) ([open source](https://github.com/4ian/GDevelop-website))
* [GDevelop homepage](https://gdevelop-app.com) ([open-source](https://github.com/4ian/GDevelop-website))
* [GDevelop wiki](http://wiki.compilgames.net)
* Help translate GD in your language: [GDevelop project on Crowdin](https://crowdin.com/project/gdevelop).
* [GDevelop Nightly Builds](http://nightlies.gd.victorlevasseur.com/) (powered by a [Buildbot](https://github.com/victorlevasseur/GD-Buildbot)) ([open source](https://github.com/victorlevasseur/GD-Nightlies-Website))

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0015 NEW)
project(GDVersion)
set(GD_VERSION_STR "4.0.96")
set(GD_VERSION_STR "4.0.97-0-release")
if(FULL_VERSION_NUMBER)
set(GENERATE_VERSION_SCRIPT ${PROJECT_SOURCE_DIR}/GenerateVersionFull.cmake)

View File

@@ -23,7 +23,8 @@ yarn start #or npm start
This will open the app in your web browser.
Images resources, GDJS Runtime, extensions will be copied in resources, and [libGD.js](https://github.com/4ian/GDevelop.js) will be downloaded automatically.
Images resources, GDJS Runtime, extensions will be copied in resources, and [libGD.js](https://github.com/4ian/GDevelop.js) will be downloaded automatically. If you wish, you can
[build libGD.js by yourself](https://github.com/4ian/GDevelop.js) (useful if you modified GDevelop native code like extensions).
### Development of the standalone app
@@ -97,7 +98,6 @@ yarn deploy #or npm run deploy
This new editor is still in development and is missing some features:
- [ ] Support for translations (See an [example of a component that can be translated](https://github.com/4ian/GD/blob/master/newIDE/app/src/MainFrame/Toolbar.js#L44))
- [ ] [Collision mask editor](https://trello.com/c/2Kzwj61r/47-collision-masks-editors-for-sprite-objects-in-the-new-ide)
- [ ] Support for native games
- [ ] More [documentation](http://wiki.compilgames.net/doku.php/gdevelop5/start) about how to package for iOS/Android with Cordova/PhoneGap Build or Cocos2d-JS.
- [ ] Search in events
@@ -108,6 +108,8 @@ This new editor is still in development and is missing some features:
You can contribute by picking anything here or anything that you think is missing or could be improved in GD5! If you don't know how to start, it's a good idea to play a bit with the editor and see if there is something that is unavailable and that you can add or fix.
See also [the roadmap for ideas and features planned](https://trello.com/b/qf0lM7k8/gdevelop-roadmap).
## Additional help
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). Check out their documentation for common tasks or help about using it.

View File

@@ -13,6 +13,21 @@ declare type gdExternalEvents = EmscriptenObject;
declare type gdSerializerElement = EmscriptenObject;
declare type gdInitialInstance = EmscriptenObject;
declare type gdBaseEvent = EmscriptenObject;
declare type gdResource = EmscriptenObject;
declare type gdObject = EmscriptenObject;
declare type gdResourcesManager = EmscriptenObject;
declare type gdInstruction = EmscriptenObject;
declare type gdInstructionMetadata = EmscriptenObject;
declare type gdInstructionsList = EmscriptenObject;
declare type gdParameterMetadata = EmscriptenObject;
declare type gdVariable = EmscriptenObject;
declare type gdVariablesContainer = EmscriptenObject;
declare type gdVectorPolygon2d = EmscriptenObject;
declare type gdSpriteObject = EmscriptenObject;
//Represents all objects that have serializeTo and unserializeFrom methods.
declare type gdSerializable = EmscriptenObject;

View File

@@ -18,6 +18,7 @@
"axios": "^0.16.1",
"blueimp-md5": "^2.10.0",
"classnames": "2.2.5",
"create-react-context": "^0.1.6",
"date-fns": "^1.29.0",
"element-closest": "2.0.2",
"firebase": "^4.8.2",

View File

@@ -25,27 +25,8 @@
<meta name="theme-color" content="#4ab0e4">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<!-- Fullstory user analytics -->
<script>
window['_fs_debug'] = false;
window['_fs_host'] = 'fullstory.com';
window['_fs_org'] = '8DWZ1';
window['_fs_namespace'] = 'FS';
(function(m,n,e,t,l,o,g,y){
if (e in m) {if(m.console && m.console.log) { m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');} return;}
g=m[e]=function(a,b){g.q?g.q.push([a,b]):g._api(a,b);};g.q=[];
o=n.createElement(t);o.async=1;o.src='https://'+_fs_host+'/s/fs.js';
y=n.getElementsByTagName(t)[0];y.parentNode.insertBefore(o,y);
g.identify=function(i,v){g(l,{uid:i});if(v)g(l,v)};g.setUserVars=function(v){g(l,v)};
g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;g(o,v)};
g.clearUserCookie=function(c,d,i){if(!c || document.cookie.match('fs_uid=[`;`]*`[`;`]*`[`;`]*`')){
d=n.domain;while(1){n.cookie='fs_uid=;domain='+d+
';path=/;expires='+new Date(0).toUTCString();i=d.indexOf('.');if(i<0)break;d=d.slice(i+1)}}};
})(window,document,window['_fs_namespace'],'script','user');
</script>
<!-- Stripe.com Checkout -->
<script src="https://checkout.stripe.com/checkout.js"></script>
<!-- Stripe.com Checkout -->
<script src="https://checkout.stripe.com/checkout.js"></script>
</head>
<body>

File diff suppressed because one or more lines are too long

View File

@@ -38,7 +38,7 @@ if (shell.test('-f', sourceFile)) {
var file = fs.createWriteStream('../public/libGD.js');
https.get(
'https://github.com/4ian/GDevelop.js/releases/download/4.0.96/libGD.js',
'https://github.com/4ian/GDevelop.js/releases/download/5.0.0-beta28/libGD.js',
function(response) {
if (response.statusCode !== 200) {
shell.echo(

View File

@@ -1,3 +1,4 @@
// @flow
export const selectableArea = 'selectable';
export const selectedArea = 'selected';
@@ -9,6 +10,7 @@ export const actionsContainer = 'actions-container';
export const conditionsContainer = 'conditions-container';
export const subInstructionsContainer = 'sub-instructions-container';
export const instructionParameter = 'instruction-parameter';
export const disabledText = 'disabled-text';
export const background = 'background';

View File

@@ -1,9 +1,19 @@
import React, { Component } from 'react';
// @flow
import * as React from 'react';
import PropTypes from 'prop-types';
import { mapFor } from '../../Utils/MapFor';
import classNames from 'classnames';
import { selectedArea, selectableArea, subInstructionsContainer, instructionParameter } from './ClassNames';
import InstructionsList from './InstructionsList';
import {
selectedArea,
selectableArea,
subInstructionsContainer,
instructionParameter,
disabledText,
} from './ClassNames';
import InstructionsList, {
type InstructionsListContext,
type InstructionContext,
} from './InstructionsList';
const gd = global.gd;
const instrFormatter = gd.InstructionSentenceFormatter.get();
instrFormatter.loadTypesFormattingFromConfig();
@@ -22,28 +32,42 @@ const styles = {
},
};
export default class Instruction extends Component {
static propTypes = {
instruction: PropTypes.object.isRequired,
isCondition: PropTypes.bool.isRequired,
onClick: PropTypes.func.isRequired,
type Props = {
instruction: gdInstruction,
isCondition: boolean,
onClick: Function,
selected: boolean,
disabled: boolean,
onDoubleClick: () => void,
onContextMenu: (x: number, y: number) => void,
// For potential sub-instructions list:
selection: PropTypes.object,
onAddNewSubInstruction: PropTypes.func,
onSubInstructionClick: PropTypes.func,
onSubInstructionDoubleClick: PropTypes.func,
onSubInstructionsListContextMenu: PropTypes.func,
onSubParameterClick: PropTypes.func,
};
// For potential sub-instructions list:
selection: PropTypes.object,
onAddNewSubInstruction: Function,
onSubInstructionClick: Function,
onSubInstructionDoubleClick: Function,
onSubInstructionsListContextMenu: (
x: number,
y: number,
instructionsListContext: InstructionsListContext
) => void,
onSubParameterClick: Function,
onSubInstructionContextMenu: (
x: number,
y: number,
instructionContext: InstructionContext
) => void,
onParameterClick: (event: any, parameterIndex: number) => void,
};
export default class Instruction extends React.Component<Props, *> {
/**
* Render the different parts of the text of the instruction.
* Parameter can have formatting, be hovered and clicked. The rest
* has not particular styling.
*/
_renderInstructionText = metadata => {
const { instruction } = this.props;
_renderInstructionText = (metadata: gdInstructionMetadata) => {
const { instruction, disabled } = this.props;
const formattedTexts = instrFormatter.getAsFormattedText(
instruction,
metadata
@@ -51,7 +75,11 @@ export default class Instruction extends Component {
const parametersCount = metadata.getParametersCount();
return (
<span>
<span
className={classNames({
[disabledText]: disabled,
})}
>
{mapFor(0, formattedTexts.size(), i => {
const formatting = formattedTexts.getTextFormatting(i);
const parameterIndex = formatting.getUserData();
@@ -147,6 +175,7 @@ export default class Instruction extends Component {
}
onParameterClick={this.props.onSubParameterClick}
addButtonLabel="Add a sub-condition"
disabled={this.props.disabled}
/>
)}
</div>

View File

@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
// @flow
import * as React from 'react';
import Instruction from './Instruction';
import { mapFor } from '../../Utils/MapFor';
import { isInstructionSelected } from '../SelectionHandler';
@@ -11,20 +11,42 @@ const styles = {
},
};
export default class InstructionsList extends Component {
static propTypes = {
instrsList: PropTypes.object.isRequired,
areConditions: PropTypes.bool.isRequired,
onAddNewInstruction: PropTypes.func.isRequired,
onInstructionClick: PropTypes.func.isRequired,
onInstructionDoubleClick: PropTypes.func.isRequired,
onInstructionContextMenu: PropTypes.func.isRequired,
onInstructionsListContextMenu: PropTypes.func.isRequired,
onParameterClick: PropTypes.func.isRequired,
selection: PropTypes.object.isRequired,
addButtonLabel: PropTypes.string,
};
export type InstructionsListContext = {
instrsList: gdInstructionsList,
isCondition: boolean,
};
export type InstructionContext = InstructionsListContext & {
instruction: gdInstruction,
indexInList: number,
};
export type ParameterContext = InstructionContext & {
parameterIndex: number,
domEvent: any,
};
type Props = {
instrsList: gdInstructionsList,
areConditions: boolean,
onAddNewInstruction: InstructionsListContext => void,
onInstructionClick: InstructionContext => void,
onInstructionDoubleClick: InstructionContext => void,
onInstructionContextMenu: (x: number, y: number, InstructionContext) => void,
onInstructionsListContextMenu: (
x: number,
y: number,
InstructionsListContext
) => void,
onParameterClick: ParameterContext => void,
selection: any,
addButtonLabel?: string,
extraClassName?: string,
style?: Object,
disabled: boolean,
};
export default class InstructionsList extends React.Component<Props, *> {
onAddNewInstruction = () => {
if (this.props.onAddNewInstruction)
this.props.onAddNewInstruction({
@@ -47,6 +69,7 @@ export default class InstructionsList extends Component {
onParameterClick,
selection,
style,
disabled,
} = this.props;
const instructions = mapFor(0, instrsList.size(), i => {
@@ -67,8 +90,7 @@ export default class InstructionsList extends Component {
key={instruction.ptr}
selected={isInstructionSelected(selection, instruction)}
onClick={() => onInstructionClick(instructionContext)}
onDoubleClick={() =>
onInstructionDoubleClick(instructionContext)}
onDoubleClick={() => onInstructionDoubleClick(instructionContext)}
onContextMenu={(x, y) =>
onInstructionContextMenu(x, y, instructionContext)}
onParameterClick={(domEvent, parameterIndex) =>
@@ -82,10 +104,9 @@ export default class InstructionsList extends Component {
onSubInstructionClick={onInstructionClick}
onSubInstructionDoubleClick={onInstructionDoubleClick}
onSubInstructionContextMenu={onInstructionContextMenu}
onSubInstructionsListContextMenu={
onInstructionsListContextMenu
}
onSubInstructionsListContextMenu={onInstructionsListContextMenu}
onSubParameterClick={onParameterClick}
disabled={disabled}
/>
);
});

View File

@@ -1,7 +1,8 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
// @flow
import * as React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import { type EventRendererProps } from './EventRenderer.flow'
import { rgbToHex } from '../../../Utils/ColorTransformer';
import {
largeSelectedArea,
@@ -31,33 +32,46 @@ const styles = {
},
};
export default class CommentEvent extends Component {
static propTypes = {
event: PropTypes.object.isRequired,
onUpdate: PropTypes.func.isRequired,
};
type State = {|
editing: boolean,
height: number,
|};
export default class CommentEvent extends React.Component<EventRendererProps, State> {
state = {
editing: false,
height: 0,
};
_container: ?any;
_input: ?any;
edit = () => {
if (!this._container) return;
this.setState(
{
editing: true,
height: this._container.offsetHeight,
},
() => {
const input = ReactDOM.findDOMNode(this._input);
input.focus();
input.value = gd.asCommentEvent(this.props.event).getComment();
// $FlowFixMe
const input: ?HTMLInputElement = ReactDOM.findDOMNode(this._input);
if (input) {
input.focus();
input.value = gd.asCommentEvent(this.props.event).getComment();
}
}
);
};
endEditing = () => {
const commentEvent = gd.asCommentEvent(this.props.event);
commentEvent.setComment(ReactDOM.findDOMNode(this._input).value);
// $FlowFixMe
const input: ?HTMLInputElement = ReactDOM.findDOMNode(this._input);
if (input) commentEvent.setComment(input.value);
this.setState(
{
editing: false,

View File

@@ -0,0 +1,33 @@
// @flow
import {
type InstructionsListContext,
type InstructionContext,
type ParameterContext,
} from '../InstructionsList';
export type EventRendererProps = {
project: gdProject,
layout: gdLayout,
event: gdBaseEvent,
disabled: boolean,
onUpdate: () => void,
selected: boolean,
onAddNewInstruction: Function,
onInstructionClick: InstructionContext => void,
onInstructionDoubleClick: InstructionContext => void,
onInstructionContextMenu: (x: number, y: number, InstructionContext) => void,
onInstructionsListContextMenu: (
x: number,
y: number,
InstructionsListContext
) => void,
onParameterClick: ParameterContext => void,
selection: any,
onUpdate: () => void,
onOpenLayout: (string) => void,
onOpenExternalEvents: (string) => void,
leftIndentWidth: number,
};

View File

@@ -1,15 +1,17 @@
import React, { Component } from 'react';
// @flow
import * as React from 'react';
import InstructionsList from '../InstructionsList.js';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {
largeSelectedArea,
largeSelectableArea,
selectableArea,
executableEventContainer,
disabledText,
} from '../ClassNames';
import InlinePopover from '../../InlinePopover';
import ObjectField from '../../InstructionEditor/ParameterFields/ObjectField';
import { type EventRendererProps } from './EventRenderer.flow';
const gd = global.gd;
const styles = {
@@ -25,29 +27,13 @@ const styles = {
},
};
export default class ForEachEvent extends Component {
static propTypes = {
event: PropTypes.object.isRequired,
onAddNewInstruction: PropTypes.func.isRequired,
onInstructionClick: PropTypes.func.isRequired,
onInstructionDoubleClick: PropTypes.func.isRequired,
onInstructionContextMenu: PropTypes.func.isRequired,
onInstructionsListContextMenu: PropTypes.func.isRequired,
onParameterClick: PropTypes.func.isRequired,
selection: PropTypes.object.isRequired,
onUpdate: PropTypes.func.isRequired,
export default class ForEachEvent extends React.Component<EventRendererProps, *> {
state = {
editing: false,
anchorEl: null,
};
constructor(props) {
super(props);
this.state = {
editing: false,
anchorEl: null,
};
}
edit = domEvent => {
edit = (domEvent: any) => {
this.setState({
editing: true,
anchorEl: domEvent.currentTarget,
@@ -81,6 +67,7 @@ export default class ForEachEvent extends Component {
<div
className={classNames({
[selectableArea]: true,
[disabledText]: this.props.disabled,
})}
onClick={this.edit}
>
@@ -104,6 +91,7 @@ export default class ForEachEvent extends Component {
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
<InstructionsList
instrsList={forEachEvent.getActions()}
@@ -118,6 +106,7 @@ export default class ForEachEvent extends Component {
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
</div>
<InlinePopover

View File

@@ -1,12 +1,14 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
// @flow
import * as React from 'react';
import classNames from 'classnames';
import TextField from 'material-ui/TextField';
import {
largeSelectedArea,
largeSelectableArea,
selectableArea,
disabledText,
} from '../ClassNames';
import { type EventRendererProps } from './EventRenderer.flow';
const gd = global.gd;
const styles = {
@@ -22,18 +24,11 @@ const styles = {
},
};
export default class GroupEvent extends Component {
static propTypes = {
event: PropTypes.object.isRequired,
export default class GroupEvent extends React.Component<EventRendererProps, *> {
state = {
editing: false,
};
constructor(props) {
super(props);
this.state = {
editing: false,
};
}
_textField: ?TextField = null;
edit = () => {
this.setState(
@@ -98,6 +93,7 @@ export default class GroupEvent extends Component {
<span
className={classNames({
[selectableArea]: true,
[disabledText]: this.props.disabled,
})}
style={{ ...styles.title, color: textColor }}
>

View File

@@ -1,4 +1,5 @@
import React, { Component } from 'react';
// @flow
import * as React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import InlinePopover from '../../InlinePopover';
@@ -7,9 +8,11 @@ import {
largeSelectedArea,
largeSelectableArea,
selectableArea,
disabledText,
} from '../ClassNames';
import { getHelpLink } from '../../../Utils/HelpLink';
import Window from '../../../Utils/Window';
import { type EventRendererProps } from './EventRenderer.flow';
const gd = global.gd;
const fontFamily = '"Lucida Console", Monaco, monospace';
@@ -54,29 +57,45 @@ const styles = {
},
};
export default class JsCodeEvent extends Component {
export default class JsCodeEvent extends React.Component<
EventRendererProps,
*
> {
state = {
editing: false,
editingObject: false,
anchorEl: null,
};
_input: ?any;
_container: ?any;
edit = () => {
if (!this._container) return;
this.setState(
{
editing: true,
height: this._container.offsetHeight,
},
() => {
const input = ReactDOM.findDOMNode(this._input);
input.focus();
input.value = gd.asJsCodeEvent(this.props.event).getInlineCode();
// $FlowFixMe
const input: ?HTMLInputElement = ReactDOM.findDOMNode(this._input);
if (input) {
input.focus();
input.value = gd.asJsCodeEvent(this.props.event).getInlineCode();
}
}
);
};
endEditing = () => {
const jsCodeEvent = gd.asJsCodeEvent(this.props.event);
jsCodeEvent.setInlineCode(ReactDOM.findDOMNode(this._input).value);
// $FlowFixMe
const input: ?HTMLInputElement = ReactDOM.findDOMNode(this._input);
if (input) jsCodeEvent.setInlineCode(input.value);
this.setState(
{
editing: false,
@@ -85,7 +104,7 @@ export default class JsCodeEvent extends Component {
);
};
editObject = domEvent => {
editObject = (domEvent: any) => {
this.setState({
editingObject: true,
anchorEl: domEvent.currentTarget,
@@ -153,6 +172,7 @@ export default class JsCodeEvent extends Component {
<p
className={classNames({
[selectableArea]: true,
[disabledText]: this.props.disabled,
})}
onClick={this.edit}
key="p"

View File

@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
// @flow
import * as React from 'react';
import OpenInNew from 'material-ui/svg-icons/action/open-in-new';
import IconButton from 'material-ui/IconButton';
import classNames from 'classnames';
@@ -11,6 +11,7 @@ import {
import InlinePopover from '../../InlinePopover';
import ExternalEventsField from '../../InstructionEditor/ParameterFields/ExternalEventsField';
import { showWarningBox } from '../../../UI/Messages/MessageBox';
import { type EventRendererProps } from './EventRenderer.flow';
const gd = global.gd;
const styles = {
@@ -25,23 +26,15 @@ const styles = {
},
};
export default class LinkEvent extends Component {
static propTypes = {
event: PropTypes.object.isRequired,
};
export default class LinkEvent extends React.Component<EventRendererProps, *> {
_externalEventsField = null;
constructor(props) {
super(props);
state = {
editing: false,
anchorEl: null,
};
this.state = {
editing: false,
anchorEl: null,
};
}
edit = domEvent => {
edit = (domEvent: any) => {
this.setState(
{
editing: true,

View File

@@ -1,15 +1,17 @@
import React, { Component } from 'react';
// @flow
import * as React from 'react';
import InstructionsList from '../InstructionsList.js';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {
largeSelectedArea,
largeSelectableArea,
selectableArea,
executableEventContainer,
disabledText,
} from '../ClassNames';
import InlinePopover from '../../InlinePopover';
import DefaultField from '../../InstructionEditor/ParameterFields/DefaultField';
import { type EventRendererProps } from './EventRenderer.flow';
const gd = global.gd;
const styles = {
@@ -25,29 +27,13 @@ const styles = {
},
};
export default class RepeatEvent extends Component {
static propTypes = {
event: PropTypes.object.isRequired,
onAddNewInstruction: PropTypes.func.isRequired,
onInstructionClick: PropTypes.func.isRequired,
onInstructionDoubleClick: PropTypes.func.isRequired,
onInstructionContextMenu: PropTypes.func.isRequired,
onInstructionsListContextMenu: PropTypes.func.isRequired,
onParameterClick: PropTypes.func.isRequired,
selection: PropTypes.object.isRequired,
onUpdate: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = {
export default class RepeatEvent extends React.Component<EventRendererProps, *> {
state = {
editing: false,
anchorEl: null,
};
}
edit = domEvent => {
edit = (domEvent: any) => {
this.setState({
editing: true,
anchorEl: domEvent.currentTarget,
@@ -81,6 +67,7 @@ export default class RepeatEvent extends Component {
<div
className={classNames({
[selectableArea]: true,
[disabledText]: this.props.disabled,
})}
onClick={this.edit}
>
@@ -104,6 +91,7 @@ export default class RepeatEvent extends Component {
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
<InstructionsList
instrsList={repeatEvent.getActions()}
@@ -118,6 +106,7 @@ export default class RepeatEvent extends Component {
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
</div>
<InlinePopover

View File

@@ -1,12 +1,13 @@
import React, { Component } from 'react';
// @flow
import * as React from 'react';
import InstructionsList from '../InstructionsList';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {
largeSelectedArea,
largeSelectableArea,
executableEventContainer,
} from '../ClassNames';
import { type EventRendererProps } from './EventRenderer.flow';
const gd = global.gd;
const styles = {
@@ -18,18 +19,10 @@ const styles = {
},
};
export default class StandardEvent extends Component {
static propTypes = {
event: PropTypes.object.isRequired,
onAddNewInstruction: PropTypes.func.isRequired,
onInstructionClick: PropTypes.func.isRequired,
onInstructionDoubleClick: PropTypes.func.isRequired,
onInstructionContextMenu: PropTypes.func.isRequired,
onInstructionsListContextMenu: PropTypes.func.isRequired,
onParameterClick: PropTypes.func.isRequired,
selection: PropTypes.object.isRequired,
};
export default class StandardEvent extends React.Component<
EventRendererProps,
*
> {
render() {
var standardEvent = gd.asStandardEvent(this.props.event);
@@ -59,6 +52,7 @@ export default class StandardEvent extends Component {
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
<InstructionsList
instrsList={standardEvent.getActions()}
@@ -73,6 +67,7 @@ export default class StandardEvent extends Component {
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
</div>
);

View File

@@ -1,13 +1,10 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
// @flow
import * as React from 'react';
import classNames from 'classnames';
import { largeSelectedArea, largeSelectableArea } from '../ClassNames';
import { type EventRendererProps } from './EventRenderer.flow';
export default class UnknownEvent extends Component {
static propTypes = {
event: PropTypes.object.isRequired,
};
export default class UnknownEvent extends React.Component<EventRendererProps, *> {
render() {
return (
<p

View File

@@ -1,12 +1,14 @@
import React, { Component } from 'react';
// @flow
import * as React from 'react';
import InstructionsList from '../InstructionsList';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {
largeSelectedArea,
largeSelectableArea,
executableEventContainer,
disabledText,
} from '../ClassNames';
import { type EventRendererProps } from './EventRenderer.flow';
const gd = global.gd;
const styles = {
@@ -22,19 +24,10 @@ const styles = {
},
};
export default class ForEachEvent extends Component {
static propTypes = {
event: PropTypes.object.isRequired,
onAddNewInstruction: PropTypes.func.isRequired,
onInstructionClick: PropTypes.func.isRequired,
onInstructionDoubleClick: PropTypes.func.isRequired,
onInstructionContextMenu: PropTypes.func.isRequired,
onInstructionsListContextMenu: PropTypes.func.isRequired,
onParameterClick: PropTypes.func.isRequired,
selection: PropTypes.object.isRequired,
onUpdate: PropTypes.func.isRequired,
};
export default class ForEachEvent extends React.Component<
EventRendererProps,
*
> {
render() {
var whileEvent = gd.asWhileEvent(this.props.event);
@@ -51,7 +44,13 @@ export default class ForEachEvent extends Component {
[executableEventContainer]: true,
})}
>
<div>While these conditions are true:</div>
<div
className={classNames({
[disabledText]: this.props.disabled,
})}
>
While these conditions are true:
</div>
<InstructionsList
instrsList={whileEvent.getWhileConditions()}
selection={this.props.selection}
@@ -60,9 +59,19 @@ export default class ForEachEvent extends Component {
onInstructionClick={this.props.onInstructionClick}
onInstructionDoubleClick={this.props.onInstructionDoubleClick}
onInstructionContextMenu={this.props.onInstructionContextMenu}
onInstructionsListContextMenu={
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
<div>Repeat these:</div>
<div
className={classNames({
[disabledText]: this.props.disabled,
})}
>
Repeat these:
</div>
<div style={styles.instructionsContainer}>
<InstructionsList
instrsList={whileEvent.getConditions()}
@@ -77,6 +86,7 @@ export default class ForEachEvent extends Component {
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
<InstructionsList
instrsList={whileEvent.getActions()}
@@ -91,6 +101,7 @@ export default class ForEachEvent extends Component {
this.props.onInstructionsListContextMenu
}
onParameterClick={this.props.onParameterClick}
disabled={this.props.disabled}
/>
</div>
</div>

View File

@@ -40,7 +40,7 @@ class EventContainer extends Component {
};
render() {
const { event, project, layout } = this.props;
const { event, project, layout, disabled } = this.props;
const EventComponent = EventsRenderingService.getEventComponent(event);
return (
@@ -68,6 +68,9 @@ class EventContainer extends Component {
onParameterClick={this.props.onParameterClick}
onOpenExternalEvents={this.props.onOpenExternalEvents}
onOpenLayout={this.props.onOpenLayout}
disabled={
disabled /* Use disabled (not event.disabled) as it is true if a parent event is disabled*/
}
/>
)}
</div>
@@ -140,17 +143,25 @@ export default class ThemableEventsTree extends Component {
);
}
_eventsToTreeData = (eventsList, flatData = [], depth = 0) => {
_eventsToTreeData = (
eventsList,
flatData = [],
depth = 0,
parentDisabled = false
) => {
const treeData = mapFor(0, eventsList.getEventsCount(), i => {
const event = eventsList.getEventAt(i);
flatData.push(event);
const disabled = parentDisabled || event.isDisabled();
return {
title: this._renderEvent,
event,
eventsList,
indexInList: i,
expanded: !event.isFolded(),
disabled,
depth,
key: event.ptr, //TODO: useless?
children: this._eventsToTreeData(
@@ -158,7 +169,8 @@ export default class ThemableEventsTree extends Component {
// flatData is a flat representation of events, one for each line.
// Hence it should not contain the folded events.
!event.isFolded() ? flatData : [],
depth + 1
depth + 1,
disabled
).treeData,
};
});
@@ -212,7 +224,7 @@ export default class ThemableEventsTree extends Component {
};
_renderEvent = ({ node }) => {
const { event, depth } = node;
const { event, depth, disabled } = node;
return (
<EventContainer
@@ -233,6 +245,9 @@ export default class ThemableEventsTree extends Component {
onInstructionsListContextMenu={this.props.onInstructionsListContextMenu}
onOpenExternalEvents={this.props.onOpenExternalEvents}
onOpenLayout={this.props.onOpenLayout}
disabled={
disabled /* Use node.disabled (not event.disabled) as it is true if a parent event is disabled*/
}
/>
);
};

View File

@@ -125,3 +125,11 @@
box-sizing: border-box;
border: 1px transparent solid;
}
/**
* Disabled text
*/
.gd-events-sheet .disabled-text {
text-decoration: line-through;
opacity: 0.6;
}

View File

@@ -1,15 +1,49 @@
import React, { Component } from 'react';
// @flow
import * as React from 'react';
import InlinePopover from './InlinePopover';
import ParameterRenderingService from './InstructionEditor/ParameterRenderingService';
import {
type ResourceSource,
type ChooseResourceFunction,
} from '../ResourcesList/ResourceSource.flow';
const gd = global.gd;
export default class InlineParameterEditor extends Component {
type Props = {|
project: gdProject,
layout: gdLayout,
open: boolean,
onRequestClose: () => void,
onChange: (string) => void,
instruction: gdInstruction,
isCondition: boolean,
parameterIndex: number,
anchorEl: ?any,
resourceSources: Array<ResourceSource>,
onChooseResource: ChooseResourceFunction,
|};
type State = {|
isValid: boolean,
parameterMetadata: ?gdParameterMetadata,
instruction: ?gdInstruction,
ParameterComponent: ?any,
|};
export default class InlineParameterEditor extends React.Component<Props, State> {
state = {
isValid: false,
parameterMetadata: null,
ParameterComponent: null,
instruction: null,
};
componentWillReceiveProps(newProps) {
_field: ?any;
componentWillReceiveProps(newProps: Props) {
if (
(newProps.open && !this.props.open) ||
newProps.instruction !== this.props.instruction
@@ -26,7 +60,7 @@ export default class InlineParameterEditor extends Component {
});
}
_loadComponentFromInstruction(props) {
_loadComponentFromInstruction(props: Props) {
const { project, isCondition, instruction, parameterIndex } = props;
if (!instruction) return this._unload();
@@ -81,6 +115,8 @@ export default class InlineParameterEditor extends Component {
ref={field => (this._field = field)}
parameterRenderingService={ParameterRenderingService}
isInline
resourceSources={this.props.resourceSources}
onChooseResource={this.props.onChooseResource}
/>
</InlinePopover>
);

View File

@@ -138,6 +138,11 @@ Object {
"fullGroupName": "Common conditions for all objects/Collision",
"type": "CollisionPoint",
},
"Raycast": Object {
"displayedName": "Raycast",
"fullGroupName": "Common conditions for all objects/Collision",
"type": "Raycast",
},
},
"Layer": Object {
"Compare layer": Object {
@@ -2073,6 +2078,11 @@ Array [
"fullGroupName": "Common conditions for all objects/Objects",
"type": "PickNearest",
},
Object {
"displayedName": "Raycast",
"fullGroupName": "Common conditions for all objects/Collision",
"type": "Raycast",
},
Object {
"displayedName": "An object is moving toward another",
"fullGroupName": "Common conditions for all objects/Movement",

View File

@@ -87,11 +87,20 @@ export default class InstructionParametersEditor extends Component {
<div key={type} style={styles.parametersContainer}>
{mapFor(0, instructionMetadata.getParametersCount(), i => {
const parameterMetadata = instructionMetadata.getParameter(i);
const parameterMetadataType = parameterMetadata.getType();
const ParameterComponent = ParameterRenderingService.getParameterComponent(
parameterMetadata.getType()
parameterMetadataType
);
if (parameterMetadata.isCodeOnly()) return null;
if (!ParameterComponent) {
console.warn(
'Missing parameter component for',
parameterMetadataType
);
return null;
}
return (
<ParameterComponent
parameterMetadata={parameterMetadata}
@@ -105,6 +114,8 @@ export default class InstructionParametersEditor extends Component {
this.forceUpdate();
}}
parameterRenderingService={ParameterRenderingService}
resourceSources={this.props.resourceSources}
onChooseResource={this.props.onChooseResource}
/>
);
})}

View File

@@ -0,0 +1,35 @@
// @flow
import React, { Component } from 'react';
import ResourceSelector from '../../../ResourcesList/ResourceSelector';
import { type ParameterFieldProps } from './ParameterFieldProps.flow';
export default class AudioResourceField extends Component<
ParameterFieldProps,
void
> {
focus() {
// TODO
}
render() {
if (!this.props.resourceSources || !this.props.onChooseResource) {
console.error(
'Missing resourceSources or onChooseResource for AudioResourceField'
);
return null;
}
return (
<ResourceSelector
project={this.props.project}
resourceSources={this.props.resourceSources}
onChooseResource={this.props.onChooseResource}
resourceKind="audio"
fullWidth
initialResourceName={this.props.value}
onChange={this.props.onChange}
floatingLabelText="Choose the audio file to use"
/>
);
}
}

View File

@@ -13,11 +13,11 @@ const fuzzyFilterOrEmpty = (searchText, key) => {
};
export default class BehaviorField extends Component {
state = { errorText: null, focused: false, text: null };
constructor(props) {
super(props);
this.state = { errorText: null };
const { parameterMetadata } = this.props;
this._description = parameterMetadata
? parameterMetadata.getDescription()
@@ -61,8 +61,8 @@ export default class BehaviorField extends Component {
if (this._field) this._field.focus();
}
_getError = () => {
if (!this.props.value) return null;
_getError = (value?: string) => {
if (!value && !this.props.value) return null;
const isValidChoice =
this._behaviorNames.filter(choice => this.props.value === choice)
@@ -73,8 +73,8 @@ export default class BehaviorField extends Component {
return null;
};
_doValidation = () => {
this.setState({ errorText: this._getError() });
_doValidation = (value?: string) => {
this.setState({ errorText: this._getError(value) });
};
componentDidUpdate() {
@@ -115,12 +115,27 @@ export default class BehaviorField extends Component {
? noBehaviorErrorText
: this.state.errorText
}
searchText={this.props.value}
onUpdateInput={value => {
this.setState({ errorText: null });
this.props.onChange(value);
searchText={this.state.focused ? this.state.text : this.props.value}
onFocus={() => {
this.setState({
focused: true,
text: this.props.value,
});
}}
onUpdateInput={value => {
this.setState({
focused: true,
text: value,
});
}}
onBlur={event => {
this.props.onChange(event.target.value);
this.setState({
focused: false,
text: null,
});
this._doValidation(event.target.value);
}}
onBlur={this._doValidation}
onNewRequest={data => {
// Note that data may be a string or a {text, value} object.
if (typeof data === 'string') {

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