diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index a734cefbf..358b738f9 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -1220,15 +1220,6 @@ public: ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage1,minArgs,maxArgs); \ inline returnType cm_##className##_##name(className *object, S32 argc, ConsoleValueRef *argv) -# define ConsoleStaticMethod(className,name,returnType,minArgs,maxArgs,usage1) \ - inline returnType cm_##className##_##name(S32, ConsoleValueRef *); \ - returnType cm_##className##_##name##_caster(SimObject *object, S32 argc, ConsoleValueRef *argv) { \ - conmethod_return_##returnType ) cm_##className##_##name(argc,argv); \ - }; \ - ConsoleConstructor \ - cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage1,minArgs,maxArgs); \ - inline returnType cm_##className##_##name(S32 argc, ConsoleValueRef *argv) - # define ConsoleMethodGroupEnd(className, groupName) \ static ConsoleConstructor cc_##className##_##groupName##_GroupEnd(#className,#groupName,NULL) @@ -1268,15 +1259,6 @@ public: className##name##obj(#className,#name,c##className##name##caster,"",minArgs,maxArgs); \ static inline returnType c##className##name(className *object, S32 argc, ConsoleValueRef *argv) -# define ConsoleStaticMethod(className,name,returnType,minArgs,maxArgs,usage1) \ - static inline returnType c##className##name(S32, ConsoleValueRef*); \ - static returnType c##className##name##caster(SimObject *object, S32 argc, ConsoleValueRef *argv) { \ - conmethod_return_##returnType ) c##className##name(argc,argv); \ - }; \ - static ConsoleConstructor \ - className##name##obj(#className,#name,c##className##name##caster,"",minArgs,maxArgs); \ - static inline returnType c##className##name(S32 argc, ConsoleValueRef *argv) - #define ConsoleDoc( text ) #endif diff --git a/Engine/source/gui/worldEditor/editorIconRegistry.cpp b/Engine/source/gui/worldEditor/editorIconRegistry.cpp index 8507d2ad2..b75a28335 100644 --- a/Engine/source/gui/worldEditor/editorIconRegistry.cpp +++ b/Engine/source/gui/worldEditor/editorIconRegistry.cpp @@ -23,7 +23,7 @@ #include "platform/platform.h" #include "gui/worldEditor/editorIconRegistry.h" -#include "console/console.h" +#include "console/engineAPI.h" #include "console/simBase.h" @@ -36,6 +36,8 @@ ConsoleDoc( "@internal" ); +IMPLEMENT_STATIC_CLASS(EditorIconRegistry,, ""); + EditorIconRegistry::EditorIconRegistry() { } @@ -168,51 +170,42 @@ void EditorIconRegistry::clear() mDefaultIcon.free(); } -ConsoleStaticMethod( EditorIconRegistry, add, void, 3, 4, "( String className, String imageFile [, bool overwrite = true] )" +DefineEngineStaticMethod( EditorIconRegistry, add, void, (String className, String imageFile, bool overwrite), (true), "@internal") { - bool overwrite = true; - if ( argc > 3 ) - overwrite = dAtob( argv[3] ); - - gEditorIcons.add( argv[1], argv[2], overwrite ); + gEditorIcons.add( className, imageFile, overwrite ); } -ConsoleStaticMethod( EditorIconRegistry, loadFromPath, void, 2, 3, "( String imagePath [, bool overwrite = true] )" +DefineEngineStaticMethod( EditorIconRegistry, loadFromPath, void, (String imagePath, bool overwrite), (true), "@internal") { - bool overwrite = true; - if ( argc > 2 ) - overwrite = dAtob( argv[2] ); - - gEditorIcons.loadFromPath( argv[1], overwrite ); + gEditorIcons.loadFromPath( imagePath, overwrite ); } -ConsoleStaticMethod( EditorIconRegistry, clear, void, 1, 1, "" +DefineEngineStaticMethod( EditorIconRegistry, clear, void, (),, "@internal") { gEditorIcons.clear(); } -ConsoleStaticMethod( EditorIconRegistry, findIconByClassName, const char*, 2, 2, "( String className )\n" - "Returns the file path to the icon file if found." +DefineEngineStaticMethod( EditorIconRegistry, findIconByClassName, const char*, (String className),, + "@brief Returns the file path to the icon file if found." "@internal") { - GFXTexHandle icon = gEditorIcons.findIcon( argv[1] ); + GFXTexHandle icon = gEditorIcons.findIcon( className ); if ( icon.isNull() ) return NULL; return icon->mPath; } -ConsoleStaticMethod( EditorIconRegistry, findIconBySimObject, const char*, 2, 2, "( SimObject )\n" +DefineEngineStaticMethod( EditorIconRegistry, findIconBySimObject, const char*, (SimObject* obj),, "Returns the file path to the icon file if found." "@internal") { - SimObject *obj = NULL; - if ( !Sim::findObject( argv[1], obj ) ) + if ( !obj ) { - Con::warnf( "EditorIconRegistry::findIcon, parameter %d was not a SimObject!", (const char*)argv[1] ); + Con::warnf( "EditorIconRegistry::findIcon, parameter was not a SimObject!"); return NULL; } diff --git a/Engine/source/gui/worldEditor/editorIconRegistry.h b/Engine/source/gui/worldEditor/editorIconRegistry.h index 35580d74c..a058b7ae7 100644 --- a/Engine/source/gui/worldEditor/editorIconRegistry.h +++ b/Engine/source/gui/worldEditor/editorIconRegistry.h @@ -30,6 +30,8 @@ #include "core/util/tDictionary.h" #endif +#include "console/engineAPI.h" + class SimObject; class AbstractClassRep; @@ -40,6 +42,7 @@ class AbstractClassRep; class EditorIconRegistry { public: + DECLARE_STATIC_CLASS(EditorIconRegistry); EditorIconRegistry(); ~EditorIconRegistry(); diff --git a/Engine/source/postFx/postEffectVis.cpp b/Engine/source/postFx/postEffectVis.cpp index bf507e162..b00ee55ae 100644 --- a/Engine/source/postFx/postEffectVis.cpp +++ b/Engine/source/postFx/postEffectVis.cpp @@ -41,6 +41,8 @@ ConsoleDoc( "@ingroup GFX\n" ); +IMPLEMENT_STATIC_CLASS(PfxVis, , "") + MODULE_BEGIN( PostEffectVis ) MODULE_INIT @@ -374,7 +376,8 @@ static ConsoleDocFragment _PfxVisclear( "PfxVis", "void clear();" ); -ConsoleStaticMethod( PfxVis, clear, void, 1, 1, "()" + +DefineEngineStaticMethod( PfxVis, clear, void, (),, "@hide") { PFXVIS->clear(); @@ -391,16 +394,15 @@ static ConsoleDocFragment _PfxVisopen( "PfxVis", "void open(PostEffect effect, bool clear);" ); -ConsoleStaticMethod( PfxVis, open, void, 2, 3, "( PostEffect, [bool clear = false] )" +DefineEngineStaticMethod( PfxVis, open, void, (PostEffect* pfx, bool clear), (false), "( PostEffect, [bool clear = false] )" "@hide") { - if ( argc == 3 && dAtob( argv[2] ) ) + if ( clear ) PFXVIS->clear(); - PostEffect *pfx; - if ( !Sim::findObject( argv[1], pfx ) ) + if ( !pfx ) { - Con::errorf( "PfxVis::add, argument %s was not a PostEffect", (const char*)argv[1] ); + Con::errorf( "PfxVis::add, argument was not a PostEffect"); return; } @@ -415,7 +417,7 @@ static ConsoleDocFragment _PfxVishide( "PfxVis", "void hide();" ); -ConsoleStaticMethod( PfxVis, hide, void, 1, 1, "()" +DefineEngineStaticMethod( PfxVis, hide, void, (),, "@hide") { PFXVIS->setVisible( false ); @@ -429,7 +431,7 @@ static ConsoleDocFragment _PfxVisshow( "PfxVis", "void show();" ); -ConsoleStaticMethod( PfxVis, show, void, 1, 1, "()" +DefineEngineStaticMethod( PfxVis, show, void, (),, "@hide") { PFXVIS->setVisible( true ); @@ -444,13 +446,12 @@ static ConsoleDocFragment _PfxVisonWindowClosed( "PfxVis", "void onWindowClosed(GuiWindowCtrl *ctrl);" ); -ConsoleStaticMethod( PfxVis, onWindowClosed, void, 2, 2, "( GuiWindowCtrl )" +DefineEngineStaticMethod( PfxVis, onWindowClosed, void, (GuiWindowCtrl* ctrl),, "@hide") { - GuiWindowCtrl *ctrl; - if ( !Sim::findObject( argv[1], ctrl ) ) + if ( !ctrl ) { - Con::errorf( "PfxVis::onWindowClosed, argument %s was not a GuiWindowCtrl", (const char*)argv[1] ); + Con::errorf( "PfxVis::onWindowClosed, argument was not a GuiWindowCtrl"); return; } diff --git a/Engine/source/postFx/postEffectVis.h b/Engine/source/postFx/postEffectVis.h index 972a7ea78..0ef807a58 100644 --- a/Engine/source/postFx/postEffectVis.h +++ b/Engine/source/postFx/postEffectVis.h @@ -104,6 +104,11 @@ public: static const char* getSingletonName() { return "PostEffectVis"; } }; +class PfxVis +{ + DECLARE_STATIC_CLASS(PfxVis) +}; + /// Returns the PostEffectVis singleton. #define PFXVIS ManagedSingleton::instance() diff --git a/Engine/source/terrain/terrImport.cpp b/Engine/source/terrain/terrImport.cpp index ad9a8d98b..063a80c93 100644 --- a/Engine/source/terrain/terrImport.cpp +++ b/Engine/source/terrain/terrImport.cpp @@ -33,15 +33,9 @@ using namespace Torque; -ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5, - "TerrainBlock.create( String terrainName, U32 resolution, String materialName, bool genNoise )\n" +DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32 resolution, String materialName, bool genNoise),, "" ) { - const UTF8 *terrainName = argv[1]; - U32 resolution = dAtoi( argv[2] ); - const UTF8 *materialName = argv[3]; - bool genNoise = dAtob( argv[4] ); - Vector materials; materials.push_back( materialName ); @@ -82,17 +76,17 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5, noise.setSeed( 134208587 ); // Set up some defaults. - F32 octaves = 3.0f; - U32 freq = 4; - F32 roughness = 0.0f; + const F32 octaves = 3.0f; + const U32 freq = 4; + const F32 roughness = 0.0f; noise.fBm( &floatHeights, blockSize, freq, 1.0f - roughness, octaves ); F32 height = 0; F32 omax, omin; noise.getMinMax( &floatHeights, &omin, &omax, blockSize ); - - F32 terrscale = 300.0f / (omax - omin); + + const F32 terrscale = 300.0f / (omax - omin); for ( S32 y = 0; y < blockSize; y++ ) { for ( S32 x = 0; x < blockSize; x++ ) @@ -111,7 +105,7 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5, terrain->updateGridMaterials( Point2I::Zero, Point2I( blockSize, blockSize ) ); } - terrain->registerObject( terrainName ); + terrain->registerObject( terrainName.c_str() ); // Add to mission group! SimGroup *missionGroup; @@ -121,21 +115,11 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5, return terrain->getId(); } -ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8, - "( String terrainName, String heightMap, F32 metersPerPixel, F32 heightScale, String materials, String opacityLayers[, bool flipYAxis=true] )\n" +DefineEngineStaticMethod( TerrainBlock, import, S32, (String terrainName, String heightMapFile, F32 metersPerPixel, F32 heightScale, String opacityLayerFiles, String materialsStr, bool flipYAxis), (true), "" ) { - // Get the parameters. - const UTF8 *terrainName = argv[1]; - const UTF8 *hmap = argv[2]; - F32 metersPerPixel = dAtof(argv[3]); - F32 heightScale = dAtof(argv[4]); - const UTF8 *opacityFiles = argv[5]; - const UTF8 *materialsStr = argv[6]; - bool flipYAxis = argc == 8? dAtob(argv[7]) : true; - // First load the height map and validate it. - Resource heightmap = GBitmap::load( hmap ); + Resource heightmap = GBitmap::load(heightMapFile); if ( !heightmap ) { Con::errorf( "Heightmap failed to load!" ); @@ -155,7 +139,7 @@ ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8, return 0; } - U32 fileCount = StringUnit::getUnitCount( opacityFiles, "\n" ); + U32 fileCount = StringUnit::getUnitCount(opacityLayerFiles, "\n" ); Vector layerMap; layerMap.setSize( terrSize * terrSize ); { @@ -163,7 +147,7 @@ ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8, for ( U32 i = 0; i < fileCount; i++ ) { - String fileNameWithChannel = StringUnit::getUnit( opacityFiles, i, "\n" ); + String fileNameWithChannel = StringUnit::getUnit(opacityLayerFiles, i, "\n" ); String fileName = StringUnit::getUnit( fileNameWithChannel, 0, "\t" ); String channel = StringUnit::getUnit( fileNameWithChannel, 1, "\t" ); @@ -251,7 +235,7 @@ ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8, } // Do we have an existing terrain with that name... then update it! - TerrainBlock *terrain = dynamic_cast( Sim::findObject( terrainName ) ); + TerrainBlock *terrain = dynamic_cast( Sim::findObject( terrainName.c_str() ) ); if ( terrain ) terrain->import( (*heightmap), heightScale, metersPerPixel, layerMap, materials, flipYAxis ); else