From ab2633dca68e869c60598a4f9835c64bda1d9140 Mon Sep 17 00:00:00 2001 From: avolkov Date: Sat, 8 Sep 2007 01:52:03 +0000 Subject: [PATCH] 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 --- sc2/content/slides/ending/final.txt | 2 +- sc2/content/slides/intro/intro.txt | 9 ++++++-- sc2/src/sc2code/intro.c | 35 ++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/sc2/content/slides/ending/final.txt b/sc2/content/slides/ending/final.txt index 5d9f8de89..0ee06ca22 100644 --- a/sc2/content/slides/ending/final.txt +++ b/sc2/content/slides/ending/final.txt @@ -25,7 +25,7 @@ MUSIC slides/ending/victoryf.mod #(************* Slides *********************************************) #(Set font to use) -FONT slides/slides.fon +FONT 0 slides/slides.fon #(Set ANIM to draw slides from) ANI slides/ending/ending.ani diff --git a/sc2/content/slides/intro/intro.txt b/sc2/content/slides/intro/intro.txt index 135b94fcc..95da371f3 100644 --- a/sc2/content/slides/intro/intro.txt +++ b/sc2/content/slides/intro/intro.txt @@ -25,12 +25,17 @@ TBC 000000 #(Set text effect; Traced, None, others when added) 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 1 +++++++++++++++++++++++++++++++++) #(Set font to use) -FONT lbm/starcon.fon +FONT 0 #(Set ANIM to draw slides from) ANI slides/intro/title.ani @@ -98,7 +103,7 @@ FTB 3000 #(************* Slides *********************************************) #(Set font to use) -FONT slides/slides.fon +FONT 1 #(Set ANIM to draw slides from) ANI slides/intro/intro.ani diff --git a/sc2/src/sc2code/intro.c b/sc2/src/sc2code/intro.c index 8427527ac..f195f5f76 100644 --- a/sc2/src/sc2code/intro.c +++ b/sc2/src/sc2code/intro.c @@ -46,7 +46,8 @@ typedef struct TimeCount TimeOut; int TimeOutOnSkip; STRING SlideShow; - FONT Font; +#define MAX_FONTS 5 + FONT Fonts[MAX_FONTS]; FRAME Frame; MUSIC_REF MusicRef; BOOLEAN Batched; @@ -411,15 +412,31 @@ DoPresentation (void *pIS) } } else if (strcmp (Opcode, "FONT") == 0) - { /* set font */ - utf8StringCopy (pPIS->Buffer, sizeof (pPIS->Buffer), pStr); - if (pPIS->Font) - DestroyFont (ReleaseFont (pPIS->Font)); - pPIS->Font = CaptureFont ((FONT_REF) LoadFontFile (pPIS->Buffer)); + { /* set and/or load a font */ + int index; + FONT *pFont; + + 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) LockMutex (GraphicsLock); - SetContextFont (pPIS->Font); + SetContextFont (*pFont); if (!pPIS->Batched) UnlockMutex (GraphicsLock); } @@ -796,6 +813,7 @@ ShowPresentation (STRING PresStr) FONT OldFont; RECT OldRect; PRESENTATION_INPUT_STATE pis; + int i; memset (&pis, 0, sizeof(pis)); pis.SlideShow = PresStr; @@ -828,7 +846,8 @@ ShowPresentation (STRING PresStr) DestroyMusic (pis.MusicRef); DestroyDrawable (ReleaseDrawable (pis.RotatedFrame)); DestroyDrawable (ReleaseDrawable (pis.Frame)); - DestroyFont (ReleaseFont (pis.Font)); + for (i = 0; i < MAX_FONTS; ++i) + DestroyFont (ReleaseFont (pis.Fonts[i])); DestroyStringTable (ReleaseStringTable (pis.SlideShow)); LockMutex (GraphicsLock);