diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 9e4f32ab6..55ece5dc7 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.7: +- DrawTracedText abstraction (bug #1029), from Nic - Experimental support for Symbian S60 3rd edition - Mika & SvdB - Pthread support - Mika - Content Dirs completely reorganized; 3DO and PC segregation - Coredev diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index 212723eed..23ea5cc43 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -250,30 +250,8 @@ add_text (int status, TEXT *pTextIn) else { // Alien speech - - // Draw the background by drawing the same text in the - // background color one pixel shifted to all 4 directions. - SetContextForeGroundColor (CommData.AlienTextBColor); - - --pText->baseline.x; - font_DrawText (pText); - - ++pText->baseline.x; - --pText->baseline.y; - font_DrawText (pText); - - ++pText->baseline.x; - ++pText->baseline.y; - font_DrawText (pText); - - --pText->baseline.x; - ++pText->baseline.y; - font_DrawText (pText); - - SetContextForeGroundColor (CommData.AlienTextFColor); - - --pText->baseline.y; - font_DrawText (pText); + font_DrawTracedText (pText, + CommData.AlienTextFColor, CommData.AlienTextBColor); } } while (!eol && maxchars); pText->pStr = pStr; diff --git a/sc2/src/sc2code/intro.c b/sc2/src/sc2code/intro.c index 1b2c5bd7c..ff9e26785 100644 --- a/sc2/src/sc2code/intro.c +++ b/sc2/src/sc2code/intro.c @@ -148,30 +148,12 @@ DoFadeScreen (PRESENTATION_INPUT_STATE* pPIS, const char *Src, BYTE FadeType) return TRUE; } -static void -DrawTracedText (TEXT *pText, COLOR Fore, COLOR Back) -{ - SetContextForeGroundColor (Back); - pText->baseline.x--; - font_DrawText (pText); - pText->baseline.x += 2; - font_DrawText (pText); - pText->baseline.x--; - pText->baseline.y--; - font_DrawText (pText); - pText->baseline.y += 2; - font_DrawText (pText); - pText->baseline.y--; - SetContextForeGroundColor (Fore); - font_DrawText (pText); -} - static void DrawTextEffect (TEXT *pText, COLOR Fore, COLOR Back, int Effect) { if (Effect == 'T') { - DrawTracedText (pText, Fore, Back); + font_DrawTracedText (pText, Fore, Back); } else { diff --git a/sc2/src/sc2code/libs/gfxlib.h b/sc2/src/sc2code/libs/gfxlib.h index 26740005b..3b8a32365 100644 --- a/sc2/src/sc2code/libs/gfxlib.h +++ b/sc2/src/sc2code/libs/gfxlib.h @@ -183,6 +183,7 @@ extern void DrawRectangle (RECT *pRect); extern void DrawFilledRectangle (RECT *pRect); extern void DrawLine (LINE *pLine); extern void font_DrawText (TEXT *pText); +extern void font_DrawTracedText (TEXT *pText, COLOR text, COLOR trace); extern void DrawBatch (PRIMITIVE *pBasePrim, PRIM_LINKS PrimLinks, BATCH_FLAGS BatchFlags); extern void BatchGraphics (void); diff --git a/sc2/src/sc2code/libs/graphics/font.c b/sc2/src/sc2code/libs/graphics/font.c index ac355e1fa..c3c2f4f06 100644 --- a/sc2/src/sc2code/libs/graphics/font.c +++ b/sc2/src/sc2code/libs/graphics/font.c @@ -62,6 +62,30 @@ font_DrawText (TEXT *lpText) DrawBatch (&_locPrim, 0, BATCH_SINGLE); } + +/* Draw the stroke by drawing the same text in the + * background color one pixel shifted to all 4 directions. + */ +void +font_DrawTracedText (TEXT *pText, COLOR text, COLOR trace) +{ + // Preserve current foreground color for full correctness + COLOR oldfg = SetContextForeGroundColor (trace); + pText->baseline.x--; + font_DrawText (pText); + pText->baseline.x += 2; + font_DrawText (pText); + pText->baseline.x--; + pText->baseline.y--; + font_DrawText (pText); + pText->baseline.y += 2; + font_DrawText (pText); + pText->baseline.y--; + SetContextForeGroundColor (text); + font_DrawText (pText); + SetContextForeGroundColor (oldfg); +} + BOOLEAN GetContextFontLeading (SIZE *pheight) {