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