The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
editor::editor_display Class Reference

#include <editor_display.hpp>

Inheritance diagram for editor::editor_display:

Public Member Functions

 editor_display (editor_controller &controller, reports &reports_object)
 
bool in_editor () const override
 
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_mapget_map () const
 
void rebuild_terrain (const map_location &loc)
 
virtual const time_of_dayget_time_of_day (const map_location &loc=map_location::null_location()) const override
 Inherited from display. More...
 
editor_controllerget_controller ()
 
virtual void layout () override
 TLD layout() override. More...
 
void set_mouseover_hex_overlay (const texture &image)
 Sets texture to be drawn in hex under the mouse's location. More...
 
void clear_mouseover_hex_overlay ()
 
void set_status (const std::string &str, const bool is_success)
 Set a status text at the bottom left of the map area. More...
 
void set_help_string (const std::string &str)
 Sets and shows the tooltip-like text at the top or bottom of the map area. More...
 
void clear_help_string ()
 Removes the help string. More...
 
bool help_string_enabled () const
 Returns whether the help text is currently shown. More...
 
void set_help_string_enabled (bool value)
 Sets whether the help text should be shown. More...
 
- Public Member Functions inherited from display
 display (const display_context *dc, std::weak_ptr< wb::manager > wb, reports &reports_object, const std::string &theme_id, const config &level)
 
virtual ~display ()
 
bool show_everything () const
 
std::size_t playing_team_index () const
 The playing team is the team whose turn it is. More...
 
std::size_t viewing_team_index () const
 The viewing team is the team currently viewing the game. More...
 
const teamplaying_team () const
 
const teamviewing_team () const
 
bool viewing_team_is_playing () const
 
void set_viewing_team_index (std::size_t team, bool observe=false)
 Sets the team controlled by the player using the computer. More...
 
void set_playing_team_index (std::size_t team)
 sets the team whose turn it currently is More...
 
void clear_exclusive_draws ()
 Cancels all the exclusive draw requests. More...
 
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. More...
 
std::string remove_exclusive_draw (const map_location &loc)
 Cancels an exclusive draw request. More...
 
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. More...
 
void add_overlay (const map_location &loc, overlay &&ov)
 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_contextcontext () const
 
halo::managerget_halo_manager ()
 
void update_tod (const time_of_day *tod_override=nullptr)
 Applies r,g,b coloring 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...
 
tod_color get_color_overlay () const
 
virtual bool in_game () const
 
virtual const map_locationdisplayed_unit_hex () const
 Virtual functions shadowed in game_display. More...
 
virtual const std::set< std::string > & observers () const
 
const rectminimap_area () const
 mapx is the width of the portion of the display which shows the game area. More...
 
const rectpalette_area () const
 
const rectunit_image_area () const
 
rect max_map_area () const
 Returns the maximum area used for the map regardless to resolution and view size. More...
 
rect map_area () const
 Returns the area used for the map. More...
 
rect map_outside_area () const
 Returns the available area for a map, this may differ from the above. More...
 
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...
 
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_locationselected_hex () const
 
const map_locationmouseover_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...
 
point get_location (const map_location &loc) const
 Functions to get the on-screen positions of hexes. More...
 
rect get_location_rect (const map_location &loc) const
 Returns the on-screen rect corresponding to a loc. More...
 
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) 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...
 
surface screenshot (bool map_screenshot=false)
 Capture a (map-)screenshot into a surface. More...
 
void queue_rerender ()
 Marks everything for rendering including all tiles and sidebar. More...
 
void queue_repaint ()
 Queues repainting to the screen, but doesn't rerender. More...
 
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. More...
 
void clear_redraw_observers ()
 Clear the redraw observers. More...
 
themeget_theme ()
 
void set_theme (const std::string &new_theme)
 
std::shared_ptr< gui::buttonfind_action_button (const std::string &id)
 Retrieves a pointer to a theme UI button. More...
 
std::shared_ptr< gui::buttonfind_menu_button (const std::string &id)
 
