VObject.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #ifndef TINYXML_INCLUDED
  43. #include "tinyxml/tinyxml.h"
  44. #endif
  45. //-----------------------------------------------------------------------------
  46. class VController;
  47. //-----------------------------------------------------------------------------
  48. class VObject : public VObjectRep,
  49. public VTreeNode
  50. {
  51. typedef VObjectRep Parent;
  52. protected:
  53. VController *mController;
  54. String mLabel;
  55. bool mEnabled;
  56. public:
  57. VObject( void );
  58. virtual ~VObject( void );
  59. static void initPersistFields( void );
  60. // Reference Methods.
  61. VObject *getObject( const String &pLabel );
  62. template <class T> inline bool getObject( const String &pLabel, T *&pObject )
  63. {
  64. // Reference Object.
  65. pObject = dynamic_cast<T*>( getObject( pLabel ) );
  66. // Valid?
  67. return ( pObject != NULL );
  68. }
  69. // Console Declaration.
  70. DECLARE_CONOBJECT( VObject );
  71. public:
  72. // Property Methods.
  73. inline VController *getController( void ) { return mController; };
  74. inline const String &getLabel( void ) const { return mLabel; };
  75. bool isEnabled( void );
  76. bool isControllerPlaying( void );
  77. bool isControllerPaused( void );
  78. bool isControllerStopped( void );
  79. bool isControllerPlayingForward( void );
  80. bool isControllerLooping( void );
  81. S32 getControllerTime( void );
  82. F32 getControllerTimeScale( void );
  83. S32 getControllerDuration( void );
  84. virtual void setLabel( const String &pLabel );
  85. void setLabelUnique( const String &pLabel );
  86. inline void setEnabled( const bool &pEnabled ) { mEnabled = pEnabled; };
  87. // Callback Methods.
  88. virtual void onAttach( void );
  89. virtual void onDetach( void );
  90. // Static Methods.
  91. static bool setEnabled( void *pObject, const char *pArray, const char *pData ) { static_cast<VObject*>( pObject )->setEnabled( dAtob( pData ) ); return false; };
  92. static bool setLabel( void *pObject, const char *pArray, const char *pData ) { static_cast<VObject*>( pObject )->setLabel( pData ); return false; };
  93. };
  94. //-----------------------------------------------------------------------------
  95. #endif // _VT_VOBJECT_H_