本文整理汇总了C++中Book::GetReadLines方法的典型用法代码示例。如果您正苦于以下问题:C++ Book::GetReadLines方法的具体用法?C++ Book::GetReadLines怎么用?C++ Book::GetReadLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::GetReadLines方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawText
void Application::DrawText( const Reader& reader, Book& book )
{
sf::Shape bg;
bg = sf::Shape::Rectangle( 5, 5, m_textOutputWidth, m_screenHeight-5, sf::Color( 182, 220, 255 ) );
m_app.Draw( bg );
int yPos = 0;
int xPos = 10;
vector<string> lstLines = book.GetReadLines();
for ( int i = 0; i < lstLines.size(); i++ )
{
yPos += m_fontSize;
cout << i << ", " << lstLines[i] << endl;
string currentLine = lstLines[i];
int beginIndex = 0;
int endIndex = 0;
int pulledLines = 1;
if ( i == reader.GetCurrentLine() )
{
cout << endl << endl;
cout << "-------------------------------------------" << endl;
cout << endl << "WRITE LINE" << endl << currentLine << endl;
cout << endl << "SPLIT UP" << endl;
}
// Account for word-wrapping
while ( currentLine.length() * (m_fontSize/2) > m_textOutputWidth )
{
endIndex = ( 2 * m_textOutputWidth / m_fontSize ) - 10;
// Adjust endIndex to be where a ' ' is.
while ( currentLine[ endIndex ] != ' ' )
{
endIndex++;
}
sf::String textLine( currentLine.substr( beginIndex, endIndex ),
m_font, m_fontSize );
textLine.SetPosition( xPos, yPos );
textLine.SetColor( sf::Color( 0, 0, 0 ) );
if ( i == reader.GetCurrentLine() )
{
cout << pulledLines << ": " << currentLine.substr( beginIndex, endIndex ) << endl;
}
m_app.Draw( textLine );
yPos += m_fontSize;
currentLine.erase( beginIndex, endIndex );
pulledLines++;
}
// Output remaining line
sf::String textLine( currentLine, m_font, m_fontSize );
textLine.SetPosition( xPos, yPos );
textLine.SetColor( sf::Color( 0, 0, 0 ) );
if ( i == reader.GetCurrentLine() )
{
cout << pulledLines << ": " << currentLine << endl;
}
m_app.Draw( textLine );
yPos += m_fontSize;
}
sf::Sprite character;
character.SetImage( m_talker );
character.SetSubRect( sf::IntRect( m_characterFrame * 112, 0, m_characterFrame * 112 + 112, 192 ) );
character.SetPosition( 600, m_screenHeight - (m_talker.GetHeight()*2) );
character.SetScale( 2, 2 );
m_app.Draw( character );
if ( ++m_characterFrame > 2 )
{
m_characterFrame = 0;
}
}