Render chat panel using common text rendering
This commit is contained in:
parent
d723ebce1a
commit
a03a2c2634
3 changed files with 21 additions and 40 deletions
|
|
@ -268,7 +268,7 @@ void WordWrapGameString(char *text, size_t width, size_t size, int spacing)
|
|||
/**
|
||||
* @todo replace SDL_Rect with croped CelOutputBuffer
|
||||
*/
|
||||
void DrawString(const CelOutputBuffer &out, const char *text, const SDL_Rect &rect, uint16_t flags, int spacing, int lineHeight, bool drawTextCursor)
|
||||
int DrawString(const CelOutputBuffer &out, const char *text, const SDL_Rect &rect, uint16_t flags, int spacing, int lineHeight, bool drawTextCursor)
|
||||
{
|
||||
GameFontTables size = GameFontSmall;
|
||||
if ((flags & UIS_MED) != 0)
|
||||
|
|
@ -313,10 +313,15 @@ void DrawString(const CelOutputBuffer &out, const char *text, const SDL_Rect &re
|
|||
if (lineHeight == -1)
|
||||
lineHeight = LineHeights[size];
|
||||
|
||||
for (unsigned i = 0; i < textLength; i++) {
|
||||
unsigned i = 0;
|
||||
for (; i < textLength; i++) {
|
||||
uint8_t frame = fontframe[size][gbFontTransTbl[static_cast<uint8_t>(text[i])]];
|
||||
int symbolWidth = fontkern[size][frame];
|
||||
if (text[i] == '\n' || sx + symbolWidth > rightMargin) {
|
||||
if (sy + lineHeight >= bottomMargin)
|
||||
break;
|
||||
sy += lineHeight;
|
||||
|
||||
if ((flags & (UIS_CENTER | UIS_RIGHT | UIS_FIT_SPACING)) != 0)
|
||||
lineWidth = GetLineWidth(&text[i + 1], size, spacing, &charactersInLine);
|
||||
|
||||
|
|
@ -328,9 +333,6 @@ void DrawString(const CelOutputBuffer &out, const char *text, const SDL_Rect &re
|
|||
sx += (w - lineWidth) / 2;
|
||||
else if ((flags & UIS_RIGHT) != 0)
|
||||
sx += w - lineWidth;
|
||||
sy += lineHeight;
|
||||
if (sy > bottomMargin)
|
||||
return;
|
||||
}
|
||||
if (frame != 0) {
|
||||
PrintChar(out, sx, sy, frame, color);
|
||||
|
|
@ -341,6 +343,8 @@ void DrawString(const CelOutputBuffer &out, const char *text, const SDL_Rect &re
|
|||
if (drawTextCursor) {
|
||||
CelDrawTo(out, sx, sy, *pSPentSpn2Cels, PentSpn2Spin());
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int PentSpn2Spin()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue