diff --git a/Engine/source/T3D/aiClient.cpp b/Engine/source/T3D/aiClient.cpp index 335ac6a15..0fab8f428 100644 --- a/Engine/source/T3D/aiClient.cpp +++ b/Engine/source/T3D/aiClient.cpp @@ -28,6 +28,7 @@ #include "T3D/player.h" #include "T3D/gameBase/moveManager.h" #include "console/consoleInternal.h" +#include "console/engineAPI.h" IMPLEMENT_CONOBJECT( AIClient ); @@ -52,6 +53,8 @@ ConsoleDocClass( AIClient, "@ingroup Networking\n" ); +IMPLEMENT_CALLBACK(AIClient, onConnect, void, (const char* idString), (idString),""); + /** * Constructor */ @@ -415,15 +418,17 @@ void AIClient::onAdd( const char *nameSpace ) { /** * Sets the move speed for an AI object */ -ConsoleMethod( AIClient, setMoveSpeed, void, 3, 3, "ai.setMoveSpeed( float );" ) { +DefineConsoleMethod( AIClient, setMoveSpeed, void, (F32 speed), , "ai.setMoveSpeed( float );" ) +{ AIClient *ai = static_cast( object ); - ai->setMoveSpeed( dAtof( argv[2] ) ); + ai->setMoveSpeed( speed ); } /** * Stops all AI movement, halt! */ -ConsoleMethod( AIClient, stop, void, 2, 2, "ai.stop();" ) { +DefineConsoleMethod( AIClient, stop, void, (),, "ai.stop();" ) +{ AIClient *ai = static_cast( object ); ai->setMoveMode( AIClient::ModeStop ); } @@ -431,10 +436,9 @@ ConsoleMethod( AIClient, stop, void, 2, 2, "ai.stop();" ) { /** * Tells the AI to aim at the location provided */ -ConsoleMethod( AIClient, setAimLocation, void, 3, 3, "ai.setAimLocation( x y z );" ) { +DefineConsoleMethod( AIClient, setAimLocation, void, (Point3F v), , "ai.setAimLocation( x y z );" ) +{ AIClient *ai = static_cast( object ); - Point3F v( 0.0f,0.0f,0.0f ); - dSscanf( argv[2], "%f %f %f", &v.x, &v.y, &v.z ); ai->setAimLocation( v ); } @@ -442,10 +446,9 @@ ConsoleMethod( AIClient, setAimLocation, void, 3, 3, "ai.setAimLocation( x y z ) /** * Tells the AI to move to the location provided */ -ConsoleMethod( AIClient, setMoveDestination, void, 3, 3, "ai.setMoveDestination( x y z );" ) { +DefineConsoleMethod( AIClient, setMoveDestination, void, (Point3F v), , "ai.setMoveDestination( x y z );" ) +{ AIClient *ai = static_cast( object ); - Point3F v( 0.0f, 0.0f, 0.0f ); - dSscanf( argv[2], "%f %f", &v.x, &v.y ); ai->setMoveDestination( v ); } @@ -453,40 +456,31 @@ ConsoleMethod( AIClient, setMoveDestination, void, 3, 3, "ai.setMoveDestination( /** * Returns the point the AI is aiming at */ -ConsoleMethod( AIClient, getAimLocation, const char *, 2, 2, "ai.getAimLocation();" ) { +DefineConsoleMethod( AIClient, getAimLocation, Point3F, (),, "ai.getAimLocation();" ) +{ AIClient *ai = static_cast( object ); - Point3F aimPoint = ai->getAimLocation(); - - static const U32 bufSize = 256; - char *returnBuffer = Con::getReturnBuffer( bufSize ); - dSprintf( returnBuffer, bufSize, "%f %f %f", aimPoint.x, aimPoint.y, aimPoint.z ); - - return returnBuffer; + return ai->getAimLocation(); } /** * Returns the point the AI is set to move to */ -ConsoleMethod( AIClient, getMoveDestination, const char *, 2, 2, "ai.getMoveDestination();" ) { +DefineConsoleMethod( AIClient, getMoveDestination, Point3F, (),, "ai.getMoveDestination();" ) +{ AIClient *ai = static_cast( object ); - Point3F movePoint = ai->getMoveDestination(); - - static const U32 bufSize = 256; - char *returnBuffer = Con::getReturnBuffer( bufSize ); - dSprintf( returnBuffer, bufSize, "%f %f %f", movePoint.x, movePoint.y, movePoint.z ); - - return returnBuffer; + return ai->getMoveDestination(); } /** * Sets the bots target object */ -ConsoleMethod( AIClient, setTargetObject, void, 3, 3, "ai.setTargetObject( obj );" ) { +DefineConsoleMethod( AIClient, setTargetObject, void, (const char * objName), , "ai.setTargetObject( obj );" ) +{ AIClient *ai = static_cast( object ); // Find the target ShapeBase *targetObject; - if( Sim::findObject( argv[2], targetObject ) ) + if( Sim::findObject( objName, targetObject ) ) ai->setTargetObject( targetObject ); else ai->setTargetObject( NULL ); @@ -495,7 +489,8 @@ ConsoleMethod( AIClient, setTargetObject, void, 3, 3, "ai.setTargetObject( obj ) /** * Gets the object the AI is targeting */ -ConsoleMethod( AIClient, getTargetObject, S32, 2, 2, "ai.getTargetObject();" ) { +DefineConsoleMethod( AIClient, getTargetObject, S32, (),, "ai.getTargetObject();" ) +{ AIClient *ai = static_cast( object ); return ai->getTargetObject(); @@ -504,7 +499,8 @@ ConsoleMethod( AIClient, getTargetObject, S32, 2, 2, "ai.getTargetObject();" ) { /** * Tells the bot the mission is cycling */ -ConsoleMethod( AIClient, missionCycleCleanup, void, 2, 2, "ai.missionCycleCleanup();" ) { +DefineConsoleMethod( AIClient, missionCycleCleanup, void, (),, "ai.missionCycleCleanup();" ) +{ AIClient *ai = static_cast( object ); ai->missionCycleCleanup(); } @@ -512,7 +508,8 @@ ConsoleMethod( AIClient, missionCycleCleanup, void, 2, 2, "ai.missionCycleCleanu /** * Sets the AI to run mode */ -ConsoleMethod( AIClient, move, void, 2, 2, "ai.move();" ) { +DefineConsoleMethod( AIClient, move, void, (),, "ai.move();" ) +{ AIClient *ai = static_cast( object ); ai->setMoveMode( AIClient::ModeMove ); } @@ -520,21 +517,17 @@ ConsoleMethod( AIClient, move, void, 2, 2, "ai.move();" ) { /** * Gets the AI's location in the world */ -ConsoleMethod( AIClient, getLocation, const char *, 2, 2, "ai.getLocation();" ) { +DefineConsoleMethod( AIClient, getLocation, Point3F, (),, "ai.getLocation();" ) +{ AIClient *ai = static_cast( object ); - Point3F locPoint = ai->getLocation(); - - static const U32 bufSize = 256; - char *returnBuffer = Con::getReturnBuffer( bufSize ); - dSprintf( returnBuffer, bufSize, "%f %f %f", locPoint.x, locPoint.y, locPoint.z ); - - return returnBuffer; + return ai->getLocation(); } /** * Adds an AI Player to the game */ -ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassType'] );" ) { +DefineConsoleFunction( aiAddPlayer, S32, (const char * name, const char * ns), (""), "'playerName'[, 'AIClassType'] );") +{ // Create the player AIClient *aiPlayer = new AIClient(); aiPlayer->registerObject(); @@ -548,18 +541,13 @@ ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassT SimGroup *g = Sim::getClientGroup(); g->addObject( aiPlayer ); - char *name = new char[ dStrlen( argv[1] ) + 1]; - char *ns = new char[ dStrlen( argv[2] ) + 1]; - - dStrcpy( name, argv[1] ); - dStrcpy( ns, argv[2] ); // Execute the connect console function, this is the same // onConnect function invoked for normal client connections - Con::executef( aiPlayer, "onConnect", name ); + aiPlayer->onConnect_callback( name ); // Now execute the onAdd command and feed it the namespace - if( argc > 2 ) + if(dStrcmp( ns,"" ) != 0 ) aiPlayer->onAdd( ns ); else aiPlayer->onAdd( "AIClient" ); @@ -571,7 +559,8 @@ ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassT /** * Tells the AI to move forward 100 units...TEST FXN */ -ConsoleMethod( AIClient, moveForward, void, 2, 2, "ai.moveForward();" ) { +DefineConsoleMethod( AIClient, moveForward, void, (),, "ai.moveForward();" ) +{ AIClient *ai = static_cast( object ); ShapeBase *player = dynamic_cast(ai->getControlObject()); diff --git a/Engine/source/T3D/aiClient.h b/Engine/source/T3D/aiClient.h index 37d490a74..be185db45 100644 --- a/Engine/source/T3D/aiClient.h +++ b/Engine/source/T3D/aiClient.h @@ -70,6 +70,8 @@ class AIClient : public AIConnection { DECLARE_CONOBJECT( AIClient ); + DECLARE_CALLBACK( void, onConnect, (const char* idString) ); + enum { ModeStop = 0, ModeMove, diff --git a/Engine/source/T3D/aiConnection.cpp b/Engine/source/T3D/aiConnection.cpp index e6b4bc11f..af60b1d3c 100644 --- a/Engine/source/T3D/aiConnection.cpp +++ b/Engine/source/T3D/aiConnection.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- #include "T3D/aiConnection.h" +#include "console/engineAPI.h" IMPLEMENT_CONOBJECT( AIConnection ); @@ -159,7 +160,7 @@ ConsoleFunction(aiConnect, S32 , 2, 20, "(...)" //----------------------------------------------------------------------------- -ConsoleMethod(AIConnection,setMove,void,4, 4,"(string field, float value)" +DefineConsoleMethod(AIConnection, setMove, void, (const char * field, F32 value), ,"(string field, float value)" "Set a field on the current move.\n\n" "@param field One of {'x','y','z','yaw','pitch','roll'}\n" "@param value Value to set field to.") @@ -167,59 +168,59 @@ ConsoleMethod(AIConnection,setMove,void,4, 4,"(string field, float value)" Move move = object->getMove(); // Ok, a little slow for now, but this is just an example.. - if (!dStricmp(argv[2],"x")) - move.x = mClampF(dAtof(argv[3]),-1,1); + if (!dStricmp(field,"x")) + move.x = mClampF(value,-1,1); else - if (!dStricmp(argv[2],"y")) - move.y = mClampF(dAtof(argv[3]),-1,1); + if (!dStricmp(field,"y")) + move.y = mClampF(value,-1,1); else - if (!dStricmp(argv[2],"z")) - move.z = mClampF(dAtof(argv[3]),-1,1); + if (!dStricmp(field,"z")) + move.z = mClampF(value,-1,1); else - if (!dStricmp(argv[2],"yaw")) - move.yaw = moveClamp(dAtof(argv[3])); + if (!dStricmp(field,"yaw")) + move.yaw = moveClamp(value); else - if (!dStricmp(argv[2],"pitch")) - move.pitch = moveClamp(dAtof(argv[3])); + if (!dStricmp(field,"pitch")) + move.pitch = moveClamp(value); else - if (!dStricmp(argv[2],"roll")) - move.roll = moveClamp(dAtof(argv[3])); + if (!dStricmp(field,"roll")) + move.roll = moveClamp(value); // object->setMove(&move); } -ConsoleMethod(AIConnection,getMove,F32,3, 3,"(string field)" +DefineConsoleMethod(AIConnection,getMove,F32, (const char * field), ,"(string field)" "Get the given field of a move.\n\n" "@param field One of {'x','y','z','yaw','pitch','roll'}\n" "@returns The requested field on the current move.") { const Move& move = object->getMove(); - if (!dStricmp(argv[2],"x")) + if (!dStricmp(field,"x")) return move.x; - if (!dStricmp(argv[2],"y")) + if (!dStricmp(field,"y")) return move.y; - if (!dStricmp(argv[2],"z")) + if (!dStricmp(field,"z")) return move.z; - if (!dStricmp(argv[2],"yaw")) + if (!dStricmp(field,"yaw")) return move.yaw; - if (!dStricmp(argv[2],"pitch")) + if (!dStricmp(field,"pitch")) return move.pitch; - if (!dStricmp(argv[2],"roll")) + if (!dStricmp(field,"roll")) return move.roll; return 0; } -ConsoleMethod(AIConnection,setFreeLook,void,3, 3,"(bool isFreeLook)" +DefineConsoleMethod(AIConnection,setFreeLook,void,(bool isFreeLook), ,"(bool isFreeLook)" "Enable/disable freelook on the current move.") { Move move = object->getMove(); - move.freeLook = dAtob(argv[2]); + move.freeLook = isFreeLook; object->setMove(&move); } -ConsoleMethod(AIConnection,getFreeLook,bool,2, 2,"getFreeLook()" +DefineConsoleMethod(AIConnection, getFreeLook, bool, (), ,"getFreeLook()" "Is freelook on for the current move?") { return object->getMove().freeLook; @@ -228,21 +229,20 @@ ConsoleMethod(AIConnection,getFreeLook,bool,2, 2,"getFreeLook()" //----------------------------------------------------------------------------- -ConsoleMethod(AIConnection,setTrigger,void,4, 4,"(int trigger, bool set)" +DefineConsoleMethod(AIConnection,setTrigger,void, (S32 idx, bool set), ,"(int trigger, bool set)" "Set a trigger.") { - S32 idx = dAtoi(argv[2]); - if (idx >= 0 && idx < MaxTriggerKeys) { + if (idx >= 0 && idx < MaxTriggerKeys) + { Move move = object->getMove(); - move.trigger[idx] = dAtob(argv[3]); + move.trigger[idx] = set; object->setMove(&move); } } -ConsoleMethod(AIConnection,getTrigger,bool,4, 4,"(int trigger)" +DefineConsoleMethod(AIConnection,getTrigger,bool, (S32 idx), ,"(int trigger)" "Is the given trigger set?") { - S32 idx = dAtoi(argv[2]); if (idx >= 0 && idx < MaxTriggerKeys) return object->getMove().trigger[idx]; return false; @@ -251,7 +251,7 @@ ConsoleMethod(AIConnection,getTrigger,bool,4, 4,"(int trigger)" //----------------------------------------------------------------------------- -ConsoleMethod(AIConnection,getAddress,const char*,2, 2,"") +DefineConsoleMethod(AIConnection,getAddress,const char*,(), ,"") { // Override the netConnection method to return to indicate // this is an ai connection. diff --git a/Engine/source/T3D/aiPlayer.cpp b/Engine/source/T3D/aiPlayer.cpp index 31ada9970..f553cfb0c 100644 --- a/Engine/source/T3D/aiPlayer.cpp +++ b/Engine/source/T3D/aiPlayer.cpp @@ -575,23 +575,21 @@ ConsoleDocFragment _setAimObject( "AIPlayer", "void setAimObject(GameBase targetObject, Point3F offset);" ); -ConsoleMethod( AIPlayer, setAimObject, void, 3, 4, "( GameBase obj, [Point3F offset] )" + +DefineConsoleMethod( AIPlayer, setAimObject, void, ( const char * objName, Point3F offset ), (Point3F::Zero), "( GameBase obj, [Point3F offset] )" "Sets the bot's target object. Optionally set an offset from target location." "@hide") { - Point3F off( 0.0f, 0.0f, 0.0f ); // Find the target GameBase *targetObject; - if( Sim::findObject( argv[2], targetObject ) ) + if( Sim::findObject( objName, targetObject ) ) { - if (argc == 4) - dSscanf( argv[3], "%g %g %g", &off.x, &off.y, &off.z ); - object->setAimObject( targetObject, off ); + object->setAimObject( targetObject, offset ); } else - object->setAimObject( 0, off ); + object->setAimObject( 0, offset ); } DefineEngineMethod( AIPlayer, getAimObject, S32, (),, diff --git a/Engine/source/T3D/camera.cpp b/Engine/source/T3D/camera.cpp index ef4541f6c..4bf3fe24b 100644 --- a/Engine/source/T3D/camera.cpp +++ b/Engine/source/T3D/camera.cpp @@ -1860,7 +1860,7 @@ DefineEngineMethod( Camera, setOffset, void, (Point3F offset), , //----------------------------------------------------------------------------- DefineEngineMethod( Camera, setOrbitMode, void, (GameBase* orbitObject, TransformF orbitPoint, F32 minDistance, F32 maxDistance, - F32 initDistance, bool ownClientObj, Point3F offset, bool locked), (false, Point3F(0.0f, 0.0f, 0.0f), false), + F32 initDistance, bool ownClientObj, Point3F offset, bool locked), (false, Point3F::Zero, false), "Set the camera to orbit around the given object, or if none is given, around the given point.\n\n" "@param orbitObject The object to orbit around. If no object is given (0 or blank string is passed in) use the orbitPoint instead\n" "@param orbitPoint The point to orbit around when no object is given. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform().\n" @@ -1883,7 +1883,7 @@ DefineEngineMethod( Camera, setOrbitMode, void, (GameBase* orbitObject, Transfor DefineEngineMethod( Camera, setOrbitObject, bool, (GameBase* orbitObject, VectorF rotation, F32 minDistance, F32 maxDistance, F32 initDistance, bool ownClientObject, Point3F offset, bool locked), - (false, Point3F(0.0f, 0.0f, 0.0f), false), + (false, Point3F::Zero, false), "Set the camera to orbit around a given object.\n\n" "@param orbitObject The object to orbit around.\n" "@param rotation The initial camera rotation about the object in radians in the form of \"x y z\".\n" @@ -1911,7 +1911,7 @@ DefineEngineMethod( Camera, setOrbitObject, bool, (GameBase* orbitObject, Vector DefineEngineMethod( Camera, setOrbitPoint, void, (TransformF orbitPoint, F32 minDistance, F32 maxDistance, F32 initDistance, Point3F offset, bool locked), - (Point3F(0.0f, 0.0f, 0.0f), false), + (Point3F::Zero, false), "Set the camera to orbit around a given point.\n\n" "@param orbitPoint The point to orbit around. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform().\n" "@param minDistance The minimum distance allowed to the orbit object or point.\n" @@ -1929,7 +1929,7 @@ DefineEngineMethod( Camera, setOrbitPoint, void, (TransformF orbitPoint, F32 min //----------------------------------------------------------------------------- -DefineEngineMethod( Camera, setTrackObject, bool, (GameBase* trackObject, Point3F offset), (Point3F(0.0f, 0.0f, 0.0f)), +DefineEngineMethod( Camera, setTrackObject, bool, (GameBase* trackObject, Point3F offset), (Point3F::Zero), "Set the camera to track a given object.\n\n" "@param trackObject The object to track.\n" "@param offset [optional] An offset added to the camera's position. Default is no offset.\n" diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index f23400232..3fd5b4a2c 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -138,8 +138,17 @@ ConsoleDocClass( Explosion, MRandomLCG sgRandom(0xdeadbeef); +//WLE - Vince - The defaults are bad, the whole point of calling this function\ +//is to determine the explosion coverage on a object. Why would you want them +//To call this with a null for the ID? In fact, it just returns a 1f if +//it can't find the object. Seems useless to me. Cause how can I apply +//damage to a object that doesn't exist? -DefineEngineFunction(calcExplosionCoverage, F32, (Point3F pos, S32 id, U32 covMask),(Point3F(0.0f,0.0f,0.0f), NULL, NULL), +//I could possible see a use with passing in a null covMask, but even that +//sounds flaky because it will be 100 percent if your saying not to take +//any thing in consideration for coverage. So I'm removing these defaults they are just bad. + +DefineEngineFunction(calcExplosionCoverage, F32, (Point3F pos, S32 id, U32 covMask),, "@brief Calculates how much an explosion effects a specific object.\n\n" "Use this to determine how much damage to apply to objects based on their " "distance from the explosion's center point, and whether the explosion is " diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 5c4c07bde..4465e1d1d 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -929,13 +929,10 @@ DefineEngineMethod(Lightning, strikeRandomPoint, void, (),, object->strikeRandomPoint(); } -DefineEngineMethod(Lightning, strikeObject, void, (S32 id), (NULL), +DefineEngineMethod(Lightning, strikeObject, void, (ShapeBase* pSB),, "Creates a LightningStrikeEvent which strikes a specific object.\n" "@note This method is currently unimplemented.\n" ) { - ShapeBase* pSB; - - if (object->isServerObject() && Sim::findObject(id, pSB)) object->strikeObject(pSB); } diff --git a/Engine/source/T3D/fx/particleEmitterNode.cpp b/Engine/source/T3D/fx/particleEmitterNode.cpp index 41e6b2192..bb362417b 100644 --- a/Engine/source/T3D/fx/particleEmitterNode.cpp +++ b/Engine/source/T3D/fx/particleEmitterNode.cpp @@ -393,8 +393,9 @@ void ParticleEmitterNode::setEmitterDataBlock(ParticleEmitterData* data) mEmitterDatablock = data; } - -DefineEngineMethod(ParticleEmitterNode, setEmitterDataBlock, void, (ParticleEmitterData* emitterDatablock), (0), + + +DefineEngineMethod(ParticleEmitterNode, setEmitterDataBlock, void, (ParticleEmitterData* emitterDatablock), (NULL), "Assigns the datablock for this emitter node.\n" "@param emitterDatablock ParticleEmitterData datablock to assign\n" "@tsexample\n" diff --git a/Engine/source/T3D/fx/precipitation.cpp b/Engine/source/T3D/fx/precipitation.cpp index 5b1743d02..4e6b09590 100644 --- a/Engine/source/T3D/fx/precipitation.cpp +++ b/Engine/source/T3D/fx/precipitation.cpp @@ -506,7 +506,7 @@ DefineEngineMethod(Precipitation, modifyStorm, void, (F32 percentage, F32 second object->modifyStorm(percentage, S32(seconds * 1000.0f)); } -DefineEngineMethod(Precipitation, setTurbulence, void, (F32 max, F32 speed, F32 seconds), (1.0f, 5.0f, 5.0), +DefineEngineMethod(Precipitation, setTurbulence, void, (F32 max, F32 speed, F32 seconds), (1.0f, 5.0f, 5.0f), "Smoothly change the turbulence parameters over a period of time.\n" "@param max New #maxTurbulence value. Set to 0 to disable turbulence.\n" "@param speed New #turbulenceSpeed value.\n" diff --git a/Engine/source/T3D/gameBase/gameProcess.cpp b/Engine/source/T3D/gameBase/gameProcess.cpp index d79c8f687..2df8a850e 100644 --- a/Engine/source/T3D/gameBase/gameProcess.cpp +++ b/Engine/source/T3D/gameBase/gameProcess.cpp @@ -20,6 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- +#include "console/engineAPI.h" #include "platform/platform.h" #include "T3D/gameBase/gameProcess.h" @@ -33,7 +34,7 @@ ClientProcessList* ClientProcessList::smClientProcessList = NULL; ServerProcessList* ServerProcessList::smServerProcessList = NULL; static U32 gNetOrderNextId = 0; -ConsoleFunction( dumpProcessList, void, 1, 1, +DefineConsoleFunction( dumpProcessList, void, ( ), , "Dumps all ProcessObjects in ServerProcessList and ClientProcessList to the console." ) { Con::printf( "client process list:" ); diff --git a/Engine/source/T3D/gameFunctions.cpp b/Engine/source/T3D/gameFunctions.cpp index e16acf1ec..010cc9e5e 100644 --- a/Engine/source/T3D/gameFunctions.cpp +++ b/Engine/source/T3D/gameFunctions.cpp @@ -88,7 +88,7 @@ extern void ShowInit(); //------------------------------------------------------------------------------ /// Camera and FOV info -namespace { +namespace CameraAndFOV{ const U32 MaxZoomSpeed = 2000; ///< max number of ms to reach target FOV @@ -112,7 +112,7 @@ static U32 sgServerQueryIndex = 0; //SERVER FUNCTIONS ONLY ConsoleFunctionGroupBegin( Containers, "Spatial query functions. Server side only!"); -ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point, float x, float y, float z)" +DefineConsoleFunction( containerFindFirst, const char*, (U32 typeMask, Point3F origin, Point3F size), , "(int mask, Point3F point, float x, float y, float z)" "@brief Find objects matching the bitmask type within a box centered at point, with extents x, y, z.\n\n" "@returns The first object found, or an empty string if nothing was found. Thereafter, you can get more " "results using containerFindNext()." @@ -120,17 +120,6 @@ ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point "@ingroup Game") { //find out what we're looking for - U32 typeMask = U32(dAtoi(argv[1])); - - //find the center of the container volume - Point3F origin(0.0f, 0.0f, 0.0f); - dSscanf(argv[2], "%g %g %g", &origin.x, &origin.y, &origin.z); - - //find the box dimensions - Point3F size(0.0f, 0.0f, 0.0f); - size.x = mFabs(dAtof(argv[3])); - size.y = mFabs(dAtof(argv[4])); - size.z = mFabs(dAtof(argv[5])); //build the container volume Box3F queryBox; @@ -155,7 +144,7 @@ ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point return buff; } -ConsoleFunction( containerFindNext, const char*, 1, 1, "()" +DefineConsoleFunction( containerFindNext, const char*, (), , "()" "@brief Get more results from a previous call to containerFindFirst().\n\n" "@note You must call containerFindFirst() to begin the search.\n" "@returns The next object found, or an empty string if nothing else was found.\n" @@ -191,9 +180,9 @@ DefineEngineFunction( setDefaultFov, void, ( F32 defaultFOV ),, "@param defaultFOV The default field of view in degrees\n" "@ingroup CameraSystem") { - sDefaultFov = mClampF(defaultFOV, MinCameraFov, MaxCameraFov); - if(sCameraFov == sTargetFov) - sTargetFov = sDefaultFov; + CameraAndFOV::sDefaultFov = mClampF(defaultFOV, MinCameraFov, MaxCameraFov); + if(CameraAndFOV::sCameraFov == CameraAndFOV::sTargetFov) + CameraAndFOV::sTargetFov = CameraAndFOV::sDefaultFov; } DefineEngineFunction( setZoomSpeed, void, ( S32 speed ),, @@ -203,7 +192,7 @@ DefineEngineFunction( setZoomSpeed, void, ( S32 speed ),, "@param speed The camera's zoom speed in ms per 90deg FOV change\n" "@ingroup CameraSystem") { - sZoomSpeed = mClamp(speed, 0, MaxZoomSpeed); + CameraAndFOV::sZoomSpeed = mClamp(speed, 0, CameraAndFOV::MaxZoomSpeed); } DefineEngineFunction( setFov, void, ( F32 FOV ),, @@ -211,22 +200,22 @@ DefineEngineFunction( setFov, void, ( F32 FOV ),, "@param FOV The camera's new FOV in degrees\n" "@ingroup CameraSystem") { - sTargetFov = mClampF(FOV, MinCameraFov, MaxCameraFov); + CameraAndFOV::sTargetFov = mClampF(FOV, MinCameraFov, MaxCameraFov); } F32 GameGetCameraFov() { - return(sCameraFov); + return(CameraAndFOV::sCameraFov); } void GameSetCameraFov(F32 fov) { - sTargetFov = sCameraFov = fov; + CameraAndFOV::sTargetFov = CameraAndFOV::sCameraFov = fov; } void GameSetCameraTargetFov(F32 fov) { - sTargetFov = fov; + CameraAndFOV::sTargetFov = fov; } void GameUpdateCameraFov() @@ -234,29 +223,29 @@ void GameUpdateCameraFov() F32 time = F32(Platform::getVirtualMilliseconds()); // need to update fov? - if(sTargetFov != sCameraFov) + if(CameraAndFOV::sTargetFov != CameraAndFOV::sCameraFov) { - F32 delta = time - sLastCameraUpdateTime; + F32 delta = time - CameraAndFOV::sLastCameraUpdateTime; // snap zoom? - if((sZoomSpeed == 0) || (delta <= 0.f)) - sCameraFov = sTargetFov; + if((CameraAndFOV::sZoomSpeed == 0) || (delta <= 0.f)) + CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov; else { // gZoomSpeed is time in ms to zoom 90deg - F32 step = 90.f * (delta / F32(sZoomSpeed)); + F32 step = 90.f * (delta / F32(CameraAndFOV::sZoomSpeed)); - if(sCameraFov > sTargetFov) + if(CameraAndFOV::sCameraFov > CameraAndFOV::sTargetFov) { - sCameraFov -= step; - if(sCameraFov < sTargetFov) - sCameraFov = sTargetFov; + CameraAndFOV::sCameraFov -= step; + if(CameraAndFOV::sCameraFov < CameraAndFOV::sTargetFov) + CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov; } else { - sCameraFov += step; - if(sCameraFov > sTargetFov) - sCameraFov = sTargetFov; + CameraAndFOV::sCameraFov += step; + if(CameraAndFOV::sCameraFov > CameraAndFOV::sTargetFov) + CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov; } } } @@ -266,23 +255,23 @@ void GameUpdateCameraFov() if(connection) { // check if fov is valid on control object - if(connection->isValidControlCameraFov(sCameraFov)) - connection->setControlCameraFov(sCameraFov); + if(connection->isValidControlCameraFov(CameraAndFOV::sCameraFov)) + connection->setControlCameraFov(CameraAndFOV::sCameraFov); else { // will set to the closest fov (fails only on invalid control object) - if(connection->setControlCameraFov(sCameraFov)) + if(connection->setControlCameraFov(CameraAndFOV::sCameraFov)) { - F32 setFov = sCameraFov; + F32 setFov = CameraAndFOV::sCameraFov; connection->getControlCameraFov(&setFov); - sTargetFov = sCameraFov = setFov; + CameraAndFOV::sTargetFov =CameraAndFOV::sCameraFov = setFov; } } } // update the console variable - sConsoleCameraFov = sCameraFov; - sLastCameraUpdateTime = time; + CameraAndFOV::sConsoleCameraFov = CameraAndFOV::sCameraFov; + CameraAndFOV::sLastCameraUpdateTime = time; } //-------------------------------------------------------------------------- @@ -355,8 +344,8 @@ bool GameProcessCameraQuery(CameraQuery *query) // Scale the normal visible distance by the performance // tuning scale which we never let over 1. - sVisDistanceScale = mClampF( sVisDistanceScale, 0.01f, 1.0f ); - query->farPlane = gClientSceneGraph->getVisibleDistance() * sVisDistanceScale; + CameraAndFOV::sVisDistanceScale = mClampF( CameraAndFOV::sVisDistanceScale, 0.01f, 1.0f ); + query->farPlane = gClientSceneGraph->getVisibleDistance() * CameraAndFOV::sVisDistanceScale; // Provide some default values query->projectionOffset = Point2F::Zero; @@ -432,10 +421,10 @@ static void Process3D() static void RegisterGameFunctions() { - Con::addVariable( "$pref::Camera::distanceScale", TypeF32, &sVisDistanceScale, + Con::addVariable( "$pref::Camera::distanceScale", TypeF32, &CameraAndFOV::sVisDistanceScale, "A scale to apply to the normal visible distance, typically used for tuning performance.\n" "@ingroup Game"); - Con::addVariable( "$cameraFov", TypeF32, &sConsoleCameraFov, + Con::addVariable( "$cameraFov", TypeF32, &CameraAndFOV::sConsoleCameraFov, "The camera's Field of View.\n\n" "@ingroup Game" ); diff --git a/Engine/source/T3D/lightBase.cpp b/Engine/source/T3D/lightBase.cpp index 150f6e9cc..dd168a483 100644 --- a/Engine/source/T3D/lightBase.cpp +++ b/Engine/source/T3D/lightBase.cpp @@ -425,21 +425,22 @@ static ConsoleDocFragment _lbplayAnimation2( "LightBase", "void playAnimation(LightAnimData anim);" ); -ConsoleMethod( LightBase, playAnimation, void, 2, 3, "( [LightAnimData anim] )\t" + +DefineConsoleMethod( LightBase, playAnimation, void, (const char * anim), (""), "( [LightAnimData anim] )\t" "Plays a light animation on the light. If no LightAnimData is passed the " "existing one is played." "@hide") { - if ( argc == 2 ) + if ( dStrIsEmpty(anim) ) { object->playAnimation(); return; } LightAnimData *animData; - if ( !Sim::findObject( argv[2], animData ) ) + if ( !Sim::findObject( anim, animData ) ) { - Con::errorf( "LightBase::playAnimation() - Invalid LightAnimData '%s'.", (const char*)argv[2] ); + Con::errorf( "LightBase::playAnimation() - Invalid LightAnimData '%s'.", anim ); return; } @@ -469,7 +470,7 @@ void LightBase::playAnimation( LightAnimData *animData ) } } -ConsoleMethod( LightBase, pauseAnimation, void, 2, 2, "Stops the light animation." ) +DefineConsoleMethod( LightBase, pauseAnimation, void, (), , "Stops the light animation." ) { object->pauseAnimation(); } diff --git a/Engine/source/T3D/missionMarker.cpp b/Engine/source/T3D/missionMarker.cpp index 65bdeae09..151cd7336 100644 --- a/Engine/source/T3D/missionMarker.cpp +++ b/Engine/source/T3D/missionMarker.cpp @@ -279,8 +279,6 @@ void WayPoint::unpackUpdate(NetConnection * con, BitStream * stream) setHidden(stream->readFlag()); } - - void WayPoint::initPersistFields() { addGroup("Misc"); @@ -506,16 +504,16 @@ ConsoleDocFragment _SpawnSpherespawnObject1( "bool spawnObject(string additionalProps);" ); -ConsoleMethod(SpawnSphere, spawnObject, S32, 2, 3, +DefineConsoleMethod(SpawnSphere, spawnObject, S32, (String additionalProps), , "([string additionalProps]) Spawns the object based on the SpawnSphere's " "class, datablock, properties, and script settings. Allows you to pass in " "extra properties." "@hide" ) { - String additionalProps; + //String additionalProps; - if (argc == 3) - additionalProps = (const char*)argv[2]; + //if (argc == 3) + // additionalProps = String(argv[2]); SimObject* obj = object->spawnObject(additionalProps); diff --git a/Engine/source/T3D/pathCamera.cpp b/Engine/source/T3D/pathCamera.cpp index 43e6f9273..d6d9d1733 100644 --- a/Engine/source/T3D/pathCamera.cpp +++ b/Engine/source/T3D/pathCamera.cpp @@ -581,7 +581,7 @@ static CameraSpline::Knot::Path resolveKnotPath(const char *arg) } DefineEngineMethod(PathCamera, pushBack, void, (TransformF transform, F32 speed, const char* type, const char* path), - (1.0, "Normal", "Linear"), + (1.0f, "Normal", "Linear"), "@brief Adds a new knot to the back of a path camera's path.\n" "@param transform Transform for the new knot. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform()\n" "@param speed Speed setting for this knot.\n" @@ -606,7 +606,7 @@ DefineEngineMethod(PathCamera, pushBack, void, (TransformF transform, F32 speed, } DefineEngineMethod(PathCamera, pushFront, void, (TransformF transform, F32 speed, const char* type, const char* path), - (1.0, "Normal", "Linear"), + (1.0f, "Normal", "Linear"), "@brief Adds a new knot to the front of a path camera's path.\n" "@param transform Transform for the new knot. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform()\n" "@param speed Speed setting for this knot.\n" diff --git a/Engine/source/T3D/physics/physicsDebris.cpp b/Engine/source/T3D/physics/physicsDebris.cpp index ba9c7e4b6..3c4077dc4 100644 --- a/Engine/source/T3D/physics/physicsDebris.cpp +++ b/Engine/source/T3D/physics/physicsDebris.cpp @@ -27,6 +27,7 @@ #include "math/mathUtils.h" #include "console/consoleTypes.h" #include "console/consoleObject.h" +#include "console/engineAPI.h" #include "sim/netConnection.h" #include "scene/sceneRenderState.h" #include "scene/sceneManager.h" @@ -237,7 +238,7 @@ void PhysicsDebrisData::unpackData(BitStream* stream) shapeName = stream->readSTString(); } -ConsoleMethod( PhysicsDebrisData, preload, void, 2, 2, +DefineConsoleMethod( PhysicsDebrisData, preload, void, (), , "@brief Loads some information to have readily available at simulation time.\n\n" "Forces generation of shaders, materials, and other data used by the %PhysicsDebris object. " "This function should be used while a level is loading in order to shorten " diff --git a/Engine/source/T3D/physics/physicsPlugin.cpp b/Engine/source/T3D/physics/physicsPlugin.cpp index 79c5076e9..b2f06b55e 100644 --- a/Engine/source/T3D/physics/physicsPlugin.cpp +++ b/Engine/source/T3D/physics/physicsPlugin.cpp @@ -24,6 +24,7 @@ #include "T3D/physics/physicsPlugin.h" #include "console/console.h" +#include "console/engineAPI.h" #include "console/consoleTypes.h" #include "console/simSet.h" #include "core/strings/stringFunctions.h" @@ -123,55 +124,52 @@ void PhysicsPlugin::_debugDraw( SceneManager *graph, const SceneRenderState *sta world->onDebugDraw( state ); } -ConsoleFunction( physicsPluginPresent, bool, 1, 1, "physicsPluginPresent()\n" +DefineConsoleFunction( physicsPluginPresent, bool, (), , "physicsPluginPresent()" "@brief Returns true if a physics plugin exists and is initialized.\n\n" "@ingroup Physics" ) { return PHYSICSMGR != NULL; } -ConsoleFunction( physicsInit, bool, 1, 2, "physicsInit( [string library] )" ) +DefineConsoleFunction( physicsInit, bool, (const char * library), ("default"), "physicsInit( [string library] )") { - const char *library = "default"; - if ( argc > 1 ) - library = argv[1]; - return PhysicsPlugin::activate( library ); } -ConsoleFunction( physicsDestroy, void, 1, 1, "physicsDestroy()" ) +DefineConsoleFunction( physicsDestroy, void, (), , "physicsDestroy()") { if ( PHYSICSMGR ) PHYSICSMGR->destroyPlugin(); } -ConsoleFunction( physicsInitWorld, bool, 2, 2, "physicsInitWorld( String worldName )" ) +DefineConsoleFunction( physicsInitWorld, bool, (const char * worldName), , "physicsInitWorld( String worldName )") { - return PHYSICSMGR && PHYSICSMGR->createWorld( (const char*)argv[1] ); + bool res = PHYSICSMGR && PHYSICSMGR->createWorld( String( worldName ) ); + return res; } -ConsoleFunction( physicsDestroyWorld, void, 2, 2, "physicsDestroyWorld( String worldName )" ) +DefineConsoleFunction( physicsDestroyWorld, void, (const char * worldName), , "physicsDestroyWorld( String worldName )") { if ( PHYSICSMGR ) - PHYSICSMGR->destroyWorld( (const char*)argv[1] ); + PHYSICSMGR->destroyWorld( worldName ); } // Control/query of the stop/started state // of the currently running simulation. -ConsoleFunction( physicsStartSimulation, void, 2, 2, "physicsStartSimulation( String worldName )" ) +DefineConsoleFunction( physicsStartSimulation, void, (const char * worldName), , "physicsStartSimulation( String worldName )") { if ( PHYSICSMGR ) - PHYSICSMGR->enableSimulation( (const char*)argv[1], true ); + PHYSICSMGR->enableSimulation( String( worldName ), true ); } -ConsoleFunction( physicsStopSimulation, void, 2, 2, "physicsStopSimulation( String worldName )" ) +DefineConsoleFunction( physicsStopSimulation, void, (const char * worldName), , "physicsStopSimulation( String worldName )") { if ( PHYSICSMGR ) - PHYSICSMGR->enableSimulation( (const char*)argv[1], false ); + PHYSICSMGR->enableSimulation( String( worldName ), false ); } -ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled()" ) +DefineConsoleFunction( physicsSimulationEnabled, bool, (), , "physicsStopSimulation( String worldName )") { return PHYSICSMGR && PHYSICSMGR->isSimulationEnabled(); } @@ -179,14 +177,14 @@ ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled // Used for slowing down time on the // physics simulation, and for pausing/restarting // the simulation. -ConsoleFunction( physicsSetTimeScale, void, 2, 2, "physicsSetTimeScale( F32 scale )" ) +DefineConsoleFunction( physicsSetTimeScale, void, (F32 scale), , "physicsSetTimeScale( F32 scale )") { if ( PHYSICSMGR ) - PHYSICSMGR->setTimeScale( argv[1] ); + PHYSICSMGR->setTimeScale( scale ); } // Get the currently set time scale. -ConsoleFunction( physicsGetTimeScale, F32, 1, 1, "physicsGetTimeScale()" ) +DefineConsoleFunction( physicsGetTimeScale, F32, (), , "physicsGetTimeScale()") { return PHYSICSMGR && PHYSICSMGR->getTimeScale(); } @@ -195,7 +193,7 @@ ConsoleFunction( physicsGetTimeScale, F32, 1, 1, "physicsGetTimeScale()" ) // physics simulation that they should store // their current state for later restoration, // such as when the editor is closed. -ConsoleFunction( physicsStoreState, void, 1, 1, "physicsStoreState()" ) +DefineConsoleFunction( physicsStoreState, void, (), , "physicsStoreState()") { PhysicsPlugin::getPhysicsResetSignal().trigger( PhysicsResetEvent_Store ); } @@ -203,14 +201,14 @@ ConsoleFunction( physicsStoreState, void, 1, 1, "physicsStoreState()" ) // Used to send a signal to objects in the // physics simulation that they should restore // their saved state, such as when the editor is opened. -ConsoleFunction( physicsRestoreState, void, 1, 1, "physicsRestoreState()" ) +DefineConsoleFunction( physicsRestoreState, void, (), , "physicsRestoreState()") { if ( PHYSICSMGR ) PHYSICSMGR->reset(); } -ConsoleFunction( physicsDebugDraw, void, 2, 2, "physicsDebugDraw( bool enable )" ) +DefineConsoleFunction( physicsDebugDraw, void, (bool enable), , "physicsDebugDraw( bool enable )") { if ( PHYSICSMGR ) - PHYSICSMGR->enableDebugDraw( (S32)argv[1] ); + PHYSICSMGR->enableDebugDraw( enable ); } diff --git a/Engine/source/T3D/staticShape.cpp b/Engine/source/T3D/staticShape.cpp index b40ee55bd..0f882824a 100644 --- a/Engine/source/T3D/staticShape.cpp +++ b/Engine/source/T3D/staticShape.cpp @@ -28,6 +28,7 @@ #include "console/simBase.h" #include "console/console.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "T3D/gameBase/moveManager.h" #include "ts/tsShapeInstance.h" #include "T3D/staticShape.h" @@ -317,15 +318,15 @@ void StaticShape::unpackUpdate(NetConnection *connection, BitStream *bstream) // This appears to be legacy T2 stuff // Marked internal, as this is flagged to be deleted // [8/1/2010 mperry] -ConsoleMethod( StaticShape, setPoweredState, void, 3, 3, "(bool isPowered)" +DefineConsoleMethod( StaticShape, setPoweredState, void, (bool isPowered), , "(bool isPowered)" "@internal") { if(!object->isServerObject()) return; - object->setPowered(dAtob(argv[2])); + object->setPowered(isPowered); } -ConsoleMethod( StaticShape, getPoweredState, bool, 2, 2, "@internal") +DefineConsoleMethod( StaticShape, getPoweredState, bool, (), , "@internal") { if(!object->isServerObject()) return(false); diff --git a/Engine/source/app/game.cpp b/Engine/source/app/game.cpp index c3300af93..4579b4819 100644 --- a/Engine/source/app/game.cpp +++ b/Engine/source/app/game.cpp @@ -33,6 +33,7 @@ #include "console/simBase.h" #include "console/console.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gui/controls/guiMLTextCtrl.h" #ifdef TORQUE_TGB_ONLY #include "T2D/oldModel/networking/t2dGameConnection.h" @@ -57,22 +58,22 @@ bool gEditingMission = false; ConsoleFunctionGroupBegin( InputManagement, "Functions that let you deal with input from scripts" ); -ConsoleFunction( deactivateDirectInput, void, 1, 1, "()" +DefineConsoleFunction( deactivateDirectInput, void, (), , + "()" "@brief Disables DirectInput.\n\n" "Also deactivates any connected joysticks.\n\n" "@ingroup Input" ) { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); if ( Input::isActive() ) Input::deactivate(); } -ConsoleFunction( activateDirectInput, void, 1, 1,"()" +DefineConsoleFunction( activateDirectInput, void, (), , + "()" "@brief Activates DirectInput.\n\n" "Also activates any connected joysticks." "@ingroup Input") { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); if ( !Input::isActive() ) Input::activate(); } @@ -81,11 +82,8 @@ ConsoleFunctionGroupEnd( InputManagement ); //-------------------------------------------------------------------------- static const U32 MaxPlayerNameLength = 16; -ConsoleFunction( strToPlayerName, const char*, 2, 2, "strToPlayerName( string )" ) +DefineConsoleFunction( strToPlayerName, const char*, (const char* ptr ), , "strToPlayerName(string);" ) { - TORQUE_UNUSED(argc); - - const char* ptr = argv[1]; // Strip leading spaces and underscores: while ( *ptr == ' ' || *ptr == '_' ) @@ -140,16 +138,16 @@ ConsoleFunction( strToPlayerName, const char*, 2, 2, "strToPlayerName( string )" ConsoleFunctionGroupBegin( Platform , "General platform functions."); -ConsoleFunction( lockMouse, void, 2, 2, "(bool isLocked)" +DefineConsoleFunction( lockMouse, void, (bool isLocked ), , "(bool isLocked)" "@brief Lock or unlock the mouse to the window.\n\n" "When true, prevents the mouse from leaving the bounds of the game window.\n\n" "@ingroup Input") { - Platform::setWindowLocked(dAtob(argv[1])); + Platform::setWindowLocked(isLocked); } -ConsoleFunction( setNetPort, bool, 2, 3, "(int port, bool bind=true)" +DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int port, bool bind=true)" "@brief Set the network port for the game to use.\n\n" "@param port The port to use.\n" @@ -161,37 +159,34 @@ ConsoleFunction( setNetPort, bool, 2, 3, "(int port, bool bind=true)" "If you don't have firewall tunneling tech you can set this to false to avoid the prompt.\n\n" "@ingroup Networking") { - bool bind = true; - if (argc == 3) - bind = dAtob(argv[2]); - return Net::openPort(dAtoi(argv[1]), bind); + return Net::openPort((S32)port, bind); } -ConsoleFunction( closeNetPort, void, 1, 1, "()" +DefineConsoleFunction( closeNetPort, void, (), , "()" "@brief Closes the current network port\n\n" "@ingroup Networking") { Net::closePort(); } -ConsoleFunction( saveJournal, void, 2, 2, "(string filename)" +DefineConsoleFunction( saveJournal, void, (const char * filename), , "(string filename)" "Save the journal to the specified file.\n\n" "@ingroup Platform") { - Journal::Record(argv[1]); + Journal::Record(filename); } -ConsoleFunction( playJournal, void, 2, 3, "(string filename)" +DefineConsoleFunction( playJournal, void, (const char * filename), , "(string filename)" "@brief Begin playback of a journal from a specified field.\n\n" "@param filename Name and path of file journal file\n" "@ingroup Platform") { // CodeReview - BJG 4/24/2007 - The break flag needs to be wired back in. // bool jBreak = (argc > 2)? dAtob(argv[2]): false; - Journal::Play(argv[1]); + Journal::Play(filename); } -ConsoleFunction( getSimTime, S32, 1, 1, "()" +DefineConsoleFunction( getSimTime, S32, (), , "()" "Return the current sim time in milliseconds.\n\n" "@brief Sim time is time since the game started.\n\n" "@ingroup Platform") @@ -199,7 +194,7 @@ ConsoleFunction( getSimTime, S32, 1, 1, "()" return Sim::getCurrentTime(); } -ConsoleFunction( getRealTime, S32, 1, 1, "()" +DefineConsoleFunction( getRealTime, S32, (), , "()" "@brief Return the current real time in milliseconds.\n\n" "Real time is platform defined; typically time since the computer booted.\n\n" "@ingroup Platform") diff --git a/Engine/source/app/net/serverQuery.cpp b/Engine/source/app/net/serverQuery.cpp index f0cace57e..9e9202365 100644 --- a/Engine/source/app/net/serverQuery.cpp +++ b/Engine/source/app/net/serverQuery.cpp @@ -410,25 +410,20 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi //----------------------------------------------------------------------------- -ConsoleFunction( queryAllServers, void, 12, 12, "queryAllServers(...);" ) +DefineConsoleFunction( queryAllServers + , void, ( U32 lanPort + , U32 flags + , const char * gameType + , const char * missionType + , U32 minPlayers + , U32 maxPlayers + , U32 maxBots + , U32 regionMask + , U32 maxPing + , U32 minCPU + , U32 filterFlags ) + , , "queryAllServers(...);" ) { - TORQUE_UNUSED(argc); - - U32 lanPort = dAtoi(argv[1]); - U8 flags = dAtoi(argv[2]); - - // It's not a good idea to hold onto args, recursive calls to - // console exec will trash them. - char* gameType = dStrdup(argv[3]); - char* missionType = dStrdup(argv[4]); - - U8 minPlayers = dAtoi(argv[5]); - U8 maxPlayers = dAtoi(argv[6]); - U8 maxBots = dAtoi(argv[7]); - U32 regionMask = dAtoi(argv[8]); - U32 maxPing = dAtoi(argv[9]); - U16 minCPU = dAtoi(argv[10]); - U8 filterFlags = dAtoi(argv[11]); U32 buddyList = 0; clearServerList(); @@ -442,32 +437,27 @@ ConsoleFunction( queryAllServers, void, 12, 12, "queryAllServers(...);" ) dFree(missionType); } -ConsoleFunction( queryLanServers, void, 12, 12, "queryLanServers(...);" ) + +DefineConsoleFunction( queryLanServers + , void, ( U32 lanPort + , U32 flags + , const char * gameType + , const char * missionType + , U32 minPlayers + , U32 maxPlayers + , U32 maxBots + , U32 regionMask + , U32 maxPing + , U32 minCPU + , U32 filterFlags ) + , , "queryLanServers(...);" ) + { - TORQUE_UNUSED(argc); - - U32 lanPort = dAtoi(argv[1]); - U8 flags = dAtoi(argv[2]); - - // It's not a good idea to hold onto args, recursive calls to - // console exec will trash them. - char* gameType = dStrdup(argv[3]); - char* missionType = dStrdup(argv[4]); - - U8 minPlayers = dAtoi(argv[5]); - U8 maxPlayers = dAtoi(argv[6]); - U8 maxBots = dAtoi(argv[7]); - U32 regionMask = dAtoi(argv[8]); - U32 maxPing = dAtoi(argv[9]); - U16 minCPU = dAtoi(argv[10]); - U8 filterFlags = dAtoi(argv[11]); clearServerList(); queryLanServers(lanPort, flags, gameType, missionType, minPlayers, maxPlayers, maxBots, regionMask, maxPing, minCPU, filterFlags); - dFree(gameType); - dFree(missionType); } //----------------------------------------------------------------------------- @@ -550,24 +540,20 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType, processMasterServerQuery( gPingSession ); } -ConsoleFunction( queryMasterServer, void, 11, 11, "queryMasterServer(...);" ) +DefineConsoleFunction( queryMasterServer + , void, ( U32 lanPort + , U32 flags + , const char * gameType + , const char * missionType + , U32 minPlayers + , U32 maxPlayers + , U32 maxBots + , U32 regionMask + , U32 maxPing + , U32 minCPU + , U32 filterFlags ) + , , "queryMasterServer(...);" ) { - TORQUE_UNUSED(argc); - - U8 flags = dAtoi(argv[1]); - - // It's not a good idea to hold onto args, recursive calls to - // console exec will trash them. - char* gameType = dStrdup(argv[2]); - char* missionType = dStrdup(argv[3]); - - U8 minPlayers = dAtoi(argv[4]); - U8 maxPlayers = dAtoi(argv[5]); - U8 maxBots = dAtoi(argv[6]); - U32 regionMask = dAtoi(argv[7]); - U32 maxPing = dAtoi(argv[8]); - U16 minCPU = dAtoi(argv[9]); - U8 filterFlags = dAtoi(argv[10]); U32 buddyList = 0; clearServerList(); @@ -580,17 +566,11 @@ ConsoleFunction( queryMasterServer, void, 11, 11, "queryMasterServer(...);" ) //----------------------------------------------------------------------------- -ConsoleFunction( querySingleServer, void, 3, 3, "querySingleServer(address, flags);" ) +DefineConsoleFunction( querySingleServer + , void, ( const char* addrText, U8 flags ) + , (0), "querySingleServer(address, flags);" ) { - TORQUE_UNUSED(argc); - NetAddress addr; - char* addrText; - - addrText = dStrdup(argv[1]); - U8 flags = dAtoi(argv[2]); - - Net::stringToAddress( addrText, &addr ); querySingleServer(&addr,flags); } @@ -672,9 +652,8 @@ void cancelServerQuery() } } -ConsoleFunction( cancelServerQuery, void, 1, 1, "cancelServerQuery()" ) +DefineConsoleFunction( cancelServerQuery, void, (), , "cancelServerQuery();" ) { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); cancelServerQuery(); } @@ -701,43 +680,36 @@ void stopServerQuery() } } -ConsoleFunction( stopServerQuery, void, 1, 1, "stopServerQuery()" ) +DefineConsoleFunction( stopServerQuery, void, (), , "stopServerQuery();" ) { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); stopServerQuery(); } //----------------------------------------------------------------------------- -ConsoleFunction(startHeartbeat, void, 1, 1, "startHeartbeat()") +DefineConsoleFunction( startHeartbeat, void, (), , "startHeartbeat();" ) { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); - if (validateAuthenticatedServer()) { gHeartbeatSeq++; processHeartbeat(gHeartbeatSeq); // thump-thump... } } -ConsoleFunction(stopHeartbeat, void, 1, 1, "stopHeartbeat();") +DefineConsoleFunction( stopHeartbeat, void, (), , "stopHeartbeat();" ) { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); gHeartbeatSeq++; } //----------------------------------------------------------------------------- -ConsoleFunction( getServerCount, int, 1, 1, "getServerCount();" ) +DefineConsoleFunction( getServerCount, int, (), , "getServerCount();" ) { - TORQUE_UNUSED(argv); TORQUE_UNUSED(argc); return gServerList.size(); } -ConsoleFunction( setServerInfo, bool, 2, 2, "setServerInfo(index);" ) +DefineConsoleFunction( setServerInfo, bool, (U32 index), , "setServerInfo(index);" ) { - TORQUE_UNUSED(argc); - U32 index = dAtoi(argv[1]); - if (index >= 0 && index < gServerList.size()) { + if (index < gServerList.size()) { ServerInfo& info = gServerList[index]; char addrString[256]; diff --git a/Engine/source/app/version.cpp b/Engine/source/app/version.cpp index 7898b38e2..5c7f336ee 100644 --- a/Engine/source/app/version.cpp +++ b/Engine/source/app/version.cpp @@ -23,6 +23,7 @@ #include "platform/platform.h" #include "app/version.h" #include "console/console.h" +#include "console/engineAPI.h" static const U32 csgVersionNumber = TORQUE_GAME_ENGINE; static const U32 appVersionNumber = TORQUE_APP_VERSION; @@ -91,44 +92,44 @@ const char* getCompileTimeString() ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." ); -ConsoleFunction( getVersionNumber, S32, 1, 1, "Get the version of the engine build, as a string.\n\n" +DefineConsoleFunction( getVersionNumber, S32, (), , "Get the version of the engine build, as a string.\n\n" "@ingroup Debugging") { return getVersionNumber(); } -ConsoleFunction( getAppVersionNumber, S32, 1, 1, "Get the version of the application build, as a string.\n\n" +DefineConsoleFunction( getAppVersionNumber, S32, (), , "Get the version of the application build, as a string.\n\n" "@ingroup Debugging") { return getAppVersionNumber(); } -ConsoleFunction( getVersionString, const char*, 1, 1, "Get the version of the engine build, as a human readable string.\n\n" +DefineConsoleFunction( getVersionString, const char*, (), , "Get the version of the engine build, as a human readable string.\n\n" "@ingroup Debugging") { return getVersionString(); } -ConsoleFunction( getAppVersionString, const char*, 1, 1, "Get the version of the aplication, as a human readable string.\n\n" +DefineConsoleFunction( getAppVersionString, const char*, (), , "Get the version of the aplication build, as a human readable string.\n\n" "@ingroup Debugging") { return getAppVersionString(); } -ConsoleFunction( getEngineName, const char*, 1, 1, "Get the name of the engine product that this is running from, as a string.\n\n" +DefineConsoleFunction( getEngineName, const char*, (), , "Get the name of the engine product that this is running from, as a string.\n\n" "@ingroup Debugging") { return getEngineProductString(); } -ConsoleFunction( getCompileTimeString, const char*, 1, 1, "Get the time of compilation.\n\n" +DefineConsoleFunction( getCompileTimeString, const char*, (), , "Get the time of compilation.\n\n" "@ingroup Debugging") { return getCompileTimeString(); } -ConsoleFunction( getBuildString, const char*, 1, 1, "Get the type of build, \"Debug\" or \"Release\".\n\n" +DefineConsoleFunction( getBuildString, const char*, (), , "Get the type of build, \"Debug\" or \"Release\".\n\n" "@ingroup Debugging") { #ifdef TORQUE_DEBUG @@ -140,7 +141,7 @@ ConsoleFunction( getBuildString, const char*, 1, 1, "Get the type of build, \"De ConsoleFunctionGroupEnd( CompileInformation ); -ConsoleFunction(isDemo, bool, 1, 1, "") +DefineConsoleFunction( isDemo, bool, (), , "") { #ifdef TORQUE_DEMO return true; @@ -149,7 +150,7 @@ ConsoleFunction(isDemo, bool, 1, 1, "") #endif } -ConsoleFunction(isWebDemo, bool, 1, 1, "") +DefineConsoleFunction( isWebDemo, bool, (), , "") { #ifdef TORQUE_DEMO return Platform::getWebDeployment(); diff --git a/Engine/source/cinterface/cinterface.cpp b/Engine/source/cinterface/cinterface.cpp index a8342745d..1994cd2f6 100644 --- a/Engine/source/cinterface/cinterface.cpp +++ b/Engine/source/cinterface/cinterface.cpp @@ -23,6 +23,7 @@ #include "platform/platform.h" #include "console/compiler.h" #include "console/consoleInternal.h" +#include "console/engineAPI.h" #include "core/util/tDictionary.h" #include "core/strings/stringFunctions.h" #include "app/mainLoop.h" @@ -458,20 +459,16 @@ extern "C" { // By default, it is marked as secure by the web plugins and then can be called from // Javascript on the web page to ensure that function calls across the language // boundry are working with arguments and return values -ConsoleFunction(testJavaScriptBridge, const char *, 4, 4, "testBridge(arg1, arg2, arg3)") +DefineConsoleFunction( testJavaScriptBridge, const char *, (const char* arg1, const char* arg2, const char* arg3), , "testBridge(arg1, arg2, arg3)") { S32 failed = 0; - if(argc != 4) - failed = 1; - else - { - if (dStrcmp(argv[1],"one")) + if (dStrcmp(arg1,"one")) failed = 2; - if (dStrcmp(argv[2],"two")) + if (dStrcmp(arg2,"two")) failed = 2; - if (dStrcmp(argv[3],"three")) + if (dStrcmp(arg3,"three")) failed = 2; - } + //attempt to call from TorqueScript -> JavaScript const char* jret = Con::evaluate("JS::bridgeCallback(\"one\",\"two\",\"three\");"); diff --git a/Engine/source/component/simComponent.cpp b/Engine/source/component/simComponent.cpp index f4e1f5c67..49cbef22e 100644 --- a/Engine/source/component/simComponent.cpp +++ b/Engine/source/component/simComponent.cpp @@ -25,6 +25,7 @@ #include "console/consoleTypes.h" #include "component/simComponent.h" #include "core/stream/stream.h" +#include "console/engineAPI.h" SimComponent::SimComponent() : mOwner( NULL ) { @@ -404,17 +405,16 @@ ConsoleMethod( SimComponent, removeComponents, bool, 3, 64, "%obj.removeComponen return true; } -ConsoleMethod( SimComponent, getComponentCount, S32, 2, 2, "() Get the current component count\n" +DefineConsoleMethod( SimComponent, getComponentCount, S32, (), , "() Get the current component count\n" "@return The number of components in the list as an integer") { return object->getComponentCount(); } -ConsoleMethod( SimComponent, getComponent, S32, 3, 3, "(idx) Get the component corresponding to the given index.\n" +DefineConsoleMethod( SimComponent, getComponent, S32, (S32 idx), , "(idx) Get the component corresponding to the given index.\n" "@param idx An integer index value corresponding to the desired component.\n" "@return The id of the component at the given index as an integer") { - S32 idx = dAtoi(argv[2]); if(idx < 0 || idx >= object->getComponentCount()) { Con::errorf("SimComponent::getComponent - Invalid index %d", idx); @@ -425,27 +425,27 @@ ConsoleMethod( SimComponent, getComponent, S32, 3, 3, "(idx) Get the component c return c ? c->getId() : 0; } -ConsoleMethod(SimComponent, setEnabled, void, 3, 3, "(enabled) Sets or unsets the enabled flag\n" +DefineConsoleMethod(SimComponent, setEnabled, void, (bool enabled), , "(enabled) Sets or unsets the enabled flag\n" "@param enabled Boolean value\n" "@return No return value") { - object->setEnabled(dAtob(argv[2])); + object->setEnabled(enabled); } -ConsoleMethod(SimComponent, isEnabled, bool, 2, 2, "() Check whether SimComponent is currently enabled\n" +DefineConsoleMethod(SimComponent, isEnabled, bool, (), , "() Check whether SimComponent is currently enabled\n" "@return true if enabled and false if not") { return object->isEnabled(); } -ConsoleMethod(SimComponent, setIsTemplate, void, 3, 3, "(template) Sets or unsets the template flag\n" +DefineConsoleMethod(SimComponent, setIsTemplate, void, (bool templateFlag), , "(template) Sets or unsets the template flag\n" "@param template Boolean value\n" "@return No return value") { - object->setIsTemplate(dAtob(argv[2])); + object->setIsTemplate(templateFlag); } -ConsoleMethod(SimComponent, getIsTemplate, bool, 2, 2, "() Check whether SimComponent is currently a template\n" +DefineConsoleMethod(SimComponent, getIsTemplate, bool, (), , "() Check whether SimComponent is currently a template\n" "@return true if is a template and false if not") { return object->getIsTemplate(); diff --git a/Engine/source/console/SimXMLDocument.cpp b/Engine/source/console/SimXMLDocument.cpp index f3018fef4..840f36ca8 100644 --- a/Engine/source/console/SimXMLDocument.cpp +++ b/Engine/source/console/SimXMLDocument.cpp @@ -571,21 +571,22 @@ DefineEngineMethod( SimXMLDocument, attribute, const char*, ( const char* attrib } // These two methods don't make a lot of sense the way TS works. Leaving them in for backwards-compatibility. -ConsoleMethod( SimXMLDocument, attributeF32, F32, 3, 3, "(string attributeName)" +DefineConsoleMethod( SimXMLDocument, attributeF32, F32, (const char * attributeName), , "(string attributeName)" "@brief Get float attribute from the current Element on the stack.\n\n" "@param attributeName Name of attribute to retrieve.\n" "@return The value of the given attribute in the form of a float.\n" "@deprecated Use attribute().") { - return dAtof( object->attribute( argv[2] ) ); + return dAtof( object->attribute( attributeName ) ); } -ConsoleMethod(SimXMLDocument, attributeS32, S32, 3, 3, "(string attributeName)" + +DefineConsoleMethod(SimXMLDocument, attributeS32, S32, (const char * attributeName), , "(string attributeName)" "@brief Get int attribute from the current Element on the stack.\n\n" "@param attributeName Name of attribute to retrieve.\n" "@return The value of the given attribute in the form of an integer.\n" "@deprecated Use attribute().") { - return dAtoi( object->attribute( argv[2] ) ); + return dAtoi( object->attribute( attributeName ) ); } // ----------------------------------------------------------------------------- diff --git a/Engine/source/console/console.cpp b/Engine/source/console/console.cpp index 689b7a7f3..18d32bed4 100644 --- a/Engine/source/console/console.cpp +++ b/Engine/source/console/console.cpp @@ -275,7 +275,7 @@ bool useTimestamp = false; ConsoleFunctionGroupBegin( Clipboard, "Miscellaneous functions to control the clipboard and clear the console."); -ConsoleFunction( cls, void, 1, 1, "()" +DefineConsoleFunction( cls, void, (), , "()" "@brief Clears the console output.\n\n" "@ingroup Console") { @@ -285,18 +285,18 @@ ConsoleFunction( cls, void, 1, 1, "()" consoleLog.setSize(0); }; -ConsoleFunction( getClipboard, const char*, 1, 1, "()" +DefineConsoleFunction( getClipboard, const char*, (), , "()" "@brief Get text from the clipboard.\n\n" "@internal") { return Platform::getClipboard(); }; -ConsoleFunction( setClipboard, bool, 2, 2, "(string text)" +DefineConsoleFunction( setClipboard, bool, (const char* text), , "(string text)" "@brief Set the system clipboard.\n\n" "@internal") { - return Platform::setClipboard(argv[1]); + return Platform::setClipboard(text); }; ConsoleFunctionGroupEnd( Clipboard ); diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index e761e0aca..a5ea49f33 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -1179,7 +1179,7 @@ static bool isInSet(char c, const char *set) return false; } -ConsoleFunction( nextToken, const char *, 4, 4, "( string str, string token, string delimiters ) " +DefineConsoleFunction( nextToken, const char*, ( const char* str1, const char* token, const char* delim), , "( string str, string token, string delimiters ) " "Tokenize a string using a set of delimiting characters.\n" "This function first skips all leading charaters in @a str that are contained in @a delimiters. " "From that position, it then scans for the next character in @a str that is contained in @a delimiters and stores all characters " @@ -1207,13 +1207,11 @@ ConsoleFunction( nextToken, const char *, 4, 4, "( string str, string token, str "@endtsexample\n\n" "@ingroup Strings" ) { - char buffer[4096]; - dStrncpy(buffer, argv[1], 4096); + char buffer[4096]; + dStrncpy(buffer, str1, 4096); char *str = buffer; - const char *token = argv[2]; - const char *delim = argv[3]; - if( str ) + if( str[0] ) { // skip over any characters that are a member of delim // no need for special '\0' check since it can never be in delim @@ -1242,8 +1240,9 @@ ConsoleFunction( nextToken, const char *, 4, 4, "( string str, string token, str str++; } - char *ret = Con::getReturnBuffer(dStrlen(str)+1); - dStrncpy(ret, str, dStrlen(str)+1); + U32 returnLen = dStrlen(str)+1; + char *ret = Con::getReturnBuffer(returnLen); + dStrncpy(ret, str, returnLen); return ret; } @@ -1289,7 +1288,7 @@ DefineEngineFunction( detag, const char*, ( const char* str ),, return str; } -ConsoleFunction(getTag, const char *, 2, 2, "(string textTagString)" +DefineConsoleFunction( getTag, const char*, ( const char* textTagString ), , "( string textTagString ) " "@brief Extracts the tag from a tagged string\n\n" "Should only be used within the context of a function that receives a tagged " @@ -1303,26 +1302,24 @@ ConsoleFunction(getTag, const char *, 2, 2, "(string textTagString)" "@see detag()\n" "@ingroup Networking") { - TORQUE_UNUSED(argc); - if(argv[1][0] == StringTagPrefixByte) + if(textTagString[0] == StringTagPrefixByte) { - const char *arg = argv[1]; - const char * space = dStrchr(argv[1], ' '); + const char * space = dStrchr(textTagString, ' '); - U32 len; + U64 len; if(space) - len = space - arg; + len = space - textTagString; else - len = dStrlen(arg) + 1; + len = dStrlen(textTagString) + 1; char * ret = Con::getReturnBuffer(len); - dStrncpy(ret, arg + 1, len - 1); + dStrncpy(ret, textTagString + 1, len - 1); ret[len - 1] = 0; return(ret); } else - return(argv[1]); + return(textTagString); } @@ -1512,13 +1509,12 @@ DefineConsoleFunction( quit, void, ( ),, //----------------------------------------------------------------------------- -#ifdef TORQUE_DEMO_PURCHASE -ConsoleFunction( realQuit, void, 1, 1, "" ) + +DefineConsoleFunction( realQuit, void, (), , "") { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); Platform::postQuitMessage(0); } -#endif + //----------------------------------------------------------------------------- @@ -2185,87 +2181,86 @@ DefineEngineFunction( exec, bool, ( const char* fileName, bool noCalls, bool jou return ret; } -ConsoleFunction(eval, const char *, 2, 2, "eval(consoleString)") +DefineConsoleFunction( eval, const char*, ( const char* consoleString ), , "eval(consoleString)" ) { - TORQUE_UNUSED(argc); - return Con::evaluate(argv[1], false, NULL); + return Con::evaluate(consoleString, false, NULL); } -ConsoleFunction(getVariable, const char *, 2, 2, "(string varName)\n" +DefineConsoleFunction( getVariable, const char*, ( const char* varName ), , "(string varName)\n" "@brief Returns the value of the named variable or an empty string if not found.\n\n" "@varName Name of the variable to search for\n" "@return Value contained by varName, \"\" if the variable does not exist\n" "@ingroup Scripting") { - return Con::getVariable(argv[1]); + return Con::getVariable(varName); } -ConsoleFunction(setVariable, void, 3, 3, "(string varName, string value)\n" +DefineConsoleFunction( setVariable, void, ( const char* varName, const char* value ), , "(string varName, string value)\n" "@brief Sets the value of the named variable.\n\n" "@param varName Name of the variable to locate\n" "@param value New value of the variable\n" "@return True if variable was successfully found and set\n" "@ingroup Scripting") { - return Con::setVariable(argv[1], argv[2]); + return Con::setVariable(varName, value); } -ConsoleFunction(isFunction, bool, 2, 2, "(string funcName)" +DefineConsoleFunction( isFunction, bool, ( const char* funcName ), , "(string funcName)" "@brief Determines if a function exists or not\n\n" "@param funcName String containing name of the function\n" "@return True if the function exists, false if not\n" "@ingroup Scripting") { - return Con::isFunction(argv[1]); + return Con::isFunction(funcName); } -ConsoleFunction(getFunctionPackage, const char*, 2, 2, "(string funcName)" +DefineConsoleFunction( getFunctionPackage, const char*, ( const char* funcName ), , "(string funcName)" "@brief Provides the name of the package the function belongs to\n\n" "@param funcName String containing name of the function\n" "@return The name of the function's package\n" "@ingroup Packages") { - Namespace::Entry* nse = Namespace::global()->lookup( StringTable->insert( argv[1] ) ); + Namespace::Entry* nse = Namespace::global()->lookup( StringTable->insert( funcName ) ); if( !nse ) return ""; return nse->mPackage; } -ConsoleFunction(isMethod, bool, 3, 3, "(string namespace, string method)" +DefineConsoleFunction( isMethod, bool, ( const char* nameSpace, const char* method ), , "(string namespace, string method)" "@brief Determines if a class/namespace method exists\n\n" "@param namespace Class or namespace, such as Player\n" "@param method Name of the function to search for\n" "@return True if the method exists, false if not\n" "@ingroup Scripting\n") { - Namespace* ns = Namespace::find( StringTable->insert( argv[1] ) ); - Namespace::Entry* nse = ns->lookup( StringTable->insert( argv[2] ) ); + Namespace* ns = Namespace::find( StringTable->insert( nameSpace ) ); + Namespace::Entry* nse = ns->lookup( StringTable->insert( method ) ); if( !nse ) return false; return true; } -ConsoleFunction(getMethodPackage, const char*, 3, 3, "(string namespace, string method)" +DefineConsoleFunction( getMethodPackage, const char*, ( const char* nameSpace, const char* method ), , "(string namespace, string method)" "@brief Provides the name of the package the method belongs to\n\n" "@param namespace Class or namespace, such as Player\n" "@param method Name of the funciton to search for\n" "@return The name of the method's package\n" "@ingroup Packages") { - Namespace* ns = Namespace::find( StringTable->insert( argv[1] ) ); + Namespace* ns = Namespace::find( StringTable->insert( nameSpace ) ); if( !ns ) return ""; - Namespace::Entry* nse = ns->lookup( StringTable->insert( argv[2] ) ); + Namespace::Entry* nse = ns->lookup( StringTable->insert( method ) ); if( !nse ) return ""; return nse->mPackage; } -ConsoleFunction(isDefined, bool, 2, 3, "(string varName)" +DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varValue ), ("") , "(string varName)" "@brief Determines if a variable exists and contains a value\n" "@param varName Name of the variable to search for\n" "@return True if the variable was defined in script, false if not\n" @@ -2274,13 +2269,13 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)" "@endtsexample\n\n" "@ingroup Scripting") { - if(dStrlen(argv[1]) == 0) + if(dStrIsEmpty(varName)) { Con::errorf("isDefined() - did you forget to put quotes around the variable name?"); return false; } - StringTableEntry name = StringTable->insert(argv[1]); + StringTableEntry name = StringTable->insert(varName); // Deal with . if (dStrchr(name, '.')) @@ -2331,7 +2326,7 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)" if (!value) { - obj->setDataField(valName, 0, argv[2]); + obj->setDataField(valName, 0, varValue); return false; } @@ -2350,8 +2345,10 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)" { if (dStrlen(value) > 0) return true; - else if (argc > 2) - obj->setDataField(valName, 0, argv[2]); + else if (!dStrIsEmpty(varValue)) + { + obj->setDataField(valName, 0, varValue); + } } } } @@ -2365,8 +2362,10 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)" if (ent) return true; - else if (argc > 2) - gEvalState.getCurrentFrame().setVariable(name, argv[2]); + else if (!dStrIsEmpty(varValue)) + { + gEvalState.getCurrentFrame().setVariable(name, varValue); + } } else Con::errorf("%s() - no local variable frame.", __FUNCTION__); @@ -2378,16 +2377,20 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)" if (ent) return true; - else if (argc > 2) - gEvalState.globalVars.setVariable(name, argv[2]); + else if (!dStrIsEmpty(varValue)) + { + gEvalState.globalVars.setVariable(name, varValue); + } } else { // Is it an object? - if (dStrcmp(argv[1], "0") && dStrcmp(argv[1], "") && (Sim::findObject(argv[1]) != NULL)) + if (dStrcmp(varName, "0") && dStrcmp(varName, "") && (Sim::findObject(varName) != NULL)) return true; - else if (argc > 2) - Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, (const char*)argv[1]); + else if (!dStrIsEmpty(varValue)) + { + Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, varValue); + } } return false; @@ -2395,39 +2398,39 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)" //----------------------------------------------------------------------------- -ConsoleFunction( isCurrentScriptToolScript, bool, 1, 1, - "() Returns true if the calling script is a tools script.\n" +DefineConsoleFunction( isCurrentScriptToolScript, bool, (), , "()" + "Returns true if the calling script is a tools script.\n" "@hide") { return Con::isCurrentScriptToolScript(); } -ConsoleFunction(getModNameFromPath, const char *, 2, 2, "(string path)" +DefineConsoleFunction( getModNameFromPath, const char *, ( const char* path ), , "(string path)" "@brief Attempts to extract a mod directory from path. Returns empty string on failure.\n\n" "@param File path of mod folder\n" "@note This is no longer relevant in Torque 3D (which does not use mod folders), should be deprecated\n" "@internal") { - StringTableEntry modPath = Con::getModNameFromPath(argv[1]); + StringTableEntry modPath = Con::getModNameFromPath(path); return modPath ? modPath : ""; } //----------------------------------------------------------------------------- -ConsoleFunction( pushInstantGroup, void, 1, 2, "([group])" +DefineConsoleFunction( pushInstantGroup, void, ( String group ),("") , "([group])" "@brief Pushes the current $instantGroup on a stack " "and sets it to the given value (or clears it).\n\n" "@note Currently only used for editors\n" "@ingroup Editors\n" "@internal") { - if( argc > 1 ) - Con::pushInstantGroup( (const char*)argv[ 1 ] ); + if( group.size() > 0 ) + Con::pushInstantGroup( group ); else Con::pushInstantGroup(); } -ConsoleFunction( popInstantGroup, void, 1, 1, "()" +DefineConsoleFunction( popInstantGroup, void, (), , "()" "@brief Pop and restore the last setting of $instantGroup off the stack.\n\n" "@note Currently only used for editors\n\n" "@ingroup Editors\n" @@ -2438,11 +2441,11 @@ ConsoleFunction( popInstantGroup, void, 1, 1, "()" //----------------------------------------------------------------------------- -ConsoleFunction(getPrefsPath, const char *, 1, 2, "([relativeFileName])" +DefineConsoleFunction( getPrefsPath, const char *, ( const char* relativeFileName ), (""), "([relativeFileName])" "@note Appears to be useless in Torque 3D, should be deprecated\n" "@internal") { - const char *filename = Platform::getPrefsPath(argc > 1 ? (const char*)argv[1] : NULL); + const char *filename = Platform::getPrefsPath(relativeFileName); if(filename == NULL || *filename == 0) return ""; diff --git a/Engine/source/console/consoleLogger.cpp b/Engine/source/console/consoleLogger.cpp index b53833d84..cc0e2afaf 100644 --- a/Engine/source/console/consoleLogger.cpp +++ b/Engine/source/console/consoleLogger.cpp @@ -225,7 +225,7 @@ void ConsoleLogger::log( const char *consoleLine ) //----------------------------------------------------------------------------- -ConsoleMethod( ConsoleLogger, attach, bool, 2, 2, "() Attaches the logger to the console and begins writing to file" +DefineConsoleMethod( ConsoleLogger, attach, bool, (), , "() Attaches the logger to the console and begins writing to file" "@tsexample\n" "// Create the logger\n" "// Will automatically start writing to testLogging.txt with normal priority\n" @@ -247,7 +247,7 @@ ConsoleMethod( ConsoleLogger, attach, bool, 2, 2, "() Attaches the logger to the //----------------------------------------------------------------------------- -ConsoleMethod( ConsoleLogger, detach, bool, 2, 2, "() Detaches the logger from the console and stops writing to file" +DefineConsoleMethod( ConsoleLogger, detach, bool, (), , "() Detaches the logger from the console and stops writing to file" "@tsexample\n" "// Create the logger\n" "// Will automatically start writing to testLogging.txt with normal priority\n" diff --git a/Engine/source/console/consoleXMLExport.cpp b/Engine/source/console/consoleXMLExport.cpp index 1b498a089..953a016cf 100644 --- a/Engine/source/console/consoleXMLExport.cpp +++ b/Engine/source/console/consoleXMLExport.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- #include "console/consoleInternal.h" +#include "console/engineAPI.h" #include "console/consoleObject.h" #include "console/SimXMLDocument.h" @@ -313,7 +314,7 @@ namespace Con { }; // namespace Con -ConsoleFunction(consoleExportXML, const char*, 1, 1, "Exports console definition XML representation") +DefineConsoleFunction( consoleExportXML, const char*, (), ,"Exports console definition XML representation" ) { Con::XMLExport xmlExport; String xml; diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index 13b4e3aa1..c61d2d1af 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -245,6 +245,19 @@ struct EngineUnmarshallData< F32 > } }; template<> +struct EngineUnmarshallData< U8 > +{ + U8 operator()( ConsoleValueRef &ref ) const + { + return (U8)((S32)ref); + } + + U8 operator()( const char* str ) const + { + return dAtoui( str ); + } +}; +template<> struct EngineUnmarshallData< const char* > { const char* operator()( const char* str ) const diff --git a/Engine/source/console/fieldBrushObject.cpp b/Engine/source/console/fieldBrushObject.cpp index 2bc6906eb..3b6f38b25 100644 --- a/Engine/source/console/fieldBrushObject.cpp +++ b/Engine/source/console/fieldBrushObject.cpp @@ -22,6 +22,7 @@ #include "core/strings/stringUnit.h" #include "console/fieldBrushObject.h" +#include "console/engineAPI.h" // Prefix added to dynamic-fields when they're used to store any copied static-fields when peristing. #define INTERNAL_FIELD_PREFIX "_fieldBrush_" @@ -122,12 +123,12 @@ static char* suppressSpaces(const char* in_pname) //----------------------------------------------------------------------------- // Query Groups. //----------------------------------------------------------------------------- -ConsoleMethod(FieldBrushObject, queryGroups, const char*, 3, 3, "(simObject) Query available static-field groups for selected object./\n" +DefineConsoleMethod(FieldBrushObject, queryGroups, const char*, (const char* simObjName), , "(simObject) Query available static-field groups for selected object./\n" "@param simObject Object to query static-field groups on.\n" "@return Space-seperated static-field group list.") { // Fetch selected object. - SimObject* pSimObject = dynamic_cast( Sim::findObject( argv[2] ) ); + SimObject* pSimObject = dynamic_cast( Sim::findObject( simObjName ) ); // Valid object? if ( pSimObject == NULL ) @@ -190,13 +191,13 @@ ConsoleMethod(FieldBrushObject, queryGroups, const char*, 3, 3, "(simObject) Que //----------------------------------------------------------------------------- // Query Fields. //----------------------------------------------------------------------------- -ConsoleMethod(FieldBrushObject, queryFields, const char*, 3, 4, "(simObject, [groupList]) Query available static-fields for selected object./\n" +DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* simObjName, const char* groupList), (""), "(simObject, [groupList]) Query available static-fields for selected object./\n" "@param simObject Object to query static-fields on.\n" "@param groupList groups to filter static-fields against.\n" "@return Space-seperated static-field list.") { // Fetch selected object. - SimObject* pSimObject = dynamic_cast( Sim::findObject( argv[2] ) ); + SimObject* pSimObject = dynamic_cast( Sim::findObject( simObjName ) ); // Valid object? if ( pSimObject == NULL ) @@ -215,7 +216,7 @@ ConsoleMethod(FieldBrushObject, queryFields, const char*, 3, 4, "(simObject, [gr const AbstractClassRep::FieldList& staticFields = pSimObject->getFieldList(); // Did we specify a groups list? - if ( argc < 4 ) + if ( dStrIsEmpty(groupList) ) { // No, so return all fields... @@ -263,7 +264,6 @@ ConsoleMethod(FieldBrushObject, queryFields, const char*, 3, 4, "(simObject, [gr // Group List. Vector groups; // Yes, so fetch group list. - const char* groupList = argv[3]; // Yes, so calculate group Count. const U32 groupCount = StringUnit::getUnitCount( groupList, " \t\n" ); @@ -366,13 +366,13 @@ ConsoleMethod(FieldBrushObject, queryFields, const char*, 3, 4, "(simObject, [gr //----------------------------------------------------------------------------- // Copy Fields. //----------------------------------------------------------------------------- -ConsoleMethod(FieldBrushObject, copyFields, void, 3, 4, "(simObject, [fieldList]) Copy selected static-fields for selected object./\n" +DefineConsoleMethod(FieldBrushObject, copyFields, void, (const char* simObjName, const char* pFieldList), (""), "(simObject, [fieldList]) Copy selected static-fields for selected object./\n" "@param simObject Object to copy static-fields from.\n" "@param fieldList fields to filter static-fields against.\n" "@return No return value.") { // Fetch selected object. - SimObject* pSimObject = dynamic_cast( Sim::findObject( argv[2] ) ); + SimObject* pSimObject = dynamic_cast( Sim::findObject( simObjName ) ); // Valid object? if ( pSimObject == NULL ) @@ -383,7 +383,6 @@ ConsoleMethod(FieldBrushObject, copyFields, void, 3, 4, "(simObject, [fieldList] } // Fetch field list. - const char* pFieldList = (argc > 3 ) ? (const char*)argv[3] : NULL; // Copy Fields. object->copyFields( pSimObject, pFieldList ); @@ -501,12 +500,12 @@ void FieldBrushObject::copyFields( SimObject* pSimObject, const char* fieldList //----------------------------------------------------------------------------- // Paste Fields. //----------------------------------------------------------------------------- -ConsoleMethod(FieldBrushObject, pasteFields, void, 3, 3, "(simObject) Paste copied static-fields to selected object./\n" +DefineConsoleMethod(FieldBrushObject, pasteFields, void, (const char* simObjName), , "(simObject) Paste copied static-fields to selected object./\n" "@param simObject Object to paste static-fields to.\n" "@return No return value.") { // Fetch selected object. - SimObject* pSimObject = dynamic_cast( Sim::findObject( argv[2] ) ); + SimObject* pSimObject = dynamic_cast( Sim::findObject( simObjName ) ); // Valid object? if ( pSimObject == NULL ) diff --git a/Engine/source/console/persistenceManager.cpp b/Engine/source/console/persistenceManager.cpp index 23dcd754e..322626801 100644 --- a/Engine/source/console/persistenceManager.cpp +++ b/Engine/source/console/persistenceManager.cpp @@ -23,6 +23,7 @@ #include "persistenceManager.h" #include "console/simSet.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "core/stream/fileStream.h" #include "gui/core/guiTypes.h" #include "materials/customMaterialDefinition.h" @@ -2189,52 +2190,51 @@ void PersistenceManager::deleteObjectsFromFile(const char* fileName) clearAll(); } -ConsoleMethod( PersistenceManager, deleteObjectsFromFile, void, 3, 3, "( fileName )" +DefineConsoleMethod( PersistenceManager, deleteObjectsFromFile, void, ( const char * fileName ), , "( fileName )" "Delete all of the objects that are created from the given file." ) { // Delete Objects. - object->deleteObjectsFromFile( argv[2] ); + object->deleteObjectsFromFile( fileName ); } -ConsoleMethod( PersistenceManager, setDirty, void, 3, 4, "(SimObject object, [filename])" +DefineConsoleMethod( PersistenceManager, setDirty, void, ( const char * objName, const char * fileName ), (""), "(SimObject object, [filename])" "Mark an existing SimObject as dirty (will be written out when saveDirty() is called).") { SimObject *dirtyObject = NULL; - if (argv[2][0]) + if (dStrcmp(objName,"") != 0) { - if (!Sim::findObject(argv[2], dirtyObject)) + if (!Sim::findObject(objName, dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); + Con::printf("PersistenceManager::setDirty(): Invalid SimObject: %s", objName); return; } } // Prevent ourselves from shooting us in the foot. - if( dirtyObject == Sim::getRootGroup() ) { - Con::errorf( "%s(): Cannot save RootGroup", (const char*)argv[ 0 ] ); + Con::errorf( "PersistenceManager::setDirty(): Cannot save RootGroup" ); return; } if (dirtyObject) { - if (argc == 4 && argv[3][0]) - object->setDirty(dirtyObject, argv[3]); + if (dStrcmp( fileName,"")!=0) + object->setDirty(dirtyObject, fileName); else object->setDirty(dirtyObject); } } -ConsoleMethod( PersistenceManager, removeDirty, void, 3, 3, "(SimObject object)" +DefineConsoleMethod( PersistenceManager, removeDirty, void, ( const char * objName ), , "(SimObject object)" "Remove a SimObject from the dirty list.") { SimObject *dirtyObject = NULL; - if (argv[2][0]) + if (dStrcmp( objName,"")!=0) { - if (!Sim::findObject(argv[2], dirtyObject)) + if (!Sim::findObject(objName, dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); + Con::printf("PersistenceManager::removeDirty(): Invalid SimObject: %s", objName); return; } } @@ -2243,15 +2243,15 @@ ConsoleMethod( PersistenceManager, removeDirty, void, 3, 3, "(SimObject object)" object->removeDirty(dirtyObject); } -ConsoleMethod( PersistenceManager, isDirty, bool, 3, 3, "(SimObject object)" +DefineConsoleMethod( PersistenceManager, isDirty, bool, ( const char * objName ), , "(SimObject object)" "Returns true if the SimObject is on the dirty list.") { SimObject *dirtyObject = NULL; - if (argv[2][0]) + if (dStrcmp ( objName,"")!=0) { - if (!Sim::findObject(argv[2], dirtyObject)) + if (!Sim::findObject(objName, dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); + Con::printf("PersistenceManager::isDirty(): Invalid SimObject: %s", objName); return false; } } @@ -2262,25 +2262,24 @@ ConsoleMethod( PersistenceManager, isDirty, bool, 3, 3, "(SimObject object)" return false; } -ConsoleMethod( PersistenceManager, hasDirty, bool, 2, 2, "()" +DefineConsoleMethod( PersistenceManager, hasDirty, bool, (), , "()" "Returns true if the manager has dirty objects to save." ) { return object->hasDirty(); } -ConsoleMethod( PersistenceManager, getDirtyObjectCount, S32, 2, 2, "()" +DefineConsoleMethod( PersistenceManager, getDirtyObjectCount, S32, (), , "()" "Returns the number of dirty objects." ) { return object->getDirtyList().size(); } -ConsoleMethod( PersistenceManager, getDirtyObject, S32, 3, 3, "( index )" +DefineConsoleMethod( PersistenceManager, getDirtyObject, S32, (S32 index), , "( index )" "Returns the ith dirty object." ) { - const S32 index = dAtoi( argv[2] ); if ( index < 0 || index >= object->getDirtyList().size() ) { - Con::warnf( "PersistenceManager::getDirtyObject() - Index (%s) out of range.", (const char*)argv[2] ); + Con::warnf( "PersistenceManager::getDirtyObject() - Index (%s) out of range.", index ); return 0; } @@ -2291,7 +2290,7 @@ ConsoleMethod( PersistenceManager, getDirtyObject, S32, 3, 3, "( index )" return ( dirtyObject.getObject() ) ? dirtyObject.getObject()->getId() : 0; } -ConsoleMethod( PersistenceManager, listDirty, void, 2, 2, "()" +DefineConsoleMethod( PersistenceManager, listDirty, void, (), , "()" "Prints the dirty list to the console.") { const PersistenceManager::DirtyList dirtyList = object->getDirtyList(); @@ -2319,21 +2318,21 @@ ConsoleMethod( PersistenceManager, listDirty, void, 2, 2, "()" } } -ConsoleMethod( PersistenceManager, saveDirty, bool, 2, 2, "()" +DefineConsoleMethod( PersistenceManager, saveDirty, bool, (), , "()" "Saves all of the SimObject's on the dirty list to their respective files.") { return object->saveDirty(); } -ConsoleMethod( PersistenceManager, saveDirtyObject, bool, 3, 3, "(SimObject object)" +DefineConsoleMethod( PersistenceManager, saveDirtyObject, bool, (const char * objName), , "(SimObject object)" "Save a dirty SimObject to it's file.") { SimObject *dirtyObject = NULL; - if (argv[2][0]) + if (dStrcmp ( objName, "")!=0) { - if (!Sim::findObject(argv[2], dirtyObject)) + if (!Sim::findObject(objName, dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); + Con::printf("%s(): Invalid SimObject: %s", object->getName(), objName); return false; } } @@ -2343,51 +2342,51 @@ ConsoleMethod( PersistenceManager, saveDirtyObject, bool, 3, 3, "(SimObject obje return false; } -ConsoleMethod( PersistenceManager, clearAll, void, 2, 2, "()" +DefineConsoleMethod( PersistenceManager, clearAll, void, (), , "()" "Clears all the tracked objects without saving them." ) { object->clearAll(); } -ConsoleMethod( PersistenceManager, removeObjectFromFile, void, 3, 4, "(SimObject object, [filename])" +DefineConsoleMethod( PersistenceManager, removeObjectFromFile, void, (const char * objName, const char * filename),("") , "(SimObject object, [filename])" "Remove an existing SimObject from a file (can optionally specify a different file than \ the one it was created in.") { SimObject *dirtyObject = NULL; - if (argv[2][0]) + if (dStrcmp ( objName , "")!=0) { - if (!Sim::findObject(argv[2], dirtyObject)) + if (!Sim::findObject(objName, dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); + Con::printf("PersistenceManager::removeObjectFromFile(): Invalid SimObject: %s", objName); return; } } if (dirtyObject) { - if (argc == 4 && argv[3][0]) - object->removeObjectFromFile(dirtyObject, argv[3]); + if (dStrcmp( filename,"")!=0) + object->removeObjectFromFile(dirtyObject, filename); else object->removeObjectFromFile(dirtyObject); } } -ConsoleMethod( PersistenceManager, removeField, void, 4, 4, "(SimObject object, string fieldName)" +DefineConsoleMethod( PersistenceManager, removeField, void, (const char * objName, const char * fieldName), , "(SimObject object, string fieldName)" "Remove a specific field from an object declaration.") { SimObject *dirtyObject = NULL; - if (argv[2][0]) + if (dStrcmp(objName,"")!=0) { - if (!Sim::findObject(argv[2], dirtyObject)) + if (!Sim::findObject(objName, dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); + Con::printf("PersistenceManager::removeField(): Invalid SimObject: %s", objName); return; } } if (dirtyObject) { - if (argv[3][0]) - object->addRemoveField(dirtyObject, argv[3]); + if (dStrcmp(fieldName,"") != 0) + object->addRemoveField(dirtyObject, fieldName); } } diff --git a/Engine/source/console/sim.cpp b/Engine/source/console/sim.cpp index 918a69b79..e0465050f 100644 --- a/Engine/source/console/sim.cpp +++ b/Engine/source/console/sim.cpp @@ -21,7 +21,7 @@ //----------------------------------------------------------------------------- #include "console/console.h" - +#include "console/engineAPI.h" #include "console/sim.h" #include "console/simEvents.h" #include "console/simObject.h" @@ -86,23 +86,21 @@ namespace Sim ConsoleFunctionGroupBegin ( SimFunctions, "Functions relating to Sim."); -ConsoleFunction(nameToID, S32, 2, 2, "nameToID(object)") +DefineConsoleFunction( nameToID, S32, (const char * objectName), ,"nameToID(object)") { - TORQUE_UNUSED(argc); - SimObject *obj = Sim::findObject(argv[1]); + SimObject *obj = Sim::findObject(objectName); if(obj) return obj->getId(); else return -1; } -ConsoleFunction(isObject, bool, 2, 2, "isObject(object)") +DefineConsoleFunction( isObject, bool, (const char * objectName), ,"isObject(object)") { - TORQUE_UNUSED(argc); - if (!dStrcmp(argv[1], "0") || !dStrcmp(argv[1], "")) + if (!dStrcmp(objectName, "0") || !dStrcmp(objectName, "")) return false; else - return (Sim::findObject(argv[1]) != NULL); + return (Sim::findObject(objectName) != NULL); } ConsoleDocFragment _spawnObject1( @@ -135,24 +133,14 @@ ConsoleDocFragment _spawnObject1( "bool spawnObject(class [, dataBlock, name, properties, script]);" ); -ConsoleFunction(spawnObject, S32, 3, 6, "spawnObject(class [, dataBlock, name, properties, script])" +DefineConsoleFunction( spawnObject, S32, ( const char * spawnClass + , const char * spawnDataBlock + , const char * spawnName + , const char * spawnProperties + , const char * spawnScript + ),("","","","") ,"spawnObject(class [, dataBlock, name, properties, script])" "@hide") { - String spawnClass((const char*)argv[1]); - String spawnDataBlock; - String spawnName; - String spawnProperties; - String spawnScript; - - if (argc >= 3) - spawnDataBlock = (const char*)argv[2]; - if (argc >= 4) - spawnName = (const char*)argv[3]; - if (argc >= 5) - spawnProperties = (const char*)argv[4]; - if (argc >= 6) - spawnScript = (const char*)argv[5]; - SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript); if (spawnObject) @@ -161,35 +149,35 @@ ConsoleFunction(spawnObject, S32, 3, 6, "spawnObject(class [, dataBlock, name, p return -1; } -ConsoleFunction(cancel,void,2,2,"cancel(eventId)") +DefineConsoleFunction( cancel, void, (S32 eventId), ,"cancel(eventId)") { - Sim::cancelEvent(dAtoi(argv[1])); + Sim::cancelEvent(eventId); } -ConsoleFunction(cancelAll,void,2,2,"cancelAll(objectId): cancel pending events on the specified object. Events will be automatically cancelled if object is deleted.") +DefineConsoleFunction( cancelAll, void, (const char * objectId), ,"cancelAll(objectId): cancel pending events on the specified object. Events will be automatically cancelled if object is deleted.") { - Sim::cancelPendingEvents(Sim::findObject(argv[1])); + Sim::cancelPendingEvents(Sim::findObject(objectId)); } -ConsoleFunction(isEventPending, bool, 2, 2, "isEventPending(%scheduleId);") +DefineConsoleFunction( isEventPending, bool, (S32 scheduleId), ,"isEventPending(%scheduleId);") { - return Sim::isEventPending(dAtoi(argv[1])); + return Sim::isEventPending(scheduleId); } -ConsoleFunction(getEventTimeLeft, S32, 2, 2, "getEventTimeLeft(scheduleId) Get the time left in ms until this event will trigger.") +DefineConsoleFunction( getEventTimeLeft, S32, (S32 scheduleId), ,"getEventTimeLeft(scheduleId) Get the time left in ms until this event will trigger.") { - return Sim::getEventTimeLeft(dAtoi(argv[1])); + return Sim::getEventTimeLeft(scheduleId); } -ConsoleFunction(getScheduleDuration, S32, 2, 2, "getScheduleDuration(%scheduleId);") +DefineConsoleFunction( getScheduleDuration, S32, (S32 scheduleId), ,"getScheduleDuration(%scheduleId);" ) { - TORQUE_UNUSED(argc); S32 ret = Sim::getScheduleDuration(dAtoi(argv[1])); + S32 ret = Sim::getScheduleDuration(scheduleId); return ret; } -ConsoleFunction(getTimeSinceStart, S32, 2, 2, "getTimeSinceStart(%scheduleId);") +DefineConsoleFunction( getTimeSinceStart, S32, (S32 scheduleId), ,"getTimeSinceStart(%scheduleId);" ) { - TORQUE_UNUSED(argc); S32 ret = Sim::getTimeSinceStart(dAtoi(argv[1])); + S32 ret = Sim::getTimeSinceStart(scheduleId); return ret; } @@ -214,7 +202,7 @@ ConsoleFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, resolvePIDs(); } diff --git a/Engine/source/console/simSet.cpp b/Engine/source/console/simSet.cpp index d03f10248..f1f77ee4f 100644 --- a/Engine/source/console/simSet.cpp +++ b/Engine/source/console/simSet.cpp @@ -25,6 +25,7 @@ #include "core/stringTable.h" #include "console/console.h" +#include "console/engineAPI.h" #include "core/stream/fileStream.h" #include "sim/actionMap.h" #include "core/fileObject.h" @@ -950,7 +951,7 @@ DefineEngineMethod( SimSet, clear, void, (),, //----------------------------------------------------------------------------- //UNSAFE; don't want this in the new API -ConsoleMethod( SimSet, deleteAllObjects, void, 2, 2, "() Delete all objects in the set." ) +DefineConsoleMethod( SimSet, deleteAllObjects, void, (), , "() Delete all objects in the set." ) { object->deleteAllObjects(); } @@ -1022,7 +1023,7 @@ DEFINE_CALLIN( fnSimSet_getCountRecursive, getCountRecursive, SimSet, U32, ( Sim return set->sizeRecursive(); } -ConsoleMethod( SimSet, getFullCount, S32, 2, 2, "() Get the number of direct and indirect child objects contained in the set.\n" +DefineConsoleMethod( SimSet, getFullCount, S32, (), , "() Get the number of direct and indirect child objects contained in the set.\n" "@return The number of objects contained in the set as well as in other sets contained directly or indirectly in the set." ) { return object->sizeRecursive(); @@ -1118,10 +1119,10 @@ DefineEngineMethod( SimSet, pushToBack, void, ( SimObject* obj ),, //----------------------------------------------------------------------------- -ConsoleMethod( SimSet, sort, void, 3, 3, "( string callbackFunction ) Sort the objects in the set using the given comparison function.\n" +DefineConsoleMethod( SimSet, sort, void, ( const char * callbackFunction ), , "( string callbackFunction ) Sort the objects in the set using the given comparison function.\n" "@param callbackFunction Name of a function that takes two object arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal." ) { - object->scriptSort( (const char*)argv[2] ); + object->scriptSort( callbackFunction ); } //----------------------------------------------------------------------------- diff --git a/Engine/source/console/telnetDebugger.cpp b/Engine/source/console/telnetDebugger.cpp index 06b758d9a..914dee776 100644 --- a/Engine/source/console/telnetDebugger.cpp +++ b/Engine/source/console/telnetDebugger.cpp @@ -25,6 +25,7 @@ #include "core/frameAllocator.h" #include "console/console.h" +#include "console/engineAPI.h" #include "core/stringTable.h" #include "console/consoleInternal.h" #include "console/ast.h" @@ -112,24 +113,25 @@ MODULE_END; // BRKCLR file line - sent when a breakpoint cannot be moved to a breakable line on the client. // - -ConsoleFunction( dbgSetParameters, void, 3, 4, "(int port, string password, bool waitForClient)" +DefineConsoleFunction( dbgSetParameters, void, (S32 port, const char * password, bool waitForClient ), (false), "( int port, string password, bool waitForClient )" "Open a debug server port on the specified port, requiring the specified password, " "and optionally waiting for the debug client to connect.\n" "@internal Primarily used for Torsion and other debugging tools") { if (TelDebugger) - TelDebugger->setDebugParameters(dAtoi(argv[1]), argv[2], argc > 3 ? dAtob(argv[3]) : false ); + { + TelDebugger->setDebugParameters(port, password, waitForClient ); + } } -ConsoleFunction( dbgIsConnected, bool, 1, 1, "()" +DefineConsoleFunction( dbgIsConnected, bool, (), , "()" "Returns true if a script debugging client is connected else return false.\n" "@internal Primarily used for Torsion and other debugging tools") { return TelDebugger && TelDebugger->isConnected(); } -ConsoleFunction( dbgDisconnect, void, 1, 1, "()" +DefineConsoleFunction( dbgDisconnect, void, (), , "()" "Forcibly disconnects any attached script debugging client.\n" "@internal Primarily used for Torsion and other debugging tools") { diff --git a/Engine/source/core/dnet.cpp b/Engine/source/core/dnet.cpp index 324a9fcfd..ea32c4cb5 100644 --- a/Engine/source/core/dnet.cpp +++ b/Engine/source/core/dnet.cpp @@ -25,6 +25,7 @@ #include "core/strings/stringFunctions.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" bool gLogToConsole = false; @@ -49,14 +50,13 @@ static const char *packetTypeNames[] = //----------------------------------------------------------------- //----------------------------------------------------------------- //----------------------------------------------------------------- -ConsoleFunction(DNetSetLogging, void, 2, 2, "(bool enabled)" +DefineConsoleFunction( DNetSetLogging, void, (bool enabled), , "(bool enabled)" "@brief Enables logging of the connection protocols\n\n" "When enabled a lot of network debugging information is sent to the console.\n" "@param enabled True to enable, false to disable\n" "@ingroup Networking") { - TORQUE_UNUSED(argc); - gLogToConsole = dAtob(argv[1]); + gLogToConsole = enabled; } ConnectionProtocol::ConnectionProtocol() diff --git a/Engine/source/core/fileObject.cpp b/Engine/source/core/fileObject.cpp index ee212fade..e872d7838 100644 --- a/Engine/source/core/fileObject.cpp +++ b/Engine/source/core/fileObject.cpp @@ -484,19 +484,17 @@ static ConsoleDocFragment _FileObjectwriteObject2( "FileObject", "void writeObject( SimObject* object, string prepend);"); -ConsoleMethod( FileObject, writeObject, void, 3, 4, "FileObject.writeObject(SimObject, object prepend)" +DefineConsoleMethod( FileObject, writeObject, void, (const char * simName, const char * objName), (""), "FileObject.writeObject(SimObject, object prepend)" "@hide") { - SimObject* obj = Sim::findObject( argv[2] ); + SimObject* obj = Sim::findObject( simName ); if( !obj ) { Con::printf("FileObject::writeObject - Invalid Object!"); return; } - - const char *objName = NULL; - if( argc == 4 ) - objName = (const char*)argv[3]; + if (!dStrcmp(objName,"")) + objName = NULL; object->writeObject( obj, (const U8*)objName ); } diff --git a/Engine/source/core/resourceManager.cpp b/Engine/source/core/resourceManager.cpp index c52891bf9..09b889f95 100644 --- a/Engine/source/core/resourceManager.cpp +++ b/Engine/source/core/resourceManager.cpp @@ -221,16 +221,18 @@ ResourceBase ResourceManager::nextResource() ConsoleFunctionGroupBegin(ResourceManagerFunctions, "Resource management functions."); -#ifdef TORQUE_DEBUG + ConsoleFunction(resourceDump, void, 1, 1, "()" "@brief List the currently managed resources\n\n" "Currently used by editors only, internal\n" "@ingroup Editors\n" "@internal") { +#ifdef TORQUE_DEBUG ResourceManager::get().dumpToConsole(); -} #endif +} + DefineEngineFunction( reloadResource, void, ( const char* path ),, "Force the resource at specified input path to be reloaded\n" diff --git a/Engine/source/core/stringBuffer.cpp b/Engine/source/core/stringBuffer.cpp index fd16d159b..ae95fc060 100644 --- a/Engine/source/core/stringBuffer.cpp +++ b/Engine/source/core/stringBuffer.cpp @@ -24,6 +24,7 @@ #include "core/frameAllocator.h" #include "core/strings/unicode.h" #include "core/strings/stringFunctions.h" +#include "console/engineAPI.h" #if defined(TORQUE_DEBUG) @@ -47,12 +48,12 @@ void dumpAllStrings(); }; - ConsoleFunction(sbmDumpStats, void, 1, 1, "") + DefineConsoleFunction( sbmDumpStats, void, (), , "()") { StringBufferManager::getManager().dumpStats(); } - ConsoleFunction(sbmDumpStrings, void, 1, 1, "") + DefineConsoleFunction( sbmDumpStrings, void, (), , "()") { StringBufferManager::getManager().dumpAllStrings(); } diff --git a/Engine/source/core/strings/stringFunctions.h b/Engine/source/core/strings/stringFunctions.h index 92602fd21..b8d98676a 100644 --- a/Engine/source/core/strings/stringFunctions.h +++ b/Engine/source/core/strings/stringFunctions.h @@ -59,6 +59,11 @@ inline S32 dStrcmp(const char *str1, const char *str2) return strcmp(str1, str2); } +inline bool dStrIsEmpty(const char *src) +{ + return src == 0 || src[0] == '\0'; +} + inline S32 dStrncmp(const char *str1, const char *str2, dsize_t len) { return strncmp(str1, str2, len); diff --git a/Engine/source/core/util/str.cpp b/Engine/source/core/util/str.cpp index 36b0637de..d8d787fb0 100644 --- a/Engine/source/core/util/str.cpp +++ b/Engine/source/core/util/str.cpp @@ -42,6 +42,7 @@ namespace KeyCmp #include "core/util/tVector.h" #include "core/dataChunker.h" #include "console/console.h" +#include "console/engineAPI.h" #include "math/mMathFn.h" @@ -476,15 +477,18 @@ static U32 sgStringMemBytes; /// Tracks the number of Strings which are currently instantiated. static U32 sgStringInstances; -ConsoleFunction( dumpStringMemStats, void, 1, 1, "()" + + +#endif +DefineConsoleFunction( dumpStringMemStats, void, (), , "()" "@brief Dumps information about String memory usage\n\n" "@ingroup Debugging\n" "@ingroup Strings\n") { +#ifdef TORQUE_DEBUG Con::printf( "String Data: %i instances, %i bytes", sgStringInstances, sgStringMemBytes ); -} - #endif +} //----------------------------------------------------------------------------- diff --git a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp index 9c3085877..10fdbe115 100644 --- a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp @@ -24,6 +24,7 @@ #include "environment/editors/guiMeshRoadEditorCtrl.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "environment/meshRoad.h" #include "renderInstance/renderPassManager.h" #include "collision/collision.h" @@ -1185,125 +1186,95 @@ void GuiMeshRoadEditorCtrl::matchTerrainToRoad() // with the terrain underneath it. } -ConsoleMethod( GuiMeshRoadEditorCtrl, deleteNode, void, 2, 2, "deleteNode()" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, deleteNode, void, (), , "deleteNode()" ) { object->deleteSelectedNode(); } -ConsoleMethod( GuiMeshRoadEditorCtrl, getMode, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, getMode, const char*, (), , "" ) { return object->getMode(); } -ConsoleMethod( GuiMeshRoadEditorCtrl, setMode, void, 3, 3, "setMode( String mode )" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, setMode, void, (const char * mode), , "setMode( String mode )" ) { - String newMode = ( argv[2] ); + String newMode = ( mode ); object->setMode( newMode ); } -ConsoleMethod( GuiMeshRoadEditorCtrl, getNodeWidth, F32, 2, 2, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeWidth, F32, (), , "" ) { return object->getNodeWidth(); } -ConsoleMethod( GuiMeshRoadEditorCtrl, setNodeWidth, void, 3, 3, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeWidth, void, ( F32 width ), , "" ) { - object->setNodeWidth( dAtof(argv[2]) ); + object->setNodeWidth( width ); } -ConsoleMethod( GuiMeshRoadEditorCtrl, getNodeDepth, F32, 2, 2, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeDepth, F32, (), , "" ) { return object->getNodeDepth(); } -ConsoleMethod( GuiMeshRoadEditorCtrl, setNodeDepth, void, 3, 3, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeDepth, void, ( F32 depth ), , "" ) { - object->setNodeDepth( dAtof(argv[2]) ); + object->setNodeDepth( depth ); } -ConsoleMethod( GuiMeshRoadEditorCtrl, getNodePosition, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodePosition, Point3F, (), , "" ) { - static const U32 bufSize = 256; - char* returnBuffer = Con::getReturnBuffer(bufSize); - dSprintf(returnBuffer, bufSize, "%f %f %f", - object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z); - - return returnBuffer; + return object->getNodePosition(); } -ConsoleMethod( GuiMeshRoadEditorCtrl, setNodePosition, void, 3, 3, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodePosition, void, (Point3F pos), , "" ) { - Point3F pos; - - S32 count = dSscanf( argv[2], "%f %f %f", - &pos.x, &pos.y, &pos.z); - - if ( (count != 3) ) - { - Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]); - return; - } object->setNodePosition( pos ); } -ConsoleMethod( GuiMeshRoadEditorCtrl, getNodeNormal, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeNormal, Point3F, (), , "" ) { - static const U32 bufSize = 256; - char* returnBuffer = Con::getReturnBuffer(bufSize); - dSprintf(returnBuffer, bufSize, "%f %f %f", - object->getNodeNormal().x, object->getNodeNormal().y, object->getNodeNormal().z); - - return returnBuffer; + return object->getNodeNormal(); } -ConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, 3, 3, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, (Point3F normal), , "" ) { - VectorF normal; - - S32 count = dSscanf( argv[2], "%f %f %f", - &normal.x, &normal.y, &normal.z); - - if ( (count != 3) ) - { - Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]); - return; - } object->setNodeNormal( normal ); } -ConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, 2, 3, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, (const char * objName), (""), "" ) { - if ( argc == 2 ) + if ( dStrIsEmpty(objName) ) object->setSelectedRoad(NULL); else { MeshRoad *road = NULL; - if ( Sim::findObject( argv[2], road ) ) + if ( Sim::findObject( objName, road ) ) object->setSelectedRoad(road); } } -ConsoleMethod( GuiMeshRoadEditorCtrl, getSelectedRoad, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, getSelectedRoad, S32, (), , "" ) { MeshRoad *road = object->getSelectedRoad(); if ( !road ) return NULL; - return road->getIdString(); + return road->getId(); } -ConsoleMethod( GuiMeshRoadEditorCtrl, regenerate, void, 2, 2, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, regenerate, void, (), , "" ) { MeshRoad *road = object->getSelectedRoad(); if ( road ) road->regenerate(); } -ConsoleMethod( GuiMeshRoadEditorCtrl, matchTerrainToRoad, void, 2, 2, "" ) +DefineConsoleMethod( GuiMeshRoadEditorCtrl, matchTerrainToRoad, void, (), , "" ) { object->matchTerrainToRoad(); } diff --git a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp index a61f15099..44f161232 100644 --- a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp @@ -24,6 +24,7 @@ #include "environment/editors/guiRiverEditorCtrl.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "environment/river.h" #include "renderInstance/renderPassManager.h" #include "collision/collision.h" @@ -1392,118 +1393,87 @@ void GuiRiverEditorCtrl::_renderSelectedRiver( ObjectRenderInst *ri, SceneRender } } -ConsoleMethod( GuiRiverEditorCtrl, deleteNode, void, 2, 2, "deleteNode()" ) +DefineConsoleMethod( GuiRiverEditorCtrl, deleteNode, void, (), , "deleteNode()" ) { object->deleteSelectedNode(); } -ConsoleMethod( GuiRiverEditorCtrl, getMode, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, getMode, const char*, (), , "" ) { return object->getMode(); } -ConsoleMethod( GuiRiverEditorCtrl, setMode, void, 3, 3, "setMode( String mode )" ) +DefineConsoleMethod( GuiRiverEditorCtrl, setMode, void, ( const char * mode ), , "setMode( String mode )" ) { - String newMode = ( argv[2] ); + String newMode = ( mode ); object->setMode( newMode ); } -ConsoleMethod( GuiRiverEditorCtrl, getNodeWidth, F32, 2, 2, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, getNodeWidth, F32, (), , "" ) { return object->getNodeWidth(); } -ConsoleMethod( GuiRiverEditorCtrl, setNodeWidth, void, 3, 3, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, setNodeWidth, void, ( F32 width ), , "" ) { - object->setNodeWidth( dAtof(argv[2]) ); + object->setNodeWidth( width ); } -ConsoleMethod( GuiRiverEditorCtrl, getNodeDepth, F32, 2, 2, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, getNodeDepth, F32, (), , "" ) { return object->getNodeDepth(); } -ConsoleMethod( GuiRiverEditorCtrl, setNodeDepth, void, 3, 3, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, setNodeDepth, void, ( F32 depth ), , "" ) { - object->setNodeDepth( dAtof(argv[2]) ); + object->setNodeDepth( depth ); } -ConsoleMethod( GuiRiverEditorCtrl, getNodePosition, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, getNodePosition, Point3F, (), , "" ) { - static const U32 bufSize = 256; - char* returnBuffer = Con::getReturnBuffer(bufSize); - dSprintf(returnBuffer, bufSize, "%f %f %f", - object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z); - - return returnBuffer; + return object->getNodePosition(); } -ConsoleMethod( GuiRiverEditorCtrl, setNodePosition, void, 3, 3, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, setNodePosition, void, (Point3F pos), , "" ) { - Point3F pos; - - S32 count = dSscanf( argv[2], "%f %f %f", - &pos.x, &pos.y, &pos.z); - - if ( (count != 3) ) - { - Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]); - return; - } - object->setNodePosition( pos ); } -ConsoleMethod( GuiRiverEditorCtrl, getNodeNormal, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, getNodeNormal, Point3F, (), , "" ) { - static const U32 bufSize = 256; - char* returnBuffer = Con::getReturnBuffer(bufSize); - dSprintf(returnBuffer, bufSize, "%f %f %f", - object->getNodeNormal().x, object->getNodeNormal().y, object->getNodeNormal().z); - - return returnBuffer; + return object->getNodeNormal(); } -ConsoleMethod( GuiRiverEditorCtrl, setNodeNormal, void, 3, 3, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, setNodeNormal, void, (Point3F normal), , "" ) { - VectorF normal; - - S32 count = dSscanf( argv[2], "%f %f %f", - &normal.x, &normal.y, &normal.z); - - if ( (count != 3) ) - { - Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]); - return; - } object->setNodeNormal( normal ); } -ConsoleMethod( GuiRiverEditorCtrl, setSelectedRiver, void, 2, 3, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, setSelectedRiver, void, (const char * objName), (""), "" ) { - if ( argc == 2 ) + if (dStrcmp( objName,"" )==0) object->setSelectedRiver(NULL); else { River *river = NULL; - if ( Sim::findObject( argv[2], river ) ) + if ( Sim::findObject( objName, river ) ) object->setSelectedRiver(river); } } -ConsoleMethod( GuiRiverEditorCtrl, getSelectedRiver, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, getSelectedRiver, S32, (), , "" ) { River *river = object->getSelectedRiver(); if ( !river ) return NULL; - return river->getIdString(); + return river->getId(); } -ConsoleMethod( GuiRiverEditorCtrl, regenerate, void, 2, 2, "" ) +DefineConsoleMethod( GuiRiverEditorCtrl, regenerate, void, (), , "" ) { River *river = object->getSelectedRiver(); if ( river ) diff --git a/Engine/source/environment/editors/guiRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiRoadEditorCtrl.cpp index 3ec502e82..1eecfb5ae 100644 --- a/Engine/source/environment/editors/guiRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRoadEditorCtrl.cpp @@ -24,6 +24,7 @@ #include "environment/editors/guiRoadEditorCtrl.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "scene/sceneManager.h" #include "collision/collision.h" #include "math/util/frustum.h" @@ -1036,86 +1037,71 @@ void GuiRoadEditorCtrl::submitUndo( const UTF8 *name ) undoMan->addAction( action ); } -ConsoleMethod( GuiRoadEditorCtrl, deleteNode, void, 2, 2, "deleteNode()" ) +DefineConsoleMethod( GuiRoadEditorCtrl, deleteNode, void, (), , "deleteNode()" ) { object->deleteSelectedNode(); } -ConsoleMethod( GuiRoadEditorCtrl, getMode, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, getMode, const char*, (), , "" ) { return object->getMode(); } -ConsoleMethod( GuiRoadEditorCtrl, setMode, void, 3, 3, "setMode( String mode )" ) +DefineConsoleMethod( GuiRoadEditorCtrl, setMode, void, ( const char * mode ), , "setMode( String mode )" ) { - String newMode = ( argv[2] ); + String newMode = ( mode ); object->setMode( newMode ); } -ConsoleMethod( GuiRoadEditorCtrl, getNodeWidth, F32, 2, 2, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, getNodeWidth, F32, (), , "" ) { return object->getNodeWidth(); } -ConsoleMethod( GuiRoadEditorCtrl, setNodeWidth, void, 3, 3, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, setNodeWidth, void, ( F32 width ), , "" ) { - object->setNodeWidth( dAtof(argv[2]) ); + object->setNodeWidth( width ); } -ConsoleMethod( GuiRoadEditorCtrl, getNodePosition, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, getNodePosition, Point3F, (), , "" ) { - static const U32 bufSize = 256; - char* returnBuffer = Con::getReturnBuffer(bufSize); - dSprintf(returnBuffer, bufSize, "%f %f %f", - object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z); - - return returnBuffer; + return object->getNodePosition(); } -ConsoleMethod( GuiRoadEditorCtrl, setNodePosition, void, 3, 3, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, setNodePosition, void, ( Point3F pos ), , "" ) { - Point3F pos; - - S32 count = dSscanf( argv[2], "%f %f %f", - &pos.x, &pos.y, &pos.z); - - if ( (count != 3) ) - { - Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]); - return; - } object->setNodePosition( pos ); } -ConsoleMethod( GuiRoadEditorCtrl, setSelectedRoad, void, 2, 3, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, setSelectedRoad, void, ( const char * pathRoad ), (""), "" ) { - if ( argc == 2 ) + if (dStrcmp( pathRoad,"")==0 ) object->setSelectedRoad(NULL); else { DecalRoad *road = NULL; - if ( Sim::findObject( argv[2], road ) ) + if ( Sim::findObject( pathRoad, road ) ) object->setSelectedRoad(road); } } -ConsoleMethod( GuiRoadEditorCtrl, getSelectedRoad, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, getSelectedRoad, S32, (), , "" ) { DecalRoad *road = object->getSelectedRoad(); if ( road ) - return road->getIdString(); + return road->getId(); return NULL; } -ConsoleMethod( GuiRoadEditorCtrl, getSelectedNode, S32, 2, 2, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, getSelectedNode, S32, (), , "" ) { return object->getSelectedNode(); } -ConsoleMethod( GuiRoadEditorCtrl, deleteRoad, void, 2, 2, "" ) +DefineConsoleMethod( GuiRoadEditorCtrl, deleteRoad, void, (), , "" ) { object->deleteSelectedRoad(); } diff --git a/Engine/source/environment/skyBox.cpp b/Engine/source/environment/skyBox.cpp index 7d3e600f7..5adb28b98 100644 --- a/Engine/source/environment/skyBox.cpp +++ b/Engine/source/environment/skyBox.cpp @@ -24,6 +24,7 @@ #include "environment/skyBox.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "scene/sceneRenderState.h" #include "renderInstance/renderPassManager.h" #include "gfx/primBuilder.h" @@ -637,7 +638,7 @@ BaseMatInstance* SkyBox::_getMaterialInstance() return mMatInstance; } -ConsoleMethod( SkyBox, postApply, void, 2, 2, "") +DefineConsoleMethod( SkyBox, postApply, void, (), , "") { object->inspectPostApply(); } \ No newline at end of file diff --git a/Engine/source/environment/sun.cpp b/Engine/source/environment/sun.cpp index bd89d4cca..45181a27b 100644 --- a/Engine/source/environment/sun.cpp +++ b/Engine/source/environment/sun.cpp @@ -27,6 +27,7 @@ #include "math/mathIO.h" #include "core/stream/bitStream.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "scene/sceneManager.h" #include "math/mathUtils.h" #include "lighting/lightInfo.h" @@ -546,18 +547,13 @@ void Sun::_onUnselected() Parent::_onUnselected(); } -ConsoleMethod(Sun, apply, void, 2, 2, "") +DefineConsoleMethod(Sun, apply, void, (), , "") { object->inspectPostApply(); } -ConsoleMethod(Sun, animate, void, 7, 7, "animate( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation )") +DefineConsoleMethod(Sun, animate, void, ( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation ), , "animate( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation )") { - F32 duration = dAtof(argv[2]); - F32 startAzimuth = dAtof(argv[3]); - F32 endAzimuth = dAtof(argv[4]); - F32 startElevation = dAtof(argv[5]); - F32 endElevation = dAtof(argv[6]); object->animate(duration, startAzimuth, endAzimuth, startElevation, endElevation); } diff --git a/Engine/source/forest/editor/forestBrushElement.cpp b/Engine/source/forest/editor/forestBrushElement.cpp index 3b870e227..b373b11db 100644 --- a/Engine/source/forest/editor/forestBrushElement.cpp +++ b/Engine/source/forest/editor/forestBrushElement.cpp @@ -23,7 +23,7 @@ #include "platform/platform.h" #include "forest/editor/forestBrushElement.h" -#include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "forest/forestItem.h" @@ -187,10 +187,10 @@ bool ForestBrush::containsItemData( const ForestItemData *inData ) return false; } -ConsoleMethod( ForestBrush, containsItemData, bool, 3, 3, "( ForestItemData obj )" ) +DefineConsoleMethod( ForestBrush, containsItemData, bool, ( const char * obj ), , "( ForestItemData obj )" ) { ForestItemData *data = NULL; - if ( !Sim::findObject( argv[2], data ) ) + if ( !Sim::findObject( obj, data ) ) { Con::warnf( "ForestBrush::containsItemData - invalid object passed" ); return false; diff --git a/Engine/source/forest/editor/forestBrushTool.cpp b/Engine/source/forest/editor/forestBrushTool.cpp index 4dd1734df..54a237528 100644 --- a/Engine/source/forest/editor/forestBrushTool.cpp +++ b/Engine/source/forest/editor/forestBrushTool.cpp @@ -30,6 +30,7 @@ #include "gui/worldEditor/editTSCtrl.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "core/util/tVector.h" #include "gfx/gfxDrawUtil.h" #include "gui/core/guiCanvas.h" @@ -681,7 +682,7 @@ bool ForestBrushTool::getGroundAt( const Point3F &worldPt, F32 *zValueOut, Vecto return true; } -ConsoleMethod( ForestBrushTool, collectElements, void, 2, 2, "" ) +DefineConsoleMethod( ForestBrushTool, collectElements, void, (), , "" ) { object->collectElements(); } \ No newline at end of file diff --git a/Engine/source/forest/editor/forestEditorCtrl.cpp b/Engine/source/forest/editor/forestEditorCtrl.cpp index 923e1ee56..651fb4780 100644 --- a/Engine/source/forest/editor/forestEditorCtrl.cpp +++ b/Engine/source/forest/editor/forestEditorCtrl.cpp @@ -25,6 +25,7 @@ #include "forest/editor/forestBrushTool.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gui/core/guiCanvas.h" #include "windowManager/platformCursorController.h" #include "forest/editor/forestUndo.h" @@ -370,33 +371,33 @@ bool ForestEditorCtrl::isDirty() return foundDirty; } -ConsoleMethod( ForestEditorCtrl, updateActiveForest, void, 2, 2, "()" ) +DefineConsoleMethod( ForestEditorCtrl, updateActiveForest, void, (), , "()" ) { object->updateActiveForest( true ); } -ConsoleMethod( ForestEditorCtrl, setActiveTool, void, 3, 3, "( ForestTool tool )" ) +DefineConsoleMethod( ForestEditorCtrl, setActiveTool, void, ( const char * toolName ), , "( ForestTool tool )" ) { - ForestTool *tool = dynamic_cast( Sim::findObject( argv[2] ) ); + ForestTool *tool = dynamic_cast( Sim::findObject( toolName ) ); object->setActiveTool( tool ); } -ConsoleMethod( ForestEditorCtrl, getActiveTool, S32, 2, 2, "()" ) +DefineConsoleMethod( ForestEditorCtrl, getActiveTool, S32, (), , "()" ) { ForestTool *tool = object->getActiveTool(); return tool ? tool->getId() : 0; } -ConsoleMethod( ForestEditorCtrl, deleteMeshSafe, void, 3, 3, "( ForestItemData obj )" ) +DefineConsoleMethod( ForestEditorCtrl, deleteMeshSafe, void, ( const char * obj ), , "( ForestItemData obj )" ) { ForestItemData *db; - if ( !Sim::findObject( argv[2], db ) ) + if ( !Sim::findObject( obj, db ) ) return; object->deleteMeshSafe( db ); } -ConsoleMethod( ForestEditorCtrl, isDirty, bool, 2, 2, "" ) +DefineConsoleMethod( ForestEditorCtrl, isDirty, bool, (), , "" ) { return object->isDirty(); } \ No newline at end of file diff --git a/Engine/source/forest/editor/forestSelectionTool.cpp b/Engine/source/forest/editor/forestSelectionTool.cpp index c2032343c..b3bc964c3 100644 --- a/Engine/source/forest/editor/forestSelectionTool.cpp +++ b/Engine/source/forest/editor/forestSelectionTool.cpp @@ -30,6 +30,7 @@ #include "gui/worldEditor/editTSCtrl.h" #include "gui/worldEditor/gizmo.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "core/util/tVector.h" #include "core/util/safeDelete.h" #include "gfx/gfxDrawUtil.h" @@ -558,32 +559,32 @@ void ForestSelectionTool::onUndoAction() mBounds.intersect( mSelection[i].getWorldBox() ); } -ConsoleMethod( ForestSelectionTool, getSelectionCount, S32, 2, 2, "" ) +DefineConsoleMethod( ForestSelectionTool, getSelectionCount, S32, (), , "" ) { return object->getSelectionCount(); } -ConsoleMethod( ForestSelectionTool, deleteSelection, void, 2, 2, "" ) +DefineConsoleMethod( ForestSelectionTool, deleteSelection, void, (), , "" ) { object->deleteSelection(); } -ConsoleMethod( ForestSelectionTool, clearSelection, void, 2, 2, "" ) +DefineConsoleMethod( ForestSelectionTool, clearSelection, void, (), , "" ) { object->clearSelection(); } -ConsoleMethod( ForestSelectionTool, cutSelection, void, 2, 2, "" ) +DefineConsoleMethod( ForestSelectionTool, cutSelection, void, (), , "" ) { object->cutSelection(); } -ConsoleMethod( ForestSelectionTool, copySelection, void, 2, 2, "" ) +DefineConsoleMethod( ForestSelectionTool, copySelection, void, (), , "" ) { object->copySelection(); } -ConsoleMethod( ForestSelectionTool, pasteSelection, void, 2, 2, "" ) +DefineConsoleMethod( ForestSelectionTool, pasteSelection, void, (), , "" ) { object->pasteSelection(); } diff --git a/Engine/source/forest/forest.cpp b/Engine/source/forest/forest.cpp index a28297522..037278e36 100644 --- a/Engine/source/forest/forest.cpp +++ b/Engine/source/forest/forest.cpp @@ -38,8 +38,10 @@ #include "environment/sun.h" #include "scene/sceneManager.h" #include "math/mathUtils.h" +#include "math/mTransform.h" #include "T3D/physics/physicsBody.h" #include "forest/editor/forestBrushElement.h" +#include "console/engineAPI.h" /// For frame signal #include "gui/core/guiCanvas.h" @@ -359,23 +361,22 @@ void Forest::saveDataFile( const char *path ) mData->write( mDataFileName ); } -ConsoleMethod( Forest, saveDataFile, bool, 2, 3, "saveDataFile( [path] )" ) +DefineConsoleMethod( Forest, saveDataFile, void, (const char * path), (""), "saveDataFile( [path] )" ) { - object->saveDataFile( argc == 3 ? (const char*)argv[2] : NULL ); - return true; + object->saveDataFile( path ); } -ConsoleMethod(Forest, isDirty, bool, 2, 2, "()") +DefineConsoleMethod(Forest, isDirty, bool, (), , "()") { return object->getData() && object->getData()->isDirty(); } -ConsoleMethod(Forest, regenCells, void, 2, 2, "()") +DefineConsoleMethod(Forest, regenCells, void, (), , "()") { object->getData()->regenCells(); } -ConsoleMethod(Forest, clear, void, 2, 2, "()" ) +DefineConsoleMethod(Forest, clear, void, (), , "()" ) { object->clear(); } diff --git a/Engine/source/gfx/gfxCardProfile.cpp b/Engine/source/gfx/gfxCardProfile.cpp index 7fdbc3eae..b222fa3e0 100644 --- a/Engine/source/gfx/gfxCardProfile.cpp +++ b/Engine/source/gfx/gfxCardProfile.cpp @@ -53,7 +53,7 @@ void GFXCardProfiler::loadProfileScript(const char* aScriptName) Con::printf(" - Loaded card profile %s", scriptName.c_str()); - Con::executef("eval", script); + Con::evaluate(script, false, NULL); delete[] script; } diff --git a/Engine/source/gfx/gfxTextureObject.cpp b/Engine/source/gfx/gfxTextureObject.cpp index 5f67528aa..655bb0164 100644 --- a/Engine/source/gfx/gfxTextureObject.cpp +++ b/Engine/source/gfx/gfxTextureObject.cpp @@ -58,16 +58,20 @@ U32 GFXTextureObject::dumpActiveTOs() return smActiveTOCount; } + + +#endif // TORQUE_DEBUG + DefineEngineFunction( dumpTextureObjects, void, (),, "Dumps a list of all active texture objects to the console.\n" "@note This function is only available in debug builds.\n" "@ingroup GFX\n" ) { +#ifdef TORQUE_DEBUG GFXTextureObject::dumpActiveTOs(); +#endif } -#endif // TORQUE_DEBUG - //----------------------------------------------------------------------------- // GFXTextureObject //----------------------------------------------------------------------------- diff --git a/Engine/source/gfx/video/videoCapture.cpp b/Engine/source/gfx/video/videoCapture.cpp index 25ba633dd..230baf501 100644 --- a/Engine/source/gfx/video/videoCapture.cpp +++ b/Engine/source/gfx/video/videoCapture.cpp @@ -305,10 +305,11 @@ void VideoFrameGrabber::_onTextureEvent(GFXTexCallbackCode code) ///---------------------------------------------------------------------- ///---------------------------------------------------------------------- - +//WLE - Vince +//Changing the resolution to Point2I::Zero instead of the Point2I(0,0) better to use constants. DefineEngineFunction( startVideoCapture, void, ( GuiCanvas *canvas, const char *filename, const char *encoder, F32 framerate, Point2I resolution ), - ( "THEORA", 30.0f, Point2I( 0, 0 ) ), + ( "THEORA", 30.0f, Point2I::Zero ), "Begins a video capture session.\n" "@see stopVideoCapture\n" "@ingroup Rendering\n" ) @@ -339,7 +340,7 @@ DefineEngineFunction( stopVideoCapture, void, (),, DefineEngineFunction( playJournalToVideo, void, ( const char *journalFile, const char *videoFile, const char *encoder, F32 framerate, Point2I resolution ), - ( NULL, "THEORA", 30.0f, Point2I( 0, 0 ) ), + ( NULL, "THEORA", 30.0f, Point2I::Zero ), "Load a journal file and capture it video.\n" "@ingroup Rendering\n" ) { diff --git a/Engine/source/gui/buttons/guiToolboxButtonCtrl.cpp b/Engine/source/gui/buttons/guiToolboxButtonCtrl.cpp index a2a0b962a..9242d8aff 100644 --- a/Engine/source/gui/buttons/guiToolboxButtonCtrl.cpp +++ b/Engine/source/gui/buttons/guiToolboxButtonCtrl.cpp @@ -24,6 +24,7 @@ #include "gui/buttons/guiToolboxButtonCtrl.h" #include "console/console.h" +#include "console/engineAPI.h" #include "gfx/gfxDevice.h" #include "gfx/gfxDrawUtil.h" #include "console/consoleTypes.h" @@ -91,19 +92,19 @@ void GuiToolboxButtonCtrl::onSleep() //------------------------------------- -ConsoleMethod( GuiToolboxButtonCtrl, setNormalBitmap, void, 3, 3, "( filepath name ) sets the bitmap that shows when the button is active") +DefineConsoleMethod( GuiToolboxButtonCtrl, setNormalBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is active") { - object->setNormalBitmap(argv[2]); + object->setNormalBitmap(name); } -ConsoleMethod( GuiToolboxButtonCtrl, setLoweredBitmap, void, 3, 3, "( filepath name ) sets the bitmap that shows when the button is disabled") +DefineConsoleMethod( GuiToolboxButtonCtrl, setLoweredBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is disabled") { - object->setLoweredBitmap(argv[2]); + object->setLoweredBitmap(name); } -ConsoleMethod( GuiToolboxButtonCtrl, setHoverBitmap, void, 3, 3, "( filepath name ) sets the bitmap that shows when the button is disabled") +DefineConsoleMethod( GuiToolboxButtonCtrl, setHoverBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is disabled") { - object->setHoverBitmap(argv[2]); + object->setHoverBitmap(name); } //------------------------------------- diff --git a/Engine/source/gui/controls/guiBitmapCtrl.cpp b/Engine/source/gui/controls/guiBitmapCtrl.cpp index e95263701..1d0cd21c7 100644 --- a/Engine/source/gui/controls/guiBitmapCtrl.cpp +++ b/Engine/source/gui/controls/guiBitmapCtrl.cpp @@ -256,11 +256,11 @@ static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap2( //"Set the bitmap displayed in the control. Note that it is limited in size, to 256x256." -ConsoleMethod( GuiBitmapCtrl, setBitmap, void, 3, 4, +DefineConsoleMethod( GuiBitmapCtrl, setBitmap, void, ( const char * fileRoot, bool resize), ( false), "( String filename | String filename, bool resize ) Assign an image to the control.\n\n" "@hide" ) { char filename[1024]; - Con::expandScriptFilename(filename, sizeof(filename), argv[2]); - object->setBitmap(filename, argc > 3 ? dAtob( argv[3] ) : false ); + Con::expandScriptFilename(filename, sizeof(filename), fileRoot); + object->setBitmap(filename, resize ); } diff --git a/Engine/source/gui/controls/guiColorPicker.cpp b/Engine/source/gui/controls/guiColorPicker.cpp index bc65ee8f9..0b8676240 100644 --- a/Engine/source/gui/controls/guiColorPicker.cpp +++ b/Engine/source/gui/controls/guiColorPicker.cpp @@ -22,6 +22,7 @@ #include "console/console.h" #include "gfx/gfxDevice.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gui/core/guiCanvas.h" #include "gui/buttons/guiButtonCtrl.h" #include "gui/core/guiDefaultControlRender.h" @@ -524,24 +525,17 @@ void GuiColorPickerCtrl::setScriptValue(const char *value) setValue(newValue); } -ConsoleMethod(GuiColorPickerCtrl, getSelectorPos, const char*, 2, 2, "Gets the current position of the selector") +DefineConsoleMethod(GuiColorPickerCtrl, getSelectorPos, Point2I, (), , "Gets the current position of the selector") { - static const U32 bufSize = 256; - char *temp = Con::getReturnBuffer(bufSize); - Point2I pos; - pos = object->getSelectorPos(); - dSprintf(temp,bufSize,"%d %d",pos.x, pos.y); - return temp; + return object->getSelectorPos(); } -ConsoleMethod(GuiColorPickerCtrl, setSelectorPos, void, 3, 3, "Sets the current position of the selector") +DefineConsoleMethod(GuiColorPickerCtrl, setSelectorPos, void, (Point2I newPos), , "Sets the current position of the selector") { - Point2I newPos; - dSscanf(argv[2], "%d %d", &newPos.x, &newPos.y); object->setSelectorPos(newPos); } -ConsoleMethod(GuiColorPickerCtrl, updateColor, void, 2, 2, "Forces update of pick color") +DefineConsoleMethod(GuiColorPickerCtrl, updateColor, void, (), , "Forces update of pick color") { object->updateColor(); } diff --git a/Engine/source/gui/controls/guiDecoyCtrl.cpp b/Engine/source/gui/controls/guiDecoyCtrl.cpp index f764c976a..37457c633 100644 --- a/Engine/source/gui/controls/guiDecoyCtrl.cpp +++ b/Engine/source/gui/controls/guiDecoyCtrl.cpp @@ -25,6 +25,7 @@ #include "gui/buttons/guiButtonBaseCtrl.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gfx/primBuilder.h" //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/controls/guiFileTreeCtrl.cpp b/Engine/source/gui/controls/guiFileTreeCtrl.cpp index 60e0c3b86..db38fbe58 100644 --- a/Engine/source/gui/controls/guiFileTreeCtrl.cpp +++ b/Engine/source/gui/controls/guiFileTreeCtrl.cpp @@ -25,6 +25,7 @@ #include "core/frameAllocator.h" #include "core/strings/stringUnit.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" IMPLEMENT_CONOBJECT(GuiFileTreeCtrl); @@ -378,18 +379,18 @@ void GuiFileTreeCtrl::recurseInsert( Item* parent, StringTableEntry path ) } -ConsoleMethod( GuiFileTreeCtrl, getSelectedPath, const char*, 2, 2, "getSelectedPath() - returns the currently selected path in the tree") +DefineConsoleMethod( GuiFileTreeCtrl, getSelectedPath, const char*, (), , "getSelectedPath() - returns the currently selected path in the tree") { const String& path = object->getSelectedPath(); return Con::getStringArg( path ); } -ConsoleMethod( GuiFileTreeCtrl, setSelectedPath, bool, 3, 3, "setSelectedPath(path) - expands the tree to the specified path") +DefineConsoleMethod( GuiFileTreeCtrl, setSelectedPath, bool, (const char * path), , "setSelectedPath(path) - expands the tree to the specified path") { - return object->setSelectedPath( argv[ 2 ] ); + return object->setSelectedPath( path ); } -ConsoleMethod( GuiFileTreeCtrl, reload, void, 2, 2, "() - Reread the directory tree hierarchy." ) +DefineConsoleMethod( GuiFileTreeCtrl, reload, void, (), , "() - Reread the directory tree hierarchy." ) { object->updateTree(); } diff --git a/Engine/source/gui/controls/guiGradientCtrl.cpp b/Engine/source/gui/controls/guiGradientCtrl.cpp index 7fe919fd1..081b62382 100644 --- a/Engine/source/gui/controls/guiGradientCtrl.cpp +++ b/Engine/source/gui/controls/guiGradientCtrl.cpp @@ -599,7 +599,7 @@ void GuiGradientCtrl::sortColorRange() dQsort( mAlphaRange.address(), mAlphaRange.size(), sizeof(ColorRange), _numIncreasing); } -ConsoleMethod(GuiGradientCtrl, getColorCount, S32, 2, 2, "Get color count") +DefineConsoleMethod(GuiGradientCtrl, getColorCount, S32, (), , "Get color count") { if( object->getDisplayMode() == GuiGradientCtrl::pHorizColorRange ) return object->mColorRange.size(); @@ -609,44 +609,25 @@ ConsoleMethod(GuiGradientCtrl, getColorCount, S32, 2, 2, "Get color count") return 0; } -ConsoleMethod(GuiGradientCtrl, getColor, const char*, 3, 3, "Get color value") +DefineConsoleMethod(GuiGradientCtrl, getColor, ColorF, (S32 idx), , "Get color value") { - S32 idx = dAtoi(argv[2]); if( object->getDisplayMode() == GuiGradientCtrl::pHorizColorRange ) { if ( idx >= 0 && idx < object->mColorRange.size() ) { - static const U32 bufSize = 256; - char* rColor = Con::getReturnBuffer(bufSize); - rColor[0] = 0; - dSprintf(rColor, bufSize, "%f %f %f %f", - object->mColorRange[idx].swatch->getColor().red, - object->mColorRange[idx].swatch->getColor().green, - object->mColorRange[idx].swatch->getColor().blue, - object->mColorRange[idx].swatch->getColor().alpha); - - return rColor; + return object->mColorRange[idx].swatch->getColor(); } } else if( object->getDisplayMode() == GuiGradientCtrl::pHorizColorRange ) { if ( idx >= 0 && idx < object->mAlphaRange.size() ) { - static const U32 bufSize = 256; - char* rColor = Con::getReturnBuffer(bufSize); - rColor[0] = 0; - dSprintf(rColor, bufSize, "%f %f %f %f", - object->mAlphaRange[idx].swatch->getColor().red, - object->mAlphaRange[idx].swatch->getColor().green, - object->mAlphaRange[idx].swatch->getColor().blue, - object->mAlphaRange[idx].swatch->getColor().alpha); - - return rColor; + return object->mAlphaRange[idx].swatch->getColor(); } } - return "1 1 1 1"; + return ColorF::ONE; } \ No newline at end of file diff --git a/Engine/source/gui/controls/guiMaterialCtrl.cpp b/Engine/source/gui/controls/guiMaterialCtrl.cpp index e5fe887f5..edfb12e76 100644 --- a/Engine/source/gui/controls/guiMaterialCtrl.cpp +++ b/Engine/source/gui/controls/guiMaterialCtrl.cpp @@ -29,6 +29,7 @@ #include "core/util/safeDelete.h" #include "console/console.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gfx/gfxDevice.h" #include "math/util/matrixSet.h" #include "scene/sceneRenderState.h" @@ -166,8 +167,8 @@ void GuiMaterialCtrl::onRender( Point2I offset, const RectI &updateRect ) GFX->setTexture( 0, NULL ); } -ConsoleMethod( GuiMaterialCtrl, setMaterial, bool, 3, 3, "( string materialName )" +DefineConsoleMethod( GuiMaterialCtrl, setMaterial, bool, ( const char * materialName ), , "( string materialName )" "Set the material to be displayed in the control." ) { - return object->setMaterial( (const char*)argv[2] ); + return object->setMaterial( materialName ); } diff --git a/Engine/source/gui/controls/guiPopUpCtrl.cpp b/Engine/source/gui/controls/guiPopUpCtrl.cpp index bad9801d2..6bc6831af 100644 --- a/Engine/source/gui/controls/guiPopUpCtrl.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrl.cpp @@ -23,6 +23,7 @@ #include "gui/core/guiCanvas.h" #include "gui/controls/guiPopUpCtrl.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gui/core/guiDefaultControlRender.h" #include "gfx/primBuilder.h" #include "gfx/gfxDrawUtil.h" @@ -299,121 +300,82 @@ void GuiPopUpMenuCtrl::initPersistFields(void) } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrl, add, void, 3, 5, "(string name, int idNum, int scheme=0)") +DefineConsoleMethod( GuiPopUpMenuCtrl, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)") { - if ( argc == 4 ) - object->addEntry(argv[2],dAtoi(argv[3])); - if ( argc == 5 ) - object->addEntry(argv[2],dAtoi(argv[3]),dAtoi(argv[4])); - else - object->addEntry(argv[2]); + object->addEntry(name, idNum, scheme); } -ConsoleMethod( GuiPopUpMenuCtrl, addScheme, void, 6, 6, "(int id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL)") +DefineConsoleMethod( GuiPopUpMenuCtrl, addScheme, void, (U32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL), , + "(int id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL)") { - ColorI fontColor, fontColorHL, fontColorSEL; - U32 r, g, b; - char buf[64]; - dStrcpy( buf, argv[3] ); - char* temp = dStrtok( buf, " \0" ); - r = temp ? dAtoi( temp ) : 0; - temp = dStrtok( NULL, " \0" ); - g = temp ? dAtoi( temp ) : 0; - temp = dStrtok( NULL, " \0" ); - b = temp ? dAtoi( temp ) : 0; - fontColor.set( r, g, b ); - - dStrcpy( buf, argv[4] ); - temp = dStrtok( buf, " \0" ); - r = temp ? dAtoi( temp ) : 0; - temp = dStrtok( NULL, " \0" ); - g = temp ? dAtoi( temp ) : 0; - temp = dStrtok( NULL, " \0" ); - b = temp ? dAtoi( temp ) : 0; - fontColorHL.set( r, g, b ); - - dStrcpy( buf, argv[5] ); - temp = dStrtok( buf, " \0" ); - r = temp ? dAtoi( temp ) : 0; - temp = dStrtok( NULL, " \0" ); - g = temp ? dAtoi( temp ) : 0; - temp = dStrtok( NULL, " \0" ); - b = temp ? dAtoi( temp ) : 0; - fontColorSEL.set( r, g, b ); - - object->addScheme( dAtoi( argv[2] ), fontColor, fontColorHL, fontColorSEL ); + object->addScheme( id, fontColor, fontColorHL, fontColorSEL ); } -ConsoleMethod( GuiPopUpMenuCtrl, getText, const char*, 2, 2, "") +DefineConsoleMethod( GuiPopUpMenuCtrl, getText, const char*, (), , "") { return object->getText(); } -ConsoleMethod( GuiPopUpMenuCtrl, clear, void, 2, 2, "Clear the popup list.") +DefineConsoleMethod( GuiPopUpMenuCtrl, clear, void, (), , "Clear the popup list.") { object->clear(); } //FIXME: clashes with SimSet.sort -ConsoleMethod(GuiPopUpMenuCtrl, sort, void, 2, 2, "Sort the list alphabetically.") +DefineConsoleMethod(GuiPopUpMenuCtrl, sort, void, (), , "Sort the list alphabetically.") { object->sort(); } // Added to sort the entries by ID -ConsoleMethod(GuiPopUpMenuCtrl, sortID, void, 2, 2, "Sort the list by ID.") +DefineConsoleMethod(GuiPopUpMenuCtrl, sortID, void, (), , "Sort the list by ID.") { object->sortID(); } -ConsoleMethod( GuiPopUpMenuCtrl, forceOnAction, void, 2, 2, "") +DefineConsoleMethod( GuiPopUpMenuCtrl, forceOnAction, void, (), , "") { object->onAction(); } -ConsoleMethod( GuiPopUpMenuCtrl, forceClose, void, 2, 2, "") +DefineConsoleMethod( GuiPopUpMenuCtrl, forceClose, void, (), , "") { object->closePopUp(); } -ConsoleMethod( GuiPopUpMenuCtrl, getSelected, S32, 2, 2, "") +DefineConsoleMethod( GuiPopUpMenuCtrl, getSelected, S32, (), , "") { return object->getSelected(); } -ConsoleMethod( GuiPopUpMenuCtrl, setSelected, void, 3, 4, "(int id, [scriptCallback=true])") +DefineConsoleMethod( GuiPopUpMenuCtrl, setSelected, void, (S32 id, bool scriptCallback), (true), "(int id, [scriptCallback=true])") { - if( argc > 3 ) - object->setSelected( dAtoi( argv[2] ), dAtob( argv[3] ) ); - else - object->setSelected( dAtoi( argv[2] ) ); + object->setSelected( id, scriptCallback ); } -ConsoleMethod( GuiPopUpMenuCtrl, setFirstSelected, void, 2, 3, "([scriptCallback=true])") +DefineConsoleMethod( GuiPopUpMenuCtrl, setFirstSelected, void, (bool scriptCallback), (true), "([scriptCallback=true])") { - if( argc > 2 ) - object->setFirstSelected( dAtob( argv[2] ) ); - else - object->setFirstSelected(); + object->setFirstSelected( scriptCallback ); + } -ConsoleMethod( GuiPopUpMenuCtrl, setNoneSelected, void, 2, 2, "") +DefineConsoleMethod( GuiPopUpMenuCtrl, setNoneSelected, void, (), , "") { object->setNoneSelected(); } -ConsoleMethod( GuiPopUpMenuCtrl, getTextById, const char*, 3, 3, "(int id)") +DefineConsoleMethod( GuiPopUpMenuCtrl, getTextById, const char*, (S32 id), , "(int id)") { - return(object->getTextById(dAtoi(argv[2]))); + return(object->getTextById(id)); } -ConsoleMethod( GuiPopUpMenuCtrl, changeTextById, void, 4, 4, "( int id, string text )" ) +DefineConsoleMethod( GuiPopUpMenuCtrl, changeTextById, void, ( S32 id, const char * text ), , "( int id, string text )" ) { - object->setEntryText( dAtoi( argv[ 2 ] ), argv[ 3 ] ); + object->setEntryText( id, text ); } -ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, string enum)" +DefineConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, (const char * className, const char * enumName), , "(string class, string enum)" "This fills the popup with a classrep's field enumeration type info.\n\n" "More of a helper function than anything. If console access to the field list is added, " "at least for the enumerated types, then this should go away..") @@ -423,7 +385,7 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str // walk the class list to get our class while(classRep) { - if(!dStricmp(classRep->getClassName(), argv[2])) + if(!dStricmp(classRep->getClassName(), className)) break; classRep = classRep->getNextClass(); } @@ -431,20 +393,20 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str // get it? if(!classRep) { - Con::warnf(ConsoleLogEntry::General, "failed to locate class rep for '%s'", (const char*)argv[2]); + Con::warnf(ConsoleLogEntry::General, "failed to locate class rep for '%s'", className); return; } // walk the fields to check for this one (findField checks StringTableEntry ptrs...) U32 i; for(i = 0; i < classRep->mFieldList.size(); i++) - if(!dStricmp(classRep->mFieldList[i].pFieldname, argv[3])) + if(!dStricmp(classRep->mFieldList[i].pFieldname, enumName)) break; // found it? if(i == classRep->mFieldList.size()) { - Con::warnf(ConsoleLogEntry::General, "failed to locate field '%s' for class '%s'", (const char*)argv[3], (const char*)argv[2]); + Con::warnf(ConsoleLogEntry::General, "failed to locate field '%s' for class '%s'", enumName, className); return; } @@ -454,7 +416,7 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str // check the type if( !conType->getEnumTable() ) { - Con::warnf(ConsoleLogEntry::General, "field '%s' is not an enumeration for class '%s'", (const char*)argv[3], (const char*)argv[2]); + Con::warnf(ConsoleLogEntry::General, "field '%s' is not an enumeration for class '%s'", enumName, className); return; } @@ -467,22 +429,22 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrl, findText, S32, 3, 3, "(string text)" +DefineConsoleMethod( GuiPopUpMenuCtrl, findText, S32, (const char * text), , "(string text)" "Returns the position of the first entry containing the specified text.") { - return( object->findText( argv[2] ) ); + return( object->findText( text ) ); } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrl, size, S32, 2, 2, "Get the size of the menu - the number of entries in it.") +DefineConsoleMethod( GuiPopUpMenuCtrl, size, S32, (), , "Get the size of the menu - the number of entries in it.") { return( object->getNumEntries() ); } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrl, replaceText, void, 3, 3, "(bool doReplaceText)") +DefineConsoleMethod( GuiPopUpMenuCtrl, replaceText, void, (bool doReplaceText), , "(bool doReplaceText)") { - object->replaceText(dAtoi(argv[2])); + object->replaceText(S32(doReplaceText)); } //------------------------------------------------------------------------------ @@ -570,9 +532,9 @@ void GuiPopUpMenuCtrl::clearEntry( S32 entry ) } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrl, clearEntry, void, 3, 3, "(S32 entry)") +DefineConsoleMethod( GuiPopUpMenuCtrl, clearEntry, void, (S32 entry), , "(S32 entry)") { - object->clearEntry(dAtoi(argv[2])); + object->clearEntry(entry); } //------------------------------------------------------------------------------ diff --git a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp index a1a46f799..90e3b0ff8 100644 --- a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp @@ -23,6 +23,7 @@ #include "gui/core/guiCanvas.h" #include "gui/controls/guiPopUpCtrlEx.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gui/core/guiDefaultControlRender.h" #include "gfx/primBuilder.h" #include "gfx/gfxDrawUtil.h" @@ -363,14 +364,9 @@ ConsoleDocFragment _GuiPopUpMenuCtrlExAdd( "void add(string name, S32 idNum, S32 scheme=0);" ); -ConsoleMethod( GuiPopUpMenuCtrlEx, add, void, 3, 5, "(string name, int idNum, int scheme=0)") +DefineConsoleMethod( GuiPopUpMenuCtrlEx, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)") { - if ( argc == 4 ) - object->addEntry(argv[2],dAtoi(argv[3])); - if ( argc == 5 ) - object->addEntry(argv[2],dAtoi(argv[3]),dAtoi(argv[4])); - else - object->addEntry(argv[2]); + object->addEntry(name, idNum, scheme); } DefineEngineMethod( GuiPopUpMenuCtrlEx, addCategory, void, (const char* text),, @@ -529,13 +525,10 @@ ConsoleDocFragment _GuiPopUpMenuCtrlExsetSelected( "setSelected(int id, bool scriptCallback=true);" ); -ConsoleMethod( GuiPopUpMenuCtrlEx, setSelected, void, 3, 4, "(int id, [scriptCallback=true])" +DefineConsoleMethod( GuiPopUpMenuCtrlEx, setSelected, void, (S32 id, bool scriptCallback), (true), "(int id, [scriptCallback=true])" "@hide") { - if( argc > 3 ) - object->setSelected( dAtoi( argv[2] ), dAtob( argv[3] ) ); - else - object->setSelected( dAtoi( argv[2] ) ); + object->setSelected( id, scriptCallback ); } ConsoleDocFragment _GuiPopUpMenuCtrlExsetFirstSelected( @@ -546,13 +539,10 @@ ConsoleDocFragment _GuiPopUpMenuCtrlExsetFirstSelected( ); -ConsoleMethod( GuiPopUpMenuCtrlEx, setFirstSelected, void, 2, 3, "([scriptCallback=true])" +DefineConsoleMethod( GuiPopUpMenuCtrlEx, setFirstSelected, void, (bool scriptCallback), (true), "([scriptCallback=true])" "@hide") { - if( argc > 2 ) - object->setFirstSelected( dAtob( argv[2] ) ); - else - object->setFirstSelected(); + object->setFirstSelected( scriptCallback ); } DefineEngineMethod( GuiPopUpMenuCtrlEx, setNoneSelected, void, ( S32 param),, @@ -571,21 +561,18 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, getTextById, const char*, (S32 id),, } -ConsoleMethod( GuiPopUpMenuCtrlEx, getColorById, const char*, 3, 3, +DefineConsoleMethod( GuiPopUpMenuCtrlEx, getColorById, ColorI, (S32 id), , "@brief Get color of an entry's box\n\n" "@param id ID number of entry to query\n\n" "@return ColorI in the format of \"Red Green Blue Alpha\", each of with is a value between 0 - 255") { ColorI color; - object->getColoredBox(color, dAtoi(argv[2])); + object->getColoredBox(color, id); + return color; - static const U32 bufSize = 512; - char *strBuffer = Con::getReturnBuffer(bufSize); - dSprintf(strBuffer, bufSize, "%d %d %d %d", color.red, color.green, color.blue, color.alpha); - return strBuffer; } -ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4, +DefineConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, ( const char * className, const char * enumName ), , "@brief This fills the popup with a classrep's field enumeration type info.\n\n" "More of a helper function than anything. If console access to the field list is added, " "at least for the enumerated types, then this should go away.\n\n" @@ -597,7 +584,7 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4, // walk the class list to get our class while(classRep) { - if(!dStricmp(classRep->getClassName(), argv[2])) + if(!dStricmp(classRep->getClassName(), className)) break; classRep = classRep->getNextClass(); } @@ -605,20 +592,20 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4, // get it? if(!classRep) { - Con::warnf(ConsoleLogEntry::General, "failed to locate class rep for '%s'", (const char*)argv[2]); + Con::warnf(ConsoleLogEntry::General, "failed to locate class rep for '%s'", className); return; } // walk the fields to check for this one (findField checks StringTableEntry ptrs...) U32 i; for(i = 0; i < classRep->mFieldList.size(); i++) - if(!dStricmp(classRep->mFieldList[i].pFieldname, argv[3])) + if(!dStricmp(classRep->mFieldList[i].pFieldname, enumName)) break; // found it? if(i == classRep->mFieldList.size()) { - Con::warnf(ConsoleLogEntry::General, "failed to locate field '%s' for class '%s'", (const char*)argv[3], (const char*)argv[2]); + Con::warnf(ConsoleLogEntry::General, "failed to locate field '%s' for class '%s'", enumName, className); return; } @@ -628,7 +615,7 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4, // check the type if( !conType->getEnumTable() ) { - Con::warnf(ConsoleLogEntry::General, "field '%s' is not an enumeration for class '%s'", (const char*)argv[3], (const char*)argv[2]); + Con::warnf(ConsoleLogEntry::General, "field '%s' is not an enumeration for class '%s'", enumName, className); return; } @@ -641,16 +628,16 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4, } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrlEx, findText, S32, 3, 3, "(string text)" +DefineConsoleMethod( GuiPopUpMenuCtrlEx, findText, S32, (const char * text), , "(string text)" "Returns the id of the first entry containing the specified text or -1 if not found." "@param text String value used for the query\n\n" "@return Numerical ID of entry containing the text.") { - return( object->findText( argv[2] ) ); + return( object->findText( text ) ); } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrlEx, size, S32, 2, 2, +DefineConsoleMethod( GuiPopUpMenuCtrlEx, size, S32, (), , "@brief Get the size of the menu\n\n" "@return Number of entries in the menu\n") { @@ -658,11 +645,11 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, size, S32, 2, 2, } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrlEx, replaceText, void, 3, 3, +DefineConsoleMethod( GuiPopUpMenuCtrlEx, replaceText, void, (S32 boolVal), , "@brief Flag that causes each new text addition to replace the current entry\n\n" "@param True to turn on replacing, false to disable it") { - object->replaceText(dAtoi(argv[2])); + object->replaceText(boolVal); } //------------------------------------------------------------------------------ @@ -750,9 +737,9 @@ void GuiPopUpMenuCtrlEx::clearEntry( S32 entry ) } //------------------------------------------------------------------------------ -ConsoleMethod( GuiPopUpMenuCtrlEx, clearEntry, void, 3, 3, "(S32 entry)") +DefineConsoleMethod( GuiPopUpMenuCtrlEx, clearEntry, void, (S32 entry), , "(S32 entry)") { - object->clearEntry(dAtoi(argv[2])); + object->clearEntry(entry); } //------------------------------------------------------------------------------ diff --git a/Engine/source/gui/controls/guiTreeViewCtrl.cpp b/Engine/source/gui/controls/guiTreeViewCtrl.cpp index 60df288eb..4b2fed88f 100644 --- a/Engine/source/gui/controls/guiTreeViewCtrl.cpp +++ b/Engine/source/gui/controls/guiTreeViewCtrl.cpp @@ -4605,11 +4605,28 @@ void GuiTreeViewCtrl::inspectObject( SimObject* obj, bool okToEdit ) //----------------------------------------------------------------------------- +S32 GuiTreeViewCtrl::insertObject( S32 parent, SimObject* obj, bool okToEdit ) +{ + mFlags.set( IsEditable, okToEdit ); + mFlags.set( IsInspector ); + + //onDefineIcons_callback(); + + GuiTreeViewCtrl::Item *item = addInspectorDataItem( getItem(parent), obj ); + return item->getID(); +} + +//----------------------------------------------------------------------------- + S32 GuiTreeViewCtrl::findItemByName(const char *name) { for (S32 i = 0; i < mItems.size(); i++) + { + if( mItems[i]->mState.test( Item::InspectorData ) ) + continue; if (mItems[i] && dStrcmp(mItems[i]->getText(),name) == 0) return mItems[i]->mId; + } return 0; } @@ -4619,8 +4636,12 @@ S32 GuiTreeViewCtrl::findItemByName(const char *name) S32 GuiTreeViewCtrl::findItemByValue(const char *name) { for (S32 i = 0; i < mItems.size(); i++) - if (mItems[i] && dStrcmp(mItems[i]->getValue(),name) == 0) - return mItems[i]->mId; + { + if( mItems[i]->mState.test( Item::InspectorData ) ) + continue; + if (mItems[i] && dStrcmp(mItems[i]->getValue(),name) == 0) + return mItems[i]->mId; + } return 0; } @@ -4767,6 +4788,10 @@ DefineEngineMethod( GuiTreeViewCtrl, insertItem, S32, ( S32 parentId, const char return object->insertItem( parentId, text, value, icon, normalImage, expandedImage ); } +DefineEngineMethod( GuiTreeViewCtrl, insertObject, S32, ( S32 parentId, SimObject* obj, bool OKToEdit ), (false), "Inserts object as a child to the given parent." ) +{ + return object->insertObject(parentId, obj, OKToEdit); +} //----------------------------------------------------------------------------- DefineEngineMethod( GuiTreeViewCtrl, lockSelection, void, ( bool lock ), ( true ), @@ -4831,27 +4856,24 @@ DefineEngineMethod( GuiTreeViewCtrl, addSelection, void, ( S32 id, bool isLastSe object->addSelection( id, isLastSelection, isLastSelection ); } -ConsoleMethod(GuiTreeViewCtrl, addChildSelectionByValue, void, 4, 4, "addChildSelectionByValue(TreeItemId parent, value)") +DefineConsoleMethod(GuiTreeViewCtrl, addChildSelectionByValue, void, (S32 id, const char * tableEntry), , "addChildSelectionByValue(TreeItemId parent, value)") { - S32 id = dAtoi(argv[2]); GuiTreeViewCtrl::Item* parentItem = object->getItem(id); - GuiTreeViewCtrl::Item* child = parentItem->findChildByValue(argv[3]); + GuiTreeViewCtrl::Item* child = parentItem->findChildByValue(tableEntry); object->addSelection(child->getID()); } -ConsoleMethod(GuiTreeViewCtrl, removeSelection, void, 3, 3, "(deselects an item)") +DefineConsoleMethod(GuiTreeViewCtrl, removeSelection, void, (S32 id), , "(deselects an item)") { - S32 id = dAtoi(argv[2]); object->removeSelection(id); } -ConsoleMethod(GuiTreeViewCtrl, removeChildSelectionByValue, void, 4, 4, "removeChildSelectionByValue(TreeItemId parent, value)") +DefineConsoleMethod(GuiTreeViewCtrl, removeChildSelectionByValue, void, (S32 id, const char * tableEntry), , "removeChildSelectionByValue(TreeItemId parent, value)") { - S32 id = dAtoi(argv[2]); GuiTreeViewCtrl::Item* parentItem = object->getItem(id); if(parentItem) { - GuiTreeViewCtrl::Item* child = parentItem->findChildByValue(argv[3]); + GuiTreeViewCtrl::Item* child = parentItem->findChildByValue(tableEntry); if(child) { object->removeSelection(child->getID()); @@ -4859,55 +4881,38 @@ ConsoleMethod(GuiTreeViewCtrl, removeChildSelectionByValue, void, 4, 4, "removeC } } -ConsoleMethod(GuiTreeViewCtrl, selectItem, bool, 3, 4, "(TreeItemId item, bool select=true)") +DefineConsoleMethod(GuiTreeViewCtrl, selectItem, bool, (S32 id, bool select), (true), "(TreeItemId item, bool select=true)") { - S32 id = dAtoi(argv[2]); - bool select = true; - if(argc == 4) - select = dAtob(argv[3]); - return(object->setItemSelected(id, select)); + return object->setItemSelected(id, select); } -ConsoleMethod(GuiTreeViewCtrl, expandItem, bool, 3, 4, "(TreeItemId item, bool expand=true)") +DefineConsoleMethod(GuiTreeViewCtrl, expandItem, bool, (S32 id, bool expand), (true), "(TreeItemId item, bool expand=true)") { - S32 id = dAtoi(argv[2]); - bool expand = true; - if(argc == 4) - expand = dAtob(argv[3]); return(object->setItemExpanded(id, expand)); } -ConsoleMethod(GuiTreeViewCtrl, markItem, bool, 3, 4, "(TreeItemId item, bool mark=true)") +DefineConsoleMethod(GuiTreeViewCtrl, markItem, bool, (S32 id, bool mark), (true), "(TreeItemId item, bool mark=true)") { - S32 id = dAtoi(argv[2]); - bool mark = true; - if(argc == 4) - mark = dAtob(argv[3]); return object->markItem(id, mark); } // Make the given item visible. -ConsoleMethod(GuiTreeViewCtrl, scrollVisible, void, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, scrollVisible, void, (S32 itemId), , "(TreeItemId item)") { - object->scrollVisible(dAtoi(argv[2])); + object->scrollVisible(itemId); } -ConsoleMethod(GuiTreeViewCtrl, buildIconTable, bool, 3,3, "(builds an icon table)") +DefineConsoleMethod(GuiTreeViewCtrl, buildIconTable, bool, (const char * icons), , "(builds an icon table)") { - const char * icons = argv[2]; return object->buildIconTable(icons); } -ConsoleMethod( GuiTreeViewCtrl, open, void, 3, 4, "(SimSet obj, bool okToEdit=true) Set the root of the tree view to the specified object, or to the root set.") +DefineConsoleMethod( GuiTreeViewCtrl, open, void, (const char * objName, bool okToEdit), (true), "(SimSet obj, bool okToEdit=true) Set the root of the tree view to the specified object, or to the root set.") { SimSet *treeRoot = NULL; - SimObject* target = Sim::findObject(argv[2]); + SimObject* target = Sim::findObject(objName); - bool okToEdit = true; - - if (argc == 4) - okToEdit = dAtob(argv[3]); if (target) treeRoot = dynamic_cast(target); @@ -4918,9 +4923,8 @@ ConsoleMethod( GuiTreeViewCtrl, open, void, 3, 4, "(SimSet obj, bool okToEdit=tr object->inspectObject(treeRoot,okToEdit); } -ConsoleMethod( GuiTreeViewCtrl, setItemTooltip, void, 4, 4, "( int id, string text ) - Set the tooltip to show for the given item." ) +DefineConsoleMethod( GuiTreeViewCtrl, setItemTooltip, void, ( S32 id, const char * text ), , "( int id, string text ) - Set the tooltip to show for the given item." ) { - S32 id = dAtoi( argv[ 2 ] ); GuiTreeViewCtrl::Item* item = object->getItem( id ); if( !item ) @@ -4929,12 +4933,11 @@ ConsoleMethod( GuiTreeViewCtrl, setItemTooltip, void, 4, 4, "( int id, string te return; } - item->mTooltip = (const char*)argv[ 3 ]; + item->mTooltip = text; } -ConsoleMethod( GuiTreeViewCtrl, setItemImages, void, 5, 5, "( int id, int normalImage, int expandedImage ) - Sets the normal and expanded images to show for the given item." ) +DefineConsoleMethod( GuiTreeViewCtrl, setItemImages, void, ( S32 id, S8 normalImage, S8 expandedImage ), , "( int id, int normalImage, int expandedImage ) - Sets the normal and expanded images to show for the given item." ) { - S32 id = dAtoi( argv[ 2 ] ); GuiTreeViewCtrl::Item* item = object->getItem( id ); if( !item ) @@ -4943,13 +4946,12 @@ ConsoleMethod( GuiTreeViewCtrl, setItemImages, void, 5, 5, "( int id, int normal return; } - item->setNormalImage((S8)dAtoi(argv[3])); - item->setExpandedImage((S8)dAtoi(argv[4])); + item->setNormalImage(normalImage); + item->setExpandedImage(expandedImage); } -ConsoleMethod( GuiTreeViewCtrl, isParentItem, bool, 3, 3, "( int id ) - Returns true if the given item contains child items." ) +DefineConsoleMethod( GuiTreeViewCtrl, isParentItem, bool, ( S32 id ), , "( int id ) - Returns true if the given item contains child items." ) { - S32 id = dAtoi( argv[ 2 ] ); if( !id && object->getItemCount() ) return true; @@ -4963,90 +4965,81 @@ ConsoleMethod( GuiTreeViewCtrl, isParentItem, bool, 3, 3, "( int id ) - Returns return item->isParent(); } -ConsoleMethod(GuiTreeViewCtrl, getItemText, const char *, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, getItemText, const char *, (S32 index), , "(TreeItemId item)") { - return(object->getItemText(dAtoi(argv[2]))); + return object->getItemText(index); } -ConsoleMethod(GuiTreeViewCtrl, getItemValue, const char *, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, getItemValue, const char *, (S32 itemId), , "(TreeItemId item)") { - return(object->getItemValue(dAtoi(argv[2]))); + return object->getItemValue(itemId); } -ConsoleMethod(GuiTreeViewCtrl, editItem, bool, 5, 5, "(TreeItemId item, string newText, string newValue)") +DefineConsoleMethod(GuiTreeViewCtrl, editItem, bool, (S32 item, const char * newText, const char * newValue), , "(TreeItemId item, string newText, string newValue)") { - return(object->editItem(dAtoi(argv[2]), argv[3], argv[4])); + return(object->editItem(item, newText, newValue)); } -ConsoleMethod(GuiTreeViewCtrl, removeItem, bool, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, removeItem, bool, (S32 itemId), , "(TreeItemId item)") { - return(object->removeItem(dAtoi(argv[2]))); + return(object->removeItem(itemId)); } -ConsoleMethod(GuiTreeViewCtrl, removeAllChildren, void, 3, 3, "removeAllChildren(TreeItemId parent)") +DefineConsoleMethod(GuiTreeViewCtrl, removeAllChildren, void, (S32 itemId), , "removeAllChildren(TreeItemId parent)") { - object->removeAllChildren(dAtoi(argv[2])); + object->removeAllChildren(itemId); } -ConsoleMethod(GuiTreeViewCtrl, clear, void, 2, 2, "() - empty tree") + +DefineConsoleMethod(GuiTreeViewCtrl, clear, void, (), , "() - empty tree") { object->removeItem(0); } -ConsoleMethod(GuiTreeViewCtrl, getFirstRootItem, S32, 2, 2, "Get id for root item.") +DefineConsoleMethod(GuiTreeViewCtrl, getFirstRootItem, S32, (), , "Get id for root item.") { return(object->getFirstRootItem()); } -ConsoleMethod(GuiTreeViewCtrl, getChild, S32, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, getChild, S32, (S32 itemId), , "(TreeItemId item)") { - return(object->getChildItem(dAtoi(argv[2]))); + return(object->getChildItem(itemId)); } -ConsoleMethod(GuiTreeViewCtrl, buildVisibleTree, void, 2, 3, "Build the visible tree") +DefineConsoleMethod(GuiTreeViewCtrl, buildVisibleTree, void, (bool forceFullUpdate), (false), "Build the visible tree") { - bool forceFullUpdate = false; - if( argc > 2 ) - forceFullUpdate = dAtob( argv[ 2 ] ); object->buildVisibleTree( forceFullUpdate ); } //FIXME: [rene 11/09/09 - This clashes with GuiControl.getParent(); bad thing; should be getParentItem] -ConsoleMethod(GuiTreeViewCtrl, getParent, S32, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, getParentItem, S32, (S32 itemId), , "(TreeItemId item)") { - return(object->getParentItem(dAtoi(argv[2]))); + return(object->getParentItem(itemId)); } -ConsoleMethod(GuiTreeViewCtrl, getNextSibling, S32, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, getNextSibling, S32, (S32 itemId), , "(TreeItemId item)") { - return(object->getNextSiblingItem(dAtoi(argv[2]))); + return(object->getNextSiblingItem(itemId)); } -ConsoleMethod(GuiTreeViewCtrl, getPrevSibling, S32, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, getPrevSibling, S32, (S32 itemId), , "(TreeItemId item)") { - return(object->getPrevSiblingItem(dAtoi(argv[2]))); + return(object->getPrevSiblingItem(itemId)); } -ConsoleMethod(GuiTreeViewCtrl, getItemCount, S32, 2, 2, "") +DefineConsoleMethod(GuiTreeViewCtrl, getItemCount, S32, (), , "") { return(object->getItemCount()); } -ConsoleMethod(GuiTreeViewCtrl, getSelectedItem, S32, 2, 3, "( int index=0 ) - Return the selected item at the given index.") +DefineConsoleMethod(GuiTreeViewCtrl, getSelectedItem, S32, ( S32 index ), (0), "( int index=0 ) - Return the selected item at the given index.") { - S32 index = 0; - if( argc > 2 ) - index = dAtoi( argv[ 2 ] ); return ( object->getSelectedItem( index ) ); } -ConsoleMethod(GuiTreeViewCtrl, getSelectedObject, S32, 2, 3, "( int index=0 ) - Return the currently selected SimObject at the given index in inspector mode or -1") +DefineConsoleMethod(GuiTreeViewCtrl, getSelectedObject, S32, ( S32 index ), (0), "( int index=0 ) - Return the currently selected SimObject at the given index in inspector mode or -1") { - S32 index = 0; - if( argc > 2 ) - index = dAtoi( argv[ 2 ] ); - GuiTreeViewCtrl::Item *item = object->getItem( object->getSelectedItem( index ) ); if( item != NULL && item->isInspectorData() ) { @@ -5058,14 +5051,14 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedObject, S32, 2, 3, "( int index=0 ) - return -1; } -ConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, 2, 2, - "Returns a space sperated list of all selected object ids.") +const char* GuiTreeViewCtrl::getSelectedObjectList() { static const U32 bufSize = 1024; char* buff = Con::getReturnBuffer(bufSize); dSprintf(buff,bufSize,""); - const Vector< GuiTreeViewCtrl::Item* > selectedItems = object->getSelectedItems(); + + const Vector< GuiTreeViewCtrl::Item* > selectedItems = this->getSelectedItems(); for(S32 i = 0; i < selectedItems.size(); i++) { GuiTreeViewCtrl::Item *item = selectedItems[i]; @@ -5078,7 +5071,7 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, 2, 2, //the start of the buffer where we want to write char* buffPart = buff+len; //the size of the remaining buffer (-1 cause dStrlen doesn't count the \0) - S32 size = bufSize-len-1; + S32 size = bufSize-len-1; //write it: if(size < 1) { @@ -5093,46 +5086,50 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, 2, 2, return buff; } -ConsoleMethod(GuiTreeViewCtrl, moveItemUp, void, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, (), , + "Returns a space seperated list of all selected object ids.") { - object->moveItemUp( dAtoi( argv[2] ) ); + return object->getSelectedObjectList(); } -ConsoleMethod(GuiTreeViewCtrl, getSelectedItemsCount, S32, 2, 2, "") +DefineConsoleMethod(GuiTreeViewCtrl, moveItemUp, void, (S32 index), , "(TreeItemId item)") +{ + object->moveItemUp( index ); +} + +DefineConsoleMethod(GuiTreeViewCtrl, getSelectedItemsCount, S32, (), , "") { return ( object->getSelectedItemsCount() ); } -ConsoleMethod(GuiTreeViewCtrl, moveItemDown, void, 3, 3, "(TreeItemId item)") +DefineConsoleMethod(GuiTreeViewCtrl, moveItemDown, void, (S32 index), , "(TreeItemId item)") { - object->moveItemDown( dAtoi( argv[2] ) ); + object->moveItemDown( index ); } //----------------------------------------------------------------------------- -ConsoleMethod(GuiTreeViewCtrl, getTextToRoot, const char*,4,4,"(TreeItemId item,Delimiter=none) gets the text from the current node to the root, concatenating at each branch upward, with a specified delimiter optionally") +DefineConsoleMethod(GuiTreeViewCtrl, getTextToRoot, const char*, (S32 itemId, const char * delimiter), , + "(TreeItemId item,Delimiter=none) gets the text from the current node to the root, concatenating at each branch upward, with a specified delimiter optionally") { - if ( argc < 4 ) + if (!dStrcmp(delimiter, "" )) { Con::warnf("GuiTreeViewCtrl::getTextToRoot - Invalid number of arguments!"); return (""); } - S32 itemId = dAtoi( argv[2] ); - StringTableEntry delimiter = argv[3]; - return object->getTextToRoot( itemId, delimiter ); } -ConsoleMethod(GuiTreeViewCtrl, getSelectedItemList,const char*, 2,2,"returns a space seperated list of mulitple item ids") +DefineConsoleMethod(GuiTreeViewCtrl, getSelectedItemList,const char*, (), ,"returns a space seperated list of mulitple item ids") { - static const U32 bufSize = 1024; + const U32 bufSize = 1024; char* buff = Con::getReturnBuffer(bufSize); - dSprintf(buff,bufSize,""); + dSprintf(buff, bufSize, ""); const Vector< S32 >& selected = object->getSelected(); - for(S32 i = 0; i < selected.size(); i++) + for(int i = 0; i < selected.size(); i++) { S32 id = selected[i]; //get the current length of the buffer @@ -5171,9 +5168,9 @@ S32 GuiTreeViewCtrl::findItemByObjectId(S32 iObjId) } //------------------------------------------------------------------------------ -ConsoleMethod(GuiTreeViewCtrl, findItemByObjectId, S32, 3, 3, "(find item by object id and returns the mId)") +DefineConsoleMethod(GuiTreeViewCtrl, findItemByObjectId, S32, ( S32 itemId ), , "(find item by object id and returns the mId)") { - return(object->findItemByObjectId(dAtoi(argv[2]))); + return(object->findItemByObjectId(itemId)); } //------------------------------------------------------------------------------ @@ -5216,30 +5213,17 @@ bool GuiTreeViewCtrl::scrollVisibleByObjectId(S32 objID) } //------------------------------------------------------------------------------ -ConsoleMethod(GuiTreeViewCtrl, scrollVisibleByObjectId, S32, 3, 3, "(show item by object id. returns true if sucessful.)") +DefineConsoleMethod(GuiTreeViewCtrl, scrollVisibleByObjectId, S32, ( S32 itemId ), , "(show item by object id. returns true if sucessful.)") { - return(object->scrollVisibleByObjectId(dAtoi(argv[2]))); + return(object->scrollVisibleByObjectId(itemId)); } //------------------------------------------------------------------------------ //FIXME: this clashes with SimSet.sort() -ConsoleMethod( GuiTreeViewCtrl, sort, void, 2, 6, "( int parent, bool traverseHierarchy=false, bool parentsFirst=false, bool caseSensitive=true ) - Sorts all items of the given parent (or root). With 'hierarchy', traverses hierarchy." ) +DefineConsoleMethod( GuiTreeViewCtrl, sort, void, ( S32 parent, bool traverseHierarchy, bool parentsFirst, bool caseSensitive ), ( 0, false, false, true ), + "( int parent, bool traverseHierarchy=false, bool parentsFirst=false, bool caseSensitive=true ) - Sorts all items of the given parent (or root). With 'hierarchy', traverses hierarchy." ) { - S32 parent = 0; - if( argc >= 3 ) - parent = dAtoi( argv[ 2 ] ); - - bool traverseHierarchy = false; - bool parentsFirst = false; - bool caseSensitive = true; - - if( argc >= 4 ) - traverseHierarchy = dAtob( argv[ 3 ] ); - if( argc >= 5 ) - parentsFirst = dAtob( argv[ 4 ] ); - if( argc >= 6 ) - caseSensitive = dAtob( argv[ 5 ] ); if( !parent ) object->sortTree( caseSensitive, traverseHierarchy, parentsFirst ); @@ -5326,19 +5310,18 @@ void GuiTreeViewCtrl::showItemRenameCtrl( Item* item ) } } -ConsoleMethod( GuiTreeViewCtrl, cancelRename, void, 2, 2, "For internal use." ) +DefineConsoleMethod( GuiTreeViewCtrl, cancelRename, void, (), , "For internal use." ) { object->cancelRename(); } -ConsoleMethod( GuiTreeViewCtrl, onRenameValidate, void, 2, 2, "For internal use." ) +DefineConsoleMethod( GuiTreeViewCtrl, onRenameValidate, void, (), , "For internal use." ) { object->onRenameValidate(); } -ConsoleMethod( GuiTreeViewCtrl, showItemRenameCtrl, void, 3, 3, "( TreeItemId id ) - Show the rename text field for the given item (only one at a time)." ) +DefineConsoleMethod( GuiTreeViewCtrl, showItemRenameCtrl, void, ( S32 id ), , "( TreeItemId id ) - Show the rename text field for the given item (only one at a time)." ) { - S32 id = dAtoi( argv[ 2 ] ); GuiTreeViewCtrl::Item* item = object->getItem( id ); if( !item ) { @@ -5349,11 +5332,8 @@ ConsoleMethod( GuiTreeViewCtrl, showItemRenameCtrl, void, 3, 3, "( TreeItemId id object->showItemRenameCtrl( item ); } -ConsoleMethod( GuiTreeViewCtrl, setDebug, void, 2, 3, "( bool value=true ) - Enable/disable debug output." ) +DefineConsoleMethod( GuiTreeViewCtrl, setDebug, void, ( bool value ), (true), "( bool value=true ) - Enable/disable debug output." ) { - bool value = true; - if( argc > 2 ) - value = dAtob( argv[ 2 ] ); object->setDebug( value ); } diff --git a/Engine/source/gui/controls/guiTreeViewCtrl.h b/Engine/source/gui/controls/guiTreeViewCtrl.h index f4dc5847f..e2360ed87 100644 --- a/Engine/source/gui/controls/guiTreeViewCtrl.h +++ b/Engine/source/gui/controls/guiTreeViewCtrl.h @@ -454,6 +454,9 @@ class GuiTreeViewCtrl : public GuiArrayCtrl GuiTreeViewCtrl(); virtual ~GuiTreeViewCtrl(); + //WLE Vince, Moving this into a function so I don't have to bounce off the console. 12/05/2013 + const char* getSelectedObjectList(); + /// Used for syncing the mSelected and mSelectedItems lists. void syncSelection(); @@ -592,6 +595,7 @@ class GuiTreeViewCtrl : public GuiArrayCtrl static void initPersistFields(); void inspectObject(SimObject * obj, bool okToEdit); + S32 insertObject(S32 parentId, SimObject * obj, bool okToEdit); void buildVisibleTree(bool bForceFullUpdate = false); void cancelRename(); diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index ef7bf3630..ced5b666d 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -2015,25 +2015,18 @@ ConsoleDocFragment _pushDialog( "void pushDialog( GuiControl ctrl, int layer=0, bool center=false);" ); -ConsoleMethod( GuiCanvas, pushDialog, void, 3, 5, "(GuiControl ctrl, int layer=0, bool center=false)" +DefineConsoleMethod( GuiCanvas, pushDialog, void, (const char * ctrlName, S32 layer, bool center), ( 0, false), "(GuiControl ctrl, int layer=0, bool center=false)" "@hide") { GuiControl *gui; - if (! Sim::findObject(argv[2], gui)) + if (! Sim::findObject(ctrlName, gui)) { - Con::printf("%s(): Invalid control: %s", (const char*)argv[0], (const char*)argv[2]); + Con::printf("pushDialog(): Invalid control: %s", ctrlName); return; } //find the layer - S32 layer = 0; - if( argc > 3 ) - layer = dAtoi( argv[ 3 ] ); - - bool center = false; - if( argc > 4 ) - center = dAtob( argv[ 4 ] ); //set the new content control object->pushDialogControl(gui, layer, center); @@ -2059,19 +2052,9 @@ ConsoleDocFragment _popDialog2( "void popDialog();" ); -ConsoleMethod( GuiCanvas, popDialog, void, 2, 3, "(GuiControl ctrl=NULL)" +DefineConsoleMethod( GuiCanvas, popDialog, void, (GuiControl * gui), (NULL), "(GuiControl ctrl=NULL)" "@hide") { - GuiControl *gui = NULL; - if (argc == 3) - { - if (!Sim::findObject(argv[2], gui)) - { - Con::printf("%s(): Invalid control: %s", (const char*)argv[0], (const char*)argv[2]); - return; - } - } - if (gui) object->popDialogControl(gui); else @@ -2097,12 +2080,9 @@ ConsoleDocFragment _popLayer2( "void popLayer(S32 layer);" ); -ConsoleMethod( GuiCanvas, popLayer, void, 2, 3, "(int layer)" +DefineConsoleMethod( GuiCanvas, popLayer, void, (S32 layer), (0), "(int layer)" "@hide") { - S32 layer = 0; - if (argc == 3) - layer = dAtoi(argv[2]); object->popDialogControl(layer); } @@ -2258,15 +2238,9 @@ ConsoleDocFragment _setCursorPos2( "bool setCursorPos( F32 posX, F32 posY);" ); -ConsoleMethod( GuiCanvas, setCursorPos, void, 3, 4, "(Point2I pos)" +DefineConsoleMethod( GuiCanvas, setCursorPos, void, (Point2I pos), , "(Point2I pos)" "@hide") { - Point2I pos(0,0); - - if(argc == 4) - pos.set(dAtoi(argv[2]), dAtoi(argv[3])); - else - dSscanf(argv[2], "%d %d", &pos.x, &pos.y); object->setCursorPos(pos); } @@ -2549,7 +2523,7 @@ DefineEngineMethod( GuiCanvas, setWindowPosition, void, ( Point2I position ),, object->getPlatformWindow()->setPosition( position ); } -ConsoleMethod( GuiCanvas, isFullscreen, bool, 2, 2, "() - Is this canvas currently fullscreen?" ) +DefineConsoleMethod( GuiCanvas, isFullscreen, bool, (), , "() - Is this canvas currently fullscreen?" ) { if (Platform::getWebDeployment()) return false; @@ -2560,14 +2534,14 @@ ConsoleMethod( GuiCanvas, isFullscreen, bool, 2, 2, "() - Is this canvas current return object->getPlatformWindow()->getVideoMode().fullScreen; } -ConsoleMethod( GuiCanvas, minimizeWindow, void, 2, 2, "() - minimize this canvas' window." ) +DefineConsoleMethod( GuiCanvas, minimizeWindow, void, (), , "() - minimize this canvas' window." ) { PlatformWindow* window = object->getPlatformWindow(); if ( window ) window->minimize(); } -ConsoleMethod( GuiCanvas, isMinimized, bool, 2, 2, "()" ) +DefineConsoleMethod( GuiCanvas, isMinimized, bool, (), , "()" ) { PlatformWindow* window = object->getPlatformWindow(); if ( window ) @@ -2576,7 +2550,7 @@ ConsoleMethod( GuiCanvas, isMinimized, bool, 2, 2, "()" ) return false; } -ConsoleMethod( GuiCanvas, isMaximized, bool, 2, 2, "()" ) +DefineConsoleMethod( GuiCanvas, isMaximized, bool, (), , "()" ) { PlatformWindow* window = object->getPlatformWindow(); if ( window ) @@ -2585,28 +2559,30 @@ ConsoleMethod( GuiCanvas, isMaximized, bool, 2, 2, "()" ) return false; } -ConsoleMethod( GuiCanvas, maximizeWindow, void, 2, 2, "() - maximize this canvas' window." ) +DefineConsoleMethod( GuiCanvas, maximizeWindow, void, (), , "() - maximize this canvas' window." ) { PlatformWindow* window = object->getPlatformWindow(); if ( window ) window->maximize(); } -ConsoleMethod( GuiCanvas, restoreWindow, void, 2, 2, "() - restore this canvas' window." ) +DefineConsoleMethod( GuiCanvas, restoreWindow, void, (), , "() - restore this canvas' window." ) { PlatformWindow* window = object->getPlatformWindow(); if( window ) window->restore(); } -ConsoleMethod( GuiCanvas, setFocus, void, 2,2, "() - Claim OS input focus for this canvas' window.") +DefineConsoleMethod( GuiCanvas, setFocus, void, (), , "() - Claim OS input focus for this canvas' window.") { PlatformWindow* window = object->getPlatformWindow(); if( window ) window->setFocus(); } -ConsoleMethod( GuiCanvas, setVideoMode, void, 5, 8, +DefineConsoleMethod( GuiCanvas, setVideoMode, void, + (U32 width, U32 height, bool fullscreen, U32 bitDepth, U32 refreshRate, U32 antialiasLevel), + ( false, 0, 0, 0), "(int width, int height, bool fullscreen, [int bitDepth], [int refreshRate], [int antialiasLevel] )\n" "Change the video mode of this canvas. This method has the side effect of setting the $pref::Video::mode to the new values.\n\n" "\\param width The screen width to set.\n" @@ -2625,8 +2601,6 @@ ConsoleMethod( GuiCanvas, setVideoMode, void, 5, 8, // Update the video mode and tell the window to reset. GFXVideoMode vm = object->getPlatformWindow()->getVideoMode(); - U32 width = dAtoi(argv[2]); - U32 height = dAtoi(argv[3]); bool changed = false; if (width == 0 && height > 0) @@ -2673,28 +2647,31 @@ ConsoleMethod( GuiCanvas, setVideoMode, void, 5, 8, } if (changed) - Con::errorf("GuiCanvas::setVideoMode(): Error - Invalid resolution of (%d, %d) - attempting (%d, %d)", dAtoi(argv[2]), dAtoi(argv[3]), width, height); + { + Con::errorf("GuiCanvas::setVideoMode(): Error - Invalid resolution of (%d, %d) - attempting (%d, %d)", width, height, width, height); + } vm.resolution = Point2I(width, height); - vm.fullScreen = dAtob(argv[4]); + vm.fullScreen = fullscreen; if (Platform::getWebDeployment()) vm.fullScreen = false; // These optional params are set to default at construction of vm. If they // aren't specified, just leave them at whatever they were set to. - if ((argc > 5) && (dStrlen(argv[5]) > 0)) + if (bitDepth > 0) { - vm.bitDepth = dAtoi(argv[5]); - } - if ((argc > 6) && (dStrlen(argv[6]) > 0)) - { - vm.refreshRate = dAtoi(argv[6]); + vm.bitDepth = refreshRate; } - if ((argc > 7) && (dStrlen(argv[7]) > 0)) + if (refreshRate > 0) { - vm.antialiasLevel = dAtoi(argv[7]); + vm.refreshRate = refreshRate; + } + + if (antialiasLevel > 0) + { + vm.antialiasLevel = antialiasLevel; } object->getPlatformWindow()->setVideoMode(vm); diff --git a/Engine/source/gui/core/guiControl.cpp b/Engine/source/gui/core/guiControl.cpp index defea875c..f61a3b6dc 100644 --- a/Engine/source/gui/core/guiControl.cpp +++ b/Engine/source/gui/core/guiControl.cpp @@ -2613,17 +2613,21 @@ DefineEngineMethod( GuiControl, setValue, void, ( const char* value ),, object->setScriptValue( value ); } -ConsoleMethod( GuiControl, getValue, const char*, 2, 2, "") +//ConsoleMethod( GuiControl, getValue, const char*, 2, 2, "") +DefineConsoleMethod( GuiControl, getValue, const char*, (), , "") { return object->getScriptValue(); } -ConsoleMethod( GuiControl, makeFirstResponder, void, 3, 3, "(bool isFirst)") +//ConsoleMethod( GuiControl, makeFirstResponder, void, 3, 3, "(bool isFirst)") +DefineConsoleMethod( GuiControl, makeFirstResponder, void, (bool isFirst), , "(bool isFirst)") { - object->makeFirstResponder(dAtob(argv[2])); + //object->makeFirstResponder(dAtob(argv[2])); + object->makeFirstResponder(isFirst); } -ConsoleMethod( GuiControl, isActive, bool, 2, 2, "") +//ConsoleMethod( GuiControl, isActive, bool, 2, 2, "") +DefineConsoleMethod( GuiControl, isActive, bool, (), , "") { return object->isActive(); } @@ -2806,22 +2810,19 @@ static ConsoleDocFragment _sGuiControlSetExtent2( "GuiControl", // The class to place the method in; use NULL for functions. "void setExtent( Point2I p );" ); // The definition string. -ConsoleMethod( GuiControl, setExtent, void, 3, 4, +DefineConsoleMethod( GuiControl, setExtent, void, ( const char* extOrX, const char* y ), (""), "( Point2I p | int x, int y ) Set the width and height of the control.\n\n" "@hide" ) { - if ( argc == 3 ) + Point2I extent; + if(!dStrIsEmpty(extOrX) && dStrIsEmpty(y)) + dSscanf(extOrX, "%f %f", &extent.x, &extent.y); + else if(!dStrIsEmpty(extOrX) && !dStrIsEmpty(y)) { - // We scan for floats because its possible that math - // done on the extent can result in fractional values. - Point2F ext; - if ( dSscanf( argv[2], "%g %g", &ext.x, &ext.y ) == 2 ) - object->setExtent( (S32)ext.x, (S32)ext.y ); - else - Con::errorf( "GuiControl::setExtent, not enough parameters!" ); + extent.x = dAtof(extOrX); + extent.y = dAtof(y); } - else if ( argc == 4 ) - object->setExtent( dAtoi(argv[2]), dAtoi(argv[3]) ); + object->setExtent( extent ); } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/core/guiTypes.cpp b/Engine/source/gui/core/guiTypes.cpp index 369d9f963..f221a0d0a 100644 --- a/Engine/source/gui/core/guiTypes.cpp +++ b/Engine/source/gui/core/guiTypes.cpp @@ -24,6 +24,7 @@ #include "platform/types.h" #include "console/consoleTypes.h" #include "console/console.h" +#include "console/engineAPI.h" #include "gui/core/guiTypes.h" #include "gui/core/guiControl.h" #include "gfx/gFont.h" @@ -694,9 +695,9 @@ bool GuiControlProfile::loadFont() return true; } -ConsoleMethod( GuiControlProfile, getStringWidth, S32, 3, 3, "( pString )" ) +DefineConsoleMethod( GuiControlProfile, getStringWidth, S32, ( const char * pString ), , "( pString )" ) { - return object->mFont->getStrNWidth( argv[2], dStrlen( argv[2] ) ); + return object->mFont->getStrNWidth( pString, dStrlen( pString ) ); } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/editor/guiDebugger.cpp b/Engine/source/gui/editor/guiDebugger.cpp index b2640809d..b77a909e4 100644 --- a/Engine/source/gui/editor/guiDebugger.cpp +++ b/Engine/source/gui/editor/guiDebugger.cpp @@ -24,6 +24,7 @@ #include "gui/editor/guiDebugger.h" #include "gui/core/guiCanvas.h" +#include "console/engineAPI.h" #include "gfx/gfxDrawUtil.h" #include "core/volume.h" @@ -65,61 +66,60 @@ DbgFileView::DbgFileView() mSize.set(1, 0); } -ConsoleMethod(DbgFileView, setCurrentLine, void, 4, 4, "(int line, bool selected)" +DefineConsoleMethod(DbgFileView, setCurrentLine, void, (S32 line, bool selected), , "(int line, bool selected)" "Set the current highlighted line.") { - object->setCurrentLine(dAtoi(argv[2]), dAtob(argv[3])); + object->setCurrentLine(line, selected); } -ConsoleMethod(DbgFileView, getCurrentLine, const char *, 2, 2, "()" +DefineConsoleMethod(DbgFileView, getCurrentLine, const char *, (), , "()" "Get the currently executing file and line, if any.\n\n" "@returns A string containing the file, a tab, and then the line number." " Use getField() with this.") { S32 lineNum; const char *file = object->getCurrentLine(lineNum); - static const U32 bufSize = 256; - char* ret = Con::getReturnBuffer(bufSize); - dSprintf(ret, bufSize, "%s\t%d", file, lineNum); + char* ret = Con::getReturnBuffer(256); + dSprintf(ret, sizeof(ret), "%s\t%d", file, lineNum); return ret; } -ConsoleMethod(DbgFileView, open, bool, 3, 3, "(string filename)" +DefineConsoleMethod(DbgFileView, open, bool, (const char * filename), , "(string filename)" "Open a file for viewing.\n\n" "@note This loads the file from the local system.") { - return object->openFile(argv[2]); + return object->openFile(filename); } -ConsoleMethod(DbgFileView, clearBreakPositions, void, 2, 2, "()" +DefineConsoleMethod(DbgFileView, clearBreakPositions, void, (), , "()" "Clear all break points in the current file.") { object->clearBreakPositions(); } -ConsoleMethod(DbgFileView, setBreakPosition, void, 3, 3, "(int line)" +DefineConsoleMethod(DbgFileView, setBreakPosition, void, (U32 line), , "(int line)" "Set a breakpoint at the specified line.") { - object->setBreakPosition(dAtoi(argv[2])); + object->setBreakPosition(line); } -ConsoleMethod(DbgFileView, setBreak, void, 3, 3, "(int line)" +DefineConsoleMethod(DbgFileView, setBreak, void, (U32 line), , "(int line)" "Set a breakpoint at the specified line.") { - object->setBreakPointStatus(dAtoi(argv[2]), true); + object->setBreakPointStatus(line, true); } -ConsoleMethod(DbgFileView, removeBreak, void, 3, 3, "(int line)" +DefineConsoleMethod(DbgFileView, removeBreak, void, (U32 line), , "(int line)" "Remove a breakpoint from the specified line.") { - object->setBreakPointStatus(dAtoi(argv[2]), false); + object->setBreakPointStatus(line, false); } -ConsoleMethod(DbgFileView, findString, bool, 3, 3, "(string findThis)" +DefineConsoleMethod(DbgFileView, findString, bool, (const char * findThis), , "(string findThis)" "Find the specified string in the currently viewed file and " "scroll it into view.") { - return object->findString(argv[2]); + return object->findString(findThis); } //this value is the offset used in the ::onRender() method... diff --git a/Engine/source/gui/editor/guiEditCtrl.cpp b/Engine/source/gui/editor/guiEditCtrl.cpp index 1710ec4f5..ca1cc0fd6 100644 --- a/Engine/source/gui/editor/guiEditCtrl.cpp +++ b/Engine/source/gui/editor/guiEditCtrl.cpp @@ -2468,7 +2468,7 @@ void GuiEditCtrl::startMouseGuideDrag( guideAxis axis, U32 guideIndex, bool lock //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, getContentControl, S32, 2, 2, "() - Return the toplevel control edited inside the GUI editor." ) +DefineConsoleMethod( GuiEditCtrl, getContentControl, S32, (), , "() - Return the toplevel control edited inside the GUI editor." ) { GuiControl* ctrl = object->getContentControl(); if( ctrl ) @@ -2479,76 +2479,60 @@ ConsoleMethod( GuiEditCtrl, getContentControl, S32, 2, 2, "() - Return the tople //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, setContentControl, void, 3, 3, "( GuiControl ctrl ) - Set the toplevel control to edit in the GUI editor." ) +DefineConsoleMethod( GuiEditCtrl, setContentControl, void, (GuiControl *ctrl ), , "( GuiControl ctrl ) - Set the toplevel control to edit in the GUI editor." ) { - GuiControl *ctrl; - if(!Sim::findObject(argv[2], ctrl)) - return; - object->setContentControl(ctrl); + if (ctrl) + object->setContentControl(ctrl); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, addNewCtrl, void, 3, 3, "(GuiControl ctrl)") +DefineConsoleMethod( GuiEditCtrl, addNewCtrl, void, (GuiControl *ctrl), , "(GuiControl ctrl)") { - GuiControl *ctrl; - if(!Sim::findObject(argv[2], ctrl)) - return; - object->addNewControl(ctrl); + if (ctrl) + object->addNewControl(ctrl); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, addSelection, void, 3, 3, "selects a control.") +DefineConsoleMethod( GuiEditCtrl, addSelection, void, (S32 id), , "selects a control.") { - S32 id = dAtoi(argv[2]); object->addSelection(id); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, removeSelection, void, 3, 3, "deselects a control.") +DefineConsoleMethod( GuiEditCtrl, removeSelection, void, (S32 id), , "deselects a control.") { - S32 id = dAtoi(argv[2]); object->removeSelection(id); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, clearSelection, void, 2, 2, "Clear selected controls list.") +DefineConsoleMethod( GuiEditCtrl, clearSelection, void, (), , "Clear selected controls list.") { object->clearSelection(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, select, void, 3, 3, "(GuiControl ctrl)") +DefineConsoleMethod( GuiEditCtrl, select, void, (GuiControl *ctrl), , "(GuiControl ctrl)") { - GuiControl *ctrl; - - if(!Sim::findObject(argv[2], ctrl)) - return; - + if (ctrl) object->setSelection(ctrl, false); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, setCurrentAddSet, void, 3, 3, "(GuiControl ctrl)") +DefineConsoleMethod( GuiEditCtrl, setCurrentAddSet, void, (GuiControl *addSet), , "(GuiControl ctrl)") { - GuiControl *addSet; - - if (!Sim::findObject(argv[2], addSet)) - { - Con::printf("%s(): Invalid control: %s", (const char*)argv[0], (const char*)argv[2]); - return; - } + if (addSet) object->setCurrentAddSet(addSet); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, getCurrentAddSet, S32, 2, 2, "Returns the set to which new controls will be added") +DefineConsoleMethod( GuiEditCtrl, getCurrentAddSet, S32, (), , "Returns the set to which new controls will be added") { const GuiControl* add = object->getCurrentAddSet(); return add ? add->getId() : 0; @@ -2556,71 +2540,65 @@ ConsoleMethod( GuiEditCtrl, getCurrentAddSet, S32, 2, 2, "Returns the set to whi //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, toggle, void, 2, 2, "Toggle activation.") +DefineConsoleMethod( GuiEditCtrl, toggle, void, (), , "Toggle activation.") { object->setEditMode( !object->isActive() ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, justify, void, 3, 3, "(int mode)" ) +DefineConsoleMethod( GuiEditCtrl, justify, void, (U32 mode), , "(int mode)" ) { - object->justifySelection((GuiEditCtrl::Justification)dAtoi(argv[2])); + object->justifySelection( (GuiEditCtrl::Justification)mode ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, bringToFront, void, 2, 2, "") +DefineConsoleMethod( GuiEditCtrl, bringToFront, void, (), , "") { object->bringToFront(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, pushToBack, void, 2, 2, "") +DefineConsoleMethod( GuiEditCtrl, pushToBack, void, (), , "") { object->pushToBack(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, deleteSelection, void, 2, 2, "() - Delete the selected controls.") +DefineConsoleMethod( GuiEditCtrl, deleteSelection, void, (), , "() - Delete the selected controls.") { object->deleteSelection(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, moveSelection, void, 4, 4, "(int dx, int dy) - Move all controls in the selection by (dx,dy) pixels.") +DefineConsoleMethod( GuiEditCtrl, moveSelection, void, (Point2I pos), , "Move all controls in the selection by (dx,dy) pixels.") { - object->moveAndSnapSelection(Point2I(dAtoi(argv[2]), dAtoi(argv[3]))); + object->moveAndSnapSelection(Point2I(pos)); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, saveSelection, void, 2, 3, "( string fileName=null ) - Save selection to file or clipboard.") +DefineConsoleMethod( GuiEditCtrl, saveSelection, void, (const char * filename), (NULL), "( string fileName=null ) - Save selection to file or clipboard.") { - const char* filename = NULL; - if( argc > 2 ) - filename = argv[ 2 ]; object->saveSelection( filename ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, loadSelection, void, 2, 3, "( string fileName=null ) - Load selection from file or clipboard.") +DefineConsoleMethod( GuiEditCtrl, loadSelection, void, (const char * filename), (NULL), "( string fileName=null ) - Load selection from file or clipboard.") { - const char* filename = NULL; - if( argc > 2 ) - filename = argv[ 2 ]; object->loadSelection( filename ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, selectAll, void, 2, 2, "()") +DefineConsoleMethod( GuiEditCtrl, selectAll, void, (), , "()") { object->selectAll(); } @@ -2635,14 +2613,14 @@ DefineEngineMethod( GuiEditCtrl, getSelection, SimSet*, (),, //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, getNumSelected, S32, 2, 2, "() - Return the number of controls currently selected." ) +DefineConsoleMethod( GuiEditCtrl, getNumSelected, S32, (), , "() - Return the number of controls currently selected." ) { return object->getNumSelected(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, getSelectionGlobalBounds, const char*, 2, 2, "() - Returns global bounds of current selection as vector 'x y width height'." ) +DefineConsoleMethod( GuiEditCtrl, getSelectionGlobalBounds, const char*, (), , "() - Returns global bounds of current selection as vector 'x y width height'." ) { RectI bounds = object->getSelectionGlobalBounds(); String str = String::ToString( "%i %i %i %i", bounds.point.x, bounds.point.y, bounds.extent.x, bounds.extent.y ); @@ -2655,22 +2633,16 @@ ConsoleMethod( GuiEditCtrl, getSelectionGlobalBounds, const char*, 2, 2, "() - R //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, selectParents, void, 2, 3, "( bool addToSelection=false ) - Select parents of currently selected controls." ) +DefineConsoleMethod( GuiEditCtrl, selectParents, void, ( bool addToSelection ), (false), "( bool addToSelection=false ) - Select parents of currently selected controls." ) { - bool addToSelection = false; - if( argc > 2 ) - addToSelection = dAtob( argv[ 2 ] ); object->selectParents( addToSelection ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, selectChildren, void, 2, 3, "( bool addToSelection=false ) - Select children of currently selected controls." ) +DefineConsoleMethod( GuiEditCtrl, selectChildren, void, ( bool addToSelection ), (false), "( bool addToSelection=false ) - Select children of currently selected controls." ) { - bool addToSelection = false; - if( argc > 2 ) - addToSelection = dAtob( argv[ 2 ] ); object->selectChildren( addToSelection ); } @@ -2685,33 +2657,29 @@ DefineEngineMethod( GuiEditCtrl, getTrash, SimGroup*, (),, //----------------------------------------------------------------------------- -ConsoleMethod(GuiEditCtrl, setSnapToGrid, void, 3, 3, "GuiEditCtrl.setSnapToGrid(gridsize)") +DefineConsoleMethod(GuiEditCtrl, setSnapToGrid, void, (U32 gridsize), , "GuiEditCtrl.setSnapToGrid(gridsize)") { - U32 gridsize = dAtoi(argv[2]); object->setSnapToGrid(gridsize); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, readGuides, void, 3, 4, "( GuiControl ctrl [, int axis ] ) - Read the guides from the given control." ) +DefineConsoleMethod( GuiEditCtrl, readGuides, void, ( GuiControl* ctrl, S32 axis ), (-1), "( GuiControl ctrl [, int axis ] ) - Read the guides from the given control." ) { // Find the control. - GuiControl* ctrl; - if( !Sim::findObject( argv[ 2 ], ctrl ) ) + if( !ctrl ) { - Con::errorf( "GuiEditCtrl::readGuides - no control '%s'", (const char*)argv[ 2 ] ); return; } // Read the guides. - if( argc > 3 ) + if( axis != -1 ) { - S32 axis = dAtoi( argv[ 3 ] ); if( axis < 0 || axis > 1 ) { - Con::errorf( "GuiEditCtrl::readGuides - invalid axis '%s'", (const char*)argv[ 3 ] ); + Con::errorf( "GuiEditCtrl::readGuides - invalid axis '%s'", axis ); return; } @@ -2726,25 +2694,22 @@ ConsoleMethod( GuiEditCtrl, readGuides, void, 3, 4, "( GuiControl ctrl [, int ax //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, writeGuides, void, 3, 4, "( GuiControl ctrl [, int axis ] ) - Write the guides to the given control." ) +DefineConsoleMethod( GuiEditCtrl, writeGuides, void, ( GuiControl* ctrl, S32 axis ), ( -1), "( GuiControl ctrl [, int axis ] ) - Write the guides to the given control." ) { // Find the control. - GuiControl* ctrl; - if( !Sim::findObject( argv[ 2 ], ctrl ) ) + if( ! ctrl ) { - Con::errorf( "GuiEditCtrl::writeGuides - no control '%i'", (const char*)argv[ 2 ] ); return; } // Write the guides. - if( argc > 3 ) + if( axis != -1 ) { - S32 axis = dAtoi( argv[ 3 ] ); if( axis < 0 || axis > 1 ) { - Con::errorf( "GuiEditCtrl::writeGuides - invalid axis '%s'", (const char*)argv[ 3 ] ); + Con::errorf( "GuiEditCtrl::writeGuides - invalid axis '%s'", axis ); return; } @@ -2759,11 +2724,10 @@ ConsoleMethod( GuiEditCtrl, writeGuides, void, 3, 4, "( GuiControl ctrl [, int a //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, clearGuides, void, 2, 3, "( [ int axis ] ) - Clear all currently set guide lines." ) +DefineConsoleMethod( GuiEditCtrl, clearGuides, void, ( S32 axis ), (-1), "( [ int axis ] ) - Clear all currently set guide lines." ) { - if( argc > 2 ) + if( axis != -1 ) { - S32 axis = dAtoi( argv[ 2 ] ); if( axis < 0 || axis > 1 ) { Con::errorf( "GuiEditCtrl::clearGuides - invalid axis '%i'", axis ); @@ -2781,22 +2745,15 @@ ConsoleMethod( GuiEditCtrl, clearGuides, void, 2, 3, "( [ int axis ] ) - Clear a //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, fitIntoParents, void, 2, 4, "( bool width=true, bool height=true ) - Fit selected controls into their parents." ) +DefineConsoleMethod( GuiEditCtrl, fitIntoParents, void, (bool width, bool height), (true, true), "( bool width=true, bool height=true ) - Fit selected controls into their parents." ) { - bool width = true; - bool height = true; - - if( argc > 2 ) - width = dAtob( argv[ 2 ] ); - if( argc > 3 ) - height = dAtob( argv[ 3 ] ); object->fitIntoParents( width, height ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiEditCtrl, getMouseMode, const char*, 2, 2, "() - Return the current mouse mode." ) +DefineConsoleMethod( GuiEditCtrl, getMouseMode, const char*, (), , "() - Return the current mouse mode." ) { switch( object->getMouseMode() ) { diff --git a/Engine/source/gui/editor/guiFilterCtrl.cpp b/Engine/source/gui/editor/guiFilterCtrl.cpp index ae9a51cca..a3ea707e8 100644 --- a/Engine/source/gui/editor/guiFilterCtrl.cpp +++ b/Engine/source/gui/editor/guiFilterCtrl.cpp @@ -23,6 +23,7 @@ #include "platform/platform.h" #include "gui/editor/guiFilterCtrl.h" +#include "console/engineAPI.h" #include "console/console.h" #include "console/consoleTypes.h" #include "guiFilterCtrl.h" @@ -59,10 +60,9 @@ void GuiFilterCtrl::initPersistFields() Parent::initPersistFields(); } -ConsoleMethod( GuiFilterCtrl, getValue, const char*, 2, 2, "Return a tuple containing all the values in the filter." +DefineConsoleMethod( GuiFilterCtrl, getValue, const char*, (), , "Return a tuple containing all the values in the filter." "@internal") { - TORQUE_UNUSED(argv); static char buffer[512]; const Filter *filter = object->get(); *buffer = 0; @@ -89,7 +89,7 @@ ConsoleMethod( GuiFilterCtrl, setValue, void, 3, 20, "(f1, f2, ...)" object->set(filter); } -ConsoleMethod( GuiFilterCtrl, identity, void, 2, 2, "Reset the filtering." +DefineConsoleMethod( GuiFilterCtrl, identity, void, (), , "Reset the filtering." "@internal") { object->identity(); diff --git a/Engine/source/gui/editor/guiInspector.cpp b/Engine/source/gui/editor/guiInspector.cpp index d05e03c6d..9cb771a31 100644 --- a/Engine/source/gui/editor/guiInspector.cpp +++ b/Engine/source/gui/editor/guiInspector.cpp @@ -20,6 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- +#include "console/engineAPI.h" #include "gui/editor/guiInspector.h" #include "gui/editor/inspector/field.h" #include "gui/editor/inspector/group.h" @@ -771,14 +772,13 @@ void GuiInspector::sendInspectPostApply() //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, inspect, void, 3, 3, "Inspect(Object)") +DefineConsoleMethod( GuiInspector, inspect, void, (const char * className), , "Inspect(Object)") { - SimObject * target = Sim::findObject(argv[2]); + SimObject * target = Sim::findObject(className); if(!target) { - if(dAtoi(argv[2]) > 0) - Con::warnf("%s::inspect(): invalid object: %s", (const char*)argv[0], (const char*)argv[2]); - + if(dAtoi(className) > 0) + Con::warnf("GuiInspector::inspect(): invalid object: %s", className); object->clearInspectObjects(); return; } @@ -788,38 +788,29 @@ ConsoleMethod( GuiInspector, inspect, void, 3, 3, "Inspect(Object)") //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, addInspect, void, 3, 4, "( id object, (bool autoSync = true) ) - Add the object to the list of objects being inspected." ) +DefineConsoleMethod( GuiInspector, addInspect, void, (const char * className, bool autoSync), (true), "( id object, (bool autoSync = true) ) - Add the object to the list of objects being inspected." ) { SimObject* obj; - if( !Sim::findObject( argv[ 2 ], obj ) ) + if( !Sim::findObject( className, obj ) ) { - Con::errorf( "%s::addInspect(): invalid object: %s", (const char*)argv[ 0 ], (const char*)argv[ 2 ] ); + Con::errorf( "GuiInspector::addInspect(): invalid object: %s", className ); return; } - if( argc > 3 ) - object->addInspectObject( obj, false ); - else - object->addInspectObject( obj ); + object->addInspectObject( obj, autoSync ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, removeInspect, void, 3, 3, "( id object ) - Remove the object from the list of objects being inspected." ) +DefineConsoleMethod( GuiInspector, removeInspect, void, (SimObject* obj), , "( id object ) - Remove the object from the list of objects being inspected." ) { - SimObject* obj; - if( !Sim::findObject( argv[ 2 ], obj ) ) - { - Con::errorf( "%s::removeInspect(): invalid object: %s", (const char*)argv[ 0 ], (const char*)argv[ 2 ] ); - return; - } - - object->removeInspectObject( obj ); + if (obj) + object->removeInspectObject( obj ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, refresh, void, 2, 2, "Reinspect the currently selected object." ) +DefineConsoleMethod( GuiInspector, refresh, void, (), , "Reinspect the currently selected object." ) { if ( object->getNumInspectObjects() == 0 ) return; @@ -831,11 +822,8 @@ ConsoleMethod( GuiInspector, refresh, void, 2, 2, "Reinspect the currently selec //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, getInspectObject, const char*, 2, 3, "getInspectObject( int index=0 ) - Returns currently inspected object" ) +DefineConsoleMethod( GuiInspector, getInspectObject, const char*, (U32 index), (0), "getInspectObject( int index=0 ) - Returns currently inspected object" ) { - U32 index = 0; - if( argc > 2 ) - index = dAtoi( argv[ 2 ] ); if( index >= object->getNumInspectObjects() ) { @@ -848,40 +836,40 @@ ConsoleMethod( GuiInspector, getInspectObject, const char*, 2, 3, "getInspectObj //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, getNumInspectObjects, S32, 2, 2, "() - Return the number of objects currently being inspected." ) +DefineConsoleMethod( GuiInspector, getNumInspectObjects, S32, (), , "() - Return the number of objects currently being inspected." ) { return object->getNumInspectObjects(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, setName, void, 3, 3, "setName(NewObjectName)") +DefineConsoleMethod( GuiInspector, setName, void, (const char * newObjectName), , "setName(NewObjectName)") { - object->setName(argv[2]); + object->setName(newObjectName); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, apply, void, 2, 2, "apply() - Force application of inspected object's attributes" ) +DefineConsoleMethod( GuiInspector, apply, void, (), , "apply() - Force application of inspected object's attributes" ) { object->sendInspectPostApply(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspector, setObjectField, void, 4, 4, +DefineConsoleMethod( GuiInspector, setObjectField, void, (const char * fieldname, const char * data ), , "setObjectField( fieldname, data ) - Set a named fields value on the inspected object if it exists. This triggers all the usual callbacks that would occur if the field had been changed through the gui." ) { - object->setObjectField( argv[2], argv[3] ); + object->setObjectField( fieldname, data ); } //----------------------------------------------------------------------------- -ConsoleStaticMethod( GuiInspector, findByObject, S32, 2, 2, +DefineConsoleStaticMethod( GuiInspector, findByObject, S32, (const char * className ), , "findByObject( SimObject ) - returns the id of an awake inspector that is inspecting the passed object if one exists." ) { SimObject *obj; - if ( !Sim::findObject( argv[1], obj ) ) + if ( !Sim::findObject( className, obj ) ) return NULL; obj = GuiInspector::findByObject( obj ); diff --git a/Engine/source/gui/editor/guiMenuBar.cpp b/Engine/source/gui/editor/guiMenuBar.cpp index c8abfe72f..988c326a7 100644 --- a/Engine/source/gui/editor/guiMenuBar.cpp +++ b/Engine/source/gui/editor/guiMenuBar.cpp @@ -216,7 +216,7 @@ DefineEngineMethod(GuiMenuBar, addMenu, void, (const char* menuText, S32 menuId) } DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const char* menuItemText, S32 menuItemId, const char* accelerator, int checkGroup), - ("","",0,NULL,-1), + ("","",0,"",-1), "@brief Adds a menu item to the specified menu. The menu argument can be either the text of a menu or its id.\n\n" "@param menu Menu name or menu Id to add the new item to.\n" "@param menuItemText Text for the new menu item.\n" diff --git a/Engine/source/gui/editor/guiParticleGraphCtrl.cpp b/Engine/source/gui/editor/guiParticleGraphCtrl.cpp index 7dfc5a7eb..11dfedafc 100644 --- a/Engine/source/gui/editor/guiParticleGraphCtrl.cpp +++ b/Engine/source/gui/editor/guiParticleGraphCtrl.cpp @@ -25,6 +25,7 @@ #include "gfx/gfxDrawUtil.h" #include "console/console.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gui/core/guiCanvas.h" #include "gui/editor/guiParticleGraphCtrl.h" @@ -1008,11 +1009,10 @@ bool GuiParticleGraphCtrl::renderGraphTooltip(Point2I cursorPos, StringTableEntr return true; } -ConsoleMethod(GuiParticleGraphCtrl, setSelectedPoint, void, 3, 3, "(int point)" +DefineConsoleMethod(GuiParticleGraphCtrl, setSelectedPoint, void, (S32 point), , "(int point)" "Set the selected point on the graph.\n" "@return No return value") { - S32 point = dAtoi(argv[2]); if(point >= object->mPlots[object->mSelectedPlot].mGraphData.size() || point < 0) { Con::errorf("Invalid point to select."); @@ -1021,11 +1021,10 @@ ConsoleMethod(GuiParticleGraphCtrl, setSelectedPoint, void, 3, 3, "(int point)" object->setSelectedPoint( point ); } -ConsoleMethod(GuiParticleGraphCtrl, setSelectedPlot, void, 3, 3, "(int plotID)" +DefineConsoleMethod(GuiParticleGraphCtrl, setSelectedPlot, void, (S32 plotID), , "(int plotID)" "Set the selected plot (a.k.a. graph)." "@return No return value" ) { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); @@ -1034,11 +1033,10 @@ ConsoleMethod(GuiParticleGraphCtrl, setSelectedPlot, void, 3, 3, "(int plotID)" object->setSelectedPlot( plotID ); } -ConsoleMethod(GuiParticleGraphCtrl, clearGraph, void, 3, 3, "(int plotID)" +DefineConsoleMethod(GuiParticleGraphCtrl, clearGraph, void, (S32 plotID), , "(int plotID)" "Clear the graph of the given plot." "@return No return value") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); @@ -1047,111 +1045,73 @@ ConsoleMethod(GuiParticleGraphCtrl, clearGraph, void, 3, 3, "(int plotID)" object->clearGraph( plotID ); } -ConsoleMethod(GuiParticleGraphCtrl, clearAllGraphs, void, 2, 2, "()" +DefineConsoleMethod(GuiParticleGraphCtrl, clearAllGraphs, void, (), , "()" "Clear all of the graphs." "@return No return value") { object->clearAllGraphs(); } -ConsoleMethod(GuiParticleGraphCtrl, addPlotPoint, const char*, 5, 6, "(int plotID, float x, float y, bool setAdded = true;)" +DefineConsoleMethod(GuiParticleGraphCtrl, addPlotPoint, S32, (S32 plotID, F32 x, F32 y, bool setAdded), (true), "(int plotID, float x, float y, bool setAdded = true;)" "Add a data point to the given plot." "@return") { - S32 plotID = dAtoi(argv[2]); - S32 pointAdded = 0; - static const U32 bufSize = 32; - char *retBuffer = Con::getReturnBuffer(bufSize); - + if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); - dSprintf(retBuffer, bufSize, "%d", -2); - return retBuffer; + return -2; } - - if(argc == 5) - { - pointAdded = object->addPlotPoint( plotID, Point2F(dAtof(argv[3]), dAtof(argv[4]))); - } else if(argc == 6) - { - pointAdded = object->addPlotPoint( plotID, Point2F(dAtof(argv[3]), dAtof(argv[4])), dAtob(argv[5])); - } - - - dSprintf(retBuffer, bufSize, "%d", pointAdded); - - return retBuffer; + return object->addPlotPoint( plotID, Point2F(x, y), setAdded); } -ConsoleMethod(GuiParticleGraphCtrl, insertPlotPoint, void, 6, 6, "(int plotID, int i, float x, float y)\n" +DefineConsoleMethod(GuiParticleGraphCtrl, insertPlotPoint, void, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)\n" "Insert a data point to the given plot and plot position.\n" "@param plotID The plot you want to access\n" "@param i The data point.\n" "@param x,y The plot position.\n" "@return No return value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); return; } - object->insertPlotPoint( plotID, dAtoi(argv[3]), Point2F(dAtof(argv[4]), dAtof(argv[5]))); + object->insertPlotPoint( plotID, i, Point2F(x, y)); } -ConsoleMethod(GuiParticleGraphCtrl, changePlotPoint, const char*, 6, 6, "(int plotID, int i, float x, float y)" +DefineConsoleMethod(GuiParticleGraphCtrl, changePlotPoint, S32, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)" "Change a data point to the given plot and plot position.\n" "@param plotID The plot you want to access\n" "@param i The data point.\n" "@param x,y The plot position.\n" "@return No return value.") { - S32 plotID = dAtoi(argv[2]); - static const U32 bufSize = 64; if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); - - char *retBuffer = Con::getReturnBuffer(bufSize); - const S32 index = -1; - dSprintf(retBuffer, bufSize, "%d", index); - return retBuffer; + return -1; } - - char *retBuffer = Con::getReturnBuffer(bufSize); - const S32 index = object->changePlotPoint( plotID, dAtoi(argv[3]), Point2F(dAtof(argv[4]), dAtof(argv[5]))); - dSprintf(retBuffer, bufSize, "%d", index); - return retBuffer; + return object->changePlotPoint( plotID, i, Point2F(x, y)); } -ConsoleMethod(GuiParticleGraphCtrl, getSelectedPlot, const char*, 2, 2, "() " +DefineConsoleMethod(GuiParticleGraphCtrl, getSelectedPlot, S32, (), , "() " "Gets the selected Plot (a.k.a. graph).\n" "@return The plot's ID.") { - static const U32 bufSize = 32; - char *retBuffer = Con::getReturnBuffer(bufSize); - const S32 plot = object->getSelectedPlot(); - dSprintf(retBuffer, bufSize, "%d", plot); - return retBuffer; + return object->getSelectedPlot(); } -ConsoleMethod(GuiParticleGraphCtrl, getSelectedPoint, const char*, 2, 2, "()" +DefineConsoleMethod(GuiParticleGraphCtrl, getSelectedPoint, S32, (), , "()" "Gets the selected Point on the Plot (a.k.a. graph)." "@return The last selected point ID") { - static const U32 bufSize = 32; - char *retBuffer = Con::getReturnBuffer(bufSize); - const S32 point = object->getSelectedPoint(); - dSprintf(retBuffer, bufSize, "%d", point); - return retBuffer; + return object->getSelectedPoint(); } -ConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, const char*, 4, 4, "(int plotID, int samples)" +DefineConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, bool, (S32 plotID, S32 samples), , "(int plotID, int samples)" "@return Returns true or false whether or not the point in the plot passed is an existing point.") { - S32 plotID = dAtoi(argv[2]); - S32 samples = dAtoi(argv[3]); if(plotID > object->MaxPlots) { @@ -1161,20 +1121,13 @@ ConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, const char*, 4, 4, "(int pl { Con::errorf("Invalid sample."); } - - static const U32 bufSize = 32; - char *retBuffer = Con::getReturnBuffer(bufSize); - const bool isPoint = object->isExistingPoint(plotID, samples); - dSprintf(retBuffer, bufSize, "%d", isPoint); - return retBuffer; + return object->isExistingPoint(plotID, samples); } -ConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, const char*, 4, 4, "(int plotID, int samples)" +DefineConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, Point2F, (S32 plotID, S32 samples), , "(int plotID, int samples)" "Get a data point from the plot specified, samples from the start of the graph." "@return The data point ID") { - S32 plotID = dAtoi(argv[2]); - S32 samples = dAtoi(argv[3]); if(plotID > object->MaxPlots) { @@ -1185,114 +1138,86 @@ ConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, const char*, 4, 4, "(int plotI Con::errorf("Invalid sample."); } - static const U32 bufSize = 64; - char *retBuffer = Con::getReturnBuffer(bufSize); - const Point2F &pos = object->getPlotPoint(plotID, samples); - dSprintf(retBuffer, bufSize, "%f %f", pos.x, pos.y); - return retBuffer; + + return object->getPlotPoint(plotID, samples); } -ConsoleMethod(GuiParticleGraphCtrl, getPlotIndex, const char*, 5, 5, "(int plotID, float x, float y)\n" +DefineConsoleMethod(GuiParticleGraphCtrl, getPlotIndex, S32, (S32 plotID, F32 x, F32 y), , "(int plotID, float x, float y)\n" "Gets the index of the point passed on the plotID passed (graph ID).\n" "@param plotID The plot you wish to check.\n" "@param x,y The coordinates of the point to get.\n" "@return Returns the index of the point.\n") { - S32 plotID = dAtoi(argv[2]); - F32 x = dAtof(argv[3]); - F32 y = dAtof(argv[4]); if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); } - - static const U32 bufSize = 32; - char *retBuffer = Con::getReturnBuffer(bufSize); - const S32 &index = object->getPlotIndex(plotID, x, y); - dSprintf(retBuffer, bufSize, "%d", index); - return retBuffer; + return object->getPlotIndex(plotID, x, y); } -ConsoleMethod(GuiParticleGraphCtrl, getGraphColor, const char*, 3, 3, "(int plotID)" +DefineConsoleMethod(GuiParticleGraphCtrl, getGraphColor, ColorF, (S32 plotID), , "(int plotID)" "Get the color of the graph passed." "@return Returns the color of the graph as a string of RGB values formatted as \"R G B\"") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); } - - static const U32 bufSize = 64; - char *retBuffer = Con::getReturnBuffer(bufSize); - const ColorF &color = object->getGraphColor(plotID); - dSprintf(retBuffer, bufSize, "%f %f %f", color.red, color.green, color.blue); - return retBuffer; + + return object->getGraphColor(plotID); + } -ConsoleMethod(GuiParticleGraphCtrl, getGraphMin, const char*, 3, 3, "(int plotID) " +DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMin, Point2F, (S32 plotID), , "(int plotID) " "Get the minimum values of the graph ranges.\n" "@return Returns the minimum of the range formatted as \"x-min y-min\"") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); } - - static const U32 bufSize = 64; - char *retBuffer = Con::getReturnBuffer(bufSize); - const Point2F graphMin = object->getGraphMin(plotID); - dSprintf(retBuffer, bufSize, "%f %f", graphMin.x, graphMin.y); - return retBuffer; + return object->getGraphMin(plotID); } -ConsoleMethod(GuiParticleGraphCtrl, getGraphMax, const char*, 3, 3, "(int plotID) " +DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMax, Point2F, (S32 plotID), , "(int plotID) " "Get the maximum values of the graph ranges.\n" "@return Returns the maximum of the range formatted as \"x-max y-max\"") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); } - - static const U32 bufSize = 64; - char *retBuffer = Con::getReturnBuffer(bufSize); - const Point2F graphMax = object->getGraphMax(plotID); - dSprintf(retBuffer, bufSize, "%f %f", graphMax.x, graphMax.y); - return retBuffer; + return object->getGraphMax(plotID); + } -ConsoleMethod(GuiParticleGraphCtrl, getGraphName, const char*, 3, 3, "(int plotID) " +DefineConsoleMethod(GuiParticleGraphCtrl, getGraphName, const char*, (S32 plotID), , "(int plotID) " "Get the name of the graph passed.\n" "@return Returns the name of the plot") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { Con::errorf("Invalid plotID."); } - static const U32 bufSize = 64; + const U32 bufSize = 64; char *retBuffer = Con::getReturnBuffer(bufSize); const StringTableEntry graphName = object->getGraphName(plotID); dSprintf(retBuffer, bufSize, "%s", graphName); return retBuffer; } -ConsoleMethod(GuiParticleGraphCtrl, setGraphMin, void, 5, 5, "(int plotID, float minX, float minY) " +DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMin, void, (S32 plotID, F32 minX, F32 minY), , "(int plotID, float minX, float minY) " "Set the min values of the graph of plotID.\n" "@param plotID The plot to modify\n" "@param minX,minY The minimum bound of the value range.\n" "@return No return value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { @@ -1300,16 +1225,15 @@ ConsoleMethod(GuiParticleGraphCtrl, setGraphMin, void, 5, 5, "(int plotID, float return; } - object->setGraphMin(dAtoi(argv[2]), Point2F(dAtof(argv[3]), dAtof(argv[4]))); + object->setGraphMin(plotID, Point2F(minX, minY)); } -ConsoleMethod(GuiParticleGraphCtrl, setGraphMinX, void, 4, 4, "(int plotID, float minX) " +DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMinX, void, (S32 plotID, F32 minX), , "(int plotID, float minX) " "Set the min X value of the graph of plotID.\n" "@param plotID The plot to modify.\n" "@param minX The minimum x value.\n" "@return No return Value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { @@ -1317,16 +1241,15 @@ ConsoleMethod(GuiParticleGraphCtrl, setGraphMinX, void, 4, 4, "(int plotID, floa return; } - object->setGraphMinX(dAtoi(argv[2]), dAtof(argv[3])); + object->setGraphMinX(plotID, minX); } -ConsoleMethod(GuiParticleGraphCtrl, setGraphMinY, void, 4, 4, "(int plotID, float minY) " +DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMinY, void, (S32 plotID, F32 minX), , "(int plotID, float minY) " "Set the min Y value of the graph of plotID." "@param plotID The plot to modify.\n" "@param minY The minimum y value.\n" "@return No return Value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { @@ -1334,16 +1257,15 @@ ConsoleMethod(GuiParticleGraphCtrl, setGraphMinY, void, 4, 4, "(int plotID, floa return; } - object->setGraphMinY(dAtoi(argv[2]), dAtof(argv[3])); + object->setGraphMinY(plotID, minX); } -ConsoleMethod(GuiParticleGraphCtrl, setGraphMax, void, 5, 5, "(int plotID, float maxX, float maxY) " +DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMax, void, (S32 plotID, F32 maxX, F32 maxY), , "(int plotID, float maxX, float maxY) " "Set the max values of the graph of plotID." "@param plotID The plot to modify\n" "@param maxX,maxY The maximum bound of the value range.\n" "@return No return value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { @@ -1351,16 +1273,15 @@ ConsoleMethod(GuiParticleGraphCtrl, setGraphMax, void, 5, 5, "(int plotID, float return; } - object->setGraphMax(dAtoi(argv[2]), Point2F(dAtof(argv[3]), dAtof(argv[4]))); + object->setGraphMax(plotID, Point2F(maxX, maxY)); } -ConsoleMethod(GuiParticleGraphCtrl, setGraphMaxX, void, 4, 4, "(int plotID, float maxX)" +DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMaxX, void, (S32 plotID, F32 maxX), , "(int plotID, float maxX)" "Set the max X value of the graph of plotID." "@param plotID The plot to modify.\n" "@param maxX The maximum x value.\n" "@return No return Value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { @@ -1368,16 +1289,15 @@ ConsoleMethod(GuiParticleGraphCtrl, setGraphMaxX, void, 4, 4, "(int plotID, floa return; } - object->setGraphMaxX(dAtoi(argv[2]), dAtof(argv[3])); + object->setGraphMaxX(plotID, maxX); } -ConsoleMethod(GuiParticleGraphCtrl, setGraphMaxY, void, 4, 4, "(int plotID, float maxY)" +DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMaxY, void, (S32 plotID, F32 maxX), , "(int plotID, float maxY)" "Set the max Y value of the graph of plotID." "@param plotID The plot to modify.\n" "@param maxY The maximum y value.\n" "@return No return Value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { @@ -1385,14 +1305,13 @@ ConsoleMethod(GuiParticleGraphCtrl, setGraphMaxY, void, 4, 4, "(int plotID, floa return; } - object->setGraphMaxY(dAtoi(argv[2]), dAtof(argv[3])); + object->setGraphMaxY(plotID, maxX); } -ConsoleMethod(GuiParticleGraphCtrl, setGraphHidden, void, 4, 4, "(int plotID, bool isHidden)" +DefineConsoleMethod(GuiParticleGraphCtrl, setGraphHidden, void, (S32 plotID, bool isHidden), , "(int plotID, bool isHidden)" "Set whether the graph number passed is hidden or not." "@return No return value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { @@ -1400,52 +1319,51 @@ ConsoleMethod(GuiParticleGraphCtrl, setGraphHidden, void, 4, 4, "(int plotID, bo return; } - object->setGraphHidden(dAtoi(argv[2]), dAtob(argv[3])); + object->setGraphHidden(plotID, isHidden); } -ConsoleMethod(GuiParticleGraphCtrl, setAutoGraphMax, void, 3, 3, "(bool autoMax) " +DefineConsoleMethod(GuiParticleGraphCtrl, setAutoGraphMax, void, (bool autoMax), , "(bool autoMax) " "Set whether the max will automatically be set when adding points " "(ie if you add a value over the current max, the max is increased to that value).\n" "@return No return value.") { - object->setAutoGraphMax(dAtob(argv[2])); + object->setAutoGraphMax(autoMax); } -ConsoleMethod(GuiParticleGraphCtrl, setAutoRemove, void, 3, 3, "(bool autoRemove) " +DefineConsoleMethod(GuiParticleGraphCtrl, setAutoRemove, void, (bool autoRemove), , "(bool autoRemove) " "Set whether or not a point should be deleted when you drag another one over it." "@return No return value.") { - object->setAutoRemove(dAtob(argv[2])); + object->setAutoRemove(autoRemove); } -ConsoleMethod(GuiParticleGraphCtrl, setRenderAll, void, 3, 3, "(bool renderAll)" +DefineConsoleMethod(GuiParticleGraphCtrl, setRenderAll, void, (bool autoRemove), , "(bool renderAll)" "Set whether or not a position should be rendered on every point or just the last selected." "@return No return value.") { - object->setRenderAll(dAtob(argv[2])); + object->setRenderAll(autoRemove); } -ConsoleMethod(GuiParticleGraphCtrl, setPointXMovementClamped, void, 3, 3, "(bool clamped)" +DefineConsoleMethod(GuiParticleGraphCtrl, setPointXMovementClamped, void, (bool autoRemove), , "(bool clamped)" "Set whether the x position of the selected graph point should be clamped" "@return No return value.") { - object->setPointXMovementClamped(dAtob(argv[2])); + object->setPointXMovementClamped(autoRemove); } -ConsoleMethod(GuiParticleGraphCtrl, setRenderGraphTooltip, void, 3, 3, "(bool renderGraphTooltip)" +DefineConsoleMethod(GuiParticleGraphCtrl, setRenderGraphTooltip, void, (bool autoRemove), , "(bool renderGraphTooltip)" "Set whether or not to render the graph tooltip." "@return No return value.") { - object->setRenderGraphTooltip(dAtob(argv[2])); + object->setRenderGraphTooltip(autoRemove); } -ConsoleMethod(GuiParticleGraphCtrl, setGraphName, void, 4, 4, "(int plotID, string graphName) " +DefineConsoleMethod(GuiParticleGraphCtrl, setGraphName, void, (S32 plotID, const char * graphName), , "(int plotID, string graphName) " "Set the name of the given plot.\n" "@param plotID The plot to modify.\n" "@param graphName The name to set on the plot.\n" "@return No return value.") { - S32 plotID = dAtoi(argv[2]); if(plotID > object->MaxPlots) { @@ -1453,10 +1371,10 @@ ConsoleMethod(GuiParticleGraphCtrl, setGraphName, void, 4, 4, "(int plotID, stri return; } - object->setGraphName(dAtoi(argv[2]), argv[3]); + object->setGraphName(plotID, graphName); } -ConsoleMethod(GuiParticleGraphCtrl, resetSelectedPoint, void, 2, 2, "()" +DefineConsoleMethod(GuiParticleGraphCtrl, resetSelectedPoint, void, (), , "()" "This will reset the currently selected point to nothing." "@return No return value.") { diff --git a/Engine/source/gui/editor/guiRectHandles.cpp b/Engine/source/gui/editor/guiRectHandles.cpp index fa98ab3b9..fb1938ba1 100644 --- a/Engine/source/gui/editor/guiRectHandles.cpp +++ b/Engine/source/gui/editor/guiRectHandles.cpp @@ -22,6 +22,7 @@ #include "console/console.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gfx/gfxDevice.h" #include "gfx/gfxDrawUtil.h" diff --git a/Engine/source/gui/editor/inspector/dynamicField.cpp b/Engine/source/gui/editor/inspector/dynamicField.cpp index 13f77a797..d028a6c7a 100644 --- a/Engine/source/gui/editor/inspector/dynamicField.cpp +++ b/Engine/source/gui/editor/inspector/dynamicField.cpp @@ -24,6 +24,7 @@ #include "gui/editor/inspector/dynamicGroup.h" #include "gui/editor/guiInspector.h" #include "gui/buttons/guiIconButtonCtrl.h" +#include "console/engineAPI.h" //----------------------------------------------------------------------------- // GuiInspectorDynamicField - Child class of GuiInspectorField @@ -315,7 +316,7 @@ void GuiInspectorDynamicField::_executeSelectedCallback() Con::executef( mInspector, "onFieldSelected", mDynField->slotName, "TypeDynamicField" ); } -ConsoleMethod( GuiInspectorDynamicField, renameField, void, 3,3, "field.renameField(newDynamicFieldName);" ) +DefineConsoleMethod( GuiInspectorDynamicField, renameField, void, (const char* newDynamicFieldName),, "field.renameField(newDynamicFieldName);" ) { - object->renameField( argv[ 2 ] ); + object->renameField( newDynamicFieldName ); } diff --git a/Engine/source/gui/editor/inspector/dynamicGroup.cpp b/Engine/source/gui/editor/inspector/dynamicGroup.cpp index 1e9d19caf..ef5d98b3a 100644 --- a/Engine/source/gui/editor/inspector/dynamicGroup.cpp +++ b/Engine/source/gui/editor/inspector/dynamicGroup.cpp @@ -24,6 +24,7 @@ #include "gui/editor/guiInspector.h" #include "gui/editor/inspector/dynamicGroup.h" #include "gui/editor/inspector/dynamicField.h" +#include "console/engineAPI.h" IMPLEMENT_CONOBJECT(GuiInspectorDynamicGroup); @@ -176,7 +177,7 @@ void GuiInspectorDynamicGroup::updateAllFields() inspectGroup(); } -ConsoleMethod(GuiInspectorDynamicGroup, inspectGroup, bool, 2, 2, "Refreshes the dynamic fields in the inspector.") +DefineConsoleMethod(GuiInspectorDynamicGroup, inspectGroup, bool, (), , "Refreshes the dynamic fields in the inspector.") { return object->inspectGroup(); } @@ -251,11 +252,11 @@ void GuiInspectorDynamicGroup::addDynamicField() instantExpand(); } -ConsoleMethod( GuiInspectorDynamicGroup, addDynamicField, void, 2, 2, "obj.addDynamicField();" ) +DefineConsoleMethod( GuiInspectorDynamicGroup, addDynamicField, void, (), , "obj.addDynamicField();" ) { object->addDynamicField(); } -ConsoleMethod( GuiInspectorDynamicGroup, removeDynamicField, void, 3, 3, "" ) +DefineConsoleMethod( GuiInspectorDynamicGroup, removeDynamicField, void, (), , "" ) { } diff --git a/Engine/source/gui/editor/inspector/field.cpp b/Engine/source/gui/editor/inspector/field.cpp index 5dd9e6c25..b2023ffb2 100644 --- a/Engine/source/gui/editor/inspector/field.cpp +++ b/Engine/source/gui/editor/inspector/field.cpp @@ -20,6 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- +#include "console/engineAPI.h" #include "platform/platform.h" #include "gui/editor/inspector/field.h" #include "gui/buttons/guiIconButtonCtrl.h" @@ -615,53 +616,49 @@ void GuiInspectorField::_setFieldDocs( StringTableEntry docs ) //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspectorField, getInspector, S32, 2, 2, "() - Return the GuiInspector to which this field belongs." ) +DefineConsoleMethod( GuiInspectorField, getInspector, S32, (), , "() - Return the GuiInspector to which this field belongs." ) { return object->getInspector()->getId(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspectorField, getInspectedFieldName, const char*, 2, 2, "() - Return the name of the field edited by this inspector field." ) +DefineConsoleMethod( GuiInspectorField, getInspectedFieldName, const char*, (), , "() - Return the name of the field edited by this inspector field." ) { return object->getFieldName(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspectorField, getInspectedFieldType, const char*, 2, 2, "() - Return the type of the field edited by this inspector field." ) +DefineConsoleMethod( GuiInspectorField, getInspectedFieldType, const char*, (), , "() - Return the type of the field edited by this inspector field." ) { return object->getFieldType(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspectorField, apply, void, 3, 4, "( string newValue, bool callbacks=true ) - Set the field's value. Suppress callbacks for undo if callbacks=false." ) +DefineConsoleMethod( GuiInspectorField, apply, void, ( const char * newValue, bool callbacks ), (true), "( string newValue, bool callbacks=true ) - Set the field's value. Suppress callbacks for undo if callbacks=false." ) { - bool callbacks = true; - if( argc > 3 ) - callbacks = dAtob( argv[ 3 ] ); - - object->setData( argv[ 2 ], callbacks ); + object->setData( newValue, callbacks ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspectorField, applyWithoutUndo, void, 3, 3, "() - Set field value without recording undo (same as 'apply( value, false )')." ) +DefineConsoleMethod( GuiInspectorField, applyWithoutUndo, void, (const char * data), , "() - Set field value without recording undo (same as 'apply( value, false )')." ) { - object->setData( argv[ 2 ], false ); + object->setData( data, false ); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspectorField, getData, const char*, 2, 2, "() - Return the value currently displayed on the field." ) +DefineConsoleMethod( GuiInspectorField, getData, const char*, (), , "() - Return the value currently displayed on the field." ) { return object->getData(); } //----------------------------------------------------------------------------- -ConsoleMethod( GuiInspectorField, reset, void, 2, 2, "() - Reset to default value." ) +DefineConsoleMethod( GuiInspectorField, reset, void, (), , "() - Reset to default value." ) { object->resetData(); } diff --git a/Engine/source/gui/editor/inspector/variableInspector.cpp b/Engine/source/gui/editor/inspector/variableInspector.cpp index 62993d600..12c33cdcc 100644 --- a/Engine/source/gui/editor/inspector/variableInspector.cpp +++ b/Engine/source/gui/editor/inspector/variableInspector.cpp @@ -22,6 +22,7 @@ #include "gui/editor/inspector/variableInspector.h" #include "gui/editor/inspector/variableGroup.h" +#include "console/engineAPI.h" GuiVariableInspector::GuiVariableInspector() { @@ -61,7 +62,7 @@ void GuiVariableInspector::loadVars( String searchStr ) //group->inspectGroup(); } -ConsoleMethod( GuiVariableInspector, loadVars, void, 3, 3, "loadVars( searchString )" ) +DefineConsoleMethod( GuiVariableInspector, loadVars, void, ( const char * searchString ), , "loadVars( searchString )" ) { - object->loadVars( argv[2] ); + object->loadVars( searchString ); } \ No newline at end of file diff --git a/Engine/source/gui/game/guiChunkedBitmapCtrl.cpp b/Engine/source/gui/game/guiChunkedBitmapCtrl.cpp index 636171609..735607224 100644 --- a/Engine/source/gui/game/guiChunkedBitmapCtrl.cpp +++ b/Engine/source/gui/game/guiChunkedBitmapCtrl.cpp @@ -31,35 +31,8 @@ #include "gfx/gfxDrawUtil.h" #include "console/engineAPI.h" +#include "guiChunkedBitmapCtrl.h" -class GuiChunkedBitmapCtrl : public GuiControl -{ -private: - typedef GuiControl Parent; - void renderRegion(const Point2I &offset, const Point2I &extent); - -protected: - StringTableEntry mBitmapName; - GFXTexHandle mTexHandle; - bool mUseVariable; - bool mTile; - -public: - //creation methods - DECLARE_CONOBJECT(GuiChunkedBitmapCtrl); - DECLARE_CATEGORY( "Gui Images" ); - - GuiChunkedBitmapCtrl(); - static void initPersistFields(); - - //Parental methods - bool onWake(); - void onSleep(); - - void setBitmap(const char *name); - - void onRender(Point2I offset, const RectI &updateRect); -}; IMPLEMENT_CONOBJECT(GuiChunkedBitmapCtrl); diff --git a/Engine/source/gui/game/guiChunkedBitmapCtrl.h b/Engine/source/gui/game/guiChunkedBitmapCtrl.h new file mode 100644 index 000000000..41bc26d19 --- /dev/null +++ b/Engine/source/gui/game/guiChunkedBitmapCtrl.h @@ -0,0 +1,37 @@ +#include "console/console.h" +#include "console/consoleTypes.h" +#include "gfx/bitmap/gBitmap.h" +#include "gui/core/guiControl.h" +#include "gfx/gfxDevice.h" +#include "gfx/gfxTextureHandle.h" +#include "gfx/gfxDrawUtil.h" +#include "console/engineAPI.h" + +class GuiChunkedBitmapCtrl : public GuiControl +{ +private: + typedef GuiControl Parent; + void renderRegion(const Point2I &offset, const Point2I &extent); + +protected: + StringTableEntry mBitmapName; + GFXTexHandle mTexHandle; + bool mUseVariable; + bool mTile; + +public: + //creation methods + DECLARE_CONOBJECT(GuiChunkedBitmapCtrl); + DECLARE_CATEGORY( "Gui Images" ); + + GuiChunkedBitmapCtrl(); + static void initPersistFields(); + + //Parental methods + bool onWake(); + void onSleep(); + + void setBitmap(const char *name); + + void onRender(Point2I offset, const RectI &updateRect); +}; \ No newline at end of file diff --git a/Engine/source/gui/game/guiIdleCamFadeBitmapCtrl.cpp b/Engine/source/gui/game/guiIdleCamFadeBitmapCtrl.cpp index d648a4177..17cc97548 100644 --- a/Engine/source/gui/game/guiIdleCamFadeBitmapCtrl.cpp +++ b/Engine/source/gui/game/guiIdleCamFadeBitmapCtrl.cpp @@ -25,6 +25,7 @@ #include "console/console.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gfx/gfxDrawUtil.h" @@ -176,13 +177,13 @@ ConsoleDocClass( GuiIdleCamFadeBitmapCtrl, "This is going to be deprecated, and any useful code ported to FadeinBitmap\n\n" "@internal"); -ConsoleMethod(GuiIdleCamFadeBitmapCtrl, fadeIn, void, 2, 2, "()" +DefineConsoleMethod(GuiIdleCamFadeBitmapCtrl, fadeIn, void, (), , "()" "@internal") { object->fadeIn(); } -ConsoleMethod(GuiIdleCamFadeBitmapCtrl, fadeOut, void, 2, 2, "()" +DefineConsoleMethod(GuiIdleCamFadeBitmapCtrl, fadeOut, void, (), , "()" "@internal") { object->fadeOut(); diff --git a/Engine/source/gui/shiny/guiTickCtrl.cpp b/Engine/source/gui/shiny/guiTickCtrl.cpp index 015e84d1e..fa788ea7b 100644 --- a/Engine/source/gui/shiny/guiTickCtrl.cpp +++ b/Engine/source/gui/shiny/guiTickCtrl.cpp @@ -20,6 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- #include "gui/shiny/guiTickCtrl.h" +#include "console/engineAPI.h" IMPLEMENT_CONOBJECT( GuiTickCtrl ); @@ -57,10 +58,8 @@ static ConsoleDocFragment _setProcessTicks( "GuiTickCtrl", "void setProcessTicks( bool tick )" ); -ConsoleMethod( GuiTickCtrl, setProcessTicks, void, 2, 3, "( [tick = true] ) - This will set this object to either be processing ticks or not" ) + +DefineConsoleMethod( GuiTickCtrl, setProcessTicks, void, (bool tick), (true), "( [tick = true] ) - This will set this object to either be processing ticks or not" ) { - if( argc == 3 ) - object->setProcessTicks( dAtob( argv[2] ) ); - else - object->setProcessTicks(); + object->setProcessTicks(tick); } \ No newline at end of file diff --git a/Engine/source/gui/utility/messageVector.cpp b/Engine/source/gui/utility/messageVector.cpp index 2c0c18fb4..eec551069 100644 --- a/Engine/source/gui/utility/messageVector.cpp +++ b/Engine/source/gui/utility/messageVector.cpp @@ -258,15 +258,12 @@ static ConsoleDocFragment _MessageVectordump2( "MessageVector", "void dump( string filename, string header);"); -ConsoleMethod( MessageVector, dump, void, 3, 4, "(string filename, string header=NULL)" +DefineConsoleMethod( MessageVector, dump, void, (const char * filename, const char * header), (""), "(string filename, string header=NULL)" "Dump the message vector to a file, optionally prefixing a header." "@hide") { - if ( argc == 4 ) - object->dump( argv[2], argv[3] ); - else - object->dump( argv[2] ); + object->dump( filename, header ); } DefineEngineMethod( MessageVector, getNumLines, S32, (),, diff --git a/Engine/source/gui/worldEditor/creator.cpp b/Engine/source/gui/worldEditor/creator.cpp index d2c8ce1de..31e159f52 100644 --- a/Engine/source/gui/worldEditor/creator.cpp +++ b/Engine/source/gui/worldEditor/creator.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- #include "platform/platform.h" +#include "console/engineAPI.h" #include "gui/worldEditor/creator.h" #include "gfx/gfxDrawUtil.h" @@ -218,37 +219,38 @@ void CreatorTree::sort() } //------------------------------------------------------------------------------ -ConsoleMethod( CreatorTree, addGroup, S32, 4, 4, "(string group, string name, string value)") +DefineConsoleMethod( CreatorTree, addGroup, S32, (S32 group, const char * name, const char * value), , "(string group, string name, string value)") { - CreatorTree::Node * grp = object->findNode(dAtoi(argv[2])); + CreatorTree::Node * grp = object->findNode(group); if(!grp || !grp->isGroup()) return(-1); // return same named group if found... for(U32 i = 0; i < grp->mChildren.size(); i++) - if(!dStricmp(argv[3], grp->mChildren[i]->mName)) + if(!dStricmp(name, grp->mChildren[i]->mName)) return(grp->mChildren[i]->mId); - CreatorTree::Node * node = object->createNode(argv[3], 0, true, grp); + CreatorTree::Node * node = object->createNode(name, 0, true, grp); object->build(); return(node ? node->getId() : -1); } -ConsoleMethod( CreatorTree, addItem, S32, 5, 5, "(Node group, string name, string value)") +DefineConsoleMethod( CreatorTree, addItem, S32, (S32 group, const char * name, const char * value), , "(Node group, string name, string value)") { - CreatorTree::Node * grp = object->findNode(dAtoi(argv[2])); + CreatorTree::Node * grp = object->findNode(group); if(!grp || !grp->isGroup()) return -1; - CreatorTree::Node * node = object->createNode(argv[3], argv[4], false, grp); + CreatorTree::Node * node = object->createNode(name, value, false, grp); object->build(); return(node ? node->getId() : -1); } //------------------------------------------------------------------------------ -ConsoleMethod( CreatorTree, fileNameMatch, bool, 5, 5, "(string world, string type, string filename)"){ +DefineConsoleMethod( CreatorTree, fileNameMatch, bool, (const char * world, const char * type, const char * filename), , "(string world, string type, string filename)") +{ // argv[2] - world short // argv[3] - type short // argv[4] - filename @@ -256,50 +258,50 @@ ConsoleMethod( CreatorTree, fileNameMatch, bool, 5, 5, "(string world, string ty // interior filenames // 0 - world short ('b', 'x', ...) // 1-> - type short ('towr', 'bunk', ...) - U32 typeLen = dStrlen(argv[3]); - if(dStrlen(argv[4]) < (typeLen + 1)) + U32 typeLen = dStrlen(type); + if(dStrlen(filename) < (typeLen + 1)) return(false); // world - if(dToupper(argv[4][0]) != dToupper(argv[2][0])) + if(dToupper(filename[0]) != dToupper(world[0])) return(false); - return(!dStrnicmp(((const char*)argv[4])+1, argv[3], typeLen)); + return(!dStrnicmp(filename+1, type, typeLen)); } -ConsoleMethod( CreatorTree, getSelected, S32, 2, 2, "Return a handle to the currently selected item.") +DefineConsoleMethod( CreatorTree, getSelected, S32, (), , "Return a handle to the currently selected item.") { return(object->getSelected()); } -ConsoleMethod( CreatorTree, isGroup, bool, 3, 3, "(Group g)") +DefineConsoleMethod( CreatorTree, isGroup, bool, (const char * group), , "(Group g)") { - CreatorTree::Node * node = object->findNode(dAtoi(argv[2])); + CreatorTree::Node * node = object->findNode(dAtoi(group)); if(node && node->isGroup()) return(true); return(false); } -ConsoleMethod( CreatorTree, getName, const char*, 3, 3, "(Node item)") +DefineConsoleMethod( CreatorTree, getName, const char*, (const char * item), , "(Node item)") { - CreatorTree::Node * node = object->findNode(dAtoi(argv[2])); + CreatorTree::Node * node = object->findNode(dAtoi(item)); return(node ? node->mName : 0); } -ConsoleMethod( CreatorTree, getValue, const char*, 3, 3, "(Node n)") +DefineConsoleMethod( CreatorTree, getValue, const char*, (S32 nodeValue), , "(Node n)") { - CreatorTree::Node * node = object->findNode(dAtoi(argv[2])); + CreatorTree::Node * node = object->findNode(nodeValue); return(node ? node->mValue : 0); } -ConsoleMethod( CreatorTree, clear, void, 2, 2, "Clear the tree.") +DefineConsoleMethod( CreatorTree, clear, void, (), , "Clear the tree.") { object->clear(); } -ConsoleMethod( CreatorTree, getParent, S32, 3, 3, "(Node n)") +DefineConsoleMethod( CreatorTree, getParent, S32, (S32 nodeValue), , "(Node n)") { - CreatorTree::Node * node = object->findNode(dAtoi(argv[2])); + CreatorTree::Node * node = object->findNode(nodeValue); if(node && node->mParent) return(node->mParent->getId()); diff --git a/Engine/source/gui/worldEditor/editor.cpp b/Engine/source/gui/worldEditor/editor.cpp index 458b24d71..cfcee744d 100644 --- a/Engine/source/gui/worldEditor/editor.cpp +++ b/Engine/source/gui/worldEditor/editor.cpp @@ -23,6 +23,7 @@ #include "gui/worldEditor/editor.h" #include "console/console.h" #include "console/consoleInternal.h" +#include "console/engineAPI.h" #include "gui/controls/guiTextListCtrl.h" #include "T3D/shapeBase.h" #include "T3D/gameBase/gameConnection.h" @@ -127,9 +128,8 @@ static GameBase * getControlObj() return(control); } -ConsoleMethod( EditManager, setBookmark, void, 3, 3, "(int slot)") +DefineConsoleMethod( EditManager, setBookmark, void, (S32 val), , "(int slot)") { - S32 val = dAtoi(argv[2]); if(val < 0 || val > 9) return; @@ -138,9 +138,8 @@ ConsoleMethod( EditManager, setBookmark, void, 3, 3, "(int slot)") object->mBookmarks[val] = control->getTransform(); } -ConsoleMethod( EditManager, gotoBookmark, void, 3, 3, "(int slot)") +DefineConsoleMethod( EditManager, gotoBookmark, void, (S32 val), , "(int slot)") { - S32 val = dAtoi(argv[2]); if(val < 0 || val > 9) return; @@ -149,17 +148,17 @@ ConsoleMethod( EditManager, gotoBookmark, void, 3, 3, "(int slot)") control->setTransform(object->mBookmarks[val]); } -ConsoleMethod( EditManager, editorEnabled, void, 2, 2, "Perform the onEditorEnabled callback on all SimObjects and set gEditingMission true" ) +DefineConsoleMethod( EditManager, editorEnabled, void, (), , "Perform the onEditorEnabled callback on all SimObjects and set gEditingMission true" ) { object->editorEnabled(); } -ConsoleMethod( EditManager, editorDisabled, void, 2, 2, "Perform the onEditorDisabled callback on all SimObjects and set gEditingMission false" ) +DefineConsoleMethod( EditManager, editorDisabled, void, (), , "Perform the onEditorDisabled callback on all SimObjects and set gEditingMission false" ) { object->editorDisabled(); } -ConsoleMethod( EditManager, isEditorEnabled, bool, 2, 2, "Return the value of gEditingMission." ) +DefineConsoleMethod( EditManager, isEditorEnabled, bool, (), , "Return the value of gEditingMission." ) { return gEditingMission; } \ No newline at end of file diff --git a/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp b/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp index 00245376e..adae0f3bf 100644 --- a/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp +++ b/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp @@ -24,6 +24,7 @@ #include "gui/worldEditor/guiConvexShapeEditorCtrl.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "T3D/convexShape.h" #include "renderInstance/renderPassManager.h" #include "collision/collision.h" @@ -2178,44 +2179,43 @@ void GuiConvexEditorCtrl::splitSelectedFace() updateGizmoPos(); } -ConsoleMethod( GuiConvexEditorCtrl, hollowSelection, void, 2, 2, "" ) +DefineConsoleMethod( GuiConvexEditorCtrl, hollowSelection, void, (), , "" ) { object->hollowSelection(); } -ConsoleMethod( GuiConvexEditorCtrl, recenterSelection, void, 2, 2, "" ) +DefineConsoleMethod( GuiConvexEditorCtrl, recenterSelection, void, (), , "" ) { object->recenterSelection(); } -ConsoleMethod( GuiConvexEditorCtrl, hasSelection, S32, 2, 2, "" ) +DefineConsoleMethod( GuiConvexEditorCtrl, hasSelection, S32, (), , "" ) { return object->hasSelection(); } -ConsoleMethod( GuiConvexEditorCtrl, handleDelete, void, 2, 2, "" ) +DefineConsoleMethod( GuiConvexEditorCtrl, handleDelete, void, (), , "" ) { object->handleDelete(); } -ConsoleMethod( GuiConvexEditorCtrl, handleDeselect, void, 2, 2, "" ) +DefineConsoleMethod( GuiConvexEditorCtrl, handleDeselect, void, (), , "" ) { object->handleDeselect(); } -ConsoleMethod( GuiConvexEditorCtrl, dropSelectionAtScreenCenter, void, 2, 2, "" ) +DefineConsoleMethod( GuiConvexEditorCtrl, dropSelectionAtScreenCenter, void, (), , "" ) { object->dropSelectionAtScreenCenter(); } -ConsoleMethod( GuiConvexEditorCtrl, selectConvex, void, 3, 3, "( ConvexShape )" ) +DefineConsoleMethod( GuiConvexEditorCtrl, selectConvex, void, (ConvexShape *convex), , "( ConvexShape )" ) { - ConvexShape *convex; - if ( Sim::findObject( argv[2], convex ) ) +if (convex) object->setSelection( convex, -1 ); } -ConsoleMethod( GuiConvexEditorCtrl, splitSelectedFace, void, 2, 2, "" ) +DefineConsoleMethod( GuiConvexEditorCtrl, splitSelectedFace, void, (), , "" ) { object->splitSelectedFace(); } \ No newline at end of file diff --git a/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp b/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp index a0e5b63af..ab6b377e2 100644 --- a/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp +++ b/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp @@ -26,6 +26,7 @@ #include "platform/platform.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "scene/sceneManager.h" #include "collision/collision.h" #include "math/util/frustum.h" @@ -785,41 +786,41 @@ void GuiDecalEditorCtrl::setMode( String mode, bool sourceShortcut = false ) Con::executef( this, "paletteSync", mMode ); } -ConsoleMethod( GuiDecalEditorCtrl, deleteSelectedDecal, void, 2, 2, "deleteSelectedDecal()" ) +DefineConsoleMethod( GuiDecalEditorCtrl, deleteSelectedDecal, void, (), , "deleteSelectedDecal()" ) { object->deleteSelectedDecal(); } -ConsoleMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, 3, 3, "deleteSelectedDecalDatablock( String datablock )" ) +DefineConsoleMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, ( const char * datablock ), , "deleteSelectedDecalDatablock( String datablock )" ) { - String lookupName( (const char*)argv[2] ); + String lookupName( datablock ); if( lookupName == String::EmptyString ) return; object->deleteDecalDatablock( lookupName ); } -ConsoleMethod( GuiDecalEditorCtrl, setMode, void, 3, 3, "setMode( String mode )()" ) +DefineConsoleMethod( GuiDecalEditorCtrl, setMode, void, ( String newMode ), , "setMode( String mode )()" ) { - String newMode = ( (const char*)argv[2] ); object->setMode( newMode ); } -ConsoleMethod( GuiDecalEditorCtrl, getMode, const char*, 2, 2, "getMode()" ) +DefineConsoleMethod( GuiDecalEditorCtrl, getMode, const char*, (), , "getMode()" ) { return object->mMode; } -ConsoleMethod( GuiDecalEditorCtrl, getDecalCount, S32, 2, 2, "getDecalCount()" ) +DefineConsoleMethod( GuiDecalEditorCtrl, getDecalCount, S32, (), , "getDecalCount()" ) { return gDecalManager->mDecalInstanceVec.size(); } -ConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, 3, 3, "getDecalTransform()" ) +DefineConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, ( U32 id ), , "getDecalTransform()" ) { - DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[dAtoi(argv[2])]; - if( decalInstance == NULL ) - return ""; + DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id]; + + if( decalInstance == NULL ) + return ""; static const U32 bufSize = 256; char* returnBuffer = Con::getReturnBuffer(bufSize); @@ -836,42 +837,30 @@ ConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, 3, 3, "getDec return returnBuffer; } -ConsoleMethod( GuiDecalEditorCtrl, getDecalLookupName, const char*, 3, 3, "getDecalLookupName( S32 )()" ) +DefineConsoleMethod( GuiDecalEditorCtrl, getDecalLookupName, const char*, ( U32 id ), , "getDecalLookupName( S32 )()" ) { - DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[dAtoi(argv[2])]; + DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id]; if( decalInstance == NULL ) return "invalid"; return decalInstance->mDataBlock->lookupName; } -ConsoleMethod( GuiDecalEditorCtrl, selectDecal, void, 3, 3, "selectDecal( S32 )()" ) +DefineConsoleMethod( GuiDecalEditorCtrl, selectDecal, void, ( U32 id ), , "selectDecal( S32 )()" ) { - DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[dAtoi(argv[2])]; + DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id]; if( decalInstance == NULL ) return; object->selectDecal( decalInstance ); } -ConsoleMethod( GuiDecalEditorCtrl, editDecalDetails, void, 4, 4, "editDecalDetails( S32 )()" ) +DefineConsoleMethod( GuiDecalEditorCtrl, editDecalDetails, void, ( U32 id, Point3F pos, Point3F tan,F32 size ), , "editDecalDetails( S32 )()" ) { - DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[ dAtoi(argv[2]) ]; + DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id]; if( decalInstance == NULL ) return; - Point3F pos; - Point3F tan; - F32 size; - - S32 count = dSscanf( argv[3], "%f %f %f %f %f %f %f", - &pos.x, &pos.y, &pos.z, &tan.x, &tan.y, &tan.z, &size); - - if ( (count != 7) ) - { - Con::printf("Failed to parse decal information \"px py pz tx ty tz s\" from '%s'", (const char*)argv[3]); - return; - } decalInstance->mPosition = pos; decalInstance->mTangent = tan; @@ -885,17 +874,17 @@ ConsoleMethod( GuiDecalEditorCtrl, editDecalDetails, void, 4, 4, "editDecalDetai gDecalManager->notifyDecalModified( decalInstance ); } -ConsoleMethod( GuiDecalEditorCtrl, getSelectionCount, S32, 2, 2, "" ) +DefineConsoleMethod( GuiDecalEditorCtrl, getSelectionCount, S32, (), , "" ) { if ( object->mSELDecal != NULL ) return 1; return 0; } -ConsoleMethod( GuiDecalEditorCtrl, retargetDecalDatablock, void, 4, 4, "" ) +DefineConsoleMethod( GuiDecalEditorCtrl, retargetDecalDatablock, void, ( const char * dbFrom, const char * dbTo ), , "" ) { - if( dStrcmp( argv[2], "" ) != 0 && dStrcmp( argv[3], "" ) != 0 ) - object->retargetDecalDatablock( argv[2], argv[3] ); + if( dStrcmp( dbFrom, "" ) != 0 && dStrcmp( dbTo, "" ) != 0 ) + object->retargetDecalDatablock( dbFrom, dbTo ); } void GuiDecalEditorCtrl::setGizmoFocus( DecalInstance * decalInstance ) diff --git a/Engine/source/gui/worldEditor/guiMissionAreaEditor.cpp b/Engine/source/gui/worldEditor/guiMissionAreaEditor.cpp index 5253a6fb4..411fd074a 100644 --- a/Engine/source/gui/worldEditor/guiMissionAreaEditor.cpp +++ b/Engine/source/gui/worldEditor/guiMissionAreaEditor.cpp @@ -22,6 +22,7 @@ #include "gui/worldEditor/guiMissionAreaEditor.h" #include "gui/core/guiCanvas.h" +#include "console/engineAPI.h" IMPLEMENT_CONOBJECT(GuiMissionAreaEditorCtrl); @@ -94,19 +95,19 @@ void GuiMissionAreaEditorCtrl::setSelectedMissionArea( MissionArea *missionArea Con::executef( this, "onMissionAreaSelected" ); } -ConsoleMethod( GuiMissionAreaEditorCtrl, setSelectedMissionArea, void, 2, 3, "" ) +DefineConsoleMethod( GuiMissionAreaEditorCtrl, setSelectedMissionArea, void, (const char * missionAreaName), (""), "" ) { - if ( argc == 2 ) + if ( dStrcmp( missionAreaName, "" )==0 ) object->setSelectedMissionArea(NULL); else { MissionArea *missionArea = NULL; - if ( Sim::findObject( argv[2], missionArea ) ) + if ( Sim::findObject( missionAreaName, missionArea ) ) object->setSelectedMissionArea(missionArea); } } -ConsoleMethod( GuiMissionAreaEditorCtrl, getSelectedMissionArea, const char*, 2, 2, "" ) +DefineConsoleMethod( GuiMissionAreaEditorCtrl, getSelectedMissionArea, const char*, (), , "" ) { MissionArea *missionArea = object->getSelectedMissionArea(); if ( !missionArea ) diff --git a/Engine/source/gui/worldEditor/guiTerrPreviewCtrl.cpp b/Engine/source/gui/worldEditor/guiTerrPreviewCtrl.cpp index 28462fec6..b5d5d2524 100644 --- a/Engine/source/gui/worldEditor/guiTerrPreviewCtrl.cpp +++ b/Engine/source/gui/worldEditor/guiTerrPreviewCtrl.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- #include "console/console.h" +#include "console/engineAPI.h" #include "console/consoleTypes.h" #include "terrain/terrData.h" #include "gui/worldEditor/guiTerrPreviewCtrl.h" @@ -87,41 +88,35 @@ void GuiTerrPreviewCtrl::initPersistFields() } -ConsoleMethod( GuiTerrPreviewCtrl, reset, void, 2, 2, "Reset the view of the terrain.") +DefineConsoleMethod( GuiTerrPreviewCtrl, reset, void, (), , "Reset the view of the terrain.") { object->reset(); } -ConsoleMethod( GuiTerrPreviewCtrl, setRoot, void, 2, 2, "Add the origin to the root and reset the origin.") +DefineConsoleMethod( GuiTerrPreviewCtrl, setRoot, void, (), , "Add the origin to the root and reset the origin.") { object->setRoot(); } -ConsoleMethod( GuiTerrPreviewCtrl, getRoot, const char *, 2, 2, "Return a Point2F representing the position of the root.") +DefineConsoleMethod( GuiTerrPreviewCtrl, getRoot, Point2F, (), , "Return a Point2F representing the position of the root.") { - Point2F p = object->getRoot(); + return object->getRoot(); - static char rootbuf[32]; - dSprintf(rootbuf,sizeof(rootbuf),"%g %g", p.x, -p.y); - return rootbuf; } -ConsoleMethod( GuiTerrPreviewCtrl, setOrigin, void, 4, 4, "(float x, float y)" +DefineConsoleMethod( GuiTerrPreviewCtrl, setOrigin, void, (Point2F pos), , "(float x, float y)" "Set the origin of the view.") { - object->setOrigin( Point2F( dAtof(argv[2]), -dAtof(argv[3]) ) ); + object->setOrigin( pos ); } -ConsoleMethod( GuiTerrPreviewCtrl, getOrigin, const char*, 2, 2, "Return a Point2F containing the position of the origin.") +DefineConsoleMethod( GuiTerrPreviewCtrl, getOrigin, Point2F, (), , "Return a Point2F containing the position of the origin.") { - Point2F p = object->getOrigin(); + return object->getOrigin(); - static char originbuf[32]; - dSprintf(originbuf,sizeof(originbuf),"%g %g", p.x, -p.y); - return originbuf; } -ConsoleMethod( GuiTerrPreviewCtrl, getValue, const char*, 2, 2, "Returns a 4-tuple containing: root_x root_y origin_x origin_y") +DefineConsoleMethod( GuiTerrPreviewCtrl, getValue, const char*, (), , "Returns a 4-tuple containing: root_x root_y origin_x origin_y") { Point2F r = object->getRoot(); Point2F o = object->getOrigin(); @@ -131,11 +126,11 @@ ConsoleMethod( GuiTerrPreviewCtrl, getValue, const char*, 2, 2, "Returns a 4-tup return valuebuf; } -ConsoleMethod( GuiTerrPreviewCtrl, setValue, void, 3, 3, "Accepts a 4-tuple in the same form as getValue returns.\n\n" +DefineConsoleMethod( GuiTerrPreviewCtrl, setValue, void, (const char * tuple), , "Accepts a 4-tuple in the same form as getValue returns.\n\n" "@see GuiTerrPreviewCtrl::getValue()") { Point2F r,o; - dSscanf(argv[2],"%g %g %g %g", &r.x, &r.y, &o.x, &o.y); + dSscanf(tuple, "%g %g %g %g", &r.x, &r.y, &o.x, &o.y); r.y = -r.y; o.y = -o.y; object->reset(); diff --git a/Engine/source/gui/worldEditor/terrainActions.cpp b/Engine/source/gui/worldEditor/terrainActions.cpp index 956fb6eab..2ad370f51 100644 --- a/Engine/source/gui/worldEditor/terrainActions.cpp +++ b/Engine/source/gui/worldEditor/terrainActions.cpp @@ -20,6 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- +#include "console/engineAPI.h" #include "platform/platform.h" #include "gui/worldEditor/terrainActions.h" @@ -796,11 +797,10 @@ void TerrainSmoothAction::smooth( TerrainBlock *terrain, F32 factor, U32 steps ) redo(); } -ConsoleMethod( TerrainSmoothAction, smooth, void, 5, 5, "( TerrainBlock obj, F32 factor, U32 steps )") +DefineConsoleMethod( TerrainSmoothAction, smooth, void, ( TerrainBlock *terrain, F32 factor, U32 steps ), , "( TerrainBlock obj, F32 factor, U32 steps )") { - TerrainBlock *terrain = NULL; - if ( Sim::findObject( argv[2], terrain ) && terrain ) - object->smooth( terrain, dAtof( argv[3] ), mClamp( dAtoi( argv[4] ), 1, 13 ) ); + if (terrain) + object->smooth( terrain, factor, mClamp( steps, 1, 13 ) ); } void TerrainSmoothAction::undo() diff --git a/Engine/source/gui/worldEditor/terrainEditor.cpp b/Engine/source/gui/worldEditor/terrainEditor.cpp index 42d72e72b..ebf132fd1 100644 --- a/Engine/source/gui/worldEditor/terrainEditor.cpp +++ b/Engine/source/gui/worldEditor/terrainEditor.cpp @@ -27,6 +27,7 @@ #include "core/strings/stringUnit.h" #include "console/consoleTypes.h" #include "console/simEvents.h" +#include "console/engineAPI.h" #include "sim/netConnection.h" #include "math/mathUtils.h" #include "gfx/primBuilder.h" @@ -2401,7 +2402,7 @@ void TerrainEditor::reorderMaterial( S32 index, S32 orderPos ) //------------------------------------------------------------------------------ -ConsoleMethod( TerrainEditor, attachTerrain, void, 2, 3, "(TerrainBlock terrain)") +DefineConsoleMethod( TerrainEditor, attachTerrain, void, (const char * terrain), (""), "(TerrainBlock terrain)") { SimSet * missionGroup = dynamic_cast(Sim::findObject("MissionGroup")); if (!missionGroup) @@ -2413,7 +2414,7 @@ ConsoleMethod( TerrainEditor, attachTerrain, void, 2, 3, "(TerrainBlock terrain) VectorPtr terrains; // attach to first found terrainBlock - if (argc == 2) + if (dStrcmp (terrain,"")==0) { for(SimSetIterator itr(missionGroup); *itr; ++itr) { @@ -2428,13 +2429,13 @@ ConsoleMethod( TerrainEditor, attachTerrain, void, 2, 3, "(TerrainBlock terrain) } else // attach to named object { - TerrainBlock* terrBlock = dynamic_cast(Sim::findObject(argv[2])); + TerrainBlock* terrBlock = dynamic_cast(Sim::findObject(terrain)); if (terrBlock) terrains.push_back(terrBlock); if(terrains.size() == 0) - Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: failed to attach to object '%s'", (const char*)argv[2]); + Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: failed to attach to object '%s'", terrain); } if (terrains.size() > 0) @@ -2457,21 +2458,21 @@ ConsoleMethod( TerrainEditor, attachTerrain, void, 2, 3, "(TerrainBlock terrain) } } -ConsoleMethod( TerrainEditor, getTerrainBlockCount, S32, 2, 2, "()") +DefineConsoleMethod( TerrainEditor, getTerrainBlockCount, S32, (), , "()") { return object->getTerrainBlockCount(); } -ConsoleMethod( TerrainEditor, getTerrainBlock, S32, 3, 3, "(S32 index)") +DefineConsoleMethod( TerrainEditor, getTerrainBlock, S32, (S32 index), , "(S32 index)") { - TerrainBlock* tb = object->getTerrainBlock(dAtoi(argv[2])); + TerrainBlock* tb = object->getTerrainBlock(index); if(!tb) return 0; else return tb->getId(); } -ConsoleMethod(TerrainEditor, getTerrainBlocksMaterialList, const char *, 2, 2, "() gets the list of current terrain materials for all terrain blocks.") +DefineConsoleMethod(TerrainEditor, getTerrainBlocksMaterialList, const char *, (), , "() gets the list of current terrain materials for all terrain blocks.") { Vector list; object->getTerrainBlocksMaterialList(list); @@ -2500,25 +2501,23 @@ ConsoleMethod(TerrainEditor, getTerrainBlocksMaterialList, const char *, 2, 2, " return ret; } -ConsoleMethod( TerrainEditor, setBrushType, void, 3, 3, "(string type)" +DefineConsoleMethod( TerrainEditor, setBrushType, void, (String type), , "(string type)" "One of box, ellipse, selection.") { - object->setBrushType(argv[2]); + object->setBrushType(type); } -ConsoleMethod( TerrainEditor, getBrushType, const char*, 2, 2, "()") +DefineConsoleMethod( TerrainEditor, getBrushType, const char*, (), , "()") { return object->getBrushType(); } -ConsoleMethod( TerrainEditor, setBrushSize, void, 3, 4, "(int w [, int h])") +DefineConsoleMethod( TerrainEditor, setBrushSize, void, ( S32 w, S32 h), (0), "(int w [, int h])") { - S32 w = dAtoi(argv[2]); - S32 h = argc > 3 ? dAtoi(argv[3]) : w; - object->setBrushSize( w, h ); + object->setBrushSize( w, h==0?w:h ); } -ConsoleMethod( TerrainEditor, getBrushSize, const char*, 2, 2, "()") +DefineConsoleMethod( TerrainEditor, getBrushSize, const char*, (), , "()") { Point2I size = object->getBrushSize(); @@ -2528,84 +2527,74 @@ ConsoleMethod( TerrainEditor, getBrushSize, const char*, 2, 2, "()") return ret; } -ConsoleMethod( TerrainEditor, setBrushPressure, void, 3, 3, "(float pressure)") +DefineConsoleMethod( TerrainEditor, setBrushPressure, void, (F32 pressure), , "(float pressure)") { - object->setBrushPressure( dAtof( argv[2] ) ); + object->setBrushPressure( pressure ); } -ConsoleMethod( TerrainEditor, getBrushPressure, F32, 2, 2, "()") +DefineConsoleMethod( TerrainEditor, getBrushPressure, F32, (), , "()") { return object->getBrushPressure(); } -ConsoleMethod( TerrainEditor, setBrushSoftness, void, 3, 3, "(float softness)") +DefineConsoleMethod( TerrainEditor, setBrushSoftness, void, (F32 softness), , "(float softness)") { - object->setBrushSoftness( dAtof( argv[2] ) ); + object->setBrushSoftness( softness ); } -ConsoleMethod( TerrainEditor, getBrushSoftness, F32, 2, 2, "()") +DefineConsoleMethod( TerrainEditor, getBrushSoftness, F32, (), , "()") { + return object->getBrushSoftness(); } -ConsoleMethod( TerrainEditor, getBrushPos, const char*, 2, 2, "Returns a Point2I.") +DefineConsoleMethod( TerrainEditor, getBrushPos, const char*, (), , "Returns a Point2I.") { return object->getBrushPos(); } -ConsoleMethod( TerrainEditor, setBrushPos, void, 3, 4, "(int x, int y)") +DefineConsoleMethod( TerrainEditor, setBrushPos, void, (Point2I pos), , "Location") { - // - Point2I pos; - if(argc == 3) - dSscanf(argv[2], "%d %d", &pos.x, &pos.y); - else - { - pos.x = dAtoi(argv[2]); - pos.y = dAtoi(argv[3]); - } object->setBrushPos(pos); } -ConsoleMethod( TerrainEditor, setAction, void, 3, 3, "(string action_name)") +DefineConsoleMethod( TerrainEditor, setAction, void, (const char * action_name), , "(string action_name)") { - object->setAction(argv[2]); + object->setAction(action_name); } -ConsoleMethod( TerrainEditor, getActionName, const char*, 3, 3, "(int num)") +DefineConsoleMethod( TerrainEditor, getActionName, const char*, (U32 index), , "(int num)") { - return (object->getActionName(dAtoi(argv[2]))); + return (object->getActionName(index)); } -ConsoleMethod( TerrainEditor, getNumActions, S32, 2, 2, "") +DefineConsoleMethod( TerrainEditor, getNumActions, S32, (), , "") { return(object->getNumActions()); } -ConsoleMethod( TerrainEditor, getCurrentAction, const char*, 2, 2, "") +DefineConsoleMethod( TerrainEditor, getCurrentAction, const char*, (), , "") { return object->getCurrentAction(); } -ConsoleMethod( TerrainEditor, resetSelWeights, void, 3, 3, "(bool clear)") +DefineConsoleMethod( TerrainEditor, resetSelWeights, void, (bool clear), , "(bool clear)") { - object->resetSelWeights(dAtob(argv[2])); + object->resetSelWeights(clear); } -ConsoleMethod( TerrainEditor, clearSelection, void, 2, 2, "") +DefineConsoleMethod( TerrainEditor, clearSelection, void, (), , "") { object->clearSelection(); } -ConsoleMethod( TerrainEditor, processAction, void, 2, 3, "(string action=NULL)") +DefineConsoleMethod( TerrainEditor, processAction, void, (String action), (""), "(string action=NULL)") { - if(argc == 3) - object->processAction(argv[2]); - else object->processAction(""); + object->processAction(action); } -ConsoleMethod( TerrainEditor, getActiveTerrain, S32, 2, 2, "") +DefineConsoleMethod( TerrainEditor, getActiveTerrain, S32, (), , "") { S32 ret = 0; @@ -2617,27 +2606,27 @@ ConsoleMethod( TerrainEditor, getActiveTerrain, S32, 2, 2, "") return ret; } -ConsoleMethod( TerrainEditor, getNumTextures, S32, 2, 2, "") +DefineConsoleMethod( TerrainEditor, getNumTextures, S32, (), , "") { return object->getNumTextures(); } -ConsoleMethod( TerrainEditor, markEmptySquares, void, 2, 2, "") +DefineConsoleMethod( TerrainEditor, markEmptySquares, void, (), , "") { object->markEmptySquares(); } -ConsoleMethod( TerrainEditor, mirrorTerrain, void, 3, 3, "") +DefineConsoleMethod( TerrainEditor, mirrorTerrain, void, (S32 mirrorIndex), , "") { - object->mirrorTerrain(dAtoi(argv[2])); + object->mirrorTerrain(mirrorIndex); } -ConsoleMethod(TerrainEditor, setTerraformOverlay, void, 3, 3, "(bool overlayEnable) - sets the terraformer current heightmap to draw as an overlay over the current terrain.") +DefineConsoleMethod(TerrainEditor, setTerraformOverlay, void, (bool overlayEnable), , "(bool overlayEnable) - sets the terraformer current heightmap to draw as an overlay over the current terrain.") { // XA: This one needs to be implemented :) } -ConsoleMethod(TerrainEditor, updateMaterial, bool, 4, 4, +DefineConsoleMethod(TerrainEditor, updateMaterial, bool, ( U32 index, String matName ), , "( int index, string matName )\n" "Changes the material name at the index." ) { @@ -2645,18 +2634,17 @@ ConsoleMethod(TerrainEditor, updateMaterial, bool, 4, 4, if ( !terr ) return false; - U32 index = dAtoi( argv[2] ); if ( index >= terr->getMaterialCount() ) return false; - terr->updateMaterial( index, argv[3] ); + terr->updateMaterial( index, matName ); object->setDirty(); return true; } -ConsoleMethod(TerrainEditor, addMaterial, S32, 3, 3, +DefineConsoleMethod(TerrainEditor, addMaterial, S32, ( String matName ), , "( string matName )\n" "Adds a new material." ) { @@ -2664,20 +2652,19 @@ ConsoleMethod(TerrainEditor, addMaterial, S32, 3, 3, if ( !terr ) return false; - terr->addMaterial( argv[2] ); + terr->addMaterial( matName ); object->setDirty(); return true; } -ConsoleMethod( TerrainEditor, removeMaterial, void, 3, 3, "( int index ) - Remove the material at the given index." ) +DefineConsoleMethod( TerrainEditor, removeMaterial, void, ( S32 index ), , "( int index ) - Remove the material at the given index." ) { TerrainBlock *terr = object->getClientTerrain(); if ( !terr ) return; - S32 index = dAtoi( argv[ 2 ] ); if ( index < 0 || index >= terr->getMaterialCount() ) { Con::errorf( "TerrainEditor::removeMaterial - index out of range!" ); @@ -2701,7 +2688,7 @@ ConsoleMethod( TerrainEditor, removeMaterial, void, 3, 3, "( int index ) - Remov object->setGridUpdateMinMax(); } -ConsoleMethod(TerrainEditor, getMaterialCount, S32, 2, 2, +DefineConsoleMethod(TerrainEditor, getMaterialCount, S32, (), , "Returns the current material count." ) { TerrainBlock *terr = object->getClientTerrain(); @@ -2711,7 +2698,7 @@ ConsoleMethod(TerrainEditor, getMaterialCount, S32, 2, 2, return 0; } -ConsoleMethod(TerrainEditor, getMaterials, const char *, 2, 2, "() gets the list of current terrain materials.") +DefineConsoleMethod(TerrainEditor, getMaterials, const char *, (), , "() gets the list of current terrain materials.") { TerrainBlock *terr = object->getClientTerrain(); if ( !terr ) @@ -2728,13 +2715,12 @@ ConsoleMethod(TerrainEditor, getMaterials, const char *, 2, 2, "() gets the list return ret; } -ConsoleMethod( TerrainEditor, getMaterialName, const char*, 3, 3, "( int index ) - Returns the name of the material at the given index." ) +DefineConsoleMethod( TerrainEditor, getMaterialName, const char*, (S32 index), , "( int index ) - Returns the name of the material at the given index." ) { TerrainBlock *terr = object->getClientTerrain(); if ( !terr ) return ""; - S32 index = dAtoi( argv[ 2 ] ); if( index < 0 || index >= terr->getMaterialCount() ) { Con::errorf( "TerrainEditor::getMaterialName - index out of range!" ); @@ -2745,13 +2731,12 @@ ConsoleMethod( TerrainEditor, getMaterialName, const char*, 3, 3, "( int index ) return Con::getReturnBuffer( name ); } -ConsoleMethod( TerrainEditor, getMaterialIndex, S32, 3, 3, "( string name ) - Returns the index of the material with the given name or -1." ) +DefineConsoleMethod( TerrainEditor, getMaterialIndex, S32, ( String name ), , "( string name ) - Returns the index of the material with the given name or -1." ) { TerrainBlock *terr = object->getClientTerrain(); if ( !terr ) return -1; - const char* name = argv[ 2 ]; const U32 count = terr->getMaterialCount(); for( U32 i = 0; i < count; ++ i ) @@ -2761,13 +2746,14 @@ ConsoleMethod( TerrainEditor, getMaterialIndex, S32, 3, 3, "( string name ) - Re return -1; } -ConsoleMethod( TerrainEditor, reorderMaterial, void, 4, 4, "( int index, int order ) " +DefineConsoleMethod( TerrainEditor, reorderMaterial, void, ( S32 index, S32 orderPos ), , "( int index, int order ) " "- Reorder material at the given index to the new position, changing the order in which it is rendered / blended." ) { - object->reorderMaterial( dAtoi( argv[2] ), dAtoi( argv[3] ) ); + object->reorderMaterial( index, orderPos ); } -ConsoleMethod(TerrainEditor, getTerrainUnderWorldPoint, S32, 3, 5, "(x/y/z) Gets the terrain block that is located under the given world point.\n" +DefineConsoleMethod(TerrainEditor, getTerrainUnderWorldPoint, S32, (const char * ptOrX, const char * Y, const char * Z), ("", "", ""), + "(x/y/z) Gets the terrain block that is located under the given world point.\n" "@param x/y/z The world coordinates (floating point values) you wish to query at. " "These can be formatted as either a string (\"x y z\") or separately as (x, y, z)\n" "@return Returns the ID of the requested terrain block (0 if not found).\n\n") @@ -2776,13 +2762,13 @@ ConsoleMethod(TerrainEditor, getTerrainUnderWorldPoint, S32, 3, 5, "(x/y/z) Gets if(tEditor == NULL) return 0; Point3F pos; - if(argc == 3) - dSscanf(argv[2], "%f %f %f", &pos.x, &pos.y, &pos.z); - else if(argc == 5) + if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(Y) && dStrIsEmpty(Z)) + dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z); + else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(Y) && !dStrIsEmpty(Z)) { - pos.x = dAtof(argv[2]); - pos.y = dAtof(argv[3]); - pos.z = dAtof(argv[4]); + pos.x = dAtof(ptOrX); + pos.y = dAtof(Y); + pos.z = dAtof(Z); } else @@ -2835,14 +2821,13 @@ void TerrainEditor::initPersistFields() Parent::initPersistFields(); } -ConsoleMethod( TerrainEditor, getSlopeLimitMinAngle, F32, 2, 2, 0) +DefineConsoleMethod( TerrainEditor, getSlopeLimitMinAngle, F32, (), , "") { return object->mSlopeMinAngle; } -ConsoleMethod( TerrainEditor, setSlopeLimitMinAngle, F32, 3, 3, 0) +DefineConsoleMethod( TerrainEditor, setSlopeLimitMinAngle, F32, (F32 angle), , "") { - F32 angle = dAtof( argv[2] ); if ( angle < 0.0f ) angle = 0.0f; if ( angle > object->mSlopeMaxAngle ) @@ -2852,14 +2837,13 @@ ConsoleMethod( TerrainEditor, setSlopeLimitMinAngle, F32, 3, 3, 0) return angle; } -ConsoleMethod( TerrainEditor, getSlopeLimitMaxAngle, F32, 2, 2, 0) +DefineConsoleMethod( TerrainEditor, getSlopeLimitMaxAngle, F32, (), , "") { return object->mSlopeMaxAngle; } -ConsoleMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, 3, 3, 0) +DefineConsoleMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, (F32 angle), , "") { - F32 angle = dAtof( argv[2] ); if ( angle > 90.0f ) angle = 90.0f; if ( angle < object->mSlopeMinAngle ) @@ -2938,7 +2922,7 @@ void TerrainEditor::autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinS scheduleMaterialUpdate(); } -ConsoleMethod( TerrainEditor, autoMaterialLayer, void, 7, 7, "(float minHeight, float maxHeight, float minSlope, float maxSlope, float coverage)") +DefineConsoleMethod( TerrainEditor, autoMaterialLayer, void, (F32 minHeight, F32 maxHeight, F32 minSlope, F32 maxSlope, F32 coverage), , "(F32 minHeight, F32 maxHeight, F32 minSlope, F32 maxSlope , F32 coverage)") { - object->autoMaterialLayer( dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4]), dAtof(argv[5]), dAtof(argv[6])); -} + object->autoMaterialLayer( minHeight,maxHeight, minSlope, maxSlope, coverage ); +} diff --git a/Engine/source/gui/worldEditor/undoActions.cpp b/Engine/source/gui/worldEditor/undoActions.cpp index aebd1fd49..6dd244f87 100644 --- a/Engine/source/gui/worldEditor/undoActions.cpp +++ b/Engine/source/gui/worldEditor/undoActions.cpp @@ -26,6 +26,7 @@ #include "gui/editor/inspector/field.h" #include "gui/editor/guiInspector.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" IMPLEMENT_CONOBJECT( MECreateUndoAction ); @@ -57,10 +58,9 @@ void MECreateUndoAction::addObject( SimObject *object ) mObjects.last().id = object->getId(); } -ConsoleMethod( MECreateUndoAction, addObject, void, 3, 3, "( SimObject obj )") +DefineConsoleMethod( MECreateUndoAction, addObject, void, (SimObject *obj), , "( SimObject obj )") { - SimObject *obj = NULL; - if ( Sim::findObject( argv[2], obj ) && obj ) + if (obj) object->addObject( obj ); } @@ -163,10 +163,9 @@ void MEDeleteUndoAction::deleteObject( const Vector &objectList ) deleteObject( objectList[i] ); } -ConsoleMethod( MEDeleteUndoAction, deleteObject, void, 3, 3, "( SimObject obj )") +DefineConsoleMethod( MEDeleteUndoAction, deleteObject, void, (SimObject *obj ), , "( SimObject obj )") { - SimObject *obj = NULL; - if ( Sim::findObject( argv[2], obj ) && obj ) + if (obj) object->deleteObject( obj ); } diff --git a/Engine/source/gui/worldEditor/worldEditor.cpp b/Engine/source/gui/worldEditor/worldEditor.cpp index c297558ab..befd30b92 100644 --- a/Engine/source/gui/worldEditor/worldEditor.cpp +++ b/Engine/source/gui/worldEditor/worldEditor.cpp @@ -3187,17 +3187,17 @@ ConsoleMethod( WorldEditor, ignoreObjClass, void, 3, 0, "(string class_name, ... object->ignoreObjClass(argc, argv); } -ConsoleMethod( WorldEditor, clearIgnoreList, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, clearIgnoreList, void, (), , "") { object->clearIgnoreList(); } -ConsoleMethod( WorldEditor, clearSelection, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, clearSelection, void, (), , "") { object->clearSelection(); } -ConsoleMethod( WorldEditor, getActiveSelection, S32, 2, 2, "() - Return the currently active WorldEditorSelection object." ) +DefineConsoleMethod( WorldEditor, getActiveSelection, S32, (), , "() - Return the currently active WorldEditorSelection object." ) { if( !object->getActiveSelectionSet() ) return 0; @@ -3205,43 +3205,36 @@ ConsoleMethod( WorldEditor, getActiveSelection, S32, 2, 2, "() - Return the curr return object->getActiveSelectionSet()->getId(); } -ConsoleMethod( WorldEditor, setActiveSelection, void, 3, 3, "( id set ) - Set the currently active WorldEditorSelection object." ) +DefineConsoleMethod( WorldEditor, setActiveSelection, void, ( WorldEditorSelection* selection), , "( id set ) - Set the currently active WorldEditorSelection object." ) { - WorldEditorSelection* selection; - if( !Sim::findObject( argv[ 2 ], selection ) ) - { - Con::errorf( "WorldEditor::setActiveSelectionSet - no selection set '%s'", (const char*)argv[ 2 ] ); - return; - } - + if (selection) object->makeActiveSelectionSet( selection ); } -ConsoleMethod( WorldEditor, selectObject, void, 3, 3, "(SimObject obj)") +DefineConsoleMethod( WorldEditor, selectObject, void, (const char * objName), , "(SimObject obj)") { - object->selectObject(argv[2]); + object->selectObject(objName); } -ConsoleMethod( WorldEditor, unselectObject, void, 3, 3, "(SimObject obj)") +DefineConsoleMethod( WorldEditor, unselectObject, void, (const char * objName), , "(SimObject obj)") { - object->unselectObject(argv[2]); + object->unselectObject(objName); } -ConsoleMethod( WorldEditor, invalidateSelectionCentroid, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, invalidateSelectionCentroid, void, (), , "") { WorldEditor::Selection* sel = object->getActiveSelectionSet(); if(sel) sel->invalidateCentroid(); } -ConsoleMethod( WorldEditor, getSelectionSize, S32, 2, 2, "() - Return the number of objects currently selected in the editor.") +DefineConsoleMethod( WorldEditor, getSelectionSize, S32, (), , "() - Return the number of objects currently selected in the editor.") { return object->getSelectionSize(); } -ConsoleMethod( WorldEditor, getSelectedObject, S32, 3, 3, "(int index)") +DefineConsoleMethod( WorldEditor, getSelectedObject, S32, (S32 index), , "(int index)") { - S32 index = dAtoi(argv[2]); if(index < 0 || index >= object->getSelectionSize()) { Con::errorf(ConsoleLogEntry::General, "WorldEditor::getSelectedObject: invalid object index"); @@ -3251,30 +3244,23 @@ ConsoleMethod( WorldEditor, getSelectedObject, S32, 3, 3, "(int index)") return(object->getSelectObject(index)); } -ConsoleMethod( WorldEditor, getSelectionRadius, F32, 2, 2, "") +DefineConsoleMethod( WorldEditor, getSelectionRadius, F32, (), , "") { return object->getSelectionRadius(); } -ConsoleMethod( WorldEditor, getSelectionCentroid, const char *, 2, 2, "") +DefineConsoleMethod( WorldEditor, getSelectionCentroid, const char *, (), , "") { return object->getSelectionCentroidText(); } -ConsoleMethod( WorldEditor, getSelectionExtent, const char *, 2, 2, "") +DefineConsoleMethod( WorldEditor, getSelectionExtent, Point3F, (), , "") { - Point3F bounds = object->getSelectionExtent(); - static const U32 bufSize = 100; - char * ret = Con::getReturnBuffer(bufSize); - dSprintf(ret, bufSize, "%g %g %g", bounds.x, bounds.y, bounds.z); - return ret; + return object->getSelectionExtent(); } -ConsoleMethod( WorldEditor, dropSelection, void, 2, 3, "( bool skipUndo = false )") +DefineConsoleMethod( WorldEditor, dropSelection, void, ( bool skipUndo ), (false), "( bool skipUndo = false )") { - bool skipUndo = false; - if ( argc > 2 ) - skipUndo = dAtob( argv[2] ); object->dropCurrentSelection( skipUndo ); } @@ -3289,17 +3275,17 @@ void WorldEditor::copyCurrentSelection() copySelection(mSelected); } -ConsoleMethod( WorldEditor, cutSelection, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, cutSelection, void, (),, "") { object->cutCurrentSelection(); } -ConsoleMethod( WorldEditor, copySelection, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, copySelection, void, (),, "") { object->copyCurrentSelection(); } -ConsoleMethod( WorldEditor, pasteSelection, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, pasteSelection, void, (),, "") { object->pasteSelection(); } @@ -3309,88 +3295,86 @@ bool WorldEditor::canPasteSelection() return mCopyBuffer.empty() != true; } -ConsoleMethod( WorldEditor, canPasteSelection, bool, 2, 2, "") +DefineConsoleMethod( WorldEditor, canPasteSelection, bool, (),, "") { return object->canPasteSelection(); } -ConsoleMethod( WorldEditor, hideObject, void, 4, 4, "(Object obj, bool hide)") +DefineConsoleMethod( WorldEditor, hideObject, void, (SceneObject *obj, bool hide), , "(Object obj, bool hide)") { - SceneObject *obj; - if ( !Sim::findObject( argv[2], obj ) ) - return; - object->hideObject(obj, dAtob(argv[3])); + if (obj) + object->hideObject(obj, hide); } -ConsoleMethod( WorldEditor, hideSelection, void, 3, 3, "(bool hide)") +DefineConsoleMethod( WorldEditor, hideSelection, void, (bool hide), , "(bool hide)") { - object->hideSelection(dAtob(argv[2])); + object->hideSelection(hide); } -ConsoleMethod( WorldEditor, lockSelection, void, 3, 3, "(bool lock)") +DefineConsoleMethod( WorldEditor, lockSelection, void, (bool lock), , "(bool lock)") { - object->lockSelection(dAtob(argv[2])); + object->lockSelection(lock); } -ConsoleMethod( WorldEditor, alignByBounds, void, 3, 3, "(int boundsAxis)" +DefineConsoleMethod( WorldEditor, alignByBounds, void, (S32 boundsAxis), , "(int boundsAxis)" "Align all selected objects against the given bounds axis.") { - if(!object->alignByBounds(dAtoi(argv[2]))) - Con::warnf(ConsoleLogEntry::General, avar("worldEditor.alignByBounds: invalid bounds axis '%s'", (const char*)argv[2])); + if(!object->alignByBounds(boundsAxis)) + Con::warnf(ConsoleLogEntry::General, avar("worldEditor.alignByBounds: invalid bounds axis '%s'", boundsAxis)); } -ConsoleMethod( WorldEditor, alignByAxis, void, 3, 3, "(int axis)" +DefineConsoleMethod( WorldEditor, alignByAxis, void, (S32 boundsAxis), , "(int axis)" "Align all selected objects along the given axis.") { - if(!object->alignByAxis(dAtoi(argv[2]))) - Con::warnf(ConsoleLogEntry::General, avar("worldEditor.alignByAxis: invalid axis '%s'", (const char*)argv[2])); + if(!object->alignByAxis(boundsAxis)) + Con::warnf(ConsoleLogEntry::General, avar("worldEditor.alignByAxis: invalid axis '%s'", boundsAxis)); } -ConsoleMethod( WorldEditor, resetSelectedRotation, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, resetSelectedRotation, void, (),, "") { object->resetSelectedRotation(); } -ConsoleMethod( WorldEditor, resetSelectedScale, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, resetSelectedScale, void, (),, "") { object->resetSelectedScale(); } -ConsoleMethod( WorldEditor, redirectConsole, void, 3, 3, "( int objID )") +DefineConsoleMethod( WorldEditor, redirectConsole, void, (S32 objID), , "( int objID )") { - object->redirectConsole(dAtoi(argv[2])); + object->redirectConsole(objID); } -ConsoleMethod( WorldEditor, addUndoState, void, 2, 2, "") +DefineConsoleMethod( WorldEditor, addUndoState, void, (),, "") { object->addUndoState(); } //----------------------------------------------------------------------------- -ConsoleMethod( WorldEditor, getSoftSnap, bool, 2, 2, "getSoftSnap()\n" +DefineConsoleMethod( WorldEditor, getSoftSnap, bool, (),, "getSoftSnap()\n" "Is soft snapping always on?") { return object->mSoftSnap; } -ConsoleMethod( WorldEditor, setSoftSnap, void, 3, 3, "setSoftSnap(bool)\n" +DefineConsoleMethod( WorldEditor, setSoftSnap, void, (bool enable), , "setSoftSnap(bool)\n" "Allow soft snapping all of the time.") { - object->mSoftSnap = dAtob(argv[2]); + object->mSoftSnap = enable; } -ConsoleMethod( WorldEditor, getSoftSnapSize, F32, 2, 2, "getSoftSnapSize()\n" +DefineConsoleMethod( WorldEditor, getSoftSnapSize, F32, (),, "getSoftSnapSize()\n" "Get the absolute size to trigger a soft snap.") { return object->mSoftSnapSize; } -ConsoleMethod( WorldEditor, setSoftSnapSize, void, 3, 3, "setSoftSnapSize(F32)\n" +DefineConsoleMethod( WorldEditor, setSoftSnapSize, void, (F32 size), , "setSoftSnapSize(F32)\n" "Set the absolute size to trigger a soft snap.") { - object->mSoftSnapSize = dAtof(argv[2]); + object->mSoftSnapSize = size; } DefineEngineMethod( WorldEditor, getSoftSnapAlignment, WorldEditor::AlignmentType, (),, @@ -3405,40 +3389,40 @@ DefineEngineMethod( WorldEditor, setSoftSnapAlignment, void, ( WorldEditor::Alig object->mSoftSnapAlignment = type; } -ConsoleMethod( WorldEditor, softSnapSizeByBounds, void, 3, 3, "softSnapSizeByBounds(bool)\n" +DefineConsoleMethod( WorldEditor, softSnapSizeByBounds, void, (bool enable), , "softSnapSizeByBounds(bool)\n" "Use selection bounds size as soft snap bounds.") { - object->mSoftSnapSizeByBounds = dAtob(argv[2]); + object->mSoftSnapSizeByBounds = enable; } -ConsoleMethod( WorldEditor, getSoftSnapBackfaceTolerance, F32, 2, 2, "getSoftSnapBackfaceTolerance()\n" +DefineConsoleMethod( WorldEditor, getSoftSnapBackfaceTolerance, F32, (), , "getSoftSnapBackfaceTolerance()\n" "The fraction of the soft snap radius that backfaces may be included.") { return object->mSoftSnapBackfaceTolerance; } -ConsoleMethod( WorldEditor, setSoftSnapBackfaceTolerance, void, 3, 3, "setSoftSnapBackfaceTolerance(F32 with range of 0..1)\n" +DefineConsoleMethod( WorldEditor, setSoftSnapBackfaceTolerance, void, (F32 range), , "setSoftSnapBackfaceTolerance(F32 with range of 0..1)\n" "The fraction of the soft snap radius that backfaces may be included.") { - object->mSoftSnapBackfaceTolerance = dAtof(argv[2]); + object->mSoftSnapBackfaceTolerance = range; } -ConsoleMethod( WorldEditor, softSnapRender, void, 3, 3, "softSnapRender(bool)\n" +DefineConsoleMethod( WorldEditor, softSnapRender, void, (bool enable), , "softSnapRender(bool)\n" "Render the soft snapping bounds.") { - object->mSoftSnapRender = dAtob(argv[2]); + object->mSoftSnapRender = enable; } -ConsoleMethod( WorldEditor, softSnapRenderTriangle, void, 3, 3, "softSnapRenderTriangle(bool)\n" +DefineConsoleMethod( WorldEditor, softSnapRenderTriangle, void, (bool enable), , "softSnapRenderTriangle(bool)\n" "Render the soft snapped triangle.") { - object->mSoftSnapRenderTriangle = dAtob(argv[2]); + object->mSoftSnapRenderTriangle = enable; } -ConsoleMethod( WorldEditor, softSnapDebugRender, void, 3, 3, "softSnapDebugRender(bool)\n" +DefineConsoleMethod( WorldEditor, softSnapDebugRender, void, (bool enable), , "softSnapDebugRender(bool)\n" "Toggle soft snapping debug rendering.") { - object->mSoftSnapDebugRender = dAtob(argv[2]); + object->mSoftSnapDebugRender = enable; } DefineEngineMethod( WorldEditor, getTerrainSnapAlignment, WorldEditor::AlignmentType, (),, @@ -3453,27 +3437,22 @@ DefineEngineMethod( WorldEditor, setTerrainSnapAlignment, void, ( WorldEditor::A object->mTerrainSnapAlignment = alignment; } -ConsoleMethod( WorldEditor, transformSelection, void, 13, 13, "transformSelection(...)\n" +DefineConsoleMethod( WorldEditor, transformSelection, void, + ( bool position, + Point3F point, + bool relativePos, + bool rotate, + Point3F rotation, + bool relativeRot, + bool rotLocal, + S32 scaleType, + Point3F scale, + bool sRelative, + bool sLocal ), , + "transformSelection(...)\n" "Transform selection by given parameters.") { - bool position = dAtob(argv[2]); - Point3F p(0.0f, 0.0f, 0.0f); - dSscanf(argv[3], "%g %g %g", &p.x, &p.y, &p.z); - bool relativePos = dAtob(argv[4]); - - bool rotate = dAtob(argv[5]); - EulerF r(0.0f, 0.0f, 0.0f); - dSscanf(argv[6], "%g %g %g", &r.x, &r.y, &r.z); - bool relativeRot = dAtob(argv[7]); - bool rotLocal = dAtob(argv[8]); - - S32 scaleType = dAtoi(argv[9]); - Point3F s(1.0f, 1.0f, 1.0f); - dSscanf(argv[10], "%g %g %g", &s.x, &s.y, &s.z); - bool sRelative = dAtob(argv[11]); - bool sLocal = dAtob(argv[12]); - - object->transformSelection(position, p, relativePos, rotate, r, relativeRot, rotLocal, scaleType, s, sRelative, sLocal); + object->transformSelection(position, point, relativePos, rotate, rotation, relativeRot, rotLocal, scaleType, scale, sRelative, sLocal); } #include "core/strings/stringUnit.h" @@ -3546,10 +3525,10 @@ void WorldEditor::colladaExportSelection( const String &path ) #endif } -ConsoleMethod( WorldEditor, colladaExportSelection, void, 3, 3, +DefineConsoleMethod( WorldEditor, colladaExportSelection, void, (const char * path), , "( String path ) - Export the combined geometry of all selected objects to the specified path in collada format." ) { - object->colladaExportSelection( (const char*)argv[2] ); + object->colladaExportSelection( path ); } void WorldEditor::makeSelectionPrefab( const char *filename ) @@ -3700,25 +3679,20 @@ void WorldEditor::explodeSelectedPrefab() setDirty(); } -ConsoleMethod( WorldEditor, makeSelectionPrefab, void, 3, 3, "( string filename ) - Save selected objects to a .prefab file and replace them in the level with a Prefab object." ) +DefineConsoleMethod( WorldEditor, makeSelectionPrefab, void, ( const char * filename ), , "( string filename ) - Save selected objects to a .prefab file and replace them in the level with a Prefab object." ) { - object->makeSelectionPrefab( argv[2] ); + object->makeSelectionPrefab( filename ); } -ConsoleMethod( WorldEditor, explodeSelectedPrefab, void, 2, 2, "() - Replace selected Prefab objects with a SimGroup containing all children objects defined in the .prefab." ) +DefineConsoleMethod( WorldEditor, explodeSelectedPrefab, void, (),, "() - Replace selected Prefab objects with a SimGroup containing all children objects defined in the .prefab." ) { object->explodeSelectedPrefab(); } -ConsoleMethod( WorldEditor, mountRelative, void, 4, 4, "( Object A, Object B )" ) +DefineConsoleMethod( WorldEditor, mountRelative, void, ( SceneObject *objA, SceneObject *objB ), , "( Object A, Object B )" ) { - SceneObject *objA; - if ( !Sim::findObject( argv[2], objA ) ) - return; - - SceneObject *objB; - if ( !Sim::findObject( argv[3], objB ) ) - return; + if (!objA || !objB) + return; MatrixF xfm = objB->getTransform(); MatrixF mat = objA->getWorldTransform(); diff --git a/Engine/source/i18n/i18n.cpp b/Engine/source/i18n/i18n.cpp index 38b213361..359c76fa4 100644 --- a/Engine/source/i18n/i18n.cpp +++ b/Engine/source/i18n/i18n.cpp @@ -24,6 +24,7 @@ #include "core/stream/stream.h" #include "core/stream/fileStream.h" #include "console/console.h" +#include "console/engineAPI.h" #include "i18n/i18n.h" #include "i18n/lang.h" @@ -57,7 +58,7 @@ const UTF8 *getCoreString(S32 id) //----------------------------------------------------------------------------- -ConsoleFunction(getCoreLangTable, S32, 1, 1, "()" +DefineConsoleFunction( getCoreLangTable, S32, (), , "()" "@brief Gets the primary LangTable used by the game\n\n" "@return ID of the core LangTable\n" "@ingroup Localization") @@ -68,17 +69,20 @@ ConsoleFunction(getCoreLangTable, S32, 1, 1, "()" return 0; } -ConsoleFunction(setCoreLangTable, void, 2, 2, "(string LangTable)" +DefineConsoleFunction( setCoreLangTable, void, (const char * lgTable), , "(string LangTable)" "@brief Sets the primary LangTable used by the game\n\n" "@param LangTable ID of the core LangTable\n" "@ingroup Localization") { - LangTable *lt; + LangTable * lt; - if(Sim::findObject(argv[1], lt)) - gCoreLangTable = lt; + if(Sim::findObject(lgTable, lt)) + { gCoreLangTable = lt; } else - Con::errorf("setCoreLangTable - Unable to find LanTable '%s'", (const char*)argv[1]); + { + Con::errorf("setCoreLangTable - Unable to find LanTable '%s'", lgTable); + } + } //----------------------------------------------------------------------------- diff --git a/Engine/source/i18n/lang.cpp b/Engine/source/i18n/lang.cpp index 3f09e6b20..d5401a5d7 100644 --- a/Engine/source/i18n/lang.cpp +++ b/Engine/source/i18n/lang.cpp @@ -325,7 +325,7 @@ void LangTable::setCurrentLanguage(S32 langid) -ConsoleMethod(LangTable, addLanguage, S32, 3, 4, +DefineConsoleMethod(LangTable, addLanguage, S32, (String filename, String languageName), ("", ""), "(string filename, [string languageName])" "@brief Adds a language to the table\n\n" "@param filename Name and path to the language file\n" @@ -335,11 +335,11 @@ ConsoleMethod(LangTable, addLanguage, S32, 3, 4, { UTF8 scriptFilenameBuffer[1024]; - Con::expandScriptFilename((char*)scriptFilenameBuffer, sizeof(scriptFilenameBuffer), argv[2]); - return object->addLanguage(scriptFilenameBuffer, argc == 4 ? (const UTF8*)argv[3] : NULL); + Con::expandScriptFilename((char*)scriptFilenameBuffer, sizeof(scriptFilenameBuffer), filename); + return object->addLanguage(scriptFilenameBuffer, (const UTF8*)languageName); } -ConsoleMethod(LangTable, getString, const char *, 3, 3, +DefineConsoleMethod(LangTable, getString, const char *, (U32 id), , "(string filename)" "@brief Grabs a string from the specified table\n\n" "If an invalid is passed, the function will attempt to " @@ -347,7 +347,7 @@ ConsoleMethod(LangTable, getString, const char *, 3, 3, "@param filename Name of the language table to access\n\n" "@return Text from the specified language table, \"\" if ID was invalid and default table is not set") { - const char * str = (const char*)object->getString(dAtoi(argv[2])); + const char * str = (const char*)object->getString(id); if(str != NULL) { char * ret = Con::getReturnBuffer(dStrlen(str) + 1); @@ -358,34 +358,34 @@ ConsoleMethod(LangTable, getString, const char *, 3, 3, return ""; } -ConsoleMethod(LangTable, setDefaultLanguage, void, 3, 3, "(int language)" +DefineConsoleMethod(LangTable, setDefaultLanguage, void, (S32 langId), , "(int language)" "@brief Sets the default language table\n\n" "@param language ID of the table\n") { - object->setDefaultLanguage(dAtoi(argv[2])); + object->setDefaultLanguage(langId); } -ConsoleMethod(LangTable, setCurrentLanguage, void, 3, 3, +DefineConsoleMethod(LangTable, setCurrentLanguage, void, (S32 langId), , "(int language)" "@brief Sets the current language table for grabbing text\n\n" "@param language ID of the table\n") { - object->setCurrentLanguage(dAtoi(argv[2])); + object->setCurrentLanguage(langId); } -ConsoleMethod(LangTable, getCurrentLanguage, S32, 2, 2, "()" +DefineConsoleMethod(LangTable, getCurrentLanguage, S32, (), , "()" "@brief Get the ID of the current language table\n\n" "@return Numerical ID of the current language table") { return object->getCurrentLanguage(); } -ConsoleMethod(LangTable, getLangName, const char *, 3, 3, "(int language)" +DefineConsoleMethod(LangTable, getLangName, const char *, (S32 langId), , "(int language)" "@brief Return the readable name of the language table\n\n" "@param language Numerical ID of the language table to access\n\n" "@return String containing the name of the table, NULL if ID was invalid or name was never specified") { - const char * str = (const char*)object->getLangName(dAtoi(argv[2])); + const char * str = (const char*)object->getLangName(langId); if(str != NULL) { char * ret = Con::getReturnBuffer(dStrlen(str) + 1); @@ -396,7 +396,7 @@ ConsoleMethod(LangTable, getLangName, const char *, 3, 3, "(int language)" return ""; } -ConsoleMethod(LangTable, getNumLang, S32, 2, 2, "()" +DefineConsoleMethod(LangTable, getNumLang, S32, (), , "()" "@brief Used to find out how many languages are in the table\n\n" "@return Size of the vector containing the languages, numerical") { diff --git a/Engine/source/lighting/advanced/advancedLightManager.cpp b/Engine/source/lighting/advanced/advancedLightManager.cpp index 29adfcc08..ef4446a40 100644 --- a/Engine/source/lighting/advanced/advancedLightManager.cpp +++ b/Engine/source/lighting/advanced/advancedLightManager.cpp @@ -34,6 +34,7 @@ #include "materials/materialManager.h" #include "math/util/sphereMesh.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "scene/sceneRenderState.h" #include "gfx/gfxCardProfile.h" #include "gfx/gfxTextureProfile.h" @@ -645,7 +646,7 @@ LightShadowMap* AdvancedLightManager::findShadowMapForObject( SimObject *object return sceneLight->getLight()->getExtended()->getShadowMap(); } -ConsoleFunction( setShadowVizLight, const char*, 2, 2, "" ) +DefineConsoleFunction( setShadowVizLight, const char*, (const char* name), (""), "") { static const String DebugTargetName( "AL_ShadowVizTexture" ); @@ -658,7 +659,7 @@ ConsoleFunction( setShadowVizLight, const char*, 2, 2, "" ) return 0; SimObject *object; - Sim::findObject( argv[1], object ); + Sim::findObject( name, object ); LightShadowMap *lightShadowMap = lm->findShadowMapForObject( object ); if ( !lightShadowMap || !lightShadowMap->getTexture() ) return 0; diff --git a/Engine/source/lighting/shadowManager.cpp b/Engine/source/lighting/shadowManager.cpp index 7c353f2ab..68a234c70 100644 --- a/Engine/source/lighting/shadowManager.cpp +++ b/Engine/source/lighting/shadowManager.cpp @@ -25,6 +25,7 @@ #include "scene/sceneManager.h" #include "materials/materialManager.h" +#include "console/engineAPI.h" const String ShadowManager::ManagerTypeName("ShadowManager"); @@ -53,7 +54,7 @@ SceneManager* ShadowManager::getSceneManager() //------------------------------------------------------------------------------ // Runtime switching of shadow systems. Requires correct world to be pushed at console. -ConsoleFunction( setShadowManager, bool, 1, 3, "string sShadowSystemName" ) +DefineConsoleFunction( setShadowManager, bool, (const char* sShadowSystemName), (""), "string sShadowSystemName") { /* // Make sure this new one exists diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index a47ac3a77..7e069c895 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -24,6 +24,7 @@ #include "materials/materialDefinition.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "math/mathTypes.h" #include "materials/materialManager.h" #include "sceneData.h" @@ -620,55 +621,55 @@ void Material::StageData::getFeatureSet( FeatureSet *outFeatures ) const } } -ConsoleMethod( Material, flush, void, 2, 2, +DefineConsoleMethod( Material, flush, void, (),, "Flushes all material instances that use this material." ) { object->flush(); } -ConsoleMethod( Material, reload, void, 2, 2, +DefineConsoleMethod( Material, reload, void, (),, "Reloads all material instances that use this material." ) { object->reload(); } -ConsoleMethod( Material, dumpInstances, void, 2, 2, +DefineConsoleMethod( Material, dumpInstances, void, (),, "Dumps a formatted list of the currently allocated material instances for this material to the console." ) { MATMGR->dumpMaterialInstances( object ); } -ConsoleMethod( Material, getAnimFlags, const char*, 3, 3, "" ) +DefineConsoleMethod( Material, getAnimFlags, const char*, (U32 id), , "" ) { char * animFlags = Con::getReturnBuffer(512); - if(object->mAnimFlags[ dAtoi(argv[2]) ] & Material::Scroll) + if(object->mAnimFlags[ id ] & Material::Scroll) { if(dStrcmp( animFlags, "" ) == 0) dStrcpy( animFlags, "$Scroll" ); } - if(object->mAnimFlags[ dAtoi(argv[2]) ] & Material::Rotate) + if(object->mAnimFlags[ id ] & Material::Rotate) { if(dStrcmp( animFlags, "" ) == 0) dStrcpy( animFlags, "$Rotate" ); else dStrcat( animFlags, " | $Rotate"); } - if(object->mAnimFlags[ dAtoi(argv[2]) ] & Material::Wave) + if(object->mAnimFlags[ id ] & Material::Wave) { if(dStrcmp( animFlags, "" ) == 0) dStrcpy( animFlags, "$Wave" ); else dStrcat( animFlags, " | $Wave"); } - if(object->mAnimFlags[ dAtoi(argv[2]) ] & Material::Scale) + if(object->mAnimFlags[ id ] & Material::Scale) { if(dStrcmp( animFlags, "" ) == 0) dStrcpy( animFlags, "$Scale" ); else dStrcat( animFlags, " | $Scale"); } - if(object->mAnimFlags[ dAtoi(argv[2]) ] & Material::Sequence) + if(object->mAnimFlags[ id ] & Material::Sequence) { if(dStrcmp( animFlags, "" ) == 0) dStrcpy( animFlags, "$Sequence" ); @@ -679,22 +680,22 @@ ConsoleMethod( Material, getAnimFlags, const char*, 3, 3, "" ) return animFlags; } -ConsoleMethod(Material, getFilename, const char*, 2, 2, "Get filename of material") +DefineConsoleMethod(Material, getFilename, const char*, (),, "Get filename of material") { SimObject *material = static_cast(object); return material->getFilename(); } -ConsoleMethod( Material, isAutoGenerated, bool, 2, 2, +DefineConsoleMethod( Material, isAutoGenerated, bool, (),, "Returns true if this Material was automatically generated by MaterialList::mapMaterials()" ) { return object->isAutoGenerated(); } -ConsoleMethod( Material, setAutoGenerated, void, 3, 3, +DefineConsoleMethod( Material, setAutoGenerated, void, (bool isAutoGenerated), , "setAutoGenerated(bool isAutoGenerated): Set whether or not the Material is autogenerated." ) { - object->setAutoGenerated(dAtob(argv[2])); + object->setAutoGenerated(isAutoGenerated); } // Accumulation diff --git a/Engine/source/materials/materialManager.cpp b/Engine/source/materials/materialManager.cpp index 5f48adf9b..50491d05b 100644 --- a/Engine/source/materials/materialManager.cpp +++ b/Engine/source/materials/materialManager.cpp @@ -30,6 +30,7 @@ #include "shaderGen/shaderGen.h" #include "core/module.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" MODULE_BEGIN( MaterialManager ) @@ -453,14 +454,14 @@ bool MaterialManager::_handleGFXEvent( GFXDevice::GFXDeviceEventType event_ ) return true; } -ConsoleFunction( reInitMaterials, void, 1, 1, +DefineConsoleFunction( reInitMaterials, void, (),, "@brief Flushes all procedural shaders and re-initializes all active material instances.\n\n" "@ingroup Materials") { MATMGR->flushAndReInitInstances(); } -ConsoleFunction( addMaterialMapping, void, 3, 3, "(string texName, string matName)\n" +DefineConsoleFunction( addMaterialMapping, void, (const char * texName, const char * matName), , "(string texName, string matName)\n" "@brief Maps the given texture to the given material.\n\n" "Generates a console warning before overwriting.\n\n" "Material maps are used by terrain and interiors for triggering " @@ -468,27 +469,27 @@ ConsoleFunction( addMaterialMapping, void, 3, 3, "(string texName, string matNam "block or interior surface using the associated texture.\n\n" "@ingroup Materials") { - MATMGR->mapMaterial(argv[1], argv[2]); + MATMGR->mapMaterial(texName, matName); } -ConsoleFunction( getMaterialMapping, const char*, 2, 2, "(string texName)\n" +DefineConsoleFunction( getMaterialMapping, const char*, (const char * texName), , "(string texName)\n" "@brief Returns the name of the material mapped to this texture.\n\n" "If no materials are found, an empty string is returned.\n\n" "@param texName Name of the texture\n\n" "@ingroup Materials") { - return MATMGR->getMapEntry(argv[1]).c_str(); + return MATMGR->getMapEntry(texName).c_str(); } -ConsoleFunction( dumpMaterialInstances, void, 1, 1, +DefineConsoleFunction( dumpMaterialInstances, void, (), , "@brief Dumps a formatted list of currently allocated material instances to the console.\n\n" "@ingroup Materials") { MATMGR->dumpMaterialInstances(); } -ConsoleFunction( getMapEntry, const char *, 2, 2, +DefineConsoleFunction( getMapEntry, const char*, (const char * texName), , "@hide") { - return MATMGR->getMapEntry( argv[1] ); + return MATMGR->getMapEntry( String(texName) ); } diff --git a/Engine/source/math/mConsoleFunctions.cpp b/Engine/source/math/mConsoleFunctions.cpp index 89d8bd6e2..1a11fe23e 100644 --- a/Engine/source/math/mConsoleFunctions.cpp +++ b/Engine/source/math/mConsoleFunctions.cpp @@ -94,13 +94,13 @@ DefineConsoleFunction( mFloor, S32, ( F32 v ),, return (S32)mFloor( v ); } -DefineConsoleFunction( mRound, S32, ( F32 v ),, - "Round v to the nearest integer.\n" - "@param v Number to convert to integer." - "@returns Number converted to integer." - "@ingroup Math" ) +DefineConsoleFunction( mRound, S32, ( F32 v ),, + "Round v to the nth decimal place or the nearest whole number by default." + "@param v Value to roundn" + "@return The rounded value as a S32." + "@ingroup Math" ) { - return (S32)mFloor( v + 0.5f ); + return mRound(v); } DefineConsoleFunction( mCeil, S32, ( F32 v ),, @@ -119,8 +119,9 @@ DefineConsoleFunction( mFloatLength, const char*, ( F32 v, U32 precision ),, "@returns Number formatted to the specified number of decimal places." "@ingroup Math" ) { - char fmtString[8] = "%.0f"; - if (precision > 9) + char fmtString[8] = "%.9f"; + + if (precision >= 9) precision = 9; fmtString[2] = '0' + precision; diff --git a/Engine/source/math/mMathFn.h b/Engine/source/math/mMathFn.h index 6b41cfa89..1855656e7 100644 --- a/Engine/source/math/mMathFn.h +++ b/Engine/source/math/mMathFn.h @@ -200,6 +200,18 @@ inline F32 mFmod(const F32 val, const F32 mod) return fmod(val, mod); } +inline S32 mRound(const F32 val) +{ + return (S32)floor(val + 0.5f); +} + +inline F32 mRound(const F32 val, const S32 n) +{ + S32 place = (S32) pow(10.0f, n); + + return mFloor((val*place)+0.5)/place; +} + inline S32 mAbs(const S32 val) { return abs(val); diff --git a/Engine/source/math/mathTypes.cpp b/Engine/source/math/mathTypes.cpp index 7afa3ab2b..ce0f198d1 100644 --- a/Engine/source/math/mathTypes.cpp +++ b/Engine/source/math/mathTypes.cpp @@ -831,6 +831,26 @@ DefineConsoleFunction( VectorOrthoBasis, MatrixF, ( AngAxisF aa ),, //----------------------------------------------------------------------------- +//ConsoleFunction(VectorRot, const char*, 3, 3, "(Vector3F, float) rotate a vector in 2d") +DefineConsoleFunction( VectorRot, const char*, (Point3F v, F32 angle), , "(Vector3F, float) rotate a vector in 2d") +{ + //VectorF v(0,0,0); + //dSscanf(argv[1],"%g %g %g",&v.x,&v.y,&v.z); + //dSscanf(axeStr,"%g %g %g",&v.x,&v.y,&v.z); + + //float angle = dAtof(argv[2]); + //float angle = dAtof(angleStr); + + float x = 0, y = 0; + + x = v.x * cos(angle) - v.y * sin(angle); + y = v.x * sin(angle) + v.y * cos(angle); + + char* returnBuffer = Con::getReturnBuffer(256); + dSprintf(returnBuffer,256,"%g %g %g", x, y, v.z); + return returnBuffer; +} + DefineConsoleFunction( VectorLerp, VectorF, ( VectorF a, VectorF b, F32 t ),, "Linearly interpolate between two vectors by @a t.\n" "@param a Vector to start interpolation from.\n" @@ -999,7 +1019,7 @@ F32 mRandF() return gRandGen.randF(); } -ConsoleFunction( getRandom, F32, 1, 3, +DefineConsoleFunction( getRandom, F32, (S32 a, S32 b), (1, 0), "( int a, int b ) " "@brief Returns a random number based on parameters passed in..\n\n" "If no parameters are passed in, getRandom() will return a float between 0.0 and 1.0. If one " @@ -1013,14 +1033,14 @@ ConsoleFunction( getRandom, F32, 1, 3, "@see setRandomSeed\n" "@ingroup Random" ) { - if (argc == 2) - return F32(gRandGen.randI(0,getMax( dAtoi(argv[1]), 0 ))); + if (b == 0) + return F32(gRandGen.randI(0,getMax( a, 0 ))); else { - if (argc == 3) + if (b != 0) { - S32 min = dAtoi(argv[1]); - S32 max = dAtoi(argv[2]); + S32 min = a; + S32 max = b; if (min > max) { S32 t = min; diff --git a/Engine/source/math/util/tResponseCurve.cpp b/Engine/source/math/util/tResponseCurve.cpp index 450549d61..2c1d5c53c 100644 --- a/Engine/source/math/util/tResponseCurve.cpp +++ b/Engine/source/math/util/tResponseCurve.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- #include "tResponseCurve.h" +#include "console/engineAPI.h" IMPLEMENT_CONOBJECT( SimResponseCurve ); @@ -63,17 +64,17 @@ void SimResponseCurve::clear() mCurve.clear(); } -ConsoleMethod( SimResponseCurve, addPoint, void, 4, 4, "addPoint( F32 value, F32 time )" ) +DefineConsoleMethod( SimResponseCurve, addPoint, void, ( F32 value, F32 time ), , "addPoint( F32 value, F32 time )" ) { - object->addPoint( dAtof(argv[2]), dAtof(argv[3]) ); + object->addPoint( value, time ); } -ConsoleMethod( SimResponseCurve, getValue, F32, 3, 3, "getValue( F32 time )" ) +DefineConsoleMethod( SimResponseCurve, getValue, F32, ( F32 time ), , "getValue( F32 time )" ) { - return object->getValue( dAtof(argv[2]) ); + return object->getValue( time ); } -ConsoleMethod( SimResponseCurve, clear, void, 2, 2, "clear()" ) +DefineConsoleMethod( SimResponseCurve, clear, void, (), , "clear()" ) { object->clear(); } \ No newline at end of file diff --git a/Engine/source/platform/menus/menuBar.cpp b/Engine/source/platform/menus/menuBar.cpp index d12f209a9..cb70838a8 100644 --- a/Engine/source/platform/menus/menuBar.cpp +++ b/Engine/source/platform/menus/menuBar.cpp @@ -24,6 +24,7 @@ #include "platform/menus/menuBar.h" #include "platform/menus/popupMenu.h" #include "gui/core/guiCanvas.h" +#include "console/engineAPI.h" //----------------------------------------------------------------------------- // Constructor/Destructor @@ -106,22 +107,21 @@ bool MenuBar::reOrder(SimObject *obj, SimObject *target /*= 0*/) // Console Methods //----------------------------------------------------------------------------- -ConsoleMethod(MenuBar, attachToCanvas, void, 4, 4, "(GuiCanvas, pos)") +DefineConsoleMethod(MenuBar, attachToCanvas, void, (const char *canvas, S32 pos), , "(GuiCanvas, pos)") { - object->attachToCanvas(dynamic_cast(Sim::findObject(argv[2])), dAtoi(argv[3])); + object->attachToCanvas(dynamic_cast(Sim::findObject(canvas)), pos); } -ConsoleMethod(MenuBar, removeFromCanvas, void, 2, 2, "()") +DefineConsoleMethod(MenuBar, removeFromCanvas, void, (), , "()") { object->removeFromCanvas(); } //----------------------------------------------------------------------------- -ConsoleMethod(MenuBar, insert, void, 4, 4,"(object, pos) insert object at position") +DefineConsoleMethod(MenuBar, insert, void, (SimObject* pObject, S32 pos), ,"(object, pos) insert object at position") { - SimObject* pObject = Sim::findObject(argv[2]); if(pObject) - object->insertObject(pObject, dAtoi(argv[3])); + object->insertObject(pObject, pos); } diff --git a/Engine/source/platform/menus/popupMenu.cpp b/Engine/source/platform/menus/popupMenu.cpp index 9d567ca65..4437a274c 100644 --- a/Engine/source/platform/menus/popupMenu.cpp +++ b/Engine/source/platform/menus/popupMenu.cpp @@ -22,6 +22,7 @@ #include "platform/menus/popupMenu.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "gui/core/guiCanvas.h" #include "core/util/safeDelete.h" @@ -194,77 +195,75 @@ bool PopupMenu::onMessageObjectReceived(StringTableEntry queue, Message *msg ) // Console Methods //----------------------------------------------------------------------------- -ConsoleMethod(PopupMenu, insertItem, S32, 3, 5, "(pos[, title][, accelerator])") +DefineConsoleMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator), ("", ""), "(pos[, title][, accelerator])") { - return object->insertItem(dAtoi(argv[2]), argc < 4 ? NULL : argv[3], argc < 5 ? "" : argv[4]); + return object->insertItem(pos, title, accelerator); } -ConsoleMethod(PopupMenu, removeItem, void, 3, 3, "(pos)") +DefineConsoleMethod(PopupMenu, removeItem, void, (S32 pos), , "(pos)") { - object->removeItem(dAtoi(argv[2])); + object->removeItem(pos); } -ConsoleMethod(PopupMenu, insertSubMenu, S32, 5, 5, "(pos, title, subMenu)") +DefineConsoleMethod(PopupMenu, insertSubMenu, S32, (S32 pos, String title, String subMenu), , "(pos, title, subMenu)") { - PopupMenu *mnu = dynamic_cast(Sim::findObject(argv[4])); + PopupMenu *mnu = dynamic_cast(Sim::findObject(subMenu)); if(mnu == NULL) { Con::errorf("PopupMenu::insertSubMenu - Invalid PopupMenu object specified for submenu"); return -1; } - return object->insertSubMenu(dAtoi(argv[2]), argv[3], mnu); + return object->insertSubMenu(pos, title, mnu); } -ConsoleMethod(PopupMenu, setItem, bool, 4, 5, "(pos, title[, accelerator])") +DefineConsoleMethod(PopupMenu, setItem, bool, (S32 pos, const char * title, const char * accelerator), (""), "(pos, title[, accelerator])") { - return object->setItem(dAtoi(argv[2]), argv[3], argc < 5 ? "" : argv[4]); + return object->setItem(pos, title, accelerator); } //----------------------------------------------------------------------------- -ConsoleMethod(PopupMenu, enableItem, void, 4, 4, "(pos, enabled)") +DefineConsoleMethod(PopupMenu, enableItem, void, (S32 pos, bool enabled), , "(pos, enabled)") { - object->enableItem(dAtoi(argv[2]), dAtob(argv[3])); + object->enableItem(pos, enabled); } -ConsoleMethod(PopupMenu, checkItem, void, 4, 4, "(pos, checked)") +DefineConsoleMethod(PopupMenu, checkItem, void, (S32 pos, bool checked), , "(pos, checked)") { - object->checkItem(dAtoi(argv[2]), dAtob(argv[3])); + object->checkItem(pos, checked); } -ConsoleMethod(PopupMenu, checkRadioItem, void, 5, 5, "(firstPos, lastPos, checkPos)") +DefineConsoleMethod(PopupMenu, checkRadioItem, void, (S32 firstPos, S32 lastPos, S32 checkPos), , "(firstPos, lastPos, checkPos)") { - object->checkRadioItem(dAtoi(argv[2]), dAtoi(argv[3]), dAtoi(argv[4])); + object->checkRadioItem(firstPos, lastPos, checkPos); } -ConsoleMethod(PopupMenu, isItemChecked, bool, 3, 3, "(pos)") +DefineConsoleMethod(PopupMenu, isItemChecked, bool, (S32 pos), , "(pos)") { - return object->isItemChecked(dAtoi(argv[2])); + return object->isItemChecked(pos); } -ConsoleMethod(PopupMenu, getItemCount, S32, 2, 2, "()") +DefineConsoleMethod(PopupMenu, getItemCount, S32, (), , "()") { return object->getItemCount(); } //----------------------------------------------------------------------------- -ConsoleMethod(PopupMenu, attachToMenuBar, void, 5, 5, "(GuiCanvas, pos, title)") +DefineConsoleMethod(PopupMenu, attachToMenuBar, void, (const char * canvasName, S32 pos, const char * title), , "(GuiCanvas, pos, title)") { - object->attachToMenuBar(dynamic_cast(Sim::findObject(argv[2])),dAtoi(argv[3]), argv[4]); + object->attachToMenuBar(dynamic_cast(Sim::findObject(canvasName)), pos, title); } -ConsoleMethod(PopupMenu, removeFromMenuBar, void, 2, 2, "()") +DefineConsoleMethod(PopupMenu, removeFromMenuBar, void, (), , "()") { object->removeFromMenuBar(); } //----------------------------------------------------------------------------- -ConsoleMethod(PopupMenu, showPopup, void, 3, 5, "(Canvas,[x, y])") +DefineConsoleMethod(PopupMenu, showPopup, void, (const char * canvasName, S32 x, S32 y), ( -1, -1), "(Canvas,[x, y])") { - GuiCanvas *pCanvas = dynamic_cast(Sim::findObject(argv[2])); - S32 x = argc >= 4 ? dAtoi(argv[3]) : -1; - S32 y = argc >= 5 ? dAtoi(argv[4]) : -1; + GuiCanvas *pCanvas = dynamic_cast(Sim::findObject(canvasName)); object->showPopup(pCanvas, x, y); } diff --git a/Engine/source/platform/platformFileIO.cpp b/Engine/source/platform/platformFileIO.cpp index fc42c0565..33fff52b7 100644 --- a/Engine/source/platform/platformFileIO.cpp +++ b/Engine/source/platform/platformFileIO.cpp @@ -23,6 +23,7 @@ #include "core/strings/stringFunctions.h" #include "util/tempAlloc.h" #include "console/console.h" +#include "console/engineAPI.h" #include "core/stringTable.h" //----------------------------------------------------------------------------- @@ -37,7 +38,7 @@ StringTableEntry Platform::getTemporaryDirectory() return path; } -ConsoleFunction(getTemporaryDirectory, const char *, 1, 1, "()" +DefineConsoleFunction( getTemporaryDirectory, const char *, (), , "@brief Returns the OS temporary directory, \"C:/Users/Mich/AppData/Local/Temp\" for example\n\n" "@note This can be useful to adhering to OS standards and practices, " "but not really used in Torque 3D right now.\n" @@ -65,7 +66,7 @@ StringTableEntry Platform::getTemporaryFileName() return StringTable->insert(buf); } -ConsoleFunction(getTemporaryFileName, const char *, 1, 1, "()" +DefineConsoleFunction( getTemporaryFileName, const char *, (), , "@brief Creates a name and extension for a potential temporary file\n\n" "This does not create the actual file. It simply creates a random name " "for a file that does not exist.\n\n" @@ -520,12 +521,12 @@ StringTableEntry Platform::getPrefsPath(const char *file /* = NULL */) //----------------------------------------------------------------------------- -ConsoleFunction(getUserDataDirectory, const char*, 1, 1, "getUserDataDirectory()") +DefineConsoleFunction( getUserDataDirectory, const char *, (), , "getUserDataDirectory()") { return Platform::getUserDataDirectory(); } -ConsoleFunction(getUserHomeDirectory, const char*, 1, 1, "getUserHomeDirectory()") +DefineConsoleFunction( getUserHomeDirectory, const char *, (), , "getUserHomeDirectory()") { return Platform::getUserHomeDirectory(); } diff --git a/Engine/source/platform/platformRedBook.cpp b/Engine/source/platform/platformRedBook.cpp index e884c7ceb..6ca34850c 100644 --- a/Engine/source/platform/platformRedBook.cpp +++ b/Engine/source/platform/platformRedBook.cpp @@ -22,6 +22,7 @@ #include "core/strings/stringFunctions.h" #include "console/console.h" +#include "console/engineAPI.h" #include "platform/platformRedBook.h" //------------------------------------------------------------------------------ @@ -209,37 +210,38 @@ bool RedBook::setVolume(F32 volume) ConsoleFunctionGroupBegin( Redbook, "Control functions for Redbook audio (ie, CD audio)."); -ConsoleFunction(redbookOpen, bool, 1, 2, "(string device=NULL)" +DefineConsoleFunction( redbookOpen, bool, (const char * device), (""), "(string device=NULL)" "@brief Deprecated\n\n" "@internal") { - if(argc == 1) + if(dStrcmp(device,"")==0) return(RedBook::open(RedBook::getDeviceName(0))); else - return(RedBook::open(argv[1])); + return(RedBook::open(device)); } -ConsoleFunction(redbookClose, bool, 1, 1, "Close the current Redbook device." +DefineConsoleFunction( redbookClose, bool, (), , "Close the current Redbook device." "@brief Deprecated\n\n" "@internal") { return(RedBook::close()); } -ConsoleFunction( redbookPlay, bool, 2, 2, "(int track) Play the selected track." +DefineConsoleFunction( redbookPlay, bool, (S32 track), , "(int track) Play the selected track." "@brief Deprecated\n\n" "@internal") { - return(RedBook::play(dAtoi(argv[1]))); + return(RedBook::play(track)); } -ConsoleFunction( redbookStop, bool, 1, 1, "Stop playing." +DefineConsoleFunction( redbookStop, bool, (), , "Stop playing." "@brief Deprecated\n\n" "@internal") { return(RedBook::stop()); } -ConsoleFunction(redbookGetTrackCount, S32, 1, 1, "Return the number of tracks." + +DefineConsoleFunction( redbookGetTrackCount, S32, (), , "Return the number of tracks." "@brief Deprecated\n\n" "@internal") { @@ -249,7 +251,7 @@ ConsoleFunction(redbookGetTrackCount, S32, 1, 1, "Return the number of tracks." return(trackCount); } -ConsoleFunction(redbookGetVolume, F32, 1, 1, "Get the volume." +DefineConsoleFunction( redbookGetVolume, F32, (), , "Get the volume." "@brief Deprecated\n\n" "@internal") { @@ -260,28 +262,28 @@ ConsoleFunction(redbookGetVolume, F32, 1, 1, "Get the volume." return(vol); } -ConsoleFunction(redbookSetVolume, bool, 2, 2, "(float volume) Set playback volume." +DefineConsoleFunction( redbookSetVolume, bool, (F32 volume), , "(float volume) Set playback volume." "@brief Deprecated\n\n" "@internal") { - return(RedBook::setVolume(dAtof(argv[1]))); + return(RedBook::setVolume(volume)); } -ConsoleFunction( redbookGetDeviceCount, S32, 1, 1, "get the number of redbook devices." +DefineConsoleFunction( redbookGetDeviceCount, S32, (), , "get the number of redbook devices." "@brief Deprecated\n\n" "@internal") { return(RedBook::getDeviceCount()); } -ConsoleFunction( redbookGetDeviceName, const char *, 2, 2, "(int index) Get name of specified Redbook device." +DefineConsoleFunction( redbookGetDeviceName, const char *, (S32 index), , "(int index) Get name of specified Redbook device." "@brief Deprecated\n\n" "@internal") { - return(RedBook::getDeviceName(dAtoi(argv[1]))); + return(RedBook::getDeviceName(index)); } -ConsoleFunction( redbookGetLastError, const char*, 1, 1, "Get a string explaining the last redbook error." +DefineConsoleFunction( redbookGetLastError, const char *, (), , "Get a string explaining the last redbook error." "@brief Deprecated\n\n" "@internal") { diff --git a/Engine/source/platform/platformTimer.cpp b/Engine/source/platform/platformTimer.cpp index 58f735840..a9a342616 100644 --- a/Engine/source/platform/platformTimer.cpp +++ b/Engine/source/platform/platformTimer.cpp @@ -22,6 +22,7 @@ #include "platform/platformTimer.h" #include "core/util/journal/process.h" +#include "console/engineAPI.h" void TimeManager::_updateTime() { @@ -168,12 +169,12 @@ S32 ScriptTimerMan::stopTimer( S32 id ) ScriptTimerMan gScriptTimerMan; -ConsoleFunction( startPrecisionTimer, S32, 1, 1, "startPrecisionTimer() - Create and start a high resolution platform timer. Returns the timer id." ) +DefineConsoleFunction( startPrecisionTimer, S32, (), , "startPrecisionTimer() - Create and start a high resolution platform timer. Returns the timer id." ) { return gScriptTimerMan.startTimer(); } -ConsoleFunction( stopPrecisionTimer, S32, 2, 2, "stopPrecisionTimer( S32 id ) - Stop and destroy timer with the passed id. Returns the elapsed milliseconds." ) +DefineConsoleFunction( stopPrecisionTimer, S32, ( S32 id), , "stopPrecisionTimer( S32 id ) - Stop and destroy timer with the passed id. Returns the elapsed milliseconds." ) { - return gScriptTimerMan.stopTimer( dAtoi( argv[1] ) ); + return gScriptTimerMan.stopTimer( id ); } \ No newline at end of file diff --git a/Engine/source/platformWin32/cardProfile.cpp b/Engine/source/platformWin32/cardProfile.cpp index 50f70bbbf..a4658f98c 100644 --- a/Engine/source/platformWin32/cardProfile.cpp +++ b/Engine/source/platformWin32/cardProfile.cpp @@ -22,6 +22,7 @@ #include "core/strings/stringFunctions.h" #include "console/console.h" +#include "console/engineAPI.h" #include "platformWin32/platformWin32.h" @@ -73,7 +74,7 @@ void initDisplayDeviceInfo() Con::setVariable( "$PCI_DEV", dev ); } -ConsoleFunction( initDisplayDeviceInfo, void, 1, 1, "()" +DefineConsoleFunction( initDisplayDeviceInfo, void, (), , "()" "@brief Initializes variables that track device and vendor information/IDs\n\n" "@ingroup Rendering") { diff --git a/Engine/source/platformWin32/winConsole.cpp b/Engine/source/platformWin32/winConsole.cpp index 25f172abb..0040c5677 100644 --- a/Engine/source/platformWin32/winConsole.cpp +++ b/Engine/source/platformWin32/winConsole.cpp @@ -27,6 +27,7 @@ #include "platformWin32/platformWin32.h" #include "platformWin32/winConsole.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "core/util/journal/process.h" @@ -37,10 +38,9 @@ namespace Con extern bool alwaysUseDebugOutput; } -ConsoleFunction(enableWinConsole, void, 2, 2, "enableWinConsole(bool);") +DefineConsoleFunction( enableWinConsole, void, (bool flag), , "enableWinConsole(bool);") { - argc; - WindowsConsole->enable(dAtob(argv[1])); + WindowsConsole->enable(flag); } void WinConsole::create() diff --git a/Engine/source/platformWin32/winDirectInput.cpp b/Engine/source/platformWin32/winDirectInput.cpp index fa02285b0..e56f86265 100644 --- a/Engine/source/platformWin32/winDirectInput.cpp +++ b/Engine/source/platformWin32/winDirectInput.cpp @@ -25,6 +25,7 @@ #include "platformWin32/winDInputDevice.h" #include "console/console.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" #include "sim/actionMap.h" #include @@ -768,37 +769,34 @@ void DInputManager::processXInput( void ) mXInputStateReset = false; } } -ConsoleFunction( enableJoystick, bool, 1, 1, "()" +DefineConsoleFunction( enableJoystick, bool, (), , "()" "@brief Enables use of the joystick.\n\n" "@note DirectInput must be enabled and active to use this function.\n\n" "@ingroup Input") { - argc; argv; return( DInputManager::enableJoystick() ); } //------------------------------------------------------------------------------ -ConsoleFunction( disableJoystick, void, 1, 1,"()" +DefineConsoleFunction( disableJoystick, void, (), , "()" "@brief Disables use of the joystick.\n\n" "@note DirectInput must be enabled and active to use this function.\n\n" "@ingroup Input") { - argc; argv; DInputManager::disableJoystick(); } //------------------------------------------------------------------------------ -ConsoleFunction( isJoystickEnabled, bool, 1, 1, "()" +DefineConsoleFunction( isJoystickEnabled, bool, (), , "()" "@brief Queries input manager to see if a joystick is enabled\n\n" "@return 1 if a joystick exists and is enabled, 0 if it's not.\n" "@ingroup Input") { - argc; argv; return DInputManager::isJoystickEnabled(); } //------------------------------------------------------------------------------ -ConsoleFunction( enableXInput, bool, 1, 1, "()" +DefineConsoleFunction( enableXInput, bool, (), , "()" "@brief Enables XInput for Xbox 360 controllers.\n\n" "@note XInput is enabled by default. Disable to use an Xbox 360 " "Controller as a joystick device.\n\n" @@ -809,21 +807,19 @@ ConsoleFunction( enableXInput, bool, 1, 1, "()" // DLL. You would want to disable it if you have 360 controllers and want to // read them as joysticks... why you'd want to do that is beyond me - argc; argv; return( DInputManager::enableXInput() ); } //------------------------------------------------------------------------------ -ConsoleFunction( disableXInput, void, 1, 1, "()" +DefineConsoleFunction( disableXInput, void, (), , "()" "@brief Disables XInput for Xbox 360 controllers.\n\n" "@ingroup Input") { - argc; argv; DInputManager::disableXInput(); } //------------------------------------------------------------------------------ -ConsoleFunction( resetXInput, void, 1, 1, "()" +DefineConsoleFunction( resetXInput, void, (), , "()" "@brief Rebuilds the XInput section of the InputManager\n\n" "Requests a full refresh of events for all controllers. Useful when called at the beginning " "of game code after actionMaps are set up to hook up all appropriate events.\n\n" @@ -834,28 +830,26 @@ ConsoleFunction( resetXInput, void, 1, 1, "()" // at the beginning of your game code after your actionMap is set up to hook // all of the appropriate events - argc; argv; DInputManager* mgr = dynamic_cast( Input::getManager() ); if ( mgr && mgr->isEnabled() ) mgr->resetXInput(); } //------------------------------------------------------------------------------ -ConsoleFunction( isXInputConnected, bool, 2, 2, "( int controllerID )" +DefineConsoleFunction( isXInputConnected, bool, (S32 controllerID), , "( int controllerID )" "@brief Checks to see if an Xbox 360 controller is connected\n\n" "@param controllerID Zero-based index of the controller to check.\n" "@return 1 if the controller is connected, 0 if it isn't, and 205 if XInput " "hasn't been initialized." "@ingroup Input") { - argc; argv; DInputManager* mgr = dynamic_cast( Input::getManager() ); - if ( mgr && mgr->isEnabled() ) return mgr->isXInputConnected( atoi( argv[1] ) ); + if ( mgr && mgr->isEnabled() ) return mgr->isXInputConnected( controllerID ); return false; } //------------------------------------------------------------------------------ -ConsoleFunction( getXInputState, S32, 3, 4, "( int controllerID, string property, bool current )" +DefineConsoleFunction( getXInputState, int, (S32 controllerID, const char * properties, bool current), (false), "( int controllerID, string property, bool currentD )" "@brief Queries the current state of a connected Xbox 360 controller.\n\n" "XInput Properties:\n\n" " - XI_THUMBLX, XI_THUMBLY - X and Y axes of the left thumbstick. \n" @@ -874,7 +868,6 @@ ConsoleFunction( getXInputState, S32, 3, 4, "( int controllerID, string property "@return %Trigger queried - Int from 0 to 255 representing how far the trigger is displaced." "@ingroup Input") { - argc; argv; DInputManager* mgr = dynamic_cast( Input::getManager() ); if ( !mgr || !mgr->isEnabled() ) @@ -883,9 +876,9 @@ ConsoleFunction( getXInputState, S32, 3, 4, "( int controllerID, string property // Use a little bit of macro magic to simplify this otherwise monolothic // block of code. #define GET_XI_STATE(constName) \ - if (!dStricmp(argv[2], #constName)) \ - return mgr->getXInputState( dAtoi( argv[1] ), constName, ( dAtoi ( argv[3] ) == 1) ); - + if (!dStricmp(properties, #constName)) \ + return mgr->getXInputState( controllerID, constName, ( current )); + GET_XI_STATE(XI_THUMBLX); GET_XI_STATE(XI_THUMBLY); GET_XI_STATE(XI_THUMBRX); @@ -912,11 +905,10 @@ ConsoleFunction( getXInputState, S32, 3, 4, "( int controllerID, string property } //------------------------------------------------------------------------------ -ConsoleFunction( echoInputState, void, 1, 1, "()" +DefineConsoleFunction( echoInputState, void, (), , "()" "@brief Prints information to the console stating if DirectInput and a Joystick are enabled and active.\n\n" "@ingroup Input") { - argc; argv; DInputManager* mgr = dynamic_cast( Input::getManager() ); if ( mgr && mgr->isEnabled() ) { @@ -929,7 +921,7 @@ ConsoleFunction( echoInputState, void, 1, 1, "()" Con::printf( "DirectInput is not enabled." ); } -ConsoleFunction( rumble, void, 4, 4, "(string device, float xRumble, float yRumble)" +DefineConsoleFunction( rumble, void, (const char * device, F32 xRumble, F32 yRumble), , "(string device, float xRumble, float yRumble)" "@brief Activates the vibration motors in the specified controller.\n\n" "The controller will constantly at it's xRumble and yRumble intensities until " "changed or told to stop." @@ -944,7 +936,7 @@ ConsoleFunction( rumble, void, 4, 4, "(string device, float xRumble, float yRumb DInputManager* mgr = dynamic_cast( Input::getManager() ); if ( mgr && mgr->isEnabled() ) { - mgr->rumble(argv[1], dAtof(argv[2]), dAtof(argv[3])); + mgr->rumble(device, xRumble, yRumble); } else { diff --git a/Engine/source/platformWin32/winExec.cpp b/Engine/source/platformWin32/winExec.cpp index 93357b1cb..7a1bf7332 100644 --- a/Engine/source/platformWin32/winExec.cpp +++ b/Engine/source/platformWin32/winExec.cpp @@ -22,6 +22,7 @@ #include "platformWin32/platformWin32.h" #include "console/console.h" +#include "console/engineAPI.h" #include "console/simBase.h" #include "core/strings/unicode.h" #include "platform/threads/thread.h" @@ -135,14 +136,14 @@ void ExecuteThread::run(void *arg /* = 0 */) // Console Functions //----------------------------------------------------------------------------- -ConsoleFunction(shellExecute, bool, 2, 4, "(string executable, string args, string directory)" +DefineConsoleFunction( shellExecute, bool, (const char * executable, const char * args, const char * directory), ("", ""), "(string executable, string args, string directory)" "@brief Launches an outside executable or batch file\n\n" "@param executable Name of the executable or batch file\n" "@param args Optional list of arguments, in string format, to pass to the executable\n" "@param directory Optional string containing path to output or shell\n" "@ingroup Platform") { - ExecuteThread *et = new ExecuteThread(argv[1], argc > 2 ? argv[2] : NULL, argc > 3 ? argv[3] : NULL); + ExecuteThread *et = new ExecuteThread( executable, args, directory ); if(! et->isAlive()) { delete et; diff --git a/Engine/source/platformWin32/winInput.cpp b/Engine/source/platformWin32/winInput.cpp index f9719ed92..8ceb7b2df 100644 --- a/Engine/source/platformWin32/winInput.cpp +++ b/Engine/source/platformWin32/winInput.cpp @@ -25,6 +25,7 @@ #include "platform/platformInput.h" #include "platformWin32/winDirectInput.h" #include "console/console.h" +#include "console/engineAPI.h" #include "core/util/journal/process.h" #include "windowManager/platformWindowMgr.h" @@ -155,19 +156,17 @@ void Input::init() } //------------------------------------------------------------------------------ -ConsoleFunction( isJoystickDetected, bool, 1, 1, "isJoystickDetected()" ) +DefineConsoleFunction( isJoystickDetected, bool, (), , "isJoystickDetected()") { - argc; argv; return( DInputDevice::joystickDetected() ); } //------------------------------------------------------------------------------ -ConsoleFunction( getJoystickAxes, const char*, 2, 2, "getJoystickAxes( instance )" ) +DefineConsoleFunction( getJoystickAxes, const char*, (U32 deviceID), , "getJoystickAxes( instance )") { - argc; DInputManager* mgr = dynamic_cast( Input::getManager() ); if ( mgr ) - return( mgr->getJoystickAxesString( dAtoi( argv[1] ) ) ); + return( mgr->getJoystickAxesString( deviceID ) ); return( "" ); } @@ -505,10 +504,9 @@ void Input::log( const char* format, ... ) va_end( argptr ); } -ConsoleFunction( inputLog, void, 2, 2, "inputLog( string )" ) +DefineConsoleFunction( inputLog, void, (const char * log), , "inputLog( string )") { - argc; - Input::log( "%s\n", (const char*)argv[1] ); + Input::log( "%s\n", log ); } #endif // LOG_INPUT diff --git a/Engine/source/platformWin32/winMath.cpp b/Engine/source/platformWin32/winMath.cpp index cdcba5eae..fb7a73054 100644 --- a/Engine/source/platformWin32/winMath.cpp +++ b/Engine/source/platformWin32/winMath.cpp @@ -22,6 +22,7 @@ #include "core/strings/stringFunctions.h" #include "console/console.h" +#include "console/engineAPI.h" #include "math/mMath.h" diff --git a/Engine/source/platformWin32/winWindow.cpp b/Engine/source/platformWin32/winWindow.cpp index 2546f2cbb..278192a40 100644 --- a/Engine/source/platformWin32/winWindow.cpp +++ b/Engine/source/platformWin32/winWindow.cpp @@ -26,6 +26,7 @@ #include "platformWin32/winDirectInput.h" #include "windowManager/win32/win32Window.h" #include "console/console.h" +#include "console/engineAPI.h" #include "math/mRandom.h" #include "core/stream/fileStream.h" #include "T3D/resource.h" @@ -603,9 +604,8 @@ bool Platform::setLoginPassword( const char* password ) // as commentary on Koreans as a nationality. Thank you for your // attention. //-------------------------------------- -ConsoleFunction( isKoreanBuild, bool, 1, 1, "isKoreanBuild()" ) +DefineConsoleFunction( isKoreanBuild, bool, ( ), , "isKoreanBuild()") { - argc; argv; HKEY regKey; bool result = false; if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TorqueRegKey, 0, KEY_QUERY_VALUE, ®Key ) == ERROR_SUCCESS ) diff --git a/Engine/source/scene/pathManager.cpp b/Engine/source/scene/pathManager.cpp index 1bb263765..350a538ba 100644 --- a/Engine/source/scene/pathManager.cpp +++ b/Engine/source/scene/pathManager.cpp @@ -30,6 +30,7 @@ #include "scene/sceneManager.h" #include "platform/profiler.h" #include "core/module.h" +#include "console/engineAPI.h" extern bool gEditingMission; @@ -206,12 +207,12 @@ void PathManager::clearPaths() #endif } -ConsoleFunction(clearServerPaths, void, 1, 1, "") +DefineConsoleFunction( clearServerPaths, void, ( ), , "") { gServerPathManager->clearPaths(); } -ConsoleFunction(clearClientPaths, void, 1, 1, "") +DefineConsoleFunction( clearClientPaths, void, ( ), , "") { gClientPathManager->clearPaths(); } diff --git a/Engine/source/sfx/sfxSource.cpp b/Engine/source/sfx/sfxSource.cpp index e3e813e47..d125f55bc 100644 --- a/Engine/source/sfx/sfxSource.cpp +++ b/Engine/source/sfx/sfxSource.cpp @@ -1345,7 +1345,7 @@ void SFXSource::_scatterTransform() //----------------------------------------------------------------------------- -DefineEngineMethod( SFXSource, play, void, ( F32 fadeInTime ), ( -1.f ), +DefineEngineMethod( SFXSource, play, void, ( F32 fadeInTime ), ( -1.0f ), "Start playback of the source.\n" "If the sound data for the source has not yet been fully loaded, there will be a delay after calling " "play and playback will start after the data has become available.\n\n" @@ -1358,7 +1358,7 @@ DefineEngineMethod( SFXSource, play, void, ( F32 fadeInTime ), ( -1.f ), //----------------------------------------------------------------------------- -DefineEngineMethod( SFXSource, stop, void, ( F32 fadeOutTime ), ( -1.f ), +DefineEngineMethod( SFXSource, stop, void, ( F32 fadeOutTime ), ( -1.0f ), "Stop playback of the source.\n" "@param fadeOutTime Seconds for the sound to fade down to zero volume. If -1, the SFXDescription::fadeOutTime " "set in the source's associated description is used. Pass 0 to disable a fade-out effect that may be " @@ -1371,7 +1371,7 @@ DefineEngineMethod( SFXSource, stop, void, ( F32 fadeOutTime ), ( -1.f ), //----------------------------------------------------------------------------- -DefineEngineMethod( SFXSource, pause, void, ( F32 fadeOutTime ), ( -1.f ), +DefineEngineMethod( SFXSource, pause, void, ( F32 fadeOutTime ), ( -1.0f ), "Pause playback of the source.\n" "@param fadeOutTime Seconds for the sound to fade down to zero volume. If -1, the SFXDescription::fadeOutTime " "set in the source's associated description is used. Pass 0 to disable a fade-out effect that may be " @@ -1569,21 +1569,24 @@ static ConsoleDocFragment _sSetTransform2( "void setTransform( Point3F position, Point3F direction )" ); -ConsoleMethod( SFXSource, setTransform, void, 3, 4, +DefineConsoleMethod( SFXSource, setTransform, void, ( const char * position, const char * direction ), ( "" ), "( vector position [, vector direction ] ) " "Set the position and orientation of a 3D sound source.\n" "@hide" ) { MatrixF mat = object->getTransform(); - Point3F pos; - dSscanf( argv[2], "%g %g %g", &pos.x, &pos.y, &pos.z ); - mat.setPosition( pos ); + if(dStrcmp( position , "")!=0 ) + { + Point3F pos; + dSscanf( position, "%g %g %g", &pos.x, &pos.y, &pos.z ); + mat.setPosition( pos ); + } - if( argc > 3 ) + if(dStrcmp( direction ,"")!=0 ) { Point3F dir; - dSscanf( argv[ 3 ], "%g %g %g", &dir.x, &dir.y, &dir.z ); + dSscanf( direction, "%g %g %g", &dir.x, &dir.y, &dir.z ); mat.setColumn( 1, dir ); } diff --git a/Engine/source/sfx/sfxSystem.cpp b/Engine/source/sfx/sfxSystem.cpp index 1b3767274..502e16733 100644 --- a/Engine/source/sfx/sfxSystem.cpp +++ b/Engine/source/sfx/sfxSystem.cpp @@ -1443,7 +1443,7 @@ static ConsoleDocFragment _sfxCreateSource4( NULL, "SFXSound sfxCreateSource( SFXDescription description, string filename, float x, float y, float z );" ); -ConsoleFunction( sfxCreateSource, S32, 2, 6, +DefineConsoleFunction( sfxCreateSource, S32, ( const char * sfxType, const char * arg0, const char * arg1, const char * arg2, const char * arg3 ), ("", "", "", ""), "( SFXTrack track | ( SFXDescription description, string filename ) [, float x, float y, float z ] ) " "Creates a new paused sound source using a profile or a description " "and filename. The return value is the source which must be " @@ -1451,13 +1451,13 @@ ConsoleFunction( sfxCreateSource, S32, 2, 6, "@hide" ) { SFXDescription* description = NULL; - SFXTrack* track = dynamic_cast< SFXTrack* >( Sim::findObject( argv[1] ) ); + SFXTrack* track = dynamic_cast< SFXTrack* >( Sim::findObject( sfxType ) ); if ( !track ) { - description = dynamic_cast< SFXDescription* >( Sim::findObject( argv[1] ) ); + description = dynamic_cast< SFXDescription* >( Sim::findObject( sfxType ) ); if ( !description ) { - Con::printf( "Unable to locate sound track/description '%s'", (const char*)argv[1] ); + Con::printf( "Unable to locate sound track/description '%s'", sfxType ); return 0; } } @@ -1466,20 +1466,22 @@ ConsoleFunction( sfxCreateSource, S32, 2, 6, if ( track ) { - if ( argc == 2 ) + // In this overloaded use of the function, arg0..arg2 are x, y, and z. + if ( dStrIsEmpty(arg0) ) { source = SFX->createSource( track ); } else { MatrixF transform; - transform.set( EulerF(0,0,0), Point3F( dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4])) ); + transform.set( EulerF(0,0,0), Point3F( dAtof(arg0), dAtof(arg1), dAtof(arg2)) ); source = SFX->createSource( track, &transform ); } } else if ( description ) { - SFXProfile* tempProfile = new SFXProfile( description, StringTable->insert( argv[2] ), true ); + // In this use, arg0 is the filename, and arg1..arg3 are x, y, and z. + SFXProfile* tempProfile = new SFXProfile( description, StringTable->insert( arg0), true ); if( !tempProfile->registerObject() ) { Con::errorf( "sfxCreateSource - unable to create profile" ); @@ -1487,14 +1489,14 @@ ConsoleFunction( sfxCreateSource, S32, 2, 6, } else { - if ( argc == 3 ) + if ( dStrIsEmpty(arg1) ) { source = SFX->createSource( tempProfile ); } else { MatrixF transform; - transform.set(EulerF(0,0,0), Point3F( dAtof(argv[3]),dAtof(argv[4]),dAtof(argv[5]) )); + transform.set(EulerF(0,0,0), Point3F( dAtof(arg1), dAtof(arg2), dAtof(arg3) )); source = SFX->createSource( tempProfile, &transform ); } @@ -1546,13 +1548,13 @@ static ConsoleDocFragment _sfxPlay3( NULL, "void sfxPlay( SFXTrack track, float x, float y, float z );" ); -ConsoleFunction( sfxPlay, S32, 2, 5, "( SFXSource source | ( SFXTrack track [, float x, float y, float z ] ) ) " +DefineConsoleFunction( sfxPlay, S32, ( const char * trackName, const char * pointOrX, const char * y, const char * z ), ( "", "", ""), "Start playing the given source or create a new source for the given track and play it.\n" "@hide" ) { - if ( argc == 2 ) + if ( dStrIsEmpty(pointOrX) ) { - SFXSource* source = dynamic_cast( Sim::findObject( argv[1] ) ); + SFXSource* source = dynamic_cast( Sim::findObject( trackName ) ); if ( source ) { source->play(); @@ -1560,18 +1562,20 @@ ConsoleFunction( sfxPlay, S32, 2, 5, "( SFXSource source | ( SFXTrack track [, f } } - SFXTrack* track = dynamic_cast( Sim::findObject( argv[1] ) ); + SFXTrack* track = dynamic_cast( Sim::findObject( trackName ) ); if ( !track ) { - Con::printf( "Unable to locate sfx track '%s'", (const char*)argv[1] ); + Con::printf( "Unable to locate sfx track '%s'", trackName ); return 0; } Point3F pos(0.f, 0.f, 0.f); - if ( argc == 3 ) - dSscanf( argv[2], "%g %g %g", &pos.x, &pos.y, &pos.z ); - else if(argc == 5) - pos.set( dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4]) ); + if ( !dStrIsEmpty( pointOrX ) && dStrIsEmpty( y ) && dStrIsEmpty( z ) ) + { + dSscanf( pointOrX, "%g %g %g", &pos.x, &pos.y, &pos.z ); + } + else if( !dStrIsEmpty( pointOrX ) && !dStrIsEmpty( y ) && !dStrIsEmpty( z ) ) + pos.set( dAtof(pointOrX), dAtof(y), dAtof(z) ); MatrixF transform; transform.set( EulerF(0,0,0), pos ); @@ -1654,19 +1658,19 @@ static ConsoleDocFragment _sPlayOnce4( "SFXSource sfxPlayOnce( SFXDescription description, string filename, float x, float y, float z, float fadeInTime=-1 );" ); -ConsoleFunction( sfxPlayOnce, S32, 2, 6, +DefineConsoleFunction( sfxPlayOnce, S32, ( const char * sfxType, const char * arg0, const char * arg1, const char * arg2, const char * arg3, const char* arg4 ), ("", "", "", "", "-1.0f"), "SFXSource sfxPlayOnce( ( SFXTrack track | SFXDescription description, string filename ) [, float x, float y, float z, float fadeInTime=-1 ] ) " "Create a new play-once source for the given profile or description+filename and start playback of the source.\n" "@hide" ) { SFXDescription* description = NULL; - SFXTrack* track = dynamic_cast< SFXTrack* >( Sim::findObject( argv[1] ) ); + SFXTrack* track = dynamic_cast< SFXTrack* >( Sim::findObject( sfxType ) ); if( !track ) { - description = dynamic_cast< SFXDescription* >( Sim::findObject( argv[1] ) ); + description = dynamic_cast< SFXDescription* >( Sim::findObject( sfxType ) ); if( !description ) { - Con::errorf( "sfxPlayOnce - Unable to locate sound track/description '%s'", (const char*)argv[1] ); + Con::errorf( "sfxPlayOnce - Unable to locate sound track/description '%s'", sfxType ); return 0; } } @@ -1674,21 +1678,22 @@ ConsoleFunction( sfxPlayOnce, S32, 2, 6, SFXSource* source = NULL; if( track ) { - if( argc == 2 ) + // In this overloaded use, arg0..arg2 are x, y, z, and arg3 is the fadeInTime. + if (dStrIsEmpty(arg0)) + { source = SFX->playOnce( track ); + } else { MatrixF transform; - transform.set( EulerF( 0, 0, 0 ), Point3F( dAtof( argv[ 2 ] ), dAtof( argv[ 3 ] ),dAtof( argv[ 4 ] ) ) ); - F32 fadeInTime = -1.f; - if( argc > 5 ) - fadeInTime = dAtof( argv[ 5 ] ); - source = SFX->playOnce( track, &transform, NULL, fadeInTime ); + transform.set( EulerF( 0, 0, 0 ), Point3F( dAtof( arg0 ), dAtof( arg1 ),dAtof( arg2 ) ) ); + source = SFX->playOnce( track, &transform, NULL, dAtof( arg3 ) ); } } else if( description ) { - SFXProfile* tempProfile = new SFXProfile( description, StringTable->insert( argv[2] ), true ); + // In this overload, arg0 is the filename, arg1..arg3 are x, y, z, and arg4 is fadeInTime. + SFXProfile* tempProfile = new SFXProfile( description, StringTable->insert( arg0 ), true ); if( !tempProfile->registerObject() ) { Con::errorf( "sfxPlayOnce - unable to create profile" ); @@ -1696,16 +1701,13 @@ ConsoleFunction( sfxPlayOnce, S32, 2, 6, } else { - if ( argc == 3 ) + if (dStrIsEmpty(arg1)) source = SFX->playOnce( tempProfile ); else { MatrixF transform; - transform.set(EulerF(0,0,0), Point3F( dAtof(argv[3]),dAtof(argv[4]),dAtof(argv[5]) )); - F32 fadeInTime = -1.f; - if( argc > 6 ) - fadeInTime = dAtof( argv[ 6 ] ); - source = SFX->playOnce( tempProfile, &transform, NULL, fadeInTime ); + transform.set( EulerF( 0, 0, 0 ), Point3F( dAtof( arg1 ), dAtof( arg2 ),dAtof( arg3 ) ) ); + source = SFX->playOnce( tempProfile, &transform, NULL, dAtof( arg4 ) ); } // Set profile to auto-delete when SFXSource releases its reference. diff --git a/Engine/source/sim/netInterface.cpp b/Engine/source/sim/netInterface.cpp index e839d6e64..759120bcf 100644 --- a/Engine/source/sim/netInterface.cpp +++ b/Engine/source/sim/netInterface.cpp @@ -26,6 +26,7 @@ #include "core/stream/bitStream.h" #include "math/mRandom.h" #include "core/util/journal/journal.h" +#include "console/engineAPI.h" #ifdef GGC_PLUGIN #include "GGCNatTunnel.h" @@ -640,15 +641,14 @@ void NetInterface::computeNetMD5(const NetAddress *address, U32 connectSequence, ConsoleFunctionGroupBegin(NetInterface, "Global control functions for the netInterfaces."); -ConsoleFunction(allowConnections,void,2,2,"allowConnections(bool allow);" +DefineConsoleFunction( allowConnections, void, ( bool allow ), , "allowConnections(bool allow)" "@brief Sets whether or not the global NetInterface allows connections from remote hosts.\n\n" "@param allow Set to true to allow remote connections.\n" "@ingroup Networking\n") { - TORQUE_UNUSED(argc); - GNet->setAllowsConnections(dAtob(argv[1])); + GNet->setAllowsConnections(allow); } ConsoleFunctionGroupEnd(NetInterface); diff --git a/Engine/source/sim/netStringTable.cpp b/Engine/source/sim/netStringTable.cpp index 880c72e1e..117d0a020 100644 --- a/Engine/source/sim/netStringTable.cpp +++ b/Engine/source/sim/netStringTable.cpp @@ -267,6 +267,11 @@ void NetStringTable::dumpToConsole() 0x11 ); } + + +#endif // DEBUG + + DefineEngineFunction( dumpNetStringTable, void, (),, "@brief Dump the current contents of the networked string table to the console.\n\n" "The results are returned in three columns. The first column is the network string ID. " @@ -275,7 +280,8 @@ DefineEngineFunction( dumpNetStringTable, void, (),, "@note This function is available only in debug builds.\n\n" "@ingroup Networking" ) { +#ifdef TORQUE_DEBUG gNetStringTable->dumpToConsole(); +#endif } -#endif // DEBUG diff --git a/Engine/source/terrain/terrData.cpp b/Engine/source/terrain/terrData.cpp index 1cb566512..f33e32340 100644 --- a/Engine/source/terrain/terrData.cpp +++ b/Engine/source/terrain/terrData.cpp @@ -48,6 +48,7 @@ #include "T3D/physics/physicsCollision.h" #include "console/engineAPI.h" +#include "console/engineAPI.h" using namespace Torque; IMPLEMENT_CO_NETOBJECT_V1(TerrainBlock); @@ -141,36 +142,28 @@ ConsoleDocFragment _getTerrainUnderWorldPoint2( "bool getTerrainUnderWorldPoint( F32 x, F32 y, F32 z);" ); -ConsoleFunction(getTerrainUnderWorldPoint, S32, 2, 4, "(Point3F x/y/z) Gets the terrain block that is located under the given world point.\n" +DefineConsoleFunction( getTerrainUnderWorldPoint, S32, (const char* ptOrX, const char* y, const char* z), ("", ""), + "(Point3F x/y/z) Gets the terrain block that is located under the given world point.\n" "@param x/y/z The world coordinates (floating point values) you wish to query at. " "These can be formatted as either a string (\"x y z\") or separately as (x, y, z)\n" "@return Returns the ID of the requested terrain block (0 if not found).\n\n" - "@hide") + "@hide") { Point3F pos; - if(argc == 2) - dSscanf(argv[1], "%f %f %f", &pos.x, &pos.y, &pos.z); - else if(argc == 4) + if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z)) + dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z); + else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z)) { - pos.x = dAtof(argv[1]); - pos.y = dAtof(argv[2]); - pos.z = dAtof(argv[3]); + pos.x = dAtof(ptOrX); + pos.y = dAtof(y); + pos.z = dAtof(z); } - - else - { - Con::errorf("getTerrainUnderWorldPoint(Point3F): Invalid argument count! Valid arguments are either \"x y z\" or x,y,z\n"); - return 0; - } - TerrainBlock* terrain = getTerrainUnderWorldPoint(pos); if(terrain != NULL) { return terrain->getId(); } - return 0; - } @@ -1326,32 +1319,31 @@ ConsoleDocFragment _getTerrainHeight2( "bool getTerrainHeight( F32 x, F32 y);" ); -ConsoleFunction(getTerrainHeight, F32, 2, 3, "(Point2 pos) - gets the terrain height at the specified position." +DefineConsoleFunction( getTerrainHeight, F32, (const char* ptOrX, const char* y), (""), "(Point2 pos) - gets the terrain height at the specified position." "@param pos The world space point, minus the z (height) value\n Can be formatted as either (\"x y\") or (x,y)\n" "@return Returns the terrain height at the given point as an F32 value.\n" "@hide") { - Point2F pos; - F32 height = 0.0f; + F32 height = 0.0f; - if(argc == 2) - dSscanf(argv[1],"%f %f",&pos.x,&pos.y); - else if(argc == 3) - { - pos.x = dAtof(argv[1]); - pos.y = dAtof(argv[2]); - } + Point2F pos; + if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y)) + dSscanf(ptOrX, "%f %f", &pos.x, &pos.y); + else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y)) + { + pos.x = dAtof(ptOrX); + pos.y = dAtof(y); + } - TerrainBlock * terrain = getTerrainUnderWorldPoint(Point3F(pos.x, pos.y, 5000.0f)); - if(terrain) - if(terrain->isServerObject()) - { - Point3F offset; - terrain->getTransform().getColumn(3, &offset); - pos -= Point2F(offset.x, offset.y); - terrain->getHeight(pos, &height); - } - return height; + TerrainBlock * terrain = getTerrainUnderWorldPoint(Point3F(pos.x, pos.y, 5000.0f)); + if(terrain && terrain->isServerObject()) + { + Point3F offset; + terrain->getTransform().getColumn(3, &offset); + pos -= Point2F(offset.x, offset.y); + terrain->getHeight(pos, &height); + } + return height; } ConsoleDocFragment _getTerrainHeightBelowPosition1( @@ -1372,28 +1364,23 @@ ConsoleDocFragment _getTerrainHeightBelowPosition2( "bool getTerrainHeightBelowPosition( F32 x, F32 y);" ); -ConsoleFunction(getTerrainHeightBelowPosition, F32, 2, 4, "(Point3F pos) - gets the terrain height at the specified position." +DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (const char* ptOrX, const char* y, const char* z), ("", ""), + "(Point3F pos) - gets the terrain height at the specified position." "@param pos The world space point. Can be formatted as either (\"x y z\") or (x,y,z)\n" "@note This function is useful if you simply want to grab the terrain height underneath an object.\n" "@return Returns the terrain height at the given point as an F32 value.\n" "@hide") { - Point3F pos; F32 height = 0.0f; - if(argc == 2) - dSscanf(argv[1], "%f %f %f", &pos.x, &pos.y, &pos.z); - else if(argc == 4) + Point3F pos; + if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z)) + dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z); + else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z)) { - pos.x = dAtof(argv[1]); - pos.y = dAtof(argv[2]); - pos.z = dAtof(argv[3]); - } - - else - { - Con::errorf("getTerrainHeightBelowPosition(Point3F): Invalid argument count! Valid arguments are either \"x y z\" or x,y,z\n"); - return 0; + pos.x = dAtof(ptOrX); + pos.y = dAtof(y); + pos.z = dAtof(z); } TerrainBlock * terrain = getTerrainUnderWorldPoint(pos); diff --git a/Engine/source/terrain/terrExport.cpp b/Engine/source/terrain/terrExport.cpp index 1a9b3d76a..8941c8b26 100644 --- a/Engine/source/terrain/terrExport.cpp +++ b/Engine/source/terrain/terrExport.cpp @@ -25,6 +25,7 @@ #include "gfx/bitmap/gBitmap.h" #include "terrain/terrMaterial.h" #include "core/stream/fileStream.h" +#include "console/engineAPI.h" #ifdef TORQUE_TOOLS @@ -136,26 +137,18 @@ bool TerrainBlock::exportLayerMaps( const UTF8 *filePrefix, const String &format return true; } -ConsoleMethod( TerrainBlock, exportHeightMap, bool, 3, 4, "(string filename, [string format]) - export the terrain block's heightmap to a bitmap file (default: png)" ) +DefineConsoleMethod( TerrainBlock, exportHeightMap, bool, (const char * fileNameStr, const char * format), ( "png"), "(string filename, [string format]) - export the terrain block's heightmap to a bitmap file (default: png)" ) { UTF8 fileName[1024]; - String format = "png"; - if( argc > 3 ) - format = (const char*)argv[ 3 ]; - - Con::expandScriptFilename( fileName, sizeof( fileName ), argv[2] ); + Con::expandScriptFilename( fileName, sizeof( fileName ), fileNameStr ); return object->exportHeightMap( fileName, format ); } -ConsoleMethod( TerrainBlock, exportLayerMaps, bool, 3, 4, "(string filePrefix, [string format]) - export the terrain block's layer maps to bitmap files (default: png)" ) +DefineConsoleMethod( TerrainBlock, exportLayerMaps, bool, (const char * filePrefixStr, const char * format), ( "png"), "(string filePrefix, [string format]) - export the terrain block's layer maps to bitmap files (default: png)" ) { UTF8 filePrefix[1024]; - String format = "png"; - if( argc > 3 ) - format = (const char*)argv[3]; - - Con::expandScriptFilename( filePrefix, sizeof( filePrefix ), argv[2] ); + Con::expandScriptFilename( filePrefix, sizeof( filePrefix ), filePrefixStr ); return object->exportLayerMaps( filePrefix, format ); } diff --git a/Engine/source/ts/collada/colladaImport.cpp b/Engine/source/ts/collada/colladaImport.cpp index b549c98f8..f3aea309e 100644 --- a/Engine/source/ts/collada/colladaImport.cpp +++ b/Engine/source/ts/collada/colladaImport.cpp @@ -22,6 +22,7 @@ #include "platform/platform.h" +#include "console/engineAPI.h" #include "core/volume.h" #include "ts/collada/colladaUtils.h" #include "ts/collada/colladaAppNode.h" @@ -125,7 +126,7 @@ static void processNode(GuiTreeViewCtrl* tree, domNode* node, S32 parentID, Scen } } -ConsoleFunction( enumColladaForImport, bool, 3, 3, +DefineConsoleFunction( enumColladaForImport, bool, (const char * shapePath, const char * ctrl), , "(string shapePath, GuiTreeViewCtrl ctrl) Collect scene information from " "a COLLADA file and store it in a GuiTreeView control. This function is " "used by the COLLADA import gui to show a preview of the scene contents " @@ -137,15 +138,15 @@ ConsoleFunction( enumColladaForImport, bool, 3, 3, "@internal") { GuiTreeViewCtrl* tree; - if (!Sim::findObject(argv[2], tree)) + if (!Sim::findObject(ctrl, tree)) { - Con::errorf("enumColladaScene::Could not find GuiTreeViewCtrl '%s'", (const char*)argv[2]); + Con::errorf("enumColladaScene::Could not find GuiTreeViewCtrl '%s'", ctrl); return false; } // Check if a cached DTS is available => no need to import the collada file // if we can load the DTS instead - Torque::Path path((const char*)argv[1]); + Torque::Path path(shapePath); if (ColladaShapeLoader::canLoadCachedDTS(path)) return false; diff --git a/Engine/source/ts/collada/colladaLights.cpp b/Engine/source/ts/collada/colladaLights.cpp index b906ecd03..ff491d341 100644 --- a/Engine/source/ts/collada/colladaLights.cpp +++ b/Engine/source/ts/collada/colladaLights.cpp @@ -20,6 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- +#include "console/engineAPI.h" #include "platform/platform.h" #include "ts/collada/colladaUtils.h" @@ -139,7 +140,7 @@ static void processNodeLights(AppNode* appNode, const MatrixF& offset, SimGroup* } // Load lights from a collada file and add to the scene. -ConsoleFunction( loadColladaLights, bool, 2, 4, +DefineConsoleFunction( loadColladaLights, bool, (const char * filename, const char * parentGroup, const char * baseObject), ("", ""), "(string filename, SimGroup parentGroup=MissionGroup, SimObject baseObject=-1)" "Load all light instances from a COLLADA (.dae) file and add to the scene.\n" "@param filename COLLADA filename to load lights from\n" @@ -162,17 +163,17 @@ ConsoleFunction( loadColladaLights, bool, 2, 4, "@ingroup Editors\n" "@internal") { - Torque::Path path((const char*)argv[1]); + Torque::Path path(filename); // Optional group to add the lights to. Create if it does not exist, and use // the MissionGroup if not specified. SimGroup* missionGroup = dynamic_cast(Sim::findObject("MissionGroup")); SimGroup* group = 0; - if ((argc > 2) && (argv[2][0])) { - if (!Sim::findObject(argv[2], group)) { + if (!dStrIsEmpty(parentGroup)){ + if (!Sim::findObject(parentGroup, group)) { // Create the group if it could not be found group = new SimGroup; - if (group->registerObject((const char*)argv[2])) { + if (group->registerObject(parentGroup)) { if (missionGroup) missionGroup->addObject(group); } @@ -187,9 +188,9 @@ ConsoleFunction( loadColladaLights, bool, 2, 4, // Optional object to provide the base transform MatrixF offset(true); - if (argc > 3) { + if (!dStrIsEmpty(baseObject)){ SceneObject *obj; - if (Sim::findObject(argv[3], obj)) + if (Sim::findObject(baseObject, obj)) offset = obj->getTransform(); } diff --git a/Engine/source/ts/tsLastDetail.cpp b/Engine/source/ts/tsLastDetail.cpp index 1e9ec9726..24f1144e2 100644 --- a/Engine/source/ts/tsLastDetail.cpp +++ b/Engine/source/ts/tsLastDetail.cpp @@ -39,6 +39,7 @@ #include "materials/materialManager.h" #include "materials/materialFeatureTypes.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" GFXImplementVertexFormat( ImposterState ) @@ -542,12 +543,9 @@ void TSLastDetail::updateImposterImages( bool forceUpdate ) GFX->endScene(); } -ConsoleFunction(tsUpdateImposterImages, void, 1, 2, "tsUpdateImposterImages( bool forceupdate )") +DefineConsoleFunction( tsUpdateImposterImages, void, (bool forceUpdate), (false), "tsUpdateImposterImages( bool forceupdate )") { - if ( argc > 1 ) - TSLastDetail::updateImposterImages( dAtob( argv[1] ) ); - else - TSLastDetail::updateImposterImages(); + TSLastDetail::updateImposterImages(forceUpdate); } diff --git a/Engine/source/util/fpsTracker.cpp b/Engine/source/util/fpsTracker.cpp index c62c3fd95..ebf49b458 100644 --- a/Engine/source/util/fpsTracker.cpp +++ b/Engine/source/util/fpsTracker.cpp @@ -22,6 +22,7 @@ #include "util/fpsTracker.h" #include "console/console.h" +#include "console/engineAPI.h" FPSTracker gFPS; @@ -87,7 +88,7 @@ void FPSTracker::update() } } -ConsoleFunction( resetFPSTracker, void, 1, 1, "()" +DefineConsoleFunction( resetFPSTracker, void, (), , "()" "@brief Reset FPS stats (fps::)\n\n" "@ingroup Game") { diff --git a/Engine/source/util/messaging/dispatcher.cpp b/Engine/source/util/messaging/dispatcher.cpp index 15ba9f3e1..2ae20ba17 100644 --- a/Engine/source/util/messaging/dispatcher.cpp +++ b/Engine/source/util/messaging/dispatcher.cpp @@ -26,6 +26,7 @@ #include "platform/threads/mutex.h" #include "core/tSimpleHashTable.h" #include "core/util/safeDelete.h" +#include "console/engineAPI.h" namespace Dispatcher { @@ -330,67 +331,67 @@ extern void unlockDispatcherMutex() using namespace Dispatcher; -ConsoleFunction(isQueueRegistered, bool, 2, 2, "(string queueName)" +DefineConsoleFunction( isQueueRegistered, bool, (const char * queueName), , "(string queueName)" "@brief Determines if a dispatcher queue exists\n\n" "@param queueName String containing the name of queue\n" "@ingroup Messaging") { - return isQueueRegistered(argv[1]); + return Dispatcher::isQueueRegistered(queueName); } -ConsoleFunction(registerMessageQueue, void, 2, 2, "(string queueName)" +DefineConsoleFunction( registerMessageQueue, void, (const char *queueName), , "(string queueName)" "@brief Registeres a dispatcher queue\n\n" "@param queueName String containing the name of queue\n" "@ingroup Messaging") { - return registerMessageQueue(argv[1]); + return Dispatcher::registerMessageQueue(queueName); } -ConsoleFunction(unregisterMessageQueue, void, 2, 2, "(string queueName)" +DefineConsoleFunction( unregisterMessageQueue, void, (const char *queueName), , "(string queueName)" "@brief Unregisters a dispatcher queue\n\n" "@param queueName String containing the name of queue\n" "@ingroup Messaging") { - return unregisterMessageQueue(argv[1]); + return Dispatcher::unregisterMessageQueue(queueName); } //----------------------------------------------------------------------------- -ConsoleFunction(registerMessageListener, bool, 3, 3, "(string queueName, string listener)" +DefineConsoleFunction( registerMessageListener, bool, (const char *queueName, const char *listenerName), , "(string queueName, string listener)" "@brief Registers an event message\n\n" "@param queueName String containing the name of queue to attach listener to\n" "@param listener Name of event messenger\n" "@ingroup Messaging") { - IMessageListener *listener = dynamic_cast(Sim::findObject(argv[2])); + Dispatcher::IMessageListener *listener = dynamic_cast(Sim::findObject(listenerName)); if(listener == NULL) { Con::errorf("registerMessageListener - Unable to find listener object, not an IMessageListener ?!"); return false; } - return registerMessageListener(argv[1], listener); + return Dispatcher::registerMessageListener(queueName, listener); } -ConsoleFunction(unregisterMessageListener, void, 3, 3, "(string queueName, string listener)" +DefineConsoleFunction( unregisterMessageListener, void, (const char *queueName, const char *listenerName), , "(string queueName, string listener)" "@brief Unregisters an event message\n\n" "@param queueName String containing the name of queue\n" "@param listener Name of event messenger\n" "@ingroup Messaging") { - IMessageListener *listener = dynamic_cast(Sim::findObject(argv[2])); + Dispatcher::IMessageListener *listener = dynamic_cast(Sim::findObject(listenerName)); if(listener == NULL) { Con::errorf("unregisterMessageListener - Unable to find listener object, not an IMessageListener ?!"); return; } - unregisterMessageListener(argv[1], listener); + Dispatcher::unregisterMessageListener(queueName, listener); } //----------------------------------------------------------------------------- -ConsoleFunction(dispatchMessage, bool, 3, 4, "(string queueName, string message, string data)" +DefineConsoleFunction( dispatchMessage, bool, (const char *queueName, const char *message, const char *data), (""), "(string queueName, string message, string data)" "@brief Dispatch a message to a queue\n\n" "@param queueName Queue to dispatch the message to\n" "@param message Message to dispatch\n" @@ -399,10 +400,10 @@ ConsoleFunction(dispatchMessage, bool, 3, 4, "(string queueName, string message, "@see dispatchMessageObject\n" "@ingroup Messaging") { - return dispatchMessage(argv[1], argv[2], argc > 3 ? argv[3] : "" ); + return Dispatcher::dispatchMessage(queueName, message, data); } -ConsoleFunction(dispatchMessageObject, bool, 3, 3, "(string queueName, string message)" +DefineConsoleFunction( dispatchMessageObject, bool, (const char *queueName, const char *message), ("", ""), "(string queueName, string message)" "@brief Dispatch a message object to a queue\n\n" "@param queueName Queue to dispatch the message to\n" "@param message Message to dispatch\n" @@ -410,12 +411,12 @@ ConsoleFunction(dispatchMessageObject, bool, 3, 3, "(string queueName, string me "@see dispatchMessage\n" "@ingroup Messaging") { - Message *msg = dynamic_cast(Sim::findObject(argv[2])); + Message *msg = dynamic_cast(Sim::findObject(message)); if(msg == NULL) { Con::errorf("dispatchMessageObject - Unable to find message object"); return false; } - return dispatchMessageObject(argv[1], msg); + return Dispatcher::dispatchMessageObject(queueName, msg); } diff --git a/Engine/source/util/messaging/eventManager.cpp b/Engine/source/util/messaging/eventManager.cpp index e7c7d1d8a..f39bf13b0 100644 --- a/Engine/source/util/messaging/eventManager.cpp +++ b/Engine/source/util/messaging/eventManager.cpp @@ -23,6 +23,7 @@ #include "platform/platform.h" #include "util/messaging/eventManager.h" +#include "console/engineAPI.h" #include "console/consoleTypes.h" #include "console/consoleInternal.h" @@ -418,30 +419,30 @@ void EventManager::dumpSubscribers() //----------------------------------------------------------------------------- // Console Methods //----------------------------------------------------------------------------- -ConsoleMethod( EventManager, registerEvent, bool, 3, 3, "( String event )\n" +DefineConsoleMethod( EventManager, registerEvent, bool, ( const char * evt ), , "( String event )\n" "Register an event with the event manager.\n" "@param event The event to register.\n" "@return Whether or not the event was registered successfully." ) { - return object->registerEvent( argv[2] ); + return object->registerEvent( evt ); } -ConsoleMethod( EventManager, unregisterEvent, void, 3, 3, "( String event )\n" +DefineConsoleMethod( EventManager, unregisterEvent, void, ( const char * evt ), , "( String event )\n" "Remove an event from the EventManager.\n" "@param event The event to remove.\n" ) { - object->unregisterEvent( argv[2] ); + object->unregisterEvent( evt ); } -ConsoleMethod( EventManager, isRegisteredEvent, bool, 3, 3, "( String event )\n" +DefineConsoleMethod( EventManager, isRegisteredEvent, bool, ( const char * evt ), , "( String event )\n" "Check if an event is registered or not.\n" "@param event The event to check.\n" "@return Whether or not the event exists." ) { - return object->isRegisteredEvent( argv[2] ); + return object->isRegisteredEvent( evt ); } -ConsoleMethod( EventManager, postEvent, bool, 3, 4, "( String event, String data )\n" +DefineConsoleMethod( EventManager, postEvent, bool, ( const char * evt, const char * data ), (""), "( String event, String data )\n" "~Trigger an event.\n" "@param event The event to trigger.\n" "@param data The data associated with the event.\n" @@ -453,10 +454,10 @@ ConsoleMethod( EventManager, postEvent, bool, 3, 4, "( String event, String data return false; } - return object->postEvent( argv[2], argc > 3 ? argv[3] : "" ); + return object->postEvent( evt, data ); } -ConsoleMethod( EventManager, subscribe, bool, 4, 5, "( SimObject listener, String event, String callback )\n\n" +DefineConsoleMethod( EventManager, subscribe, bool, ( const char * listenerName, const char * evt, const char * callback ), (""), "( SimObject listener, String event, String callback )\n\n" "Subscribe a listener to an event.\n" "@param listener The listener to subscribe.\n" "@param event The event to subscribe to.\n" @@ -464,49 +465,50 @@ ConsoleMethod( EventManager, subscribe, bool, 4, 5, "( SimObject listener, Strin "@return Whether or not the subscription was successful." ) { // Find the listener object. - SimObject *cbObj = dynamic_cast(Sim::findObject(argv[2])); + SimObject *cbObj = dynamic_cast(Sim::findObject(listenerName)); if( cbObj == NULL ) { Con::warnf( "EventManager::subscribe - Invalid listener." ); return false; } - return object->subscribe( cbObj, argv[3], argc > 4 ? (const char*)argv[4] : NULL ); + return object->subscribe( cbObj, evt, callback ); } -ConsoleMethod( EventManager, remove, void, 4, 4, "( SimObject listener, String event )\n\n" +DefineConsoleMethod( EventManager, remove, void, ( const char * listenerName, const char * evt), , "( SimObject listener, String event )\n\n" "Remove a listener from an event.\n" "@param listener The listener to remove.\n" "@param event The event to be removed from.\n") { // Find the listener object. - SimObject * listener = dynamic_cast< SimObject * >( Sim::findObject( argv[2] ) ); + SimObject * listener = dynamic_cast< SimObject * >( Sim::findObject( listenerName ) ); if( listener ) - object->remove( listener, argv[3] ); + object->remove( listener, evt ); } -ConsoleMethod( EventManager, removeAll, void, 3, 3, "( SimObject listener )\n\n" +DefineConsoleMethod( EventManager, removeAll, void, ( const char * listenerName ), , "( SimObject listener )\n\n" "Remove a listener from all events.\n" "@param listener The listener to remove.\n") { // Find the listener object. - SimObject * listener = dynamic_cast< SimObject * >( Sim::findObject( argv[2] ) ); + + SimObject * listener = dynamic_cast< SimObject * >( Sim::findObject( listenerName ) ); if( listener ) object->removeAll( listener ); } -ConsoleMethod( EventManager, dumpEvents, void, 2, 2, "()\n\n" +DefineConsoleMethod( EventManager, dumpEvents, void, (), , "()\n\n" "Print all registered events to the console." ) { object->dumpEvents(); } -ConsoleMethod( EventManager, dumpSubscribers, void, 2, 3, "( String event )\n\n" +DefineConsoleMethod( EventManager, dumpSubscribers, void, ( const char * listenerName ), (""), "( String event )\n\n" "Print all subscribers to an event to the console.\n" "@param event The event whose subscribers are to be printed. If this parameter isn't specified, all events will be dumped." ) { - if( argc > 2 ) - object->dumpSubscribers( argv[2] ); + if (dStrcmp(listenerName, "") != 0) + object->dumpSubscribers( listenerName ); else object->dumpSubscribers(); } diff --git a/Engine/source/util/messaging/message.cpp b/Engine/source/util/messaging/message.cpp index c23c87bc6..7e2b7af08 100644 --- a/Engine/source/util/messaging/message.cpp +++ b/Engine/source/util/messaging/message.cpp @@ -155,19 +155,19 @@ const char *Message::getType() // Console Methods //----------------------------------------------------------------------------- -ConsoleMethod(Message, getType, const char *, 2, 2, "() Get message type (script class name or C++ class name if no script defined class)") +DefineConsoleMethod(Message, getType, const char *, (), , "() Get message type (script class name or C++ class name if no script defined class)") { return object->getType(); } //----------------------------------------------------------------------------- -ConsoleMethod(Message, addReference, void, 2, 2, "() Increment the reference count for this message") +DefineConsoleMethod(Message, addReference, void, (), , "() Increment the reference count for this message") { object->addReference(); } -ConsoleMethod(Message, freeReference, void, 2, 2, "() Decrement the reference count for this message") +DefineConsoleMethod(Message, freeReference, void, (), , "() Decrement the reference count for this message") { object->freeReference(); } diff --git a/Engine/source/util/sampler.cpp b/Engine/source/util/sampler.cpp index ea80b59a8..7e163d004 100644 --- a/Engine/source/util/sampler.cpp +++ b/Engine/source/util/sampler.cpp @@ -27,6 +27,7 @@ #include "core/util/tVector.h" #include "core/stream/fileStream.h" #include "console/console.h" +#include "console/engineAPI.h" #include "console/consoleTypes.h" /// Bookkeeping structure for registered sampling keys. @@ -393,7 +394,7 @@ SAMPLE_FUNC( const char* ); // Console Functions. //-------------------------------------------------------------------------------- -ConsoleFunction( beginSampling, void, 2, 3, "(location, [backend]) -" +DefineConsoleFunction( beginSampling, void, (const char * location, const char * backend), ("CSV"), "(location, [backend]) -" "@brief Takes a string informing the backend where to store " "sample data and optionally a name of the specific logging " "backend to use. The default is the CSV backend. In most " @@ -403,30 +404,22 @@ ConsoleFunction( beginSampling, void, 2, 3, "(location, [backend]) -" "@endtsexample\n\n" "@ingroup Rendering") { - const char* location = argv[ 1 ]; - const char* backend = "CSV"; - if( argc > 2 ) - backend = argv[ 2 ]; beginSampling( location, backend ); } -ConsoleFunction( stopSampling, void, 1, 1, "()" +DefineConsoleFunction( stopSampling, void, (), , "()" "@brief Stops the rendering sampler\n\n" "@ingroup Rendering\n") { stopSampling(); } -ConsoleFunction( enableSamples, void, 2, 3, "(pattern, [state]) -" +DefineConsoleFunction( enableSamples, void, (const char * pattern, bool state), (true), "(pattern, [state]) -" "@brief Enable sampling for all keys that match the given name " "pattern. Slashes are treated as separators.\n\n" "@ingroup Rendering") { - const char* pattern = argv[ 1 ]; - bool state = true; - if( argc > 2 ) - state = dAtob( argv[ 2 ] ); Sampler::enableKeys( pattern, state ); } diff --git a/Engine/source/util/settings.cpp b/Engine/source/util/settings.cpp index 5852984ff..1b0ddfea6 100644 --- a/Engine/source/util/settings.cpp +++ b/Engine/source/util/settings.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- #include "util/settings.h" +#include "console/engineAPI.h" #include "console/consoleTypes.h" #include "console/SimXMLDocument.h" @@ -481,19 +482,12 @@ const char* Settings::findNextValue() } // make sure to replace the strings -ConsoleMethod(Settings, findFirstValue, const char*, 2, 5, "settingObj.findFirstValue();") +DefineConsoleMethod(Settings, findFirstValue, const char*, ( const char* pattern, bool deepSearch, bool includeDefaults ), ("", false, false), "settingObj.findFirstValue();") { - if( argc == 3 ) - return object->findFirstValue( argv[2] ); - else if( argc == 4 ) - return object->findFirstValue( argv[2], dAtob(argv[3]) ); - else if( argc == 5 ) - return object->findFirstValue( argv[2], dAtob(argv[3]), dAtob(argv[4]) ); - else - return ""; + return object->findFirstValue( pattern, deepSearch, includeDefaults ); } -ConsoleMethod(Settings, findNextValue, const char*, 2, 2, "settingObj.findNextValue();") +DefineConsoleMethod(Settings, findNextValue, const char*, (), , "settingObj.findNextValue();") { return object->findNextValue(); } @@ -650,48 +644,41 @@ void SettingSaveNode::buildDocument(SimXMLDocument *document, bool skipWrite) document->popElement(); } -ConsoleMethod(Settings, setValue, void, 3, 4, "settingObj.setValue(settingName, value);") +DefineConsoleMethod(Settings, setValue, void, (const char * settingName, const char * value), (""), "settingObj.setValue(settingName, value);") { - const char *fieldName = StringTable->insert( argv[2] ); + StringTableEntry fieldName = StringTable->insert( settingName ); - if(argc == 3) - object->setValue( fieldName); - else if(argc == 4) - object->setValue( fieldName, argv[3] ); + if (!dStrIsEmpty(value)) + object->setValue( fieldName, value ); + else + object->setValue( fieldName ); } -ConsoleMethod(Settings, setDefaultValue, void, 4, 4, "settingObj.setDefaultValue(settingName, value);") +DefineConsoleMethod(Settings, setDefaultValue, void, (const char * settingName, const char * value), , "settingObj.setDefaultValue(settingName, value);") { - const char *fieldName = StringTable->insert( argv[2] ); - object->setDefaultValue( fieldName, argv[3] ); + StringTableEntry fieldName = StringTable->insert( settingName ); + object->setDefaultValue( fieldName, value ); } -ConsoleMethod(Settings, value, const char*, 3, 4, "settingObj.value(settingName, defaultValue);") +DefineConsoleMethod(Settings, value, const char*, (const char * settingName, const char * defaultValue), (""), "settingObj.value(settingName, defaultValue);") { - const char *fieldName = StringTable->insert( argv[2] ); + StringTableEntry fieldName = StringTable->insert( settingName ); - if(argc == 3) + if (dStrcmp(defaultValue, "") != 0) + return object->value( fieldName, defaultValue ); + else if (dStrcmp(settingName, "") != 0) return object->value( fieldName ); - if(argc == 4) - return object->value( fieldName, argv[3] ); return ""; } -ConsoleMethod(Settings, remove, void, 3, 4, "settingObj.remove(settingName, includeDefaults = false);") +DefineConsoleMethod(Settings, remove, void, (const char * settingName, bool includeDefaults), (false), "settingObj.remove(settingName, includeDefaults = false);") { // there's a problem with some fields not being removed properly, but works if you run it twice, // a temporary solution for now is simply to call the remove twice - if(argc == 3) - { - object->remove( argv[2] ); - object->remove( argv[2] ); - } - else if(argc == 4) - { - object->remove( argv[2], dAtob(argv[3]) ); - object->remove( argv[2], dAtob(argv[3]) ); - } + + object->remove( settingName, includeDefaults ); + object->remove( settingName, includeDefaults ); } ConsoleMethod(Settings, write, bool, 2, 2, "%success = settingObj.write();") @@ -700,33 +687,27 @@ ConsoleMethod(Settings, write, bool, 2, 2, "%success = settingObj.write();") return object->write(); } -ConsoleMethod(Settings, read, bool, 2, 2, "%success = settingObj.read();") +DefineConsoleMethod(Settings, read, bool, (), , "%success = settingObj.read();") { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); return object->read(); } -ConsoleMethod(Settings, beginGroup, void, 3, 4, "settingObj.beginGroup(groupName, fromStart = false);") +DefineConsoleMethod(Settings, beginGroup, void, (const char * groupName, bool includeDefaults), (false), "settingObj.beginGroup(groupName, fromStart = false);") { - if(argc == 3) - object->beginGroup( argv[2] ); - if(argc == 4) - object->beginGroup( argv[2], dAtob(argv[3]) ); + object->beginGroup( groupName, includeDefaults ); } -ConsoleMethod(Settings, endGroup, void, 2, 2, "settingObj.endGroup();") +DefineConsoleMethod(Settings, endGroup, void, (), , "settingObj.endGroup();") { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); object->endGroup(); } -ConsoleMethod(Settings, clearGroups, void, 2, 2, "settingObj.clearGroups();") +DefineConsoleMethod(Settings, clearGroups, void, (), , "settingObj.clearGroups();") { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); object->clearGroups(); } -ConsoleMethod(Settings, getCurrentGroups, const char*, 2, 2, "settingObj.getCurrentGroups();") +DefineConsoleMethod(Settings, getCurrentGroups, const char*, (), , "settingObj.getCurrentGroups();") { return object->getCurrentGroups(); } \ No newline at end of file diff --git a/Engine/source/util/undo.cpp b/Engine/source/util/undo.cpp index 0a04a8ca2..140eda541 100644 --- a/Engine/source/util/undo.cpp +++ b/Engine/source/util/undo.cpp @@ -25,6 +25,7 @@ #include "console/console.h" #include "console/consoleTypes.h" +#include "console/engineAPI.h" //----------------------------------------------------------------------------- // UndoAction @@ -144,10 +145,10 @@ void CompoundUndoAction::onDeleteNotify( SimObject* object ) Parent::onDeleteNotify( object ); } -ConsoleMethod( CompoundUndoAction, addAction, void, 3, 3, "addAction( UndoAction )" ) +DefineConsoleMethod( CompoundUndoAction, addAction, void, (const char * objName), , "addAction( UndoAction )" ) { UndoAction *action; - if ( Sim::findObject( argv[2], action ) ) + if ( Sim::findObject( objName, action ) ) object->addAction( action ); } @@ -205,7 +206,7 @@ UndoManager& UndoManager::getDefaultManager() return *defaultMan; } -ConsoleMethod(UndoManager, clearAll, void, 2, 2, "Clears the undo manager.") +DefineConsoleMethod(UndoManager, clearAll, void, (),, "Clears the undo manager.") { object->clearAll(); } @@ -343,7 +344,7 @@ void UndoManager::redo() (*react).redo(); } -ConsoleMethod(UndoManager, getUndoCount, S32, 2, 2, "") +DefineConsoleMethod(UndoManager, getUndoCount, S32, (),, "") { return object->getUndoCount(); } @@ -353,9 +354,9 @@ S32 UndoManager::getUndoCount() return mUndoStack.size(); } -ConsoleMethod(UndoManager, getUndoName, const char*, 3, 3, "(index)") +DefineConsoleMethod(UndoManager, getUndoName, const char*, (S32 index), , "(index)") { - return object->getUndoName(dAtoi(argv[2])); + return object->getUndoName(index); } const char* UndoManager::getUndoName(S32 index) @@ -366,9 +367,9 @@ const char* UndoManager::getUndoName(S32 index) return NULL; } -ConsoleMethod(UndoManager, getUndoAction, S32, 3, 3, "(index)") +DefineConsoleMethod(UndoManager, getUndoAction, S32, (S32 index), , "(index)") { - UndoAction * action = object->getUndoAction(dAtoi(argv[2])); + UndoAction * action = object->getUndoAction(index); if ( !action ) return -1; @@ -385,7 +386,7 @@ UndoAction* UndoManager::getUndoAction(S32 index) return NULL; } -ConsoleMethod(UndoManager, getRedoCount, S32, 2, 2, "") +DefineConsoleMethod(UndoManager, getRedoCount, S32, (),, "") { return object->getRedoCount(); } @@ -395,9 +396,9 @@ S32 UndoManager::getRedoCount() return mRedoStack.size(); } -ConsoleMethod(UndoManager, getRedoName, const char*, 3, 3, "(index)") +DefineConsoleMethod(UndoManager, getRedoName, const char*, (S32 index), , "(index)") { - return object->getRedoName(dAtoi(argv[2])); + return object->getRedoName(index); } const char* UndoManager::getRedoName(S32 index) @@ -408,9 +409,9 @@ const char* UndoManager::getRedoName(S32 index) return NULL; } -ConsoleMethod(UndoManager, getRedoAction, S32, 3, 3, "(index)") +DefineConsoleMethod(UndoManager, getRedoAction, S32, (S32 index), , "(index)") { - UndoAction * action = object->getRedoAction(dAtoi(argv[2])); + UndoAction * action = object->getRedoAction(index); if ( !action ) return -1; @@ -500,12 +501,12 @@ void UndoManager::popCompound( bool discard ) } //----------------------------------------------------------------------------- -ConsoleMethod(UndoAction, addToManager, void, 2, 3, "action.addToManager([undoManager])") +DefineConsoleMethod(UndoAction, addToManager, void, (const char * undoManager), (""), "action.addToManager([undoManager])") { UndoManager *theMan = NULL; - if(argc == 3) + if (!dStrIsEmpty(undoManager)) { - SimObject *obj = Sim::findObject(argv[2]); + SimObject *obj = Sim::findObject(undoManager); if(obj) theMan = dynamic_cast (obj); } @@ -514,32 +515,32 @@ ConsoleMethod(UndoAction, addToManager, void, 2, 3, "action.addToManager([undoMa //----------------------------------------------------------------------------- -ConsoleMethod( UndoAction, undo, void, 2, 2, "() - Undo action contained in undo." ) +DefineConsoleMethod( UndoAction, undo, void, (),, "() - Undo action contained in undo." ) { object->undo(); } //----------------------------------------------------------------------------- -ConsoleMethod( UndoAction, redo, void, 2, 2, "() - Reo action contained in undo." ) +DefineConsoleMethod( UndoAction, redo, void, (),, "() - Reo action contained in undo." ) { object->redo(); } //----------------------------------------------------------------------------- -ConsoleMethod(UndoManager, undo, void, 2, 2, "UndoManager.undo();") +DefineConsoleMethod(UndoManager, undo, void, (),, "UndoManager.undo();") { object->undo(); } //----------------------------------------------------------------------------- -ConsoleMethod(UndoManager, redo, void, 2, 2, "UndoManager.redo();") +DefineConsoleMethod(UndoManager, redo, void, (),, "UndoManager.redo();") { object->redo(); } //----------------------------------------------------------------------------- -ConsoleMethod(UndoManager, getNextUndoName, const char *, 2, 2, "UndoManager.getNextUndoName();") +DefineConsoleMethod(UndoManager, getNextUndoName, const char *, (),, "UndoManager.getNextUndoName();") { const char *name = object->getNextUndoName(); if(!name) @@ -550,7 +551,7 @@ ConsoleMethod(UndoManager, getNextUndoName, const char *, 2, 2, "UndoManager.get } //----------------------------------------------------------------------------- -ConsoleMethod(UndoManager, getNextRedoName, const char *, 2, 2, "UndoManager.getNextRedoName();") +DefineConsoleMethod(UndoManager, getNextRedoName, const char *, (),, "UndoManager.getNextRedoName();") { const char *name = object->getNextRedoName(); if(!name) @@ -562,11 +563,8 @@ ConsoleMethod(UndoManager, getNextRedoName, const char *, 2, 2, "UndoManager.get //----------------------------------------------------------------------------- -ConsoleMethod( UndoManager, pushCompound, const char*, 2, 3, "( string name=\"\" ) - Push a CompoundUndoAction onto the compound stack for assembly." ) +DefineConsoleMethod( UndoManager, pushCompound, const char*, ( String name ), ("\"\""), "( string name=\"\" ) - Push a CompoundUndoAction onto the compound stack for assembly." ) { - String name; - if( argc > 2 ) - name = (const char*)argv[ 2 ]; CompoundUndoAction* action = object->pushCompound( name ); if( !action ) @@ -580,17 +578,14 @@ ConsoleMethod( UndoManager, pushCompound, const char*, 2, 3, "( string name=\"\" //----------------------------------------------------------------------------- -ConsoleMethod( UndoManager, popCompound, void, 2, 3, "( bool discard=false ) - Pop the current CompoundUndoAction off the stack." ) +DefineConsoleMethod( UndoManager, popCompound, void, ( bool discard ), (false), "( bool discard=false ) - Pop the current CompoundUndoAction off the stack." ) { if( !object->getCompoundStackDepth() ) { - Con::errorf( "%s::popCompound - no compound on stack", (const char*)argv[ 0 ] ); + Con::errorf( "UndoManager::popCompound - no compound on stack (%s) ",object->getName() ); return; } - bool discard = false; - if( argc > 2 ) - discard = dAtob( argv[ 2 ] ); object->popCompound( discard ); }