Game Development Community

dev|Pro Game Development Curriculum

GuiMessageVectorCtrl text wrap bug fix

by Luigi Rosso · 02/15/2008 (12:23 pm) · 0 comments

I noticed a small bug in TGEA_1_0_3's GuiMessageVectorCtrl. When wrapping text the line breaks always render one extra character at the end of the line. I stepped through the code and the "line break" calculator is good, there was just a small bug in the text rendering in the onRender method. Here's the fix:

Change lines 617-618 from:
strWidth = GFX->drawTextN(mProfile->mFont, globalStart, &mMessageVector->getLine(i).message[walkAcross->start],
                                          walkAcross->end - walkAcross->start + 1, mProfile->mFontColors, mMaxColorIndex);

to:
strWidth = GFX->drawTextN(mProfile->mFont, globalStart, &mMessageVector->getLine(i).message[walkAcross->start],
                                          walkAcross->end - walkAcross->start, mProfile->mFontColors, mMaxColorIndex);

Also change lines 623-624 from:
strWidth = GFX->drawTextN(mProfile->mFont, globalStart, &mMessageVector->getLine(i).message[walkAcross->start],
                                          walkAcross->end - walkAcross->start + 1);

to:
strWidth = GFX->drawTextN(mProfile->mFont, globalStart, &mMessageVector->getLine(i).message[walkAcross->start],
                                          walkAcross->end - walkAcross->start);

This fixed the problem for me. I've tested it in a few scenarios and it works out, don't change it if you don't have a problem with it :-)

About the author

Recent Blogs