The Battle for Wesnoth  1.17.5+dev
game_display.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2022
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 "sdl/utils.hpp"
41 #include "tod_manager.hpp"
42 #include "color.hpp"
43 #include "synced_context.hpp"
44 #include "units/unit.hpp"
45 #include "units/drawer.hpp"
46 #include "whiteboard/manager.hpp"
47 #include "overlay.hpp"
48 
49 static lg::log_domain log_display("display");
50 #define ERR_DP LOG_STREAM(err, log_display)
51 #define LOG_DP LOG_STREAM(info, log_display)
52 
53 static lg::log_domain log_engine("engine");
54 #define ERR_NG LOG_STREAM(err, log_engine)
55 
56 std::map<map_location, int> game_display::debugHighlights_;
57 
58 /**
59  * Function to return 2 half-hex footsteps images for the given location.
60  * Only loc is on the current route set by set_route.
61  *
62  * This function is only used internally by game_display so I have moved it out of the header into the compilaton unit.
63  */
64 std::vector<texture> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
65 
67  std::weak_ptr<wb::manager> wb,
68  reports& reports_object,
69  const std::string& theme_id,
70  const config& level)
71  : display(&board, wb, reports_object, theme_id, level, false)
72  , overlay_map_()
73  , attack_indicator_src_()
74  , attack_indicator_dst_()
75  , route_()
76  , displayedUnitHex_()
77  , in_game_(false)
78  , chat_man_(new display_chat_manager(*this))
79  , mode_(RUNNING)
80  , needs_rebuild_(false)
81 {
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) {
102  // TODO: highdpi - textures
103  // TODO: highdpi - make sure these are scaled correctly
104  surface old_mask(image::get_image(old_tod.image_mask,image::HEXED));
106 
107  const int niterations = static_cast<int>(10/turbo_speed());
108  const int frame_time = 30;
109  const int starting_ticks = SDL_GetTicks();
110  for(int i = 0; i != niterations; ++i) {
111 
112  if(old_mask != nullptr) {
113  // TODO: highdpi - do this on the fly, rather than baking it
114  const int32_t proportion = floating_to_fixed_point(1.0) - fixed_point_divide(i,niterations);
115  adjust_surface_alpha(old_mask, proportion);
116  tod_hex_mask1 = old_mask;
117  }
118 
119  if(new_mask != nullptr) {
120  // TODO: highdpi - do this on the fly, rather than baking it
121  const int32_t proportion = fixed_point_divide(i,niterations);
122  adjust_surface_alpha(new_mask, proportion);
123  tod_hex_mask2 = new_mask;
124  }
125 
126  invalidate_all();
127 
128  const int cur_ticks = SDL_GetTicks();
129  const int wanted_ticks = starting_ticks + i*frame_time;
130  if(cur_ticks < wanted_ticks) {
131  SDL_Delay(wanted_ticks - cur_ticks);
132  }
133  }
134  }
135 
136  tod_hex_mask1 = nullptr;
137  tod_hex_mask2 = nullptr;
138  }
139 
140  first_turn = false;
141 
143 
144  invalidate_all();
145 }
146 
148 {
149  if(hex.valid() && fogged(hex)) {
150  return;
151  }
152  display::select_hex(hex);
153 
154  display_unit_hex(hex);
155 }
156 
158 {
159  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
160 
162  if (u) {
163  displayedUnitHex_ = hex;
164  invalidate_unit();
165  } else {
167  if (u) {
168  // mouse moved from unit hex to non-unit hex
169  if (dc_->units().count(selectedHex_)) {
171  invalidate_unit();
172  }
173  }
174  }
175 
178 }
179 
180 
182 {
183  if (!hex.valid())
184  return;
185 
186  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
187 
189  if (u) {
190  displayedUnitHex_ = hex;
191  invalidate_unit();
192  }
193 }
194 
196 {
197  if (src == displayedUnitHex_) {
198  displayedUnitHex_ = dst;
199  invalidate_unit();
200  }
201 }
202 
203 void game_display::scroll_to_leader(int side, SCROLL_TYPE scroll_type,bool force)
204 {
205  unit_map::const_iterator leader = dc_->units().find_leader(side);
206 
207  if(leader.valid() && leader->is_visible_to_team(dc_->get_team(viewing_side()), false)) {
208  scroll_to_tile(leader->get_location(), scroll_type, true, force);
209  }
210 }
211 
213  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
214  w->pre_draw();
215  }
217  /**
218  * @todo FIXME: must modify changed, but best to do it at the
219  * floating_label level
220  */
221  chat_man_->prune_chat_messages();
222 }
223 
224 
226  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
227  w->post_draw();
228  }
229 }
230 
232 {
234  if (fake_unit_man_->empty()) {
235  return;
236  }
237  unit_drawer drawer = unit_drawer(*this);
238 
239  for (const unit* temp_unit : *fake_unit_man_) {
240  const map_location& loc = temp_unit->get_location();
242  if (invalidated_.find(loc) != invalidated_.end()
243  && (request == exclusive_unit_draw_requests_.end() || request->second == temp_unit->id()))
244  drawer.redraw_unit(*temp_unit);
245  }
246 }
247 
249 {
250  halo_man_->render();
251 }
252 
254 {
255  const bool on_map = get_map().on_board(loc);
256  const bool is_shrouded = shrouded(loc);
257 // const bool is_fogged = fogged(loc);
258  const int xpos = get_location_x(loc);
259  const int ypos = get_location_y(loc);
260  const int zoom = int(zoom_);
261  const SDL_Rect dest{xpos, ypos, zoom, zoom};
262 
263  display::draw_hex(loc);
264 
265  if(cursor::get() == cursor::WAIT) {
266  // Interaction is disabled, so we don't need anything else
267  return;
268  }
269 
270  if(on_map && loc == mouseoverHex_ && !map_screenshot_) {
271  drawing_layer hex_top_layer = LAYER_MOUSEOVER_BOTTOM;
273  if( u != nullptr ) {
274  hex_top_layer = LAYER_MOUSEOVER_TOP;
275  }
276  if(u == nullptr) {
277  drawing_buffer_add( hex_top_layer, loc, dest,
278  image::get_texture("misc/hover-hex-top.png~RC(magenta>gold)", image::HEXED));
280  image::get_texture("misc/hover-hex-bottom.png~RC(magenta>gold)", image::HEXED));
281  } else if(dc_->teams()[currentTeam_].is_enemy(u->side())) {
282  drawing_buffer_add( hex_top_layer, loc, dest,
283  image::get_texture("misc/hover-hex-enemy-top.png~RC(magenta>red)", image::HEXED));
285  image::get_texture("misc/hover-hex-enemy-bottom.png~RC(magenta>red)", image::HEXED));
286  } else if(dc_->teams()[currentTeam_].side() == u->side()) {
287  drawing_buffer_add( hex_top_layer, loc, dest,
288  image::get_texture("misc/hover-hex-top.png~RC(magenta>green)", image::HEXED));
290  image::get_texture("misc/hover-hex-bottom.png~RC(magenta>green)", image::HEXED));
291  } else {
292  drawing_buffer_add( hex_top_layer, loc, dest,
293  image::get_texture("misc/hover-hex-top.png~RC(magenta>lightblue)", image::HEXED));
295  image::get_texture("misc/hover-hex-bottom.png~RC(magenta>lightblue)", image::HEXED));
296  }
297  }
298 
299 
300 
301  // Draw reach_map information.
302  // We remove the reachability mask of the unit
303  // that we want to attack.
304  if (!is_shrouded && !reach_map_.empty()
305  && reach_map_.find(loc) == reach_map_.end() && loc != attack_indicator_dst_) {
308  image::get_texture(unreachable,image::HEXED));
309  }
310 
311  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
312  w->draw_hex(loc);
313 
314  if (!(w->is_active() && w->has_temp_move()))
315  {
316  std::vector<texture> footstepImages = footsteps_images(loc, route_, dc_);
317  if (!footstepImages.empty()) {
318  drawing_buffer_add(LAYER_FOOTSTEPS, loc, dest, footstepImages);
319  }
320  }
321  }
322  // Draw the attack direction indicator
323  if(on_map && loc == attack_indicator_src_) {
325  image::get_texture("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", image::HEXED));
326  } else if (on_map && loc == attack_indicator_dst_) {
328  image::get_texture("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", image::HEXED));
329  }
330 
331  // Linger overlay unconditionally otherwise it might give glitches
332  // so it's drawn over the shroud and fog.
333  if(mode_ != RUNNING) {
337  }
338 
339  if(on_map && loc == selectedHex_ && !game_config::images::selected.empty()) {
342  image::get_texture(selected, image::HEXED));
343  }
344 
345  // Show def% and turn to reach info
346  if(!is_shrouded && on_map) {
347  draw_movement_info(loc);
348  }
349 
350  if(game_config::debug) {
351  int debugH = debugHighlights_[loc];
352  if (debugH) {
353  std::string txt = std::to_string(debugH);
355  }
356  }
357  //simulate_delay += 1;
358 }
359 
361 {
363 }
364 
366 {
368 }
369 
371 {
372  if ( !team_valid() )
373  return;
374 
375  refresh_report("report_clock");
376  refresh_report("report_battery");
377  refresh_report("report_countdown");
378 
380  {
381  wb::future_map future; // start planned unit map scope
382 
383  // We display the unit the mouse is over if it is over a unit,
384  // otherwise we display the unit that is selected.
385  for (const std::string &name : reports_object_->report_list()) {
386  refresh_report(name);
387  }
388  invalidateGameStatus_ = false;
389  }
390 }
391 
392 
394 {
395  if(mode != mode_) {
396  mode_ = mode;
397  invalidate_all();
398  }
399 }
400 
402 {
403  // Search if there is a mark here
405 
406  std::shared_ptr<wb::manager> wb = wb_.lock();
407 
408  // Don't use empty route or the first step (the unit will be there)
409  if(w != route_.marks.end()
410  && !route_.steps.empty() && route_.steps.front() != loc) {
411  const unit_map::const_iterator un =
412  (wb && wb->get_temp_move_unit().valid()) ?
413  wb->get_temp_move_unit() : dc_->units().find(route_.steps.front());
414  if(un != dc_->units().end()) {
415  // Display the def% of this terrain
416  int move_cost = un->movement_cost(get_map().get_terrain(loc));
417  int def = (move_cost == movetype::UNREACHABLE ?
418  0 : 100 - un->defense_modifier(get_map().get_terrain(loc)));
419  std::stringstream def_text;
420  def_text << def << "%";
421 
422  color_t color = game_config::red_to_green(def, false);
423 
424  // simple mark (no turn point) use smaller font
425  int def_font = w->second.turns > 0 ? 18 : 16;
426  draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
427 
428  const int xpos = get_location_x(loc);
429  const int ypos = get_location_y(loc);
430  const int zoom = int(zoom_);
431  const SDL_Rect dest{xpos, ypos, zoom, zoom};
432 
433  if (w->second.invisible) {
435  image::get_texture("misc/hidden.png", image::HEXED));
436  }
437 
438  if (w->second.zoc) {
440  image::get_texture("misc/zoc.png", image::HEXED));
441  }
442 
443  if (w->second.capture) {
445  image::get_texture("misc/capture.png", image::HEXED));
446  }
447 
448  //we display turn info only if different from a simple last "1"
449  if (w->second.turns > 1 || (w->second.turns == 1 && loc != route_.steps.back())) {
450  std::stringstream turns_text;
451  turns_text << w->second.turns;
452  draw_text_in_hex(loc, LAYER_MOVE_INFO, turns_text.str(), 17, font::NORMAL_COLOR, 0.5,0.8);
453  }
454 
455  // The hex is full now, so skip the "show enemy moves"
456  return;
457  }
458  }
459  // When out-of-turn, it's still interesting to check out the terrain defs of the selected unit
460  else if (selectedHex_.valid() && loc == mouseoverHex_)
461  {
464  if(selectedUnit != dc_->units().end() && mouseoveredUnit == dc_->units().end()) {
465  // Display the def% of this terrain
466  int move_cost = selectedUnit->movement_cost(get_map().get_terrain(loc));
467  int def = (move_cost == movetype::UNREACHABLE ?
468  0 : 100 - selectedUnit->defense_modifier(get_map().get_terrain(loc)));
469  std::stringstream def_text;
470  def_text << def << "%";
471 
472  color_t color = game_config::red_to_green(def, false);
473 
474  // use small font
475  int def_font = 16;
476  draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
477  }
478  }
479 
480  if (!reach_map_.empty()) {
481  reach_map::iterator reach = reach_map_.find(loc);
482  if (reach != reach_map_.end() && reach->second > 1) {
483  const std::string num = std::to_string(reach->second);
485  }
486  }
487 }
488 
489 // TODO: highdpi - make sure the result of this gets scaled where it's used
490 std::vector<texture> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_)
491 {
492  std::vector<texture> res;
493 
494  if (route_.steps.size() < 2) {
495  return res; // no real "route"
496  }
497 
498  std::vector<map_location>::const_iterator i =
499  std::find(route_.steps.begin(),route_.steps.end(),loc);
500 
501  if( i == route_.steps.end()) {
502  return res; // not on the route
503  }
504 
505  // Check which footsteps images of game_config we will use
506  int move_cost = 1;
507  const unit_map::const_iterator u = dc_->units().find(route_.steps.front());
508  if(u != dc_->units().end()) {
509  move_cost = u->movement_cost(dc_->map().get_terrain(loc));
510  }
511  int image_number = std::min<int>(move_cost, game_config::foot_speed_prefix.size());
512  if (image_number < 1) {
513  return res; // Invalid movement cost or no images
514  }
515  const std::string foot_speed_prefix = game_config::foot_speed_prefix[image_number-1];
516 
517  texture teleport;
518 
519  // We draw 2 half-hex (with possibly different directions),
520  // but skip the first for the first step.
521  const int first_half = (i == route_.steps.begin()) ? 1 : 0;
522  // and the second for the last step
523  const int second_half = (i+1 == route_.steps.end()) ? 0 : 1;
524 
525  for (int h = first_half; h <= second_half; ++h) {
526  const std::string sense( h==0 ? "-in" : "-out" );
527 
528  if (!tiles_adjacent(*(i+(h-1)), *(i+h))) {
529  std::string teleport_image =
531  teleport = image::get_texture(teleport_image, image::HEXED);
532  continue;
533  }
534 
535  // In function of the half, use the incoming or outgoing direction
536  map_location::DIRECTION dir = (i+(h-1))->get_relative_dir(*(i+h));
537 
538  std::string rotate;
539  if (dir > map_location::SOUTH_EAST) {
540  // No image, take the opposite direction and do a 180 rotation
541  dir = i->get_opposite_dir(dir);
542  rotate = "~FL(horiz)~FL(vert)";
543  }
544 
545  const std::string image = foot_speed_prefix
546  + sense + "-" + i->write_direction(dir)
547  + ".png" + rotate;
548 
549  res.push_back(image::get_texture(image, image::HEXED));
550  }
551 
552  // we draw teleport image (if any) in last
553  if (teleport != nullptr) res.push_back(teleport);
554 
555  return res;
556 }
557 
558 
559 
561 {
563  highlight_another_reach(paths_list);
564 }
565 
567  const map_location& goal)
568 {
569  // Fold endpoints of routes into reachability map.
570  for (const pathfind::paths::step &dest : paths_list.destinations) {
571  reach_map_[dest.curr]++;
572  }
573  reach_map_changed_ = true;
574 
575  if(goal != map_location::null_location() && paths_list.destinations.contains(goal)) {
576  const auto& path_to_goal = paths_list.destinations.get_path(paths_list.destinations.find(goal));
577  const map_location enemy_unit_location = path_to_goal[0];
578  units_that_can_reach_goal_.insert(enemy_unit_location);
579  }
580 }
581 
583 {
585  if(!reach_map_.empty()) {
586  reach_map_.clear();
587  reach_map_changed_ = true;
588  return true;
589  } else {
590  return false;
591  }
592 }
593 
595 {
596  for(std::vector<map_location>::const_iterator i = route_.steps.begin();
597  i != route_.steps.end(); ++i) {
598  invalidate(*i);
599  }
600 }
601 
603 {
605 
606  if(route != nullptr) {
607  route_ = *route;
608  } else {
609  route_.steps.clear();
610  route_.marks.clear();
611  }
612 
614 }
615 
616 void game_display::float_label(const map_location& loc, const std::string& text, const color_t& color)
617 {
618  if(preferences::show_floating_labels() == false || fogged(loc)) {
619  return;
620  }
621 
622  font::floating_label flabel(text);
624  flabel.set_color(color);
625  flabel.set_position(get_location_x(loc)+zoom_/2, get_location_y(loc));
626  flabel.set_move(0, -0.1 * turbo_speed() * get_zoom_factor());
627  flabel.set_lifetime(1000/turbo_speed());
629 
630  font::add_floating_label(flabel);
631 }
632 
634 {
635  assert(game_config::debug);
636  return debugHighlights_[loc];
637 }
638 
640 {
641  if (attack_indicator_src_ != src || attack_indicator_dst_ != dst) {
644 
645  attack_indicator_src_ = src;
646  attack_indicator_dst_ = dst;
647 
650  }
651 }
652 
654 {
656 }
657 
659 {
660  if (team_valid())
661  {
662  return dc_->teams()[currentTeam_].team_name();
663  }
664  return std::string();
665 }
666 
668 {
669  in_game_ = true;
670  create_buttons();
671  invalidate_all();
672 }
673 
675  if (b) {
676  needs_rebuild_ = true;
677  }
678 }
679 
681  if (needs_rebuild_) {
682  needs_rebuild_ = false;
684  invalidate_all();
685  rebuild_all();
686  return true;
687  }
688  return false;
689 }
690 
692 {
693  return overlay_map_;
694 }
The overlay used for the linger mode.
Definition: display.hpp:834
surface get_image(const image::locator &i_locator, TYPE type)
[DEPRECATED] Caches and returns an image.
Definition: picture.cpp:864
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:52
virtual void select_hex(map_location hex)
Definition: display.cpp:1617
::tod_manager * tod_manager
Definition: resources.cpp:30
void set_game_mode(const game_mode mode)
reports * reports_object_
Definition: display.hpp:743
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:305
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:3009
This class represents a single unit of a specific type.
Definition: unit.hpp:120
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:1039
static double get_zoom_factor()
Returns the current zoom factor.
Definition: display.hpp:265
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:2514
map_location mouseoverHex_
Definition: display.hpp:768
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:1773
dest_vect destinations
Definition: pathfind.hpp:101
std::vector< texture > 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.
int viewing_side() const
Definition: display.hpp:112
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:1037
#define h
game_display(game_board &board, std::weak_ptr< wb::manager > wb, reports &reports_object, const std::string &theme_id, const config &level)
Bottom half of image following the mouse.
Definition: display.hpp:823
map_location displayedUnitHex_
map_location selectedHex_
Definition: display.hpp:767
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:728
Standard hexagonal tile mask applied, removing portions that don&#39;t fit.
Definition: picture.hpp:241
drawing_layer
The layers to render something on.
Definition: display.hpp:795
Same as HEXED, but with Time of Day color tint applied.
Definition: picture.hpp:243
virtual const gamemap & map() const =0
void new_turn()
Update lighting settings.
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:30
surface tod_hex_mask2
Definition: display.hpp:763
Unit and team statistics.
bool team_valid() const
Definition: display.cpp:725
Top half of image following the mouse.
Definition: display.hpp:803
#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:827
void scroll_to_leader(int side, SCROLL_TYPE scroll_type=ONSCREEN, bool force=true)
Scrolls to the leader of a certain side.
double turbo_speed() const
Definition: display.cpp:2373
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:1042
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:601
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
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
Definition: display.hpp:1022
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:452
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:1487
bool invalidateGameStatus_
Definition: display.hpp:741
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:897
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:3002
pathfind::marked_route route_
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:735
Generic locator abstracting the location of an image.
Definition: picture.hpp:62
std::unique_ptr< halo::manager > halo_man_
Definition: display.hpp:643
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:730
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:3177
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:763
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:2176
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1625
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:714
int get_location_y(const map_location &loc) const
Definition: display.cpp:745
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:2549
static std::map< map_location, int > debugHighlights_
int w
Movement info (defense%, etc...).
Definition: display.hpp:833
const bool & debug
std::vector< std::string > foot_speed_prefix
virtual bool has_time_area() const override
static lg::log_domain log_engine("engine")
overlay_map overlay_map_
bool show_floating_labels()
Definition: game.cpp:823
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:740
const gamemap & get_map() const
Definition: display.hpp:101
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:648
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:103
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:759
const display_context * dc_
Definition: display.hpp:642
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:111
bool contains(const map_location &) const
Definition: pathfind.cpp:515
Functions to load and save images from/to disk.
Standard logging facilities (interface).
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.
void adjust_surface_alpha(surface &surf, int32_t amount)
Definition: utils.cpp:975
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:732
int side() const
The side this unit belongs to.
Definition: unit.hpp:333
constexpr int32_t fixed_point_divide(int n1, int n2)
Definition: math.hpp:215
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:60
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
Definition: picture.cpp:1105
bool valid() const
Definition: map.hpp:274
void set_route(const pathfind::marked_route *route)
Sets the route along which footsteps are drawn to show movement of a unit.
constexpr int32_t floating_to_fixed_point(double n)
Converts a double to a fixed point.
Definition: math.hpp:195
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:2781
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:644
std::vector< map_location > & steps
Definition: pathfind.hpp:187
Definition: display.hpp:49
Layer which holds the attack indicator.
Definition: display.hpp:828
Footsteps showing path from unit to mouse.
Definition: display.hpp:802
const color_t BAD_COLOR
"black stripes" on unreachable hexes.
Definition: display.hpp:822
std::size_t currentTeam_
Definition: display.hpp:713
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:497
const std::vector< map_location > & route_
Definition: move.cpp:295
void drawing_buffer_add(const drawing_layer layer, const map_location &loc, const SDL_Rect &dest, const texture &tex, const SDL_Rect &clip=SDL_Rect(), bool hflip=false, bool vflip=false, uint8_t alpha_mod=SDL_ALPHA_OPAQUE)
Add an item to the drawing buffer.
Definition: display.cpp:1207
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.