Replaced a ton of ConsoleMethods with the DefineConsoleMethod Macro.

This commit is contained in:
Vincent Gee 2014-11-03 22:42:51 -05:00
parent 378a933894
commit acb192e2a5
133 changed files with 1716 additions and 2087 deletions

View file

@ -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,18 +2052,9 @@ ConsoleDocFragment _popDialog2(
"void popDialog();"
);
ConsoleMethod( GuiCanvas, popDialog, void, 2, 3, "(GuiControl ctrl=NULL)"
DefineConsoleMethod( GuiCanvas, popDialog, void, (GuiControl * gui), , "(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);
@ -2097,12 +2081,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);
}
@ -2255,15 +2236,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);
}
@ -2546,7 +2521,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;
@ -2557,14 +2532,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 )
@ -2573,7 +2548,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 )
@ -2582,28 +2557,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"
@ -2622,8 +2599,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)
@ -2670,28 +2645,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);

View file

@ -2612,17 +2612,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();
}
@ -2805,22 +2809,29 @@ 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,
"( Point2I p | int x, int y ) Set the width and height of the control.\n\n"
//ConsoleMethod( GuiControl, setExtent, void, 3, 4,
DefineConsoleMethod( GuiControl, setExtent, void, ( Point2F ext ), ,
" Set the width and height of the control.\n\n"
"@hide" )
{
if ( argc == 3 )
{
// 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 )
//if ( argc == 3 )
//if ( pOrX != "" && 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 )
// if ( dSscanf( pOrX, "%g %g", &ext.x, &ext.y ) == 2 )
object->setExtent( (S32)ext.x, (S32)ext.y );
else
Con::errorf( "GuiControl::setExtent, not enough parameters!" );
}
else if ( argc == 4 )
object->setExtent( dAtoi(argv[2]), dAtoi(argv[3]) );
// else
// Con::errorf( "GuiControl::setExtent, not enough parameters!" );
//}
////else if ( argc == 4 )
//else if ( pOrX != "" && y != "" )
//{
// //object->setExtent( dAtoi(argv[2]), dAtoi(argv[3]) );
// object->setExtent( dAtoi(pOrX), dAtoi(y) );
//}
}
//-----------------------------------------------------------------------------

View file

@ -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 ) );
}
//-----------------------------------------------------------------------------