Intro.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. #ifdef PRECOMPILEDHEADERS
  2. #include "JA2 All.h"
  3. #include "Intro.h"
  4. #include "Cinematics.h"
  5. #else
  6. #include "sgp.h"
  7. #include "sys globals.h"
  8. #include "sysutil.h"
  9. #include "vobject_blitters.h"
  10. #include "wcheck.h"
  11. #include "cursors.h"
  12. #include "font control.h"
  13. #include "cursor control.h"
  14. #include "render dirty.h"
  15. #include "GameScreen.h"
  16. #include "Text.h"
  17. #include "Utilities.h"
  18. #include "WordWrap.h"
  19. #include "Font Control.h"
  20. #include "text.h"
  21. #include "Multi Language Graphic Utils.h"
  22. #include "Line.h"
  23. #include "Intro.h"
  24. #include "Cinematics.h"
  25. #endif
  26. extern STR16 gzIntroScreen[];
  27. extern HVSURFACE ghFrameBuffer;
  28. enum
  29. {
  30. INTRO_TXT__CANT_FIND_INTRO,
  31. };
  32. //ddd
  33. //ggg
  34. BOOLEAN gfIntroScreenEntry;
  35. BOOLEAN gfIntroScreenExit;
  36. UINT32 guiIntroExitScreen = INTRO_SCREEN;
  37. extern BOOLEAN gfDoneWithSplashScreen;
  38. SMKFLIC *gpSmackFlic = NULL;
  39. #define SMKINTRO_FIRST_VIDEO 255
  40. #define SMKINTRO_NO_VIDEO -1
  41. //enums for the various smacker files
  42. enum
  43. {
  44. SMKINTRO_REBEL_CRDT,
  45. SMKINTRO_OMERTA,
  46. SMKINTRO_PRAGUE_CRDT,
  47. SMKINTRO_PRAGUE,
  48. //there are no more videos shown for the begining
  49. SMKINTRO_END_END_SPEECH_MIGUEL,
  50. SMKINTRO_END_END_SPEECH_NO_MIGUEL,
  51. SMKINTRO_END_HELI_FLYBY,
  52. SMKINTRO_END_SKYRIDER_HELICOPTER,
  53. SMKINTRO_END_NOSKYRIDER_HELICOPTER,
  54. SMKINTRO_SPLASH_SCREEN,
  55. SMKINTRO_SPLASH_TALONSOFT,
  56. //there are no more videos shown for the endgame
  57. SMKINTRO_LAST_END_GAME,
  58. };
  59. INT32 giCurrentIntroBeingPlayed = SMKINTRO_NO_VIDEO;
  60. CHAR *gpzSmackerFileNames[] =
  61. {
  62. //begining of the game
  63. "INTRO\\Rebel_cr.smk",
  64. "INTRO\\Omerta.smk",
  65. "INTRO\\Prague_cr.smk",
  66. "INTRO\\Prague.smk",
  67. //endgame
  68. "INTRO\\Throne_Mig.smk",
  69. "INTRO\\Throne_NoMig.smk",
  70. "INTRO\\Heli_FlyBy.smk",
  71. "INTRO\\Heli_Sky.smk",
  72. "INTRO\\Heli_NoSky.smk",
  73. "INTRO\\SplashScreen.smk",
  74. "INTRO\\TalonSoftid_endhold.smk",
  75. };
  76. //enums used for when the intro screen can come up, either begining game intro, or end game cinematic
  77. INT8 gbIntroScreenMode=-1;
  78. extern void CDromEjectionErrorMessageBoxCallBack( UINT8 bExitValue );
  79. void GetIntroScreenUserInput();
  80. BOOLEAN EnterIntroScreen();
  81. void RenderIntroScreen();
  82. void ExitIntroScreen();
  83. void HandleIntroScreen();
  84. void PrepareToExitIntroScreen();
  85. INT32 GetNextIntroVideo( UINT32 uiCurrentVideo );
  86. void StartPlayingIntroFlic( INT32 iIndexOfFlicToPlay );
  87. void DisplaySirtechSplashScreen();
  88. //ppp
  89. UINT32 IntroScreenInit( void )
  90. {
  91. //Set so next time we come in, we can set up
  92. gfIntroScreenEntry = TRUE;
  93. return( 1 );
  94. }
  95. UINT32 IntroScreenShutdown( void )
  96. {
  97. return( 1 );
  98. }
  99. UINT32 IntroScreenHandle( void )
  100. {
  101. if( gfIntroScreenEntry )
  102. {
  103. EnterIntroScreen();
  104. gfIntroScreenEntry = FALSE;
  105. gfIntroScreenExit = FALSE;
  106. InvalidateRegion( 0, 0, 640, 480 );
  107. }
  108. RestoreBackgroundRects();
  109. GetIntroScreenUserInput();
  110. HandleIntroScreen();
  111. ExecuteBaseDirtyRectQueue();
  112. EndFrameBufferRender();
  113. if( gfIntroScreenExit )
  114. {
  115. ExitIntroScreen();
  116. gfIntroScreenExit = FALSE;
  117. gfIntroScreenEntry = TRUE;
  118. }
  119. return( guiIntroExitScreen );
  120. }
  121. BOOLEAN EnterIntroScreen()
  122. {
  123. INT32 iFirstVideoID = -1;
  124. ClearMainMenu();
  125. SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR );
  126. // Don't play music....
  127. SetMusicMode( MUSIC_NONE );
  128. #ifdef JA2BETAVERSION
  129. if( FileExists( "..\\NoIntro.txt" ) )
  130. {
  131. PrepareToExitIntroScreen();
  132. return( TRUE );
  133. }
  134. #endif
  135. //if the library doesnt exist, exit
  136. if( !IsLibraryOpened( LIBRARY_INTRO ) )
  137. {
  138. PrepareToExitIntroScreen();
  139. return( TRUE );
  140. }
  141. //initialize smacker
  142. SmkInitialize( ghWindow, 640, 480);
  143. //get the index opf the first video to watch
  144. iFirstVideoID = GetNextIntroVideo( SMKINTRO_FIRST_VIDEO );
  145. if( iFirstVideoID != -1 )
  146. {
  147. StartPlayingIntroFlic( iFirstVideoID );
  148. guiIntroExitScreen = INTRO_SCREEN;
  149. }
  150. //Got no intro video, exit
  151. else
  152. {
  153. PrepareToExitIntroScreen();
  154. }
  155. return( TRUE );
  156. }
  157. void RenderIntroScreen()
  158. {
  159. }
  160. void ExitIntroScreen()
  161. {
  162. //shutdown smaker
  163. SmkShutdown();
  164. }
  165. void HandleIntroScreen()
  166. {
  167. BOOLEAN fFlicStillPlaying = FALSE;
  168. //if we are exiting this screen, this frame, dont update the screen
  169. if( gfIntroScreenExit )
  170. return;
  171. //handle smaker each frame
  172. fFlicStillPlaying = SmkPollFlics();
  173. //if the flic is not playing
  174. if( !fFlicStillPlaying )
  175. {
  176. INT32 iNextVideoToPlay = -1;
  177. iNextVideoToPlay = GetNextIntroVideo( giCurrentIntroBeingPlayed );
  178. if( iNextVideoToPlay != -1 )
  179. {
  180. StartPlayingIntroFlic( iNextVideoToPlay );
  181. }
  182. else
  183. {
  184. PrepareToExitIntroScreen();
  185. giCurrentIntroBeingPlayed = -1;
  186. }
  187. }
  188. InvalidateScreen();
  189. }
  190. void GetIntroScreenUserInput()
  191. {
  192. InputAtom Event;
  193. POINT MousePos;
  194. GetCursorPos(&MousePos);
  195. while( DequeueEvent( &Event ) )
  196. {
  197. // HOOK INTO MOUSE HOOKS
  198. switch( Event.usEvent)
  199. {
  200. case LEFT_BUTTON_DOWN:
  201. MouseSystemHook(LEFT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  202. break;
  203. case LEFT_BUTTON_UP:
  204. MouseSystemHook(LEFT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y ,_LeftButtonDown, _RightButtonDown);
  205. break;
  206. case RIGHT_BUTTON_DOWN:
  207. MouseSystemHook(RIGHT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  208. break;
  209. case RIGHT_BUTTON_UP:
  210. MouseSystemHook(RIGHT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  211. break;
  212. case RIGHT_BUTTON_REPEAT:
  213. MouseSystemHook(RIGHT_BUTTON_REPEAT, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  214. break;
  215. case LEFT_BUTTON_REPEAT:
  216. MouseSystemHook(LEFT_BUTTON_REPEAT, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  217. break;
  218. }
  219. if( Event.usEvent == KEY_UP )
  220. {
  221. switch( Event.usParam )
  222. {
  223. case ESC:
  224. PrepareToExitIntroScreen();
  225. break;
  226. case SPACE:
  227. SmkCloseFlic( gpSmackFlic );
  228. break;
  229. #ifdef JA2TESTVERSION
  230. case 'r':
  231. break;
  232. case 'i':
  233. InvalidateRegion( 0, 0, 640, 480 );
  234. break;
  235. #endif
  236. }
  237. }
  238. }
  239. // if the user presses either mouse button
  240. if( gfLeftButtonState || gfRightButtonState )
  241. {
  242. //advance to the next flic
  243. SmkCloseFlic( gpSmackFlic );
  244. }
  245. }
  246. void PrepareToExitIntroScreen()
  247. {
  248. //if its the intro at the begining of the game
  249. if( gbIntroScreenMode == INTRO_BEGINING )
  250. {
  251. //go to the init screen
  252. guiIntroExitScreen = INIT_SCREEN;
  253. }
  254. else if( gbIntroScreenMode == INTRO_SPLASH )
  255. {
  256. //display a logo when exiting
  257. DisplaySirtechSplashScreen();
  258. gfDoneWithSplashScreen = TRUE;
  259. guiIntroExitScreen = INIT_SCREEN;
  260. }
  261. else
  262. {
  263. //We want to reinitialize the game
  264. ReStartingGame();
  265. // guiIntroExitScreen = MAINMENU_SCREEN;
  266. guiIntroExitScreen = CREDIT_SCREEN;
  267. }
  268. gfIntroScreenExit = TRUE;
  269. }
  270. INT32 GetNextIntroVideo( UINT32 uiCurrentVideo )
  271. {
  272. INT32 iStringToUse = -1;
  273. //switch on whether it is the beginging or the end game video
  274. switch( gbIntroScreenMode )
  275. {
  276. //the video at the begining of the game
  277. case INTRO_BEGINING:
  278. {
  279. switch( uiCurrentVideo )
  280. {
  281. case SMKINTRO_FIRST_VIDEO:
  282. iStringToUse = SMKINTRO_REBEL_CRDT;
  283. break;
  284. case SMKINTRO_REBEL_CRDT:
  285. iStringToUse = SMKINTRO_OMERTA;
  286. break;
  287. case SMKINTRO_OMERTA:
  288. iStringToUse = SMKINTRO_PRAGUE_CRDT;
  289. break;
  290. case SMKINTRO_PRAGUE_CRDT:
  291. iStringToUse = SMKINTRO_PRAGUE;
  292. break;
  293. case SMKINTRO_PRAGUE:
  294. iStringToUse = -1;
  295. break;
  296. // case SMKINTRO_LAST_INTRO:
  297. // iStringToUse = -1;
  298. // break;
  299. }
  300. }
  301. break;
  302. //end game
  303. case INTRO_ENDING:
  304. {
  305. switch( uiCurrentVideo )
  306. {
  307. case SMKINTRO_FIRST_VIDEO:
  308. //if Miguel is dead, play the flic with out him in it
  309. if( gMercProfiles[ MIGUEL ].bMercStatus == MERC_IS_DEAD )
  310. iStringToUse = SMKINTRO_END_END_SPEECH_NO_MIGUEL;
  311. else
  312. iStringToUse = SMKINTRO_END_END_SPEECH_MIGUEL;
  313. break;
  314. case SMKINTRO_END_END_SPEECH_MIGUEL:
  315. case SMKINTRO_END_END_SPEECH_NO_MIGUEL:
  316. iStringToUse = SMKINTRO_END_HELI_FLYBY;
  317. break;
  318. //if SkyRider is dead, play the flic without him
  319. case SMKINTRO_END_HELI_FLYBY:
  320. if( gMercProfiles[ SKYRIDER ].bMercStatus == MERC_IS_DEAD )
  321. iStringToUse = SMKINTRO_END_NOSKYRIDER_HELICOPTER;
  322. else
  323. iStringToUse = SMKINTRO_END_SKYRIDER_HELICOPTER;
  324. break;
  325. }
  326. }
  327. break;
  328. case INTRO_SPLASH:
  329. switch( uiCurrentVideo )
  330. {
  331. case SMKINTRO_FIRST_VIDEO:
  332. iStringToUse = SMKINTRO_SPLASH_SCREEN;
  333. break;
  334. case SMKINTRO_SPLASH_SCREEN:
  335. //iStringToUse = SMKINTRO_SPLASH_TALONSOFT;
  336. break;
  337. }
  338. break;
  339. }
  340. return( iStringToUse );
  341. }
  342. void StartPlayingIntroFlic( INT32 iIndexOfFlicToPlay )
  343. {
  344. if( iIndexOfFlicToPlay != -1 )
  345. {
  346. //start playing a flic
  347. gpSmackFlic = SmkPlayFlic( gpzSmackerFileNames[ iIndexOfFlicToPlay ], 0, 0, TRUE );
  348. if( gpSmackFlic != NULL )
  349. {
  350. giCurrentIntroBeingPlayed = iIndexOfFlicToPlay;
  351. }
  352. else
  353. {
  354. //do a check
  355. #ifdef JA2BETAVERSION
  356. PrepareToExitIntroScreen();
  357. #else
  358. DoScreenIndependantMessageBox( gzIntroScreen[INTRO_TXT__CANT_FIND_INTRO], MSG_BOX_FLAG_OK, CDromEjectionErrorMessageBoxCallBack );
  359. #endif
  360. }
  361. }
  362. }
  363. void SetIntroType( INT8 bIntroType )
  364. {
  365. if( bIntroType == INTRO_BEGINING )
  366. {
  367. gbIntroScreenMode = INTRO_BEGINING;
  368. }
  369. else if( bIntroType == INTRO_ENDING )
  370. {
  371. gbIntroScreenMode = INTRO_ENDING;
  372. }
  373. else if( bIntroType == INTRO_SPLASH )
  374. {
  375. gbIntroScreenMode = INTRO_SPLASH;
  376. }
  377. }
  378. void DisplaySirtechSplashScreen()
  379. {
  380. HVOBJECT hPixHandle;
  381. VOBJECT_DESC VObjectDesc;
  382. UINT32 uiLogoID;
  383. UINT32 uiDestPitchBYTES;
  384. UINT8 *pDestBuf;
  385. // JA3Gold: do nothing until we have a graphic to replace Talonsoft's
  386. //return;
  387. // CLEAR THE FRAME BUFFER
  388. pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
  389. memset(pDestBuf, 0, SCREEN_HEIGHT * uiDestPitchBYTES );
  390. UnLockVideoSurface( FRAME_BUFFER );
  391. memset( &VObjectDesc, 0, sizeof( VOBJECT_DESC ) );
  392. VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
  393. FilenameForBPP("INTERFACE\\SirtechSplash.sti", VObjectDesc.ImageFile);
  394. // FilenameForBPP("INTERFACE\\TShold.sti", VObjectDesc.ImageFile);
  395. if( !AddVideoObject(&VObjectDesc, &uiLogoID) )
  396. {
  397. AssertMsg( 0, String( "Failed to load %s", VObjectDesc.ImageFile ) );
  398. return;
  399. }
  400. GetVideoObject(&hPixHandle, uiLogoID);
  401. BltVideoObject(FRAME_BUFFER, hPixHandle, 0,0, 0, VO_BLT_SRCTRANSPARENCY,NULL);
  402. DeleteVideoObjectFromIndex(uiLogoID);
  403. InvalidateScreen();
  404. RefreshScreen( NULL );
  405. }