From 0fff33869cd6cc2828c35408067200c1d9b837d4 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Tue, 17 Apr 2018 22:36:32 +0200 Subject: [PATCH] Eliminate unnecessary uses of ConsoleMethod --- Engine/source/T3D/assets/MaterialAsset.cpp | 2 +- .../camera/cameraComponent_ScriptBinding.h | 3 +- Engine/source/T3D/components/component.cpp | 41 ++++--- Engine/source/T3D/entity.cpp | 31 ++--- Engine/source/T3D/gameBase/gameConnection.cpp | 22 ++-- Engine/source/T3D/player.cpp | 20 ++-- Engine/source/afx/afxCamera.cpp | 110 ++++++++---------- Engine/source/gui/core/guiCanvas.cpp | 23 ++-- .../source/gui/editor/guiInspectorTypes.cpp | 13 +-- .../gui/editor/inspector/componentGroup.cpp | 9 +- .../gui/editor/inspector/entityGroup.cpp | 8 +- .../gui/editor/inspector/mountingGroup.cpp | 8 +- .../gui/worldEditor/worldEditorSelection.cpp | 45 +++---- Engine/source/navigation/guiNavEditorCtrl.cpp | 7 +- Engine/source/util/settings.cpp | 3 +- 15 files changed, 155 insertions(+), 190 deletions(-) diff --git a/Engine/source/T3D/assets/MaterialAsset.cpp b/Engine/source/T3D/assets/MaterialAsset.cpp index 697f21e37..6cf3561a1 100644 --- a/Engine/source/T3D/assets/MaterialAsset.cpp +++ b/Engine/source/T3D/assets/MaterialAsset.cpp @@ -157,7 +157,7 @@ void MaterialAsset::copyTo(SimObject* object) Parent::copyTo(object); } -ConsoleMethod(MaterialAsset, compileShader, void, 2, 2, "() - Compiles the material's generated shader, if any. Not yet implemented\n") +DefineEngineMethod(MaterialAsset, compileShader, void, (), , "Compiles the material's generated shader, if any. Not yet implemented\n") { object->compileShader(); } diff --git a/Engine/source/T3D/components/camera/cameraComponent_ScriptBinding.h b/Engine/source/T3D/components/camera/cameraComponent_ScriptBinding.h index d3b7f9883..412d8e5b6 100644 --- a/Engine/source/T3D/components/camera/cameraComponent_ScriptBinding.h +++ b/Engine/source/T3D/components/camera/cameraComponent_ScriptBinding.h @@ -24,7 +24,8 @@ #include "T3D/components/camera/cameraComponent.h" //Basically, this only exists for backwards compatibility for parts of the editors -ConsoleMethod(CameraComponent, getMode, const char*, 2, 2, "() - We get the first behavior of the requested type on our owner object.\n" +DefineEngineMethod(CameraComponent, getMode, const char*, (),, + "@brief We get the first behavior of the requested type on our owner object.\n" "@return (string name) The type of the behavior we're requesting") { return "fly"; diff --git a/Engine/source/T3D/components/component.cpp b/Engine/source/T3D/components/component.cpp index 83fc015f1..92c9dda44 100644 --- a/Engine/source/T3D/components/component.cpp +++ b/Engine/source/T3D/components/component.cpp @@ -605,8 +605,8 @@ void Component::addDependency(StringTableEntry name) ////////////////////////////////////////////////////////////////////////// // Console Methods ////////////////////////////////////////////////////////////////////////// -ConsoleMethod(Component, beginGroup, void, 3, 3, "(groupName)\n" - "Starts the grouping for following fields being added to be grouped into\n" +DefineEngineMethod(Component, beginGroup, void, (String groupName),, + "@brief Starts the grouping for following fields being added to be grouped into\n" "@param groupName The name of this group\n" "@param desc The Description of this field\n" "@param type The DataType for this field (default, int, float, Point2F, bool, enum, Object, keybind, color)\n" @@ -616,11 +616,11 @@ ConsoleMethod(Component, beginGroup, void, 3, 3, "(groupName)\n" "-object: the T2D object type that are valid choices for the field. The object types observe inheritance, so if you have a t2dSceneObject field you will be able to choose t2dStaticSrpites, t2dAnimatedSprites, etc.\n" "@return Nothing\n") { - object->beginFieldGroup(argv[2]); + object->beginFieldGroup(groupName); } -ConsoleMethod(Component, endGroup, void, 2, 2, "()\n" - "Ends the grouping for prior fields being added to be grouped into\n" +DefineEngineMethod(Component, endGroup, void, (),, + "@brief Ends the grouping for prior fields being added to be grouped into\n" "@param groupName The name of this group\n" "@param desc The Description of this field\n" "@param type The DataType for this field (default, int, float, Point2F, bool, enum, Object, keybind, color)\n" @@ -641,7 +641,8 @@ DefineEngineMethod(Component, addComponentField, void, (String fieldName, String object->addComponentField(fieldName, fieldDesc, fieldType, defValue, userData, hidden); } -ConsoleMethod(Component, getComponentFieldCount, S32, 2, 2, "() - Get the number of ComponentField's on this object\n" +DefineEngineMethod(Component, getComponentFieldCount, S32, (),, + "@brief Get the number of ComponentField's on this object\n" "@return Returns the number of BehaviorFields as a nonnegative integer\n") { return object->getComponentFieldCount(); @@ -650,11 +651,12 @@ ConsoleMethod(Component, getComponentFieldCount, S32, 2, 2, "() - Get the number // [tom, 1/12/2007] Field accessors split into multiple methods to allow space // for long descriptions and type data. -ConsoleMethod(Component, getComponentField, const char *, 3, 3, "(int index) - Gets a Tab-Delimited list of information about a ComponentField specified by Index\n" +DefineEngineMethod(Component, getComponentField, const char *, (S32 index),, + "@brief Gets a Tab-Delimited list of information about a ComponentField specified by Index\n" "@param index The index of the behavior\n" "@return FieldName, FieldType and FieldDefaultValue, each separated by a TAB character.\n") { - ComponentField *field = object->getComponentField(dAtoi(argv[2])); + ComponentField *field = object->getComponentField(index); if (field == NULL) return ""; @@ -664,11 +666,12 @@ ConsoleMethod(Component, getComponentField, const char *, 3, 3, "(int index) - G return buf; } -ConsoleMethod(Component, setComponentield, const char *, 3, 3, "(int index) - Gets a Tab-Delimited list of information about a ComponentField specified by Index\n" +DefineEngineMethod(Component, setComponentield, const char *, (S32 index),, + "@brief Gets a Tab-Delimited list of information about a ComponentField specified by Index\n" "@param index The index of the behavior\n" "@return FieldName, FieldType and FieldDefaultValue, each separated by a TAB character.\n") { - ComponentField *field = object->getComponentField(dAtoi(argv[2])); + ComponentField *field = object->getComponentField(index); if (field == NULL) return ""; @@ -689,36 +692,40 @@ DefineEngineMethod(Component, getComponentFieldType, const char *, (String field return field->mFieldTypeName;; } -ConsoleMethod(Component, getBehaviorFieldUserData, const char *, 3, 3, "(int index) - Gets the UserData associated with a field by index in the field list\n" +DefineEngineMethod(Component, getBehaviorFieldUserData, const char *, (S32 index),, + "@brief Gets the UserData associated with a field by index in the field list\n" "@param index The index of the behavior\n" "@return Returns a string representing the user data of this field\n") { - ComponentField *field = object->getComponentField(dAtoi(argv[2])); + ComponentField *field = object->getComponentField(index); if (field == NULL) return ""; return field->mUserData; } -ConsoleMethod(Component, getComponentFieldDescription, const char *, 3, 3, "(int index) - Gets a field description by index\n" +DefineEngineMethod(Component, getComponentFieldDescription, const char *, (S32 index),, + "@brief Gets a field description by index\n" "@param index The index of the behavior\n" "@return Returns a string representing the description of this field\n") { - ComponentField *field = object->getComponentField(dAtoi(argv[2])); + ComponentField *field = object->getComponentField(index); if (field == NULL) return ""; return field->mFieldDescription ? field->mFieldDescription : ""; } -ConsoleMethod(Component, addDependency, void, 3, 3, "(string behaviorName) - Gets a field description by index\n" +DefineEngineMethod(Component, addDependency, void, (String behaviorName),, + "@brief Gets a field description by index\n" "@param index The index of the behavior\n" "@return Returns a string representing the description of this field\n") { - object->addDependency(argv[2]); + object->addDependency(behaviorName); } -ConsoleMethod(Component, setDirty, void, 2, 2, "() - Gets a field description by index\n" +DefineEngineMethod(Component, setDirty, void, (),, + "@brief Gets a field description by index\n" "@param index The index of the behavior\n" "@return Returns a string representing the description of this field\n") { diff --git a/Engine/source/T3D/entity.cpp b/Engine/source/T3D/entity.cpp index 587eb145b..c13eb61fa 100644 --- a/Engine/source/T3D/entity.cpp +++ b/Engine/source/T3D/entity.cpp @@ -1823,12 +1823,11 @@ ConsoleMethod(Entity, addComponents, void, 2, 2, "() - Add all fielded behaviors object->addComponents(); }*/ -ConsoleMethod(Entity, addComponent, bool, 3, 3, "(ComponentInstance bi) - Add a behavior to the object\n" +DefineEngineMethod(Entity, addComponent, bool, (Component* comp),, + "@brief Add a behavior to the object\n" "@param bi The behavior instance to add" "@return (bool success) Whether or not the behavior was successfully added") { - Component *comp = dynamic_cast(Sim::findObject(argv[2])); - if (comp != NULL) { bool success = object->addComponent(comp); @@ -1848,40 +1847,33 @@ ConsoleMethod(Entity, addComponent, bool, 3, 3, "(ComponentInstance bi) - Add a return false; } -ConsoleMethod(Entity, removeComponent, bool, 3, 4, "(ComponentInstance bi, [bool deleteBehavior = true])\n" +DefineEngineMethod(Entity, removeComponent, bool, (Component* comp, bool deleteComponent), (true), "@param bi The behavior instance to remove\n" "@param deleteBehavior Whether or not to delete the behavior\n" "@return (bool success) Whether the behavior was successfully removed") { - bool deleteComponent = true; - if (argc > 3) - deleteComponent = dAtob(argv[3]); - - return object->removeComponent(dynamic_cast(Sim::findObject(argv[2])), deleteComponent); + return object->removeComponent(comp, deleteComponent); } -ConsoleMethod(Entity, clearComponents, void, 2, 2, "() - Clear all behavior instances\n" +DefineEngineMethod(Entity, clearComponents, void, (),, "Clear all behavior instances\n" "@return No return value") { object->clearComponents(); } -ConsoleMethod(Entity, getComponentByIndex, S32, 3, 3, "(int index) - Gets a particular behavior\n" +DefineEngineMethod(Entity, getComponentByIndex, Component*, (S32 index),, + "@brief Gets a particular behavior\n" "@param index The index of the behavior to get\n" "@return (ComponentInstance bi) The behavior instance you requested") { - Component *comp = object->getComponent(dAtoi(argv[2])); - - return (comp != NULL) ? comp->getId() : 0; + return object->getComponent(index); } -DefineEngineMethod(Entity, getComponent, S32, (String componentName), (""), +DefineEngineMethod(Entity, getComponent, Component*, (String componentName), (""), "Get the number of static fields on the object.\n" "@return The number of static fields defined on the object.") { - Component *comp = object->getComponent(componentName); - - return (comp != NULL) ? comp->getId() : 0; + return object->getComponent(componentName); } /*ConsoleMethod(Entity, getBehaviorByType, S32, 3, 3, "(string BehaviorTemplateName) - gets a behavior\n" @@ -1910,7 +1902,8 @@ DefineEngineMethod(Entity, getComponent, S32, (String componentName), (""), return object->reOrder(inst, idx); }*/ -ConsoleMethod(Entity, getComponentCount, S32, 2, 2, "() - Get the count of behaviors on an object\n" +DefineEngineMethod(Entity, getComponentCount, S32, (),, + "@brief Get the count of behaviors on an object\n" "@return (int count) The number of behaviors on an object") { return object->getComponentCount(); diff --git a/Engine/source/T3D/gameBase/gameConnection.cpp b/Engine/source/T3D/gameBase/gameConnection.cpp index 7c5effdc5..2376e7180 100644 --- a/Engine/source/T3D/gameBase/gameConnection.cpp +++ b/Engine/source/T3D/gameBase/gameConnection.cpp @@ -2451,41 +2451,37 @@ DefineEngineMethod( GameConnection, getVisibleGhostDistance, F32, (),, // Object Selection in Torque by Dave Myers // http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7335 -ConsoleMethod(GameConnection, setSelectedObj, bool, 3, 4, "(object, [propagate_to_client])") +DefineEngineMethod(GameConnection, setSelectedObj, bool, (SceneObject* obj, bool propagate_to_client), (false), "") { - SceneObject* pending_selection; - if (!Sim::findObject(argv[2], pending_selection)) + if (!obj) return false; - bool propagate_to_client = (argc > 3) ? dAtob(argv[3]) : false; - object->setSelectedObj(pending_selection, propagate_to_client); + object->setSelectedObj(obj, propagate_to_client); return true; } -ConsoleMethod(GameConnection, getSelectedObj, S32, 2, 2, "()") +DefineEngineMethod(GameConnection, getSelectedObj, SimObject*, (),, "") { - SimObject* selected = object->getSelectedObj(); - return (selected) ? selected->getId(): -1; + return object->getSelectedObj(); } -ConsoleMethod(GameConnection, clearSelectedObj, void, 2, 3, "([propagate_to_client])") +DefineEngineMethod(GameConnection, clearSelectedObj, void, (bool propagate_to_client), (false), "") { - bool propagate_to_client = (argc > 2) ? dAtob(argv[2]) : false; object->setSelectedObj(NULL, propagate_to_client); } -ConsoleMethod(GameConnection, setPreSelectedObjFromRollover, void, 2, 2, "()") +DefineEngineMethod(GameConnection, setPreSelectedObjFromRollover, void, (),, "") { object->setPreSelectedObjFromRollover(); } -ConsoleMethod(GameConnection, clearPreSelectedObj, void, 2, 2, "()") +DefineEngineMethod(GameConnection, clearPreSelectedObj, void, (),, "") { object->clearPreSelectedObj(); } -ConsoleMethod(GameConnection, setSelectedObjFromPreSelected, void, 2, 2, "()") +DefineEngineMethod(GameConnection, setSelectedObjFromPreSelected, void, (),, "") { object->setSelectedObjFromPreSelected(); } diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 15b57046a..fa43394ca 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -7517,7 +7517,7 @@ U32 Player::lockAnimation() return last_anim_lock_tag; } -ConsoleMethod(Player, isAnimationLocked, bool, 2, 2, "isAnimationLocked()") +DefineEngineMethod(Player, isAnimationLocked, bool, (),, "") { return object->isAnimationLocked(); } @@ -7533,14 +7533,13 @@ void Player::setLookAnimationOverride(bool flag) #endif } -ConsoleMethod(Player, setLookAnimationOverride, void, 3, 3, "setLookAnimationOverride(flag)") +DefineEngineMethod(Player, setLookAnimationOverride, void, (bool flag),, "") { - object->setLookAnimationOverride(dAtob(argv[2])); + object->setLookAnimationOverride(flag); } -ConsoleMethod(Player, copyHeadRotation, void, 3, 3, "copyHeadRotation(other_player)") +DefineEngineMethod(Player, copyHeadRotation, void, (Player* other_player),, "") { - Player* other_player = dynamic_cast(Sim::findObject(argv[2])); if (other_player) object->copyHeadRotation(other_player); } @@ -7609,9 +7608,9 @@ void Player::restoreMovement(U32 tag) } } -ConsoleMethod(Player, setMovementSpeedBias, void, 3, 3, "setMovementSpeedBias(F32 bias)") +DefineEngineMethod(Player, setMovementSpeedBias, void, (F32 bias),, "setMovementSpeedBias(F32 bias)") { - object->setMovementSpeedBias(dAtof(argv[2])); + object->setMovementSpeedBias(bias); } void Player::overrideFootfallFX(bool decals, bool sounds, bool dust) @@ -7642,12 +7641,11 @@ void Player::setControllers(Vector controllerList) mControllers[1] = controllerList.size() > 1 ? controllerList[1] : NULL; } -ConsoleMethod(Player, setVRControllers, void, 4, 4, "") +DefineEngineMethod(Player, setVRControllers, void, (OpenVRTrackedObject* controllerL, OpenVRTrackedObject* controllerR,, "") { - OpenVRTrackedObject *controllerL, *controllerR; Vector list; - if (Sim::findObject(argv[2], controllerL)) + if (controllerL) { list.push_back(controllerL); } @@ -7656,7 +7654,7 @@ ConsoleMethod(Player, setVRControllers, void, 4, 4, "") list.push_back(NULL); } - if (Sim::findObject(argv[3], controllerR)) + if (controllerR) { list.push_back(controllerR); } diff --git a/Engine/source/afx/afxCamera.cpp b/Engine/source/afx/afxCamera.cpp index 63ad635ac..1aad5f455 100644 --- a/Engine/source/afx/afxCamera.cpp +++ b/Engine/source/afx/afxCamera.cpp @@ -483,105 +483,91 @@ ConsoleMethod(afxCamera, setOrbitMode, void, 7, 8, object->setOrbitMode(orbitObject, pos, aa, minDis, maxDis, curDis, (argc == 8) ? dAtob(argv[7]) : false); } -ConsoleMethod( afxCamera, setFlyMode, void, 2, 2, "()" "Set the camera to be able to fly freely.") +DefineEngineMethod(afxCamera, setFlyMode, void, (),, + "@brief Set the camera to be able to fly freely.") { - object->setFlyMode(); + object->setFlyMode(); } -ConsoleMethod( afxCamera, getPosition, const char *, 2, 2, "()" - "Get the position of the camera.\n\n" - "@returns A string of form \"x y z\".") -{ - Point3F& pos = object->getPosition(); - dSprintf(buffer, sizeof(buffer),"%f %f %f",pos.x,pos.y,pos.z); - return buffer; +DefineEngineMethod(afxCamera, getPosition, Point3F, (),, + "@brief Get the position of the camera.\n\n" + "@returns The position of the camera.") +{ + return object->getPosition(); } -ConsoleMethod(afxCamera, setCameraSubject, bool, 3, 3, "") -{ - SceneObject* subject; - if (!Sim::findObject(argv[2], subject)) - { - Con::errorf("Camera subject \"%s\" not found.", argv[2].getStringValue()); - return false; - } - - object->setCameraSubject(subject); - - return true; +DefineEngineMethod(afxCamera, setCameraSubject, bool, (SceneObject* subject),, "") +{ + if (!subject) + { + Con::errorf("Camera subject not found."); + return false; + } + + object->setCameraSubject(subject); + + return true; } -ConsoleMethod(afxCamera, setThirdPersonDistance, bool, 3, 3, "") -{ - F32 distance; - dSscanf(argv[2], "%f", &distance); +DefineEngineMethod(afxCamera, setThirdPersonDistance, bool, (F32 distance),, "") +{ + object->setThirdPersonDistance(distance); - object->setThirdPersonDistance(distance); - - return true; + return true; } -ConsoleMethod(afxCamera, getThirdPersonDistance, F32, 2, 2, "") +DefineEngineMethod(afxCamera, getThirdPersonDistance, F32, (),, "") { return object->getThirdPersonDistance(); } -ConsoleMethod(afxCamera, setThirdPersonAngle, bool, 3, 3, "") -{ - F32 angle; - dSscanf(argv[2], "%f", &angle); +DefineEngineMethod(afxCamera, setThirdPersonAngle, bool, (F32 distance),, "") +{ + object->setThirdPersonAngle(distance); - object->setThirdPersonAngle(angle); - - return true; + return true; } -ConsoleMethod(afxCamera, getThirdPersonAngle, F32, 2, 2, "") +DefineEngineMethod(afxCamera, getThirdPersonAngle, F32, (),, "") { return object->getThirdPersonAngle(); } -ConsoleMethod(afxCamera, setThirdPersonOffset, void, 3, 4, "(Point3F offset [, Point3F coi_offset])") +DefineEngineMethod(afxCamera, setThirdPersonOffset, void, (Point3F offset, Point3F coi_offset), (Point3F::Max), "") { - Point3F offset; - dSscanf(argv[2], "%f %f %f", &offset.x, &offset.y, &offset.z); - if (argc > 3) - { - Point3F coi_offset; - dSscanf(argv[3], "%f %f %f", &coi_offset.x, &coi_offset.y, &coi_offset.z); - object->setThirdPersonOffset(offset, coi_offset); - } - else - object->setThirdPersonOffset(offset); + if (coi_offset == Point3F::Max) + { + object->setThirdPersonOffset(offset); + } + else + { + object->setThirdPersonOffset(offset, coi_offset); + } } -ConsoleMethod(afxCamera, getThirdPersonOffset, const char *, 2, 2, "()") +DefineEngineMethod(afxCamera, getThirdPersonOffset, Point3F, (),, "") { - const Point3F& pos = object->getThirdPersonOffset(); - dSprintf(buffer, sizeof(buffer),"%f %f %f",pos.x,pos.y,pos.z); - return buffer; + return object->getThirdPersonOffset(); } -ConsoleMethod(afxCamera, getThirdPersonCOIOffset, const char *, 2, 2, "()") +DefineEngineMethod(afxCamera, getThirdPersonCOIOffset, Point3F, (),, "") { - const Point3F& pos = object->getThirdPersonCOIOffset(); - dSprintf(buffer, sizeof(buffer),"%f %f %f",pos.x,pos.y,pos.z); - return buffer; + return object->getThirdPersonCOIOffset(); } -ConsoleMethod(afxCamera, setThirdPersonMode, void, 2, 2, "()") +DefineEngineMethod(afxCamera, setThirdPersonMode, void, (),, "") { - object->setThirdPersonMode(); + object->setThirdPersonMode(); } -ConsoleMethod(afxCamera, setThirdPersonSnap, void, 2, 2, "()") +DefineEngineMethod(afxCamera, setThirdPersonSnap, void, (),, "") { - object->setThirdPersonSnap(); + object->setThirdPersonSnap(); } -ConsoleMethod(afxCamera, getMode, const char *, 2, 2, "()") +DefineEngineMethod(afxCamera, getMode, const char*, (),, "") { - return object->getMode(); + return object->getMode(); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index 885d157a0..5b5ca637b 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -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(); diff --git a/Engine/source/gui/editor/guiInspectorTypes.cpp b/Engine/source/gui/editor/guiInspectorTypes.cpp index f31d4facd..4c07f4959 100644 --- a/Engine/source/gui/editor/guiInspectorTypes.cpp +++ b/Engine/source/gui/editor/guiInspectorTypes.cpp @@ -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(); } diff --git a/Engine/source/gui/editor/inspector/componentGroup.cpp b/Engine/source/gui/editor/inspector/componentGroup.cpp index 27aec03fa..e81eec63d 100644 --- a/Engine/source/gui/editor/inspector/componentGroup.cpp +++ b/Engine/source/gui/editor/inspector/componentGroup.cpp @@ -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(); } diff --git a/Engine/source/gui/editor/inspector/entityGroup.cpp b/Engine/source/gui/editor/inspector/entityGroup.cpp index 7b7559833..de4897165 100644 --- a/Engine/source/gui/editor/inspector/entityGroup.cpp +++ b/Engine/source/gui/editor/inspector/entityGroup.cpp @@ -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, (), , "") { } diff --git a/Engine/source/gui/editor/inspector/mountingGroup.cpp b/Engine/source/gui/editor/inspector/mountingGroup.cpp index 7afa53105..759139658 100644 --- a/Engine/source/gui/editor/inspector/mountingGroup.cpp +++ b/Engine/source/gui/editor/inspector/mountingGroup.cpp @@ -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, (), , "") { } diff --git a/Engine/source/gui/worldEditor/worldEditorSelection.cpp b/Engine/source/gui/worldEditor/worldEditorSelection.cpp index 00311adea..472ac46ef 100644 --- a/Engine/source/gui/worldEditor/worldEditorSelection.cpp +++ b/Engine/source/gui/worldEditor/worldEditorSelection.cpp @@ -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; } diff --git a/Engine/source/navigation/guiNavEditorCtrl.cpp b/Engine/source/navigation/guiNavEditorCtrl.cpp index bc605c054..7ef0fb87e 100644 --- a/Engine/source/navigation/guiNavEditorCtrl.cpp +++ b/Engine/source/navigation/guiNavEditorCtrl.cpp @@ -627,13 +627,12 @@ void GuiNavEditorCtrl::_prepRenderImage(SceneManager* sceneGraph, const SceneRen }*/ } -ConsoleMethod(GuiNavEditorCtrl, getMode, const char*, 2, 2, "") +DefineEngineMethod(GuiNavEditorCtrl, getMode, const char*, (), , "") { return object->getMode(); } -ConsoleMethod(GuiNavEditorCtrl, setMode, void, 3, 3, "setMode(String mode)") +DefineEngineMethod(GuiNavEditorCtrl, setMode, void, (String mode),, "setMode(String mode)") { - String newMode = (argv[2]); - object->setMode(newMode); + object->setMode(mode); } diff --git a/Engine/source/util/settings.cpp b/Engine/source/util/settings.cpp index 60f58966e..96fd2d5c8 100644 --- a/Engine/source/util/settings.cpp +++ b/Engine/source/util/settings.cpp @@ -681,9 +681,8 @@ DefineEngineMethod(Settings, remove, void, (const char * settingName, bool inclu object->remove( settingName, includeDefaults ); } -ConsoleMethod(Settings, write, bool, 2, 2, "%success = settingObj.write();") +DefineEngineMethod(Settings, write, bool, (),, "%success = settingObj.write();") { - TORQUE_UNUSED(argc); TORQUE_UNUSED(argv); return object->write(); }