|
1 |
|
2 #include "PlayerInfo.hh" |
|
3 |
|
4 #include <sstream> |
|
5 |
|
6 namespace graphics |
|
7 { |
|
8 |
|
9 void PlayerInfo::draw (Display *display) { |
|
10 CL_GraphicContext *gc = display->get_gc(); |
|
11 |
|
12 // draw status info at bottom of display |
|
13 gc->fill_rect( |
|
14 CL_Rect(area.left, area.top, area.right, area.bottom), |
|
15 CL_Gradient( |
|
16 CL_Color(0, 0, 0), |
|
17 CL_Color(50, 50, 50), |
|
18 CL_Color(50, 50, 50, 150), |
|
19 CL_Color(100, 100, 100, 200) |
|
20 ) |
|
21 ); |
|
22 |
|
23 // Health |
|
24 gc->draw_rect( |
|
25 CL_Rect( |
|
26 area.left + 9, |
|
27 area.top + 9, |
|
28 area.left + 11 + 100 * bar_length, |
|
29 area.top + 31 |
|
30 ), |
|
31 CL_Color(150, 150, 150) |
|
32 ); |
|
33 |
|
34 gc->fill_rect( |
|
35 CL_Rect( |
|
36 area.left + 10, |
|
37 area.top + 10, |
|
38 area.left + 10 + (int) (p->getHealthPercent() * bar_length), |
|
39 area.top + 30 |
|
40 ), |
|
41 CL_Gradient( |
|
42 CL_Color(200, 0, 0), |
|
43 CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0), |
|
44 CL_Color(200, 0, 0), |
|
45 CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0) |
|
46 ) |
|
47 ); |
|
48 |
|
49 // stats - kills |
|
50 std::stringstream sskills; |
|
51 sskills << "Kills: " << p->getKills(); |
|
52 getSimpleFont().draw( |
|
53 area.left + 20 + 100 * bar_length, |
|
54 area.top + 10, |
|
55 sskills.str(), |
|
56 get_gc() |
|
57 ); |
|
58 |
|
59 // stats - deaths |
|
60 std::stringstream ssdeaths; |
|
61 ssdeaths << "Deaths: " << p->getDeaths(); |
|
62 getSimpleFont().draw( |
|
63 area.left + 20 + 100 * bar_length, |
|
64 area.top + 30, |
|
65 ssdeaths.str(), |
|
66 get_gc() |
|
67 ); |
|
68 |
|
69 // stats - ratio |
|
70 std::stringstream ssratio; |
|
71 ssratio << "Ratio: " << (p->getKills()+1) / (p->getDeaths()+1); |
|
72 getSimpleFont().draw( |
|
73 area.left + 20 + 100 * bar_length, |
|
74 area.top + 50, |
|
75 ssratio.str(), |
|
76 get_gc() |
|
77 ); |
|
78 |
|
79 |
|
80 // Weapon clip / reloading |
|
81 gc->draw_rect( |
|
82 CL_Rect( |
|
83 area.left + 9, |
|
84 area.top + 69, |
|
85 area.left + 11 + 100 * bar_length, |
|
86 area.top + 91 |
|
87 ), |
|
88 CL_Color(150, 150, 150) |
|
89 ); |
|
90 |
|
91 gc->fill_rect( |
|
92 CL_Rect( |
|
93 area.left + 10, |
|
94 area.top + 70, |
|
95 area.left + 10 + (100 - (int) (p->getCurrentWeapon()->getReloadTimer() * 100 / p->getCurrentWeapon()->getReloadTime())) * bar_length, |
|
96 area.top + 90 |
|
97 ), |
|
98 CL_Gradient( |
|
99 CL_Color(100, 100, 0), |
|
100 CL_Color(100, 100, 0), |
|
101 CL_Color(100, 100, 0), |
|
102 CL_Color(100, 100, 100) |
|
103 ) |
|
104 ); |
|
105 |
|
106 // current weapon name |
|
107 getSimpleFont().draw( |
|
108 area.left + 20 + 100 * bar_length, |
|
109 area.top + 70, |
|
110 p->getCurrentWeapon()->getName(), |
|
111 get_gc() |
|
112 ); |
|
113 } |
|
114 |
|
115 |
|
116 |
|
117 } |