// *fix 1.2.7 necessary to look for the next line, if we match exactly bool lookup_line(LineInfo& li, bool find_line) // override { LineInfoList::iterator lili, lili_end = m_li.end(); for(lili = m_li.begin(); lili != lili_end; lili++) if (find_line && lili->ip_offset >= li.ip_offset) { if (lili->ip_offset == li.ip_offset) { lili++; if (lili == lili_end) return false; //*ALWAYS?* } li = *lili; return true; } else if (!find_line && lili->line >= li.line) { li = *lili; return true; } return false; }
// *add 1.2.7 void dump(ostream& out) { LineInfoList::iterator lili; for(lili = m_li.begin(); lili != m_li.end(); lili++) out << lili->line << ' ' << lili->ip_offset << ' ' << lili->file << endl; }
/** Render a text * * The vRect parameter are top, bottom, left right coordonates in pixels * values. * * \param qr The QuadµRenderer used to draw * \param vLineList The LineInfoList used to cache * \param vColor The color to renderer * \param vRect The rectangle wherer to draw the text * \param vVertAlign The vertical alignment flag * \param vHorzAlign The horizontal alignment flag * \param vSelection Should we draw a selection * \param vSelectionStart The selection start * \param vSelectionEnd The selection end * */ void RainbruRPG::OgreGui::Font:: renderAligned(Brush* qr, LineInfoList& vLineList, const ColourValue& vColor, const Ogre::Rectangle& vRect, VerticalAlignType vVertAlign, HorizontalAlignType vHorzAlign, bool vSelection, int vSelectionStart, int vSelectionEnd ){ // Get the total height of the text (If we need it) float textHeight = 0.0f; if ( vVertAlign != VAT_TOP ) textHeight = (float)(mLineList.size( ) * getMaxGlyphHeight( )); float currentY = 0.0f; size_t charIndex = 0; // Get screen space clip region and Brush position Ogre::Rectangle clip = qr->getClipRegion(); Ogre::Vector2 pos; // Go through each character LineInfoList::const_iterator it=it = vLineList.begin( ); /* Get the DrawingDevSettings value for Y and add it to scissor rectangle. * * Fix the 16+ bug. * */ int dDevY = 0; // WAS qr->getDrawingDevYSum(); clip.top += dDevY; clip.bottom += dDevY; for ( it = vLineList.begin(); it != vLineList.end( ); it++ ){ const LineInfo& line = (*it); // Get the rendering position Ogre::Vector2 npos = calculatePos( vRect, line.getWidth(), textHeight, vHorzAlign, vVertAlign ); npos.y += currentY; /* See if this line actually needs to be rendered * * v0.0.5-180 : * The following test is very important : * if ( ( npos.y + getMaxGlyphHeight( ) + pos.y ) < clip.top ) * * It is guilty in the 16+ bug of the MultiColumnList (The items * starting at index 17 are not drawn). But if I remove it, there is * a little black square clipping in the screen. * * The following test was removed : * if ( !clip.isZero( ) ){ * * The bug is fixed by adding Y drawingDev sum to clip.top and * clip.bottom. Please see the code before this for statement. * */ if ( ( npos.y + getMaxGlyphHeight( ) + pos.y ) < clip.top ){ currentY += getMaxGlyphHeight( ); charIndex += line.getText().size( ); continue; } else if ( (npos.y + pos.y) > clip.bottom ){ return; } int start = vSelectionStart - charIndex; int end = vSelectionEnd - charIndex; // Render the line of text render( qr, line.getText(), vColor, npos, vSelection, start, end ); // Reset the current line currentY += getMaxGlyphHeight( ); charIndex += line.getText().size( ); } }