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