terom@410: terom@411: #include "PlayerInfoView.hh" terom@412: #include "Graphics.hh" terom@410: terom@410: #include terom@410: terom@410: namespace graphics terom@410: { terom@410: terom@412: void PlayerInfoView::draw (Display &display) { terom@412: CL_GraphicContext *gc = display.get_gc(); terom@412: CL_Font font = graphics->fonts.getSimpleFont(); terom@412: terom@412: int bar_length = 3; terom@410: terom@410: // draw status info at bottom of display terom@410: gc->fill_rect( terom@410: CL_Rect(area.left, area.top, area.right, area.bottom), terom@410: CL_Gradient( terom@410: CL_Color(0, 0, 0), terom@410: CL_Color(50, 50, 50), terom@410: CL_Color(50, 50, 50, 150), terom@410: CL_Color(100, 100, 100, 200) terom@410: ) terom@410: ); terom@410: terom@410: // Health terom@412: double health_percent = player->getHealthPercent(); terom@412: terom@410: gc->draw_rect( terom@410: CL_Rect( terom@410: area.left + 9, terom@410: area.top + 9, terom@410: area.left + 11 + 100 * bar_length, terom@410: area.top + 31 terom@410: ), terom@410: CL_Color(150, 150, 150) terom@410: ); terom@410: terom@410: gc->fill_rect( terom@410: CL_Rect( terom@410: area.left + 10, terom@410: area.top + 10, terom@412: area.left + 10 + (int) (health_percent * bar_length), terom@410: area.top + 30 terom@410: ), terom@410: CL_Gradient( terom@410: CL_Color(200, 0, 0), terom@412: CL_Color(200 - (int)(health_percent * 2), (int)(health_percent * 2), 0), terom@410: CL_Color(200, 0, 0), terom@412: CL_Color(200 - (int)(health_percent * 2), (int)(health_percent * 2), 0) terom@410: ) terom@410: ); terom@410: terom@410: // stats - kills terom@410: std::stringstream sskills; terom@412: sskills << "Kills: " << player->getKills(); terom@412: font.draw( terom@410: area.left + 20 + 100 * bar_length, terom@410: area.top + 10, terom@410: sskills.str(), terom@412: display.get_gc() terom@410: ); terom@410: terom@410: // stats - deaths terom@410: std::stringstream ssdeaths; terom@412: ssdeaths << "Deaths: " << player->getDeaths(); terom@412: font.draw( terom@410: area.left + 20 + 100 * bar_length, terom@410: area.top + 30, terom@410: ssdeaths.str(), terom@412: display.get_gc() terom@410: ); terom@410: terom@410: // stats - ratio terom@410: std::stringstream ssratio; terom@412: ssratio << "Ratio: " << (player->getKills() + 1) / (player->getDeaths() + 1); terom@412: font.draw( terom@410: area.left + 20 + 100 * bar_length, terom@410: area.top + 50, terom@410: ssratio.str(), terom@412: display.get_gc() terom@410: ); terom@410: terom@410: terom@410: // Weapon clip / reloading terom@410: gc->draw_rect( terom@410: CL_Rect( terom@410: area.left + 9, terom@410: area.top + 69, terom@410: area.left + 11 + 100 * bar_length, terom@410: area.top + 91 terom@410: ), terom@410: CL_Color(150, 150, 150) terom@410: ); terom@410: terom@410: gc->fill_rect( terom@410: CL_Rect( terom@410: area.left + 10, terom@410: area.top + 70, terom@412: area.left + 10 + (100 - (int) ( terom@412: player->getCurrentWeapon()->getReloadTimer() * 100 / player->getCurrentWeapon()->getReloadTime() terom@412: )) * bar_length, terom@410: area.top + 90 terom@410: ), terom@410: CL_Gradient( terom@410: CL_Color(100, 100, 0), terom@410: CL_Color(100, 100, 0), terom@410: CL_Color(100, 100, 0), terom@410: CL_Color(100, 100, 100) terom@410: ) terom@410: ); terom@410: terom@410: // current weapon name terom@412: font.draw( terom@410: area.left + 20 + 100 * bar_length, terom@410: area.top + 70, terom@412: player->getCurrentWeapon()->getName(), terom@412: display.get_gc() terom@410: ); terom@410: } terom@410: terom@410: terom@410: terom@410: }