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