67 #include "widgets/button.hpp" 69 #include <boost/circular_buffer.hpp> 87 std::weak_ptr<wb::manager>
wb,
89 const std::string& theme_id,
104 const std::vector<team>&
get_teams()
const {
return dc_->teams();}
109 bool team_valid()
const;
119 void set_team(std::size_t
team,
bool observe=
false);
124 void set_playing_team(std::size_t team);
146 std::string remove_exclusive_draw(
const map_location& loc);
155 const std::string&
halo=
"",
const std::string& team_name=
"",
const std::string& item_id=
"",
156 bool visible_under_fog =
true,
float submerge = 0.0
f,
float z_order = 0);
162 void remove_single_overlay(
const map_location& loc,
const std::string& toDelete);
187 void update_tod(
const time_of_day* tod_override =
nullptr);
194 void adjust_color_overlay(
int r,
int g,
int b);
197 virtual bool in_game()
const {
return false; }
203 virtual const std::set<std::string>&
observers()
const {
static const std::set<std::string> fake_obs = std::set<std::string> ();
return fake_obs; }
210 const rect& minimap_area()
const;
211 const rect& palette_area()
const;
212 const rect& unit_image_area()
const;
218 rect max_map_area()
const;
223 rect map_area()
const;
230 rect map_outside_area()
const;
233 static bool outside_area(
const SDL_Rect& area,
const int x,
const int y);
258 const double zf = get_zoom_factor();
259 return {r.x, r.y, int(r.w * zf), int(r.h * zf)};
264 const double zf = get_zoom_factor();
265 return {int(p.x * zf), int(p.y * zf)};
280 const map_location pixel_position_to_hex(
int x,
int y)
const;
316 :
loc_(loc), rect_(rect){}
341 const rect_of_hexes hexes_under_rect(
const SDL_Rect& r)
const;
353 surface screenshot(
bool map_screenshot =
false);
357 void queue_rerender();
360 void queue_repaint();
364 void add_redraw_observer(std::function<
void(
display&)>
f);
367 void clear_redraw_observers();
370 void set_theme(
const std::string& new_theme);
382 std::shared_ptr<gui::button> find_action_button(
const std::string&
id);
383 std::shared_ptr<gui::button> find_menu_button(
const std::string&
id);
385 void create_buttons();
387 void layout_buttons();
392 void refresh_report(
const std::string& report_name,
const config * new_cfg=
nullptr);
401 void draw_report(
const std::string& report_name,
bool test_run =
false);
405 bool draw_reports(
const rect& region);
407 void draw_minimap_units();
415 bool invalidate(
const std::set<map_location>& locs);
421 bool propagate_invalidation(
const std::set<map_location>& locs);
424 bool invalidate_locations_in_rect(
const SDL_Rect&
rect);
425 bool invalidate_visible_locations_in_rect(
const SDL_Rect& rect);
430 void invalidate_animations();
436 void invalidate_animations_location(
const map_location& loc);
438 void reset_standing_animations();
442 void update_fps_label();
443 void clear_fps_label();
444 void update_fps_count();
452 void set_diagnostic(
const std::string&
msg);
456 void bounds_check_position();
457 void bounds_check_position(
int& xpos,
int& ypos)
const;
464 bool scroll(
int xmov,
int ymov,
bool force =
false);
467 bool set_zoom(
bool increase);
470 bool set_zoom(
unsigned int amount,
const bool validate_value_and_set_index =
true);
472 static bool zoom_at_max();
473 static bool zoom_at_min();
476 void toggle_default_zoom();
492 void scroll_to_tile(
const map_location& loc,
SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=
true,
bool force =
true);
501 SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=
true,
502 double add_spacing=0.0,
bool force=
true);
505 void scroll_to_tiles(
const std::vector<map_location>::const_iterator & begin,
506 const std::vector<map_location>::const_iterator & end,
507 SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=
true,
508 bool only_if_possible=
false,
double add_spacing=0.0,
512 SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=
true,
513 bool only_if_possible=
false,
514 double add_spacing=0.0,
bool force=
true)
516 scroll_to_tiles(locs.begin(), locs.end(), scroll_type, check_fogged,
517 only_if_possible, add_spacing, force);
524 bool tile_fully_on_screen(
const map_location& loc)
const;
527 bool tile_nearly_on_screen(
const map_location &loc)
const;
535 bool prevent_draw_ =
false;
539 void fade_tod_mask(
const std::string& old,
const std::string& new_);
542 void fade_to(
const color_t& color,
int duration);
543 void set_fade(
const color_t& color);
554 virtual void update()
override;
557 virtual void layout()
override;
560 virtual void render()
override;
563 virtual bool expose(
const rect& region)
override;
566 virtual rect screen_location()
override;
574 void update_render_textures();
578 void render_map_outside_area();
602 , discard_previous(false)
608 void announce(
const std::string& msg,
616 void recalculate_minimap();
622 void redraw_minimap();
635 bool is_blindfolded()
const;
647 void reinit_flags_for_team(
const team&);
650 reports_object_ = &reports_object;
654 void init_flags_for_side_internal(std::size_t side,
const std::string& side_color);
662 std::weak_ptr<wb::manager>
wb_;
674 virtual rect get_clip_rect()
const;
682 virtual void draw_invalidated();
692 const std::string& timeid,
697 void scroll_to_xy(
int screenxpos,
int screenypos,
SCROLL_TYPE scroll_type,
bool force =
true);
699 static void fill_images_list(
const std::string& prefix, std::vector<std::string>& images);
701 static const std::string& get_variant(
const std::vector<std::string>& variants,
const map_location &loc);
737 int current_frame_sample_ = 0;
741 uint32_t last_frame_finished_ = 0u;
753 uint8_t tod_hex_alpha1 = 0;
754 uint8_t tod_hex_alpha2 = 0;
773 std::vector<animated<image::locator>>
flags_;
796 LAYER_UNIT_BG = LAYER_UNIT_FIRST+10,
797 LAYER_UNIT_DEFAULT=LAYER_UNIT_FIRST+40,
798 LAYER_TERRAIN_FG = LAYER_UNIT_FIRST+50,
806 LAYER_UNIT_MOVE_DEFAULT=LAYER_UNIT_FIRST+60,
807 LAYER_UNIT_FG = LAYER_UNIT_FIRST+80,
811 LAYER_UNIT_MISSILE_DEFAULT = LAYER_UNIT_FIRST+90,
812 LAYER_UNIT_LAST=LAYER_UNIT_FIRST+100,
829 static void add_submerge_ipf_mod(std::string& image_path,
int image_height,
double submersion_amount,
int shift = 0);
836 const drawing_layer layer,
const std::string& text, std::size_t font_size,
837 color_t color,
double x_in_hex=0.5,
double y_in_hex=0.5);
879 return key < rhs.
key;
898 void drawing_buffer_commit();
902 bool draw_all_panels(
const rect& region);
917 void draw_wrap(
bool update,
bool force);
924 void add_arrow(
arrow&);
926 void remove_arrow(
arrow&);
929 void update_arrow(
arrow &
a);
938 void process_reachmap_changes();
942 virtual overlay_map& get_overlays() = 0;
976 return debug_flags_.test(flag);
981 debug_flags_.set(flag, value);
986 debug_flags_.flip(flag);
1010 display_.blindfold(
true);
1020 display_.blindfold(
false);
1021 display_.queue_rerender();
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.
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.
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.
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.
virtual bool in_game() const
static rect scaled_to_zoom(const SDL_Rect &r)
Scale the width and height of a rect by the current zoom factor.
boost::circular_buffer< unsigned > frametimes_
const map_location & operator*() const
const map_location & selected_hex() const
rect dest
The screen coordinates for the specified hex.
static double get_zoom_factor()
Returns the current zoom factor.
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
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::function< void(const rect &)> do_draw
Handles the actual drawing at this location.
void toggle_debug_flag(DEBUG_FLAG flag)
map_location mouseoverHex_
Manages a list of fake units for the display object.
bool operator!=(const iterator &that) const
Mouseover overlay used by editor.
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.
map_location selectedHex_
std::list< draw_helper > drawing_buffer_
static display * singleton_
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%.
Toggle to continuously redraw the whole map.
drawing_layer
The layers to render something on.
std::vector< texture > terrain_image_vector_
Wrapper class to encapsulate creation and management of an SDL_Texture.
Unit and team statistics.
void invalidate_all()
Mark the entire screen as requiring redraw.
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.
std::map< std::string, rect > reportLocations_
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.
Overlays x,y coords on tiles.
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.
std::map< std::string, texture > reportSurfaces_
void set_theme(const std::string &theme)
std::string label
What to show in the filter's drop-down list.
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
const map_location & reference
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_
The basic class for representing 8-bit RGB or RGBA colour values.
virtual int playing_side() const
void set_prevent_draw(bool pd)
Prevent the game display from drawing.
bool invalidateGameStatus_
A top-level drawable item (TLD), such as a window.
Separates background and foreground terrain layers.
int invalidated_hexes_
Count work done for the debug info displayed under fps.
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_.
Encapsulates the map of the game.
Holds options for calls to function 'announce' (announce).
std::vector< std::shared_ptr< gui::button > > menu_buttons_
static std::string get_location(const std::string &loc)
blindfold(display &d, bool lock=true)
virtual bool has_time_area() const
unsigned int fps_counter_
std::size_t playing_team() const
The playing team is the team whose turn it is.
Definitions related to theme-support.
An abstract description of a rectangle with integer coordinates.
const display_context & get_disp_context() const
void set_debug_flag(DEBUG_FLAG flag, bool value)
static point scaled_to_zoom(const point &p)
const map_location * pointer
Declarations for File-IO.
Movement info (defense%, etc...).
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.
std::list< arrow * > arrows_list_t
std::vector< std::string > fog_images_
std::chrono::seconds fps_start_
std::map< map_location, unsigned int > reach_map
Helper for rendering the map by ordering draw operations.
virtual const std::set< std::string > & observers() const
std::bitset< __NUM_DEBUG_FLAGS > debug_flags_
Currently set debug flags.
const std::vector< team > & get_teams() const
const gamemap & get_map() const
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 ...
Overlays number of bitmaps on tiles.
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::set< map_location > invalidated_
std::map< std::string, config > reports_
const display_context * dc_
std::forward_iterator_tag iterator_category
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
Functions to load and save images from/to disk.
static const map_location & null_location()
Overlays terrain codes on tiles.
tod_color get_color_overlay() const
Container associating units to locations.
bool debug_flag_set(DEBUG_FLAG flag) const
const std::unique_ptr< fake_unit_manager > fake_unit_man_
std::vector< animated< image::locator > > flags_
Animated flags for each team.
A config object defines a single node in a WML file, with access to child nodes.
std::vector< std::tuple< int, int, int > > fps_history_
bool operator<(const draw_helper &rhs) const
Class that keeps track of all the keys on the keyboard.
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)
const uint32_t key
Controls the ordering of draw calls by layer and location.
std::weak_ptr< wb::manager > wb_
Layer which holds the attack indicator.
Footsteps showing path from unit to mouse.
"black stripes" on unreachable hexes.