#include <editor_display.hpp>
Public Member Functions | |
editor_display (const display_context *dc, CVideo &video, reports &reports_object, const config &theme_cfg, const config &level) | |
bool | in_editor () const |
void | add_brush_loc (const map_location &hex) |
void | set_brush_locs (const std::set< map_location > &hexes) |
void | clear_brush_locs () |
void | remove_brush_loc (const map_location &hex) |
const editor_map & | map () const |
void | rebuild_terrain (const map_location &loc) |
Public Member Functions inherited from display | |
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) | |
virtual | ~display () |
bool | show_everything () const |
const gamemap & | get_map () const |
const std::vector< team > & | get_teams () const |
size_t | playing_team () const |
The playing team is the team whose turn it is. More... | |
bool | team_valid () const |
size_t | viewing_team () const |
The viewing team is the team currently viewing the game. More... | |
int | viewing_side () const |
void | set_team (size_t team, bool observe=false) |
Sets the team controlled by the player using the computer. More... | |
void | set_playing_team (size_t team) |
set_playing_team sets the team whose turn it currently is More... | |
void | clear_exclusive_draws () |
Cancels all the exclusive draw requests. More... | |
const unit_map & | get_units () const |
bool | add_exclusive_draw (const map_location &loc, unit &unit) |
Allows a unit to request to be the only one drawn in its hex. More... | |
std::string | remove_exclusive_draw (const map_location &loc) |
Cancels an exclusive draw request. More... | |
void | parse_team_overlays () |
Check the overlay_map for proper team-specific overlays to be displayed/hidden. More... | |
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. More... | |
void | remove_overlay (const map_location &loc) |
remove_overlay will remove all overlays on a tile. More... | |
void | remove_single_overlay (const map_location &loc, const std::string &toDelete) |
remove_single_overlay will remove a single overlay from a tile More... | |
void | reload_map () |
Updates internals that cache map size. More... | |
void | change_display_context (const display_context *dc) |
const display_context & | get_disp_context () const |
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 decide not to. More... | |
virtual const game_data * | get_game_data () const |
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 animation code can have a convenient and correct filter context readily available. a more correct solution is most likely to pass it a filter context from unit_animator when it needs to be matched. (it's not possible to store filter contexts with animations, because animations are cached across scenarios.) Note that after these lines which return nullptr, unit filters used in animations will not be able to make use of wml variables or lua scripting (but the latter was a bad idea anyways because it would be slow to constantly recompile the script.) More... | |
void | reset_halo_manager () |
void | reset_halo_manager (halo::manager &hm) |
halo::manager & | get_halo_manager () |
void | update_tod () |
Add r,g,b from tod_manager to the map. More... | |
void | adjust_color_overlay (int r, int g, int b) |
Add r,g,b to the colors for all images displayed on the map. More... | |
CVideo & | video () |
Gets the underlying screen object. More... | |
surface & | get_screen_surface () |
return the screen surface or the surface used for map_screenshot. More... | |
virtual bool | in_game () const |
virtual const map_location & | displayed_unit_hex () const |
Virtual functions shadowed in game_display. More... | |
virtual int | playing_side () const |
virtual const std::set < std::string > & | observers () const |
int | w () const |
the dimensions of the display. More... | |
int | h () const |
height More... | |
const SDL_Rect & | minimap_area () const |
const SDL_Rect & | palette_area () const |
const SDL_Rect & | unit_image_area () const |
SDL_Rect | screen_area () const |
const SDL_Rect & | max_map_area () const |
Returns the maximum area used for the map regardless to resolution and view size. More... | |
const SDL_Rect & | map_area () const |
Returns the area used for the map. More... | |
const SDL_Rect & | map_outside_area () const |
Returns the available area for a map, this may differ from the above. More... | |
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. More... | |
int | hex_width () const |
Function which returns the width of a hex in pixels, up to where the next hex starts. More... | |
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 edge). More... | |
double | get_zoom_factor () const |
Returns the current zoom factor. More... | |
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 corresponds to. More... | |
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 corresponds to. More... | |
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 mouse is currently over, or an invalid location if the mouse isn't over the minimap. More... | |
const map_location & | selected_hex () const |
const map_location & | mouseover_hex () const |
virtual void | select_hex (map_location hex) |
virtual void | highlight_hex (map_location hex) |
void | invalidate_game_status () |
Function to invalidate the game status displayed on the sidebar. More... | |
int | get_location_x (const map_location &loc) const |
Functions to get the on-screen positions of hexes. More... | |
int | get_location_y (const map_location &loc) const |
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) More... | |
const rect_of_hexes | get_visible_hexes () const |
Returns the rectangular area of visible hexes. More... | |
bool | shrouded (const map_location &loc) const |
Returns true if location (x,y) is covered in shroud. More... | |
bool | fogged (const map_location &loc) const |
Returns true if location (x,y) is covered in fog. More... | |
void | set_grid (const bool grid) |
Determines whether a grid should be overlayed on the game board. More... | |
bool | get_draw_coordinates () const |
Getter for the x,y debug overlay on tiles. More... | |
void | set_draw_coordinates (bool value) |
Setter for the x,y debug overlay on tiles. More... | |
bool | get_draw_terrain_codes () const |
Getter for the terrain code debug overlay on tiles. More... | |
void | set_draw_terrain_codes (bool value) |
Setter for the terrain code debug overlay on tiles. More... | |
bool | screenshot (const std::string &filename, bool map_screenshot=false) |
Save a (map-)screenshot and return whether the operation succeeded. More... | |
void | redraw_everything () |
Invalidates entire screen, including all tiles and sidebar. More... | |
void | add_redraw_observer (std::function< void(display &)> f) |
Adds a redraw observer, a function object to be called when redraw_everything is used. More... | |
void | clear_redraw_observers () |
Clear the redraw observers. More... | |
theme & | get_theme () |
std::shared_ptr< gui::button > | find_action_button (const std::string &id) |
Retrieves a pointer to a theme UI button. More... | |
std::shared_ptr< gui::button > | find_menu_button (const std::string &id) |
std::shared_ptr< gui::zoom_slider > | find_slider (const std::string &id) |
gui::button::TYPE | string_to_button_type (std::string type) |
void | create_buttons () |
void | layout_buttons () |
void | render_buttons () |
void | invalidate_theme () |
void | refresh_report (std::string const &report_name, const config *new_cfg=nullptr) |
Redraws the specified report (if anything has changed). More... | |
void | draw_minimap_units () |
void | invalidate_all () |
Function to invalidate all tiles. More... | |
bool | invalidate (const map_location &loc) |
Function to invalidate a specific tile for redrawing. More... | |
bool | invalidate (const std::set< map_location > &locs) |
bool | propagate_invalidation (const std::set< map_location > &locs) |
If this set is partially invalidated, invalidate all its hexes. More... | |
bool | invalidate_locations_in_rect (const SDL_Rect &rect) |
invalidate all hexes under the rectangle rect (in screen coordinates) More... | |
bool | invalidate_visible_locations_in_rect (const SDL_Rect &rect) |
void | invalidate_animations () |
Function to invalidate animated terrains and units which may have changed. More... | |
void | invalidate_animations_location (const map_location &loc) |
Per-location invalidation called by invalidate_animations() Extra game per-location invalidation (village ownership) More... | |
void | set_mouseover_hex_overlay (const surface &image) |
mouseover_hex_overlay_ require a prerendered surface and is drawn underneath the mouse's location More... | |
void | clear_mouseover_hex_overlay () |
terrain_builder & | get_builder () |
void | flip () |
void | update_display () |
Copy the backbuffer to the framebuffer. More... | |
void | rebuild_all () |
Rebuild all dynamic terrain. More... | |
const theme::action * | action_pressed () |
const theme::menu * | menu_pressed () |
void | enable_menu (const std::string &item, bool enable) |
Finds the menu which has a given item in it, and enables or disables it. More... | |
void | set_diagnostic (const std::string &msg) |
void | set_turbo (const bool turbo) |
Set/Get whether 'turbo' mode is on. More... | |
double | turbo_speed () const |
void | set_turbo_speed (const double speed) |
void | set_idle_anim (bool ison) |
control unit idle animations and their frequency More... | |
bool | idle_anim () const |
void | set_idle_anim_rate (int rate) |
double | idle_anim_rate () const |
void | bounds_check_position () |
void | bounds_check_position (int &xpos, int &ypos) |
bool | scroll (int xmov, int ymov, bool force=false) |
Scrolls the display by xmov,ymov pixels. More... | |
bool | set_zoom (int amount, bool absolute=false) |
Zooms the display by the specified amount. More... | |
bool | zoom_at_max () const |
bool | zoom_at_min () const |
void | set_default_zoom () |
Sets the zoom amount to the default. More... | |
bool | view_locked () const |
void | set_view_locked (bool value) |
Sets whether the map view is locked (e.g. More... | |
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. More... | |
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. More... | |
void | scroll_to_tiles (const std::vector< map_location >::const_iterator &begin, const std::vector< map_location >::const_iterator &end, 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. More... | |
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. More... | |
events::generic_event & | scroll_event () const |
Expose the event, so observers can be notified about map scrolling. More... | |
events::generic_event & | complete_redraw_event () |
bool | tile_fully_on_screen (const map_location &loc) |
Check if a tile is fully visible on screen. More... | |
bool | tile_nearly_on_screen (const map_location &loc) const |
Checks if location loc or one of the adjacent tiles is visible on screen. More... | |
virtual void | draw () |
Draws invalidated items. More... | |
void | draw (bool update) |
void | draw (bool update, bool force) |
map_labels & | labels () |
const map_labels & | labels () const |
void | announce (const std::string &msg, const SDL_Color &color=font::GOOD_COLOR) |
Announce a message prominently. More... | |
void | recalculate_minimap () |
Schedule the minimap for recalculation. More... | |
void | redraw_minimap () |
Schedule the minimap to be redrawn. More... | |
virtual const time_of_day & | get_time_of_day (const map_location &loc=map_location::null_location()) const |
virtual bool | has_time_area () const |
void | blindfold (bool flag) |
bool | is_blindfolded () const |
void | write (config &cfg) const |
virtual void | handle_event (const SDL_Event &) |
virtual void | handle_window_event (const SDL_Event &event) |
void | init_flags () |
Init the flag list and the team colors used by ~TC. More... | |
void | reinit_flags_for_side (size_t side) |
Rebuild the flag list (not team colors) for a single side. More... | |
void | reset_reports (reports &reports_object) |
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. More... | |
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. More... | |
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. More... | |
void | drawing_buffer_add (const tdrawing_layer layer, const map_location &loc, int x, int y, const std::vector< surface > &surf, const SDL_Rect &clip=SDL_Rect()) |
void | add_arrow (arrow &) |
void | remove_arrow (arrow &) |
void | update_arrow (arrow &a) |
Called by arrow objects when they change. More... | |
void | replace_overlay_map (overlay_map *overlays) |
Public Member Functions inherited from filter_context | |
virtual | ~filter_context () |
Public Member Functions inherited from events::sdl_handler | |
virtual void | process_event () |
virtual void | volatile_draw () |
virtual void | volatile_undraw () |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
virtual void | process_help_string (int, int) |
virtual void | process_tooltip_string (int, int) |
virtual void | join () |
virtual void | join (context &c) |
virtual void | join_same (sdl_handler *parent) |
virtual void | leave () |
virtual void | join_global () |
virtual void | leave_global () |
Protected Member Functions | |
void | pre_draw () |
Called near the beginning of each draw() call. More... | |
image::TYPE | get_image_type (const map_location &loc) |
The editor uses different rules for terrain highlighting (e.g. More... | |
void | draw_hex (const map_location &loc) |
Redraws a single gamemap location. More... | |
const SDL_Rect & | get_clip_rect () |
Get the clipping rectangle for drawing. More... | |
void | draw_sidebar () |
Called near the end of a draw operation, derived classes can use this to render a specific sidebar. More... | |
Protected Member Functions inherited from display | |
void | clear_screen () |
Clear the screen contents. More... | |
virtual void | post_draw () |
Called at the very end of each draw() call. More... | |
virtual void | draw_invalidated () |
Only called when there's actual redrawing to do. More... | |
virtual void | post_commit () |
Hook for actions to take right after draw() calls drawing_buffer_commit No action here by default. More... | |
virtual void | draw_border (const map_location &loc, const int xpos, const int ypos) |
Draws the border tile overlay. More... | |
void | draw_minimap () |
std::vector< surface > | get_terrain_images (const map_location &loc, const std::string &timeid, image::TYPE type, TERRAIN_TYPE terrain_type) |
std::vector< surface > | get_fog_shroud_images (const map_location &loc, image::TYPE image_type) |
void | draw_image_for_report (surface &img, SDL_Rect &rect) |
void | scroll_to_xy (int screenxpos, int screenypos, SCROLL_TYPE scroll_type, bool force=true) |
void | fill_images_list (const std::string &prefix, std::vector< std::string > &images) |
const std::string & | get_variant (const std::vector< std::string > &variants, const map_location &loc) const |
void | drawing_buffer_commit () |
Draws the drawing_buffer_ and clears it. More... | |
void | drawing_buffer_clear () |
Clears the drawing buffer. More... | |
void | draw_all_panels () |
redraw all panels associated with the map display More... | |
void | draw_init () |
Initiate a redraw. More... | |
void | draw_wrap (bool update, bool force) |
void | process_reachmap_changes () |
Protected Member Functions inherited from video2::draw_layering | |
draw_layering (const bool auto_join=true) | |
virtual | ~draw_layering () |
Protected Member Functions inherited from events::sdl_handler | |
sdl_handler (const bool auto_join=true) | |
virtual | ~sdl_handler () |
virtual std::vector < sdl_handler * > | handler_members () |
Additional Inherited Members | |
Public Types inherited from display | |
enum | SCROLL_TYPE { SCROLL, WARP, ONSCREEN, ONSCREEN_WARP } |
enum | tdrawing_layer { LAYER_TERRAIN_BG, LAYER_GRID_TOP, LAYER_MOUSEOVER_OVERLAY, LAYER_FOOTSTEPS, LAYER_MOUSEOVER_TOP, LAYER_UNIT_FIRST, LAYER_UNIT_BG = LAYER_UNIT_FIRST+10, LAYER_UNIT_DEFAULT =LAYER_UNIT_FIRST+40, LAYER_TERRAIN_FG = LAYER_UNIT_FIRST+50, LAYER_GRID_BOTTOM, LAYER_UNIT_MOVE_DEFAULT =LAYER_UNIT_FIRST+60, LAYER_UNIT_FG = LAYER_UNIT_FIRST+80, LAYER_UNIT_MISSILE_DEFAULT = LAYER_UNIT_FIRST+90, LAYER_UNIT_LAST =LAYER_UNIT_FIRST+100, LAYER_REACHMAP, LAYER_MOUSEOVER_BOTTOM, LAYER_FOG_SHROUD, LAYER_ARROWS, LAYER_ACTIONS_NUMBERING, LAYER_SELECTED_HEX, LAYER_ATTACK_INDICATOR, LAYER_UNIT_BAR, LAYER_MOVE_INFO, LAYER_LINGER_OVERLAY, LAYER_BORDER, LAYER_LAST_LAYER } |
The layers to render something on. More... | |
Static Public Member Functions inherited from display | |
static display * | get_singleton () |
Returns the display object if a display object exists. More... | |
static Uint32 | rgb (Uint8 red, Uint8 green, Uint8 blue) |
static Uint8 | red (Uint32 color) |
static Uint8 | green (Uint32 color) |
static Uint8 | blue (Uint32 color) |
static Uint32 | max_rgb (Uint32 first, Uint32 second) |
static void | sunset (const size_t delay=0) |
Debug function to toggle the "sunset" mode. More... | |
static void | toggle_benchmark () |
Toggle to continuously redraw the screen. More... | |
static void | toggle_debug_foreground () |
Toggle to debug foreground terrain. More... | |
Protected Types inherited from display | |
enum | TERRAIN_TYPE { BACKGROUND, FOREGROUND } |
typedef std::map< map_location, std::string > | exclusive_unit_draw_requests_t |
typedef std::list< tblit > | tdrawing_buffer |
typedef std::map< map_location, unsigned int > | reach_map |
typedef std::multimap < map_location, overlay > | overlay_map |
Static Protected Attributes inherited from display | |
static int | last_zoom_ = SmallZoom |
static display * | singleton_ = nullptr |
Definition at line 25 of file editor_display.hpp.
editor::editor_display::editor_display | ( | const display_context * | dc, |
CVideo & | video, | ||
reports & | reports_object, | ||
const config & | theme_cfg, | ||
const config & | level | ||
) |
Definition at line 57 of file editor_display.cpp.
References display::clear_screen().
void editor::editor_display::add_brush_loc | ( | const map_location & | hex | ) |
Definition at line 66 of file editor_display.cpp.
References brush_locations_, and display::invalidate().
void editor::editor_display::clear_brush_locs | ( | ) |
Definition at line 79 of file editor_display.cpp.
References brush_locations_, and display::invalidate().
|
protectedvirtual |
Redraws a single gamemap location.
Reimplemented from display.
Definition at line 107 of file editor_display.cpp.
References brush_locations_, display::draw_hex(), display::drawing_buffer_add(), game_config::images::editor_brush, image::get_image(), display::get_location_x(), display::get_location_y(), display::LAYER_FOG_SHROUD, display::LAYER_SELECTED_HEX, map(), image::SCALED_TO_HEX, and image::TOD_COLORED.
|
protectedvirtual |
Called near the end of a draw operation, derived classes can use this to render a specific sidebar.
Very similar to post_commit.
Reimplemented from display.
Definition at line 144 of file editor_display.cpp.
References config::add_child(), display::dc_, display::get_map(), gamemap::get_terrain_editor_string(), int(), lexical_cast(), display::mouseoverHex_, display::refresh_report(), and display_context::teams().
|
protectedvirtual |
Get the clipping rectangle for drawing.
Virtual since the editor might use a slightly different approach.
Reimplemented from display.
Definition at line 139 of file editor_display.cpp.
References display::map_outside_area().
|
protectedvirtual |
The editor uses different rules for terrain highlighting (e.g.
selections)
Reimplemented from display.
Definition at line 99 of file editor_display.cpp.
References image::BRIGHTENED, map(), and image::TOD_COLORED.
|
inlinevirtual |
Reimplemented from display.
Definition at line 32 of file editor_display.hpp.
|
inline |
Definition at line 38 of file editor_display.hpp.
References display::get_map().
Referenced by editor::mouse_action_select::affected_hexes(), editor::mouse_action_fill::affected_hexes(), editor::mouse_action_paint::click_left(), editor::mouse_action_fill::click_left(), editor::mouse_action_paint::click_right(), editor::mouse_action_fill::click_right(), draw_hex(), get_image_type(), editor::mouse_action::key_event(), editor::mouse_action_starting_position::up_left(), and editor::mouse_action_starting_position::up_right().
|
protectedvirtual |
Called near the beginning of each draw() call.
Derived classes can use this to add extra actions before redrawing invalidated hexes takes place. No action here by default.
Reimplemented from display.
Definition at line 95 of file editor_display.cpp.
void editor::editor_display::rebuild_terrain | ( | const map_location & | loc | ) |
Definition at line 91 of file editor_display.cpp.
References display::builder_.
Referenced by editor::context_manager::refresh_after_action().
void editor::editor_display::remove_brush_loc | ( | const map_location & | hex | ) |
Definition at line 85 of file editor_display.cpp.
References brush_locations_, and display::invalidate().
void editor::editor_display::set_brush_locs | ( | const std::set< map_location > & | hexes | ) |
Definition at line 72 of file editor_display.cpp.
References brush_locations_, and display::invalidate().
Referenced by editor::mouse_action::update_brush_highlights().
|
protected |
Definition at line 53 of file editor_display.hpp.
Referenced by add_brush_loc(), clear_brush_locs(), draw_hex(), remove_brush_loc(), and set_brush_locs().