cl_cinematic.c

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 
00026 #include "cl_cinematic.h"
00027 #include "cl_cinematic_ogm.h"
00028 #include "cl_cinematic_roq.h"
00029 #include "../cl_console.h"
00030 #include "../sound/s_main.h"
00031 #include "../sound/s_music.h"
00032 
00033 void CIN_InitCinematic (cinematic_t *cin)
00034 {
00035     memset(cin, 0, sizeof(*cin));
00036 }
00037 
00043 void CIN_SetParameters (cinematic_t *cin, int x, int y, int w, int h, int status, qboolean noSound)
00044 {
00045     cin->x = x * viddef.rx;
00046     cin->y = y * viddef.ry;
00047     cin->w = w * viddef.rx;
00048     cin->h = h * viddef.ry;
00049     if (status > CIN_STATUS_NONE)
00050         cin->status = status;
00051     cin->noSound = noSound;
00052 }
00053 
00057 void CIN_RunCinematic (cinematic_t *cin)
00058 {
00059     assert(cin->status != CIN_STATUS_NONE);
00060 
00061     /* Decode chunks until the desired frame is reached */
00062     if (cin->cinematicType == CINEMATIC_TYPE_ROQ && CIN_ROQ_RunCinematic(cin))
00063         return;
00064     else if (cin->cinematicType == CINEMATIC_TYPE_OGM && CIN_OGM_RunCinematic(cin))
00065         return;
00066 
00067     /* If we get here, the cinematic has either finished or failed */
00068     if (cin->replay) {
00069         char name[MAX_QPATH];
00070         Q_strncpyz(name, cin->name, sizeof(name));
00071         CIN_PlayCinematic(cin, name);
00072         cin->replay = qtrue;
00073     } else {
00074         CIN_StopCinematic(cin);
00075     }
00076 }
00077 
00081 void CIN_PlayCinematic (cinematic_t *cin, const char *fileName)
00082 {
00083     char name[MAX_OSPATH];
00084 
00085     Com_StripExtension(fileName, name, sizeof(name));
00086 
00087     /* If already playing a cinematic, stop it */
00088     CIN_StopCinematic(cin);
00089 
00090     if (FS_CheckFile("%s.roq", name) >= 0)
00091         CIN_ROQ_PlayCinematic(cin, va("%s.roq", name));
00092     else if (FS_CheckFile("%s.ogm", name) >= 0)
00093         CIN_OGM_PlayCinematic(cin, va("%s.ogm", name));
00094     else
00095         Com_Printf("Could not find cinematic '%s'\n", name);
00096 }
00097 
00101 void CIN_StopCinematic (cinematic_t *cin)
00102 {
00103     if (cin->status == CIN_STATUS_NONE)
00104         return;         /* Not playing */
00105 
00106     cin->status = CIN_STATUS_NONE;
00107 
00108     if (cin->cinematicType == CINEMATIC_TYPE_ROQ)
00109         CIN_ROQ_StopCinematic(cin);
00110     else if (cin->cinematicType == CINEMATIC_TYPE_OGM)
00111         CIN_OGM_StopCinematic(cin);
00112 
00113     CIN_InitCinematic(cin);
00114 }
00115 
00116 void CIN_Init (void)
00117 {
00118     CIN_ROQ_Init();
00119     CIN_OGM_Init();
00120 }
00121 
00122 void CIN_Shutdown (void)
00123 {
00124 }

Generated by  doxygen 1.6.2