movie.cpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*
  2. ** Command & Conquer Renegade(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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/movie.cpp $*
  25. * *
  26. * $Author:: Tom_s $*
  27. * *
  28. * $Modtime:: 2/25/02 11:46a $*
  29. * *
  30. * $Revision:: 31 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "movie.h"
  36. #include "binkmovie.h"
  37. #include "campaign.h"
  38. #include "input.h"
  39. #include "_globals.h"
  40. #include "registry.h"
  41. #include "renegadedialogmgr.h"
  42. #include "wwmemlog.h"
  43. #include "gameinitmgr.h"
  44. #include "wwaudio.h"
  45. #include "specialbuilds.h"
  46. #include "stylemgr.h"
  47. #include "render2dsentence.h"
  48. enum {
  49. STARTUP_MOVIE_OFF,
  50. STARTUP_MOVIE_EA,
  51. STARTUP_MOVIE_INTRO,
  52. };
  53. int MovieStartupMode = STARTUP_MOVIE_OFF;
  54. bool IntroMovieSkipAllowed = false;
  55. bool SkipAllIntroMovies = false;
  56. void MovieGameModeClass::Init()
  57. {
  58. WWMEMLOG(MEM_BINK);
  59. BINKMovie::Init();
  60. IsPending = false;
  61. IsPlaying = false;
  62. RegistryClass registry( APPLICATION_SUB_KEY_NAME_OPTIONS );
  63. if ( registry.Is_Valid() ) {
  64. IntroMovieSkipAllowed = registry.Get_Bool( "IntroMovieSkipAllowed", false );
  65. SkipAllIntroMovies = registry.Get_Bool( "SkipAllIntroMovies", false );
  66. registry.Set_Bool( "SkipAllIntroMovies", SkipAllIntroMovies );
  67. }
  68. }
  69. void MovieGameModeClass::Shutdown()
  70. {
  71. BINKMovie::Shutdown();
  72. IsPending = false;
  73. IsPlaying = false;
  74. }
  75. /*
  76. ** called each time through the main loop
  77. */
  78. void MovieGameModeClass::Think()
  79. {
  80. WWMEMLOG(MEM_BINK);
  81. if ( Is_Active() ) {
  82. BINKMovie::Update();
  83. if ( IsPending == false && BINKMovie::Is_Complete() ) {
  84. Movie_Done();
  85. return;
  86. }
  87. if (( MovieStartupMode == STARTUP_MOVIE_INTRO ) &&
  88. ( IntroMovieSkipAllowed == false )) {
  89. return;
  90. }
  91. bool leave = Input::Get_State(INPUT_FUNCTION_MENU_TOGGLE);
  92. static bool was_leave = true;
  93. if ( leave && !was_leave ) {
  94. was_leave = leave; // Weird. Double looping calls
  95. Movie_Done();
  96. }
  97. was_leave = leave;
  98. }
  99. }
  100. void MovieGameModeClass::Render()
  101. {
  102. WWMEMLOG(MEM_BINK);
  103. if ( Is_Active() ) {
  104. if (IsPlaying) {
  105. if (BINKMovie::Is_Complete () == false) {
  106. BINKMovie::Render ();
  107. } else {
  108. WWAudioClass::Get_Instance ()->Temp_Disable_Audio (false);
  109. BINKMovie::Stop ();
  110. IsPlaying = false;
  111. }
  112. }
  113. }
  114. }
  115. void MovieGameModeClass::Start_Movie( const char * filename )
  116. {
  117. WWMEMLOG(MEM_BINK);
  118. //
  119. // Check to see if we should enforce the CD or not...
  120. //
  121. bool force_cd = true;
  122. #ifdef WWDEBUG
  123. RegistryClass registry( APPLICATION_SUB_KEY_NAME_DEBUG );
  124. if ( registry.Is_Valid() ) {
  125. force_cd = (registry.Get_Int( "DisableCDCheck", 0 ) == 0);
  126. }
  127. #endif //WWDEBUG
  128. #if defined(BETACLIENT) || defined(FREEDEDICATEDSERVER) || defined(MULTIPLAYERDEMO)
  129. force_cd = false;
  130. #endif //BETACLIENT
  131. //
  132. // Play the movie (if it exists locally)
  133. //
  134. if ( ::GetFileAttributes ( filename ) != 0xFFFFFFFF ) {
  135. Play_Movie ( filename );
  136. } else {
  137. //
  138. // Strip any path information off the filename
  139. //
  140. StringClass filename_only( filename, true );
  141. const char *delimiter = ::strrchr( filename, '\\' );
  142. if ( delimiter != NULL ) {
  143. filename_only = delimiter + 1;
  144. }
  145. //
  146. // Try to find the CD...
  147. //
  148. StringClass cd_path;
  149. if ( CDVerifier.Get_CD_Path( cd_path ) ) {
  150. //
  151. // Build a full-path to the movie on the CD
  152. //
  153. StringClass full_path = cd_path;
  154. if ( cd_path[cd_path.Get_Length () - 1] != '\\' ) {
  155. full_path += "\\";
  156. }
  157. full_path += filename_only;
  158. Play_Movie( full_path );
  159. } else if ( force_cd ) {
  160. PendingMovieFilename = filename_only;
  161. IsPending = true;
  162. CDVerifier.Display_UI( this );
  163. }
  164. }
  165. }
  166. void MovieGameModeClass::Play_Movie( const char * filename )
  167. {
  168. WWAudioClass::Get_Instance ()->Temp_Disable_Audio (true);
  169. FontCharsClass* font = StyleMgrClass::Get_Font(StyleMgrClass::FONT_INGAME_SUBTITLE_TXT);
  170. BINKMovie::Play( filename, "data\\subtitle.ini", font );
  171. if (font) {
  172. font->Release_Ref();
  173. }
  174. IsPlaying = true;
  175. return ;
  176. }
  177. void MovieGameModeClass::HandleNotification (CDVerifyEvent &event)
  178. {
  179. if ( event.Event() == CDVerifyEvent::VERIFIED ) {
  180. //
  181. // Get the path to the CD...
  182. //
  183. StringClass cd_path;
  184. if ( CDVerifier.Get_CD_Path( cd_path ) ) {
  185. //
  186. // Build a full-path to the movie on the CD
  187. //
  188. StringClass full_path = cd_path;
  189. if ( cd_path[cd_path.Get_Length () - 1] != '\\' ) {
  190. full_path += "\\";
  191. }
  192. full_path += PendingMovieFilename;
  193. Play_Movie( full_path );
  194. }
  195. } else if ( event.Event() == CDVerifyEvent::NOT_VERIFIED ) {
  196. if ( MovieStartupMode == STARTUP_MOVIE_EA || MovieStartupMode == STARTUP_MOVIE_INTRO) {
  197. MovieStartupMode = STARTUP_MOVIE_OFF;
  198. // Goto main menu
  199. RenegadeDialogMgrClass::Goto_Location (RenegadeDialogMgrClass::LOC_MAIN_MENU);
  200. Deactivate();
  201. } else {
  202. Movie_Done();
  203. }
  204. }
  205. PendingMovieFilename = "";
  206. IsPending = false;
  207. return ;
  208. }
  209. void MovieGameModeClass::Startup_Movies( void )
  210. {
  211. if ( SkipAllIntroMovies ) {
  212. MovieStartupMode = STARTUP_MOVIE_INTRO;
  213. MovieGameModeClass::Movie_Done();
  214. } else {
  215. MovieStartupMode = STARTUP_MOVIE_EA;
  216. Start_Movie( "DATA\\MOVIES\\EA_WW.BIK" ); // Play WW/EA movie
  217. }
  218. }
  219. void MovieGameModeClass::Movie_Done( void )
  220. {
  221. if (IsPlaying) {
  222. WWAudioClass::Get_Instance ()->Temp_Disable_Audio (false);
  223. BINKMovie::Stop ();
  224. IsPlaying = false;
  225. }
  226. if ( MovieStartupMode == STARTUP_MOVIE_EA ) {
  227. MovieStartupMode = STARTUP_MOVIE_INTRO;
  228. Start_Movie( "DATA\\MOVIES\\R_INTRO.BIK" ); // Play Renegade intro movie
  229. } else if ( MovieStartupMode == STARTUP_MOVIE_INTRO ) {
  230. MovieStartupMode = STARTUP_MOVIE_OFF;
  231. // Goto main menu
  232. #ifdef MULTIPLAYERDEMO
  233. RenegadeDialogMgrClass::Goto_Location (RenegadeDialogMgrClass::LOC_SPLASH_IN);
  234. #else
  235. RenegadeDialogMgrClass::Goto_Location (RenegadeDialogMgrClass::LOC_MAIN_MENU);
  236. #endif //MULTIPLAYERDEMO
  237. IntroMovieSkipAllowed = true;
  238. RegistryClass registry( APPLICATION_SUB_KEY_NAME_OPTIONS );
  239. if ( registry.Is_Valid() ) {
  240. registry.Set_Bool( "IntroMovieSkipAllowed", true );
  241. }
  242. Deactivate();
  243. } else {
  244. CampaignManager::Continue();
  245. }
  246. }