The Battle for Wesnoth  1.17.4+dev
display.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2022
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  *
19  * map_display and display: classes which take care of
20  * displaying the map and game-data on the screen.
21  *
22  * The display is divided into two main sections:
23  * - the game area, which displays the tiles of the game board, and units on them,
24  * - and the side bar, which appears on the right hand side.
25  * The side bar display is divided into three sections:
26  * - the minimap, which is displayed at the top right
27  * - the game status, which includes the day/night image,
28  * the turn number, information about the current side,
29  * and information about the hex currently moused over (highlighted)
30  * - the unit status, which displays an image and stats
31  * for the current unit.
32  */
33 
34 #pragma once
35 
36 class config;
37 class fake_unit_manager;
38 class terrain_builder;
39 class map_labels;
40 class arrow;
41 class reports;
42 class team;
43 struct overlay;
44 
45 namespace halo {
46  class manager;
47 }
48 
49 namespace wb {
50  class manager;
51 }
52 
53 #include "animated.hpp"
54 #include "display_context.hpp"
55 #include "filesystem.hpp"
56 #include "font/standard_colors.hpp"
57 #include "game_config.hpp"
58 #include "picture.hpp" //only needed for enums (!)
59 #include "key.hpp"
60 #include "time_of_day.hpp"
61 #include "sdl/rect.hpp"
62 #include "sdl/surface.hpp"
63 #include "theme.hpp"
64 #include "video.hpp"
65 #include "widgets/button.hpp"
66 
67 #include <boost/circular_buffer.hpp>
68 
69 #include <functional>
70 #include <chrono>
71 #include <cstdint>
72 #include <deque>
73 #include <list>
74 #include <map>
75 #include <memory>
76 #include <vector>
77 
78 class gamemap;
79 
81 {
82 public:
83  display(const display_context* dc,
84  std::weak_ptr<wb::manager> wb,
85  reports& reports_object,
86  const std::string& theme_id,
87  const config& level,
88  bool auto_join = true);
89 
90  virtual ~display();
91  /**
92  * Returns the display object if a display object exists. Otherwise it returns nullptr.
93  * the display object represents the game gui which handles themewml and drawing the map.
94  * A display object only exists during a game or while the mapeditor is running.
95  */
96  static display* get_singleton() { return singleton_ ;}
97 
98  bool show_everything() const { return !dont_show_all_ && !is_blindfolded(); }
99 
100  const gamemap& get_map() const { return dc_->map(); }
101 
102  const std::vector<team>& get_teams() const {return dc_->teams();}
103 
104  /** The playing team is the team whose turn it is. */
105  std::size_t playing_team() const { return activeTeam_; }
106 
107  bool team_valid() const;
108 
109  /** The viewing team is the team currently viewing the game. */
110  std::size_t viewing_team() const { return currentTeam_; }
111  int viewing_side() const { return currentTeam_ + 1; }
112 
113  /**
114  * Sets the team controlled by the player using the computer.
115  * Data from this team will be displayed in the game status.
116  */
117  void set_team(std::size_t team, bool observe=false);
118 
119  /**
120  * set_playing_team sets the team whose turn it currently is
121  */
122  void set_playing_team(std::size_t team);
123 
124 
125  /**
126  * Cancels all the exclusive draw requests.
127  */
128  void clear_exclusive_draws() { exclusive_unit_draw_requests_.clear(); }
129  const unit_map& get_units() const {return dc_->units();}
130 
131  /**
132  * Allows a unit to request to be the only one drawn in its hex. Useful for situations where
133  * multiple units (one real, multiple temporary) can end up stacked, such as with the whiteboard.
134  * @param loc The location of the unit requesting exclusivity.
135  * @param unit The unit requesting exclusivity.
136  * @return false if there's already an exclusive draw request for this location.
137  */
138  bool add_exclusive_draw(const map_location& loc, unit& unit);
139  /**
140  * Cancels an exclusive draw request.
141  * @return The id of the unit whose exclusive draw request was canceled, or else
142  * the empty string if there was no exclusive draw request for this location.
143  */
144  std::string remove_exclusive_draw(const map_location& loc);
145 
146  /**
147  * Check the overlay_map for proper team-specific overlays to be
148  * displayed/hidden
149  */
150  void parse_team_overlays();
151 
152  /**
153  * Functions to add and remove overlays from locations.
154  *
155  * An overlay is an image that is displayed on top of the tile.
156  * One tile may have multiple overlays.
157  */
158  void add_overlay(const map_location& loc, const std::string& image,
159  const std::string& halo="", const std::string& team_name="",const std::string& item_id="",
160  bool visible_under_fog = true, float z_order = 0);
161 
162  /** remove_overlay will remove all overlays on a tile. */
163  void remove_overlay(const map_location& loc);
164 
165  /** remove_single_overlay will remove a single overlay from a tile */
166  void remove_single_overlay(const map_location& loc, const std::string& toDelete);
167 
168  /**
169  * Updates internals that cache map size. This should be called when the map
170  * size has changed.
171  */
172  void reload_map();
173 
174  void change_display_context(const display_context* dc);
175 
177  {
178  return *dc_;
179  }
180 
181  void reset_halo_manager();
182  void reset_halo_manager(halo::manager & hm);
183  halo::manager & get_halo_manager() { return *halo_man_; }
184 
185  /**
186  * Applies r,g,b coloring to the map.
187  *
188  * The color is usually taken from @ref get_time_of_day unless @a tod_override is given, in which
189  * case that color is used.
190  *
191  * @param tod_override The ToD to apply to the map instead of that of the current ToD's.
192  */
193  void update_tod(const time_of_day* tod_override = nullptr);
194 
195  /**
196  * Add r,g,b to the colors for all images displayed on the map.
197  *
198  * Used for special effects like flashes.
199  */
200  void adjust_color_overlay(int r, int g, int b);
201  tod_color get_color_overlay() const { return color_adjust_; }
202 
203 
204  /** Gets the underlying screen object. */
205  CVideo& video() { return screen_; }
206 
207  /** return the screen surface or the surface used for map_screenshot. */
208  surface& get_screen_surface() { return map_screenshot_ ? map_screenshot_surf_ : screen_.getDrawingSurface();}
209 
210  virtual bool in_game() const { return false; }
211  virtual bool in_editor() const { return false; }
212 
213  /** Virtual functions shadowed in game_display. These are needed to generate reports easily, without dynamic casting. Hope to factor out eventually. */
214  virtual const map_location & displayed_unit_hex() const { return map_location::null_location(); }
215  virtual int playing_side() const { return -100; } //In this case give an obviously wrong answer to fail fast, since this could actually cause a big bug. */
216  virtual const std::set<std::string>& observers() const { static const std::set<std::string> fake_obs = std::set<std::string> (); return fake_obs; }
217 
218  /**
219  * mapx is the width of the portion of the display which shows the game area.
220  * Between mapx and x is the sidebar region.
221  */
222 
223  const SDL_Rect& minimap_area() const
224  { return theme_.mini_map_location(screen_.draw_area()); }
225  const SDL_Rect& palette_area() const
226  { return theme_.palette_location(screen_.draw_area()); }
227  const SDL_Rect& unit_image_area() const
228  { return theme_.unit_image_location(screen_.draw_area()); }
229 
230  /**
231  * Returns the maximum area used for the map
232  * regardless to resolution and view size
233  */
234  const SDL_Rect& max_map_area() const;
235 
236  /**
237  * Returns the area used for the map
238  */
239  const SDL_Rect& map_area() const;
240 
241  /**
242  * Returns the available area for a map, this may differ
243  * from the above. This area will get the background area
244  * applied to it.
245  */
246  const SDL_Rect& map_outside_area() const { return map_screenshot_ ?
247  max_map_area() : theme_.main_map_location(screen_.draw_area()); }
248 
249  /** Check if the bbox of the hex at x,y has pixels outside the area rectangle. */
250  static bool outside_area(const SDL_Rect& area, const int x,const int y);
251 
252  /**
253  * Function which returns the width of a hex in pixels,
254  * up to where the next hex starts.
255  * (i.e. not entirely from tip to tip -- use hex_size()
256  * to get the distance from tip to tip)
257  */
258  static int hex_width() { return (zoom_*3)/4; }
259 
260  /**
261  * Function which returns the size of a hex in pixels
262  * (from top tip to bottom tip or left edge to right edge).
263  */
264  static int hex_size(){ return zoom_; }
265 
266  /** Returns the current zoom factor. */
267  static double get_zoom_factor()
268  {
269  return static_cast<double>(zoom_) / static_cast<double>(game_config::tile_size);
270  }
271 
272  /**
273  * given x,y co-ordinates of an onscreen pixel, will return the
274  * location of the hex that this pixel corresponds to.
275  * Returns an invalid location if the mouse isn't over any valid location.
276  */
277  const map_location hex_clicked_on(int x, int y) const;
278 
279  /**
280  * given x,y co-ordinates of a pixel on the map, will return the
281  * location of the hex that this pixel corresponds to.
282  * Returns an invalid location if the mouse isn't over any valid location.
283  */
284  const map_location pixel_position_to_hex(int x, int y) const;
285 
286  /**
287  * given x,y co-ordinates of the mouse, will return the location of the
288  * hex in the minimap that the mouse is currently over, or an invalid
289  * location if the mouse isn't over the minimap.
290  */
291  map_location minimap_location_on(int x, int y);
292 
293  const map_location& selected_hex() const { return selectedHex_; }
294  const map_location& mouseover_hex() const { return mouseoverHex_; }
295 
296  virtual void select_hex(map_location hex);
297  virtual void highlight_hex(map_location hex);
298 
299  /** Function to invalidate the game status displayed on the sidebar. */
300  void invalidate_game_status() { invalidateGameStatus_ = true; }
301 
302  /** Functions to get the on-screen positions of hexes. */
303  int get_location_x(const map_location& loc) const;
304  int get_location_y(const map_location& loc) const;
305 
306  /**
307  * Rectangular area of hexes, allowing to decide how the top and bottom
308  * edges handles the vertical shift for each parity of the x coordinate
309  */
311  int left;
312  int right;
313  int top[2]; // for even and odd values of x, respectively
314  int bottom[2];
315 
316  /** very simple iterator to walk into the rect_of_hexes */
317  struct iterator {
318  iterator(const map_location &loc, const rect_of_hexes &rect)
319  : loc_(loc), rect_(rect){}
320 
321  /** increment y first, then when reaching bottom, increment x */
322  iterator& operator++();
323  bool operator==(const iterator &that) const { return that.loc_ == loc_; }
324  bool operator!=(const iterator &that) const { return that.loc_ != loc_; }
325  const map_location& operator*() const {return loc_;}
326 
327  typedef std::forward_iterator_tag iterator_category;
329  typedef int difference_type;
330  typedef const map_location *pointer;
331  typedef const map_location &reference;
332 
333  private:
336  };
338 
339  iterator begin() const;
340  iterator end() const;
341  };
342 
343  /** Return the rectangular area of hexes overlapped by r (r is in screen coordinates) */
344  const rect_of_hexes hexes_under_rect(const SDL_Rect& r) const;
345 
346  /** Returns the rectangular area of visible hexes */
347  const rect_of_hexes get_visible_hexes() const {return hexes_under_rect(map_area());}
348 
349  /** Returns true if location (x,y) is covered in shroud. */
350  bool shrouded(const map_location& loc) const;
351 
352  /** Returns true if location (x,y) is covered in fog. */
353  bool fogged(const map_location& loc) const;
354 
355  /** Getter for the x,y debug overlay on tiles */
356  bool get_draw_coordinates() const { return draw_coordinates_; }
357  /** Setter for the x,y debug overlay on tiles */
358  void set_draw_coordinates(bool value) { draw_coordinates_ = value; }
359 
360  /** Getter for the terrain code debug overlay on tiles */
361  bool get_draw_terrain_codes() const { return draw_terrain_codes_; }
362  /** Setter for the terrain code debug overlay on tiles */
363  void set_draw_terrain_codes(bool value) { draw_terrain_codes_ = value; }
364 
365  /** Getter for the number of bitmaps debug overlay on tiles */
366  bool get_draw_num_of_bitmaps() const { return draw_num_of_bitmaps_; }
367  /** Setter for the terrain code debug overlay on tiles */
368  void set_draw_num_of_bitmaps(bool value) { draw_num_of_bitmaps_ = value; }
369 
370  /** Capture a (map-)screenshot into a surface. */
371  surface screenshot(bool map_screenshot = false);
372 
373  /** Invalidates entire screen, including all tiles and sidebar. Calls redraw observers. */
374  void redraw_everything();
375 
376  /** Adds a redraw observer, a function object to be called when redraw_everything is used */
377  void add_redraw_observer(std::function<void(display&)> f);
378 
379  /** Clear the redraw observers */
380  void clear_redraw_observers();
381 
382  theme& get_theme() { return theme_; }
383  void set_theme(const std::string& new_theme);
384 
385  /**
386  * Retrieves a pointer to a theme UI button.
387  *
388  * @note The returned pointer may either be nullptr, meaning the button
389  * isn't defined by the current theme, or point to a valid
390  * gui::button object. However, the objects retrieved will be
391  * destroyed and recreated by draw() method calls. Do *NOT* store
392  * these pointers for longer than strictly necessary to
393  * accomplish a specific task before the next screen refresh.
394  */
395  std::shared_ptr<gui::button> find_action_button(const std::string& id);
396  std::shared_ptr<gui::button> find_menu_button(const std::string& id);
397 
398  void create_buttons();
399 
400  void layout_buttons();
401 
402  void render_buttons();
403 
404  void invalidate_theme() { panelsDrawn_ = false; }
405 
406  void refresh_report(const std::string& report_name, const config * new_cfg=nullptr);
407 
408  void draw_minimap_units();
409 
410  /** Function to invalidate all tiles. */
411  void invalidate_all();
412 
413  /** Function to invalidate a specific tile for redrawing. */
414  bool invalidate(const map_location& loc);
415 
416  bool invalidate(const std::set<map_location>& locs);
417 
418  /**
419  * If this set is partially invalidated, invalidate all its hexes.
420  * Returns if any new invalidation was needed
421  */
422  bool propagate_invalidation(const std::set<map_location>& locs);
423 
424  /** invalidate all hexes under the rectangle rect (in screen coordinates) */
425  bool invalidate_locations_in_rect(const SDL_Rect& rect);
426  bool invalidate_visible_locations_in_rect(const SDL_Rect& rect);
427 
428  /**
429  * Function to invalidate animated terrains and units which may have changed.
430  */
431  void invalidate_animations();
432 
433  /**
434  * Per-location invalidation called by invalidate_animations()
435  * Extra game per-location invalidation (village ownership)
436  */
437  void invalidate_animations_location(const map_location& loc);
438 
439  void reset_standing_animations();
440 
441  /**
442  * mouseover_hex_overlay_ require a prerendered surface
443  * and is drawn underneath the mouse's location
444  */
446  { mouseover_hex_overlay_ = image; }
447 
449  { mouseover_hex_overlay_ = nullptr; }
450 
451  /** Toggle to continuously redraw the screen. */
452  static void toggle_benchmark();
453 
454  /**
455  * Toggle to debug foreground terrain.
456  * Separate background and foreground layer
457  * to better spot any error there.
458  */
459  static void toggle_debug_foreground();
460 
461  terrain_builder& get_builder() {return *builder_;}
462 
463  void flip();
464 
465  /** Copy the backbuffer to the framebuffer. */
466  void update_display();
467 
468  /** Rebuild all dynamic terrain. */
469  void rebuild_all();
470 
471  const theme::action* action_pressed();
472  const theme::menu* menu_pressed();
473 
474  void set_diagnostic(const std::string& msg);
475 
476  double turbo_speed() const;
477 
478  void bounds_check_position();
479  void bounds_check_position(int& xpos, int& ypos) const;
480 
481  /**
482  * Scrolls the display by xmov,ymov pixels.
483  * Invalidation and redrawing will be scheduled.
484  * @return true if the map actually moved.
485  */
486  bool scroll(int xmov, int ymov, bool force = false);
487 
488  /** Zooms the display in (true) or out (false). */
489  bool set_zoom(bool increase);
490 
491  /** Sets the display zoom to the specified amount. */
492  bool set_zoom(unsigned int amount, const bool validate_value_and_set_index = true);
493 
494  static bool zoom_at_max();
495  static bool zoom_at_min();
496 
497  /** Sets the zoom amount to the default. */
498  void toggle_default_zoom();
499 
500  bool view_locked() const { return view_locked_; }
501 
502  /** Sets whether the map view is locked (e.g. so the user can't scroll away) */
503  void set_view_locked(bool value) { view_locked_ = value; }
504 
505  enum SCROLL_TYPE { SCROLL, WARP, ONSCREEN, ONSCREEN_WARP };
506 
507  /**
508  * Scroll such that location loc is on-screen.
509  * WARP jumps to loc; SCROLL uses scroll speed;
510  * ONSCREEN only scrolls if x,y is offscreen
511  * force : scroll even if preferences tell us not to,
512  * or the view is locked.
513  */
514  void scroll_to_tile(const map_location& loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,bool force = true);
515 
516  /**
517  * Scroll such that location loc1 is on-screen.
518  * It will also try to make it such that loc2 is on-screen,
519  * but this is not guaranteed. For ONSCREEN scrolls add_spacing
520  * sets the desired minimum distance from the border in hexes.
521  */
522  void scroll_to_tiles(map_location loc1, map_location loc2,
523  SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,
524  double add_spacing=0.0, bool force=true);
525 
526  /** Scroll to fit as many locations on-screen as possible, starting with the first. */
527  void scroll_to_tiles(const std::vector<map_location>::const_iterator & begin,
528  const std::vector<map_location>::const_iterator & end,
529  SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,
530  bool only_if_possible=false, double add_spacing=0.0,
531  bool force=true);
532  /** Scroll to fit as many locations on-screen as possible, starting with the first. */
533  void scroll_to_tiles(const std::vector<map_location>& locs,
534  SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,
535  bool only_if_possible=false,
536  double add_spacing=0.0, bool force=true)
537  {
538  scroll_to_tiles(locs.begin(), locs.end(), scroll_type, check_fogged,
539  only_if_possible, add_spacing, force);
540  }
541 
542  /** Expose the event, so observers can be notified about map scrolling. */
543  events::generic_event &scroll_event() const { return scroll_event_; }
544 
545  /** Check if a tile is fully visible on screen. */
546  bool tile_fully_on_screen(const map_location& loc) const;
547 
548  /** Checks if location @a loc or one of the adjacent tiles is visible on screen. */
549  bool tile_nearly_on_screen(const map_location &loc) const;
550 
551  /**
552  * Draws invalidated items.
553  * If update is true, will also copy the display to the frame buffer.
554  * If force is true, will not skip frames, even if running behind.
555  * Not virtual, since it gathers common actions. Calls various protected
556  * virtuals (further below) to allow specialized behavior in derived classes.
557  */
558  virtual void draw();
559 
560  void draw(bool update);
561 
562  void draw(bool update, bool force);
563 
564  map_labels& labels();
565  const map_labels& labels() const;
566 
567  /** Holds options for calls to function 'announce' (@ref announce). */
569  {
570  /** Lifetime measured in milliseconds. */
571  int lifetime;
572 
573  /**
574  * An announcement according these options should replace the
575  * previous announce (typical of fast announcing) or not
576  * (typical of movement feedback).
577  */
579 
581  : lifetime(1600)
582  , discard_previous(false)
583  {
584  }
585  };
586 
587  /** Announce a message prominently. */
588  void announce(const std::string& msg,
589  const color_t& color = font::GOOD_COLOR,
591 
592  /**
593  * Schedule the minimap for recalculation.
594  * Useful if any terrain in the map has changed.
595  */
596  void recalculate_minimap() {minimap_ = nullptr; redrawMinimap_ = true; }
597 
598  /**
599  * Schedule the minimap to be redrawn.
600  * Useful if units have moved about on the map.
601  */
602  void redraw_minimap() { redrawMinimap_ = true; }
603 
604  virtual const time_of_day& get_time_of_day(const map_location& loc = map_location::null_location()) const;
605 
606  virtual bool has_time_area() const {return false;}
607 
608  void blindfold(bool flag);
609  bool is_blindfolded() const;
610 
611  void write(config& cfg) const;
612 
613  virtual void handle_event(const SDL_Event& );
614  virtual void handle_window_event(const SDL_Event& event);
615 
616 private:
617  void read(const config& cfg);
618 
619 public:
620  /** Init the flag list and the team colors used by ~TC */
621  void init_flags();
622 
623  /** Rebuild the flag list (not team colors) for a single side. */
624  void reinit_flags_for_team(const team&);
625  void reset_reports(reports& reports_object)
626  {
627  reports_object_ = &reports_object;
628  }
629 
630 private:
631  void init_flags_for_side_internal(std::size_t side, const std::string& side_color);
632 
634 
635 protected:
636  //TODO sort
638  std::unique_ptr<halo::manager> halo_man_;
639  std::weak_ptr<wb::manager> wb_;
640 
641  typedef std::map<map_location, std::string> exclusive_unit_draw_requests_t;
642  /** map of hexes where only one unit should be drawn, the one identified by the associated id string */
643  exclusive_unit_draw_requests_t exclusive_unit_draw_requests_;
644 
645  map_location get_middle_location() const;
646  /**
647  * Called near the beginning of each draw() call.
648  * Derived classes can use this to add extra actions before redrawing
649  * invalidated hexes takes place. No action here by default.
650  */
651  virtual void pre_draw() {}
652 
653  /**
654  * Called at the very end of each draw() call.
655  * Derived classes can use this to add extra actions after redrawing
656  * invalidated hexes takes place. No action here by default.
657  */
658  virtual void post_draw() {}
659 
660  /**
661  * Get the clipping rectangle for drawing.
662  * Virtual since the editor might use a slightly different approach.
663  */
664  virtual const SDL_Rect& get_clip_rect();
665 
666  /**
667  * Only called when there's actual redrawing to do. Loops through
668  * invalidated locations and redraws them. Derived classes can override
669  * this, possibly to insert pre- or post-processing around a call to the
670  * base class's function.
671  */
672  virtual void draw_invalidated();
673 
674  /**
675  * Hook for actions to take right after draw() calls drawing_buffer_commit
676  * No action here by default.
677  */
678  virtual void post_commit() {}
679 
680  /**
681  * Redraws a single gamemap location.
682  */
683  virtual void draw_hex(const map_location& loc);
684 
685  /**
686  * @returns the image type to be used for the passed hex
687  */
688  virtual image::TYPE get_image_type(const map_location& loc);
689 
690  /**
691  * Called near the end of a draw operation, derived classes can use this
692  * to render a specific sidebar. Very similar to post_commit.
693  */
694  virtual void draw_sidebar() {}
695 
696  void draw_minimap();
697 
698  enum TERRAIN_TYPE { BACKGROUND, FOREGROUND};
699 
700  void get_terrain_images(const map_location &loc,
701  const std::string& timeid,
703 
704  std::vector<surface> get_fog_shroud_images(const map_location& loc, image::TYPE image_type);
705 
706  void draw_image_for_report(surface& img, SDL_Rect& rect);
707 
708  void scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE scroll_type,bool force = true);
709 
710  static void fill_images_list(const std::string& prefix, std::vector<std::string>& images);
711 
712  static const std::string& get_variant(const std::vector<std::string>& variants, const map_location &loc);
713 
715  std::size_t currentTeam_;
716  bool dont_show_all_; //const team *viewpoint_;
717  /**
718  * Position of the top-left corner of the viewport, in pixels.
719  *
720  * Dependent on zoom_.. For example, ypos_==72 only means we're one
721  * hex below the top of the map when zoom_ == 72 (the default value).
722  */
723  int xpos_, ypos_;
726  /**
727  * The current zoom, in pixels (on screen) per 72 pixels (in the
728  * graphic assets), i.e., 72 means 100%.
729  */
730  static unsigned int zoom_;
732  /** The previous value of zoom_. */
733  static unsigned int last_zoom_;
734  const std::unique_ptr<fake_unit_manager> fake_unit_man_;
735  const std::unique_ptr<terrain_builder> builder_;
744  const std::unique_ptr<map_labels> map_labels_;
746 
747  /** Event raised when the map is being scrolled */
749 
750  boost::circular_buffer<unsigned> frametimes_; // in milliseconds
751  unsigned int fps_counter_;
752  std::chrono::seconds fps_start_;
753  unsigned int fps_actual_;
754  uint32_t last_frame_finished_ = 0u;
755 
756  // Not set by the initializer:
757  std::map<std::string, SDL_Rect> reportRects_;
758  std::map<std::string, surface> reportSurfaces_;
759  std::map<std::string, config> reports_;
760  std::vector<std::shared_ptr<gui::button>> menu_buttons_, action_buttons_;
761  std::set<map_location> invalidated_;
763  // If we're transitioning from one time of day to the next,
764  // then we will use these two masks on top of all hexes when we blit.
765  surface tod_hex_mask1, tod_hex_mask2;
766  std::vector<std::string> fog_images_;
767  std::vector<std::string> shroud_images_;
768 
772 
773  /** Local cache for preferences::animate_map, since it is constantly queried. */
775 
776  /** Local version of preferences::animate_water, used to detect when it's changed. */
778 
779 private:
780 
781  // This surface must be freed by the caller
782  surface get_flag(const map_location& loc);
783 
784  /** Animated flags for each team */
785  std::vector<animated<image::locator>> flags_;
786 
787  // This vector is a class member to avoid repeated memory allocations in get_terrain_images(),
788  // which turned out to be a significant bottleneck while profiling.
789  std::vector<surface> terrain_image_vector_;
790 
791 public:
792  /**
793  * The layers to render something on. This value should never be stored
794  * it's the internal drawing order and adding removing and reordering
795  * the layers should be safe.
796  * If needed in WML use the name and map that to the enum value.
797  */
799  LAYER_TERRAIN_BG, /**<
800  * Layer for the terrain drawn behind the
801  * unit.
802  */
803  LAYER_GRID_TOP, /**< Top half part of grid image */
804  LAYER_MOUSEOVER_OVERLAY, /**< Mouseover overlay used by editor*/
805  LAYER_FOOTSTEPS, /**< Footsteps showing path from unit to mouse */
806  LAYER_MOUSEOVER_TOP, /**< Top half of image following the mouse */
807  LAYER_UNIT_FIRST, /**< Reserve layers to be selected for WML. */
808  LAYER_UNIT_BG = LAYER_UNIT_FIRST+10, /**< Used for the ellipse behind the unit. */
809  LAYER_UNIT_DEFAULT=LAYER_UNIT_FIRST+40,/**<default layer for drawing units */
810  LAYER_TERRAIN_FG = LAYER_UNIT_FIRST+50, /**<
811  * Layer for the terrain drawn in front of
812  * the unit.
813  */
814  LAYER_GRID_BOTTOM, /**<
815  * Used for the bottom half part of grid image.
816  * Should be under moving units, to avoid masking south move.
817  */
818  LAYER_UNIT_MOVE_DEFAULT=LAYER_UNIT_FIRST+60/**<default layer for drawing moving units */,
819  LAYER_UNIT_FG = LAYER_UNIT_FIRST+80, /**<
820  * Used for the ellipse in front of the
821  * unit.
822  */
823  LAYER_UNIT_MISSILE_DEFAULT = LAYER_UNIT_FIRST+90, /**< default layer for missile frames*/
824  LAYER_UNIT_LAST=LAYER_UNIT_FIRST+100,
825  LAYER_REACHMAP, /**< "black stripes" on unreachable hexes. */
826  LAYER_MOUSEOVER_BOTTOM, /**< Bottom half of image following the mouse */
827  LAYER_FOG_SHROUD, /**< Fog and shroud. */
828  LAYER_ARROWS, /**< Arrows from the arrows framework. Used for planned moves display. */
829  LAYER_ACTIONS_NUMBERING, /**< Move numbering for the whiteboard. */
830  LAYER_SELECTED_HEX, /**< Image on the selected unit */
831  LAYER_ATTACK_INDICATOR, /**< Layer which holds the attack indicator. */
832  LAYER_UNIT_BAR, /**<
833  * Unit bars and overlays are drawn on this
834  * layer (for testing here).
835  */
836  LAYER_MOVE_INFO, /**< Movement info (defense%, etc...). */
837  LAYER_LINGER_OVERLAY, /**< The overlay used for the linger mode. */
838  LAYER_BORDER, /**< The border of the map. */
839  };
840 
841  /**
842  * Draw an image at a certain location.
843  * x,y: pixel location on screen to draw the image
844  * image: the image to draw
845  * reverse: if the image should be flipped across the x axis
846  * greyscale: used for instance to give the petrified appearance to a unit image
847  * alpha: the merging to use with the background
848  * blendto: blend to this color using blend_ratio
849  * submerged: the amount of the unit out of 1.0 that is submerged
850  * (presumably under water) and thus shouldn't be drawn
851  */
852  void render_image(int x, int y, const display::drawing_layer drawing_layer,
853  const map_location& loc, surface image,
854  bool hreverse=false, bool greyscale=false,
855  int32_t alpha=floating_to_fixed_point(1.0), color_t blendto = {0,0,0},
856  double blend_ratio=0, double submerged=0.0,bool vreverse =false);
857 
858  /**
859  * Draw text on a hex. (0.5, 0.5) is the center.
860  * The font size is adjusted to the zoom factor.
861  */
862  void draw_text_in_hex(const map_location& loc,
863  const drawing_layer layer, const std::string& text, std::size_t font_size,
864  color_t color, double x_in_hex=0.5, double y_in_hex=0.5);
865 
866 protected:
867 
868  //TODO sort
869  std::size_t activeTeam_;
870 
871  /**
872  * In order to render a hex properly it needs to be rendered per row. On
873  * this row several layers need to be drawn at the same time. Mainly the
874  * unit and the background terrain. This is needed since both can spill
875  * in the next hex. The foreground terrain needs to be drawn before to
876  * avoid decapitation a unit.
877  *
878  * In other words:
879  * for every layer
880  * for every row (starting from the top)
881  * for every hex in the row
882  * ...
883  *
884  * this is modified to:
885  * for every layer group
886  * for every row (starting from the top)
887  * for every layer in the group
888  * for every hex in the row
889  * ...
890  *
891  * * Surfaces are rendered per level in a map.
892  * * Per level the items are rendered per location these locations are
893  * stored in the drawing order required for units.
894  * * every location has a vector with surfaces, each with its own screen
895  * coordinate to render at.
896  * * every vector element has a vector with surfaces to render.
897  */
899  {
900  private:
901  unsigned int key_;
902 
903  // FIXME: temporary method. Group splitting should be made
904  // public into the definition of drawing_layer
905  //
906  // The drawing is done per layer_group, the range per group is [low, high).
907  static inline const std::array layer_groups {
908  LAYER_TERRAIN_BG,
909  LAYER_UNIT_FIRST,
910  LAYER_UNIT_MOVE_DEFAULT,
911  // Make sure the movement doesn't show above fog and reachmap.
912  LAYER_REACHMAP
913  };
914 
915  public:
916  drawing_buffer_key(const map_location &loc, drawing_layer layer);
917 
918  bool operator<(const drawing_buffer_key &rhs) const { return key_ < rhs.key_; }
919  };
920 
921  /** Helper structure for rendering the terrains. */
923  {
924  public:
925  // We don't want to copy this.
926  // It's expensive when done frequently due to the surface vector.
927  blit_helper(const blit_helper&) = delete;
928 
929  blit_helper(const drawing_layer layer, const map_location& loc,
930  const int x, const int y, const surface& surf,
931  const SDL_Rect& clip)
932  : x_(x), y_(y), surf_(1, surf), clip_(clip),
933  key_(loc, layer)
934  {}
935 
936  blit_helper(const drawing_layer layer, const map_location& loc,
937  const int x, const int y, const std::vector<surface>& surf,
938  const SDL_Rect& clip)
939  : x_(x), y_(y), surf_(surf), clip_(clip),
940  key_(loc, layer)
941  {}
942 
943  int x() const { return x_; }
944  int y() const { return y_; }
945  const std::vector<surface> &surf() const { return surf_; }
946  const SDL_Rect &clip() const { return clip_; }
947 
948  bool operator<(const blit_helper &rhs) const { return key_ < rhs.key_; }
949 
950  private:
951  int x_; /**< x screen coordinate to render at. */
952  int y_; /**< y screen coordinate to render at. */
953  std::vector<surface> surf_; /**< surface(s) to render. */
954  SDL_Rect clip_; /**<
955  * The clipping area of the source if
956  * omitted the entire source is used.
957  */
959  };
960 
961  typedef std::list<blit_helper> drawing_buffer;
962  drawing_buffer drawing_buffer_;
963 
964 public:
965  /**
966  * Add an item to the drawing buffer. You need to update screen on affected area
967  *
968  * @param layer The layer to draw on.
969  * @param loc The hex the image belongs to, needed for the
970  * drawing order.
971  * @param x The x coordinate.
972  * @param y The y coordinate.
973  * @param surf The surface to use.
974  * @param clip
975  */
976  void drawing_buffer_add(const drawing_layer layer,
977  const map_location& loc, int x, int y, const surface& surf,
978  const SDL_Rect &clip = SDL_Rect());
979 
980  void drawing_buffer_add(const drawing_layer layer,
981  const map_location& loc, int x, int y,
982  const std::vector<surface> &surf,
983  const SDL_Rect &clip = SDL_Rect());
984 
985 protected:
986 
987  /** Draws the drawing_buffer_ and clears it. */
988  void drawing_buffer_commit();
989 
990  /** Clears the drawing buffer. */
991  void drawing_buffer_clear();
992 
993  /** redraw all panels associated with the map display */
994  void draw_all_panels();
995 
996 
997  /**
998  * Initiate a redraw.
999  *
1000  * Invalidate controls and panels when changed after they have been drawn
1001  * initially. Useful for dynamic theme modification.
1002  */
1003  void draw_init();
1004  void draw_wrap(bool update,bool force);
1005 
1006  /** Used to indicate to drawing functions that we are doing a map screenshot */
1008 
1009 public: //operations for the arrow framework
1010 
1011  void add_arrow(arrow&);
1012 
1013  void remove_arrow(arrow&);
1014 
1015  /** Called by arrow objects when they change. You should not need to call this directly. */
1016  void update_arrow(arrow & a);
1017 
1018 protected:
1019 
1020  // Tiles lit for showing where unit(s) can reach
1021  typedef std::map<map_location,unsigned int> reach_map;
1022  reach_map reach_map_;
1023  reach_map reach_map_old_;
1025  void process_reachmap_changes();
1026 
1027  typedef std::map<map_location, std::vector<overlay>> overlay_map;
1028 
1029  virtual overlay_map& get_overlays() = 0;
1030 
1031 private:
1032  /** Handle for the label which displays frames per second. */
1034  /** Count work done for the debug info displayed under fps */
1037 
1039 
1040  std::vector<std::function<void(display&)>> redraw_observers_;
1041 
1042  /** Debug flag - overlay x,y coords on tiles */
1044  /** Debug flag - overlay terrain codes on tiles */
1046  /** Debug flag - overlay number of bitmaps on tiles */
1048 
1049  typedef std::list<arrow*> arrows_list_t;
1050  typedef std::map<map_location, arrows_list_t > arrows_map_t;
1051  /** Maps the list of arrows for each location */
1052  arrows_map_t arrows_map_;
1053 
1055 
1056  bool dirty_;
1057 
1058  std::vector<std::tuple<int, int, int>> fps_history_;
1059 
1060 protected:
1062 };
1063 
1064 struct blindfold
1065 {
1066  blindfold(display& d, bool lock=true) : display_(d), blind(lock) {
1067  if(blind) {
1068  display_.blindfold(true);
1069  }
1070  }
1071 
1073  unblind();
1074  }
1075 
1076  void unblind() {
1077  if(blind) {
1078  display_.blindfold(false);
1079  blind = false;
1080  }
1081  }
1082 
1083 private:
1085  bool blind;
1086 };
The overlay used for the linger mode.
Definition: display.hpp:837
const map_location & mouseover_hex() const
Definition: display.hpp:294
TYPE
Used to specify the rendering format of images.
Definition: picture.hpp:229
int zoom_index_
Definition: display.hpp:731
Reserve layers to be selected for WML.
Definition: display.hpp:807
virtual void pre_draw()
Called near the beginning of each draw() call.
Definition: display.hpp:651
bool discard_previous
An announcement according these options should replace the previous announce (typical of fast announc...
Definition: display.hpp:578
halo::manager & get_halo_manager()
Definition: display.hpp:183
Move numbering for the whiteboard.
Definition: display.hpp:829
void set_draw_num_of_bitmaps(bool value)
Setter for the terrain code debug overlay on tiles.
Definition: display.hpp:368
reports * reports_object_
Definition: display.hpp:745
bool view_locked() const
Definition: display.hpp:500
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:96
virtual const map_location & displayed_unit_hex() const
Virtual functions shadowed in game_display.
Definition: display.hpp:214
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Definition: display.hpp:300
In order to render a hex properly it needs to be rendered per row.
Definition: display.hpp:898
Small struct to store and manipulate ToD color adjusts.
Definition: time_of_day.hpp:27
theme & get_theme()
Definition: display.hpp:382
void set_draw_terrain_codes(bool value)
Setter for the terrain code debug overlay on tiles.
Definition: display.hpp:363
virtual void draw_sidebar()
Called near the end of a draw operation, derived classes can use this to render a specific sidebar...
Definition: display.hpp:694
static int hex_size()
Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right ...
Definition: display.hpp:264
This class represents a single unit of a specific type.
Definition: unit.hpp:120
bool animate_water_
Local version of preferences::animate_water, used to detect when it&#39;s changed.
Definition: display.hpp:777
CKey keys_
Definition: display.hpp:771
virtual bool in_game() const
Definition: display.hpp:210
boost::circular_buffer< unsigned > frametimes_
Definition: display.hpp:750
bool get_draw_num_of_bitmaps() const
Getter for the number of bitmaps debug overlay on tiles.
Definition: display.hpp:366
const map_location & operator*() const
Definition: display.hpp:325
int ypos_
Definition: display.hpp:723
const map_location & selected_hex() const
Definition: display.hpp:293
bool reach_map_changed_
Definition: display.hpp:1024
static double get_zoom_factor()
Returns the current zoom factor.
Definition: display.hpp:267
drawing_buffer drawing_buffer_
Definition: display.hpp:962
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
Definition: display.hpp:543
const color_t GOOD_COLOR
void clear_exclusive_draws()
Cancels all the exclusive draw requests.
Definition: display.hpp:128
Arrows from the arrows framework.
Definition: display.hpp:828
#define a
void scroll_to_tiles(const std::vector< map_location > &locs, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool only_if_possible=false, double add_spacing=0.0, bool force=true)
Scroll to fit as many locations on-screen as possible, starting with the first.
Definition: display.hpp:533
Definition: video.hpp:35
std::map< std::string, SDL_Rect > reportRects_
Definition: display.hpp:757
map_location mouseoverHex_
Definition: display.hpp:770
Manages a list of fake units for the display object.
bool operator!=(const iterator &that) const
Definition: display.hpp:324
Mouseover overlay used by editor.
Definition: display.hpp:804
bool draw_coordinates_
Debug flag - overlay x,y coords on tiles.
Definition: display.hpp:1043
drawing_buffer_key key_
Definition: display.hpp:958
std::list< blit_helper > drawing_buffer
Definition: display.hpp:961
int fps_handle_
Handle for the label which displays frames per second.
Definition: display.hpp:1033
bool show_everything() const
Definition: display.hpp:98
The class terrain_builder is constructed from a config object, and a gamemap object.
Definition: builder.hpp:48
bool blind
Definition: display.hpp:1085
std::map< map_location, std::string > exclusive_unit_draw_requests_t
Definition: display.hpp:641
const unit_map & get_units() const
Definition: display.hpp:129
int viewing_side() const
Definition: display.hpp:111
reach_map reach_map_
Definition: display.hpp:1022
const rect_of_hexes & rect_
Definition: display.hpp:335
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:110
std::vector< std::function< void(display &)> > redraw_observers_
Definition: display.hpp:1040
Bottom half of image following the mouse.
Definition: display.hpp:826
void clear_mouseover_hex_overlay()
Definition: display.hpp:448
double turbo_speed()
Definition: general.cpp:486
map_location selectedHex_
Definition: display.hpp:769
CVideo & screen_
Definition: display.hpp:714
static display * singleton_
Definition: display.hpp:1061
const SDL_Rect & unit_image_area() const
Definition: display.hpp:227
#define d
Top half part of grid image.
Definition: display.hpp:803
terrain_builder & get_builder()
Definition: display.hpp:461
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
Definition: display.hpp:310
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:730
const SDL_Rect & minimap_area() const
mapx is the width of the portion of the display which shows the game area.
Definition: display.hpp:223
drawing_layer
The layers to render something on.
Definition: display.hpp:798
void redraw_minimap()
Schedule the minimap to be redrawn.
Definition: display.hpp:602
bool panelsDrawn_
Definition: display.hpp:742
surface tod_hex_mask2
Definition: display.hpp:765
Unit and team statistics.
very simple iterator to walk into the rect_of_hexes
Definition: display.hpp:317
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
Definition: display.hpp:347
map_location loc_
surface map_screenshot_surf_
Definition: display.hpp:1038
virtual bool in_editor() const
Definition: display.hpp:211
Top half of image following the mouse.
Definition: display.hpp:806
#define b
std::vector< std::string > shroud_images_
Definition: display.hpp:767
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:56
const config & options()
Definition: game.cpp:562
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
Definition: parser.cpp:764
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:75
Image on the selected unit.
Definition: display.hpp:830
void set_theme(const std::string &theme)
Definition: game.cpp:823
Arrows destined to be drawn on the map.
Definition: arrow.hpp:30
void read(config &cfg, std::istream &in, abstract_validator *validator)
Definition: parser.cpp:627
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:1027
Animate units.
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.hpp:596
const map_location & reference
Definition: display.hpp:331
void set_draw_coordinates(bool value)
Setter for the x,y debug overlay on tiles.
Definition: display.hpp:358
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
Definition: display.hpp:1007
arrows_map_t arrows_map_
Maps the list of arrows for each location.
Definition: display.hpp:1052
This class is the frontend of the whiteboard framework for the rest of the Wesnoth code...
Definition: manager.hpp:43
const std::unique_ptr< map_labels > map_labels_
Definition: display.hpp:744
bool dirty_
Definition: display.hpp:1056
Encapsulates the map of the game.
Definition: map.hpp:171
void unblind()
Definition: display.hpp:1076
SDL_Rect minimap_location_
Definition: display.hpp:737
const SDL_Rect & palette_area() const
Definition: display.hpp:225
void set_zoom(unsigned int amount)
Sets the scaling factor for images.
Definition: picture.cpp:719
tod_color color_adjust_
Definition: display.hpp:1054
virtual int playing_side() const
Definition: display.hpp:215
virtual void post_draw()
Called at the very end of each draw() call.
Definition: display.hpp:658
bool invalidateGameStatus_
Definition: display.hpp:743
unsigned int fps_actual_
Definition: display.hpp:753
void set_mouseover_hex_overlay(const surface &image)
mouseover_hex_overlay_ require a prerendered surface and is drawn underneath the mouse&#39;s location ...
Definition: display.hpp:445
blit_helper(const drawing_layer layer, const map_location &loc, const int x, const int y, const std::vector< surface > &surf, const SDL_Rect &clip)
Definition: display.hpp:936
int invalidated_hexes_
Count work done for the debug info displayed under fps.
Definition: display.hpp:1035
bool draw_terrain_codes_
Debug flag - overlay terrain codes on tiles.
Definition: display.hpp:1045
bool get_draw_coordinates() const
Getter for the x,y debug overlay on tiles.
Definition: display.hpp:356
std::vector< surface > surf_
surface(s) to render.
Definition: display.hpp:953
static int hex_width()
Function which returns the width of a hex in pixels, up to where the next hex starts.
Definition: display.hpp:258
static unsigned int last_zoom_
The previous value of zoom_.
Definition: display.hpp:733
Fog and shroud.
Definition: display.hpp:827
std::unique_ptr< halo::manager > halo_man_
Definition: display.hpp:638
Encapsulates the map of the game.
Definition: location.hpp:38
surface & get_screen_surface()
return the screen surface or the surface used for map_screenshot.
Definition: display.hpp:208
Holds options for calls to function &#39;announce&#39; (announce).
Definition: display.hpp:568
std::size_t activeTeam_
Definition: display.hpp:869
std::vector< std::shared_ptr< gui::button > > menu_buttons_
Definition: display.hpp:760
blindfold(display &d, bool lock=true)
Definition: display.hpp:1066
virtual bool has_time_area() const
Definition: display.hpp:606
unsigned int fps_counter_
Definition: display.hpp:751
Definition: theme.hpp:41
double g
Definition: astarsearch.cpp:65
std::size_t playing_team() const
The playing team is the team whose turn it is.
Definition: display.hpp:105
bool draw_num_of_bitmaps_
Debug flag - overlay number of bitmaps on tiles.
Definition: display.hpp:1047
bool redraw_background_
Definition: display.hpp:739
bool dont_show_all_
Definition: display.hpp:716
Definitions related to theme-support.
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.hpp:246
Helper structure for rendering the terrains.
Definition: display.hpp:922
const display_context & get_disp_context() const
Definition: display.hpp:176
const map_location * pointer
Definition: display.hpp:330
Declarations for File-IO.
theme theme_
Definition: display.hpp:725
Movement info (defense%, etc...).
Definition: display.hpp:836
bool view_locked_
Definition: display.hpp:724
surface mouseover_hex_overlay_
Definition: display.hpp:762
std::map< map_location, arrows_list_t > arrows_map_t
Definition: display.hpp:1050
void set_view_locked(bool value)
Sets whether the map view is locked (e.g.
Definition: display.hpp:503
std::list< arrow * > arrows_list_t
Definition: display.hpp:1049
std::vector< std::string > fog_images_
Definition: display.hpp:766
std::chrono::seconds fps_start_
Definition: display.hpp:752
int x_
x screen coordinate to render at.
Definition: display.hpp:951
display & display_
Definition: display.hpp:1084
std::map< map_location, unsigned int > reach_map
Definition: display.hpp:1021
bool redrawMinimap_
Definition: display.hpp:738
virtual const std::set< std::string > & observers() const
Definition: display.hpp:216
bool operator<(const blit_helper &rhs) const
Definition: display.hpp:948
Definition: display.hpp:45
const std::vector< team > & get_teams() const
Definition: display.hpp:102
reach_map reach_map_old_
Definition: display.hpp:1023
const gamemap & get_map() const
Definition: display.hpp:100
virtual void post_commit()
Hook for actions to take right after draw() calls drawing_buffer_commit No action here by default...
Definition: display.hpp:678
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:643
Contains the SDL_Rect helper code.
iterator(const map_location &loc, const rect_of_hexes &rect)
Definition: display.hpp:318
bool invalidateAll_
Definition: display.hpp:740
events::generic_event scroll_event_
Event raised when the map is being scrolled.
Definition: display.hpp:748
#define f
int lifetime
Lifetime measured in milliseconds.
Definition: display.hpp:571
std::map< std::string, surface > reportSurfaces_
Definition: display.hpp:758
std::set< map_location > invalidated_
Definition: display.hpp:761
unsigned int tile_size
Definition: game_config.cpp:69
blit_helper(const drawing_layer layer, const map_location &loc, const int x, const int y, const surface &surf, const SDL_Rect &clip)
Definition: display.hpp:929
std::map< std::string, config > reports_
Definition: display.hpp:759
const display_context * dc_
Definition: display.hpp:637
std::forward_iterator_tag iterator_category
Definition: display.hpp:327
bool operator<(const drawing_buffer_key &rhs) const
Definition: display.hpp:918
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:110
std::vector< surface > terrain_image_vector_
Definition: display.hpp:789
Functions to load and save images from/to disk.
const std::vector< surface > & surf() const
Definition: display.hpp:945
int drawn_hexes_
Definition: display.hpp:1036
int diagnostic_label_
Definition: display.hpp:741
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:205
static const map_location & null_location()
Definition: location.hpp:81
tod_color get_color_overlay() const
Definition: display.hpp:201
Container associating units to locations.
Definition: map.hpp:98
const std::unique_ptr< fake_unit_manager > fake_unit_man_
Definition: display.hpp:734
std::vector< animated< image::locator > > flags_
Animated flags for each team.
Definition: display.hpp:785
bool get_draw_terrain_codes() const
Getter for the terrain code debug overlay on tiles.
Definition: display.hpp:361
int y_
y screen coordinate to render at.
Definition: display.hpp:952
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60
std::vector< std::tuple< int, int, int > > fps_history_
Definition: display.hpp:1058
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:28
The border of the map.
Definition: display.hpp:838
constexpr int32_t floating_to_fixed_point(double n)
Converts a double to a fixed point.
Definition: math.hpp:195
SDL_Rect clip_
The clipping area of the source if omitted the entire source is used.
Definition: display.hpp:954
bool animate_map_
Local cache for preferences::animate_map, since it is constantly queried.
Definition: display.hpp:774
bool operator==(const iterator &that) const
Definition: display.hpp:323
const std::unique_ptr< terrain_builder > builder_
Definition: display.hpp:735
void invalidate_theme()
Definition: display.hpp:404
void reset_reports(reports &reports_object)
Definition: display.hpp:625
std::weak_ptr< wb::manager > wb_
Definition: display.hpp:639
Definition: display.hpp:49
Layer which holds the attack indicator.
Definition: display.hpp:831
int blindfold_ctr_
Definition: display.hpp:633
TERRAIN_TYPE
Definition: display.hpp:698
Footsteps showing path from unit to mouse.
Definition: display.hpp:805
"black stripes" on unreachable hexes.
Definition: display.hpp:825
std::size_t currentTeam_
Definition: display.hpp:715
surface minimap_
Definition: display.hpp:736
const SDL_Rect & clip() const
Definition: display.hpp:946