The Battle for Wesnoth  1.19.20+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_single_overlay will remove a single overlay from a tile */
174  void remove_single_overlay(const map_location& loc, const std::string& toDelete);
175 
176  /**
177  * Updates internals that cache map size. This should be called when the map
178  * size has changed.
179  */
180  void reload_map();
181 
182  void change_display_context(const display_context* dc);
183 
184  const display_context& context() const
185  {
186  return *dc_;
187  }
188 
190 
191  /**
192  * Applies r,g,b coloring to the map.
193  *
194  * The color is usually taken from @ref get_time_of_day unless @a tod_override is given, in which
195  * case that color is used.
196  *
197  * @param tod_override The ToD to apply to the map instead of that of the current ToD's.
198  */
199  void update_tod(const time_of_day* tod_override = nullptr);
200 
201  /**
202  * Add r,g,b to the colors for all images displayed on the map.
203  *
204  * Used for special effects like flashes.
205  */
206  void adjust_color_overlay(int r, int g, int b);
208 
209  virtual bool in_game() const { return false; }
210  virtual bool in_editor() const { return false; }
211 
212  /** Virtual functions shadowed in game_display. These are needed to generate reports easily, without dynamic casting. Hope to factor out eventually. */
213  virtual const map_location & displayed_unit_hex() const { return map_location::null_location(); }
214  virtual const std::set<std::string>& observers() const { static const std::set<std::string> fake_obs = std::set<std::string> (); return fake_obs; }
215 
216  /**
217  * mapx is the width of the portion of the display which shows the game area.
218  * Between mapx and x is the sidebar region.
219  */
220 
221  const rect& minimap_area() const;
222  const rect& palette_area() const;
223  const rect& unit_image_area() const;
224 
225  /**
226  * Returns the maximum area used for the map
227  * regardless to resolution and view size
228  */
229  rect max_map_area() const;
230 
231  /**
232  * Returns the area used for the map
233  */
234  rect map_area() const;
235 
236  /**
237  * Returns the available area for a map, this may differ
238  * from the above. This area will get the background area
239  * applied to it.
240  */
241  rect map_outside_area() const;
242 
243  /** Check if the bbox of the hex at x,y has pixels outside the area rectangle. */
244  static bool outside_area(const rect& area, const int x,const int y);
245 
246  /**
247  * Function which returns the "average" width of a hex in pixels,
248  * up to where the next hex starts (half a hex up/down on the y axis).
249  */
250  static int hex_width() { return (zoom_*3)/4; }
251 
252  /**
253  * Function which returns the size of a hex in pixels
254  * (from left tip to right tip or top edge to bottom edge).
255  */
256  static int hex_size(){ return zoom_; }
257 
258  /** Returns the current zoom factor. */
259  static double get_zoom_factor()
260  {
261  return static_cast<double>(zoom_) / static_cast<double>(game_config::tile_size);
262  }
263 
264  /** Scale the width and height of a rect by the current zoom factor */
265  static rect scaled_to_zoom(const rect& r)
266  {
267  const double zf = get_zoom_factor();
268  return {r.x, r.y, int(r.w * zf), int(r.h * zf)};
269  }
270 
271  static point scaled_to_zoom(const point& p)
272  {
273  const double zf = get_zoom_factor();
274  return {int(p.x * zf), int(p.y * zf)};
275  }
276 
277  /**
278  * given x,y co-ordinates of an onscreen pixel, will return the
279  * location of the hex that this pixel corresponds to.
280  * Returns an invalid location if the mouse isn't over any valid location.
281  */
282  map_location hex_clicked_on(int x, int y) const;
283 
284  /**
285  * given x,y co-ordinates of a pixel on the map, will return the
286  * location of the hex that this pixel corresponds to.
287  * Returns an invalid location if the mouse isn't over any valid location.
288  */
289  map_location pixel_position_to_hex(int x, int y) const;
290 
291  /**
292  * given x,y co-ordinates of the mouse, will return the location of the
293  * hex in the minimap that the mouse is currently over, or an invalid
294  * location if the mouse isn't over the minimap.
295  */
296  map_location minimap_location_on(int x, int y);
297 
298  const map_location& selected_hex() const { return selectedHex_; }
299  const map_location& mouseover_hex() const { return mouseoverHex_; }
300 
301  virtual void select_hex(map_location hex);
302  virtual void highlight_hex(map_location hex);
303 
304  /** Function to invalidate the game status displayed on the sidebar. */
306 
307  /** Functions to get the on-screen positions of hexes. */
308  point get_location(const map_location& loc) const;
309 
310  /** Returns the on-screen rect corresponding to a @a loc */
311  rect get_location_rect(const map_location& loc) const;
312 
313  /**
314  * Rectangular area of hexes, allowing to decide how the top and bottom
315  * edges handles the vertical shift for each parity of the x coordinate
316  */
318  int left;
319  int right;
320  int top[2]; // for even and odd values of x, respectively
321  int bottom[2];
322 
323  /** very simple iterator to walk into the rect_of_hexes */
324  struct iterator {
326  : loc_(loc), rect_(rect){}
327 
328  /** increment y first, then when reaching bottom, increment x */
329  iterator& operator++();
330  bool operator==(const iterator &that) const { return that.loc_ == loc_; }
331  bool operator!=(const iterator &that) const { return that.loc_ != loc_; }
332  const map_location& operator*() const {return loc_;}
333 
334  typedef std::forward_iterator_tag iterator_category;
336  typedef int difference_type;
337  typedef const map_location *pointer;
338  typedef const map_location &reference;
339 
340  private:
343  };
345 
346  iterator begin() const;
347  iterator end() const;
348  };
349 
350  /** Return the rectangular area of hexes overlapped by r (r is in screen coordinates) */
351  const rect_of_hexes hexes_under_rect(const rect& r) const;
352 
353  /** Returns the rectangular area of visible hexes */
355 
356  /** Returns true if location (x,y) is covered in shroud. */
357  bool shrouded(const map_location& loc) const;
358 
359  /** Returns true if location (x,y) is covered in fog. */
360  bool fogged(const map_location& loc) const;
361 
362  /** Capture a (map-)screenshot into a surface. */
363  surface screenshot(bool map_screenshot = false);
364 
365  /** Marks everything for rendering including all tiles and sidebar.
366  * Also calls redraw observers. */
367  void queue_rerender();
368 
369  /** Queues repainting to the screen, but doesn't rerender. */
370  void queue_repaint();
371 
372  /** Adds a redraw observer, a function object to be called when a
373  * full rerender is queued. */
374  void add_redraw_observer(const std::function<void(display&)>& f);
375 
376  /** Clear the redraw observers */
377  void clear_redraw_observers();
378 
379  theme& get_theme() { return theme_; }
380  void set_theme(const std::string& new_theme);
381 
382  /**
383  * Retrieves a pointer to a theme UI button.
384  *
385  * @note The returned pointer may either be nullptr, meaning the button
386  * isn't defined by the current theme, or point to a valid
387  * gui::button object. However, the objects retrieved will be
388  * destroyed and recreated by draw() method calls. Do *NOT* store
389  * these pointers for longer than strictly necessary to
390  * accomplish a specific task before the next screen refresh.
391  */
392  std::shared_ptr<gui::button> find_action_button(const std::string& id);
393  std::shared_ptr<gui::button> find_menu_button(const std::string& id);
394 
395  void create_buttons();
396 
397  void layout_buttons();
398 
399  void draw_buttons();
400 
401  /** Hide theme buttons so they don't draw. */
402  void hide_buttons();
403  /** Unhide theme buttons so they draw again. */
404  void unhide_buttons();
405 
406  /** Update the given report. Actual drawing is done in draw_report(). */
407  void refresh_report(const std::string& report_name, const config * new_cfg=nullptr);
408 
409  /**
410  * Draw the specified report.
411  *
412  * If test_run is true, it will simulate the draw without actually
413  * drawing anything. This will add any overflowing information to the
414  * report tooltip, and also registers the tooltip.
415  */
416  void draw_report(const std::string& report_name, bool test_run = false);
417 
418  /** Draw all reports in the given region.
419  * Returns true if something was drawn, false otherwise. */
420  bool draw_reports(const rect& region);
421 
422  void draw_minimap_units();
423 
424  /** Function to invalidate all tiles. */
425  void invalidate_all();
426 
427  /** Function to invalidate a specific tile for redrawing. */
428  bool invalidate(const map_location& loc);
429 
430  bool invalidate(const std::set<map_location>& locs);
431 
432  /**
433  * If this set is partially invalidated, invalidate all its hexes.
434  * Returns if any new invalidation was needed
435  */
436  bool propagate_invalidation(const std::set<map_location>& locs);
437 
438  /** invalidate all hexes under the rectangle rect (in screen coordinates) */
441 
442  /**
443  * Function to invalidate animated terrains and units which may have changed.
444  */
445  void invalidate_animations();
446 
447  /**
448  * Per-location invalidation called by invalidate_animations()
449  * Extra game per-location invalidation (village ownership)
450  */
452 
454 
456 
457  /** Rebuild all dynamic terrain. */
458  void rebuild_all();
459 
460  const theme::action* action_pressed();
461  const theme::menu* menu_pressed();
462 
463  void set_diagnostic(const std::string& msg);
464 
465  double turbo_speed() const;
466 
467  void bounds_check_position();
468  void bounds_check_position(int& xpos, int& ypos) const;
469 
470  /**
471  * Scrolls the display by @a amount pixels.
472  * Invalidation and redrawing will be scheduled.
473  * @return true if the map actually moved.
474  */
475  bool scroll(const point& amount, bool force = false);
476 
477  /** Zooms the display in (true) or out (false). */
478  bool set_zoom(bool increase);
479 
480  /** Sets the display zoom to the specified amount. */
481  bool set_zoom(unsigned int amount, const bool validate_value_and_set_index = true);
482 
483  static bool zoom_at_max();
484  static bool zoom_at_min();
485 
486  /** Sets the zoom amount to the default. */
487  void toggle_default_zoom();
488 
489  bool view_locked() const { return view_locked_; }
490 
491  /** Sets whether the map view is locked (e.g. so the user can't scroll away) */
492  void set_view_locked(bool value) { view_locked_ = value; }
493 
495 
496  /**
497  * Scroll such that location loc is on-screen.
498  * WARP jumps to loc; SCROLL uses scroll speed;
499  * ONSCREEN only scrolls if x,y is offscreen
500  * force : scroll even if preferences tell us not to,
501  * or the view is locked.
502  */
503  void scroll_to_tile(const map_location& loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,bool force = true);
504 
505  /**
506  * Scroll such that location loc1 is on-screen.
507  * It will also try to make it such that loc2 is on-screen,
508  * but this is not guaranteed. For ONSCREEN scrolls add_spacing
509  * sets the desired minimum distance from the border in hexes.
510  */
511  void scroll_to_tiles(map_location loc1, map_location loc2,
512  SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,
513  double add_spacing=0.0, bool force=true);
514 
515  /** Scroll to fit as many locations on-screen as possible, starting with the first. */
516  void scroll_to_tiles(const std::vector<map_location>& locs,
517  SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true,
518  bool only_if_possible=false,
519  double add_spacing=0.0, bool force=true);
520 
521  /** Expose the event, so observers can be notified about map scrolling. */
523 
524  /** Check if a tile is fully visible on screen. */
525  bool tile_fully_on_screen(const map_location& loc) const;
526 
527  /** Checks if location @a loc or one of the adjacent tiles is visible on screen. */
528  bool tile_nearly_on_screen(const map_location &loc) const;
529 
530  /** Prevent the game display from drawing.
531  * Used while story screen is showing to prevent flicker. */
532  void set_prevent_draw(bool pd = true);
533  bool get_prevent_draw();
534 
535  /**
536  * @param dest The original destination.
537  * @param submerge How deep underwater it is.
538  * @param size The size of its image.
539  * @param alpha How transparent to make the submerged part.
540  * @param hreverse Whether to flip the image horizontally.
541  * @param vreverse Whether to flip the image vertically.
542  * @return The data necessary for showing the submerged effect for units and map overlays (aka items).
543  */
544  static submerge_data get_submerge_data(const rect& dest, double submerge, const point& size, uint8_t alpha, bool hreverse, bool vreverse);
545 
546 private:
547  bool prevent_draw_ = false;
548 
549 public:
550  /** ToD mask smooth fade */
551  void fade_tod_mask(const std::string& old, const std::string& new_);
552 
553  /** Screen fade */
554  void fade_to(const color_t& color, const std::chrono::milliseconds& duration);
555  void set_fade(const color_t& color);
556 
557 private:
558  color_t fade_color_ = {0,0,0,0};
559 
560 public:
561  /*-------------------------------------------------------*/
562  /* top_level_drawable interface (called by draw_manager) */
563  /*-------------------------------------------------------*/
564 
565  /** Update animations and internal state */
566  virtual void update() override;
567 
568  /** Finalize screen layout. */
569  virtual void layout() override;
570 
571  /** Update offscreen render buffers. */
572  virtual void render() override;
573 
574  /** Paint the indicated region to the screen. */
575  virtual bool expose(const rect& region) override;
576 
577  /** Return the current draw location of the display, on the screen. */
578  virtual rect screen_location() override;
579 
580 private:
581  /** Render textures, for intermediate rendering. */
584 
585  /** Ensure render textures are valid and correct. */
586  void update_render_textures();
587 
588  /** Draw/redraw the off-map background area.
589  * This updates both render textures. */
591 
592  /** Perform rendering of invalidated items. */
593  void draw();
594 
595 public:
596  map_labels& labels();
597  const map_labels& labels() const;
598 
599  /** Holds options for calls to function 'announce' (@ref announce). */
601  {
602  /** Lifetime measured in milliseconds. */
603  std::chrono::milliseconds lifetime;
604 
605  /**
606  * An announcement according these options should replace the
607  * previous announce (typical of fast announcing) or not
608  * (typical of movement feedback).
609  */
611 
613  : lifetime(1600)
614  , discard_previous(false)
615  {
616  }
617  };
618 
619  /** Announce a message prominently. */
620  void announce(const std::string& msg,
621  const color_t& color = font::GOOD_COLOR,
622  const announce_options& options = announce_options());
623 
624  /**
625  * Schedule the minimap for recalculation.
626  * Useful if any terrain in the map has changed.
627  */
628  void recalculate_minimap();
629 
630  /**
631  * Schedule the minimap to be redrawn.
632  * Useful if units have moved about on the map.
633  */
634  void redraw_minimap();
635 
636 private:
637  /** Actually draw the minimap. */
638  void draw_minimap();
639 
640 public:
642 
643  virtual bool has_time_area() const {return false;}
644 
645  void blindfold(bool flag);
646  bool is_blindfolded() const;
647 
648  void write(config& cfg) const;
649 
650 private:
651  void read(const config& cfg);
652 
653 public:
654  /** Init the flag list and the team colors used by ~TC */
655  void init_flags();
656 
657  /** Rebuild the flag list (not team colors) for a single side. */
658  void reinit_flags_for_team(const team&);
659  void reset_reports(reports& reports_object)
660  {
661  reports_object_ = &reports_object;
662  }
663 
664 private:
666 
667 protected:
668  //TODO sort
671  std::weak_ptr<wb::manager> wb_;
672 
673  typedef std::map<map_location, std::string> exclusive_unit_draw_requests_t;
674  /** map of hexes where only one unit should be drawn, the one identified by the associated id string */
676 
678 
679  /**
680  * Get the clipping rectangle for drawing.
681  * Virtual since the editor might use a slightly different approach.
682  */
683  virtual rect get_clip_rect() const;
684 
685  /**
686  * Only called when there's actual redrawing to do. Loops through
687  * invalidated locations and redraws them. Derived classes can override
688  * this, possibly to insert pre- or post-processing around a call to the
689  * base class's function.
690  */
691  virtual void draw_invalidated();
692 
693  /**
694  * Redraws a single gamemap location.
695  */
696  virtual void draw_hex(const map_location& loc);
697 
698  void draw_overlays_at(const map_location& loc);
699 
701 
702  void get_terrain_images(const map_location &loc,
703  const std::string& timeid,
705 
706  std::vector<texture> get_fog_shroud_images(const map_location& loc, image::TYPE image_type);
707 
708  void scroll_to_xy(const point& screen_coordinates, SCROLL_TYPE scroll_type, bool force = true);
709 
710  static void fill_images_list(const std::string& prefix, std::vector<std::string>& images);
711 
712  std::size_t viewing_team_index_;
713  bool dont_show_all_; //const team *viewpoint_;
714  /**
715  * Position of the top-left corner of the viewport, in pixels.
716  *
717  * Dependent on zoom_.. For example, ypos_==72 only means we're one
718  * hex below the top of the map when zoom_ == 72 (the default value).
719  */
723  /**
724  * The current zoom, in pixels (on screen) per 72 pixels (in the
725  * graphic assets), i.e., 72 means 100%.
726  */
727  static unsigned int zoom_;
729  /** The previous value of zoom_. */
730  static unsigned int last_zoom_;
731  const std::unique_ptr<fake_unit_manager> fake_unit_man_;
732  const std::unique_ptr<terrain_builder> builder_;
733  std::function<rect(rect)> minimap_renderer_;
739  const std::unique_ptr<map_labels> map_labels_;
741 
742  /** Event raised when the map is being scrolled */
744 
745  // Not set by the initializer:
746  std::map<std::string, rect> reportLocations_;
747  std::map<std::string, texture> reportSurfaces_;
748  std::map<std::string, config> reports_;
749  std::vector<std::shared_ptr<gui::button>> menu_buttons_, action_buttons_;
750  std::set<map_location> invalidated_;
751  // If we're transitioning from one time of day to the next,
752  // then we will use these two masks on top of all hexes when we blit.
755  uint8_t tod_hex_alpha1 = 0;
756  uint8_t tod_hex_alpha2 = 0;
757  std::vector<std::string> fog_images_;
758  std::vector<std::string> shroud_images_;
759 
763 
764  /** Local cache for prefs::get().animate_map, since it is constantly queried. */
766 
767  /** Local version of prefs::get().animate_water, used to detect when it's changed. */
769 
770 private:
771 
773 
774  /** Animated flags for each team */
775  std::vector<animated<image::locator>> flags_;
776 
777  // This vector is a class member to avoid repeated memory allocations in get_terrain_images(),
778  // which turned out to be a significant bottleneck while profiling.
779  std::vector<texture> terrain_image_vector_;
780 
781 public:
782  /**
783  * Draw text on a hex. (0.5, 0.5) is the center.
784  * The font size is adjusted to the zoom factor.
785  */
786  void draw_text_in_hex(const map_location& loc,
787  const drawing_layer layer, const std::string& text, std::size_t font_size,
788  color_t color, double x_in_hex=0.5, double y_in_hex=0.5);
789 
790 protected:
791 
792  //TODO sort
793  std::size_t playing_team_index_;
794 
795  /**
796  * Helper for rendering the map by ordering draw operations.
797  *
798  * In order to render a hex properly, they need to be rendered per row.
799  * In this row several layers need to be drawn at the same time, mainly
800  * the unit and the background terrain. This is needed since both can spill
801  * into the next hex. The foreground terrain needs to be drawn before to
802  * avoid decapitating a unit.
803  *
804  * In other words:
805  * for every layer
806  * for every row (starting from the top)
807  * for every hex in the row
808  * ...
809  *
810  * this is modified to:
811  * for every layer group
812  * for every row (starting from the top)
813  * for every layer in the group
814  * for every hex in the row
815  * ...
816  */
817  struct draw_helper
818  {
819  /** Controls the ordering of draw calls by layer and location. */
820  const uint32_t key;
821 
822  /** Handles the actual drawing at this location. */
823  std::function<void(const rect&)> do_draw;
824 
825  /** The screen coordinates for the specified hex. This is passed to @ref do_draw */
827 
828  bool operator<(const draw_helper& rhs) const
829  {
830  return key < rhs.key;
831  }
832  };
833 
834  std::list<draw_helper> drawing_buffer_;
835 
836 public:
837  /**
838  * Add an item to the drawing buffer.
839  *
840  * @param layer The layer to draw on.
841  * @param loc The hex the image belongs to, needed for the drawing order.
842  * @param draw_func The draw operation to be run.
843  */
844  void drawing_buffer_add(const drawing_layer layer, const map_location& loc, decltype(draw_helper::do_draw) draw_func);
845 
846 protected:
847 
848  /** Draws the drawing_buffer_ and clears it. */
849  void drawing_buffer_commit();
850 
851  /** Redraws all panels intersecting the given region.
852  * Returns true if something was drawn, false otherwise. */
853  bool draw_all_panels(const rect& region);
854 
855 private:
856  void draw_panel(const theme::panel& panel);
857  void draw_label(const theme::label& label);
858 
859 protected:
860  /** Used to indicate to drawing functions that we are doing a map screenshot */
862 
863 public: //operations for the arrow framework
864 
865  void add_arrow(arrow&);
866 
867  void remove_arrow(arrow&);
868 
869  /** Called by arrow objects when they change. You should not need to call this directly. */
870  void update_arrow(arrow & a);
871 
872 protected:
873 
874  // Tiles lit for showing where unit(s) can reach
875  typedef std::map<map_location,unsigned int> reach_map;
879  // The team assigned to the reachmap being drawn
882 
883  typedef std::map<map_location, std::vector<overlay>> overlay_map;
884 
885  virtual overlay_map& get_overlays() = 0;
886 
887 private:
888  /** Count work done for the debug info displayed under fps */
891 
892  std::vector<std::function<void(display&)>> redraw_observers_;
893 
894 public:
895  enum DEBUG_FLAG {
896  /** Overlays x,y coords on tiles */
898 
899  /** Overlays terrain codes on tiles */
901 
902  /** Overlays number of bitmaps on tiles */
904 
905  /** Separates background and foreground terrain layers. */
907 
908  /** Toggle to continuously redraw the whole map. */
910 
911  /** Dummy entry to size the bitmask. Keep this last! */
913  };
914 
916  {
917  return debug_flags_.test(flag);
918  }
919 
920  void set_debug_flag(DEBUG_FLAG flag, bool value)
921  {
922  debug_flags_.set(flag, value);
923  }
924 
926  {
927  debug_flags_.flip(flag);
928  }
929 
930 private:
931  /** Currently set debug flags. */
932  std::bitset<NUM_DEBUG_FLAGS> debug_flags_;
933 
934  /** Maps the list of arrows for each location */
935  std::map<map_location, std::list<arrow*>> arrows_map_;
936 
938 
939 protected:
940  static display * singleton_;
941 };
942 
943 struct blindfold
944 {
945  blindfold(display& d, bool lock=true) : display_(d), blind(lock) {
946  if(blind) {
947  display_.blindfold(true);
948  }
949  }
950 
952  unblind();
953  }
954 
955  void unblind() {
956  if(blind) {
957  display_.blindfold(false);
959  blind = false;
960  }
961  }
962 
963 private:
965  bool blind;
966 };
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: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:331
void unhide_buttons()
Unhide theme buttons so they draw again.
Definition: display.cpp:922
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:336
void reset_reports(reports &reports_object)
Definition: display.hpp:659
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
Definition: display.hpp:861
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:1351
void layout_buttons()
Definition: display.cpp:782
bool redraw_background_
Definition: display.hpp:735
void update_render_textures()
Ensure render textures are valid and correct.
Definition: display.cpp:2367
void toggle_debug_flag(DEBUG_FLAG flag)
Definition: display.hpp:925
bool invalidate_locations_in_rect(const rect &rect)
invalidate all hexes under the rectangle rect (in screen coordinates)
Definition: display.cpp:3016
static unsigned int last_zoom_
The previous value of zoom_.
Definition: display.hpp:730
std::size_t viewing_team_index_
Definition: display.hpp:712
void write(config &cfg) const
Definition: display.cpp:3118
static bool zoom_at_min()
Definition: display.cpp:1680
std::map< map_location, std::vector< overlay > > overlay_map
Definition: display.hpp:883
void get_terrain_images(const map_location &loc, const std::string &timeid, TERRAIN_TYPE terrain_type)
Definition: display.cpp:1016
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:643
map_location selectedHex_
Definition: display.hpp:760
void recalculate_minimap()
Schedule the minimap for recalculation.
Definition: display.cpp:1458
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:375
void redraw_minimap()
Schedule the minimap to be redrawn.
Definition: display.cpp:1479
point get_location(const map_location &loc) const
Functions to get the on-screen positions of hexes.
Definition: display.cpp:668
virtual void render() override
Update offscreen render buffers.
Definition: display.cpp:2287
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:136
void fade_tod_mask(const std::string &old, const std::string &new_)
ToD mask smooth fade.
Definition: display.cpp:2082
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:360
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
Definition: display.cpp:2963
void set_playing_team_index(std::size_t team)
sets the team whose turn it currently is
Definition: display.cpp:353
uint8_t tod_hex_alpha1
Definition: display.hpp:755
const team & playing_team() const
Definition: display.cpp:326
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:1442
bool view_locked_
Definition: display.hpp:721
double turbo_speed() const
Definition: display.cpp:2007
@ ONSCREEN
Definition: display.hpp:494
@ ONSCREEN_WARP
Definition: display.hpp:494
@ SCROLL
Definition: display.hpp:494
void scroll_to_xy(const point &screen_coordinates, SCROLL_TYPE scroll_type, bool force=true)
Definition: display.cpp:1779
int invalidated_hexes_
Count work done for the debug info displayed under fps.
Definition: display.hpp:889
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:394
void set_fade(const color_t &color)
Definition: display.cpp:2136
void queue_repaint()
Queues repainting to the screen, but doesn't rerender.
Definition: display.cpp:2193
bool reach_map_changed_
Definition: display.hpp:878
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:256
static double get_zoom_factor()
Returns the current zoom factor.
Definition: display.hpp:259
const rect & unit_image_area() const
Definition: display.cpp:462
TERRAIN_TYPE
Definition: display.hpp:700
@ FOREGROUND
Definition: display.hpp:700
@ BACKGROUND
Definition: display.hpp:700
bool propagate_invalidation(const std::set< map_location > &locs)
If this set is partially invalidated, invalidate all its hexes.
Definition: display.cpp:2984
void clear_redraw_observers()
Clear the redraw observers.
Definition: display.cpp:2205
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Definition: display.hpp:305
const theme::action * action_pressed()
Definition: display.cpp:1410
static submerge_data get_submerge_data(const rect &dest, double submerge, const point &size, uint8_t alpha, bool hreverse, bool vreverse)
Definition: display.cpp:2035
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
Definition: display.cpp:762
void set_theme(const std::string &new_theme)
Definition: display.cpp:241
void rebuild_all()
Rebuild all dynamic terrain.
Definition: display.cpp:422
void change_display_context(const display_context *dc)
Definition: display.cpp:433
void set_prevent_draw(bool pd=true)
Prevent the game display from drawing.
Definition: display.cpp:2021
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:722
tod_color color_adjust_
Definition: display.hpp:937
bool get_prevent_draw()
Definition: display.cpp:2030
virtual void layout() override
Finalize screen layout.
Definition: display.cpp:2256
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1382
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
Definition: display.cpp:381
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:2200
bool invalidate_visible_locations_in_rect(const rect &rect)
Definition: display.cpp:3011
static bool zoom_at_max()
Definition: display.cpp:1675
static display * singleton_
Definition: display.hpp:940
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
Definition: display.cpp:772
void render_map_outside_area()
Draw/redraw the off-map background area.
Definition: display.cpp:2412
map_labels & labels()
Definition: display.cpp:2428
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:3094
@ DEBUG_COORDINATES
Overlays x,y coords on tiles.
Definition: display.hpp:897
@ DEBUG_BENCHMARK
Toggle to continuously redraw the whole map.
Definition: display.hpp:909
@ DEBUG_NUM_BITMAPS
Overlays number of bitmaps on tiles.
Definition: display.hpp:903
@ NUM_DEBUG_FLAGS
Dummy entry to size the bitmask.
Definition: display.hpp:912
@ DEBUG_FOREGROUND
Separates background and foreground terrain layers.
Definition: display.hpp:906
@ DEBUG_TERRAIN_CODES
Overlays terrain codes on tiles.
Definition: display.hpp:900
void process_reachmap_changes()
Definition: display.cpp:3135
void draw_minimap_units()
Definition: display.cpp:1535
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:1857
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:541
void invalidate_animations_location(const map_location &loc)
Per-location invalidation called by invalidate_animations() Extra game per-location invalidation (vil...
Definition: display.cpp:3031
map_location mouseoverHex_
Definition: display.hpp:761
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
Definition: display.cpp:663
bool view_locked() const
Definition: display.hpp:489
bool set_zoom(bool increase)
Zooms the display in (true) or out (false).
Definition: display.cpp:1685
std::map< std::string, rect > reportLocations_
Definition: display.hpp:746
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
Definition: display.hpp:354
bool invalidateAll_
Definition: display.hpp:736
int drawn_hexes_
Definition: display.hpp:890
void draw_overlays_at(const map_location &loc)
Definition: display.cpp:2639
texture get_flag(const map_location &loc)
Definition: display.cpp:308
tod_color get_color_overlay() const
Definition: display.hpp:207
void invalidate_all()
Function to invalidate all tiles.
Definition: display.cpp:2956
std::map< std::string, config > reports_
Definition: display.hpp:748
point viewport_origin_
Position of the top-left corner of the viewport, in pixels.
Definition: display.hpp:720
map_location get_middle_location() const
Definition: display.cpp:3112
void bounds_check_position()
Definition: display.cpp:1989
std::function< rect(rect)> minimap_renderer_
Definition: display.hpp:733
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
Definition: display.cpp:717
void init_flags()
Init the flag list and the team colors used by ~TC.
Definition: display.cpp:252
static rect scaled_to_zoom(const rect &r)
Scale the width and height of a rect by the current zoom factor.
Definition: display.hpp:265
std::vector< std::shared_ptr< gui::button > > action_buttons_
Definition: display.hpp:749
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:1234
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.cpp:510
std::size_t reach_map_team_index_
Definition: display.hpp:880
bool prevent_draw_
Definition: display.hpp:547
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:675
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:1770
void reload_map()
Updates internals that cache map size.
Definition: display.cpp:427
rect max_map_area() const
Returns the maximum area used for the map regardless to resolution and view size.
Definition: display.cpp:467
halo::manager & get_halo_manager()
Definition: display.hpp:189
bool tile_fully_on_screen(const map_location &loc) const
Check if a tile is fully visible on screen.
Definition: display.cpp:1765
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:685
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:1867
bool is_blindfolded() const
Definition: display.cpp:447
std::vector< texture > terrain_image_vector_
Definition: display.hpp:779
std::vector< std::string > fog_images_
Definition: display.hpp:757
void fade_to(const color_t &color, const std::chrono::milliseconds &duration)
Screen fade.
Definition: display.cpp:2104
virtual bool in_editor() const
Definition: display.hpp:210
texture tod_hex_mask2
Definition: display.hpp:754
theme & get_theme()
Definition: display.hpp:379
const display_context & context() const
Definition: display.hpp:184
std::map< map_location, std::list< arrow * > > arrows_map_
Maps the list of arrows for each location.
Definition: display.hpp:935
std::map< map_location, std::string > exclusive_unit_draw_requests_t
Definition: display.hpp:673
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:892
void read(const config &cfg)
Definition: display.cpp:3127
const theme::menu * menu_pressed()
Definition: display.cpp:1426
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:615
const std::unique_ptr< terrain_builder > builder_
Definition: display.hpp:732
virtual const map_location & displayed_unit_hex() const
Virtual functions shadowed in game_display.
Definition: display.hpp:213
std::vector< animated< image::locator > > flags_
Animated flags for each team.
Definition: display.hpp:775
const map_location & selected_hex() const
Definition: display.hpp:298
rect get_location_rect(const map_location &loc) const
Returns the on-screen rect corresponding to a loc.
Definition: display.cpp:679
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
Definition: display.hpp:522
static void fill_images_list(const std::string &prefix, std::vector< std::string > &images)
Definition: display.cpp:400
void draw_report(const std::string &report_name, bool test_run=false)
Draw the specified report.
Definition: display.cpp:2782
std::set< map_location > invalidated_
Definition: display.hpp:750
color_t fade_color_
Definition: display.hpp:558
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:932
void queue_rerender()
Marks everything for rendering including all tiles and sidebar.
Definition: display.cpp:2141
rect minimap_location_
Definition: display.hpp:734
void create_buttons()
Definition: display.cpp:825
int blindfold_ctr_
Definition: display.hpp:665
std::string remove_exclusive_draw(const map_location &loc)
Cancels an exclusive draw request.
Definition: display.cpp:367
bool invalidateGameStatus_
Definition: display.hpp:738
reach_map reach_map_old_
Definition: display.hpp:877
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
Definition: display.cpp:2443
void drawing_buffer_commit()
Draws the drawing_buffer_ and clears it.
Definition: display.cpp:1239
rect map_area() const
Returns the area used for the map.
Definition: display.cpp:484
int zoom_index_
Definition: display.hpp:728
void draw_panel(const theme::panel &panel)
Definition: display.cpp:1268
void draw_buttons()
Definition: display.cpp:890
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:250
void set_debug_flag(DEBUG_FLAG flag, bool value)
Definition: display.hpp:920
void reset_standing_animations()
Definition: display.cpp:3080
bool animate_water_
Local version of prefs::get().animate_water, used to detect when it's changed.
Definition: display.hpp:768
bool debug_flag_set(DEBUG_FLAG flag) const
Definition: display.hpp:915
void toggle_default_zoom()
Sets the zoom amount to the default.
Definition: display.cpp:1753
virtual rect get_clip_rect() const
Get the clipping rectangle for drawing.
Definition: display.cpp:2438
CKey keys_
Definition: display.hpp:762
reports * reports_object_
Definition: display.hpp:740
bool draw_reports(const rect &region)
Draw all reports in the given region.
Definition: display.cpp:2942
void invalidate_animations()
Function to invalidate animated terrains and units which may have changed.
Definition: display.cpp:3042
virtual rect screen_location() override
Return the current draw location of the display, on the screen.
Definition: display.cpp:2359
void hide_buttons()
Hide theme buttons so they don't draw.
Definition: display.cpp:912
virtual bool expose(const rect &region) override
Paint the indicated region to the screen.
Definition: display.cpp:2314
std::list< draw_helper > drawing_buffer_
Definition: display.hpp:834
uint8_t tod_hex_alpha2
Definition: display.hpp:756
std::vector< std::shared_ptr< gui::button > > menu_buttons_
Definition: display.hpp:749
virtual void update() override
Update animations and internal state.
Definition: display.cpp:2239
void draw()
Perform rendering of invalidated items.
Definition: display.cpp:2210
const rect & minimap_area() const
mapx is the width of the portion of the display which shows the game area.
Definition: display.cpp:452
texture back_
Definition: display.hpp:583
events::generic_event scroll_event_
Event raised when the map is being scrolled.
Definition: display.hpp:743
bool show_everything() const
Definition: display.hpp:104
terrain_builder & get_builder()
Definition: display.hpp:455
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
Definition: display.cpp:2479
texture tod_hex_mask1
Definition: display.hpp:753
virtual bool in_game() const
Definition: display.hpp:209
virtual ~display()
Definition: display.cpp:231
const rect & palette_area() const
Definition: display.cpp:457
std::map< map_location, unsigned int > reach_map
Definition: display.hpp:875
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:793
halo::manager halo_man_
Definition: display.hpp:670
void reinit_flags_for_team(const team &)
Rebuild the flag list (not team colors) for a single side.
Definition: display.cpp:263
void draw_minimap()
Actually draw the minimap.
Definition: display.cpp:1484
texture front_
Render textures, for intermediate rendering.
Definition: display.hpp:582
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:299
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:527
void update_arrow(arrow &a)
Called by arrow objects when they change.
Definition: display.cpp:3101
void draw_label(const theme::label &label)
Definition: display.cpp:1293
const std::unique_ptr< fake_unit_manager > fake_unit_man_
Definition: display.hpp:731
const display_context * dc_
Definition: display.hpp:669
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:519
bool animate_map_
Local cache for prefs::get().animate_map, since it is constantly queried.
Definition: display.hpp:765
static point scaled_to_zoom(const point &p)
Definition: display.hpp:271
std::vector< std::string > shroud_images_
Definition: display.hpp:758
void set_view_locked(bool value)
Sets whether the map view is locked (e.g.
Definition: display.hpp:492
bool scroll(const point &amount, bool force=false)
Scrolls the display by amount pixels.
Definition: display.cpp:1582
virtual const std::set< std::string > & observers() const
Definition: display.hpp:214
static unsigned int zoom_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e....
Definition: display.hpp:727
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
Definition: display.cpp:658
bool dont_show_all_
Definition: display.hpp:713
std::bitset< NUM_DEBUG_FLAGS > debug_flags_
Currently set debug flags.
Definition: display.hpp:932
void blindfold(bool flag)
Definition: display.cpp:439
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Update the given report.
Definition: display.cpp:2712
std::weak_ptr< wb::manager > wb_
Definition: display.hpp:671
void add_arrow(arrow &)
Definition: display.cpp:3087
const std::unique_ptr< map_labels > map_labels_
Definition: display.hpp:739
void set_diagnostic(const std::string &msg)
Definition: display.cpp:1392
virtual void select_hex(map_location hex)
Definition: display.cpp:1374
int diagnostic_label_
Definition: display.hpp:737
std::map< std::string, texture > reportSurfaces_
Definition: display.hpp:747
bool draw_all_panels(const rect &region)
Redraws all panels intersecting the given region.
Definition: display.cpp:1329
reach_map reach_map_
Definition: display.hpp:876
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:142
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:159
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...
bool blind
Definition: display.hpp:965
blindfold(display &d, bool lock=true)
Definition: display.hpp:945
~blindfold()
Definition: display.hpp:951
void unblind()
Definition: display.hpp:955
display & display_
Definition: display.hpp:964
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:601
bool discard_previous
An announcement according these options should replace the previous announce (typical of fast announc...
Definition: display.hpp:610
std::chrono::milliseconds lifetime
Lifetime measured in milliseconds.
Definition: display.hpp:603
Helper for rendering the map by ordering draw operations.
Definition: display.hpp:818
std::function< void(const rect &)> do_draw
Handles the actual drawing at this location.
Definition: display.hpp:823
const uint32_t key
Controls the ordering of draw calls by layer and location.
Definition: display.hpp:820
rect dest
The screen coordinates for the specified hex.
Definition: display.hpp:826
bool operator<(const draw_helper &rhs) const
Definition: display.hpp:828
very simple iterator to walk into the rect_of_hexes
Definition: display.hpp:324
const map_location & operator*() const
Definition: display.hpp:332
std::forward_iterator_tag iterator_category
Definition: display.hpp:334
iterator & operator++()
increment y first, then when reaching bottom, increment x
Definition: display.cpp:593
const rect_of_hexes & rect_
Definition: display.hpp:342
bool operator==(const iterator &that) const
Definition: display.hpp:330
const map_location * pointer
Definition: display.hpp:337
bool operator!=(const iterator &that) const
Definition: display.hpp:331
iterator(const map_location &loc, const rect_of_hexes &rect)
Definition: display.hpp:325
const map_location & reference
Definition: display.hpp:338
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
Definition: display.hpp:317
iterator end() const
Definition: display.cpp:610
iterator begin() const
Definition: display.cpp:606
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