Пример #1
0
KeyboardExtension::KeyboardExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsKeyboardExtension(*this);

    SetExtensionInformation("BuiltinKeyboard",
                          _("Keyboard features"),
                          _("Built-in extensions allowing to use keyboard"),
                          "Florian Rival",
                          "Open source (LGPL)");

    GetAllConditions()["KeyPressed"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.input.isKeyPressed").SetIncludeFile("inputtools.js");
    GetAllConditions()["KeyFromTextPressed"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.input.isKeyPressed").SetIncludeFile("inputtools.js");
    GetAllConditions()["AnyKeyPressed"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.input.anyKeyPressed").SetIncludeFile("inputtools.js");
}
Пример #2
0
    /**
     * \brief Constructor of an extension declares everything the extension contains : Objects, actions, conditions and expressions.
     */
    DestroyOutsideAutomatismJsExtension()
    {
        SetExtensionInformation("DestroyOutsideAutomatism",
                              _("Destroy Outside Screen Automatism"),
                              _("Automatism destroying object when they go outside the screen"),
                              "Florian Rival",
                              "zlib/libpng License (Open Source)");
        DeclareDestroyOutsideAutomatismExtension(*this);

        GetAutomatismMetadata("DestroyOutsideAutomatism::DestroyOutside").SetIncludeFile("DestroyOutsideAutomatism/destroyoutsideruntimeautomatism.js");

        GetAllConditionsForAutomatism("DestroyOutsideAutomatism::DestroyOutside")["DestroyOutsideAutomatism::ExtraBorder"].codeExtraInformation
            .SetFunctionName("getExtraBorder").SetIncludeFile("DestroyOutsideAutomatism/destroyoutsideruntimeautomatism.js");
        GetAllActionsForAutomatism("DestroyOutsideAutomatism::DestroyOutside")["DestroyOutsideAutomatism::ExtraBorder"].codeExtraInformation
            .SetFunctionName("setExtraBorder").SetAssociatedGetter("getExtraBorder").SetIncludeFile("DestroyOutsideAutomatism/destroyoutsideruntimeautomatism.js");

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #3
0
CommonConversionsExtension::CommonConversionsExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsCommonConversionsExtension(*this);

    SetExtensionInformation("BuiltinCommonConversions",
                          _("Standard Conversions"),
                          _("Built-in extension providing standard conversions expressions."),
                          "Florian Rival",
                          "Open source (LGPL)");

    GetAllExpressions()["ToNumber"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.common.toNumber").SetIncludeFile("commontools.js");
    GetAllStrExpressions()["ToString"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.common.toString").SetIncludeFile("commontools.js");
    GetAllStrExpressions()["LargeNumberToString"].codeExtraInformation //TODO: Check if scientific notation is added or not by toString.
        .SetFunctionName("gdjs.evtTools.common.toString").SetIncludeFile("commontools.js");
    GetAllExpressions()["ToRad"].codeExtraInformation
        .SetFunctionName("gdjs.toRad");
    GetAllExpressions()["ToDeg"].codeExtraInformation
        .SetFunctionName("gdjs.toDegrees");
}
Пример #4
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    SystemInfoCppExtension()
    {
        SetExtensionInformation("SystemInfo",
            _("System information"),
            _("Provides information about the system running the game"),
            "Florian Rival",
            "Open source (MIT License)");

        #if defined(GD_IDE_ONLY)
        AddCondition("IsMobile",
            _("Is a mobile device"),
            _("Check if the device running the game is a mobile device"),
            _("The device is a mobile device"),
            _("System information"),
            "CppPlatform/Extensions/systeminfoicon24.png",
            "CppPlatform/Extensions/systeminfoicon16.png")

            .SetFunctionName("SystemInfo::IsMobile").SetIncludeFile("SystemInfo/SystemInfoTools.h");
        #endif

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #5
0
    /**
     * \brief Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    JsExtension()
    {
        SetExtensionInformation("LinkedObjects",
                              _("Linked objects"),
                              _("Extension allowing to virtually link two objects."),
                              "Florian Rival",
                              "Open source (MIT License)");

        CloneExtension("GDevelop C++ platform", "LinkedObjects");

        GetAllActions()["LinkedObjects::LinkObjects"].codeExtraInformation.SetIncludeFile("LinkedObjects/linkedobjects.js")
            .SetFunctionName("gdjs.evtTools.linkedObjects.linkObjects");
        GetAllActions()["LinkedObjects::RemoveLinkBetween"].codeExtraInformation.SetIncludeFile("LinkedObjects/linkedobjects.js")
            .SetFunctionName("gdjs.evtTools.linkedObjects.removeLinkBetween");
        GetAllActions()["LinkedObjects::RemoveAllLinksOf"].codeExtraInformation.SetIncludeFile("LinkedObjects/linkedobjects.js")
            .SetFunctionName("gdjs.evtTools.linkedObjects.removeAllLinksOf");
        GetAllActions()["LinkedObjects::PickObjectsLinkedTo"].codeExtraInformation.SetIncludeFile("LinkedObjects/linkedobjects.js")
            .SetFunctionName("gdjs.evtTools.linkedObjects.pickObjectsLinkedTo");
        GetAllConditions()["LinkedObjects::PickObjectsLinkedTo"].codeExtraInformation.SetIncludeFile("LinkedObjects/linkedobjects.js")
            .SetFunctionName("gdjs.evtTools.linkedObjects.pickObjectsLinkedTo");

        StripUnimplementedInstructionsAndExpressions();
    };
Пример #6
0
WindowExtension::WindowExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsWindowExtension(*this);

    SetExtensionInformation("BuiltinWindow",
                          _("Window features"),
                          _("Built-in extension allowing to manipulate the game's window"),
                          "Florian Rival",
                          "Open source (MIT License)");

    GetAllActions()["SetFullScreen"].SetFunctionName("gdjs.evtTools.window.setFullScreen");
    GetAllActions()["SetWindowMargins"].SetFunctionName("gdjs.evtTools.window.setMargins");
    GetAllActions()["SetWindowTitle"].SetFunctionName("gdjs.evtTools.window.setWindowTitle");
    GetAllActions()["SetWindowSize"].SetFunctionName("gdjs.evtTools.window.setCanvasSize");

    GetAllStrExpressions()["WindowTitle"].SetFunctionName("gdjs.evtTools.window.getWindowTitle");
    GetAllExpressions()["SceneWindowWidth"].SetFunctionName("gdjs.evtTools.window.getCanvasWidth");
    GetAllExpressions()["SceneWindowHeight"].SetFunctionName("gdjs.evtTools.window.getCanvasHeight");
    GetAllExpressions()["ScreenWidth"].SetFunctionName("gdjs.evtTools.window.getWindowWidth");
    GetAllExpressions()["ScreenHeight"].SetFunctionName("gdjs.evtTools.window.getWindowHeight");

    StripUnimplementedInstructionsAndExpressions();
}
StringInstructionsExtension::StringInstructionsExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsStringInstructionsExtension(*this);

    SetExtensionInformation("BuiltinStringInstructions",
                          _("Text manipulation"),
                          _("Built-in extension providing expressions related to strings."),
                          "Florian Rival",
                          "Open source (MIT License)");

    GetAllStrExpressions()["NewLine"]
        .SetFunctionName("gdjs.evtTools.string.newLine");
    GetAllStrExpressions()["FromCodePoint"]
        .SetFunctionName("gdjs.evtTools.string.fromCodePoint");
    GetAllStrExpressions()["ToUpperCase"]
        .SetFunctionName("gdjs.evtTools.string.toUpperCase");
    GetAllStrExpressions()["ToLowerCase"]
        .SetFunctionName("gdjs.evtTools.string.toLowerCase");
    GetAllStrExpressions()["SubStr"]
        .SetFunctionName("gdjs.evtTools.string.subStr");
    GetAllStrExpressions()["StrAt"]
        .SetFunctionName("gdjs.evtTools.string.strAt");
    GetAllStrExpressions()["StrRepeat"]
        .SetFunctionName("gdjs.evtTools.string.strRepeat");
    GetAllExpressions()["StrLength"]
        .SetFunctionName("gdjs.evtTools.string.strLen");
    GetAllExpressions()["StrFind"]
        .SetFunctionName("gdjs.evtTools.string.strFind");
    GetAllExpressions()["StrRFind"]
        .SetFunctionName("gdjs.evtTools.string.strRFind");
    GetAllExpressions()["StrFindFrom"]
        .SetFunctionName("gdjs.evtTools.string.strFindFrom");
    GetAllExpressions()["StrRFindFrom"]
        .SetFunctionName("gdjs.evtTools.string.strRFindFrom");

    StripUnimplementedInstructionsAndExpressions();
}
Пример #8
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("Box3DObject",
                              _("3D Box Object"),
                              _("Extension allowing to use 3D Box objects."),
                              "Florian Rival",
                              "Open source (MIT License)");

        {
            gd::ObjectMetadata & obj = AddObject("Box3D",
                       _("3D Box"),
                       _("Displays a 3D Box"),
                       "CppPlatform/Extensions/Box3Dicon.png",
                       &CreateBox3DObject);

            AddRuntimeObject(obj, "RuntimeBox3DObject", &CreateRuntimeBox3DObject);

            #if defined(GD_IDE_ONLY)

            obj.SetIncludeFile("Box3DObject/Box3DObject.h");

            obj.AddAction("Width",
                           _("Width"),
                           _("Modify the width of a 3D Box."),
                           _("Do _PARAM1__PARAM2_ to the width of _PARAM0_"),
                           _("Size"),
                           "res/actions/scaleWidth24.png",
                           "res/actions/scaleWidth.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))

                .SetFunctionName("SetWidth").SetManipulatedType("number").SetGetter("GetWidth").SetIncludeFile("Box3DObject/Box3DObject.h");

            obj.AddCondition("Width",
                           _("Width"),
                           _("Compare the width of a 3D Box."),
                           _("width of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Size"),
                           "res/conditions/scaleWidth24.png",
                           "res/conditions/scaleWidth.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))

                .SetFunctionName("GetWidth").SetManipulatedType("number").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddAction("Height",
                           _("Height"),
                           _("Modify the height of a 3D Box."),
                           _("Do _PARAM1__PARAM2_ to the height of _PARAM0_"),
                           _("Size"),
                           "res/actions/scaleHeight24.png",
                           "res/actions/scaleHeight.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))

                .SetFunctionName("SetHeight").SetManipulatedType("number").SetGetter("GetHeight").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddCondition("Height",
                           _("Height"),
                           _("Compare the height of a 3D Box."),
                           _("height of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Size"),
                           "res/conditions/scaleHeight24.png",
                           "res/conditions/scaleHeight.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))

                .SetFunctionName("SetHeight").SetManipulatedType("number").SetGetter("GetHeight").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddAction("Depth",
                           _("Depth"),
                           _("Modify the depth of a 3D Box."),
                           _("Do _PARAM1__PARAM2_ to the depth of _PARAM0_"),
                           _("Size"),
                           "res/actions/depth24.png",
                           "res/actions/depth.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))

                .SetFunctionName("SetDepth").SetManipulatedType("number").SetGetter("GetDepth").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddCondition("Depth",
                           _("Depth"),
                           _("Compare the depth of a 3D Box."),
                           _("depth of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Size"),
                           "res/conditions/depth24.png",
                           "res/conditions/depth.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))

                .SetFunctionName("GetDepth").SetManipulatedType("number").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddAction("ZPosition",
                           _("Z Position"),
                           _("Modify the Z Position of a 3D Box."),
                           _("Do _PARAM1__PARAM2_ to the Z position of _PARAM0_"),
                           _(""),
                           "res/actions/position24.png",
                           "res/actions/position.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))

                .SetFunctionName("SetZPosition").SetManipulatedType("number").SetGetter("GetZPosition").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddCondition("ZPosition",
                           _("Z Position"),
                           _("Compare Z position of a 3D Box."),
                           _("Z position of _PARAM0_ is _PARAM1__PARAM2_"),
                           _(""),
                           "res/conditions/position24.png",
                           "res/conditions/position.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))

                .SetFunctionName("GetZPosition").SetManipulatedType("number").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddAction("Yaw",
                           _("Yaw"),
                           _("Modify Yaw of a 3D Box object."),
                           _("Do _PARAM1__PARAM2_ to yaw of _PARAM0_"),
                           _("Angle"),
                           "res/actions/rotate24.png",
                           "res/actions/rotate.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))

                .SetFunctionName("SetAngle").SetManipulatedType("number").SetGetter("GetAngle").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddCondition("Yaw",
                           _("Yaw"),
                           _("Compare Yaw of a 3D Box object."),
                           _("Yaw of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Angle"),
                           "res/conditions/rotate24.png",
                           "res/conditions/rotate.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))

                .SetFunctionName("GetAngle").SetManipulatedType("number").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddAction("Pitch",
                           _("Pitch"),
                           _("Modify Pitch of a 3D Box object."),
                           _("Do _PARAM1__PARAM2_ to pitch of _PARAM0_"),
                           _("Angle"),
                           "res/actions/rotate24.png",
                           "res/actions/rotate.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))

                .SetFunctionName("SetPitch").SetManipulatedType("number").SetGetter("GetPitch").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddCondition("Pitch",
                           _("Pitch"),
                           _("Compare Pitch of a 3D Box object."),
                           _("Pitch of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Angle"),
                           "res/conditions/rotate24.png",
                           "res/conditions/rotate.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))

                .SetFunctionName("GetPitch").SetManipulatedType("number").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddAction("Roll",
                           _("Roll"),
                           _("Modify Roll of a 3D Box object."),
                           _("Do _PARAM1__PARAM2_ to roll of _PARAM0_"),
                           _("Angle"),
                           "res/actions/rotate24.png",
                           "res/actions/rotate.png")
                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))

                .SetFunctionName("SetRoll").SetManipulatedType("number").SetGetter("GetRoll").SetIncludeFile("Box3DObject/Box3DObject.h");


            obj.AddCondition("Roll",
                           _("Roll"),
                           _("Compare Roll of a 3D Box object."),
                           _("Roll of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Angle"),
                           "res/conditions/rotate24.png",
                           "res/conditions/rotate.png")

                .AddParameter("object", _("Object"), "Box3D")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))
                .SetFunctionName("GetRoll").SetManipulatedType("number").SetIncludeFile("Box3DObject/Box3DObject.h");

            obj.AddExpression("Depth", _("Depth of the 3D Box"), _("Depth of the 3D Box"), _("Size"), "res/actions/scaleHeight.png")
                .AddParameter("object", _("Object"), "Box3D")
                .codeExtraInformation.SetFunctionName("GetDepth").SetIncludeFile("Box3DObject/Box3DObject.h");

            obj.AddExpression("Z", _("Z Position"), _("Z Position"), _("Position"), "res/actions/scaleHeight.png")
                .AddParameter("object", _("Object"), "Box3D")
                .SetFunctionName("GetZPosition").SetIncludeFile("Box3DObject/Box3DObject.h");

            obj.AddExpression("Yaw", _("Yaw"), _("Yaw"), _("Angle"), "res/actions/scaleHeight.png")
                .AddParameter("object", _("Object"), "Box3D")
                .SetFunctionName("GetAngle").SetIncludeFile("Box3DObject/Box3DObject.h");

            obj.AddExpression("Pitch", _("Pitch"), _("Pitch"), _("Angle"), "res/actions/scaleHeight.png")
                .AddParameter("object", _("Object"), "Box3D")
                .SetFunctionName("GetPitch").SetIncludeFile("Box3DObject/Box3DObject.h");

            obj.AddExpression("Roll", _("Roll"), _("Roll"), _("Angle"), "res/actions/scaleHeight.png")
                .AddParameter("object", _("Object"), "Box3D")
                .SetFunctionName("GetRoll").SetIncludeFile("Box3DObject/Box3DObject.h");

            #endif

        }

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #9
0
SceneExtension::SceneExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsSceneExtension(*this);

    SetExtensionInformation("BuiltinScene",
                          _("Scene management features"),
                          _("Built-in extension allowing to manipulate scenes"),
                          "Florian Rival",
                          "Open source (LGPL)");

    GetAllExpressions()["Random"].codeExtraInformation
        .SetFunctionName("gdjs.random");

    GetAllConditions()["DepartScene"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.runtimeScene.sceneJustBegins");
    GetAllActions()["SceneBackground"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.runtimeScene.setBackgroundColor");
    GetAllActions()["Scene"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.runtimeScene.changeScene");
    GetAllActions()["Quit"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.runtimeScene.stopGame");

    {
        class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
        {
            virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
            {
                std::string value1Code;
                {
                    gd::CallbacksForGeneratingExpressionCode callbacks(value1Code, codeGenerator, context);
                    gd::ExpressionParser parser(instruction.GetParameters()[0].GetPlainString());
                    if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks) || value1Code.empty()) value1Code = "0";
                }

                std::string value2Code;
                {
                    gd::CallbacksForGeneratingExpressionCode callbacks(value2Code, codeGenerator, context);
                    gd::ExpressionParser parser(instruction.GetParameters()[2].GetPlainString());
                    if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks) || value2Code.empty()) value2Code = "0";
                }

                std::string resultingBoolean = codeGenerator.GenerateBooleanFullName("conditionTrue", context)+".val";

                if ( instruction.GetParameters()[1].GetPlainString() == "=" || instruction.GetParameters()[1].GetPlainString().empty() )
                    return resultingBoolean + " = ("+value1Code+" == "+value2Code+");\n";
                else if ( instruction.GetParameters()[1].GetPlainString() == ">")
                    return resultingBoolean + " = ("+value1Code+" > "+value2Code+");\n";
                else if ( instruction.GetParameters()[1].GetPlainString() == "<")
                    return resultingBoolean + " = ("+value1Code+" < "+value2Code+");\n";
                else if ( instruction.GetParameters()[1].GetPlainString() == "<=")
                    return resultingBoolean + " = ("+value1Code+" <= "+value2Code+");\n";
                else if ( instruction.GetParameters()[1].GetPlainString() == ">=")
                    return resultingBoolean + " = ("+value1Code+" >= "+value2Code+");\n";
                else if ( instruction.GetParameters()[1].GetPlainString() == "!=")
                    return resultingBoolean + " = ("+value1Code+" != "+value2Code+");\n";

                return "";
            };
        };
        gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGenerator = new CodeGenerator;

        GetAllConditions()["Egal"].codeExtraInformation
            .SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGenerator));
    }

    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:
        /*

    AddAction("DisableInputWhenFocusIsLost",
                   _("Disable input when focus is lost"),
                   _("Set if the keyboard and mouse buttons must be taken into account even\nif the window is not active."),
                   _("Disable input when focus is lost: _PARAM1_"),
                   _("Scene"),
                   "res/actions/window24.png",
                   "res/actions/window.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("yesorno", _("Deactivate input when focus is lost"))
        .codeExtraInformation.SetFunctionName("DisableInputWhenFocusIsLost").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneTools.h");
        */

}
Пример #10
0
    /**
     * Constructor of an extension declares everything the extension contains : Objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("Light",
                              _("Light"),
                              _("Allow to display lights and use light obstacles."),
                              "Florian Rival",
                              "zlib/libpng License (Open Source)");

            {
                gd::ObjectMetadata & obj = AddObject("Light",
                           _("Light"),
                           _("Emits light that can be stopped by objects"),
                           "CppPlatform/Extensions/lightIcon32.png",
                           &CreateLightObject,
                           &DestroyLightObject);

                AddRuntimeObject(obj, "RuntimeLightObject", CreateRuntimeLightObject,DestroyRuntimeLightObject);

                #if defined(GD_IDE_ONLY)
                LightObject::LoadEdittimeIcon();
                obj.SetIncludeFile("Light/LightObject.h");

                obj.AddAction("ChangeColor",
                               _("Color"),
                               _("Change light color."),
                               _("Change color of _PARAM0_ to _PARAM1_"),
                               _("Setup"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("color", _("Color"))
                    .codeExtraInformation.SetFunctionName("SetColor").SetIncludeFile("Light/LightObject.h");


                obj.AddAction("Intensity",
                               _("Intensity"),
                               _("Modify the intensity of a light"),
                               _("Do _PARAM1__PARAM2_ to the intensity of _PARAM0_"),
                               _("Setup"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("operator", _("Modification's sign"))
                    .AddParameter("expression", _("Value"))
                .codeExtraInformation.SetFunctionName("SetIntensity").SetManipulatedType("number").SetAssociatedGetter("GetIntensity").SetIncludeFile("Light/LightObject.h");


                obj.AddCondition("Intensity",
                               _("Intensity"),
                               _("Test the intensity of a light."),
                               _("Intensity of _PARAM0_ is _PARAM1__PARAM2_"),
                               _("Setup"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("relationalOperator", _("Sign of the test"))
                    .AddParameter("expression", _("Value to test"))
                .codeExtraInformation.SetFunctionName("GetIntensity").SetManipulatedType("number").SetIncludeFile("Light/LightObject.h");


                obj.AddAction("Radius",
                               _("Radius"),
                               _("Modify the radius of a liht"),
                               _("Do _PARAM1__PARAM2_ to radius of _PARAM0_"),
                               _("Setup"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("operator", _("Modification's sign"))
                    .AddParameter("expression", _("Value"))
                .codeExtraInformation.SetFunctionName("SetRadius").SetManipulatedType("number").SetAssociatedGetter("GetRadius").SetIncludeFile("Light/LightObject.h");


                obj.AddCondition("Radius",
                               _("Radius"),
                               _("Test the radius of a light."),
                               _("The radius of _PARAM0_ is _PARAM2_ _PARAM1_"),
                               _("Setup"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("relationalOperator", _("Sign of the test"))
                    .AddParameter("expression", _("Value to test"))
                .codeExtraInformation.SetFunctionName("GetRadius").SetManipulatedType("number").SetIncludeFile("Light/LightObject.h");


                obj.AddAction("Quality",
                               _("Quality"),
                               _("Modify the quality of a light"),
                               _("Do _PARAM1__PARAM2_ to the quality of _PARAM0_"),
                               _("Setup"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("operator", _("Modification's sign"))
                    .AddParameter("expression", _("Value"))
                .codeExtraInformation.SetFunctionName("SetQuality").SetManipulatedType("number").SetAssociatedGetter("GetQuality").SetIncludeFile("Light/LightObject.h");


                obj.AddCondition("Quality",
                               _("Quality"),
                               _("Test the quality of a light"),
                               _("The quality of _PARAM0_ is _PARAM1__PARAM2_"),
                               _("Setup"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("relationalOperator", _("Sign of the test"))
                    .AddParameter("expression", _("Value to test"))
                .codeExtraInformation.SetFunctionName("GetQuality").SetManipulatedType("number").SetIncludeFile("Light/LightObject.h");


                obj.AddAction("ChangeGlobalColor",
                               _("Global color"),
                               _("Change scene color for a global light."),
                               _("Change scene global color of _PARAM0_ to _PARAM1_"),
                               _("Setup"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("color", _("Color"))
                .codeExtraInformation.SetFunctionName("SetGlobalColor").SetIncludeFile("Light/LightObject.h");


                obj.AddAction("SetGlobalLight",
                               _("Make a light global"),
                               _("Make a light global or simple."),
                               _("Make _PARAM0_ global : _PARAM1_"),
                               _("Light type"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("yesorno", _("Make light global"))
                .codeExtraInformation.SetFunctionName("SetGlobalLight").SetIncludeFile("Light/LightObject.h");


                obj.AddCondition("GlobalLight",
                               _("A light is global"),
                               _("Return true if light is global"),
                               _("_PARAM0_ is a global light"),
                               _("Light type"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                .codeExtraInformation.SetFunctionName("IsGlobalLight").SetIncludeFile("Light/LightObject.h");


/*
                obj.AddAction("Angle",
                               _("Change the angle"),
                               _("Modify the angle of a Text object."),
                               _("Do _PARAM1__PARAM2_ to the angle of _PARAM0_"),
                               _("Rotation"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png",
                               &LightObject::ActAngle)
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("operator", _("Modification's sign"))
                    .AddParameter("expression", _("Value"))



                obj.AddCondition("Angle",
                               _("Angle d'un objet texte"),
                               _("Test the value of the angle of a text object."),
                               _("The angle of _PARAM0_ is _PARAM1__PARAM2_"),
                               _("Rotation"),
                               "CppPlatform/Extensions/lightIcon24.png",
                               "CppPlatform/Extensions/lightIcon16.png",
                               &LightObject::CondAngle)
                    .AddParameter("object", _("Object"), "Light", false)
                    .AddParameter("relationalOperator", _("Sign of the test"))
                    .AddParameter("expression", _("Value to test"))

*/

                obj.AddExpression("Intensity", _("Intensity"), _("Intensity"), _("Setup"), "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .codeExtraInformation.SetFunctionName("GetIntensity").SetIncludeFile("Light/LightObject.h");

                obj.AddExpression("Radius", _("Radius"), _("Radius"), _("Setup"), "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .codeExtraInformation.SetFunctionName("GetRadius").SetIncludeFile("Light/LightObject.h");

                obj.AddExpression("Quality", _("Quality"), _("Quality"), _("Setup"), "CppPlatform/Extensions/lightIcon16.png")
                    .AddParameter("object", _("Object"), "Light", false)
                    .codeExtraInformation.SetFunctionName("GetQuality").SetIncludeFile("Light/LightObject.h");


                /*
                obj.AddExpression("Angle", _("Angle"), _("Angle"), _("Light"), "CppPlatform/Extensions/lightIcon16.png", &LightObject::ExpAngle)
                    .AddParameter("object", _("Object"), "Light", false)
*/

                #endif

            }

            {
                AddAutomatism("LightObstacleAutomatism",
                      _("Light obstacle"),
                      _("LightObstacle"),
                      _("Mark the objects as obstacles for Light objects."),
                      "",
                      "CppPlatform/Extensions/lightObstacleicon32.png",
                      "LightObstacleAutomatism",
                      boost::shared_ptr<gd::Automatism>(new LightObstacleAutomatism),
                      boost::shared_ptr<gd::AutomatismsSharedData>(new SceneLightObstacleDatas));

            };

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #11
0
    /**
     * \brief Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    PlatformBehaviorJsExtension()
    {
        SetExtensionInformation("PlatformBehavior",
                              _("Platform Behavior"),
                              _("Allows to use controllable objects which can run and jump on platforms."),
                              "Florian Rival",
                              "Open source (MIT License)");
        DeclarePlatformBehaviorExtension(*this);

        GetBehaviorMetadata("PlatformBehavior::PlatformBehavior")
            .SetIncludeFile("PlatformBehavior/platformruntimebehavior.js")
            .AddIncludeFile("PlatformBehavior/platformerobjectruntimebehavior.js");

        GetBehaviorMetadata("PlatformBehavior::PlatformerObjectBehavior")
            .SetIncludeFile("PlatformBehavior/platformruntimebehavior.js")
            .AddIncludeFile("PlatformBehavior/platformerobjectruntimebehavior.js");

        {

            std::map<gd::String, gd::InstructionMetadata > & autActions = GetAllActionsForBehavior("PlatformBehavior::PlatformerObjectBehavior");
            std::map<gd::String, gd::InstructionMetadata > & autConditions = GetAllConditionsForBehavior("PlatformBehavior::PlatformerObjectBehavior");
            std::map<gd::String, gd::ExpressionMetadata > & autExpressions = GetAllExpressionsForBehavior("PlatformBehavior::PlatformerObjectBehavior");

            autConditions["PlatformBehavior::IsMoving"].SetFunctionName("isMoving");
            autConditions["PlatformBehavior::IsOnFloor"].SetFunctionName("isOnFloor");
            autConditions["PlatformBehavior::IsOnLadder"].SetFunctionName("isOnLadder");
            autConditions["PlatformBehavior::IsJumping"].SetFunctionName("isJumping");
            autConditions["PlatformBehavior::IsFalling"].SetFunctionName("isFalling");
            autConditions["PlatformBehavior::IsGrabbingPlatform"].SetFunctionName("isGrabbingPlatform");

            autConditions["PlatformBehavior::Gravity"].SetFunctionName("getGravity");
            autActions["PlatformBehavior::Gravity"].SetFunctionName("setGravity").SetGetter("getGravity");
            autExpressions["Gravity"].SetFunctionName("getGravity");
            autConditions["PlatformBehavior::MaxFallingSpeed"].SetFunctionName("getMaxFallingSpeed");
            autActions["PlatformBehavior::MaxFallingSpeed"].SetFunctionName("setMaxFallingSpeed").SetGetter("getMaxFallingSpeed");
            autExpressions["MaxFallingSpeed"].SetFunctionName("getMaxFallingSpeed");
            autConditions["PlatformBehavior::Acceleration"].SetFunctionName("getAcceleration");
            autActions["PlatformBehavior::Acceleration"].SetFunctionName("setAcceleration").SetGetter("getAcceleration");
            autExpressions["Acceleration"].SetFunctionName("getAcceleration");
            autConditions["PlatformBehavior::Deceleration"].SetFunctionName("getDeceleration");
            autActions["PlatformBehavior::Deceleration"].SetFunctionName("setDeceleration").SetGetter("getDeceleration");
            autExpressions["Deceleration"].SetFunctionName("getDeceleration");
            autConditions["PlatformBehavior::MaxSpeed"].SetFunctionName("getMaxSpeed");
            autActions["PlatformBehavior::MaxSpeed"].SetFunctionName("setMaxSpeed").SetGetter("getMaxSpeed");
            autExpressions["MaxSpeed"].SetFunctionName("getMaxSpeed");
            autConditions["PlatformBehavior::JumpSpeed"].SetFunctionName("getJumpSpeed");
            autActions["PlatformBehavior::JumpSpeed"].SetFunctionName("setJumpSpeed").SetGetter("getJumpSpeed");
            autExpressions["JumpSpeed"].SetFunctionName("getJumpSpeed");

            autActions["PlatformBehavior::SetCanJump"].SetFunctionName("setCanJump");
            autActions["PlatformBehavior::SimulateLeftKey"].SetFunctionName("simulateLeftKey");
            autActions["PlatformBehavior::SimulateRightKey"].SetFunctionName("simulateRightKey");
            autActions["PlatformBehavior::SimulateUpKey"].SetFunctionName("simulateUpKey");
            autActions["PlatformBehavior::SimulateDownKey"].SetFunctionName("simulateDownKey");
            autActions["PlatformBehavior::SimulateLadderKey"].SetFunctionName("simulateLadderKey");
            autActions["PlatformBehavior::SimulateJumpKey"].SetFunctionName("simulateJumpKey");
            autActions["PlatformBehavior::SimulateReleaseKey"].SetFunctionName("simulateReleaseKey");
            autActions["PlatformBehavior::SimulateControl"].SetFunctionName("simulateControl");
            autActions["PlatformBehavior::IgnoreDefaultControls"].SetFunctionName("ignoreDefaultControls");
        }
        {
            std::map<gd::String, gd::InstructionMetadata > & autActions = GetAllActionsForBehavior("PlatformBehavior::PlatformBehavior");

            autActions["PlatformBehavior::ChangePlatformType"].SetFunctionName("changePlatformType");
        }
        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #12
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("Inventory",
                              _("Inventory"),
                              _("Provides action and condition to store an inventory with items in memory."),
                              "Florian Rival",
                              "Open source (MIT License)");

        #if defined(GD_IDE_ONLY)
        AddAction("Add",
                       _("Add an item"),
                       _("Add an item in an inventory."),
                       _("Add a _PARAM2_ to inventory _PARAM1_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .SetFunctionName("InventoryTools::Add").SetIncludeFile("Inventory/InventoryTools.h");

        AddAction("Remove",
                       _("Remove an item"),
                       _("Remove an item from an inventory."),
                       _("Remove a _PARAM2_ from inventory _PARAM1_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .SetFunctionName("InventoryTools::Remove").SetIncludeFile("Inventory/InventoryTools.h");

        AddCondition("Count",
                       _("Item count"),
                       _("Compare the number of an item in an inventory."),
                       _("Count of _PARAM2_ in _PARAM1_ is _PARAM3__PARAM4_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Count"))
            .SetFunctionName("InventoryTools::Count").SetIncludeFile("Inventory/InventoryTools.h")
            .SetManipulatedType("number");

        AddCondition("Has",
                       _("Has an item"),
                       _("Check that there is at least one of the specified item in the inventory."),
                       _("Inventory _PARAM1_ contains a _PARAM2_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .SetFunctionName("InventoryTools::Has").SetIncludeFile("Inventory/InventoryTools.h");

        AddAction("SetMaximum",
                       _("Set a maximum count for an item"),
                       _("Set the maximum number that can be added in the inventory for the specified item. By default, there is an unlimited number allowed for each item."),
                       _("Set the maximum count for _PARAM2_ in inventory _PARAM1_ to _PARAM3_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .AddParameter("expression", _("Maximum count"))
            .SetFunctionName("InventoryTools::SetMaximum").SetIncludeFile("Inventory/InventoryTools.h");

        AddAction("SetUnlimited",
                       _("Set unlimited count for an item"),
                       _("Allow an unlimited amount of an object to be in an inventory. This is the case by default for each item."),
                       _("Allow an unlimited count of _PARAM2_ in inventory _PARAM1_: _PARAM3_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .AddParameter("yesorno", _("Allow an unlimited amount?"))
            .SetFunctionName("InventoryTools::SetUnlimited").SetIncludeFile("Inventory/InventoryTools.h");

        AddCondition("IsFull",
                       _("Item full"),
                       _("Check if an item has reached the maximum number allowed in the inventory."),
                       _("Inventory _PARAM1_ is full of _PARAM2_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .SetFunctionName("InventoryTools::Has").SetIncludeFile("Inventory/InventoryTools.h");

        AddAction("Equip",
                       _("Equip an item"),
                       _("Mark an item as being equiped. If the item count is 0 it won't be marked as equiped."),
                       _("Set _PARAM2_ as equiped in inventory _PARAM1_: _PARAM3_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .AddParameter("yesorno", _("Equip?"))
            .SetFunctionName("InventoryTools::Equip").SetIncludeFile("Inventory/InventoryTools.h");

        AddCondition("IsEquipped",
                       _("Item equiped"),
                       _("Check if an item is equiped."),
                       _("_PARAM2_ is equipped in inventory _PARAM1_"),
                       _("Inventories"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .SetFunctionName("InventoryTools::IsEquipped").SetIncludeFile("Inventory/InventoryTools.h");

        AddAction("SerializeToVariable",
                       _("Save an inventory in a variable"),
                       _("Save all the items of the inventory in a variable, so that it can be restored later."),
                       _("Save inventory _PARAM1_ in variable _PARAM2_"),
                       _("Inventories/Variables"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("scenevar", _("Scene variable"))
            .SetFunctionName("InventoryTools::SerializeToVariable").SetIncludeFile("Inventory/InventoryTools.h");

        AddAction("UnserializeFromVariable",
                       _("Load an inventory from a variable"),
                       _("Load the content of the inventory from a variable."),
                       _("Load inventory _PARAM1_ from variable _PARAM2_"),
                       _("Inventories/Variables"),
                       "CppPlatform/Extensions/Inventoryicon24.png",
                       "CppPlatform/Extensions/Inventoryicon16.png")

            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Inventory name"))
            .AddParameter("scenevar", _("Scene variable"))
            .SetFunctionName("InventoryTools::UnserializeFromVariable").SetIncludeFile("Inventory/InventoryTools.h");

        AddExpression("Count", _("Item count"), _("Get the number of an item in the inventory"), _("Inventory"), "CppPlatform/Extensions/Inventoryicon16.png")
            .AddCodeOnlyParameter("currentScene", _(""))
            .AddParameter("string", _("Inventory name"))
            .AddParameter("string", _("Item name"))
            .SetFunctionName("InventoryTools::Count").SetIncludeFile("Inventory/InventoryTools.h");

        #endif

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #13
0
SpriteExtension::SpriteExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsSpriteExtension(*this);

    SetExtensionInformation("Sprite",
                          _("Sprite"),
                          _("Extension for adding animated objects in the scene, which can contain animations with directions within each."),
                          "Florian Rival",
                          "Open source (MIT License)");

    std::map<gd::String, gd::InstructionMetadata > & spriteActions = GetAllActionsForObject("Sprite");
    std::map<gd::String, gd::InstructionMetadata > & spriteConditions = GetAllConditionsForObject("Sprite");
    std::map<gd::String, gd::ExpressionMetadata > & spriteExpressions = GetAllExpressionsForObject("Sprite");
    spriteActions["ChangeBlendMode"].SetFunctionName("setBlendMode").SetIncludeFile("spriteruntimeobject.js");
    spriteActions["Opacity"].SetFunctionName("setOpacity").SetGetter("getOpacity").SetIncludeFile("spriteruntimeobject.js");
    spriteConditions["BlendMode"].SetFunctionName("getBlendMode").SetIncludeFile("spriteruntimeobject.js");
    spriteConditions["Opacity"].SetFunctionName("getOpacity").SetIncludeFile("spriteruntimeobject.js");

    spriteActions["ChangeAnimation"].SetFunctionName("setAnimation").SetGetter("getAnimation");
    spriteActions["ChangeDirection"].SetFunctionName("setDirectionOrAngle").SetGetter("getDirectionOrAngle");
    spriteActions["ChangeSprite"].SetFunctionName("setAnimationFrame").SetGetter("getAnimationFrame");
    spriteConditions["Animation"].SetFunctionName("getAnimation");
    spriteConditions["Direction"].SetFunctionName("getDirectionOrAngle");
    spriteConditions["Sprite"].SetFunctionName("getAnimationFrame");
    spriteConditions["AnimationEnded"].SetFunctionName("hasAnimationEnded");
    spriteActions["PauseAnimation"].SetFunctionName("pauseAnimation");
    spriteActions["PlayAnimation"].SetFunctionName("playAnimation");
    spriteConditions["AnimStopped"].SetFunctionName("animationPaused");
    spriteActions["ChangeAnimationSpeedScale"].SetFunctionName("setAnimationSpeedScale").SetGetter("getAnimationSpeedScale").SetManipulatedType("number").SetIncludeFile("spriteruntimeobject.js");


    spriteActions["ChangeScaleWidth"].SetFunctionName("setScaleX").SetGetter("getScaleX");
    spriteActions["ChangeScaleHeight"].SetFunctionName("setScaleY").SetGetter("getScaleY");
    spriteActions["ChangeScale"].SetFunctionName("setScale").SetManipulatedType("number").SetGetter("getScale");
    spriteConditions["ScaleWidth"].SetFunctionName("getScaleX");
    spriteConditions["ScaleHeight"].SetFunctionName("getScaleY");
    spriteActions["TourneVersPos"].SetFunctionName("rotateTowardPosition");
    spriteActions["TourneVers"].SetFunctionName("turnTowardObject");
    spriteActions["ChangeColor"].SetFunctionName("setColor");
    spriteActions["FlipX"].SetFunctionName("flipX");
    spriteActions["FlipY"].SetFunctionName("flipY");
    spriteConditions["FlippedX"].SetFunctionName("isFlippedX");
    spriteConditions["FlippedY"].SetFunctionName("isFlippedY");

    GetAllConditions()["Collision"]
        .AddCodeOnlyParameter("currentScene", "") //We need an extra parameter pointing to the scene.
        .SetFunctionName("gdjs.evtTools.object.hitBoxesCollisionTest"); //No pixel perfect collision for now on the JS platform.

    spriteExpressions["X"].SetFunctionName("getPointX");
    spriteExpressions["Y"].SetFunctionName("getPointY");
    spriteExpressions["PointX"].SetFunctionName("getPointX");
    spriteExpressions["PointY"].SetFunctionName("getPointY");
    spriteExpressions["Direc"].SetFunctionName("getDirectionOrAngle"); //Deprecated
    spriteExpressions["Direction"].SetFunctionName("getDirectionOrAngle");
    spriteExpressions["Anim"].SetFunctionName("getAnimation"); //Deprecated
    spriteExpressions["Animation"].SetFunctionName("getAnimation");
    spriteExpressions["Sprite"].SetFunctionName("getAnimationFrame");
    spriteExpressions["AnimationSpeedScale"].SetFunctionName("getAnimationSpeedScale");
    spriteExpressions["ScaleX"].SetFunctionName("getScaleX");
    spriteExpressions["ScaleY"].SetFunctionName("getScaleY");


    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:
/*
    //Objects instructions:
    {
        obj.AddAction("CopyImageOnImageOfSprite",
                       _("Copy an image on the current one of an object"),
                       _("Copy an image on the current image of an object.\nNote that the source image must be preferably kept loaded in memory."),
                       _("Copy image _PARAM2_ on the current of _PARAM0_ at _PARAM3_;_PARAM4_"),
                       _("Effects"),
                       "res/copy24.png",
                       "res/copyicon.png")

            .AddParameter("object", _("Object"), "Sprite")
            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Name of the source image"))
            .AddParameter("expression", _("X position"))
            .AddParameter("expression", _("Y position"))
            .AddParameter("yesorno", _("Should the copy take in account the source transparency\?"))
            .SetFunctionName("CopyImageOnImageOfCurrentSprite").SetIncludeFile("GDCpp/RuntimeSpriteObject.h");



        obj.AddAction("CreateMaskFromColorOnActualImage", //Actual is indeed a mistake : Current should have been chosen.
                       _("Make a color of the image of an object transparent"),
                       _("Make a color of the image of an object transparent."),
                       _("Make color _PARAM1_ of the current image of _PARAM0_ transparent"),
                       _("Effects"),
                       "res/actions/opacity24.png",
                       "res/actions/opacity.png")

            .AddParameter("object", _("Object"), "Sprite")
            .AddParameter("color", _("Color to make transparent"))
            .SetFunctionName("MakeColorTransparent").SetIncludeFile("GDCpp/RuntimeSpriteObject.h");
    }

*/
}
Пример #14
0
FileExtension::FileExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsFileExtension(*this);

    SetExtensionInformation("BuiltinFile",
                          _("Files"),
                          _("Built-in extension providing functions for storing data."),
                          "Florian Rival",
                          "Open source (LGPL)");

    GetAllActions()["LoadFile"]
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.loadJSONFileFromStorage");
    GetAllConditions()["GroupExists"]
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.elementExistsInJSONFile");
    GetAllActions()["UnloadFile"]
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.unloadJSONFile");
    GetAllActions()["EcrireFichierExp"]
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.writeNumberInJSONFile");
    GetAllActions()["EcrireFichierTxt"]
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.writeStringInJSONFile");
    GetAllActions()["LireFichierExp"]
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.readNumberFromJSONFile");
    GetAllActions()["LireFichierTxt"]
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.readStringFromJSONFile");
    GetAllActions()["DeleteGroupFichier"]
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.deleteElementFromJSONFile");
    GetAllActions()["DeleteFichier"].SetGroup(_("Storage"))
        .codeExtraInformation.SetFunctionName("gdjs.evtTools.storage.clearJSONFile");

    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:
    /*
    AddCondition("FileExists",
                   _("A file exists"),
                   _("Test if the file exists."),
                   _("The file _PARAM0_ exists"),
                   _("Files"),
                   "res/conditions/fichier24.png",
                   "res/conditions/fichier.png")
        .AddParameter("file", _("Filename"), "",false)
        .codeExtraInformation.SetFunctionName("FileExists").SetIncludeFile("GDCpp/BuiltinExtensions/FileTools.h");

    AddAction("LaunchFile",
                   _("Launch a file"),
                   _("This action launch the specified file."),
                   _("Launch the file _PARAM0_"),
                   _("Files"),
                   "res/actions/launchFile24.png",
                   "res/actions/launchFile.png")
        .AddParameter("file", _("Filename"), "",false)
        .codeExtraInformation.SetFunctionName("LaunchFile").SetIncludeFile("GDCpp/BuiltinExtensions/FileTools.h");

    AddAction("ExecuteCmd",
                   _("Execute a command"),
                   _("This action execute the specified command."),
                   _("Execute _PARAM0_"),
                   _("Files"),
                   "res/actions/launchFile24.png",
                   "res/actions/launchFile.png")
        .AddParameter("string", _("Command"), "",false)
        .codeExtraInformation.SetFunctionName("ExecuteCmd").SetIncludeFile("GDCpp/BuiltinExtensions/FileTools.h");
    */
}
Пример #15
0
CameraExtension::CameraExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsCameraExtension(*this);

    SetExtensionInformation("BuiltinCamera",
                          _("Cameras and layers features"),
                          _("Builtin camera extension"),
                          "Florian Rival",
                          "Open source (LGPL)");

    GetAllActions()["CameraX"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.setCameraX").SetAssociatedGetter("gdjs.evtTools.camera.getCameraX");
    GetAllActions()["CameraY"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.setCameraY").SetAssociatedGetter("gdjs.evtTools.camera.getCameraY");
    GetAllConditions()["CameraX"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraX");
    GetAllConditions()["CameraY"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraY");
    GetAllConditions()["CameraWidth"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraWidth");
    GetAllConditions()["CameraHeight"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraHeight");
    GetAllActions()["ShowLayer"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.showLayer");
    GetAllActions()["HideLayer"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.hideLayer");
    GetAllConditions()["LayerVisible"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.layerIsVisible");
    GetAllConditions()["CameraAngle"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraRotation");
    GetAllActions()["RotateCamera"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.setCameraRotation").SetAssociatedGetter("gdjs.evtTools.camera.getCameraRotation");
    GetAllActions()["ZoomCamera"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.setCameraZoom");

    GetAllExpressions()["CameraX"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraX");
    GetAllExpressions()["VueX"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraX");
    GetAllExpressions()["CameraY"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraY");
    GetAllExpressions()["VueY"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraY");
    GetAllExpressions()["CameraRotation"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraRotation");
    GetAllExpressions()["VueRotation"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraRotation");
    GetAllExpressions()["CameraWidth"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraWidth");
    GetAllExpressions()["CameraHeight"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.getCameraHeight");

    GetAllActions()["FixCamera"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.centerCameraWithinLimits");
    GetAllActions()["CentreCamera"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.camera.centerCamera");

    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:
/*
    AddAction("AddCamera",
                   _("Add a camera to a layer"),
                   _("This action add a camera to a layer"),
                   _("Add a camera to layer _PARAM1_"),
                   _("Layers and cameras"),
                   "res/actions/camera24.png",
                   "res/actions/camera.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("layer", _("Layer ( Base layer if empty )"), "",false).SetDefaultValue("\"\"")
        .AddParameter("expression", _("Width"), "",true)
        .AddParameter("expression", _("Height"), "",true)
        .AddParameter("expression", _("Render zone: Top left side: X Position ( Between 0 and 1 )"), "",true)
        .AddParameter("expression", _("Render zone: Top left side: Y Position ( Between 0 and 1 )"), "",true)
        .AddParameter("expression", _("Render zone: Bottom right side: X Position ( Between 0 and 1 )"), "",true)
        .AddParameter("expression", _("Render zone: Bottom right side: Y Position ( Between 0 and 1 )"), "",true)
        .codeExtraInformation.SetFunctionName("AddCamera").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneCameraTools.h");

    AddAction("DeleteCamera",
                   _("Delete a camera of a layer"),
                   _("Remove the specified camera from a layer"),
                   _("Delete camera _PARAM2_ from layer _PARAM1_"),
                   _("Layers and cameras"),
                   "res/actions/camera24.png",
                   "res/actions/camera.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("layer", _("Layer ( Base layer if empty )"), "",false).SetDefaultValue("\"\"")
        .AddParameter("expression", _("Camera number"), "",false)
        .codeExtraInformation.SetFunctionName("DeleteCamera").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneCameraTools.h");

    AddAction("CameraSize",
                   _("Modify the size of a camera"),
                   _("This action modify the size of a camera of the specified layer. The zoom will be reset."),
                   _("Change the size of camera _PARAM2_ of _PARAM1_ to _PARAM3_*_PARAM4_"),
                   _("Layers and cameras"),
                   "res/actions/camera24.png",
                   "res/actions/camera.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("layer", _("Layer ( Base layer if empty )"), "",false).SetDefaultValue("\"\"")
        .AddParameter("expression", _("Camera number"), "",false)
        .AddParameter("expression", _("Width"), "",false)
        .AddParameter("expression", _("Height"), "",false)
        .codeExtraInformation.SetFunctionName("SetCameraSize").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneCameraTools.h");

    AddAction("CameraViewport",
                   _("Modify the render zone of a camera"),
                   _("This action modify the render zone of a camera of the specified layer."),
                   _("Set the render zone of camera _PARAM2_ from layer _PARAM1_ to PARAM3_;_PARAM4_ _PARAM5_;_PARAM6_"),
                   _("Layers and cameras"),
                   "res/actions/camera24.png",
                   "res/actions/camera.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("layer", _("Layer ( Base layer if empty )"), "",false).SetDefaultValue("\"\"")
        .AddParameter("expression", _("Camera number"), "",false)
        .AddParameter("expression", _("Render zone: Top left side: X Position ( Between 0 and 1 )"), "",false)
        .AddParameter("expression", _("Render zone: Top left side: X Position ( Between 0 and 1 )"), "",false)
        .AddParameter("expression", _("Render zone: Bottom right side: X Position ( Between 0 and 1 )"), "",false)
        .AddParameter("expression", _("Render zone: Bottom right side: X Position ( Between 0 and 1 )"), "",false)
        .codeExtraInformation.SetFunctionName("SetCameraViewport").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneCameraTools.h");

    AddExpression("CameraViewportLeft", _("X position of the top left side point of a render zone"), _("X position of the top left side point of a render zone"), _("Camera"), "res/actions/camera.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("layer", _("Layer"), "",false)
        .AddParameter("expression", _("Camera number ( default : 0 )"), "",false).SetDefaultValue("0")
        .codeExtraInformation.SetFunctionName("GetCameraViewportLeft").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneCameraTools.h");


    AddExpression("CameraViewportTop", _("Y position of the top left side point of a render zone"), _("Y position of the top left side point of a render zone"), _("Camera"), "res/actions/camera.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("layer", _("Layer"), "",false)
        .AddParameter("expression", _("Camera number ( default : 0 )"), "",false).SetDefaultValue("0")
        .codeExtraInformation.SetFunctionName("GetCameraViewportTop").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneCameraTools.h");


    AddExpression("CameraViewportRight", _("X position of the bottom right side point of a render zone"), _("X position of the bottom right side point of a render zone"), _("Camera"), "res/actions/camera.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("layer", _("Layer"), "",false)
        .AddParameter("expression", _("Camera number ( default : 0 )"), "",false).SetDefaultValue("0")
        .codeExtraInformation.SetFunctionName("GetCameraViewportRight").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneCameraTools.h");


    AddExpression("CameraViewportBottom", _("Y position of the bottom right side point of a render zone"), _("Y position of the bottom right side point of a render zone"), _("Camera"), "res/actions/camera.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("layer", _("Layer"), "",false)
        .AddParameter("expression", _("Camera number ( default : 0 )"), "",false).SetDefaultValue("0")
        .codeExtraInformation.SetFunctionName("GetCameraViewportBottom").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneCameraTools.h");


*/
}
Пример #16
0
WindowExtension::WindowExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsWindowExtension(*this);

    SetExtensionInformation("BuiltinWindow",
                          _("Window features"),
                          _("Built-in extension allowing to manipulate the game's window"),
                          "Florian Rival",
                          "Open source (LGPL)");

    GetAllActions()["SetFullScreen"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.window.setFullScreen");
    GetAllActions()["SetWindowMargins"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.window.setMargins");
    GetAllActions()["SetWindowTitle"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.window.setWindowTitle");
    GetAllActions()["SetWindowSize"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.window.setCanvasSize");

    GetAllStrExpressions()["WindowTitle"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.window.getWindowTitle");
    GetAllExpressions()["SceneWindowWidth"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.window.getWindowWidth");
    GetAllExpressions()["SceneWindowHeight"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.window.getWindowHeight");

    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:

    /*
    AddAction("EcrireTexte",
                   _("Display a text"),
                   _("Display the specified text to screen"),
                   _("Display _PARAM1_ at _PARAM2_;_PARAM3_ ( color  : _PARAM4_ , size : _PARAM5_, font : _PARAM6_ )"),
                   _("Scene"),
                   "res/actions/texte24.png",
                   "res/actions/texte.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("string", _("Text"), "",false)
        .AddParameter("expression", _("X position"), "",false)
        .AddParameter("expression", _("Y position"), "",false)
        .AddParameter("color", _("Color"), "",false)
        .AddParameter("expression", _("Size"), "",false)
        .AddParameter("police", _("Font"), "",true)
        .AddParameter("layer", _("Layer ( Base layer if empty )"), "",true).SetDefaultValue("\"\"")
        .codeExtraInformation.SetFunctionName("DisplayLegacyTextOnScene").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneTools.h");


    AddAction("SetWindowIcon",
                   _("Change window's icon"),
                   _("This action change the icon of the game's window."),
                   _("Use _PARAM1_ as icon for the game's window."),
                   _("Game's window"),
                   "res/actions/window24.png",
                   "res/actions/window.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("string", _("Name of the image to be used as the icon"), "",false)
        .codeExtraInformation.SetFunctionName("SetWindowIcon").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneTools.h");


    AddExpression("ScreenWidth", _("Width of the current resolution"), _("Width of the current resolution"), _("Screen"), "res/display16.png")
        .codeExtraInformation.SetFunctionName("GetScreenWidth").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneTools.h");

    AddExpression("ScreenHeight", _("Height of the current resolution"), _("Height of the current resolution"), _("Screen"), "res/display16.png")
        .codeExtraInformation.SetFunctionName("GetScreenHeight").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneTools.h");

    AddExpression("ColorDepth", _("Color depth"), _("Color depth"), _("Screen"), "res/display16.png")
        .codeExtraInformation.SetFunctionName("GetColorDepth").SetIncludeFile("GDCpp/BuiltinExtensions/RuntimeSceneTools.h");

    */
}
Пример #17
0
SpriteExtension::SpriteExtension()
{
    SetExtensionInformation("Sprite",
                          _("Sprite"),
                          _("Extension for adding animated objects in the scene, which can contain animations with directions within each."),
                          "Florian Rival",
                          "Open source ( LGPL )");
    CloneExtension("Game Develop C++ platform", "Sprite");

    std::map<std::string, gd::InstructionMetadata > & spriteActions = GetAllActionsForObject("Sprite");
    std::map<std::string, gd::InstructionMetadata > & spriteConditions = GetAllConditionsForObject("Sprite");
    std::map<std::string, gd::ExpressionMetadata > & spriteExpressions = GetAllExpressionsForObject("Sprite");
    spriteActions["ChangeBlendMode"].codeExtraInformation.
        SetFunctionName("setBlendMode").SetIncludeFile("spriteruntimeobject.js");
    spriteActions["Opacity"].codeExtraInformation.
        SetFunctionName("setOpacity").SetAssociatedGetter("getOpacity").SetIncludeFile("spriteruntimeobject.js");
    spriteConditions["BlendMode"].codeExtraInformation.
        SetFunctionName("getBlendMode").SetIncludeFile("spriteruntimeobject.js");
    spriteConditions["Opacity"].codeExtraInformation.
        SetFunctionName("getOpacity").SetIncludeFile("spriteruntimeobject.js");

    spriteActions["ChangeAnimation"].codeExtraInformation.
        SetFunctionName("setAnimation").SetAssociatedGetter("getAnimation");
    spriteActions["ChangeDirection"].codeExtraInformation.
        SetFunctionName("setDirectionOrAngle").SetAssociatedGetter("getDirectionOrAngle");
    spriteActions["ChangeSprite"].codeExtraInformation.
        SetFunctionName("setAnimationFrame").SetAssociatedGetter("getAnimationFrame");
    spriteConditions["Animation"].codeExtraInformation.
        SetFunctionName("getAnimation");
    spriteConditions["Direction"].codeExtraInformation.
        SetFunctionName("getDirectionOrAngle");
    spriteConditions["Sprite"].codeExtraInformation.
        SetFunctionName("getAnimationFrame");
    spriteConditions["AnimationEnded"].codeExtraInformation.
        SetFunctionName("hasAnimationEnded");
    spriteActions["PauseAnimation"].codeExtraInformation.
        SetFunctionName("pauseAnimation");
    spriteActions["PlayAnimation"].codeExtraInformation.
        SetFunctionName("playAnimation");
    spriteConditions["AnimStopped"].codeExtraInformation.
        SetFunctionName("animationPaused");

    spriteActions["ChangeScaleWidth"].codeExtraInformation.
        SetFunctionName("setScaleX").SetAssociatedGetter("getScaleX");
    spriteActions["ChangeScaleHeight"].codeExtraInformation.
        SetFunctionName("setScaleY").SetAssociatedGetter("getScaleY");
    spriteActions["ChangeScale"].codeExtraInformation.
        SetFunctionName("setScale").SetManipulatedType("number").SetAssociatedGetter("getScale");
    spriteConditions["ScaleWidth"].codeExtraInformation
        .SetFunctionName("getScaleX");
    spriteConditions["ScaleHeight"].codeExtraInformation
        .SetFunctionName("getScaleY");
    spriteActions["TourneVersPos"].codeExtraInformation.
        SetFunctionName("turnTowardPosition");
    spriteActions["TourneVers"].codeExtraInformation.
        SetFunctionName("turnTowardObject");
    spriteActions["FlipX"].codeExtraInformation.
        SetFunctionName("flipX");
    spriteActions["FlipY"].codeExtraInformation.
        SetFunctionName("flipY");

    spriteConditions["SourisSurObjet"].codeExtraInformation.
        SetFunctionName("cursorOnObject");

    GetAllConditions()["Collision"]
        .AddCodeOnlyParameter("currentScene", "") //We need an extra parameter pointing to the scene.
        .codeExtraInformation //No pixel perfect collision for now on the JS platform.
        .SetFunctionName("gdjs.evtTools.object.hitBoxesCollisionTest");

    spriteExpressions["X"].codeExtraInformation.
        SetFunctionName("getPointX");
    spriteExpressions["Y"].codeExtraInformation.
        SetFunctionName("getPointY");
    spriteExpressions["PointX"].codeExtraInformation.
        SetFunctionName("getPointX");
    spriteExpressions["PointY"].codeExtraInformation.
        SetFunctionName("getPointY");
    spriteExpressions["Direc"].codeExtraInformation. //Deprecated
        SetFunctionName("getDirectionOrAngle");
    spriteExpressions["Direction"].codeExtraInformation.
        SetFunctionName("getDirectionOrAngle");
    spriteExpressions["Anim"].codeExtraInformation.  //Deprecated
        SetFunctionName("getAnimation");
    spriteExpressions["Animation"].codeExtraInformation.
        SetFunctionName("getAnimation");
    spriteExpressions["Sprite"].codeExtraInformation.
        SetFunctionName("getAnimationFrame");
    spriteExpressions["ScaleX"].codeExtraInformation.
        SetFunctionName("getScaleX");
    spriteExpressions["ScaleY"].codeExtraInformation.
        SetFunctionName("getScaleY");


    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:
/*
    //Objects instructions:
    {
        obj.AddCondition("BlendMode",
                       _("Blend mode"),
                       _("Compare the number of the blend mode currently used by an object"),
                       _("The number of the current blend mode of _PARAM0_ is _PARAM1__PARAM2_"),
                       _("Effects"),
                       "res/conditions/opacity24.png",
                       "res/conditions/opacity.png")

            .AddParameter("object", _("Object"), "Sprite", false)
            .AddParameter("relationalOperator", _("Sign of the test"), "",false)
            .AddParameter("expression", _("Value to test  ( 0 : Alpha, 1 : Add, 2 : Multiply, 3 : None )"), "",false)
            .codeExtraInformation.SetFunctionName("GetBlendMode").SetManipulatedType("number").SetIncludeFile("GDCpp/SpriteObject.h");

        obj.AddAction("CopyImageOnImageOfSprite",
                       _("Copy an image on the current one of an object"),
                       _("Copy an image on the current image of an object.\nNote that the source image must be preferably kept loaded in memory."),
                       _("Copy image _PARAM2_ on the current of _PARAM0_ at _PARAM3_;_PARAM4_"),
                       _("Effects"),
                       "res/copy24.png",
                       "res/copyicon.png")

            .AddParameter("object", _("Object"), "Sprite", false)
            .AddCodeOnlyParameter("currentScene", "")
            .AddParameter("string", _("Name of the source image"), "",false)
            .AddParameter("expression", _("X position"), "",false)
            .AddParameter("expression", _("Y position"), "",false)
            .AddParameter("yesorno", _("Should the copy take in account the source transparency\?"), "",false)
            .codeExtraInformation.SetFunctionName("CopyImageOnImageOfCurrentSprite").SetIncludeFile("GDCpp/SpriteObject.h");



        obj.AddAction("CreateMaskFromColorOnActualImage", //Actual is indeed a mistake : Current should have been chosen.
                       _("Make a color of the image of an object transparent"),
                       _("Make a color of the image of an object transparent."),
                       _("Make color _PARAM1_ of the current image of _PARAM0_ transparent"),
                       _("Effects"),
                       "res/actions/opacity24.png",
                       "res/actions/opacity.png")

            .AddParameter("object", _("Object"), "Sprite", false)
            .AddParameter("color", _("Color to make transparent"), "",false)
            .codeExtraInformation.SetFunctionName("MakeColorTransparent").SetIncludeFile("GDCpp/SpriteObject.h");


        obj.AddAction("ChangeColor",
                       _("Change the global color"),
                       _("Change the global color of an object. The default color is white."),
                       _("Change color of _PARAM0_ to _PARAM1_"),
                       _("Effects"),
                       "res/actions/color24.png",
                       "res/actions/color.png")

            .AddParameter("object", _("Object"), "Sprite", false)
            .AddParameter("color", _("Color"), "",false)
            .codeExtraInformation.SetFunctionName("SetColor").SetIncludeFile("GDCpp/SpriteObject.h");


        obj.AddAction("ChangeBlendMode",
                       _("Change Blend mode"),
                       _("Change the number of the blend mode of an object.\nThe default blend mode is 0 ( Alpha )."),
                       _("Change Blend mode of _PARAM0_ to _PARAM1_"),
                       _("Effects"),
                       "res/actions/color24.png",
                       "res/actions/color.png")

            .AddParameter("object", _("Object"), "Sprite", false)
            .AddParameter("expression", _("Mode ( 0 : Alpha, 1 : Add, 2 : Multiply, 3 : None )"), "",false)
            .codeExtraInformation.SetFunctionName("SetBlendMode").SetIncludeFile("GDCpp/SpriteObject.h");
        #endif

    }

*/
}
Пример #18
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("SoundObject",
                              _("Sound object"),
                              _("Extension allowing to use spatialized sounds."),
                              "Thomas Flecy, Victor Levasseur et al.",
                              "Open source (MIT License)");


        //Declaration of all objects available
        {
            gd::ObjectMetadata & obj = AddObject("Sound",
                       _("Sound"),
                       _("Invisible object emitting a sound which can be moved in the space."),
                       "CppPlatform/Extensions/soundicon32.png",
                       &CreateSoundObject);

            AddRuntimeObject(obj, "RuntimeSoundObject", CreateRuntimeSoundObject);

            #if defined(GD_IDE_ONLY)
            SoundObject::LoadEdittimeIcon();
            obj.SetIncludeFile("SoundObject/SoundObject.h");

            obj.AddAction("Volume",
                           _("Sound level"),
                           _("Modify the sound level of a Sound object."),
                           _("Do _PARAM1__PARAM2_ to the sound level of _PARAM0_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .codeExtraInformation.SetFunctionName("SetVolume").SetManipulatedType("number").SetAssociatedGetter("GetVolume").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddAction("Pitch",
                           _("Pitch"),
                           _("Change the pitch of a sound object."),
                           _("Do _PARAM1__PARAM2_ to Pitch of _PARAM0_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .codeExtraInformation.SetFunctionName("SetPitch").SetManipulatedType("number").SetAssociatedGetter("GetPitch").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddAction("Attenuation",
                           _("Attenuation"),
                           _("Change the attenuation of a sound object."),
                           _("Do _PARAM1__PARAM2_ to the attenuation of _PARAM0_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .codeExtraInformation.SetFunctionName("SetAttenuation").SetManipulatedType("number").SetAssociatedGetter("GetAttenuation").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddAction("ZPos",
                           _("Z Position"),
                           _("Modify the sound level of a Sound object."),
                           _("Do _PARAM1__PARAM2_ to the sound level of _PARAM0_"),
                           _("Position"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .codeExtraInformation.SetFunctionName("SetZPos").SetManipulatedType("number").SetAssociatedGetter("GetZPos").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddAction("Loop",
                           _("Automatic restart"),
                           _("Activate or desactivate the looping of a sound."),
                           _("Activate looping for _PARAM0_: _PARAM1_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("yesorno", _("Loop"))
                .codeExtraInformation.SetFunctionName("SetLoop").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddAction("RelativeToListener",
                           _("Listener relation"),
                           _("Activate or desactivate the sound spatialisation relative to the listener."),
                           _("Set _PARAM0_ as relative to the listener position: _PARAM1_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("yesorno", _("Relative to the listener"))
                .codeExtraInformation.SetFunctionName("SetRelativeToListener").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddAction("Play",
                           _("Play"),
                           _("Play a sound."),
                           _("Play sound _PARAM0_"),
                           "",
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("Play").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddAction("Stop",
                           _("Stop"),
                           _("Stop a sound."),
                           _("Stop _PARAM0_"),
                           "",
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("Stop").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddAction("Pause",
                           _("Pause"),
                           _("Pause a sound."),
                           _("Pause _PARAM0_"),
                           "",
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("Pause").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("Volume",
                           _("Sound level"),
                           _("Test the sound level of a Sound object."),
                           _("Th sound level of _PARAM0_ is _PARAM2_ _PARAM1_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))
                .codeExtraInformation.SetFunctionName("GetVolume").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("Pitch",
                           _("Pitch"),
                           _("Test the pitch value of a sound."),
                           _("Pitch of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))
                .codeExtraInformation.SetFunctionName("GetPitch").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("Attenuation",
                           _("Attenuation"),
                           _("Test the attenuation of a sound."),
                           _("The attenuation of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))
                .codeExtraInformation.SetFunctionName("GetAttenuation").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("MinDistance",
                           _("Minimal distance"),
                           _("Test the minimal distance of a sound"),
                           _("The minimal distance of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))
                .codeExtraInformation.SetFunctionName("GetMinDistance").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("ZPos",
                           _("Z Position"),
                           _("Test Z position of a sound."),
                           _("The Z position of _PARAM0_ is _PARAM1__PARAM2_"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value to test"))
                .codeExtraInformation.SetFunctionName("GetZPos").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("Loop",
                           _("Automatic restart"),
                           _("Test if an sound is looping."),
                           _("_PARAM0_ is looping"),
                           _("Parameters"),
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("GetLoop").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("Playing",
                           _("Being played"),
                           _("Test if a sound is being played."),
                           _("_PARAM0_ is being played"),
                           "",
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("IsPlaying").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("Paused",
                           _("Paused"),
                           _("A sound is paused"),
                           _("_PARAM0_ is paused"),
                           "",
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("IsPaused").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("Stopped",
                           _("Stopped"),
                           _("Test if a sound is stopped."),
                           _("_PARAM0_ is stopped"),
                           "",
                           "res/actions/son24.png",
                           "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("IsStopped").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddCondition("RelativeToListener",
                           _("Listener relation"),
                           _("Test if a sound is relative to the listener."),
                           _("_PARAM0_ is relative to the listener"),
                           _("Parameters"),
                           "res/conditions/son24.png",
                           "res/conditions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("IsRelativeToListener").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddExpression("Volume", _("Sound level"), _("Sound level"), _("Parameters"), "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("GetVolume").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddExpression("Pitch", _("Pitch"), _("Pitch"), _("Parameters"), "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("GetPitch").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddExpression("Attenuation", _("Attenuation"), _("Attenuation"), _("Parameters"), "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("GetAttenuation").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddExpression("MinDistance", _("Minimal distance"), _("Minimal distance"), _("Parameters"), "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("GetMinDistance").SetIncludeFile("SoundObject/SoundObject.h");


            obj.AddExpression("ZPos", _("Z Position"), _("Z Position"), _("Position"), "res/actions/son.png")
                .AddParameter("object", _("Object"), "Sound", false)
                .codeExtraInformation.SetFunctionName("GetZPos").SetIncludeFile("SoundObject/SoundObject.h");

        #endif
        }

        // Actions liées à l'écouteur
        #if defined(GD_IDE_ONLY)
        AddAction("ListenerX",
                       _("X position"),
                       _("Modify the X position of the listener."),
                       _("Do _PARAM0__PARAM1_ to the X position of the listener"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .codeExtraInformation.SetFunctionName("SetListenerX").SetManipulatedType("number").SetAssociatedGetter("GetListenerX").SetIncludeFile("SoundObject/SoundListener.h");


        AddAction("ListenerY",
                       _("Y position"),
                       _("Modify the Y position of the listener."),
                       _("Do _PARAM0__PARAM1_ to the Y position of the listener"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .codeExtraInformation.SetFunctionName("SetListenerY").SetManipulatedType("number").SetAssociatedGetter("GetListenerY").SetIncludeFile("SoundObject/SoundListener.h");


        AddAction("ListenerZ",
                       _("Z position"),
                       _("Modify the Z position of the listener."),
                       _("Do _PARAM0__PARAM1_ to the Z position of the listener"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .codeExtraInformation.SetFunctionName("SetListenerZ").SetManipulatedType("number").SetAssociatedGetter("GetListenerZ").SetIncludeFile("SoundObject/SoundListener.h");


        AddAction("ListenerDirectionX",
                       _("Direction on X axis"),
                       _("Change the direction of the listener on X axis."),
                       _("Do _PARAM1__PARAM2_ to the direction on X axis of the listener"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .codeExtraInformation.SetFunctionName("SetListenerDirectionX").SetManipulatedType("number").SetAssociatedGetter("GetListenerDirectionX").SetIncludeFile("SoundObject/SoundListener.h");


        AddAction("ListenerDirectionY",
                       _("Direction on Y axis"),
                       _("Change the direction of the listener on Y axis."),
                       _("Do _PARAM1__PARAM2_ to the direction on Y axis of the listener"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .codeExtraInformation.SetFunctionName("SetListenerDirectionY").SetManipulatedType("number").SetAssociatedGetter("GetListenerDirectionY").SetIncludeFile("SoundObject/SoundListener.h");


        AddAction("ListenerDirectionZ",
                       _("Direction on Z axis"),
                       _("Change the direction of the listener on Z axis."),
                       _("Do _PARAM1__PARAM2_ to the direction on Z axis of the listener"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .codeExtraInformation.SetFunctionName("SetListenerDirectionZ").SetManipulatedType("number").SetAssociatedGetter("GetListenerDirectionZ").SetIncludeFile("SoundObject/SoundListener.h");


        // Conditions liées à l'écouteur
        AddCondition("ListenerX",
                       _("X position"),
                       _("Test the position of the listener on X axis."),
                       _("The listener X position is _PARAM1__PARAM0_"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))
            .codeExtraInformation.SetFunctionName("GetListenerX").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundListener.h");

        AddCondition("ListenerY",
                       _("Y position"),
                       _("Test the position of the listener on Y axis."),
                       _("The listener Y position is _PARAM1__PARAM0_"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))
            .codeExtraInformation.SetFunctionName("GetListenerY").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundListener.h");

        AddCondition("ListenerZ",
                       _("Z position"),
                       _("Test the position of the listener on Z axis."),
                       _("The listener Z position is _PARAM1__PARAM0_"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))
            .codeExtraInformation.SetFunctionName("GetListenerZ").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundListener.h");

        AddCondition("ListenerDirectionX",
                       _("X direction"),
                       _("Test the direction of the listener on X axis."),
                       _("The listener X direction is _PARAM1__PARAM0_"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))
            .codeExtraInformation.SetFunctionName("GetListenerDirectionX").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundListener.h");

        AddCondition("ListenerDirectionY",
                       _("Y direction"),
                       _("Test the direction of the listener on Y axis."),
                       _("The listener Y direction is _PARAM1__PARAM0_"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))

            .codeExtraInformation.SetFunctionName("GetListenerDirectionY").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundListener.h");




        AddCondition("ListenerDirectionZ",
                       _("Z direction"),
                       _("Test the direction of the listener on Z axis."),
                       _("The listener Z direction is _PARAM1__PARAM0_"),
                       _("Listener"),
                       "res/actions/son24.png",
                       "res/actions/son.png")

            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))

            .codeExtraInformation.SetFunctionName("GetListenerDirectionZ").SetManipulatedType("number").SetIncludeFile("SoundObject/SoundListener.h");




        AddExpression("ListenerX", _("X position"), _("Listener X position"), _("Listener"), "res/actions/son.png")
            .codeExtraInformation.SetFunctionName("GetListenerX").SetIncludeFile("SoundObject/SoundListener.h");


        AddExpression("ListenerY", _("Y position"), _("Listener Y position"), _("Listener"), "res/actions/son.png")
            .codeExtraInformation.SetFunctionName("GetListenerY").SetIncludeFile("SoundObject/SoundListener.h");


        AddExpression("ListenerZ", _("Z position"), _("Listener Z position"), _("Listener"), "res/actions/son.png")
            .codeExtraInformation.SetFunctionName("GetListenerZ").SetIncludeFile("SoundObject/SoundListener.h");


        AddExpression("ListenerDirectionX", _("Direction on X axis"), _("Listener x direction"), _("Listener"), "res/actions/son.png")
            .codeExtraInformation.SetFunctionName("GetListenerDirectionX").SetIncludeFile("SoundObject/SoundListener.h");


        AddExpression("ListenerDirectionY", _("Direction on Y axis"), _("Listener y direction"), _("Listener"), "res/actions/son.png")
            .codeExtraInformation.SetFunctionName("GetListenerDirectionY").SetIncludeFile("SoundObject/SoundListener.h");


        AddExpression("ListenerDirectionZ", _("Direction on Z axis"), _("Listener z direction"), _("Listener"), "res/actions/son.png")
            .codeExtraInformation.SetFunctionName("GetListenerDirectionZ").SetIncludeFile("SoundObject/SoundListener.h");

        #endif

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #19
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("Light",
                              _("Light"),
                              _("Allow to display lights and use light obstacles."),
                              "Florian Rival",
                              "Open source (MIT License)");

        gd::ObjectMetadata & obj = AddObject<LightObject>(
                   "Light",
                   _("Light"),
                   _("Emits light that can be stopped by objects"),
                   "CppPlatform/Extensions/lightIcon32.png");

        AddRuntimeObject<LightObject, RuntimeLightObject>(
            obj, "RuntimeLightObject");

        #if defined(GD_IDE_ONLY)
        LightObject::LoadEdittimeIcon();
        obj.SetIncludeFile("Light/LightObject.h");

        obj.AddAction("ChangeColor",
                       _("Color"),
                       _("Change light color."),
                       _("Change color of _PARAM0_ to _PARAM1_"),
                       _("Setup"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("color", _("Color"))

            .SetFunctionName("SetColor").SetIncludeFile("Light/LightObject.h");


        obj.AddAction("Intensity",
                       _("Intensity"),
                       _("Modify the intensity of a light"),
                       _("Do _PARAM1__PARAM2_ to the intensity of _PARAM0_"),
                       _("Setup"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .SetFunctionName("SetIntensity").SetManipulatedType("number").SetGetter("GetIntensity").SetIncludeFile("Light/LightObject.h");


        obj.AddCondition("Intensity",
                       _("Intensity"),
                       _("Test the intensity of a light."),
                       _("Intensity of _PARAM0_ is _PARAM1__PARAM2_"),
                       _("Setup"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))

            .SetFunctionName("GetIntensity").SetManipulatedType("number").SetIncludeFile("Light/LightObject.h");


        obj.AddAction("Radius",
                       _("Radius"),
                       _("Modify the radius of a light"),
                       _("Do _PARAM1__PARAM2_ to radius of _PARAM0_"),
                       _("Setup"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .SetFunctionName("SetRadius").SetManipulatedType("number").SetGetter("GetRadius").SetIncludeFile("Light/LightObject.h");


        obj.AddCondition("Radius",
                       _("Radius"),
                       _("Test the radius of a light."),
                       _("The radius of _PARAM0_ is _PARAM2_ _PARAM1_"),
                       _("Setup"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))

            .SetFunctionName("GetRadius").SetManipulatedType("number").SetIncludeFile("Light/LightObject.h");


        obj.AddAction("Quality",
                       _("Quality"),
                       _("Modify the quality of a light"),
                       _("Do _PARAM1__PARAM2_ to the quality of _PARAM0_"),
                       _("Setup"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("operator", _("Modification's sign"))
            .AddParameter("expression", _("Value"))

            .SetFunctionName("SetQuality").SetManipulatedType("number").SetGetter("GetQuality").SetIncludeFile("Light/LightObject.h");


        obj.AddCondition("Quality",
                       _("Quality"),
                       _("Test the quality of a light"),
                       _("The quality of _PARAM0_ is _PARAM1__PARAM2_"),
                       _("Setup"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("relationalOperator", _("Sign of the test"))
            .AddParameter("expression", _("Value to test"))

            .SetFunctionName("GetQuality").SetManipulatedType("number").SetIncludeFile("Light/LightObject.h");


        obj.AddAction("ChangeGlobalColor",
                       _("Global color"),
                       _("Change scene color for a global light."),
                       _("Change scene global color of _PARAM0_ to _PARAM1_"),
                       _("Setup"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("color", _("Color"))

            .SetFunctionName("SetGlobalColor").SetIncludeFile("Light/LightObject.h");


        obj.AddAction("SetGlobalLight",
                       _("Make a light global"),
                       _("Make a light global or simple."),
                       _("Make _PARAM0_ global : _PARAM1_"),
                       _("Light type"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .AddParameter("yesorno", _("Make light global"))

            .SetFunctionName("SetGlobalLight").SetIncludeFile("Light/LightObject.h");


        obj.AddCondition("GlobalLight",
                       _("A light is global"),
                       _("Return true if light is global"),
                       _("_PARAM0_ is a global light"),
                       _("Light type"),
                       "CppPlatform/Extensions/lightIcon24.png",
                       "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")

            .SetFunctionName("IsGlobalLight").SetIncludeFile("Light/LightObject.h");

        obj.AddExpression("Intensity", _("Intensity"), _("Intensity"), _("Setup"), "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .SetFunctionName("GetIntensity").SetIncludeFile("Light/LightObject.h");

        obj.AddExpression("Radius", _("Radius"), _("Radius"), _("Setup"), "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .SetFunctionName("GetRadius").SetIncludeFile("Light/LightObject.h");

        obj.AddExpression("Quality", _("Quality"), _("Quality"), _("Setup"), "CppPlatform/Extensions/lightIcon16.png")
            .AddParameter("object", _("Object"), "Light")
            .SetFunctionName("GetQuality").SetIncludeFile("Light/LightObject.h");
        #endif

        AddBehavior("LightObstacleBehavior",
              _("Light obstacle"),
              _("LightObstacle"),
              _("Mark the objects as obstacles for Light objects."),
              "",
              "CppPlatform/Extensions/lightObstacleIcon32.png",
              "LightObstacleBehavior",
              std::shared_ptr<gd::Behavior>(new LightObstacleBehavior),
              std::shared_ptr<gd::BehaviorsSharedData>(new SceneLightObstacleDatas));

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #20
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("PathfindingBehavior",
                              _("Pathfinding behavior"),
                              _("Compute paths for objects avoiding obstacles."),
                              "Florian Rival",
                              "Open source (MIT License)");

        {
            gd::BehaviorMetadata & aut = AddBehavior("PathfindingBehavior",
                  _("Pathfinding"),
                  "Pathfinding",
                  _("Behavior which move objects and avoid objects flagged as obstacles."),
                  "",
                  "CppPlatform/Extensions/AStaricon.png",
                  "PathfindingBehavior",
                  std::shared_ptr<gd::Behavior>(new PathfindingBehavior),
                  std::shared_ptr<gd::BehaviorsSharedData>(new gd::BehaviorsSharedData));

            #if defined(GD_IDE_ONLY)

            aut.SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddAction("SetDestination",
                           _("Move to a position"),
                           _("Move the object to a position"),
                           _("Move _PARAM0_ to _PARAM3_;_PARAM4_"),
                           _(""),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddCodeOnlyParameter("currentScene", "")

                .AddParameter("expression", _("Destination X position"))
                .AddParameter("expression", _("Destination Y position"))
                .SetFunctionName("MoveTo").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("PathFound",
                           _("Path found"),
                           _("Return true if a path has been found."),
                           _("A path has been found for _PARAM0_"),
                           _(""),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("PathFound").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("DestinationReached",
                           _("Destination reached"),
                           _("Return true if destination was reached."),
                           _("_PARAM0_ reached its destination"),
                           _(""),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("DestinationReached").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("CellWidth",
                           _("Width of the cells"),
                           _("Change the width of the cells of the virtual grid."),
                           _("Do _PARAM2__PARAM3_ to the width of the virtual cells of _PARAM0_"),
                           _("Virtual grid"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Width (pixels)"))
                .SetFunctionName("SetCellWidth").SetGetter("GetCellWidth").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("CellWidth",
                           _("Width of the virtual grid"),
                           _("Compare the width of the cells of the virtual grid."),
                           _("Width of the virtual cells of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Virtual grid"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Width (pixels)"))
                .SetFunctionName("GetCellWidth").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("CellHeight",
                           _("Height of the cells"),
                           _("Change the height of the cells of the virtual grid."),
                           _("Do _PARAM2__PARAM3_ to the height of the virtual cells of _PARAM0_"),
                           _("Virtual grid"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Height (pixels)"))
                .SetFunctionName("SetCellHeight").SetGetter("GetCellHeight").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("CellHeight",
                           _("Height of the virtual grid"),
                           _("Compare the height of the cells of the virtual grid."),
                           _("Height of the virtual cells of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Virtual grid"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Height (pixels)"))
                .SetFunctionName("GetCellHeight").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("Acceleration",
                           _("Acceleration"),
                           _("Change the acceleration when moving the object"),
                           _("Do _PARAM2__PARAM3_ to the acceleration of _PARAM0_ on the path"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("SetAcceleration").SetGetter("GetAcceleration").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("Acceleration",
                           _("Acceleration"),
                           _("Compare the acceleration when moving the object"),
                           _("Acceleration of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("GetAcceleration").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("MaxSpeed",
                           _("Maximum speed"),
                           _("Change the maximum speed when moving the object"),
                           _("Do _PARAM2__PARAM3_ to the max. speed of _PARAM0_ on the path"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("SetMaxSpeed").SetGetter("GetMaxSpeed").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("MaxSpeed",
                           _("Maximum speed"),
                           _("Compare the maximum speed when moving the object"),
                           _("Max. speed of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("GetMaxSpeed").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("Speed",
                           _("Speed"),
                           _("Change the speed of the object on the path"),
                           _("Do _PARAM2__PARAM3_ to the speed of _PARAM0_ on the path"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("SetSpeed").SetGetter("GetSpeed").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("Speed",
                           _("Speed"),
                           _("Compare the speed of the object on the path"),
                           _("Speed of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("GetSpeed").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("AngularMaxSpeed",
                           _("Angular maximum speed"),
                           _("Change the maximum angular speed when moving the object"),
                           _("Do _PARAM2__PARAM3_ to the max. angular speed of _PARAM0_ on the path"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("SetAngularMaxSpeed").SetGetter("GetAngularMaxSpeed").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("AngularMaxSpeed",
                           _("Angular maximum speed"),
                           _("Compare the maximum angular speed when moving the object"),
                           _("Max. angular speed of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("GetAngularMaxSpeed").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("AngleOffset",
                           _("Rotation offset"),
                           _("Change the rotation offset applied when moving the object"),
                           _("Do _PARAM2__PARAM3_ to the rotation offset of _PARAM0_ on the path"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("SetAngleOffset").SetGetter("GetAngleOffset").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("AngleOffset",
                           _("Rotation offset"),
                           _("Compare the rotation offset when moving the object"),
                           _("Rotation offset of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value"))
                .SetFunctionName("GetAngleOffset").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("ExtraBorder",
                           _("Extra border"),
                           _("Change the size of the extra border applied to the object when planning a path"),
                           _("Do _PARAM2__PARAM3_ to the extra border of _PARAM0_ on the path"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Value (in pixels)"))
                .SetFunctionName("SetExtraBorder").SetGetter("GetExtraBorder").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("ExtraBorder",
                           _("Extra border"),
                           _("Compare the size of the extra border applied to the object when planning a path"),
                           _("Size of the extra border applied to _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Value (in pixels)"))
                .SetFunctionName("GetExtraBorder").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("AllowDiagonals",
                           _("Diagonals moves"),
                           _("Allow or restrict diagonal moves on the path"),
                           _("Allow diagonal moves for _PARAM0_ on the path: _PARAM2_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("yesorno", _("Allow?"))
                .SetFunctionName("SetAllowDiagonals").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("DiagonalsAllowed",
                           _("Diagonals moves"),
                           _("Return true if the object is allowed to do diagonal moves on the path"),
                           _("Diagonal moves allowed for _PARAM0_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("DiagonalsAllowed").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddAction("RotateObject",
                           _("Rotate the object"),
                           _("Enable or disable rotation of the object on the path"),
                           _("Enable rotation of _PARAM0_ on the path: _PARAM2_"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("yesorno", _("Rotate object?"))
                .SetFunctionName("SetRotateObject").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");


            aut.AddCondition("ObjectRotated",
                           _("Object rotated"),
                           _("Return true if the object is rotated when traveling on its path."),
                           _("_PARAM0_ is rotated when traveling on its path"),
                           _("Path"),
                           "CppPlatform/Extensions/AStaricon24.png",
                           "CppPlatform/Extensions/AStaricon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("IsObjectRotated").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("GetNodeX", _("Get a waypoint X position"), _("Get next waypoint X position"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("expression", _("Node index (start at 0!)"))
                .SetFunctionName("GetNodeX").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("GetNodeY", _("Get a waypoint Y position"), _("Get next waypoint Y position"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .AddParameter("expression", _("Node index (start at 0!)"))
                .SetFunctionName("GetNodeY").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("NextNodeIndex", _("Index of the next waypoint"), _("Get the index of the next waypoint to reach"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetNextNodeIndex").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("NodeCount", _("Waypoint count"), _("Get the number of waypoints on the path"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetNodeCount").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("NextNodeX", _("Get next waypoint X position"), _("Get next waypoint X position"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetNextNodeX").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("NextNodeY", _("Get next waypoint Y position"), _("Get next waypoint Y position"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetNextNodeY").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("LastNodeX", _("Last waypoint X position"), _("Last waypoint X position"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetLastNodeX").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("LastNodeY", _("Last waypoint Y position"), _("Last waypoint Y position"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetLastNodeY").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("DestinationX", _("Destination X position"), _("Destination X position"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetDestinationX").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("DestinationY", _("Destination Y position"), _("Destination Y position"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetDestinationY").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("Acceleration", _("Acceleration"), _("Acceleration of the object on the path"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetAcceleration").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("MaxSpeed", _("Maximum speed"), _("Maximum speed of the object on the path"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetMaxSpeed").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("Speed", _("Speed"), _("Speed of the object on the path"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetSpeed").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("AngularMaxSpeed", _("Angular maximum speed"), _("Angular maximum speed of the object on the path"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetAngularMaxSpeed").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("AngleOffset", _("Rotation offset"), _("Rotation offset applied the object on the path"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetAngleOffset").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("ExtraBorder", _("Extra border size"), _("Extra border applied the object on the path"), _("Path"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetExtraBorder").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("CellWidth", _("Width of a cell"), _("Width of the virtual grid"), _("Virtual grid"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetCellWidth").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            aut.AddExpression("CellHeight", _("Height of a cell"), _("Height of the virtual grid"), _("Virtual grid"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingBehavior")
                .SetFunctionName("GetCellHeight").SetIncludeFile("PathfindingBehavior/PathfindingBehavior.h");

            #endif

        }
        {
            gd::BehaviorMetadata & aut = AddBehavior("PathfindingObstacleBehavior",
                  _("Obstacle for pathfinding"),
                  "PathfindingObstacle",
                  _("Flag the object as being an obstacle for pathfinding."),
                  "",
                  "CppPlatform/Extensions/pathfindingobstacleicon.png",
                  "PathfindingObstacleBehavior",
                  std::shared_ptr<gd::Behavior>(new PathfindingObstacleBehavior),
                  std::shared_ptr<gd::BehaviorsSharedData>(new gd::BehaviorsSharedData));

            #if defined(GD_IDE_ONLY)
            aut.SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");

            aut.AddAction("Cost",
                           _("Cost"),
                           _("Change the cost of going through the object."),
                           _("Do _PARAM2__PARAM3_ to the cost of _PARAM0_"),
                           _("Obstacles"),
                           "CppPlatform/Extensions/pathfindingobstacleicon24.png",
                           "CppPlatform/Extensions/pathfindingobstacleicon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
                .AddParameter("operator", _("Modification's sign"))
                .AddParameter("expression", _("Difficulty"))
                .SetFunctionName("SetCost").SetGetter("GetCost").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");


            aut.AddCondition("Cost",
                           _("Cost"),
                           _("Compare the cost of going through the object"),
                           _("Cost of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Obstacles"),
                           "CppPlatform/Extensions/pathfindingobstacleicon24.png",
                           "CppPlatform/Extensions/pathfindingobstacleicon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
                .AddParameter("relationalOperator", _("Sign of the test"))
                .AddParameter("expression", _("Difficulty"))
                .SetFunctionName("GetCost").SetManipulatedType("number").SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");


            aut.AddAction("SetImpassable",
                           _("Set impassable"),
                           _("Set the object as being an impassable obstacle or not"),
                           _("Set _PARAM0_ as an impassable obstacle: _PARAM2_"),
                           _("Obstacles"),
                           "CppPlatform/Extensions/pathfindingobstacleicon24.png",
                           "CppPlatform/Extensions/pathfindingobstacleicon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
                .AddParameter("yesorno", _("Impassable?"))
                .SetFunctionName("SetImpassable").SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");


            aut.AddCondition("IsImpassable",
                           _("Is impassable"),
                           _("Return true if the obstacle is impassable"),
                           _("_PARAM0_ is impassable"),
                           _("Obstacles"),
                           "CppPlatform/Extensions/pathfindingobstacleicon24.png",
                           "CppPlatform/Extensions/pathfindingobstacleicon16.png")

                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
                .SetFunctionName("IsImpassable").SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");

            aut.AddExpression("Cost", _("Cost"), _("Obstacle cost"), _("Obstacles"), "CppPlatform/Extensions/AStaricon16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("behavior", _("Behavior"), "PathfindingObstacleBehavior")
                .SetFunctionName("GetCost").SetIncludeFile("PathfindingBehavior/PathfindingObstacleBehavior.h");

            #endif
        }

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #21
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("PathBehavior",
                              _("Path Behavior"),
                              _("Behavior allowing to move objects on a predefined path"),
                              "Florian Rival",
                              "Open source (MIT License)");

            {
                gd::BehaviorMetadata & aut = AddBehavior("PathBehavior",
                      _("Path"),
                      _("Path"),
                      _("Make objects move on a predefined path."),
                      "",
                      "CppPlatform/Extensions/pathicon.png",
                      "PathBehavior",
                      std::shared_ptr<gd::Behavior>(new PathBehavior),
                      std::shared_ptr<gd::BehaviorsSharedData>(new ScenePathDatas));

                #if defined(GD_IDE_ONLY)

                aut.SetIncludeFile("PathBehavior/PathBehavior.h");

                aut.AddAction("SetReverseAtEnd",
                               _("De/activate rounding"),
                               _("Activate or desactivate rounding"),
                               _("Activate rounding for _PARAM0_: _PARAM2_"),
                               _("Options"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("yesorno", _("Activate"))
                    .SetFunctionName("SetReverseAtEnd").SetIncludeFile("PathBehavior/PathBehavior.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"),
                               _("Stop _PARAM0_ when the end of the path is reached: _PARAM2_"),
                               _("Options"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("yesorno", _("Activate"))
                    .SetFunctionName("SetStopAtEnd").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddCondition("ReverseAtEnd",
                               _("Rounds"),
                               _("Return true if the object round"),
                               _("_PARAM0_ is rounding"),
                               _("Options"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("ReverseAtEnd").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddCondition("StopAtEnd",
                               _("Stop at the end of the path"),
                               _("Return true if the object stops at the end of its path."),
                               _("_PARAM0_ stops at the end of the path"),
                               _("Options"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("StopAtEnd").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddAction("Reverse",
                               _("Invert the movement on the path"),
                               _("Invert the movement on the path."),
                               _("Invert the sens of the movement of _PARAM0_ on its path"),
                               _("Movement"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("Reverse").SetIncludeFile("PathBehavior/PathBehavior.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."),
                               _("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", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("relationalOperator", _("Comparison sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("GetCurrentSegment").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddAction("EnterSegment",
                               _("Position on the segment of a path"),
                               _("Put the object directly on specific segment of the path"),
                               _("Do _PARAM2__PARAM3_ to number of the current segment of _PARAM0_"),
                               _("Position"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("operator", _("Modification sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("SetCurrentSegment").SetGetter("GetCurrentSegment").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");

                aut.AddExpression("Segment", _("Current segment"), _("Number of the current segment"), _("Position"), "CppPlatform/Extensions/pathicon16.png")
                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("GetCurrentSegment").SetIncludeFile("PathBehavior/PathBehavior.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."),
                               _("The position of _PARAM0_ on the current segment is _PARAM2__PARAM3_"),
                               _("Position"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("relationalOperator", _("Comparison sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("GetPositionOnSegment").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.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."),
                               _("Put _PARAM0_ on _PARAM2__PARAM3_ on the current segment"),
                               _("Position"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("operator", _("Modification sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("SetPositionOnSegment").SetGetter("GetPositionOnSegment").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");

                aut.AddExpression("Position", _("Position on the segment"), _("Position on the segment ( value between 0 and 1 )"), _("Position"), "CppPlatform/Extensions/pathicon16.png")
                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("GetPositionOnSegment").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddCondition("GetPathName",
                               _("Path name"),
                               _("Test the path name."),
                               _("The name of the current path of _PARAM0_ is _PARAM1__PARAM2_"),
                               _("Path"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("relationalOperator", _("Comparison sign"))
                    .AddParameter("string", _("Name"))
                    .SetFunctionName("GetCurrentPathName").SetManipulatedType("string").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddAction("SetPathName",
                               _("Change the path"),
                               _("Change the path used."),
                               _("Set _PARAM2_ as the current path of _PARAM0_"),
                               _("Path"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("string", _("Name"))
                    .SetFunctionName("ChangeCurrentPath").SetIncludeFile("PathBehavior/PathBehavior.h");

                aut.AddStrExpression("CurrentPathName", _("Current path name"), _("Current path name"), _("Path"), "CppPlatform/Extensions/pathicon16.png")
                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("GetCurrentPathName").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddCondition("GetOffsetX",
                               _("X position of the path"),
                               _("Return true if the X position satisfies the test."),
                               _("The X position of the path of _PARAM0_ is _PARAM2__PARAM3_"),
                               _("Path position"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("relationalOperator", _("Comparison sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("GetOffsetX").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddAction("SetOffsetX",
                               _("Modify the path X position"),
                               _("Change the path X position."),
                               _("Do _PARAM2__PARAM3_ to the X position of the path of _PARAM0_"),
                               _("Path position"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("operator", _("Modification sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("SetOffsetX").SetGetter("GetOffsetX").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");

                aut.AddExpression("PathX", _("X position of the path"), _("X position of the path"), _("Path position"), "CppPlatform/Extensions/pathicon16.png")
                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("GetOffsetX").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddCondition("GetOffsetY",
                               _("Path Y position"),
                               _("Return true if the Y position satisfies the test."),
                               _("The Y position of the path of _PARAM0_ is _PARAM2__PARAM3_"),
                               _("Path position"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("relationalOperator", _("Comparison sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("GetOffsetY").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddAction("SetOffsetY",
                               _("Modify the path Y position"),
                               _("Change the path Y position."),
                               _("Do _PARAM2__PARAM3_ to the Y position of the path of _PARAM0_"),
                               _("Path position"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("operator", _("Modification sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("SetOffsetY").SetGetter("GetOffsetY").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");

                aut.AddExpression("PathY", _("Path Y position"), _("Path Y position"), _("Path position"), "CppPlatform/Extensions/pathicon16.png")
                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("GetOffsetY").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddCondition("GetFollowAngle",
                               _("Automatic rotation"),
                               _("Return true if the object's angle is automatically updated."),
                               _("The angle of _PARAM0_ is automatically updated on the path"),
                               _("Options"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("FollowAngle").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddAction("SetFollowAngle",
                               _("De/activate automatic rotation"),
                               _("Activate or deactivate the automatic update of the angle of the object on the path."),
                               _("Activate automatic rotation of _PARAM0_: _PARAM2_"),
                               _("Options"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("yesorno", _("Activate \?"))
                    .SetFunctionName("SetFollowAngle").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddCondition("GetAngleOffset",
                               _("Angle offset"),
                               _("Return true if the angle offset satifies the condition."),
                               _("The angle offset of _PARAM0_ is _PARAM2__PARAM3_"),
                               _("Options"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("relationalOperator", _("Comparison sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("GetAngleOffset").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddAction("SetAngleOffset",
                               _("Change the angle offset"),
                               _("Change the angle offset"),
                               _("Do _PARAM2__PARAM3_ to angle offset of _PARAM0_"),
                               _("Options"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("operator", _("Modification sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("SetAngleOffset").SetGetter("GetAngleOffset").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");

                aut.AddExpression("AngleOffset", _("Angle offset"), _("Add an offset to the angle of the object"), _("Options"), "CppPlatform/Extensions/pathicon16.png")
                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("GetAngleOffset").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddCondition("GetSpeed",
                               _("Speed"),
                               _("Return true if the speed satisfy the condition."),
                               _("The speed of _PARAM0_ on the path is _PARAM2__PARAM3_"),
                               _("Movement"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("relationalOperator", _("Comparison sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("GetSpeed").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");


                aut.AddAction("SetSpeed",
                               _("Change the speed"),
                               _("Change the speed of the object on the path."),
                               _("Do _PARAM1__PARAM2_ to the speed of _PARAM0_ on the path"),
                               _("Movement"),
                               "CppPlatform/Extensions/pathicon24.png",
                               "CppPlatform/Extensions/pathicon16.png")

                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .AddParameter("operator", _("Modification sign"))
                    .AddParameter("expression", _("Value"))
                    .SetFunctionName("SetSpeed").SetGetter("GetSpeed").SetManipulatedType("number").SetIncludeFile("PathBehavior/PathBehavior.h");

                aut.AddExpression("Speed", _("Speed"), _("Moving speed on the path"), _("Movement"), "CppPlatform/Extensions/pathicon16.png")
                    .AddParameter("object", _("Object"))
                    .AddParameter("behavior", _("Behavior"), "PathBehavior")
                    .SetFunctionName("GetSpeed").SetIncludeFile("PathBehavior/PathBehavior.h");


                #endif

            };

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #22
0
JoystickExtension::JoystickExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsJoystickExtension(*this);

    SetExtensionInformation("BuiltinJoystick",
                          _("Joysticks features"),
                          _("Built-in extension allowing to use joysticks"),
                          "Florian Rival",
                          "Open source (MIT License)");

    //Nothing is available for now.
    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:
    /*
    AddCondition("JoystickButtonDown",
                   _("A button of a joystick is pressed"),
                   _("Test if a button of a joystick is pressed."),
                   _("The button _PARAM2_ of joystick _PARAM1_ is pressed"),
                   _("Joystick"),
                   "res/conditions/joystick24.png",
                   "res/conditions/joystick.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("expression", _("Joystick number ( First joystick: 0 )"))
        .AddParameter("expression", _("Button"))
        .SetFunctionName("JoystickButtonDown").SetIncludeFile("GDCpp/Extensions/Builtin/JoystickTools.h");



    AddCondition("JoystickAxis",
                   _("Value of an axis of a joystick"),
                   _("Test the value of an axis of a joystick."),
                   _("The value of the axis _PARAM2_ of joystick _PARAM1_ is _PARAM3__PARAM4_"),
                   _("Joystick"),
                   "res/conditions/joystick24.png",
                   "res/conditions/joystick.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("expression", _("Joystick number ( First joystick: 0 )"))
        .AddParameter("joyaxis", _("Axis"))
        .AddParameter("relationalOperator", _("Sign of the test"))
        .AddParameter("expression", _("Value to test"))
        .SetFunctionName("GetJoystickAxisValue").SetManipulatedType("number").SetIncludeFile("GDCpp/Extensions/Builtin/JoystickTools.h");



    AddAction("GetJoystickAxis",
                   _("Get the value of the axis of a joystick"),
                   _("Save in the variable the value of the axis of the joystick ( from -100 to 100 )."),
                   _("Save in _PARAM3_ the value of axis _PARAM2_ of joystick _PARAM1_"),
                   _("Joystick"),
                   "res/actions/joystick24.png",
                   "res/actions/joystick.png")
        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("expression", _("Joystick number ( First joystick: 0 )"))
        .AddParameter("joyaxis", _("Axis"))
        .AddParameter("scenevar", _("Save result to scene variable"))
        .SetFunctionName("JoystickAxisValueToVariable").SetManipulatedType("number").SetIncludeFile("GDCpp/Extensions/Builtin/JoystickTools.h");

    AddExpression("GetJoystickAxis",
                   _("Joystick axis"),
                   _("Value of an axis of a joystick"),
                   _("Joystick"),
                   "res/conditions/joystick.png")

        .AddCodeOnlyParameter("currentScene", "")
        .AddParameter("expression", _("Joystick number ( First joystick: 0 )"))
        .AddParameter("joyaxis", _("Axis"))
        .SetFunctionName("GetJoystickAxisValue").SetIncludeFile("GDCpp/Extensions/Builtin/JoystickTools.h");

    */
}
Пример #23
0
VariablesExtension::VariablesExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsVariablesExtension(*this);

    SetExtensionInformation("BuiltinVariables",
                          _("Variable features"),
                          _("Built-in extension allowing to manipulate variables"),
                          "Florian Rival",
                          "Open source (LGPL)");

    GetAllConditions()["VarScene"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.getVariableNumber");
    GetAllConditions()["VarSceneTxt"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.getVariableString");
    GetAllConditions()["VarGlobal"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.getVariableNumber");
    GetAllConditions()["VarGlobalTxt"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.getVariableString");
    GetAllExpressions()["Variable"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.getVariableNumber");
    GetAllStrExpressions()["VariableString"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.getVariableString");
    GetAllExpressions()["GlobalVariable"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.getVariableNumber");
    GetAllStrExpressions()["GlobalVariableString"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.getVariableString");

    GetAllConditions()["VarSceneDef"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.sceneVariableExists");
    GetAllConditions()["VarGlobalDef"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.globalVariableExists");

    GetAllConditions()["VariableChildExists"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.variableChildExists");
    GetAllConditions()["GlobalVariableChildExists"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.variableChildExists");
    GetAllActions()["VariableRemoveChild"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.variableRemoveChild");
    GetAllActions()["GlobalVariableRemoveChild"].codeExtraInformation.SetFunctionName("gdjs.evtTools.common.variableRemoveChild");

    {
        class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
        {
            virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
            {
                std::string expressionCode;
                {
                    gd::CallbacksForGeneratingExpressionCode callbacks(expressionCode, codeGenerator, context);
                    gd::ExpressionParser parser(instruction.GetParameters()[2].GetPlainString());
                    if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks) || expressionCode.empty())
                        expressionCode = "0";
                }
                std::string varGetter;
                {
                    VariableCodeGenerationCallbacks callbacks(varGetter, codeGenerator, context, VariableCodeGenerationCallbacks::LAYOUT_VARIABLE);
                    gd::VariableParser parser(instruction.GetParameters()[0].GetPlainString());
                    if ( !parser.Parse(callbacks) )
                        varGetter = "runtimeScene.getVariables().get(\"\")";
                }

                std::string op = instruction.GetParameters()[1].GetPlainString();
                if ( op == "=" )
                    return varGetter+".setNumber("+expressionCode+");\n";
                else if ( op == "+" )
                    return varGetter+".add("+expressionCode+");\n";
                else if ( op == "-" )
                    return varGetter+".sub("+expressionCode+");\n";
                else if ( op == "*" )
                    return varGetter+".mul("+expressionCode+");\n";
                else if ( op == "/" )
                    return varGetter+".div("+expressionCode+");\n";

                return "";
            };
        };

        gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGen = new CodeGenerator;
        GetAllActions()["ModVarScene"].codeExtraInformation.SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGen));
    }
    {
        class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
        {
            virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
            {
                std::string expressionCode;
                {
                    gd::CallbacksForGeneratingExpressionCode callbacks(expressionCode, codeGenerator, context);
                    gd::ExpressionParser parser(instruction.GetParameters()[2].GetPlainString());
                    if (!parser.ParseStringExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks) || expressionCode.empty())
                        expressionCode = "\"\"";
                }

                std::string varGetter;
                {
                    VariableCodeGenerationCallbacks callbacks(varGetter, codeGenerator, context, VariableCodeGenerationCallbacks::LAYOUT_VARIABLE);
                    gd::VariableParser parser(instruction.GetParameters()[0].GetPlainString());
                    if ( !parser.Parse(callbacks) )
                        varGetter = "runtimeScene.getVariables().get(\"\")";
                }

                std::string op = instruction.GetParameters()[1].GetPlainString();
                if ( op == "=" )
                    return varGetter+".setString("+expressionCode+");\n";
                else if ( op == "+" )
                    return varGetter+".concatenate("+expressionCode+");\n";

                return "";
            };
        };

        gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGen = new CodeGenerator;
        GetAllActions()["ModVarSceneTxt"].codeExtraInformation.SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGen));
    }
    {
        class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
        {
            virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
            {
                std::string expressionCode;
                {
                    gd::CallbacksForGeneratingExpressionCode callbacks(expressionCode, codeGenerator, context);
                    gd::ExpressionParser parser(instruction.GetParameters()[2].GetPlainString());
                    if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks) || expressionCode.empty())
                        expressionCode = "0";
                }
                std::string varGetter;
                {
                    VariableCodeGenerationCallbacks callbacks(varGetter, codeGenerator, context, VariableCodeGenerationCallbacks::PROJECT_VARIABLE);
                    gd::VariableParser parser(instruction.GetParameters()[0].GetPlainString());
                    if ( !parser.Parse(callbacks) )
                        varGetter = "runtimeScene.getVariables().get(\"\")";
                }

                std::string op = instruction.GetParameters()[1].GetPlainString();
                if ( op == "=" )
                    return varGetter+".setNumber("+expressionCode+");\n";
                else if ( op == "+" )
                    return varGetter+".add("+expressionCode+");\n";
                else if ( op == "-" )
                    return varGetter+".sub("+expressionCode+");\n";
                else if ( op == "*" )
                    return varGetter+".mul("+expressionCode+");\n";
                else if ( op == "/" )
                    return varGetter+".div("+expressionCode+");\n";

                return "";
            };
        };

        gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGen = new CodeGenerator;
        GetAllActions()["ModVarGlobal"].codeExtraInformation.SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGen));
    }
    {
        class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
        {
            virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
            {
                std::string expressionCode;
                {
                    gd::CallbacksForGeneratingExpressionCode callbacks(expressionCode, codeGenerator, context);
                    gd::ExpressionParser parser(instruction.GetParameters()[2].GetPlainString());
                    if (!parser.ParseStringExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks) || expressionCode.empty())
                        expressionCode = "\"\"";
                }

                std::string varGetter;
                {
                    VariableCodeGenerationCallbacks callbacks(varGetter, codeGenerator, context, VariableCodeGenerationCallbacks::PROJECT_VARIABLE);
                    gd::VariableParser parser(instruction.GetParameters()[0].GetPlainString());
                    if ( !parser.Parse(callbacks) )
                        varGetter = "runtimeScene.getVariables().get(\"\")";
                }

                std::string op = instruction.GetParameters()[1].GetPlainString();
                if ( op == "=" )
                    return varGetter+".setString("+expressionCode+");\n";
                else if ( op == "+" )
                    return varGetter+".concatenate("+expressionCode+");\n";

                return "";
            };
        };

        gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGen = new CodeGenerator;
        GetAllActions()["ModVarGlobalTxt"].codeExtraInformation.SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGen));
    }
}
Пример #24
0
    /**
     * Constructor of an extension declares everything the extension contains : Objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("TimedEvent",
                              _("Timed events"),
                              _("Event which launch its conditions and actions only after a amount of time is reached."),
                              "Florian Rival",
                              "zlib/libpng License (Open Source)");

        #if defined(GD_IDE_ONLY)

        {
            class CodeGen : public gd::EventMetadata::CodeGenerator
            {
                virtual std::string Generate(gd::BaseEvent & event_, gd::EventsCodeGenerator & codeGenerator,
                                             gd::EventsCodeGenerationContext & context)
                {
                    TimedEvent & event = dynamic_cast<TimedEvent&>(event_);
                    const gd::Layout & scene = codeGenerator.GetLayout();

                    codeGenerator.AddIncludeFile("TimedEvent/TimedEventTools.h");

                    //Notify parent timed event that they have a child
                    for (unsigned int i = 0;i<TimedEvent::codeGenerationCurrentParents.size();++i)
                        TimedEvent::codeGenerationCurrentParents[i]->codeGenerationChildren.push_back(&event);

                    //And register this event as potential parent
                    TimedEvent::codeGenerationCurrentParents.push_back(&event);
                    event.codeGenerationChildren.clear();

                    //Prepare code for computing timeout
                    std::string timeOutCode;
                    gd::CallbacksForGeneratingExpressionCode callbacks(timeOutCode, codeGenerator, context);
                    gd::ExpressionParser parser(event.GetTimeoutExpression());
                    if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), scene, callbacks) || timeOutCode.empty()) timeOutCode = "0";

                    //Prepare name
                    std::string codeName = !event.GetName().empty() ? "GDNamedTimedEvent_"+codeGenerator.ConvertToString(event.GetName()) : "GDTimedEvent_"+ToString(&event);

                    std::string outputCode;

                    outputCode += "if ( static_cast<double>(GDpriv::TimedEvents::UpdateAndGetTimeOf(*runtimeContext->scene, \""+codeName+"\"))/1000000.0 > "+timeOutCode+")";
                    outputCode += "{";

                    outputCode += codeGenerator.GenerateConditionsListCode(event.GetConditions(), context);

                    std::string ifPredicat;
                    for (unsigned int i = 0;i<event.GetConditions().size();++i)
                    {
                        if (i!=0) ifPredicat += " && ";
                        ifPredicat += "condition"+ToString(i)+"IsTrue";
                    }

                    if ( !ifPredicat.empty() ) outputCode += "if (" +ifPredicat+ ")\n";
                    outputCode += "{\n";
                    outputCode += codeGenerator.GenerateActionsListCode(event.GetActions(), context);
                    if ( event.HasSubEvents() ) //Sub events
                    {
                        outputCode += "\n{\n";
                        outputCode += codeGenerator.GenerateEventsListCode(event.GetSubEvents(), context);
                        outputCode += "}\n";
                    }

                    outputCode += "}\n";

                    outputCode += "}";

                    //This event cannot be a parent of other TimedEvent anymore
                    if (!TimedEvent::codeGenerationCurrentParents.empty())
                        TimedEvent::codeGenerationCurrentParents.pop_back();
                    else
                        std::cout << "Error! CodeGenerationCurrentParents cannot be empty!";

                    return outputCode;
                }
            };
            gd::EventMetadata::CodeGenerator * codeGen = new CodeGen;

            AddEvent("TimedEvent",
                          _("Timed event"),
                          _("Event which launch its conditions and actions only after a amount of time is reached."),
                          "",
                          "CppPlatform/Extensions/timedevent16.png",
                          boost::shared_ptr<gd::BaseEvent>(new TimedEvent))
                .SetCodeGenerator(boost::shared_ptr<gd::EventMetadata::CodeGenerator>(codeGen));
        }

        {
            class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
            {
                virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
                {
                    codeGenerator.AddIncludeFile("TimedEvent/TimedEventTools.h");

                    std::string codeName = "GDNamedTimedEvent_"+codeGenerator.ConvertToString(instruction.GetParameter(1).GetPlainString());
                    return "GDpriv::TimedEvents::Reset(*runtimeContext->scene, \""+codeName+"\");\n";

                    return "";
                };
            };
            gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGenerator = new CodeGenerator; //Need for code to compile

            AddAction("ResetTimedEvent",
                           _("Reset a timed event"),
                           _("Reset a timed event"),
                           _("Reset the timed event(s) called _PARAM1_"),
                           _("Timed events"),
                           "CppPlatform/Extensions/timedevent24.png",
                           "CppPlatform/Extensions/timedevent16.png")
                .AddCodeOnlyParameter("currentScene", "")
                .AddParameter("", _("Name"))
                .codeExtraInformation.SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGenerator));
        }

        {
            class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
            {
                virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
                {
                    codeGenerator.AddIncludeFile("TimedEvent/TimedEventTools.h");

                    for (unsigned int i = 0;i<TimedEvent::codeGenerationCurrentParents.size();++i)
                    {
                        if ( TimedEvent::codeGenerationCurrentParents[i] == NULL )
                        {
                            std::cout << "WARNING : NULL timed event in codeGenerationCurrentParents";
                            continue;
                        }

                        if (TimedEvent::codeGenerationCurrentParents[i]->GetName() == instruction.GetParameter(0).GetPlainString())
                        {
                            TimedEvent & timedEvent = *TimedEvent::codeGenerationCurrentParents[i];

                            std::string code;
                            {
                                std::string codeName = !timedEvent.GetName().empty() ? "GDNamedTimedEvent_"+codeGenerator.ConvertToString(timedEvent.GetName()) : "GDTimedEvent_"+ToString(&timedEvent);
                                code += "GDpriv::TimedEvents::Reset(*runtimeContext->scene, \""+codeName+"\");\n";
                            }
                            for (unsigned int j = 0;j<timedEvent.codeGenerationChildren.size();++j)
                            {
                                std::string codeName = !timedEvent.codeGenerationChildren[j]->GetName().empty() ? "GDNamedTimedEvent_"+codeGenerator.ConvertToString(timedEvent.codeGenerationChildren[j]->GetName()) : "GDTimedEvent_"+ToString(timedEvent.codeGenerationChildren[j]);
                                code += "GDpriv::TimedEvents::Reset(*runtimeContext->scene, \""+codeName+"\");\n";
                            }
                            return code;
                        }
                    }

                    return "";
                };
            };
            gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGenerator = new CodeGenerator; //Need for code to compile

            AddAction("ResetTimedEventAndSubs",
                           _("Reset a timed event and sub events"),
                           _("Reset a timed events, as well as all of its sub events."),
                           _("Reset timed events called _PARAM1_ and their sub events"),
                           _("Timed events"),
                           "CppPlatform/Extensions/timedevent24.png",
                           "CppPlatform/Extensions/timedevent16.png")

                .AddParameter("", _("Name"))
                .codeExtraInformation.SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGenerator))
                .SetIncludeFile("TimedEvent/TimedEventTools.h");
        }
        #endif

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #25
0
BaseObjectExtension::BaseObjectExtension()
{
    SetExtensionInformation("BuiltinObject",
                          _("Base object"),
                          _("Base object"),
                          "Florian Rival",
                          "Open source ( LGPL )");
    CloneExtension("Game Develop C++ platform", "BuiltinObject");

    std::map<std::string, gd::InstructionMetadata > & objectActions = GetAllActionsForObject("");
    std::map<std::string, gd::InstructionMetadata > & objectConditions = GetAllConditionsForObject("");
    std::map<std::string, gd::ExpressionMetadata > & objectExpressions = GetAllExpressionsForObject("");
    std::map<std::string, gd::StrExpressionMetadata > & objectStrExpressions = GetAllStrExpressionsForObject("");

    objectActions["MettreX"].codeExtraInformation
        .SetFunctionName("setX").SetAssociatedGetter("getX").SetIncludeFile("runtimeobject.js");
    objectActions["MettreY"].codeExtraInformation
        .SetFunctionName("setY").SetAssociatedGetter("getY").SetIncludeFile("runtimeobject.js");
    objectConditions["PosX"].codeExtraInformation
        .SetFunctionName("getX").SetIncludeFile("runtimeobject.js");
    objectConditions["PosY"].codeExtraInformation
        .SetFunctionName("getY").SetIncludeFile("runtimeobject.js");
    objectActions["ChangeLayer"].codeExtraInformation
        .SetFunctionName("setLayer").SetIncludeFile("runtimeobject.js");
    objectConditions["Layer"].codeExtraInformation
        .SetFunctionName("isOnLayer").SetIncludeFile("runtimeobject.js");
    objectActions["ChangePlan"].codeExtraInformation
        .SetFunctionName("setZOrder").SetAssociatedGetter("getZOrder").SetIncludeFile("runtimeobject.js");
    objectConditions["Plan"].codeExtraInformation
        .SetFunctionName("getZOrder").SetIncludeFile("runtimeobject.js");
    objectActions["Cache"].codeExtraInformation
        .SetFunctionName("hide").SetIncludeFile("runtimeobject.js");
    objectActions["Montre"].codeExtraInformation
        .SetFunctionName("hide").SetIncludeFile("runtimeobject.js");
    objectConditions["Visible"].codeExtraInformation
        .SetFunctionName("isVisible").SetIncludeFile("runtimeobject.js");
    objectConditions["Invisible"].codeExtraInformation
        .SetFunctionName("isHidden").SetIncludeFile("runtimeobject.js");
    objectActions["Delete"].codeExtraInformation
        .SetFunctionName("deleteFromScene");
    objectActions["MettreAutourPos"].codeExtraInformation
        .SetFunctionName("putAround");
    objectActions["MettreAutour"].codeExtraInformation
        .SetFunctionName("putAroundObject").SetIncludeFile("runtimeobject.js");
    objectConditions["VarObjet"].codeExtraInformation
        .SetFunctionName("getVariableNumber").SetIncludeFile("runtimeobject.js");
    objectConditions["VarObjetTxt"].codeExtraInformation
        .SetFunctionName("getVariableString").SetIncludeFile("runtimeobject.js");
    objectConditions["VarObjetDef"].codeExtraInformation
        .SetFunctionName("hasVariable").SetIncludeFile("runtimeobject.js");
    objectActions["ModVarObjet"].codeExtraInformation
        .SetFunctionName("setVariableNumber").SetAssociatedGetter("getVariableNumber").SetIncludeFile("runtimeobject.js");
    objectActions["ModVarObjetTxt"].codeExtraInformation
        .SetFunctionName("setVariableString").SetAssociatedGetter("getVariableString").SetIncludeFile("runtimeobject.js");
    objectActions["AddForceXY"].codeExtraInformation
        .SetFunctionName("addForce").SetIncludeFile("runtimeobject.js");
    objectActions["AddForceAL"].codeExtraInformation
        .SetFunctionName("addPolarForce").SetIncludeFile("runtimeobject.js");
    objectActions["AddForceVersPos"].codeExtraInformation
        .SetFunctionName("addForceTowardPosition").SetIncludeFile("runtimeobject.js");
    objectActions["AddForceVers"].codeExtraInformation
        .SetFunctionName("addForceTowardObject").SetIncludeFile("runtimeobject.js");
    objectActions["Arreter"].codeExtraInformation
        .SetFunctionName("clearForces").SetIncludeFile("runtimeobject.js");
    objectConditions["Arret"].codeExtraInformation
        .SetFunctionName("hasNoForces").SetIncludeFile("runtimeobject.js");
    objectConditions["Vitesse"].codeExtraInformation
        .SetFunctionName("getAverageForce().getLength").SetIncludeFile("runtimeobject.js");
    objectConditions["AngleOfDisplacement"].codeExtraInformation
        .SetFunctionName("averageForceAngleIs").SetIncludeFile("runtimeobject.js");
    objectActions["SeparateFromObjects"].codeExtraInformation
        .SetFunctionName("separateFromObjects").SetIncludeFile("runtimeobject.js");
    objectActions["Ecarter"].codeExtraInformation //Deprecated
        .SetFunctionName("separateObjectsWithoutForces").SetIncludeFile("runtimeobject.js");
    objectActions["Rebondir"].codeExtraInformation //Deprecated
        .SetFunctionName("separateObjectsWithForces").SetIncludeFile("runtimeobject.js");
    objectConditions["AutomatismActivated"].codeExtraInformation
        .SetFunctionName("automatismActivated").SetIncludeFile("runtimeobject.js");
    objectActions["ActivateAutomatism"].codeExtraInformation
        .SetFunctionName("activateAutomatism").SetIncludeFile("runtimeobject.js");
    objectConditions["ObjectVariableChildExists"].codeExtraInformation
        .SetFunctionName("variableChildExists").SetIncludeFile("runtimeobject.js");
    objectActions["ObjectVariableRemoveChild"].codeExtraInformation
        .SetFunctionName("variableRemoveChild").SetIncludeFile("runtimeobject.js");

    objectExpressions["X"].codeExtraInformation.SetFunctionName("getX");
    objectExpressions["Y"].codeExtraInformation.SetFunctionName("getY");
    objectExpressions["ZOrder"].codeExtraInformation.SetFunctionName("getZOrder");
    objectExpressions["Plan"].codeExtraInformation.SetFunctionName("getZOrder");
    objectExpressions["Width"].codeExtraInformation.SetFunctionName("getWidth");
    objectExpressions["Height"].codeExtraInformation.SetFunctionName("getHeight");
    objectExpressions["Largeur"].codeExtraInformation.SetFunctionName("getWidth"); //Deprecated
    objectExpressions["Hauteur"].codeExtraInformation.SetFunctionName("getHeight"); //Deprecated
    objectExpressions["Variable"].codeExtraInformation.SetFunctionName("gdjs.RuntimeObject.getVariableNumber").SetStatic();
    objectStrExpressions["VariableString"].codeExtraInformation.SetFunctionName("gdjs.RuntimeObject.getVariableString").SetStatic();
    objectExpressions["ForceX"].codeExtraInformation.SetFunctionName("getAverageForce().getX");
    objectExpressions["ForceY"].codeExtraInformation.SetFunctionName("getAverageForce().getY");
    objectExpressions["ForceAngle"].codeExtraInformation.SetFunctionName("getAverageForce().getAngle");
    objectExpressions["Angle"].codeExtraInformation.SetFunctionName("getAverageForce().getAngle"); //Deprecated
    objectExpressions["ForceLength"].codeExtraInformation.SetFunctionName("getAverageForce().getLength");
    objectExpressions["Longueur"].codeExtraInformation.SetFunctionName("getAverageForce().getLength"); //Deprecated
    objectExpressions["Distance"].codeExtraInformation.SetFunctionName("getDistanceFrom");
    objectExpressions["SqDistance"].codeExtraInformation.SetFunctionName("getSqDistanceFrom");


    GetAllActions()["Create"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.createObjectOnScene");
    GetAllActions()["CreateByName"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.createObjectFromGroupOnScene");
    GetAllExpressions()["Count"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.pickedObjectsCount");
    GetAllConditions()["NbObjet"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.pickedObjectsCount");
    GetAllConditions()["CollisionNP"]
        .AddCodeOnlyParameter("currentScene", "") //We need an extra parameter pointing to the scene.
        .codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.hitBoxesCollisionTest");
    GetAllConditions()["Distance"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.distanceTest");
    GetAllConditions()["SeDirige"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.movesTowardTest");
    GetAllConditions()["EstTourne"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.turnedTowardTest");

    GetAllActions()["AjoutObjConcern"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.pickAllObjects");
    GetAllConditions()["AjoutObjConcern"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.pickAllObjects");
    GetAllActions()["AjoutHasard"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.pickRandomObject");
    GetAllConditions()["AjoutHasard"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.object.pickRandomObject");


    {
        class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
        {
        public:
            virtual std::string GenerateCode(gd::Instruction &, gd::EventsCodeGenerator &, gd::EventsCodeGenerationContext &)
            {
                return "runtimeScene.updateObjectsForces();";
            };
        };
        gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGen = new CodeGenerator;

        GetAllActions()["MoveObjects"].codeExtraInformation
            .SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGen));
    }

    {
        class CodeGenerator : public gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator
        {
        public:
            virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
            {
                std::string outputCode;

                std::vector<std::string> realObjects = codeGenerator.ExpandObjectsName(instruction.GetParameter(0).GetPlainString(), context);
                for (unsigned int i = 0;i<realObjects.size();++i)
                {
                    context.SetCurrentObject(realObjects[i]);
                    context.ObjectsListNeeded(realObjects[i]);

                    std::string newX, newY;

                    std::string expression1Code;
                    {
                        gd::CallbacksForGeneratingExpressionCode callbacks(expression1Code, codeGenerator, context);
                        gd::ExpressionParser parser(instruction.GetParameters()[2].GetPlainString());
                        if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks) || expression1Code.empty())
                            expression1Code = "0";
                    }

                    std::string expression2Code;
                    {
                        gd::CallbacksForGeneratingExpressionCode callbacks(expression2Code, codeGenerator, context);
                        gd::ExpressionParser parser(instruction.GetParameters()[4].GetPlainString());
                        if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks) || expression2Code.empty())
                            expression2Code = "0";
                    }

                    std::string op1 = instruction.GetParameter(1).GetPlainString();
                    if ( op1 == "=" || op1.empty() )
                        newX = expression1Code;
                    else if ( op1 == "/" || op1 == "*" || op1 == "-" || op1 == "+" )
                        newX = codeGenerator.GetObjectListName(realObjects[i], context)+"[i].getX() "+op1 + expression1Code;
                    else
                        return "";
                    std::string op2 = instruction.GetParameter(3).GetPlainString();
                    if ( op2 == "=" || op2.empty() )
                        newY = expression2Code;
                    else if ( op2 == "/" || op2 == "*" || op2 == "-" || op2 == "+" )
                        newY = codeGenerator.GetObjectListName(realObjects[i], context)+"[i].getY() "+op2 + expression2Code;
                    else
                        return "";

                    std::string call = codeGenerator.GetObjectListName(realObjects[i], context)+"[i].setPosition("+newX+","+newY+")";

                    outputCode += "for(var i = 0, len = "+codeGenerator.GetObjectListName(realObjects[i], context)+".length ;i < len;++i) {\n";
                    outputCode += "    "+call+";\n";
                    outputCode += "}\n";

                    context.SetNoCurrentObject();
                }

                return outputCode;
            };
        };
        gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator * codeGen = new CodeGenerator;

        objectActions["MettreXY"].codeExtraInformation
            .SetCustomCodeGenerator(boost::shared_ptr<gd::InstructionMetadata::ExtraInformation::CustomCodeGenerator>(codeGen));
    }

    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:
/*
        obj.AddAction("AddForceTournePos",
                       _("Add a force so as to move around a position"),
                       _("Add a force to an object so as it rotates toward a position.\nNote that the moving is not precise, especially if the speed is high.\nTo position an object around a position more precisly, use the actions in the category  \"Position\"."),
                       _("Rotate _PARAM0_ around _PARAM1_;_PARAM2_ with _PARAM3_�/sec and _PARAM4_ pixels away"),
                       _("Displacement"),
                       "res/actions/forceTourne24.png",
                       "res/actions/forceTourne.png")

            .AddParameter("object", _("Object"))
            .AddParameter("expression", _("X position of the center"))
            .AddParameter("expression", _("Y position of the center"))
            .AddParameter("expression", _("Speed ( in Degrees per seconds )"))
            .AddParameter("expression", _("Distance ( in pixels )"))
            .AddParameter("expression", _("Damping ( Default : 0 )"))
            .codeExtraInformation.SetFunctionName("AddForceToMoveAround");

        obj.AddAction("AddForceTourne",
                       _("Add a force so as to move around an object"),
                       _("Add a force to an object so as it rotates around another.\nNote that the moving is not precise, especially if the speed is high.\nTo position an object around a position more precisly, use the actions in the category  \"Position\"."),
                       _("Rotate _PARAM0_ around _PARAM1_ with _PARAM2_�/sec and _PARAM3_ pixels away"),
                       _("Displacement"),
                       "res/actions/forceTourne24.png",
                       "res/actions/forceTourne.png")

            .AddParameter("object", _("Object"))
            .AddParameter("objectPtr", _("Rotate around this object"))
            .AddParameter("expression", _("Speed ( Degrees per second )"))
            .AddParameter("expression", _("Distance ( in pixel )"))
            .AddParameter("expression", _("Damping ( Default : 0 )"))
            .codeExtraInformation.SetFunctionName("AddForceToMoveAroundObject").SetIncludeFile("GDCpp/BuiltinExtensions/ObjectTools.h");
*/
}
Пример #26
0
    /**
     * \brief Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    JsExtension()
    {
        SetExtensionInformation("PathfindingBehavior",
                              _("Pathfinding behavior"),
                              _("Compute paths for objects avoiding obstacles."),
                              "Florian Rival",
                              "Open source (MIT License)");
        CloneExtension("GDevelop C++ platform", "PathfindingBehavior");

        GetBehaviorMetadata("PathfindingBehavior::PathfindingBehavior")
            .SetIncludeFile("PathfindingBehavior/pathfindingruntimebehavior.js")
            .AddIncludeFile("PathfindingBehavior/pathfindingobstacleruntimebehavior.js");

        {

            std::map<gd::String, gd::InstructionMetadata > & autActions = GetAllActionsForBehavior("PathfindingBehavior::PathfindingBehavior");
            std::map<gd::String, gd::InstructionMetadata > & autConditions = GetAllConditionsForBehavior("PathfindingBehavior::PathfindingBehavior");
            std::map<gd::String, gd::ExpressionMetadata > & autExpressions = GetAllExpressionsForBehavior("PathfindingBehavior::PathfindingBehavior");

            autConditions["PathfindingBehavior::PathFound"].SetFunctionName("pathFound");
            autActions["PathfindingBehavior::SetDestination"].SetFunctionName("moveTo");
            autConditions["PathfindingBehavior::DestinationReached"].SetFunctionName("destinationReached");
            autActions["PathfindingBehavior::CellWidth"].SetFunctionName("setCellWidth").SetGetter("getCellWidth");
            autConditions["PathfindingBehavior::CellWidth"].SetFunctionName("getCellWidth");
            autActions["PathfindingBehavior::CellHeight"].SetFunctionName("setCellHeight").SetGetter("getCellHeight");
            autConditions["PathfindingBehavior::CellHeight"].SetFunctionName("getCellHeight");
            autActions["PathfindingBehavior::Acceleration"].SetFunctionName("setAcceleration").SetGetter("getAcceleration");
            autConditions["PathfindingBehavior::Acceleration"].SetFunctionName("getAcceleration");
            autActions["PathfindingBehavior::MaxSpeed"].SetFunctionName("setMaxSpeed").SetGetter("getMaxSpeed");
            autConditions["PathfindingBehavior::MaxSpeed"].SetFunctionName("getMaxSpeed");
            autActions["PathfindingBehavior::Speed"].SetFunctionName("setSpeed").SetGetter("getSpeed");
            autConditions["PathfindingBehavior::Speed"].SetFunctionName("getSpeed");
            autActions["PathfindingBehavior::AngularMaxSpeed"].SetFunctionName("setAngularMaxSpeed").SetGetter("getAngularMaxSpeed");
            autConditions["PathfindingBehavior::AngularMaxSpeed"].SetFunctionName("getAngularMaxSpeed");
            autActions["PathfindingBehavior::AngleOffset"].SetFunctionName("setAngleOffset").SetGetter("getAngleOffset");
            autConditions["PathfindingBehavior::AngleOffset"].SetFunctionName("getAngleOffset");
            autActions["PathfindingBehavior::ExtraBorder"].SetFunctionName("setExtraBorder").SetGetter("getExtraBorder");
            autConditions["PathfindingBehavior::ExtraBorder"].SetFunctionName("getExtraBorder");

            autActions["PathfindingBehavior::AllowDiagonals"].SetFunctionName("allowDiagonals");
            autConditions["PathfindingBehavior::DiagonalsAllowed"].SetFunctionName("diagonalsAllowed");
            autActions["PathfindingBehavior::RotateObject"].SetFunctionName("setRotateObject");
            autConditions["PathfindingBehavior::ObjectRotated"].SetFunctionName("isObjectRotated");

            autExpressions["GetNodeX"].SetFunctionName("getNodeX");
            autExpressions["GetNodeY"].SetFunctionName("getNodeY");
            autExpressions["NextNodeIndex"].SetFunctionName("getNextNodeIndex");
            autExpressions["NodeCount"].SetFunctionName("getNodeCount");
            autExpressions["NextNodeX"].SetFunctionName("getNextNodeX");
            autExpressions["NextNodeY"].SetFunctionName("getNextNodeY");
            autExpressions["LastNodeX"].SetFunctionName("getLastNodeX");
            autExpressions["LastNodeY"].SetFunctionName("getLastNodeY");
            autExpressions["DestinationX"].SetFunctionName("getDestinationX");
            autExpressions["DestinationY"].SetFunctionName("getDestinationY");

            autExpressions["Acceleration"].SetFunctionName("getAcceleration");
            autExpressions["MaxSpeed"].SetFunctionName("getMaxSpeed");
            autExpressions["Speed"].SetFunctionName("getSpeed");
            autExpressions["AngularMaxSpeed"].SetFunctionName("getAngularMaxSpeed");
            autExpressions["AngleOffset"].SetFunctionName("getAngleOffset");
            autExpressions["ExtraBorder"].SetFunctionName("getExtraBorder");
            autExpressions["CellWidth"].SetFunctionName("getCellWidth");
            autExpressions["CellHeight"].SetFunctionName("getCellHeight");
        }

        GetBehaviorMetadata("PathfindingBehavior::PathfindingObstacleBehavior")
            .SetIncludeFile("PathfindingBehavior/pathfindingruntimebehavior.js")
            .AddIncludeFile("PathfindingBehavior/pathfindingobstacleruntimebehavior.js");

        {
            std::map<gd::String, gd::InstructionMetadata > & autActions = GetAllActionsForBehavior("PathfindingBehavior::PathfindingObstacleBehavior");
            std::map<gd::String, gd::InstructionMetadata > & autConditions = GetAllConditionsForBehavior("PathfindingBehavior::PathfindingObstacleBehavior");
            std::map<gd::String, gd::ExpressionMetadata > & autExpressions = GetAllExpressionsForBehavior("PathfindingBehavior::PathfindingObstacleBehavior");

            autActions["PathfindingObstacleBehavior::Cost"].SetFunctionName("setCost").SetGetter("getCost");
            autConditions["PathfindingObstacleBehavior::Cost"].SetFunctionName("getCost");
            autActions["PathfindingObstacleBehavior::SetImpassable"].SetFunctionName("setImpassable");
            autConditions["PathfindingObstacleBehavior::IsImpassable"].SetFunctionName("isImpassable");

            autExpressions["Cost"].SetFunctionName("getCost");
        }

        StripUnimplementedInstructionsAndExpressions();
    };
Пример #27
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("AdvancedXML",
                              _("Advanced XML 1.0"),
                              _("Extension allowing to manipulate XML files."),
                              "Victor Levasseur",
                              "Open source (MIT License)");

        #if defined(GD_IDE_ONLY)

        AddAction("NewFile",
                       _("Create an XML document"),
                       _("Create an XML document"),
                       _("Create an XML document into reference _PARAM0_"),
                       _("Advanced XML : Documents"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference (allow to access later to the element)"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::CreateNewDocument").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        AddAction("LoadFile",
                       _("Load an XML file"),
                       _("Load an XML file."),
                       _("Load XML File _PARAM0_ into reference _PARAM1_"),
                       _("Advanced XML : Documents"),
                       "res/AdvancedXML/AdvancedXMLOpen.png",
                       "res/AdvancedXML/AdvancedXMLOpen16.png")

            .AddParameter("file", _("Source file"))
            .AddParameter("string", _("Reference (allow to access later to the element)"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::LoadXmlFile").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        AddAction("SaveFile",
                       _("Save an XML file"),
                       _("Save an XML file."),
                       _("Save XML file _PARAM1_ into _PARAM0_"),
                       _("Advanced XML : Documents"),
                       "res/AdvancedXML/AdvancedXMLSave.png",
                       "res/AdvancedXML/AdvancedXMLSave16.png")

            .AddParameter("file", _("File where to save the document"))
            .AddParameter("string", _("Reference to the XML document"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::SaveXmlFile").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        AddAction("BrowseTo",
                       _("Load an element into a reference"),
                       _("Load an element (relative to another) in a reference.\nNote: References allows to access to an element using the name of the reference pointing to it."),
                       _("Load path _PARAM2_ (relative to the element _PARAM0_) into reference _PARAM1_"),
                       _("Advanced XML: General"),
                       "res/AdvancedXML/AdvancedXMLRef.png",
                       "res/AdvancedXML/AdvancedXMLRef16.png")

            .AddParameter("string", _("Reference of an existing element ( The path of the element will be relative to this element )"))
            .AddParameter("string", _("Name of the reference to the newly created element"))
            .AddParameter("string", _("Path ( tags can be browsed by separating them using /. Use * to go to the first child element without knowing the tag name )"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::BrowseTo").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        AddAction("NextSibling",
                       _("Go to next element"),
                       _("Create a reference on the element following the specified element.\nNote: The reference will be invalid if there is no valid element following the specified one.Conditions are available to check if an element is valid."),
                       _("Load the element called _PARAM2_ following _PARAM1_ into reference _PARAM0_"),
                       _("Advanced XML: General"),
                       "res/AdvancedXML/AdvancedXMLRef.png",
                       "res/AdvancedXML/AdvancedXMLRef16.png")

            .AddParameter("string", _("Reference to create"))
            .AddParameter("string", _("Reference to the element preceeding the element to be accessed"))
            .AddParameter("string", _("Tag name filter "), "", true)
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::NextSibling").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        AddCondition("IsRefValid",
                       _("The reference is valid"),
                       _("Is valid only when the reference is pointing to an existing and valid element."),
                       _("_PARAM0_ exists and is valid"),
                       _("Advanced XML: General"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference to the element to be tested"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::IsRefValid").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");



        AddCondition("GetElementType",
                       _("Element type"),
                       _("Test the type of the element.\n(0-> Tag, 1-> Text, 2-> Comment, 3-> XML Document, -1 -> Unknown )"),
                       _("Type of _PARAM0_ _PARAM1__PARAM2_"),
                       _("Advanced XML: General"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference to the element to be tested"))
            .AddParameter("relationalOperator", _("Comparison sign"))
            .AddParameter("expression", _("Type"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::GetRefType").SetManipulatedType("number").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");



        AddExpression("GetElementType",
                       _("Element type"),
                       _("Return the type of the element.\n(0-> Tag, 1-> Text, 2-> Comment, 3-> XML Document, -1 -> Unknown )"),
                       _("Advanced XML: General"),
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Element reference"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::GetRefType").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");



        AddAction("CreateNewElement",
                       _("Create a new element"),
                       _("Create a new element.\nNote: References allows to access to an element using the name of the reference pointing to it."),
                       _("Create a new element of type _PARAM1_ and attach to it the reference _PARAM0_"),
                       _("Advanced XML: General"),
                       "res/AdvancedXML/AdvancedXMLAdd.png",
                       "res/AdvancedXML/AdvancedXMLAdd16.png")

            .AddParameter("string", _("Reference which will be used to access to the element"))
            .AddParameter("expression", _("Tye of the element to be created\n(0-> Tag, 1-> Text, 2-> Comment )"))
            .AddParameter("string", _("Text of the element\nIf the element is a tag, it will be the tag name,if the element is a text or a comment, it will be the content."))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::CreateNewElement").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        AddAction("DeleteAnElement",
                       _("Delete an element"),
                       _("Delete an element (The element will be removed from its parent and will be destroyed)."),
                       _("Delete element _PARAM0_"),
                       _("Advanced XML: General"),
                       "res/AdvancedXML/AdvancedXMLRemove.png",
                       "res/AdvancedXML/AdvancedXMLRemove16.png")

            .AddParameter("string", _("Reference to the element to be deleted"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::DeleteAnElement").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        AddAction("InsertElementIntoAnother",
                       _("Add an element inside another"),
                       _("Add an element into another: The element will be a \"child\" of its \"parent\"."),
                       _("Add _PARAM0_ as a child of _PARAM1_ (before _PARAM2_)"),
                       _("Advanced XML: Tag"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference to the element to be added"))
            .AddParameter("string", _("Reference to the parent element (must be a Tag element)"))
            .AddParameter("string", _("The element will be added before this element (if not defined, the element will be added at the end)"), "", true)
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::InsertElementIntoAnother").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        AddAction("SetTagName",
                       _("Change the tag name"),
                       _("Change the tag name"),
                       _("Do _PARAM1__PARAM2_ to the name of tag _PARAM0_"),
                       _("Advanced XML: Tag"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference to the Tag element"))
            .AddParameter("operator", _("Modification sign"))
            .AddParameter("string", _("Tag name"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::SetText").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h").SetAssociatedGetter("AdvancedXML::GetText").SetManipulatedType("string");

        AddStrExpression("GetTagName",
                       _("Tag name"),
                       _("Get the name of a tag"),
                       _("Advanced XML: Tag"),
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Element reference"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::GetText").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");



        AddAction("SetContent",
                       _("Change the content of the element"),
                       _("Change the content (text) of the element ( For text and comments elements only )."),
                       _("Do _PARAM1__PARAM2_ to the content of _PARAM0_"),
                       _("Advanced XML : Text and comments"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference to the element"))
            .AddParameter("operator", _("Modification sign"))
            .AddParameter("string", _("Contents"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::SetText").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h").SetAssociatedGetter("AdvancedXML::GetText").SetManipulatedType("string");

        AddStrExpression("GetContent",
                       _("Contents"),
                       _("Get the content of a text or comment element"),
                       _("Advanced XML : Text and comments"),
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Element reference"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::GetText").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");



        AddExpression("GetAttributeNumber",
                       _("Value of an attribute of an element"),
                       _("Get the value of an attribute of an element"),
                       _("Advanced XML: Tag"),
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Element reference"))
            .AddParameter("string", _("Name of the attribute"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::GetAttributeNumber").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");



        AddAction("SetAttributeNumber",
                       _("Change the value of an attribute"),
                       _("Change the value of an attribute of an element ( which must be a Tag element )."),
                       _("Do _PARAM2__PARAM3_ to the attribute _PARAM1_ of element _PARAM0_"),
                       _("Advanced XML: Tag"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference to the element"))
            .AddParameter("string", _("Name of the attribute"))
            .AddParameter("operator", _("Modification sign"))
            .AddParameter("expression", _("Value"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::SetAttributeNumber").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h").SetAssociatedGetter("AdvancedXML::GetAttributeNumber").SetManipulatedType("number");

        AddStrExpression("GetAttributeString",
                       _("Text of an attribute of an element"),
                       _("Get the text of an attribute of an element"),
                       _("Advanced XML: Tag"),
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Element reference"))
            .AddParameter("string", _("Name of the attribute"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::GetAttributeString").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");



        AddAction("SetAttributeString",
                       _("Change the text of an attribute"),
                       _("Change the text of an attribute of an element ( which must be a Tag element )."),
                       _("Do _PARAM2__PARAM3_ to the attribute _PARAM1_ of element _PARAM0_"),
                       _("Advanced XML: Tag"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference to the element"))
            .AddParameter("string", _("Name of the attribute"))
            .AddParameter("operator", _("Modification sign"))
            .AddParameter("string", _("Value"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::SetAttributeString").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h").SetAssociatedGetter("AdvancedXML::GetAttributeString").SetManipulatedType("string");

        AddAction("RemoveAttribute",
                       _("Delete an attribute"),
                       _("Delete an attribute from an element ( which must be a Tag element)."),
                       _("Delete attribute _PARAM1_ from the element _PARAM0_"),
                       _("Advanced XML: Tag"),
                       "res/AdvancedXML/AdvancedXML.png",
                       "res/AdvancedXML/AdvancedXML16.png")

            .AddParameter("string", _("Reference to the element"))
            .AddParameter("string", _("Name of the attribute"))
            .AddCodeOnlyParameter("currentScene", "")

            .codeExtraInformation.SetFunctionName("AdvancedXML::RemoveAttribute").SetIncludeFile("AdvancedXML/src/AdvancedXMLTools.h");

        #endif

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #28
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("Network",
                              _("Network features"),
                              _("Built-in extension allowing to exchange data on the network between games."),
                              "Florian Rival",
                              "Open source (MIT License)");

        #if defined(GD_IDE_ONLY)

        AddAction("AddRecipient",
                       _("Add a recipient"),
                       _("Add the computer with the corresponding IP Adress as a recipient of sent data."),
                       _("Add _PARAM0_ to recipients"),
                       _("Network: Sending"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .AddParameter("string", _("Recipient IP address."))
            .AddParameter("expression", _("Recipient port (Default : 50001)"), "", true)

            .SetFunctionName("GDpriv::NetworkExtension::AddRecipient").SetIncludeFile("Network/NetworkManagerFunctions.h");

        AddAction("RemoveAllRecipients",
                       _("Delete all recipients"),
                       _("Clear the list of the recipients of sent data"),
                       _("Clear the list of recipients"),
                       _("Network: Sending"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .SetFunctionName("GDpriv::NetworkExtension::RemoveAllRecipients").SetIncludeFile("Network/NetworkManagerFunctions.h");


        AddAction("ListenToPort",
                       _("Initialize data reception"),
                       _("Initialize the network so as to be able te receive data from other computers."),
                       _("Initialize data reception"),
                       _("Network: Reception"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .AddParameter("expression", _("Listening port (Default : 50001)"), "", true).SetDefaultValue("50001")
            .SetFunctionName("GDpriv::NetworkExtension::ListenToPort").SetIncludeFile("Network/NetworkManagerFunctions.h");

        AddAction("StopListening",
                       _("Stop data reception"),
                       _("Stop data reception."),
                       _("Stop data reception"),
                       _("Network: Reception"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .SetFunctionName("GDpriv::NetworkExtension::ActStopListening").SetIncludeFile("Network/NetworkManagerFunctions.h");

        AddAction("SendValue",
                       _("Send a value"),
                       _("Send a value to recipients"),
                       _("Send value _PARAM1_ with title _PARAM0_ to recipients"),
                       _("Network: Sending"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .AddParameter("string", _("Group"))
            .AddParameter("expression", _("Value"))

            .SetFunctionName("GDpriv::NetworkExtension::SendValue").SetIncludeFile("Network/NetworkManagerFunctions.h");

        AddAction("SendString",
                       _("Send a text"),
                       _("Send a text to recipients"),
                       _("Send text _PARAM1_ with title _PARAM0_ to recipients"),
                       _("Network: Sending"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .AddParameter("string", _("Group"))
            .AddParameter("string", _("Text"))

            .SetFunctionName("GDpriv::NetworkExtension::SendString").SetIncludeFile("Network/NetworkManagerFunctions.h");

        AddAction("ReceivePackets",
                       _("Receive waiting data"),
                       _("Receive data sent by other computers.\nYou can then access to them with the appropriate expressions."),
                       _("Receive data"),
                       _("Network: Reception"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .SetFunctionName("GDpriv::NetworkExtension::ReceivePackets").SetIncludeFile("Network/NetworkManagerFunctions.h");

        AddAction("ResetReceivedData",
                       _("Delete all received data stored in memory"),
                       _("Delete every received data stored in memory"),
                       _("Delete every received data stored in memory"),
                       _("Network: Reception"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .SetFunctionName("GDpriv::NetworkExtension::ResetReceivedData").SetIncludeFile("Network/NetworkManagerFunctions.h");

        AddStrExpression("GetReceivedDataString", _("Get the text of a data"), _("Get the text contained in a data"), _("Network: Reception"), "CppPlatform/Extensions/networkicon.png")
            .AddParameter("string", _("Name of the data containing the text to get"))

            .SetFunctionName("GDpriv::NetworkExtension::GetReceivedDataString").SetIncludeFile("Network/NetworkManagerFunctions.h");


        AddExpression("GetReceivedDataValue", _("Get the value of a data"), _("Get the value contained in a data"), _("Network: Reception"), "CppPlatform/Extensions/networkicon.png")
            .AddParameter("string", _("Name of the data containing the text to get"))

            .SetFunctionName("GDpriv::NetworkExtension::GetReceivedDataValue").SetIncludeFile("Network/NetworkManagerFunctions.h");


        AddStrExpression("GetLastError", _("Last error occured"), _("Get the text describing the last error which occured."), _("Network: Errors"), "res/error.png")

            .SetFunctionName("GDpriv::NetworkExtension::GetLastError").SetIncludeFile("Network/NetworkManagerFunctions.h");


        AddStrExpression("GetPublicAddress", _("IP address"), _("Allow to get the public IP Address of the computer."), _("Network"), "CppPlatform/Extensions/networkicon.png")
            .AddParameter("expression", _("Maximum time to wait before getting the address ( in seconds ) ( 0 = no timeout )"), "", true)

            .SetFunctionName("GDpriv::NetworkExtension::GetPublicAddress").SetIncludeFile("Network/NetworkManagerFunctions.h");


        AddStrExpression("GetLocalAddress", _("Local IP address ( local/LAN )"), _("Allow to get the public IP Address of the computer."), _("Network"), "CppPlatform/Extensions/networkicon.png")

            .SetFunctionName("GDpriv::NetworkExtension::GetLocalAddress").SetIncludeFile("Network/NetworkManagerFunctions.h");


        AddAction("GenerateObjectNetworkId",
                       _("Generate objects' identifiers"),
                       _("Generate automatically identifiers for these objects.\nNote that this action must be preferably used at the start of the scene for example, so as to be sure objects\nhave the same unique identifiers on the different computers."),
                       _("Generate unique network identifiers for _PARAM0_"),
                       _("Automatism Automatic Network Updater"),
                       "CppPlatform/Extensions/networkicon24.png",
                       "CppPlatform/Extensions/networkicon.png")

            .AddParameter("objectList", _("Object"))
            .AddParameter("automatism", _("Automatism"), "NetworkAutomatism", false)
            .SetFunctionName("NetworkAutomatism::GenerateObjectNetworkIdentifier").SetIncludeFile("Network/NetworkAutomatism.h");

        #endif

        {
            gd::AutomatismMetadata & aut = AddAutomatism("NetworkAutomatism",
                  _("Automatic network update"),
                  _("NetworkUpdater"),
                  _("Allows to automatically synchronize the objects of a game on the network."),
                  "",
                  "CppPlatform/Extensions/networkicon32.png",
                  "NetworkAutomatism",
                  std::shared_ptr<gd::Automatism>(new NetworkAutomatism),
                  std::shared_ptr<gd::AutomatismsSharedData>(new SceneNetworkDatas));

            #if defined(GD_IDE_ONLY)
            aut.SetIncludeFile("Network/NetworkAutomatism.h");

            aut.AddAction("SetAsSender",
                           _("Set to send data"),
                           _("The automatism will send the data of the objects.\nBe sure to have generated identifiers for these objects before."),
                           _("Set _PARAM0_ to send data"),
                           _("Automatism Automatic Network Updater"),
                           "CppPlatform/Extensions/networkicon24.png",
                           "CppPlatform/Extensions/networkicon.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "NetworkAutomatism", false)
                .SetFunctionName("SetAsSender").SetIncludeFile("Network/NetworkAutomatism.h");

            aut.AddAction("SetAsReceiver",
                           _("Set to receive data"),
                           _("The automatism will receive the data and will update the objects.\nBe sure to have generated identifiers for these objects before."),
                           _("Set _PARAM0_ to receive data"),
                           _("Automatism Automatic Network Updater"),
                           "CppPlatform/Extensions/networkicon24.png",
                           "CppPlatform/Extensions/networkicon.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "NetworkAutomatism", false)
                .SetFunctionName("SetAsReceiver").SetIncludeFile("Network/NetworkAutomatism.h");

            aut.AddAction("SetIdentifier",
                           _("Change object's identifier"),
                           _("Each object need a unique identifier, the same on all computers, so as to be identified and updated"),
                           _("Set identifier of _PARAM0_ to _PARAM2_"),
                           _("Automatism Automatic Network Updater"),
                           "CppPlatform/Extensions/networkicon24.png",
                           "CppPlatform/Extensions/networkicon.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "NetworkAutomatism", false)
                .AddParameter("expression", _("Identifier"))
                .SetFunctionName("SetIdentifier").SetIncludeFile("Network/NetworkAutomatism.h");

            aut.AddExpression("GetIdentifier", _("Get the identifier of the object"), _("Get the identifier of the object"), _("Automatism Automatic Network Updater"), "res/texteicon.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "NetworkAutomatism", false)
                .SetFunctionName("GetIdentifier").SetIncludeFile("Network/NetworkAutomatism.h");
            #endif
        }

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #29
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("Function",
                              _("Function events"),
                              _("Extension allowing to use events behaving as functions."),
                              "Florian Rival",
                              "Open source (MIT License)");

        #if defined(GD_IDE_ONLY)

        AddAction("LaunchFunction",
            _("Launch a function"),
            _("Launch a function"),
            _("Launch _PARAM0_ (_PARAM1_, _PARAM2_, _PARAM3_, _PARAM4_, _PARAM5_, _PARAM6_, _PARAM7_)"),
            _("Functions"),
            "res/actions/function24.png",
            "res/actions/function.png")
            .AddParameter("", _("Name of the function"))
            .AddParameter("string", _("Parameter 1"), "", true)
            .AddParameter("string", _("Parameter 2"), "", true)
            .AddParameter("string", _("Parameter 3"), "", true)
            .AddParameter("string", _("Parameter 4"), "", true)
            .AddParameter("string", _("Parameter 5"), "", true)
            .AddParameter("string", _("Parameter 6"), "", true)
            .AddParameter("string", _("Parameter 7"), "", true)
            .codeExtraInformation.SetCustomCodeGenerator([](gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context) {
                gd::String functionName = instruction.GetParameter(0).GetPlainString();
                const gd::Project & project = codeGenerator.GetProject();
                const gd::Layout & layout = codeGenerator.GetLayout();

                const FunctionEvent * functionEvent = FunctionEvent::SearchForFunctionInEvents(project, layout.GetEvents(), functionName);
                if ( !functionEvent )
                {
                    std::cout << "Function \""+functionName+"\" not found!" << std::endl;
                    return "//Function \""+functionName+"\" not found.\n";
                }

                codeGenerator.AddGlobalDeclaration("void "+FunctionEvent::MangleFunctionName(layout, *functionEvent)+"(RuntimeContext *, std::map <gd::String, std::vector<RuntimeObject*> *>, std::vector<gd::String> &);\n");
                gd::String code;

                //Generate code for objects passed as arguments
                gd::String objectsAsArgumentCode;
                {
                    objectsAsArgumentCode += "runtimeContext->ClearObjectListsMap()";
                    std::vector<gd::String> realObjects = codeGenerator.ExpandObjectsName(functionEvent->GetObjectsPassedAsArgument(), context);
                    for (std::size_t i = 0;i<realObjects.size();++i)
                    {
                        context.EmptyObjectsListNeeded(realObjects[i]);
                        objectsAsArgumentCode += ".AddObjectListToMap(\""+codeGenerator.ConvertToString(realObjects[i])+"\", "+ManObjListName(realObjects[i])+")";
                    }
                    objectsAsArgumentCode += ".ReturnObjectListsMap()";
                }

                //Generate code for evaluating parameters
                code += "std::vector<gd::String> functionParameters;\n";
                for (std::size_t i = 1;i<8;++i)
                {
                    gd::String parameterCode;
                    gd::CallbacksForGeneratingExpressionCode callbacks(parameterCode, codeGenerator, context);
                    gd::ExpressionParser parser(instruction.GetParameter(i).GetPlainString());
                    parser.ParseStringExpression(CppPlatform::Get(), project, layout, callbacks);
                    if (parameterCode.empty()) parameterCode = "\"\"";

                    code += "functionParameters.push_back("+parameterCode+");\n";
                }

                code += FunctionEvent::MangleFunctionName(layout, *functionEvent)+"(runtimeContext, "+objectsAsArgumentCode+", functionParameters);\n";
                return code;
            });

        AddEvent("Function",
            _("Function"),
            _("Function event : An event which is launched only thanks to action \"Launch a function\""),
            "",
            "res/function.png",
            std::shared_ptr<gd::BaseEvent>(new FunctionEvent))
            .SetCodeGenerator([](gd::BaseEvent & event_, gd::EventsCodeGenerator & codeGenerator,
                gd::EventsCodeGenerationContext & /* The function has nothing to do with the current context */){
                FunctionEvent & event = dynamic_cast<FunctionEvent&>(event_);
                const gd::Layout & layout = codeGenerator.GetLayout();

                //Declaring function prototype.
                codeGenerator.AddGlobalDeclaration("void "+FunctionEvent::MangleFunctionName(layout, event)+"(RuntimeContext *, std::map <gd::String, std::vector<RuntimeObject*> *>, std::vector<gd::String> &);\n");

                //Generating function code:
                gd::String functionCode;
                functionCode += "\nvoid "+FunctionEvent::MangleFunctionName(layout, event)+"(RuntimeContext * runtimeContext, std::map <gd::String, std::vector<RuntimeObject*> *> objectsListsMap, std::vector<gd::String> & currentFunctionParameters)\n{\n";

                gd::EventsCodeGenerationContext callerContext;
                {
                    std::vector<gd::String> realObjects = codeGenerator.ExpandObjectsName(event.GetObjectsPassedAsArgument(), callerContext);
                    for (std::size_t i = 0;i<realObjects.size();++i)
                    {
                        callerContext.EmptyObjectsListNeeded(realObjects[i]);
                        functionCode += "std::vector<RuntimeObject*> "+ManObjListName(realObjects[i]) + ";\n";
                        functionCode += "if ( objectsListsMap[\""+realObjects[i]+"\"] != NULL ) "+ManObjListName(realObjects[i])+" = *objectsListsMap[\""+realObjects[i]+"\"];\n";
                    }
                }
                functionCode += "{";

                gd::EventsCodeGenerationContext context;
                context.InheritsFrom(callerContext);

                //Generating function body code
                gd::String conditionsCode = codeGenerator.GenerateConditionsListCode(event.GetConditions(), context);
                gd::String actionsCode = codeGenerator.GenerateActionsListCode(event.GetActions(), context);
                gd::String subeventsCode = codeGenerator.GenerateEventsListCode(event.GetSubEvents(), context);

                functionCode += codeGenerator.GenerateObjectsDeclarationCode(context);
                gd::String ifPredicat = "true";
                for (std::size_t i = 0;i<event.GetConditions().size();++i)
                    ifPredicat += " && condition"+gd::String::From(i)+"IsTrue";

                functionCode += conditionsCode;
                functionCode += "if (" +ifPredicat+ ")\n";
                functionCode += "{\n";
                functionCode += actionsCode;
                if ( event.HasSubEvents() ) //Sub events
                {
                    functionCode += "\n{\n";
                    functionCode += subeventsCode;
                    functionCode += "}\n";
                }
                functionCode += "}\n";

                functionCode += "}\n"; //Context end
                functionCode += "}\n"; //Function end
                codeGenerator.AddCustomCodeOutsideMain(functionCode);

                return "";
            });

        AddStrExpression("Parameter",
            _("Parameter of the current function"),
            _("Return the text contained in a parameter of the currently launched function"),
            _("Function"),
            "res/function.png")
            .AddParameter("expression", _("Index of the parameter (Parameters start at 0!)"))
            .codeExtraInformation.SetCustomCodeGenerator([](const std::vector<gd::Expression> & parameters, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context) {
                codeGenerator.AddIncludeFile("Function/FunctionTools.h");
                const gd::Project & game = codeGenerator.GetProject();
                const gd::Layout & scene = codeGenerator.GetLayout();

                //Ensure currentFunctionParameters vector is always existing.
                gd::String mainFakeParameters = "std::vector<gd::String> currentFunctionParameters;\n";
                if (codeGenerator.GetCustomCodeInMain().find(mainFakeParameters) == gd::String::npos)
                    codeGenerator.AddCustomCodeInMain(mainFakeParameters);

                //Generate code for evaluating index
                gd::String expression;
                gd::CallbacksForGeneratingExpressionCode callbacks(expression, codeGenerator, context);
                gd::ExpressionParser parser(parameters[0].GetPlainString());
                if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), game, scene, callbacks) || expression.empty()) expression = "0";

                gd::String code;

                code += "GDpriv::FunctionTools::GetSafelyStringFromVector(currentFunctionParameters, "+expression+")";

                return code;
            });
        #endif

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
Пример #30
0
    /**
     * Constructor of an extension declares everything the extension contains : Objects, actions, conditions and expressions.
     */
    Extension()
    {
        SetExtensionInformation("PhysicsAutomatism",
                              _("Physics automatism"),
                              _("Automatism allowing to move objects as if they were subject to the laws of physics."),
                              "Florian Rival",
                              "zlib/libpng License (Open Source)");

        {
            gd::AutomatismMetadata & aut = AddAutomatism("PhysicsAutomatism",
                  _("Physics engine"),
                  _("Physics"),
                  _("Make objects move as if they were subject to the laws of physics."),
                  "",
                  "res/physics32.png",
                  "PhysicsAutomatism",
                  boost::shared_ptr<gd::Automatism>(new PhysicsAutomatism),
                  boost::shared_ptr<gd::AutomatismsSharedData>(new ScenePhysicsDatas));

            #if defined(GD_IDE_ONLY)
            aut.SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetStatic",
                           _("Make the object static"),
                           _("Make object immovable."),
                           _("Make _PARAM0_ static"),
                           _("Movement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetStatic").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetDynamic",
                           _("Make the object dynamic"),
                           _("Make object dynamic ( affected by forces and other objects )."),
                           _("Make _PARAM0_ dynamic"),
                           _("Movement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetDynamic").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("IsDynamic",
                           _("The object is dynamic"),
                           _("Test if an object is dynamic ( affected by forces and the other objects )."),
                           _("_PARAM0_ is dynamic"),
                           _("Movement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .codeExtraInformation.SetFunctionName("IsDynamic").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetFixedRotation",
                           _("Fix rotation"),
                           _("Prevent the object from rotating"),
                           _("Fix rotation of _PARAM0_"),
                           _("Rotation"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetFixedRotation").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("AddRevoluteJoint",
                           _("Add a hinge"),
                           _("Add a hinge about which the object will rotate.\nDistance between hinge and object will remain identical."),
                           _("Add a hinge to _PARAM0_ at _PARAM2_;_PARAM3_"),
                           _("Joints"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("Hinge X position"))
                .AddParameter("expression", _("Hinge Y position"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("AddRevoluteJoint").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("AddRevoluteJointBetweenObjects",
                           _("Add a hinge between two objects"),
                           _("Add a hinge about which the object will rotate."),
                           _("Add a hinge between _PARAM0_ and _PARAM2_"),
                           _("Joints"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("objectPtr", _("Object"))
                .AddCodeOnlyParameter("currentScene", "")
                .AddParameter("expression", _("X position of the hinge, from the first object mass center"), "", true).SetDefaultValue("0")
                .AddParameter("expression", _("Y position of the hinge, from the first object mass center"), "", true).SetDefaultValue("0")
                .codeExtraInformation.SetFunctionName("AddRevoluteJointBetweenObjects").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("ActAddGearJointBetweenObjects",
                           _("Add a gear between two objects"),
                           _("Add a virtual gear between two objects."),
                           _("Add a gear between _PARAM0_ and _PARAM2_"),
                           _("Joints"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("objectPtr", _("Object"))
                .AddParameter("expression", _("Ratio"), "", true).SetDefaultValue("1")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("AddGearJointBetweenObjects").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetFreeRotation",
                           _("Make object's rotation free"),
                           _("Allows object to rotate."),
                           _("Allow _PARAM0_ to rotate"),
                           _("Rotation"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetFreeRotation").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("IsFixedRotation",
                           _("Fixed rotation"),
                           _("Test if object is rotation fixed."),
                           _("_PARAM0_ is rotation fixed."),
                           _("Rotation"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("IsFixedRotation").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetAsBullet",
                           _("Consider as a bullet."),
                           _("Consider the object as a bullet, so as to have better collision handling."),
                           _("Consider _PARAM0_ as a bullet"),
                           _("Other"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetAsBullet").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("DontSetAsBullet",
                           _("Do not consider as a bullet"),
                           _("Do not consider object as a bullet, so as to use standard collision handling."),
                           _("Do not consider _PARAM0_ as a bullet."),
                           _("Other"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("DontSetAsBullet").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("IsBullet",
                           _("Object is considered as a bullet"),
                           _("Test if object is considered as a bullet"),
                           _("_PARAM0_ is considered as a bullet"),
                           _("Other"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("IsBullet").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("ApplyImpulse",
                           _("Apply an impulse"),
                           _("Apply an impulse to the object."),
                           _("Apply to _PARAM0_ impulse _PARAM2_;_PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("X component ( Newtons/Seconds )"))
                .AddParameter("expression", _("Y component ( Newtons/Seconds )"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("ApplyImpulse").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("ApplyImpulseUsingPolarCoordinates",
                           _("Apply an impulse (angle)"),
                           _("Apply an impulse to an object, using a angle and a length as coordinates."),
                           _("Apply to _PARAM0_ impulse _PARAM3_ with angle: _PARAM2_°"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("Angle"))
                .AddParameter("expression", _("Impulse value ( Newton/seconds )"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("ApplyImpulseUsingPolarCoordinates").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("ApplyImpulseTowardPosition",
                           _("Apply an impulse toward a position"),
                           _("Apply an impulse, directed toward a position, to the object."),
                           _("Apply to _PARAM0_ impulse _PARAM4_ toward position _PARAM2_;_PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("X position"))
                .AddParameter("expression", _("Y position"))
                .AddParameter("expression", _("Impulse value ( Newton/seconds )"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("ApplyImpulseTowardPosition").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("ApplyForce",
                           _("Add a force"),
                           _("Add a force to object"),
                           _("Apply to _PARAM0_ force _PARAM2_;_PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("X component ( Newtons )"))
                .AddParameter("expression", _("Y component ( Newtons )"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("ApplyForce").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("ApplyForceUsingPolarCoordinates",
                           _("Apply a force ( angle )"),
                           _("Apply a force to an object, using an angle and a length as coordinates."),
                           _("Apply to _PARAM0_ force _PARAM3_ at angle _PARAM2_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("Angle"))
                .AddParameter("expression", _("Length of the force ( Newtons )"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("ApplyForceUsingPolarCoordinates").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("ApplyForceTowardPosition",
                           _("Apply a force toward a position"),
                           _("Apply a force, directed toward a position, to the object."),
                           _("Add to _PARAM0_ force _PARAM4_ toward position _PARAM2_;_PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("X position"))
                .AddParameter("expression", _("Y position"))
                .AddParameter("expression", _("Length of the force ( Newtons )"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("ApplyForceTowardPosition").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("ApplyTorque",
                           _("Add a torque (a rotation)"),
                           _("Add a torque (a rotation) to object."),
                           _("Add to _PARAM0_ torque _PARAM2_"),
                           _("Rotation"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("Torque value"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("ApplyTorque").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetLinearVelocity",
                           _("Linear velocity"),
                           _("Modify velocity of an object."),
                           _("Set linear velocity of _PARAM0_ to _PARAM2_;_PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("X Coordinate"))
                .AddParameter("expression", _("Y Coordinate"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetLinearVelocity").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("LinearVelocityX",
                           _("X component"),
                           _("Compare the linear velocity on X axis of object."),
                           _("Linear velocity on X axis of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("relationalOperator", _("Comparison sign"))
                .AddParameter("expression", _("Value to test"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetLinearVelocityX").SetManipulatedType("number").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("LinearVelocityY",
                           _("Y component"),
                           _("Compare the linear velocity on Y axis of object."),
                           _("Linear velocity on Y axis of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("relationalOperator", _("Comparison sign"))
                .AddParameter("expression", _("Value to test"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetLinearVelocityY").SetManipulatedType("number").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("LinearVelocity",
                           _("Linear speed"),
                           _("Compare the linear velocity of the object."),
                           _("Linear velocity of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("relationalOperator", _("Comparison sign"))
                .AddParameter("expression", _("Value to test"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetLinearVelocity").SetManipulatedType("number").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetAngularVelocity",
                           _("Angular speed"),
                           _("Modify angular velocity of object."),
                           _("Set angular speed of _PARAM0_ to _PARAM2_"),
                           _("Rotation"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("New value"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetAngularVelocity").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("AngularVelocity",
                           _("Angular speed"),
                           _("Compare the angular speed of the object."),
                           _("Angular speed of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Rotation"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("relationalOperator", _("Comparison sign"))
                .AddParameter("expression", _("Value to test"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetAngularVelocity").SetManipulatedType("number").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("LinearDamping",
                           _("Linear damping"),
                           _("Compare the linear damping of the object."),
                           _("Linear damping of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("relationalOperator", _("Comparison sign"))
                .AddParameter("expression", _("Value to test"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetLinearDamping").SetManipulatedType("number").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("CollisionWith",
                           _("Collision"),
                           _("Test if two objects are colliding.\nAttention! Only objects specified in the first parameter will be taken in account by the next actions and conditions, if they are colliding with the other objects."),
                           _("_PARAM0_ is in collision with a _PARAM2_"),
                           "",
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("objectList", _("Object"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("CollisionWith").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetLinearDamping",
                           _("Linear damping"),
                           _("Modify linear damping of object."),
                           _("Put linear damping of _PARAM0_ to _PARAM2_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("Value"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetLinearDamping").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("AngularDamping",
                           _("Angular damping"),
                           _("Test object's angular damping"),
                           _("Angular damping of _PARAM0_ is _PARAM2__PARAM3_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("relationalOperator", _("Comparison sign"))
                .AddParameter("expression", _("Value to test"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetAngularDamping").SetManipulatedType("number").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetAngularDamping",
                           _("Angular damping"),
                           _("Modify angular damping of object."),
                           _("Set angular damping of _PARAM0_ to _PARAM2_"),
                           _("Displacement"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("Value"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetAngularDamping").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetGravity",
                           _("Gravity"),
                           _("Modify the gravity"),
                           _("Set gravity force to _PARAM2_;_PARAM3_"),
                           _("Global options"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("X Coordinate"))
                .AddParameter("expression", _("Y Coordinate"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetGravity").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetPolygonScaleX",
                           _("Change collision polygon X scale"),
                           _("Change the X scale of the polygon. Use a value greater than 1 to enlarge the polygon, less than 1 to reduce it."),
                           _("Change collision polygon of _PARAM0_ X scale to _PARAM2_"),
                           _("Collision polygon"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("Scale"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetPolygonScaleX").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddAction("SetPolygonScaleY",
                           _("Change collision polygon Y scale"),
                           _("Change the Y scale of the polygon. Use a value greater than 1 to enlarge the polygon, less than 1 to reduce it."),
                           _("Change collision polygon of _PARAM0_ Y scale to _PARAM2_"),
                           _("Collision polygon"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("expression", _("Scale"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("SetPolygonScaleY").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("GetPolygonScaleX",
                           _("Collision polygon X scale"),
                           _("Test the value of the collision polygon X scale."),
                           _("Collision polygon of _PARAM0_ X scale is _PARAM2__PARAM3_"),
                           _("Collision polygon"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("relationalOperator", _("Comparison sign"))
                .AddParameter("expression", _("Value to test"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetPolygonScaleX").SetManipulatedType("number").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddCondition("GetPolygonScaleY",
                           _("Collision polygon Y scale"),
                           _("Test the value of the collision polygon Y scale."),
                           _("Collision polygon of _PARAM0_ Y scale is _PARAM2__PARAM3_"),
                           _("Collision polygon"),
                           "res/physics24.png",
                           "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddParameter("relationalOperator", _("Comparison sign"))
                .AddParameter("expression", _("Value to test"))
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetPolygonScaleY").SetManipulatedType("number").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddExpression("PolygonScaleX", _("Collision polygon X scale"), _("Collision polygon X scale"), _("Collision polygon"), "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetPolygonScaleX").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddExpression("PolygonScaleY", _("Collision polygon Y scale"), _("Collision polygon Y scale"), _("Collision polygon"), "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetPolygonScaleY").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddExpression("LinearVelocity", _("Linear speed"), _("Linear speed"), _("Displacement"), "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetLinearVelocity").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddExpression("LinearVelocityX", _("X component"), _("X component"), _("Displacement"), "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetLinearVelocityX").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddExpression("LinearVelocityY", _("Y component"), _("Y component"), _("Displacement"), "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetLinearVelocityY").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddExpression("AngularVelocity", _("Angular speed"), _("Angular speed"), _("Rotation"), "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetAngularVelocity").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddExpression("LinearDamping", _("Linear damping"), _("Linear damping"), _("Displacement"), "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetLinearDamping").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            aut.AddExpression("AngularDamping", _("Angular damping"), _("Angular damping"), _("Rotation"), "res/physics16.png")
                .AddParameter("object", _("Object"))
                .AddParameter("automatism", _("Automatism"), "PhysicsAutomatism")
                .AddCodeOnlyParameter("currentScene", "")
                .codeExtraInformation.SetFunctionName("GetAngularDamping").SetIncludeFile("PhysicsAutomatism/PhysicsAutomatism.h");

            #endif

        }

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };