63 #include "widgets/button.hpp" 65 #include <boost/circular_buffer.hpp> 96 const std::vector<team>&
get_teams()
const {
return dc_->teams();}
101 bool team_valid()
const;
111 void set_team(std::size_t
team,
bool observe=
false);
116 void set_playing_team(std::size_t team);
138 std::string remove_exclusive_draw(
const map_location& loc);
144 void parse_team_overlays();
153 const std::string&
halo=
"",
const std::string& team_name=
"",
const std::string& item_id=
"",
154 bool visible_under_fog =
true,
float z_order = 0);
160 void remove_single_overlay(
const map_location& loc,
const std::string& toDelete);
175 void reset_halo_manager();
187 void update_tod(
const time_of_day* tod_override =
nullptr);
194 void adjust_color_overlay(
int r,
int g,
int b);
203 virtual bool in_game()
const {
return false; }
209 virtual const std::set<std::string>&
observers()
const {
static const std::set<std::string> fake_obs = std::set<std::string> ();
return fake_obs; }
217 {
return theme_.mini_map_location(screen_.screen_area()); }
219 {
return theme_.palette_location(screen_.screen_area()); }
221 {
return theme_.unit_image_location(screen_.screen_area()); }
227 const SDL_Rect& max_map_area()
const;
232 const SDL_Rect& map_area()
const;
240 max_map_area() : theme_.main_map_location(screen_.screen_area()); }
243 static bool outside_area(
const SDL_Rect& area,
const int x,
const int y);
277 const map_location pixel_position_to_hex(
int x,
int y)
const;
312 :
loc_(loc), rect_(rect){}
337 const rect_of_hexes hexes_under_rect(
const SDL_Rect& r)
const;
370 surface screenshot(
bool map_screenshot =
false);
373 void redraw_everything();
376 void add_redraw_observer(std::function<
void(
display&)>
f);
379 void clear_redraw_observers();
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);
398 void create_buttons();
400 void layout_buttons();
402 void render_buttons();
406 void refresh_report(
const std::string& report_name,
const config * new_cfg=
nullptr);
408 void draw_minimap_units();
411 void invalidate_all();
416 bool invalidate(
const std::set<map_location>& locs);
422 bool propagate_invalidation(
const std::set<map_location>& locs);
425 bool invalidate_locations_in_rect(
const SDL_Rect& rect);
426 bool invalidate_visible_locations_in_rect(
const SDL_Rect& rect);
431 void invalidate_animations();
437 void invalidate_animations_location(
const map_location& loc);
439 void reset_standing_animations();
446 { mouseover_hex_overlay_ = image; }
449 { mouseover_hex_overlay_ =
nullptr; }
452 static void toggle_benchmark();
459 static void toggle_debug_foreground();
466 void update_display();
478 void enable_menu(
const std::string&
item,
bool enable);
480 void set_diagnostic(
const std::string&
msg);
498 void bounds_check_position();
499 void bounds_check_position(
int& xpos,
int& ypos)
const;
506 bool scroll(
int xmov,
int ymov,
bool force =
false);
512 bool set_zoom(
unsigned int amount,
const bool validate_value_and_set_index =
true);
514 static bool zoom_at_max();
515 static bool zoom_at_min();
518 void toggle_default_zoom();
534 void scroll_to_tile(
const map_location& loc,
SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=
true,
bool force =
true);
543 SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=
true,
544 double add_spacing=0.0,
bool force=
true);
547 void scroll_to_tiles(
const std::vector<map_location>::const_iterator & begin,
548 const std::vector<map_location>::const_iterator & end,
549 SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=
true,
550 bool only_if_possible=
false,
double add_spacing=0.0,
554 SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=
true,
555 bool only_if_possible=
false,
556 double add_spacing=0.0,
bool force=
true)
558 scroll_to_tiles(locs.begin(), locs.end(), scroll_type, check_fogged,
559 only_if_possible, add_spacing, force);
566 bool tile_fully_on_screen(
const map_location& loc)
const;
569 bool tile_nearly_on_screen(
const map_location &loc)
const;
580 void draw(
bool update);
582 void draw(
bool update,
bool force);
602 , discard_previous(false)
608 void announce(
const std::string& msg,
629 bool is_blindfolded()
const;
633 virtual void handle_event(
const SDL_Event& );
634 virtual void handle_window_event(
const SDL_Event& event);
644 void reinit_flags_for_team(
const team&);
647 reports_object_ = &reports_object;
651 void init_flags_for_side_internal(std::size_t side,
const std::string& side_color);
659 std::weak_ptr<wb::manager>
wb_;
684 virtual const SDL_Rect& get_clip_rect();
692 virtual void draw_invalidated();
721 const std::string& timeid,
726 void draw_image_for_report(
surface& img, SDL_Rect& rect);
728 void scroll_to_xy(
int screenxpos,
int screenypos,
SCROLL_TYPE scroll_type,
bool force =
true);
730 static void fill_images_list(
const std::string& prefix, std::vector<std::string>& images);
732 static const std::string& get_variant(
const std::vector<std::string>& variants,
const map_location &loc);
777 uint32_t last_frame_finished_ = 0u;
808 std::vector<animated<image::locator>>
flags_;
831 LAYER_UNIT_BG = LAYER_UNIT_FIRST+10,
832 LAYER_UNIT_DEFAULT=LAYER_UNIT_FIRST+40,
833 LAYER_TERRAIN_FG = LAYER_UNIT_FIRST+50,
841 LAYER_UNIT_MOVE_DEFAULT=LAYER_UNIT_FIRST+60,
842 LAYER_UNIT_FG = LAYER_UNIT_FIRST+80,
846 LAYER_UNIT_MISSILE_DEFAULT = LAYER_UNIT_FIRST+90,
847 LAYER_UNIT_LAST=LAYER_UNIT_FIRST+100,
877 bool hreverse=
false,
bool greyscale=
false,
879 double blend_ratio=0,
double submerged=0.0,
bool vreverse =
false);
886 const drawing_layer layer,
const std::string& text, std::size_t
font_size,
887 color_t color,
double x_in_hex=0.5,
double y_in_hex=0.5);
943 const int x,
const int y,
const surface& surf,
944 const SDL_Rect& clip)
945 : x_(x), y_(y), surf_(1, surf), clip_(clip),
950 const int x,
const int y,
const std::vector<surface>& surf,
951 const SDL_Rect& clip)
952 : x_(x), y_(y), surf_(surf), clip_(clip),
956 int x()
const {
return x_; }
957 int y()
const {
return y_; }
958 const std::vector<surface> &
surf()
const {
return surf_; }
959 const SDL_Rect &
clip()
const {
return clip_; }
989 void drawing_buffer_add(
const drawing_layer layer,
991 const SDL_Rect &clip = SDL_Rect());
993 void drawing_buffer_add(
const drawing_layer layer,
995 const std::vector<surface> &surf,
996 const SDL_Rect &clip = SDL_Rect());
1001 void drawing_buffer_commit();
1004 void drawing_buffer_clear();
1007 void draw_all_panels();
1017 void draw_wrap(
bool update,
bool force);
1024 void add_arrow(
arrow&);
1026 void remove_arrow(
arrow&);
1029 void update_arrow(
arrow &
a);
1038 void process_reachmap_changes();
1042 virtual overlay_map& get_overlays() = 0;
1082 display_.blindfold(
true);
1092 display_.blindfold(
false);
static const std::array< drawing_layer, 4 > layer_groups
The overlay used for the linger mode.
const map_location & mouseover_hex() const
TYPE
Used to specify the rendering format of images.
Reserve layers to be selected for WML.
virtual void pre_draw()
Called near the beginning of each draw() call.
bool discard_previous
An announcement according these options should replace the previous announce (typical of fast announc...
halo::manager & get_halo_manager()
Move numbering for the whiteboard.
void set_draw_num_of_bitmaps(bool value)
Setter for the terrain code debug overlay on tiles.
reports * reports_object_
static display * get_singleton()
Returns the display object if a display object exists.
virtual const map_location & displayed_unit_hex() const
Virtual functions shadowed in game_display.
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Small struct to store and manipulate ToD color adjusts.
In order to render a hex properly it needs to be rendered per row.
void set_draw_terrain_codes(bool value)
Setter for the terrain code debug overlay on tiles.
virtual void draw_sidebar()
Called near the end of a draw operation, derived classes can use this to render a specific sidebar...
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 ...
This class represents a single unit of a specific type.
bool animate_water_
Local version of preferences::animate_water, used to detect when it's changed.
void set_grid(const bool grid)
Determines whether a grid should be overlayed on the game board.
virtual bool in_game() const
boost::circular_buffer< unsigned > frametimes_
bool get_draw_num_of_bitmaps() const
Getter for the number of bitmaps debug overlay on tiles.
const map_location & operator*() const
const map_location & selected_hex() const
static double get_zoom_factor()
Returns the current zoom factor.
drawing_buffer drawing_buffer_
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
void set_turbo(const bool turbo)
Set/Get whether 'turbo' mode is on.
void clear_exclusive_draws()
Cancels all the exclusive draw requests.
Arrows from the arrows framework.
void scroll_to_tiles(const std::vector< map_location > &locs, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool only_if_possible=false, double add_spacing=0.0, bool force=true)
Scroll to fit as many locations on-screen as possible, starting with the first.
std::map< std::string, SDL_Rect > reportRects_
map_location mouseoverHex_
Manages a list of fake units for the display object.
bool operator!=(const iterator &that) const
Mouseover overlay used by editor.
bool draw_coordinates_
Debug flag - overlay x,y coords on tiles.
std::list< blit_helper > drawing_buffer
int fps_handle_
Handle for the label which displays frames per second.
bool show_everything() const
The class terrain_builder is constructed from a config object, and a gamemap object.
std::map< map_location, std::string > exclusive_unit_draw_requests_t
const unit_map & get_units() const
const rect_of_hexes & rect_
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::vector< std::function< void(display &)> > redraw_observers_
Bottom half of image following the mouse.
void clear_mouseover_hex_overlay()
map_location selectedHex_
static display * singleton_
const SDL_Rect & unit_image_area() const
Top half part of grid image.
terrain_builder & get_builder()
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
static unsigned int zoom_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e., 72 means 100%.
const SDL_Rect & minimap_area() const
mapx is the width of the portion of the display which shows the game area.
drawing_layer
The layers to render something on.
void redraw_minimap()
Schedule the minimap to be redrawn.
Unit and team statistics.
very simple iterator to walk into the rect_of_hexes
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
surface map_screenshot_surf_
virtual bool in_editor() const
Top half of image following the mouse.
std::vector< std::string > shroud_images_
Object which defines a time of day with associated bonuses, image, sounds etc.
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
This class stores all the data for a single 'side' (in game nomenclature).
Image on the selected unit.
void set_idle_anim_rate(int rate)
void set_theme(const std::string &theme)
Arrows destined to be drawn on the map.
void read(config &cfg, std::istream &in, abstract_validator *validator)
std::map< map_location, std::vector< overlay > > overlay_map
void recalculate_minimap()
Schedule the minimap for recalculation.
const map_location & reference
void set_draw_coordinates(bool value)
Setter for the x,y debug overlay on tiles.
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
arrows_map_t arrows_map_
Maps the list of arrows for each location.
This class is the frontend of the whiteboard framework for the rest of the Wesnoth code...
const std::unique_ptr< map_labels > map_labels_
Encapsulates the map of the game.
SDL_Rect minimap_location_
const SDL_Rect & palette_area() const
void set_zoom(unsigned int amount)
Sets the scaling factor for images.
virtual int playing_side() const
virtual void post_draw()
Called at the very end of each draw() call.
bool invalidateGameStatus_
void set_mouseover_hex_overlay(const surface &image)
mouseover_hex_overlay_ require a prerendered surface and is drawn underneath the mouse's location ...
blit_helper(const drawing_layer layer, const map_location &loc, const int x, const int y, const std::vector< surface > &surf, const SDL_Rect &clip)
int invalidated_hexes_
Count work done for the debug info displayed under fps.
bool draw_terrain_codes_
Debug flag - overlay terrain codes on tiles.
bool get_draw_coordinates() const
Getter for the x,y debug overlay on tiles.
std::vector< surface > surf_
surface(s) to render.
static int hex_width()
Function which returns the width of a hex in pixels, up to where the next hex starts.
static unsigned int last_zoom_
The previous value of zoom_.
std::unique_ptr< halo::manager > halo_man_
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Encapsulates the map of the game.
surface & get_screen_surface()
return the screen surface or the surface used for map_screenshot.
Holds options for calls to function 'announce' (announce).
std::vector< std::shared_ptr< gui::button > > menu_buttons_
blindfold(display &d, bool lock=true)
double idle_anim_rate() const
virtual bool has_time_area() const
void set_turbo_speed(const double speed)
unsigned int fps_counter_
std::size_t playing_team() const
The playing team is the team whose turn it is.
bool draw_num_of_bitmaps_
Debug flag - overlay number of bitmaps on tiles.
Definitions related to theme-support.
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
Helper structure for rendering the terrains.
const display_context & get_disp_context() const
const map_location * pointer
Movement info (defense%, etc...).
surface mouseover_hex_overlay_
std::map< map_location, arrows_list_t > arrows_map_t
void set_view_locked(bool value)
Sets whether the map view is locked (e.g.
void set_idle_anim(bool ison)
control unit idle animations and their frequency
std::list< arrow * > arrows_list_t
std::vector< std::string > fog_images_
std::chrono::seconds fps_start_
int x_
x screen coordinate to render at.
std::map< map_location, unsigned int > reach_map
virtual const std::set< std::string > & observers() const
bool operator<(const blit_helper &rhs) const
const std::vector< team > & get_teams() const
const gamemap & get_map() const
virtual void post_commit()
Hook for actions to take right after draw() calls drawing_buffer_commit No action here by default...
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 ...
Contains the SDL_Rect helper code.
iterator(const map_location &loc, const rect_of_hexes &rect)
events::generic_event scroll_event_
Event raised when the map is being scrolled.
int lifetime
Lifetime measured in milliseconds.
std::map< std::string, surface > reportSurfaces_
std::set< map_location > invalidated_
blit_helper(const drawing_layer layer, const map_location &loc, const int x, const int y, const surface &surf, const SDL_Rect &clip)
std::map< std::string, config > reports_
const display_context * dc_
std::forward_iterator_tag iterator_category
bool operator<(const drawing_buffer_key &rhs) const
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
std::vector< surface > terrain_image_vector_
Functions to load and save images from/to disk.
const std::vector< surface > & surf() const
CVideo & video()
Gets the underlying screen object.
static const map_location & null_location()
Container associating units to locations.
const std::unique_ptr< fake_unit_manager > fake_unit_man_
std::vector< animated< image::locator > > flags_
Animated flags for each team.
bool get_draw_terrain_codes() const
Getter for the terrain code debug overlay on tiles.
int y_
y screen coordinate to render at.
A config object defines a single node in a WML file, with access to child nodes.
Class that keeps track of all the keys on the keyboard.
SDL_Rect clip_
The clipping area of the source if omitted the entire source is used.
bool animate_map_
Local cache for preferences::animate_map, since it is constantly queried.
bool operator==(const iterator &that) const
const std::unique_ptr< terrain_builder > builder_
void reset_reports(reports &reports_object)
std::weak_ptr< wb::manager > wb_
Layer which holds the attack indicator.
Footsteps showing path from unit to mouse.
std::pair< std::string, unsigned > item
"black stripes" on unreachable hexes.
const SDL_Rect & clip() const