Eliminate unnecessary uses of ConsoleMethod

This commit is contained in:
Lukas Joergensen 2018-04-17 22:36:32 +02:00
parent 2bbc716db6
commit 0fff33869c
15 changed files with 155 additions and 190 deletions

View file

@ -2812,7 +2812,7 @@ DefineEngineMethod( GuiCanvas, setVideoMode, void,
Con::setVariable( "$pref::Video::mode", vm.toString() );
}
ConsoleMethod( GuiCanvas, showWindow, void, 2, 2, "" )
DefineEngineMethod(GuiCanvas, showWindow, void, (),, "")
{
if (!object->getPlatformWindow())
return;
@ -2822,7 +2822,7 @@ ConsoleMethod( GuiCanvas, showWindow, void, 2, 2, "" )
object->getPlatformWindow()->setDisplayWindow(true);
}
ConsoleMethod( GuiCanvas, hideWindow, void, 2, 2, "" )
DefineEngineMethod(GuiCanvas, hideWindow, void, (),, "")
{
if (!object->getPlatformWindow())
return;
@ -2832,30 +2832,29 @@ ConsoleMethod( GuiCanvas, hideWindow, void, 2, 2, "" )
object->getPlatformWindow()->setDisplayWindow(false);
}
ConsoleMethod( GuiCanvas, cursorClick, void, 4, 4, "button, isDown" )
DefineEngineMethod(GuiCanvas, cursorClick, void, (S32 buttonId, bool isDown), , "")
{
const S32 buttonId = dAtoi(argv[2]);
const bool isDown = dAtob(argv[3]);
object->cursorClick(buttonId, isDown);
}
ConsoleMethod( GuiCanvas, cursorNudge, void, 4, 4, "x, y" )
DefineEngineMethod(GuiCanvas, cursorNudge, void, (F32 x, F32 y), , "")
{
object->cursorNudge(dAtof(argv[2]), dAtof(argv[3]));
object->cursorNudge(x, y);
}
// This function allows resetting of the video-mode from script. It was motivated by
// the need to temporarily disable vsync during datablock cache load to avoid a
// significant slowdown.
bool AFX_forceVideoReset = false;
ConsoleMethod( GuiCanvas, resetVideoMode, void, 2,2, "()")
DefineEngineMethod(GuiCanvas, resetVideoMode, void, (), , "")
{
PlatformWindow* window = object->getPlatformWindow();
if( window )
if (window)
{
GFXWindowTarget* gfx_target = window->getGFXTarget();
if ( gfx_target )
GFXWindowTarget* gfx_target = window->getGFXTarget();
if (gfx_target)
{
AFX_forceVideoReset = true;
gfx_target->resetMode();

View file

@ -601,13 +601,12 @@ void GuiInspectorTypeFileName::updateValue()
}
}
ConsoleMethod( GuiInspectorTypeFileName, apply, void, 3,3, "apply(newValue);" )
DefineEngineMethod(GuiInspectorTypeFileName, apply, void, (String path), , "")
{
String path( (const char*)argv[2] );
if ( path.isNotEmpty() )
path = Platform::makeRelativePathName( path, Platform::getMainDotCsDir() );
object->setData( path.c_str() );
if (path.isNotEmpty())
path = Platform::makeRelativePathName(path, Platform::getMainDotCsDir());
object->setData(path.c_str());
}
@ -1502,7 +1501,7 @@ void GuiInspectorTypeBitMask32::updateData()
setData( data );
}
ConsoleMethod( GuiInspectorTypeBitMask32, applyBit, void, 2,2, "apply();" )
DefineEngineMethod( GuiInspectorTypeBitMask32, applyBit, void, (),, "" )
{
object->updateData();
}

View file

@ -469,7 +469,7 @@ void GuiInspectorComponentGroup::onRightMouseUp(const GuiEvent &event)
Con::executef(this, "onRightMouseUp", event.mousePoint);
}
ConsoleMethod(GuiInspectorComponentGroup, inspectGroup, bool, 2, 2, "Refreshes the dynamic fields in the inspector.")
DefineEngineMethod(GuiInspectorComponentGroup, inspectGroup, bool, (),, "Refreshes the dynamic fields in the inspector.")
{
return object->inspectGroup();
}
@ -515,16 +515,17 @@ AbstractClassRep::Field* GuiInspectorComponentGroup::findObjectBehaviorField(Com
}
return NULL;
}
ConsoleMethod(GuiInspectorComponentGroup, addDynamicField, void, 2, 2, "obj.addDynamicField();")
DefineEngineMethod(GuiInspectorComponentGroup, addDynamicField, void, (), , "obj.addDynamicField();")
{
object->addDynamicField();
}
ConsoleMethod(GuiInspectorComponentGroup, removeDynamicField, void, 3, 3, "")
DefineEngineMethod(GuiInspectorComponentGroup, removeDynamicField, void, (), , "")
{
}
DefineEngineMethod(GuiInspectorComponentGroup, getComponent, S32, (), ,"")
DefineEngineMethod(GuiInspectorComponentGroup, getComponent, S32, (), , "")
{
return object->getComponent()->getId();
}

View file

