undo_ScriptBinding.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. ConsoleMethodGroupBeginWithDocs(UndoManager, SimObject)
  23. /*! @return Returns the number of redo Actions stored as an integer
  24. */
  25. ConsoleMethodWithDocs(UndoManager, getRedoCount, ConsoleInt, 2, 2, ())
  26. {
  27. return object->getRedoCount();
  28. }
  29. /*! Clears the undo manager.
  30. @return No Return Value
  31. */
  32. ConsoleMethodWithDocs(UndoManager, clearAll, ConsoleVoid, 2, 2, ())
  33. {
  34. object->clearAll();
  35. }
  36. /*! @return Returns the number of UndoActions stored as an integer
  37. */
  38. ConsoleMethodWithDocs(UndoManager, getUndoCount, ConsoleInt, 2, 2, ())
  39. {
  40. return object->getUndoCount();
  41. }
  42. /*! Gets the name of the UndoAction at given index.
  43. @param index An integer index value for the desired undo
  44. @return The name as a string
  45. */
  46. ConsoleMethodWithDocs(UndoManager, getUndoName, ConsoleString, 3, 3, ( S32 index ))
  47. {
  48. return object->getUndoName(dAtoi(argv[2]));
  49. }
  50. /*! Gets the name of the Action at given index.
  51. @param index An integer index value for the desired redo
  52. @return The name as a string
  53. */
  54. ConsoleMethodWithDocs(UndoManager, getRedoName, ConsoleString, 3, 3, ( S32 index ))
  55. {
  56. return object->getRedoName(dAtoi(argv[2]));
  57. }
  58. /*! Adds an UndoAction to the manager
  59. @param undoManager The manager to add the object to (default NULL)
  60. @return No Return Value
  61. */
  62. ConsoleMethodWithDocs(UndoAction, addToManager, ConsoleVoid, 2, 3, ([undoManager]?))
  63. {
  64. UndoManager *theMan = NULL;
  65. if(argc == 3)
  66. {
  67. SimObject *obj = Sim::findObject(argv[2]);
  68. if(obj)
  69. theMan = dynamic_cast<UndoManager*> (obj);
  70. }
  71. object->addToManager(theMan);
  72. }
  73. /*! Pops the top undo action off the stack, resolves it,
  74. and then pushes it onto the redo stack
  75. */
  76. ConsoleMethodWithDocs(UndoManager, undo, ConsoleVoid, 2, 2, ())
  77. {
  78. object->undo();
  79. }
  80. /*! Pops the top redo action off the stack, resolves it,
  81. and then pushes it onto the undo stack
  82. */
  83. ConsoleMethodWithDocs(UndoManager, redo, ConsoleVoid, 2, 2, ())
  84. {
  85. object->redo();
  86. }
  87. /*! Gets the name of the action at the top of the undo stack
  88. @return The name of the top action on the undo stack
  89. */
  90. ConsoleMethodWithDocs(UndoManager, getNextUndoName, ConsoleString, 2, 2, ())
  91. {
  92. StringTableEntry name = object->getNextUndoName();
  93. if(!name)
  94. return NULL;
  95. char *ret = Con::getReturnBuffer(dStrlen(name) + 1);
  96. dStrcpy(ret, name);
  97. return ret;
  98. }
  99. /*! Gets the name of the action at the top of the undo stack
  100. @return The name of the top action on the redo stack
  101. */
  102. ConsoleMethodWithDocs(UndoManager, getNextRedoName, ConsoleString, 2, 2, ())
  103. {
  104. StringTableEntry name = object->getNextRedoName();
  105. if(!name)
  106. return NULL;
  107. char *ret = Con::getReturnBuffer(dStrlen(name) + 1);
  108. dStrcpy(ret, name);
  109. return ret;
  110. }
  111. ConsoleMethodGroupEndWithDocs(UndoManager)