The Battle for Wesnoth  1.17.17+dev
game_display.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2023
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 "utils/general.hpp"
47 #include "whiteboard/manager.hpp"
48 #include "overlay.hpp"
49 #include "draw.hpp"
50 
51 static lg::log_domain log_display("display");
52 #define ERR_DP LOG_STREAM(err, log_display)
53 #define LOG_DP LOG_STREAM(info, log_display)
54 #define DBG_DP LOG_STREAM(debug, log_display)
55 
56 static lg::log_domain log_engine("engine");
57 #define ERR_NG LOG_STREAM(err, log_engine)
58 
59 std::map<map_location, int> game_display::debugHighlights_;
60 
61 /**
62  * Function to return 2 half-hex footsteps images for the given location.
63  * Only loc is on the current route set by set_route.
64  *
65  * This function is only used internally by game_display so I have moved it out of the header into the compilaton unit.
66  */
67 std::vector<texture> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_);
68 
70  std::weak_ptr<wb::manager> wb,
71  reports& reports_object,
72  const std::string& theme_id,
73  const config& level)
74  : display(&board, wb, reports_object, theme_id, level)
75  , overlay_map_()
76  , attack_indicator_src_()
77  , attack_indicator_dst_()
78  , route_()
79  , displayedUnitHex_()
80  , in_game_(false)
81  , chat_man_(new display_chat_manager(*this))
82  , mode_(RUNNING)
83  , needs_rebuild_(false)
84 {
85 }
86 
88 {
89  try {
90  chat_man_->prune_chat_messages(true);
91  } catch(...) {
92  DBG_DP << "Caught exception in game_display destructor: " << utils::get_unknown_exception_type();
93  }
94 }
95 
97 {
98  static bool first_turn = true;
99 
100  // We want to skip this on the first run of this function
101  if(!first_turn) {
104 
105  if(old_tod.image_mask != tod.image_mask) {
106  fade_tod_mask(old_tod.image_mask, tod.image_mask);
107  }
108  }
109 
110  first_turn = false;
111 
112  update_tod();
113 }
114 
116 {
117  if(hex.valid() && fogged(hex)) {
118  return;
119  }
120  display::select_hex(hex);
121 
122  display_unit_hex(hex);
123 }
124 
126 {
127  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
128 
130  if (u) {
131  displayedUnitHex_ = hex;
132  invalidate_unit();
133  } else {
135  if (u) {
136  // mouse moved from unit hex to non-unit hex
137  if (dc_->units().count(selectedHex_)) {
139  invalidate_unit();
140  }
141  }
142  }
143 
146 }
147 
148 
150 {
151  if (!hex.valid())
152  return;
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  }
161 }
162 
164 {
165  if (src == displayedUnitHex_) {
166  displayedUnitHex_ = dst;
167  invalidate_unit();
168  }
169 }
170 
171 void game_display::scroll_to_leader(int side, SCROLL_TYPE scroll_type,bool force)
172 {
173  unit_map::const_iterator leader = dc_->units().find_leader(side);
174 
175  if(leader.valid() && leader->is_visible_to_team(dc_->get_team(viewing_side()), false)) {
176  scroll_to_tile(leader->get_location(), scroll_type, true, force);
177  }
178 }
179 
181 {
182  display::update();
183 
184  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
185  w->pre_draw();
186  }
188  /**
189  * @todo FIXME: must modify changed, but best to do it at the
190  * floating_label level
191  */
192  chat_man_->prune_chat_messages();
193 }
194 
195 
197 {
198  display::render();
199 
200  if (std::shared_ptr<wb::manager> w = wb_.lock()) {
201  w->post_draw();
202  }
203 }
204 
206 {
208  if (fake_unit_man_->empty()) {
209  return;
210  }
211  unit_drawer drawer = unit_drawer(*this);
212 
213  for (const unit* temp_unit : *fake_unit_man_) {
214  const map_location& loc = temp_unit->get_location();
216  if (invalidated_.find(loc) != invalidated_.end()
217  && (request == exclusive_unit_draw_requests_.end() || request->second == temp_unit->id()))
218  drawer.redraw_unit(*temp_unit);
219  }
220 }
221 
222 namespace
223 {
224 const std::string mouseover_normal_top = "misc/hover-hex-top.png~RC(magenta>gold)";
225 const std::string mouseover_normal_bot = "misc/hover-hex-bottom.png~RC(magenta>gold)";
226 
227 const std::string mouseover_enemy_top = "misc/hover-hex-enemy-top.png~RC(magenta>red)";
228 const std::string mouseover_enemy_bot = "misc/hover-hex-enemy-bottom.png~RC(magenta>red)";
229 
230 const std::string mouseover_self_top = "misc/hover-hex-top.png~RC(magenta>green)";
231 const std::string mouseover_self_bot = "misc/hover-hex-bottom.png~RC(magenta>green)";
232 
233 const std::string mouseover_ally_top = "misc/hover-hex-top.png~RC(magenta>lightblue)";
234 const std::string mouseover_ally_bot = "misc/hover-hex-bottom.png~RC(magenta>lightblue)";
235 }
236 
238 {
239  const bool on_map = get_map().on_board(loc);
240  const bool is_shrouded = shrouded(loc);
241 
242  display::draw_hex(loc);
243 
244  if(cursor::get() == cursor::WAIT) {
245  // Interaction is disabled, so we don't need anything else
246  return;
247  }
248 
249  if(on_map && loc == mouseoverHex_ && !map_screenshot_) {
250  drawing_layer hex_top_layer = LAYER_MOUSEOVER_BOTTOM;
252  if(u != nullptr) {
253  hex_top_layer = LAYER_MOUSEOVER_TOP;
254  }
255 
256  const std::string* mo_top_path;
257  const std::string* mo_bot_path;
258 
259  if(u == nullptr) {
260  mo_top_path = &mouseover_normal_top;
261  mo_bot_path = &mouseover_normal_bot;
262  } else if(dc_->teams()[currentTeam_].is_enemy(u->side())) {
263  mo_top_path = &mouseover_enemy_top;
264  mo_bot_path = &mouseover_enemy_bot;
265  } else if(dc_->teams()[currentTeam_].side() == u->side()) {
266  mo_top_path = &mouseover_self_top;
267  mo_bot_path = &mouseover_self_bot;
268  } else {
269  mo_top_path = &mouseover_ally_top;
270  mo_bot_path = &mouseover_ally_bot;
271  }
272 
273  drawing_buffer_add(hex_top_layer, loc,
274  [tex = image::get_texture(*mo_top_path, image::HEXED)](const rect& dest) { draw::blit(tex, dest); });
275 
277  [tex = image::get_texture(*mo_bot_path, image::HEXED)](const rect& dest) { draw::blit(tex, dest); });
278  }
279 
280  // Draw reach_map information.
281  // We remove the reachability mask of the unit that we want to attack.
282  if(!is_shrouded && !reach_map_.empty() && reach_map_.find(loc) == reach_map_.end() && loc != attack_indicator_dst_) {
285  [tex = image::get_texture(unreachable, image::HEXED)](const rect& dest) { draw::blit(tex, dest); });
286  }
287 
288  if(std::shared_ptr<wb::manager> w = wb_.lock()) {
289  w->draw_hex(loc);
290 
291  if(!(w->is_active() && w->has_temp_move())) {
292  std::vector<texture> footstepImages = footsteps_images(loc, route_, dc_);
293  if(!footstepImages.empty()) {
294  drawing_buffer_add(LAYER_FOOTSTEPS, loc, [images = std::move(footstepImages)](const rect& dest) {
295  for(const texture& t : images) {
296  draw::blit(t, dest);
297  }
298  });
299  }
300  }
301  }
302 
303  // Draw the attack direction indicator
304  if(on_map && loc == attack_indicator_src_) {
306  [tex = image::get_texture("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", image::HEXED)](const rect& dest)
307  { draw::blit(tex, dest); }
308  );
309  } else if(on_map && loc == attack_indicator_dst_) {
311  [tex = image::get_texture("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", image::HEXED)](const rect& dest)
312  { draw::blit(tex, dest); }
313  );
314  }
315 
316  // Linger overlay unconditionally otherwise it might give glitches
317  // so it's drawn over the shroud and fog.
318  if(mode_ != RUNNING) {
321  [tex = image::get_texture(linger, image::TOD_COLORED)](const rect& dest) { draw::blit(tex, dest); });
322  }
323 
324  if(on_map && loc == selectedHex_ && !game_config::images::selected.empty()) {
327  [tex = image::get_texture(selected, image::HEXED)](const rect& dest) { draw::blit(tex, dest); });
328  }
329 
330  // Show def% and turn to reach info
331  if(!is_shrouded && on_map) {
332  draw_movement_info(loc);
333  }
334 
335  if(game_config::debug) {
336  int debugH = debugHighlights_[loc];
337  if (debugH) {
338  std::string txt = std::to_string(debugH);
340  }
341  }
342 }
343 
345 {
347 }
348 
350 {
352 }
353 
355 {
356  display::layout();
357 
358  if ( !team_valid() )
359  return;
360 
361  refresh_report("report_clock");
362  refresh_report("report_battery");
363  refresh_report("report_countdown");
364 
366  {
367  wb::future_map future; // start planned unit map scope
368 
369  // We display the unit the mouse is over if it is over a unit,
370  // otherwise we display the unit that is selected.
371  for (const std::string &name : reports_object_->report_list()) {
372  refresh_report(name);
373  }
374  invalidateGameStatus_ = false;
375  }
376 }
377 
378 
380 {
381  if(mode != mode_) {
382  mode_ = mode;
383  invalidate_all();
384  }
385 }
386 
388 {
389  // Search if there is a mark here
391 
392  std::shared_ptr<wb::manager> wb = wb_.lock();
393 
394  // Don't use empty route or the first step (the unit will be there)
395  if(w != route_.marks.end()
396  && !route_.steps.empty() && route_.steps.front() != loc) {
397  const unit_map::const_iterator un =
398  (wb && wb->get_temp_move_unit().valid()) ?
399  wb->get_temp_move_unit() : dc_->units().find(route_.steps.front());
400  if(un != dc_->units().end()) {
401  // Display the def% of this terrain
402  int move_cost = un->movement_cost(get_map().get_terrain(loc));
403  int def = (move_cost == movetype::UNREACHABLE ?
404  0 : 100 - un->defense_modifier(get_map().get_terrain(loc)));
405  std::stringstream def_text;
406  def_text << def << "%";
407 
408  color_t color = game_config::red_to_green(def, false);
409 
410  // simple mark (no turn point) use smaller font
411  int def_font = w->second.turns > 0 ? 18 : 16;
412  draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
413 
415  [inv = w->second.invisible, zoc = w->second.zoc, cap = w->second.capture](const rect& dest) {
416  if(inv) {
417  draw::blit(image::get_texture(image::locator{"misc/hidden.png"}, image::HEXED), dest);
418  }
419 
420  if(zoc) {
421  draw::blit(image::get_texture(image::locator{"misc/zoc.png"}, image::HEXED), dest);
422  }
423 
424  if(cap) {
425  draw::blit(image::get_texture(image::locator{"misc/capture.png"}, image::HEXED), dest);
426  }
427  });
428 
429  //we display turn info only if different from a simple last "1"
430  if (w->second.turns > 1 || (w->second.turns == 1 && loc != route_.steps.back())) {
431  std::stringstream turns_text;
432  turns_text << w->second.turns;
433  draw_text_in_hex(loc, LAYER_MOVE_INFO, turns_text.str(), 17, font::NORMAL_COLOR, 0.5,0.8);
434  }
435 
436  // The hex is full now, so skip the "show enemy moves"
437  return;
438  }
439  }
440  // When out-of-turn, it's still interesting to check out the terrain defs of the selected unit
441  else if (selectedHex_.valid() && loc == mouseoverHex_)
442  {
443  const unit_map::const_iterator selectedUnit = resources::gameboard->find_visible_unit(selectedHex_,dc_->teams()[currentTeam_]);
444  const unit_map::const_iterator mouseoveredUnit = resources::gameboard->find_visible_unit(mouseoverHex_,dc_->teams()[currentTeam_]);
445  if(selectedUnit != dc_->units().end() && mouseoveredUnit == dc_->units().end()) {
446  // Display the def% of this terrain
447  int move_cost = selectedUnit->movement_cost(get_map().get_terrain(loc));
448  int def = (move_cost == movetype::UNREACHABLE ?
449  0 : 100 - selectedUnit->defense_modifier(get_map().get_terrain(loc)));
450  std::stringstream def_text;
451  def_text << def << "%";
452 
453  color_t color = game_config::red_to_green(def, false);
454 
455  // use small font
456  int def_font = 16;
457  draw_text_in_hex(loc, LAYER_MOVE_INFO, def_text.str(), def_font, color);
458  }
459  }
460 
461  if (!reach_map_.empty()) {
462  reach_map::iterator reach = reach_map_.find(loc);
463  if (reach != reach_map_.end() && reach->second > 1) {
464  const std::string num = std::to_string(reach->second);
465  draw_text_in_hex(loc, LAYER_MOVE_INFO, num, 16, font::YELLOW_COLOR);
466  }
467  }
468 }
469 
470 std::vector<texture> footsteps_images(const map_location& loc, const pathfind::marked_route & route_, const display_context * dc_)
471 {
472  std::vector<texture> res;
473 
474  if (route_.steps.size() < 2) {
475  return res; // no real "route"
476  }
477 
478  std::vector<map_location>::const_iterator i =
479  std::find(route_.steps.begin(),route_.steps.end(),loc);
480 
481  if( i == route_.steps.end()) {
482  return res; // not on the route
483  }
484 
485  // Check which footsteps images of game_config we will use
486  int move_cost = 1;
487  const unit_map::const_iterator u = dc_->units().find(route_.steps.front());
488  if(u != dc_->units().end()) {
489  move_cost = u->movement_cost(dc_->map().get_terrain(loc));
490  }
491  int image_number = std::min<int>(move_cost, game_config::foot_speed_prefix.size());
492  if (image_number < 1) {
493  return res; // Invalid movement cost or no images
494  }
495  const std::string foot_speed_prefix = game_config::foot_speed_prefix[image_number-1];
496 
497  texture teleport;
498 
499  // We draw 2 half-hex (with possibly different directions),
500  // but skip the first for the first step.
501  const int first_half = (i == route_.steps.begin()) ? 1 : 0;
502  // and the second for the last step
503  const int second_half = (i+1 == route_.steps.end()) ? 0 : 1;
504 
505  for (int h = first_half; h <= second_half; ++h) {
506  const std::string sense( h==0 ? "-in" : "-out" );
507 
508  if (!tiles_adjacent(*(i+(h-1)), *(i+h))) {
509  std::string teleport_image =
511  teleport = image::get_texture(teleport_image, image::HEXED);
512  continue;
513  }
514 
515  // In function of the half, use the incoming or outgoing direction
516  map_location::DIRECTION dir = (i+(h-1))->get_relative_dir(*(i+h));
517 
518  std::string rotate;
519  if (dir > map_location::SOUTH_EAST) {
520  // No image, take the opposite direction and do a 180 rotation
521  dir = i->get_opposite_dir(dir);
522  rotate = "~FL(horiz)~FL(vert)";
523  }
524 
525  const std::string image = foot_speed_prefix
526  + sense + "-" + i->write_direction(dir)
527  + ".png" + rotate;
528 
529  res.push_back(image::get_texture(image, image::HEXED));
530  }
531 
532  // we draw teleport image (if any) in last
533  if (teleport != nullptr) res.push_back(teleport);
534 
535  return res;
536 }
537 
538 
539 
541 {
543  highlight_another_reach(paths_list);
544 }
545 
547  const map_location& goal)
548 {
549  // Fold endpoints of routes into reachability map.
550  for (const pathfind::paths::step &dest : paths_list.destinations) {
551  reach_map_[dest.curr]++;
552  }
553  reach_map_changed_ = true;
554 
555  if(goal != map_location::null_location() && paths_list.destinations.contains(goal)) {
556  const auto& path_to_goal = paths_list.destinations.get_path(paths_list.destinations.find(goal));
557  const map_location enemy_unit_location = path_to_goal[0];
558  units_that_can_reach_goal_.insert(enemy_unit_location);
559  }
560 }
561 
563 {
565  if(!reach_map_.empty()) {
566  reach_map_.clear();
567  reach_map_changed_ = true;
568  return true;
569  } else {
570  return false;
571  }
572 }
573 
575 {
576  for(std::vector<map_location>::const_iterator i = route_.steps.begin();
577  i != route_.steps.end(); ++i) {
578  invalidate(*i);
579  }
580 }
581 
583 {
585 
586  if(route != nullptr) {
587  route_ = *route;
588  } else {
589  route_.steps.clear();
590  route_.marks.clear();
591  }
592 
594 }
595 
596 void game_display::float_label(const map_location& loc, const std::string& text, const color_t& color)
597 {
598  if(preferences::show_floating_labels() == false || fogged(loc)) {
599  return;
600  }
601 
602  font::floating_label flabel(text);
604  flabel.set_color(color);
605  flabel.set_position(get_location_x(loc)+zoom_/2, get_location_y(loc));
606  flabel.set_move(0, -0.1 * turbo_speed() * get_zoom_factor());
607  flabel.set_lifetime(1000/turbo_speed());
609 
610  font::add_floating_label(flabel);
611 }
612 
614 {
615  assert(game_config::debug);
616  return debugHighlights_[loc];
617 }
618 
620 {
621  if (attack_indicator_src_ != src || attack_indicator_dst_ != dst) {
624 
625  attack_indicator_src_ = src;
626  attack_indicator_dst_ = dst;
627 
630  }
631 }
632 
634 {
636 }
637 
639 {
640  if (team_valid())
641  {
642  return dc_->teams()[currentTeam_].team_name();
643  }
644  return std::string();
645 }
646 
648 {
649  in_game_ = true;
650  create_buttons();
651  invalidate_all();
652 }
653 
655  if (b) {
656  needs_rebuild_ = true;
657  }
658 }
659 
661  if (needs_rebuild_) {
662  needs_rebuild_ = false;
664  invalidate_all();
665  rebuild_all();
666  return true;
667  }
668  return false;
669 }
670 
672 {
673  return overlay_map_;
674 }
const std::vector< map_location > & route_
Definition: move.cpp:295
double t
Definition: astarsearch.cpp:65
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:161
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
const team & get_team(int side) const
This getter takes a 1-based side number, not a 0-based team number.
virtual const gamemap & map() const =0
virtual const std::vector< team > & teams() const =0
virtual const unit_map & units() const =0
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:87
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
Definition: display.hpp:927
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:1445
int viewing_side() const
The 1-based equivalent of the 0-based viewing_team() function.
Definition: display.hpp:130
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:947
map_location selectedHex_
Definition: display.hpp:775
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:122
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.cpp:1621
virtual void render() override
Update offscreen render buffers.
Definition: display.cpp:2428
void fade_tod_mask(const std::string &old, const std::string &new_)
ToD mask smooth fade.
Definition: display.cpp:2214
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
Definition: display.cpp:3094
drawing_layer
The layers to render something on.
Definition: display.hpp:803
@ LAYER_MOUSEOVER_BOTTOM
Bottom half of image following the mouse.
Definition: display.hpp:831
@ LAYER_ATTACK_INDICATOR
Layer which holds the attack indicator.
Definition: display.hpp:836
@ LAYER_MOVE_INFO
Movement info (defense%, etc...).
Definition: display.hpp:841
@ LAYER_FOOTSTEPS
Footsteps showing path from unit to mouse.
Definition: display.hpp:810
@ LAYER_LINGER_OVERLAY
The overlay used for the linger mode.
Definition: display.hpp:842
@ LAYER_SELECTED_HEX
Image on the selected unit.
Definition: display.hpp:835
@ LAYER_REACHMAP
"black stripes" on unreachable hexes.
Definition: display.hpp:830
@ LAYER_MOUSEOVER_TOP
Top half of image following the mouse.
Definition: display.hpp:811
double turbo_speed() const
Definition: display.cpp:2200
bool reach_map_changed_
Definition: display.hpp:944
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
Definition: display.cpp:712
static double get_zoom_factor()
Returns the current zoom factor.
Definition: display.hpp:267
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Definition: display.hpp:313
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:457
virtual void layout() override
Finalize screen layout.
Definition: display.cpp:2397
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1523
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
Definition: display.cpp:410
void process_reachmap_changes()
Definition: display.cpp:3266
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:2037
map_location mouseoverHex_
Definition: display.hpp:776
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
Definition: display.cpp:707
const gamemap & get_map() const
Definition: display.hpp:105
void invalidate_all()
Function to invalidate all tiles.
Definition: display.cpp:3087
void drawing_buffer_add(const drawing_layer layer, const map_location &loc, decltype(draw_helper::do_draw) draw_func)
Add an item to the drawing buffer.
Definition: display.cpp:1259
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:683
bool team_valid() const
Definition: display.cpp:697
std::set< map_location > invalidated_
Definition: display.hpp:765
void create_buttons()
Definition: display.cpp:876
bool invalidateGameStatus_
Definition: display.hpp:746
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
Definition: display.cpp:2587
reports * reports_object_
Definition: display.hpp:748
virtual void update() override
Update animations and internal state.
Definition: display.cpp:2380
int get_location_y(const map_location &loc) const
Definition: display.cpp:717
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
Definition: display.cpp:2628
std::size_t currentTeam_
Definition: display.hpp:720
const std::unique_ptr< fake_unit_manager > fake_unit_man_
Definition: display.hpp:739
const display_context * dc_
Definition: display.hpp:677
static unsigned int zoom_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e....
Definition: display.hpp:735
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
Definition: display.cpp:702
bool dont_show_all_
Definition: display.hpp:721
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Update the given report.
Definition: display.cpp:2843
std::weak_ptr< wb::manager > wb_
Definition: display.hpp:679
virtual void select_hex(map_location hex)
Definition: display.cpp:1515
reach_map reach_map_
Definition: display.hpp:942
void set_move(double xmove, double ymove)
void set_lifetime(int lifetime, int fadeout=100)
void set_position(double xpos, double ypos)
void set_color(const color_t &color)
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
void set_font_size(int font_size)
Game board class.
Definition: game_board.hpp:53
unit_map::iterator find_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:184
unit * get_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:212
std::string current_team_name() const
virtual void draw_invalidated() override
Only called when there's actual redrawing to do.
void draw_movement_info(const map_location &loc)
Draws the movement info (turns available) for a given location.
void display_unit_hex(map_location hex)
Change the unit to be displayed in the sidebar.
void invalidate_unit_after_move(const map_location &src, const map_location &dst)
Same as invalidate_unit() if moving the displayed unit.
std::string attack_indicator_direction() const
Function to get attack direction suffix.
game_mode mode_
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
map_location displayedUnitHex_
void invalidate_route()
void scroll_to_leader(int side, SCROLL_TYPE scroll_type=ONSCREEN, bool force=true)
Scrolls to the leader of a certain side.
void set_game_mode(const game_mode mode)
virtual void draw_hex(const map_location &loc) override
Redraws a single gamemap location.
static std::map< map_location, int > debugHighlights_
void set_attack_indicator(const map_location &src, const map_location &dst)
Set the attack direction indicator.
static int & debug_highlight(const map_location &loc)
annotate hex with number, useful for debugging or UI prototype
const std::unique_ptr< display_chat_manager > chat_man_
pathfind::marked_route route_
virtual void render() override
TLD render() override.
void set_route(const pathfind::marked_route *route)
Sets the route along which footsteps are drawn to show movement of a unit.
virtual overlay_map & get_overlays() override
Inherited from display.
std::set< map_location > units_that_can_reach_goal_
void invalidate_unit()
Function to invalidate that unit status displayed on the sidebar.
virtual void select_hex(map_location hex) override
Function to display a location as selected.
void highlight_reach(const pathfind::paths &paths_list)
Sets the paths that are currently displayed as available for the unit to move along.
void new_turn()
Update lighting settings.
void clear_attack_indicator()
virtual const time_of_day & get_time_of_day(const map_location &loc) const override
void highlight_another_reach(const pathfind::paths &paths_list, const map_location &goal=map_location::null_location())
Add more paths to highlight.
map_location attack_indicator_dst_
game_mode
Sets the linger mode for the display.
@ RUNNING
no linger overlay, show fog and shroud.
bool unhighlight_reach()
Reset highlighting of paths.
void needs_rebuild(bool b)
Sets whether the screen (map visuals) needs to be rebuilt.
overlay_map overlay_map_
bool maybe_rebuild()
Rebuilds the screen if needs_rebuild(true) was previously called, and resets the flag.
virtual void layout() override
TLD layout() override.
virtual bool has_time_area() const override
game_display(game_board &board, std::weak_ptr< wb::manager > wb, reports &reports_object, const std::string &theme_id, const config &level)
virtual void update() override
TLD update() override.
map_location attack_indicator_src_
void float_label(const map_location &loc, const std::string &text, const color_t &color)
Function to float a label above a tile.
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:302
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Definition: map.cpp:385
Generic locator abstracting the location of an image.
Definition: picture.hpp:64
static const int UNREACHABLE
Magic value that signifies a hex is unreachable.
Definition: movetype.hpp:176
const std::set< std::string > & report_list()
Definition: reports.cpp:1798
static bool is_synced()
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:33
bool has_time_area() const
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
const time_of_day & get_previous_time_of_day() const
void redraw_unit(const unit &u) const
draw a unit.
Definition: drawer.cpp:167
unit_iterator end()
Definition: map.hpp:429
std::size_t count(const map_location &loc) const
Definition: map.hpp:414
unit_iterator find(std::size_t id)
Definition: map.cpp:301
unit_iterator find_leader(int side)
Definition: map.cpp:319
This class represents a single unit of a specific type.
Definition: unit.hpp:134
Drawing functions, for drawing things on the screen.
std::size_t i
Definition: function.cpp:968
int w
static lg::log_domain log_engine("engine")
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.
static lg::log_domain log_display("display")
#define DBG_DP
int side() const
The side this unit belongs to.
Definition: unit.hpp:344
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
Definition: location.cpp:503
Standard logging facilities (interface).
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
CURSOR_TYPE get()
Definition: cursor.cpp:216
@ WAIT
Definition: cursor.hpp:29
void blit(const texture &tex, const SDL_Rect &dst)
Draws a texture, or part of a texture, at the given location.
Definition: draw.cpp:301
const int SIZE_FLOAT_LABEL
Definition: constants.cpp:32
const color_t YELLOW_COLOR
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
const color_t BAD_COLOR
const color_t NORMAL_COLOR
@ ANCHOR_LABEL_MAP
std::string selected
std::string unreachable
std::string foot_teleport_enter
std::vector< std::string > foot_speed_prefix
std::string foot_teleport_exit
const bool & debug
Definition: game_config.cpp:91
color_t red_to_green(double val, bool for_text)
Return a color corresponding to the value val red for val=0.0 to green for val=100....
Functions to load and save images from/to disk.
@ HEXED
Standard hexagonal tile mask applied, removing portions that don't fit.
Definition: picture.hpp:235
@ TOD_COLORED
Same as HEXED, but with Time of Day color tint applied.
Definition: picture.hpp:237
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:985
bool show_floating_labels()
Definition: game.cpp:823
Unit and team statistics.
::tod_manager * tod_manager
Definition: resources.cpp:30
game_board * gameboard
Definition: resources.cpp:21
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:87
std::string get_unknown_exception_type()
Utility function for finding the type of thing caught with catch(...).
Definition: general.cpp:23
Definition: display.hpp:49
std::string::const_iterator iterator
Definition: tokenizer.hpp:25
The basic class for representing 8-bit RGB or RGBA colour values.
Definition: color.hpp:59
Encapsulates the map of the game.
Definition: location.hpp:38
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:40
bool valid() const
Definition: location.hpp:89
static const map_location & null_location()
Definition: location.hpp:81
Structure which holds a single route and marks for special events.
Definition: pathfind.hpp:142
std::vector< map_location > & steps
Definition: pathfind.hpp:187
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
bool contains(const map_location &) const
Definition: pathfind.cpp:514
const_iterator find(const map_location &) const
Definition: pathfind.cpp:478
map_location curr
Definition: pathfind.hpp:89
Object which contains all the possible locations a unit can move to, with associated best routes to t...
Definition: pathfind.hpp:73
dest_vect destinations
Definition: pathfind.hpp:101
An abstract description of a rectangle with integer coordinates.
Definition: rect.hpp:47
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:57
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 valid() const
Definition: map.hpp:274
Applies the planned unit map for the duration of the struct's life.
Definition: manager.hpp:253
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
#define h
#define b