The Battle for Wesnoth  1.17.0-dev
game_display.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2021
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  * During a game, show map & info-panels at top+right.
19  */
20 
21 #include "game_display.hpp"
22 
23 #include "gettext.hpp"
24 #include "wesconfig.h"
25 
26 #include "cursor.hpp"
27 #include "display_chat_manager.hpp"
28 #include "fake_unit_manager.hpp"
29 #include "fake_unit_ptr.hpp"
30 #include "floating_label.hpp"
31 #include "game_board.hpp"
32 #include "preferences/game.hpp"
33 #include "halo.hpp"
34 #include "log.hpp"
35 #include "map/map.hpp"
36 #include "map/label.hpp"
37 #include "font/standard_colors.hpp"
38 #include "reports.hpp"
39 #include "resources.hpp"
40 #include "tod_manager.hpp"
41 #include "color.hpp"
42 #include "synced_context.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 
66  std::weak_ptr<wb::manager> wb,
67  reports& reports_object,
68  const config& theme_cfg,
69  const config& level)
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  , in_game_(false)
77  , chat_man_(new display_chat_manager(*this))
78  , mode_(RUNNING)
79  , needs_rebuild_(false)
80 {
81  video().clear_screen();
82 }
83 
85 {
86  try {
87  chat_man_->prune_chat_messages(true);
88  } catch(...) {
89  }
90 }
91 
93 {
94  static bool first_turn = true;
96 
97  // We want to skip this on the first run of this function
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 = 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 = 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 = nullptr;
133  tod_hex_mask2 = 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()) {
383  refresh_report(name);
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  const map_location& goal)
561 {
562  // Fold endpoints of routes into reachability map.
563  for (const pathfind::paths::step &dest : paths_list.destinations) {
564  reach_map_[dest.curr]++;
565  }
566  reach_map_changed_ = true;
567 
568  if(goal != map_location::null_location() && paths_list.destinations.contains(goal)) {
569  const auto& path_to_goal = paths_list.destinations.get_path(paths_list.destinations.find(goal));
570  const map_location enemy_unit_location = path_to_goal[0];
571  units_that_can_reach_goal_.insert(enemy_unit_location);
572  }
573 }
574 
576 {
578  if(!reach_map_.empty()) {
579  reach_map_.clear();
580  reach_map_changed_ = true;
581  return true;
582  } else {
583  return false;
584  }
585 }
586 
588 {
589  for(std::vector<map_location>::const_iterator i = route_.steps.begin();
590  i != route_.steps.end(); ++i) {
591  invalidate(*i);
592  }
593 }
594 
596 {
598 
599  if(route != nullptr) {
600  route_ = *route;
601  } else {
602  route_.steps.clear();
603  route_.marks.clear();
604  }
605 
607 }
608 
609 void game_display::float_label(const map_location& loc, const std::string& text, const color_t& color)
610 {
611  if(preferences::show_floating_labels() == false || fogged(loc)) {
612  return;
613  }
614 
615  font::floating_label flabel(text);
617  flabel.set_color(color);
618  flabel.set_position(get_location_x(loc)+zoom_/2, get_location_y(loc));
619  flabel.set_move(0, -0.1 * turbo_speed());
620  flabel.set_lifetime(1000/turbo_speed());
622 
623  font::add_floating_label(flabel);
624 }
625 
627 {
628  assert(game_config::debug);
629  return debugHighlights_[loc];
630 }
631 
633 {
634  if (attack_indicator_src_ != src || attack_indicator_dst_ != dst) {
637 
638  attack_indicator_src_ = src;
639  attack_indicator_dst_ = dst;
640 
643  }
644 }
645 
647 {
649 }
650 
652 {
653  if (team_valid())
654  {
655  return dc_->teams()[currentTeam_].team_name();
656  }
657  return std::string();
658 }
659 
661 {
662  in_game_ = true;
663  create_buttons();
664  invalidate_all();
665 }
666 
668  if (b) {
669  needs_rebuild_ = true;
670  }
671 }
672 
674  if (needs_rebuild_) {
675  needs_rebuild_ = false;
677  invalidate_all();
678  rebuild_all();
679  return true;
680  }
681  return false;
682 }
683 
685 {
686  return overlay_map_;
687 }
The overlay used for the linger mode.
Definition: display.hpp:863
surface get_image(const image::locator &i_locator, TYPE type)
Caches and returns an image.
Definition: picture.cpp:816
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:51
virtual void select_hex(map_location hex)
Definition: display.cpp:1620
::tod_manager * tod_manager
Definition: resources.cpp:30
void set_game_mode(const game_mode mode)
reports * reports_object_
Definition: display.hpp:771
unit_iterator end()
Definition: map.hpp:429
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:296
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:96
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
Definition: display.cpp:3026
This class represents a single unit of a specific type.
Definition: unit.hpp:121
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:1040
unit_iterator find_leader(int side)
Definition: map.cpp:328
map_location attack_indicator_src_
static const int UNREACHABLE
Magic value that signifies a hex is unreachable.
Definition: movetype.hpp:176
virtual void draw_invalidated()
Only called when there&#39;s actual redrawing to do.
Definition: display.cpp:2551
map_location mouseoverHex_
Definition: display.hpp:796
void set_lifetime(int lifetime, int fadeout=100)
void invalidate_unit()
Function to invalidate that unit status displayed on the sidebar.
std::string unreachable
std::set< map_location > units_that_can_reach_goal_
const std::set< std::string > & report_list()
Definition: reports.cpp:1772
dest_vect destinations
Definition: pathfind.hpp:101
int viewing_side() const
Definition: display.hpp:107
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:32
game_mode mode_
reach_map reach_map_
Definition: display.hpp:1038
#define h
Bottom half of image following the mouse.
Definition: display.hpp:852
map_location displayedUnitHex_
map_location selectedHex_
Definition: display.hpp:795
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_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e., 72 means 100%.
Definition: display.hpp:753
drawing_layer
The layers to render something on.
Definition: display.hpp:824
Same as SCALED_TO_HEX, but with Time of Day color tint applied.
Definition: picture.hpp:240
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:791
game_display(game_board &board, std::weak_ptr< wb::manager > wb, reports &reports_object, const config &theme_cfg, const config &level)
Unit and team statistics.
bool team_valid() const
Definition: display.cpp:735
Top half of image following the mouse.
Definition: display.hpp:832
#define b
static lg::log_domain log_display("display")
void highlight_another_reach(const pathfind::paths &paths_list, const map_location &goal=map_location::null_location())
Add more paths to highlight.
no linger overlay, show fog and shroud.
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:56
Image on the selected unit.
Definition: display.hpp:856
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:1087
double turbo_speed() const
Definition: display.cpp:2400
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:211
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:1043
Applies the planned unit map for the duration of the struct&#39;s life.
Definition: manager.hpp:252
map_location curr
Definition: pathfind.hpp:89
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:302
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.hpp:619
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:56
bool valid() const
Definition: location.hpp:89
#define fxpdiv(x, y)
IN: unsigned and int - OUT: fixed_t.
Definition: math.hpp:324
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:21
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:459
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:1523
bool invalidateGameStatus_
Definition: display.hpp:769
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:414
void create_buttons()
Definition: display.cpp:879
Structure which holds a single route and marks for special events.
Definition: pathfind.hpp:141
const color_t YELLOW_COLOR
void needs_rebuild(bool b)
Sets whether the screen (map visuals) needs to be rebuilt.
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:3019
pathfind::marked_route route_
int32_t fixed_t
Definition: math.hpp:313
virtual void draw_hex(const map_location &loc) override
Redraws a single gamemap location.
std::vector< map_location > get_path(const const_iterator &) const
Returns the path going from the source point (included) to the destination point j (excluded)...
Definition: pathfind.cpp:498
std::string attack_indicator_direction() const
Function to get attack direction suffix.
static bool is_synced()
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:745
Generic locator abstracting the location of an image.
Definition: picture.hpp:60
std::unique_ptr< halo::manager > halo_man_
Definition: display.hpp:661
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Definition: math.hpp:318
Encapsulates the map of the game.
Definition: location.hpp:38
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:740
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
unit_iterator find(std::size_t id)
Definition: map.cpp:310
void process_reachmap_changes()
Definition: display.cpp:3199
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:503
surface tod_hex_mask1
Definition: display.hpp:791
std::size_t i
Definition: function.cpp:967
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:2203
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1628
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:739
int get_location_y(const map_location &loc) const
Definition: display.cpp:755
CURSOR_TYPE get()
Definition: cursor.cpp:216
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Definition: map.cpp:385
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:40
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
Definition: display.cpp:2588
int w
Movement info (defense%, etc...).
Definition: display.hpp:862
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:1209
overlay_map overlay_map_
bool show_floating_labels()
Definition: game.cpp:837
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:750
const gamemap & get_map() const
Definition: display.hpp:96
Image rescaled to fit into a hexagonal tile according to the zoom settings.
Definition: picture.hpp:238
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:666
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:92
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:787
const display_context * dc_
Definition: display.hpp:660
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:106
bool contains(const map_location &) const
Definition: pathfind.cpp:515
Functions to load and save images from/to disk.
Standard logging facilities (interface).
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:201
Object which contains all the possible locations a unit can move to, with associated best routes to t...
Definition: pathfind.hpp:72
virtual void pre_draw() override
game_display pre_draw does specific things related e.g.
static const map_location & null_location()
Definition: location.hpp:81
virtual void post_draw() override
Calls the whiteboard&#39;s post-draw method.
const int SIZE_FLOAT_LABEL
Definition: constants.cpp:32
map_location attack_indicator_dst_
const std::unique_ptr< fake_unit_manager > fake_unit_man_
Definition: display.hpp:757
int side() const
The side this unit belongs to.
Definition: unit.hpp:334
const_iterator find(const map_location &) const
Definition: pathfind.cpp:479
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:61
bool valid() const
Definition: map.hpp:274
void clear_screen()
Clear the screen contents.
Definition: video.cpp:345
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 display_unit_hex(map_location hex)
Change the unit to be displayed in the sidebar.
std::string::const_iterator iterator
Definition: tokenizer.hpp:25
unit_map::iterator find_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:183
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Redraws the specified report (if anything has changed).
Definition: display.cpp:2806
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:662
std::vector< map_location > & steps
Definition: pathfind.hpp:187
Definition: display.hpp:49
Layer which holds the attack indicator.
Definition: display.hpp:857
Footsteps showing path from unit to mouse.
Definition: display.hpp:831
const color_t BAD_COLOR
"black stripes" on unreachable hexes.
Definition: display.hpp:851
std::size_t currentTeam_
Definition: display.hpp:738
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:504
const std::vector< map_location > & route_
Definition: move.cpp:295
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.