Compare commits

...

79 Commits

Author SHA1 Message Date
Florian Rival
e79a328748 Bump newIDE version 2018-02-25 23:24:20 +01:00
Florian Rival
2083ee1029 Update hosted GDJS root for previews in browser with S3 in newIDE 2018-02-25 23:24:10 +01:00
Florian Rival
3e982cdd87 Add link to roadmap in newIDE readme 2018-02-25 22:58:06 +01:00
Florian Rival
883527b289 Fix tests 2018-02-25 22:38:46 +01:00
Florian Rival
a4d84efdd5 Add support for editing properties of resources in ResourcePropertiesEditor in newIDE 2018-02-25 22:35:17 +01:00
Florian Rival
e46c8493bc Refactor Resource to use gd::PropertyDescriptor for custom properties 2018-02-25 22:17:04 +01:00
Florian Rival
4c443b09cf Update zombie-laser example for newIDE 2018-02-25 18:57:14 +01:00
Florian Rival
98bc2236f4 Merge pull request #445 from Lizard-13/raycast-1
Add Raycast condition
2018-02-25 18:08:43 +01:00
Florian Rival
5199299639 Add analytics when a user choose a new subscription plan 2018-02-25 17:45:49 +01:00
Florian Rival
3268d1db25 Merge pull request #451 from 4ian/feature/profile-in-context
Preview over wifi, GDevelop splash and minor improvements
2018-02-25 17:36:34 +01:00
Florian Rival
741770924b Remove useless package & update subscription descriptions 2018-02-25 17:34:55 +01:00
Florian Rival
49aa9469bb Add SubscriptionChecker when trying to deactivate GDevelop splash in ProjectPropertiesDialog 2018-02-25 17:19:24 +01:00
Florian Rival
7cbe34436c Improve design of SubscriptionDialog and SubscriptionCheckDialog 2018-02-25 16:40:48 +01:00
Lizard-13
122f7ecf3e Fix date functions (#450) 2018-02-25 14:13:23 +01:00
Florian Rival
d79bdd9554 Add SubscriptionChecker to ask users to get a subscription if needed 2018-02-24 20:34:59 +01:00
Lizard-13
3e331cb2e8 Fix event description string (#448) 2018-02-24 19:02:15 +01:00
Florian Rival
361fb6aeab Move UserProfile into a single object provided by a Provider (using react-create-context)
Can be updated later to use the new React Context API once it's ready
SubscriptionCheckDialog is still a Work-In-Progress.
2018-02-24 16:23:45 +01:00
Florian Rival
b4a76895ee [WIP] Display dialog asking for a subscription when starting network preview
TODO: Refactor to store user profile in a context/store to avoid de-synchronisation
between components using UserProfileContainer.
2018-02-24 14:31:08 +01:00
Florian Rival
b2251e1a12 Fix external layout previews for web-app 2018-02-23 15:55:19 +01:00
Florian Rival
1c1860370a Prevent pinch-to-zoom on exported games/preview and set black address bar 2018-02-23 15:24:35 +01:00
Florian Rival
1a190b2a44 Add Network Preview (Preview over wifi) to newIDE with live reload 2018-02-23 12:41:18 +01:00
Florian Rival
b1e0f72416 Add local server in Electron app (to serve previews over wifi) 2018-02-20 08:31:13 +01:00
Florian Rival
2c4ae7573e Add LoadingScreen in project properties to allow to show/hide splash at startup 2018-02-18 23:02:26 +01:00
Florian Rival
04ff1f2726 Add GDevelop Splashscreen at game startup 2018-02-18 21:55:42 +01:00
Florian Rival
eaa5200f95 Fix warning 2018-02-18 17:00:05 +01:00
Florian Rival
53c749b79e Update some links in newIDE to the new GDevelop website (gdevelop-app.com) 2018-02-18 16:30:39 +01:00
Lizard-13
eb96ee8497 Fix @static hint 2018-02-17 17:56:07 -03:00
Lizard-13
458444ee7b Implement collinear case 2018-02-17 16:02:13 -03:00
Lizard-13
c8eb13f18f Minor fixes
Removed circle code, unused includes and debug lines.
Improved extension strings.
Added reference link.
Updated "Laser and zombies.gdg" example
2018-02-17 16:01:11 -03:00
Lizard-13
a224b93edc Remove circle from test game 2018-02-17 16:01:00 -03:00
Lizard-13
f077ca6723 Commented out circle raycasting and added icons 2018-02-17 16:00:52 -03:00
Lizard-13
6bbfa1d4a1 Implement C++ version
And little fixes on the JS version
2018-02-17 16:00:32 -03:00
Lizard-13
3c3dc6ef6e Implement raycast JS version and test game 2018-02-17 16:00:18 -03:00
Lizard-13
5c101dbcda Engine condition set up
Neither tested nor compiled yet
2018-02-17 15:56:50 -03:00
Florian Rival
701b78361a Add support for disabled events in EventsSheet in newIDE 2018-02-17 16:34:42 +01:00
Florian Rival
07f26027f6 Bump newIDE version 2018-02-15 22:56:13 +01:00
Florian Rival
09cf13d6e2 Add confirm before close dialog to newIDE 2018-02-15 22:50:08 +01:00
Florian Rival
42f91565fa Merge pull request #443 from 4ian/feature/cordova-icons
Add support for icons when exporting to Android/iOS
2018-02-13 19:51:04 +01:00
Florian Rival
ac6c146808 Fix ImageThumbnail error when onContextMenu is not specified 2018-02-13 19:50:21 +01:00
Florian Rival
59ad23f8ac Allow to customize game orientation (for when exported with Cordova) 2018-02-11 23:44:00 +01:00
Florian Rival
769c6fe3d5 Move ResourcesLoader in its own folder + refactor methods 2018-02-11 23:17:44 +01:00
Florian Rival
07b92911ab Add message on web-app about non support of automatic icons creation 2018-02-11 22:03:30 +01:00
Florian Rival
eb57bcfc87 Add iOS icons support for Cordova + fix image caching 2018-02-11 21:52:40 +01:00
Florian Rival
7addeba73a Add support for Android icons in Cordova export 2018-02-11 21:14:18 +01:00
Florian Rival
263902b45a Avoid caching in ImagePreview and ImageThumbnail 2018-02-11 18:14:47 +01:00
Florian Rival
d283f759fe Add PlatformSpecificAssets to Project 2018-02-10 18:36:02 +01:00
Florian Rival
fabd028a63 Update VSCode C++ properties for Intellisense 2018-02-10 18:35:05 +01:00
Florian Rival
2b18272c41 Merge branch 'master' of github.com:4ian/GD 2018-02-07 00:02:25 +01:00
Florian Rival
a1fb39da3d Fix scene unloading re-creating a RuntimeSceneRenderer leading to issues with Cocos2d-JS renderer 2018-02-05 23:12:51 +01:00
Florian Rival
09602fdf9e Merge pull request #441 from ronnystandtke/patch-1
Update gdevelop.desktop
2018-02-04 17:03:22 +01:00
ronnystandtke
d574ef17ba Update gdevelop.desktop
added German L10n
2018-02-04 17:00:34 +01:00
Florian Rival
0e3f70627b Bump newIDE version 2018-02-03 19:32:52 +01:00
Florian Rival
a814a07105 Fix ResourcesEditor selection 2018-02-03 19:24:47 +01:00
Florian Rival
c49af90a9c Add program opening count to Keen.io analytics 2018-02-03 19:09:33 +01:00
Florian Rival
24afa155c8 Improve Keen.io analytics events by adding user profile information 2018-02-03 18:30:09 +01:00
Florian Rival
9e5a431516 Only run Fullstory on newIDE web-app 2018-02-03 17:53:57 +01:00
Florian Rival
182a94285c Unregister service worker (it is not ready yet) 2018-02-03 13:05:22 +01:00
Florian Rival
442c2c8dd9 Merge pull request #439 from 4ian/feature/resources-editor
Resources editor for newIDE
2018-02-03 12:57:22 +01:00
Florian Rival
f8fd0dd353 Add a preview in ResourcesEditor 2018-02-03 12:55:30 +01:00
Florian Rival
faad9e23ac Add ResourcesEditor with ResourcePropertiesEditor and Toolbar 2018-01-30 23:12:31 +01:00
Florian Rival
d2af0da1b1 Added tools method to ResourcesManager and finish working version of ResourcesList 2018-01-30 21:56:40 +01:00
Florian Rival
c65e5c3e49 [WIP] Add ResourcesEditor based on a generic SortableVirtualizedItemList
TODO:
* Use SortableVirtualizedItemList for ObjectsList and ObjectsGroupsList
* Add missing features (sorting, delete, thumbnail for images, properties edition) to ResourcesEditor
2018-01-30 00:58:21 +01:00
Florian Rival
24a8dfc5f0 Add SemiControlledTextField to be able to type freely in PropertiesEditor 2018-01-28 18:45:44 +01:00
Florian Rival
9c6790ac37 Update default gravity in PhysicsBehavior 2018-01-27 23:50:49 +01:00
Florian Rival
18ef7460ba Bump newIDE version 2018-01-27 19:34:36 +01:00
Florian Rival
63cd0e76c3 Fix warning 2018-01-27 19:34:27 +01:00
Florian Rival
bdbf7fd9fc Add support for editing BehaviorSharedData in newIDE
TODO:
* Support for cancelling modifications made on it in ScenePropertiesDialog
2018-01-27 19:13:27 +01:00
Florian Rival
6bbedbd8f9 Fix BehaviorSharedData not created by newIDE + fix warnings 2018-01-27 17:00:44 +01:00
Florian Rival
648bd1ff2e Show warning if game name or package name is empty when exporting in newIDE 2018-01-24 23:31:02 +01:00
Florian Rival
d4288caedb Fix .env file loading with electron-app and bump newIDE version 2018-01-23 00:15:13 +01:00
Florian Rival
0a35bc3272 Bump newIDE version 2018-01-22 23:35:55 +01:00
Florian Rival
d8b737a31f Fix LocalS3Export always reusing the same folder leading to useless files in exported game 2018-01-22 23:35:32 +01:00
Florian Rival
cfd2655f6c Bump newIDE version 2018-01-22 23:29:21 +01:00
Florian Rival
1896241b9d Move AWS S3 credentials to an .env file for games deployment on GDevelop hosting 2018-01-22 23:25:42 +01:00
Florian Rival
0ed22a6ee1 Fix upload to GDevelop hosting of exported games with large files 2018-01-22 22:52:44 +01:00
Florian Rival
2bfcb99c3e Add analytics when a signup is done 2018-01-22 00:20:32 +01:00
Florian Rival
815f8a520a Bump newIDE version 2018-01-21 22:11:59 +01:00
Florian Rival
f115b6607f Add PhysicsBehavior support to newIDE, with an example 2018-01-21 22:11:24 +01:00
Florian Rival
c876f67502 Add pathfinding example to newIDE web-app 2018-01-20 21:25:25 +01:00
199 changed files with 24256 additions and 3003 deletions

View File

@@ -10,28 +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/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}"
@@ -39,7 +42,6 @@
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "clang-x64",
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
@@ -49,10 +51,27 @@
"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",
@@ -61,19 +80,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/*",
@@ -81,9 +115,8 @@
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "msvc-x64"
}
}
],
"version": 3
}
}

View File

@@ -67,7 +67,11 @@
"__functional_base": "cpp",
"__functional_base_03": "cpp",
"chrono": "cpp",
"ratio": "cpp"
"ratio": "cpp",
"atomic": "cpp",
"locale": "cpp",
"string_view": "cpp",
"__string": "cpp"
},
"files.exclude": {
"Binaries/*build*": 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

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

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

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

@@ -68,7 +68,7 @@ public:
* Usage example:
\code
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[ToString(_("Initial speed"))].SetValue("5");
properties[_("Initial speed")].SetValue(gd::String::From(initialSpeed));
return properties;
\endcode

View File

@@ -5,6 +5,10 @@
*/
#include "GDCore/Project/BehaviorsSharedData.h"
#if defined(GD_IDE_ONLY)
#include <map>
#include "GDCore/IDE/Dialogs/PropertyDescriptor.h"
#endif
namespace gd
{
@@ -13,4 +17,12 @@ BehaviorsSharedData::~BehaviorsSharedData()
{
};
#if defined(GD_IDE_ONLY)
std::map<gd::String, gd::PropertyDescriptor> BehaviorsSharedData::GetProperties(gd::Project & project) const
{
std::map<gd::String, gd::PropertyDescriptor> nothing;
return nothing;
}
#endif
}

View File

@@ -8,9 +8,13 @@
#define BEHAVIORSSHAREDDATA_H
#include <memory>
#include <map>
#include "GDCore/String.h"
class BehaviorsRuntimeSharedData;
namespace gd { class SerializerElement; }
namespace gd { class PropertyDescriptor; }
namespace gd { class Project; }
namespace gd { class Layout; }
namespace gd
{
@@ -52,6 +56,31 @@ public:
virtual void SetTypeName(const gd::String & type_) { type = type_; };
#if defined(GD_IDE_ONLY)
/**
* \brief Called when the IDE wants to know about the properties of the shared data.
*
* Usage example:
\code
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[_("Initial speed")].SetValue(gd::String::From(initialSpeed));
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 property of the shared data
*
* \return false if the new value cannot be set
* \see gd::InitialInstance
*/
virtual bool UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project) {return false;};
/**
* \brief Serialize behaviors shared data.
*/

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

@@ -29,6 +29,7 @@ namespace gd
{
gd::Layer Layout::badLayer;
gd::BehaviorsSharedData Layout::badBehaviorSharedData;
Layout::Layout(const Layout & other)
{
@@ -74,6 +75,53 @@ void Layout::SetName(const gd::String & name_)
mangledName = gd::SceneNameMangler::GetMangledSceneName(name);
};
bool Layout::HasBehaviorSharedData(const gd::String & behaviorName)
{
return behaviorsInitialSharedDatas.find(behaviorName) != behaviorsInitialSharedDatas.end();
}
std::vector <gd::String> Layout::GetAllBehaviorSharedDataNames() const
{
std::vector < gd::String > allNames;
for (auto & it : behaviorsInitialSharedDatas)
allNames.push_back(it.first);
return allNames;
}
const gd::BehaviorsSharedData & Layout::GetBehaviorSharedData(const gd::String & behaviorName) const
{
auto it = behaviorsInitialSharedDatas.find(behaviorName);
if (it != behaviorsInitialSharedDatas.end())
return *it->second;
return badBehaviorSharedData;
}
gd::BehaviorsSharedData & Layout::GetBehaviorSharedData(const gd::String & behaviorName)
{
auto it = behaviorsInitialSharedDatas.find(behaviorName);
if (it != behaviorsInitialSharedDatas.end())
return *it->second;
return badBehaviorSharedData;
}
std::shared_ptr<gd::BehaviorsSharedData> Layout::GetBehaviorSharedDataSmartPtr(const gd::String & behaviorName)
{
auto it = behaviorsInitialSharedDatas.find(behaviorName);
if (it != behaviorsInitialSharedDatas.end())
return it->second;
return std::shared_ptr<gd::BehaviorsSharedData>();
}
const std::map < gd::String, std::shared_ptr<gd::BehaviorsSharedData> > & Layout::GetAllBehaviorSharedData() const
{
return behaviorsInitialSharedDatas;
}
gd::Layer & Layout::GetLayer(const gd::String & name)
{
std::vector<gd::Layer>::iterator layer = find_if(initialLayers.begin(), initialLayers.end(), bind2nd(gd::LayerHasName(), name));
@@ -83,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));
@@ -92,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;
@@ -253,15 +253,45 @@ public:
///@}
/**
* Make sure that the scene had an instance of shared data for
* This ensures that the scene had an instance of shared data for
* every behavior of every object that can be used on the scene
* ( i.e. the objects of the scene and the global objects )
* (i.e. the objects of the scene and the global objects)
*
* Must be called when a behavior have been added/deleted
* or when a scene have been added to a project.
*/
void UpdateBehaviorsSharedData(gd::Project & project);
/**
* \brief Get the names of all shared data stored for behaviors
*/
std::vector <gd::String> GetAllBehaviorSharedDataNames() const;
/**
* \brief Check if shared data are stored for a behavior
*/
bool HasBehaviorSharedData(const gd::String & behaviorName);
/**
* \brief Get the shared data stored for a behavior
*/
const gd::BehaviorsSharedData & GetBehaviorSharedData(const gd::String & behaviorName) const;
/**
* \brief Get the shared data stored for a behavior
*/
gd::BehaviorsSharedData & GetBehaviorSharedData(const gd::String & behaviorName);
/**
* \brief Get a map of all shared data stored for behaviors
*/
const std::map < gd::String, std::shared_ptr<gd::BehaviorsSharedData> > & GetAllBehaviorSharedData() const;
/**
* \brief Get the (smart pointer to the) shared data stored for a behavior.
*/
std::shared_ptr<gd::BehaviorsSharedData> GetBehaviorSharedDataSmartPtr(const gd::String & behaviorName);
#if defined(GD_IDE_ONLY)
/**
* Return the settings associated to the layout.
@@ -357,9 +387,6 @@ public:
void UnserializeFrom(gd::Project & project, const SerializerElement & element);
///@}
//TODO: Send this to private part.
std::map < gd::String, std::shared_ptr<gd::BehaviorsSharedData> > behaviorsInitialSharedDatas; ///< Initial shared datas of behaviors
//TODO: GD C++ Platform specific code below
#if defined(GD_IDE_ONLY)
/** \name Events compilation and bitcode management
@@ -442,6 +469,7 @@ private:
gd::InitialInstancesContainer initialInstances; ///< Initial instances
std::vector < gd::Layer > initialLayers; ///< Initial layers
ObjectGroupsContainer objectGroups; ///< Objects groups
std::map < gd::String, std::shared_ptr<gd::BehaviorsSharedData> > behaviorsInitialSharedDatas; ///< Initial shared datas of behaviors
bool stopSoundsOnStartup; ///< True to make the scene stop all sounds at startup.
bool standardSortMethod; ///< True to sort objects using standard sort.
float oglFOV; ///< OpenGL Field Of View value
@@ -449,6 +477,7 @@ private:
float oglZFar; ///< OpenGL Far Z position
bool disableInputWhenNotFocused; /// If set to true, the input must be disabled when the window do not have the focus.
static gd::Layer badLayer; ///< Null object, returned when GetLayer can not find an appropriate layer.
static gd::BehaviorsSharedData badBehaviorSharedData; ///< Null object, returned when GetBehaviorSharedData can not find the specified behavior shared data.
#if defined(GD_IDE_ONLY)
EventsList events; ///< Scene events
gd::LayoutEditorCanvasOptions associatedSettings;

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

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

@@ -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");

View File

@@ -21,7 +21,7 @@ class GD_EXTENSION_API AdMobObject : public gd::Object
public:
AdMobObject(gd::String name_);
virtual ~AdMobObject() {};
virtual std::unique_ptr<gd::Object> Clone() const { return gd::make_unique<AdMobObject>(*this); }
virtual std::unique_ptr<gd::Object> Clone() const override { return gd::make_unique<AdMobObject>(*this); }
#if !defined(GD_NO_WX_GUI)
void DrawInitialInstance(gd::InitialInstance & instance, sf::RenderTarget & renderTarget, gd::Project & project, gd::Layout & layout) override;

View File

@@ -37,9 +37,7 @@ IF (NOT EMSCRIPTEN)
ADD_SUBDIRECTORY(PathBehavior)
ENDIF()
ADD_SUBDIRECTORY(PathfindingBehavior)
IF (NOT EMSCRIPTEN)
ADD_SUBDIRECTORY(PhysicsBehavior)
ENDIF()
ADD_SUBDIRECTORY(PhysicsBehavior)
ADD_SUBDIRECTORY(PlatformBehavior)
ADD_SUBDIRECTORY(PrimitiveDrawing)
ADD_SUBDIRECTORY(Shopify)

View File

@@ -322,13 +322,13 @@ PathBehaviorEditor::PathBehaviorEditor(wxWindow* parent, gd::Project & game_, gd
followAngleCheck->SetValue(behavior.FollowAngle());
//Setup shared datas
if ( !scene || scene->behaviorsInitialSharedDatas.find(behavior.GetName()) == scene->behaviorsInitialSharedDatas.end())
if (!scene || !scene->HasBehaviorSharedData(behavior.GetName()))
{
gd::LogError(_("Unable to access to shared datas."));
return;
}
sharedDatas = std::dynamic_pointer_cast<ScenePathDatas>(scene->behaviorsInitialSharedDatas[behavior.GetName()]);
sharedDatas = std::dynamic_pointer_cast<ScenePathDatas>(scene->GetBehaviorSharedDataSmartPtr(behavior.GetName()));
if ( sharedDatas == std::shared_ptr<ScenePathDatas>() )
{

View File

@@ -10,36 +10,36 @@ This project is released under the MIT License.
#include "PathfindingBehavior.h"
#include "PathfindingObstacleBehavior.h"
void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
void DeclarePathfindingBehaviorExtension(gd::PlatformExtension& extension)
{
extension.SetExtensionInformation("PathfindingBehavior",
_("Pathfinding behavior"),
_("Compute paths for objects avoiding obstacles."),
"Florian Rival",
"Open source (MIT License)");
_("Pathfinding behavior"),
_("Compute paths for objects avoiding obstacles."),
"Florian Rival",
"Open source (MIT License)");
{
gd::BehaviorMetadata &aut = extension.AddBehavior("PathfindingBehavior",
_("Pathfinding"),
"Pathfinding",
_("With this, characters will move while avoiding all objects that are flagged as obstacles."),
"",
"CppPlatform/Extensions/AStaricon.png",
"PathfindingBehavior",
std::make_shared<PathfindingBehavior>(),
std::make_shared<gd::BehaviorsSharedData>());
gd::BehaviorMetadata& aut = extension.AddBehavior("PathfindingBehavior",
_("Pathfinding"),
"Pathfinding",
_("With this, characters will move while avoiding all objects that are flagged as obstacles."),
"",
"CppPlatform/Extensions/AStaricon.png",
"PathfindingBehavior",
std::make_shared<PathfindingBehavior>(),
std::make_shared<gd::BehaviorsSharedData>());
#if defined(GD_IDE_ONLY)
aut.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("SetDestination",
_("Move to a position"),
_("Move the object to a position"),
_("Move _PARAM0_ to _PARAM3_;_PARAM4_"),
_(""),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Move to a position"),
_("Move the object to a position"),
_("Move _PARAM0_ to _PARAM3_;_PARAM4_"),
_(""),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
.AddCodeOnlyParameter("currentScene", "")
@@ -50,12 +50,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("PathFound",
_("Path found"),
_("Return true if a path has been found."),
_("A path has been found for _PARAM0_"),
_(""),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Path found"),
_("Return true if a path has been found."),
_("A path has been found for _PARAM0_"),
_(""),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -63,12 +63,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("DestinationReached",
_("Destination reached"),
_("Return true if the destination was reached."),
_("_PARAM0_ reached its destination"),
_(""),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Destination reached"),
_("Return true if the destination was reached."),
_("_PARAM0_ reached its destination"),
_(""),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -76,12 +76,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("CellWidth",
_("Width of the cells"),
_("Change the width of the cells of the virtual grid."),
_("Do _PARAM2__PARAM3_ to the width of the virtual cells of _PARAM0_"),
_("Virtual grid"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Width of the cells"),
_("Change the width of the cells of the virtual grid."),
_("Do _PARAM2__PARAM3_ to the width of the virtual cells of _PARAM0_"),
_("Virtual grid"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -93,12 +93,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("CellWidth",
_("Width of the virtual grid"),
_("Compare the width of the cells of the virtual grid."),
_("Width of the virtual cells of _PARAM0_ is _PARAM2__PARAM3_"),
_("Virtual grid"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Width of the virtual grid"),
_("Compare the width of the cells of the virtual grid."),
_("Width of the virtual cells of _PARAM0_ is _PARAM2__PARAM3_"),
_("Virtual grid"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -109,12 +109,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("CellHeight",
_("Height of the cells"),
_("Change the height of the cells of the virtual grid."),
_("Do _PARAM2__PARAM3_ to the height of the virtual cells of _PARAM0_"),
_("Virtual grid"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Height of the cells"),
_("Change the height of the cells of the virtual grid."),
_("Do _PARAM2__PARAM3_ to the height of the virtual cells of _PARAM0_"),
_("Virtual grid"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -126,12 +126,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("CellHeight",
_("Height of the virtual grid"),
_("Compare the height of the cells of the virtual grid."),
_("Height of the virtual cells of _PARAM0_ is _PARAM2__PARAM3_"),
_("Virtual grid"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Height of the virtual grid"),
_("Compare the height of the cells of the virtual grid."),
_("Height of the virtual cells of _PARAM0_ is _PARAM2__PARAM3_"),
_("Virtual grid"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -142,12 +142,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("Acceleration",
_("Acceleration"),
_("Change the acceleration when moving the object"),
_("Do _PARAM2__PARAM3_ to the acceleration of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Acceleration"),
_("Change the acceleration when moving the object"),
_("Do _PARAM2__PARAM3_ to the acceleration of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -159,12 +159,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("Acceleration",
_("Acceleration"),
_("Compare the acceleration when moving the object"),
_("Acceleration of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Acceleration"),
_("Compare the acceleration when moving the object"),
_("Acceleration of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -175,12 +175,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("MaxSpeed",
_("Maximum speed"),
_("Change the maximum speed when moving the object"),
_("Do _PARAM2__PARAM3_ to the max. speed of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Maximum speed"),
_("Change the maximum speed when moving the object"),
_("Do _PARAM2__PARAM3_ to the max. speed of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -192,12 +192,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("MaxSpeed",
_("Maximum speed"),
_("Compare the maximum speed when moving the object"),
_("Max. speed of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Maximum speed"),
_("Compare the maximum speed when moving the object"),
_("Max. speed of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -208,12 +208,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("Speed",
_("Speed"),
_("Change the speed of the object on the path"),
_("Do _PARAM2__PARAM3_ to the speed of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Speed"),
_("Change the speed of the object on the path"),
_("Do _PARAM2__PARAM3_ to the speed of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -225,12 +225,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("Speed",
_("Speed"),
_("Compare the speed of the object on the path"),
_("Speed of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Speed"),
_("Compare the speed of the object on the path"),
_("Speed of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -241,12 +241,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("AngularMaxSpeed",
_("Angular maximum speed"),
_("Change the maximum angular speed when moving the object"),
_("Do _PARAM2__PARAM3_ to the max. angular speed of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Angular maximum speed"),
_("Change the maximum angular speed when moving the object"),
_("Do _PARAM2__PARAM3_ to the max. angular speed of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -258,12 +258,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("AngularMaxSpeed",
_("Angular maximum speed"),
_("Compare the maximum angular speed when moving the object"),
_("Max. angular speed of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Angular maximum speed"),
_("Compare the maximum angular speed when moving the object"),
_("Max. angular speed of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -274,12 +274,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("AngleOffset",
_("Rotation offset"),
_("Change the rotation offset applied when moving the object"),
_("Do _PARAM2__PARAM3_ to the rotation offset of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Rotation offset"),
_("Change the rotation offset applied when moving the object"),
_("Do _PARAM2__PARAM3_ to the rotation offset of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -291,12 +291,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("AngleOffset",
_("Rotation offset"),
_("Compare the rotation offset when moving the object"),
_("Rotation offset of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Rotation offset"),
_("Compare the rotation offset when moving the object"),
_("Rotation offset of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -307,12 +307,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("ExtraBorder",
_("Extra border"),
_("Change the size of the extra border applied to the object when planning a path"),
_("Do _PARAM2__PARAM3_ to the extra border of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Extra border"),
_("Change the size of the extra border applied to the object when planning a path"),
_("Do _PARAM2__PARAM3_ to the extra border of _PARAM0_ on the path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -324,12 +324,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("ExtraBorder",
_("Extra border"),
_("Compare the size of the extra border applied to the object when planning a path"),
_("Size of the extra border applied to _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Extra border"),
_("Compare the size of the extra border applied to the object when planning a path"),
_("Size of the extra border applied to _PARAM0_ is _PARAM2__PARAM3_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -340,12 +340,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("AllowDiagonals",
_("Diagonals moves"),
_("Allow or restrict diagonal movement on the path"),
_("Allow diagonal movement for _PARAM0_ on the path: _PARAM2_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Diagonals moves"),
_("Allow or restrict diagonal movement on the path"),
_("Allow diagonal movement for _PARAM0_ on the path: _PARAM2_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -354,12 +354,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("DiagonalsAllowed",
_("Diagonals moves"),
_("Return true if the object is allowed to move diagonally on the path"),
_("Diagonal moves allowed for _PARAM0_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Diagonals moves"),
_("Return true if the object is allowed to move diagonally on the path"),
_("Diagonal moves allowed for _PARAM0_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -367,12 +367,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddAction("RotateObject",
_("Rotate the object"),
_("Enable or disable rotation of the object on the path"),
_("Enable rotation of _PARAM0_ on the path: _PARAM2_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Rotate the object"),
_("Enable or disable rotation of the object on the path"),
_("Enable rotation of _PARAM0_ on the path: _PARAM2_"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -381,12 +381,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");
aut.AddCondition("ObjectRotated",
_("Object rotated"),
_("Return true if the object is rotated when traveling on its path."),
_("_PARAM0_ is rotated when traveling on its path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
_("Object rotated"),
_("Return true if the object is rotated when traveling on its path."),
_("_PARAM0_ is rotated when traveling on its path"),
_("Path"),
"CppPlatform/Extensions/AStaricon24.png",
"CppPlatform/Extensions/AStaricon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
@@ -506,26 +506,26 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
#endif
}
{
gd::BehaviorMetadata &aut = extension.AddBehavior("PathfindingObstacleBehavior",
_("Obstacle for pathfinding"),
"PathfindingObstacle",
_("Flag the object as being an obstacle for pathfinding."),
"",
"CppPlatform/Extensions/pathfindingobstacleicon.png",
"PathfindingObstacleBehavior",
std::make_shared<PathfindingObstacleBehavior>(),
std::make_shared<gd::BehaviorsSharedData>());
gd::BehaviorMetadata& aut = extension.AddBehavior("PathfindingObstacleBehavior",
_("Obstacle for pathfinding"),
"PathfindingObstacle",
_("Flag the object as being an obstacle for pathfinding."),
"",
"CppPlatform/Extensions/pathfindingobstacleicon.png",
"PathfindingObstacleBehavior",
std::make_shared<PathfindingObstacleBehavior>(),
std::make_shared<gd::BehaviorsSharedData>());
#if defined(GD_IDE_ONLY)
aut.SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");
aut.AddAction("Cost",
_("Cost"),
_("Change the cost of going through the object."),
_("Do _PARAM2__PARAM3_ to the cost of _PARAM0_"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
"CppPlatform/Extensions/pathfindingobstacleicon16.png")
_("Cost"),
_("Change the cost of going through the object."),
_("Do _PARAM2__PARAM3_ to the cost of _PARAM0_"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
"CppPlatform/Extensions/pathfindingobstacleicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
@@ -537,12 +537,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");
aut.AddCondition("Cost",
_("Cost"),
_("Compare the cost of going through the object"),
_("Cost of _PARAM0_ is _PARAM2__PARAM3_"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
"CppPlatform/Extensions/pathfindingobstacleicon16.png")
_("Cost"),
_("Compare the cost of going through the object"),
_("Cost of _PARAM0_ is _PARAM2__PARAM3_"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
"CppPlatform/Extensions/pathfindingobstacleicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
@@ -553,12 +553,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");
aut.AddAction("SetImpassable",
_("Should object be impassable?"),
_("Decide if the object is an impassable obstacle"),
_("Set _PARAM0_ as an impassable obstacle: _PARAM2_"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
"CppPlatform/Extensions/pathfindingobstacleicon16.png")
_("Should object be impassable?"),
_("Decide if the object is an impassable obstacle"),
_("Set _PARAM0_ as an impassable obstacle: _PARAM2_"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
"CppPlatform/Extensions/pathfindingobstacleicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
@@ -567,12 +567,12 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
.SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");
aut.AddCondition("IsImpassable",
_("Is object impassable?"),
_("Return true if the obstacle is impassable"),
_("_PARAM0_ is impassable"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
"CppPlatform/Extensions/pathfindingobstacleicon16.png")
_("Is object impassable?"),
_("Return true if the obstacle is impassable"),
_("_PARAM0_ is impassable"),
_("Obstacles"),
"CppPlatform/Extensions/pathfindingobstacleicon24.png",
"CppPlatform/Extensions/pathfindingobstacleicon16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
@@ -592,9 +592,8 @@ void DeclarePathfindingBehaviorExtension(gd::PlatformExtension &extension)
/**
* \brief This class declares information about the extension.
*/
class PathfindingBehaviorCppExtension : public ExtensionBase
{
public:
class PathfindingBehaviorCppExtension : public ExtensionBase {
public:
/**
* Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
*/
@@ -607,7 +606,7 @@ class PathfindingBehaviorCppExtension : public ExtensionBase
};
#if defined(ANDROID)
extern "C" ExtensionBase *CreateGDCppPathfindingBehaviorExtension()
extern "C" ExtensionBase* CreateGDCppPathfindingBehaviorExtension()
{
return new PathfindingBehaviorCppExtension;
}
@@ -616,7 +615,7 @@ extern "C" ExtensionBase *CreateGDCppPathfindingBehaviorExtension()
* Used by GDevelop to create the extension class
* -- Do not need to be modified. --
*/
extern "C" ExtensionBase *GD_EXTENSION_API CreateGDExtension()
extern "C" ExtensionBase* GD_EXTENSION_API CreateGDExtension()
{
return new PathfindingBehaviorCppExtension;
}

View File

@@ -7,7 +7,6 @@ This project is released under the MIT License.
#if defined(GD_IDE_ONLY)
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/Tools/Localization.h"
#include <iostream>
void DeclarePathfindingBehaviorExtension(gd::PlatformExtension & extension);
@@ -99,6 +98,7 @@ public:
}
StripUnimplementedInstructionsAndExpressions();
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
};
};