void create_buttons ()
 
void layout_buttons ()
 
void draw_buttons ()
 
void hide_buttons ()
 Hide theme buttons so they don't draw. More...
 
void unhide_buttons ()
 Unhide theme buttons so they draw again. More...
 
void refresh_report (const std::string &report_name, const config *new_cfg=nullptr)
 Update the given report. More...
 
void draw_report (const std::string &report_name, bool test_run=false)
 Draw the specified report. More...
 
bool draw_reports (const rect &region)
 Draw all reports in the given region. 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 reset_standing_animations ()
 
terrain_builderget_builder ()
 
void update_fps_label ()
 
void clear_fps_label ()
 
void update_fps_count ()
 
void rebuild_all ()
 Rebuild all dynamic terrain. More...
 
const theme::actionaction_pressed ()
 
const theme::menumenu_pressed ()
 
void set_diagnostic (const std::string &msg)
 
double turbo_speed () const
 
void bounds_check_position ()
 
void bounds_check_position (int &xpos, int &ypos) const
 
bool scroll (const point &amount, bool force=false)
 Scrolls the display by amount pixels. More...
 
bool set_zoom (bool increase)
 Zooms the display in (true) or out (false). More...
 
bool set_zoom (unsigned int amount, const bool validate_value_and_set_index=true)
 Sets the display zoom to the specified amount. More...
 
void toggle_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 > &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_eventscroll_event () const
 Expose the event, so observers can be notified about map scrolling. More...
 
bool tile_fully_on_screen (const map_location &loc) const
 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...
 
void set_prevent_draw (bool pd=true)
 Prevent the game display from drawing. More...
 
bool get_prevent_draw ()
 
void fade_tod_mask (const std::string &old, const std::string &new_)
 ToD mask smooth fade. More...
 
void fade_to (const color_t &color, const std::chrono::milliseconds &duration)
 Screen fade. More...
 
void set_fade (const color_t &color)
 
virtual void update () override
 Update animations and internal state. More...
 
virtual void render () override
 Update offscreen render buffers. More...
 
virtual bool expose (const rect &region) override
 Paint the indicated region to the screen. More...
 
virtual rect screen_location () override
 Return the current draw location of the display, on the screen. More...
 
map_labelslabels ()
 
const map_labelslabels () const
 
void announce (const std::string &msg, const color_t &color=font::GOOD_COLOR, const announce_options &options=announce_options())
 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 bool has_time_area () const
 
void blindfold (bool flag)
 
bool is_blindfolded () const
 
void write (config &cfg) const
 
void init_flags ()
 Init the flag list and the team colors used by ~TC. More...
 
void reinit_flags_for_team (const team &)
 Rebuild the flag list (not team colors) for a single side. More...
 
void reset_reports (reports &reports_object)
 
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. More...
 
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. More...
 
void add_arrow (arrow &)
 
void remove_arrow (arrow &)
 
void update_arrow (arrow &a)
 Called by arrow objects when they change. More...
 
bool debug_flag_set (DEBUG_FLAG flag) const
 
void set_debug_flag (DEBUG_FLAG flag, bool value)
 
void toggle_debug_flag (DEBUG_FLAG flag)
 

Protected Member Functions

void draw_hex (const map_location &loc) override
 Redraws a single gamemap location. More...
 
virtual overlay_mapget_overlays () override
 Inherited from display. More...
 
rect get_clip_rect () const override
 Get the clipping rectangle for drawing. More...
 
- Protected Member Functions inherited from display
map_location get_middle_location () const
 
virtual void draw_invalidated ()
 Only called when there's actual redrawing to do. More...
 
void draw_overlays_at (const map_location &loc)
 
void get_terrain_images (const map_location &loc, const std::string &timeid, TERRAIN_TYPE terrain_type)
 
std::vector< textureget_fog_shroud_images (const map_location &loc, image::TYPE image_type)
 
void scroll_to_xy (const point &screen_coordinates, SCROLL_TYPE scroll_type, bool force=true)
 
