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