File diff suppressed because it is too large Load Diff

View File

@@ -6,29 +6,23 @@ This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#include "GDCore/Extensions/PlatformExtension.h"
#include <iostream>
#include "GDCore/Tools/Localization.h"
void DeclarePhysicsBehaviorExtension(gd::PlatformExtension & extension);
/**
* \brief This class declares information about the JS extension.
*/
class JsExtension : public gd::PlatformExtension
class PhysicsBehaviorJsExtension : public gd::PlatformExtension
{
public:
/**
* \brief Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
*/
JsExtension()
PhysicsBehaviorJsExtension()
{
SetExtensionInformation("PhysicsBehavior",
_("Physics behavior"),
_("Behavior allowing to move objects as if they were subject to the laws of physics."),
"Florian Rival",
"Open source (MIT License)");
CloneExtension("GDevelop C++ platform", "PhysicsBehavior");
DeclarePhysicsBehaviorExtension(*this);
GetBehaviorMetadata("PhysicsBehavior::PhysicsBehavior")
.SetIncludeFile("Extensions/PhysicsBehavior/box2djs/box2d.js")
@@ -145,14 +139,21 @@ public:
*/
StripUnimplementedInstructionsAndExpressions();
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
};
};
#if defined(EMSCRIPTEN)
extern "C" gd::PlatformExtension * CreateGDJSPhysicsBehaviorExtension() {
return new PhysicsBehaviorJsExtension;
}
#else
/**
* Used by GDevelop to create the extension class
* -- Do not need to be modified. --
*/
extern "C" gd::PlatformExtension * GD_EXTENSION_API CreateGDJSExtension() {
return new JsExtension;
return new PhysicsBehaviorJsExtension;
}
#endif
#endif