void drawing_buffer_commit ()
 Draws the drawing_buffer_ and clears it. More...
 
bool draw_all_panels (const rect &region)
 Redraws all panels intersecting the given region. More...
 
void process_reachmap_changes ()
 
- Protected Member Functions inherited from gui2::top_level_drawable
 top_level_drawable ()
 
virtual ~top_level_drawable ()
 
 top_level_drawable (const top_level_drawable &)
 
top_level_drawableoperator= (const top_level_drawable &)
 
 top_level_drawable (top_level_drawable &&)
 
top_level_drawableoperator= (top_level_drawable &&)
 

Protected Attributes

std::set< map_locationbrush_locations_
 
editor_controllercontroller_
 
texture mouseover_hex_overlay_
 
- Protected Attributes inherited from display
const display_contextdc_
 
halo::manager halo_man_
 
std::weak_ptr< wb::managerwb_
 
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 More...
 
std::size_t viewing_team_index_
 
bool dont_show_all_
 
point viewport_origin_
 Position of the top-left corner of the viewport, in pixels. More...
 
bool view_locked_
 
theme theme_
 
int zoom_index_
 
const std::unique_ptr< fake_unit_managerfake_unit_man_
 
const std::unique_ptr< terrain_builderbuilder_
 
std::function< rect(rect)> minimap_renderer_
 
SDL_Rect minimap_location_
 
bool redraw_background_
 
bool invalidateAll_
 
int diagnostic_label_
 
bool invalidateGameStatus_
 
const std::unique_ptr< map_labelsmap_labels_
 
reportsreports_object_
 
events::generic_event scroll_event_
 Event raised when the map is being scrolled. More...
 
boost::circular_buffer< std::chrono::milliseconds > frametimes_
 
int current_frame_sample_ = 0
 
unsigned int fps_counter_
 
std::chrono::steady_clock::time_point fps_start_
 
unsigned int fps_actual_
 
utils::optional< std::chrono::steady_clock::time_point > last_frame_finished_ = {}
 
std::map< std::string, rectreportLocations_
 
std::map< std::string, texturereportSurfaces_
 
std::map< std::string, configreports_
 
std::vector< std::shared_ptr< gui::button > > menu_buttons_
 
std::vector< std::shared_ptr< gui::button > > action_buttons_
 
std::set< map_locationinvalidated_
 
texture tod_hex_mask1 = {}
 
texture tod_hex_mask2 = {}
 
uint8_t tod_hex_alpha1 = 0
 
uint8_t tod_hex_alpha2 = 0
 
std::vector< std::string > fog_images_
 
std::vector< std::string > shroud_images_
 
map_location selectedHex_
 
map_location mouseoverHex_
 
CKey keys_
 
bool animate_map_
 Local cache for prefs::get().animate_map, since it is constantly queried. More...
 
bool animate_water_
 Local version of prefs::get().animate_water, used to detect when it's changed. More...
 
std::size_t playing_team_index_
 
std::list< draw_helperdrawing_buffer_
 
bool map_screenshot_
 Used to indicate to drawing functions that we are doing a map screenshot. More...
 
reach_map reach_map_
 
reach_map reach_map_old_
 
bool reach_map_changed_
 

Private Attributes

int help_handle_ = 0
 ID of the floating label that's controlled by set_help_string() / clear_help_string(). More...
 
bool help_string_at_top_ = false
 Ignored when help_handle_ == 0. More...
 
bool help_string_enabled_ = true
 Whether the help text is currently shown. More...
 
std::string help_string_
 Current help string, cached for easy visibility toggling. More...
 

Additional Inherited Members

- Public Types inherited from display
enum  SCROLL_TYPE { SCROLL , WARP , ONSCREEN , ONSCREEN_WARP }
 
enum  DEBUG_FLAG {
  DEBUG_COORDINATES , DEBUG_TERRAIN_CODES , DEBUG_NUM_BITMAPS , DEBUG_FOREGROUND ,
  DEBUG_BENCHMARK , __NUM_DEBUG_FLAGS
}
 
