Merge branch 'feature-multitouch'

This commit is contained in:
Florian Rival
2015-03-15 19:12:41 +13:00
165 changed files with 6152 additions and 3783 deletions

6
.gitignore vendored
View File

@@ -1,4 +1,3 @@
/GDSDK
/docs/GDJS Runtime Documentation
/docs/GDJS Documentation
/docs/GDCpp Documentation
@@ -48,6 +47,8 @@ Binaries/Packaging/opensuse-build-service/final/
*.debhelper.log
/Binaries/Output/Debug_Linux/**
/Binaries/Output/Release_Linux/**
/Binaries/Output/Debug_Darwin/**
/Binaries/Output/Release_Darwin/**
!/Binaries/Output/Release_Linux/StartGDevelop.sh
!/Binaries/Output/Release_Linux/CppPlatform/
/Binaries/**/MinGW32
@@ -63,7 +64,6 @@ Binaries/Packaging/opensuse-build-service/final/
/Binaries/Output/WebIDE/libGD.raw.js
/WebIDE
!/GDCpp/scripts/bcp.exe
/GDJS/tests/node_modules
!/scripts/libgettextlib-0-17.dll
!/scripts/libgettextsrc-0-17.dll
!/xgettext.exe
@@ -73,3 +73,5 @@ Binaries/Packaging/opensuse-build-service/final/
!/Binaries/Output/Release_Windows/locale/msgfmt.exe
!/ExtLibs/curl.exe
!/ExtLibs/7za.exe
**/.DS_Store
**/node_modules/

View File

@@ -6,20 +6,27 @@ compiler:
install:
- sudo apt-get update
#Download and compile dependencies
- cd ExtLibs
- sudo apt-get install p7zip-full
#SFML dependencies:
- sudo apt-get install libopenal-dev libjpeg-dev libglew-dev libudev-dev libxrandr-dev libsndfile1-dev libglu1-mesa-dev libfreetype6-dev
- cd ..
#Compile the tests only
- mkdir .build-tests
- cd .build-tests
- cmake -DBUILD_GDJS=FALSE -DBUILD_IDE=FALSE -DBUILD_EXTENSIONS=FALSE -DBUILD_TESTS=TRUE -DNO_GUI=TRUE ..
- make -j 4
- cd ..
#Install GDJS tests dependencies
- cd GDJS/tests
- npm install
- cd ../..
script:
# - export LD_LIBRARY_PATH=$PWD/Binaries/Output/Release_Linux:$PWD/.build-tests/ExtLibs/SFML/lib:$LD_LIBRARY_PATH
#GDJS game engine tests:
- cd GDJS/tests
- npm test
- cd ../..
#GDCore and GDCpp game engine tests:
- cd .build-tests
# - export LD_LIBRARY_PATH=$PWD/Binaries/Output/Release_Linux:$PWD/.build-tests/ExtLibs/SFML/lib:$LD_LIBRARY_PATH
- Core/GDCore_tests
- GDCpp/GDCpp_tests
- GDCpp/GDCpp_tests

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

After

Width:  |  Height:  |  Size: 943 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

View File

@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<project firstLayout="">
<gdVersion build="78" major="3" minor="6" revision="0" />
<properties linuxExecutableFilename="" macExecutableFilename="" useExternalSourceFiles="false" winExecutableFilename="" winExecutableIconFile="">
<name>Projet</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="TextObject" />
</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="Block-Place-Normal.png" kind="image" name="Block-Place-Normal.png" smoothed="true" userAdded="true" />
<resource alwaysLoaded="false" file="Block-Gel.png" kind="image" name="Block-Gel.png" smoothed="true" userAdded="false" />
<resource alwaysLoaded="false" file="Pointer-Standard.png" kind="image" name="Pointer-Standard.png" smoothed="true" userAdded="false" />
</resources>
<resourceFolders />
</resources>
<objects />
<objectsGroups />
<variables />
<layouts>
<layout b="209" disableInputWhenNotFocused="true" mangledName="New_32scene" name="New scene" oglFOV="90.000000" oglZFar="500.000000" oglZNear="1.000000" r="209" standardSortMethod="true" stopSoundsOnStartup="true" title="" v="209">
<uiSettings associatedLayout="" grid="false" gridB="255" gridG="180" gridHeight="32" gridOffsetX="0" gridOffsetY="0" gridR="158" gridWidth="32" snap="true" windowMask="false" zoomFactor="1.000000" />
<objectsGroups />
<variables />
<instances>
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Explanation" width="0.000000" x="63.000031" y="27.999985" zOrder="1">
<numberProperties />
<stringProperties />
<initialVariables />
</instance>
</instances>
<objects>
<object name="Marker" type="Sprite">
<variables>
<variable name="TouchId" value="0" />
</variables>
<automatisms />
<animations>
<animation useMultipleDirections="false">
<directions>
<direction looping="false" timeBetweenFrames="1.000000">
<sprites>
<sprite hasCustomCollisionMask="false" image="Pointer-Standard.png">
<points />
<originPoint name="origine" x="0.000000" y="0.000000" />
<centerPoint automatic="true" name="centre" x="22.000000" y="22.000000" />
<customCollisionMask>
<polygon>
<vertice x="0.000000" y="0.000000" />
<vertice x="44.000000" y="0.000000" />
<vertice x="44.000000" y="44.000000" />
<vertice x="0.000000" y="44.000000" />
</polygon>
</customCollisionMask>
</sprite>
</sprites>
</direction>
</directions>
</animation>
</animations>
</object>
<object bold="false" italic="false" name="Explanation" smoothed="true" type="TextObject::Text" underlined="false">
<variables />
<automatisms />
<string>Launch this example from a device with a touch screen.&#x0A;For example, you can export it to a website and use&#x0A;a device with Android or iOS.&#x0A;&#x0A;A marker will follow each touch that is made on the screen: &#x0A;this support an unlimited number of touches on the screen!</string>
<font></font>
<characterSize>25</characterSize>
<color b="0" g="0" r="0" />
</object>
</objects>
<events>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::Standard</type>
<conditions>
<condition>
<type inverted="false" value="PopStartedTouch" />
<parameters>
<parameter></parameter>
</parameters>
<subConditions />
</condition>
</conditions>
<actions>
<action>
<type inverted="false" value="Create" />
<parameters>
<parameter></parameter>
<parameter>Marker</parameter>
<parameter>0</parameter>
<parameter>0</parameter>
<parameter></parameter>
</parameters>
<subActions />
</action>
<action>
<type inverted="false" value="ModVarObjet" />
<parameters>
<parameter>Marker</parameter>
<parameter>TouchId</parameter>
<parameter>=</parameter>
<parameter>LastTouchId()</parameter>
</parameters>
<subActions />
</action>
</actions>
<events />
</event>
<event disabled="false" folded="false" infiniteLoopWarning="true">
<type>BuiltinCommonInstructions::While</type>
<whileConditions>
<condition>
<type inverted="false" value="PopEndedTouch" />
<parameters>
<parameter></parameter>
</parameters>
<subConditions />
</condition>
</whileConditions>
<conditions>
<condition>
<type inverted="false" value="VarObjet" />
<parameters>
<parameter>Marker</parameter>
<parameter>TouchId</parameter>
<parameter>=</parameter>
<parameter>LastEndedTouchId()</parameter>
</parameters>
<subConditions />
</condition>
</conditions>
<actions>
<action>
<type inverted="false" value="Delete" />
<parameters>
<parameter>Marker</parameter>
<parameter></parameter>
</parameters>
<subActions />
</action>
</actions>
<events />
</event>
<event disabled="false" folded="false">
<type>BuiltinCommonInstructions::ForEach</type>
<object>Marker</object>
<conditions />
<actions>
<action>
<type inverted="false" value="MettreXY" />
<parameters>
<parameter>Marker</parameter>
<parameter>=</parameter>
<parameter>TouchX(Marker.Variable(TouchId),&quot;&quot;,0)</parameter>
<parameter>=</parameter>
<parameter>TouchY(Marker.Variable(TouchId),&quot;&quot;,0)</parameter>
</parameters>
<subActions />
</action>
</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>
</layer>
</layers>
<automatismsSharedData />
</layout>
</layouts>
<externalEvents />
<externalLayouts />
<externalSourceFiles />
</project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

View File

@@ -1,6 +1,4 @@
This is the directory where binaries are produced.
In particular, the extensions and/or the JS platform files will be
created into Output/Release. Copy all files generated into Output/Release
into the folder of GDevelop to test them. Be sure to use the same
version of GDevelop for the build.
created into Output/Release_OSNAME with OSNAME being Windows, Linux or Darwin.

View File

@@ -29,15 +29,19 @@ ENDIF()
project(GDevelop)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
IF(NOT WIN32 AND NOT BUILD_TESTS)
IF(NOT WIN32 AND NOT APPLE AND NOT BUILD_TESTS)
SET(CMAKE_SKIP_BUILD_RPATH TRUE) #Avoid errors when packaging for linux.
ENDIF()
IF(APPLE)
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_")
ENDIF()
#Sanity checks
IF ("${CMAKE_BUILD_TYPE}" STREQUAL "")
message( "CMAKE_BUILD_TYPE is empty, assuming build type is Release" )
set(CMAKE_BUILD_TYPE Release)
IF(NOT WIN32)
IF(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_SHARED_LINKER_FLAGS "-s") #Force stripping to avoid errors when packaging for linux.
ENDIF()
ENDIF()
@@ -47,6 +51,7 @@ IF (EMSCRIPTEN)
set(BUILD_IDE FALSE CACHE BOOL "" FORCE) #Force disable IDE when compiling with emscripten.
ENDIF()
#Activate C++11
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_CXX11)

View File

@@ -76,8 +76,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
add_definitions( -Dlinux )
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
IF (NOT NO_GUI)
@@ -121,7 +124,7 @@ ELSE()
ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
target_link_libraries(GDCore ws2_32 user32 opengl32 glu32 psapi)
ELSEIF ()
ELSE ()
target_link_libraries(GDCore ${wxWidgets_LIBRARIES})
target_link_libraries(GDCore ${GTK_LIBRARIES})
ENDIF()
@@ -138,7 +141,9 @@ if(BUILD_TESTS)
add_executable(GDCore_tests ${test_source_files})
target_link_libraries(GDCore_tests GDCore)
target_link_libraries(GDCore_tests sfml-audio sfml-graphics sfml-window sfml-network sfml-system)
target_link_libraries(GDCore_tests GLU GL)
IF (NOT APPLE)
target_link_libraries(GDCore_tests GLU GL)
ENDIF()
target_link_libraries(GDCore_tests ${wxWidgets_LIBRARIES})
target_link_libraries(GDCore_tests ${GTK_LIBRARIES})
endif()

View File

