Esempio n. 1
0
   void lookup_range(int& l1, int& l2)
   {
       LineInfoList::iterator lili;
       if (m_li.size()==0) 
	   {
		   l1 = l2 = -1; 
	   }
	   l1 = m_li.front().line;
	   l2 = m_li.back().line;
   } 
Esempio n. 2
0
 // *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;
 }
Esempio n. 3
0
 // *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;
 }
Esempio n. 4
0
 void add(const LineInfo& li) // override
 {
   m_li.push_back(li);
 }
Esempio n. 5
0
/** 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( );
  }

}
Esempio n. 6
0
/** Feed the LineInfoList for the given text
  *
  * \param vText  The text to draw
  * \param vWidth The allowed width
  * \param vOut   The LineInfoList to feed
  * \param vWrap  The word wrap parameter
  *
  */
void RainbruRPG::OgreGui::Font::
processText( const std::string& vText, float vWidth, 
	     LineInfoList& vOut, bool vWrap)const{

  // Get the total size of the text
  unsigned int count = (unsigned int)vText.size( );

  // Stores pixel width of line and word
  float lineWidth = 0.0f;
  float wordWidth = 0.0f;

  // Stores current word
  std::string word;

  // Stores the current line
  std::string line;

  unsigned int x;
  for ( x = 0; x < count; x++ ){
    char c = vText[x];

    // Add the new character to the current word
    Glyph* gl=getGlyph(c);
    wordWidth += gl->getSpace();
    word += c;

    bool delim=isDelim(c);
    if ( delim || ( x == ( count-1 ) ) ){
      // Is this line too long to fit?
      if ( vWrap && ( lineWidth + wordWidth > vWidth ) ){
	// Save current line
	vOut.push_back( LineInfo( line, lineWidth ) );

	// Reset line width
	lineWidth = 0.0f;
	line = "";
      }
      if ( c == '\n' ){
	// Save current line
	vOut.push_back( LineInfo( line + word, lineWidth + wordWidth ) );

	// Reset line width
	lineWidth = 0.0f;
	wordWidth = 0.0f;

	line = "";
	word = "";
      }
      else{
	lineWidth += wordWidth;
	line += word;

	wordWidth = 0.0f;
	word = "";
      }
    }
  }
  
  // Push any remaining text onto list
  vOut.push_back( LineInfo( line + word, lineWidth + wordWidth ) );
}