- Static Public Member Functions inherited from display
static displayget_singleton ()
 Returns the display object if a display object exists. More...
 
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. More...
 
static int hex_width ()
 Function which returns the width of a hex in pixels, up to where the next hex starts. More...
 
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 edge). More...
 
static double get_zoom_factor ()
 Returns the current zoom factor. More...
 
static rect scaled_to_zoom (const SDL_Rect &r)
 Scale the width and height of a rect by the current zoom factor. More...
 
static point scaled_to_zoom (const point &p)
 
static bool zoom_at_max ()
 
static bool zoom_at_min ()
 
static submerge_data get_submerge_data (const rect &dest, double submerge, const point &size, uint8_t alpha, bool hreverse, bool vreverse)
 
- Protected Types inherited from display
enum  TERRAIN_TYPE { BACKGROUND , FOREGROUND }
 
typedef std::map< map_location, std::string > exclusive_unit_draw_requests_t
 
typedef std::map< map_location, unsigned int > reach_map
 
typedef std::map< map_location, std::vector< overlay > > overlay_map
 
- Static Protected Member Functions inherited from display
static void fill_images_list (const std::string &prefix, std::vector< std::string > &images)
 
- Static Protected Attributes inherited from display
static unsigned int zoom_ = DefaultZoom
 The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e., 72 means 100%. More...
 
static unsigned int last_zoom_ = SmallZoom
 The previous value of zoom_. More...
 
static displaysingleton_ = nullptr
 

Detailed Description

Definition at line 23 of file editor_display.hpp.

Constructor & Destructor Documentation

◆ editor_display()

editor::editor_display::editor_display ( editor_controller controller,
reports reports_object 
)

Definition at line 36 of file editor_display.cpp.

Member Function Documentation

◆ add_brush_loc()

void editor::editor_display::add_brush_loc ( const map_location hex)

Definition at line 44 of file editor_display.cpp.

References brush_locations_, and display::invalidate().

◆ clear_brush_locs()

void editor::editor_display::clear_brush_locs ( )

Definition at line 57 of file editor_display.cpp.

References brush_locations_, and display::invalidate().

◆ clear_help_string()

void editor::editor_display::clear_help_string ( )

Removes the help string.

Definition at line 200 of file editor_display.cpp.

References help_handle_, and font::remove_floating_label().

Referenced by editor::location_palette::hide(), set_help_string(), and set_help_string_enabled().

◆ clear_mouseover_hex_overlay()

void editor::editor_display::clear_mouseover_hex_overlay ( )
inline

◆ draw_hex()

void editor::editor_display::draw_hex ( const map_location loc)
overrideprotectedvirtual

◆ get_clip_rect()

rect editor::editor_display::get_clip_rect ( ) const
overrideprotectedvirtual

Get the clipping rectangle for drawing.

Virtual since the editor might use a slightly different approach.

Reimplemented from display.

Definition at line 105 of file editor_display.cpp.

References display::map_outside_area().

◆ get_controller()

editor_controller& editor::editor_display::get_controller ( )
inline

◆ get_map()

const editor_map& editor::editor_display::get_map ( ) const
inline

◆ get_overlays()

display::overlay_map & editor::editor_display::get_overlays ( )
overrideprotectedvirtual

Inherited from display.

Implements display.

Definition at line 156 of file editor_display.cpp.

References controller_, editor::editor_controller::get_current_map_context(), and editor::map_context::get_overlays().

◆ get_time_of_day()

const time_of_day & editor::editor_display::get_time_of_day ( const map_location loc = map_location::null_location()) const
overridevirtual

◆ help_string_enabled()

bool editor::editor_display::help_string_enabled ( ) const
inline

Returns whether the help text is currently shown.

Definition at line 85 of file editor_display.hpp.

References help_string_enabled_.

◆ in_editor()

bool editor::editor_display::in_editor ( ) const
inlineoverridevirtual

Reimplemented from display.

