The Battle for Wesnoth  1.13.11+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 - 2018 by Chris Beck <render787@gmail.com>
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 "formatter.hpp"
20 #include "preferences/game.hpp"
21 #include "halo.hpp"
22 #include "map/map.hpp"
23 #include "map/location.hpp"
24 #include "color.hpp"
25 #include "sdl/surface.hpp"
26 #include "team.hpp"
27 #include "units/unit.hpp"
28 #include "units/animation.hpp"
30 #include "units/frame.hpp"
31 
32 // Map of different energy bar surfaces and their dimensions.
33 static std::map<surface, SDL_Rect> energy_bar_rects;
34 
36  disp(thedisp),
37  dc(disp.get_disp_context()),
38  map(dc.map()),
39  teams(dc.teams()),
40  halo_man(thedisp.get_halo_manager()),
41  viewing_team(disp.viewing_team()),
42  playing_team(disp.playing_team()),
43  viewing_team_ref(teams[viewing_team]),
44  playing_team_ref(teams[playing_team]),
45  is_blindfolded(disp.is_blindfolded()),
46  show_everything(disp.show_everything()),
47  sel_hex(disp.selected_hex()),
48  mouse_hex(disp.mouseover_hex()),
49  zoom_factor(disp.get_zoom_factor()),
50  hex_size(disp.hex_size()),
51  hex_size_by_2(disp.hex_size()/2)
52 {}
53 
54 void unit_drawer::redraw_unit (const unit & u) const
55 {
57  map_location loc = u.get_location();
58 
59  int side = u.side();
60 
61  bool hidden = u.get_hidden();
62  bool is_flying = u.is_flying();
63  map_location::DIRECTION facing = u.facing();
64  int hitpoints = u.hitpoints();
65  int max_hitpoints = u.max_hitpoints();
66  int movement_left = u.movement_left();
67  int total_movement = u.total_movement();
68 
69  bool can_recruit = u.can_recruit();
70  bool can_advance = u.can_advance();
71 
72  int experience = u.experience();
73  int max_experience = u.max_experience();
74 
75  bool emit_zoc = u.emits_zoc();
76 
77  color_t hp_color=u.hp_color();
78  color_t xp_color=u.xp_color();
79 
80  std::string ellipse=u.image_ellipse();
81 
83  {
84  ac.clear_haloes();
85  if(ac.anim_) {
86  ac.anim_->update_last_draw_time();
87  }
88  return;
89  }
90 
91  if (!ac.anim_) {
92  ac.set_standing();
93  if (!ac.anim_) return;
94  }
95 
96  if (ac.refreshing_) return;
97  ac.refreshing_ = true;
98 
99  ac.anim_->update_last_draw_time();
100  frame_parameters params;
102  const terrain_type& terrain_info = map.get_terrain_info(terrain);
103 
104  // do not set to 0 so we can distinguish the flying from the "not on submerge terrain"
105  // instead use -1.0 (as in "negative depth", it will be ignored by rendering)
106  params.submerge= is_flying ? -1.0 : terrain_info.unit_submerge();
107 
108  if (u.invisible(loc, dc) &&
109  params.highlight_ratio > 0.6) {
110  params.highlight_ratio = 0.6;
111  }
112  if (loc == sel_hex && params.highlight_ratio == 1.0) {
113  params.highlight_ratio = 1.5;
114  }
115 
116  int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * zoom_factor);
117  if (is_flying && height_adjust < 0) {
118  height_adjust = 0;
119  }
120  params.y -= height_adjust;
121  params.halo_y -= height_adjust;
122 
123  int red = 0,green = 0,blue = 0,tints = 0;
124  double blend_ratio = 0;
125  // Add future colored states here
126  if(u.poisoned()) {
127  green += 255;
128  blend_ratio += 0.25;
129  tints += 1;
130  }
131  if(u.slowed()) {
132  red += 191;
133  green += 191;
134  blue += 255;
135  blend_ratio += 0.25;
136  tints += 1;
137  }
138  if(tints > 0) {
139  params.blend_with = color_t((red/tints),(green/tints),(blue/tints));
140  params.blend_ratio = ((blend_ratio/tints));
141  }
142 
143  //hackish : see unit_frame::merge_parameters
144  // we use image_mod on the primary image
145  // and halo_mod on secondary images and all haloes
146  params.image_mod = u.image_mods();
147  params.halo_mod = u.TC_image_mods();
148  params.image= u.default_anim_image();
149 
150 
151  if(u.incapacitated()) params.image_mod +="~GS()";
152  params.primary_frame = true;
153 
154 
155  const frame_parameters adjusted_params = ac.anim_->get_current_params(params);
156 
157  const map_location dst = loc.get_direction(facing);
158  const int xsrc = disp.get_location_x(loc);
159  const int ysrc = disp.get_location_y(loc);
160  const int xdst = disp.get_location_x(dst);
161  const int ydst = disp.get_location_y(dst);
162 
163  const int x = static_cast<int>(adjusted_params.offset * xdst + (1.0-adjusted_params.offset) * xsrc) + hex_size_by_2;
164  const int y = static_cast<int>(adjusted_params.offset * ydst + (1.0-adjusted_params.offset) * ysrc) + hex_size_by_2;
165 
166  bool has_halo = ac.unit_halo_ && ac.unit_halo_->valid();
167  if(!has_halo && !u.image_halo().empty()) {
168  ac.unit_halo_ = halo_man.add(x, y - height_adjust, u.image_halo()+u.TC_image_mods(), map_location(-1, -1));
169  }
170  if(has_halo && u.image_halo().empty()) {
172  ac.unit_halo_.reset();
173  } else if(has_halo) {
174  halo_man.set_location(ac.unit_halo_, x, y - height_adjust);
175  }
176 
177  // We draw bars only if wanted, visible on the map view
178  bool draw_bars = ac.draw_bars_ ;
179  if (draw_bars) {
180  SDL_Rect unit_rect {xsrc, ysrc +adjusted_params.y, hex_size, hex_size};
181  draw_bars = sdl::rects_overlap(unit_rect, disp.map_outside_area());
182  }
183  surface ellipse_front(nullptr);
184  surface ellipse_back(nullptr);
185  int ellipse_floating = 0;
186  // Always show the ellipse for selected units
187  if(draw_bars && (preferences::show_side_colors() || sel_hex == loc)) {
188  if(adjusted_params.submerge > 0.0) {
189  // The division by 2 seems to have no real meaning,
190  // It just works fine with the current center of ellipse
191  // and prevent a too large adjust if submerge = 1.0
192  ellipse_floating = static_cast<int>(adjusted_params.submerge * hex_size_by_2);
193  }
194 
195  if(ellipse.empty()){
196  ellipse="misc/ellipse";
197  }
198 
199  if(ellipse != "none") {
200  // check if the unit has a ZoC or can recruit
201  const std::string nozoc = !emit_zoc ? "nozoc-" : "";
202  const std::string leader = can_recruit ? "leader-" : "";
203  const std::string selected = sel_hex == loc ? "selected-" : "";
204  const std::string tc = team::get_side_color_id(side);
205 
206  const std::string ellipse_top = formatter() << ellipse << "-" << leader << nozoc << selected << "top.png~RC(ellipse_red>" << tc << ")";
207  const std::string ellipse_bot = formatter() << ellipse << "-" << leader << nozoc << selected << "bottom.png~RC(ellipse_red>" << tc << ")";
208 
209  // Load the ellipse parts recolored to match team color
210  ellipse_back.assign(image::get_image(image::locator(ellipse_top), image::SCALED_TO_ZOOM));
211  ellipse_front.assign(image::get_image(image::locator(ellipse_bot), image::SCALED_TO_ZOOM));
212  }
213  }
214  if (ellipse_back != nullptr) {
215  //disp.drawing_buffer_add(display::LAYER_UNIT_BG, loc,
217  xsrc, ysrc +adjusted_params.y-ellipse_floating, ellipse_back);
218  }
219 
220  if (ellipse_front != nullptr) {
221  //disp.drawing_buffer_add(display::LAYER_UNIT_FG, loc,
223  xsrc, ysrc +adjusted_params.y-ellipse_floating, ellipse_front);
224  }
225  if(draw_bars) {
226  const image::locator* orb_img = nullptr;
228  const int xoff = unit_img.null() ? hex_size_by_2 : (hex_size - unit_img->w)/2;
229  const int yoff = unit_img.null() ? hex_size_by_2 : (hex_size - unit_img->h)/2;
230  /*static*/ const image::locator partmoved_orb(game_config::images::orb + "~RC(magenta>" +
231  preferences::partial_color() + ")" );
232  /*static*/ const image::locator moved_orb(game_config::images::orb + "~RC(magenta>" +
233  preferences::moved_color() + ")" );
234  /*static*/ const image::locator ally_orb(game_config::images::orb + "~RC(magenta>" +
235  preferences::allied_color() + ")" );
236  /*static*/ const image::locator enemy_orb(game_config::images::orb + "~RC(magenta>" +
237  preferences::enemy_color() + ")" );
238  /*static*/ const image::locator unmoved_orb(game_config::images::orb + "~RC(magenta>" +
239  preferences::unmoved_color() + ")" );
240 
241  const std::string* energy_file = &game_config::images::energy;
242 
243  if(size_t(side) != viewing_team+1) {
244  if(disp.team_valid() &&
245  viewing_team_ref.is_enemy(side)) {
247  orb_img = &enemy_orb;
248  else
249  orb_img = nullptr;
250  } else {
252  orb_img = &ally_orb;
253  else orb_img = nullptr;
254  }
255  } else {
257  orb_img = &moved_orb;
258  else orb_img = nullptr;
259 
260  if(playing_team == viewing_team && !u.user_end_turn()) {
261  if (movement_left == total_movement) {
263  orb_img = &unmoved_orb;
264  else orb_img = nullptr;
265  } else if ( dc.unit_can_move(u) ) {
267  orb_img = &partmoved_orb;
268  else orb_img = nullptr;
269  }
270  }
271  }
272 
273  if (orb_img != nullptr) {
276  loc, xsrc + xoff, ysrc + yoff + adjusted_params.y, orb);
277  }
278 
279  double unit_energy = 0.0;
280  if(max_hitpoints > 0) {
281  unit_energy = double(hitpoints)/double(max_hitpoints);
282  }
283  const int bar_shift = static_cast<int>(-5*zoom_factor);
284  const int hp_bar_height = static_cast<int>(max_hitpoints * u.hp_bar_scaling());
285 
286  const fixed_t bar_alpha = (loc == mouse_hex || loc == sel_hex) ? ftofxp(1.0): ftofxp(0.8);
287 
288  draw_bar(*energy_file, xsrc+xoff+bar_shift, ysrc+yoff+adjusted_params.y,
289  loc, hp_bar_height, unit_energy,hp_color, bar_alpha);
290 
291  if(experience > 0 && can_advance) {
292  const double filled = double(experience)/double(max_experience);
293 
294  const int xp_bar_height = static_cast<int>(max_experience * u.xp_bar_scaling() / std::max<int>(u.level(),1));
295 
296  draw_bar(*energy_file, xsrc+xoff, ysrc+yoff+adjusted_params.y,
297  loc, xp_bar_height, filled, xp_color, bar_alpha);
298  }
299 
300  if (can_recruit) {
302  if(!crown.null()) {
303  //if(bar_alpha != ftofxp(1.0)) {
304  // crown = adjust_surface_alpha(crown, bar_alpha);
305  //}
307  loc, xsrc+xoff, ysrc+yoff+adjusted_params.y, crown);
308  }
309  }
310 
311  for(std::vector<std::string>::const_iterator ov = u.overlays().begin(); ov != u.overlays().end(); ++ov) {
312  const surface ov_img(image::get_image(*ov, image::SCALED_TO_ZOOM));
313  if(ov_img != nullptr) {
315  loc, xsrc+xoff, ysrc+yoff+adjusted_params.y, ov_img);
316  }
317  }
318  }
319 
320  // Smooth unit movements from terrain of different elevation.
321  // Do this separately from above so that the health bar doesn't go up and down.
322 
323  const t_translation::terrain_code terrain_dst = map.get_terrain(dst);
324  const terrain_type& terrain_dst_info = map.get_terrain_info(terrain_dst);
325 
326  int height_adjust_unit = static_cast<int>((terrain_info.unit_height_adjust() * (1.0 - adjusted_params.offset) +
327  terrain_dst_info.unit_height_adjust() * adjusted_params.offset) *
328  zoom_factor);
329  if (is_flying && height_adjust_unit < 0) {
330  height_adjust_unit = 0;
331  }
332  params.y -= height_adjust_unit - height_adjust;
333  params.halo_y -= height_adjust_unit - height_adjust;
334 
335  ac.anim_->redraw(params, halo_man);
336  ac.refreshing_ = false;
337 }
338 
339 void unit_drawer::draw_bar(const std::string& image, int xpos, int ypos,
340  const map_location& loc, size_t height, double filled,
341  const color_t& col, fixed_t alpha) const
342 {
343 
344  filled = std::min<double>(std::max<double>(filled,0.0),1.0);
345  height = static_cast<size_t>(height*zoom_factor);
346 
348 
349  // We use UNSCALED because scaling (and bilinear interpolation)
350  // is bad for calculate_energy_bar.
351  // But we will do a geometric scaling later.
352  surface bar_surf(image::get_image(image));
353  if(surf == nullptr || bar_surf == nullptr) {
354  return;
355  }
356 
357  // calculate_energy_bar returns incorrect results if the surface colors
358  // have changed (for example, due to bilinear interpolation)
359  const SDL_Rect& unscaled_bar_loc = calculate_energy_bar(bar_surf);
360 
361  SDL_Rect bar_loc;
362  if (surf->w == bar_surf->w && surf->h == bar_surf->h)
363  bar_loc = unscaled_bar_loc;
364  else {
365  const fixed_t xratio = fxpdiv(surf->w,bar_surf->w);
366  const fixed_t yratio = fxpdiv(surf->h,bar_surf->h);
367  const SDL_Rect scaled_bar_loc {
368  fxptoi(unscaled_bar_loc. x * xratio)
369  , fxptoi(unscaled_bar_loc. y * yratio + 127)
370  , fxptoi(unscaled_bar_loc. w * xratio + 255)
371  , fxptoi(unscaled_bar_loc. h * yratio + 255)
372  };
373  bar_loc = scaled_bar_loc;
374  }
375 
376  if(height > static_cast<size_t>(bar_loc.h)) {
377  height = bar_loc.h;
378  }
379 
380  //if(alpha != ftofxp(1.0)) {
381  // surf.assign(adjust_surface_alpha(surf,alpha));
382  // if(surf == nullptr) {
383  // return;
384  // }
385  //}
386 
387  const size_t skip_rows = bar_loc.h - height;
388 
389  SDL_Rect top {0, 0, surf->w, bar_loc.y};
390  SDL_Rect bot = sdl::create_rect(0, bar_loc.y + skip_rows, surf->w, 0);
391  bot.h = surf->w - bot.y;
392 
393  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos, ypos, surf, top);
394  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos, ypos + top.h, surf, bot);
395 
396  size_t unfilled = static_cast<size_t>(height * (1.0 - filled));
397 
398  if(unfilled < height && alpha >= ftofxp(0.3)) {
399  const uint8_t r_alpha = std::min<unsigned>(unsigned(fxpmult(alpha,255)),255);
400  surface filled_surf = create_compatible_surface(bar_surf, bar_loc.w, height - unfilled);
401  SDL_Rect filled_area = sdl::create_rect(0, 0, bar_loc.w, height-unfilled);
402  sdl::fill_surface_rect(filled_surf,&filled_area,SDL_MapRGBA(bar_surf->format,col.r,col.g,col.b, r_alpha));
403  disp.drawing_buffer_add(display::LAYER_UNIT_BAR, loc, xpos + bar_loc.x, ypos + bar_loc.y + unfilled, filled_surf);
404  }
405 }
406 
408  bool operator()(uint32_t color) const { return (color&0xFF000000) > 0x10000000 &&
409  (color&0x00FF0000) < 0x00100000 &&
410  (color&0x0000FF00) < 0x00001000 &&
411  (color&0x000000FF) < 0x00000010; }
412 };
413 
414 const SDL_Rect& unit_drawer::calculate_energy_bar(surface surf) const
415 {
416  const std::map<surface,SDL_Rect>::const_iterator i = energy_bar_rects.find(surf);
417  if(i != energy_bar_rects.end()) {
418  return i->second;
419  }
420 
421  int first_row = -1, last_row = -1, first_col = -1, last_col = -1;
422 
424 
425  const_surface_lock image_lock(image);
426  const uint32_t* const begin = image_lock.pixels();
427 
428  for(int y = 0; y != image->h; ++y) {
429  const uint32_t* const i1 = begin + image->w*y;
430  const uint32_t* const i2 = i1 + image->w;
431  const uint32_t* const itor = std::find_if(i1,i2,is_energy_color());
432  const int count = std::count_if(itor,i2,is_energy_color());
433 
434  if(itor != i2) {
435  if(first_row == -1) {
436  first_row = y;
437  }
438 
439  first_col = itor - i1;
440  last_col = first_col + count;
441  last_row = y;
442  }
443  }
444 
445  const SDL_Rect res {
446  first_col
447  , first_row
448  , last_col-first_col
449  , last_row+1-first_row
450  };
451  energy_bar_rects.emplace(surf, res);
452  return calculate_energy_bar(surf);
453 }
454 
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: image.cpp:920
bool refreshing_
avoid infinite recursion. flag used for drawing / animation
std::string unmoved_color()
Definition: general.cpp:345
Reserve layers to be selected for WML.
Definition: display.hpp:820
int total_movement() const
The maximum moves this unit has.
Definition: unit.hpp:1057
All parameters from a frame at a given instant.
Definition: frame.hpp:33
std::vector< char_t > string
image::locator image
Definition: frame.hpp:39
bool incapacitated() const
Check if the unit has been petrified.
Definition: unit.hpp:763
bool is_blindfolded
Definition: drawer.hpp:58
This class represents a single unit of a specific type.
Definition: unit.hpp:100
#define fxptoi(x)
IN: fixed_t - OUT: int.
Definition: math.hpp:321
bool null() const
Definition: surface.hpp:79
bool rects_overlap(const SDL_Rect &rect1, const SDL_Rect &rect2)
Tests whether two rectangles overlap.
Definition: rect.cpp:33
bool team_valid() const
Definition: display.cpp:716
pixel_t * pixels() const
Definition: surface.hpp:148
bool slowed() const
Check if the unit has been slowed.
Definition: unit.hpp:772
std::unique_ptr< unit_animation > anim_
The current animation.
Frame for unit's animation sequence.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
Definition: unit.hpp:1067
bool get_hidden() const
Gets whether this unit is currently hidden on the map.
Definition: unit.hpp:580
bool user_end_turn() const
Check whether the user ended their turn.
Definition: unit.hpp:652
bool show_enemy_orb()
Definition: general.cpp:265
int hex_size
Definition: drawer.hpp:64
bool is_enemy(int n) const
Definition: team.hpp:241
color_t xp_color() const
Color for this unit's XP.
Definition: unit.cpp:1125
int level() const
The current level of this unit.
Definition: unit.hpp:441
bool show_allied_orb()
Definition: general.cpp:258
halo::manager & halo_man
Definition: drawer.hpp:53
void fill_surface_rect(surface &dst, SDL_Rect *dst_rect, const uint32_t color)
Fill a rectangle on a given surface.
Definition: rect.hpp:115
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
Definition: translation.hpp:55
bool draw_bars_
bool indicating whether to draw bars with the unit
double hp_bar_scaling() const
The factor by which the HP bar should be scaled.
Definition: unit.hpp:592
color_t hp_color() const
Color for this unit's current hitpoints.
Definition: unit.cpp:1115
#define h
map_location::DIRECTION facing() const
The current directin this unit is facing within its hex.
Definition: unit.hpp:1157
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
Definition: display.cpp:731
-file sdl_utils.hpp
bool show_side_colors()
Definition: game.cpp:765
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:54
bool can_advance() const
Checks whether this unit has any options to advance to.
Definition: unit.hpp:172
int get_location_y(const map_location &loc) const
Definition: display.cpp:736
int unit_height_adjust() const
Definition: terrain.hpp:61
const std::vector< std::string > & overlays() const
Get the unit's overlay images.
Definition: unit.hpp:1383
bool invisible(const map_location &loc, const display_context &dc, bool see_all=true) const
Definition: unit.cpp:2359
t_translation::terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:301
int max_experience() const
The max number of experience points this unit can have.
Definition: unit.hpp:417
static const std::string & leader_crown()
The path to the leader crown overlay.
Definition: unit.cpp:1067
std::string image_mods() const
Gets an IPF string containing all IPF image mods.
Definition: unit.cpp:2501
void clear_haloes()
Clear the haloes associated to the unit.
std::string image_ellipse() const
Get the unit's ellipse image.
Definition: unit.hpp:1349
bool operator()(uint32_t color) const
Definition: drawer.cpp:408
size_t playing_team
Definition: drawer.hpp:55
#define fxpmult(x, y)
IN: unsigned and fixed_t - OUT: unsigned.
Definition: math.hpp:315
std::string halo_mod
Definition: frame.hpp:48
const map_location & get_location() const
The current map location this unit is at.
Definition: unit.hpp:1141
std::ostringstream wrapper.
Definition: formatter.hpp:38
int hitpoints() const
The current number of hitpoints this unit has.
Definition: unit.hpp:393
#define fxpdiv(x, y)
IN: unsigned and int - OUT: fixed_t.
Definition: math.hpp:318
Unit bars and overlays are drawn on this layer (for testing here).
Definition: display.hpp:845
std::string selected
int hex_size_by_2
Definition: drawer.hpp:65
void draw_bar(const std::string &image, int xpos, int ypos, const map_location &loc, size_t height, double filled, const color_t &col, fixed_t alpha) const
draw a health/xp bar of a unit
Definition: drawer.cpp:339
const gamemap & map
Definition: drawer.hpp:51
const SDL_Rect & calculate_energy_bar(surface surf) const
Finds the start and end rows on the energy bar image.
Definition: drawer.cpp:414
std::string default_anim_image() const
The default image to use for animation frames with no defined image.
Definition: unit.cpp:2332
int max_hitpoints() const
The max number of hitpoints this unit can have.
Definition: unit.hpp:399
uint8_t r
Red value.
Definition: color.hpp:177
bool emits_zoc() const
Tests whether the unit has a zone-of-control, considering incapacitated.
Definition: unit.hpp:1123
map_display and display: classes which take care of displaying the map and game-data on the screen...
display & disp
Definition: drawer.hpp:49
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
Definition: map.cpp:98
int experience() const
The current number of experience points this unit has.
Definition: unit.hpp:411
static const ::config * terrain
The terrain used to create the cache.
Definition: minimap.cpp:130
int32_t fixed_t
Definition: math.hpp:307
double unit_submerge() const
Definition: terrain.hpp:62
bool show_moved_orb()
Definition: general.cpp:272
static std::string get_side_color_id(unsigned side)
Definition: team.cpp:941
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:452
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Definition: math.hpp:312
Encapsulates the map of the game.
Definition: location.hpp:42
boost::optional< color_t > blend_with
Definition: frame.hpp:53
unit_animation_component & anim_comp() const
Definition: unit.hpp:1328
std::string allied_color()
Definition: general.cpp:305
double highlight_ratio
Definition: frame.hpp:56
std::string moved_color()
Definition: general.cpp:335
double xp_bar_scaling() const
The factor by which the XP bar should be scaled.
Definition: unit.hpp:601
std::string image_mod
Definition: frame.hpp:42
Helper class for pinning SDL surfaces into memory.
Definition: surface.hpp:128
std::string image_halo() const
Get the unit's halo image.
Definition: unit.hpp:1340
size_t i
Definition: function.cpp:933
const team & viewing_team_ref
Definition: drawer.hpp:56
std::string TC_image_mods() const
Constructs a recolor (RC) IPF string for this unit's team color.
Definition: unit.cpp:2496
bool can_recruit() const
Whether this unit can recruit other units - ie, are they a leader unit.
Definition: unit.hpp:481
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:44
const display_context & dc
Definition: drawer.hpp:50
int w
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:460
double blend_ratio
Definition: frame.hpp:55
double submerge
Definition: frame.hpp:58
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an SDL_Rect with the given dimensions.
Definition: rect.hpp:40
std::string partial_color()
Definition: general.cpp:355
void drawing_buffer_add(const drawing_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:1218
void assign(SDL_Surface *surf)
Definition: surface.hpp:46
unit_drawer(display &thedisp)
Definition: drawer.cpp:35
surface make_neutral_surface(const surface &surf)
Definition: utils.cpp:70
this module manages the cache of images.
Definition: image.cpp:103
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.hpp:236
surface create_compatible_surface(const surface &surf, int width, int height)
Definition: utils.cpp:2097
bool is_flying() const
Check if the unit is a flying unit.
Definition: unit.hpp:1250
bool is_visible_to_team(const team &team, const display_context &dc, bool const see_all=true) const
Definition: unit.cpp:2402
map_location get_direction(DIRECTION d, unsigned int n=1u) const
Definition: location.hpp:261
halo::handle unit_halo_
handle to the halo of this unit
void set_standing(bool with_bars=true)
Sets the animation state to standing.
bool show_unmoved_orb()
Definition: general.cpp:279
bool poisoned() const
Check if the unit has been poisoned.
Definition: unit.hpp:754
uint8_t g
Green value.
Definition: color.hpp:180
uint8_t b
Blue value.
Definition: color.hpp:183
bool show_partial_orb()
Definition: general.cpp:286
double zoom_factor
Definition: drawer.hpp:62
bool show_everything
Definition: drawer.hpp:59
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:54
boost::tribool primary_frame
Definition: frame.hpp:67
int side() const
The side this unit belongs to.
Definition: unit.hpp:244
std::string enemy_color()
Definition: general.cpp:325
static std::map< surface, SDL_Rect > energy_bar_rects
Definition: drawer.cpp:33
map_location mouse_hex
Definition: drawer.hpp:61
void remove(const handle &h)
Remove the halo with the given handle.
Definition: halo.cpp:466
map_location sel_hex
Definition: drawer.hpp:60