src/Graphics/PlayerInfo.cc
branchnew_graphics
changeset 410 41fd46cffc52
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Graphics/PlayerInfo.cc	Wed Jan 21 01:57:24 2009 +0200
@@ -0,0 +1,117 @@
+
+#include "PlayerInfo.hh"
+
+#include <sstream>
+
+namespace graphics
+{
+
+void PlayerInfo::draw (Display *display) {
+    CL_GraphicContext *gc = display->get_gc();
+
+    // draw status info at bottom of display
+    gc->fill_rect(
+        CL_Rect(area.left, area.top, area.right, area.bottom),
+        CL_Gradient(
+            CL_Color(0, 0, 0),
+            CL_Color(50, 50, 50),
+            CL_Color(50, 50, 50, 150),
+            CL_Color(100, 100, 100, 200)
+        )
+    );
+    
+    // Health
+    gc->draw_rect(
+        CL_Rect(
+            area.left + 9,
+            area.top + 9,
+            area.left + 11 + 100 * bar_length,
+            area.top + 31
+        ),
+        CL_Color(150, 150, 150)
+    );
+
+    gc->fill_rect(
+        CL_Rect(
+            area.left + 10,
+            area.top + 10,
+            area.left + 10 + (int) (p->getHealthPercent() * 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, 0, 0),
+            CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0)
+        )
+    );
+
+    // stats - kills
+    std::stringstream sskills;
+    sskills << "Kills:  " << p->getKills();
+    getSimpleFont().draw(
+        area.left + 20 + 100 * bar_length,
+        area.top + 10,
+        sskills.str(),
+        get_gc()
+    );
+    
+    // stats - deaths
+    std::stringstream ssdeaths;
+    ssdeaths << "Deaths:  " << p->getDeaths();
+    getSimpleFont().draw(
+        area.left + 20 + 100 * bar_length,
+        area.top + 30,
+        ssdeaths.str(),
+        get_gc()
+    );
+    
+    // stats - ratio
+    std::stringstream ssratio;
+    ssratio << "Ratio:  " << (p->getKills()+1) / (p->getDeaths()+1);
+    getSimpleFont().draw(
+        area.left + 20 + 100 * bar_length,
+        area.top + 50,
+        ssratio.str(),
+        get_gc()
+    );
+    
+
+    // Weapon clip / reloading
+    gc->draw_rect(
+        CL_Rect(
+            area.left + 9,
+            area.top + 69,
+            area.left + 11 + 100 * bar_length,
+            area.top + 91
+        ),
+        CL_Color(150, 150, 150)
+    );
+
+    gc->fill_rect(
+        CL_Rect(
+            area.left + 10,
+            area.top + 70,
+            area.left + 10 + (100 - (int) (p->getCurrentWeapon()->getReloadTimer() * 100 / p->getCurrentWeapon()->getReloadTime())) * bar_length,
+            area.top + 90
+        ),
+        CL_Gradient(
+            CL_Color(100, 100, 0),
+            CL_Color(100, 100, 0),
+            CL_Color(100, 100, 0),
+            CL_Color(100, 100, 100)
+        )
+    );
+   
+    // current weapon name
+    getSimpleFont().draw(
+        area.left + 20 + 100 * bar_length,
+        area.top + 70,
+        p->getCurrentWeapon()->getName(),
+        get_gc()
+    );
+}
+
+
+
+}