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