void TypewriterText::Draw(CDisplay& DisplayRef) { for(int i = 0, k = 0; k < mFirstLine && i < mStringLength; i++) { if(mString[i] == '\n') k++; } if(i >= mStringLength){ return; //UH, WHAT? } Font* OurFont = GetFontBySizeIndex(mFontNumber); if(!OurFont) return; //WE'RE AT OUR STARTING POINT. POINT Origin; Origin.x = mXOrigin; Origin.y = mYOrigin; int DrawnLines = 1; for(; i < mCurrentStringPosition && DrawnLines <= mMaxLinesToDraw; i++) { if(mString[i] == '\n'){ Origin.y += OurFont->GetCharHeight(); DrawnLines++; Origin.x = mXOrigin; } else{ Origin.x += OurFont->DrawLetter(mString[i], Origin); } } //WE'RE AT THE CURSOR POSITION. if(mCursorSpriteNumber == -1 || mCursorFlashDelay == -1){ return; } if(Origin.x + mCursorSprite.GetWidth() > mWidth + mXOrigin){ Origin.y += OurFont->GetCharHeight(); } mCursorSprite.SetLoc(Origin); if(mCursorOn) mCursorSprite.Draw(DisplayRef); }
void BriefingBox::Init() { mBoxSprite.InitializeSpriteCopy(GetGlobalSpriteData(BRIEFINGBOX_SPRITE_NUMBER)); mBoxSprite.SetDelay(800); RECT Client; GetClientRect(TheDisplay.GetHWnd(), &Client); mCenterToStop = ((Client.right - Client.left) / 2) - (mBoxSprite.GetWidth() / 2); int MaxLines = 10; Font* TheFont = GetFontBySizeIndex(BRIEFINGBOX_TEXT_FONTNUMBER); if(TheFont){ int Height = (mBoxSprite.GetHeight() - BRIEFINGBOX_TEXT_BOTTOM) - BRIEFINGBOX_TEXT_YOFFSET; MaxLines = Height / TheFont->GetCharHeight(); } mCenterToClose = mBoxSprite.GetWidth() * -1; mOrigin.y = ((Client.bottom - Client.top) / 2) - (mBoxSprite.GetHeight() / 2); mOrigin.x = mCenterToClose; mCurrentText.Initialize("TESTING!", mOrigin, 20, mBoxSprite.GetWidth() - (3 * BRIEFINGBOX_TEXT_XOFFSET), BRIEFINGBOX_TEXT_FONTNUMBER, BRIEFINGBOX_CURSOR_SPRITE_NUMBER, 80, -1, BRIEFINGBOX_CURSOR_SOUND_NUMBER, BRIEFINGBOX_CURSOR_ENDLINESOUND_NUMBER, MaxLines); }