Definition at line 28 of file editor_display.hpp.

◆ layout()

void editor::editor_display::layout ( )
overridevirtual

TLD layout() override.

Replaces old refresh_reports(). Be sure to call the base class method as well.

This updates some reports that may need to be refreshed every frame.

Reimplemented from display.

Definition at line 110 of file editor_display.cpp.

References config::add_child(), display::context(), font::get_floating_label_rect(), get_map(), gamemap::get_terrain_editor_string(), display::get_visible_hexes(), help_handle_, help_string_at_top_, display::layout(), display::map_outside_area(), display::mouseoverHex_, font::move_floating_label(), display::refresh_report(), utf8::size(), and display::rect_of_hexes::top.

◆ rebuild_terrain()

void editor::editor_display::rebuild_terrain ( const map_location loc)

Definition at line 69 of file editor_display.cpp.

References display::builder_.

◆ remove_brush_loc()

void editor::editor_display::remove_brush_loc ( const map_location hex)

Definition at line 63 of file editor_display.cpp.

References brush_locations_, and display::invalidate().

◆ set_brush_locs()

void editor::editor_display::set_brush_locs ( const std::set< map_location > &  hexes)

◆ set_help_string()

void editor::editor_display::set_help_string ( const std::string &  str)

◆ set_help_string_enabled()

void editor::editor_display::set_help_string_enabled ( bool  value)

Sets whether the help text should be shown.

Definition at line 189 of file editor_display.cpp.

References clear_help_string(), help_string_, help_string_enabled_, and set_help_string().

Referenced by editor::editor_controller::do_execute_command(), and editor::editor_controller::init_gui().

◆ set_mouseover_hex_overlay()

void editor::editor_display::set_mouseover_hex_overlay ( const texture image)
inline

◆ set_status()

void editor::editor_display::set_status ( const std::string &  str,
const bool  is_success 
)

Set a status text at the bottom left of the map area.

Parameters
strThe text to display.
is_successType of message. When true, message is shown in green with checkmark. When false, message is shown in red with cross mark

Definition at line 161 of file editor_display.cpp.

References font::add_floating_label(), border, video::game_canvas_size(), font::get_floating_label_rect(), font::move_floating_label(), font::floating_label::set_bg_color(), font::floating_label::set_border_size(), font::floating_label::set_font_size(), font::floating_label::set_lifetime(), font::floating_label::set_position(), utf8::size(), font::SIZE_SMALL, font::floating_label::use_markup(), and VGETTEXT.

Member Data Documentation

◆ brush_locations_

std::set<map_location> editor::editor_display::brush_locations_
protected

◆ controller_

editor_controller& editor::editor_display::controller_
protected

Definition at line 104 of file editor_display.hpp.

Referenced by get_controller(), get_overlays(), and get_time_of_day().

◆ help_handle_

int editor::editor_display::help_handle_ = 0
private

ID of the floating label that's controlled by set_help_string() / clear_help_string().

Definition at line 110 of file editor_display.hpp.

Referenced by clear_help_string(), layout(), and set_help_string().

◆ help_string_

std::string editor::editor_display::help_string_
private

Current help string, cached for easy visibility toggling.

Definition at line 122 of file editor_display.hpp.

Referenced by set_help_string(), and set_help_string_enabled().

◆ help_string_at_top_

bool editor::editor_display::help_string_at_top_ = false
private

Ignored when help_handle_ == 0.

Othewise, true if the help label obscures the northern hexes in the map area, false if it's over the southern hexes instead.

Definition at line 116 of file editor_display.hpp.

Referenced by layout(), and set_help_string().

◆ help_string_enabled_

bool editor::editor_display::help_string_enabled_ = true
private

Whether the help text is currently shown.

Definition at line 119 of file editor_display.hpp.

Referenced by help_string_enabled(), set_help_string(), and set_help_string_enabled().

◆ mouseover_hex_overlay_

texture editor::editor_display::mouseover_hex_overlay_
protected

The documentation for this class was generated from the following files: