guiSpriteCtrl_ScriptBindings.h 4.5 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(GuiSpriteCtrl, GuiControl)
  23. /*! Gets whether the control is in static or dynamic (animated)mode.
  24. @return Returns whether the control is in static or dynamic (animated)mode.
  25. */
  26. ConsoleMethodWithDocs( GuiSpriteCtrl, isStaticFrameProvider, ConsoleBool, 2, 2, ())
  27. {
  28. return object->isStaticFrameProvider();
  29. }
  30. //-----------------------------------------------------------------------------
  31. /*! Sets the image asset Id to use as the image.
  32. @param imageAssetId The image asset Id to use as the image.
  33. @return No return value.
  34. */
  35. ConsoleMethodWithDocs( GuiSpriteCtrl, setImage, ConsoleVoid, 3, 3, (imageAssetId))
  36. {
  37. object->setImage( argv[2] );
  38. }
  39. //------------------------------------------------------------------------------
  40. /*! Gets current image asset Id.
  41. @return (string imageAssetId) The image being displayed.
  42. */
  43. ConsoleMethodWithDocs( GuiSpriteCtrl, getImage, ConsoleString, 2, 2, ())
  44. {
  45. // Are we in static mode?
  46. if ( !object->isStaticFrameProvider() )
  47. {
  48. // No, so warn.
  49. Con::warnf( "GuiSpriteCtrl::getImage() - Method invalid, not in static mode." );
  50. return StringTable->EmptyString;
  51. }
  52. // Get image.
  53. return DYNAMIC_VOID_CAST_TO(GuiSpriteCtrl, ImageFrameProvider, object)->getImage();
  54. }
  55. //-----------------------------------------------------------------------------
  56. /*! Sets the image frame to use as the image.
  57. @param imageFrame The image frame to use as the image.
  58. @return No return value.
  59. */
  60. ConsoleMethodWithDocs( GuiSpriteCtrl, setImageFrame, ConsoleVoid, 3, 3, (int imageFrame))
  61. {
  62. object->setImageFrame( dAtoi(argv[2]) );
  63. }
  64. //------------------------------------------------------------------------------
  65. /*! Gets current image Frame.
  66. @return (int frame) The frame currently being displayed.
  67. */
  68. ConsoleMethodWithDocs( GuiSpriteCtrl, getImageFrame, ConsoleInt, 2, 2, ())
  69. {
  70. // Are we in static mode?
  71. if ( !object->isStaticFrameProvider() )
  72. {
  73. // No, so warn.
  74. Con::warnf( "GuiSpriteCtrl::getFrame() - Method invalid, not in static mode." );
  75. return -1;
  76. }
  77. // Get image frame.
  78. return object->getImageFrame();
  79. }
  80. //------------------------------------------------------------------------------
  81. /*! Sets the animation asset Id to display.
  82. @param animationAssetId The animation asset Id to play
  83. @return No return value.
  84. */
  85. ConsoleMethodWithDocs( GuiSpriteCtrl, setAnimation, ConsoleVoid, 3, 3, (string animationAssetId))
  86. {
  87. // Set animation.
  88. object->setAnimation( argv[2] );
  89. }
  90. //------------------------------------------------------------------------------
  91. /*! Gets the current animation asset Id.
  92. @return (string ianimationAssetId) The animation being displayed.
  93. */
  94. ConsoleMethodWithDocs( GuiSpriteCtrl, getAnimation, ConsoleString, 2, 2, ())
  95. {
  96. // Are we in static mode?
  97. if ( object->isStaticFrameProvider() )
  98. {
  99. // Yes, so warn.
  100. Con::warnf( "GuiSpriteCtrl::getAnimation() - Method invalid, in static mode." );
  101. return StringTable->EmptyString;
  102. }
  103. // Get animation.
  104. return DYNAMIC_VOID_CAST_TO(GuiSpriteCtrl, ImageFrameProvider, object)->getAnimation();
  105. }
  106. ConsoleMethodGroupEndWithDocs(GuiSpriteCtrl)