Added presentation commands TEXT, TE, MOVIE
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2848 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.7:
|
Changes towards version 0.7:
|
||||||
|
- Added presentaion commands TEXT, TE (text effect), MOVIE - Alex
|
||||||
- Increased the size of display queue (elements were sometimes missing
|
- Increased the size of display queue (elements were sometimes missing
|
||||||
in e.g. Nemesis vs. Nemesis battles with many marines out) - Alex
|
in e.g. Nemesis vs. Nemesis battles with many marines out) - Alex
|
||||||
- ShowPresentation() no longer clears the screen by force; presentations
|
- ShowPresentation() no longer clears the screen by force; presentations
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ FTB 0
|
|||||||
TC FFFFFF
|
TC FFFFFF
|
||||||
#(Set text back color; 0xRRGGBB)
|
#(Set text back color; 0xRRGGBB)
|
||||||
TBC 000000
|
TBC 000000
|
||||||
|
#(Set text effect; Traced, None, others when added)
|
||||||
|
TE TRACED
|
||||||
|
|
||||||
#(Play music)
|
#(Play music)
|
||||||
MUSIC slides/ending/victoryf.mod
|
MUSIC slides/ending/victoryf.mod
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ FTB 0
|
|||||||
TC FFFFFF
|
TC FFFFFF
|
||||||
#(Set text back color; 0xRRGGBB)
|
#(Set text back color; 0xRRGGBB)
|
||||||
TBC 000000
|
TBC 000000
|
||||||
|
#(Set text effect; Traced, None, others when added)
|
||||||
|
TE TRACED
|
||||||
|
|
||||||
#(************ Title Screen ******************************************)
|
#(************ Title Screen ******************************************)
|
||||||
|
|
||||||
|
|||||||
+108
-62
@@ -59,12 +59,16 @@ typedef struct
|
|||||||
COLOR TextColor;
|
COLOR TextColor;
|
||||||
COLOR TextBackColor;
|
COLOR TextBackColor;
|
||||||
int TextVPos;
|
int TextVPos;
|
||||||
|
int TextEffect;
|
||||||
RECT clip_r;
|
RECT clip_r;
|
||||||
RECT tfade_r;
|
RECT tfade_r;
|
||||||
#define MAX_TEXT_LINES 15
|
#define MAX_TEXT_LINES 15
|
||||||
TEXT TextLines[MAX_TEXT_LINES];
|
TEXT TextLines[MAX_TEXT_LINES];
|
||||||
COUNT LinesCount;
|
COUNT LinesCount;
|
||||||
char Buffer[512];
|
char Buffer[512];
|
||||||
|
int MovieFrame;
|
||||||
|
int MovieEndFrame;
|
||||||
|
int InterframeDelay;
|
||||||
|
|
||||||
} PRESENTATION_INPUT_STATE;
|
} PRESENTATION_INPUT_STATE;
|
||||||
|
|
||||||
@@ -161,6 +165,20 @@ DrawTracedText (TEXT *pText, COLOR Fore, COLOR Back)
|
|||||||
font_DrawText (pText);
|
font_DrawText (pText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
DrawTextEffect (TEXT *pText, COLOR Fore, COLOR Back, int Effect)
|
||||||
|
{
|
||||||
|
if (Effect == 'T')
|
||||||
|
{
|
||||||
|
DrawTracedText (pText, Fore, Back);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetContextForeGroundColor (Fore);
|
||||||
|
font_DrawText (pText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static COUNT
|
static COUNT
|
||||||
ParseTextLines (TEXT *Lines, COUNT MaxLines, char* Buffer)
|
ParseTextLines (TEXT *Lines, COUNT MaxLines, char* Buffer)
|
||||||
{
|
{
|
||||||
@@ -295,6 +313,20 @@ Present_GenerateSIS (PRESENTATION_INPUT_STATE* pPIS)
|
|||||||
pPIS->SisFrame = SisFrame;
|
pPIS->SisFrame = SisFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Present_DrawMovieFrame (PRESENTATION_INPUT_STATE* pPIS)
|
||||||
|
{
|
||||||
|
STAMP s;
|
||||||
|
|
||||||
|
s.origin.x = 0;
|
||||||
|
s.origin.y = 0;
|
||||||
|
s.frame = SetAbsFrameIndex (pPIS->Frame, pPIS->MovieFrame);
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
|
SetContextClipping (TRUE);
|
||||||
|
DrawStamp (&s);
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
ShowPresentationFile (const char *name)
|
ShowPresentationFile (const char *name)
|
||||||
{
|
{
|
||||||
@@ -313,10 +345,23 @@ DoPresentation (void *pIS)
|
|||||||
|
|
||||||
if (pPIS->TimeOut)
|
if (pPIS->TimeOut)
|
||||||
{
|
{
|
||||||
if (GetTimeCounter () > pPIS->TimeOut)
|
TimeCount Delay = ONE_SECOND / 84;
|
||||||
{ /* time elapsed - continue normal ops */
|
|
||||||
pPIS->TimeOut = 0;
|
if (GetTimeCounter () >= pPIS->TimeOut)
|
||||||
return TRUE;
|
{
|
||||||
|
if (pPIS->MovieFrame >= 0)
|
||||||
|
{ /* Movie mode */
|
||||||
|
Present_DrawMovieFrame (pPIS);
|
||||||
|
++pPIS->MovieFrame;
|
||||||
|
if (pPIS->MovieFrame > pPIS->MovieEndFrame)
|
||||||
|
pPIS->MovieFrame = -1; /* movie is done */
|
||||||
|
Delay = pPIS->InterframeDelay;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* time elapsed - continue normal ops */
|
||||||
|
pPIS->TimeOut = 0;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pPIS->TimeOutOnSkip &&
|
if (pPIS->TimeOutOnSkip &&
|
||||||
@@ -325,10 +370,11 @@ DoPresentation (void *pIS)
|
|||||||
|| PulsedInputState.menu[KEY_MENU_RIGHT]) )
|
|| PulsedInputState.menu[KEY_MENU_RIGHT]) )
|
||||||
{ /* skip requested - continue normal ops */
|
{ /* skip requested - continue normal ops */
|
||||||
pPIS->TimeOut = 0;
|
pPIS->TimeOut = 0;
|
||||||
|
pPIS->MovieFrame = -1; /* abort any movie in progress */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SleepThread (ONE_SECOND / 84);
|
SleepThread (Delay);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,48 +498,33 @@ DoPresentation (void *pIS)
|
|||||||
{ /* text vertical align */
|
{ /* text vertical align */
|
||||||
pPIS->TextVPos = toupper (*pStr);
|
pPIS->TextVPos = toupper (*pStr);
|
||||||
}
|
}
|
||||||
|
else if (strcmp (Opcode, "TE") == 0)
|
||||||
|
{ /* text vertical align */
|
||||||
|
pPIS->TextEffect = toupper (*pStr);
|
||||||
|
}
|
||||||
else if (strcmp (Opcode, "TEXT") == 0)
|
else if (strcmp (Opcode, "TEXT") == 0)
|
||||||
{ /* simple text draw */
|
{ /* simple text draw */
|
||||||
SIZE leading;
|
int x, y;
|
||||||
COUNT i;
|
|
||||||
COORD y;
|
|
||||||
|
|
||||||
utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr);
|
|
||||||
pPIS->LinesCount = ParseTextLines (pPIS->TextLines,
|
|
||||||
MAX_TEXT_LINES, pPIS->Buffer);
|
|
||||||
|
|
||||||
if (!pPIS->Batched)
|
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
GetContextFontLeading (&leading);
|
|
||||||
if (!pPIS->Batched)
|
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
switch (pPIS->TextVPos)
|
|
||||||
{
|
|
||||||
case 'T': /* top */
|
|
||||||
y = leading;
|
|
||||||
break;
|
|
||||||
case 'M': /* middle */
|
|
||||||
y = (pPIS->clip_r.extent.height
|
|
||||||
- pPIS->LinesCount * leading) / 2;
|
|
||||||
break;
|
|
||||||
default: /* bottom */
|
|
||||||
y = pPIS->clip_r.extent.height - pPIS->LinesCount * leading;
|
|
||||||
}
|
|
||||||
for (i = 0; i < pPIS->LinesCount; ++i, y += leading)
|
|
||||||
{
|
|
||||||
pPIS->TextLines[i].align = ALIGN_CENTER;
|
|
||||||
pPIS->TextLines[i].baseline.x = SCREEN_WIDTH / 2;
|
|
||||||
pPIS->TextLines[i].baseline.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pPIS->Batched)
|
assert (sizeof (pPIS->Buffer) >= 256);
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
SetContextClipping (TRUE);
|
if (3 == sscanf (pStr, "%d %d %255[^\n]", &x, &y, pPIS->Buffer))
|
||||||
for (i = 0; i < pPIS->LinesCount; ++i)
|
{
|
||||||
DrawTracedText (pPIS->TextLines + i,
|
TEXT t;
|
||||||
pPIS->TextColor, pPIS->TextBackColor);
|
|
||||||
if (!pPIS->Batched)
|
t.align = ALIGN_LEFT;
|
||||||
UnlockMutex (GraphicsLock);
|
t.pStr = pPIS->Buffer;
|
||||||
|
t.CharCount = (COUNT)~0;
|
||||||
|
t.baseline.x = x;
|
||||||
|
t.baseline.y = y;
|
||||||
|
if (!pPIS->Batched)
|
||||||
|
LockMutex (GraphicsLock);
|
||||||
|
SetContextClipping (TRUE);
|
||||||
|
DrawTextEffect (&t, pPIS->TextColor, pPIS->TextBackColor,
|
||||||
|
pPIS->TextEffect);
|
||||||
|
if (!pPIS->Batched)
|
||||||
|
UnlockMutex (GraphicsLock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp (Opcode, "TFI") == 0)
|
else if (strcmp (Opcode, "TFI") == 0)
|
||||||
{ /* text fade-in */
|
{ /* text fade-in */
|
||||||
@@ -536,15 +567,15 @@ DoPresentation (void *pIS)
|
|||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
SetContextClipping (TRUE);
|
SetContextClipping (TRUE);
|
||||||
for (i = 0; i < pPIS->LinesCount; ++i)
|
for (i = 0; i < pPIS->LinesCount; ++i)
|
||||||
DrawTracedText (pPIS->TextLines + i,
|
DrawTextEffect (pPIS->TextLines + i, pPIS->TextFadeColor,
|
||||||
pPIS->TextFadeColor, pPIS->TextFadeColor);
|
pPIS->TextFadeColor, pPIS->TextEffect);
|
||||||
|
|
||||||
/* do transition */
|
/* do transition */
|
||||||
SetTransitionSource (&pPIS->tfade_r);
|
SetTransitionSource (&pPIS->tfade_r);
|
||||||
BatchGraphics ();
|
BatchGraphics ();
|
||||||
for (i = 0; i < pPIS->LinesCount; ++i)
|
for (i = 0; i < pPIS->LinesCount; ++i)
|
||||||
DrawTracedText (pPIS->TextLines + i,
|
DrawTextEffect (pPIS->TextLines + i, pPIS->TextColor,
|
||||||
pPIS->TextColor, pPIS->TextBackColor);
|
pPIS->TextBackColor, pPIS->TextEffect);
|
||||||
ScreenTransition (3, &pPIS->tfade_r);
|
ScreenTransition (3, &pPIS->tfade_r);
|
||||||
UnbatchGraphics ();
|
UnbatchGraphics ();
|
||||||
|
|
||||||
@@ -562,8 +593,8 @@ DoPresentation (void *pIS)
|
|||||||
SetTransitionSource (&pPIS->tfade_r);
|
SetTransitionSource (&pPIS->tfade_r);
|
||||||
BatchGraphics ();
|
BatchGraphics ();
|
||||||
for (i = 0; i < pPIS->LinesCount; ++i)
|
for (i = 0; i < pPIS->LinesCount; ++i)
|
||||||
DrawTracedText (pPIS->TextLines + i,
|
DrawTextEffect (pPIS->TextLines + i, pPIS->TextFadeColor,
|
||||||
pPIS->TextFadeColor, pPIS->TextFadeColor);
|
pPIS->TextFadeColor, pPIS->TextEffect);
|
||||||
ScreenTransition (3, &pPIS->tfade_r);
|
ScreenTransition (3, &pPIS->tfade_r);
|
||||||
UnbatchGraphics ();
|
UnbatchGraphics ();
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
@@ -708,7 +739,6 @@ DoPresentation (void *pIS)
|
|||||||
int x1, x2, y1, y2;
|
int x1, x2, y1, y2;
|
||||||
if (4 == sscanf (pStr, "%d %d %d %d", &x1, &y1, &x2, &y2))
|
if (4 == sscanf (pStr, "%d %d %d %d", &x1, &y1, &x2, &y2))
|
||||||
{
|
{
|
||||||
COLOR old_color;
|
|
||||||
LINE l;
|
LINE l;
|
||||||
|
|
||||||
l.first.x = x1;
|
l.first.x = x1;
|
||||||
@@ -718,9 +748,8 @@ DoPresentation (void *pIS)
|
|||||||
|
|
||||||
if (!pPIS->Batched)
|
if (!pPIS->Batched)
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
old_color = SetContextForeGroundColor (pPIS->TextColor);
|
SetContextForeGroundColor (pPIS->TextColor);
|
||||||
DrawLine (&l);
|
DrawLine (&l);
|
||||||
SetContextForeGroundColor (old_color);
|
|
||||||
if (!pPIS->Batched)
|
if (!pPIS->Batched)
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
@@ -729,6 +758,28 @@ DoPresentation (void *pIS)
|
|||||||
log_add (log_Warning, "Bad LINE command '%s'", pStr);
|
log_add (log_Warning, "Bad LINE command '%s'", pStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strcmp (Opcode, "MOVIE") == 0)
|
||||||
|
{
|
||||||
|
int fps, from, to;
|
||||||
|
|
||||||
|
if (3 == sscanf (pStr, "%d %d %d", &fps, &from, &to) &&
|
||||||
|
fps > 0 && from >= 0 && to >= 0 && to >= from)
|
||||||
|
{
|
||||||
|
Present_UnbatchGraphics (pPIS, TRUE);
|
||||||
|
|
||||||
|
pPIS->MovieFrame = from;
|
||||||
|
pPIS->MovieEndFrame = to;
|
||||||
|
pPIS->InterframeDelay = ONE_SECOND / fps;
|
||||||
|
|
||||||
|
pPIS->TimeOut = GetTimeCounter ();
|
||||||
|
pPIS->TimeOutOnSkip = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_add (log_Warning, "Bad MOVIE command '%s'", pStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (strcmp (Opcode, "NOOP") == 0)
|
else if (strcmp (Opcode, "NOOP") == 0)
|
||||||
{ /* no operation - must be a comment in script */
|
{ /* no operation - must be a comment in script */
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
@@ -746,6 +797,7 @@ ShowPresentation (STRING PresStr)
|
|||||||
RECT OldRect;
|
RECT OldRect;
|
||||||
PRESENTATION_INPUT_STATE pis;
|
PRESENTATION_INPUT_STATE pis;
|
||||||
|
|
||||||
|
memset (&pis, 0, sizeof(pis));
|
||||||
pis.SlideShow = PresStr;
|
pis.SlideShow = PresStr;
|
||||||
if (!pis.SlideShow)
|
if (!pis.SlideShow)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -762,17 +814,11 @@ ShowPresentation (STRING PresStr)
|
|||||||
SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);
|
SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);
|
||||||
pis.MenuRepeatDelay = 0;
|
pis.MenuRepeatDelay = 0;
|
||||||
pis.InputFunc = DoPresentation;
|
pis.InputFunc = DoPresentation;
|
||||||
pis.Font = 0;
|
|
||||||
pis.Frame = 0;
|
|
||||||
pis.RotatedFrame = 0;
|
|
||||||
pis.LastDrawKind = -1;
|
pis.LastDrawKind = -1;
|
||||||
pis.LastAngle = 0;
|
|
||||||
pis.MusicRef = 0;
|
|
||||||
pis.SisFrame = 0;
|
|
||||||
pis.Batched = FALSE;
|
|
||||||
pis.TextVPos = 'B';
|
pis.TextVPos = 'B';
|
||||||
pis.LastSyncTime = pis.StartTime = GetTimeCounter ();
|
pis.MovieFrame = -1;
|
||||||
pis.TimeOut = 0;
|
pis.StartTime = GetTimeCounter ();
|
||||||
|
pis.LastSyncTime = pis.StartTime;
|
||||||
DoInput (&pis, TRUE);
|
DoInput (&pis, TRUE);
|
||||||
|
|
||||||
SleepThreadUntil (FadeMusic (0, ONE_SECOND));
|
SleepThreadUntil (FadeMusic (0, ONE_SECOND));
|
||||||
|
|||||||
Reference in New Issue
Block a user