VObject.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //-----------------------------------------------------------------------------
  2. // Verve
  3. // Copyright (C) 2014 - Violent Tulip
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //-----------------------------------------------------------------------------
  23. #ifndef _VT_VOBJECT_H_
  24. #define _VT_VOBJECT_H_
  25. #ifndef _VT_VERVECONFIG_H_
  26. #include "Verve/VerveConfig.h"
  27. #endif
  28. #ifdef VT_EDITOR
  29. #ifndef _SIMOBJECT_H_
  30. #include "console/simObject.h"
  31. #endif
  32. #define VObjectRep SimObject
  33. #else
  34. #ifndef _CONSOLEOBJECT_H_
  35. #include "console/consoleObject.h"
  36. #endif
  37. #define VObjectRep ConsoleObject
  38. #endif
  39. #ifndef _VT_VTREENODE_H_
  40. #include "Verve/Core/VTreeNode.h"
  41. #endif
  42. //-----------------------------------------------------------------------------
  43. class VController;
  44. //-----------------------------------------------------------------------------
  45. class VObject : public VObjectRep,
  46. public VTreeNode
  47. {
  48. typedef VObjectRep Parent;
  49. protected:
  50. VController *mController;
  51. String mLabel;
  52. bool mEnabled;
  53. public:
  54. VObject( void );
  55. virtual ~VObject( void );
  56. static void initPersistFields( void );
  57. // Reference Methods.
  58. VObject *getObject( const String &pLabel );
  59. template <class T> inline bool getObject( const String &pLabel, T *&pObject )
  60. {
  61. // Reference Object.
  62. pObject = dynamic_cast<T*>( getObject( pLabel ) );
  63. // Valid?
  64. return ( pObject != NULL );
  65. }
  66. // Console Declaration.
  67. DECLARE_CONOBJECT( VObject );
  68. public:
  69. // Property Methods.
  70. inline VController *getController( void ) { return mController; };
  71. inline const String &getLabel( void ) const { return mLabel; };
  72. bool isEnabled( void );
  73. bool isControllerPlaying( void );
  74. bool isControllerPaused( void );
  75. bool isControllerStopped( void );
  76. bool isControllerPlayingForward( void );
  77. bool isControllerLooping( void );
  78. S32 getControllerTime( void );
  79. F32 getControllerTimeScale( void );
  80. S32 getControllerDuration( void );
  81. virtual void setLabel( const String &pLabel );
  82. void setLabelUnique( const String &pLabel );
  83. inline void setEnabled( const bool &pEnabled ) { mEnabled = pEnabled; };
  84. // Callback Methods.
  85. virtual void onAttach( void );
  86. virtual void onDetach( void );
  87. // Static Methods.
  88. static bool setEnabled( void *pObject, const char *pArray, const char *pData ) { static_cast<VObject*>( pObject )->setEnabled( dAtob( pData ) ); return false; };
  89. static bool setLabel( void *pObject, const char *pArray, const char *pData ) { static_cast<VObject*>( pObject )->setLabel( pData ); return false; };
  90. };
  91. //-----------------------------------------------------------------------------
  92. #endif // _VT_VOBJECT_H_