Allow multiple FONTs to be used in presentations at the same time

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2850 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2007-09-08 01:52:03 +00:00
parent 00dad6a7b0
commit ab2633dca6
3 changed files with 35 additions and 11 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ MUSIC slides/ending/victoryf.mod
#(************* Slides *********************************************) #(************* Slides *********************************************)
#(Set font to use) #(Set font to use)
FONT slides/slides.fon FONT 0 slides/slides.fon
#(Set ANIM to draw slides from) #(Set ANIM to draw slides from)
ANI slides/ending/ending.ani ANI slides/ending/ending.ani
+7 -2
View File
@@ -25,12 +25,17 @@ TBC 000000
#(Set text effect; Traced, None, others when added) #(Set text effect; Traced, None, others when added)
TE TRACED TE TRACED
#(Load font to use later)
FONT 0 lbm/starcon.fon
#(Load font to use later)
FONT 1 slides/slides.fon
#(************ Title Screen ******************************************) #(************ Title Screen ******************************************)
#(+++++++++++ Title 1 +++++++++++++++++++++++++++++++++) #(+++++++++++ Title 1 +++++++++++++++++++++++++++++++++)
#(Set font to use) #(Set font to use)
FONT lbm/starcon.fon FONT 0
#(Set ANIM to draw slides from) #(Set ANIM to draw slides from)
ANI slides/intro/title.ani ANI slides/intro/title.ani
@@ -98,7 +103,7 @@ FTB 3000
#(************* Slides *********************************************) #(************* Slides *********************************************)
#(Set font to use) #(Set font to use)
FONT slides/slides.fon FONT 1
#(Set ANIM to draw slides from) #(Set ANIM to draw slides from)
ANI slides/intro/intro.ani ANI slides/intro/intro.ani
+27 -8
View File
@@ -46,7 +46,8 @@ typedef struct
TimeCount TimeOut; TimeCount TimeOut;
int TimeOutOnSkip; int TimeOutOnSkip;
STRING SlideShow; STRING SlideShow;
FONT Font; #define MAX_FONTS 5
FONT Fonts[MAX_FONTS];
FRAME Frame; FRAME Frame;
MUSIC_REF MusicRef; MUSIC_REF MusicRef;
BOOLEAN Batched; BOOLEAN Batched;
@@ -411,15 +412,31 @@ DoPresentation (void *pIS)
} }
} }
else if (strcmp (Opcode, "FONT") == 0) else if (strcmp (Opcode, "FONT") == 0)
{ /* set font */ { /* set and/or load a font */
utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr); int index;
if (pPIS->Font) FONT *pFont;
DestroyFont (ReleaseFont (pPIS->Font));
pPIS->Font = CaptureFont ((FONT_REF) LoadFontFile (pPIS->Buffer)); assert (sizeof (pPIS->Buffer) >= 256);
pPIS->Buffer[0] = '\0';
if (1 > sscanf (pStr, "%d %255[^\n]", &index, pPIS->Buffer) ||
index < 0 || index >= MAX_FONTS)
{
log_add (log_Warning, "Bad FONT command '%s'", pStr);
continue;
}
pFont = &pPIS->Fonts[index];
if (pPIS->Buffer[0])
{ /* asked to load a font */
if (*pFont)
DestroyFont (ReleaseFont (*pFont));
*pFont = CaptureFont ((FONT_REF) LoadFontFile (pPIS->Buffer));
}
if (!pPIS->Batched) if (!pPIS->Batched)
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
SetContextFont (pPIS->Font); SetContextFont (*pFont);
if (!pPIS->Batched) if (!pPIS->Batched)
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
@@ -796,6 +813,7 @@ ShowPresentation (STRING PresStr)
FONT OldFont; FONT OldFont;
RECT OldRect; RECT OldRect;
PRESENTATION_INPUT_STATE pis; PRESENTATION_INPUT_STATE pis;
int i;
memset (&pis, 0, sizeof(pis)); memset (&pis, 0, sizeof(pis));
pis.SlideShow = PresStr; pis.SlideShow = PresStr;
@@ -828,7 +846,8 @@ ShowPresentation (STRING PresStr)
DestroyMusic (pis.MusicRef); DestroyMusic (pis.MusicRef);
DestroyDrawable (ReleaseDrawable (pis.RotatedFrame)); DestroyDrawable (ReleaseDrawable (pis.RotatedFrame));
DestroyDrawable (ReleaseDrawable (pis.Frame)); DestroyDrawable (ReleaseDrawable (pis.Frame));
DestroyFont (ReleaseFont (pis.Font)); for (i = 0; i < MAX_FONTS; ++i)
DestroyFont (ReleaseFont (pis.Fonts[i]));
DestroyStringTable (ReleaseStringTable (pis.SlideShow)); DestroyStringTable (ReleaseStringTable (pis.SlideShow));
LockMutex (GraphicsLock); LockMutex (GraphicsLock);