View File

@@ -7,6 +7,7 @@ This project is released under the MIT License.
#include "PhysicsBehavior.h"
#include <string>
#include "GDCore/Tools/Localization.h"
#include "Box2D/Box2D.h"
#include "Triangulation/triangulate.h"
#include "GDCpp/Runtime/RuntimeScene.h"
@@ -17,6 +18,10 @@ This project is released under the MIT License.
#include "GDCpp/Runtime/Project/Project.h"
#include "GDCpp/Runtime/Project/Layout.h"
#include "RuntimeScenePhysicsDatas.h"
#if defined(GD_IDE_ONLY)
#include <map>
#include "GDCore/IDE/Dialogs/PropertyDescriptor.h"
#endif
#undef GetObject
@@ -100,10 +105,6 @@ void PhysicsBehavior::DoStepPostEvents(RuntimeScene & scene)
float newHeight = object->GetHeight();
if ( (int)objectOldWidth != (int)newWidth || (int)objectOldHeight != (int)newHeight )
{
/*std::cout << "Changed:" << (int)objectOldWidth << "!=" << (int)newWidth << std::endl;
std::cout << "Changed:" << (int)objectOldHeight << "!=" << (int)newHeight << std::endl;
std::cout << "( Object name:" << object->GetName() << std::endl;*/
double oldAngularVelocity = body->GetAngularVelocity();
b2Vec2 oldVelocity = body->GetLinearVelocity();
@@ -700,6 +701,76 @@ void PhysicsBehavior::UnserializeFrom(const gd::SerializerElement & element)
SetPolygonCoords(PhysicsBehavior::GetCoordsVectorFromString(coordsStr, '/', ';'));
}
#if defined(GD_IDE_ONLY)
std::map<gd::String, gd::PropertyDescriptor> PhysicsBehavior::GetProperties(gd::Project & project) const
{
std::map<gd::String, gd::PropertyDescriptor> properties;
gd::String shapeTypeStr = _("Box (rectangle)");
if (shapeType == Box) shapeTypeStr = _("Box (rectangle)");
else if (shapeType == Circle) shapeTypeStr = _("Circle");
else if (shapeType == CustomPolygon) shapeTypeStr = _("Custom polygon");
properties[_("Shape")]
.SetValue(shapeTypeStr)
.SetType("Choice")
.AddExtraInfo(_("Box (rectangle)"))
.AddExtraInfo(_("Circle"));
properties[_("Dynamic object")].SetValue(dynamic ? "true" : "false").SetType("Boolean");
properties[_("Fixed rotation")].SetValue(fixedRotation ? "true" : "false").SetType("Boolean");
properties[_("Consider as bullet (better collision handling)")].SetValue(isBullet ? "true" : "false").SetType("Boolean");
properties[_("Mass density")].SetValue(gd::String::From(massDensity));
properties[_("Friction")].SetValue(gd::String::From(averageFriction));
properties[_("Restitution (elasticity)")].SetValue(gd::String::From(averageRestitution));
properties[_("Linear Damping")].SetValue(gd::String::From(linearDamping));
properties[_("Angular Damping")].SetValue(gd::String::From(angularDamping));
properties[_("PLEASE_ALSO_SHOW_EDIT_BUTTON_THANKS")].SetValue("");
return properties;
}
bool PhysicsBehavior::UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project)
{
if (name == _("Shape"))
{
if (value == _("Box (rectangle)"))
shapeType = Box;
else if (value == _("Circle"))
shapeType = Circle;
else if (value == _("Custom polygon"))
shapeType = CustomPolygon;
}
if ( name == _("Dynamic object") ) {
dynamic = (value != "0");
}
if ( name == _("Fixed rotation") ) {
fixedRotation = (value != "0");
}
if ( name == _("Consider as bullet (better collision handling)") ) {
isBullet = (value != "0");
}
if ( name == _("Mass density") ) {
massDensity = value.To<float>();
}
if ( name == _("Friction") ) {
averageFriction = value.To<float>();
}
if ( name == _("Restitution (elasticity)") ) {
averageRestitution = value.To<float>();
}
if ( name == _("Linear Damping") ) {
if ( value.To<float>() < 0 ) return false;
linearDamping = value.To<float>();
}
if ( name == _("Angular Damping") ) {
if ( value.To<float>() < 0 ) return false;
angularDamping = value.To<float>();
}
return true;
}
#endif
gd::String PhysicsBehavior::GetStringFromCoordsVector(const std::vector<sf::Vector2f> &vec, char32_t coordsSep, char32_t composantSep)
{

View File

@@ -56,6 +56,9 @@ public:
* Called when user wants to edit the behavior.
*/
virtual void EditBehavior( wxWindow* parent, gd::Project & project_, gd::Layout * layout_, gd::MainFrameWrapper & mainFrameWrapper_ );
virtual std::map<gd::String, gd::PropertyDescriptor> GetProperties(gd::Project & project) const;
virtual bool UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project);
#endif
/**

View File

@@ -241,13 +241,13 @@ scene(scene_)
}
//Setup shared datas
if ( !scene || scene->behaviorsInitialSharedDatas.find(behavior.GetName()) == scene->behaviorsInitialSharedDatas.end())
if (!scene || !scene->HasBehaviorSharedData(behavior.GetName()))
{
gd::LogError(_("Unable to access to shared datas."));
return;
}
sharedDatas = std::dynamic_pointer_cast<ScenePhysicsDatas>(scene->behaviorsInitialSharedDatas[behavior.GetName()]);
sharedDatas = std::dynamic_pointer_cast<ScenePhysicsDatas>(scene->GetBehaviorSharedDataSmartPtr(behavior.GetName()));
if ( sharedDatas == std::shared_ptr<ScenePhysicsDatas>() )
{

View File

@@ -6,9 +6,46 @@ This project is released under the MIT License.
*/
#include "ScenePhysicsDatas.h"
#include "GDCore/Tools/Localization.h"
#include "GDCore/Serialization/SerializerElement.h"
#if defined(GD_IDE_ONLY)
#include <map>
#include "GDCore/String.h"
#include "GDCore/CommonTools.h"
#include "GDCore/Project/Project.h"
#include "GDCore/IDE/Dialogs/PropertyDescriptor.h"
#endif
#if defined(GD_IDE_ONLY)
std::map<gd::String, gd::PropertyDescriptor> ScenePhysicsDatas::GetProperties(gd::Project & project) const
{
std::map<gd::String, gd::PropertyDescriptor> properties;
properties[_("Gravity on X axis (in m/s²)")].SetValue(gd::String::From(gravityX));
properties[_("Gravity on Y axis (in m/s²)")].SetValue(gd::String::From(gravityY));
properties[_("X Scale: number of pixels for 1 meter")].SetValue(gd::String::From(scaleX));
properties[_("Y Scale: number of pixels for 1 meter")].SetValue(gd::String::From(scaleY));
return properties;
}
bool ScenePhysicsDatas::UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project)
{
if (name == _("Gravity on X axis (in m/s²)")) {
gravityX = value.To<float>();
}
if (name == _("Gravity on Y axis (in m/s²)")) {
gravityY = value.To<float>();
}
if (name == _("X scale: number of pixels for 1 meter")) {
scaleX = value.To<float>();
}
if (name == _("Y scale: number of pixels for 1 meter")) {
scaleY = value.To<float>();
}
return true;
}
void ScenePhysicsDatas::SerializeTo(gd::SerializerElement & element) const
{
element.SetAttribute("gravityX", gravityX);

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() {};
@@ -34,6 +34,8 @@ public:
}
#if defined(GD_IDE_ONLY)
virtual std::map<gd::String, gd::PropertyDescriptor> GetProperties(gd::Project & project) const;
virtual bool UpdateProperty(const gd::String & name, const gd::String & value, gd::Project & project);
virtual void SerializeTo(gd::SerializerElement & element) const;
#endif

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

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

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;

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

