]> icculus.org git repositories - taylor/freespace2.git/blob - src/movie/movie.cpp
merge in updated graphics code
[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.5  2005/10/01 21:48:01  taylor
11  * various cleanups
12  * fix decoder to swap opcode 0xb since it screws up on PPC
13  * the previous opcode 0xc change was wrong since we had already determined that it messes up FS1 movies
14  *
15  * Revision 1.4  2005/03/29 07:50:34  taylor
16  * Update to newest movie code with much better video support and audio support from
17  *   Pierre Willenbrock.  Movies are enabled always now (no longer a build option)
18  *   and but can be skipped with the "--nomovies" or "-n" cmdline options.
19  *
20  *
21  *
22  * $NoKeywords: $
23  *
24  */
25
26 #include "pstypes.h"
27 #include "mvelib.h"
28 #include "movie.h"
29 #include "cutscenes.h"
30 #include "freespace.h"
31 #include "mouse.h"
32 #include "sound.h"
33 #include "cmdline.h"
34 #include "gamesequence.h"
35 #include "mainhallmenu.h"
36
37 int movie_play(const char *filename)
38 {
39         // mark the movie as viewable in the techroom if in a campaign
40         if (Game_mode & GM_CAMPAIGN_MODE) {
41                 cutscene_mark_viewable(filename);
42         }
43
44         if (Cmdline_play_movies) {
45                 MVESTREAM *movie;
46
47                 movie = mve_open(filename);
48
49                 if (movie) {
50                         // kill all background sounds
51                         game_stop_looped_sounds();
52                         main_hall_stop_music();
53                         main_hall_stop_ambient();
54
55                         // clear the screen and hide the mouse cursor
56                         Mouse_hidden++;
57                         gr_set_clear_color(0, 0, 0);
58                         gr_reset_clip();
59                         gr_clear();
60                         gr_flip();
61                         gr_clear();
62                         gr_zbuffer_clear(1);    // G400, blah
63
64                         // ready to play...
65                         mve_init(movie);
66                         mve_play(movie);
67
68                         // ...done playing, close the mve and show the cursor again
69                         mve_shutdown();
70                         mve_close(movie);
71
72                         Mouse_hidden--;
73                         main_hall_start_ambient();
74                 } else {
75                         printf("Can't open movie file: '%s'\n", filename);
76                         return 0;
77                 }
78         
79         } else {
80                 mprintf(("Movies are disabled, skipping...\n"));
81         }
82
83         return 1;
84 }
85
86 int movie_play_two(const char *filename1, const char *filename2)
87 {
88         // make sure the first movie played correctly, then play the second one
89         if ( movie_play(filename1) ) {
90                 movie_play(filename2);
91         } else {
92                 printf("Not playing second movie: %s\n", filename2);
93                 return 0;
94         }
95
96         return 1;
97 }