@@ -19,6 +19,32 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(gd::Plat
"Open source (MIT License)");
#if defined(GD_IDE_ONLY)
extension.AddCondition("SourisSurObjet",
_("The cursor/touch is on an object"),
_("Test if the cursor is over an object, or if the object is being touched."),
_("The cursor/touch is on _PARAM0_"),
_("Mouse and touch"),
"res/conditions/surObjet24.png",
"res/conditions/surObjet.png")
.AddParameter("objectList", _("Object"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Accurate test (yes by default)"), "", true).SetDefaultValue("yes")
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsSimple();
extension.AddAction("TouchSimulateMouse",
_("De/activate moving mouse cursor with touches"),
_("When activated, any touch made on a touchscreen will also move the mouse cursor. When deactivated, mouse and touch positions will be completely independant.\nBy default, this is activated so that you can simply use the mouse conditions to also support touchscreens. If you want to have multitouch and differentiate mouse and touches, just deactivate it with this action."),
_("Move mouse cursor when touching screen: _PARAM1_"),
_("Mouse and touch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Activate (yes by default when game is launched)")).SetDefaultValue("yes")
.MarkAsAdvanced();
extension.AddAction("CentreSourisX",
_("Center cursor horizontally"),
_("Put the cursor in the middle of the screen horizontally."),
@@ -87,9 +113,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(gd::Plat
.MarkAsAdvanced();
extension.AddCondition("SourisX",
_("Cursor/touch X position"),
_("Cursor X position"),
_("Compare the X position of the cursor or of a touch."),
_("Cursor/touch X position is _PARAM1__PARAM2_"),
_("Cursor X position is _PARAM1__PARAM2_"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
@@ -101,9 +127,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(gd::Plat
.SetManipulatedType("number");
extension.AddCondition("SourisY",
_("Cursor/touch Y position"),
_("Cursor Y position"),
_("Compare the Y position of the cursor or of a touch."),
_("Cursor/touch Y position is _PARAM1__PARAM2_"),
_("Cursor Y position is _PARAM1__PARAM2_"),
_("Mouse and touch"),
"res/conditions/mouse24.png",
"res/conditions/mouse.png")
@@ -125,34 +151,96 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsMouseExtension(gd::Plat
.AddParameter("mouse", _("Button to test"))
.MarkAsSimple();
extension.AddExpression("MouseX", _("Cursor/touch X position"), _("Cursor/touch X position"), _("Mouse and touch"), "res/actions/mouse.png")
extension.AddCondition("TouchX",
_("Touch X position"),
_("Compare the X position of a specific touch."),
_("Touch #_PARAM1_ X position is _PARAM2__PARAM3_"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("X position"))
.AddParameter("layer", _("Layer ( Base layer if empty )"), "", true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number ( default : 0 )"), "", true).SetDefaultValue("0")
.SetManipulatedType("number");
extension.AddCondition("TouchY",
_("Touch Y position"),
_("Compare the Y position of a specific touch."),
_("Touch #_PARAM1_ Y position is _PARAM2__PARAM3_"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"))
.AddParameter("relationalOperator", _("Sign of the test"))
.AddParameter("expression", _("X position"))
.AddParameter("layer", _("Layer ( Base layer if empty )"), "", true).SetDefaultValue("\"\"")
.AddParameter("expression", _("Camera number ( default : 0 )"), "", true).SetDefaultValue("0")
.SetManipulatedType("number");
extension.AddCondition("PopStartedTouch",
_("A new touch has started"),
_("Return true if a touch has started. The touch identifier can be accessed using LastTouchId().\nAs more than one touch can have started, this condition is only true once for each touch: the next time you use it, it will be for a new touch or it will return false if there is no more touch that just started."),
_("A new touch has started"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddCondition("PopEndedTouch",
_("A touch has ended"),
_("Return true if a touch has ended. The touch identifier can be accessed using LastEndedTouchId().\nAs more than one touch can have ended, this condition is only true once for each touch: the next time you use it, it will be for a new touch or it will return false if there is no more touch that just ended."),
_("A touch has ended"),
_("Mouse and touch/Multitouch"),
"res/conditions/touch24.png",
"res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddExpression("MouseX", _("Cursor X position"), _("Cursor X position"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0");
extension.AddExpression("SourisX", _("Cursor/touch X position"), _("Cursor/touch X position"), _("Mouse and touch"), "res/actions/mouse.png")
extension.AddExpression("SourisX", _("Cursor X position"), _("Cursor X position"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0")
.SetHidden();
extension.AddExpression("MouseY", _("Cursor/touch Y position"), _("Cursor/touch Y position"), _("Mouse and touch"), "res/actions/mouse.png")
extension.AddExpression("MouseY", _("Cursor Y position"), _("Cursor Y position"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0");
extension.AddExpression("SourisY", _("Cursor/touch Y position"), _("Cursor/touch Y position"), _("Mouse and touch"), "res/actions/mouse.png")
extension.AddExpression("SourisY", _("Cursor Y position"), _("Cursor Y position"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0")
.SetHidden();
extension.AddExpression("MouseWheelDelta", _("Mouse wheel: Displacement"), _("Mouse wheel displacement"), _("Mouse cursor"), "res/actions/mouse.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddExpression("MouseWheelDelta", _("Mouse wheel: Displacement"), _("Mouse wheel displacement"), _("Mouse and touch"), "res/actions/mouse.png")
extension.AddExpression("TouchX", _("Touch X position"), _("Touch X position"), _("Multitouch"), "res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"), "", false)
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0");
extension.AddExpression("TouchY", _("Touch Y position"), _("Touch Y position"), _("Multitouch"), "res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("expression", _("Touch identifier"), "", false)
.AddParameter("layer", _("Layer"), "", true).SetDefaultValue("\"\"")
.AddParameter("camera", _("Camera"), "", true).SetDefaultValue("0");
extension.AddExpression("LastTouchId", _("Identifier of the last touch"), _("Identifier of the last touch"), _("Multitouch"), "res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
extension.AddExpression("LastEndedTouchId", _("Identifier of the last ended touch"), _("Identifier of the last ended touch"), _("Multitouch"), "res/conditions/touch.png")
.AddCodeOnlyParameter("currentScene", "");
#endif

View File

@@ -396,20 +396,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(gd::Pla
.AddCodeOnlyParameter("currentScene", "")
.SetHidden(); //Deprecated
obj.AddCondition("SourisSurObjet",
_("The cursor is on an object"),
_("Test if the cursor is over a Sprite object. The test is accurate by default (check that the cursor is not on a transparent pixel)."),
_("The cursor is on _PARAM0_"),
_("Mouse"),
"res/conditions/surObjet24.png",
"res/conditions/surObjet.png")
.AddParameter("object", _("Object"), "Sprite", false)
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Precise test ( yes by default )"), "", true).SetDefaultValue("yes")
.MarkAsSimple();
obj.AddExpression("X", _("X position of a point"), _("X position of a point"), _("Position"), "res/actions/position.png")
.SetHidden()
.AddParameter("object", _("Object"), "Sprite", false)

View File

@@ -68,7 +68,7 @@ void CommentEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::Event
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
renderingHelper->GetHTMLRenderer().SetDC(&dc);
renderingHelper->GetHTMLRenderer().SetStandardFonts( 8 );
renderingHelper->GetHTMLRenderer().SetStandardFonts(renderingHelper->GetNiceFont().GetPointSize());
//Prepare HTML texts
std::string str1 = "<FONT color="+ToString(wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX).mb_str())+">"+renderingHelper->GetHTMLText(com1)+"</FONT>";
@@ -122,7 +122,7 @@ unsigned int CommentEvent::GetRenderedHeight(unsigned int width, const gd::Platf
dc.SelectObject(fakeBmp);
renderingHelper->GetHTMLRenderer().SetDC(&dc);
renderingHelper->GetHTMLRenderer().SetStandardFonts( 8 );
renderingHelper->GetHTMLRenderer().SetStandardFonts(renderingHelper->GetNiceFont().GetPointSize());
std::string str1 = "<FONT color="+ToString(wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX).mb_str())+">"+renderingHelper->GetHTMLText(com1)+"</FONT>";
std::string str2 = "<FONT color="+ToString(wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX).mb_str())+">"+renderingHelper->GetHTMLText(com2)+"</FONT>";

View File

@@ -134,6 +134,8 @@ gd::BaseEvent::EditEventReturnType LinkEvent::EditEvent(wxWindow* parent_, gd::P
void LinkEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
#if !defined(GD_NO_WX_GUI)
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
dc.SetBrush( wxBrush( wxColour( 255, 255, 255 ) ) );
dc.SetPen( wxPen( wxColour( 0, 0, 0 ), 1) );
wxRect rect(x+1, y, width-2, GetRenderedHeight(width, platform)-2);
@@ -146,15 +148,14 @@ void LinkEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEd
dc.SetTextForeground( wxColour( 0, 0, 0 ) );
else
dc.SetTextForeground( wxColour( 160, 160, 160 ) );
dc.SetFont( wxFont( 12, wxDEFAULT, wxNORMAL, wxNORMAL ) );
dc.SetFont(renderingHelper->GetNiceFont());
dc.DrawText( _("Link to ")+GetTarget(), x+32, y + 3 );
wxRect lien = dc.GetTextExtent(_("Link to ")+GetTarget());
dc.SetFont( wxFont( 10, wxDEFAULT, wxNORMAL, wxNORMAL ) );
if ( IncludeAllEvents() )
dc.DrawText( _("Include all events"), x+lien.GetWidth()+32+10, y + 5 );
else
dc.DrawText( _("Include events ")+ToString(GetIncludeStart()+1)+_(" to ")+ToString(GetIncludeEnd()+1), x+lien.GetWidth()+32+10, y + 5 );
if ( !IncludeAllEvents() )
{
wxRect textRect = dc.GetTextExtent(_("Link to ")+GetTarget());
dc.DrawText( _("Include only events ")+ToString(GetIncludeStart()+1)+_(" to ")+ToString(GetIncludeEnd()+1), x+textRect.GetWidth()+32+10, y + 5 );
}
#endif
}
@@ -166,11 +167,13 @@ unsigned int LinkEvent::GetRenderedHeight(unsigned int width, const gd::Platform
#if !defined(GD_NO_WX_GUI)
if ( eventHeightNeedUpdate )
{
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
wxMemoryDC dc;
wxBitmap fakeBmp(1,1);
dc.SelectObject(fakeBmp);
dc.SetFont( wxFont( 12, wxDEFAULT, wxNORMAL, wxNORMAL ) );
dc.SetFont(renderingHelper->GetNiceFont());
wxRect lien = dc.GetTextExtent(_("Link to "));
renderedHeight = lien.GetHeight()+10;

View File

@@ -5,6 +5,7 @@
*/
#include "GDCore/CommonTools.h"
#include "GDCore/Tools/VersionWrapper.h"
#include "GDCore/Tools/Locale/LocaleManager.h"
#include "AnalyticsSender.h"
#include "GDCore/Serialization/Serializer.h"
#include "GDCore/Serialization/SerializerElement.h"
@@ -53,6 +54,8 @@ void AnalyticsSender::SendData(std::string collection, SerializerElement & data)
data.SetAttribute("gdVersion", VersionWrapper::FullString());
data.SetAttribute("os", gd::ToString(wxGetOsDescription()));
data.SetAttribute("lang",
gd::ToString(wxLocale::GetLanguageCanonicalName(LocaleManager::Get()->GetLanguage())));
// Create request
std::cout << "Sending analytics data..."; std::cout.flush();

View File

@@ -28,6 +28,7 @@
#include "GDCore/PlatformDefinition/Project.h"
#include "GDCore/PlatformDefinition/Layout.h"
#include "GDCore/PlatformDefinition/Object.h"
#include "GDCore/IDE/EventsRenderingHelper.h"
#include "GDCore/IDE/ExpressionsCorrectnessTesting.h"
#include "GDCore/IDE/Dialogs/ChooseObjectDialog.h"
#include "GDCore/IDE/Dialogs/ChooseLayerDialog.h"
@@ -360,12 +361,7 @@ lastErrorPos(std::string::npos)
ExpressionEdit->SetText(expression);
ExpressionEdit->SetLexer(wxSTC_LEX_CPP);
#if defined(WINDOWS)
wxFont font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Consolas");
#else
wxFont font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
#endif
ExpressionEdit->StyleSetFont(wxSTC_STYLE_DEFAULT, font);
ExpressionEdit->StyleSetFont(wxSTC_STYLE_DEFAULT, gd::EventsRenderingHelper::Get()->GetFont());
ExpressionEdit->StyleClearAll();
ExpressionEdit->StyleSetForeground(4, *wxBLACK); //Numbers

View File

@@ -25,6 +25,7 @@
#include "GDCore/IDE/Dialogs/ChooseVariableDialog.h"
#include "GDCore/IDE/Dialogs/ChooseAutomatismDialog.h"
#include "GDCore/IDE/ExpressionsCorrectnessTesting.h"
#include "GDCore/IDE/EventsRenderingHelper.h"
#include "GDCore/IDE/Dialogs/AdvancedEntryDialog.h"
#include "GDCore/IDE/wxTools/TreeItemExpressionMetadata.h"
#include "GDCore/PlatformDefinition/Object.h"
@@ -285,12 +286,7 @@ EditStrExpressionDialog::EditStrExpressionDialog(wxWindow* parent, std::string e
ValList->Expand(ValList->GetRootItem());
TexteEdit->SetLexer(wxSTC_LEX_CPP);
#if defined(WINDOWS)
wxFont font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Consolas");
#else
wxFont font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
#endif
TexteEdit->StyleSetFont(wxSTC_STYLE_DEFAULT, font);
TexteEdit->StyleSetFont(wxSTC_STYLE_DEFAULT, gd::EventsRenderingHelper::Get()->GetFont());
TexteEdit->StyleClearAll();
TexteEdit->StyleSetForeground(4, *wxBLACK); //Numbers

View File

@@ -10,6 +10,7 @@
#include "GDCore/Serialization/Serializer.h"
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/IDE/EventsRefactorer.h"
#include "GDCore/IDE/wxTools/SafeYield.h"
#include "GDCore/CommonTools.h"
#include "SFML/Network.hpp"
@@ -78,7 +79,7 @@ sf::Http::Response::Status EventStoreDialog::FetchTemplate(std::string id)
nameTxt->SetLabel("Loading the template...");
descriptionEdit->SetValue("");
wxSafeYield();
gd::SafeYield::Do();
// Create request
sf::Http Http(host, port);

View File

@@ -27,6 +27,7 @@
#include "GDCore/IDE/Dialogs/LayoutEditorCanvas/LayoutEditorCanvasOptions.h"
#include "GDCore/IDE/Dialogs/MainFrameWrapper.h"
#include "GDCore/IDE/Dialogs/GridSetupDialog.h"
#include "GDCore/IDE/wxTools/GUIContentScaleFactor.h"
#include "GDCore/IDE/CommonBitmapManager.h"
#include "GDCore/IDE/SkinHelper.h"
#include "GDCore/Tools/Log.h"
@@ -113,6 +114,8 @@ LayoutEditorCanvas::LayoutEditorCanvas(wxWindow* parent, gd::Project & project_,
altPressed(false),
shiftPressed(false),
isMovingInstance(false),
gapBetweenButtonsAndRectangle(gd::GUIContentScaleFactor::Get() > 1 ? 12 : 5),
smallButtonSize(gd::GUIContentScaleFactor::Get() > 1 ? 12 : 5),
firstRefresh(true),
isSelecting(false),
editing(true)
@@ -312,8 +315,8 @@ void LayoutEditorCanvas::OnIdle(wxIdleEvent & event)
{
// Send a paint message when the control is idle, to ensure maximum framerate
Refresh();
#if !defined(WINDOWS)
event.RequestMore(); //On linux, we need to specify that we want continuous idle events
#if defined(__WXGTK__)
event.RequestMore(); //On GTK, we need to specify that we want continuous idle events.
#endif
}
@@ -511,8 +514,8 @@ wxRibbonButtonBar* LayoutEditorCanvas::CreateRibbonPage(wxRibbonPage * page)
{
wxRibbonPanel *ribbonPanel = new wxRibbonPanel(page, wxID_ANY, _("Mode"), SkinHelper::GetRibbonIcon("preview"), wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE);
modeRibbonBar = new wxRibbonButtonBar(ribbonPanel, wxID_ANY);
modeRibbonBar->AddButton(idRibbonEditMode, !hideLabels ? _("Edition") : "", SkinHelper::GetRibbonIcon("edit"), _("Edit the layout"));
modeRibbonBar->AddButton(idRibbonPreviewMode, !hideLabels ? _("Preview") : "", SkinHelper::GetRibbonIcon("preview"), _("Launch a preview of the layout"), wxRIBBON_BUTTON_HYBRID);
modeRibbonBar->AddButton(idRibbonEditMode, !hideLabels ? _("Stop the preview") : "", SkinHelper::GetRibbonIcon("edit"), _("Stop the preview and go back to editing"));
modeRibbonBar->AddButton(idRibbonPreviewMode, !hideLabels ? _("Preview") : "", SkinHelper::GetRibbonIcon("preview"), _("Launch a preview"), wxRIBBON_BUTTON_HYBRID);
}
wxRibbonPanel *toolsPanel = new wxRibbonPanel(page, wxID_ANY, _("Tools"), SkinHelper::GetRibbonIcon("tools"), wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE);
@@ -729,7 +732,7 @@ void LayoutEditorCanvas::OnLeftDown( wxMouseEvent &event )
//Check if there is a click on a gui element inside the layout
for (unsigned int i = 0;i<guiElements.size();++i)
{
if ( guiElements[i].area.Contains(event.GetX(), event.GetY()) )
if ( guiElements[i].area.Contains(wxPoint(sf::Mouse::getPosition(*this).x, sf::Mouse::getPosition(*this).y)) )
{
OnGuiElementPressed(guiElements[i]);
return ;
@@ -884,7 +887,7 @@ public:
}
std::vector<InitialInstance*> & GetSelectedList() { return selectedList; };
std::vector<InitialInstance*> & IgnoreLockedInstances() { ignoreLockedInstances = true; };
InstancesInAreaPicker & IgnoreLockedInstances() { ignoreLockedInstances = true; return *this; };
private:
const LayoutEditorCanvas & editor;
@@ -892,7 +895,7 @@ private:
bool ignoreLockedInstances;
};
void LayoutEditorCanvas::OnLeftUp( wxMouseEvent &event )
void LayoutEditorCanvas::OnLeftUp(wxMouseEvent &)
{
if ( !editing ) return;
@@ -913,7 +916,7 @@ void LayoutEditorCanvas::OnLeftUp( wxMouseEvent &event )
//Check if there is a click released on a gui element inside the layout
for (unsigned int i = 0;i<guiElements.size();++i)
{
if ( guiElements[i].area.Contains(event.GetX(), event.GetY()) )
if ( guiElements[i].area.Contains(wxPoint(sf::Mouse::getPosition(*this).x, sf::Mouse::getPosition(*this).y)) )
{
OnGuiElementReleased(guiElements[i]);
return;
@@ -970,7 +973,7 @@ void LayoutEditorCanvas::OnLeftUp( wxMouseEvent &event )
}
}
void LayoutEditorCanvas::OnMotion( wxMouseEvent &event )
void LayoutEditorCanvas::OnMotion(wxMouseEvent &)
{
if (!editing) return;
@@ -1064,7 +1067,7 @@ void LayoutEditorCanvas::OnMotion( wxMouseEvent &event )
bool hoveringSomething = false;
for (unsigned int i = 0;i<guiElements.size();++i)
{
if ( guiElements[i].area.Contains(event.GetX(), event.GetY()) ) {
if ( guiElements[i].area.Contains(wxPoint(sf::Mouse::getPosition(*this).x, sf::Mouse::getPosition(*this).y)) ) {
OnGuiElementHovered(guiElements[i]);
hoveringSomething = true;
}
@@ -1104,7 +1107,7 @@ void LayoutEditorCanvas::OnMotion( wxMouseEvent &event )
}
}
void LayoutEditorCanvas::OnMiddleDown( wxMouseEvent &event )
void LayoutEditorCanvas::OnMiddleDown(wxMouseEvent &)
{
if ( !editing ) return;

View File

@@ -479,8 +479,10 @@ protected:
double oldMouseX; ///< The mouse X position which was usually stored the last time a right click happened.
double oldMouseY; ///< The mouse Y position which was usually stored the last time a right click happened.
bool isMovingInstance;
static constexpr float gapBetweenButtonsAndRectangle = 5;
static constexpr float smallButtonSize = 5;
float gapBetweenButtonsAndRectangle;
float smallButtonSize;
bool firstRefresh;
bool isSelecting;

View File

@@ -674,13 +674,18 @@ void LayoutEditorCanvas::UpdateSize()
if ( parentControl->GetSize().GetWidth() <= 0 || parentControl->GetSize().GetHeight() <= 0)
return;
unsigned int width = parentControl->GetSize().GetWidth()-(vScrollbar ? vScrollbar->GetSize().GetWidth() : 0);
unsigned int height = parentControl->GetSize().GetHeight()- (hScrollbar ? hScrollbar->GetSize().GetHeight() : 0);
#if defined(MACOS) //&& defined(RETINA)
width *= 2;
height *= 2;
#endif
//Scene takes all the space available in edition mode.
Window::setSize(sf::Vector2u(
parentControl->GetSize().GetWidth()-(vScrollbar ? vScrollbar->GetSize().GetWidth() : 0),
parentControl->GetSize().GetHeight()- (hScrollbar ? hScrollbar->GetSize().GetHeight() : 0)));
Window::setSize(sf::Vector2u(width, height));
wxWindowBase::SetPosition(wxPoint(0,0));
wxWindowBase::SetSize(parentControl->GetSize().GetWidth() - (vScrollbar ? vScrollbar->GetSize().GetWidth() : 0),
parentControl->GetSize().GetHeight()- (hScrollbar ? hScrollbar->GetSize().GetHeight() : 0));
wxWindowBase::SetSize(width, height);
UpdateViewAccordingToZoomFactor();
}

View File

@@ -15,6 +15,7 @@
#if !defined(GD_NO_WX_GUI)
#include <wx/treectrl.h>
#include <wx/bitmap.h>
#include <wx/log.h>
#endif
namespace gd
@@ -81,101 +82,35 @@ std::vector<std::string> ObjectListDialogsHelper::GetMatchingObjects() const
}
#if !defined(GD_NO_WX_GUI)
void ObjectListDialogsHelper::RefreshLists(wxTreeCtrl * sceneObjectsList, wxTreeCtrl * sceneGroupsList, wxTreeCtrl * globalObjectsList, wxTreeCtrl * globalGroupsList)
{
bool searching = searchText.empty() ? false : true;
sceneObjectsList->DeleteAllItems();
sceneObjectsList->AddRoot( _( "All objects groups of the scene" ) );
for ( unsigned int i = 0;i < layout.GetObjectsCount();i++ )
{
std::string name = layout.GetObject(i).GetName();
//Only add the object if it has the correct type
if (( objectTypeAllowed.empty() || layout.GetObject(i).GetType() == objectTypeAllowed ) &&
( !searching || (searching && gd::StrUppercase(name).find(gd::StrUppercase(searchText)) != std::string::npos)))
{
sceneObjectsList->AppendItem( sceneObjectsList->GetRootItem(), name );
}
}
sceneObjectsList->ExpandAll();
sceneGroupsList->DeleteAllItems();
sceneGroupsList->AddRoot( _( "All groups of the scene" ) );
for ( unsigned int i = 0;i < layout.GetObjectGroups().size();i++ )
{
std::string name = layout.GetObjectGroups()[i].GetName();
//Only add the group if it has all objects of the correct type
if (( objectTypeAllowed.empty() || gd::GetTypeOfObject(project, layout, layout.GetObjectGroups()[i].GetName()) == objectTypeAllowed ) &&
( !searching || (searching && gd::StrUppercase(name).find(gd::StrUppercase(searchText)) != std::string::npos)))
{
sceneGroupsList->AppendItem( sceneGroupsList->GetRootItem(), name );
}
}
sceneGroupsList->ExpandAll();
globalObjectsList->DeleteAllItems();
globalObjectsList->AddRoot( _( "All globals objects" ) );
for ( unsigned int i = 0;i < project.GetObjectsCount();i++ )
{
std::string name = project.GetObject(i).GetName();
//Only add the object if it has the correct type
if ((objectTypeAllowed.empty() || project.GetObject(i).GetType() == objectTypeAllowed ) &&
( !searching || (searching && gd::StrUppercase(name).find(gd::StrUppercase(searchText)) != std::string::npos)))
{
globalObjectsList->AppendItem( globalObjectsList->GetRootItem(), name );
}
}
globalObjectsList->ExpandAll();
globalGroupsList->DeleteAllItems();
globalGroupsList->AddRoot( _( "All globals groups" ) );
for ( unsigned int i = 0;i < project.GetObjectGroups().size();i++ )
{
std::string name = project.GetObjectGroups()[i].GetName();
//Only add the group if it has all objects of the correct type
if (( objectTypeAllowed.empty() || gd::GetTypeOfObject(project, layout, project.GetObjectGroups()[i].GetName()) == objectTypeAllowed ) &&
( !searching || (searching && gd::StrUppercase(name).find(gd::StrUppercase(searchText)) != std::string::npos)))
{
globalGroupsList->AppendItem( globalGroupsList->GetRootItem(), name );
}
}
globalGroupsList->ExpandAll();
}
void ObjectListDialogsHelper::RefreshList(wxTreeCtrl * objectsList)
void ObjectListDialogsHelper::RefreshList(wxTreeCtrl * objectsList, wxTreeItemId * objectsRootItem_, wxTreeItemId * groupsRootItem_)
{
objectsList->DeleteAllItems();
objectsList->AssignImageList(imageList);
objectsList->AddRoot( "Root" );
imageList->RemoveAll();
imageList->Add(gd::SkinHelper::GetIcon("object", 24));
imageList->Add(gd::SkinHelper::GetIcon("group", 24));
if (!objectsList->GetImageList())
objectsList->AssignImageList(new wxImageList(24,24, true));
objectsList->GetImageList()->RemoveAll();
objectsList->GetImageList()->Add(gd::SkinHelper::GetIcon("object", 24));
objectsList->GetImageList()->Add(gd::SkinHelper::GetIcon("group", 24));
wxTreeItemId objectsRootItem = objectsList->AppendItem(objectsList->GetRootItem(), _("Objects"), 0);
wxTreeItemId groupsRootItem = objectsList->AppendItem(objectsList->GetRootItem(), _("Groups"), 1);
AddObjectsToList(objectsList, objectsRootItem, layout, false, false);
if ( groupsAllowed ) AddGroupsToList(objectsList, groupsRootItem, layout.GetObjectGroups(), false, false);
AddObjectsToList(objectsList, objectsRootItem, project, true, false);
if ( groupsAllowed ) AddGroupsToList(objectsList, groupsRootItem, project.GetObjectGroups(), true, false);
AddObjectsToList(objectsList, objectsRootItem, layout, false);
if ( groupsAllowed ) AddGroupsToList(objectsList, groupsRootItem, layout.GetObjectGroups(), false);
AddObjectsToList(objectsList, objectsRootItem, project, true);
if ( groupsAllowed ) AddGroupsToList(objectsList, groupsRootItem, project.GetObjectGroups(), true);
objectsList->ExpandAll();
objectsList->Expand(objectsRootItem);
objectsList->Expand(groupsRootItem);
//If asked, return the root items for the objects and groups.
if (objectsRootItem_) *objectsRootItem_ = objectsRootItem;
if (groupsRootItem_) *groupsRootItem_ = groupsRootItem;
}
wxTreeItemId ObjectListDialogsHelper::AddObjectsToList(wxTreeCtrl * objectsList, wxTreeItemId rootItem, const gd::ClassWithObjects & objects, bool globalObjects, bool substituteIfEmpty)
wxTreeItemId ObjectListDialogsHelper::AddObjectsToList(wxTreeCtrl * objectsList, wxTreeItemId rootItem, const gd::ClassWithObjects & objects, bool globalObjects)
{
bool searching = searchText.empty() ? false : true;
@@ -188,18 +123,8 @@ wxTreeItemId ObjectListDialogsHelper::AddObjectsToList(wxTreeCtrl * objectsList,
if ((objectTypeAllowed.empty() || objects.GetObject(i).GetType() == objectTypeAllowed ) &&
( !searching || (searching && gd::StrUppercase(name).find(searchText) != std::string::npos)) )
{
int thumbnailID = -1;
wxBitmap thumbnail;
if ( objects.GetObject(i).GenerateThumbnail(project, thumbnail) && thumbnail.IsOk() )
{
imageList->Add(thumbnail);
thumbnailID = imageList->GetImageCount()-1;
}
wxTreeItemId item = objectsList->AppendItem( rootItem,
objects.GetObject(i).GetName(), thumbnailID );
objectsList->SetItemData(item, new gd::TreeItemStringData(globalObjects ? "GlobalObject" : "LayoutObject"));
if ( globalObjects ) objectsList->SetItemBold(item, true);
wxTreeItemId item = objectsList->AppendItem(rootItem, "theobject");
MakeObjectItem(objectsList, item, objects.GetObject(i), globalObjects);
lastAddedItem = item;
}
@@ -208,7 +133,7 @@ wxTreeItemId ObjectListDialogsHelper::AddObjectsToList(wxTreeCtrl * objectsList,
return lastAddedItem;
}
wxTreeItemId ObjectListDialogsHelper::AddGroupsToList(wxTreeCtrl * objectsList, wxTreeItemId rootItem, const std::vector <ObjectGroup> & groups, bool globalGroup, bool substituteIfEmpty)
wxTreeItemId ObjectListDialogsHelper::AddGroupsToList(wxTreeCtrl * objectsList, wxTreeItemId rootItem, const std::vector <ObjectGroup> & groups, bool globalGroups)
{
bool searching = searchText.empty() ? false : true;
@@ -218,9 +143,8 @@ wxTreeItemId ObjectListDialogsHelper::AddGroupsToList(wxTreeCtrl * objectsList,
if (( objectTypeAllowed.empty() || gd::GetTypeOfObject(project, layout, groups[i].GetName()) == objectTypeAllowed ) &&
( !searching || (searching && gd::StrUppercase(groups[i].GetName()).find(searchText) != std::string::npos)) )
{
wxTreeItemId item = objectsList->AppendItem( rootItem, groups[i].GetName(), 1 );
objectsList->SetItemData(item, new gd::TreeItemStringData(globalGroup ? "GlobalGroup" : "LayoutGroup"));
if ( globalGroup ) objectsList->SetItemBold(item, true);
wxTreeItemId item = objectsList->AppendItem(rootItem, "thegroup");
MakeGroupItem(objectsList, item, groups[i], globalGroups);
lastAddedItem = item;
}
@@ -228,6 +152,41 @@ wxTreeItemId ObjectListDialogsHelper::AddGroupsToList(wxTreeCtrl * objectsList,
return lastAddedItem;
}
void ObjectListDialogsHelper::MakeGroupItem(wxTreeCtrl * objectsList, wxTreeItemId item, const gd::ObjectGroup & group, bool globalGroup)
{
objectsList->SetItemText(item, group.GetName());
objectsList->SetItemImage(item, 1);
objectsList->SetItemData(item, new gd::TreeItemStringData(globalGroup ? "GlobalGroup" : "LayoutGroup"));
if ( globalGroup ) objectsList->SetItemBold(item, true);
if (hasGroupExtraRendering) groupExtraRendering(item);
}
void ObjectListDialogsHelper::MakeObjectItem(wxTreeCtrl * objectsList, wxTreeItemId item, const gd::Object & object, bool globalObject)
{
objectsList->SetItemText(item, object.GetName());
objectsList->SetItemImage(item, MakeObjectItemThumbnail(objectsList, object));
objectsList->SetItemData(item, new gd::TreeItemStringData(globalObject ? "GlobalObject" : "LayoutObject"));
if (globalObject) objectsList->SetItemBold(item, true);
}
int ObjectListDialogsHelper::MakeObjectItemThumbnail(wxTreeCtrl * objectsList, const gd::Object & object)
{
wxLogNull noLogPlease; //Discard any warning when loading thumbnails.
int thumbnailID = -1;
wxBitmap thumbnail;
if (objectsList->GetImageList() &&
object.GenerateThumbnail(project, thumbnail) &&
thumbnail.IsOk() )
{
objectsList->GetImageList()->Add(thumbnail);
thumbnailID = objectsList->GetImageList()->GetImageCount()-1;
}
return thumbnailID;
}
#endif
}

View File

@@ -8,9 +8,11 @@
#define GDCORE_OBJECTLISTDIALOGSHELPER_H
#include <string>
#include <functional>
#include <vector>
namespace gd { class Project; }
namespace gd { class Layout; }
namespace gd { class Object; }
namespace gd { class ClassWithObjects; }
namespace gd { class ObjectGroup; }
class wxTreeCtrl;
@@ -38,17 +40,34 @@ public:
* \param project Project
* \param layout Layout
*/
ObjectListDialogsHelper(const gd::Project & project_, const gd::Layout & layout_) : project(project_), layout(layout_), groupsAllowed(true)
ObjectListDialogsHelper(const gd::Project & project_, const gd::Layout & layout_) :
project(project_),
layout(layout_),
groupsAllowed(true),
hasGroupExtraRendering(false)
{
#if !defined(GD_NO_WX_GUI)
imageList = new wxImageList(24,24, true);
#endif
};
virtual ~ObjectListDialogsHelper() {};
/**
* \brief Specify the filter text: only objects and groups having a name
* containing this text will be shown when calling RefreshList.
* \param searchText The filter text
*/
void SetSearchText(std::string searchText_);
/**
* \brief Specify a type of object to display. Only objects of this type will
* be shown when calling RefreshList.
* \param allowedObjectType The type of objects. For example, "Sprite" or "TextObject::Text".
*/
void SetAllowedObjectType(std::string allowedObjectType_) { objectTypeAllowed = allowedObjectType_; }
/**
* \brief Set if groups of objects are displayed when calling RefreshList (true by default).
* \param canSelectGroup true to show groups, false to hide them.
*/
void SetGroupsAllowed(bool canSelectGroup) { groupsAllowed = canSelectGroup; }
/**
@@ -58,33 +77,48 @@ public:
#if !defined(GD_NO_WX_GUI)
/**
* \brief Update tree controls with objects and objects groups from the project and layout
* \param sceneObjectsList The wxTreeCtrl which will contain the layout objects
* \param sceneGroupsList The wxTreeCtrl which will contain the layout groups
* \param globalObjectsList The wxTreeCtrl which will contain the project objects
* \param globalGroupsList The wxTreeCtrl which will contain the project groups
* \param objectTypeAllowed If not empty, only objects of this type will be displayed
* \param searchText The text in the search box, which is used to filter objects
* \brief Update a tree control with all objects and objects groups from the project and layout
* \param objectsList The wxTreeCtrl which will contain the objects and groups
* \aram objectsRootItem Optional pointer to a wxTreeItemId which will be filled with the item being the root item for objects.
* \aram groupsRootItem Optional pointer to a wxTreeItemId which will be filled with the item being the root item for groups.
*/
void RefreshLists(wxTreeCtrl * sceneObjectsList,
wxTreeCtrl * sceneGroupsList,
wxTreeCtrl * globalObjectsList,
wxTreeCtrl * globalGroupsList);
void RefreshList(wxTreeCtrl * objectsList, wxTreeItemId * objectsRootItem = NULL,
wxTreeItemId * groupsRootItem = NULL);
/**
* \brief Update a tree control with all objects and objects groups from the project and layout
* \note The wxTreeCtrl must have an image list containing the object icon and the object group icon
* ( at index 0 and 1 )
* \param objectsList The wxTreeCtrl which will contain the objects and groups
* \param objectTypeAllowed If not empty, only objects of this type will be displayed
* \param searchText The text in the search box, which is used to filter objects
* \brief Format the specified wxTreeItemId for the object (label, thumbnail...).
*/
void RefreshList(wxTreeCtrl * objectsList);
void MakeObjectItem(wxTreeCtrl * objectsList, wxTreeItemId item, const gd::Object & object, bool globalObject);
/**
* \brief Format the specified wxTreeItemId for the group (label, thumbnail...).
*/
void MakeGroupItem(wxTreeCtrl * objectsList, wxTreeItemId item, const gd::ObjectGroup & group, bool globalGroup);
/**
* \brief Set a callback that will be called whenever a group item is being rendered.
* \see gd::ObjectListDialogsHelper::MakeGroupItem
*/
void SetGroupExtraRendering(std::function<void(wxTreeItemId)> function)
{
hasGroupExtraRendering = true;
groupExtraRendering = function;
}
#endif
private:
wxTreeItemId AddObjectsToList(wxTreeCtrl * tree, wxTreeItemId rootItem, const gd::ClassWithObjects & objects, bool globalObjects, bool substituteIfEmpty);
wxTreeItemId AddGroupsToList(wxTreeCtrl * tree, wxTreeItemId rootItem, const std::vector <gd::ObjectGroup> & groups, bool globalGroup, bool substituteIfEmpty);
#if !defined(GD_NO_WX_GUI)
wxTreeItemId AddObjectsToList(wxTreeCtrl * tree, wxTreeItemId rootItem, const gd::ClassWithObjects & objects, bool globalObjects);
wxTreeItemId AddGroupsToList(wxTreeCtrl * tree, wxTreeItemId rootItem, const std::vector <gd::ObjectGroup> & groups, bool globalGroup);
/**
* \brief Generate the thumnail for the specified object, add it to the image list of the
* wxTreeCtrl and return the id on the thumbnail.
* \param objectsList the wxTreeCtrl containing the objects list.
* \param object The object for which thumbnail should be generated.
*/
int MakeObjectItemThumbnail(wxTreeCtrl * objectsList, const gd::Object & object);
#endif
const Project & project;
const Layout & layout;
@@ -92,9 +126,8 @@ private:
std::string searchText;
bool groupsAllowed;
#if !defined(GD_NO_WX_GUI)
wxImageList *imageList;
#endif
bool hasGroupExtraRendering;
std::function<void(wxTreeItemId)> groupExtraRendering;
};
}

View File

@@ -127,7 +127,10 @@ void ParameterControlsHelper::UpdateParameterContent(unsigned int i, const Param
void ParameterControlsHelper::OnOptionalCheckboxClick(wxCommandEvent& event)
{
unsigned int i = gd::ToInt(gd::ToString(window->FindFocus()->GetName()));
wxWindow * control = dynamic_cast<wxWindow*>(event.GetEventObject());
if (!control) return;
unsigned int i = gd::ToInt(gd::ToString(control->GetName()));
if (i >= paramCheckboxes.size()) return;
bool enable = paramCheckboxes.at(i)->GetValue();
@@ -138,7 +141,10 @@ void ParameterControlsHelper::OnOptionalCheckboxClick(wxCommandEvent& event)
void ParameterControlsHelper::OnParameterBtClick(wxCommandEvent& event)
{
unsigned int i = ToInt(gd::ToString(wxWindow::FindFocus()->GetName()));
wxWindow * control = dynamic_cast<wxWindow*>(event.GetEventObject());
if (!control) return;
unsigned int i = ToInt(gd::ToString(control->GetName()));
if (i >= paramMetadata.size() || i >= paramEdits.size()) return;
if (!editionCallback || !editionCallbackProject || !editionCallbackLayout) return;

View File

@@ -99,8 +99,8 @@ public:
void SetSelectedPoint(unsigned int point) {selectedPolygonPoint = point;};
private:
PolygonEditionHelper(const PolygonEditionHelper&) {};
PolygonEditionHelper& operator=(PolygonEditionHelper) {};
PolygonEditionHelper(const PolygonEditionHelper&);
PolygonEditionHelper& operator=(PolygonEditionHelper);
bool movingPolygonPoint;
unsigned int selectedPolygon;

View File

@@ -18,6 +18,7 @@
#include "GDCore/IDE/EventsEditorItemsAreas.h"
#include "GDCore/IDE/EventsEditorSelection.h"
#include "GDCore/IDE/CommonBitmapManager.h"
#include "GDCore/IDE/wxTools/GUIContentScaleFactor.h"
#include "GDCore/Events/Event.h"
using namespace std;
@@ -114,14 +115,19 @@ niceRectangleOutline(wxPen(wxColour(205,205,246), 1)),
actionsRectangleOutline(wxPen(wxColour(205,205,246))),
conditionsRectangleOutline(wxPen(wxColour(185,185,247), 1)),
actionsRectangleFill(*wxWHITE_BRUSH),
conditionsRectangleFill(wxBrush(wxColour(252,252,255))),
niceFont(wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL))
conditionsRectangleFill(wxBrush(wxColour(252,252,255)))
{
fakeBmp.Create(10,10,-1);
//Setup fonts, with "retina" support.
int fontSize = gd::GUIContentScaleFactor::Get() > 1 ? 15 : 9;
int niceFontSize = gd::GUIContentScaleFactor::Get() > 1 ? 12 : 8;
niceFont = wxFont(niceFontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
#if defined(WINDOWS)
SetFont(wxFont(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Consolas"));
SetFont(wxFont(fontSize, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Consolas"));
#else
SetFont(wxFont(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false));
SetFont(wxFont(fontSize, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false));
#endif
}

View File

@@ -32,174 +32,174 @@ namespace gd
*/
class GD_CORE_API EventsRenderingHelper
{
public:
static EventsRenderingHelper * Get();
static void DestroySingleton();
public:
static EventsRenderingHelper * Get();
static void DestroySingleton();
/**
* Draw a nice rectangle, often used as conditions background, on a wxDC.
*/
void DrawNiceRectangle(wxDC & dc, const wxRect & rect) const;
/**
* Draw a nice rectangle, often used as conditions background, on a wxDC.
*/
void DrawNiceRectangle(wxDC & dc, const wxRect & rect) const;
/**
* \brief Draw the specified condition list
* \param conditions Conditions to be rendered
* \param dc wxWidgets DC to be used
* \param x x position of the drawing
* \param y y position of the drawing
* \param width Width available for the drawing
* \param event Event owning the condition list
* \param areas EventsEditorItemsAreas object when drawn areas will be registered
* \param selection EventsEditorSelection object providing information about selection
* \param platform The platform currently used
* \return Height used for the drawing
*/
int DrawConditionsList(std::vector < gd::Instruction > & conditions, wxDC & dc, int x, int y, int width, gd::BaseEvent * event,
gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* \brief Draw the specified condition list
* \param conditions Conditions to be rendered
* \param dc wxWidgets DC to be used
* \param x x position of the drawing
* \param y y position of the drawing
* \param width Width available for the drawing
* \param event Event owning the condition list
* \param areas EventsEditorItemsAreas object when drawn areas will be registered
* \param selection EventsEditorSelection object providing information about selection
* \param platform The platform currently used
* \return Height used for the drawing
*/
int DrawConditionsList(std::vector < gd::Instruction > & conditions, wxDC & dc, int x, int y, int width, gd::BaseEvent * event,
gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* \brief Draw the specified action list
* \see gd::EventsRenderingHelper::DrawConditionsList
*/
int DrawActionsList(std::vector < gd::Instruction > & actions, wxDC & dc, int x, int y, int width, gd::BaseEvent * event,
gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* \brief Draw the specified action list
* \see gd::EventsRenderingHelper::DrawConditionsList
*/
int DrawActionsList(std::vector < gd::Instruction > & actions, wxDC & dc, int x, int y, int width, gd::BaseEvent * event,
gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform);
/**
* \brief Get the height taken by drawing a condition list
* \param conditions Conditions to be rendered
* \param width Width available for the drawing
* \param platform The platform currently used
* \return Height used for the drawing
*/
unsigned int GetRenderedConditionsListHeight(const std::vector < gd::Instruction > & conditions, int width, const gd::Platform & platform);
/**
* \brief Get the height taken by drawing a condition list
* \see gd::EventsRenderingHelper::GetRenderedConditionsListHeight
*/
unsigned int GetRenderedActionsListHeight(const std::vector < gd::Instruction > & actions, int width, const gd::Platform & platform);
/**
* \brief Get the height taken by drawing a condition list
* \param conditions Conditions to be rendered
* \param width Width available for the drawing
* \param platform The platform currently used
* \return Height used for the drawing
*/
unsigned int GetRenderedConditionsListHeight(const std::vector < gd::Instruction > & conditions, int width, const gd::Platform & platform);
/**
* \brief Get the height taken by drawing a condition list
* \see gd::EventsRenderingHelper::GetRenderedConditionsListHeight
*/
unsigned int GetRenderedActionsListHeight(const std::vector < gd::Instruction > & actions, int width, const gd::Platform & platform);
inline unsigned int GetConditionsColumnWidth() const {return conditionsColumnWidth;};
inline void SetConditionsColumnWidth(unsigned int conditionsColumnWidth_) { conditionsColumnWidth = conditionsColumnWidth_; };
inline unsigned int GetConditionsColumnWidth() const {return conditionsColumnWidth;};
inline void SetConditionsColumnWidth(unsigned int conditionsColumnWidth_) { conditionsColumnWidth = conditionsColumnWidth_; };
/**
* Draw a text in dc at point, without taking more than widthAvailable.
* \return X position of the last character and total height taken by the text
*/
wxPoint DrawTextInArea(std::string text, wxDC & dc, wxRect rect, wxPoint point);
/**
* Draw a text in dc at point, without taking more than widthAvailable.
* \return X position of the last character and total height taken by the text
*/
wxPoint DrawTextInArea(std::string text, wxDC & dc, wxRect rect, wxPoint point);
/**
* \return Height taken by the text
*/
unsigned int GetTextHeightInArea(const std::string & text, unsigned int widthAvailable);
/**
* \return Height taken by the text
*/
unsigned int GetTextHeightInArea(const std::string & text, unsigned int widthAvailable);
/**
* Draw a specific instruction
* \param instruction Instruction to be rendered
* \param instructionMetadata Instruction metadata
* \param isCondition true if the instruction is a condition
* \param dc The wxWidgets DC to be used for rendering
* \param point The drawing position
* \param freeWidth Width available
* \param event Event owning the condition list
* \param areas EventsEditorItemsAreas object when drawn areas will be registered
* \param selection EventsEditorSelection object providing information about selection
* \return Height used for the drawing
*/
int DrawInstruction(gd::Instruction & instruction,
const gd::InstructionMetadata & instructionMetadata,
bool isCondition, wxDC & dc, wxPoint point, int freeWidth,
gd::BaseEvent * event, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection);
/**
* Draw a specific instruction
* \param instruction Instruction to be rendered
* \param instructionMetadata Instruction metadata
* \param isCondition true if the instruction is a condition
* \param dc The wxWidgets DC to be used for rendering
* \param point The drawing position
* \param freeWidth Width available
* \param event Event owning the condition list
* \param areas EventsEditorItemsAreas object when drawn areas will be registered
* \param selection EventsEditorSelection object providing information about selection
* \return Height used for the drawing
*/
int DrawInstruction(gd::Instruction & instruction,
const gd::InstructionMetadata & instructionMetadata,
bool isCondition, wxDC & dc, wxPoint point, int freeWidth,
gd::BaseEvent * event, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection);
/**
* Change font. Only use a fixed width font.
*/
void SetFont(const wxFont & font);
/**
* Change font. Only use a fixed width font.
*/
void SetFont(const wxFont & font);
inline const wxFont & GetFont() const {return font;};
inline wxFont & GetFont() {return font;};
inline const wxFont & GetFont() const {return font;};
inline wxFont & GetFont() {return font;};
inline const wxFont & GetNiceFont() const {return niceFont;};
inline wxFont & GetNiceFont() {return niceFont;};
inline const wxFont & GetNiceFont() const {return niceFont;};
inline wxFont & GetNiceFont() {return niceFont;};
inline const wxHtmlDCRenderer & GetHTMLRenderer() const {return htmlRenderer;};
inline wxHtmlDCRenderer & GetHTMLRenderer() {return htmlRenderer;};
inline const wxHtmlDCRenderer & GetHTMLRenderer() const {return htmlRenderer;};
inline wxHtmlDCRenderer & GetHTMLRenderer() {return htmlRenderer;};
const wxBrush & GetSelectedRectangleFillBrush() const { return selectionRectangleFill; }
wxBrush & GetSelectedRectangleFillBrush() { return selectionRectangleFill; }
const wxBrush & GetSelectedRectangleFillBrush() const { return selectionRectangleFill; }
wxBrush & GetSelectedRectangleFillBrush() { return selectionRectangleFill; }
const wxPen & GetSelectedRectangleOutlinePen() const { return selectionRectangleOutline; }
wxPen & GetSelectedRectangleOutlinePen() { return selectionRectangleOutline; }
const wxPen & GetSelectedRectangleOutlinePen() const { return selectionRectangleOutline; }
wxPen & GetSelectedRectangleOutlinePen() { return selectionRectangleOutline; }
const wxBrush & GetHighlightedRectangleFillBrush() const { return highlightRectangleFill; }
wxBrush & GetHighlightedRectangleFillBrush() { return highlightRectangleFill; }
const wxBrush & GetHighlightedRectangleFillBrush() const { return highlightRectangleFill; }
wxBrush & GetHighlightedRectangleFillBrush() { return highlightRectangleFill; }
const wxPen & GetHighlightedRectangleOutlinePen() const { return highlightRectangleOutline; }
wxPen & GetHighlightedRectangleOutlinePen() { return highlightRectangleOutline; }
const wxPen & GetHighlightedRectangleOutlinePen() const { return highlightRectangleOutline; }
wxPen & GetHighlightedRectangleOutlinePen() { return highlightRectangleOutline; }
const wxPen & GetConditionsRectangleOutlinePen() const { return conditionsRectangleOutline; }
wxPen & GetConditionsRectangleOutlinePen() { return conditionsRectangleOutline; }
const wxPen & GetConditionsRectangleOutlinePen() const { return conditionsRectangleOutline; }
wxPen & GetConditionsRectangleOutlinePen() { return conditionsRectangleOutline; }
const wxPen & GetActionsRectangleOutlinePen() const { return actionsRectangleOutline; }
wxPen & GetActionsRectangleOutlinePen() { return actionsRectangleOutline; }
const wxPen & GetActionsRectangleOutlinePen() const { return actionsRectangleOutline; }
wxPen & GetActionsRectangleOutlinePen() { return actionsRectangleOutline; }
const wxBrush & GetConditionsRectangleFillBrush() const { return conditionsRectangleFill; }
wxBrush & GetConditionsRectangleFillBrush() { return conditionsRectangleFill; }
const wxBrush & GetConditionsRectangleFillBrush() const { return conditionsRectangleFill; }
wxBrush & GetConditionsRectangleFillBrush() { return conditionsRectangleFill; }
const wxBrush & GetActionsRectangleFillBrush() const { return actionsRectangleFill; }
wxBrush & GetActionsRectangleFillBrush() { return actionsRectangleFill; }
const wxBrush & GetActionsRectangleFillBrush() const { return actionsRectangleFill; }
wxBrush & GetActionsRectangleFillBrush() { return actionsRectangleFill; }
/**
* Make sure a text will be correctly display by replacing specials characters
* and inserting tags like <br>.
*/
std::string GetHTMLText(std::string text);
/**
* Make sure a text will be correctly display by replacing specials characters
* and inserting tags like <br>.
*/
std::string GetHTMLText(std::string text);
wxColor eventGradient1;
wxColor eventGradient2;
wxColor eventGradient3;
wxColor eventGradient4;
wxColor eventBorderColor;
wxColor eventConditionsGradient1;
wxColor eventConditionsGradient2;
wxColor eventConditionsGradient3;
wxColor eventConditionsGradient4;
wxColor eventConditionsBorderColor;
wxColor selectionColor;
wxColor disabledColor;
wxColor disabledColor2;
wxColor eventGradient1;
wxColor eventGradient2;
wxColor eventGradient3;
wxColor eventGradient4;
wxColor eventBorderColor;
wxColor eventConditionsGradient1;
wxColor eventConditionsGradient2;
wxColor eventConditionsGradient3;
wxColor eventConditionsGradient4;
wxColor eventConditionsBorderColor;
wxColor selectionColor;
wxColor disabledColor;
wxColor disabledColor2;
int instructionsListBorder;
int separationBetweenInstructions;
int instructionsListBorder;
int separationBetweenInstructions;
private:
EventsRenderingHelper();
virtual ~EventsRenderingHelper() {};
private:
EventsRenderingHelper();
virtual ~EventsRenderingHelper() {};
unsigned int conditionsColumnWidth;
unsigned int conditionsColumnWidth;
wxPen selectionRectangleOutline;
wxBrush selectionRectangleFill;
wxPen highlightRectangleOutline;
wxBrush highlightRectangleFill;
wxPen selectionRectangleOutline;
wxBrush selectionRectangleFill;
wxPen highlightRectangleOutline;
wxBrush highlightRectangleFill;
wxPen niceRectangleOutline;
wxColour niceRectangleFill1;
wxColour niceRectangleFill2;
wxPen niceRectangleOutline;
wxColour niceRectangleFill1;
wxColour niceRectangleFill2;
wxPen actionsRectangleOutline;
wxPen conditionsRectangleOutline;
wxBrush actionsRectangleFill;
wxBrush conditionsRectangleFill;
wxPen actionsRectangleOutline;
wxPen conditionsRectangleOutline;
wxBrush actionsRectangleFill;
wxBrush conditionsRectangleFill;
wxFont font; ///< Fixed width font
float fontCharacterWidth;
wxFont font; ///< Fixed width font
float fontCharacterWidth;
wxFont niceFont;
wxFont niceFont;
wxHtmlDCRenderer htmlRenderer;
wxHtmlDCRenderer htmlRenderer;
static EventsRenderingHelper *singleton;
wxBitmap fakeBmp;
static EventsRenderingHelper *singleton;
wxBitmap fakeBmp;
};
}

View File

@@ -38,12 +38,6 @@ void ExtensionsLoader::LoadAllExtensions(const std::string & directory, gd::Plat
#if defined(WINDOWS)
suffix += "w";
#elif defined(LINUX)
suffix += "l";
#elif defined(MAC)
suffix += "m";
#else
#warning No target system defined.
#endif
#if defined(GD_IDE_ONLY)
@@ -129,19 +123,13 @@ void ExtensionsLoader::ExtensionsLoadingDone(const std::string & directory)
#if defined(WINDOWS)
suffix += "w";
#elif defined(LINUX)
suffix += "l";
#elif defined(MAC)
suffix += "m";
#else
#warning No target system defined.
#endif
#if defined(GD_IDE_ONLY)
suffix += "e";
#endif
#if defined(LINUX) || defined (MAC)
#if defined(LINUX) || defined (MACOS)
//List all extensions loaded
struct dirent *lecture;

View File

@@ -42,6 +42,8 @@ void PlatformLoader::LoadAllPlatformsInManager(std::string dir)
std::shared_ptr<gd::Platform> platform = LoadPlatformInManager("GDCpp.dll");
#elif defined(LINUX)
std::shared_ptr<gd::Platform> platform = LoadPlatformInManager("libGDCpp.so");
#elif defined(MACOS)
std::shared_ptr<gd::Platform> platform = LoadPlatformInManager("libGDCpp.dylib");
#else
#warning Add the appropriate filename here for the C++ Platform!
std::shared_ptr<gd::Platform> platform;
@@ -57,6 +59,8 @@ void PlatformLoader::LoadAllPlatformsInManager(std::string dir)
std::shared_ptr<gd::Platform> platform = LoadPlatformInManager("./JsPlatform/GDJS.dll");
#elif defined(LINUX)
std::shared_ptr<gd::Platform> platform = LoadPlatformInManager("./JsPlatform/libGDJS.so");
#elif defined(MACOS)
std::shared_ptr<gd::Platform> platform = LoadPlatformInManager("./JsPlatform/libGDJS.dylib");
#else
#warning Add the appropriate filename here for the Js Platform!
std::shared_ptr<gd::Platform> platform;

View File

@@ -0,0 +1,13 @@
/*
* GDevelop Core
* Copyright 2008-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#include "GDCore/IDE/wxTools/GUIContentScaleFactor.h"
//By default, consider that the screen content is rendered
//normally (no "retina" screen).
double gd::GUIContentScaleFactor::scaleFactor = 1.0;
#endif

View File

@@ -0,0 +1,54 @@
/*
* GDevelop Core
* Copyright 2008-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#ifndef GDCORE_GUICONTENTSCALEFACTOR_H
#define GDCORE_GUICONTENTSCALEFACTOR_H
#include <wx/window.h>
namespace gd
{
/**
* \brief Store the Content Scale Factor, i.e 2 for retina
* screens and 1 for normal screens.
*
* \ingroup IDE
* \ingroup wxTools
*/
class GD_CORE_API GUIContentScaleFactor
{
public:
/**
* \brief Return the scale factor.
*
* The scale is 1 for normal screen, 2 for "retina" ones
* or more.
*/
static double Get()
{
return scaleFactor;
}
/**
* \brief Set the scale factor.
*
* \note Should be called at the initialization of the application
* that is using GDCore (i.e: The IDE).
*/
static void Set(double factor)
{
scaleFactor = factor;
}
private:
static double scaleFactor;
};
}
#endif // GDCORE_GUICONTENTSCALEFACTOR_H
#endif

View File

@@ -0,0 +1,42 @@
/*
* GDevelop Core
* Copyright 2008-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#ifndef GDCORE_SAFEYIELD_H
#define GDCORE_SAFEYIELD_H
#include <wx/utils.h>
namespace gd
{
/**
* \brief Allow to yield the application to prevent it to look
* frozen when doing heavy computations.
*
* \ingroup IDE
* \ingroup wxTools
*/
class GD_CORE_API SafeYield
{
public:
/**
* \brief Launch a yield to prevent the application to appear to be
* frozen.
*/
static void Do(wxWindow *win = NULL, bool onlyIfNeeded = false)
{
#if !defined(MACOS) //wxSafeYield froze the app on MacOS.
wxSafeYield(win, onlyIfNeeded);
#endif
}
private:
};
}
#endif // GDCORE_SAFEYIELD_H
#endif

View File

@@ -0,0 +1,43 @@
/*
* GDevelop Core
* Copyright 2008-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#include <iomanip>
#include "GDCore/Tools/Localization.h"
#include "ShowFolder.h"
#include <wx/utils.h>
#include <wx/log.h>
namespace gd
{
/**
* \brief Open a folder with the file explorer/finder.
*
* \ingroup IDE
* \ingroup wxTools
*/
void GD_CORE_API ShowFolder(wxString path)
{
#if defined(WINDOWS)
wxExecute("explorer.exe \""+path+"\"");
#elif defined(MACOS)
system(std::string("open \""+path+"\"").c_str());
#elif defined(LINUX)
int returnCode = system(std::string("xdg-open \""+path+"\"").c_str());
if (returnCode != 0) {
wxString error = _("Oops, it seems that the folder couldn't be displayed. Open your file explorer and go to:\n\n");
error += path;
wxLogWarning(error);
}
#else
#warning gd::ShowFolder is not available for your system.
#endif
}
}
#endif

View File

@@ -0,0 +1,32 @@
/*
* GDevelop Core
* Copyright 2008-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#ifndef GDCORE_SHOWFOLDER_H
#define GDCORE_SHOWFOLDER_H
#include <iomanip>
#include "GDCore/Tools/Localization.h"
#include <wx/utils.h>
#include <wx/log.h>
namespace gd
{
/**
* \brief Open a folder in the system file explorer.
*
* On Windows, explorer.exe is used.
* On MacOS, "open" is called.
* On Linux, "xdg-open" is called.
*
* \ingroup IDE
* \ingroup wxTools
*/
void GD_CORE_API ShowFolder(wxString path);
}
#endif // GDCORE_SHOWFOLDER_H
#endif

View File

@@ -9,6 +9,7 @@
#include <vector>
#include <string>
#include <memory>
#include <ctime>
#include "GDCore/Events/EventsList.h"
namespace gd { class BaseEvent; }
namespace gd { class Project; }

View File

@@ -262,7 +262,7 @@ public:
*/
///@{
/**
* Set if the input must be disabled when window lost focus.
* Set if the input must be disabled when window lose focus.
*/
void DisableInputWhenFocusIsLost(bool disable = true) { disableInputWhenNotFocused = disable; }

View File

@@ -28,6 +28,7 @@
#include "GDCore/Serialization/Serializer.h"
#include "GDCore/IDE/MetadataProvider.h"
#include "GDCore/IDE/PlatformManager.h"
#include "GDCore/IDE/wxTools/SafeYield.h"
#include "GDCore/CommonTools.h"
#include "GDCore/TinyXml/tinyxml.h"
#include "GDCore/Tools/VersionWrapper.h"
@@ -907,7 +908,7 @@ void Project::ExposeResources(gd::ArbitraryResourceWorker & worker)
worker.ExposeResource(GetResourcesManager().GetResource(resources[i]));
}
#if !defined(GD_NO_WX_GUI)
wxSafeYield();
gd::SafeYield::Do();
#endif
//Add layouts resources
@@ -924,7 +925,7 @@ void Project::ExposeResources(gd::ArbitraryResourceWorker & worker)
LaunchResourceWorkerOnEvents(*this, GetExternalEvents(s).GetEvents(), worker);
}
#if !defined(GD_NO_WX_GUI)
wxSafeYield();
gd::SafeYield::Do();
#endif
//Add global objects resources
@@ -932,7 +933,7 @@ void Project::ExposeResources(gd::ArbitraryResourceWorker & worker)
GetObject(j).ExposeResources(worker);
#if !defined(GD_NO_WX_GUI)
wxSafeYield();
gd::SafeYield::Do();
#endif
}

View File

@@ -7,7 +7,7 @@
#if defined(WINDOWS)
#include <windows.h>
#include "GDCore/CommonTools.h"
#elif defined(LINUX) || defined (MAC)
#elif defined(LINUX) || defined (MACOS)
#include <dlfcn.h>
#endif
#include <string>
@@ -38,7 +38,7 @@ namespace gd
std::string errorMsg = "Error ("+ToString(dw)+"): "+std::string(lpMsgBuf);
return errorMsg;
}
#elif defined(LINUX) || defined (MAC)
#elif defined(LINUX) || defined (MACOS)
Handle OpenLibrary(const char* path) {return dlopen(path, RTLD_LAZY);}
void* GetSymbol(Handle library, const char* name) { return dlsym(library, name);}
void CloseLibrary(Handle library) {dlclose(library);}

View File

@@ -14,7 +14,7 @@
typedef HINSTANCE__* HINSTANCE;
#endif
typedef HINSTANCE Handle;
#elif defined(LINUX) || defined (MAC)
#elif defined(LINUX) || defined (MACOS)
typedef void* Handle;
#else
#warning system not supported for dynamic libraries loading
@@ -49,7 +49,7 @@ void GD_CORE_API CloseLibrary(Handle library);
*/
std::string GD_CORE_API DynamicLibraryLastError();
#if defined(LINUX) || defined (MAC)
#if defined(LINUX) || defined (MACOS)
/**
* \brief Set all symbols from a raw C++ dynamic library available ( RTLD_GLOBAL )
*

View File

@@ -4,6 +4,7 @@
* This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
#include <locale.h>
#include "GDCore/Tools/Locale/LocaleManager.h"
#include "GDCore/Tools/Log.h"

View File

@@ -24,24 +24,26 @@ IF(NOT NO_GUI)
ENDIF()
ELSE()
#Use wx-config on *nix:
find_package(PkgConfig REQUIRED)
find_package(wxWidgets REQUIRED)
EXEC_PROGRAM(${wxWidgets_CONFIG_EXECUTABLE} ARGS --query-toolkit OUTPUT_VARIABLE WXWIDGETS_GTK_VERSION)
IF(${WXWIDGETS_GTK_VERSION} MATCHES "gtk2")
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
set(GTK_INCLUDE_DIRS "${GTK2_INCLUDE_DIRS}" PARENT_SCOPE)
set(GTK_LIBRARY_DIRS "${GTK2_LIBRARY_DIRS}" PARENT_SCOPE)
set(GTK_CFLAGS_OTHER "${GTK2_CFLAGS_OTHER}" PARENT_SCOPE)
ELSEIF(${WXWIDGETS_GTK_VERSION} MATCHES "gtk3")
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
set(GTK_INCLUDE_DIRS "${GTK3_INCLUDE_DIRS}" PARENT_SCOPE)
set(GTK_LIBRARY_DIRS "${GTK3_LIBRARY_DIRS}" PARENT_SCOPE)
set(GTK_CFLAGS_OTHER "${GTK3_CFLAGS_OTHER}" PARENT_SCOPE)
ELSE()
message(WARNING "Unable to identify the GTK+ version used by wxWidgets")
set(GTK_INCLUDE_DIRS "" PARENT_SCOPE)
set(GTK_LIBRARY_DIRS "" PARENT_SCOPE)
set(GTK_CFLAGS_OTHER "" PARENT_SCOPE)
IF (NOT APPLE)
find_package(PkgConfig REQUIRED)
EXEC_PROGRAM(${wxWidgets_CONFIG_EXECUTABLE} ARGS --query-toolkit OUTPUT_VARIABLE WXWIDGETS_GTK_VERSION)
IF(${WXWIDGETS_GTK_VERSION} MATCHES "gtk2")
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
set(GTK_INCLUDE_DIRS "${GTK2_INCLUDE_DIRS}" PARENT_SCOPE)
set(GTK_LIBRARY_DIRS "${GTK2_LIBRARY_DIRS}" PARENT_SCOPE)
set(GTK_CFLAGS_OTHER "${GTK2_CFLAGS_OTHER}" PARENT_SCOPE)
ELSEIF(${WXWIDGETS_GTK_VERSION} MATCHES "gtk3")
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
set(GTK_INCLUDE_DIRS "${GTK3_INCLUDE_DIRS}" PARENT_SCOPE)
set(GTK_LIBRARY_DIRS "${GTK3_LIBRARY_DIRS}" PARENT_SCOPE)
set(GTK_CFLAGS_OTHER "${GTK3_CFLAGS_OTHER}" PARENT_SCOPE)
ELSE()
message(WARNING "Unable to identify the GTK+ version used by wxWidgets")
set(GTK_INCLUDE_DIRS "" PARENT_SCOPE)
set(GTK_LIBRARY_DIRS "" PARENT_SCOPE)
set(GTK_CFLAGS_OTHER "" PARENT_SCOPE)
ENDIF()
ENDIF()
ENDIF()
ENDIF()

View File

@@ -88,7 +88,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -120,8 +124,8 @@ IF(WIN32)
set_target_properties(AES PROPERTIES SUFFIX ".xgdwe")
set_target_properties(AES_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(AES PROPERTIES SUFFIX ".xgdle")
set_target_properties(AES_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(AES PROPERTIES SUFFIX ".xgde")
set_target_properties(AES_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(AES_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "AES")

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(AdvancedXML PROPERTIES SUFFIX ".xgdwe")
set_target_properties(AdvancedXML_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(AdvancedXML PROPERTIES SUFFIX ".xgdle")
set_target_properties(AdvancedXML_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(AdvancedXML PROPERTIES SUFFIX ".xgde")
set_target_properties(AdvancedXML_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(AdvancedXML_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "AdvancedXML")

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(Box3DObject PROPERTIES SUFFIX ".xgdwe")
set_target_properties(Box3DObject_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(Box3DObject PROPERTIES SUFFIX ".xgdle")
set_target_properties(Box3DObject_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(Box3DObject PROPERTIES SUFFIX ".xgde")
set_target_properties(Box3DObject_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(Box3DObject_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "Box3DObject")

View File

@@ -16,7 +16,9 @@ IF (NOT EMSCRIPTEN) #Only add some extensions when compiling with emscripten.
ADD_SUBDIRECTORY(AdvancedXML)
ADD_SUBDIRECTORY(AES)
ADD_SUBDIRECTORY(Box3DObject)
ADD_SUBDIRECTORY(CommonDialogs)
IF (NOT APPLE)
ADD_SUBDIRECTORY(CommonDialogs)
ENDIF()
ENDIF()
ADD_SUBDIRECTORY(DestroyOutsideAutomatism)
ADD_SUBDIRECTORY(DraggableAutomatism)

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -124,8 +128,8 @@ IF(WIN32)
set_target_properties(CommonDialogs PROPERTIES SUFFIX ".xgdwe")
set_target_properties(CommonDialogs_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(CommonDialogs PROPERTIES SUFFIX ".xgdle")
set_target_properties(CommonDialogs_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(CommonDialogs PROPERTIES SUFFIX ".xgde")
set_target_properties(CommonDialogs_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(CommonDialogs_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "CommonDialogs")

View File

@@ -24,7 +24,7 @@ This project is released under the MIT License.
#endif
//Linux build uses dlib for dialogs
#if defined(LINUX) || defined(MAC)
#if defined(LINUX) || defined(MACOS)
#include "nwidgets/MessageBox.h"
#include "nwidgets/YesNoMsgBox.h"
#include "nwidgets/OpenFile.h"
@@ -49,7 +49,7 @@ void GD_EXTENSION_API ShowMessageBox( RuntimeScene & scene, const std::string &
#if defined(WINDOWS)
MessageBox(NULL, message.c_str(), title.c_str(), MB_ICONINFORMATION);
#endif
#if defined(LINUX) || defined(MAC)
#if defined(LINUX) || defined(MACOS)
nw::MsgBox msgBox(title, message);
msgBox.wait_until_closed();
#endif
@@ -88,7 +88,7 @@ void GD_EXTENSION_API ShowOpenFile( RuntimeScene & scene, gd::Variable & variabl
if(GetOpenFileName(&toGetFileName) == TRUE)
result = filePath;
#endif
#if defined(LINUX) || defined(MAC)
#if defined(LINUX) || defined(MACOS)
nw::OpenFile * dialog = new nw::OpenFile(title, true, result);
dialog->wait_until_closed();
#endif
@@ -115,7 +115,7 @@ void GD_EXTENSION_API ShowYesNoMsgBox( RuntimeScene & scene, gd::Variable & vari
else
result = "no";
#endif
#if defined(LINUX) || defined(MAC)
#if defined(LINUX) || defined(MACOS)
nw::YesNoMsgBox dialog(title, message, result);
dialog.wait_until_closed();
#endif
@@ -431,7 +431,7 @@ bool GD_EXTENSION_API ShowTextInput( RuntimeScene & scene, gd::Variable & variab
if (ibox.DoModal(title.c_str(), message.c_str()))
result = ibox.Text;
#endif
#if defined(LINUX) || defined(MAC)
#if defined(LINUX) || defined(MACOS)
nw::TextInput dialog(title, message, result);
dialog.wait_until_closed();
#endif

View File

@@ -94,7 +94,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -130,8 +134,8 @@ IF(WIN32)
ELSEIF(EMSCRIPTEN)
set_target_properties(DestroyOutsideAutomatism PROPERTIES SUFFIX ".bc")
ELSE()
set_target_properties(DestroyOutsideAutomatism PROPERTIES SUFFIX ".xgdle")
set_target_properties(DestroyOutsideAutomatism_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(DestroyOutsideAutomatism PROPERTIES SUFFIX ".xgde")
set_target_properties(DestroyOutsideAutomatism_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
#Linker files for the IDE extension

View File

@@ -94,7 +94,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -130,8 +134,8 @@ IF(WIN32)
ELSEIF(EMSCRIPTEN)
set_target_properties(DraggableAutomatism PROPERTIES SUFFIX ".bc")
ELSE()
set_target_properties(DraggableAutomatism PROPERTIES SUFFIX ".xgdle")
set_target_properties(DraggableAutomatism_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(DraggableAutomatism PROPERTIES SUFFIX ".xgde")
set_target_properties(DraggableAutomatism_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
#Linker files for the IDE extension

View File

@@ -28,14 +28,14 @@ DraggableAutomatism::DraggableAutomatism() :
void DraggableAutomatism::DoStepPreEvents(RuntimeScene & scene)
{
//Begin drag ?
if ( !dragged && sf::Mouse::isButtonPressed(sf::Mouse::Left) &&
if ( !dragged && scene.GetInputManager().IsMouseButtonPressed("Left") &&
!leftPressedLastFrame && !somethingDragged )
{
RuntimeLayer & theLayer = scene.GetRuntimeLayer(object->GetLayer());
for (unsigned int cameraIndex = 0;cameraIndex < theLayer.GetCameraCount();++cameraIndex)
{
sf::Vector2f mousePos = scene.renderWindow->mapPixelToCoords(sf::Mouse::getPosition(*scene.renderWindow),
theLayer.GetCamera(cameraIndex).GetSFMLView());
sf::Vector2f mousePos = scene.renderWindow->mapPixelToCoords(
scene.GetInputManager().GetMousePosition(), theLayer.GetCamera(cameraIndex).GetSFMLView());
if ( object->GetDrawableX() <= mousePos.x
&& object->GetDrawableX() + object->GetWidth() >= mousePos.x
@@ -52,7 +52,7 @@ void DraggableAutomatism::DoStepPreEvents(RuntimeScene & scene)
}
}
//End dragging ?
else if ( !sf::Mouse::isButtonPressed(sf::Mouse::Left) ) {
else if ( !scene.GetInputManager().IsMouseButtonPressed("Left") ) {
dragged = false;
somethingDragged = false;
}
@@ -60,8 +60,8 @@ void DraggableAutomatism::DoStepPreEvents(RuntimeScene & scene)
//Being dragging ?
if ( dragged ) {
RuntimeLayer & theLayer = scene.GetRuntimeLayer(object->GetLayer());
sf::Vector2f mousePos = scene.renderWindow->mapPixelToCoords(sf::Mouse::getPosition(*scene.renderWindow),
theLayer.GetCamera(dragCameraIndex).GetSFMLView());
sf::Vector2f mousePos = scene.renderWindow->mapPixelToCoords(
scene.GetInputManager().GetMousePosition(), theLayer.GetCamera(dragCameraIndex).GetSFMLView());
object->SetX(mousePos.x-xOffset);
object->SetY(mousePos.y-yOffset);
@@ -71,7 +71,7 @@ void DraggableAutomatism::DoStepPreEvents(RuntimeScene & scene)
void DraggableAutomatism::DoStepPostEvents(RuntimeScene & scene)
{
leftPressedLastFrame = sf::Mouse::isButtonPressed(sf::Mouse::Left);
leftPressedLastFrame = scene.GetInputManager().IsMouseButtonPressed("Left");
}
void DraggableAutomatism::OnDeActivate()

View File

@@ -15,6 +15,9 @@ gdjs.DraggableRuntimeAutomatism = function(runtimeScene, automatismData, owner)
gdjs.RuntimeAutomatism.call(this, runtimeScene, automatismData, owner);
this._dragged = false;
this._touchId = null;
this._mouse = false;
this._xOffset = 0;
this._yOffset = 0;
};
@@ -23,59 +26,116 @@ gdjs.DraggableRuntimeAutomatism.prototype = Object.create( gdjs.RuntimeAutomatis
gdjs.DraggableRuntimeAutomatism.thisIsARuntimeAutomatismConstructor = "DraggableAutomatism::Draggable";
gdjs.DraggableRuntimeAutomatism.prototype.onDeActivate = function() {
if ( this._dragged ) gdjs.DraggableRuntimeAutomatism.draggingSomething = false;
this._dragged = false;
this._endDrag();
};
gdjs.DraggableRuntimeAutomatism.prototype.doStepPreEvents = function(runtimeScene) {
var mousePos = null;
gdjs.DraggableRuntimeAutomatism.prototype._endDrag = function() {
if ( this._dragged && this._mouse ) gdjs.DraggableRuntimeAutomatism.mouseDraggingSomething = false;
if ( this._dragged && this._touchId !== null ) gdjs.DraggableRuntimeAutomatism.touchDraggingSomething[this._touchId] = false;
//Begin drag ?
if ( !this._dragged && runtimeScene.getGame().isMouseButtonPressed(0) &&
this._dragged = false;
this._mouse = false;
this._touchId = null;
}
gdjs.DraggableRuntimeAutomatism.prototype._tryBeginDrag = function(runtimeScene) {
if (this._dragged) return false;
var inputManager = runtimeScene.getGame().getInputManager();
//Try mouse
if (inputManager.isMouseButtonPressed(0) &&
!gdjs.DraggableRuntimeAutomatism.leftPressedLastFrame &&
!gdjs.DraggableRuntimeAutomatism.draggingSomething ) {
!gdjs.DraggableRuntimeAutomatism.mouseDraggingSomething) {
mousePos = runtimeScene.getLayer(this.owner.getLayer()).convertCoords(
runtimeScene.getGame().getMouseX(),
runtimeScene.getGame().getMouseY());
if (this.owner.getDrawableX() <= mousePos[0]
&& this.owner.getDrawableX() + this.owner.getWidth() >= mousePos[0]
&& this.owner.getDrawableY() <= mousePos[1]
&& this.owner.getDrawableY() + this.owner.getHeight() >= mousePos[1] ) {
mousePos = runtimeScene.getLayer(this.owner.getLayer()).convertCoords(
runtimeScene.getGame().getMouseX(),
runtimeScene.getGame().getMouseY());
inputManager.getMouseX(),
inputManager.getMouseY());
if (this.owner.insideObject(mousePos[0], mousePos[1])) {
this._dragged = true;
gdjs.DraggableRuntimeAutomatism.draggingSomething = true;
this._mouse = true;
this._xOffset = mousePos[0] - this.owner.getX();
this._yOffset = mousePos[1] - this.owner.getY();
gdjs.DraggableRuntimeAutomatism.mouseDraggingSomething = true;
return true;
}
} else { //Try touches
var touchIds = inputManager.getStartedTouchIdentifiers();
for(var i = 0;i<touchIds.length;++i) {
if (gdjs.DraggableRuntimeAutomatism.touchDraggingSomething[touchIds[i]])
continue;
touchPos = runtimeScene.getLayer(this.owner.getLayer()).convertCoords(
inputManager.getTouchX(touchIds[i]),
inputManager.getTouchY(touchIds[i]));
if (this.owner.insideObject(touchPos[0], touchPos[1])) {
this._dragged = true;
this._touchId = touchIds[i];
this._xOffset = touchPos[0] - this.owner.getX();
this._yOffset = touchPos[1] - this.owner.getY();
gdjs.DraggableRuntimeAutomatism.touchDraggingSomething[touchIds[i]] = true;
return true;
}
}
}
//End dragging ?
else if ( !runtimeScene.getGame().isMouseButtonPressed(0) ) {
this._dragged = false;
gdjs.DraggableRuntimeAutomatism.draggingSomething = false;
}
//Being dragging ?
if ( this._dragged ) {
if ( mousePos === null ) {
mousePos = runtimeScene.getLayer(this.owner.getLayer()).convertCoords(
runtimeScene.getGame().getMouseX(),
runtimeScene.getGame().getMouseY());
}
return false;
}
gdjs.DraggableRuntimeAutomatism.prototype._shouldEndDrag = function(runtimeScene) {
if (!this._dragged) return false;
var inputManager = runtimeScene.getGame().getInputManager();
if (this._mouse)
return !inputManager.isMouseButtonPressed(0);
else if (this._touchId !== null) {
return inputManager.getAllTouchIdentifiers().indexOf(this._touchId) === -1;
}
return false;
}
gdjs.DraggableRuntimeAutomatism.prototype._updateObjectPosition = function(runtimeScene) {
if (!this._dragged) return false;
var inputManager = runtimeScene.getGame().getInputManager();
if (this._mouse) {
mousePos = runtimeScene.getLayer(this.owner.getLayer()).convertCoords(
inputManager.getMouseX(),
inputManager.getMouseY());
this.owner.setX(mousePos[0] - this._xOffset);
this.owner.setY(mousePos[1] - this._yOffset);
}
else if (this._touchId !== null) {
touchPos = runtimeScene.getLayer(this.owner.getLayer()).convertCoords(
inputManager.getTouchX(this._touchId),
inputManager.getTouchY(this._touchId));
this.owner.setX(touchPos[0] - this._xOffset);
this.owner.setY(touchPos[1] - this._yOffset);
}
return true;
}
gdjs.DraggableRuntimeAutomatism.prototype.doStepPreEvents = function(runtimeScene) {
this._tryBeginDrag(runtimeScene);
if (this._shouldEndDrag(runtimeScene)) {
this._endDrag();
}
this._updateObjectPosition(runtimeScene);
};
gdjs.DraggableRuntimeAutomatism.prototype.doStepPostEvents = function(runtimeScene) {
gdjs.DraggableRuntimeAutomatism.leftPressedLastFrame =
runtimeScene.getGame().isMouseButtonPressed(0);
runtimeScene.getGame().getInputManager().isMouseButtonPressed(0);
};
gdjs.DraggableRuntimeAutomatism.prototype.isDragged = function(runtimeScene) {
@@ -83,7 +143,10 @@ gdjs.DraggableRuntimeAutomatism.prototype.isDragged = function(runtimeScene) {
};
//Static property used to avoid start dragging an object while another is dragged.
gdjs.DraggableRuntimeAutomatism.draggingSomething = false;
gdjs.DraggableRuntimeAutomatism.mouseDraggingSomething = false;
//Static property used to avoid start dragging an object while another is dragged by the same touch.
gdjs.DraggableRuntimeAutomatism.touchDraggingSomething = [];
//Static property used to only start dragging when clicking.
gdjs.DraggableRuntimeAutomatism.leftPressedLastFrame = false;

View File

@@ -0,0 +1,119 @@
describe('gdjs.DraggableRuntimeAutomatism', function() {
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
var runtimeScene = new gdjs.RuntimeScene(runtimeGame, null);
runtimeScene.loadFromScene({
layers:[{name:"", visibility: true}],
variables: [],
automatismsSharedData: [],
objects: [],
instances: []
});
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", automatisms: [{type: "DraggableAutomatism::Draggable"}]});
var object2 = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", automatisms: [{type: "DraggableAutomatism::Draggable"}]});
runtimeScene.addObject(object);
runtimeScene.addObject(object2);
it('should handle mouse', function() {
object.setPosition(450, 500);
//Drag'n'drop
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onMouseMove(450, 500);
runtimeGame.getInputManager().onMouseButtonPressed(0);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onMouseMove(750, 600);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onMouseButtonReleased(0);
runtimeScene.renderAndStep();
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(600);
//Mouse move with dragging
runtimeGame.getInputManager().onMouseMove(600, 600);
runtimeScene.renderAndStep();
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(600);
//Start dragging again
runtimeGame.getInputManager().onMouseMove(750, 600);
runtimeGame.getInputManager().onMouseButtonPressed(0);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onMouseMove(850, 700);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onMouseButtonReleased(0);
runtimeScene.renderAndStep();
expect(object.getX()).to.be(850);
expect(object.getY()).to.be(700);
});
it('should handle touches', function() {
runtimeGame.getInputManager().touchSimulateMouse(false);
object.setPosition(450, 500);
//Drag'n'drop
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onTouchStart(1, 10, 20);
runtimeGame.getInputManager().onTouchStart(0, 450, 500);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchMove(0, 750, 600);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchEnd(0);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onFrameEnded();
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(600);
//Move another unrelated touch
runtimeGame.getInputManager().onTouchMove(1, 750, 600);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onTouchMove(1, 850, 700);
runtimeScene.renderAndStep();
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(600);
//Start drag'n'drop with another touch
runtimeGame.getInputManager().onTouchEnd(1);
runtimeGame.getInputManager().onFrameEnded();
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onTouchStart(1, 750, 600);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onTouchMove(1, 850, 700);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onTouchEnd(1);
runtimeGame.getInputManager().onFrameEnded();
expect(object.getX()).to.be(850);
expect(object.getY()).to.be(700);
});
it('should handle multitouch', function() {
runtimeGame.getInputManager().touchSimulateMouse(false);
object.setPosition(450, 500);
object2.setPosition(650, 600);
//Drag'n'drop
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onTouchStart(2, 450, 500);
runtimeGame.getInputManager().onTouchStart(1, 650, 600);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchMove(2, 750, 700);
runtimeGame.getInputManager().onTouchMove(1, 100, 200);
runtimeScene.renderAndStep();
runtimeGame.getInputManager().onFrameEnded();
runtimeGame.getInputManager().onTouchEnd(2);
expect(object.getX()).to.be(750);
expect(object.getY()).to.be(700);
expect(object2.getX()).to.be(100);
expect(object2.getY()).to.be(200);
});
});

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(Function PROPERTIES SUFFIX ".xgdwe")
set_target_properties(Function_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(Function PROPERTIES SUFFIX ".xgdle")
set_target_properties(Function_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(Function PROPERTIES SUFFIX ".xgde")
set_target_properties(Function_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(Function_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "Function")

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(Light PROPERTIES SUFFIX ".xgdwe")
set_target_properties(Light_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(Light PROPERTIES SUFFIX ".xgdle")
set_target_properties(Light_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(Light PROPERTIES SUFFIX ".xgde")
set_target_properties(Light_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(Light_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "Light")

View File

@@ -83,7 +83,7 @@ public:
obj.AddAction("Radius",
_("Radius"),
_("Modify the radius of a liht"),
_("Modify the radius of a light"),
_("Do _PARAM1__PARAM2_ to radius of _PARAM0_"),
_("Setup"),
"CppPlatform/Extensions/lightIcon24.png",

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(LinkedObjects PROPERTIES SUFFIX ".xgdwe")
set_target_properties(LinkedObjects_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(LinkedObjects PROPERTIES SUFFIX ".xgdle")
set_target_properties(LinkedObjects_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(LinkedObjects PROPERTIES SUFFIX ".xgde")
set_target_properties(LinkedObjects_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(LinkedObjects_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "LinkedObjects")
@@ -166,5 +170,7 @@ if(BUILD_TESTS)
target_link_libraries(LinkedObjects_Runtime_tests GDCpp_Runtime)
target_link_libraries(LinkedObjects_Runtime_tests LinkedObjects_Runtime)
target_link_libraries(LinkedObjects_Runtime_tests sfml-audio sfml-graphics sfml-window sfml-network sfml-system)
target_link_libraries(LinkedObjects_Runtime_tests GLU GL)
IF (NOT APPLE)
target_link_libraries(LinkedObjects_Runtime_tests GLU GL)
ENDIF()
endif()

View File

@@ -81,7 +81,7 @@ public:
"CppPlatform/Extensions/LinkedObjectsicon16.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectList", "Pick these objects...")
.AddParameter("objectList", _("Pick these objects..."))
.AddParameter("objectPtr", _("...if they are linked to this object"))
.codeExtraInformation.SetFunctionName("GDpriv::LinkedObjects::PickObjectsLinkedTo").SetIncludeFile("LinkedObjects/LinkedObjectsTools.h");
@@ -96,7 +96,7 @@ public:
"CppPlatform/Extensions/LinkedObjectsicon16.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectList", "Pick these objects...")
.AddParameter("objectList", _("Pick these objects..."))
.AddParameter("objectPtr", _("...if they are linked to this object"))
.codeExtraInformation.SetFunctionName("GDpriv::LinkedObjects::PickObjectsLinkedTo").SetIncludeFile("LinkedObjects/LinkedObjectsTools.h");

View File

@@ -12,6 +12,7 @@ This project is released under the MIT License.
#include <memory>
#include "GDCpp/RuntimeObject.h"
#include "GDCpp/RuntimeScene.h"
#include "GDCpp/ObjectsListsTools.h"
#include "ObjectsLinksManager.h"
using namespace std;
@@ -28,58 +29,11 @@ bool GD_EXTENSION_API PickObjectsLinkedTo(RuntimeScene & scene,
RuntimeObject * object)
{
if (!object) return false;
bool isTrue = false;
//Create a boolean for each object
std::vector < std::vector<bool> > pickedList;
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it = pickedObjectsLists.begin();
it != pickedObjectsLists.end();++it)
{
std::vector<bool> arr;
arr.assign(it->second->size(), false);
pickedList.push_back(arr);
}
//Pick objects which are linked to the object
unsigned int i = 0;
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it = pickedObjectsLists.begin();
it != pickedObjectsLists.end();++it, ++i)
{
if ( !it->second ) continue;
const std::vector<RuntimeObject*> & arr1 = *it->second;
std::vector<RuntimeObject*> linkedObjects = ObjectsLinksManager::managers[&scene].GetObjectsLinkedWith(object);
for(unsigned int k = 0;k<arr1.size();++k)
{
if ( std::find(linkedObjects.begin(), linkedObjects.end(), arr1[k]) != linkedObjects.end()) {
pickedList[i][k] = true;
isTrue = true;
}
}
}
//Trim not picked objects from arrays.
i = 0;
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it = pickedObjectsLists.begin();
it != pickedObjectsLists.end();++it, ++i)
{
size_t finalSize = 0;
if ( !it->second ) continue;
std::vector<RuntimeObject*> & arr = *it->second;
for(unsigned int k = 0;k<arr.size();++k)
{
RuntimeObject * obj = arr[k];
if ( pickedList[i][k] )
{
arr[finalSize] = obj;
finalSize++;
}
}
arr.resize(finalSize);
}
return isTrue;
std::vector<RuntimeObject*> linkedObjects = ObjectsLinksManager::managers[&scene].GetObjectsLinkedWith(object);
return PickObjectsIf(pickedObjectsLists, false, [&linkedObjects](RuntimeObject * obj) {
return std::find(linkedObjects.begin(), linkedObjects.end(), obj) != linkedObjects.end();
});
}
void GD_EXTENSION_API LinkObjects(RuntimeScene & scene, RuntimeObject * a, RuntimeObject * b)

View File

@@ -97,46 +97,11 @@ gdjs.evtTools.linkedObjects.removeAllLinksOf = function(runtimeScene, objA) {
};
gdjs.evtTools.linkedObjects.pickObjectsLinkedTo = function(runtimeScene, objectsLists, obj) {
if (obj === null) return false;
var isTrue = false;
var objectsValues = objectsLists.values();
for(var i = 0, leni = objectsValues.length;i<leni;++i) {
var arr = objectsValues[i];
for(var k = 0, lenk = arr.length;k<lenk;++k) {
arr[k].pick = false;
}
}
//Pick only linked objects
var linkedObjects =
gdjs.evtTools.linkedObjects.managers.get(runtimeScene.getName()).getObjectsLinkedWith(obj);
for(var i = 0, leni = objectsValues.length;i<leni;++i) {
var arr = objectsValues[i];
for(var k = 0, lenk = arr.length;k<lenk;++k) {
if ( linkedObjects.indexOf(arr[k]) !== -1 ) { //The current object is linked to obj.
isTrue = true;
arr[k].pick = true; //Pick the objects
}
}
}
//Trim not picked objects from arrays.
for(var i = 0, leni = objectsValues.length;i<leni;++i) {
var arr = objectsValues[i];
var finalSize = 0;
for(var k = 0, lenk = arr.length;k<lenk;++k) {
var obj = arr[k];
if ( arr[k].pick ) {
arr[finalSize] = obj;
finalSize++;
}
}
arr.length = finalSize;
}
return isTrue;
return gdjs.evtTools.object.PickObjectsIf(function(obj) {
return linkedObjects.indexOf(obj) !== -1;
}, objectsLists, false);
};

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(Network PROPERTIES SUFFIX ".xgdwe")
set_target_properties(Network_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(Network PROPERTIES SUFFIX ".xgdle")
set_target_properties(Network_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(Network PROPERTIES SUFFIX ".xgde")
set_target_properties(Network_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(Network_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "Network")

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(PanelSpriteObject PROPERTIES SUFFIX ".xgdwe")
set_target_properties(PanelSpriteObject_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(PanelSpriteObject PROPERTIES SUFFIX ".xgdle")
set_target_properties(PanelSpriteObject_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(PanelSpriteObject PROPERTIES SUFFIX ".xgde")
set_target_properties(PanelSpriteObject_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(PanelSpriteObject_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "PanelSpriteObject")

View File

@@ -88,7 +88,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -120,8 +124,8 @@ IF(WIN32)
set_target_properties(ParticleSystem PROPERTIES SUFFIX ".xgdwe")
set_target_properties(ParticleSystem_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(ParticleSystem PROPERTIES SUFFIX ".xgdle")
set_target_properties(ParticleSystem_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(ParticleSystem PROPERTIES SUFFIX ".xgde")
set_target_properties(ParticleSystem_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(ParticleSystem_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "ParticleSystem")

View File

@@ -702,7 +702,7 @@ object(object_)
FlexGridSizer32->Add(StaticBoxSizer2, 1, wxALL|wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL, 5);
StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, Core, _("Miscellaneous"));
FlexGridSizer30 = new wxFlexGridSizer(0, 3, 0, 0);
destroyWhenNoParticlesCheck = new wxCheckBox(Core, ID_CHECKBOX2, _("Destroy the object when no more particles are spayed"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
destroyWhenNoParticlesCheck = new wxCheckBox(Core, ID_CHECKBOX2, _("Destroy the object when no more particles are sprayed"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
destroyWhenNoParticlesCheck->SetValue(false);
FlexGridSizer30->Add(destroyWhenNoParticlesCheck, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer1->Add(FlexGridSizer30, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);

View File

@@ -294,7 +294,7 @@ namespace SPK
int nb = (*it)->updateNumber(deltaTime);
if (nb > 0)
{
EmitterData data = {*it,nb};
EmitterData data = {*it,static_cast<unsigned int>(nb)};
activeEmitters.push_back(data);
nbAutoBorn += nb;
}

View File

@@ -1590,7 +1590,7 @@
<cols>3</cols>
<object class="sizeritem">
<object class="wxCheckBox" name="ID_CHECKBOX2" variable="destroyWhenNoParticlesCheck" member="yes">
<label>Destroy the object when no more particles are spayed</label>
<label>Destroy the object when no more particles are sprayed</label>
</object>
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(PathAutomatism PROPERTIES SUFFIX ".xgdwe")
set_target_properties(PathAutomatism_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(PathAutomatism PROPERTIES SUFFIX ".xgdle")
set_target_properties(PathAutomatism_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(PathAutomatism PROPERTIES SUFFIX ".xgde")
set_target_properties(PathAutomatism_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(PathAutomatism_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "PathAutomatism")

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(PathfindingAutomatism PROPERTIES SUFFIX ".xgdwe")
set_target_properties(PathfindingAutomatism_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(PathfindingAutomatism PROPERTIES SUFFIX ".xgdle")
set_target_properties(PathfindingAutomatism_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(PathfindingAutomatism PROPERTIES SUFFIX ".xgde")
set_target_properties(PathfindingAutomatism_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(PathfindingAutomatism_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "PathfindingAutomatism")

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -120,8 +124,8 @@ IF(WIN32)
set_target_properties(PhysicsAutomatism PROPERTIES SUFFIX ".xgdwe")
set_target_properties(PhysicsAutomatism_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(PhysicsAutomatism PROPERTIES SUFFIX ".xgdle")
set_target_properties(PhysicsAutomatism_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(PhysicsAutomatism PROPERTIES SUFFIX ".xgde")
set_target_properties(PhysicsAutomatism_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(PhysicsAutomatism_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "PhysicsAutomatism")

View File

@@ -94,7 +94,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -130,8 +134,8 @@ IF(WIN32)
ELSEIF(EMSCRIPTEN)
set_target_properties(PlatformAutomatism PROPERTIES SUFFIX ".bc")
ELSE()
set_target_properties(PlatformAutomatism PROPERTIES SUFFIX ".xgdle")
set_target_properties(PlatformAutomatism_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(PlatformAutomatism PROPERTIES SUFFIX ".xgde")
set_target_properties(PlatformAutomatism_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
#Linker files for the IDE extension

View File

@@ -97,8 +97,8 @@ void PlatformerObjectAutomatism::DoStepPreEvents(RuntimeScene & scene)
double requestedDeltaY = 0;
//Change the speed according to the player's input.
leftKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed( sf::Keyboard::Left );
rightKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed( sf::Keyboard::Right );
leftKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Left");
rightKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Right");
if ( leftKey )
currentSpeed -= acceleration*timeDelta;
if ( rightKey )
@@ -186,7 +186,7 @@ void PlatformerObjectAutomatism::DoStepPreEvents(RuntimeScene & scene)
//2) Y axis:
//Go on a ladder
ladderKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed(sf::Keyboard::Up);
ladderKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Up");
if (ladderKey && IsOverlappingLadder(potentialObjects))
{
canJump = true;
@@ -199,8 +199,8 @@ void PlatformerObjectAutomatism::DoStepPreEvents(RuntimeScene & scene)
if ( isOnLadder )
{
upKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed(sf::Keyboard::Up);
downKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed(sf::Keyboard::Down);
upKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Up");
downKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Down");
if ( upKey )
requestedDeltaY -= 150*timeDelta;
if ( downKey )
@@ -224,7 +224,9 @@ void PlatformerObjectAutomatism::DoStepPreEvents(RuntimeScene & scene)
}
//Jumping
jumpKey |= !ignoreDefaultControls && (sf::Keyboard::isKeyPressed( sf::Keyboard::LShift ) || sf::Keyboard::isKeyPressed( sf::Keyboard::RShift ) );
jumpKey |= !ignoreDefaultControls &&
(scene.GetInputManager().IsKeyPressed("LShift") || scene.GetInputManager().IsKeyPressed("RShift") ||
scene.GetInputManager().IsKeyPressed("Space"));
if ( canJump && jumpKey )
{
jumping = true;

View File

@@ -60,6 +60,7 @@ gdjs.PlatformerObjectRuntimeAutomatism.prototype.doStepPreEvents = function(runt
var RIGHTKEY = 39;
var DOWNKEY = 40;
var SHIFTKEY = 16;
var SPACEKEY = 32;
var object = this.owner;
var timeDelta = runtimeScene.getElapsedTime()/1000;
@@ -68,8 +69,8 @@ gdjs.PlatformerObjectRuntimeAutomatism.prototype.doStepPreEvents = function(runt
var requestedDeltaY = 0;
//Change the speed according to the player's input.
this._leftKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(LEFTKEY);
this._rightKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(RIGHTKEY);
this._leftKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(LEFTKEY);
this._rightKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(RIGHTKEY);
if ( this._leftKey ) this._currentSpeed -= this._acceleration*timeDelta;
if ( this._rightKey ) this._currentSpeed += this._acceleration*timeDelta;
@@ -149,7 +150,7 @@ gdjs.PlatformerObjectRuntimeAutomatism.prototype.doStepPreEvents = function(runt
//2) Y axis:
//Go on a ladder
this._ladderKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(UPKEY);
this._ladderKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(UPKEY);
if (this._ladderKey && this._isOverlappingLadder()) {
this._canJump = true;
this._isOnFloor = false;
@@ -160,8 +161,8 @@ gdjs.PlatformerObjectRuntimeAutomatism.prototype.doStepPreEvents = function(runt
}
if ( this._isOnLadder ) {
this._upKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(UPKEY);
this._downKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(DOWNKEY);
this._upKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(UPKEY);
this._downKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(DOWNKEY);
if ( this._upKey )
requestedDeltaY -= 150*timeDelta;
if ( this._downKey )
@@ -183,7 +184,9 @@ gdjs.PlatformerObjectRuntimeAutomatism.prototype.doStepPreEvents = function(runt
}
//Jumping
this._jumpKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(SHIFTKEY);
this._jumpKey |= !this._ignoreDefaultControls &&
(runtimeScene.getGame().getInputManager().isKeyPressed(SHIFTKEY) ||
runtimeScene.getGame().getInputManager().isKeyPressed(SPACEKEY));
if ( this._canJump && this._jumpKey ) {
this._jumping = true;
this._canJump = false;

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(PrimitiveDrawing PROPERTIES SUFFIX ".xgdwe")
set_target_properties(PrimitiveDrawing_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(PrimitiveDrawing PROPERTIES SUFFIX ".xgdle")
set_target_properties(PrimitiveDrawing_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(PrimitiveDrawing PROPERTIES SUFFIX ".xgde")
set_target_properties(PrimitiveDrawing_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(PrimitiveDrawing_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "PrimitiveDrawing")

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(SoundObject PROPERTIES SUFFIX ".xgdwe")
set_target_properties(SoundObject_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(SoundObject PROPERTIES SUFFIX ".xgdle")
set_target_properties(SoundObject_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(SoundObject PROPERTIES SUFFIX ".xgde")
set_target_properties(SoundObject_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(SoundObject_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "SoundObject")

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(TextEntryObject PROPERTIES SUFFIX ".xgdwe")
set_target_properties(TextEntryObject_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(TextEntryObject PROPERTIES SUFFIX ".xgdle")
set_target_properties(TextEntryObject_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(TextEntryObject PROPERTIES SUFFIX ".xgde")
set_target_properties(TextEntryObject_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(TextEntryObject_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "TextEntryObject")

View File

@@ -48,19 +48,16 @@ void RuntimeTextEntryObject::UpdateTime(float)
if (!activated || scene == NULL) return;
//Retrieve text entered
const std::vector<sf::Event> & events = scene->GetRenderTargetEvents();
for (unsigned int i = 0;i<events.size();++i)
const auto & characters = scene->GetInputManager().GetCharactersEntered();
for (unsigned int i = 0;i<characters.size();++i)
{
if (events[i].type == sf::Event::TextEntered )
//Skip some non displayable characters
if (characters[i] > 30 && (characters[i] < 127 || characters[i] > 159))
text += characters[i];
else if (characters[i] == 8)
{
//Skip some non displayable characters
if (events[i].text.unicode > 30 && (events[i].text.unicode < 127 || events[i].text.unicode > 159))
text += events[i].text.unicode;
else if (events[i].text.unicode == 8)
{
//Backspace
if ( !text.empty() ) text.erase(text.end()-1);
}
//Backspace
if (!text.empty()) text.erase(text.end()-1);
}
}
}

View File

@@ -94,7 +94,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -130,8 +134,8 @@ IF(WIN32)
ELSEIF(EMSCRIPTEN)
set_target_properties(DestroyOutsideAutomatism PROPERTIES SUFFIX ".bc")
ELSE()
set_target_properties(TextObject PROPERTIES SUFFIX ".xgdle")
set_target_properties(TextObject_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(TextObject PROPERTIES SUFFIX ".xgde")
set_target_properties(TextObject_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
#Linker files for the IDE extension

View File

@@ -94,7 +94,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -150,8 +154,8 @@ IF(WIN32)
ELSEIF(EMSCRIPTEN)
set_target_properties(TileMapObject PROPERTIES SUFFIX ".bc")
ELSE()
set_target_properties(TileMapObject PROPERTIES SUFFIX ".xgdle")
set_target_properties(TileMapObject_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(TileMapObject PROPERTIES SUFFIX ".xgde")
set_target_properties(TileMapObject_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
#Linker files for the IDE extension

View File

@@ -18,7 +18,7 @@ This project is released under the MIT License.
#include "GDCpp/Position.h"
#include "GDCpp/Polygon2d.h"
#include "GDCpp/PolygonCollision.h"
#include "GDCpp/BuiltinExtensions/ObjectTools.h"
#include "GDCpp/ObjectsListsTools.h"
#include "GDCpp/Serialization/SerializerElement.h"
#include "GDCpp/CommonTools.h"
@@ -208,36 +208,26 @@ void RuntimeTileMapObject::ChangeTexture(const std::string &textureName, Runtime
needGeneration = true;
}
namespace
bool GD_EXTENSION_API SingleTileCollision(std::map<std::string, std::vector<RuntimeObject*>*> tileMapList,
int layer,
int column,
int row,
std::map<std::string, std::vector<RuntimeObject*>*> objectLists,
bool conditionInverted)
{
/**
* Extra parameter struct for the TwoObjectListsTest.
*/
struct TileExtraParameter : public ListsTestFuncExtraParameter
{
TileExtraParameter(int layer_, int column_, int row_) : ListsTestFuncExtraParameter(), layer(layer_), column(column_), row(row_) {};
int layer;
int column;
int row;
};
bool TileCollisionInnerTest(RuntimeObject *tileMapObject_, RuntimeObject *object, const ListsTestFuncExtraParameter &extraParameter)
{
return TwoObjectListsTest(tileMapList, objectLists, conditionInverted, [layer, column, row](RuntimeObject* tileMapObject_, RuntimeObject * object) {
RuntimeTileMapObject *tileMapObject = dynamic_cast<RuntimeTileMapObject*>(tileMapObject_);
if(!tileMapObject || tileMapObject->tileSet.Get().IsDirty())
return false;
const TileExtraParameter &tileExtraParam = dynamic_cast<const TileExtraParameter&>(extraParameter);
//Get the tile hitbox
int tileId = tileMapObject->tileMap.Get().GetTile(tileExtraParam.layer, tileExtraParam.column, tileExtraParam.row);
int tileId = tileMapObject->tileMap.Get().GetTile(layer, column, row);
if(tileId < 0 || tileId >= tileMapObject->tileSet.Get().GetTilesCount())
return false;
Polygon2d tileHitbox = tileMapObject->tileSet.Get().GetTileHitbox(tileId).hitbox;
tileHitbox.Move(tileMapObject->GetX() + tileExtraParam.column * tileMapObject->tileSet.Get().tileSize.x,
tileMapObject->GetY() + tileExtraParam.row * tileMapObject->tileSet.Get().tileSize.y);
tileHitbox.Move(tileMapObject->GetX() + column * tileMapObject->tileSet.Get().tileSize.x,
tileMapObject->GetY() + row * tileMapObject->tileSet.Get().tileSize.y);
//Get the object hitbox
std::vector<Polygon2d> objectHitboxes = object->GetHitBoxes();
@@ -251,17 +241,7 @@ namespace
}
return false;
}
}
bool GD_EXTENSION_API SingleTileCollision(std::map<std::string, std::vector<RuntimeObject*>*> tileMapList,
int layer,
int column,
int row,
std::map<std::string, std::vector<RuntimeObject*>*> objectLists,
bool conditionInverted)
{
return TwoObjectListsTest(tileMapList, objectLists, conditionInverted, &TileCollisionInnerTest, TileExtraParameter(layer, column, row));
});
}
RuntimeObject * CreateRuntimeTileMapObject(RuntimeScene & scene, const gd::Object & object)

View File

@@ -94,7 +94,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -130,8 +134,8 @@ IF(WIN32)
ELSEIF(EMSCRIPTEN)
set_target_properties(TiledSpriteObject PROPERTIES SUFFIX ".bc")
ELSE()
set_target_properties(TiledSpriteObject PROPERTIES SUFFIX ".xgdle")
set_target_properties(TiledSpriteObject_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(TiledSpriteObject PROPERTIES SUFFIX ".xgde")
set_target_properties(TiledSpriteObject_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
#Linker files for the IDE extension

View File

@@ -87,7 +87,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -119,8 +123,8 @@ IF(WIN32)
set_target_properties(TimedEvent PROPERTIES SUFFIX ".xgdwe")
set_target_properties(TimedEvent_Runtime PROPERTIES SUFFIX ".xgdw")
ELSE()
set_target_properties(TimedEvent PROPERTIES SUFFIX ".xgdle")
set_target_properties(TimedEvent_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(TimedEvent PROPERTIES SUFFIX ".xgde")
set_target_properties(TimedEvent_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
set_target_properties(TimedEvent_Runtime PROPERTIES RUNTIME_OUTPUT_NAME "TimedEvent")

View File

@@ -94,7 +94,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
add_definitions( -DGD_EXTENSION_API= )
@@ -130,8 +134,8 @@ IF(WIN32)
ELSEIF(EMSCRIPTEN)
set_target_properties(DraggableAutomatism PROPERTIES SUFFIX ".bc")
ELSE()
set_target_properties(TopDownMovementAutomatism PROPERTIES SUFFIX ".xgdle")
set_target_properties(TopDownMovementAutomatism_Runtime PROPERTIES SUFFIX ".xgdl")
set_target_properties(TopDownMovementAutomatism PROPERTIES SUFFIX ".xgde")
set_target_properties(TopDownMovementAutomatism_Runtime PROPERTIES SUFFIX ".xgd")
ENDIF(WIN32)
#Linker files for the IDE extension

View File

@@ -55,10 +55,10 @@ float TopDownMovementAutomatism::GetSpeed()
void TopDownMovementAutomatism::DoStepPreEvents(RuntimeScene & scene)
{
//Get the player input:
leftKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed( sf::Keyboard::Left );
rightKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed( sf::Keyboard::Right );
downKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed( sf::Keyboard::Down );
upKey |= !ignoreDefaultControls && sf::Keyboard::isKeyPressed( sf::Keyboard::Up );
leftKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Left");
rightKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Right");
downKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Down");
upKey |= !ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Up");
int direction = -1;
float directionInRad = 0;

View File

@@ -98,10 +98,10 @@ gdjs.TopDownMovementRuntimeAutomatism.prototype.doStepPreEvents = function(runti
var timeDelta = runtimeScene.getElapsedTime()/1000;
//Get the player input:
this._leftKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(LEFTKEY);
this._rightKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(RIGHTKEY);
this._downKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(DOWNKEY);
this._upKey |= !this._ignoreDefaultControls && runtimeScene.getGame().isKeyPressed(UPKEY);
this._leftKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(LEFTKEY);
this._rightKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(RIGHTKEY);
this._downKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(DOWNKEY);
this._upKey |= !this._ignoreDefaultControls && runtimeScene.getGame().getInputManager().isKeyPressed(UPKEY);
var direction = -1;
var directionInRad = 0;

View File

@@ -80,8 +80,11 @@ IF(WIN32)
add_definitions( -DwxUSE_UNICODE=1 )
add_definitions( -DWXUSINGDLL )
ELSE()
add_definitions( -Dlinux )
IF(APPLE)
add_definitions( -DMACOS )
ELSE()
add_definitions( -DLINUX )
ENDIF()
add_definitions( -DGD_API= )
add_definitions( -DGD_CORE_API= )
IF (NOT NO_GUI)
@@ -179,7 +182,9 @@ ELSE()
ELSE()
target_link_libraries(GDCpp_Runtime sfml-audio sfml-graphics sfml-window sfml-network sfml-system)
target_link_libraries(GDCpp_Runtime_exe sfml-audio sfml-graphics sfml-window sfml-network sfml-system)
target_link_libraries(GDCpp_Runtime_exe GLU GL)
IF (NOT APPLE)
target_link_libraries(GDCpp_Runtime_exe GLU GL)
ENDIF()
ENDIF(WIN32)
ENDIF()
@@ -211,5 +216,7 @@ if(BUILD_TESTS)
add_executable(GDCpp_tests ${test_source_files})
target_link_libraries(GDCpp_tests GDCpp_Runtime)
target_link_libraries(GDCpp_tests sfml-audio sfml-graphics sfml-window sfml-network sfml-system)
target_link_libraries(GDCpp_tests GLU GL)
IF (NOT APPLE)
target_link_libraries(GDCpp_tests GLU GL)
ENDIF()
endif()

View File

@@ -66,7 +66,7 @@ void GD_API LaunchFile( const std::string & file )
string appel = "xdg-open \""+file+"\"";
system(appel.c_str());
#elif defined(MAC)
#elif defined(MACOS)
string appel = "open \""+file+"\"";
system(appel.c_str());

View File

@@ -12,176 +12,15 @@ using namespace std;
bool GD_API IsKeyPressed(RuntimeScene & scene, std::string key)
{
if ( !scene.RenderWindowHasFocus() && scene.IsInputDisabledWhenFocusIsLost() )
return false;
const std::map<std::string, int> & keyMap = GetKeyNameToSfKeyMap();
std::map<std::string, int>::const_iterator it = keyMap.find(key);
if (it != keyMap.end())
return sf::Keyboard::isKeyPressed(static_cast<sf::Keyboard::Key>(it->second));
return false;
return scene.GetInputManager().IsKeyPressed(key);
}
bool GD_API AnyKeyIsPressed(RuntimeScene & scene)
{
if ( !scene.RenderWindowHasFocus() && scene.IsInputDisabledWhenFocusIsLost() )
return false;
const std::vector<sf::Event> & events = scene.GetRenderTargetEvents();
for (unsigned int i = 0;i<events.size();++i)
{
if (events[i].type == sf::Event::KeyPressed)
return true;
}
return false;
return scene.GetInputManager().AnyKeyIsPressed();
}
std::string GD_API LastPressedKey(RuntimeScene & scene)
{
const std::map<int, std::string> & keyMap = GetSfKeyToKeyNameMap();
std::map<int, std::string>::const_iterator it = keyMap.find(scene.GetLastPressedKey());
if (it != keyMap.end())
return it->second;
return "";
}
const std::map<std::string, int> & GD_API GetKeyNameToSfKeyMap()
{
static bool initialized = false;
static std::map<std::string, int> * map = new std::map<std::string, int>();
if (!initialized)
{
(*map)["a"] = sf::Keyboard::A;
(*map)["b"] = sf::Keyboard::B;
(*map)["c"] = sf::Keyboard::C;
(*map)["d"] = sf::Keyboard::D;
(*map)["e"] = sf::Keyboard::E;
(*map)["f"] = sf::Keyboard::F;
(*map)["g"] = sf::Keyboard::G;
(*map)["h"] = sf::Keyboard::H;
(*map)["i"] = sf::Keyboard::I;
(*map)["j"] = sf::Keyboard::J;
(*map)["k"] = sf::Keyboard::K;
(*map)["l"] = sf::Keyboard::L;
(*map)["m"] = sf::Keyboard::M;
(*map)["n"] = sf::Keyboard::N;
(*map)["o"] = sf::Keyboard::O;
(*map)["p"] = sf::Keyboard::P;
(*map)["q"] = sf::Keyboard::Q;
(*map)["r"] = sf::Keyboard::R;
(*map)["s"] = sf::Keyboard::S;
(*map)["t"] = sf::Keyboard::T;
(*map)["u"] = sf::Keyboard::U;
(*map)["v"] = sf::Keyboard::V;
(*map)["w"] = sf::Keyboard::W;
(*map)["x"] = sf::Keyboard::X;
(*map)["y"] = sf::Keyboard::Y;
(*map)["z"] = sf::Keyboard::Z;
(*map)["Num9"] = sf::Keyboard::Num9;
(*map)["Num8"] = sf::Keyboard::Num8;
(*map)["Num7"] = sf::Keyboard::Num7;
(*map)["Num6"] = sf::Keyboard::Num6;
(*map)["Num5"] = sf::Keyboard::Num5;
(*map)["Num4"] = sf::Keyboard::Num4;
(*map)["Num3"] = sf::Keyboard::Num3;
(*map)["Num2"] = sf::Keyboard::Num2;
(*map)["Num1"] = sf::Keyboard::Num1;
(*map)["Num0"] = sf::Keyboard::Num0;
(*map)["Escape"] = sf::Keyboard::Escape;
(*map)["RControl"] = sf::Keyboard::RControl;
(*map)["RShift"] = sf::Keyboard::RShift;
(*map)["RAlt"] = sf::Keyboard::RAlt;
(*map)["LControl"] = sf::Keyboard::LControl;
(*map)["LShift"] = sf::Keyboard::LShift;
(*map)["LAlt"] = sf::Keyboard::LAlt;
(*map)["LSystem"] = sf::Keyboard::LSystem;
(*map)["RSystem"] = sf::Keyboard::RSystem;
(*map)["Menu"] = sf::Keyboard::Menu;
(*map)["LBracket"] = sf::Keyboard::LBracket;
(*map)["RBracket"] = sf::Keyboard::RBracket;
(*map)["SemiColon"] = sf::Keyboard::SemiColon;
(*map)["Comma"] = sf::Keyboard::Comma;
(*map)["Period"] = sf::Keyboard::Period;
(*map)["Quote"] = sf::Keyboard::Quote;
(*map)["Slash"] = sf::Keyboard::Slash;
(*map)["BackSlash"] = sf::Keyboard::BackSlash;
(*map)["Tilde"] = sf::Keyboard::Tilde;
(*map)["Equal"] = sf::Keyboard::Equal;
(*map)["Dash"] = sf::Keyboard::Dash;
(*map)["Space"] = sf::Keyboard::Space;
(*map)["Return"] = sf::Keyboard::Return;
(*map)["Back"] = sf::Keyboard::BackSpace;
(*map)["Tab"] = sf::Keyboard::Tab;
(*map)["PageUp"] = sf::Keyboard::PageUp;
(*map)["PageDown"] = sf::Keyboard::PageDown;
(*map)["End"] = sf::Keyboard::End;
(*map)["Home"] = sf::Keyboard::Home;
(*map)["Insert"] = sf::Keyboard::Insert;
(*map)["Delete"] = sf::Keyboard::Delete;
(*map)["Add"] = sf::Keyboard::Add;
(*map)["Subtract"] = sf::Keyboard::Subtract;
(*map)["Multiply"] = sf::Keyboard::Multiply;
(*map)["Divide"] = sf::Keyboard::Divide;
(*map)["Left"] = sf::Keyboard::Left;
(*map)["Right"] = sf::Keyboard::Right;
(*map)["Up"] = sf::Keyboard::Up;
(*map)["Down"] = sf::Keyboard::Down;
(*map)["Numpad0"] = sf::Keyboard::Numpad0;
(*map)["Numpad1"] = sf::Keyboard::Numpad1;
(*map)["Numpad2"] = sf::Keyboard::Numpad2;
(*map)["Numpad3"] = sf::Keyboard::Numpad3;
(*map)["Numpad4"] = sf::Keyboard::Numpad4;
(*map)["Numpad5"] = sf::Keyboard::Numpad5;
(*map)["Numpad6"] = sf::Keyboard::Numpad6;
(*map)["Numpad7"] = sf::Keyboard::Numpad7;
(*map)["Numpad8"] = sf::Keyboard::Numpad8;
(*map)["Numpad9"] = sf::Keyboard::Numpad9;
(*map)["F1"] = sf::Keyboard::F1;
(*map)["F2"] = sf::Keyboard::F2;
(*map)["F3"] = sf::Keyboard::F3;
(*map)["F4"] = sf::Keyboard::F4;
(*map)["F5"] = sf::Keyboard::F5;
(*map)["F6"] = sf::Keyboard::F6;
(*map)["F7"] = sf::Keyboard::F7;
(*map)["F8"] = sf::Keyboard::F8;
(*map)["F9"] = sf::Keyboard::F9;
(*map)["F10"] = sf::Keyboard::F10;
(*map)["F11"] = sf::Keyboard::F11;
(*map)["F12"] = sf::Keyboard::F12;
(*map)["F13"] = sf::Keyboard::F13;
(*map)["F14"] = sf::Keyboard::F14;
(*map)["F15"] = sf::Keyboard::F15;
(*map)["Pause"] = sf::Keyboard::Pause;
initialized = true;
}
return *map;
}
const std::map<int, std::string> & GD_API GetSfKeyToKeyNameMap()
{
static bool initialized = false;
static std::map<int, std::string> * map = new std::map<int, std::string>();
if (!initialized)
{
const std::map<std::string, int> & keyMap = GetKeyNameToSfKeyMap();
for(std::map<std::string, int>::const_iterator it = keyMap.begin();it!=keyMap.end();++it)
(*map)[it->second] = it->first;
initialized = true;
}
return *map;
return scene.GetInputManager().GetLastPressedKey();
}

View File

@@ -12,7 +12,5 @@ class RuntimeScene;
bool IsKeyPressed(RuntimeScene & scene, std::string key);
bool AnyKeyIsPressed(RuntimeScene & scene);
std::string LastPressedKey(RuntimeScene & scene);
const std::map<std::string, int> & GetKeyNameToSfKeyMap();
const std::map<int, std::string> & GetSfKeyToKeyNameMap();
#endif // KEYBOARDTOOLS_H

View File

@@ -15,9 +15,7 @@ MouseExtension::MouseExtension()
{
gd::BuiltinExtensionsImplementer::ImplementsMouseExtension(*this);
#if defined(GD_IDE_ONLY)
GetAllActions()["CentreSourisX"].codeExtraInformation.SetFunctionName("CenterCursorHorizontally").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllActions()["CentreSourisY"].codeExtraInformation.SetFunctionName("CenterCursorVertically").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllActions()["CacheSouris"].codeExtraInformation.SetFunctionName("HideCursor").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
@@ -29,11 +27,15 @@ MouseExtension::MouseExtension()
GetAllConditions()["SourisY"].codeExtraInformation.SetFunctionName("GetCursorYPosition").SetManipulatedType("number").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllConditions()["SourisBouton"].codeExtraInformation.SetFunctionName("MouseButtonPressed").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllConditions()["SourisSurObjet"].codeExtraInformation.SetFunctionName("CursorOnObject").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllExpressions()["MouseX"].codeExtraInformation.SetFunctionName("GetCursorXPosition").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllExpressions()["SourisX"].codeExtraInformation.SetFunctionName("GetCursorXPosition").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllExpressions()["MouseY"].codeExtraInformation.SetFunctionName("GetCursorYPosition").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllExpressions()["SourisY"].codeExtraInformation.SetFunctionName("GetCursorYPosition").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
GetAllExpressions()["MouseWheelDelta"].codeExtraInformation.SetFunctionName("GetMouseWheelDelta").SetIncludeFile("GDCpp/BuiltinExtensions/MouseTools.h");
StripUnimplementedInstructionsAndExpressions(); //Touch support is not implemented
#endif
}

View File

@@ -1,6 +1,7 @@
#include "GDCpp/BuiltinExtensions/MouseTools.h"
#include "GDCpp/RuntimeScene.h"
#include "GDCpp/RuntimeLayer.h"
#include "GDCpp/ObjectsListsTools.h"
#include <SFML/Graphics.hpp>
void GD_API CenterCursor( RuntimeScene & scene )
@@ -10,12 +11,12 @@ void GD_API CenterCursor( RuntimeScene & scene )
void GD_API CenterCursorHorizontally( RuntimeScene & scene )
{
sf::Mouse::setPosition(sf::Vector2i(scene.renderWindow->getSize().x/2, sf::Mouse::getPosition(*scene.renderWindow).y ), *scene.renderWindow );
sf::Mouse::setPosition(sf::Vector2i(scene.renderWindow->getSize().x/2, scene.GetInputManager().GetMousePosition().y ), *scene.renderWindow );
}
void GD_API CenterCursorVertically( RuntimeScene & scene )
{
sf::Mouse::setPosition(sf::Vector2i(sf::Mouse::getPosition(*scene.renderWindow).x, scene.renderWindow->getSize().y/2), *scene.renderWindow );
sf::Mouse::setPosition(sf::Vector2i(scene.GetInputManager().GetMousePosition().x, scene.renderWindow->getSize().y/2), *scene.renderWindow );
}
void GD_API SetCursorPosition( RuntimeScene & scene, float newX, float newY )
@@ -40,7 +41,7 @@ double GD_API GetCursorXPosition( RuntimeScene & scene, const std::string & laye
//Get view, and compute mouse position
const sf::View & view = scene.GetRuntimeLayer(layer).GetCamera(camera).GetSFMLView();
return scene.renderWindow->mapPixelToCoords(sf::Mouse::getPosition(*scene.renderWindow), view).x;
return scene.renderWindow->mapPixelToCoords(scene.GetInputManager().GetMousePosition(), view).x;
}
double GD_API GetCursorYPosition( RuntimeScene & scene, const std::string & layer, unsigned int camera )
@@ -50,34 +51,22 @@ double GD_API GetCursorYPosition( RuntimeScene & scene, const std::string & laye
//Get view, and compute mouse position
const sf::View & view = scene.GetRuntimeLayer(layer).GetCamera(camera).GetSFMLView();
return scene.renderWindow->mapPixelToCoords(sf::Mouse::getPosition(*scene.renderWindow), view).y;
return scene.renderWindow->mapPixelToCoords(scene.GetInputManager().GetMousePosition(), view).y;
}
bool GD_API MouseButtonPressed( RuntimeScene & scene, const std::string & key )
bool GD_API MouseButtonPressed(RuntimeScene & scene, const std::string & button)
{
if ( !scene.RenderWindowHasFocus() && scene.IsInputDisabledWhenFocusIsLost() )
return false;
if ( key == "Left" ) { return sf::Mouse::isButtonPressed( sf::Mouse::Left ); }
if ( key == "Right" ) { return sf::Mouse::isButtonPressed( sf::Mouse::Right ); }
if ( key == "Middle" ) { return sf::Mouse::isButtonPressed( sf::Mouse::Middle ); }
if ( key == "XButton1" ) { return sf::Mouse::isButtonPressed( sf::Mouse::XButton1 ); }
if ( key == "XButton2" ) { return sf::Mouse::isButtonPressed( sf::Mouse::XButton2 ); }
return false;
return scene.GetInputManager().IsMouseButtonPressed(button);
}
int GD_API GetMouseWheelDelta( RuntimeScene & scene )
int GD_API GetMouseWheelDelta(RuntimeScene & scene)
{
if ( !scene.RenderWindowHasFocus() && scene.IsInputDisabledWhenFocusIsLost() )
return false;
return scene.GetInputManager().GetMouseWheelDelta();
}
const std::vector<sf::Event> & events = scene.GetRenderTargetEvents();
for (unsigned int i = 0;i<events.size();++i)
{
if (events[i].type == sf::Event::MouseWheelMoved )
return events[i].mouseWheel.delta;
}
return 0;
}
bool GD_API CursorOnObject(std::map <std::string, std::vector<RuntimeObject*> *> objectsLists, RuntimeScene & scene, bool precise, bool conditionInverted)
{
return PickObjectsIf(objectsLists, conditionInverted, [&scene, precise](RuntimeObject * obj) {
return obj->CursorOnObject(scene, precise);
});
}

View File

@@ -2,17 +2,21 @@
#define MOUSETOOLS_H
#include <string>
#include <map>
#include <vector>
class RuntimeScene;
class RuntimeObject;
void GD_API CenterCursor( RuntimeScene & scene );
void GD_API CenterCursorHorizontally( RuntimeScene & scene );
void GD_API CenterCursorVertically( RuntimeScene & scene );
void GD_API SetCursorPosition( RuntimeScene & scene, float newX, float newY );
void GD_API HideCursor( RuntimeScene & scene );
void GD_API ShowCursor( RuntimeScene & scene );
double GD_API GetCursorXPosition( RuntimeScene & scene, const std::string & layer, unsigned int camera );
double GD_API GetCursorYPosition( RuntimeScene & scene, const std::string & layer, unsigned int camera );
bool GD_API MouseButtonPressed( RuntimeScene & scene, const std::string & key );
int GD_API GetMouseWheelDelta(RuntimeScene & scene );
void GD_API CenterCursor(RuntimeScene & scene);
void GD_API CenterCursorHorizontally(RuntimeScene & scene);
void GD_API CenterCursorVertically(RuntimeScene & scene);
void GD_API SetCursorPosition(RuntimeScene & scene, float newX, float newY);
void GD_API HideCursor(RuntimeScene & scene);
void GD_API ShowCursor(RuntimeScene & scene);
double GD_API GetCursorXPosition(RuntimeScene & scene, const std::string & layer, unsigned int camera);
double GD_API GetCursorYPosition(RuntimeScene & scene, const std::string & layer, unsigned int camera);
bool GD_API MouseButtonPressed(RuntimeScene & scene, const std::string & key);
int GD_API GetMouseWheelDelta(RuntimeScene & scene);
bool GD_API CursorOnObject(std::map <std::string, std::vector<RuntimeObject*> *> objectsLists, RuntimeScene & scene, bool precise, bool conditionInverted);
#endif // MOUSETOOLS_H
#endif // MOUSETOOLS_H

View File

@@ -61,7 +61,7 @@ void GD_API SendDataToPhpWebPage(const std::string & webpageurl,
"&data6="+data6+"&check6="+data6md5+"\"";
system(call.c_str());
#elif defined(MAC)
#elif defined(MACOS)
string call = "open \""+webpageurl+
"?data1="+data1+"&check1="+data1md5+
"&data2="+data2+"&check2="+data2md5+

View File

@@ -1,7 +1,13 @@
/*
* GDevelop C++ Platform
* Copyright 2008-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#include "ObjectTools.h"
#include "GDCpp/RuntimeObject.h"
#include "GDCpp/Polygon2d.h"
#include "GDCpp/PolygonCollision.h"
#include "GDCpp/ObjectsListsTools.h"
#include "MathematicalTools.h"
#include <cmath>
#include <iostream>
@@ -22,203 +28,44 @@ double GD_API PickedObjectsCount( std::map <std::string, std::vector<RuntimeObje
return size;
}
/**
* Internal function picking from objectsLists1 and objectsLists2 only pairs of objects for which the test is true.
* If inverted == true, only the objects of the first table are filtered.
*
* Note that the functor is not called stricly for each pair: When considering a pair of objects, if these objects
* have already been marked as picked, the functor won't be called again.
*
* objectsLists1 and objectsLists2 may contains one or more identical pointers to some lists (See *This is important*
* comment at the end of the algorithm, when trimming the list).
*
* Cost (Worst case, functor being always false):
* Cost(Creating tables with a total of NbObjList1+NbObjList2 booleans)
* + Cost(functor)*NbObjList1*NbObjList2
* + Cost(Testing NbObjList1+NbObjList2 booleans)
* + Cost(Removing NbObjList1+NbObjList2 objects from all the lists)
*
* Cost (Best case, functor being always true):
* Cost(Creating tables with a total of NbObjList1+NbObjList2 booleans)
* + Cost(functor)*(NbObjList1+NbObjList2)
* + Cost(Testing NbObjList1+NbObjList2 booleans)
*/
bool GD_API TwoObjectListsTest(std::map <std::string, std::vector<RuntimeObject*> *> objectsLists1,
std::map <std::string, std::vector<RuntimeObject*> *> objectsLists2,
bool conditionInverted,
TwoObjectsListsTestFunc functor, const ListsTestFuncExtraParameter &extraParameter )
{
bool isTrue = false;
//Create a boolean for each object
std::vector < std::vector<bool> > pickedList1;
std::vector < std::vector<bool> > pickedList2;
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it = objectsLists1.begin();
it != objectsLists1.end();++it)
{
std::vector<bool> arr;
arr.assign(it->second->size(), false);
pickedList1.push_back(arr);
}
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it = objectsLists2.begin();
it != objectsLists2.end();++it)
{
std::vector<bool> arr;
arr.assign(it->second->size(), false);
pickedList2.push_back(arr);
}
//Launch the function each object of the first list with each object
//of the second list.
unsigned int i = 0;
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it = objectsLists1.begin();
it != objectsLists1.end();++it, ++i)
{
if ( !it->second ) continue;
const std::vector<RuntimeObject*> & arr1 = *it->second;
for(unsigned int k = 0;k<arr1.size();++k) {
bool atLeastOneObject = false;
unsigned int j = 0;
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it2 = objectsLists2.begin();
it2 != objectsLists2.end();++it2, ++j)
{
if ( !it2->second ) continue;
const std::vector<RuntimeObject*> & arr2 = *it2->second;
for(unsigned int l = 0;l<arr2.size();++l) {
if ( pickedList1[i][k] && pickedList2[j][l]) continue; //Avoid unnecessary costly call to functor.
if ( arr1[k] != arr2[l] && functor(arr1[k], arr2[l], extraParameter) ) {
if ( !conditionInverted ) {
isTrue = true;
//Pick the objects
pickedList1[i][k] = true;
pickedList2[j][l] = true;
}
atLeastOneObject = true;
}
}
}
if ( !atLeastOneObject && conditionInverted ) { //The object is not overlapping any other object.
isTrue = true;
pickedList1[i][k] = true;
}
}
}
//Trim not picked objects from arrays.
i = 0;
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it = objectsLists1.begin();
it != objectsLists1.end();++it, ++i)
{
size_t finalSize = 0;
if ( !it->second ) continue;
std::vector<RuntimeObject*> & arr = *it->second;
for(unsigned int k = 0;k<arr.size();++k)
{
RuntimeObject * obj = arr[k];
if ( pickedList1[i][k] )
{
arr[finalSize] = obj;
finalSize++;
}
}
arr.resize(finalSize);
}
if ( !conditionInverted ) {
unsigned int i = 0;
for(std::map <std::string, std::vector<RuntimeObject*> *>::const_iterator it = objectsLists2.begin();
it != objectsLists2.end();++it, ++i)
{
size_t finalSize = 0;
if ( !it->second ) continue;
std::vector<RuntimeObject*> & arr = *it->second;
//*This is important*! We can have a list that has already been trimmed just before
if ( arr.size() != pickedList2[i].size() ) //If the size of the objects list != size of the boolean "picked" list...
continue; //... then the object list was already trimmed, skip it.
for(unsigned int k = 0;k<arr.size();++k)
{
RuntimeObject * obj = arr[k];
if ( pickedList2[i][k] )
{
arr[finalSize] = obj;
finalSize++;
}
}
arr.resize(finalSize);
}
}
return isTrue;
}
static bool HitBoxesInnerTest(RuntimeObject * obj1, RuntimeObject * obj2, const ListsTestFuncExtraParameter &extraParameter)
{
return obj1->IsCollidingWith(obj2);
}
bool GD_API HitBoxesCollision(std::map <std::string, std::vector<RuntimeObject*> *> objectsLists1, std::map <std::string, std::vector<RuntimeObject*> *> objectsLists2, bool conditionInverted )
{
return TwoObjectListsTest(objectsLists1, objectsLists2, conditionInverted, &HitBoxesInnerTest, ListsTestFuncExtraParameter());
}
static bool TurnedTowardInnerTest(RuntimeObject * obj1, RuntimeObject * obj2, const ListsTestFuncExtraParameter &extraParameter)
{
const ToleranceExtraParameter &toleranceExtraParam = dynamic_cast<const ToleranceExtraParameter&>(extraParameter);
double objAngle = atan2(obj2->GetDrawableY()+obj2->GetCenterY() - (obj1->GetDrawableY()+obj1->GetCenterY()),
obj2->GetDrawableX()+obj2->GetCenterX() - (obj1->GetDrawableX()+obj1->GetCenterX()));
objAngle *= 180.0/3.14159;
return abs(GDpriv::MathematicalTools::angleDifference(obj1->GetAngle(), objAngle)) <= toleranceExtraParam.tolerance/2;
return TwoObjectListsTest(objectsLists1, objectsLists2, conditionInverted, [](RuntimeObject * obj1, RuntimeObject * obj2) {
return obj1->IsCollidingWith(obj2);
});
}
bool GD_API ObjectsTurnedToward( std::map <std::string, std::vector<RuntimeObject*> *> objectsLists1, std::map <std::string, std::vector<RuntimeObject*> *> objectsLists2, float tolerance, bool conditionInverted )
{
return TwoObjectListsTest(objectsLists1, objectsLists2, conditionInverted, TurnedTowardInnerTest, ToleranceExtraParameter(tolerance));
}
return TwoObjectListsTest(objectsLists1, objectsLists2, conditionInverted, [tolerance](RuntimeObject * obj1, RuntimeObject * obj2) {
double objAngle = atan2(obj2->GetDrawableY()+obj2->GetCenterY() - (obj1->GetDrawableY()+obj1->GetCenterY()),
obj2->GetDrawableX()+obj2->GetCenterX() - (obj1->GetDrawableX()+obj1->GetCenterX()));
objAngle *= 180.0/3.14159;
static bool DistanceInnerTest(RuntimeObject * obj1, RuntimeObject * obj2, const ListsTestFuncExtraParameter &extraParameter)
{
const DistanceExtraParameter &distanceExtraParam = dynamic_cast<const DistanceExtraParameter&>(extraParameter);
float X = obj1->GetDrawableX()+obj1->GetCenterX() - (obj2->GetDrawableX()+obj2->GetCenterX());
float Y = obj1->GetDrawableY()+obj1->GetCenterY() - (obj2->GetDrawableY()+obj2->GetCenterY());
return (X*X+Y*Y) <= distanceExtraParam.squaredLength;
return abs(GDpriv::MathematicalTools::angleDifference(obj1->GetAngle(), objAngle)) <= tolerance/2;
});
}
float GD_API DistanceBetweenObjects( std::map <std::string, std::vector<RuntimeObject*> *> objectsLists1, std::map <std::string, std::vector<RuntimeObject*> *> objectsLists2, float length, bool conditionInverted)
{
length *= length;
return TwoObjectListsTest(objectsLists1, objectsLists2, conditionInverted, DistanceInnerTest, DistanceExtraParameter(length));
return TwoObjectListsTest(objectsLists1, objectsLists2, conditionInverted, [length](RuntimeObject * obj1, RuntimeObject * obj2) {
float X = obj1->GetDrawableX()+obj1->GetCenterX() - (obj2->GetDrawableX()+obj2->GetCenterX());
float Y = obj1->GetDrawableY()+obj1->GetCenterY() - (obj2->GetDrawableY()+obj2->GetCenterY());
return (X*X+Y*Y) <= length;
});
}
static bool MovesTowardInnerTest(RuntimeObject * obj1, RuntimeObject * obj2, const ListsTestFuncExtraParameter &extraParameter)
{
if ( obj1->TotalForceLength() == 0 ) return false;
const ToleranceExtraParameter &toleranceExtraParam = dynamic_cast<const ToleranceExtraParameter&>(extraParameter);
double objAngle = atan2(obj2->GetDrawableY()+obj2->GetCenterY() - (obj1->GetDrawableY()+obj1->GetCenterY()),
obj2->GetDrawableX()+obj2->GetCenterX() - (obj1->GetDrawableX()+obj1->GetCenterX()));
objAngle *= 180.0/3.14159;
return abs(GDpriv::MathematicalTools::angleDifference(obj1->TotalForceAngle(), objAngle)) <= toleranceExtraParam.tolerance/2;
}
bool GD_API MovesToward( std::map <std::string, std::vector<RuntimeObject*> *> objectsLists1, std::map <std::string, std::vector<RuntimeObject*> *> objectsLists2, float tolerance, bool conditionInverted )
{
return TwoObjectListsTest(objectsLists1, objectsLists2, conditionInverted, MovesTowardInnerTest, ToleranceExtraParameter(tolerance));
return TwoObjectListsTest(objectsLists1, objectsLists2, conditionInverted, [tolerance](RuntimeObject * obj1, RuntimeObject * obj2) {
if ( obj1->TotalForceLength() == 0 ) return false;
double objAngle = atan2(obj2->GetDrawableY()+obj2->GetCenterY() - (obj1->GetDrawableY()+obj1->GetCenterY()),
obj2->GetDrawableX()+obj2->GetCenterX() - (obj1->GetDrawableX()+obj1->GetCenterX()));
objAngle *= 180.0/3.14159;
return abs(GDpriv::MathematicalTools::angleDifference(obj1->TotalForceAngle(), objAngle)) <= tolerance/2;
});
}

View File

@@ -1,3 +1,8 @@
/*
* GDevelop C++ Platform
* Copyright 2008-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#ifndef OBJECTTOOLS_H
#define OBJECTTOOLS_H
@@ -7,52 +12,6 @@
class RuntimeScene;
class RuntimeObject;
/**
* Base class used to add extra parameters to the test function inside TwoObjectListsTest.
*/
struct GD_API ListsTestFuncExtraParameter
{
ListsTestFuncExtraParameter(){};
virtual ~ListsTestFuncExtraParameter(){};
};
/**
* Used by MovesToward and ObjectsTurnedToward function to bring a extra parameter to the test function.
*/
struct ToleranceExtraParameter : public ListsTestFuncExtraParameter
{
ToleranceExtraParameter(float tolerance_) : ListsTestFuncExtraParameter(), tolerance(tolerance_) {};
float tolerance;
};
/**
* Used by DistanceBetweenObjects to get the length
*/
struct DistanceExtraParameter : public ListsTestFuncExtraParameter
{
DistanceExtraParameter(float squaredLength_) : ListsTestFuncExtraParameter(), squaredLength(squaredLength_) {};
float squaredLength;
};
typedef bool (*TwoObjectsListsTestFunc)(RuntimeObject*, RuntimeObject*, const ListsTestFuncExtraParameter &extraParameter);
/**
* \brief Do a test on two tables of objects so as to remove the objects for which the test is false.
*
* \note If conditionInverted == true, only the objects of the first table are filtered.
* \param objectsLists1 The first object lists
* \param objectsLists2 The second object lists
* \param conditionInverted true if the test must be inverted
* \param functor The function to be called
* \param extraParameter An extra parameter send to the functor
*/
bool GD_API TwoObjectListsTest(std::map <std::string, std::vector<RuntimeObject*> *> objectsLists1,
std::map <std::string, std::vector<RuntimeObject*> *> objectsLists2,
bool conditionInverted,
TwoObjectsListsTestFunc functor, const ListsTestFuncExtraParameter &extraParameter );
/**
* Only used internally by GD events generated code.
*/
@@ -78,4 +37,4 @@ float GD_API DistanceBetweenObjects(std::map <std::string, std::vector<RuntimeOb
*/
bool GD_API MovesToward( std::map <std::string, std::vector<RuntimeObject*> *> objectsLists1, std::map <std::string, std::vector<RuntimeObject*> *> objectsLists2, float tolerance, bool conditionInverted );
#endif // OBJECTTOOLS_H
#endif // OBJECTTOOLS_H

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