--- a/src/Graphics/PlayerInfoView.cc Wed Jan 21 03:33:35 2009 +0200
+++ b/src/Graphics/PlayerInfoView.cc Wed Jan 21 23:07:22 2009 +0200
@@ -1,13 +1,17 @@
#include "PlayerInfoView.hh"
+#include "Graphics.hh"
#include <sstream>
namespace graphics
{
-void PlayerInfoView::draw (Display *display) {
- CL_GraphicContext *gc = display->get_gc();
+void PlayerInfoView::draw (Display &display) {
+ CL_GraphicContext *gc = display.get_gc();
+ CL_Font font = graphics->fonts.getSimpleFont();
+
+ int bar_length = 3;
// draw status info at bottom of display
gc->fill_rect(
@@ -21,6 +25,8 @@
);
// Health
+ double health_percent = player->getHealthPercent();
+
gc->draw_rect(
CL_Rect(
area.left + 9,
@@ -35,45 +41,45 @@
CL_Rect(
area.left + 10,
area.top + 10,
- area.left + 10 + (int) (p->getHealthPercent() * bar_length),
+ area.left + 10 + (int) (health_percent * bar_length),
area.top + 30
),
CL_Gradient(
CL_Color(200, 0, 0),
- CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0),
+ CL_Color(200 - (int)(health_percent * 2), (int)(health_percent * 2), 0),
CL_Color(200, 0, 0),
- CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0)
+ CL_Color(200 - (int)(health_percent * 2), (int)(health_percent * 2), 0)
)
);
// stats - kills
std::stringstream sskills;
- sskills << "Kills: " << p->getKills();
- getSimpleFont().draw(
+ sskills << "Kills: " << player->getKills();
+ font.draw(
area.left + 20 + 100 * bar_length,
area.top + 10,
sskills.str(),
- get_gc()
+ display.get_gc()
);
// stats - deaths
std::stringstream ssdeaths;
- ssdeaths << "Deaths: " << p->getDeaths();
- getSimpleFont().draw(
+ ssdeaths << "Deaths: " << player->getDeaths();
+ font.draw(
area.left + 20 + 100 * bar_length,
area.top + 30,
ssdeaths.str(),
- get_gc()
+ display.get_gc()
);
// stats - ratio
std::stringstream ssratio;
- ssratio << "Ratio: " << (p->getKills()+1) / (p->getDeaths()+1);
- getSimpleFont().draw(
+ ssratio << "Ratio: " << (player->getKills() + 1) / (player->getDeaths() + 1);
+ font.draw(
area.left + 20 + 100 * bar_length,
area.top + 50,
ssratio.str(),
- get_gc()
+ display.get_gc()
);
@@ -92,7 +98,9 @@
CL_Rect(
area.left + 10,
area.top + 70,
- area.left + 10 + (100 - (int) (p->getCurrentWeapon()->getReloadTimer() * 100 / p->getCurrentWeapon()->getReloadTime())) * bar_length,
+ area.left + 10 + (100 - (int) (
+ player->getCurrentWeapon()->getReloadTimer() * 100 / player->getCurrentWeapon()->getReloadTime()
+ )) * bar_length,
area.top + 90
),
CL_Gradient(
@@ -104,11 +112,11 @@
);
// current weapon name
- getSimpleFont().draw(
+ font.draw(
area.left + 20 + 100 * bar_length,
area.top + 70,
- p->getCurrentWeapon()->getName(),
- get_gc()
+ player->getCurrentWeapon()->getName(),
+ display.get_gc()
);
}