WindowVideoManager.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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: WindowVideoManager.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: WindowVideoManager.h
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose:
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __WINDOWVIDEOMANAGER_H_
  45. #define __WINDOWVIDEOMANAGER_H_
  46. //-----------------------------------------------------------------------------
  47. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  48. //-----------------------------------------------------------------------------
  49. //-----------------------------------------------------------------------------
  50. // USER INCLUDES //////////////////////////////////////////////////////////////
  51. //-----------------------------------------------------------------------------
  52. //-----------------------------------------------------------------------------
  53. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  54. //-----------------------------------------------------------------------------
  55. class GameWindow;
  56. class AsciiString;
  57. class VideoStreamInterface;
  58. class VideoBuffer;
  59. //-----------------------------------------------------------------------------
  60. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  61. //-----------------------------------------------------------------------------
  62. enum WindowVideoPlayType
  63. {
  64. WINDOW_PLAY_MOVIE_ONCE = 0,
  65. WINDOW_PLAY_MOVIE_LOOP,
  66. WINDOW_PLAY_MOVIE_SHOW_LAST_FRAME,
  67. WINDOW_PLAY_MOVIE_COUNT
  68. };
  69. enum WindowVideoStates
  70. {
  71. WINDOW_VIDEO_STATE_START = 0,
  72. WINDOW_VIDEO_STATE_STOP,
  73. WINDOW_VIDEO_STATE_PAUSE,
  74. WINDOW_VIDEO_STATE_PLAY,
  75. WINDOW_VIDEO_STATE_HIDDEN,
  76. WINDOW_VIDEO_STATE_COUNT
  77. };
  78. class WindowVideo
  79. {
  80. public:
  81. WindowVideo( void );
  82. ~WindowVideo( void );
  83. VideoStreamInterface *getVideoStream( void );
  84. VideoBuffer *getVideoBuffer( void );
  85. GameWindow *getWin( void );
  86. AsciiString getMovieName( void );
  87. WindowVideoPlayType getPlayType ( void );
  88. WindowVideoStates getState( void );
  89. void setPlayType(WindowVideoPlayType playType);
  90. void setWindowState( WindowVideoStates state );
  91. void init( GameWindow *win, AsciiString movieName, WindowVideoPlayType playType,VideoBuffer *videoBuffer,
  92. VideoStreamInterface *videoStream);
  93. private:
  94. WindowVideoPlayType m_playType;
  95. GameWindow *m_win;
  96. VideoBuffer *m_videoBuffer;
  97. VideoStreamInterface *m_videoStream;
  98. AsciiString m_movieName;
  99. WindowVideoStates m_state;
  100. };
  101. class WindowVideoManager : public SubsystemInterface
  102. {
  103. public:
  104. WindowVideoManager( void );
  105. ~WindowVideoManager( void );
  106. // Inhertited from subsystem ====================================================================
  107. virtual void init( void );
  108. virtual void reset( void );
  109. virtual void update( void );
  110. //===============================================================================================
  111. void playMovie( GameWindow *win, AsciiString movieName, WindowVideoPlayType playType );
  112. void hideMovie( GameWindow *win ); ///< If the window becomes hidden while we're playing, stop the movie but test to see if we should resume
  113. void pauseMovie( GameWindow *win ); ///< Pause a movie and display it's current frame
  114. void resumeMovie( GameWindow *win ); ///< If a movie has been stopped, resume it.
  115. void stopMovie( GameWindow *win ); ///< Stop a movie
  116. void stopAndRemoveMovie( GameWindow *win ); ///< Stop a movie, and remove it from the manager
  117. void stopAllMovies( void ); ///< Stop all playing movies
  118. void pauseAllMovies( void ); ///< Pauses all movies on their current frame
  119. void resumeAllMovies( void ); ///< Resume Playing all movies
  120. Int getWinState( GameWindow *win ); ///< return the current state of the window.
  121. private:
  122. typedef const GameWindow* ConstGameWindowPtr;
  123. // use special class for hashing, since std::hash won't compile for arbitrary ptrs
  124. struct hashConstGameWindowPtr
  125. {
  126. size_t operator()(ConstGameWindowPtr p) const
  127. {
  128. std::hash<UnsignedInt> hasher;
  129. return hasher((UnsignedInt)p);
  130. }
  131. };
  132. typedef std::hash_map< ConstGameWindowPtr, WindowVideo *, hashConstGameWindowPtr, std::equal_to<ConstGameWindowPtr> > WindowVideoMap;
  133. WindowVideoMap m_playingVideos; ///< List of currently playin Videos
  134. //WindowVideoMap m_pausedVideos; ///< List of currently paused Videos
  135. Bool m_stopAllMovies; ///< Maintains is we're in a stop all Movies State
  136. Bool m_pauseAllMovies; ///< Maintains if we're in a pause all movies state
  137. };
  138. //-----------------------------------------------------------------------------
  139. // INLINING ///////////////////////////////////////////////////////////////////
  140. //-----------------------------------------------------------------------------
  141. inline VideoStreamInterface *WindowVideo::getVideoStream( void ){ return m_videoStream; };
  142. inline VideoBuffer *WindowVideo::getVideoBuffer( void ){ return m_videoBuffer; };
  143. inline GameWindow *WindowVideo::getWin( void ){ return m_win; };
  144. inline AsciiString WindowVideo::getMovieName( void ){ return m_movieName; };
  145. inline WindowVideoPlayType WindowVideo::getPlayType ( void ){ return m_playType; };
  146. inline WindowVideoStates WindowVideo::getState( void ){ return m_state; };
  147. inline void WindowVideo::setPlayType(WindowVideoPlayType playType){ m_playType = playType; };
  148. //-----------------------------------------------------------------------------
  149. // EXTERNALS //////////////////////////////////////////////////////////////////
  150. //-----------------------------------------------------------------------------
  151. #endif // __WINDOWVIDEOMANAGER_H_