Ejemplo n.º 1
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");
    */
}
Ejemplo n.º 2
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();
    };
Ejemplo n.º 3
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();
    };
Ejemplo n.º 4
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");
*/
}
Ejemplo n.º 5
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();
    };
Ejemplo n.º 6
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

    }

*/
}