Beispiel #1
0
	void ConfigScene::render( unsigned int ticks )
	{
		Point2D textSize;
		vector<Point3D> vertices;
		vector<Color> colors;
		vector<unsigned int short> indices;
		
		if( ticks - this->lastDrawTicks > 15 )
		{
			Screen::get()->clear();
			
			for( vector<ColoredRectangle *>::iterator it = this->rectangles.begin() ; it != this->rectangles.end() ; it++ )
				(*it)->prepareRendering( vertices, colors, indices );
				
			ColoredRectangle::render( vertices, colors, indices );
			
			unsigned int screenWidth = Screen::get()->getWidth() - this->left - this->right;
			unsigned int screenHeight = Screen::get()->getHeight() - this->top - this->bottom;
			
			// Top
			textSize.moveTo( 0, 0 );
			Font::get("bitmap")->getTextSize( textSize, this->sTop );
			Font::get("bitmap")->write( Point2D( this->left + (screenWidth - textSize.getX()) / 2.0f, this->top + 20 ), this->sTop );
			
			// Left
			textSize.moveTo( 0, 0 );
			Font::get("bitmap")->getTextSize( textSize, this->sLeft );
			Font::get("bitmap")->write( Point2D( this->left + 20, this->top + (screenHeight - textSize.getY()) / 2.0f ), this->sLeft );
			
			// Right
			textSize.moveTo( 0, 0 );
			Font::get("bitmap")->getTextSize( textSize, this->sRight );
			Font::get("bitmap")->write( Point2D( this->left + screenWidth - textSize.getX() - 20, this->top + (screenHeight - textSize.getY()) / 2.0f ), this->sRight );
			
			// Bottom
			textSize.moveTo( 0, 0 );
			Font::get("bitmap")->getTextSize( textSize, this->sBottom );
			Font::get("bitmap")->write( Point2D( this->left + (screenWidth - textSize.getX()) / 2.0f, this->top + screenHeight - textSize.getY() - 20 ), this->sBottom );
			
			// Instructions
			textSize.moveTo( 0, this->top + (screenHeight - Font::get("bitmap")->getTextHeight( this->instructions ) ) / 2.0f );
			
			string line;
			unsigned int index = 0;
			size_t newLineIndex = this->instructions.find( '\n', index );
			
			while( newLineIndex != string::npos )
			{
				line = this->instructions.substr( index, newLineIndex - index );
				textSize.setX( this->left + (screenWidth - Font::get("bitmap")->getTextWidth( line )) / 2.0f );
				
				Font::get("bitmap")->write( textSize, line );
				textSize.moveBy( 0, Font::get("bitmap")->getTextHeight( line ) );
				
				index = newLineIndex + 1;
				newLineIndex = this->instructions.find( '\n', index );
			}
			
			if( index < this->instructions.length() )
			{
				line = this->instructions.substr( index );
				textSize.setX( this->left + (screenWidth - Font::get("bitmap")->getTextWidth( line )) / 2.0f );
				Font::get("bitmap")->write( textSize, line );
			}
			
			Font::get("bitmap")->render();
			
			Screen::get()->render();
			
			this->lastDrawTicks = ticks;
		}
	}