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