]> icculus.org git repositories - taylor/freespace2.git/blob - src/movie/movie.cpp
Update to newest movie code with much better video support and audio support from
[taylor/freespace2.git] / src / movie / movie.cpp
1 /*
2  * $Logfile: /Freespace2/src/movie/movie.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Frontend for MVE playing
8  *
9  * $Log$
10  * Revision 1.4  2005/03/29 07:50:34  taylor
11  * Update to newest movie code with much better video support and audio support from
12  *   Pierre Willenbrock.  Movies are enabled always now (no longer a build option)
13  *   and but can be skipped with the "--nomovies" or "-n" cmdline options.
14  *
15  *
16  *
17  * $NoKeywords: $
18  *
19  */
20
21 #include "pstypes.h"
22 #include "mvelib.h"
23 #include "movie.h"
24 #include "cutscenes.h"
25 #include "freespace.h"
26 #include "mouse.h"
27 #include "sound.h"
28 #include "cmdline.h"
29 #include "gamesequence.h"
30 #include "mainhallmenu.h"
31
32 int movie_play(char *filename, int cd_prompt)
33 {
34         // mark the movie as viewable in the techroom if in a campaign
35         if (Game_mode & GM_CAMPAIGN_MODE) {
36                 cutscene_mark_viewable(filename);
37         }
38
39         if (Cmdline_play_movies) {
40                 MVESTREAM *movie;
41
42                 printf("Playing movie: %s\n", filename);
43
44                 // umm, yeah
45         //      if ( cd_prompt == -1 )
46         //              cd_prompt = require_cd;
47
48                 // look for correct CD when viewing movies in the tech room
49         //      if (gameseq_get_state() == GS_STATE_VIEW_CUTSCENES) {
50         //              cutscenes_validate_cd(filename, cd_prompt);
51         //      }
52
53                 movie = mve_open(filename);
54
55                 if (movie) {
56                         // kill all background sounds
57                         game_stop_looped_sounds();
58                         main_hall_stop_music();
59                         main_hall_stop_ambient();
60
61                         // clear the screen and hide the mouse cursor
62                         Mouse_hidden++;
63                         gr_reset_clip();
64                         gr_clear();
65                         gr_flip();
66                         gr_zbuffer_clear(1);    // G400, blah
67                         
68                         // ready to play...
69                         mve_init(movie);
70                         mve_play(movie);
71
72                         // ...done playing, close the mve and show the cursor again
73                         mve_shutdown();
74                         mve_close(movie);
75
76                         Mouse_hidden--;
77                         main_hall_start_ambient();
78                 } else {
79                         printf("Can't open movie file: '%s'\n", filename);
80                         return 0;
81                 }
82         
83         } else {
84                 mprintf(("Movies are disabled, skipping...\n"));
85         }
86
87         return 1;
88 }
89
90 int movie_play_two(char *filename1, char *filename2)
91 {
92         // FIXME: part of the CD code which isn't included yet
93         int require_cd = 0;
94
95         // make sure the first movie played correctly, then play the second one
96         if (movie_play(filename1, require_cd)) {
97                 movie_play(filename2, require_cd);
98         } else {
99                 printf("Not playing second movie: %s\n", filename2);
100                 return 0;
101         }
102
103         return 1;
104 }