33 #ifndef DISPLAY_H_INCLUDED
34 #define DISPLAY_H_INCLUDED
63 #include "widgets/button.hpp"
64 #include "widgets/slider.hpp"
69 #include <boost/weak_ptr.hpp>
70 #include <boost/scoped_ptr.hpp>
152 bool visible_under_fog =
true);
177 {
return 0xFF000000 | (red << 16) | (green << 8) |
blue; }
179 {
return (color & 0x00FF0000) >> 16;}
181 {
return (color & 0x0000FF00) >> 8;}
183 {
return (color & 0x000000FF) ;}
207 virtual bool in_game()
const {
return false; }
213 virtual const std::set<std::string>&
observers()
const {
static const std::set<std::string> fake_obs = std::set<std::string> ();
return fake_obs; }
252 bool outside_area(
const SDL_Rect& area,
const int x,
const int y)
const;
420 bool invalidate(
const std::set<map_location>& locs);
472 static void sunset(
const size_t delay = 0);
529 bool scroll(
int xmov,
int ymov,
bool force =
false);
570 double add_spacing=0.0,
bool force=
true);
573 void scroll_to_tiles(
const std::vector<map_location>::const_iterator & begin,
574 const std::vector<map_location>::const_iterator &
end,
576 bool only_if_possible=
false,
double add_spacing=0.0,
581 bool only_if_possible=
false,
582 double add_spacing=0.0,
bool force=
true)
585 only_if_possible, add_spacing, force);
608 void draw(
bool update);
610 void draw(
bool update,
bool force);
665 boost::weak_ptr<wb::manager>
wb_;
736 const int xpos,
const int ypos);
811 std::map<std::string, sdl::timage> reportImages_;
817 std::vector<std::shared_ptr<gui::zoom_slider>>
sliders_;
855 std::vector<animated<image::locator> >
flags_;
926 bool hreverse=
false,
bool greyscale=
false,
928 double blend_ratio=0,
double submerged=0.0,
bool vreverse =
false);
943 bool hreverse=
false,
bool greyscale=
false,
945 double blend_ratio=0,
double submerged=0.0,
bool vreverse =
false);
954 SDL_Color
color,
double x_in_hex=0.5,
double y_in_hex=0.5);
1008 const int x,
const int y,
const sdl::timage& image)
1009 :
x_(x),
y_(y), images_(1, image),
key_(loc, layer)
1013 const int x,
const int y,
1014 const std::vector<sdl::timage>&
images)
1015 :
x_(x),
y_(y), images_(images),
key_(loc, layer)
1020 const SDL_Rect&
clip)
1026 const int x,
const int y,
const std::vector<surface>&
surf,
1027 const SDL_Rect&
clip)
1036 std::vector<sdl::timage> &
images() {
return images_; }
1048 std::vector<sdl::timage> images_;
1066 const sdl::timage&
img);
1070 const std::vector<sdl::timage> &imgs);
1081 const SDL_Rect &clip = SDL_Rect());
1085 const std::vector<surface> &surf,
1086 const SDL_Rect &clip = SDL_Rect());
1101 void draw_panel_image(SDL_Rect *clip =
nullptr);
1169 bool update_panel_image_;
1170 sdl::timage panel_image_;
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
TYPE
UNSCALED : image will be drawn "as is" without changing size, even in case of redraw SCALED_TO_ZOOM :...
void drawing_buffer_add(const tdrawing_layer layer, const map_location &loc, int x, int y, const surface &surf, const SDL_Rect &clip=SDL_Rect())
Add an item to the drawing buffer.
static void sunset(const size_t delay=0)
Debug function to toggle the "sunset" mode.
virtual const std::set< std::string > & observers() const
void drawing_buffer_commit()
Draws the drawing_buffer_ and clears it.
boost::scoped_ptr< fake_unit_manager > fake_unit_man_
void draw_minimap_units()
Don't draw to this layer it's a dummy to size the vector.
std::set< map_location > previous_invalidated_
virtual void pre_draw()
Called near the beginning of each draw() call.
halo::manager & get_halo_manager()
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
virtual void select_hex(map_location hex)
static const unsigned int max_layer_group
reports * reports_object_
Used for the bottom half part of grid image.
virtual void handle_window_event(const SDL_Event &event)
static display * get_singleton()
Returns the display object if a display object exists.
bool operator==(const iterator &that) const
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
Small struct to store and manipulate ToD colors.
In order to render a hex properly it needs to be rendered per row.
std::shared_ptr< gui::zoom_slider > find_slider(const std::string &id)
std::vector< surface > surf_
surface(s) to render.
virtual bool in_editor() const
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 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_draw_terrain_codes(bool value)
Setter for the terrain code debug overlay on tiles.
void invalidate_animations()
Function to invalidate animated terrains and units which may have changed.
virtual void draw_sidebar()
Called near the end of a draw operation, derived classes can use this to render a specific sidebar...
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
void draw_wrap(bool update, bool force)
boost::weak_ptr< wb::manager > wb_
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.
std::map< surface, SDL_Rect > energy_bar_rects_
bool get_draw_terrain_codes() const
Getter for the terrain code debug overlay on tiles.
const std::string & get_variant(const std::vector< std::string > &variants, const map_location &loc) const
static void toggle_benchmark()
Toggle to continuously redraw the screen.
const SDL_Rect & mini_map_location(const SDL_Rect &screen) const
void change_display_context(const display_context *dc)
const SDL_Rect & minimap_area() const
bool operator!=(const iterator &that) const
const SDL_Rect & clip() const
int y_
y screen coordinate to render at.
GLuint GLuint GLsizei GLenum type
void draw_init()
Initiate a redraw.
void set_turbo(const bool turbo)
Set/Get whether 'turbo' mode is on.
void set_default_zoom()
Sets the zoom amount to the default.
void set_idle_anim_rate(int rate)
void clear_exclusive_draws()
Cancels all the exclusive draw requests.
Top half of image following the mouse.
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_
Used for the ellipse in front of the unit.
void draw_all_panels()
redraw all panels associated with the map display
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
map_location mouseoverHex_
void init_flags()
Init the flag list and the team colors used by ~TC.
Manages a list of fake units for the display object.
bool draw_coordinates_
Debug flag - overlay x,y coords on tiles.
Arrows from the arrows framework.
tblit(const tdrawing_layer layer, const map_location &loc, const int x, const int y, const surface &surf, const SDL_Rect &clip)
void redraw_everything()
Invalidates entire screen, including all tiles and sidebar.
int fps_handle_
Handle for the label which displays frames per second.
GLenum GLsizei GLenum GLenum const GLvoid * image
The class terrain_builder is constructed from a config object, and a gamemap object.
virtual bool has_time_area() const
Footsteps showing path from unit to mouse.
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...
Layer for the terrain drawn behind the unit.
Movement info (defense%, etc...).
void reset_halo_manager()
std::map< map_location, std::string > exclusive_unit_draw_requests_t
virtual void draw_border(const map_location &loc, const int xpos, const int ypos)
Draws the border tile overlay.
bool tile_nearly_on_screen(const map_location &loc) const
Checks if location loc or one of the adjacent tiles is visible on screen.
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...
Layer which holds the attack indicator.
const rect_of_hexes & rect_
double get_zoom_factor() const
Returns the current zoom factor.
iterator & operator++()
increment y first, then when reaching bottom, increment x
std::vector< std::function< void(display &)> > redraw_observers_
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
bool tile_fully_on_screen(const map_location &loc)
Check if a tile is fully visible on screen.
std::vector< surface > get_terrain_images(const map_location &loc, const std::string &timeid, image::TYPE type, TERRAIN_TYPE terrain_type)
void clear_mouseover_hex_overlay()
GLint GLint GLint GLint GLint GLint y
map_location selectedHex_
void draw_text_in_hex(const map_location &loc, const tdrawing_layer layer, const std::string &text, size_t font_size, SDL_Color color, double x_in_hex=0.5, double y_in_hex=0.5)
Draw text on a hex.
virtual int playing_side() const
static Uint8 blue(Uint32 color)
static display * singleton_
virtual void draw()
Draws invalidated items.
terrain_builder & get_builder()
events::generic_event & scroll_event() const
Expose the event, so observers can be notified about map scrolling.
void enable_menu(const std::string &item, bool enable)
Finds the menu which has a given item in it, and enables or disables it.
Rectangular area of hexes, allowing to decide how the top and bottom edges handles the vertical shift...
double idle_anim_rate() const
events::generic_event & complete_redraw_event()
void clear_redraw_observers()
Clear the redraw observers.
virtual bool in_game() const
void redraw_minimap()
Schedule the minimap to be redrawn.
virtual const gamemap & map() const =0
std::vector< surface > get_fog_shroud_images(const map_location &loc, image::TYPE image_type)
void remove_arrow(arrow &)
Unit bars and overlays are drawn on this layer (for testing here).
Layer for the terrain drawn in front of the unit.
Top half part of grid image.
void update_display()
Copy the backbuffer to the framebuffer.
Unit and team statistics.
Mouseover overlay used by editor.
int get_location_y(const map_location &loc) const
very simple iterator to walk into the rect_of_hexes
virtual const tod_manager & get_tod_man() const
This is implemented properly in game_display. The display:: impl could be pure virtual here but we de...
const SDL_Color GOOD_COLOR
"black stripes" on unreachable hexes.
std::vector< std::shared_ptr< gui::button > > action_buttons_
surface map_screenshot_surf_
static const tdrawing_layer layer_groups[]
const theme::action * action_pressed()
GLdouble GLdouble GLdouble b
std::vector< std::string > shroud_images_
void draw_image_for_report(surface &img, SDL_Rect &rect)
Object which defines a time of day with associated bonuses, image, sounds etc.
void blindfold(bool flag)
tdrawing_layer
The layers to render something on.
static Uint8 green(Uint32 color)
events::generic_event complete_redraw_event_
notify observers that the screen has been redrawn completely atm this is used for replay_controller t...
void parse_team_overlays()
Check the overlay_map for proper team-specific overlays to be displayed/hidden.
This class stores all the data for a single 'side' (in game nomenclature).
virtual const map_location & displayed_unit_hex() const
Virtual functions shadowed in game_display.
const map_location & mouseover_hex() const
std::list< tblit > tdrawing_buffer
size_t playing_team() const
The playing team is the team whose turn it is.
const theme::menu * menu_pressed()
GLenum GLenum GLuint GLint GLint layer
Arrows destined to be drawn on the map.
bool invalidate_visible_locations_in_rect(const SDL_Rect &rect)
void recalculate_minimap()
Schedule the minimap for recalculation.
void scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE scroll_type, bool force=true)
const map_location & reference
virtual const game_data * get_game_data() const
GLsizei const GLfloat * value
bool get_draw_coordinates() const
Getter for the x,y debug overlay on tiles.
static Uint8 red(Uint32 color)
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.
virtual image::TYPE get_image_type(const map_location &loc)
This class is the frontend of the whiteboard framework for the rest of the Wesnoth code...
GLboolean GLboolean GLboolean GLboolean a
Encapsulates the map of the game.
SDL_Rect minimap_location_
void render_image(int x, int y, const display::tdrawing_layer drawing_layer, const map_location &loc, surface image, bool hreverse=false, bool greyscale=false, fixed_t alpha=ftofxp(1.0), Uint32 blendto=0, double blend_ratio=0, double submerged=0.0, bool vreverse=false)
Draw an image at a certain location.
int w() const
the dimensions of the display.
const SDL_Rect & max_map_area() const
Returns the maximum area used for the map regardless to resolution and view size. ...
GLclampf GLclampf GLclampf alpha
bool operator<(const drawing_buffer_key &rhs) const
const SDL_Rect & unit_image_location(const SDL_Rect &screen) const
default layer for missile frames
default layer for drawing moving units
void bounds_check_position()
virtual void post_draw()
Called at the very end of each draw() call.
bool invalidateGameStatus_
void update_arrow(arrow &a)
Called by arrow objects when they change.
virtual const unit_map & units() const =0
int nextDraw_
Holds the tick count for when the next drawing event is scheduled.
void set_mouseover_hex_overlay(const surface &image)
mouseover_hex_overlay_ require a prerendered surface and is drawn underneath the mouse's location ...
virtual const time_of_day & get_time_of_day(const map_location &loc=map_location::null_location()) const
static const map_location & null_location()
void invalidate_all()
Function to invalidate all tiles.
bool is_blindfolded() const
int invalidated_hexes_
Count work done for the debug info displayed under fps.
bool draw_terrain_codes_
Debug flag - overlay terrain codes on tiles.
const SDL_Rect & palette_area() const
tdrawing_buffer drawing_buffer_
const std::string ¶meters float amount
const unit_map & get_units() const
int x_
x screen coordinate to render at.
void write(config &cfg) const
Encapsulates the map of the game.
Used for the ellipse behind the unit.
double turbo_speed() const
Reserve layers to be selected for WML.
boost::scoped_ptr< terrain_builder > builder_
default layer for drawing units
boost::scoped_ptr< map_labels > map_labels_
void process_reachmap_changes()
virtual void handle_event(const SDL_Event &)
surface & get_screen_surface()
return the screen surface or the surface used for map_screenshot.
const SDL_Rect & palette_location(const SDL_Rect &screen) const
void set_playing_team(size_t team)
set_playing_team sets the team whose turn it currently is
SDL_Rect screen_area() const
virtual const std::vector< team > & teams() const =0
Move numbering for the whiteboard.
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.
int hex_width() const
Function which returns the width of a hex in pixels, up to where the next hex starts.
virtual void highlight_hex(map_location hex)
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue)
std::vector< std::shared_ptr< gui::button > > menu_buttons_
Contains a wrapper class for the GPU_Image class.
void set_diagnostic(const std::string &msg)
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.
void invalidate_animations_location(const map_location &loc)
Per-location invalidation called by invalidate_animations() Extra game per-location invalidation (vil...
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
blindfold(display &d, bool lock=true)
static Uint32 max_rgb(Uint32 first, Uint32 second)
void set_turbo_speed(const double speed)
drawing_buffer_key(const map_location &loc, tdrawing_layer layer)
void read(const config &cfg)
Definitions related to theme-support.
void init_flags_for_side_internal(size_t side, const std::string &side_color)
display(const display_context *dc, CVideo &video, boost::weak_ptr< wb::manager > wb, reports &reports_object, const config &theme_cfg, const config &level, bool auto_join=true)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
GLint GLint GLint GLint GLint x
bool invalidate_locations_in_rect(const SDL_Rect &rect)
invalidate all hexes under the rectangle rect (in screen coordinates)
bool add_exclusive_draw(const map_location &loc, unit &unit)
Allows a unit to request to be the only one drawn in its hex.
const map_location * pointer
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
const SDL_Rect & unit_image_area() const
GLdouble GLdouble GLdouble r
virtual const SDL_Rect & get_clip_rect()
Get the clipping rectangle for drawing.
The overlay used for the linger mode.
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
Helper structure for rendering the terrains.
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) ...
std::list< arrow * > arrows_list_t
std::vector< std::string > fog_images_
const rect_of_hexes get_visible_hexes() const
Returns the rectangular area of visible hexes.
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
std::map< map_location, unsigned int > reach_map
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)
Functions to add and remove overlays from locations.
static std::map< std::string, std::string > images
const SDL_Rect & map_area() const
Returns the area used for the map.
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.
void reload_map()
Updates internals that cache map size.
SDL_Rect clip_
The clipping area of the source if omitted the entire source is used.
const gamemap & get_map() const
std::map< std::string, surface > reportSurfaces_
std::set< map_location > invalidated_
void clear_screen()
Clear the screen contents.
Image on the selected unit.
void drawing_buffer_clear()
Clears the drawing buffer.
const SDL_Rect & main_map_location(const SDL_Rect &screen) const
std::map< std::string, config > reports_
const display_context * dc_
std::forward_iterator_tag iterator_category
bool show_everything() const
this module manages the cache of images.
void update_tod()
Add r,g,b from tod_manager to the map.
gui::button::TYPE string_to_button_type(std::string type)
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
void add_redraw_observer(std::function< void(display &)> f)
Adds a redraw observer, a function object to be called when redraw_everything is used.
CVideo & video()
Gets the underlying screen object.
Container associating units to locations.
void reinit_flags_for_side(size_t side)
Rebuild the flag list (not team colors) for a single side.
Bottom half of image following the mouse.
const display_context & get_disp_context() const
bool outside_area(const SDL_Rect &area, const int x, const int y) const
Check if the bbox of the hex at x,y has pixels outside the area rectangle.
void fill_images_list(const std::string &prefix, std::vector< std::string > &images)
std::vector< animated< image::locator > > flags_
Animated flags for each team.
size_t viewing_team() const
The viewing team is the team currently viewing the game.
const map_location & operator*() const
boost::scoped_ptr< halo::manager > halo_man_
A config object defines a single node in a WML file, with access to child nodes.
void refresh_report(std::string const &report_name, const config *new_cfg=nullptr)
Redraws the specified report (if anything has changed).
Class that keeps track of all the keys on the keyboard.
void remove_single_overlay(const map_location &loc, const std::string &toDelete)
remove_single_overlay will remove a single overlay from a tile
int hex_size() const
Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right ...
surface get_flag(const map_location &loc)
std::vector< std::shared_ptr< gui::zoom_slider > > sliders_
void announce(const std::string &msg, const SDL_Color &color=font::GOOD_COLOR)
Announce a message prominently.
bool operator<(const tblit &rhs) const
bool scroll(int xmov, int ymov, bool force=false)
Scrolls the display by xmov,ymov pixels.
void remove_overlay(const map_location &loc)
remove_overlay will remove all overlays on a tile.
const std::vector< team > & get_teams() const
bool animate_map_
Local cache for preferences::animate_map, since it is constantly queried.
static void toggle_debug_foreground()
Toggle to debug foreground terrain.
GLsizei const GLcharARB ** string
virtual game_lua_kernel * get_lua_kernel() const
TODO: display should not work as a filter context, this was only done for expedience so that the unit...
std::multimap< map_location, overlay > overlay_map
void reset_reports(reports &reports_object)
std::shared_ptr< gui::button > find_menu_button(const std::string &id)
const map_location & selected_hex() const
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
std::string remove_exclusive_draw(const map_location &loc)
Cancels an exclusive draw request.
void rebuild_all()
Rebuild all dynamic terrain.
bool set_zoom(int amount, bool absolute=false)
Zooms the display by the specified amount.
bool propagate_invalidation(const std::set< map_location > &locs)
If this set is partially invalidated, invalidate all its hexes.
void replace_overlay_map(overlay_map *overlays)
bool screenshot(const std::string &filename, bool map_screenshot=false)
Save a (map-)screenshot and return whether the operation succeeded.
const std::vector< surface > & surf() const
void set_team(size_t team, bool observe=false)
Sets the team controlled by the player using the computer.
tblit(const tdrawing_layer layer, const map_location &loc, const int x, const int y, const std::vector< surface > &surf, const SDL_Rect &clip)