The Battle for Wesnoth  1.15.0-dev
game_display.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://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 /**
16  * @file
17  * During a game, show map & info-panels at top+right.
18  */
19 
20 #include "game_display.hpp"
21 
22 #include "gettext.hpp"
23 #include "wesconfig.h"
24 
25 #include "cursor.hpp"
26 #include "display_chat_manager.hpp"
27 #include "fake_unit_manager.hpp"
28 #include "fake_unit_ptr.hpp"
29 #include "floating_label.hpp"
30 #include "game_board.hpp"
31 #include "preferences/game.hpp"
32 #include "halo.hpp"
33 #include "log.hpp"
34 #include "map/map.hpp"
35 #include "map/label.hpp"
36 #include "font/standard_colors.hpp"
37 #include "reports.hpp"
38 #include "resources.hpp"
39 #include "tod_manager.hpp"
40 #include "color.hpp"
41 #include "synced_context.hpp"
42 #include "terrain/type_data.hpp"
43 #include "units/unit.hpp"
44 #include "units/drawer.hpp"
45 #include "whiteboard/manager.hpp"
46 #include "overlay.hpp"
47 
48 static lg::log_domain log_display("display");
49 #define ERR_DP LOG_STREAM(err, log_display)
50 #define LOG_DP LOG_STREAM(info, log_display)
51 
52 static lg::log_domain log_engine("engine");
53 #define ERR_NG LOG_STREAM(err, log_engine)
54 
55 std::map<map_location,fixed_t> game_display::debugHighlights_;
56 
57 /**
58  * Function to return 2 half-hex footsteps images for the given location.
59  * Only loc is on the current route set by set_route.
60  *
61  * This function is only used internally by game_display so I have moved it out of the header into the compilaton unit.
62  */
63 std::vector<surface> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
64 
65 game_display::game_display(game_board& board, std::weak_ptr<wb::manager> wb,
66  reports & reports_object,
67  const config& theme_cfg,
68  const config& level,
69  bool) :
70  display(&board, wb, reports_object, theme_cfg, level, false),
71  overlay_map_(),
72  attack_indicator_src_(),
73  attack_indicator_dst_(),
74  route_(),
75  displayedUnitHex_(),
76  sidebarScaling_(1.0),
77  first_turn_(true),
78  in_game_(false),
79  chat_man_(new display_chat_manager(*this)),
80  mode_(RUNNING),
81  needs_rebuild_(false)
82 {
83  video().clear_screen();
84 }
85 
87 {
88  try {
89  // SDL_FreeSurface(minimap_);
90  chat_man_->prune_chat_messages(true);
91  } catch (...) {}
92 }
93 
95 {
97 
98  if( !first_turn_) {
100 
101  if(old_tod.image_mask != tod.image_mask) {
104 
105  const int niterations = static_cast<int>(10/turbo_speed());
106  const int frame_time = 30;
107  const int starting_ticks = SDL_GetTicks();
108  for(int i = 0; i != niterations; ++i) {
109 
110  if(old_mask != nullptr) {
111  const fixed_t proportion = ftofxp(1.0) - fxpdiv(i,niterations);
112  adjust_surface_alpha(old_mask, proportion);
113  tod_hex_mask1.assign(old_mask);
114  }
115 
116  if(new_mask != nullptr) {
117  const fixed_t proportion = fxpdiv(i,niterations);
118  adjust_surface_alpha(new_mask, proportion);
119  tod_hex_mask2.assign(new_mask);
120  }
121 
122  invalidate_all();
123 
124  const int cur_ticks = SDL_GetTicks();
125  const int wanted_ticks = starting_ticks + i*frame_time;
126  if(cur_ticks < wanted_ticks) {
127  SDL_Delay(wanted_ticks - cur_ticks);
128  }
129  }
130  }
131 
132  tod_hex_mask1.assign(nullptr);
133  tod_hex_mask2.assign(nullptr);
134  }
135 
136  first_turn_ = false;
137 
139 
140  invalidate_all();
141 }
142 
144 {
145  if(hex.valid() && fogged(hex)) {
146  return;
147  }
148  display::select_hex(hex);
149 
150  display_unit_hex(hex);
151 }
152 
154 {
155  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
156 
158  if (u) {
159  displayedUnitHex_ = hex;
160  invalidate_unit();
161  } else {
163  if (u) {
164  // mouse moved from unit hex to non-unit hex
165  if (dc_->units().count(selectedHex_)) {
167  invalidate_unit();
168  }
169  }
170  }
171 
174 }
175 
176 
178 {
179  if (!hex.valid())
180  return;
181 
182  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
183 
185  if (u) {
186  displayedUnitHex_ = hex;
187  invalidate_unit();
188  }
189 }
190 
192 {
193  if (src == displayedUnitHex_) {
194  displayedUnitHex_ = dst;
195  invalidate_unit();
196  }
197 }
198 
199 void game_display::scroll_to_leader(int side, SCROLL_TYPE scroll_type,bool force)
200 {
201  unit_map::const_iterator leader = dc_->units().find_leader(side);
202 
203  if(leader.valid() && leader->is_visible_to_team(dc_->get_team(viewing_side()), false)) {
204  scroll_to_tile(leader->get_location(), scroll_type, true, force);
205  }
206 }
207 
209  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
210  w->pre_draw();
211  }
213  /**
214  * @todo FIXME: must modify changed, but best to do it at the
215  * floating_label level
216  */
217  chat_man_->prune_chat_messages();
218 }
219 
220 
222  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
223  w->post_draw();
224  }
225 }
226 
228 {
229  halo_man_->unrender(invalidated_);
231  if (fake_unit_man_->empty()) {
232  return;
233  }
234  unit_drawer drawer = unit_drawer(*this);
235 
236  for (const unit* temp_unit : *fake_unit_man_) {
237  const map_location& loc = temp_unit->get_location();
239  if (invalidated_.find(loc) != invalidated_.end()
240  && (request == exclusive_unit_draw_requests_.end() || request->second == temp_unit->id()))
241  drawer.redraw_unit(*temp_unit);
242  }
243 }
244 
246 {
247  halo_man_->render();
248 }
249 
251 {
252  const bool on_map = get_map().on_board(loc);
253  const bool is_shrouded = shrouded(loc);
254 // const bool is_fogged = fogged(loc);
255  const int xpos = get_location_x(loc);
256  const int ypos = get_location_y(loc);
257 
258 // image::TYPE image_type = get_image_type(loc);
259 
260  display::draw_hex(loc);
261 
262  if(cursor::get() == cursor::WAIT) {
263  // Interaction is disabled, so we don't need anything else
264  return;
265  }
266 
267  if(on_map && loc == mouseoverHex_) {
268  drawing_layer hex_top_layer = LAYER_MOUSEOVER_BOTTOM;
270  if( u != nullptr ) {
271  hex_top_layer = LAYER_MOUSEOVER_TOP;
272  }
273  if(u == nullptr) {
274  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
275  image::get_image("misc/hover-hex-top.png~RC(magenta>gold)", image::SCALED_TO_HEX));
277  image::get_image("misc/hover-hex-bottom.png~RC(magenta>gold)", image::SCALED_TO_HEX));
278  } else if(dc_->teams()[currentTeam_].is_enemy(u->side())) {
279  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
280  image::get_image("misc/hover-hex-enemy-top.png~RC(magenta>red)", image::SCALED_TO_HEX));
282  image::get_image("misc/hover-hex-enemy-bottom.png~RC(magenta>red)", image::SCALED_TO_HEX));
283  } else if(dc_->teams()[currentTeam_].side() == u->side()) {
284  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
285  image::get_image("misc/hover-hex-top.png~RC(magenta>green)", image::SCALED_TO_HEX));
287  image::get_image("misc/hover-hex-bottom.png~RC(magenta>green)", image::SCALED_TO_HEX));
288  } else {
289  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
290  image::get_image("misc/hover-hex-top.png~RC(magenta>lightblue)", image::SCALED_TO_HEX));
292  image::get_image("misc/hover-hex-bottom.png~RC(magenta>lightblue)", image::SCALED_TO_HEX));
293  }
294  }
295 
296 
297 
298  // Draw reach_map information.
299  // We remove the reachability mask of the unit
300  // that we want to attack.
301  if (!is_shrouded && !reach_map_.empty()
302  && reach_map_.find(loc) == reach_map_.end() && loc != attack_indicator_dst_) {
304  drawing_buffer_add(LAYER_REACHMAP, loc, xpos, ypos,
306  }
307 
308  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
309  w->draw_hex(loc);
310 
311  if (!(w->is_active() && w->has_temp_move()))
312  {
313  std::vector<surface> footstepImages = footsteps_images(loc, route_, dc_);
314  if (!footstepImages.empty()) {
316  }
317  }
318  }
319  // Draw the attack direction indicator
320  if(on_map && loc == attack_indicator_src_) {
322  image::get_image("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", image::SCALED_TO_HEX));
323  } else if (on_map && loc == attack_indicator_dst_) {
325  image::get_image("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", image::SCALED_TO_HEX));
326  }
327 
328  // Linger overlay unconditionally otherwise it might give glitches
329  // so it's drawn over the shroud and fog.
330  if(mode_ != RUNNING) {
332  drawing_buffer_add(LAYER_LINGER_OVERLAY, loc, xpos, ypos,
334  }
335 
336  if(on_map && loc == selectedHex_ && !game_config::images::selected.empty()) {
338  drawing_buffer_add(LAYER_SELECTED_HEX, loc, xpos, ypos,
340  }
341 
342  // Show def% and turn to reach info
343  if(!is_shrouded && on_map) {
344  draw_movement_info(loc);
345  }
346 
347  if(game_config::debug) {
348  int debugH = debugHighlights_[loc];
349  if (debugH) {
350  std::string txt = std::to_string(debugH);
352  }
353  }
354  //simulate_delay += 1;
355 }
356 
358 {
360 }
361 
363 {
365 }
366 
368 {
369  if ( !team_valid() )
370  return;
371 
372  refresh_report("report_clock");
373  refresh_report("report_battery");
374  refresh_report("report_countdown");
375 
377  {
378  wb::future_map future; // start planned unit map scope
379 
380  // We display the unit the mouse is over if it is over a unit,
381  // otherwise we display the unit that is selected.
382  for (const std::string &name : reports_object_->report_list()) {
384  }
385  invalidateGameStatus_ = false;
386  }
387 }
388 
389 
391 {
392  if(mode != mode_) {
393  mode_ = mode;
394  invalidate_all();
395  }
396 }
397 
399 {
400  // Search if there is a mark here
402 
403  std::shared_ptr<wb::manager> wb = wb_.lock();
404 
405  // Don't use empty route or the first step (the unit will be there)
406  if(w != route_.marks.end()
407  && !route_.steps.empty() && route_.steps.front() != loc) {
408  const unit_map::const_iterator un =
409  (wb && wb->get_temp_move_unit().valid()) ?
410  wb->get_temp_move_unit() : dc_->units().find(route_.steps.front());
411  if(un != dc_->units().end()) {
412  // Display the def% of this terrain
413  int move_cost = un->movement_cost(get_map().get_terrain(loc));
414  int def = (move_cost == movetype::UNREACHABLE ?
415  0 : 100 - un->defense_modifier(get_map().get_terrain(loc)));
416  std::stringstream def_text;
417  def_text << def << "%";
418 
419  color_t color = game_config::red_to_green(def, false);
420 
421  // simple mark (no turn point) use smaller font
422  int def_font = w->second.turns > 0 ? 18 : 16;
423  draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
424 
425  int xpos = get_location_x(loc);
426  int ypos = get_location_y(loc);
427  if (w->second.invisible) {
428  drawing_buffer_add(LAYER_MOVE_INFO, loc, xpos, ypos,
429  image::get_image("misc/hidden.png", image::SCALED_TO_HEX));
430  }
431 
432  if (w->second.zoc) {
433  drawing_buffer_add(LAYER_MOVE_INFO, loc, xpos, ypos,
434  image::get_image("misc/zoc.png", image::SCALED_TO_HEX));
435  }
436 
437  if (w->second.capture) {
438  drawing_buffer_add(LAYER_MOVE_INFO, loc, xpos, ypos,
439  image::get_image("misc/capture.png", image::SCALED_TO_HEX));
440  }
441 
442  //we display turn info only if different from a simple last "1"
443  if (w->second.turns > 1 || (w->second.turns == 1 && loc != route_.steps.back())) {
444  std::stringstream turns_text;
445  turns_text << w->second.turns;
446  draw_text_in_hex(loc, LAYER_MOVE_INFO, turns_text.str(), 17, font::NORMAL_COLOR, 0.5,0.8);
447  }
448 
449  // The hex is full now, so skip the "show enemy moves"
450  return;
451  }
452  }
453  // When out-of-turn, it's still interesting to check out the terrain defs of the selected unit
454  else if (selectedHex_.valid() && loc == mouseoverHex_)
455  {
458  if(selectedUnit != dc_->units().end() && mouseoveredUnit == dc_->units().end()) {
459  // Display the def% of this terrain
460  int move_cost = selectedUnit->movement_cost(get_map().get_terrain(loc));
461  int def = (move_cost == movetype::UNREACHABLE ?
462  0 : 100 - selectedUnit->defense_modifier(get_map().get_terrain(loc)));
463  std::stringstream def_text;
464  def_text << def << "%";
465 
466  color_t color = game_config::red_to_green(def, false);
467 
468  // use small font
469  int def_font = 16;
470  draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
471  }
472  }
473 
474  if (!reach_map_.empty()) {
475  reach_map::iterator reach = reach_map_.find(loc);
476  if (reach != reach_map_.end() && reach->second > 1) {
477  const std::string num = std::to_string(reach->second);
479  }
480  }
481 }
482 
483 std::vector<surface> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_)
484 {
485  std::vector<surface> res;
486 
487  if (route_.steps.size() < 2) {
488  return res; // no real "route"
489  }
490 
491  std::vector<map_location>::const_iterator i =
492  std::find(route_.steps.begin(),route_.steps.end(),loc);
493 
494  if( i == route_.steps.end()) {
495  return res; // not on the route
496  }
497 
498  // Check which footsteps images of game_config we will use
499  int move_cost = 1;
500  const unit_map::const_iterator u = dc_->units().find(route_.steps.front());
501  if(u != dc_->units().end()) {
502  move_cost = u->movement_cost(dc_->map().get_terrain(loc));
503  }
504  int image_number = std::min<int>(move_cost, game_config::foot_speed_prefix.size());
505  if (image_number < 1) {
506  return res; // Invalid movement cost or no images
507  }
508  const std::string foot_speed_prefix = game_config::foot_speed_prefix[image_number-1];
509 
510  surface teleport = nullptr;
511 
512  // We draw 2 half-hex (with possibly different directions),
513  // but skip the first for the first step.
514  const int first_half = (i == route_.steps.begin()) ? 1 : 0;
515  // and the second for the last step
516  const int second_half = (i+1 == route_.steps.end()) ? 0 : 1;
517 
518  for (int h = first_half; h <= second_half; ++h) {
519  const std::string sense( h==0 ? "-in" : "-out" );
520 
521  if (!tiles_adjacent(*(i+(h-1)), *(i+h))) {
522  std::string teleport_image =
524  teleport = image::get_image(teleport_image, image::SCALED_TO_HEX);
525  continue;
526  }
527 
528  // In function of the half, use the incoming or outgoing direction
529  map_location::DIRECTION dir = (i+(h-1))->get_relative_dir(*(i+h));
530 
531  std::string rotate;
532  if (dir > map_location::SOUTH_EAST) {
533  // No image, take the opposite direction and do a 180 rotation
534  dir = i->get_opposite_dir(dir);
535  rotate = "~FL(horiz)~FL(vert)";
536  }
537 
538  const std::string image = foot_speed_prefix
539  + sense + "-" + i->write_direction(dir)
540  + ".png" + rotate;
541 
542  res.push_back(image::get_image(image, image::SCALED_TO_HEX));
543  }
544 
545  // we draw teleport image (if any) in last
546  if (teleport != nullptr) res.push_back(teleport);
547 
548  return res;
549 }
550 
551 
552 
554 {
556  highlight_another_reach(paths_list);
557 }
558 
560 {
561  // Fold endpoints of routes into reachability map.
562  for (const pathfind::paths::step &dest : paths_list.destinations) {
563  reach_map_[dest.curr]++;
564  }
565  reach_map_changed_ = true;
566 }
567 
569 {
570  if(!reach_map_.empty()) {
571  reach_map_.clear();
572  reach_map_changed_ = true;
573  return true;
574  } else {
575  return false;
576  }
577 }
578 
580 {
581  for(std::vector<map_location>::const_iterator i = route_.steps.begin();
582  i != route_.steps.end(); ++i) {
583  invalidate(*i);
584  }
585 }
586 
588 {
590 
591  if(route != nullptr) {
592  route_ = *route;
593  } else {
594  route_.steps.clear();
595  route_.marks.clear();
596  }
597 
599 }
600 
601 void game_display::float_label(const map_location& loc, const std::string& text, const color_t& color)
602 {
603  if(preferences::show_floating_labels() == false || fogged(loc)) {
604  return;
605  }
606 
607  font::floating_label flabel(text);
609  flabel.set_color(color);
610  flabel.set_position(get_location_x(loc)+zoom_/2, get_location_y(loc));
611  flabel.set_move(0, -2 * turbo_speed());
612  flabel.set_lifetime(60/turbo_speed());
614 
615  font::add_floating_label(flabel);
616 }
617 
619 {
620  assert(game_config::debug);
621  return debugHighlights_[loc];
622 }
623 
625 {
626  if (attack_indicator_src_ != src || attack_indicator_dst_ != dst) {
629 
630  attack_indicator_src_ = src;
631  attack_indicator_dst_ = dst;
632 
635  }
636 }
637 
639 {
641 }
642 
644 {
645  if (team_valid())
646  {
647  return dc_->teams()[currentTeam_].team_name();
648  }
649  return std::string();
650 }
651 
653 {
654  in_game_ = true;
655  create_buttons();
656  invalidate_all();
657 }
658 
660  if (b) {
661  needs_rebuild_ = true;
662  }
663 }
664 
666  if (needs_rebuild_) {
667  needs_rebuild_ = false;
669  invalidate_all();
670  rebuild_all();
671  return true;
672  }
673  return false;
674 }
675 
677 {
678  return overlay_map_;
679 }
The overlay used for the linger mode.
Definition: display.hpp:854
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: picture.cpp:1022
void invalidate_unit_after_move(const map_location &src, const map_location &dst)
Same as invalidate_unit() if moving the displayed unit.
Game board class.
Definition: game_board.hpp:50
virtual void select_hex(map_location hex)
Definition: display.cpp:1590
::tod_manager * tod_manager
Definition: resources.cpp:29
void set_game_mode(const game_mode mode)
reports * reports_object_
Definition: display.hpp:756
unit_iterator end()
Definition: map.hpp:415
const team & get_team(int side) const
static int & debug_highlight(const map_location &loc)
annotate hex with number, useful for debugging or UI prototype
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Definition: display.hpp:291
game_mode
Sets the linger mode for the display.
std::string image_mask
The image that is to be laid over all images while this time of day lasts.
Definition: time_of_day.hpp:97
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
Definition: display.cpp:2979
This class represents a single unit of a specific type.
Definition: unit.hpp:99
void set_move(double xmove, double ymove)
virtual overlay_map & get_overlays() override
Inherited from display.
void invalidate_route()
const time_of_day & get_previous_time_of_day() const
bool reach_map_changed_
Definition: display.hpp:1027
unit_iterator find_leader(int side)
Definition: map.cpp:329
map_location attack_indicator_src_
static const int UNREACHABLE
Magic value that signifies a hex is unreachable.
Definition: movetype.hpp:83
virtual void draw_invalidated()
Only called when there&#39;s actual redrawing to do.
Definition: display.cpp:2510
map_location mouseoverHex_
Definition: display.hpp:787
void invalidate_unit()
Function to invalidate that unit status displayed on the sidebar.
std::string unreachable
const std::set< std::string > & report_list()
Definition: reports.cpp:1619
dest_vect destinations
Definition: pathfind.hpp:99
int viewing_side() const
Definition: display.hpp:103
bool is_shrouded(const display *disp, const map_location &loc)
Our definition of map labels being obscured is if the tile is obscured, or the tile below is obscured...
Definition: label.cpp:31
game_mode mode_
reach_map reach_map_
Definition: display.hpp:1025
#define h
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Definition: map.cpp:377
Bottom half of image following the mouse.
Definition: display.hpp:843
map_location displayedUnitHex_
map_location selectedHex_
Definition: display.hpp:786
void set_font_size(int font_size)
virtual void post_commit() override
Hook for actions to take right after draw() calls drawing_buffer_commit No action here by default...
static unsigned int zoom_
Definition: display.hpp:739
drawing_layer
The layers to render something on.
Definition: display.hpp:815
virtual const gamemap & map() const =0
void new_turn()
Update lighting settings.
static std::map< map_location, int > debugHighlights_
surface tod_hex_mask2
Definition: display.hpp:782
Unit and team statistics.
t_translation::terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:309
bool team_valid() const
Definition: display.cpp:706
Top half of image following the mouse.
Definition: display.hpp:823
#define b
static lg::log_domain log_display("display")
no linger overlay, show fog and shroud.
const int SIZE_XLARGE
Definition: constants.cpp:29
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:57
static const char * name(const std::vector< SDL_Joystick *> &joysticks, const std::size_t index)
Definition: joystick.cpp:48
Image on the selected unit.
Definition: display.hpp:847
game_display(game_board &board, std::weak_ptr< wb::manager > wb, reports &reports_object, const config &theme_cfg, const config &level, bool dummy=false)
void scroll_to_leader(int side, SCROLL_TYPE scroll_type=ONSCREEN, bool force=true)
Scrolls to the leader of a certain side.
void adjust_surface_alpha(surface &surf, fixed_t amount)
Definition: utils.cpp:1174
double turbo_speed() const
Definition: display.cpp:2357
virtual void draw_invalidated() override
Only called when there&#39;s actual redrawing to do.
unit * get_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:187
void set_lifetime(int lifetime)
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:1030
Applies the planned unit map for the duration of the struct&#39;s life.
Definition: manager.hpp:251
map_location curr
Definition: pathfind.hpp:87
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.hpp:616
const time_of_day & get_time_of_day(int for_turn=0) const
Returns global time of day for the passed turn.
Definition: tod_manager.hpp:54
bool valid() const
Definition: location.hpp:93
#define fxpdiv(x, y)
IN: unsigned and int - OUT: fixed_t.
Definition: math.hpp:303
std::vector< surface > footsteps_images(const map_location &loc, const pathfind::marked_route &route_, const display_context *dc_)
Function to return 2 half-hex footsteps images for the given location.
game_board * gameboard
Definition: resources.cpp:20
std::string selected
std::string foot_teleport_enter
virtual const time_of_day & get_time_of_day(const map_location &loc) const override
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
Definition: display.cpp:430
void draw_text_in_hex(const map_location &loc, const drawing_layer layer, const std::string &text, std::size_t font_size, color_t color, double x_in_hex=0.5, double y_in_hex=0.5)
Draw text on a hex.
Definition: display.cpp:1492
void highlight_another_reach(const pathfind::paths &paths_list)
Add more paths to highlight.
bool invalidateGameStatus_
Definition: display.hpp:754
void highlight_reach(const pathfind::paths &paths_list)
Sets the paths that are currently displayed as available for the unit to move along.
void set_position(double xpos, double ypos)
virtual const unit_map & units() const =0
std::size_t count(const map_location &loc) const
Definition: map.hpp:400
void create_buttons()
Definition: display.cpp:851
Structure which holds a single route and marks for special events.
Definition: pathfind.hpp:140
const color_t YELLOW_COLOR
void needs_rebuild(bool b)
Sets whether the screen (map visuals) needs to be rebuilt. This is typically after the map has been c...
virtual void draw_sidebar() override
Called near the end of a draw operation, derived classes can use this to render a specific sidebar...
void invalidate_all()
Function to invalidate all tiles.
Definition: display.cpp:2969
pathfind::marked_route route_
int32_t fixed_t
Definition: math.hpp:292
virtual void draw_hex(const map_location &loc) override
Redraws a single gamemap location.
std::string attack_indicator_direction() const
Function to get attack direction suffix.
const color_t NORMAL_COLOR
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
Definition: display.cpp:716
std::unique_ptr< halo::manager > halo_man_
Definition: display.hpp:657
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Definition: math.hpp:297
Encapsulates the map of the game.
Definition: location.hpp:42
void float_label(const map_location &loc, const std::string &text, const color_t &color)
Function to float a label above a tile.
void set_color(const color_t &color)
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
Definition: display.cpp:711
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
unit_iterator find(std::size_t id)
Definition: map.cpp:311
void process_reachmap_changes()
Definition: display.cpp:3161
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
std::string current_team_name() const
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
Definition: location.cpp:557
surface tod_hex_mask1
Definition: display.hpp:782
std::size_t i
Definition: function.cpp:933
virtual const std::vector< team > & teams() const =0
void scroll_to_tile(const map_location &loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool force=true)
Scroll such that location loc is on-screen.
Definition: display.cpp:2160
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1598
bool has_time_area() const
virtual void select_hex(map_location hex) override
Function to display a location as selected.
bool dont_show_all_
Definition: display.hpp:735
int get_location_y(const map_location &loc) const
Definition: display.cpp:726
CURSOR_TYPE get()
Definition: cursor.cpp:213
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:44
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
Definition: display.cpp:2547
int w
Movement info (defense%, etc...).
Definition: display.hpp:853
const bool & debug
std::vector< std::string > foot_speed_prefix
virtual bool has_time_area() const override
static lg::log_domain log_engine("engine")
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:1178
overlay_map overlay_map_
void assign(SDL_Surface *surf)
Definition: surface.hpp:46
bool show_floating_labels()
Definition: game.cpp:840
std::string foot_teleport_exit
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
Definition: display.cpp:721
const gamemap & get_map() const
Definition: display.hpp:92
exclusive_unit_draw_requests_t exclusive_unit_draw_requests_
map of hexes where only one unit should be drawn, the one identified by the associated id string ...
Definition: display.hpp:662
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:54
bool unhighlight_reach()
Reset highlighting of paths.
color_t red_to_green(int val, bool for_text)
Return a color corresponding to the value val red for val=0 to green for val=100, passing by yellow...
std::set< map_location > invalidated_
Definition: display.hpp:778
bool find(E event, F functor)
Tests whether an event handler is available.
const display_context * dc_
Definition: display.hpp:656
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:102
this module manages the cache of images.
Standard logging facilities (interface).
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:196
Object which contains all the possible locations a unit can move to, with associated best routes to t...
Definition: pathfind.hpp:70
virtual void pre_draw() override
game_display pre_draw does specific things related e.g.
static const map_location & null_location()
Definition: location.hpp:85
virtual void post_draw() override
Calls the whiteboard&#39;s post-draw method.
map_location attack_indicator_dst_
const std::unique_ptr< fake_unit_manager > fake_unit_man_
Definition: display.hpp:742
int side() const
The side this unit belongs to.
Definition: unit.hpp:303
void draw_movement_info(const map_location &loc)
Draws the movement info (turns available) for a given location.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:92
bool valid() const
Definition: map.hpp:276
void clear_screen()
Clear the screen contents.
Definition: video.cpp:374
void set_route(const pathfind::marked_route *route)
Sets the route along which footsteps are drawn to show movement of a unit.
void clear_attack_indicator()
static bool is_synced()
void display_unit_hex(map_location hex)
Change the unit to be displayed in the sidebar.
std::string::const_iterator iterator
Definition: tokenizer.hpp:24
unit_map::iterator find_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:168
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Redraws the specified report (if anything has changed).
Definition: display.cpp:2761
void set_attack_indicator(const map_location &src, const map_location &dst)
Set the attack direction indicator.
std::weak_ptr< wb::manager > wb_
Definition: display.hpp:658
std::vector< map_location > & steps
Definition: pathfind.hpp:186
Definition: display.hpp:48
Layer which holds the attack indicator.
Definition: display.hpp:848
Footsteps showing path from unit to mouse.
Definition: display.hpp:822
const color_t BAD_COLOR
"black stripes" on unreachable hexes.
Definition: display.hpp:842
std::size_t currentTeam_
Definition: display.hpp:734
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:475
const std::vector< map_location > & route_
Definition: move.cpp:292
const std::unique_ptr< display_chat_manager > chat_man_
bool maybe_rebuild()
Rebuilds the screen if needs_rebuild(true) was previously called, and resets the flag.