diff --git a/Source/engine/render/text_render.cpp b/Source/engine/render/text_render.cpp index bcb7e80dc..8bd51216e 100644 --- a/Source/engine/render/text_render.cpp +++ b/Source/engine/render/text_render.cpp @@ -116,8 +116,46 @@ const uint8_t fontkern[3][68] = { } }; +namespace { + +enum text_color : uint8_t { + COL_WHITE, + COL_BLUE, + COL_RED, + COL_GOLD, + COL_BLACK, +}; + int LineHeights[3] = { 12, 43, 50 }; +uint8_t fontColorTableGold[256]; +uint8_t fontColorTableBlue[256]; +uint8_t fontColorTableRed[256]; + +static void PrintChar(const CelOutputBuffer &out, int sx, int sy, int nCel, text_color col) +{ + switch (col) { + case COL_WHITE: + CelDrawTo(out, sx, sy, *pPanelText, nCel); + return; + case COL_BLUE: + CelDrawLightTo(out, sx, sy, *pPanelText, nCel, fontColorTableBlue); + break; + case COL_RED: + CelDrawLightTo(out, sx, sy, *pPanelText, nCel, fontColorTableRed); + break; + case COL_GOLD: + CelDrawLightTo(out, sx, sy, *pPanelText, nCel, fontColorTableGold); + break; + case COL_BLACK: + light_table_index = 15; + CelDrawLightTo(out, sx, sy, *pPanelText, nCel, nullptr); + return; + } +} + +} // namespace + std::optional pPanelText; /** Graphics for the medium size font */ std::optional pMedTextCels; @@ -125,10 +163,6 @@ std::optional BigTGold_cel; std::optional pSPentSpn2Cels; -uint8_t fontColorTableGold[256]; -uint8_t fontColorTableBlue[256]; -uint8_t fontColorTableRed[256]; - void InitText() { pPanelText = LoadCel("CtrlPan\\SmalText.CEL", 13); @@ -172,28 +206,6 @@ void FreeText() pSPentSpn2Cels = std::nullopt; } -void PrintChar(const CelOutputBuffer &out, int sx, int sy, int nCel, text_color col) -{ - switch (col) { - case COL_WHITE: - CelDrawTo(out, sx, sy, *pPanelText, nCel); - return; - case COL_BLUE: - CelDrawLightTo(out, sx, sy, *pPanelText, nCel, fontColorTableBlue); - break; - case COL_RED: - CelDrawLightTo(out, sx, sy, *pPanelText, nCel, fontColorTableRed); - break; - case COL_GOLD: - CelDrawLightTo(out, sx, sy, *pPanelText, nCel, fontColorTableGold); - break; - case COL_BLACK: - light_table_index = 15; - CelDrawLightTo(out, sx, sy, *pPanelText, nCel, nullptr); - return; - } -} - int GetLineWidth(const char *text, GameFontTables size, int spacing, int *charactersInLine) { int lineWidth = 0; diff --git a/Source/engine/render/text_render.hpp b/Source/engine/render/text_render.hpp index 5126c0918..419be6d7b 100644 --- a/Source/engine/render/text_render.hpp +++ b/Source/engine/render/text_render.hpp @@ -20,14 +20,6 @@ enum GameFontTables : uint8_t { GameFontBig, }; -enum text_color : uint8_t { - COL_WHITE, - COL_BLUE, - COL_RED, - COL_GOLD, - COL_BLACK, -}; - extern const uint8_t gbFontTransTbl[256]; extern const uint8_t fontframe[3][128]; extern const uint8_t fontkern[3][68]; @@ -41,16 +33,6 @@ extern std::optional pSPentSpn2Cels; void InitText(); void FreeText(); -/** - * @brief Print letter to the given buffer - * @param out The buffer to print to - * @param sx Backbuffer offset - * @param sy Backbuffer offset - * @param nCel Number of letter in Windows-1252 - * @param col text_color color value - */ -void PrintChar(const CelOutputBuffer &out, int sx, int sy, int nCel, text_color col); - /** * @brief Calculate pixel width of first line of text, respecting kerning * @param text Text to check, will read until first eol or terminator