The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
drawer.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Chris Beck <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "units/drawer.hpp"
16 
17 #include "display.hpp"
18 #include "display_context.hpp"
19 #include "game_preferences.hpp"
20 #include "halo.hpp"
21 #include "map/map.hpp"
22 #include "map/location.hpp"
23 #include "sdl/utils.hpp"
24 #include "team.hpp"
25 #include "units/unit.hpp"
26 #include "units/animation.hpp"
28 #include "units/frame.hpp"
29 
30 unit_drawer::unit_drawer(display & thedisp, std::map<surface,SDL_Rect> & bar_rects) :
31  disp(thedisp),
32  dc(disp.get_disp_context()),
33  map(dc.map()),
34  teams(dc.teams()),
35  halo_man(thedisp.get_halo_manager()),
36  energy_bar_rects_(bar_rects),
37  viewing_team(disp.viewing_team()),
38  playing_team(disp.playing_team()),
39  viewing_team_ref(teams[viewing_team]),
40  playing_team_ref(teams[playing_team]),
41  is_blindfolded(disp.is_blindfolded()),
42  show_everything(disp.show_everything()),
43  sel_hex(disp.selected_hex()),
44  mouse_hex(disp.mouseover_hex()),
45  zoom_factor(disp.get_zoom_factor()),
46  hex_size(disp.hex_size()),
47  hex_size_by_2(disp.hex_size()/2)
48 {}
49 
50 void unit_drawer::redraw_unit (const unit & u) const
51 {
53  map_location loc = u.get_location();
54 
55  int side = u.side();
56 
57  bool hidden = u.get_hidden();
58  bool is_flying = u.is_flying();
59  map_location::DIRECTION facing = u.facing();
60  int hitpoints = u.hitpoints();
61  int max_hitpoints = u.max_hitpoints();
62  int movement_left = u.movement_left();
63  int total_movement = u.total_movement();
64 
65  bool can_recruit = u.can_recruit();
66  bool can_advance = u.can_advance();
67 
68  int experience = u.experience();
69  int max_experience = u.max_experience();
70 
71  bool emit_zoc = u.emits_zoc();
72 
73  SDL_Color hp_color=u.hp_color();
74  SDL_Color xp_color=u.xp_color();
75 
76  std::string ellipse=u.image_ellipse();
77 
79  {
80  ac.clear_haloes();
81  if(ac.anim_) {
82  ac.anim_->update_last_draw_time();
83  }
84  return;
85  }
86 
87  if (!ac.anim_) {
88  ac.set_standing();
89  if (!ac.anim_) return;
90  }
91 
92  if (ac.refreshing_) return;
93  ac.refreshing_ = true;
94 
95  ac.anim_->update_last_draw_time();
98  const terrain_type& terrain_info = map.get_terrain_info(terrain);
99 
100  // do not set to 0 so we can distinguish the flying from the "not on submerge terrain"
101  // instead use -1.0 (as in "negative depth", it will be ignored by rendering)
102  params.submerge= is_flying ? -1.0 : terrain_info.unit_submerge();
103 
104  if (u.invisible(loc) &&
105  params.highlight_ratio > 0.5) {
106  params.highlight_ratio = 0.5;
107  }
108  if (loc == sel_hex && params.highlight_ratio == 1.0) {
109  params.highlight_ratio = 1.5;
110  }
111 
112  int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * zoom_factor);
113  if (is_flying && height_adjust < 0) {
114  height_adjust = 0;
115  }
116  params.y -= height_adjust;
117  params.halo_y -= height_adjust;
118 
119  int red = 0,green = 0,blue = 0,tints = 0;
120  double blend_ratio = 0;
121  // Add future colored states here
122  if(u.poisoned()) {
123  green += 255;
124  blend_ratio += 0.25;
125  tints += 1;
126  }
127  if(u.slowed()) {
128  red += 191;
129  green += 191;
130  blue += 255;
131  blend_ratio += 0.25;
132  tints += 1;
133  }
134  if(tints > 0) {
135  params.blend_with = disp.rgb((red/tints),(green/tints),(blue/tints));
136  params.blend_ratio = ((blend_ratio/tints));
137  }
138 
139  //hackish : see unit_frame::merge_parameters
140  // we use image_mod on the primary image
141  // and halo_mod on secondary images and all haloes
142  params.image_mod = u.image_mods();
143  params.halo_mod = u.TC_image_mods();
144  params.image= u.default_anim_image();
145 
146 
147  if(u.incapacitated()) params.image_mod +="~GS()";
148  params.primary_frame = t_true;
149 
150 
151  const frame_parameters adjusted_params = ac.anim_->get_current_params(params);
152 
153  const map_location dst = loc.get_direction(facing);
154  const int xsrc = disp.get_location_x(loc);
155  const int ysrc = disp.get_location_y(loc);
156  const int xdst = disp.get_location_x(dst);
157  const int ydst = disp.get_location_y(dst);
158 
159  const int x = static_cast<int>(adjusted_params.offset * xdst + (1.0-adjusted_params.offset) * xsrc) + hex_size_by_2;
160  const int y = static_cast<int>(adjusted_params.offset * ydst + (1.0-adjusted_params.offset) * ysrc) + hex_size_by_2;
161 
162  bool has_halo = ac.unit_halo_ && ac.unit_halo_->valid();
163  if(!has_halo && !u.image_halo().empty()) {
164  ac.unit_halo_ = halo_man.add(x, y - height_adjust, u.image_halo()+u.TC_image_mods(), map_location(-1, -1));
165  }
166  if(has_halo && u.image_halo().empty()) {
168  ac.unit_halo_ = halo::handle(); //halo::NO_HALO;
169  } else if(has_halo) {
170  halo_man.set_location(ac.unit_halo_, x, y - height_adjust);
171  }
172 
173 
174 
175  // We draw bars only if wanted, visible on the map view
176  bool draw_bars = ac.draw_bars_ ;
177  if (draw_bars) {
178  SDL_Rect unit_rect = sdl::create_rect(xsrc, ysrc +adjusted_params.y, hex_size, hex_size);
179  draw_bars = sdl::rects_overlap(unit_rect, disp.map_outside_area());
180  }
181 #ifdef SDL_GPU
182  sdl::timage ellipse_front;
183  sdl::timage ellipse_back;
184 #else
185  surface ellipse_front(nullptr);
186  surface ellipse_back(nullptr);
187 #endif
188  int ellipse_floating = 0;
189  // Always show the ellipse for selected units
190  if(draw_bars && (preferences::show_side_colors() || sel_hex == loc)) {
191  if(adjusted_params.submerge > 0.0) {
192  // The division by 2 seems to have no real meaning,
193  // It just works fine with the current center of ellipse
194  // and prevent a too large adjust if submerge = 1.0
195  ellipse_floating = static_cast<int>(adjusted_params.submerge * hex_size_by_2);
196  }
197 
198  if(ellipse.empty()){
199  ellipse="misc/ellipse";
200  }
201 
202  if(ellipse != "none") {
203  // check if the unit has a ZoC or can recruit
204  const char* const nozoc = emit_zoc ? "" : "nozoc-";
205  const char* const leader = can_recruit ? "leader-" : "";
206  const char* const selected = sel_hex == loc ? "selected-" : "";
207 
208  // Load the ellipse parts recolored to match team color
209  char buf[100];
211 #ifdef SDL_GPU
212  snprintf(buf,sizeof(buf),"%s-%s%s%stop.png~RC(ellipse_red>%s)",ellipse.c_str(),leader,nozoc,selected,tc.c_str());
213  ellipse_back = image::get_texture(image::locator(buf), image::SCALED_TO_ZOOM);
214  snprintf(buf,sizeof(buf),"%s-%s%s%sbottom.png~RC(ellipse_red>%s)",ellipse.c_str(),leader,nozoc,selected,tc.c_str());
215  ellipse_front = image::get_texture(image::locator(buf), image::SCALED_TO_ZOOM);
216 #else
217  snprintf(buf,sizeof(buf),"%s-%s%s%stop.png~RC(ellipse_red>%s)",ellipse.c_str(),leader,nozoc,selected,tc.c_str());
218  ellipse_back.assign(image::get_image(image::locator(buf), image::SCALED_TO_ZOOM));
219  snprintf(buf,sizeof(buf),"%s-%s%s%sbottom.png~RC(ellipse_red>%s)",ellipse.c_str(),leader,nozoc,selected,tc.c_str());
220  ellipse_front.assign(image::get_image(image::locator(buf), image::SCALED_TO_ZOOM));
221 #endif
222  }
223  }
224 #ifdef SDL_GPU
225  if (!ellipse_back.null()) {
226  //disp.drawing_buffer_add(display::LAYER_UNIT_BG, loc,
228  xsrc, ysrc +adjusted_params.y-ellipse_floating, ellipse_back);
229  }
230 
231  if (!ellipse_front.null()) {
232  //disp.drawing_buffer_add(display::LAYER_UNIT_FG, loc,
234  xsrc, ysrc +adjusted_params.y-ellipse_floating, ellipse_front);
235  }
236 #else
237  if (ellipse_back != nullptr) {
238  //disp.drawing_buffer_add(display::LAYER_UNIT_BG, loc,
240  xsrc, ysrc +adjusted_params.y-ellipse_floating, ellipse_back);
241  }
242 
243  if (ellipse_front != nullptr) {
244  //disp.drawing_buffer_add(display::LAYER_UNIT_FG, loc,
246  xsrc, ysrc +adjusted_params.y-ellipse_floating, ellipse_front);
247  }
248 #endif
249  if(draw_bars) {
250  const image::locator* orb_img = nullptr;
252  const int xoff = (hex_size - unit_img->w)/2;
253  const int yoff = (hex_size - unit_img->h)/2;
254  /*static*/ const image::locator partmoved_orb(game_config::images::orb + "~RC(magenta>" +
255  preferences::partial_color() + ")" );
256  /*static*/ const image::locator moved_orb(game_config::images::orb + "~RC(magenta>" +
257  preferences::moved_color() + ")" );
258  /*static*/ const image::locator ally_orb(game_config::images::orb + "~RC(magenta>" +
259  preferences::allied_color() + ")" );
260  /*static*/ const image::locator enemy_orb(game_config::images::orb + "~RC(magenta>" +
261  preferences::enemy_color() + ")" );
262  /*static*/ const image::locator unmoved_orb(game_config::images::orb + "~RC(magenta>" +
263  preferences::unmoved_color() + ")" );
264 
265  const std::string* energy_file = &game_config::images::energy;
266 
267  if(size_t(side) != viewing_team+1) {
268  if(disp.team_valid() &&
269  viewing_team_ref.is_enemy(side)) {
271  orb_img = &enemy_orb;
272  else
273  orb_img = nullptr;
274  } else {
276  orb_img = &ally_orb;
277  else orb_img = nullptr;
278  }
279  } else {
281  orb_img = &moved_orb;
282  else orb_img = nullptr;
283 
284  if(playing_team == viewing_team && !u.user_end_turn()) {
285  if (movement_left == total_movement) {
287  orb_img = &unmoved_orb;
288  else orb_img = nullptr;
289  } else if ( dc.unit_can_move(u) ) {
291  orb_img = &partmoved_orb;
292  else orb_img = nullptr;
293  }
294  }
295  }
296 
297  if (orb_img != nullptr) {
300  loc, xsrc + xoff, ysrc + yoff + adjusted_params.y, orb);
301  }
302 
303  double unit_energy = 0.0;
304  if(max_hitpoints > 0) {
305  unit_energy = double(hitpoints)/double(max_hitpoints);
306  }
307  const int bar_shift = static_cast<int>(-5*zoom_factor);
308  const int hp_bar_height = static_cast<int>(max_hitpoints * u.hp_bar_scaling());
309 
310  const fixed_t bar_alpha = (loc == mouse_hex || loc == sel_hex) ? ftofxp(1.0): ftofxp(0.8);
311 
312  draw_bar(*energy_file, xsrc+xoff+bar_shift, ysrc+yoff+adjusted_params.y,
313  loc, hp_bar_height, unit_energy,hp_color, bar_alpha);
314 
315  if(experience > 0 && can_advance) {
316  const double filled = double(experience)/double(max_experience);
317 
318  const int xp_bar_height = static_cast<int>(max_experience * u.xp_bar_scaling() / std::max<int>(u.level(),1));
319 
320  draw_bar(*energy_file, xsrc+xoff, ysrc+yoff+adjusted_params.y,
321  loc, xp_bar_height, filled, xp_color, bar_alpha);
322  }
323 
324  if (can_recruit) {
326  if(!crown.null()) {
327  //if(bar_alpha != ftofxp(1.0)) {
328  // crown = adjust_surface_alpha(crown, bar_alpha);
329  //}
331  loc, xsrc+xoff, ysrc+yoff+adjusted_params.y, crown);
332  }
333  }
334 
335  for(std::vector<std::string>::const_iterator ov = u.overlays().begin(); ov != u.overlays().end(); ++ov) {
336 #ifdef SDL_GPU
337  const sdl::timage ov_img(image::get_texture(*ov, image::SCALED_TO_ZOOM));
338  if(!ov_img.null()) {
340  loc, xsrc, ysrc +adjusted_params.y, ov_img);
341  }
342 #else
343  const surface ov_img(image::get_image(*ov, image::SCALED_TO_ZOOM));
344  if(ov_img != nullptr) {
346  loc, xsrc+xoff, ysrc+yoff+adjusted_params.y, ov_img);
347  }
348 #endif
349  }
350  }
351 
352  // Smooth unit movements from terrain of different elevation.
353  // Do this separately from above so that the health bar doesn't go up and down.
354 
355  const t_translation::t_terrain terrain_dst = map.get_terrain(dst);
356  const terrain_type& terrain_dst_info = map.get_terrain_info(terrain_dst);
357 
358  int height_adjust_unit = static_cast<int>((terrain_info.unit_height_adjust() * (1.0 - adjusted_params.offset) +
359  terrain_dst_info.unit_height_adjust() * adjusted_params.offset) *
360  zoom_factor);
361  if (is_flying && height_adjust_unit < 0) {
362  height_adjust_unit = 0;
363  }
364  params.y -= height_adjust_unit - height_adjust;
365  params.halo_y -= height_adjust_unit - height_adjust;
366 
367  ac.anim_->redraw(params, halo_man);
368  ac.refreshing_ = false;
369 }
370 
371 //TODO: proper SDL_gpu implementation
372 void unit_drawer::draw_bar(const std::string& image, int xpos, int ypos,
373  const map_location& loc, size_t height, double filled,
374  const SDL_Color& col, fixed_t alpha) const
375 {
376 
377  filled = std::min<double>(std::max<double>(filled,0.0),1.0);
378  height = static_cast<size_t>(height*zoom_factor);
379 
381 
382  // We use UNSCALED because scaling (and bilinear interpolation)
383  // is bad for calculate_energy_bar.
384  // But we will do a geometric scaling later.
385  surface bar_surf(image::get_image(image));
386  if(surf == nullptr || bar_surf == nullptr) {
387  return;
388  }
389 
390  // calculate_energy_bar returns incorrect results if the surface colors
391  // have changed (for example, due to bilinear interpolation)
392  const SDL_Rect& unscaled_bar_loc = calculate_energy_bar(bar_surf);
393 
394  SDL_Rect bar_loc;
395  if (surf->w == bar_surf->w && surf->h == bar_surf->h)
396  bar_loc = unscaled_bar_loc;
397  else {
398  const fixed_t xratio = fxpdiv(surf->w,bar_surf->w);
399  const fixed_t yratio = fxpdiv(surf->h,bar_surf->h);
400  const SDL_Rect scaled_bar_loc = sdl::create_rect(
401  fxptoi(unscaled_bar_loc. x * xratio)
402  , fxptoi(unscaled_bar_loc. y * yratio + 127)
403  , fxptoi(unscaled_bar_loc. w * xratio + 255)
404  , fxptoi(unscaled_bar_loc. h * yratio + 255));
405  bar_loc = scaled_bar_loc;
406  }
407 
408  if(height > static_cast<size_t>(bar_loc.h)) {
409  height = bar_loc.h;
410  }
411 
412  //if(alpha != ftofxp(1.0)) {
413  // surf.assign(adjust_surface_alpha(surf,alpha));
414  // if(surf == nullptr) {
415  // return;
416  // }
417  //}
418 
419  const size_t skip_rows = bar_loc.h - height;
420 
421  SDL_Rect top = sdl::create_rect(0, 0, surf->w, bar_loc.y);
422  SDL_Rect bot = sdl::create_rect(0, bar_loc.y + skip_rows, surf->w, 0);
423  bot.h = surf->w - bot.y;
424 
425 #ifdef SDL_GPU
426  sdl::timage img(surf);
427  img.set_clip(top);
428  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos, ypos, surf);
429  img.set_clip(bot);
430  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos, ypos + top.h, surf);
431 #else
432  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos, ypos, surf, top);
433  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos, ypos + top.h, surf, bot);
434 #endif
435 
436  size_t unfilled = static_cast<size_t>(height * (1.0 - filled));
437 
438  if(unfilled < height && alpha >= ftofxp(0.3)) {
439  const Uint8 r_alpha = std::min<unsigned>(unsigned(fxpmult(alpha,255)),255);
440  surface filled_surf = create_compatible_surface(bar_surf, bar_loc.w, height - unfilled);
441  SDL_Rect filled_area = sdl::create_rect(0, 0, bar_loc.w, height-unfilled);
442  sdl::fill_rect(filled_surf,&filled_area,SDL_MapRGBA(bar_surf->format,col.r,col.g,col.b, r_alpha));
443 #ifdef SDL_GPU
444  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos + bar_loc.x, ypos + bar_loc.y + unfilled, sdl::timage(filled_surf));
445 #else
446  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos + bar_loc.x, ypos + bar_loc.y + unfilled, filled_surf);
447 #endif
448  }
449 }
450 
452  bool operator()(Uint32 color) const { return (color&0xFF000000) > 0x10000000 &&
453  (color&0x00FF0000) < 0x00100000 &&
454  (color&0x0000FF00) < 0x00001000 &&
455  (color&0x000000FF) < 0x00000010; }
456 };
457 
459 {
460  const std::map<surface,SDL_Rect>::const_iterator i = energy_bar_rects_.find(surf);
461  if(i != energy_bar_rects_.end()) {
462  return i->second;
463  }
464 
465  int first_row = -1, last_row = -1, first_col = -1, last_col = -1;
466 
468 
469  const_surface_lock image_lock(image);
470  const Uint32* const begin = image_lock.pixels();
471 
472  for(int y = 0; y != image->h; ++y) {
473  const Uint32* const i1 = begin + image->w*y;
474  const Uint32* const i2 = i1 + image->w;
475  const Uint32* const itor = std::find_if(i1,i2,is_energy_color());
476  const int count = std::count_if(itor,i2,is_energy_color());
477 
478  if(itor != i2) {
479  if(first_row == -1) {
480  first_row = y;
481  }
482 
483  first_col = itor - i1;
484  last_col = first_col + count;
485  last_row = y;
486  }
487  }
488 
489  const SDL_Rect res = sdl::create_rect(first_col
490  , first_row
491  , last_col-first_col
492  , last_row+1-first_row);
493  energy_bar_rects_.insert(std::pair<surface,SDL_Rect>(surf,res));
494  return calculate_energy_bar(surf);
495 }
496 
std::string image_halo() const
Definition: unit.hpp:356
std::string image_mods() const
Definition: unit.cpp:2430
double highlight_ratio
Definition: frame.hpp:88
double blend_ratio
Definition: frame.hpp:87
void drawing_buffer_add(const tdrawing_layer layer, const map_location &loc, int x, int y, const surface &surf, const SDL_Rect &clip=SDL_Rect())
Add an item to the drawing buffer.
Definition: display.cpp:1241
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: image.cpp:878
bool refreshing_
avoid infinite recursion. flag used for drawing / animation
int total_movement() const
Definition: unit.hpp:218
std::string unmoved_color()
bool is_visible_to_team(team const &team, gamemap const &map, bool const see_all=true) const
Definition: unit.cpp:2333
bool null() const
Definition: utils.hpp:104
const map_location & get_location() const
Definition: unit.hpp:286
bool emits_zoc() const
Definition: unit.hpp:257
void fill_rect(surface &dst, SDL_Rect *dst_rect, const Uint32 color)
Fill a rectangle on a given surface.
Definition: rect.hpp:143
int max_hitpoints() const
Definition: unit.hpp:169
bool is_blindfolded
Definition: drawer.hpp:61
Definition: unit.hpp:95
image::locator image
Definition: frame.hpp:76
std::string TC_image_mods() const
Definition: unit.cpp:2423
int experience() const
Definition: unit.hpp:171
bool user_end_turn() const
Definition: unit.hpp:229
double hp_bar_scaling() const
Definition: unit.hpp:195
bool rects_overlap(const SDL_Rect &rect1, const SDL_Rect &rect2)
Tests whether two rectangles overlap.
Definition: rect.cpp:52
bool team_valid() const
Definition: display.hpp:99
double xp_bar_scaling() const
Definition: unit.hpp:196
int hitpoints() const
Definition: unit.hpp:168
Sint32 fixed_t
Definition: drawer.hpp:40
Frame for unit's animation sequence.
std::string energy
Definition: game_config.cpp:84
#define fxpdiv(x, y)
IN: unsigned and int - OUT: fixed_t.
Definition: util.hpp:509
bool show_enemy_orb()
const Uint32 * pixels() const
Definition: utils.hpp:455
int hex_size
Definition: drawer.hpp:67
bool is_enemy(int n) const
Definition: team.hpp:247
bool show_allied_orb()
unit_drawer(display &thedisp, std::map< surface, SDL_Rect > &bar_rects)
Definition: drawer.cpp:30
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glew.h:3783
halo::manager & halo_man
Definition: drawer.hpp:55
bool poisoned() const
Definition: unit.hpp:214
bool draw_bars_
bool indicating whether to draw bars with the unit
const GLfloat * params
Definition: glew.h:1499
int side() const
Definition: unit.hpp:201
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
Definition: display.cpp:713
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
double submerge
Definition: frame.hpp:90
SDL_Color xp_color() const
Colors for the unit's XP.
Definition: unit.cpp:1075
All parameters from a frame at a given instant.
Definition: frame.hpp:71
-file sdl_utils.hpp
bool unit_can_move(const unit &u) const
Will return true iff the unit u has any possible moves it can do (including attacking etc)...
size_t viewing_team
Definition: drawer.hpp:57
bool get_hidden() const
Definition: unit.hpp:304
Unit bars and overlays are drawn on this layer (for testing here).
Definition: display.hpp:898
int get_location_y(const map_location &loc) const
Definition: display.cpp:718
int unit_height_adjust() const
Definition: terrain.hpp:58
#define fxptoi(x)
IN: fixed_t - OUT: int.
Definition: util.hpp:512
static std::vector< team > *& teams
Definition: team.cpp:50
bool operator()(Uint32 color) const
Definition: drawer.cpp:452
static const std::string & leader_crown()
The path to the leader crown overlay.
Definition: unit.cpp:234
#define fxpmult(x, y)
IN: unsigned and fixed_t - OUT: unsigned.
Definition: util.hpp:506
bool incapacitated() const
Definition: unit.hpp:215
void clear_haloes()
Clear the haloes associated to the unit.
GLclampf GLclampf blue
Definition: glew.h:1488
const std::vector< std::string > & overlays() const
Definition: unit.hpp:260
size_t playing_team
Definition: drawer.hpp:58
GLclampf green
Definition: glew.h:1488
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1858
GLenum GLenum dst
Definition: glew.h:2392
std::string halo_mod
Definition: frame.hpp:82
std::string selected
Definition: game_config.cpp:84
int hex_size_by_2
Definition: drawer.hpp:68
bool can_recruit() const
Definition: unit.hpp:207
const gamemap & map
Definition: drawer.hpp:53
const SDL_Rect & calculate_energy_bar(surface surf) const
Finds the start and end rows on the energy bar image.
Definition: drawer.cpp:458
GLclampf GLclampf GLclampf alpha
Definition: glew.h:1488
GLenum GLuint GLsizei const char * buf
Definition: glew.h:2498
std::string image_ellipse() const
Definition: unit.hpp:358
map_display and display: classes which take care of displaying the map and game-data on the screen...
display & disp
Definition: drawer.hpp:51
unit_animation_component & anim_comp() const
Definition: unit.hpp:276
int movement_left() const
Returns how far a unit can move this turn (zero if incapacitated).
Definition: unit.hpp:220
static const ::config * terrain
The terrain used to create the cache.
Definition: minimap.cpp:135
surf
Definition: filter.cpp:143
GLuint GLuint GLsizei count
Definition: glew.h:1221
double unit_submerge() const
Definition: terrain.hpp:59
GLuint color
Definition: glew.h:5801
bool invisible(const map_location &loc, bool see_all=true) const
Definition: unit.cpp:2291
bool is_flying() const
Definition: unit.hpp:305
boost::scoped_ptr< unit_animation > anim_
The current animation.
bool show_moved_orb()
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
Definition: translation.hpp:47
handle add(int x, int y, const std::string &image, const map_location &loc, halo::ORIENTATION orientation=NORMAL, bool infinite=true)
Add a haloing effect using 'image centered on (x,y).
Definition: halo.cpp:478
Encapsulates the map of the game.
Definition: location.hpp:38
const terrain_type & get_terrain_info(const t_translation::t_terrain &terrain) const
Definition: map.cpp:100
std::string default_anim_image() const
The default image to use for animation frames with no defined image.
Definition: unit.cpp:2267
Reserve layers to be selected for WML.
Definition: display.hpp:873
GLuint res
Definition: glew.h:9258
std::string allied_color()
std::map< std::string, tfilter >::iterator itor
Definition: filter.cpp:199
map_location::DIRECTION facing() const
Definition: unit.hpp:278
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue)
Definition: display.hpp:176
std::string moved_color()
std::string image_mod
Definition: frame.hpp:78
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:5910
size_t i
Definition: function.cpp:1057
const team & viewing_team_ref
Definition: drawer.hpp:59
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
bool slowed() const
Definition: unit.hpp:216
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:40
const display_context & dc
Definition: drawer.hpp:52
int level() const
Definition: unit.hpp:175
void set_location(const handle &h, int x, int y)
Set the position of an existing haloing effect, according to its handle.
Definition: halo.cpp:486
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1220
const GLfloat * tc
Definition: glew.h:12749
t_translation::t_terrain get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:341
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
Definition: rect.cpp:28
std::string partial_color()
bool can_advance() const
Definition: unit.hpp:323
int max_experience() const
Definition: unit.hpp:172
SDL_Color hp_color() const
Colors for the unit's current hitpoints.
Definition: unit.cpp:1065
tristate primary_frame
Definition: frame.hpp:97
void draw_bar(const std::string &image, int xpos, int ypos, const map_location &loc, size_t height, double filled, const SDL_Color &col, fixed_t alpha) const
draw a health/xp bar of a unit
Definition: drawer.cpp:372
Uint32 blend_with
Definition: frame.hpp:86
GLint GLvoid * img
Definition: glew.h:1353
surface make_neutral_surface(const surface &surf)
Definition: utils.cpp:135
this module manages the cache of images.
Definition: image.cpp:75
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.hpp:248
surface create_compatible_surface(const surface &surf, int width, int height)
Definition: utils.cpp:2166
Definition: frame.hpp:68
map_location get_direction(DIRECTION d, unsigned int n=1u) const
Definition: location.hpp:232
static std::string get_side_color_index(int side)
Definition: team.cpp:840
halo::handle unit_halo_
handle to the halo of this unit
std::map< surface, SDL_Rect > & energy_bar_rects_
Definition: drawer.hpp:56
void set_standing(bool with_bars=true)
Sets the animation state to standing.
bool show_unmoved_orb()
bool show_partial_orb()
double zoom_factor
Definition: drawer.hpp:65
bool show_everything
Definition: drawer.hpp:62
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:50
GLsizei const GLcharARB ** string
Definition: glew.h:4503
std::string enemy_color()
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Definition: util.hpp:503
boost::shared_ptr< halo_record > handle
Definition: halo.hpp:34
map_location mouse_hex
Definition: drawer.hpp:64
void remove(const handle &h)
Remove the halo with the given handle.
Definition: halo.cpp:492
map_location sel_hex
Definition: drawer.hpp:63