67 #include "widgets/button.hpp"
69 #include <boost/circular_buffer.hpp>
90 std::weak_ptr<wb::manager>
wb,
92 const std::string& theme_id,
172 const std::string&
halo=
"",
const std::string& team_name=
"",
const std::string& item_id=
"",
173 bool visible_under_fog =
true,
float submerge = 0.0f,
float z_order = 0);
214 virtual bool in_game()
const {
return false; }
220 virtual const std::set<std::string>&
observers()
const {
static const std::set<std::string> fake_obs = std::set<std::string> ();
return fake_obs; }
250 static bool outside_area(
const SDL_Rect& area,
const int x,
const int y);
276 return {r.x, r.y, int(r.w * zf), int(r.h * zf)};
282 return {int(
p.x * zf), int(
p.y * zf)};
387 void set_theme(
const std::string& new_theme);
418 void draw_report(
const std::string& report_name,
bool test_run =
false);
432 bool invalidate(
const std::set<map_location>& locs);
481 bool scroll(
int xmov,
int ymov,
bool force =
false);
487 bool set_zoom(
unsigned int amount,
const bool validate_value_and_set_index =
true);
519 double add_spacing=0.0,
bool force=
true);
522 void scroll_to_tiles(
const std::vector<map_location>::const_iterator & begin,
523 const std::vector<map_location>::const_iterator & end,
525 bool only_if_possible=
false,
double add_spacing=0.0,
530 bool only_if_possible=
false,
531 double add_spacing=0.0,
bool force=
true)
534 only_if_possible, add_spacing, force);
556 void fade_tod_mask(
const std::string& old,
const std::string& new_);
571 virtual void update()
override;
574 virtual void layout()
override;
577 virtual void render()
override;
580 virtual bool expose(
const rect& region)
override;
627 const announce_options&
options = announce_options());
679 std::weak_ptr<wb::manager>
wb_;
709 const std::string& timeid,
716 static void fill_images_list(
const std::string& prefix, std::vector<std::string>& images);
790 std::vector<animated<image::locator>>
flags_;
846 static void add_submerge_ipf_mod(std::string& image_path,
int image_height,
double submersion_amount,
int shift = 0);
853 const drawing_layer layer,
const std::string& text, std::size_t font_size,
854 color_t color,
double x_in_hex=0.5,
double y_in_hex=0.5);
Class that keeps track of all the keys on the keyboard.
Arrows destined to be drawn on the map.
A config object defines a single node in a WML file, with access to child nodes.
Abstract class for exposing game data that doesn't depend on the GUI, however which for historical re...
virtual const gamemap & map() const =0
virtual const std::vector< team > & teams() const =0
virtual const unit_map & units() const =0
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
arrows_map_t arrows_map_
Maps the list of arrows for each location.
int xpos_
Position of the top-left corner of the viewport, in pixels.
void reset_reports(reports &reports_object)
bool map_screenshot_
Used to indicate to drawing functions that we are doing a map screenshot.
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.
static void add_submerge_ipf_mod(std::string &image_path, int image_height, double submersion_amount, int shift=0)
int viewing_side() const
The 1-based equivalent of the 0-based viewing_team() function.
void update_render_textures()
Ensure render textures are valid and correct.
void toggle_debug_flag(DEBUG_FLAG flag)
static unsigned int last_zoom_
The previous value of zoom_.
void write(config &cfg) const
const unit_map & get_units() const
const display_context & get_disp_context() const
static bool zoom_at_min()
std::map< map_location, std::vector< overlay > > overlay_map
void get_terrain_images(const map_location &loc, const std::string &timeid, TERRAIN_TYPE terrain_type)
void remove_overlay(const map_location &loc)
remove_overlay will remove all overlays on a tile.
virtual bool has_time_area() const
map_location selectedHex_
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
void recalculate_minimap()
Schedule the minimap for recalculation.
void redraw_minimap()
Schedule the minimap to be redrawn.
point get_location(const map_location &loc) const
unsigned int fps_counter_
bool invalidate_locations_in_rect(const SDL_Rect &rect)
invalidate all hexes under the rectangle rect (in screen coordinates)
const 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...
virtual void render() override
Update offscreen render buffers.
void init_flags_for_side_internal(std::size_t side, const std::string &side_color)
void remove_single_overlay(const map_location &loc, const std::string &toDelete)
remove_single_overlay will remove a single overlay from a tile
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.
void fade_tod_mask(const std::string &old, const std::string &new_)
ToD mask smooth fade.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
virtual const time_of_day & get_time_of_day(const map_location &loc=map_location::null_location()) const
void announce(const std::string &msg, const color_t &color=font::GOOD_COLOR, const announce_options &options=announce_options())
Announce a message prominently.
std::list< arrow * > arrows_list_t
drawing_layer
The layers to render something on.
@ LAYER_UNIT_FG
Used for the ellipse in front of the unit.
@ LAYER_MOUSEOVER_BOTTOM
Bottom half of image following the mouse.
@ LAYER_ATTACK_INDICATOR
Layer which holds the attack indicator.
@ LAYER_BORDER
The border of the map.
@ LAYER_UNIT_FIRST
Reserve layers to be selected for WML.
@ LAYER_MOVE_INFO
Movement info (defense%, etc...).
@ LAYER_ACTIONS_NUMBERING
Move numbering for the whiteboard.
@ LAYER_MOUSEOVER_OVERLAY
Mouseover overlay used by editor.
@ LAYER_UNIT_MISSILE_DEFAULT
default layer for missile frames
@ LAYER_TERRAIN_BG
Layer for the terrain drawn behind the unit.
@ LAYER_UNIT_DEFAULT
default layer for drawing units
@ LAYER_FOG_SHROUD
Fog and shroud.
@ LAYER_UNIT_MOVE_DEFAULT
default layer for drawing moving units
@ LAYER_GRID_BOTTOM
Used for the bottom half part of grid image.
@ LAYER_UNIT_BG
Used for the ellipse behind the unit.
@ LAYER_FOOTSTEPS
Footsteps showing path from unit to mouse.
@ LAYER_LINGER_OVERLAY
The overlay used for the linger mode.
@ LAYER_GRID_TOP
Top half part of grid image.
@ LAYER_TERRAIN_FG
Layer for the terrain drawn in front of the unit.
@ LAYER_SELECTED_HEX
Image on the selected unit.
@ LAYER_ARROWS
Arrows from the arrows framework.
@ LAYER_UNIT_BAR
Unit bars and overlays are drawn on this layer (for testing here).
@ LAYER_REACHMAP
"black stripes" on unreachable hexes.
@ LAYER_MOUSEOVER_TOP
Top half of image following the mouse.
double turbo_speed() const
void set_prevent_draw(bool pd)
Prevent the game display from drawing.
int current_frame_sample_
int invalidated_hexes_
Count work done for the debug info displayed under fps.
void adjust_color_overlay(int r, int g, int b)
Add r,g,b to the colors for all images displayed on the map.
bool add_exclusive_draw(const map_location &loc, unit &unit)
Allows a unit to request to be the only one drawn in its hex.
void set_fade(const color_t &color)
void queue_repaint()
Queues repainting to the screen, but doesn't rerender.
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 ...
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
static double get_zoom_factor()
Returns the current zoom factor.
const rect & unit_image_area() const
bool scroll(int xmov, int ymov, bool force=false)
Scrolls the display by xmov,ymov pixels.
bool propagate_invalidation(const std::set< map_location > &locs)
If this set is partially invalidated, invalidate all its hexes.
void clear_redraw_observers()
Clear the redraw observers.
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
const theme::action * action_pressed()
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
void set_theme(const std::string &new_theme)
void rebuild_all()
Rebuild all dynamic terrain.
void change_display_context(const display_context *dc)
void add_redraw_observer(std::function< void(display &)> f)
Adds a redraw observer, a function object to be called when a full rerender is queued.
void clear_exclusive_draws()
Cancels all the exclusive draw requests.
virtual overlay_map & get_overlays()=0
virtual void layout() override
Finalize screen layout.
virtual void highlight_hex(map_location hex)
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
static bool zoom_at_max()
static display * singleton_
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
void render_map_outside_area()
Draw/redraw the off-map background area.
void set_team(std::size_t team, bool observe=false)
Sets the team controlled by the player using the computer.
const 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...
void remove_arrow(arrow &)
@ DEBUG_COORDINATES
Overlays x,y coords on tiles.
@ DEBUG_BENCHMARK
Toggle to continuously redraw the whole map.
@ __NUM_DEBUG_FLAGS
Dummy entry to size the bitmask.
@ DEBUG_NUM_BITMAPS
Overlays number of bitmaps on tiles.
@ DEBUG_FOREGROUND
Separates background and foreground terrain layers.
@ DEBUG_TERRAIN_CODES
Overlays terrain codes on tiles.
void process_reachmap_changes()
void draw_minimap_units()
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.
void invalidate_animations_location(const map_location &loc)
Per-location invalidation called by invalidate_animations() Extra game per-location invalidation (vil...
map_location mouseoverHex_
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
const gamemap & get_map() const
bool set_zoom(bool increase)
Zooms the display in (true) or out (false).
std::map< std::string, rect > reportLocations_
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
texture get_flag(const map_location &loc)
tod_color get_color_overlay() const
void invalidate_all()
Function to invalidate all tiles.
std::map< std::string, config > reports_
std::bitset< __NUM_DEBUG_FLAGS > debug_flags_
Currently set debug flags.
SDL_Rect minimap_location_
map_location get_middle_location() const
void bounds_check_position()
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
void init_flags()
Init the flag list and the team colors used by ~TC.
std::vector< std::shared_ptr< gui::button > > action_buttons_
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.
const rect_of_hexes hexes_under_rect(const SDL_Rect &r) const
Return the rectangular area of hexes overlapped by r (r is in screen coordinates)
void scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE scroll_type, bool force=true)
virtual int playing_side() const
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
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
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
void reload_map()
Updates internals that cache map size.
rect max_map_area() const
Returns the maximum area used for the map regardless to resolution and view size.
halo::manager & get_halo_manager()
bool tile_fully_on_screen(const map_location &loc) const
Check if a tile is fully visible on screen.
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...
std::map< map_location, arrows_list_t > arrows_map_t
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.
bool is_blindfolded() const
std::vector< texture > terrain_image_vector_
std::vector< std::string > fog_images_
virtual bool in_editor() const
int fps_handle_
Handle for the label which displays frames per second.
bool invalidate_visible_locations_in_rect(const SDL_Rect &rect)
std::map< map_location, std::string > exclusive_unit_draw_requests_t
std::vector< std::function< void(display &)> > redraw_observers_
void read(const config &cfg)
const theme::menu * menu_pressed()
const std::unique_ptr< terrain_builder > builder_
virtual const map_location & displayed_unit_hex() const
Virtual functions shadowed in game_display.
std::vector< animated< image::locator > > flags_
Animated flags for each team.
const map_location & selected_hex() const
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
static void fill_images_list(const std::string &prefix, std::vector< std::string > &images)
void draw_report(const std::string &report_name, bool test_run=false)
Draw the specified report.
std::set< map_location > invalidated_
std::vector< texture > get_fog_shroud_images(const map_location &loc, image::TYPE image_type)
void fade_to(const color_t &color, int duration)
Screen fade.
void queue_rerender()
Marks everything for rendering including all tiles and sidebar.
std::string remove_exclusive_draw(const map_location &loc)
Cancels an exclusive draw request.
bool invalidateGameStatus_
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
void drawing_buffer_commit()
Draws the drawing_buffer_ and clears it.
rect map_area() const
Returns the area used for the map.
void draw_panel(const theme::panel &panel)
void set_playing_team(std::size_t team)
set_playing_team sets the team whose turn it currently is
std::chrono::seconds fps_start_
static int hex_width()
Function which returns the width of a hex in pixels, up to where the next hex starts.
void set_debug_flag(DEBUG_FLAG flag, bool value)
void reset_standing_animations()
bool animate_water_
Local version of preferences::animate_water, used to detect when it's changed.
bool debug_flag_set(DEBUG_FLAG flag) const
void toggle_default_zoom()
Sets the zoom amount to the default.
virtual rect get_clip_rect() const
Get the clipping rectangle for drawing.
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.
reports * reports_object_
bool draw_reports(const rect ®ion)
Draw all reports in the given region.
void invalidate_animations()
Function to invalidate animated terrains and units which may have changed.
virtual rect screen_location() override
Return the current draw location of the display, on the screen.
static const std::string & get_variant(const std::vector< std::string > &variants, const map_location &loc)
virtual bool expose(const rect ®ion) override
Paint the indicated region to the screen.
std::list< draw_helper > drawing_buffer_
std::vector< std::shared_ptr< gui::button > > menu_buttons_
virtual void update() override
Update animations and internal state.
void draw()
Perform rendering of invalidated items.
int get_location_y(const map_location &loc) const
const rect & minimap_area() const
mapx is the width of the portion of the display which shows the game area.
events::generic_event scroll_event_
Event raised when the map is being scrolled.
bool show_everything() const
terrain_builder & get_builder()
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
virtual bool in_game() const
const rect & palette_area() const
std::map< map_location, unsigned int > reach_map
static display * get_singleton()
Returns the display object if a display object exists.
std::vector< std::tuple< int, int, int > > fps_history_
void reinit_flags_for_team(const team &)
Rebuild the flag list (not team colors) for a single side.
void draw_minimap()
Actually draw the minimap.
texture front_
Render textures, for intermediate rendering.
const map_location & mouseover_hex() const
void update_arrow(arrow &a)
Called by arrow objects when they change.
void draw_label(const theme::label &label)
const std::unique_ptr< fake_unit_manager > fake_unit_man_
const display_context * dc_
bool animate_map_
Local cache for preferences::animate_map, since it is constantly queried.
static point scaled_to_zoom(const point &p)
std::vector< std::string > shroud_images_
void set_view_locked(bool value)
Sets whether the map view is locked (e.g.
static rect scaled_to_zoom(const SDL_Rect &r)
Scale the width and height of a rect by the current zoom factor.
virtual const std::set< std::string > & observers() const
static unsigned int zoom_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e....
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
void blindfold(bool flag)
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Update the given report.
std::weak_ptr< wb::manager > wb_
const std::unique_ptr< map_labels > map_labels_
boost::circular_buffer< unsigned > frametimes_
uint32_t last_frame_finished_
void set_diagnostic(const std::string &msg)
virtual void select_hex(map_location hex)
const std::vector< team > & get_teams() const
std::map< std::string, texture > reportSurfaces_
std::size_t playing_team() const
The playing team is the team whose turn it is.
bool draw_all_panels(const rect ®ion)
Redraws all panels intersecting the given region.
void add_overlay(const map_location &loc, const std::string &image, const std::string &halo="", const std::string &team_name="", const std::string &item_id="", bool visible_under_fog=true, float submerge=0.0f, float z_order=0)
Functions to add and remove overlays from locations.
display(const display_context *dc, std::weak_ptr< wb::manager > wb, reports &reports_object, const std::string &theme_id, const config &level)
Manages a list of fake units for the display object.
Encapsulates the map of the game.
A top-level drawable item (TLD), such as a window.
This class stores all the data for a single 'side' (in game nomenclature).
The class terrain_builder is constructed from a config object, and a gamemap object.
Wrapper class to encapsulate creation and management of an SDL_Texture.
Container associating units to locations.
This class represents a single unit of a specific type.
This class is the frontend of the whiteboard framework for the rest of the Wesnoth code.
Declarations for File-IO.
std::string label
What to show in the filter's drop-down list.
Functions to load and save images from/to disk.
TYPE
Used to specify the rendering format of images.
Unit and team statistics.
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Contains the SDL_Rect helper code.
This file contains object "key", which is used to store information about keys while annotation parsi...
blindfold(display &d, bool lock=true)
The basic class for representing 8-bit RGB or RGBA colour values.
Holds options for calls to function 'announce' (announce).
bool discard_previous
An announcement according these options should replace the previous announce (typical of fast announc...
int lifetime
Lifetime measured in milliseconds.
Helper for rendering the map by ordering draw operations.
std::function< void(const rect &)> do_draw
Handles the actual drawing at this location.
const uint32_t key
Controls the ordering of draw calls by layer and location.
rect dest
The screen coordinates for the specified hex.
bool operator<(const draw_helper &rhs) const
very simple iterator to walk into the rect_of_hexes
const map_location & operator*() const
std::forward_iterator_tag iterator_category
iterator & operator++()
increment y first, then when reaching bottom, increment x
const rect_of_hexes & rect_
bool operator==(const iterator &that) const
const map_location * pointer
bool operator!=(const iterator &that) const
iterator(const map_location &loc, const rect_of_hexes &rect)
const map_location & reference
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
Encapsulates the map of the game.
static const map_location & null_location()
An abstract description of a rectangle with integer coordinates.
Object which defines a time of day with associated bonuses, image, sounds etc.
Small struct to store and manipulate ToD color adjusts.
Definitions related to theme-support.