@@ -450,7 +450,7 @@ bool RuntimeScene::LoadFromSceneAndCustomInstances( const gd::Layout & scene, co
//Behaviors shared data
std::cout << ".";
behaviorsSharedDatas.LoadFrom(scene.behaviorsInitialSharedDatas);
behaviorsSharedDatas.LoadFrom(scene.GetAllBehaviorSharedData());
std::cout << ".";
//Extensions specific initialization

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

@@ -138,6 +138,7 @@ gd::PlatformExtension * CreateGDJSLinkedObjectsExtension();
gd::PlatformExtension * CreateGDJSSystemInfoExtension();
gd::PlatformExtension * CreateGDJSShopifyExtension();
gd::PlatformExtension * CreateGDJSPathfindingBehaviorExtension();
gd::PlatformExtension * CreateGDJSPhysicsBehaviorExtension();
}
#endif
@@ -185,6 +186,7 @@ JsPlatform::JsPlatform() :
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSSystemInfoExtension())); std::cout.flush();
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSShopifyExtension())); std::cout.flush();
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSPathfindingBehaviorExtension())); std::cout.flush();
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSPhysicsBehaviorExtension())); std::cout.flush();
#endif
std::cout << "done." << std::endl;
};

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

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

@@ -1,4 +1,4 @@
# Rename this file as .env.local and complete the following values.
# Copy this file as ".env.local" and complete the following values.
# If values are not completed, some features will be unavailable.
REACT_APP_PREVIEW_S3_ACCESS_KEY_ID=

View File

@@ -13,6 +13,12 @@ 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 gdInstruction = EmscriptenObject;
declare type gdInstructionMetadata = EmscriptenObject;
declare type gdInstructionsList = 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

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

@@ -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 {
@@ -503,6 +508,78 @@ Object {
},
},
},
"Physics behavior": Object {
"Collision": Object {
"displayedName": "Collision",
"fullGroupName": "Physics behavior/",
"type": "PhysicsBehavior::CollisionWith",
},
"Collision polygon": Object {
"Collision polygon X scale": Object {
"displayedName": "Collision polygon X scale",
"fullGroupName": "Physics behavior/Collision polygon",
"type": "PhysicsBehavior::GetPolygonScaleX",
},
"Collision polygon Y scale": Object {
"displayedName": "Collision polygon Y scale",
"fullGroupName": "Physics behavior/Collision polygon",
"type": "PhysicsBehavior::GetPolygonScaleY",
},
},
"Displacement": Object {
"Angular damping": Object {
"displayedName": "Angular damping",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::AngularDamping",
},
"Linear damping": Object {
"displayedName": "Linear damping",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::LinearDamping",
},
"Linear speed": Object {
"displayedName": "Linear speed",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::LinearVelocity",
},
"X component": Object {
"displayedName": "X component",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::LinearVelocityX",
},
"Y component": Object {
"displayedName": "Y component",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::LinearVelocityY",
},
},
"Movement": Object {
"The object is dynamic": Object {
"displayedName": "The object is dynamic",
"fullGroupName": "Physics behavior/Movement",
"type": "PhysicsBehavior::IsDynamic",
},
},
"Other": Object {
"Object is treated like a bullet": Object {
"displayedName": "Object is treated like a bullet",
"fullGroupName": "Physics behavior/Other",
"type": "PhysicsBehavior::IsBullet",
},
},
"Rotation": Object {
"Angular speed": Object {
"displayedName": "Angular speed",
"fullGroupName": "Physics behavior/Rotation",
"type": "PhysicsBehavior::AngularVelocity",
},
"Fixed rotation": Object {
"displayedName": "Fixed rotation",
"fullGroupName": "Physics behavior/Rotation",
"type": "PhysicsBehavior::IsFixedRotation",
},
},
},
"Platform Behavior": Object {
"Is falling": Object {
"displayedName": "Is falling",
@@ -1846,6 +1923,121 @@ Array [
"fullGroupName": "Pathfinding behavior/Obstacles",
"type": "PathfindingBehavior::SetImpassable",
},
Object {
"displayedName": "Add a gear between two objects",
"fullGroupName": "Physics behavior/Joints",
"type": "PhysicsBehavior::ActAddGearJointBetweenObjects",
},
Object {
"displayedName": "Add a hinge",
"fullGroupName": "Physics behavior/Joints",
"type": "PhysicsBehavior::AddRevoluteJoint",
},
Object {
"displayedName": "Add a hinge between two objects",
"fullGroupName": "Physics behavior/Joints",
"type": "PhysicsBehavior::AddRevoluteJointBetweenObjects",
},
Object {
"displayedName": "Add a force",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::ApplyForce",
},
Object {
"displayedName": "Apply a force toward a position",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::ApplyForceTowardPosition",
},
Object {
"displayedName": "Apply a force ( angle )",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::ApplyForceUsingPolarCoordinates",
},
Object {
"displayedName": "Apply an impulse",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::ApplyImpulse",
},
Object {
"displayedName": "Apply an impulse toward a position",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::ApplyImpulseTowardPosition",
},
Object {
"displayedName": "Apply an impulse (angle)",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::ApplyImpulseUsingPolarCoordinates",
},
Object {
"displayedName": "Add a torque (a rotation)",
"fullGroupName": "Physics behavior/Rotation",
"type": "PhysicsBehavior::ApplyTorque",
},
Object {
"displayedName": "Do not treat object like a bullet",
"fullGroupName": "Physics behavior/Other",
"type": "PhysicsBehavior::DontSetAsBullet",
},
Object {
"displayedName": "Angular damping",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::SetAngularDamping",
},
Object {
"displayedName": "Angular speed",
"fullGroupName": "Physics behavior/Rotation",
"type": "PhysicsBehavior::SetAngularVelocity",
},
Object {
"displayedName": "Treat object like a bullet.",
"fullGroupName": "Physics behavior/Other",
"type": "PhysicsBehavior::SetAsBullet",
},
Object {
"displayedName": "Make the object dynamic",
"fullGroupName": "Physics behavior/Movement",
"type": "PhysicsBehavior::SetDynamic",
},
Object {
"displayedName": "Fix rotation",
"fullGroupName": "Physics behavior/Rotation",
"type": "PhysicsBehavior::SetFixedRotation",
},
Object {
"displayedName": "Make object's rotation free",
"fullGroupName": "Physics behavior/Rotation",
"type": "PhysicsBehavior::SetFreeRotation",
},
Object {
"displayedName": "Gravity",
"fullGroupName": "Physics behavior/Global options",
"type": "PhysicsBehavior::SetGravity",
},
Object {
"displayedName": "Linear damping",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::SetLinearDamping",
},
Object {
"displayedName": "Linear velocity",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::SetLinearVelocity",
},
Object {
"displayedName": "Change the X scale of a collision polygon",
"fullGroupName": "Physics behavior/Collision polygon",
"type": "PhysicsBehavior::SetPolygonScaleX",
},
Object {
"displayedName": "Change the Y scale of a collision polygon",
"fullGroupName": "Physics behavior/Collision polygon",
"type": "PhysicsBehavior::SetPolygonScaleY",
},
Object {
"displayedName": "Make the object static",
"fullGroupName": "Physics behavior/Movement",
"type": "PhysicsBehavior::SetStatic",
},
]
`;
@@ -1886,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",
@@ -2591,5 +2788,65 @@ Array [
"fullGroupName": "Pathfinding behavior/Obstacles",
"type": "PathfindingBehavior::IsImpassable",
},
Object {
"displayedName": "Angular damping",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::AngularDamping",
},
Object {
"displayedName": "Angular speed",
"fullGroupName": "Physics behavior/Rotation",
"type": "PhysicsBehavior::AngularVelocity",
},
Object {
"displayedName": "Collision",
"fullGroupName": "Physics behavior/",
"type": "PhysicsBehavior::CollisionWith",
},
Object {
"displayedName": "Collision polygon X scale",
"fullGroupName": "Physics behavior/Collision polygon",
"type": "PhysicsBehavior::GetPolygonScaleX",
},
Object {
"displayedName": "Collision polygon Y scale",
"fullGroupName": "Physics behavior/Collision polygon",
"type": "PhysicsBehavior::GetPolygonScaleY",
},
Object {
"displayedName": "Object is treated like a bullet",
"fullGroupName": "Physics behavior/Other",
"type": "PhysicsBehavior::IsBullet",
},
Object {
"displayedName": "The object is dynamic",
"fullGroupName": "Physics behavior/Movement",
"type": "PhysicsBehavior::IsDynamic",
},
Object {
"displayedName": "Fixed rotation",
"fullGroupName": "Physics behavior/Rotation",
"type": "PhysicsBehavior::IsFixedRotation",
},
Object {
"displayedName": "Linear damping",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::LinearDamping",
},
Object {
"displayedName": "Linear speed",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::LinearVelocity",
},
Object {
"displayedName": "X component",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::LinearVelocityX",
},
Object {
"displayedName": "Y component",
"fullGroupName": "Physics behavior/Displacement",
"type": "PhysicsBehavior::LinearVelocityY",
},
]
`;

View File

@@ -46,6 +46,13 @@ export class Toolbar extends PureComponent {
tooltip={t('Launch a preview of the scene')}
/>
)}
{this.props.showNetworkPreviewButton && (
<ToolbarIcon
onClick={this.props.onNetworkPreview}
src="res/ribbon_default/networkpreview32.png"
tooltip={t('Preview the scene on a mobile or tablet connected to your wifi')}
/>
)}
{this.props.showPreviewButton && <ToolbarSeparator />}
<ToolbarIcon
onClick={this.props.onAddStandardEvent}

