mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Eliminate ConsoleStaticMethod
This commit is contained in:
parent
2e6133af48
commit
323206a796
6 changed files with 47 additions and 79 deletions
|
|
@ -1220,15 +1220,6 @@ public:
|
||||||
ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage1,minArgs,maxArgs); \
|
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)
|
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) \
|
# define ConsoleMethodGroupEnd(className, groupName) \
|
||||||
static ConsoleConstructor cc_##className##_##groupName##_GroupEnd(#className,#groupName,NULL)
|
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); \
|
className##name##obj(#className,#name,c##className##name##caster,"",minArgs,maxArgs); \
|
||||||
static inline returnType c##className##name(className *object, S32 argc, ConsoleValueRef *argv)
|
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 )
|
#define ConsoleDoc( text )
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "gui/worldEditor/editorIconRegistry.h"
|
#include "gui/worldEditor/editorIconRegistry.h"
|
||||||
|
|
||||||
#include "console/console.h"
|
#include "console/engineAPI.h"
|
||||||
#include "console/simBase.h"
|
#include "console/simBase.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -36,6 +36,8 @@ ConsoleDoc(
|
||||||
"@internal"
|
"@internal"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_STATIC_CLASS(EditorIconRegistry,, "");
|
||||||
|
|
||||||
EditorIconRegistry::EditorIconRegistry()
|
EditorIconRegistry::EditorIconRegistry()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -168,51 +170,42 @@ void EditorIconRegistry::clear()
|
||||||
mDefaultIcon.free();
|
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")
|
"@internal")
|
||||||
{
|
{
|
||||||
bool overwrite = true;
|
gEditorIcons.add( className, imageFile, overwrite );
|
||||||
if ( argc > 3 )
|
|
||||||
overwrite = dAtob( argv[3] );
|
|
||||||
|
|
||||||
gEditorIcons.add( argv[1], argv[2], overwrite );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleStaticMethod( EditorIconRegistry, loadFromPath, void, 2, 3, "( String imagePath [, bool overwrite = true] )"
|
DefineEngineStaticMethod( EditorIconRegistry, loadFromPath, void, (String imagePath, bool overwrite), (true),
|
||||||
"@internal")
|
"@internal")
|
||||||
{
|
{
|
||||||
bool overwrite = true;
|
gEditorIcons.loadFromPath( imagePath, overwrite );
|
||||||
if ( argc > 2 )
|
|
||||||
overwrite = dAtob( argv[2] );
|
|
||||||
|
|
||||||
gEditorIcons.loadFromPath( argv[1], overwrite );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleStaticMethod( EditorIconRegistry, clear, void, 1, 1, ""
|
DefineEngineStaticMethod( EditorIconRegistry, clear, void, (),,
|
||||||
"@internal")
|
"@internal")
|
||||||
{
|
{
|
||||||
gEditorIcons.clear();
|
gEditorIcons.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleStaticMethod( EditorIconRegistry, findIconByClassName, const char*, 2, 2, "( String className )\n"
|
DefineEngineStaticMethod( EditorIconRegistry, findIconByClassName, const char*, (String className),,
|
||||||
"Returns the file path to the icon file if found."
|
"@brief Returns the file path to the icon file if found."
|
||||||
"@internal")
|
"@internal")
|
||||||
{
|
{
|
||||||
GFXTexHandle icon = gEditorIcons.findIcon( argv[1] );
|
GFXTexHandle icon = gEditorIcons.findIcon( className );
|
||||||
if ( icon.isNull() )
|
if ( icon.isNull() )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return icon->mPath;
|
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."
|
"Returns the file path to the icon file if found."
|
||||||
"@internal")
|
"@internal")
|
||||||
{
|
{
|
||||||
SimObject *obj = NULL;
|
if ( !obj )
|
||||||
if ( !Sim::findObject( argv[1], 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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
#include "core/util/tDictionary.h"
|
#include "core/util/tDictionary.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "console/engineAPI.h"
|
||||||
|
|
||||||
class SimObject;
|
class SimObject;
|
||||||
class AbstractClassRep;
|
class AbstractClassRep;
|
||||||
|
|
||||||
|
|
@ -40,6 +42,7 @@ class AbstractClassRep;
|
||||||
class EditorIconRegistry
|
class EditorIconRegistry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
DECLARE_STATIC_CLASS(EditorIconRegistry);
|
||||||
|
|
||||||
EditorIconRegistry();
|
EditorIconRegistry();
|
||||||
~EditorIconRegistry();
|
~EditorIconRegistry();
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ ConsoleDoc(
|
||||||
"@ingroup GFX\n"
|
"@ingroup GFX\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_STATIC_CLASS(PfxVis, , "")
|
||||||
|
|
||||||
MODULE_BEGIN( PostEffectVis )
|
MODULE_BEGIN( PostEffectVis )
|
||||||
|
|
||||||
MODULE_INIT
|
MODULE_INIT
|
||||||
|
|
@ -374,7 +376,8 @@ static ConsoleDocFragment _PfxVisclear(
|
||||||
"PfxVis",
|
"PfxVis",
|
||||||
"void clear();" );
|
"void clear();" );
|
||||||
|
|
||||||
ConsoleStaticMethod( PfxVis, clear, void, 1, 1, "()"
|
|
||||||
|
DefineEngineStaticMethod( PfxVis, clear, void, (),,
|
||||||
"@hide")
|
"@hide")
|
||||||
{
|
{
|
||||||
PFXVIS->clear();
|
PFXVIS->clear();
|
||||||
|
|
@ -391,16 +394,15 @@ static ConsoleDocFragment _PfxVisopen(
|
||||||
"PfxVis",
|
"PfxVis",
|
||||||
"void open(PostEffect effect, bool clear);" );
|
"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")
|
"@hide")
|
||||||
{
|
{
|
||||||
if ( argc == 3 && dAtob( argv[2] ) )
|
if ( clear )
|
||||||
PFXVIS->clear();
|
PFXVIS->clear();
|
||||||
|
|
||||||
PostEffect *pfx;
|
if ( !pfx )
|
||||||
if ( !Sim::findObject( argv[1], 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -415,7 +417,7 @@ static ConsoleDocFragment _PfxVishide(
|
||||||
"PfxVis",
|
"PfxVis",
|
||||||
"void hide();" );
|
"void hide();" );
|
||||||
|
|
||||||
ConsoleStaticMethod( PfxVis, hide, void, 1, 1, "()"
|
DefineEngineStaticMethod( PfxVis, hide, void, (),,
|
||||||
"@hide")
|
"@hide")
|
||||||
{
|
{
|
||||||
PFXVIS->setVisible( false );
|
PFXVIS->setVisible( false );
|
||||||
|
|
@ -429,7 +431,7 @@ static ConsoleDocFragment _PfxVisshow(
|
||||||
"PfxVis",
|
"PfxVis",
|
||||||
"void show();" );
|
"void show();" );
|
||||||
|
|
||||||
ConsoleStaticMethod( PfxVis, show, void, 1, 1, "()"
|
DefineEngineStaticMethod( PfxVis, show, void, (),,
|
||||||
"@hide")
|
"@hide")
|
||||||
{
|
{
|
||||||
PFXVIS->setVisible( true );
|
PFXVIS->setVisible( true );
|
||||||
|
|
@ -444,13 +446,12 @@ static ConsoleDocFragment _PfxVisonWindowClosed(
|
||||||
"PfxVis",
|
"PfxVis",
|
||||||
"void onWindowClosed(GuiWindowCtrl *ctrl);" );
|
"void onWindowClosed(GuiWindowCtrl *ctrl);" );
|
||||||
|
|
||||||
ConsoleStaticMethod( PfxVis, onWindowClosed, void, 2, 2, "( GuiWindowCtrl )"
|
DefineEngineStaticMethod( PfxVis, onWindowClosed, void, (GuiWindowCtrl* ctrl),,
|
||||||
"@hide")
|
"@hide")
|
||||||
{
|
{
|
||||||
GuiWindowCtrl *ctrl;
|
if ( !ctrl )
|
||||||
if ( !Sim::findObject( argv[1], 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,11 @@ public:
|
||||||
static const char* getSingletonName() { return "PostEffectVis"; }
|
static const char* getSingletonName() { return "PostEffectVis"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PfxVis
|
||||||
|
{
|
||||||
|
DECLARE_STATIC_CLASS(PfxVis)
|
||||||
|
};
|
||||||
|
|
||||||
/// Returns the PostEffectVis singleton.
|
/// Returns the PostEffectVis singleton.
|
||||||
#define PFXVIS ManagedSingleton<PostEffectVis>::instance()
|
#define PFXVIS ManagedSingleton<PostEffectVis>::instance()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,9 @@
|
||||||
|
|
||||||
using namespace Torque;
|
using namespace Torque;
|
||||||
|
|
||||||
ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5,
|
DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32 resolution, String materialName, bool genNoise),,
|
||||||
"TerrainBlock.create( String terrainName, U32 resolution, String materialName, bool genNoise )\n"
|
|
||||||
"" )
|
"" )
|
||||||
{
|
{
|
||||||
const UTF8 *terrainName = argv[1];
|
|
||||||
U32 resolution = dAtoi( argv[2] );
|
|
||||||
const UTF8 *materialName = argv[3];
|
|
||||||
bool genNoise = dAtob( argv[4] );
|
|
||||||
|
|
||||||
Vector<String> materials;
|
Vector<String> materials;
|
||||||
materials.push_back( materialName );
|
materials.push_back( materialName );
|
||||||
|
|
||||||
|
|
@ -82,17 +76,17 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5,
|
||||||
noise.setSeed( 134208587 );
|
noise.setSeed( 134208587 );
|
||||||
|
|
||||||
// Set up some defaults.
|
// Set up some defaults.
|
||||||
F32 octaves = 3.0f;
|
const F32 octaves = 3.0f;
|
||||||
U32 freq = 4;
|
const U32 freq = 4;
|
||||||
F32 roughness = 0.0f;
|
const F32 roughness = 0.0f;
|
||||||
noise.fBm( &floatHeights, blockSize, freq, 1.0f - roughness, octaves );
|
noise.fBm( &floatHeights, blockSize, freq, 1.0f - roughness, octaves );
|
||||||
|
|
||||||
F32 height = 0;
|
F32 height = 0;
|
||||||
|
|
||||||
F32 omax, omin;
|
F32 omax, omin;
|
||||||
noise.getMinMax( &floatHeights, &omin, &omax, blockSize );
|
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 y = 0; y < blockSize; y++ )
|
||||||
{
|
{
|
||||||
for ( S32 x = 0; x < blockSize; x++ )
|
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->updateGridMaterials( Point2I::Zero, Point2I( blockSize, blockSize ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
terrain->registerObject( terrainName );
|
terrain->registerObject( terrainName.c_str() );
|
||||||
|
|
||||||
// Add to mission group!
|
// Add to mission group!
|
||||||
SimGroup *missionGroup;
|
SimGroup *missionGroup;
|
||||||
|
|
@ -121,21 +115,11 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5,
|
||||||
return terrain->getId();
|
return terrain->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8,
|
DefineEngineStaticMethod( TerrainBlock, import, S32, (String terrainName, String heightMapFile, F32 metersPerPixel, F32 heightScale, String opacityLayerFiles, String materialsStr, bool flipYAxis), (true),
|
||||||
"( String terrainName, String heightMap, F32 metersPerPixel, F32 heightScale, String materials, String opacityLayers[, bool flipYAxis=true] )\n"
|
|
||||||
"" )
|
"" )
|
||||||
{
|
{
|
||||||
// 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.
|
// First load the height map and validate it.
|
||||||
Resource<GBitmap> heightmap = GBitmap::load( hmap );
|
Resource<GBitmap> heightmap = GBitmap::load(heightMapFile);
|
||||||
if ( !heightmap )
|
if ( !heightmap )
|
||||||
{
|
{
|
||||||
Con::errorf( "Heightmap failed to load!" );
|
Con::errorf( "Heightmap failed to load!" );
|
||||||
|
|
@ -155,7 +139,7 @@ ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
U32 fileCount = StringUnit::getUnitCount( opacityFiles, "\n" );
|
U32 fileCount = StringUnit::getUnitCount(opacityLayerFiles, "\n" );
|
||||||
Vector<U8> layerMap;
|
Vector<U8> layerMap;
|
||||||
layerMap.setSize( terrSize * terrSize );
|
layerMap.setSize( terrSize * terrSize );
|
||||||
{
|
{
|
||||||
|
|
@ -163,7 +147,7 @@ ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8,
|
||||||
|
|
||||||
for ( U32 i = 0; i < fileCount; i++ )
|
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 fileName = StringUnit::getUnit( fileNameWithChannel, 0, "\t" );
|
||||||
String channel = StringUnit::getUnit( fileNameWithChannel, 1, "\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!
|
// Do we have an existing terrain with that name... then update it!
|
||||||
TerrainBlock *terrain = dynamic_cast<TerrainBlock*>( Sim::findObject( terrainName ) );
|
TerrainBlock *terrain = dynamic_cast<TerrainBlock*>( Sim::findObject( terrainName.c_str() ) );
|
||||||
if ( terrain )
|
if ( terrain )
|
||||||
terrain->import( (*heightmap), heightScale, metersPerPixel, layerMap, materials, flipYAxis );
|
terrain->import( (*heightmap), heightScale, metersPerPixel, layerMap, materials, flipYAxis );
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue