The Battle for Wesnoth  1.19.7+dev
display.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  *
19  * map_display and display: classes which take care of
20  * displaying the map and game-data on the screen.
21  *
22  * The display is divided into two main sections:
23  * - the game area, which displays the tiles of the game board, and units on them,
24  * - and the side bar, which appears on the right hand side.
25  * The side bar display is divided into three sections:
26  * - the minimap, which is displayed at the top right
27  * - the game status, which includes the day/night image,
28  * the turn number, information about the current side,
29  * and information about the hex currently moused over (highlighted)
30  * - the unit status, which displays an image and stats
31  * for the current unit.
32  */
33 
34 #pragma once
35 
36 class 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 
45 namespace wb {
46  class manager;
47 }
48 
49 #include "animated.hpp"
50 #include "display_context.hpp"
51 #include "drawing_layer.hpp"
52 #include "font/standard_colors.hpp"
53 #include "game_config.hpp"
55 #include "halo.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 "sdl/texture.hpp"
62 #include "theme.hpp"
63 #include "widgets/button.hpp"
64 
65 #include <boost/circular_buffer.hpp>
66 
67 #include <bitset>
68 #include <functional>
69 #include <chrono>
70 #include <cstdint>
71 #include <list>
72 #include <map>
73 #include <memory>
74 #include <vector>
75 
76 namespace display_direction {
77  /**
78  * @note needs to be defined after includes
79  * as it uses std::string
80  */
81  const std::string& get_direction(std::size_t n);
82 }
83 
85 {
88  std::array<SDL_Vertex, 4> alpha_verts;
89 };
90 
91 class gamemap;
92 
93 /**
94  * Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
95  */
97 {
98 public:
99  display(const display_context* dc,
100  std::weak_ptr<wb::manager> wb,
101  reports& reports_object,
102  const std::string& theme_id,
103  const config& level);
104 
105  virtual ~display();
106  /**
107  * Returns the display object if a display object exists. Otherwise it returns nullptr.
108  * the display object represents the game gui which handles themewml and drawing the map.
109  * A display object only exists during a game or while the mapeditor is running.
110  */
111  static display* get_singleton() { return singleton_ ;}
112 
113  bool show_everything() const { return !dont_show_all_ && !is_blindfolded(); }
114 
115  /** The playing team is the team whose turn it is. */
116  std::size_t playing_team_index() const { return playing_team_index_; }
117 
118  /**
119  * The viewing team is the team currently viewing the game. It's the team whose gold and income
120  * is shown in the top bar of the default theme.
121  *
122  * For players, it will be their side (or one of them, if they control multiple sides).
123  *
124  * The value returned is a 0-based index into the vector returned by dc_->teams().
125  */
126  std::size_t viewing_team_index() const { return viewing_team_index_; }
127 
128  const team& playing_team() const;
129  const team& viewing_team() const;
130 
132  {
134  }
135 
136  /**
137  * Sets the team controlled by the player using the computer.
138  * Data from this team will be displayed in the game status.
139  */
140  void set_viewing_team_index(std::size_t team, bool observe=false);
141 
142  /**
143  * sets the team whose turn it currently is
144  */
145  void set_playing_team_index(std::size_t team);
146 
147  /**
148  * Cancels all the exclusive draw requests.
149  */
151 
152  /**
153  * Allows a unit to request to be the only one drawn in its hex. Useful for situations where
154  * multiple units (one real, multiple temporary) can end up stacked, such as with the whiteboard.
155  * @param loc The location of the unit requesting exclusivity.
156  * @param unit The unit requesting exclusivity.
157  * @return false if there's already an exclusive draw request for this location.
158  */
159  bool add_exclusive_draw(const map_location& loc, const unit& unit);
160 
161  /**
162  * Cancels an exclusive draw request.
163  * @return The id of the unit whose exclusive draw request was canceled, or else
164  * the empty string if there was no exclusive draw request for this location.
165  */
166  std::string remove_exclusive_draw(const map_location& loc);
167 
168  /** Returns true if there is no exclusive draw request for @a loc, or if there is, that it's for @a unit */
169  bool unit_can_draw_here(const map_location& loc, const unit& unit) const;
170 
171  /**
172  * Functions to add and remove overlays from locations.
173  *
174  * An overlay is an image that is displayed on top of the tile.
175  * One tile may have multiple overlays.
176  */
177  void add_overlay(const map_location& loc, overlay&& ov);
178 
179  /** remove_overlay will remove all overlays on a tile. */
180  void remove_overlay(const map_location& loc);
181 
182  /** remove_single_overlay will remove a single overlay from a tile */
183  void remove_single_overlay(const map_location& loc, const std::string& toDelete);
184 
185  /**
186  * Updates internals that cache map size. This should be called when the map
187  * size has changed.
188  */
189  void reload_map();
190 
191  void change_display_context(const display_context* dc);
192 
193  const display_context& context() const
194  {
195  return *dc_;
196  }
197 
199 
200  /**
201  * Applies r,g,b coloring to the map.
202  *
203  * The color is usually taken from @ref get_time_of_day unless @a tod_override is given, in which
204  * case that color is used.
205  *
206  * @param tod_override The ToD to apply to the map instead of that of the current ToD's.
207  */
208  void update_tod(const time_of_day* tod_override = nullptr);
209 
210  /**
211  * Add r,g,b to the colors for all images displayed on the map.
212  *
213  * Used for special effects like flashes.
214  */
215  void adjust_color_overlay(int r, int g, int b);
217 
218  virtual bool in_game() const { return false; }
219  virtual bool in_editor() const { return false; }
220 
221  /** Virtual functions shadowed in game_display. These are needed to generate reports easily, without dynamic casting. Hope to factor out eventually. */
222  virtual const map_location & displayed_unit_hex() const { return map_location::null_location(); }
223  virtual const std::set<std::string>& observers() const { static const std::set<std::string> fake_obs = std::set<std::string> (); return fake_obs; }
224 
225  /**
226  * mapx is the width of the portion of the display which shows the game area.
227  * Between mapx and x is the sidebar region.
228  */
229 
230  const rect& minimap_area() const;
231  const rect& palette_area() const;
232  const rect& unit_image_area() const;
233 
234  /**
235  * Returns the maximum area used for the map
236  * regardless to resolution and view size
237  */
238  rect max_map_area() const;
239 
240  /**
241  * Returns the area used for the map
242  */
243  rect map_area() const;
244 
245  /**
246  * Returns the available area for a map, this may differ
247  * from the above. This area will get the background area
248  * applied to it.
249  */
250  rect map_outside_area() const;
251 
252  /** Check if the bbox of the hex at x,y has pixels outside the area rectangle. */
253  static bool outside_area(const SDL_Rect& area, const int x,const int y);
254 
255  /**
256  * Function which returns the width of a hex in pixels,
257  * up to where the next hex starts.
258  * (i.e. not entirely from tip to tip -- use hex_size()
259  * to get the distance from tip to tip)
260  */
261  static int hex_width() { return (zoom_*3)/4; }
262 
263  /**
264  * Function which returns the size of a hex in pixels
265  * (from top tip to bottom tip or left edge to right edge).
266  */
267  static int hex_size(){ return zoom_; }
268 
269  /** Returns the current zoom factor. */
270  static double get_zoom_factor()
271  {
272  return static_cast<double>(zoom_) / static_cast<double>(game_config::tile_size);
273  }
274 
275  /** Scale the width and height of a rect by the current zoom factor */
276  static rect scaled_to_zoom(const SDL_Rect& r)
277  {
278  const double zf = get_zoom_factor();
279  return {r.x, r.y, int(r.w * zf), int(r.h * zf)};
280  }
281 
282  static point scaled_to_zoom(const point& p)
283  {
284  const double zf = get_zoom_factor();
285  return {int(p.x * zf), int(p.y * zf)};
286  }
287 
288  /**
289  * given x,y co-ordinates of an onscreen pixel, will return the
290  * location of the hex that this pixel corresponds to.
291  * Returns an invalid location if the mouse isn't over any valid location.
292  */
293  map_location hex_clicked_on(int x, int y) const;
294 
295  /**
296  * given x,y co-ordinates of a pixel on the map, will return the
297  * location of the hex that this pixel corresponds to.
298  * Returns an invalid location if the mouse isn't over any valid location.
299  */
300  map_location pixel_position_to_hex(int x, int y) const;
301 
302  /**
303  * given x,y co-ordinates of the mouse, will return the location of the
304  * hex in the minimap that the mouse is currently over, or an invalid
305  * location if the mouse isn't over the minimap.
306  */
307  map_location minimap_location_on(int x, int y);
308 
309  const map_location& selected_hex() const { return selectedHex_; }
310  const map_location& mouseover_hex() const { return mouseoverHex_; }
311 
312  virtual void select_hex(map_location hex);
313  virtual void highlight_hex(map_location hex);
314 
315  /** Function to invalidate the game status displayed on the sidebar. */
317 
318  /** Functions to get the on-screen positions of hexes. */
319  point get_location(const map_location& loc) const;
320 
321  /** Returns the on-screen rect corresponding to a @a loc */
322  rect get_location_rect(const map_location& loc) const;
323 
324  /**
325  * Rectangular area of hexes, allowing to decide how the top and bottom
326  * edges handles the vertical shift for each parity of the x coordinate
327  */
329  int left;
330  int right;
331  int top[2]; // for even and odd values of x, respectively
332  int bottom[2];
333 
334  /** very simple iterator to walk into the rect_of_hexes */
335  struct iterator {
337  : loc_(loc), rect_(rect){}
338 
339  /** increment y first, then when reaching bottom, increment x */
340  iterator& operator++();
341  bool operator==(const iterator &that) const { return that.loc_ == loc_; }
342  bool operator!=(const iterator &that) const { return that.loc_ != loc_; }
343  const map_location& operator*() const {return loc_;}
344 
345  typedef std::forward_iterator_tag iterator_category;
347  typedef int difference_type;
348  typedef const map_location *pointer;
349  typedef const map_location &reference;
350 
351  private:
354  };
356 
357  iterator begin() const;
358  iterator end() const;
359  };
360 
361  /** Return the rectangular area of hexes overlapped by r (r is in screen coordinates) */
362  const rect_of_hexes hexes_under_rect(const rect& r) const;
363 
364  /** Returns the rectangular area of visible hexes */
366 
367  /** Returns true if location (x,y) is covered in shroud. */
368  bool shrouded(const map_location& loc) const;
369 
370  /** Returns true if location (x,y) is covered in fog. */
371  bool fogged(const map_location& loc) const;
372 
373  /** Capture a (map-)screenshot into a surface. */
374  surface screenshot(bool map_screenshot = false);
375 
376  /** Marks everything for rendering including all tiles and sidebar.
377  * Also calls redraw observers. */
378  void queue_rerender();
379 
380  /** Queues repainting to the screen, but doesn't rerender. */
381  void queue_repaint();
382 
383  /** Adds a redraw observer, a function object to be called when a
384  * full rerender is queued. */
385  void add_redraw_observer(const std::function<void(display&)>& f);
386 
387  /** Clear the redraw observers */
388  void clear_redraw_observers();
389 
390  theme& get_theme() { return theme_; }
391  void set_theme(const std::string& new_theme);
392 
393  /**
394  * Retrieves a pointer to a theme UI button.
395  *
396  * @note The returned pointer may either be nullptr, meaning the button
397  * isn't defined by the current theme, or point to a valid
398  * gui::button object. However, the objects retrieved will be
399  * destroyed and recreated by draw() method calls. Do *NOT* store
400  * these pointers for longer than strictly necessary to
401  * accomplish a specific task before the next screen refresh.
402  */
403  std::shared_ptr<gui::button> find_action_button(const std::string& id);
404  std::shared_ptr<gui::button> find_menu_button(const std::string& id);
405 
406  void create_buttons();
407 
408  void layout_buttons();
409 
410  void draw_buttons();
411 
412  /** Hide theme buttons so they don't draw. */
413  void hide_buttons();
414  /** Unhide theme buttons so they draw again. */
415  void unhide_buttons();
416 
417  /** Update the given report. Actual drawing is done in draw_report(). */
418  void refresh_report(const std::string& report_name, const config * new_cfg=nullptr);
419 
420  /**
421  * Draw the specified report.
422  *
423  * If test_run is true, it will simulate the draw without actually
424  * drawing anything. This will add any overflowing information to the
425  * report tooltip, and also registers the tooltip.
426  */
427  void draw_report(const std::string& report_name, bool test_run = false);
428 
429  /** Draw all reports in the given region.
430  * Returns true if something was drawn, false otherwise. */
431  bool draw_reports(const rect& region);
432 
433  void draw_minimap_units();
434 
435  /** Function to invalidate all tiles. */
436  void invalidate_all();
437 
438  /** Function to invalidate a specific tile for redrawing. */
439  bool invalidate(const map_location& loc);
440 
441  bool invalidate(const std::set<map_location>& locs);
442 
443  /**
444  * If this set is partially invalidated, invalidate all its hexes.
445  * Returns if any new invalidation was needed
446  */
447  bool propagate_invalidation(const std::set<map_location>& locs);
448 
449  /** invalidate all hexes under the rectangle rect (in screen coordinates) */
450  bool invalidate_locations_in_rect(const SDL_Rect& rect);
451  bool invalidate_visible_locations_in_rect(const SDL_Rect& rect);
452 
453  /**
454  * Function to invalidate animated terrains and units which may have changed.
455  */
456  void invalidate_animations();
457 
458  /**
459  * Per-location invalidation called by invalidate_animations()
460  * Extra game per-location invalidation (village ownership)
461  */
463 
465 
467 
468  void update_fps_label();
469  void clear_fps_label();
470  void update_fps_count();
471 
472  /** Rebuild all dynamic terrain. */
473  void rebuild_all();
474 
475  const theme::action* action_pressed();
476  const theme::menu* menu_pressed();
477 
478  void set_diagnostic(const std::string& msg);
479 
480  double turbo_speed() const;
481 
482  void bounds_check_position();
483  void bounds_check_position(int& xpos, int& ypos) const;
484 
485  /**
486  * Scrolls the display by @a amount pixels.
487  * Invalidation and redrawing will be scheduled.
488  * @return true if the map actually moved.
489  */
490  bool scroll(const point& amount, bool force = false);
491 
492  /** Zooms the display in (true) or out (false). */
493  bool set_zoom(bool increase);
494 
495  /** Sets the display zoom to the specified amount. */
496  bool set_zoom(unsigned int amount, const bool validate_value_and_set_index = true);
497 
498  static bool zoom_at_max();
499  static bool zoom_at_min();
500 
501  /** Sets the zoom amount to the default. */
502  void toggle_default_zoom();
503 
504  bool view_locked() const { return view_locked_; }
505 
506  /** Sets whether the map view is locked (e.g. so the user can't scroll away) */
507  void set_view_locked(bool value) { view_locked_ = value; }
508 
510 
511  /**
512  * Scroll such that location loc is on-screen.
513  * WARP jumps to loc; SCROLL uses scroll speed;
514  * ONSCREEN only scrolls if x,y is offscreen
515  * force : scroll even if preferences tell us not to,
516  * or the view is locked.
517  */
518  void scroll_to_tile(const map_location& loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,bool force = true);
519 
520  /**
521  * Scroll such that location loc1 is on-screen.
522  * It will also try to make it such that loc2 is on-screen,
523  * but this is not guaranteed. For ONSCREEN scrolls add_spacing
524  * sets the desired minimum distance from the border in hexes.
525  */
526  void scroll_to_tiles(map_location loc1, map_location loc2,
527  SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,
528  double add_spacing=0.0, bool force=true);
529 
530  /** Scroll to fit as many locations on-screen as possible, starting with the first. */
531  void scroll_to_tiles(const std::vector<map_location>& locs,
532  SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,
533  bool only_if_possible=false,
534  double add_spacing=0.0, bool force=true);
535 
536  /** Expose the event, so observers can be notified about map scrolling. */
538 
539  /** Check if a tile is fully visible on screen. */
540  bool tile_fully_on_screen(const map_location& loc) const;
541 
542  /** Checks if location @a loc or one of the adjacent tiles is visible on screen. */
543  bool tile_nearly_on_screen(const map_location &loc) const;
544 
545  /** Prevent the game display from drawing.
546  * Used while story screen is showing to prevent flicker. */
547  void set_prevent_draw(bool pd = true);
548  bool get_prevent_draw();
549 
550  /**
551  * @param dest The original destination.
552  * @param submerge How deep underwater it is.
553  * @param size The size of its image.
554  * @param alpha How transparent to make the submerged part.
555  * @param hreverse Whether to flip the image horizontally.
556  * @param vreverse Whether to flip the image vertically.
557  * @return The data necessary for showing the submerged effect for units and map overlays (aka items).
558  */
559  static submerge_data get_submerge_data(const rect& dest, double submerge, const point& size, uint8_t alpha, bool hreverse, bool vreverse);
560 
561 private:
562  bool prevent_draw_ = false;
563 
564 public:
565  /** ToD mask smooth fade */
566  void fade_tod_mask(const std::string& old, const std::string& new_);
567 
568  /** Screen fade */
569  void fade_to(const color_t& color, const std::chrono::milliseconds& duration);
570  void set_fade(const color_t& color);
571 
572 private:
573  color_t fade_color_ = {0,0,0,0};
574 
575 public:
576  /*-------------------------------------------------------*/
577  /* top_level_drawable interface (called by draw_manager) */
578  /*-------------------------------------------------------*/
579 
580  /** Update animations and internal state */
581  virtual void update() override;
582 
583  /** Finalize screen layout. */
584  virtual void layout() override;
585 
586  /** Update offscreen render buffers. */
587  virtual void render() override;
588 
589  /** Paint the indicated region to the screen. */
590  virtual bool expose(const rect& region) override;
591 
592  /** Return the current draw location of the display, on the screen. */
593  virtual rect screen_location() override;
594 
595 private:
596  /** Render textures, for intermediate rendering. */
599 
600  /** Ensure render textures are valid and correct. */
601  void update_render_textures();
602 
603  /** Draw/redraw the off-map background area.
604  * This updates both render textures. */
606 
607  /** Perform rendering of invalidated items. */
608  void draw();
609 
610 public:
611  map_labels& labels();
612  const map_labels& labels() const;
613 
614  /** Holds options for calls to function 'announce' (@ref announce). */
616  {
617  /** Lifetime measured in milliseconds. */
618  std::chrono::milliseconds lifetime;
619 
620  /**
621  * An announcement according these options should replace the
622  * previous announce (typical of fast announcing) or not
623  * (typical of movement feedback).
624  */
626 
628  : lifetime(1600)
629  , discard_previous(false)
630  {
631  }
632  };
633 
634  /** Announce a message prominently. */
635  void announce(const std::string& msg,
636  const color_t& color = font::GOOD_COLOR,
637  const announce_options& options = announce_options());
638 
639  /**
640  * Schedule the minimap for recalculation.
641  * Useful if any terrain in the map has changed.
642  */
643  void recalculate_minimap();
644 
645  /**
646  * Schedule the minimap to be redrawn.
647  * Useful if units have moved about on the map.
648  */
649  void redraw_minimap();
650 
651 private:
652  /** Actually draw the minimap. */
653  void draw_minimap();
654 
655 public:
657 
658  virtual bool has_time_area() const {return false;}
659 
660  void blindfold(bool flag);
661  bool is_blindfolded() const;
662 
663  void write(config& cfg) const;
664 
665 private:
666  void read(const config& cfg);
667 
668 public:
669  /** Init the flag list and the team colors used by ~TC */
670  void init_flags();
671 
672  /** Rebuild the flag list (not team colors) for a single side. */
673  void reinit_flags_for_team(const team&);
674  void reset_reports(reports& reports_object)
675  {
676  reports_object_ = &reports_object;
677  }
678 
679 private:
681 
682 protected:
683  //TODO sort
686  std::weak_ptr<wb::manager> wb_;
687 
688  typedef std::map<map_location, std::string> exclusive_unit_draw_requests_t;
689  /** map of hexes where only one unit should be drawn, the one identified by the associated id string */
691 
693 
694  /**
695  * Get the clipping rectangle for drawing.
696  * Virtual since the editor might use a slightly different approach.
697  */
698  virtual rect get_clip_rect() const;
699 
700  /**
701  * Only called when there's actual redrawing to do. Loops through
702  * invalidated locations and redraws them. Derived classes can override
703  * this, possibly to insert pre- or post-processing around a call to the
704  * base class's function.
705  */
706  virtual void draw_invalidated();
707 
708  /**
709  * Redraws a single gamemap location.
710  */
711  virtual void draw_hex(const map_location& loc);
712 
713  void draw_overlays_at(const map_location& loc);
714 
716 
717  void get_terrain_images(const map_location &loc,
718  const std::string& timeid,
720 
721  std::vector<texture> get_fog_shroud_images(const map_location& loc, image::TYPE image_type);
722 
723  void scroll_to_xy(const point& screen_coordinates, SCROLL_TYPE scroll_type, bool force = true);
724 
725  static void fill_images_list(const std::string& prefix, std::vector<std::string>& images);
726 
727  std::size_t viewing_team_index_;
728  bool dont_show_all_; //const team *viewpoint_;
729  /**
730  * Position of the top-left corner of the viewport, in pixels.
731  *
732  * Dependent on zoom_.. For example, ypos_==72 only means we're one
733  * hex below the top of the map when zoom_ == 72 (the default value).
734  */
738  /**
739  * The current zoom, in pixels (on screen) per 72 pixels (in the
740  * graphic assets), i.e., 72 means 100%.
741  */
742  static unsigned int zoom_;
744  /** The previous value of zoom_. */
745  static unsigned int last_zoom_;
746  const std::unique_ptr<fake_unit_manager> fake_unit_man_;
747  const std::unique_ptr<terrain_builder> builder_;
748  std::function<rect(rect)> minimap_renderer_;
754  const std::unique_ptr<map_labels> map_labels_;
756 
757  /** Event raised when the map is being scrolled */
759 
760  boost::circular_buffer<std::chrono::milliseconds> frametimes_;
762  unsigned int fps_counter_;
763  std::chrono::steady_clock::time_point fps_start_;
764  unsigned int fps_actual_;
765  utils::optional<std::chrono::steady_clock::time_point> last_frame_finished_ = {};
766 
767  // Not set by the initializer:
768  std::map<std::string, rect> reportLocations_;
769  std::map<std::string, texture> reportSurfaces_;
770  std::map<std::string, config> reports_;
771  std::vector<std::shared_ptr<gui::button>> menu_buttons_, action_buttons_;
772  std::set<map_location> invalidated_;
773  // If we're transitioning from one time of day to the next,
774  // then we will use these two masks on top of all hexes when we blit.
777  uint8_t tod_hex_alpha1 = 0;
778  uint8_t tod_hex_alpha2 = 0;
779  std::vector<std::string> fog_images_;
780  std::vector<std::string> shroud_images_;
781 
785 
786  /** Local cache for prefs::get().animate_map, since it is constantly queried. */
788 
789  /** Local version of prefs::get().animate_water, used to detect when it's changed. */
791 
792 private:
793 
795 
796  /** Animated flags for each team */
797  std::vector<animated<image::locator>> flags_;
798 
799  // This vector is a class member to avoid repeated memory allocations in get_terrain_images(),
800  // which turned out to be a significant bottleneck while profiling.
801  std::vector<texture> terrain_image_vector_;
802 
803 public:
804  /**
805  * Draw text on a hex. (0.5, 0.5) is the center.
806  * The font size is adjusted to the zoom factor.
807  */
808  void draw_text_in_hex(const map_location& loc,
809  const drawing_layer layer, const std::string& text, std::size_t font_size,
810  color_t color, double x_in_hex=0.5, double y_in_hex=0.5);
811 
812 protected:
813 
814  //TODO sort
815  std::size_t playing_team_index_;
816 
817  /**
818  * Helper for rendering the map by ordering draw operations.
819  *
820  * In order to render a hex properly, they need to be rendered per row.
821  * In this row several layers need to be drawn at the same time, mainly
822  * the unit and the background terrain. This is needed since both can spill
823  * into the next hex. The foreground terrain needs to be drawn before to
824  * avoid decapitating a unit.
825  *
826  * In other words:
827  * for every layer
828  * for every row (starting from the top)
829  * for every hex in the row
830  * ...
831  *
832  * this is modified to:
833  * for every layer group
834  * for every row (starting from the top)
835  * for every layer in the group
836  * for every hex in the row
837  * ...
838  */
839  struct draw_helper
840  {
841  /** Controls the ordering of draw calls by layer and location. */
842  const uint32_t key;
843 
844  /** Handles the actual drawing at this location. */
845  std::function<void(const rect&)> do_draw;
846 
847  /** The screen coordinates for the specified hex. This is passed to @ref do_draw */
849 
850  bool operator<(const draw_helper& rhs) const
851  {
852  return key < rhs.key;
853  }
854  };
855 
856  std::list<draw_helper> drawing_buffer_;
857 
858 public:
859  /**
860  * Add an item to the drawing buffer.
861  *
862  * @param layer The layer to draw on.
863  * @param loc The hex the image belongs to, needed for the drawing order.
864  * @param draw_func The draw operation to be run.
865  */
866  void drawing_buffer_add(const drawing_layer layer, const map_location& loc, decltype(draw_helper::do_draw) draw_func);
867 
868 protected:
869 
870  /** Draws the drawing_buffer_ and clears it. */
871  void drawing_buffer_commit();
872 
873  /** Redraws all panels intersecting the given region.
874  * Returns true if something was drawn, false otherwise. */
875  bool draw_all_panels(const rect& region);
876 
877 private:
878  void draw_panel(const theme::panel& panel);
879  void draw_label(const theme::label& label);
880 
881 protected:
882  /** Used to indicate to drawing functions that we are doing a map screenshot */
884 
885 public: //operations for the arrow framework
886 
887  void add_arrow(arrow&);
888 
889  void remove_arrow(arrow&);
890 
891  /** Called by arrow objects when they change. You should not need to call this directly. */
892  void update_arrow(arrow & a);
893 
894 protected:
895 
896  // Tiles lit for showing where unit(s) can reach
897  typedef std::map<map_location,unsigned int> reach_map;
902 
903  typedef std::map<map_location, std::vector<overlay>> overlay_map;
904 
905  virtual overlay_map& get_overlays() = 0;
906 
907 private:
908  /** Handle for the label which displays frames per second. */
910  /** Count work done for the debug info displayed under fps */
913 
914  std::vector<std::function<void(display&)>> redraw_observers_;
915 
916 public:
917  enum DEBUG_FLAG {
918  /** Overlays x,y coords on tiles */
920 
921  /** Overlays terrain codes on tiles */
923 
924  /** Overlays number of bitmaps on tiles */
926 
927  /** Separates background and foreground terrain layers. */
929 
930  /** Toggle to continuously redraw the whole map. */
932 
933  /** Dummy entry to size the bitmask. Keep this last! */
935  };
936 
938  {
939  return debug_flags_.test(flag);
940  }
941 
942  void set_debug_flag(DEBUG_FLAG flag, bool value)
943  {
944  debug_flags_.set(flag, value);
945  }
946 
948  {
949  debug_flags_.flip(flag);
950  }
951 
952 private:
953  /** Currently set debug flags. */
954  std::bitset<__NUM_DEBUG_FLAGS> debug_flags_;
955 
956  /** Maps the list of arrows for each location */
957  std::map<map_location, std::list<arrow*>> arrows_map_;
958 
960 
961  std::vector<std::tuple<int, int, int>> fps_history_;
962 
963 protected:
964  static display * singleton_;
965 };
966 
967 struct blindfold
968 {
969  blindfold(display& d, bool lock=true) : display_(d), blind(lock) {
970  if(blind) {
971  display_.blindfold(true);
972  }
973  }
974 
976  unblind();
977  }
978 
979  void unblind() {
980  if(blind) {
981  display_.blindfold(false);
983  blind = false;
984  }
985  }
986 
987 private:
989  bool blind;
990 };
map_location loc
Definition: move.cpp:172
Animate units.
double g
Definition: astarsearch.cpp:63
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:29
Arrows destined to be drawn on the map.
Definition: arrow.hpp:30
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:97
const team & viewing_team() const
Definition: display.cpp:342
void unhide_buttons()
Unhide theme buttons so they draw again.
Definition: display.cpp:942
void set_viewing_team_index(std::size_t team, bool observe=false)
Sets the team controlled by the player using the computer.
Definition: display.cpp:347
void reset_reports(reports &reports_object)
Definition: display.hpp:674
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
Definition: display.hpp:883
void draw_text_in_hex(const map_location &loc, const drawing_layer layer, const std::string &text, std::size_t font_size, color_t color, double x_in_hex=0.5, double y_in_hex=0.5)
Draw text on a hex.
Definition: display.cpp:1453
void layout_buttons()
Definition: display.cpp:790
bool redraw_background_
Definition: display.hpp:750
void update_render_textures()
Ensure render textures are valid and correct.
Definition: display.cpp:2491
void toggle_debug_flag(DEBUG_FLAG flag)
Definition: display.hpp:947
static unsigned int last_zoom_
The previous value of zoom_.
Definition: display.hpp:745
std::size_t viewing_team_index_
Definition: display.hpp:727
void write(config &cfg) const
Definition: display.cpp:3242
static bool zoom_at_min()
Definition: display.cpp:1798
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:903
void get_terrain_images(const map_location &loc, const std::string &timeid, TERRAIN_TYPE terrain_type)
Definition: display.cpp:1039
void remove_overlay(const map_location &loc)
remove_overlay will remove all overlays on a tile.
Definition: display.cpp:134
virtual bool has_time_area() const
Definition: display.hpp:658
map_location selectedHex_
Definition: display.hpp:782
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.cpp:1576
void clear_fps_label()
Definition: display.cpp:1368
bool unit_can_draw_here(const map_location &loc, const unit &unit) const
Returns true if there is no exclusive draw request for loc, or if there is, that it's for unit.
Definition: display.cpp:386
void redraw_minimap()
Schedule the minimap to be redrawn.
Definition: display.cpp:1597
point get_location(const map_location &loc) const
Functions to get the on-screen positions of hexes.
Definition: display.cpp:679
unsigned int fps_counter_
Definition: display.hpp:762
bool invalidate_locations_in_rect(const SDL_Rect &rect)
invalidate all hexes under the rectangle rect (in screen coordinates)
Definition: display.cpp:3140
virtual void render() override
Update offscreen render buffers.
Definition: display.cpp:2414
void remove_single_overlay(const map_location &loc, const std::string &toDelete)
remove_single_overlay will remove a single overlay from a tile
Definition: display.cpp:139
static bool outside_area(const SDL_Rect &area, const int x, const int y)
Check if the bbox of the hex at x,y has pixels outside the area rectangle.
Definition: display.cpp:530
boost::circular_buffer< std::chrono::milliseconds > frametimes_
Definition: display.hpp:760
void fade_tod_mask(const std::string &old, const std::string &new_)
ToD mask smooth fade.
Definition: display.cpp:2200
bool add_exclusive_draw(const map_location &loc, const unit &unit)
Allows a unit to request to be the only one drawn in its hex.
Definition: display.cpp:371
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
Definition: display.cpp:3087
void set_playing_team_index(std::size_t team)
sets the team whose turn it currently is
Definition: display.cpp:364
uint8_t tod_hex_alpha1
Definition: display.hpp:777
const team & playing_team() const
Definition: display.cpp:337
void announce(const std::string &msg, const color_t &color=font::GOOD_COLOR, const announce_options &options=announce_options())
Announce a message prominently.
Definition: display.cpp:1560
bool view_locked_
Definition: display.hpp:736
double turbo_speed() const
Definition: display.cpp:2125
@ ONSCREEN
Definition: display.hpp:509
@ ONSCREEN_WARP
Definition: display.hpp:509
@ SCROLL
Definition: display.hpp:509
int current_frame_sample_
Definition: display.hpp:761
void scroll_to_xy(const point &screen_coordinates, SCROLL_TYPE scroll_type, bool force=true)
Definition: display.cpp:1897
int invalidated_hexes_
Count work done for the debug info displayed under fps.
Definition: display.hpp:911
void adjust_color_overlay(int r, int g, int b)
Add r,g,b to the colors for all images displayed on the map.
Definition: display.cpp:405
void set_fade(const color_t &color)
Definition: display.cpp:2256
void queue_repaint()
Queues repainting to the screen, but doesn't rerender.
Definition: display.cpp:2313
bool reach_map_changed_
Definition: display.hpp:900
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:267
static double get_zoom_factor()
Returns the current zoom factor.
Definition: display.hpp:270
const rect & unit_image_area() const
Definition: display.cpp:473
TERRAIN_TYPE
Definition: display.hpp:715
@ FOREGROUND
Definition: display.hpp:715
@ BACKGROUND
Definition: display.hpp:715
bool propagate_invalidation(const std::set< map_location > &locs)
If this set is partially invalidated, invalidate all its hexes.
Definition: display.cpp:3108
void clear_redraw_observers()
Clear the redraw observers.
Definition: display.cpp:2325
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Definition: display.hpp:316
const theme::action * action_pressed()
Definition: display.cpp:1528
static submerge_data get_submerge_data(const rect &dest, double submerge, const point &size, uint8_t alpha, bool hreverse, bool vreverse)
Definition: display.cpp:2153
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
Definition: display.cpp:770
void set_theme(const std::string &new_theme)
Definition: display.cpp:248
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:433
void change_display_context(const display_context *dc)
Definition: display.cpp:444
void set_prevent_draw(bool pd=true)
Prevent the game display from drawing.
Definition: display.cpp:2139
void clear_exclusive_draws()
Cancels all the exclusive draw requests.
Definition: display.hpp:150
unsigned int fps_actual_
Definition: display.hpp:764
virtual overlay_map & get_overlays()=0
theme theme_
Definition: display.hpp:737
tod_color color_adjust_
Definition: display.hpp:959
bool get_prevent_draw()
Definition: display.cpp:2148
virtual void layout() override
Finalize screen layout.
Definition: display.cpp:2383
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1484
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
Definition: display.cpp:392
void add_redraw_observer(const std::function< void(display &)> &f)
Adds a redraw observer, a function object to be called when a full rerender is queued.
Definition: display.cpp:2320
static bool zoom_at_max()
Definition: display.cpp:1793
static display * singleton_
Definition: display.hpp:964
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
Definition: display.cpp:780
void render_map_outside_area()
Draw/redraw the off-map background area.
Definition: display.cpp:2536
map_labels & labels()
Definition: display.cpp:2552
std::size_t playing_team_index() const
The playing team is the team whose turn it is.
Definition: display.hpp:116
void remove_arrow(arrow &)
Definition: display.cpp:3218
@ DEBUG_COORDINATES
Overlays x,y coords on tiles.
Definition: display.hpp:919
@ DEBUG_BENCHMARK
Toggle to continuously redraw the whole map.
Definition: display.hpp:931
@ __NUM_DEBUG_FLAGS
Dummy entry to size the bitmask.
Definition: display.hpp:934
@ DEBUG_NUM_BITMAPS
Overlays number of bitmaps on tiles.
Definition: display.hpp:925
@ DEBUG_FOREGROUND
Separates background and foreground terrain layers.
Definition: display.hpp:928
@ DEBUG_TERRAIN_CODES
Overlays terrain codes on tiles.
Definition: display.hpp:922
void process_reachmap_changes()
Definition: display.cpp:3259
void draw_minimap_units()
Definition: display.cpp:1653
void scroll_to_tile(const map_location &loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool force=true)
Scroll such that location loc is on-screen.
Definition: display.cpp:1975
map_location pixel_position_to_hex(int x, int y) const
given x,y co-ordinates of a pixel on the map, will return the location of the hex that this pixel cor...
Definition: display.cpp:552
void invalidate_animations_location(const map_location &loc)
Per-location invalidation called by invalidate_animations() Extra game per-location invalidation (vil...
Definition: display.cpp:3155
map_location mouseoverHex_
Definition: display.hpp:783
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
Definition: display.cpp:674
bool view_locked() const
Definition: display.hpp:504
bool set_zoom(bool increase)
Zooms the display in (true) or out (false).
Definition: display.cpp:1803
std::map< std::string, rect > reportLocations_
Definition: display.hpp:768
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
Definition: display.hpp:365
bool invalidateAll_
Definition: display.hpp:751
int drawn_hexes_
Definition: display.hpp:912
void draw_overlays_at(const map_location &loc)
Definition: display.cpp:2763
std::chrono::steady_clock::time_point fps_start_
Definition: display.hpp:763
texture get_flag(const map_location &loc)
Definition: display.cpp:319
tod_color get_color_overlay() const
Definition: display.hpp:216
void invalidate_all()
Function to invalidate all tiles.
Definition: display.cpp:3080
std::map< std::string, config > reports_
Definition: display.hpp:770
std::bitset< __NUM_DEBUG_FLAGS > debug_flags_
Currently set debug flags.
Definition: display.hpp:954
SDL_Rect minimap_location_
Definition: display.hpp:749
point viewport_origin_
Position of the top-left corner of the viewport, in pixels.
Definition: display.hpp:735
map_location get_middle_location() const
Definition: display.cpp:3236
void bounds_check_position()
Definition: display.cpp:2107
std::function< rect(rect)> minimap_renderer_
Definition: display.hpp:748
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
Definition: display.cpp:725
void init_flags()
Init the flag list and the team colors used by ~TC.
Definition: display.cpp:259
std::vector< std::shared_ptr< gui::button > > action_buttons_
Definition: display.hpp:771
void drawing_buffer_add(const drawing_layer layer, const map_location &loc, decltype(draw_helper::do_draw) draw_func)
Add an item to the drawing buffer.
Definition: display.cpp:1258
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.cpp:521
bool prevent_draw_
Definition: display.hpp:562
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:690
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
Definition: display.cpp:1888
void reload_map()
Updates internals that cache map size.
Definition: display.cpp:438
rect max_map_area() const
Returns the maximum area used for the map regardless to resolution and view size.
Definition: display.cpp:478
void update_fps_count()
Definition: display.cpp:1512
halo::manager & get_halo_manager()
Definition: display.hpp:198
bool tile_fully_on_screen(const map_location &loc) const
Check if a tile is fully visible on screen.
Definition: display.cpp:1883
void update_fps_label()
Definition: display.cpp:1297
map_location minimap_location_on(int x, int y)
given x,y co-ordinates of the mouse, will return the location of the hex in the minimap that the mous...
Definition: display.cpp:693
void scroll_to_tiles(map_location loc1, map_location loc2, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, double add_spacing=0.0, bool force=true)
Scroll such that location loc1 is on-screen.
Definition: display.cpp:1985
bool is_blindfolded() const
Definition: display.cpp:458
std::vector< texture > terrain_image_vector_
Definition: display.hpp:801
std::vector< std::string > fog_images_
Definition: display.hpp:779
void fade_to(const color_t &color, const std::chrono::milliseconds &duration)
Screen fade.
Definition: display.cpp:2223
virtual bool in_editor() const
Definition: display.hpp:219
int fps_handle_
Handle for the label which displays frames per second.
Definition: display.hpp:909
texture tod_hex_mask2
Definition: display.hpp:776
theme & get_theme()
Definition: display.hpp:390
const display_context & context() const
Definition: display.hpp:193
bool invalidate_visible_locations_in_rect(const SDL_Rect &rect)
Definition: display.cpp:3135
std::map< map_location, std::list< arrow * > > arrows_map_
Maps the list of arrows for each location.
Definition: display.hpp:957
std::map< map_location, std::string > exclusive_unit_draw_requests_t
Definition: display.hpp:688
void add_overlay(const map_location &loc, overlay &&ov)
Functions to add and remove overlays from locations.
Definition: display.cpp:121
std::vector< std::function< void(display &)> > redraw_observers_
Definition: display.hpp:914
void read(const config &cfg)
Definition: display.cpp:3251
const theme::menu * menu_pressed()
Definition: display.cpp:1544
const rect_of_hexes hexes_under_rect(const rect &r) const
Return the rectangular area of hexes overlapped by r (r is in screen coordinates)
Definition: display.cpp:626
const std::unique_ptr< terrain_builder > builder_
Definition: display.hpp:747
virtual const map_location & displayed_unit_hex() const
Virtual functions shadowed in game_display.
Definition: display.hpp:222
std::vector< animated< image::locator > > flags_
Animated flags for each team.
Definition: display.hpp:797
const map_location & selected_hex() const
Definition: display.hpp:309
rect get_location_rect(const map_location &loc) const
Returns the on-screen rect corresponding to a loc.
Definition: display.cpp:687
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
Definition: display.hpp:537
static void fill_images_list(const std::string &prefix, std::vector< std::string > &images)
Definition: display.cpp:411
void draw_report(const std::string &report_name, bool test_run=false)
Draw the specified report.
Definition: display.cpp:2906
std::set< map_location > invalidated_
Definition: display.hpp:772
color_t fade_color_
Definition: display.hpp:573
virtual const time_of_day & get_time_of_day(const map_location &loc=map_location::null_location()) const =0
std::vector< texture > get_fog_shroud_images(const map_location &loc, image::TYPE image_type)
Definition: display.cpp:952
void queue_rerender()
Marks everything for rendering including all tiles and sidebar.
Definition: display.cpp:2261
void create_buttons()
Definition: display.cpp:845
int blindfold_ctr_
Definition: display.hpp:680
std::string remove_exclusive_draw(const map_location &loc)
Cancels an exclusive draw request.
Definition: display.cpp:378
bool invalidateGameStatus_
Definition: display.hpp:753
reach_map reach_map_old_
Definition: display.hpp:899
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
Definition: display.cpp:2567
void drawing_buffer_commit()
Draws the drawing_buffer_ and clears it.
Definition: display.cpp:1263
rect map_area() const
Returns the area used for the map.
Definition: display.cpp:495
int zoom_index_
Definition: display.hpp:743
void draw_panel(const theme::panel &panel)
Definition: display.cpp:1379
void draw_buttons()
Definition: display.cpp:910
static int hex_width()
Function which returns the width of a hex in pixels, up to where the next hex starts.
Definition: display.hpp:261
void set_debug_flag(DEBUG_FLAG flag, bool value)
Definition: display.hpp:942
void reset_standing_animations()
Definition: display.cpp:3204
utils::optional< std::chrono::steady_clock::time_point > last_frame_finished_
Definition: display.hpp:765
bool animate_water_
Local version of prefs::get().animate_water, used to detect when it's changed.
Definition: display.hpp:790
bool debug_flag_set(DEBUG_FLAG flag) const
Definition: display.hpp:937
void toggle_default_zoom()
Sets the zoom amount to the default.
Definition: display.cpp:1871
virtual rect get_clip_rect() const
Get the clipping rectangle for drawing.
Definition: display.cpp:2562
CKey keys_
Definition: display.hpp:784
reports * reports_object_
Definition: display.hpp:755
bool draw_reports(const rect &region)
Draw all reports in the given region.
Definition: display.cpp:3066
void invalidate_animations()
Function to invalidate animated terrains and units which may have changed.
Definition: display.cpp:3166
virtual rect screen_location() override
Return the current draw location of the display, on the screen.
Definition: display.cpp:2483
void hide_buttons()
Hide theme buttons so they don't draw.
Definition: display.cpp:932
virtual bool expose(const rect &region) override
Paint the indicated region to the screen.
Definition: display.cpp:2438
std::list< draw_helper > drawing_buffer_
Definition: display.hpp:856
uint8_t tod_hex_alpha2
Definition: display.hpp:778
std::vector< std::shared_ptr< gui::button > > menu_buttons_
Definition: display.hpp:771
virtual void update() override
Update animations and internal state.
Definition: display.cpp:2366
void draw()
Perform rendering of invalidated items.
Definition: display.cpp:2330
const rect & minimap_area() const
mapx is the width of the portion of the display which shows the game area.
Definition: display.cpp:463
texture back_
Definition: display.hpp:598
events::generic_event scroll_event_
Event raised when the map is being scrolled.
Definition: display.hpp:758
bool show_everything() const
Definition: display.hpp:113
terrain_builder & get_builder()
Definition: display.hpp:466
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
Definition: display.cpp:2603
texture tod_hex_mask1
Definition: display.hpp:775
virtual bool in_game() const
Definition: display.hpp:218
virtual ~display()
Definition: display.cpp:238
const rect & palette_area() const
Definition: display.cpp:468
std::map< map_location, unsigned int > reach_map
Definition: display.hpp:897
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:111
std::size_t playing_team_index_
Definition: display.hpp:815
std::vector< std::tuple< int, int, int > > fps_history_
Definition: display.hpp:961
halo::manager halo_man_
Definition: display.hpp:685
void reinit_flags_for_team(const team &)
Rebuild the flag list (not team colors) for a single side.
Definition: display.cpp:270
void draw_minimap()
Actually draw the minimap.
Definition: display.cpp:1602
texture front_
Render textures, for intermediate rendering.
Definition: display.hpp:597
bool viewing_team_is_playing() const
Definition: display.hpp:131
std::size_t viewing_team_index() const
The viewing team is the team currently viewing the game.
Definition: display.hpp:126
const map_location & mouseover_hex() const
Definition: display.hpp:310
map_location hex_clicked_on(int x, int y) const
given x,y co-ordinates of an onscreen pixel, will return the location of the hex that this pixel corr...
Definition: display.cpp:538
void update_arrow(arrow &a)
Called by arrow objects when they change.
Definition: display.cpp:3225
void draw_label(const theme::label &label)
Definition: display.cpp:1404
const std::unique_ptr< fake_unit_manager > fake_unit_man_
Definition: display.hpp:746
const display_context * dc_
Definition: display.hpp:684
bool animate_map_
Local cache for prefs::get().animate_map, since it is constantly queried.
Definition: display.hpp:787
static point scaled_to_zoom(const point &p)
Definition: display.hpp:282
std::vector< std::string > shroud_images_
Definition: display.hpp:780
void set_view_locked(bool value)
Sets whether the map view is locked (e.g.
Definition: display.hpp:507
static rect scaled_to_zoom(const SDL_Rect &r)
Scale the width and height of a rect by the current zoom factor.
Definition: display.hpp:276
bool scroll(const point &amount, bool force=false)
Scrolls the display by amount pixels.
Definition: display.cpp:1700
virtual const std::set< std::string > & observers() const
Definition: display.hpp:223
static unsigned int zoom_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e....
Definition: display.hpp:742
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
Definition: display.cpp:669
bool dont_show_all_
Definition: display.hpp:728
void blindfold(bool flag)
Definition: display.cpp:450
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Update the given report.
Definition: display.cpp:2836
std::weak_ptr< wb::manager > wb_
Definition: display.hpp:686
void add_arrow(arrow &)
Definition: display.cpp:3211
const std::unique_ptr< map_labels > map_labels_
Definition: display.hpp:754
void set_diagnostic(const std::string &msg)
Definition: display.cpp:1494
virtual void select_hex(map_location hex)
Definition: display.cpp:1476
int diagnostic_label_
Definition: display.hpp:752
std::map< std::string, texture > reportSurfaces_
Definition: display.hpp:769
bool draw_all_panels(const rect &region)
Redraws all panels intersecting the given region.
Definition: display.cpp:1431
reach_map reach_map_
Definition: display.hpp:898
display(const display_context *dc, std::weak_ptr< wb::manager > wb, reports &reports_object, const std::string &theme_id, const config &level)
Definition: display.cpp:145
Manages a list of fake units for the display object.
Encapsulates the map of the game.
Definition: map.hpp:172
A top-level drawable item (TLD), such as a window.
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:75
The class terrain_builder is constructed from a config object, and a gamemap object.
Definition: builder.hpp:48
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:33
Definition: theme.hpp:44
This class represents a single unit of a specific type.
Definition: unit.hpp:133
This class is the frontend of the whiteboard framework for the rest of the Wesnoth code.
Definition: manager.hpp:44
drawing_layer
std::string label
What to show in the filter's drop-down list.
Definition: manager.cpp:200
const std::string & get_direction(std::size_t n)
Definition: display.cpp:837
void rect(const SDL_Rect &rect)
Draw a rectangle.
Definition: draw.cpp:150
const color_t GOOD_COLOR
unsigned int tile_size
Definition: game_config.cpp:55
TYPE
Used to specify the rendering format of images.
Definition: picture.hpp:162
Unit and team statistics.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:85
Definition: display.hpp:45
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
Contains the SDL_Rect helper code.
This file contains object "key", which is used to store information about keys while annotation parsi...
bool blind
Definition: display.hpp:989
blindfold(display &d, bool lock=true)
Definition: display.hpp:969
~blindfold()
Definition: display.hpp:975
void unblind()
Definition: display.hpp:979
display & display_
Definition: display.hpp:988
The basic class for representing 8-bit RGB or RGBA colour values.
Definition: color.hpp:59
Holds options for calls to function 'announce' (announce).
Definition: display.hpp:616
bool discard_previous
An announcement according these options should replace the previous announce (typical of fast announc...
Definition: display.hpp:625
std::chrono::milliseconds lifetime
Lifetime measured in milliseconds.
Definition: display.hpp:618
Helper for rendering the map by ordering draw operations.
Definition: display.hpp:840
std::function< void(const rect &)> do_draw
Handles the actual drawing at this location.
Definition: display.hpp:845
const uint32_t key
Controls the ordering of draw calls by layer and location.
Definition: display.hpp:842
rect dest
The screen coordinates for the specified hex.
Definition: display.hpp:848
bool operator<(const draw_helper &rhs) const
Definition: display.hpp:850
very simple iterator to walk into the rect_of_hexes
Definition: display.hpp:335
const map_location & operator*() const
Definition: display.hpp:343
std::forward_iterator_tag iterator_category
Definition: display.hpp:345
iterator & operator++()
increment y first, then when reaching bottom, increment x
Definition: display.cpp:604
const rect_of_hexes & rect_
Definition: display.hpp:353
bool operator==(const iterator &that) const
Definition: display.hpp:341
const map_location * pointer
Definition: display.hpp:348
bool operator!=(const iterator &that) const
Definition: display.hpp:342
iterator(const map_location &loc, const rect_of_hexes &rect)
Definition: display.hpp:336
const map_location & reference
Definition: display.hpp:349
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
Definition: display.hpp:328
iterator end() const
Definition: display.cpp:621
iterator begin() const
Definition: display.cpp:617
Encapsulates the map of the game.
Definition: location.hpp:45
static const map_location & null_location()
Definition: location.hpp:102
Holds a 2D point.
Definition: point.hpp:25
An abstract description of a rectangle with integer coordinates.
Definition: rect.hpp:47
std::array< SDL_Vertex, 4 > alpha_verts
Definition: display.hpp:88
rect unsub_dest
Definition: display.hpp:87
rect unsub_src
Definition: display.hpp:86
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:57
Small struct to store and manipulate ToD color adjusts.
Definition: time_of_day.hpp:27
mock_party p
static map_location::direction n
Definitions related to theme-support.
#define d
#define f
#define b