author | Tero Marttila <terom@fixme.fi> |
Tue, 13 Jan 2009 20:21:28 +0200 | |
changeset 390 | 3c8078b96469 |
parent 389 | e74c1820fbd2 |
child 392 | 6c4dc68360eb |
permissions | -rw-r--r-- |
25 | 1 |
|
2 |
#include "Graphics.hh" |
|
86 | 3 |
#include "GameState.hh" |
108 | 4 |
#include <cmath> |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
5 |
#include <sstream> |
25 | 6 |
|
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
7 |
Graphics::Graphics (Engine &engine, GameState &state, PixelCoordinate resolution, bool fullscreen) : |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
8 |
CL_DisplayWindow(GRAPHICS_WINDOW_TITLE, resolution.x, resolution.y, fullscreen), |
25 | 9 |
engine(engine), |
10 |
state(state), |
|
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
11 |
resolution(resolution), |
25 | 12 |
update_timer(GRAPHICS_UPDATE_INTERVAL_MS), |
235 | 13 |
input(get_ic()->get_keyboard()), |
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
14 |
simple_font("Font2", engine.getResourceManager()) |
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
15 |
{ |
86 | 16 |
|
25 | 17 |
// connect timer signal |
205 | 18 |
slots.connect(update_timer.sig_tick(), this, &Graphics::on_update); |
25 | 19 |
|
20 |
// enable |
|
205 | 21 |
update_timer.start(); |
25 | 22 |
} |
23 |
||
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
24 |
const std::vector<CL_DisplayMode> & Graphics::getDisplayModes (void) { |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
25 |
return CL_DisplayMode::get_display_modes(); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
26 |
} |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
27 |
|
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
28 |
void Graphics::check_input (void) { |
25 | 29 |
LocalPlayer *player; |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
30 |
PlayerInput input_mask; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
31 |
TimeMS input_dt; |
25 | 32 |
|
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
33 |
// update gui flags |
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
34 |
handle_input(input.readGuiInput()); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
35 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
36 |
// stop here if we don't have a local player |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
37 |
if ((player = state.getLocalPlayer()) == NULL) |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
38 |
return; |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
39 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
40 |
// build input_mask |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
41 |
input.readPlayerInput(input_mask, input_dt); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
42 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
43 |
// apply input if there was any |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
44 |
if (input_mask) |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
45 |
player->handleInput(input_mask, input_dt); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
46 |
} |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
47 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
48 |
void Graphics::handle_input (GuiInput flags) { |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
49 |
// update flags |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
50 |
this->flags = flags; |
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
51 |
|
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
52 |
// quit? |
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
53 |
if (flags & GUI_INPUT_QUIT) { |
108 | 54 |
engine.stop(); |
25 | 55 |
|
108 | 56 |
return; |
25 | 57 |
} |
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
58 |
|
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
59 |
// dump player debug info on stderr |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
60 |
if ((flags & GUI_INPUT_DEBUG_PLAYER) && state.getLocalPlayer()) |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
61 |
state.getLocalPlayer()->printDebugInfo(); |
25 | 62 |
|
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
63 |
// toggle fullscreen? |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
64 |
if (flags & GUI_INPUT_TOGGLE_FULLSCREEN) { |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
65 |
if (is_fullscreen()) |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
66 |
set_windowed(); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
67 |
else |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
68 |
set_fullscreen(); |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
69 |
} |
25 | 70 |
} |
71 |
||
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
72 |
static PixelDimension value_between (PixelDimension low, PixelDimension value, PixelDimension high) { |
316
d909a7e36f8d
value_between now puts small map in the center, or at least should
nireco
parents:
315
diff
changeset
|
73 |
if (high < low) |
d909a7e36f8d
value_between now puts small map in the center, or at least should
nireco
parents:
315
diff
changeset
|
74 |
return (high + low) / 2; |
d909a7e36f8d
value_between now puts small map in the center, or at least should
nireco
parents:
315
diff
changeset
|
75 |
|
d909a7e36f8d
value_between now puts small map in the center, or at least should
nireco
parents:
315
diff
changeset
|
76 |
else if (value < low) |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
77 |
return low; |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
78 |
|
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
79 |
else if (value > high) |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
80 |
return high; |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
81 |
|
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
82 |
else |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
83 |
return value; |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
84 |
} |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
85 |
|
25 | 86 |
void Graphics::do_redraw (void) { |
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
87 |
CL_GraphicContext *gc = get_gc(); |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
88 |
LocalPlayer *player; |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
89 |
|
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
90 |
// calculate camera |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
91 |
PixelCoordinate camera(0, 0); |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
92 |
|
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
93 |
// ...to track our local player |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
94 |
if ((player = state.getLocalPlayer()) != NULL) { |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
95 |
// try and center the screen on the player |
318 | 96 |
PixelCoordinate target = player->getCoordinate() - PixelCoordinate(resolution.x / 2, (resolution.y - 100) / 2); |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
97 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
98 |
// ...but keep the world in view |
318 | 99 |
PixelCoordinate max = state.world.getDimensions() - resolution + PixelCoordinate(0, 100); |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
100 |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
101 |
// ...by limiting the value to 0...max |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
102 |
camera = PixelCoordinate( |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
103 |
value_between(0, target.x, max.x), |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
104 |
value_between(0, target.y, max.y) |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
105 |
); |
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
106 |
} |
25 | 107 |
|
312 | 108 |
// Black background |
248 | 109 |
gc->clear(CL_Color::black); |
25 | 110 |
|
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
111 |
// Draw the game |
266
ad72d0a0cc02
increase the map size and control the camera to always have the screen full of terrain
terom
parents:
248
diff
changeset
|
112 |
state.draw(this, camera, flags & GUI_INPUT_DISPLAY_WEAPON); |
180 | 113 |
|
312 | 114 |
if (player != NULL) { |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
115 |
// draw player info box |
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
116 |
draw_player_info(gc, player); |
312 | 117 |
} |
118 |
||
184 | 119 |
// Flip window buffer, sync |
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
230
diff
changeset
|
120 |
flip(1); |
25 | 121 |
} |
122 |
||
205 | 123 |
void Graphics::on_update (TimeMS tick_length) { |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
124 |
(void) tick_length; |
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
125 |
|
25 | 126 |
// check keyboard input |
311
440763821484
make Input have its own timer, and add key-repeat handling, and fix some warnings
terom
parents:
282
diff
changeset
|
127 |
check_input(); |
25 | 128 |
|
129 |
// redraw display |
|
130 |
do_redraw(); |
|
131 |
} |
|
315 | 132 |
|
133 |
void Graphics::draw_player_info(CL_GraphicContext *gc, Player *p) { |
|
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
134 |
int box_top = resolution.y - 100; |
315 | 135 |
int box_left = 0; |
389
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
136 |
int box_right = resolution.x; |
e74c1820fbd2
implement --help, --fullscreen, --resolution and --list-modes
Tero Marttila <terom@fixme.fi>
parents:
377
diff
changeset
|
137 |
int box_bottom = resolution.y; |
318 | 138 |
int bar_length = 3; // *100 |
315 | 139 |
|
140 |
// draw status info at bottom of display |
|
141 |
gc->fill_rect( |
|
142 |
CL_Rect( |
|
143 |
box_left, |
|
144 |
box_top, |
|
145 |
box_right, |
|
146 |
box_bottom |
|
147 |
), |
|
148 |
CL_Gradient( |
|
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
149 |
CL_Color(0, 0, 0), |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
150 |
CL_Color(50, 50, 50), |
315 | 151 |
CL_Color(50, 50, 50, 150), |
152 |
CL_Color(100, 100, 100, 200) |
|
153 |
) |
|
154 |
); |
|
318 | 155 |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
156 |
// Health |
315 | 157 |
gc->draw_rect( |
158 |
CL_Rect( |
|
159 |
box_left + 9, |
|
160 |
box_top + 9, |
|
318 | 161 |
box_left + 11 + 100 * bar_length, |
315 | 162 |
box_top + 31 |
163 |
), |
|
164 |
CL_Color(150, 150, 150) |
|
165 |
); |
|
166 |
||
167 |
gc->fill_rect( |
|
168 |
CL_Rect( |
|
169 |
box_left + 10, |
|
170 |
box_top + 10, |
|
318 | 171 |
box_left + 10 + (int) (p->getHealthPercent() * bar_length), |
315 | 172 |
box_top + 30 |
173 |
), |
|
174 |
CL_Gradient( |
|
175 |
CL_Color(200, 0, 0), |
|
176 |
CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0), |
|
177 |
CL_Color(200, 0, 0), |
|
178 |
CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0) |
|
179 |
) |
|
180 |
); |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
181 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
182 |
// stats - kills |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
183 |
std::stringstream sskills; |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
184 |
sskills << "Kills: " << p->getKills(); |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
185 |
getSimpleFont().draw( |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
186 |
box_left + 20 + 100 * bar_length, |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
187 |
box_top + 10, |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
188 |
sskills.str(), |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
189 |
get_gc() |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
190 |
); |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
191 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
192 |
// stats - deaths |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
193 |
std::stringstream ssdeaths; |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
194 |
ssdeaths << "Deaths: " << p->getDeaths(); |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
195 |
getSimpleFont().draw( |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
196 |
box_left + 20 + 100 * bar_length, |
326 | 197 |
box_top + 30, |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
198 |
ssdeaths.str(), |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
199 |
get_gc() |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
200 |
); |
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
201 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
202 |
// stats - ratio |
326 | 203 |
std::stringstream ssratio; |
204 |
ssratio << "Ratio: " << (p->getKills()+1) / (p->getDeaths()+1); |
|
205 |
getSimpleFont().draw( |
|
206 |
box_left + 20 + 100 * bar_length, |
|
207 |
box_top + 50, |
|
208 |
ssratio.str(), |
|
209 |
get_gc() |
|
210 |
); |
|
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
211 |
|
318 | 212 |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
213 |
// Weapon clip / reloading |
318 | 214 |
gc->draw_rect( |
215 |
CL_Rect( |
|
216 |
box_left + 9, |
|
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
217 |
box_top + 69, |
318 | 218 |
box_left + 11 + 100 * bar_length, |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
219 |
box_top + 91 |
318 | 220 |
), |
221 |
CL_Color(150, 150, 150) |
|
222 |
); |
|
223 |
||
224 |
gc->fill_rect( |
|
225 |
CL_Rect( |
|
226 |
box_left + 10, |
|
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
227 |
box_top + 70, |
354 | 228 |
box_left + 10 + (100 - (int) (p->getCurrentWeapon()->getReloadTimer() * 100 / p->getCurrentWeapon()->getReloadTime())) * bar_length, |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
229 |
box_top + 90 |
318 | 230 |
), |
231 |
CL_Gradient( |
|
232 |
CL_Color(100, 100, 0), |
|
233 |
CL_Color(100, 100, 0), |
|
234 |
CL_Color(100, 100, 0), |
|
235 |
CL_Color(100, 100, 100) |
|
236 |
) |
|
237 |
); |
|
377
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
238 |
|
01d3c340b372
direction normalization functions in vector, change rope color, misc comments+whitespace
terom
parents:
354
diff
changeset
|
239 |
// current weapon name |
325
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
240 |
getSimpleFont().draw( |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
241 |
box_left + 20 + 100 * bar_length, |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
242 |
box_top + 70, |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
243 |
p->getCurrentWeapon()->getName(), |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
244 |
get_gc() |
a19c78786d7f
kills, deaths and weapon name is displayed in right place
nireco
parents:
318
diff
changeset
|
245 |
); |
315 | 246 |
} |
247 |