mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-10 12:41:35 -10:00
Conflicts: .gitignore code/Makefile.am code/ai/ai.h code/ai/ai_profiles.cpp code/ai/ai_profiles.h code/ai/aibig.cpp code/ai/aicode.cpp code/ai/aiturret.cpp code/asteroid/asteroid.cpp code/asteroid/asteroid.h code/bmpman/bm_internal.h code/bmpman/bmpman.cpp code/bmpman/bmpman.h code/camera/camera.cpp code/camera/camera.h code/cfile/cfile.cpp code/cmdline/cmdline.cpp code/cmdline/cmdline.h code/controlconfig/controlsconfig.h code/controlconfig/controlsconfigcommon.cpp code/cutscene/movie.cpp code/cutscene/oggplayer.cpp code/debugconsole/consoleparse.cpp code/fred2/campaigneditordlg.cpp code/fred2/fred.cpp code/fred2/fred.rc code/fred2/missionsave.cpp code/fred2/resource.h code/fred2/sexp_tree.cpp code/fred2/sexp_tree.h code/fred2/shipflagsdlg.cpp code/fred2/shipflagsdlg.h code/fred2/shiptexturesdlg.cpp code/fred2/voiceactingmanager.cpp code/freespace2/freespace.cpp code/freespace2/freespace.rc code/gamehelp/contexthelp.cpp code/globalincs/alphacolors.cpp code/globalincs/alphacolors.h code/globalincs/version.h code/globalincs/vmallocator.h code/globalincs/windebug.cpp code/graphics/2d.cpp code/graphics/font.cpp code/graphics/generic.cpp code/graphics/generic.h code/graphics/grinternal.h code/graphics/gropengl.cpp code/graphics/gropengldraw.cpp code/graphics/gropenglextension.h code/graphics/gropenglpostprocessing.cpp code/graphics/gropenglstate.cpp code/graphics/gropenglstate.h code/graphics/gropengltexture.cpp code/graphics/gropengltnl.cpp code/hud/hud.cpp code/hud/hud.h code/hud/hudconfig.cpp code/hud/hudlock.cpp code/hud/hudmessage.cpp code/hud/hudparse.cpp code/hud/hudreticle.cpp code/hud/hudreticle.h code/hud/hudshield.cpp code/hud/hudsquadmsg.cpp code/hud/hudtarget.cpp code/hud/hudtarget.h code/hud/hudtargetbox.cpp code/inetfile/cftp.cpp code/inetfile/chttpget.cpp code/io/joy.cpp code/io/joy_ff.cpp code/io/key.cpp code/io/keycontrol.cpp code/io/mouse.cpp code/io/timer.cpp code/localization/localize.cpp code/localization/localize.h code/math/fvi.cpp code/math/vecmat.cpp code/menuui/credits.cpp code/menuui/mainhallmenu.cpp code/menuui/mainhallmenu.h code/menuui/optionsmenumulti.cpp code/menuui/playermenu.cpp code/mission/missionbriefcommon.cpp code/mission/missioncampaign.cpp code/mission/missiongoals.h code/mission/missionmessage.cpp code/mission/missionparse.cpp code/mission/missionparse.h code/missionui/missionbrief.cpp code/missionui/missioncmdbrief.cpp code/missionui/missiondebrief.cpp code/missionui/missionscreencommon.cpp code/missionui/missionshipchoice.cpp code/missionui/missionweaponchoice.cpp code/missionui/redalert.cpp code/missionui/redalert.h code/mod_table/mod_table.cpp code/mod_table/mod_table.h code/model/model.h code/model/modelcollide.cpp code/model/modelinterp.cpp code/model/modelread.cpp code/network/multi.cpp code/network/multi_dogfight.cpp code/network/multi_ingame.cpp code/network/multi_log.cpp code/network/multi_rate.cpp code/network/multiteamselect.cpp code/network/multiui.cpp code/network/multiutil.cpp code/network/stand_gui-unix.cpp code/object/collideshipship.cpp code/object/collideshipweapon.cpp code/object/object.cpp code/object/object.h code/object/objectsnd.cpp code/object/objectsort.cpp code/osapi/osapi.cpp code/osapi/osapi_unix.cpp code/osapi/outwnd.h code/parse/generic_log.cpp code/parse/lua.cpp code/parse/parselo.cpp code/parse/parselo.h code/parse/scripting.cpp code/parse/scripting.h code/parse/sexp.cpp code/parse/sexp.h code/physics/physics.cpp code/pilotfile/csg.cpp code/pilotfile/csg_convert.cpp code/pilotfile/pilotfile.cpp code/pilotfile/pilotfile_convert.h code/playerman/playercontrol.cpp code/radar/radardradis.cpp code/radar/radardradis.h code/radar/radarsetup.cpp code/radar/radarsetup.h code/ship/ship.cpp code/ship/ship.h code/ship/shipfx.cpp code/ship/shiphit.cpp code/sound/audiostr.cpp code/sound/ds.cpp code/sound/openal.cpp code/sound/rtvoice.cpp code/sound/sound.cpp code/sound/voicerec.cpp code/stats/medals.cpp code/stats/medals.h code/stats/scoring.cpp code/ui/ui.h code/weapon/beam.cpp code/weapon/weapon.h code/weapon/weapons.cpp code/wxfred2/aboutbox.cpp code/wxfred2/campaigneditor.cpp code/wxfred2/campaigneditor.h code/wxfred2/commandbriefingeditor.cpp code/wxfred2/debriefingeditor.cpp code/wxfred2/fredframe.cpp code/wxfred2/fredframe.h code/wxfred2/missionspecseditor.cpp code/wxfred2/missionspecseditor.h code/wxfred2/voiceactingmanagereditor.cpp code/wxfred2/wxfred.xrc code/wxfred2/wxfred2.cpp code/wxfred2/wxfred2.h configure.ac fs2open.Doxyfile jansson/LICENSE jansson/dump.c jansson/hashtable.c jansson/hashtable.h jansson/jansson.h jansson/jansson_config.h jansson/jansson_private.h jansson/load.c jansson/memory.c jansson/pack_unpack.c jansson/strbuffer.c jansson/strbuffer.h jansson/strconv.c jansson/utf.c jansson/utf.h jansson/value.c libpng/png.c libpng/png.h libpng/pngconf.h libpng/pngdebug.h libpng/pngerror.c libpng/pngget.c libpng/pnginfo.h libpng/pnglibconf.h libpng/pngmem.c libpng/pngpread.c libpng/pngpriv.h libpng/pngread.c libpng/pngrio.c libpng/pngrtran.c libpng/pngrutil.c libpng/pngset.c libpng/pngstruct.h libpng/pngtrans.c libpng/pngwio.c libpng/pngwrite.c libpng/pngwtran.c libpng/pngwutil.c projects/Eclipse/Freespace2/.project projects/MSVC_2005/Fred2.vcproj projects/MSVC_2005/Freespace2.sln projects/MSVC_2005/Freespace2.vcproj projects/MSVC_2005/code.vcproj projects/MSVC_2005/wxFRED2.vcproj projects/MSVC_2008/Fred2.vcproj projects/MSVC_2008/Freespace2.doxproj projects/MSVC_2008/Freespace2.vcproj projects/MSVC_2008/code.vcproj projects/MSVC_2010/Fred2.vcxproj projects/MSVC_2010/Freespace2.vcxproj projects/MSVC_2010/code.vcxproj projects/MSVC_2010/code.vcxproj.filters projects/MSVC_2010/wxFRED2.vcxproj projects/MSVC_2011/Fred2.vcxproj projects/MSVC_2011/Freespace2.vcxproj projects/MSVC_2011/code.vcxproj projects/MSVC_2011/code.vcxproj.filters projects/MSVC_2011/wxFRED2.vcxproj projects/MSVC_2013/Fred2.vcxproj projects/MSVC_2013/Freespace2.vcxproj projects/MSVC_2013/code.vcxproj projects/MSVC_2013/code.vcxproj.filters projects/MSVC_2013/libjpeg.vcxproj projects/MSVC_2013/liblua.vcxproj projects/MSVC_2013/libpng.vcxproj projects/MSVC_2013/wxFRED2.vcxproj projects/MSVC_2013/zlib.vcxproj projects/MSVC_6/Fred2.dsp projects/MSVC_6/Freespace2.dsp projects/MSVC_6/code.dsp projects/MSVC_6/wxFRED2.dsp projects/Xcode/English.lproj/InfoPlist.strings projects/Xcode/FS2_Open.xcodeproj/project.pbxproj projects/Xcode4/English.lproj/InfoPlist.strings projects/Xcode4/FS2_Open.xcodeproj/project.pbxproj projects/Xcode4/Frameworks.tgz projects/codeblocks/Freespace2/Freespace2.cbp zlib/adler32.c zlib/compress.c zlib/crc32.c zlib/crc32.h zlib/deflate.c zlib/deflate.h zlib/infback.c zlib/inffast.c zlib/inffixed.h zlib/inflate.c zlib/inftrees.c zlib/trees.c zlib/uncompr.c zlib/zconf.h zlib/zlib.h zlib/zutil.c zlib/zutil.h
163 lines
3.9 KiB
C++
163 lines
3.9 KiB
C++
/*
|
|
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
|
*
|
|
* All source code herein is the property of Volition, Inc. You may not sell
|
|
* or otherwise commercially exploit the source or things you created based on the
|
|
* source.
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
#include "graphics/2d.h"
|
|
#include "globalincs/systemvars.h"
|
|
#include "cutscene/movie.h"
|
|
#include "osapi/osapi.h"
|
|
#include "cmdline/cmdline.h"
|
|
#include "cfile/cfile.h"
|
|
#include "cutscene/cutscenes.h" // cutscene_mark_viewable()
|
|
#include "cutscene/mvelib.h"
|
|
#include "cutscene/oggplayer.h"
|
|
|
|
extern int Game_mode;
|
|
|
|
const char *movie_ext_list[] = { ".ogg", ".mve" };
|
|
const int NUM_MOVIE_EXT = sizeof(movie_ext_list) / sizeof(char*);
|
|
|
|
|
|
#define MOVIE_NONE -1
|
|
#define MOVIE_OGG 0
|
|
#define MOVIE_MVE 1
|
|
|
|
// This module links freespace movie calls to the actual API calls the play the movie.
|
|
// This module handles all the different requires of OS and gfx API and finding the file to play
|
|
|
|
|
|
// filename - file to search for
|
|
// out_name - output, full path to file
|
|
// returns non-zero if file is found
|
|
int movie_find(char *filename, char *out_name)
|
|
{
|
|
char full_path[MAX_PATH];
|
|
char tmp_name[MAX_PATH];
|
|
int size, offset = 0;
|
|
|
|
if (out_name == NULL)
|
|
return MOVIE_NONE;
|
|
|
|
|
|
memset( full_path, 0, sizeof(full_path) );
|
|
memset( tmp_name, 0, sizeof(tmp_name) );
|
|
|
|
// remove extension
|
|
strcpy_s( tmp_name, filename );
|
|
char *p = strrchr(tmp_name, '.');
|
|
if ( p ) *p = 0;
|
|
|
|
int rc = cf_find_file_location_ext(tmp_name, NUM_MOVIE_EXT, movie_ext_list, CF_TYPE_ANY, sizeof(full_path) - 1, full_path, &size, &offset, 0);
|
|
|
|
if (rc == MOVIE_NONE)
|
|
return MOVIE_NONE;
|
|
|
|
strcpy( out_name, full_path );
|
|
|
|
return rc;
|
|
}
|
|
|
|
// Play one movie
|
|
bool movie_play(char *name)
|
|
{
|
|
// mark the movie as viewable to the player when in a campaign
|
|
// do this before anything else so that we're sure the movie is available
|
|
// to the player even if it's not going to play right now
|
|
if (Game_mode & GM_CAMPAIGN_MODE) {
|
|
cutscene_mark_viewable(name);
|
|
}
|
|
|
|
extern int Is_standalone;
|
|
|
|
if (Cmdline_nomovies || Is_standalone)
|
|
return false;
|
|
|
|
|
|
char full_name[MAX_PATH];
|
|
int rc = 0;
|
|
|
|
memset(full_name, 0, sizeof(full_name));
|
|
|
|
rc = movie_find(name, full_name);
|
|
|
|
if (rc == MOVIE_NONE) {
|
|
strcpy_s(full_name, name);
|
|
char *p = strrchr(full_name, '.');
|
|
if ( p ) *p = 0;
|
|
|
|
mprintf(("Movie Error: Unable to open '%s' movie in any supported format.\n", full_name));
|
|
return false;
|
|
}
|
|
|
|
// clear the screen and hide the mouse cursor
|
|
io::mouse::CursorManager::get()->showCursor(false);
|
|
gr_reset_clip();
|
|
gr_set_color(255, 255, 255);
|
|
gr_set_clear_color(0, 0, 0);
|
|
gr_zbuffer_clear(0);
|
|
// clear first buffer
|
|
gr_clear();
|
|
gr_flip();
|
|
// clear second buffer (may not be one, but that's ok)
|
|
gr_clear();
|
|
gr_flip();
|
|
// clear third buffer (may not be one, but that's ok)
|
|
gr_clear();
|
|
|
|
if (rc == MOVIE_OGG) {
|
|
THEORAFILE *movie_ogg = theora_open(name);
|
|
|
|
if (movie_ogg) {
|
|
// start playing ...
|
|
theora_play(movie_ogg);
|
|
|
|
// ... done playing, close the movie
|
|
theora_close(movie_ogg);
|
|
} else {
|
|
// uh-oh, movie is invalid... Abory, Retry, Fail?
|
|
mprintf(("MOVIE ERROR: Found invalid movie! (%s)\n", name));
|
|
io::mouse::CursorManager::get()->showCursor(true); // show the mouse cursor!
|
|
return false;
|
|
}
|
|
} else if (rc == MOVIE_MVE) {
|
|
MVESTREAM *movie_mve = mve_open(name);
|
|
|
|
if (movie_mve) {
|
|
// start playing ...
|
|
mve_init(movie_mve);
|
|
mve_play(movie_mve);
|
|
|
|
// ... done playing, close the movie
|
|
mve_shutdown();
|
|
mve_close(movie_mve);
|
|
} else {
|
|
// uh-oh, movie is invalid... Abory, Retry, Fail?
|
|
mprintf(("MOVIE ERROR: Found invalid movie! (%s)\n", name));
|
|
io::mouse::CursorManager::get()->showCursor(true); // show the mouse cursor!
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// show the mouse cursor again
|
|
io::mouse::CursorManager::get()->showCursor(true);
|
|
|
|
return true;
|
|
}
|
|
|
|
void movie_play_two(char *name1, char *name2)
|
|
{
|
|
if ( movie_play(name1) )
|
|
movie_play(name2);
|
|
}
|