Files
GDevelop/Extensions/PathAutomatism/Extension.cpp
T
Victor Levasseur b32732916c Actions and conditions are declared in the extension with gd::String (except for the sentence)
Added push_back and Split methods to gd::String
2015-06-25 16:49:40 +02:00

404 lines
23 KiB
C++

/**
GDevelop - Path Automatism Extension
Copyright (c) 2010-2015 Florian Rival (Florian.Rival@gmail.com)
This project is released under the MIT License.
*/
/**
* Contributors to the extension:
* Victor Levasseur ( Created Path automatism editor and enhanced extension )
*/
#include "GDCpp/ExtensionBase.h"
#include "GDCore/Tools/Version.h"
#include "PathAutomatism.h"
#include "ScenePathDatas.h"
/**
* \brief This class declares information about the extension.
*/
class Extension : public ExtensionBase
{
public:
/**
* Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
*/
Extension()
{
SetExtensionInformation("PathAutomatism",
GD_T("Path Automatism"),
GD_T("Automatism allowing to move objects on a predefined path"),
"Florian Rival",
"Open source (MIT License)");
{
gd::AutomatismMetadata & aut = AddAutomatism("PathAutomatism",
GD_T("Path"),
GD_T("Path"),
GD_T("Make objects move on a predefined path."),
"",
"CppPlatform/Extensions/pathicon.png",
"PathAutomatism",
std::shared_ptr<gd::Automatism>(new PathAutomatism),
std::shared_ptr<gd::AutomatismsSharedData>(new ScenePathDatas));
#if defined(GD_IDE_ONLY)
aut.SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetReverseAtEnd",
_("De/activate rounding"),
_("Activate or desactivate rounding"),
GD_T("Activate rounding for _PARAM0_: _PARAM2_"),
_("Options"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("yesorno", GD_T("Activate"))
.SetFunctionName("SetReverseAtEnd").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetStopAtEnd",
_("De/activate the stop at the end of the path"),
_("Activate or deactivate the stop at the end of the object"),
GD_T("Stop _PARAM0_ when the end of the path is reached: _PARAM2_"),
_("Options"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("yesorno", GD_T("Activate"))
.SetFunctionName("SetStopAtEnd").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("ReverseAtEnd",
_("Rounds"),
_("Return true if the object round"),
GD_T("_PARAM0_ is rounding"),
_("Options"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("ReverseAtEnd").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("StopAtEnd",
_("Stop at the end of the path"),
_("Return true if the object stops at the end of its path."),
GD_T("_PARAM0_ stops at the end of the path"),
_("Options"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("StopAtEnd").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("Reverse",
_("Invert the movement on the path"),
_("Invert the movement on the path."),
GD_T("Invert the sens of the movement of _PARAM0_ on its path"),
_("Movement"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("Reverse").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("GetSegment",
_("Number of the segment on the path"),
_("True if the number of the current segment on the path satisfies the test."),
GD_T("The number of the current segment of the path of _PARAM0_ is _PARAM2__PARAM3_"),
_("Position"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("relationalOperator", GD_T("Comparison sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("GetCurrentSegment").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("EnterSegment",
_("Position on the segment of a path"),
_("Put the object directly on specific segment of the path"),
GD_T("Do _PARAM2__PARAM3_ to number of the current segment of _PARAM0_"),
_("Position"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("operator", GD_T("Modification sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("SetCurrentSegment").SetGetter("GetCurrentSegment").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddExpression("Segment", GD_T("Current segment"), GD_T("Number of the current segment"), GD_T("Position"), "CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("GetCurrentSegment").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("GetPosition",
_("Position of the object on the segment"),
_("Return true if the position on the path satisfy the test.\nPosition on a segment is a value between 0 and 1."),
GD_T("The position of _PARAM0_ on the current segment is _PARAM2__PARAM3_"),
_("Position"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("relationalOperator", GD_T("Comparison sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("GetPositionOnSegment").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetPosition",
_("Put the object on a precise position of the current segment"),
_("Put the object on a precise position on the current segment."),
GD_T("Put _PARAM0_ on _PARAM2__PARAM3_ on the current segment"),
_("Position"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("operator", GD_T("Modification sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("SetPositionOnSegment").SetGetter("GetPositionOnSegment").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddExpression("Position", GD_T("Position on the segment"), GD_T("Position on the segment ( value between 0 and 1 )"), GD_T("Position"), "CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("GetPositionOnSegment").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("GetPathName",
_("Path name"),
_("Test the path name."),
GD_T("The name of the current path of _PARAM0_ is _PARAM1__PARAM2_"),
_("Path"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("relationalOperator", GD_T("Comparison sign"))
.AddParameter("string", GD_T("Name"))
.SetFunctionName("GetCurrentPathName").SetManipulatedType("string").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetPathName",
_("Change the path"),
_("Change the path used."),
GD_T("Set _PARAM2_ as the current path of _PARAM0_"),
_("Path"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("string", GD_T("Name"))
.SetFunctionName("ChangeCurrentPath").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddStrExpression("CurrentPathName", GD_T("Current path name"), GD_T("Current path name"), GD_T("Path"), "CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("GetCurrentPathName").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("GetOffsetX",
_("X position of the path"),
_("Return true if the X position satisfies the test."),
GD_T("The X position of the path of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path position"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("relationalOperator", GD_T("Comparison sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("GetOffsetX").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetOffsetX",
_("Modify the path X position"),
_("Change the path X position."),
GD_T("Do _PARAM2__PARAM3_ to the X position of the path of _PARAM0_"),
_("Path position"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("operator", GD_T("Modification sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("SetOffsetX").SetGetter("GetOffsetX").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddExpression("PathX", GD_T("X position of the path"), GD_T("X position of the path"), GD_T("Path position"), "CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("GetOffsetX").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("GetOffsetY",
_("Path Y position"),
_("Return true if the Y position satisfies the test."),
GD_T("The Y position of the path of _PARAM0_ is _PARAM2__PARAM3_"),
_("Path position"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("relationalOperator", GD_T("Comparison sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("GetOffsetY").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetOffsetY",
_("Modify the path Y position"),
_("Change the path Y position."),
GD_T("Do _PARAM2__PARAM3_ to the Y position of the path of _PARAM0_"),
_("Path position"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("operator", GD_T("Modification sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("SetOffsetY").SetGetter("GetOffsetY").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddExpression("PathY", GD_T("Path Y position"), GD_T("Path Y position"), GD_T("Path position"), "CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("GetOffsetY").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("GetFollowAngle",
_("Automatic rotation"),
_("Return true if the object's angle is automatically updated."),
GD_T("The angle of _PARAM0_ is automatically updated on the path"),
_("Options"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("FollowAngle").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetFollowAngle",
_("De/activate automatic rotation"),
_("Activate or deactivate the automatic update of the angle of the object on the path."),
GD_T("Activate automatic rotation of _PARAM0_: _PARAM2_"),
_("Options"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("yesorno", GD_T("Activate \?"))
.SetFunctionName("SetFollowAngle").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("GetAngleOffset",
_("Angle offset"),
_("Return true if the angle offset satifies the condition."),
GD_T("The angle offset of _PARAM0_ is _PARAM2__PARAM3_"),
_("Options"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("relationalOperator", GD_T("Comparison sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("GetAngleOffset").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetAngleOffset",
_("Change the angle offset"),
_("Change the angle offset"),
GD_T("Do _PARAM2__PARAM3_ to angle offset of _PARAM0_"),
_("Options"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("operator", GD_T("Modification sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("SetAngleOffset").SetGetter("GetAngleOffset").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddExpression("AngleOffset", GD_T("Angle offset"), GD_T("Add an offset to the angle of the object"), GD_T("Options"), "CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("GetAngleOffset").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddCondition("GetSpeed",
_("Speed"),
_("Return true if the speed satisfy the condition."),
GD_T("The speed of _PARAM0_ on the path is _PARAM2__PARAM3_"),
_("Movement"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("relationalOperator", GD_T("Comparison sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("GetSpeed").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddAction("SetSpeed",
_("Change the speed"),
_("Change the speed of the object on the path."),
GD_T("Do _PARAM1__PARAM2_ to the speed of _PARAM0_ on the path"),
_("Movement"),
"CppPlatform/Extensions/pathicon24.png",
"CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.AddParameter("operator", GD_T("Modification sign"))
.AddParameter("expression", GD_T("Value"))
.SetFunctionName("SetSpeed").SetGetter("GetSpeed").SetManipulatedType("number").SetIncludeFile("PathAutomatism/PathAutomatism.h");
aut.AddExpression("Speed", GD_T("Speed"), GD_T("Moving speed on the path"), GD_T("Movement"), "CppPlatform/Extensions/pathicon16.png")
.AddParameter("object", GD_T("Object"))
.AddParameter("automatism", GD_T("Automatism"), "PathAutomatism", false)
.SetFunctionName("GetSpeed").SetIncludeFile("PathAutomatism/PathAutomatism.h");
#endif
};
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
};
};
/**
* Used by GDevelop to create the extension class
* -- Do not need to be modified. --
*/
extern "C" ExtensionBase * GD_EXTENSION_API CreateGDExtension() {
return new Extension;
}