void CL_ClanImageStretch::draw_image(CL_GraphicContext &gc, const CL_Rect &rect, CL_Image &image, int sizing_left, int sizing_top, int sizing_right, int sizing_bottom) { std::vector<ImagePart> image_parts = calc_stretch_image_parts(rect, image, sizing_left, sizing_top, sizing_right, sizing_bottom); size_t size = image_parts.size(); for (size_t index = 0; index < size; index++) image.draw(gc, image_parts[index].source_rect, image_parts[index].dest_rect); }
/** Builds the screen. */ void CAChampionshipScreen::buildScreen() { // Background: // m_background.draw ( *CA_APP->graphicContext, CL_Rect(0, 0, CA_APP->width, CA_APP->height) ); displayTitle(); CL_Draw::fill( *CA_APP->graphicContext, CL_Rectf(left, top, right, bottom), CL_Colorf(0, 0, 0, 64) ); const int rankWidth = 30; const int rankLeft = 0; const int nameWidth = 200; const int nameLeft = 50; const int addPtWidth = 30; const int addPtLeft = 260; const int totalPtWidth = 50; const int totalPtLeft = 300; const int caWidth = (totalPtLeft + totalPtWidth)*2; const int middleMargin = 30; const int caHeight = (barHeight * m_player.size())/2; const int marginTop = (top+bottom)/2 - caHeight/2; for (unsigned int rank=0; rank < m_player.size(); rank++) { std::ostringstream ossRankStr, ossTotalPoints, ossRacePoints; ossRankStr << rank + 1 << "."; ossTotalPoints << m_player[rank]->getTotalPoints(); int marginLeft = (right+left)/2 + middleMargin/2; int upPos = rank - m_player.size()/2; if (rank < m_player.size()/2 ) { marginLeft -= caWidth/2 + middleMargin; upPos = rank; } // Buttons: // m_button.draw ( *CA_APP->graphicContext, CL_Rect(marginLeft+rankLeft, marginTop+barHeight*upPos, marginLeft+rankLeft+rankWidth, marginTop+(barHeight*(upPos+1))) ); m_button.draw ( *CA_APP->graphicContext, CL_Rect(marginLeft+nameLeft, marginTop+barHeight*upPos, marginLeft+nameLeft+nameWidth, marginTop+(barHeight*(upPos+1))) ); if (m_displayMode != DISPLAY_CHAMPIONSHIP) { for (int i=0; i<= int(m_displayMode); i++) { std::vector<Player*>::const_iterator it = std::find(m_runningPlayers[i].begin(), m_runningPlayers[i].end(), m_player[rank]); if (it != m_runningPlayers[i].end() && m_player[rank]->getRacePoints() != 0) { CL_Image buttonToUse = (i==0 ? m_buttonEasy : (i==1)? m_buttonMedium : m_buttonHard); // Choose the button color buttonToUse.draw ( *CA_APP->graphicContext, CL_Rect(marginLeft+addPtLeft, marginTop+barHeight*upPos, marginLeft+addPtLeft+addPtWidth, marginTop+(barHeight*(upPos+1))) ); ossRacePoints << "+" << m_player[rank]->getRacePoints(); } } } m_button.draw ( *CA_APP->graphicContext, CL_Rect(marginLeft+totalPtLeft, marginTop+barHeight*upPos, marginLeft+totalPtLeft+totalPtWidth, marginTop+(barHeight*(upPos+1))) ); // Texts: // const int textPosX = marginLeft; const int textPosY = marginTop + 4 + barHeight*upPos; m_font.draw_text( *CA_APP->graphicContext, textPosX+rankLeft+rankWidth/2, textPosY, ossRankStr.str()); m_font.draw_text( *CA_APP->graphicContext, textPosX+nameLeft+nameWidth/2, textPosY, m_player[rank]->getName() ); m_font.draw_text( *CA_APP->graphicContext, textPosX+addPtLeft+addPtWidth/2, textPosY, ossRacePoints.str() ); m_font.draw_text( *CA_APP->graphicContext, textPosX+totalPtLeft+totalPtWidth/2, textPosY, ossTotalPoints.str() ); } }