2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 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.
|
|
|
|
|
|
|
|
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2008-02-16 05:12:58 -08:00
|
|
|
/**
|
|
|
|
* @file seqdisp.c
|
2007-06-28 10:47:08 -07:00
|
|
|
*
|
2008-02-16 05:12:58 -08:00
|
|
|
* Functions for the display of the Escape Sequences (FMV).
|
2007-06-28 10:47:08 -07:00
|
|
|
*
|
|
|
|
*/
|
2006-11-06 06:40:07 -08:00
|
|
|
#include <string.h>
|
2007-11-24 03:49:51 -08:00
|
|
|
#include <SDL_timer.h>
|
2006-06-16 12:10:23 -07:00
|
|
|
#include <physfs.h>
|
|
|
|
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/framework/frame.h"
|
|
|
|
#include "lib/ivis_common/rendmode.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "seqdisp.h"
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/sequence/sequence.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "loop.h"
|
|
|
|
#include "hci.h"//for font
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/sound/audio.h"
|
|
|
|
#include "lib/sound/cdaudio.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "warzoneconfig.h"
|
2006-05-27 09:37:17 -07:00
|
|
|
// FIXME Direct iVis implementation include!
|
|
|
|
#include "lib/ivis_opengl/screen.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/script/script.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "scripttabs.h"
|
|
|
|
#include "design.h"
|
|
|
|
#include "wrappers.h"
|
2007-06-30 17:28:49 -07:00
|
|
|
#include "init.h" // For fileLoadBuffer
|
2008-02-08 03:05:31 -08:00
|
|
|
#include "drive.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* local Definitions
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
#define STD_FRAME_TIME 40 //milliseconds
|
|
|
|
#define VIDEO_PLAYBACK_WIDTH 640
|
|
|
|
#define VIDEO_PLAYBACK_HEIGHT 480
|
|
|
|
#define MAX_TEXT_OVERLAYS 32
|
|
|
|
#define MAX_SEQ_LIST 6
|
|
|
|
#define SUBTITLE_BOX_MIN 430
|
|
|
|
#define SUBTITLE_BOX_MAX 480
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char pText[MAX_STR_LENGTH];
|
2007-01-04 10:41:24 -08:00
|
|
|
UDWORD x;
|
|
|
|
UDWORD y;
|
|
|
|
UDWORD startFrame;
|
|
|
|
UDWORD endFrame;
|
2007-06-28 10:47:08 -07:00
|
|
|
BOOL bSubtitle;
|
2006-02-18 10:54:37 -08:00
|
|
|
} SEQTEXT;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
typedef struct {
|
2007-04-13 08:11:03 -07:00
|
|
|
const char *pSeq; //name of the sequence to play
|
|
|
|
const char *pAudio; //name of the wav to play
|
2007-06-28 10:47:08 -07:00
|
|
|
BOOL bSeqLoop; //loop this sequence
|
|
|
|
SDWORD currentText; //cuurent number of text messages for this seq
|
|
|
|
SEQTEXT aText[MAX_TEXT_OVERLAYS]; //text data to display for this sequence
|
2006-02-18 10:54:37 -08:00
|
|
|
} SEQLIST;
|
2007-06-28 10:47:08 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* local Variables
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2007-11-20 14:58:25 -08:00
|
|
|
static BOOL bBackDropWasAlreadyUp;
|
|
|
|
static BOOL bAudioPlaying = FALSE;
|
|
|
|
static BOOL bHoldSeqForAudio = FALSE;
|
|
|
|
static BOOL bCDPath = FALSE;
|
|
|
|
static BOOL bHardPath = FALSE;
|
|
|
|
static BOOL bSeqSubtitles = TRUE;
|
|
|
|
static char aHardPath[MAX_STR_LENGTH];
|
|
|
|
static char aVideoName[MAX_STR_LENGTH];
|
|
|
|
static SEQLIST aSeqList[MAX_SEQ_LIST];
|
2007-06-28 10:47:08 -07:00
|
|
|
static SDWORD currentSeq = -1;
|
|
|
|
static SDWORD currentPlaySeq = -1;
|
2007-11-20 14:58:25 -08:00
|
|
|
static BOOL g_bResumeInGame = FALSE;
|
2007-12-24 07:57:29 -08:00
|
|
|
|
|
|
|
static unsigned int time_started = 0;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* local ProtoTypes
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2007-11-20 14:58:25 -08:00
|
|
|
static void seq_SetVideoPath(void);
|
2007-12-24 07:57:29 -08:00
|
|
|
static BOOL seq_StartFullScreenVideo(const char* videoName, const char* audioName);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* Source
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
/* Renders a video sequence specified by filename to a buffer*/
|
|
|
|
BOOL seq_RenderVideoToBuffer( iSurface *pSurface, char *sequenceName, int time, int seqCommand)
|
|
|
|
{
|
|
|
|
if (seqCommand == SEQUENCE_KILL)
|
|
|
|
{
|
|
|
|
//stop the movie
|
2007-12-24 07:57:29 -08:00
|
|
|
seq_Shutdown();
|
2007-06-28 10:47:08 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-12-24 07:57:29 -08:00
|
|
|
seq_StartFullScreenVideo(sequenceName, NULL);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-11-20 14:58:25 -08:00
|
|
|
static void seq_SetVideoPath(void)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
// now set up the hard disc path /
|
|
|
|
if (!bHardPath)
|
|
|
|
{
|
2006-10-07 07:13:47 -07:00
|
|
|
strcpy(aHardPath, "sequences/");
|
2006-02-18 10:54:37 -08:00
|
|
|
bHardPath=TRUE; //yes, always true, as it should be on windows ALSO.
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//full screenvideo functions
|
2007-04-13 08:11:03 -07:00
|
|
|
static BOOL seq_StartFullScreenVideo(const char* videoName, const char* audioName)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-27 15:03:09 -08:00
|
|
|
const char* aAudioName;
|
2006-08-29 12:57:34 -07:00
|
|
|
bHoldSeqForAudio = FALSE;
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
//set a valid video path if there is one
|
|
|
|
if(!bCDPath && !bHardPath)
|
|
|
|
{
|
|
|
|
seq_SetVideoPath();
|
|
|
|
}
|
|
|
|
|
2007-12-24 07:57:29 -08:00
|
|
|
ASSERT( (strlen(videoName) + strlen(aHardPath))<MAX_STR_LENGTH,"sequence path+name greater than max string" );
|
2007-12-27 15:03:09 -08:00
|
|
|
snprintf(aVideoName, sizeof(aVideoName), "%s%s", aHardPath, videoName);
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
//set audio path
|
|
|
|
if (audioName != NULL)
|
|
|
|
{
|
2007-05-12 13:39:57 -07:00
|
|
|
ASSERT( strlen(audioName) < MAX_STR_LENGTH, "sequence path+name greater than max string" );
|
2007-12-27 15:03:09 -08:00
|
|
|
sasprintf((char**)&aAudioName, "sequenceaudio/%s", audioName);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//start video mode
|
|
|
|
if (loop_GetVideoMode() == 0)
|
|
|
|
{
|
|
|
|
cdAudio_Pause();
|
|
|
|
loop_SetVideoPlaybackMode();
|
2007-10-01 12:45:49 -07:00
|
|
|
iV_SetFont(font_regular);
|
2007-12-09 08:09:23 -08:00
|
|
|
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2007-12-24 07:57:29 -08:00
|
|
|
if (!seq_Play(aVideoName))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
// don't stop or cancel it as we may have text to display
|
|
|
|
debug( LOG_WARNING,"seq_StartFullScreenVideo: unable to initialise sequence %s",aVideoName );
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (audioName == NULL)
|
|
|
|
{
|
|
|
|
bAudioPlaying = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-31 07:16:59 -08:00
|
|
|
static const float maxVolume = 1.f;
|
|
|
|
|
2008-01-27 13:28:35 -08:00
|
|
|
bAudioPlaying = audio_PlayStream(aAudioName, maxVolume, NULL, NULL) ? TRUE : FALSE;
|
2007-12-31 07:16:59 -08:00
|
|
|
ASSERT(bAudioPlaying == TRUE, "seq_StartFullScreenVideo: unable to initialise sound %s", aAudioName);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2007-12-27 15:03:09 -08:00
|
|
|
|
2007-12-24 07:57:29 -08:00
|
|
|
time_started = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-03-30 10:38:35 -07:00
|
|
|
BOOL seq_UpdateFullScreenVideo(int *pbClear)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
SDWORD i, x, y, w = 640, h = 480;
|
2007-01-07 11:29:26 -08:00
|
|
|
UDWORD subMin, subMax;
|
2007-12-24 07:57:29 -08:00
|
|
|
UDWORD realFrame;
|
2007-06-28 10:47:08 -07:00
|
|
|
BOOL bMoreThanOneSequenceLine = FALSE;
|
2007-12-24 07:57:29 -08:00
|
|
|
BOOL stillText;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-01-07 11:29:26 -08:00
|
|
|
x = (pie_GetVideoBufferWidth() - w)/2;
|
|
|
|
y = (pie_GetVideoBufferHeight() - h)/2;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
subMin = SUBTITLE_BOX_MAX + D_H;
|
|
|
|
subMax = SUBTITLE_BOX_MIN + D_H;
|
|
|
|
|
2007-12-24 07:57:29 -08:00
|
|
|
stillText = FALSE;
|
2007-06-28 10:47:08 -07:00
|
|
|
//get any text lines over bottom of the video
|
2007-12-24 07:57:29 -08:00
|
|
|
realFrame = (SDL_GetTicks()-time_started)/40; // standard frame is 40 msec
|
2007-06-28 10:47:08 -07:00
|
|
|
for(i=0;i<MAX_TEXT_OVERLAYS;i++)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].pText[0] != 0)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].bSubtitle == TRUE)
|
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
if(realFrame <= aSeqList[currentPlaySeq].aText[i].endFrame)
|
|
|
|
{
|
|
|
|
stillText = TRUE;
|
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
if ((realFrame >= aSeqList[currentPlaySeq].aText[i].startFrame) && (realFrame <= aSeqList[currentPlaySeq].aText[i].endFrame))
|
|
|
|
{
|
|
|
|
if (subMin > aSeqList[currentPlaySeq].aText[i].y)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].y > SUBTITLE_BOX_MIN)
|
|
|
|
{
|
|
|
|
subMin = aSeqList[currentPlaySeq].aText[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (subMax < aSeqList[currentPlaySeq].aText[i].y)
|
|
|
|
{
|
|
|
|
subMax = aSeqList[currentPlaySeq].aText[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aSeqList[currentPlaySeq].bSeqLoop)//if its a looped video always draw the text
|
|
|
|
{
|
|
|
|
if (subMin >= aSeqList[currentPlaySeq].aText[i].y)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].y > SUBTITLE_BOX_MIN)
|
|
|
|
{
|
|
|
|
subMin = aSeqList[currentPlaySeq].aText[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (subMax < aSeqList[currentPlaySeq].aText[i].y)
|
|
|
|
{
|
|
|
|
subMax = aSeqList[currentPlaySeq].aText[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
subMin -= D_H;//adjust video window here because text is already ofset for big screens
|
|
|
|
subMax -= D_H;
|
|
|
|
|
|
|
|
if (subMin < SUBTITLE_BOX_MIN)
|
|
|
|
{
|
|
|
|
subMin = SUBTITLE_BOX_MIN;
|
|
|
|
}
|
|
|
|
if (subMax > SUBTITLE_BOX_MAX)
|
|
|
|
{
|
|
|
|
subMax = SUBTITLE_BOX_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (subMax > subMin)
|
|
|
|
{
|
|
|
|
bMoreThanOneSequenceLine = TRUE;
|
|
|
|
}
|
|
|
|
|
2007-12-24 07:57:29 -08:00
|
|
|
//call sequence player to download last frame
|
|
|
|
if(seq_Playing())
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
seq_Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
//print any text over the video
|
|
|
|
for(i=0;i<MAX_TEXT_OVERLAYS;i++)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].pText[0] != 0)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
if ((realFrame >= aSeqList[currentPlaySeq].aText[i].startFrame) && (realFrame <= aSeqList[currentPlaySeq].aText[i].endFrame))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
if (bMoreThanOneSequenceLine)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
aSeqList[currentPlaySeq].aText[i].x = 20 + D_W;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2007-12-24 07:57:29 -08:00
|
|
|
iV_DrawText(&(aSeqList[currentPlaySeq].aText[i].pText[0]),
|
|
|
|
aSeqList[currentPlaySeq].aText[i].x, aSeqList[currentPlaySeq].aText[i].y);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2007-12-24 07:57:29 -08:00
|
|
|
else if (aSeqList[currentPlaySeq].bSeqLoop)//if its a looped video always draw the text
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
if (bMoreThanOneSequenceLine)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
aSeqList[currentPlaySeq].aText[i].x = 20 + D_W;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2007-12-24 07:57:29 -08:00
|
|
|
iV_DrawText(&(aSeqList[currentPlaySeq].aText[i].pText[0]),
|
|
|
|
aSeqList[currentPlaySeq].aText[i].x, aSeqList[currentPlaySeq].aText[i].y);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2007-12-27 15:03:09 -08:00
|
|
|
|
2007-12-24 07:57:29 -08:00
|
|
|
if ((!seq_Playing() && !stillText) || (bHoldSeqForAudio))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
if (bAudioPlaying)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].bSeqLoop)
|
|
|
|
{
|
2007-12-24 07:57:29 -08:00
|
|
|
seq_Shutdown();
|
|
|
|
if (!seq_Play(aVideoName))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
bHoldSeqForAudio = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bHoldSeqForAudio = TRUE;
|
|
|
|
}
|
|
|
|
return TRUE;//should hold the video
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;//should terminate the video
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_StopFullScreenVideo(void)
|
|
|
|
{
|
2008-02-08 03:05:31 -08:00
|
|
|
StopDriverMode();
|
2007-06-28 10:47:08 -07:00
|
|
|
if (!seq_AnySeqLeft())
|
|
|
|
{
|
|
|
|
loop_ClearVideoPlaybackMode();
|
|
|
|
}
|
|
|
|
|
2007-12-24 07:57:29 -08:00
|
|
|
seq_Shutdown();
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if (!seq_AnySeqLeft())
|
|
|
|
{
|
|
|
|
if ( g_bResumeInGame == TRUE )
|
|
|
|
{
|
|
|
|
resetDesignPauseState();
|
|
|
|
intAddReticule();
|
|
|
|
g_bResumeInGame = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BUFFER_WIDTH 600
|
|
|
|
#define FOLLOW_ON_JUSTIFICATION 160
|
|
|
|
#define MIN_JUSTIFICATION 40
|
|
|
|
|
|
|
|
// add a string at x,y or add string below last line if x and y are 0
|
2006-11-26 03:20:44 -08:00
|
|
|
BOOL seq_AddTextForVideo(char* pText, SDWORD xOffset, SDWORD yOffset, SDWORD startFrame, SDWORD endFrame, SDWORD bJustify)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
SDWORD sourceLength, currentLength;
|
|
|
|
char* currentText;
|
|
|
|
SDWORD justification;
|
2007-12-24 07:57:29 -08:00
|
|
|
static SDWORD lastX;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-10-01 12:45:49 -07:00
|
|
|
iV_SetFont(font_regular);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( aSeqList[currentSeq].currentText < MAX_TEXT_OVERLAYS,
|
|
|
|
"seq_AddTextForVideo: too many text lines" );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-02-18 10:54:37 -08:00
|
|
|
sourceLength = strlen(pText);
|
2007-06-28 10:47:08 -07:00
|
|
|
currentLength = sourceLength;
|
|
|
|
currentText = &(aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].pText[0]);
|
|
|
|
|
|
|
|
//if the string is bigger than the buffer get the last end of the last fullword in the buffer
|
|
|
|
if (currentLength >= MAX_STR_LENGTH)
|
|
|
|
{
|
|
|
|
currentLength = MAX_STR_LENGTH - 1;
|
|
|
|
//get end of the last word
|
|
|
|
while((pText[currentLength] != ' ') && (currentLength > 0))
|
|
|
|
{
|
|
|
|
currentLength--;
|
|
|
|
}
|
|
|
|
currentLength--;
|
|
|
|
}
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
memcpy(currentText,pText,currentLength);
|
|
|
|
currentText[currentLength] = 0;//terminate the string what ever
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
//check the string is shortenough to print
|
|
|
|
//if not take a word of the end and try again
|
|
|
|
while(iV_GetTextWidth(currentText) > BUFFER_WIDTH)
|
|
|
|
{
|
|
|
|
currentLength--;
|
|
|
|
while((pText[currentLength] != ' ') && (currentLength > 0))
|
|
|
|
{
|
|
|
|
currentLength--;
|
|
|
|
}
|
|
|
|
currentText[currentLength] = 0;//terminate the string what ever
|
|
|
|
}
|
|
|
|
currentText[currentLength] = 0;//terminate the string what ever
|
|
|
|
|
|
|
|
//check if x and y are 0 and put text on next line
|
|
|
|
if (((xOffset == 0) && (yOffset == 0)) && (currentLength > 0))
|
|
|
|
{
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x = lastX;
|
|
|
|
// aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText-1].x;
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].y = aSeqList[currentSeq].
|
|
|
|
aText[aSeqList[currentSeq].currentText-1].y + iV_GetTextLineSize();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x = xOffset + D_W;
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].y = yOffset + D_H;
|
|
|
|
}
|
|
|
|
lastX = aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x;
|
|
|
|
|
|
|
|
if ((bJustify) && (currentLength == sourceLength))
|
|
|
|
{
|
|
|
|
//justify this text
|
|
|
|
justification = BUFFER_WIDTH - iV_GetTextWidth(currentText);
|
|
|
|
if ((bJustify == SEQ_TEXT_JUSTIFY) && (justification > MIN_JUSTIFICATION))
|
|
|
|
{
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x += (justification/2);
|
|
|
|
}
|
|
|
|
else if ((bJustify == SEQ_TEXT_FOLLOW_ON) && (justification > FOLLOW_ON_JUSTIFICATION))
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-18 10:54:37 -08:00
|
|
|
//set start and finish times for the objects
|
2007-06-28 10:47:08 -07:00
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].startFrame = startFrame;
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].endFrame = endFrame;
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].bSubtitle = bJustify;
|
|
|
|
|
|
|
|
aSeqList[currentSeq].currentText++;
|
|
|
|
if (aSeqList[currentSeq].currentText >= MAX_TEXT_OVERLAYS)
|
|
|
|
{
|
|
|
|
aSeqList[currentSeq].currentText = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//check text is okay on the screen
|
|
|
|
if (currentLength < sourceLength)
|
|
|
|
{
|
|
|
|
//RECURSE x= 0 y = 0 for nextLine
|
|
|
|
if (bJustify == SEQ_TEXT_JUSTIFY)
|
|
|
|
{
|
|
|
|
bJustify = SEQ_TEXT_POSITION;
|
|
|
|
}
|
2006-11-26 03:20:44 -08:00
|
|
|
seq_AddTextForVideo(&pText[currentLength + 1], 0, 0, startFrame, endFrame, bJustify);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_ClearTextForVideo(void)
|
|
|
|
{
|
|
|
|
SDWORD i, j;
|
|
|
|
|
|
|
|
for (j=0; j < MAX_SEQ_LIST; j++)
|
|
|
|
{
|
|
|
|
for(i=0;i<MAX_TEXT_OVERLAYS;i++)
|
|
|
|
{
|
|
|
|
aSeqList[j].aText[i].pText[0] = 0;
|
|
|
|
aSeqList[j].aText[i].x = 0;
|
|
|
|
aSeqList[j].aText[i].y = 0;
|
|
|
|
aSeqList[j].aText[i].startFrame = 0;
|
|
|
|
aSeqList[j].aText[i].endFrame = 0;
|
|
|
|
aSeqList[j].aText[i].bSubtitle = 0;
|
|
|
|
}
|
|
|
|
aSeqList[j].currentText = 0;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-11-23 05:28:38 -08:00
|
|
|
static BOOL seq_AddTextFromFile(const char *pTextName, BOOL bJustify)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-12-27 15:03:09 -08:00
|
|
|
char aTextName[MAX_STR_LENGTH];
|
2006-08-12 09:52:37 -07:00
|
|
|
char *pTextBuffer, *pCurrentLine, *pText;
|
2007-06-28 10:47:08 -07:00
|
|
|
UDWORD fileSize;
|
|
|
|
SDWORD xOffset, yOffset, startFrame, endFrame;
|
2006-09-24 12:11:34 -07:00
|
|
|
const char *seps = "\n";
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-12-27 15:03:09 -08:00
|
|
|
snprintf(aTextName, sizeof(aTextName), "sequenceaudio/%s", pTextName);
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-30 17:28:49 -07:00
|
|
|
if (loadFileToBufferNoError(aTextName, fileLoadBuffer, FILE_LOAD_BUFFER_SIZE, &fileSize) == FALSE) //Did I mention this is lame? -Q
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-06-30 17:28:49 -07:00
|
|
|
pTextBuffer = fileLoadBuffer;
|
2007-06-28 10:47:08 -07:00
|
|
|
pCurrentLine = strtok(pTextBuffer,seps);
|
|
|
|
while(pCurrentLine != NULL)
|
|
|
|
{
|
|
|
|
if (*pCurrentLine != '/')
|
|
|
|
{
|
|
|
|
if (sscanf(pCurrentLine,"%d %d %d %d", &xOffset, &yOffset, &startFrame, &endFrame) == 4)
|
|
|
|
{
|
|
|
|
//get the text
|
|
|
|
pText = strrchr(pCurrentLine,'"');
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( pText != NULL,"seq_AddTextFromFile error parsing text file" );
|
2007-06-28 10:47:08 -07:00
|
|
|
if (pText != NULL)
|
|
|
|
{
|
|
|
|
*pText = (UBYTE)0;
|
|
|
|
}
|
|
|
|
pText = strchr(pCurrentLine,'"');
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( pText != NULL,"seq_AddTextFromFile error parsing text file" );
|
2007-06-28 10:47:08 -07:00
|
|
|
if (pText != NULL)
|
|
|
|
{
|
2006-11-26 03:20:44 -08:00
|
|
|
seq_AddTextForVideo(&pText[1], xOffset, yOffset, startFrame, endFrame, bJustify);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//get next line
|
|
|
|
pCurrentLine = strtok(NULL,seps);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//clear the sequence list
|
|
|
|
void seq_ClearSeqList(void)
|
|
|
|
{
|
|
|
|
SDWORD i;
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
seq_ClearTextForVideo();
|
|
|
|
for(i=0;i<MAX_SEQ_LIST;i++)
|
|
|
|
{
|
|
|
|
aSeqList[i].pSeq = NULL;
|
|
|
|
}
|
|
|
|
currentSeq = -1;
|
|
|
|
currentPlaySeq = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//add a sequence to the list to be played
|
2007-04-13 08:11:03 -07:00
|
|
|
void seq_AddSeqToList(const char *pSeqName, const char *pAudioName, const char *pTextName, BOOL bLoop)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
SDWORD strLen;
|
|
|
|
currentSeq++;
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if ((currentSeq) >= MAX_SEQ_LIST)
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( FALSE, "seq_AddSeqToList: too many sequences" );
|
2007-06-28 10:47:08 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//OK so add it to the list
|
|
|
|
aSeqList[currentSeq].pSeq = pSeqName;
|
|
|
|
aSeqList[currentSeq].pAudio = pAudioName;
|
|
|
|
aSeqList[currentSeq].bSeqLoop = bLoop;
|
2006-02-18 10:54:37 -08:00
|
|
|
if (pTextName != NULL)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
seq_AddTextFromFile(pTextName, FALSE);//SEQ_TEXT_POSITION);//ordinary text not justified
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bSeqSubtitles)
|
|
|
|
{
|
2007-12-27 15:03:09 -08:00
|
|
|
char aSubtitleName[MAX_STR_LENGTH];
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
//check for a subtitle file
|
|
|
|
strLen = strlen(pSeqName);
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( strLen < MAX_STR_LENGTH,"seq_AddSeqToList: sequence name error" );
|
2007-12-27 15:03:09 -08:00
|
|
|
strlcpy(aSubtitleName, pSeqName, sizeof(aSubtitleName));
|
2007-06-28 10:47:08 -07:00
|
|
|
aSubtitleName[strLen - 4] = 0;
|
2007-12-27 15:03:09 -08:00
|
|
|
strlcat(aSubtitleName, ".txt", sizeof(aSubtitleName));
|
2007-06-28 10:47:08 -07:00
|
|
|
seq_AddTextFromFile(aSubtitleName, TRUE);//SEQ_TEXT_JUSTIFY);//subtitles centre justified
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*checks to see if there are any sequences left in the list to play*/
|
|
|
|
BOOL seq_AnySeqLeft(void)
|
|
|
|
{
|
|
|
|
UBYTE nextSeq;
|
|
|
|
|
|
|
|
nextSeq = (UBYTE)(currentPlaySeq+1);
|
|
|
|
|
|
|
|
//check haven't reached end
|
|
|
|
if (nextSeq > MAX_SEQ_LIST)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (aSeqList[nextSeq].pSeq)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-19 17:49:20 -07:00
|
|
|
static void seqDispCDOK( void )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
BOOL bPlayedOK;
|
|
|
|
|
|
|
|
if ( bBackDropWasAlreadyUp == FALSE )
|
|
|
|
{
|
|
|
|
screen_StopBackDrop();
|
|
|
|
}
|
|
|
|
|
|
|
|
currentPlaySeq++;
|
|
|
|
if (currentPlaySeq >= MAX_SEQ_LIST)
|
|
|
|
{
|
|
|
|
bPlayedOK = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-03 04:22:51 -07:00
|
|
|
bPlayedOK = seq_StartFullScreenVideo( aSeqList[currentPlaySeq].pSeq, aSeqList[currentPlaySeq].pAudio );
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bPlayedOK == FALSE )
|
|
|
|
{
|
2006-09-03 04:22:51 -07:00
|
|
|
//don't do the callback if we're playing the win/lose video
|
|
|
|
if (!getScriptWinLoseVideo())
|
|
|
|
{
|
|
|
|
debug(LOG_SCRIPT, "*** Called video quit trigger!");
|
|
|
|
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_VIDEO_QUIT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
displayGameOver(getScriptWinLoseVideo() == PLAY_WIN);
|
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*returns the next sequence in the list to play*/
|
|
|
|
void seq_StartNextFullScreenVideo(void)
|
|
|
|
{
|
|
|
|
seqDispCDOK();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void seq_SetSubtitles(BOOL bNewState)
|
|
|
|
{
|
|
|
|
bSeqSubtitles = bNewState;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_GetSubtitles(void)
|
|
|
|
{
|
|
|
|
return bSeqSubtitles;
|
|
|
|
}
|