]> icculus.org git repositories - taylor/freespace2.git/blob - src/movie/movie.cpp
use a better multi_sw_ok_to_commit() check
[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 #include "audiostr.h"
37
38
39 int movie_play(const char *filename)
40 {
41         // mark the movie as viewable in the techroom if in a campaign
42         if (Game_mode & GM_CAMPAIGN_MODE) {
43                 cutscene_mark_viewable(filename);
44         }
45
46         if ( !Cmdline_play_movies ) {
47                 mprintf(("Movies are disabled, skipping playback of '%s'...\n", filename));
48                 return 1;
49         }
50
51         MVESTREAM *movie = NULL;
52
53         movie = mve_open(filename);
54
55         if (movie == NULL) {
56                 mprintf(("Can't open movie file: '%s'\n", filename));
57                 return 0;
58         }
59
60         // kill all background sounds
61         snd_stop_all();
62         audiostream_pause_all();
63
64         // clear the screen and hide the mouse cursor
65         Mouse_hidden++;
66         gr_set_clear_color(0, 0, 0);
67         gr_reset_clip();
68         gr_clear();
69         gr_flip();
70         gr_clear();
71         gr_zbuffer_clear(1);    // G400, blah
72
73         // ready to play...
74         mve_init(movie);
75         mve_play(movie);
76
77         // ...done playing, close the mve and show the cursor again
78         mve_shutdown();
79         mve_close(movie);
80
81         Mouse_hidden--;
82
83         audiostream_unpause_all();
84
85         return 1;
86 }
87
88 int movie_play_two(const char *filename1, const char *filename2)
89 {
90         // make sure the first movie played correctly, then play the second one
91         if ( movie_play(filename1) ) {
92                 movie_play(filename2);
93         } else {
94                 printf("Not playing second movie: %s\n", filename2);
95                 return 0;
96         }
97
98         return 1;
99 }