The Battle for Wesnoth  1.15.11+dev
game_display.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * During a game, show map & info-panels at top+right.
18  */
19 
20 #include "game_display.hpp"
21 
22 #include "gettext.hpp"
23 #include "wesconfig.h"
24 
25 #include "cursor.hpp"
26 #include "display_chat_manager.hpp"
27 #include "fake_unit_manager.hpp"
28 #include "fake_unit_ptr.hpp"
29 #include "floating_label.hpp"
30 #include "game_board.hpp"
31 #include "preferences/game.hpp"
32 #include "halo.hpp"
33 #include "log.hpp"
34 #include "map/map.hpp"
35 #include "map/label.hpp"
36 #include "font/standard_colors.hpp"
37 #include "reports.hpp"
38 #include "resources.hpp"
39 #include "tod_manager.hpp"
40 #include "color.hpp"
41 #include "synced_context.hpp"
42 #include "units/unit.hpp"
43 #include "units/drawer.hpp"
44 #include "whiteboard/manager.hpp"
45 #include "overlay.hpp"
46 
47 static lg::log_domain log_display("display");
48 #define ERR_DP LOG_STREAM(err, log_display)
49 #define LOG_DP LOG_STREAM(info, log_display)
50 
51 static lg::log_domain log_engine("engine");
52 #define ERR_NG LOG_STREAM(err, log_engine)
53 
54 std::map<map_location,fixed_t> game_display::debugHighlights_;
55 
56 /**
57  * Function to return 2 half-hex footsteps images for the given location.
58  * Only loc is on the current route set by set_route.
59  *
60  * This function is only used internally by game_display so I have moved it out of the header into the compilaton unit.
61  */
62 std::vector<surface> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
63 
65  std::weak_ptr<wb::manager> wb,
66  reports& reports_object,
67  const config& theme_cfg,
68  const config& level)
69  : display(&board, wb, reports_object, theme_cfg, level, false)
70  , overlay_map_()
71  , attack_indicator_src_()
72  , attack_indicator_dst_()
73  , route_()
74  , displayedUnitHex_()
75  , in_game_(false)
76  , chat_man_(new display_chat_manager(*this))
77  , mode_(RUNNING)
78  , needs_rebuild_(false)
79 {
80  video().clear_screen();
81 }
82 
84 {
85  try {
86  chat_man_->prune_chat_messages(true);
87  } catch(...) {
88  }
89 }
90 
92 {
93  static bool first_turn = true;
95 
96  // We want to skip this on the first run of this function
97  if(!first_turn) {
99 
100  if(old_tod.image_mask != tod.image_mask) {
103 
104  const int niterations = static_cast<int>(10/turbo_speed());
105  const int frame_time = 30;
106  const int starting_ticks = SDL_GetTicks();
107  for(int i = 0; i != niterations; ++i) {
108 
109  if(old_mask != nullptr) {
110  const fixed_t proportion = ftofxp(1.0) - fxpdiv(i,niterations);
111  adjust_surface_alpha(old_mask, proportion);
112  tod_hex_mask1 = old_mask;
113  }
114 
115  if(new_mask != nullptr) {
116  const fixed_t proportion = fxpdiv(i,niterations);
117  adjust_surface_alpha(new_mask, proportion);
118  tod_hex_mask2 = new_mask;
119  }
120 
121  invalidate_all();
122 
123  const int cur_ticks = SDL_GetTicks();
124  const int wanted_ticks = starting_ticks + i*frame_time;
125  if(cur_ticks < wanted_ticks) {
126  SDL_Delay(wanted_ticks - cur_ticks);
127  }
128  }
129  }
130 
131  tod_hex_mask1 = nullptr;
132  tod_hex_mask2 = nullptr;
133  }
134 
135  first_turn = false;
136 
138 
139  invalidate_all();
140 }
141 
143 {
144  if(hex.valid() && fogged(hex)) {
145  return;
146  }
147  display::select_hex(hex);
148 
149  display_unit_hex(hex);
150 }
151 
153 {
154  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
155 
157  if (u) {
158  displayedUnitHex_ = hex;
159  invalidate_unit();
160  } else {
162  if (u) {
163  // mouse moved from unit hex to non-unit hex
164  if (dc_->units().count(selectedHex_)) {
166  invalidate_unit();
167  }
168  }
169  }
170 
173 }
174 
175 
177 {
178  if (!hex.valid())
179  return;
180 
181  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
182 
184  if (u) {
185  displayedUnitHex_ = hex;
186  invalidate_unit();
187  }
188 }
189 
191 {
192  if (src == displayedUnitHex_) {
193  displayedUnitHex_ = dst;
194  invalidate_unit();
195  }
196 }
197 
198 void game_display::scroll_to_leader(int side, SCROLL_TYPE scroll_type,bool force)
199 {
200  unit_map::const_iterator leader = dc_->units().find_leader(side);
201 
202  if(leader.valid() && leader->is_visible_to_team(dc_->get_team(viewing_side()), false)) {
203  scroll_to_tile(leader->get_location(), scroll_type, true, force);
204  }
205 }
206 
208  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
209  w->pre_draw();
210  }
212  /**
213  * @todo FIXME: must modify changed, but best to do it at the
214  * floating_label level
215  */
216  chat_man_->prune_chat_messages();
217 }
218 
219 
221  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
222  w->post_draw();
223  }
224 }
225 
227 {
228  halo_man_->unrender(invalidated_);
230  if (fake_unit_man_->empty()) {
231  return;
232  }
233  unit_drawer drawer = unit_drawer(*this);
234 
235  for (const unit* temp_unit : *fake_unit_man_) {
236  const map_location& loc = temp_unit->get_location();
238  if (invalidated_.find(loc) != invalidated_.end()
239  && (request == exclusive_unit_draw_requests_.end() || request->second == temp_unit->id()))
240  drawer.redraw_unit(*temp_unit);
241  }
242 }
243 
245 {
246  halo_man_->render();
247 }
248 
250 {
251  const bool on_map = get_map().on_board(loc);
252  const bool is_shrouded = shrouded(loc);
253 // const bool is_fogged = fogged(loc);
254  const int xpos = get_location_x(loc);
255  const int ypos = get_location_y(loc);
256 
257 // image::TYPE image_type = get_image_type(loc);
258 
259  display::draw_hex(loc);
260 
261  if(cursor::get() == cursor::WAIT) {
262  // Interaction is disabled, so we don't need anything else
263  return;
264  }
265 
266  if(on_map && loc == mouseoverHex_) {
267  drawing_layer hex_top_layer = LAYER_MOUSEOVER_BOTTOM;
269  if( u != nullptr ) {
270  hex_top_layer = LAYER_MOUSEOVER_TOP;
271  }
272  if(u == nullptr) {
273  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
274  image::get_image("misc/hover-hex-top.png~RC(magenta>gold)", image::SCALED_TO_HEX));
276  image::get_image("misc/hover-hex-bottom.png~RC(magenta>gold)", image::SCALED_TO_HEX));
277  } else if(dc_->teams()[currentTeam_].is_enemy(u->side())) {
278  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
279  image::get_image("misc/hover-hex-enemy-top.png~RC(magenta>red)", image::SCALED_TO_HEX));
281  image::get_image("misc/hover-hex-enemy-bottom.png~RC(magenta>red)", image::SCALED_TO_HEX));
282  } else if(dc_->teams()[currentTeam_].side() == u->side()) {
283  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
284  image::get_image("misc/hover-hex-top.png~RC(magenta>green)", image::SCALED_TO_HEX));
286  image::get_image("misc/hover-hex-bottom.png~RC(magenta>green)", image::SCALED_TO_HEX));
287  } else {
288  drawing_buffer_add( hex_top_layer, loc, xpos, ypos,
289  image::get_image("misc/hover-hex-top.png~RC(magenta>lightblue)", image::SCALED_TO_HEX));
291  image::get_image("misc/hover-hex-bottom.png~RC(magenta>lightblue)", image::SCALED_TO_HEX));
292  }
293  }
294 
295 
296 
297  // Draw reach_map information.
298  // We remove the reachability mask of the unit
299  // that we want to attack.
300  if (!is_shrouded && !reach_map_.empty()
301  && reach_map_.find(loc) == reach_map_.end() && loc != attack_indicator_dst_) {
303  drawing_buffer_add(LAYER_REACHMAP, loc, xpos, ypos,
305  }
306 
307  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
308  w->draw_hex(loc);
309 
310  if (!(w->is_active() && w->has_temp_move()))
311  {
312  std::vector<surface> footstepImages = footsteps_images(loc, route_, dc_);
313  if (!footstepImages.empty()) {
315  }
316  }
317  }
318  // Draw the attack direction indicator
319  if(on_map && loc == attack_indicator_src_) {
321  image::get_image("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", image::SCALED_TO_HEX));
322  } else if (on_map && loc == attack_indicator_dst_) {
324  image::get_image("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", image::SCALED_TO_HEX));
325  }
326 
327  // Linger overlay unconditionally otherwise it might give glitches
328  // so it's drawn over the shroud and fog.
329  if(mode_ != RUNNING) {
331  drawing_buffer_add(LAYER_LINGER_OVERLAY, loc, xpos, ypos,
333  }
334 
335  if(on_map && loc == selectedHex_ && !game_config::images::selected.empty()) {
337  drawing_buffer_add(LAYER_SELECTED_HEX, loc, xpos, ypos,
339  }
340 
341  // Show def% and turn to reach info
342  if(!is_shrouded && on_map) {
343  draw_movement_info(loc);
344  }
345 
346  if(game_config::debug) {
347  int debugH = debugHighlights_[loc];
348  if (debugH) {
349  std::string txt = std::to_string(debugH);
351  }
352  }
353  //simulate_delay += 1;
354 }
355 
357 {
359 }
360 
362 {
364 }
365 
367 {
368  if ( !team_valid() )
369  return;
370 
371  refresh_report("report_clock");
372  refresh_report("report_battery");
373  refresh_report("report_countdown");
374 
376  {
377  wb::future_map future; // start planned unit map scope
378 
379  // We display the unit the mouse is over if it is over a unit,
380  // otherwise we display the unit that is selected.
381  for (const std::string &name : reports_object_->report_list()) {
382  refresh_report(name);
383  }
384  invalidateGameStatus_ = false;
385  }
386 }
387 
388 
390 {
391  if(mode != mode_) {
392  mode_ = mode;
393  invalidate_all();
394  }
395 }
396 
398 {
399  // Search if there is a mark here
401 
402  std::shared_ptr<wb::manager> wb = wb_.lock();
403 
404  // Don't use empty route or the first step (the unit will be there)
405  if(w != route_.marks.end()
406  && !route_.steps.empty() && route_.steps.front() != loc) {
407  const unit_map::const_iterator un =
408  (wb && wb->get_temp_move_unit().valid()) ?
409  wb->get_temp_move_unit() : dc_->units().find(route_.steps.front());
410  if(un != dc_->units().end()) {
411  // Display the def% of this terrain
412  int move_cost = un->movement_cost(get_map().get_terrain(loc));
413  int def = (move_cost == movetype::UNREACHABLE ?
414  0 : 100 - un->defense_modifier(get_map().get_terrain(loc)));
415  std::stringstream def_text;
416  def_text << def << "%";
417 
418  color_t color = game_config::red_to_green(def, false);
419 
420  // simple mark (no turn point) use smaller font
421  int def_font = w->second.turns > 0 ? 18 : 16;
422  draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
423 
424  int xpos = get_location_x(loc);
425  int ypos = get_location_y(loc);
426  if (w->second.invisible) {
427  drawing_buffer_add(LAYER_MOVE_INFO, loc, xpos, ypos,
428  image::get_image("misc/hidden.png", image::SCALED_TO_HEX));
429  }
430 
431  if (w->second.zoc) {
432  drawing_buffer_add(LAYER_MOVE_INFO, loc, xpos, ypos,
433  image::get_image("misc/zoc.png", image::SCALED_TO_HEX));
434  }
435 
436  if (w->second.capture) {
437  drawing_buffer_add(LAYER_MOVE_INFO, loc, xpos, ypos,
438  image::get_image("misc/capture.png", image::SCALED_TO_HEX));
439  }
440 
441  //we display turn info only if different from a simple last "1"
442  if (w->second.turns > 1 || (w->second.turns == 1 && loc != route_.steps.back())) {
443  std::stringstream turns_text;
444  turns_text << w->second.turns;
445  draw_text_in_hex(loc, LAYER_MOVE_INFO, turns_text.str(), 17, font::NORMAL_COLOR, 0.5,0.8);
446  }
447 
448  // The hex is full now, so skip the "show enemy moves"
449  return;
450  }
451  }
452  // When out-of-turn, it's still interesting to check out the terrain defs of the selected unit
453  else if (selectedHex_.valid() && loc == mouseoverHex_)
454  {
457  if(selectedUnit != dc_->units().end() && mouseoveredUnit == dc_->units().end()) {
458  // Display the def% of this terrain
459  int move_cost = selectedUnit->movement_cost(get_map().get_terrain(loc));
460  int def = (move_cost == movetype::UNREACHABLE ?
461  0 : 100 - selectedUnit->defense_modifier(get_map().get_terrain(loc)));
462  std::stringstream def_text;
463  def_text << def << "%";
464 
465  color_t color = game_config::red_to_green(def, false);
466 
467  // use small font
468  int def_font = 16;
469  draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
470  }
471  }
472 
473  if (!reach_map_.empty()) {
474  reach_map::iterator reach = reach_map_.find(loc);
475  if (reach != reach_map_.end() && reach->second > 1) {
476  const std::string num = std::to_string(reach->second);
478  }
479  }
480 }
481 
482 std::vector<surface> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_)
483 {
484  std::vector<surface> res;
485 
486  if (route_.steps.size() < 2) {
487  return res; // no real "route"
488  }
489 
490  std::vector<map_location>::const_iterator i =
491  std::find(route_.steps.begin(),route_.steps.end(),loc);
492 
493  if( i == route_.steps.end()) {
494  return res; // not on the route
495  }
496 
497  // Check which footsteps images of game_config we will use
498  int move_cost = 1;
499  const unit_map::const_iterator u = dc_->units().find(route_.steps.front());
500  if(u != dc_->units().end()) {
501  move_cost = u->movement_cost(dc_->map().get_terrain(loc));
502  }
503  int image_number = std::min<int>(move_cost, game_config::foot_speed_prefix.size());
504  if (image_number < 1) {
505  return res; // Invalid movement cost or no images
506  }
507  const std::string foot_speed_prefix = game_config::foot_speed_prefix[image_number-1];
508 
509  surface teleport = nullptr;
510 
511  // We draw 2 half-hex (with possibly different directions),
512  // but skip the first for the first step.
513  const int first_half = (i == route_.steps.begin()) ? 1 : 0;
514  // and the second for the last step
515  const int second_half = (i+1 == route_.steps.end()) ? 0 : 1;
516 
517  for (int h = first_half; h <= second_half; ++h) {
518  const std::string sense( h==0 ? "-in" : "-out" );
519 
520  if (!tiles_adjacent(*(i+(h-1)), *(i+h))) {
521  std::string teleport_image =
523  teleport = image::get_image(teleport_image, image::SCALED_TO_HEX);
524  continue;
525  }
526 
527  // In function of the half, use the incoming or outgoing direction
528  map_location::DIRECTION dir = (i+(h-1))->get_relative_dir(*(i+h));
529 
530  std::string rotate;
531  if (dir > map_location::SOUTH_EAST) {
532  // No image, take the opposite direction and do a 180 rotation
533  dir = i->get_opposite_dir(dir);
534  rotate = "~FL(horiz)~FL(vert)";
535  }
536 
537  const std::string image = foot_speed_prefix
538  + sense + "-" + i->write_direction(dir)
539  + ".png" + rotate;
540 
541  res.push_back(image::get_image(image, image::SCALED_TO_HEX));
542  }
543 
544  // we draw teleport image (if any) in last
545  if (teleport != nullptr) res.push_back(teleport);
546 
547  return res;
548 }
549 
550 
551 
553 {
555  highlight_another_reach(paths_list);
556 }
557 
559  const map_location& goal)
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  if(goal != map_location::null_location() && paths_list.destinations.contains(goal)) {
568  const auto& path_to_goal = paths_list.destinations.get_path(paths_list.destinations.find(goal));
569  const map_location enemy_unit_location = path_to_goal[0];
570  units_that_can_reach_goal_.insert(enemy_unit_location);
571  }
572 }
573 
575 {
577  if(!reach_map_.empty()) {
578  reach_map_.clear();
579  reach_map_changed_ = true;
580  return true;
581  } else {
582  return false;
583  }
584 }
585 
587 {
588  for(std::vector<map_location>::const_iterator i = route_.steps.begin();
589  i != route_.steps.end(); ++i) {
590  invalidate(*i);
591  }
592 }
593 
595 {
597 
598  if(route != nullptr) {
599  route_ = *route;
600  } else {
601  route_.steps.clear();
602  route_.marks.clear();
603  }
604 
606 }
607 
608 void game_display::float_label(const map_location& loc, const std::string& text, const color_t& color)
609 {
610  if(preferences::show_floating_labels() == false || fogged(loc)) {
611  return;
612  }
613 
614  font::floating_label flabel(text);
616  flabel.set_color(color);
617  flabel.set_position(get_location_x(loc)+zoom_/2, get_location_y(loc));
618  flabel.set_move(0, -0.1 * turbo_speed());
619  flabel.set_lifetime(1000/turbo_speed());
621 
622  font::add_floating_label(flabel);
623 }
624 
626 {
627  assert(game_config::debug);
628  return debugHighlights_[loc];
629 }
630 
632 {
633  if (attack_indicator_src_ != src || attack_indicator_dst_ != dst) {
636 
637  attack_indicator_src_ = src;
638  attack_indicator_dst_ = dst;
639 
642  }
643 }
644 
646 {
648 }
649 
651 {
652  if (team_valid())
653  {
654  return dc_->teams()[currentTeam_].team_name();
655  }
656  return std::string();
657 }
658 
660 {
661  in_game_ = true;
662  create_buttons();
663  invalidate_all();
664 }
665 
667  if (b) {
668  needs_rebuild_ = true;
669  }
670 }
671 
673  if (needs_rebuild_) {
674  needs_rebuild_ = false;
676  invalidate_all();
677  rebuild_all();
678  return true;
679  }
680  return false;
681 }
682 
684 {
685  return overlay_map_;
686 }
The overlay used for the linger mode.
Definition: display.hpp:860
surface get_image(const image::locator &i_locator, TYPE type)
Caches and returns an image.
Definition: picture.cpp:815
void invalidate_unit_after_move(const map_location &src, const map_location &dst)
Same as invalidate_unit() if moving the displayed unit.
Game board class.
Definition: game_board.hpp:50
virtual void select_hex(map_location hex)
Definition: display.cpp:1605
::tod_manager * tod_manager
Definition: resources.cpp:29
void set_game_mode(const game_mode mode)
reports * reports_object_
Definition: display.hpp:768
unit_iterator end()
Definition: map.hpp:428
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:293
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:95
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
Definition: display.cpp:3013
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:1037
unit_iterator find_leader(int side)
Definition: map.cpp:327
map_location attack_indicator_src_
static const int UNREACHABLE
Magic value that signifies a hex is unreachable.
Definition: movetype.hpp:175
virtual void draw_invalidated()
Only called when there&#39;s actual redrawing to do.
Definition: display.cpp:2539
map_location mouseoverHex_
Definition: display.hpp:793
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:1765
dest_vect destinations
Definition: pathfind.hpp:100
int viewing_side() const
Definition: display.hpp:105
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:1035
#define h
Bottom half of image following the mouse.
Definition: display.hpp:849
map_location displayedUnitHex_
map_location selectedHex_
Definition: display.hpp:792
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:750
drawing_layer
The layers to render something on.
Definition: display.hpp:821
Same as SCALED_TO_HEX, but with Time of Day color tint applied.
Definition: picture.hpp:239
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:788
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:732
Top half of image following the mouse.
Definition: display.hpp:829
#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:55
Image on the selected unit.
Definition: display.hpp:853
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:1086
double turbo_speed() const
Definition: display.cpp:2388
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:210
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:1040
Applies the planned unit map for the duration of the struct&#39;s life.
Definition: manager.hpp:251
map_location curr
Definition: pathfind.hpp:88
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:297
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.hpp:616
const time_of_day & get_time_of_day(int for_turn=0) const
Returns global time of day for the passed turn.
Definition: tod_manager.hpp:54
bool valid() const
Definition: location.hpp:88
#define fxpdiv(x, y)
IN: unsigned and int - OUT: fixed_t.
Definition: math.hpp:323
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:456
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:1508
bool invalidateGameStatus_
Definition: display.hpp:766
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:413
void create_buttons()
Definition: display.cpp:876
Structure which holds a single route and marks for special events.
Definition: pathfind.hpp:140
const color_t YELLOW_COLOR
void needs_rebuild(bool b)
Sets whether the screen (map visuals) needs to be rebuilt.
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:3006
pathfind::marked_route route_
int32_t fixed_t
Definition: math.hpp:312
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:497
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:742
Generic locator abstracting the location of an image.
Definition: picture.hpp:59
std::unique_ptr< halo::manager > halo_man_
Definition: display.hpp:658
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Definition: math.hpp:317
Encapsulates the map of the game.
Definition: location.hpp:37
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:737
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
unit_iterator find(std::size_t id)
Definition: map.cpp:309
void process_reachmap_changes()
Definition: display.cpp:3186
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:502
surface tod_hex_mask1
Definition: display.hpp:788
std::size_t i
Definition: function.cpp:940
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:2191
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1613
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:736
int get_location_y(const map_location &loc) const
Definition: display.cpp:752
CURSOR_TYPE get()
Definition: cursor.cpp:215
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:380
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:39
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
Definition: display.cpp:2576
int w
Movement info (defense%, etc...).
Definition: display.hpp:859
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:1206
overlay_map overlay_map_
bool show_floating_labels()
Definition: game.cpp:831
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:747
const gamemap & get_map() const
Definition: display.hpp:94
Image rescaled to fit into a hexagonal tile according to the zoom settings.
Definition: picture.hpp:237
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:663
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:91
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:784
const display_context * dc_
Definition: display.hpp:657
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:104
bool contains(const map_location &) const
Definition: pathfind.cpp:514
Functions to load and save images from/to disk.
Standard logging facilities (interface).
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:198
Object which contains all the possible locations a unit can move to, with associated best routes to t...
Definition: pathfind.hpp:71
virtual void pre_draw() override
game_display pre_draw does specific things related e.g.
static const map_location & null_location()
Definition: location.hpp:80
virtual void post_draw() override
Calls the whiteboard&#39;s post-draw method.
const int SIZE_FLOAT_LABEL
Definition: constants.cpp:31
map_location attack_indicator_dst_
const std::unique_ptr< fake_unit_manager > fake_unit_man_
Definition: display.hpp:754
int side() const
The side this unit belongs to.
Definition: unit.hpp:333
const_iterator find(const map_location &) const
Definition: pathfind.cpp:478
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:59
bool valid() const
Definition: map.hpp:273
void clear_screen()
Clear the screen contents.
Definition: video.cpp:365
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:24
unit_map::iterator find_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:182
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Redraws the specified report (if anything has changed).
Definition: display.cpp:2794
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:659
std::vector< map_location > & steps
Definition: pathfind.hpp:186
Definition: display.hpp:48
Layer which holds the attack indicator.
Definition: display.hpp:854
Footsteps showing path from unit to mouse.
Definition: display.hpp:828
const color_t BAD_COLOR
"black stripes" on unreachable hexes.
Definition: display.hpp:848
std::size_t currentTeam_
Definition: display.hpp:735
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:501
const std::vector< map_location > & route_
Definition: move.cpp:294
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.