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