terom@410: terom@411: #include "PlayerInfoView.hh" terom@410: terom@410: #include terom@410: terom@410: namespace graphics terom@410: { terom@410: terom@411: void PlayerInfoView::draw (Display *display) { terom@410: CL_GraphicContext *gc = display->get_gc(); 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@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@410: area.left + 10 + (int) (p->getHealthPercent() * bar_length), terom@410: area.top + 30 terom@410: ), terom@410: CL_Gradient( terom@410: CL_Color(200, 0, 0), terom@410: CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0), terom@410: CL_Color(200, 0, 0), terom@410: CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0) terom@410: ) terom@410: ); terom@410: terom@410: // stats - kills terom@410: std::stringstream sskills; terom@410: sskills << "Kills: " << p->getKills(); terom@410: getSimpleFont().draw( terom@410: area.left + 20 + 100 * bar_length, terom@410: area.top + 10, terom@410: sskills.str(), terom@410: get_gc() terom@410: ); terom@410: terom@410: // stats - deaths terom@410: std::stringstream ssdeaths; terom@410: ssdeaths << "Deaths: " << p->getDeaths(); terom@410: getSimpleFont().draw( terom@410: area.left + 20 + 100 * bar_length, terom@410: area.top + 30, terom@410: ssdeaths.str(), terom@410: get_gc() terom@410: ); terom@410: terom@410: // stats - ratio terom@410: std::stringstream ssratio; terom@410: ssratio << "Ratio: " << (p->getKills()+1) / (p->getDeaths()+1); terom@410: getSimpleFont().draw( terom@410: area.left + 20 + 100 * bar_length, terom@410: area.top + 50, terom@410: ssratio.str(), terom@410: 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@410: area.left + 10 + (100 - (int) (p->getCurrentWeapon()->getReloadTimer() * 100 / p->getCurrentWeapon()->getReloadTime())) * 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@410: getSimpleFont().draw( terom@410: area.left + 20 + 100 * bar_length, terom@410: area.top + 70, terom@410: p->getCurrentWeapon()->getName(), terom@410: get_gc() terom@410: ); terom@410: } terom@410: terom@410: terom@410: terom@410: }