The Battle for Wesnoth  1.13.11+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 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 /**
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 "sound.hpp"
42 #include "synced_context.hpp"
43 #include "terrain/type_data.hpp"
44 #include "units/unit.hpp"
45 #include "units/drawer.hpp"
46 #include "whiteboard/manager.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 {
84  video().clear_screen();
85 }
86 
88 {
89  try {
90  // SDL_FreeSurface(minimap_);
91  chat_man_->prune_chat_messages(true);
92  } catch (...) {}
93 }
94 
96 {
98 
99  if( !first_turn_) {
101 
102  if(old_tod.image_mask != tod.image_mask) {
105 
106  const int niterations = static_cast<int>(10/turbo_speed());
107  const int frame_time = 30;
108  const int starting_ticks = SDL_GetTicks();
109  for(int i = 0; i != niterations; ++i) {
110 
111  if(old_mask != nullptr) {
112  const fixed_t proportion = ftofxp(1.0) - fxpdiv(i,niterations);
113  adjust_surface_alpha(old_mask, proportion);
114  tod_hex_mask1.assign(old_mask);
115  }
116 
117  if(new_mask != nullptr) {
118  const fixed_t proportion = fxpdiv(i,niterations);
119  adjust_surface_alpha(new_mask, proportion);
120  tod_hex_mask2.assign(new_mask);
121  }
122 
123  invalidate_all();
124 
125  const int cur_ticks = SDL_GetTicks();
126  const int wanted_ticks = starting_ticks + i*frame_time;
127  if(cur_ticks < wanted_ticks) {
128  SDL_Delay(wanted_ticks - cur_ticks);
129  }
130  }
131  }
132 
133  tod_hex_mask1.assign(nullptr);
134  tod_hex_mask2.assign(nullptr);
135  }
136 
137  first_turn_ = false;
138 
140 
141  invalidate_all();
142 }
143 
145 {
146  if(hex.valid() && fogged(hex)) {
147  return;
148  }
149  display::select_hex(hex);
150 
151  display_unit_hex(hex);
152 }
153 
155 {
156  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
157 
159  if (u) {
160  displayedUnitHex_ = hex;
161  invalidate_unit();
162  } else {
164  if (u) {
165  // mouse moved from unit hex to non-unit hex
166  if (dc_->units().count(selectedHex_)) {
168  invalidate_unit();
169  }
170  }
171  }
172 
175 }
176 
177 
179 {
180  if (!hex.valid())
181  return;
182 
183  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
184 
186  if (u) {
187  displayedUnitHex_ = hex;
188  invalidate_unit();
189  }
190 }
191 
193 {
194  if (src == displayedUnitHex_) {
195  displayedUnitHex_ = dst;
196  invalidate_unit();
197  }
198 }
199 
200 void game_display::scroll_to_leader(int side, SCROLL_TYPE scroll_type,bool force)
201 {
202  unit_map::const_iterator leader = dc_->units().find_leader(side);
203 
204  if(leader.valid()) {
205  scroll_to_tile(leader->get_location(), scroll_type, true, force);
206  }
207 }
208 
210  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
211  w->pre_draw();
212  }
214  /**
215  * @todo FIXME: must modify changed, but best to do it at the
216  * floating_label level
217  */
218  chat_man_->prune_chat_messages();
219 }
220 
221 
223  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
224  w->post_draw();
225  }
226 }
227 
229 {
230  halo_man_->unrender(invalidated_);
232  if (fake_unit_man_->empty()) {
233  return;
234  }
235  unit_drawer drawer = unit_drawer(*this);
236 
237  for (const unit* temp_unit : *fake_unit_man_) {
238  const map_location& loc = temp_unit->get_location();
240  if (invalidated_.find(loc) != invalidated_.end()
241  && (request == exclusive_unit_draw_requests_.end() || request->second == temp_unit->id()))
242  drawer.redraw_unit(*temp_unit);
243  }
244 }
245 
247 {
248  halo_man_->render();
249 }
250 
252 {
253  const bool on_map = get_map().on_board(loc);
254  const bool is_shrouded = shrouded(loc);
255 // const bool is_fogged = fogged(loc);
256  const int xpos = get_location_x(loc);
257  const int ypos = get_location_y(loc);
258 
259 // image::TYPE image_type = get_image_type(loc);
260 
261  display::draw_hex(loc);
262 
263  if(cursor::get() == cursor::WAIT) {
264  // Interaction is disabled, so we don't need anything else
265  return;
266  }
267 
268  if(on_map && loc == mouseoverHex_) {
269  drawing_layer hex_top_layer = LAYER_MOUSEOVER_BOTTOM;
271  if( u != nullptr ) {
272  hex_top_layer = LAYER_MOUSEOVER_TOP;
273  }
274  if(u == nullptr) {
275  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
276  image::get_image("misc/hover-hex-top.png~RC(magenta>gold)", image::SCALED_TO_HEX));
278  image::get_image("misc/hover-hex-bottom.png~RC(magenta>gold)", image::SCALED_TO_HEX));
279  } else if(dc_->teams()[currentTeam_].is_enemy(u->side())) {
280  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
281  image::get_image("misc/hover-hex-enemy-top.png~RC(magenta>red)", image::SCALED_TO_HEX));
283  image::get_image("misc/hover-hex-enemy-bottom.png~RC(magenta>red)", image::SCALED_TO_HEX));
284  } else if(dc_->teams()[currentTeam_].side() == u->side()) {
285  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
286  image::get_image("misc/hover-hex-top.png~RC(magenta>green)", image::SCALED_TO_HEX));
288  image::get_image("misc/hover-hex-bottom.png~RC(magenta>green)", image::SCALED_TO_HEX));
289  } else {
290  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
291  image::get_image("misc/hover-hex-top.png~RC(magenta>lightblue)", image::SCALED_TO_HEX));
293  image::get_image("misc/hover-hex-bottom.png~RC(magenta>lightblue)", image::SCALED_TO_HEX));
294  }
295  }
296 
297 
298 
299  // Draw reach_map information.
300  // We remove the reachability mask of the unit
301  // that we want to attack.
302  if (!is_shrouded && !reach_map_.empty()
303  && reach_map_.find(loc) == reach_map_.end() && loc != attack_indicator_dst_) {
305  drawing_buffer_add(LAYER_REACHMAP, loc, xpos, ypos,
307  }
308 
309  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
310  w->draw_hex(loc);
311 
312  if (!(w->is_active() && w->has_temp_move()))
313  {
314  std::vector<surface> footstepImages = footsteps_images(loc, route_, dc_);
315  if (!footstepImages.empty()) {
317  }
318  }
319  }
320  // Draw the attack direction indicator
321  if(on_map && loc == attack_indicator_src_) {
323  image::get_image("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", image::SCALED_TO_HEX));
324  } else if (on_map && loc == attack_indicator_dst_) {
326  image::get_image("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", image::SCALED_TO_HEX));
327  }
328 
329  // Linger overlay unconditionally otherwise it might give glitches
330  // so it's drawn over the shroud and fog.
331  if(mode_ != RUNNING) {
333  drawing_buffer_add(LAYER_LINGER_OVERLAY, loc, xpos, ypos,
335  }
336 
337  if(on_map && loc == selectedHex_ && !game_config::images::selected.empty()) {
339  drawing_buffer_add(LAYER_SELECTED_HEX, loc, xpos, ypos,
341  }
342 
343  // Show def% and turn to reach info
344  if(!is_shrouded && on_map) {
345  draw_movement_info(loc);
346  }
347 
348  if(game_config::debug) {
349  int debugH = debugHighlights_[loc];
350  if (debugH) {
351  std::string txt = std::to_string(debugH);
353  }
354  }
355  //simulate_delay += 1;
356 }
357 
359 {
361 }
362 
364 {
366 }
367 
369 {
370  if ( !team_valid() )
371  return;
372 
373  refresh_report("report_clock");
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  }
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 }
The overlay used for the linger mode.
Definition: display.hpp:850
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: image.cpp:920
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
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
Definition: display.cpp:726
std::string attack_indicator_direction() const
Function to get attack direction suffix.
virtual void select_hex(map_location hex)
Definition: display.cpp:1626
::tod_manager * tod_manager
Definition: resources.cpp:29
void set_game_mode(const game_mode mode)
size_t currentTeam_
Definition: display.hpp:730
reports * reports_object_
Definition: display.hpp:752
unit_iterator end()
Definition: map.hpp:415
std::vector< char_t > string
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:287
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:3020
This class represents a single unit of a specific type.
Definition: unit.hpp:100
void set_move(double xmove, double ymove)
void invalidate_route()
size_t count(const map_location &loc) const
Definition: map.hpp:400
bool team_valid() const
Definition: display.cpp:716
bool reach_map_changed_
Definition: display.hpp:1023
std::string current_team_name() const
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
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
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
Definition: display.cpp:2546
map_location mouseoverHex_
Definition: display.hpp:783
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:1585
dest_vect destinations
Definition: pathfind.hpp:99
void draw_text_in_hex(const map_location &loc, const drawing_layer layer, const std::string &text, 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:1532
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:1021
#define h
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
Definition: display.cpp:731
Bottom half of image following the mouse.
Definition: display.hpp:839
map_location displayedUnitHex_
map_location selectedHex_
Definition: display.hpp:782
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:735
drawing_layer
The layers to render something on.
Definition: display.hpp:811
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:778
Unit and team statistics.
int get_location_y(const map_location &loc) const
Definition: display.cpp:736
bool has_time_area() const
Top half of image following the mouse.
Definition: display.hpp:819
const time_of_day & get_previous_time_of_day() const
#define b
static lg::log_domain log_display("display")
t_translation::terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:301
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
Image on the selected unit.
Definition: display.hpp:843
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:1172
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
Definition: location.hpp:343
virtual void draw_invalidated() override
Only called when there's actual redrawing to do.
bool valid() const
Definition: location.hpp:74
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)
Applies the planned unit map for the duration of the struct's life.
Definition: manager.hpp:251
map_location curr
Definition: pathfind.hpp:87
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.hpp:612
#define fxpdiv(x, y)
IN: unsigned and int - OUT: fixed_t.
Definition: math.hpp:318
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:444
void highlight_another_reach(const pathfind::paths &paths_list)
Add more paths to highlight.
bool invalidateGameStatus_
Definition: display.hpp:750
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
void create_buttons()
Definition: display.cpp:891
Structure which holds a single route and marks for special events.
Definition: pathfind.hpp:140
const color_t YELLOW_COLOR
static const map_location & null_location()
Definition: location.hpp:224
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:3010
pathfind::marked_route route_
int32_t fixed_t
Definition: math.hpp:307
virtual void draw_hex(const map_location &loc) override
Redraws a single gamemap location.
const color_t NORMAL_COLOR
std::unique_ptr< halo::manager > halo_man_
Definition: display.hpp:653
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Definition: math.hpp:312
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)
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
double turbo_speed() const
Definition: display.cpp:2393
void process_reachmap_changes()
Definition: display.cpp:3235
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
surface tod_hex_mask1
Definition: display.hpp:778
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:2196
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1634
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
Definition: display.cpp:721
virtual void select_hex(map_location hex) override
Function to display a location as selected.
bool dont_show_all_
Definition: display.hpp:731
size_t i
Definition: function.cpp:933
CURSOR_TYPE get()
Definition: cursor.cpp:194
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:2583
int w
Movement info (defense%, etc...).
Definition: display.hpp:849
std::vector< std::string > foot_speed_prefix
virtual bool has_time_area() const override
static lg::log_domain log_engine("engine")
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Definition: map.cpp:369
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
overlay_map overlay_map_
void assign(SDL_Surface *surf)
Definition: surface.hpp:46
bool show_floating_labels()
Definition: game.cpp:842
std::string foot_teleport_exit
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:658
bool unhighlight_reach()
Reset highlighting of paths.
const gamemap & get_map() const
Definition: display.hpp:91
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:774
bool find(E event, F functor)
Tests whether an event handler is available.
const display_context * dc_
Definition: display.hpp:652
this module manages the cache of images.
Definition: image.cpp:103
Standard logging facilities (interface).
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:195
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 char * name(const std::vector< SDL_Joystick * > &joysticks, const size_t index)
Definition: joystick.cpp:48
virtual void post_draw() override
Calls the whiteboard's post-draw method.
map_location attack_indicator_dst_
const std::unique_ptr< fake_unit_manager > fake_unit_man_
Definition: display.hpp:738
unit_iterator find(size_t id)
Definition: map.cpp:311
size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:101
bool valid() const
Definition: map.hpp:276
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:93
void clear_screen()
Clear the screen contents.
Definition: video.cpp:370
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()
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:54
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
int side() const
The side this unit belongs to.
Definition: unit.hpp:244
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:2802
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:654
std::vector< map_location > & steps
Definition: pathfind.hpp:186
Definition: display.hpp:47
Layer which holds the attack indicator.
Definition: display.hpp:844
Footsteps showing path from unit to mouse.
Definition: display.hpp:818
const color_t BAD_COLOR
"black stripes" on unreachable hexes.
Definition: display.hpp:838
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:485
const std::vector< map_location > & route_
Definition: move.cpp:292
void replace_overlay_map(overlay_map *overlays)
Definition: display.hpp:1063
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.