AnimateWindowManager.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: AnimateWindowManager.h /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Mar 2002
  34. //
  35. // Filename: AnimateWindowManager.h
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose: The Animate Window class will be used by registering a window with
  40. // the manager with stating what kind of animation to do. Then on every
  41. // update, we'll move the windows.
  42. //
  43. //-----------------------------------------------------------------------------
  44. ///////////////////////////////////////////////////////////////////////////////
  45. #pragma once
  46. #ifndef __ANIMATEWINDOWMANAGER_H_
  47. #define __ANIMATEWINDOWMANAGER_H_
  48. //-----------------------------------------------------------------------------
  49. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  50. //-----------------------------------------------------------------------------
  51. //-----------------------------------------------------------------------------
  52. // USER INCLUDES //////////////////////////////////////////////////////////////
  53. //-----------------------------------------------------------------------------
  54. #include "Lib/BaseType.h"
  55. #include "Common/SubsystemInterface.h"
  56. #include "Common/GameMemory.h"
  57. //-----------------------------------------------------------------------------
  58. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  59. //-----------------------------------------------------------------------------
  60. class GameWindow;
  61. class ProcessAnimateWindowSlideFromBottom;
  62. class ProcessAnimateWindowSlideFromBottomTimed;
  63. class ProcessAnimateWindowSlideFromTop;
  64. class ProcessAnimateWindowSlideFromLeft;
  65. class ProcessAnimateWindowSlideFromRight;
  66. class ProcessAnimateWindowSlideFromRightFast;
  67. class ProcessAnimateWindowSpiral;
  68. class ProcessAnimateWindowSlideFromTopFast;
  69. class ProcessAnimateWindowSideSelect;
  70. class ProcessAnimateWindow;
  71. //-----------------------------------------------------------------------------
  72. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  73. //-----------------------------------------------------------------------------
  74. enum AnimTypes
  75. {
  76. WIN_ANIMATION_NONE = 0,
  77. WIN_ANIMATION_SLIDE_RIGHT,
  78. WIN_ANIMATION_SLIDE_RIGHT_FAST,
  79. WIN_ANIMATION_SLIDE_LEFT,
  80. WIN_ANIMATION_SLIDE_TOP,
  81. WIN_ANIMATION_SLIDE_BOTTOM,
  82. WIN_ANIMATION_SPIRAL,
  83. WIN_ANIMATION_SLIDE_BOTTOM_TIMED,
  84. WIN_ANIMATION_SLIDE_TOP_FAST,
  85. WIN_ANIMATION_COUNT
  86. } ;
  87. //-----------------------------------------------------------------------------
  88. class AnimateWindow : public MemoryPoolObject
  89. {
  90. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(AnimateWindow, "AnimateWindow")
  91. public:
  92. AnimateWindow( void );
  93. //~AnimateWindow( void );
  94. void setAnimData( ICoord2D startPos, ICoord2D endPos, ICoord2D curPos, ICoord2D restPos, Coord2D vel, UnsignedInt startTime, UnsignedInt endTime);
  95. ICoord2D getStartPos( void ); ///< Get the Start Position 2D coord
  96. ICoord2D getCurPos( void ); ///< Get the Current Position 2D coord
  97. ICoord2D getEndPos( void ); ///< Get the End Position 2D coord
  98. ICoord2D getRestPos( void ); ///< Get the Rest Position 2D coord
  99. GameWindow *getGameWindow( void ); ///< Get the GameWindow that will be animating
  100. AnimTypes getAnimType( void ); ///< Get the Animation type
  101. UnsignedInt getDelay( void ); ///< Get the Time Delay
  102. Coord2D getVel( void ); ///< Get the Velocity Position 2D coord
  103. UnsignedInt getStartTime( void ); ///< Get the start time of the time-based anim
  104. UnsignedInt getEndTime( void ); ///< Get the end time of the time-based anim
  105. void setStartPos( ICoord2D starPos); ///< Set the Start Position 2D coord
  106. void setCurPos( ICoord2D curPos); ///< Set the Current Position 2D coord
  107. void setEndPos( ICoord2D endPos); ///< Set the End Position 2D coord
  108. void setRestPos( ICoord2D restPos); ///< Set the Rest Position 2D coord
  109. void setGameWindow( GameWindow *win); ///< Set the GameWindow that will be animating
  110. void setAnimType( AnimTypes animType); ///< Set the Animation type
  111. void setDelay( UnsignedInt delay); ///< Set the Time Delay
  112. void setVel( Coord2D vel); ///< Set the Velocity Position 2D coord
  113. void setStartTime( UnsignedInt t); ///< Set the start time of the time-based anim
  114. void setEndTime( UnsignedInt t); ///< Set the end time of the time-based anim
  115. void setFinished(Bool finished); ///< Set if the animation has finished
  116. Bool isFinished( void ); ///< Return if the animation has finished or not.
  117. void setNeedsToFinish( Bool needsToFinish); ///< set if we need this animation to finish for the manager to return true
  118. Bool needsToFinish( void ); ///< set if the animation has finished
  119. private:
  120. UnsignedInt m_delay; ///< Holds the delay time in which the animation will start (in milliseconds)
  121. ICoord2D m_startPos; ///< Holds the starting position of the animation
  122. ///<(usuall is also the end position of the animation when the animation is reversed)
  123. ICoord2D m_endPos; ///< Holds the target End Position (usually is the same as the rest position)
  124. ICoord2D m_curPos; ///< It's Current Position
  125. ICoord2D m_restPos; ///< When the Manager Resets, It sets the window's position to this position
  126. GameWindow *m_win; ///< the window that this animation is happening on
  127. Coord2D m_vel; ///< the Velocity of the animation
  128. UnsignedInt m_startTime; ///< time we started the time-based anim
  129. UnsignedInt m_endTime; ///< time we should end the time-based anim
  130. AnimTypes m_animType; ///< The type of animation that will happen
  131. Bool m_needsToFinish; ///< Flag to tell the manager if we need to finish before it's done with it's animation
  132. Bool m_isFinished; ///< We're finished
  133. };
  134. //-----------------------------------------------------------------------------
  135. typedef std::list<AnimateWindow *> AnimateWindowList;
  136. //-----------------------------------------------------------------------------
  137. class AnimateWindowManager : public SubsystemInterface
  138. {
  139. public:
  140. AnimateWindowManager( void );
  141. ~AnimateWindowManager( void );
  142. // Inhertited from subsystem ====================================================================
  143. virtual void init( void );
  144. virtual void reset( void );
  145. virtual void update( void );
  146. //===============================================================================================
  147. void registerGameWindow(GameWindow *win, AnimTypes animType, Bool needsToFinish, UnsignedInt ms = 0, UnsignedInt delayMs = 0); // Registers a new window to animate.
  148. Bool isFinished( void ); ///< Are all the animations that need to be finished, finished?
  149. void reverseAnimateWindow( void ); ///< tell each animation type to setup the windows to run in reverse
  150. void resetToRestPosition( void ); ///< Reset all windows to their rest position
  151. Bool isReversed( void ); ///< Returns whether or not we're in our reversed state.
  152. Bool isEmpty( void );
  153. private:
  154. AnimateWindowList m_winList; ///< A list of AnimationWindows that we don't care if their finished animating
  155. AnimateWindowList m_winMustFinishList; ///< A list of AnimationWindows that we do care about
  156. Bool m_needsUpdate; ///< If we're done animating all our monitored windows, then this will be false
  157. Bool m_reverse; ///< Are we in a reverse state?
  158. ProcessAnimateWindowSlideFromRight *m_slideFromRight; ///< Holds the process in which the windows slide from the right
  159. ProcessAnimateWindowSlideFromRightFast *m_slideFromRightFast;
  160. ProcessAnimateWindowSlideFromTop *m_slideFromTop; ///< Holds the process in which the windows slide from the Top
  161. ProcessAnimateWindowSlideFromLeft *m_slideFromLeft; ///< Holds the process in which the windows slide from the Left
  162. ProcessAnimateWindowSlideFromBottom *m_slideFromBottom; ///< Holds the process in which the windows slide from the Bottom
  163. ProcessAnimateWindowSpiral *m_spiral; ///< Holds the process in which the windows Spiral onto the screen
  164. ProcessAnimateWindowSlideFromBottomTimed *m_slideFromBottomTimed; ///< Holds the process in which the windows slide from the Bottom in a time-based fashion
  165. ProcessAnimateWindowSlideFromTopFast *m_slideFromTopFast; ///< holds the process in wich the windows slide from the top,fast
  166. ProcessAnimateWindow *getProcessAnimate( AnimTypes animType); ///< returns the process for the kind of animation we need.
  167. };
  168. //-----------------------------------------------------------------------------
  169. // INLINING ///////////////////////////////////////////////////////////////////
  170. //-----------------------------------------------------------------------------
  171. inline ICoord2D AnimateWindow::getStartPos( void ) { return m_startPos; };
  172. inline ICoord2D AnimateWindow::getCurPos( void ) { return m_curPos; };
  173. inline ICoord2D AnimateWindow::getEndPos( void ) { return m_endPos; };
  174. inline ICoord2D AnimateWindow::getRestPos( void ) { return m_restPos; };
  175. inline GameWindow *AnimateWindow::getGameWindow( void ){ return m_win; };
  176. inline AnimTypes AnimateWindow::getAnimType( void ) { return m_animType; };
  177. inline UnsignedInt AnimateWindow::getDelay( void ) { return m_delay; };
  178. inline Coord2D AnimateWindow::getVel( void ) { return m_vel; };
  179. inline UnsignedInt AnimateWindow::getStartTime( void ) { return m_startTime; };
  180. inline UnsignedInt AnimateWindow::getEndTime( void ) { return m_endTime; };
  181. inline void AnimateWindow::setStartPos( ICoord2D startPos) { m_startPos = startPos; };
  182. inline void AnimateWindow::setCurPos( ICoord2D curPos) { m_curPos = curPos; };
  183. inline void AnimateWindow::setEndPos( ICoord2D endPos) { m_endPos = endPos; };
  184. inline void AnimateWindow::setRestPos( ICoord2D restPos) { m_restPos = restPos; };
  185. inline void AnimateWindow::setGameWindow( GameWindow *win) { m_win = win; };
  186. inline void AnimateWindow::setAnimType( AnimTypes animType) { m_animType = animType; };
  187. inline void AnimateWindow::setDelay( UnsignedInt delay) { m_delay = delay; };
  188. inline void AnimateWindow::setVel( Coord2D vel) { m_vel = vel; };
  189. inline void AnimateWindow::setStartTime( UnsignedInt t ) { m_startTime = t; }
  190. inline void AnimateWindow::setEndTime( UnsignedInt t ) { m_endTime = t; }
  191. inline void AnimateWindow::setFinished( Bool finished) { m_isFinished = finished; };
  192. inline Bool AnimateWindow::isFinished( void ) { return m_isFinished; };
  193. inline void AnimateWindow::setNeedsToFinish( Bool needsToFinish) { m_needsToFinish = needsToFinish; };
  194. inline Bool AnimateWindow::needsToFinish( void ) { return m_needsToFinish; };
  195. inline Bool AnimateWindowManager::isFinished( void ) { return !m_needsUpdate; };
  196. inline Bool AnimateWindowManager::isReversed( void ) { return m_reverse; };
  197. inline Bool AnimateWindowManager::isEmpty( void ){return (m_winList.size() == 0 && m_winMustFinishList.size() == 0); }
  198. //-----------------------------------------------------------------------------
  199. // EXTERNALS //////////////////////////////////////////////////////////////////
  200. //-----------------------------------------------------------------------------
  201. #endif // __ANIMATEWINDOWMANAGER_H_