View File

@@ -102,7 +102,9 @@ export default class EventsSheet extends Component {
canRemove={hasSomethingSelected(this.state.selection)}
onRemove={this.deleteSelection}
showPreviewButton={this.props.showPreviewButton}
onPreview={this.props.onPreview}
showNetworkPreviewButton={this.props.showNetworkPreviewButton}
onPreview={() => this.props.onPreview({})}
onNetworkPreview={() => this.props.onPreview({networkPreview: true})}
canUndo={canUndo(this.state.history)}
canRedo={canRedo(this.state.history)}
undo={this.undo}
@@ -296,6 +298,13 @@ export default class EventsSheet extends Component {
});
};
toggleDisabled = () => {
getSelectedEvents(this.state.selection).forEach(event =>
event.setDisabled(!event.isDisabled())
);
this._saveChangesToHistory(() => this._eventsTree.forceEventsUpdate());
}
deleteSelection = () => {
const { events } = this.props;
const eventsRemover = new gd.EventsRemover();
@@ -528,6 +537,10 @@ export default class EventsSheet extends Component {
accelerator: 'CmdOrCtrl+V',
},
{ type: 'separator' },
{
label: 'Toggle disabled',
click: () => this.toggleDisabled(),
},
{
label: 'Delete',
click: () => this.deleteSelection(),

View File

@@ -5,7 +5,7 @@ import Window from '../../Utils/Window';
export default class BrowserExport extends Component {
openWebsite = () => {
Window.openExternalURL('http://compilgames.net');
Window.openExternalURL('http://gdevelop-app.com');
};
render() {

View File

@@ -1,7 +1,7 @@
import indexHTML from './GDJSindex.html.js';
const gdjsRoot =
'https://s3-eu-west-1.amazonaws.com/gdevelop-resources/GDJS-4095';
'https://s3-eu-west-1.amazonaws.com/gdevelop-resources/GDJS-5.0.0-beta26';
export const findGDJS = cb => {
return cb({

View File

@@ -1,10 +1,12 @@
// @flow
import React from 'react';
import * as React from 'react';
import BrowserS3FileSystem from './BrowserS3FileSystem';
import BrowserPreviewLinkDialog from './BrowserPreviewLinkDialog';
import { findGDJS } from './BrowserS3GDJSFinder';
import assignIn from 'lodash/assignIn';
import { type PreviewOptions } from '../PreviewLauncher.flow';
import { GDevelopGamesPreview } from '../../Utils/GDevelopServices/ApiConfigs';
import { makeTimestampedId } from '../../Utils/TimestampedId';
const awsS3 = require('aws-sdk/clients/s3');
const gd = global.gd;
@@ -23,8 +25,25 @@ const awsS3Client = new awsS3({
correctClockSkew: true,
});
export default class BrowserS3PreviewLauncher {
static _openPreviewWindow = (project: gdProject, url: string): any => {
type State = {|
showPreviewLinkDialog: boolean,
url: ?string,
|};
type Props = {};
export default class BrowserS3PreviewLauncher extends React.Component<
Props,
State
> {
canDoNetworkPreview = () => false;
state = {
showPreviewLinkDialog: false,
url: null,
};
_openPreviewWindow = (project: gdProject, url: string): any => {
const windowObjectReference = window.open(url, `_blank`);
return {
url,
@@ -32,7 +51,7 @@ export default class BrowserS3PreviewLauncher {
};
};
static _prepareExporter = (): Promise<any> => {
_prepareExporter = (): Promise<any> => {
return new Promise((resolve, reject) => {
findGDJS(({ gdjsRoot, filesContent }) => {
if (!gdjsRoot) {
@@ -41,8 +60,7 @@ export default class BrowserS3PreviewLauncher {
}
console.info('GDJS found in ', gdjsRoot);
const prefix =
'' + Date.now() + '-' + Math.floor(Math.random() * 1000000);
const prefix = makeTimestampedId();
const outputDir = destinationBucketBaseUrl + prefix;
const browserS3FileSystem = new BrowserS3FileSystem({
@@ -68,13 +86,14 @@ export default class BrowserS3PreviewLauncher {
});
};
static launchLayoutPreview = (
launchLayoutPreview = (
project: gdProject,
layout: gdLayout
layout: gdLayout,
options: PreviewOptions
): Promise<any> => {
if (!project || !layout) return Promise.reject();
return BrowserS3PreviewLauncher._prepareExporter().then(
return this._prepareExporter().then(
({ exporter, outputDir, browserS3FileSystem }) => {
exporter.exportLayoutForPixiPreview(project, layout, outputDir);
exporter.delete();
@@ -82,25 +101,59 @@ export default class BrowserS3PreviewLauncher {
.uploadPendingObjects()
.then(() => {
const finalUrl = outputDir + '/index.html';
return BrowserS3PreviewLauncher._openPreviewWindow(
project,
finalUrl
);
return this._openPreviewWindow(project, finalUrl);
})
.then(({ url, windowObjectReference }) => {
if (!windowObjectReference) {
return { dialog: <BrowserPreviewLinkDialog url={url} /> };
this.setState({
showPreviewLinkDialog: true,
url,
});
}
});
}
);
};
static launchExternalLayoutPreview = (
launchExternalLayoutPreview = (
project: gdProject,
layout: gdLayout,
externalLayout: gdExternalLayout
externalLayout: gdExternalLayout,
options: PreviewOptions
): Promise<any> => {
return Promise.reject('Not implemented');
if (!project || !layout || !externalLayout) return Promise.reject();
return this._prepareExporter().then(
({ exporter, outputDir, browserS3FileSystem }) => {
exporter.exportExternalLayoutForPixiPreview(
project,
layout,
externalLayout,
outputDir
);
exporter.delete();
return browserS3FileSystem
.uploadPendingObjects()
.then(() => {
const finalUrl = outputDir + '/index.html';
return this._openPreviewWindow(project, finalUrl);
})
.then(({ url, windowObjectReference }) => {
if (!windowObjectReference) {
this.setState({
showPreviewLinkDialog: true,
url,
});
}
});
}
);
};
render() {
const { showPreviewLinkDialog, url } = this.state;
if (!showPreviewLinkDialog) return null;
return <BrowserPreviewLinkDialog url={url} />;
}
}

View File

@@ -1,6 +1,13 @@
//TODO: Download the file then read it instead of hardcoding it.
export default `<html><head><meta http-equiv="Content-Type" content="text/html; 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;

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