Created a 3DOVID resource type, which corresponds to LEGACY_VIDEO.

This resource may be passed to ShowPresentation and it will play it as
a video.  It can represent basic videos (intro/victory) as well as
spins.

All code that plays FMVs has been updated to deal with this new type.


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3101 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2008-11-29 03:32:51 +00:00
parent 5417b9f06a
commit 460aaa5b56
8 changed files with 263 additions and 35 deletions
+5 -24
View File
@@ -39,7 +39,6 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic)
{ {
#ifdef WANT_SHIP_SPINS #ifdef WANT_SHIP_SPINS
char vnbuf[32]; char vnbuf[32];
char snbuf[32];
BYTE clut_buf[1]; BYTE clut_buf[1];
RECT old_r, r; RECT old_r, r;
@@ -57,25 +56,13 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic)
FreeHyperData (); FreeHyperData ();
sprintf (vnbuf, "slides/spins/ship%02u.duk", (unsigned)index); // TODO: It would be nice to have better resource names for these.
sprintf (snbuf, "slides/spins/ship%02u.aif", (unsigned)index); sprintf (vnbuf, "slides.spins.%02u", (unsigned)index);
if (optWhichIntro == OPT_PC || !DoFMVEx (vnbuf, "slides/spins/spin.aif", snbuf, SHIP_SPIN_LOOP_FRAME)) ShowPresentation (vnbuf);
{
STRING f;
sprintf (vnbuf, "slides/spins/ship%02u.txt", (unsigned)index);
f = CaptureStringTable (LoadStringTableFile (contentDir, vnbuf));
if (f)
{
ShowPresentation (f);
/* BUG: Leak? This is also in ShowPresentationFile */
/* DestroyStringTable (ReleaseStringTable (f)); */
clut_buf[0] = FadeAllToBlack; clut_buf[0] = FadeAllToBlack;
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 4)); SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 4));
FlushColorXForms (); FlushColorXForms ();
}
}
GetContextClipRect (&old_r); GetContextClipRect (&old_r);
r.corner.x = r.corner.y = 0; r.corner.x = r.corner.y = 0;
@@ -156,11 +143,7 @@ Introduction (void)
{ {
BYTE xform_buf[1]; BYTE xform_buf[1];
/* by default we do 3DO cinematics; or PC slides when 3DO files are ShowPresentation (INTROPRES_STRTAB);
* not present */
if (optWhichIntro == OPT_PC || !DoFMV ("slides/intro/intro.duk"))
ShowPresentation ( CaptureStringTable (
LoadStringTable (INTROPRES_STRTAB)));
xform_buf[0] = FadeAllToBlack; xform_buf[0] = FadeAllToBlack;
SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2)); SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2));
@@ -176,9 +159,7 @@ Victory (void)
/* by default we do 3DO cinematics; or PC slides when 3DO files are /* by default we do 3DO cinematics; or PC slides when 3DO files are
* not present */ * not present */
if (optWhichIntro == OPT_PC || !DoFMV ("slides/ending/victory.duk")) ShowPresentation (FINALPRES_STRTAB);
ShowPresentation ( CaptureStringTable (
LoadStringTable (FINALPRES_STRTAB)));
xform_buf[0] = FadeAllToBlack; xform_buf[0] = FadeAllToBlack;
XFormColorMap ((COLORMAPPTR)xform_buf, 0); XFormColorMap ((COLORMAPPTR)xform_buf, 0);
+1 -1
View File
@@ -33,7 +33,7 @@ extern BOOLEAN DoFMV (const char *name);
extern BOOLEAN DoFMVEx (const char *name, const char *audname, extern BOOLEAN DoFMVEx (const char *name, const char *audname,
const char *speechname, DWORD loopframe); const char *speechname, DWORD loopframe);
extern BOOLEAN ShowPresentation (STRING PresStr); extern BOOLEAN ShowPresentation (RESOURCE presentation);
extern BOOLEAN ShowPresentationFile (const char *name); extern BOOLEAN ShowPresentationFile (const char *name);
#endif /* _FMV_H */ #endif /* _FMV_H */
+31 -4
View File
@@ -31,8 +31,12 @@
#include "libs/inplib.h" #include "libs/inplib.h"
#include "libs/log.h" #include "libs/log.h"
// TODO: Fold DoFMV and friends into libs/video; then we can get rid of this.
#include "libs/video/vidintrn.h"
#include <ctype.h> #include <ctype.h>
static BOOLEAN ShowSlidePresentation (STRING PresStr);
typedef struct typedef struct
{ {
@@ -85,7 +89,6 @@ typedef struct {
} SPINANIM_INPUT_STATE; } SPINANIM_INPUT_STATE;
static BOOLEAN DoPresentation (void *pIS); static BOOLEAN DoPresentation (void *pIS);
static BOOLEAN DoSpinAnim (void *pIS);
BOOLEAN BOOLEAN
DoFMVEx (const char *name, const char *audname, const char *speechname, DoFMVEx (const char *name, const char *audname, const char *speechname,
@@ -313,7 +316,7 @@ Present_DrawMovieFrame (PRESENTATION_INPUT_STATE* pPIS)
BOOLEAN BOOLEAN
ShowPresentationFile (const char *name) ShowPresentationFile (const char *name)
{ {
return ShowPresentation (CaptureStringTable ( return ShowSlidePresentation (CaptureStringTable (
LoadStringTableFile (contentDir, name))); LoadStringTableFile (contentDir, name)));
} }
@@ -788,8 +791,8 @@ DoPresentation (void *pIS)
return FALSE; return FALSE;
} }
BOOLEAN static BOOLEAN
ShowPresentation (STRING PresStr) ShowSlidePresentation (STRING PresStr)
{ {
CONTEXT OldContext; CONTEXT OldContext;
FONT OldFont; FONT OldFont;
@@ -840,3 +843,27 @@ ShowPresentation (STRING PresStr)
return TRUE; return TRUE;
} }
BOOLEAN
ShowPresentation (RESOURCE res)
{
const char *resType = res_GetResourceType (res);
if (!resType)
{
return FALSE;
}
if (!strcmp (resType, "STRTAB"))
{
return ShowSlidePresentation (CaptureStringTable (
LoadStringTable (res)));
}
else if (!strcmp (resType, "3DOVID"))
{
LEGACY_VIDEO vid = LoadLegacyVideoInstance (res);
return DoFMVEx (vid->video, vid->audio, vid->speech, vid->loop);
DestroyLegacyVideo (vid);
}
log_add (log_Warning, "Tried to present '%s', of non-presentable type '%s'", res, resType);
return FALSE;
}
+2
View File
@@ -24,6 +24,7 @@
#include "libs/log.h" #include "libs/log.h"
#include "libs/gfxlib.h" #include "libs/gfxlib.h"
#include "libs/sndlib.h" #include "libs/sndlib.h"
#include "libs/vidlib.h"
#include "coderes.h" #include "coderes.h"
#include "propfile.h" #include "propfile.h"
#include <ctype.h> #include <ctype.h>
@@ -182,6 +183,7 @@ InitResourceSystem (void)
InstallGraphicResTypes (); InstallGraphicResTypes ();
InstallStringTableResType (); InstallStringTableResType ();
InstallAudioResTypes (); InstallAudioResTypes ();
InstallVideoResType ();
InstallCodeResType (); InstallCodeResType ();
return ndx; return ndx;
+1 -1
View File
@@ -1 +1 @@
uqm_CFILES="vfileins.c video.c videodec.c vidplayer.c dukvid.c" uqm_CFILES="vfileins.c vresins.c video.c videodec.c vidplayer.c dukvid.c"
+29
View File
@@ -0,0 +1,29 @@
// Copyright 2008 Michael Martin
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef VIDINTERN_H_
#define VIDINTERN_H_
#include "libs/vidlib.h"
typedef struct legacy_video_desc {
char *video, *audio, *speech;
DWORD loop;
} LEGACY_VIDEO_DESC;
#endif
+184
View File
@@ -0,0 +1,184 @@
// Copyright 2008 Michael Martin
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include "vidintrn.h"
#include "libs/log.h"
static BOOLEAN
FreeLegacyVideoData (void *data)
{
LEGACY_VIDEO pLV;
if (!data)
return FALSE;
pLV = (LEGACY_VIDEO) data;
if (pLV->video)
HFree (pLV->video);
if (pLV->audio)
HFree (pLV->audio);
if (pLV->speech)
HFree (pLV->video);
HFree (pLV);
return TRUE;
}
static void
GetLegacyVideoData (const char *path, RESOURCE_DATA *resdata)
{
void *result = NULL;
char paths[1024], *audio_path, *speech_path, *loop_str;
DWORD LoopFrame = VID_NO_LOOP;
/* Parse out the video components. */
strncpy (paths, path, 1023);
paths[1023] = '\0';
audio_path = strchr (paths, ':');
if (audio_path == NULL)
{
speech_path = NULL;
loop_str = NULL;
}
else
{
*audio_path = '\0';
audio_path++;
speech_path = strchr (audio_path, ':');
if (speech_path == NULL)
{
loop_str = NULL;
}
else
{
*speech_path = '\0';
speech_path++;
loop_str = strchr (speech_path, ':');
if (loop_str != NULL) {
*loop_str = '\0';
loop_str++;
}
}
}
log_add (log_Info, "\t'%s' -- video", paths);
if (audio_path)
log_add (log_Info, "\t'%s' -- audio", audio_path);
else
log_add (log_Info, "\tNo associated audio");
if (speech_path)
log_add (log_Info, "\t'%s' -- speech path", speech_path);
else
log_add (log_Info, "\tNo associated speech");
if (loop_str)
{
char *end;
LoopFrame = (DWORD) strtol (loop_str, &end, 10);
// We allow whitespace at the end, but nothing printable.
if (*end > 32) {
log_add (log_Warning, "Warning: Unparsable loop frame '%s'. Disabling loop.", loop_str);
LoopFrame = VID_NO_LOOP;
}
log_add (log_Info, "\tLoop frame is %d", LoopFrame);
}
else
log_add (log_Info, "\tNo specified loop frame");
result = HMalloc (sizeof (LEGACY_VIDEO_DESC));
if (result)
{
LEGACY_VIDEO pLV = (LEGACY_VIDEO) result;
int len;
pLV->video = NULL;
pLV->audio = NULL;
pLV->speech = NULL;
pLV->loop = LoopFrame;
len = strlen(paths)+1;
pLV->video = (char *)HMalloc (len);
if (!pLV->video)
{
log_add (log_Warning, "Warning: Couldn't allocate space for '%s'", paths);
goto err;
}
strncpy(pLV->video, paths, len);
if (audio_path)
{
len = strlen(audio_path)+1;
pLV->audio = (char *)HMalloc (len);
if (!pLV->audio)
{
log_add (log_Warning, "Warning: Couldn't allocate space for '%s'", audio_path);
goto err;
}
strncpy(pLV->audio, audio_path, len);
}
if (speech_path)
{
len = strlen(speech_path)+1;
pLV->speech = (char *)HMalloc (len);
if (!pLV->speech)
{
log_add (log_Warning, "Warning: Couldn't allocate space for '%s'", speech_path);
goto err;
}
strncpy(pLV->speech, speech_path, len);
}
resdata->ptr = result;
}
return;
err:
if (result)
FreeLegacyVideoData ((LEGACY_VIDEO)result);
resdata->ptr = NULL;
return;
}
BOOLEAN
InstallVideoResType (void)
{
InstallResTypeVectors ("3DOVID", GetLegacyVideoData, FreeLegacyVideoData);
return TRUE;
}
LEGACY_VIDEO
LoadLegacyVideoInstance (RESOURCE res)
{
void *data;
data = res_GetResource (res);
if (data)
{
res_DetachResource (res);
}
return (LEGACY_VIDEO)data;
}
BOOLEAN
DestroyLegacyVideo (LEGACY_VIDEO vid)
{
return FreeLegacyVideoData (vid);
}
+7 -2
View File
@@ -21,6 +21,7 @@
#include "libs/compiler.h" #include "libs/compiler.h"
#include "libs/sndlib.h" #include "libs/sndlib.h"
#include "libs/reslib.h"
typedef enum typedef enum
{ {
@@ -29,9 +30,10 @@ typedef enum
SOFTWARE_FMV SOFTWARE_FMV
} VIDEO_TYPE; } VIDEO_TYPE;
struct tfb_videoclip;
typedef struct tfb_videoclip *VIDEO_REF; typedef struct tfb_videoclip *VIDEO_REF;
typedef struct legacy_video_desc *LEGACY_VIDEO;
extern BOOLEAN InstallVideoResType (void);
extern BOOLEAN InitVideoPlayer (BOOLEAN UseCDROM); extern BOOLEAN InitVideoPlayer (BOOLEAN UseCDROM);
extern void UninitVideoPlayer (void); extern void UninitVideoPlayer (void);
@@ -46,4 +48,7 @@ extern void VidStop (void);
extern VIDEO_REF VidPlaying (void); extern VIDEO_REF VidPlaying (void);
extern void VidDoInput (void); extern void VidDoInput (void);
LEGACY_VIDEO LoadLegacyVideoInstance (RESOURCE res);
BOOLEAN DestroyLegacyVideo (LEGACY_VIDEO vid);
#endif /* _VIDLIB_H */ #endif /* _VIDLIB_H */