The Battle for Wesnoth  1.15.0-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 http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * During a game, show map & info-panels at top+right.
18  */
19 
20 #include "game_display.hpp"
21 
22 #include "color.hpp"
23 #include "cursor.hpp"
24 #include "display_chat_manager.hpp"
25 #include "fake_unit_manager.hpp"
26 #include "fake_unit_ptr.hpp"
27 #include "floating_label.hpp"
28 #include "font/standard_colors.hpp"
29 #include "game_board.hpp"
30 #include "gettext.hpp"
31 #include "halo.hpp"
32 #include "log.hpp"
33 #include "map/label.hpp"
34 #include "map/map.hpp"
35 #include "ogl/utils.hpp"
36 #include "overlay.hpp"
37 #include "preferences/game.hpp"
38 #include "reports.hpp"
39 #include "resources.hpp"
40 #include "synced_context.hpp"
41 #include "terrain/type_data.hpp"
42 #include "tod_manager.hpp"
43 #include "units/drawer.hpp"
44 #include "units/unit.hpp"
45 #include "wesconfig.h"
46 #include "whiteboard/manager.hpp"
47 
48 static lg::log_domain log_display("display");
49 #define ERR_DP LOG_STREAM(err, log_display)
50 #define LOG_DP LOG_STREAM(info, log_display)
51 
52 static lg::log_domain log_engine("engine");
53 #define ERR_NG LOG_STREAM(err, log_engine)
54 
55 std::map<map_location, fixed_t> game_display::debugHighlights_;
56 
57 game_display::game_display(game_board& board, std::weak_ptr<wb::manager> wb,
58  const config& theme_cfg,
59  const config& level,
60  bool)
61  : display(&board, wb, theme_cfg, level, false)
62  , overlay_map_()
63  , attack_indicator_src_()
64  , attack_indicator_dst_()
65  , hex_def_fl_labels_()
66  , route_()
67  , displayedUnitHex_()
68  , first_turn_(true)
69  , in_game_(false)
70  , chat_man_(new display_chat_manager(*this))
71  , mode_(RUNNING)
72  , needs_rebuild_(false)
73 {
74 #ifdef USE_GL_RENDERING
75  gl::clear_screen();
76 #else
77  video().clear_screen();
78 #endif
79 
80 }
81 
83 {
84  try {
85  // SDL_FreeSurface(minimap_);
86  chat_man_->prune_chat_messages(true);
87  } catch(...) {
88  }
89 }
90 
92 {
94 
95  if(!first_turn_) {
97 
98  if(old_tod.image_mask != tod.image_mask) {
101 
102  const int niterations = static_cast<int>(10 / turbo_speed());
103  const int frame_time = 30;
104  const int starting_ticks = SDL_GetTicks();
105  for(int i = 0; i != niterations; ++i) {
106  if(old_mask != nullptr) {
107  const fixed_t proportion = ftofxp(1.0) - fxpdiv(i, niterations);
108  adjust_surface_alpha(old_mask, proportion);
109  tod_hex_mask1.assign(old_mask);
110  }
111 
112  if(new_mask != nullptr) {
113  const fixed_t proportion = fxpdiv(i, niterations);
114  adjust_surface_alpha(new_mask, proportion);
115  tod_hex_mask2.assign(new_mask);
116  }
117 
118 
119  const int cur_ticks = SDL_GetTicks();
120  const int wanted_ticks = starting_ticks + i * frame_time;
121  if(cur_ticks < wanted_ticks) {
122  SDL_Delay(wanted_ticks - cur_ticks);
123  }
124  }
125  }
126 
127  tod_hex_mask1.assign(nullptr);
128  tod_hex_mask2.assign(nullptr);
129  }
130 
131  first_turn_ = false;
132 
134 
135 }
136 
138 {
139  if(hex.valid() && fogged(hex)) {
140  return;
141  }
142  display::select_hex(hex);
143 
144  display_unit_hex(hex);
145 }
146 
148 {
149  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
150 
152  if(u) {
153  displayedUnitHex_ = hex;
154  } else {
156  if(u) {
157  // mouse moved from unit hex to non-unit hex
158  if(dc_->units().count(selectedHex_)) {
160  }
161  }
162  }
163 
165 }
166 
168 {
169  if(!hex.valid())
170  return;
171 
172  wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
173 
175  if(u) {
176  displayedUnitHex_ = hex;
177  }
178 }
179 
181 {
182  if(src == displayedUnitHex_) {
183  displayedUnitHex_ = dst;
184  }
185 }
186 
187 void game_display::scroll_to_leader(int side, SCROLL_TYPE scroll_type, bool force)
188 {
189  unit_map::const_iterator leader = dc_->units().find_leader(side);
190 
191  if(leader.valid()) {
192  scroll_to_tile(leader->get_location(), scroll_type, true, force);
193  }
194 }
195 
197 {
198  if(std::shared_ptr<wb::manager> w = wb_.lock()) {
199  w->pre_draw();
200  }
201 
202  /**
203  * @todo FIXME: must modify changed, but best to do it at the
204  * floating_label level
205  */
206  chat_man_->prune_chat_messages();
207 }
208 
210 {
211  if(std::shared_ptr<wb::manager> w = wb_.lock()) {
212  w->post_draw();
213  }
214 }
215 
217 {
218  if(!get_map().on_board(loc) || cursor::get() == cursor::WAIT) {
219  return;
220  }
221 
222  texture* cursor_bg = nullptr;
223  texture* cursor_fg = nullptr;
224 
225  // image::SCALED_TO_HEX
226 
227  // TODO: either merge into one image or draw layered.
228 
229  // Default
230  static texture default_cursor_bg(image::get_texture("misc/hover-hex-top.png~RC(magenta>gold)"));
231  static texture default_cursor_fg(image::get_texture("misc/hover-hex-bottom.png~RC(magenta>gold)"));
232 
233  // Your troops
234  static texture team_cursor_bg(image::get_texture("misc/hover-hex-top.png~RC(magenta>green)"));
235  static texture team_cursor_fg(image::get_texture("misc/hover-hex-bottom.png~RC(magenta>green)"));
236 
237  // Allies
238  static texture ally_cursor_bg(image::get_texture("misc/hover-hex-top.png~RC(magenta>lightblue)"));
239  static texture ally_cursor_fg(image::get_texture("misc/hover-hex-bottom.png~RC(magenta>lightblue)"));
240 
241  // Enemies
242  static texture enemy_cursor_bg(image::get_texture("misc/hover-hex-enemy-top.png~RC(magenta>red)"));
243  static texture enemy_cursor_fg(image::get_texture("misc/hover-hex-enemy-bottom.png~RC(magenta>red)"));
244 
245  const team& t = dc_->teams()[currentTeam_];
246 
248 
249  if(u == nullptr) {
250  cursor_bg = &default_cursor_bg;
251  cursor_fg = &default_cursor_fg;
252  } else if(t.is_enemy(u->side())) {
253  cursor_bg = &enemy_cursor_bg;
254  cursor_fg = &enemy_cursor_fg;
255  } else if(t.side() == u->side()) {
256  cursor_bg = &team_cursor_bg;
257  cursor_fg = &team_cursor_fg;
258  } else {
259  cursor_bg = &ally_cursor_bg;
260  cursor_fg = &ally_cursor_fg;
261  }
262 
263  if(cursor_bg) {
264  render_scaled_to_zoom(*cursor_bg, loc);
265  }
266 
267  if(cursor_fg) {
268  render_scaled_to_zoom(*cursor_fg, loc);
269  }
270 
271  //
272  // Draw accompanying defense ratings and turn reach numbers within the hex.
273  //
275 
276  if(!game_config::images::selected.empty() && get_map().on_board(selectedHex_)) {
278 
279  render_scaled_to_zoom(selected, selectedHex_); // SCALED_TO_HEX
280  }
281 }
282 
284 {
285  //
286  // Render halos.
287  //
288  halo_man_->render();
289 
290  //
291  // Mask on unreachable locations
292  //
293  if(!reach_map_.empty()) {
294  for(const map_location& loc : get_visible_hexes()) {
295  if(shrouded(loc) || loc == attack_indicator_dst_ || reach_map_.find(loc) != reach_map_.end()) {
296  continue;
297  }
298 
299  // was SCALED_TO_HEX
301 
302  render_scaled_to_zoom(unreachable, loc);
303  }
304  }
305 
306  //
307  // Attack indicator - source
308  //
309  if(get_map().on_board(attack_indicator_src_)) {
310  texture indicator = image::get_texture("misc/attack-indicator-src-" + attack_indicator_direction() + ".png");
311 
312  // was SCALED_TO_HEX
314  }
315 
316  //
317  // Attack indicator - target
318  //
319  if(get_map().on_board(attack_indicator_dst_)) {
320  texture indicator = image::get_texture("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png");
321 
322  // was SCALED_TO_HEX
324  }
325 
326  //
327  // Draw route steps
328  //
329  if(std::shared_ptr<wb::manager> w = wb_.lock()) {
330  // w->draw_hex(loc);
331 
332  if(!w->is_active() && !w->has_temp_move()) {
334  }
335  }
336 
337  // Linger overlay unconditionally otherwise it might give glitches
338  // so it's drawn over the shroud and fog.
339  // FIXME: ^ split into seperate function so that happens.
340  if(mode_ != RUNNING) {
341  for(const map_location& loc : get_visible_hexes()) {
343 
344  // was TOD_COLORED
345  render_scaled_to_zoom(linger, loc);
346  }
347  }
348 
349 #if 0
350  if(game_config::debug) {
351  int debugH = debugHighlights_[loc];
352  if (debugH) {
353  std::string txt = std::to_string(debugH);
355  }
356  }
357 
358  //simulate_delay += 1;
359 #endif
360 }
361 
363 {
365 }
366 
368 {
370 }
371 
372 // USE AS REFERENCE FOR WHAT NEEDS TO BE UPDATED IN GUI2 UI
373 #if 0
374 void game_display::draw_sidebar()
375 {
376  if(!team_valid())
377  return;
378 
379  refresh_report("report_clock");
380  refresh_report("report_countdown");
381 
382  if(invalidateGameStatus_) {
383  wb::future_map future; // start planned unit map scope
384 
385  // We display the unit the mouse is over if it is over a unit,
386  // otherwise we display the unit that is selected.
387  for(const std::string& name : reports_object_->report_list()) {
388  refresh_report(name);
389  }
390  invalidateGameStatus_ = false;
391  }
392 }
393 #endif
394 
396 {
397  if(mode != mode_) {
398  mode_ = mode;
399  }
400 }
401 
403 {
404  // No route steps. Draw terrain defense based on selected hex.
405  if(route_.steps.empty()) {
406  if(selectedHex_.valid()) {
407  const unit_map::const_iterator selectedUnit =
409 
410  const unit_map::const_iterator mouseoveredUnit =
412 
413 #if 0
414  if(selectedUnit != dc_->units().end() && mouseoveredUnit == dc_->units().end()) {
415  // Display the def% of this terrain
416  int def = 100 - selectedUnit->defense_modifier(get_map().get_terrain(mouseoverHex_));
417  std::stringstream def_text;
418  def_text << def << "%";
419 
420  color_t color = game_config::red_to_green(def, false);
421 
422  // Use small font
423  static const int def_font = 16;
424  draw_text_in_hex(mouseoverHex_, def_text.str(), def_font, color);
425  }
426 #endif
427 
428  // LAYER_MOVE_INFO
429  for(const auto& reach : reach_map_) {
430  unsigned int num = reach.second;
431  if(num > 1) {
432  draw_text_in_hex(reach.first, std::to_string(num), 16, font::YELLOW_COLOR);
433  }
434  }
435  }
436 
437  hex_def_fl_labels_.clear();
438  return;
439  }
440 
441  std::shared_ptr<wb::manager> wb = wb_.lock();
442 
443  // First step of the route should be a unit.
444  const unit_map::const_iterator un = (wb && wb->get_temp_move_unit().valid())
445  ? wb->get_temp_move_unit()
446  : dc_->units().find(route_.steps.front());
447 
448  const bool unit_at_start = (un != dc_->units().end());
449 
450  if(!unit_at_start) {
451  // Remove all the defense labels.
452  hex_def_fl_labels_.clear();
453 
454  return;
455  }
456 
457  const unsigned int num_marks = route_.marks.size();
458 
459  if(hex_def_fl_labels_.size() != num_marks) {
460  hex_def_fl_labels_.resize(num_marks);
461  }
462 
463  int i = 0;
464 
465  for(const auto& mark : route_.marks) {
466  const map_location& m_loc = mark.first;
467 
468  if(route_.steps.front() == m_loc || shrouded(m_loc) || !get_map().on_board(m_loc)) {
469  continue;
470  }
471 
472  //
473  // Display the unit's defence on this terrain
474  //
475  const int def = 100 - un->defense_modifier(get_map().get_terrain(m_loc));
476 
477  std::stringstream def_text;
478  def_text << def << "%";
479 
480  color_t color = game_config::red_to_green(def, false);
481 
482  // Simple mark (no turn point) uses smaller font.
483  int def_font = mark.second.turns > 0 ? 18 : 16;
484 
485  int& marker_id = hex_def_fl_labels_[i].id;
486  marker_id = draw_text_in_hex(m_loc, def_text.str(), def_font, color, marker_id);
487 
488  //
489  // Draw special location markers
490  //
491 
492  // TODO: do we want SCALED_TO_HEX?
493  // LAYER_MOVE_INFO
494 
495  if(mark.second.invisible) {
496  static texture hidden(image::get_texture("misc/hidden.png"));
497  render_scaled_to_zoom(hidden, m_loc);
498  }
499 
500  if(mark.second.zoc) {
501  static texture zoc(image::get_texture("misc/zoc.png"));
502  render_scaled_to_zoom(zoc, m_loc);
503  }
504 
505  if(mark.second.capture) {
506  static texture capture(image::get_texture("misc/capture.png"));
507  render_scaled_to_zoom(capture, m_loc);
508  }
509 
510  // We display turn info only if different from a simple last "1"
511  if(mark.second.turns > 1 || (mark.second.turns == 1 && m_loc != route_.steps.back())) {
512  std::stringstream turns_text;
513  turns_text << mark.second.turns;
514  // draw_text_in_hex(m_loc, turns_text.str(), 17, font::NORMAL_COLOR, 0.5, 0.8); TODO
515  }
516 
517  ++i;
518  }
519 }
520 
522 {
523  // No real route.
524  if(route_.steps.size() < 2) {
525  return;
526  }
527 
528  const unit_map::const_iterator u = dc_->units().find(route_.steps.front());
529  const bool unit_at_start = u != dc_->units().end();
530 
531  for(auto iter = route_.steps.begin(); iter != route_.steps.end(); ++iter) {
532  // Step location.
533  const map_location& loc = *iter;
534 
535  // Check which footsteps image variant to use.
536  int move_cost = 1;
537  if(unit_at_start) {
538  move_cost = u->movement_cost(dc_->map().get_terrain(loc));
539  }
540 
541  const int image_number = std::min<int>(move_cost, game_config::foot_speed_prefix.size());
542  if(image_number < 1) {
543  continue; // Invalid movement cost or no images.
544  }
545 
546  const std::string& foot_speed_prefix = game_config::foot_speed_prefix[image_number - 1];
547 
548  std::string teleport_image = "";
549 
550  // We draw 2 half-hex (with possibly different directions), but skip the first for the first step...
551  const int first_half = (iter == route_.steps.begin()) ? 1 : 0;
552 
553  // ...and the second for the last step
554  const int second_half = (iter + 1 == route_.steps.end()) ? 0 : 1;
555 
556  for(int h = first_half; h <= second_half; ++h) {
557  const std::string sense(h == 0 ? "-in" : "-out");
558 
559  const map_location& loc_a = *(iter + (h - 1));
560  const map_location& loc_b = *(iter + h);
561 
562  // If we have a teleport image, record it and preceed to next step.
563  if(!tiles_adjacent(loc_a, loc_b)) {
564  teleport_image = (h == 0)
567 
568  continue;
569  }
570 
571  // In function of the half, use the incoming or outgoing direction
572  map_location::DIRECTION dir = loc_a.get_relative_dir(loc_b);
573 
574  bool rotate = false;
575  if(dir > map_location::SOUTH_EAST) {
576  // No image, take the opposite direction and flag a 180 rotation.
578  rotate = true;
579  }
580 
581  std::ostringstream ss;
582  ss << foot_speed_prefix << sense << "-" << map_location::write_direction(dir) << ".png";
583 
584  // Pass rotate flag twice so we get both a horizontal and vertical flip (180 rotation).
585  render_scaled_to_zoom(image::get_texture(ss.str()), loc, rotate, rotate); // SCALED_TO_HEX
586  }
587 
588  // Render teleport image last, if any.
589  if(!teleport_image.empty()) {
590  render_scaled_to_zoom(image::get_texture(teleport_image), loc); // SCALED_TO_HEX
591  }
592  }
593 }
594 
596 {
598  highlight_another_reach(paths_list);
599 }
600 
602 {
603  // Fold endpoints of routes into reachability map.
604  for(const pathfind::paths::step& dest : paths_list.destinations) {
605  reach_map_[dest.curr]++;
606  }
607 }
608 
610 {
611  if(!reach_map_.empty()) {
612  reach_map_.clear();
613  return true;
614  } else {
615  return false;
616  }
617 }
618 
620 {
621  if(route != nullptr) {
622  route_ = *route;
623  } else {
624  route_.steps.clear();
625  route_.marks.clear();
626  }
627 }
628 
629 void game_display::float_label(const map_location& loc, const std::string& text, const color_t& color)
630 {
631  if(preferences::show_floating_labels() == false || fogged(loc)) {
632  return;
633  }
634 
635  font::floating_label flabel(text);
637  flabel.set_color(color);
638  flabel.set_position(get_location_x(loc) + zoom_ / 2, get_location_y(loc));
639  flabel.set_move(0, -2 * turbo_speed());
640  flabel.set_lifetime(60 / turbo_speed());
642 
643  font::add_floating_label(flabel);
644 }
645 
647 {
648  assert(game_config::debug);
649  return debugHighlights_[loc];
650 }
651 
653 {
654  if(attack_indicator_src_ != src || attack_indicator_dst_ != dst) {
655  attack_indicator_src_ = src;
656  attack_indicator_dst_ = dst;
657  }
658 }
659 
661 {
663 }
664 
666 {
667  if(team_valid()) {
668  return dc_->teams()[currentTeam_].team_name();
669  }
670  return std::string();
671 }
672 
674 {
675  in_game_ = true;
676 }
677 
679 {
680  if(b) {
681  needs_rebuild_ = true;
682  }
683 }
684 
686 {
687  if(needs_rebuild_) {
688  needs_rebuild_ = false;
690  rebuild_all();
691  return true;
692  }
693  return false;
694 }
695 
697 {
698  return overlay_map_;
699 }
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: image.cpp:989
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:910
::tod_manager * tod_manager
Definition: resources.cpp:29
void set_game_mode(const game_mode mode)
unit_iterator end()
Definition: map.hpp:415
static int & debug_highlight(const map_location &loc)
annotate hex with number, useful for debugging or UI prototype
game_mode
Sets the linger mode for the display.
std::string image_mask
The image that is to be laid over all images while this time of day lasts.
Definition: time_of_day.hpp:97
DIRECTION get_relative_dir(const map_location &loc, map_location::RELATIVE_DIR_MODE mode) const
Definition: location.cpp:225
This class represents a single unit of a specific type.
Definition: unit.hpp:99
void set_move(double xmove, double ymove)
Set the amount to move the text each frame.
virtual overlay_map & get_overlays() override
Inherited from display.
const time_of_day & get_previous_time_of_day() const
unit_iterator find_leader(int side)
Definition: map.cpp:329
map_location attack_indicator_src_
map_location mouseoverHex_
Definition: display.hpp:901
std::string unreachable
dest_vect destinations
Definition: pathfind.hpp:99
virtual void draw_hex_cursor(const map_location &loc) override
Draws the map&#39;s hex cursor.
game_mode mode_
reach_map reach_map_
Definition: display.hpp:932
#define h
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Definition: map.cpp:367
map_location displayedUnitHex_
map_location selectedHex_
Definition: display.hpp:900
void set_font_size(int font_size)
static unsigned int zoom_
Definition: display.hpp:864
virtual const gamemap & map() const =0
void new_turn()
Update lighting settings.
static std::map< map_location, int > debugHighlights_
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:26
surface tod_hex_mask2
Definition: display.hpp:896
t_translation::terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Definition: map.cpp:299
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
Definition: display.cpp:601
bool team_valid() const
Definition: display.cpp:606
#define b
static lg::log_domain log_display("display")
no linger overlay, show fog and shroud.
const int SIZE_XLARGE
Definition: constants.cpp:29
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:57
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:44
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:1387
virtual void draw_hex_overlays() override
Draws various map overlays such as game reachmap.
Movement info (defense %, etc...).
unit * get_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:187
void set_lifetime(int lifetime)
Set the number of frames to display the text for, or -1 to display until removed. ...
Applies the planned unit map for the duration of the struct&#39;s life.
Definition: manager.hpp:251
map_location curr
Definition: pathfind.hpp:87
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.hpp:647
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:93
#define fxpdiv(x, y)
IN: unsigned and int - OUT: fixed_t.
Definition: math.hpp:303
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:343
bool is_enemy(int n) const
Definition: team.hpp:241
void highlight_another_reach(const pathfind::paths &paths_list)
Add more paths to highlight.
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)
Set the location on the screen to display the text.
virtual const unit_map & units() const =0
std::size_t count(const map_location &loc) const
Definition: map.hpp:400
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. This is typically after the map has been c...
pathfind::marked_route route_
int32_t fixed_t
Definition: math.hpp:292
std::string attack_indicator_direction() const
Function to get attack direction suffix.
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
Definition: display.cpp:616
std::unique_ptr< halo::manager > halo_man_
Definition: display.hpp:694
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Definition: math.hpp:297
Encapsulates the map of the game.
Definition: location.hpp:42
void float_label(const map_location &loc, const std::string &text, const color_t &color)
Function to float a label above a tile.
void set_color(const color_t &color)
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
Definition: display.cpp:611
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
unit_iterator find(std::size_t id)
Definition: map.cpp:311
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:557
static std::string mark
Definition: tstring.cpp:73
surface tod_hex_mask1
Definition: display.hpp:896
std::size_t i
Definition: function.cpp:933
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:1197
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
virtual void highlight_hex(map_location hex)
Definition: display.cpp:916
bool has_time_area() const
void render_scaled_to_zoom(const texture &tex, const int x_pos, const int y_pos, T &&... extra_args) const
Renders a texture directly to the screen (or current rendering target) scaled to the current zoom fac...
Definition: display.hpp:766
virtual void select_hex(map_location hex) override
Function to display a location as selected.
bool dont_show_all_
Definition: display.hpp:859
int get_location_y(const map_location &loc) const
Definition: display.cpp:626
CURSOR_TYPE get()
Definition: cursor.cpp:213
int add_floating_label(const floating_label &flabel)
Add a label floating on the screen above everything else.
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:44
int w
const bool & debug
std::vector< std::string > foot_speed_prefix
virtual bool has_time_area() const override
static lg::log_domain log_engine("engine")
static DIRECTION get_opposite_dir(DIRECTION d)
Definition: location.hpp:59
std::vector< font::floating_label_scope_helper > hex_def_fl_labels_
overlay_map overlay_map_
void assign(SDL_Surface *surf)
Definition: surface.hpp:46
bool show_floating_labels()
Definition: game.cpp:841
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:621
const gamemap & get_map() const
Definition: display.hpp:109
double t
Definition: astarsearch.cpp:63
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...
const display_context * dc_
Definition: display.hpp:692
void adjust_surface_alpha(surface &surf, fixed_t amount)
Definition: utils.cpp:1175
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:128
Standard logging facilities (interface).
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:237
Object which contains all the possible locations a unit can move to, with associated best routes to t...
Definition: pathfind.hpp:70
virtual void pre_draw() override
game_display pre_draw does specific things related e.g.
static const map_location & null_location()
Definition: location.hpp:85
virtual void post_draw() override
Calls the whiteboard&#39;s post-draw method.
game_display(game_board &board, std::weak_ptr< wb::manager > wb, const config &theme_cfg, const config &level, bool dummy=false)
map_location attack_indicator_dst_
int side() const
The side this unit belongs to.
Definition: unit.hpp:265
int side() const
Definition: team.hpp:187
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
bool valid() const
Definition: map.hpp:276
void clear_screen()
Clear the screen contents.
Definition: video.cpp:309
void set_route(const pathfind::marked_route *route)
Sets the route along which footsteps are drawn to show movement of a unit.
void draw_movement_info()
Draws the movement info (turns available).
void clear_attack_indicator()
static std::string write_direction(DIRECTION dir)
Definition: location.cpp:139
static bool is_synced()
void display_unit_hex(map_location hex)
Change the unit to be displayed in the sidebar.
std::multimap< map_location, overlay > overlay_map
Definition: display.hpp:934
unit_map::iterator find_visible_unit(const map_location &loc, const team &current_team, bool see_all=false)
Definition: game_board.cpp:168
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:696
std::vector< map_location > & steps
Definition: pathfind.hpp:186
Definition: display.hpp:49
void draw_footstep_images() const
texture get_texture(const image::locator &i_locator, TYPE type)
Definition: image.cpp:1483
const color_t BAD_COLOR
int draw_text_in_hex(const map_location &loc, const std::string &text, std::size_t font_size, color_t color, int fl_label_id=0, double x_in_hex=0.5, double y_in_hex=0.5)
Adds a floating label with the specified text at the given location.
Definition: display.cpp:878
std::size_t currentTeam_
Definition: display.hpp:858
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:395
const std::vector< map_location > & route_
Definition: move.cpp:289
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.