示例#1
0
WindowExtension::WindowExtension() {
  gd::BuiltinExtensionsImplementer::ImplementsWindowExtension(*this);

  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();
}
示例#2
0
MouseExtension::MouseExtension()
{
    gd::BuiltinExtensionsImplementer::ImplementsMouseExtension(*this);

    #if defined(GD_IDE_ONLY)
    GetAllActions()["CentreSourisX"].SetFunctionName("CenterCursorHorizontally").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllActions()["CentreSourisY"].SetFunctionName("CenterCursorVertically").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllActions()["CacheSouris"].SetFunctionName("HideCursor").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllActions()["MontreSouris"].SetFunctionName("ShowCursor").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllActions()["SetSourisXY"].SetFunctionName("SetCursorPosition").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllActions()["CentreSouris"].SetFunctionName("CenterCursor").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");

    GetAllConditions()["SourisX"].SetFunctionName("GetCursorXPosition").SetManipulatedType("number").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllConditions()["SourisY"].SetFunctionName("GetCursorYPosition").SetManipulatedType("number").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllConditions()["SourisBouton"].SetFunctionName("MouseButtonPressed").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllConditions()["MouseButtonReleased"].SetFunctionName("MouseButtonReleased").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");

    GetAllConditions()["SourisSurObjet"].SetFunctionName("CursorOnObject").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");

    GetAllExpressions()["MouseX"].SetFunctionName("GetCursorXPosition").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllExpressions()["SourisX"].SetFunctionName("GetCursorXPosition").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllExpressions()["MouseY"].SetFunctionName("GetCursorYPosition").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllExpressions()["SourisY"].SetFunctionName("GetCursorYPosition").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");
    GetAllExpressions()["MouseWheelDelta"].SetFunctionName("GetMouseWheelDelta").SetIncludeFile("GDCpp/Extensions/Builtin/MouseTools.h");

    StripUnimplementedInstructionsAndExpressions(); //Touch support is not implemented
    #endif
}
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");
    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();
}
示例#4
0
NetworkExtension::NetworkExtension()
{
    SetExtensionInformation("BuiltinNetwork",
                          _("Basic internet features"),
                          _("Built-in extension providing network features."),
                          "Florian Rival",
                          "Open source ( LGPL )");

    CloneExtension("Game Develop C++ platform", "BuiltinNetwork");

    GetAllActions()["SendRequest"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.network.sendHttpRequest").SetIncludeFile("networktools.js");
    GetAllActions()["JSONToVariableStructure"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.network.jsonToVariableStructure").SetIncludeFile("networktools.js");

    GetAllStrExpressions()["ToJSON"].codeExtraInformation
        .SetFunctionName("gdjs.evtTools.network.variableStructureToJSON").SetIncludeFile("networktools.js");

    StripUnimplementedInstructionsAndExpressions(); //Unimplemented things are listed here:
    /*
    AddAction("EnvoiDataNet",
                   _("Send datas to a website"),
                   _("Send datas to a specified web site.\nYou need to set up a .php page on your web site so as to receive this datas.\nEnter here a password, and enter the same in the configuration of your .php page.\nRead the help file to get more informations."),
                   _("Send to _PARAM0_ the following datas : _PARAM2_, _PARAM3_,_PARAM4_,_PARAM5_,_PARAM6_,_PARAM7_"),
                   _("Network"),
                   "res/actions/net24.png",
                   "res/actions/net.png")
        .AddParameter("string", _(".php page URL ( Don't forget the protocol http:// ) "), "",false)
        .AddParameter("password", _("Password"), "",false)
        .AddParameter("string", _("Data 1"), "",false)
        .AddParameter("string", _("Data 2"), "",true)
        .AddParameter("string", _("Data 3"), "",true)
        .AddParameter("string", _("Data 4"), "",true)
        .AddParameter("string", _("Data 5"), "",true)
        .AddParameter("string", _("Data 6"), "",true)
        .codeExtraInformation.SetFunctionName("SendDataToPhpWebPage").SetIncludeFile("GDCpp/BuiltinExtensions/NetworkTools.h");

    AddAction("DownloadFile",
                   _("Download a file"),
                   _("Download a file from a web site"),
                   _("Download file _PARAM1_ from _PARAM0_ under the name of _PARAM2_"),
                   _("Network"),
                   "res/actions/net24.png",
                   "res/actions/net.png")
        .AddParameter("string", _("Host ( For example : http://www.website.com )"), "",false)
        .AddParameter("string", _("Path to file ( For example : /folder/file.txt )"), "",false)
        .AddParameter("string", _("Save as"), "",false)
        .codeExtraInformation.SetFunctionName("DownloadFile").SetIncludeFile("GDCpp/BuiltinExtensions/NetworkTools.h");
    */
}
示例#5
0
    /**
     * \brief Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    JsExtension()
    {
        SetExtensionInformation("SystemInfo",
            _("System information"),
            _("Provides information about the system running the game"),
            "Florian Rival",
            "Open source (MIT License)");

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

        GetAllConditions()["SystemInfo::IsMobile"].codeExtraInformation.SetIncludeFile("SystemInfo/systeminfotools.js")
            .SetFunctionName("gdjs.evtTools.systemInfo.isMobile");

        StripUnimplementedInstructionsAndExpressions();
    };
示例#6
0
    /**
     * Constructor of an extension declares everything the extension contains: objects, actions, conditions and expressions.
     */
    TextObjectJsExtension()
    {
        DeclareTextObjectExtension(*this);

        GetObjectMetadata("TextObject::Text")
            .SetIncludeFile("TextObject/textruntimeobject.js")
            .AddIncludeFile("TextObject/textruntimeobject-pixi-renderer.js")
            .AddIncludeFile("TextObject/textruntimeobject-cocos-renderer.js");

        GetAllActionsForObject("TextObject::Text")["TextObject::String"].SetFunctionName("setString").SetGetter("getString").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllConditionsForObject("TextObject::Text")["TextObject::String"].SetFunctionName("getString").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllActionsForObject("TextObject::Text")["TextObject::Size"].SetFunctionName("setCharacterSize").SetGetter("getCharacterSize").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllConditionsForObject("TextObject::Text")["TextObject::Size"].SetFunctionName("getCharacterSize").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllActionsForObject("TextObject::Text")["TextObject::Angle"].SetFunctionName("setAngle").SetGetter("getAngle").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllConditionsForObject("TextObject::Text")["TextObject::Angle"].SetFunctionName("getAngle").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllActionsForObject("TextObject::Text")["TextObject::Opacity"].SetFunctionName("setOpacity").SetGetter("getOpacity").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllConditionsForObject("TextObject::Text")["TextObject::Opacity"].SetFunctionName("getOpacity").SetIncludeFile("TextObject/textruntimeobject.js");

        GetAllActionsForObject("TextObject::Text")["TextObject::SetBold"].SetFunctionName("setBold").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllConditionsForObject("TextObject::Text")["TextObject::IsBold"].SetFunctionName("isBold").SetIncludeFile("TextObject/textruntimeobject.js");

        GetAllActionsForObject("TextObject::Text")["TextObject::SetItalic"].SetFunctionName("setItalic").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllConditionsForObject("TextObject::Text")["TextObject::IsItalic"].SetFunctionName("isItalic").SetIncludeFile("TextObject/textruntimeobject.js");

        GetAllExpressionsForObject("TextObject::Text")["Opacity"].SetFunctionName("getOpacity").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllExpressionsForObject("TextObject::Text")["Angle"].SetFunctionName("getAngle").SetIncludeFile("TextObject/textruntimeobject.js");
        GetAllStrExpressionsForObject("TextObject::Text")["String"].SetFunctionName("getString").SetIncludeFile("TextObject/textruntimeobject.js");

        GetAllActionsForObject("TextObject::Text")["TextObject::ChangeColor"].SetFunctionName("setColor").SetIncludeFile("TextObject/textruntimeobject.js");

        //Unimplemented actions and conditions:
        GetAllActionsForObject("TextObject::Text")["TextObject::Font"].SetFunctionName("");
        GetAllActionsForObject("TextObject::Text")["TextObject::SetUnderlined"].SetFunctionName("");
        GetAllConditionsForObject("TextObject::Text")["TextObject::IsUnderlined"].SetFunctionName("");

        StripUnimplementedInstructionsAndExpressions();

        GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
    };
示例#7
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();
}
示例#8
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();
    };
