* Move the SEQ_TEXT_.* constants into an enum: SEQ_TEXT_POSITIONING

* Use this enum as parameter type instead of mixed SDWORD and BOOLs (BOOLs are serious abuse here!!!)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6165 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-10-15 15:35:26 +00:00
parent e5183abb69
commit e4db079de7
2 changed files with 32 additions and 15 deletions

View File

@ -306,7 +306,7 @@ BOOL seq_UpdateFullScreenVideo(int *pbClear)
{ {
if (aSeqList[currentPlaySeq].aText[i].pText[0] != '\0') if (aSeqList[currentPlaySeq].aText[i].pText[0] != '\0')
{ {
if (aSeqList[currentPlaySeq].aText[i].bSubtitle == true) if (aSeqList[currentPlaySeq].aText[i].bSubtitle)
{ {
if ((realFrame >= aSeqList[currentPlaySeq].aText[i].startFrame) && (realFrame <= aSeqList[currentPlaySeq].aText[i].endFrame)) if ((realFrame >= aSeqList[currentPlaySeq].aText[i].startFrame) && (realFrame <= aSeqList[currentPlaySeq].aText[i].endFrame))
{ {
@ -452,7 +452,7 @@ BOOL seq_StopFullScreenVideo(void)
#define MIN_JUSTIFICATION 40 #define MIN_JUSTIFICATION 40
// add a string at x,y or add string below last line if x and y are 0 // add a string at x,y or add string below last line if x and y are 0
BOOL seq_AddTextForVideo(const char* pText, SDWORD xOffset, SDWORD yOffset, SDWORD startFrame, SDWORD endFrame, SDWORD bJustify) BOOL seq_AddTextForVideo(const char* pText, SDWORD xOffset, SDWORD yOffset, SDWORD startFrame, SDWORD endFrame, SEQ_TEXT_POSITIONING textJustification)
{ {
SDWORD sourceLength, currentLength; SDWORD sourceLength, currentLength;
char* currentText; char* currentText;
@ -512,15 +512,18 @@ BOOL seq_AddTextForVideo(const char* pText, SDWORD xOffset, SDWORD yOffset, SDWO
} }
lastX = aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x; lastX = aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x;
if ((bJustify) && (currentLength == sourceLength)) if (textJustification
&& currentLength == sourceLength)
{ {
//justify this text //justify this text
justification = BUFFER_WIDTH - iV_GetTextWidth(currentText); justification = BUFFER_WIDTH - iV_GetTextWidth(currentText);
if ((bJustify == SEQ_TEXT_JUSTIFY) && (justification > MIN_JUSTIFICATION)) if (textJustification == SEQ_TEXT_JUSTIFY
&& justification > MIN_JUSTIFICATION)
{ {
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x += (justification/2); aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x += (justification/2);
} }
else if ((bJustify == SEQ_TEXT_FOLLOW_ON) && (justification > FOLLOW_ON_JUSTIFICATION)) else if (textJustification == SEQ_TEXT_FOLLOW_ON
&& justification > FOLLOW_ON_JUSTIFICATION)
{ {
} }
@ -530,7 +533,7 @@ BOOL seq_AddTextForVideo(const char* pText, SDWORD xOffset, SDWORD yOffset, SDWO
//set start and finish times for the objects //set start and finish times for the objects
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].startFrame = startFrame; aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].startFrame = startFrame;
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].endFrame = endFrame; aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].endFrame = endFrame;
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].bSubtitle = bJustify; aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].bSubtitle = textJustification;
aSeqList[currentSeq].currentText++; aSeqList[currentSeq].currentText++;
if (aSeqList[currentSeq].currentText >= MAX_TEXT_OVERLAYS) if (aSeqList[currentSeq].currentText >= MAX_TEXT_OVERLAYS)
@ -542,11 +545,11 @@ BOOL seq_AddTextForVideo(const char* pText, SDWORD xOffset, SDWORD yOffset, SDWO
if (currentLength < sourceLength) if (currentLength < sourceLength)
{ {
//RECURSE x= 0 y = 0 for nextLine //RECURSE x= 0 y = 0 for nextLine
if (bJustify == SEQ_TEXT_JUSTIFY) if (textJustification == SEQ_TEXT_JUSTIFY)
{ {
bJustify = SEQ_TEXT_POSITION; textJustification = SEQ_TEXT_POSITION;
} }
seq_AddTextForVideo(&pText[currentLength + 1], 0, 0, startFrame, endFrame, bJustify); seq_AddTextForVideo(&pText[currentLength + 1], 0, 0, startFrame, endFrame, textJustification);
} }
return true; return true;
} }
@ -571,7 +574,7 @@ BOOL seq_ClearTextForVideo(void)
return true; return true;
} }
static BOOL seq_AddTextFromFile(const char *pTextName, BOOL bJustify) static BOOL seq_AddTextFromFile(const char *pTextName, SEQ_TEXT_POSITIONING textJustification)
{ {
char aTextName[MAX_STR_LENGTH]; char aTextName[MAX_STR_LENGTH];
char *pTextBuffer, *pCurrentLine, *pText; char *pTextBuffer, *pCurrentLine, *pText;
@ -616,7 +619,7 @@ static BOOL seq_AddTextFromFile(const char *pTextName, BOOL bJustify)
ASSERT( pText != NULL,"seq_AddTextFromFile error parsing text file" ); ASSERT( pText != NULL,"seq_AddTextFromFile error parsing text file" );
if (pText != NULL) if (pText != NULL)
{ {
seq_AddTextForVideo(&pText[1], xOffset, yOffset, startFrame, endFrame, bJustify); seq_AddTextForVideo(&pText[1], xOffset, yOffset, startFrame, endFrame, textJustification);
} }
} }
} }

View File

@ -39,9 +39,23 @@
#define SEQUENCE_KILL 3//stop #define SEQUENCE_KILL 3//stop
#define SEQUENCE_HOLD 4//play once and hold last frame #define SEQUENCE_HOLD 4//play once and hold last frame
#define SEQ_TEXT_POSITION 0//position text typedef enum
#define SEQ_TEXT_FOLLOW_ON 1//justify if less than 3/4 length {
#define SEQ_TEXT_JUSTIFY 2//justify if less than 520/600 /**
* Position text.
*/
SEQ_TEXT_POSITION,
/**
* Justify if less than 3/4 length.
*/
SEQ_TEXT_FOLLOW_ON,
/**
* Justify if less than 520/600 length.
*/
SEQ_TEXT_JUSTIFY,
} SEQ_TEXT_POSITIONING;
/***************************************************************************/ /***************************************************************************/
/* /*
@ -63,7 +77,7 @@ extern BOOL seq_StopFullScreenVideo(void);
//control //control
extern BOOL seq_GetVideoSize(SDWORD* pWidth, SDWORD* pHeight); extern BOOL seq_GetVideoSize(SDWORD* pWidth, SDWORD* pHeight);
//text //text
extern BOOL seq_AddTextForVideo(const char* pText, SDWORD xOffset, SDWORD yOffset, SDWORD startTime, SDWORD endTime, SDWORD bJustify); extern BOOL seq_AddTextForVideo(const char* pText, SDWORD xOffset, SDWORD yOffset, SDWORD startTime, SDWORD endTime, SEQ_TEXT_POSITIONING textJustification);
extern BOOL seq_ClearTextForVideo(void); extern BOOL seq_ClearTextForVideo(void);
//clear the sequence list //clear the sequence list
extern void seq_ClearSeqList(void); extern void seq_ClearSeqList(void);