63 #include "widgets/button.hpp"
65 #include <boost/circular_buffer.hpp>
100 std::weak_ptr<wb::manager>
wb,
102 const std::string& theme_id,
218 virtual bool in_game()
const {
return false; }
223 virtual const std::set<std::string>&
observers()
const {
static const std::set<std::string> fake_obs = std::set<std::string> ();
return fake_obs; }
253 static bool outside_area(
const SDL_Rect& area,
const int x,
const int y);
279 return {r.x, r.y, int(r.w * zf), int(r.h * zf)};
285 return {int(
p.x * zf), int(
p.y * zf)};
391 void set_theme(
const std::string& new_theme);
427 void draw_report(
const std::string& report_name,
bool test_run =
false);
441 bool invalidate(
const std::set<map_location>& locs);
490 bool scroll(
const point& amount,
bool force =
false);
496 bool set_zoom(
unsigned int amount,
const bool validate_value_and_set_index =
true);
528 double add_spacing=0.0,
bool force=
true);
533 bool only_if_possible=
false,
534 double add_spacing=0.0,
bool force=
true);
566 void fade_tod_mask(
const std::string& old,
const std::string& new_);
569 void fade_to(
const color_t& color,
const std::chrono::milliseconds& duration);
581 virtual void update()
override;
584 virtual void layout()
override;
587 virtual void render()
override;
590 virtual bool expose(
const rect& region)
override;
637 const announce_options& options = announce_options());
686 std::weak_ptr<wb::manager>
wb_;
718 const std::string& timeid,
725 static void fill_images_list(
const std::string& prefix, std::vector<std::string>& images);
797 std::vector<animated<image::locator>>
flags_;
809 const drawing_layer layer,
const std::string& text, std::size_t font_size,
810 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...
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
const team & viewing_team() const
void unhide_buttons()
Unhide theme buttons so they draw again.
void set_viewing_team_index(std::size_t team, bool observe=false)
Sets the team controlled by the player using the computer.
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.
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_.
std::size_t viewing_team_index_
void write(config &cfg) 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_
void recalculate_minimap()
Schedule the minimap for recalculation.
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.
void redraw_minimap()
Schedule the minimap to be redrawn.
point get_location(const map_location &loc) const
Functions to get the on-screen positions of hexes.
unsigned int fps_counter_
bool invalidate_locations_in_rect(const SDL_Rect &rect)
invalidate all hexes under the rectangle rect (in screen coordinates)
virtual void render() override
Update offscreen render buffers.
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.
boost::circular_buffer< std::chrono::milliseconds > frametimes_
void fade_tod_mask(const std::string &old, const std::string &new_)
ToD mask smooth fade.
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.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
void set_playing_team_index(std::size_t team)
sets the team whose turn it currently is
const team & playing_team() const
void announce(const std::string &msg, const color_t &color=font::GOOD_COLOR, const announce_options &options=announce_options())
Announce a message prominently.
double turbo_speed() const
int current_frame_sample_
void scroll_to_xy(const point &screen_coordinates, SCROLL_TYPE scroll_type, bool force=true)
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.
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 ...
static double get_zoom_factor()
Returns the current zoom factor.
const rect & unit_image_area() const
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()
static submerge_data get_submerge_data(const rect &dest, double submerge, const point &size, uint8_t alpha, bool hreverse, bool vreverse)
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 set_prevent_draw(bool pd=true)
Prevent the game display from drawing.
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.
std::size_t playing_team_index() const
The playing team is the team whose turn it is.
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.
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 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.
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.
void draw_overlays_at(const map_location &loc)
std::chrono::steady_clock::time_point fps_start_
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_
point viewport_origin_
Position of the top-left corner of the viewport, in pixels.
map_location get_middle_location() const
void bounds_check_position()
std::function< rect(rect)> minimap_renderer_
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.
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...
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_
void fade_to(const color_t &color, const std::chrono::milliseconds &duration)
Screen fade.
virtual bool in_editor() const
int fps_handle_
Handle for the label which displays frames per second.
const display_context & context() const
bool invalidate_visible_locations_in_rect(const SDL_Rect &rect)
std::map< map_location, std::list< arrow * > > arrows_map_
Maps the list of arrows for each location.
std::map< map_location, std::string > exclusive_unit_draw_requests_t
void add_overlay(const map_location &loc, overlay &&ov)
Functions to add and remove overlays from locations.
std::vector< std::function< void(display &)> > redraw_observers_
void read(const config &cfg)
const theme::menu * menu_pressed()
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)
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
rect get_location_rect(const map_location &loc) const
Returns the on-screen rect corresponding to a loc.
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_
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)
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)
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()
utils::optional< std::chrono::steady_clock::time_point > last_frame_finished_
bool animate_water_
Local version of prefs::get().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.
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.
void hide_buttons()
Hide theme buttons so they don't draw.
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.
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::size_t playing_team_index_
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.
bool viewing_team_is_playing() const
std::size_t viewing_team_index() const
The viewing team is the team currently viewing the game.
const map_location & mouseover_hex() 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...
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 prefs::get().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.
bool scroll(const point &amount, bool force=false)
Scrolls the display by amount pixels.
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_
void set_diagnostic(const std::string &msg)
virtual void select_hex(map_location hex)
std::map< std::string, texture > reportSurfaces_
bool draw_all_panels(const rect ®ion)
Redraws all panels intersecting the given region.
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.
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.
std::string label
What to show in the filter's drop-down list.
const std::string & get_direction(std::size_t n)
void rect(const SDL_Rect &rect)
Draw a rectangle.
TYPE
Used to specify the rendering format of images.
Unit and team statistics.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
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...
std::chrono::milliseconds 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.
std::array< SDL_Vertex, 4 > alpha_verts
Object which defines a time of day with associated bonuses, image, sounds etc.
Small struct to store and manipulate ToD color adjusts.
static map_location::direction n
Definitions related to theme-support.