@ -87,7 +87,8 @@ void GuiInspectorEntityGroup::onMouseMove(const GuiEvent &event)
{
//mParent->mOverDivider = false;
}
ConsoleMethod(GuiInspectorEntityGroup, inspectGroup, bool, 2, 2, "Refreshes the dynamic fields in the inspector.")
DefineEngineMethod(GuiInspectorEntityGroup, inspectGroup, bool, (),, "Refreshes the dynamic fields in the inspector.")
{
return object->inspectGroup();
}
@ -128,11 +129,12 @@ AbstractClassRep::Field* GuiInspectorEntityGroup::findObjectBehaviorField(Compon
}
return NULL;
}
ConsoleMethod(GuiInspectorEntityGroup, addDynamicField, void, 2, 2, "obj.addDynamicField();")
DefineEngineMethod(GuiInspectorEntityGroup, addDynamicField, void, (), , "obj.addDynamicField();")
{
object->addDynamicField();
}
ConsoleMethod(GuiInspectorEntityGroup, removeDynamicField, void, 3, 3, "")
DefineEngineMethod(GuiInspectorEntityGroup, removeDynamicField, void, (), , "")
{
}

View file

@ -242,7 +242,8 @@ void GuiInspectorMountingGroup::onMouseMove(const GuiEvent &event)
//mParent->mOverDivider = false;
bool test = false;
}
ConsoleMethod(GuiInspectorMountingGroup, inspectGroup, bool, 2, 2, "Refreshes the dynamic fields in the inspector.")
DefineEngineMethod(GuiInspectorMountingGroup, inspectGroup, bool, (),, "Refreshes the dynamic fields in the inspector.")
{
return object->inspectGroup();
}
@ -319,12 +320,13 @@ AbstractClassRep::Field* GuiInspectorMountingGroup::findObjectComponentField(Com
}
return NULL;
}
ConsoleMethod( GuiInspectorMountingGroup, addDynamicField, void, 2, 2, "obj.addDynamicField();" )
DefineEngineMethod(GuiInspectorMountingGroup, addDynamicField, void, (), , "obj.addDynamicField();")
{
object->addDynamicField();
}
ConsoleMethod( GuiInspectorMountingGroup, removeDynamicField, void, 3, 3, "" )
DefineEngineMethod(GuiInspectorMountingGroup, removeDynamicField, void, (), , "")
{
}

View file

@ -657,58 +657,42 @@ void WorldEditorSelection::setSize(const VectorF & newsize)
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, containsGlobalBounds, bool, 2, 2, "() - True if an object with global bounds is contained in the selection." )
DefineEngineMethod( WorldEditorSelection, containsGlobalBounds, bool, (),, "True if an object with global bounds is contained in the selection." )
{
return object->containsGlobalBounds();
}
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, getCentroid, const char*, 2, 2, "() - Return the median of all object positions in the selection." )
DefineEngineMethod( WorldEditorSelection, getCentroid, Point3F, (),, "Return the median of all object positions in the selection." )
{
static const U32 bufSize = 256;
char* buffer = Con::getReturnBuffer( bufSize );
const Point3F& centroid = object->getCentroid();
dSprintf( buffer, bufSize, "%g %g %g", centroid.x, centroid.y, centroid.z );
return buffer;
return centroid;
}
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, getBoxCentroid, const char*, 2, 2, "() - Return the center of the bounding box around the selection." )
DefineEngineMethod( WorldEditorSelection, getBoxCentroid, Point3F, (),, "Return the center of the bounding box around the selection." )
{
static const U32 bufSize = 256;
char* buffer = Con::getReturnBuffer( bufSize );
const Point3F& boxCentroid = object->getBoxCentroid();
dSprintf( buffer, bufSize, "%g %g %g", boxCentroid.x, boxCentroid.y, boxCentroid.z );
return buffer;
return boxCentroid;
}
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, offset, void, 3, 4, "( vector delta, float gridSnap=0 ) - Move all objects in the selection by the given delta." )
{
F32 x, y, z;
dSscanf( argv[ 3 ], "%g %g %g", &x, &y, &z );
F32 gridSnap = 0.f;
if( argc > 3 )
gridSnap = dAtof( argv[ 3 ] );
object->offset( Point3F( x, y, z ), gridSnap );
DefineEngineMethod(WorldEditorSelection, offset, void, (Point3F delta, F32 gridSnap), (0.0f), "Move all objects in the selection by the given delta.")
{
object->offset( delta, gridSnap );
WorldEditor::updateClientTransforms( object );
}
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, union, void, 3, 3, "( SimSet set ) - Add all objects in the given set to this selection." )
DefineEngineMethod( WorldEditorSelection, union, void, (SimSet* selection),, "Add all objects in the given set to this selection." )
{
SimSet* selection;
if( !Sim::findObject( argv[ 2 ], selection ) )
if( !selection)
{
Con::errorf( "WorldEditorSelection::union - no SimSet '%s'", (const char*)argv[ 2 ] );
Con::errorf( "WorldEditorSelection::union - no SimSet");
return;
}
@ -719,12 +703,11 @@ ConsoleMethod( WorldEditorSelection, union, void, 3, 3, "( SimSet set ) - Add al
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, subtract, void, 3, 3, "( SimSet ) - Remove all objects in the given set from this selection." )
DefineEngineMethod( WorldEditorSelection, subtract, void, (SimSet* selection),, "Remove all objects in the given set from this selection." )
{
SimSet* selection;
if( !Sim::findObject( argv[ 2 ], selection ) )
if( !selection )
{
Con::errorf( "WorldEditorSelection::subtract - no SimSet '%s'", (const char*)argv[ 2 ] );
Con::errorf( "WorldEditorSelection::subtract - no SimSet" );
return;
}