示例#9
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");

    */
}
示例#10
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");


*/
}
示例#11
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");
*/
}
示例#12
0
文件: JsExtension.cpp 项目: 4ian/GD
  /**
   * \brief Constructor of an extension declares everything the extension
   * contains: objects, actions, conditions and expressions.
   */
  PhysicsBehaviorJsExtension() {
    DeclarePhysicsBehaviorExtension(*this);

    GetBehaviorMetadata("PhysicsBehavior::PhysicsBehavior")
        .SetIncludeFile("Extensions/PhysicsBehavior/box2djs/box2d.js")
        .AddIncludeFile("Extensions/PhysicsBehavior/physicsruntimebehavior.js");

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

    autActions["PhysicsBehavior::SetStatic"].SetFunctionName("setStatic");
    autActions["PhysicsBehavior::SetDynamic"].SetFunctionName("setDynamic");
    autConditions["PhysicsBehavior::SetDynamic"].SetFunctionName("isDynamic");
    autActions["PhysicsBehavior::SetFixedRotation"].SetFunctionName(
        "setFixedRotation");
    autActions["PhysicsBehavior::SetFreeRotation"].SetFunctionName(
        "setFreeRotation");
    autActions["PhysicsBehavior::AddRevoluteJoint"].SetFunctionName(
        "addRevoluteJoint");
    autActions["PhysicsBehavior::AddRevoluteJointBetweenObjects"]
        .SetFunctionName("addRevoluteJointBetweenObjects");
    autActions["PhysicsBehavior::ActAddGearJointBetweenObjects"]
        .SetFunctionName("addGearJointBetweenObjects");
    autConditions["PhysicsBehavior::IsFixedRotation"].SetFunctionName(
        "isFixedRotation");
    autActions["PhysicsBehavior::SetAsBullet"].SetFunctionName("setAsBullet");
    autActions["PhysicsBehavior::DontSetAsBullet"].SetFunctionName(
        "dontSetAsBullet");
    autConditions["PhysicsBehavior::IsBullet"].SetFunctionName("isBullet");
    autActions["PhysicsBehavior::ApplyImpulse"].SetFunctionName("applyImpulse");
    autActions["PhysicsBehavior::ApplyImpulseUsingPolarCoordinates"]
        .SetFunctionName("applyImpulseUsingPolarCoordinates");
    autActions["PhysicsBehavior::ApplyImpulseTowardPosition"].SetFunctionName(
        "applyImpulseTowardPosition");
    autActions["PhysicsBehavior::ApplyForce"].SetFunctionName("applyForce");
    autActions["PhysicsBehavior::ApplyForceUsingPolarCoordinates"]
        .SetFunctionName("applyForceUsingPolarCoordinates");
    autActions["PhysicsBehavior::ApplyForceTowardPosition"].SetFunctionName(
        "applyForceTowardPosition");
    autActions["PhysicsBehavior::ApplyTorque"].SetFunctionName("applyTorque");
    autActions["PhysicsBehavior::SetLinearVelocity"].SetFunctionName(
        "setLinearVelocity");
    autConditions["PhysicsBehavior::LinearVelocityX"].SetFunctionName(
        "getLinearVelocityX");
    autConditions["PhysicsBehavior::LinearVelocityY"].SetFunctionName(
        "getLinearVelocityY");
    autConditions["PhysicsBehavior::LinearVelocity"].SetFunctionName(
        "getLinearVelocity");
    autActions["PhysicsBehavior::SetAngularVelocity"].SetFunctionName(
        "setAngularVelocity");
    autConditions["PhysicsBehavior::AngularVelocity"].SetFunctionName(
        "getAngularVelocity");
    autConditions["PhysicsBehavior::CollisionWith"].SetFunctionName(
        "collisionWith");
    autConditions["PhysicsBehavior::LinearDamping"].SetFunctionName(
        "getLinearDamping");
    autActions["PhysicsBehavior::SetLinearDamping"].SetFunctionName(
        "setLinearDamping");
    autConditions["PhysicsBehavior::AngularDamping"].SetFunctionName(
        "getAngularDamping");
    autActions["PhysicsBehavior::SetAngularDamping"].SetFunctionName(
        "setAngularDamping");
    autActions["PhysicsBehavior::SetGravity"].SetFunctionName("setGravity");
    autExpressions["LinearVelocity"].SetFunctionName("getLinearVelocity");
    autExpressions["LinearVelocityX"].SetFunctionName("getLinearVelocityX");
    autExpressions["LinearVelocityY"].SetFunctionName("getLinearVelocityY");
    autExpressions["AngularVelocity"].SetFunctionName("getAngularVelocity");
    autExpressions["LinearDamping"].SetFunctionName("getLinearDamping");
    autExpressions["AngularDamping"].SetFunctionName("getAngularDamping");

    /*
        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("behavior", _("Behavior"), "PhysicsBehavior")
            .AddParameter("expression", _("Scale"))
            .AddCodeOnlyParameter("currentScene", "")
            .SetFunctionName("SetPolygonScaleX").SetIncludeFile("PhysicsBehavior/PhysicsBehavior.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("behavior", _("Behavior"), "PhysicsBehavior")
            .AddParameter("expression", _("Scale"))
            .AddCodeOnlyParameter("currentScene", "")
            .SetFunctionName("SetPolygonScaleY").SetIncludeFile("PhysicsBehavior/PhysicsBehavior.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("behavior", _("Behavior"), "PhysicsBehavior")
            .AddParameter("relationalOperator", _("Comparison sign"))
            .AddParameter("expression", _("Value to test"))
            .AddCodeOnlyParameter("currentScene", "")
            .SetFunctionName("GetPolygonScaleX").SetManipulatedType("number").SetIncludeFile("PhysicsBehavior/PhysicsBehavior.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("behavior", _("Behavior"), "PhysicsBehavior")
            .AddParameter("relationalOperator", _("Comparison sign"))
            .AddParameter("expression", _("Value to test"))
            .AddCodeOnlyParameter("currentScene", "")
            .SetFunctionName("GetPolygonScaleY").SetManipulatedType("number").SetIncludeFile("PhysicsBehavior/PhysicsBehavior.h");

        aut.AddExpression("PolygonScaleX", _("Collision polygon X scale"),
       _("Collision polygon X scale"), _("Collision polygon"),
       "res/physics16.png") .AddParameter("object", _("Object"))
            .AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
            .AddCodeOnlyParameter("currentScene", "")
            .SetFunctionName("GetPolygonScaleX").SetIncludeFile("PhysicsBehavior/PhysicsBehavior.h");

        aut.AddExpression("PolygonScaleY", _("Collision polygon Y scale"),
       _("Collision polygon Y scale"), _("Collision polygon"),
       "res/physics16.png") .AddParameter("object", _("Object"))
            .AddParameter("behavior", _("Behavior"), "PhysicsBehavior")
            .AddCodeOnlyParameter("currentScene", "")
            .SetFunctionName("GetPolygonScaleY").SetIncludeFile("PhysicsBehavior/PhysicsBehavior.h");
*/

    StripUnimplementedInstructionsAndExpressions();
    GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
  };
示例#13
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");
        */

}
示例#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
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");
    }

*/
}
示例#16
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

    }

*/
}
示例#17
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();
    };
示例#18
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");

    */
}