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

@ -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<GuiCanvas*>(Sim::findObject(argv[2])), dAtoi(argv[3]));
object->attachToCanvas(dynamic_cast<GuiCanvas*>(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);
}

View file

@ -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<PopupMenu *>(Sim::findObject(argv[4]));
PopupMenu *mnu = dynamic_cast<PopupMenu *>(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<GuiCanvas*>(Sim::findObject(argv[2])),dAtoi(argv[3]), argv[4]);
object->attachToMenuBar(dynamic_cast<GuiCanvas*>(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<GuiCanvas*>(Sim::findObject(argv[2]));
S32 x = argc >= 4 ? dAtoi(argv[3]) : -1;
S32 y = argc >= 5 ? dAtoi(argv[4]) : -1;
GuiCanvas *pCanvas = dynamic_cast<GuiCanvas*>(Sim::findObject(canvasName));
object->showPopup(pCanvas, x, y);
}

View file

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

View file

@ -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")
{

View file

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