display Class Reference

#include <display.hpp>

Inheritance diagram for display:

Inheritance graph
[legend]
Collaboration diagram for display:

Collaboration graph
[legend]

List of all members.

Public Types

enum  SCROLL_TYPE { SCROLL, WARP, ONSCREEN }
enum  tdrawing_layer {
  LAYER_TERRAIN_BG, LAYER_TERRAIN_TMP_BG, LAYER_UNIT_BG, LAYER_UNIT_FIRST,
  LAYER_UNIT_LAST = LAYER_UNIT_FIRST+100, LAYER_UNIT_FG, LAYER_UNIT_FAKE, LAYER_TERRAIN_FG,
  LAYER_TERRAIN_TMP_FG, LAYER_UNIT_BAR, LAYER_LINGER_OVERLAY, LAYER_LAST_LAYER
}
 The layers to render something on. More...

Public Member Functions

 display (CVideo &video, const gamemap &map, const config &theme_cfg, const config &cfg, const config &level)
virtual ~display ()
CVideovideo ()
surface get_screen_surface ()
virtual bool in_game () const
virtual bool in_editor () const
int w () const
 width
int h () const
 height
const SDL_Rect & minimap_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.
const SDL_Rect & map_area () const
 Returns the area used for the map.
const SDL_Rect & map_outside_area () const
 Returns the available area for a map, this may differ from the above.
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.
int hex_width () const
 Function which returns the width of a hex in pixels, up to where the next hex starts.
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).
double get_zoom_factor ()
 Returns the current zoom factor.
const gamemap::location hex_clicked_on (int x, int y, gamemap::location::DIRECTION *nearest_hex=NULL, gamemap::location::DIRECTION *second_nearest_hex=NULL) const
const gamemap::location pixel_position_to_hex (int x, int y, gamemap::location::DIRECTION *nearest_hex=NULL, gamemap::location::DIRECTION *second_nearest_hex=NULL) const
gamemap::location minimap_location_on (int x, int y)
const gamemap::locationselected_hex ()
const gamemap::locationmouseover_hex ()
virtual void select_hex (gamemap::location hex)
virtual void highlight_hex (gamemap::location hex)
void invalidate_game_status ()
 Function to invalidate the game status displayed on the sidebar.
void get_rect_hex_bounds (SDL_Rect rect, gamemap::location &topleft, gamemap::location &bottomright) const
int get_location_x (const gamemap::location &loc) const
 Functions to get the on-screen positions of hexes.
int get_location_y (const gamemap::location &loc) const
bool shrouded (const gamemap::location &loc) const
 Returns true if location (x,y) is covered in shroud.
bool fogged (const gamemap::location &loc) const
 Returns true if location (x,y) is covered in fog.
void set_grid (const bool grid)
 Determines whether a grid should be overlayed on the game board.
void get_visible_hex_bounds (gamemap::location &topleft, gamemap::location &bottomright) const
 Returns the locations of 2 hexes that bind the visible area of the map.
int screenshot (std::string filename, bool map_screenshot=false)
 Save a (map-)screenshot and return the estimated file size.
void redraw_everything ()
 Invalidates entire screen, including all tiles and sidebar.
themeget_theme ()
gui::buttonfind_button (const std::string &id)
gui::button::TYPE string_to_button_type (std::string type)
void create_buttons ()
void invalidate_theme ()
void refresh_report (reports::TYPE report_num, reports::report report, bool brightened=false)
virtual void invalidate (const gamemap::location &loc)
virtual void invalidate_rectangle (const gamemap::location &first_corner, const gamemap::location &second_corner)
virtual void invalidate_zone (const int x1, const int y1, const int x2, const int y2)
virtual void draw_minimap_units ()
const gamemapget_map () const
void set_hex_overlay (const gamemap::location &loc, surface image)
void clear_hex_overlay (const gamemap::location &loc)
void set_selected_hex_overlay (const surface &image)
void clear_selected_hex_overlay ()
void set_mouseover_hex_overlay (const surface &image)
void clear_mouseover_hex_overlay ()
void sunset (const size_t delay=0)
 Debug function to toggle the "sunset" mode.
void toggle_benchmark ()
 Toogle to continuously redraw the screen.
void flip ()
void update_display ()
 Copy the backbuffer to the framebuffer.
void rebuild_all ()
 Rebuild all dynamic terrain.
void render_unit_image (int x, int y, const bool fake_unit, const int drawing_order, 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 the image of a unit at a certain location.
const theme::menumenu_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.
void set_diagnostic (const std::string &msg)
void delay (unsigned int milliseconds) const
 Delay routines: use these instead of SDL_Delay (for --nogui).
void set_turbo (const bool turbo)
 Set/Get whether 'turbo' mode is on.
double turbo_speed () const
void set_turbo_speed (const double speed)
void set_idle_anim (bool ison)
bool idle_anim () const
void set_idle_anim_rate (int rate)
double idle_anim_rate () const
void add_highlighted_loc (const gamemap::location &hex)
 Add a location to highlight.
void clear_highlighted_locs ()
void remove_highlighted_loc (const gamemap::location &hex)
void bounds_check_position ()
void bounds_check_position (int &xpos, int &ypos)
void invalidate_all ()
 Function to invalidate all tiles.
void scroll (int xmov, int ymov)
 Scrolls the display by xmov,ymov pixels.
void set_zoom (int amount)
 Zooms the display by the specified amount.
void set_default_zoom ()
 Sets the zoom amount to the default.
void scroll_to_tile (const gamemap::location &loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true)
 Scroll such that location loc is on-screen.
void scroll_to_tiles (gamemap::location loc1, gamemap::location loc2, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, double add_spacing=0.0)
 Scroll such that location loc1 is on-screen.
void scroll_to_tiles (const std::vector< gamemap::location > &locs, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool only_if_possible=false, double add_spacing=0.0)
 Scroll to fit as many locations on-screen as possible, starting with the first.
events::generic_eventscroll_event () const
 Expose the event, so observers can be notified about map scrolling.
bool tile_on_screen (const gamemap::location &loc)
 Check if a tile is fully on screen.
virtual void draw (bool update=true, bool force=false)=0
 Draws invalidated items.
map_labelslabels ()
const map_labelslabels () const
void announce (const std::string msg, const SDL_Color &colour=font::GOOD_COLOUR)
 Announce a message prominently.
void recalculate_minimap ()
 Schedule the minimap for recalculation.
void redraw_minimap ()
 Schedule the minimap to be redrawn.
void set_report_content (const reports::TYPE which_report, const std::string &content)
 Set what will be shown for the report with type which_report.
std::map< reports::TYPE,
std::string > 
get_report_contents ()
void draw_text_in_hex (const gamemap::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.
void drawing_buffer_add (const tdrawing_layer layer, const int drawing_order, const tblit &blit)
 Add an item to the drawing buffer.

Static Public Member Functions

static Uint32 rgb (Uint8 red, Uint8 green, Uint8 blue)

Protected Types

enum  ADJACENT_TERRAIN_TYPE { ADJACENT_BACKGROUND, ADJACENT_FOREGROUND, ADJACENT_FOGSHROUD }
typedef std::map
< tdrawing_layer, std::map
< int, std::vector< tblit > > > 
tdrawing_buffer
 * Surfaces are rendered per level in a map.

Protected Member Functions

virtual void draw_border (const gamemap::location &loc, const int xpos, const int ypos)
 Draws the border tile overlay.
void draw_minimap ()
std::vector< surfaceget_terrain_images (const gamemap::location &loc, const std::string timeid, image::TYPE type, ADJACENT_TERRAIN_TYPE terrain_type)
std::vector< std::string > get_fog_shroud_graphics (const gamemap::location &loc)
void draw_image_for_report (surface &img, SDL_Rect &rect)
void scroll_to_xy (int screenxpos, int screenypos, SCROLL_TYPE scroll_type)
void drawing_buffer_commit ()
 Draws the drawing_buffer_ and clears it.
void drawing_buffer_clear ()
 Clears the drawing buffer.
void draw_all_panels ()
 redraw all panels associated with the map display
void invalidate_locations_in_rect (SDL_Rect r)
bool draw_init ()
 Invalidate controls and panels when changed after they have been drawn initially.
void draw_wrap (bool update, bool force, bool changed)

Protected Attributes

CVideoscreen_
const gamemapmap_
const viewpointviewpoint_
int xpos_
int ypos_
theme theme_
int zoom_
int last_zoom_
terrain_builder builder_
surface minimap_
SDL_Rect minimap_location_
bool redrawMinimap_
bool redraw_background_
bool invalidateAll_
bool grid_
int diagnostic_label_
bool panelsDrawn_
double turbo_speed_
bool turbo_
bool invalidateGameStatus_
map_labels map_labels_
events::generic_event _scroll_event
 Event raised when the map is being scrolled.
int nextDraw_
 Holds the tick count for when the next drawing event is scheduled.
SDL_Rect reportRects_ [reports::NUM_REPORTS]
surface reportSurfaces_ [reports::NUM_REPORTS]
reports::report reports_ [reports::NUM_REPORTS]
std::map< reports::TYPE,
std::string > 
report_
std::vector< gui::buttonbuttons_
std::set< gamemap::locationinvalidated_
std::map< gamemap::location,
surface
hex_overlay_
surface selected_hex_overlay_
surface mouseover_hex_overlay_
gamemap::location selectedHex_
gamemap::location mouseoverHex_
std::set< gamemap::locationhighlighted_locations_
CKey keys_
tdrawing_buffer drawing_buffer_
bool map_screenshot_
 Used to indicate to drawing funtions that we are doing a map screenshot.

Private Attributes

int fps_handle_
 Handle for the label which displays frames per second.
bool idle_anim_
double idle_anim_rate_
surface map_screenshot_surf_

Classes

struct  ordered_draw
 Strict weak ordering to sort a STL-set of hexes for drawing using the z-order. More...
struct  tblit
 Helper structure for rendering the terrains. More...


Detailed Description

Definition at line 58 of file display.hpp.


Member Typedef Documentation

typedef std::map<tdrawing_layer, std::map<int , std::vector<tblit> > > display::tdrawing_buffer [protected]

* Surfaces are rendered per level in a map.

Per level the items are rendered per location these locations are stored in the drawing order required for units. every location has a vector with surfaces, each with its own screen coordinate to render at. every vector element has a vector with surfaces to render.

Definition at line 522 of file display.hpp.


Member Enumeration Documentation

Enumerator:
SCROLL 
WARP 
ONSCREEN 

Definition at line 302 of file display.hpp.

Enumerator:
ADJACENT_BACKGROUND 
ADJACENT_FOREGROUND 
ADJACENT_FOGSHROUD 

Definition at line 374 of file display.hpp.

The layers to render something on.

This value should never be stored it's the internal drawing order and adding removing and reordering the layers should be save. If needed in WML use the name and map that to the enum value.

Enumerator:
LAYER_TERRAIN_BG  Layer for the terrain drawn behind the unit.

LAYER_TERRAIN_TMP_BG  Layer which holds stuff that needs to be sorted out further, but under units.
LAYER_UNIT_BG  Used for the ellipse behind the unit.
LAYER_UNIT_FIRST  Reserve layeres to be selected for WML.
LAYER_UNIT_LAST 
LAYER_UNIT_FG  Used for the ellipse in front of the unit.

LAYER_UNIT_FAKE  The fake unit is drawn on this layer.
LAYER_TERRAIN_FG  Layer for the terrain drawn in front of the unit.

LAYER_TERRAIN_TMP_FG  Layer which holds stuff that needs to be sorted out further, but on top of units.
LAYER_UNIT_BAR  Unit bars and overlays are drawn on this layer (for testing here).

LAYER_LINGER_OVERLAY  The overlay used for the linger mode.
LAYER_LAST_LAYER  Don't draw to this layer it's a dummy to size the vector.

Definition at line 466 of file display.hpp.


Constructor & Destructor Documentation

display::display ( CVideo video,
const gamemap map,
const config theme_cfg,
const config cfg,
const config level 
)

display::~display (  )  [virtual]

Definition at line 129 of file display.cpp.


Member Function Documentation

static Uint32 display::rgb ( Uint8  red,
Uint8  green,
Uint8  blue 
) [inline, static]

CVideo& display::video (  )  [inline]

Definition at line 69 of file display.hpp.

References screen_.

Referenced by gui::dialog::add_button(), gui::dialog::add_option(), dialogs::animate_unit_advancement(), gui::dialog::dialog(), do_replay(), map_editor::brush_bar::draw(), map_editor::terrain_palette::draw(), draw_all_panels(), draw_background(), game_display::draw_minimap_units(), draw_tip_of_day(), fade_logo(), dialogs::file_dialog::file_dialog(), play_controller::finish_turn(), play_controller::fire_prestart(), flip(), gui::dialog::get_frame(), gui::dialog::get_menu(), dialogs::get_save_name(), playsingle_controller::init_gui(), play_controller::init_managers(), gui::dialog::layout(), dialogs::load_game_dialog(), move_unit_between(), dialogs::network_connect_dialog(), dialogs::network_data_dialog(), map_editor::new_map_dialog(), open_connection(), playmp_scenario(), playsingle_scenario(), map_editor::preferences_dialog(), game_events::pump(), map_editor::resize_dialog(), run_lobby_loop(), events::menu_handler::scenario_settings_table(), preferences::set_adjust_gamma(), preferences::set_fullscreen(), preferences::set_gamma(), gui::dialog::set_image(), gui::dialog::set_menu(), preferences::set_resolution(), gui::dialog::set_textbox(), gui::floating_textbox::show(), gui::dialog::show(), about::show_about(), gui::show_dialog(), help::show_help(), preferences::show_hotkeys_dialog(), show_intro_part(), show_intro_part_helper(), gui::show_title(), preferences::show_video_mode_dialog(), events::menu_handler::status_table(), teleport_unit_between(), the_end(), mp::ui::ui(), unit_display::unit_attack(), unit_display::unit_die(), unit_display::unit_healing(), events::menu_handler::unit_list(), unit_display::unit_recruited(), map_editor::update_l_button_palette(), and default_map_generator::user_config().

surface display::get_screen_surface (  )  [inline]

virtual bool display::in_game (  )  const [inline, virtual]

Reimplemented in game_display.

Definition at line 74 of file display.hpp.

Referenced by hotkey::execute_command(), and hotkey::key_event().

virtual bool display::in_editor (  )  const [inline, virtual]

Reimplemented in editor_display.

Definition at line 75 of file display.hpp.

Referenced by hotkey::execute_command().

int display::w (  )  const [inline]

int display::h (  )  const [inline]

const SDL_Rect& display::minimap_area (  )  const [inline]

Definition at line 82 of file display.hpp.

References theme::mini_map_location(), screen_area(), and theme_.

Referenced by draw_minimap(), and minimap_location_on().

const SDL_Rect& display::unit_image_area (  )  const [inline]

Definition at line 84 of file display.hpp.

References screen_area(), theme_, and theme::unit_image_location().

SDL_Rect display::screen_area (  )  const [inline]

const SDL_Rect & display::max_map_area (  )  const

Returns the maximum area used for the map regardless to resolution and view size.

Definition at line 133 of file display.cpp.

References theme::border(), gamemap::h(), hex_size(), hex_width(), map_, theme_, and gamemap::w().

Referenced by map_area(), map_outside_area(), and screenshot().

const SDL_Rect & display::map_area (  )  const

const SDL_Rect& display::map_outside_area (  )  const [inline]

bool display::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.

Definition at line 178 of file display.cpp.

References hex_size().

Referenced by scroll_to_tiles(), and tile_on_screen().

int display::hex_width (  )  const [inline]

Function which returns the width of a hex in pixels, up to where the next hex starts.

(i.e. not entirely from tip to tip -- use hex_size() to get the distance from tip to tip)

Definition at line 116 of file display.hpp.

References zoom_.

Referenced by bounds_check_position(), draw_minimap(), get_location_x(), get_rect_hex_bounds(), max_map_area(), minimap_location_on(), and pixel_position_to_hex().

int display::hex_size (  )  const [inline]

Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right edge).

Definition at line 120 of file display.hpp.

References zoom_.

Referenced by game_display::add_overlay(), draw_minimap(), draw_text_in_hex(), unit_frame::invalidate(), max_map_area(), minimap_location_on(), outside_area(), pixel_position_to_hex(), unit_frame::redraw(), unit::redraw_unit(), and scroll_to_tiles().

double display::get_zoom_factor (  )  [inline]

Returns the current zoom factor.

Definition at line 123 of file display.hpp.

References image::tile_size, and zoom_.

Referenced by game_display::draw_bar(), draw_text_in_hex(), unit::overlaps(), unit_frame::redraw(), and unit::redraw_unit().

const gamemap::location display::hex_clicked_on ( int  x,
int  y,
gamemap::location::DIRECTION nearest_hex = NULL,
gamemap::location::DIRECTION second_nearest_hex = NULL 
) const

const gamemap::location display::pixel_position_to_hex ( int  x,
int  y,
gamemap::location::DIRECTION nearest_hex = NULL,
gamemap::location::DIRECTION second_nearest_hex = NULL 
) const

gamemap::location display::minimap_location_on ( int  x,
int  y 
)

const gamemap::location& display::selected_hex (  )  [inline]

Definition at line 144 of file display.hpp.

References selectedHex_.

Referenced by unit::overlaps(), unit::redraw_unit(), and events::menu_handler::unit_list().

const gamemap::location& display::mouseover_hex (  )  [inline]

Definition at line 145 of file display.hpp.

References mouseoverHex_.

Referenced by unit::redraw_unit(), and unit_display::unit_recruited().

void display::select_hex ( gamemap::location  hex  )  [virtual]

Reimplemented in game_display.

Definition at line 1035 of file display.cpp.

References invalidate(), and selectedHex_.

Referenced by game_display::select_hex().

void display::highlight_hex ( gamemap::location  hex  )  [virtual]

Reimplemented in game_display.

Definition at line 1042 of file display.cpp.

References invalidate(), and mouseoverHex_.

Referenced by game_display::highlight_hex().

void display::invalidate_game_status (  )  [inline]

void display::get_rect_hex_bounds ( SDL_Rect  rect,
gamemap::location topleft,
gamemap::location bottomright 
) const

Todo:
FIXME This routine should properly determine what to update, and not increase by one just to be sure.

Definition at line 329 of file display.cpp.

References theme::border(), gamemap::h(), hex_width(), is_odd(), map_, map_area(), theme_, gamemap::w(), gamemap::location::x, xpos_, gamemap::location::y, ypos_, and zoom_.

Referenced by get_visible_hex_bounds(), and invalidate_locations_in_rect().

int display::get_location_x ( const gamemap::location loc  )  const

int display::get_location_y ( const gamemap::location loc  )  const

bool display::shrouded ( const gamemap::location loc  )  const [inline]

bool display::fogged ( const gamemap::location loc  )  const [inline]

void display::set_grid ( const bool  grid  )  [inline]

Determines whether a grid should be overlayed on the game board.

(to more clearly show where hexes are)

Definition at line 168 of file display.hpp.

References grid_.

Referenced by preferences::set_grid().

void display::get_visible_hex_bounds ( gamemap::location topleft,
gamemap::location bottomright 
) const

Returns the locations of 2 hexes that bind the visible area of the map.

Definition at line 411 of file display.cpp.

References get_rect_hex_bounds(), map_area(), and r.

Referenced by draw_init(), game_display::invalidate_animations(), and game_display::process_reachmap_changes().

int display::screenshot ( std::string  filename,
bool  map_screenshot = false 
)

Save a (map-)screenshot and return the estimated file size.

Definition at line 417 of file display.cpp.

References create_compatible_surface(), DBG_DP, draw(), gamemap::empty(), CVideo::getSurface(), invalidateAll_, map_, map_screenshot_, map_screenshot_surf_, max_map_area(), redraw_everything(), screen_, size, xpos_, and ypos_.

Referenced by hotkey::execute_command().

void display::redraw_everything (  ) 

theme& display::get_theme (  )  [inline]

gui::button * display::find_button ( const std::string &  id  ) 

gui::button::TYPE display::string_to_button_type ( std::string  type  ) 

Definition at line 512 of file display.cpp.

References gui::button::TYPE_CHECK, gui::button::TYPE_IMAGE, and gui::button::TYPE_PRESS.

Referenced by create_buttons().

void display::create_buttons (  ) 

void display::invalidate_theme (  )  [inline]

void display::refresh_report ( reports::TYPE  report_num,
reports::report  report,
bool  brightened = false 
)

virtual void display::invalidate ( const gamemap::location loc  )  [inline, virtual]

void display::invalidate_rectangle ( const gamemap::location first_corner,
const gamemap::location second_corner 
) [virtual]

Definition at line 2024 of file display.cpp.

References invalidate(), gamemap::location::x, and gamemap::location::y.

Referenced by invalidate_zone().

void display::invalidate_zone ( const int  x1,
const int  y1,
const int  x2,
const int  y2 
) [virtual]

Definition at line 2033 of file display.cpp.

References invalidate_rectangle(), map_area(), pixel_position_to_hex(), and rect.

Referenced by unit_frame::invalidate().

virtual void display::draw_minimap_units (  )  [inline, virtual]

Reimplemented in game_display.

Definition at line 193 of file display.hpp.

Referenced by draw_minimap().

const gamemap& display::get_map (  )  const [inline]

Definition at line 195 of file display.hpp.

References map_.

Referenced by unit_animation::matches(), unit::overlaps(), and unit::redraw_unit().

void display::set_hex_overlay ( const gamemap::location loc,
surface  image 
) [inline]

Definition at line 205 of file display.hpp.

References hex_overlay_.

void display::clear_hex_overlay ( const gamemap::location loc  ) 

Definition at line 961 of file display.cpp.

References hex_overlay_.

void display::set_selected_hex_overlay ( const surface image  )  [inline]

Definition at line 208 of file display.hpp.

References selected_hex_overlay_.

void display::clear_selected_hex_overlay (  )  [inline]

Definition at line 209 of file display.hpp.

References selected_hex_overlay_.

void display::set_mouseover_hex_overlay ( const surface image  )  [inline]

Definition at line 211 of file display.hpp.

References mouseover_hex_overlay_.

void display::clear_mouseover_hex_overlay (  )  [inline]

Definition at line 212 of file display.hpp.

References mouseover_hex_overlay_.

Referenced by map_editor::map_editor::reset_mouseover_overlay().

void display::sunset ( const size_t  delay = 0  ) 

Debug function to toggle the "sunset" mode.

The map area become progressively darker, except where hexes are refreshed. delay is the number of frames between each darkening (0 to toggle).

Definition at line 731 of file display.cpp.

References sunset_delay.

Referenced by events::console_handler::do_sunset().

void display::toggle_benchmark (  ) 

Toogle to continuously redraw the screen.

Definition at line 737 of file display.cpp.

References benchmark.

Referenced by events::console_handler::do_benchmark().

void display::flip (  ) 

void display::update_display (  ) 

void display::rebuild_all (  )  [inline]

Rebuild all dynamic terrain.

Definition at line 230 of file display.hpp.

References builder_, and terrain_builder::rebuild_all().

Referenced by process_event().

void display::render_unit_image ( int  x,
int  y,
const bool  fake_unit,
const int  drawing_order,
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 the image of a unit at a certain location.

x,y: pixel location on screen to draw the unit image: the image of the unit reverse: if the unit should be flipped across the x axis greyscale: used when the unit is stoned alpha: the merging to use with the background blendto: blend to this colour using blend_ratio submerged: the amount of the unit out of 1.0 that is submerged (presumably under water) and thus shouldn't be drawn

Definition at line 971 of file display.cpp.

References adjust_surface_alpha(), surface::assign(), blend_surface(), brighten_image(), drawing_buffer_add(), ERR_DP, flop_surface(), ftofxp, greyscale_image(), LAYER_UNIT_FIRST, map_area(), rects_overlap(), and image::reverse_image().

Referenced by unit_frame::redraw(), and unit::redraw_unit().

const theme::menu * display::menu_pressed (  ) 

Definition at line 1165 of file display.cpp.

References buttons_, theme::menus(), and theme_.

Referenced by play_controller::play_slice().

void display::enable_menu ( const std::string &  item,
bool  enable 
)

Finds the menu which has a given item in it, and enables or disables it.

Definition at line 1182 of file display.cpp.

References buttons_, theme::menus(), and theme_.

Referenced by playsingle_controller::linger(), playsingle_controller::play_ai_turn(), playsingle_controller::play_human_turn(), playmp_controller::play_human_turn(), and playmp_controller::play_network_turn().

void display::set_diagnostic ( const std::string &  msg  ) 

void display::delay ( unsigned int  milliseconds  )  const

void display::set_turbo ( const bool  turbo  )  [inline]

Set/Get whether 'turbo' mode is on.

When turbo mode is on, everything moves much faster.

Definition at line 260 of file display.hpp.

References turbo_.

Referenced by preferences::set_turbo().

double display::turbo_speed (  )  const

void display::set_turbo_speed ( const double  speed  )  [inline]

Definition at line 264 of file display.hpp.

References turbo_speed_.

Referenced by preferences::set_turbo_speed().

void display::set_idle_anim ( bool  ison  )  [inline]

Definition at line 267 of file display.hpp.

References idle_anim_.

Referenced by preferences::set_idle_anim().

bool display::idle_anim (  )  const [inline]

Definition at line 268 of file display.hpp.

References idle_anim_.

Referenced by unit::start_animation().

void display::set_idle_anim_rate ( int  rate  ) 

Definition at line 1789 of file display.cpp.

References idle_anim_rate_.

Referenced by display(), and preferences::set_idle_anim_rate().

double display::idle_anim_rate (  )  const [inline]

Definition at line 270 of file display.hpp.

References idle_anim_rate_.

Referenced by unit::start_animation().

void display::add_highlighted_loc ( const gamemap::location hex  ) 

Add a location to highlight.

Note that this has nothing to do with selecting hexes, it is pure highlighting. These hexes will be highlighted slightly darker than the currently selected hex.

Definition at line 1201 of file display.cpp.

References highlighted_locations_, and invalidate().

void display::clear_highlighted_locs (  ) 

Definition at line 1211 of file display.cpp.

References highlighted_locations_, and invalidate().

void display::remove_highlighted_loc ( const gamemap::location hex  ) 

Definition at line 1220 of file display.cpp.

References highlighted_locations_, and invalidate().

void display::bounds_check_position (  ) 

Definition at line 1723 of file display.cpp.

References MaxZoom, MinZoom, image::set_zoom(), xpos_, ypos_, and zoom_.

Referenced by redraw_everything(), scroll(), scroll_to_xy(), and set_zoom().

void display::bounds_check_position ( int &  xpos,
int &  ypos 
)

Definition at line 1742 of file display.cpp.

References theme::border(), h(), gamemap::h(), hex_width(), map_, map_area(), theme_, gamemap::w(), and zoom_.

void display::invalidate_all (  ) 

void display::scroll ( int  xmov,
int  ymov 
)

void display::set_zoom ( int  amount  ) 

Zooms the display by the specified amount.

Negative values zoom out. Note the amount should be a multiple of four, otherwise the images might start to look odd (hex_width() gets rounding errors).

Definition at line 1439 of file display.cpp.

References bounds_check_position(), draw(), invalidate_all(), map_area(), map_labels_, MaxZoom, MinZoom, map_labels::recalculate_labels(), redraw_background_, image::set_zoom(), xpos_, ypos_, and zoom_.

Referenced by hotkey::execute_command(), and set_default_zoom().

void display::set_default_zoom (  ) 

Sets the zoom amount to the default.

Definition at line 1466 of file display.cpp.

References DefaultZoom, last_zoom_, set_zoom(), and zoom_.

Referenced by hotkey::execute_command().

void display::scroll_to_tile ( const gamemap::location loc,
SCROLL_TYPE  scroll_type = ONSCREEN,
bool  check_fogged = true 
)

void display::scroll_to_tiles ( gamemap::location  loc1,
gamemap::location  loc2,
SCROLL_TYPE  scroll_type = ONSCREEN,
bool  check_fogged = true,
double  add_spacing = 0.0 
)

Scroll such that location loc1 is on-screen.

It will also try to make it such that loc2 is on-screen, but this is not guaranteed. For ONSCREEN scrolls add_spacing sets the desired minimum distance from the border in hexes.

Definition at line 1580 of file display.cpp.

Referenced by unit_display::move_unit(), move_unit_between(), scroll_to_tile(), teleport_unit_between(), and unit_display::unit_attack().

void display::scroll_to_tiles ( const std::vector< gamemap::location > &  locs,
SCROLL_TYPE  scroll_type = ONSCREEN,
bool  check_fogged = true,
bool  only_if_possible = false,
double  add_spacing = 0.0 
)

Scroll to fit as many locations on-screen as possible, starting with the first.

Definition at line 1590 of file display.cpp.

References ERR_DP, fogged(), get_location_x(), get_location_y(), h(), hex_size(), map_, map_area(), gamemap::on_board(), ONSCREEN, outside_area(), r, round_double(), scroll_to_xy(), and w().

events::generic_event& display::scroll_event (  )  const [inline]

Expose the event, so observers can be notified about map scrolling.

Definition at line 324 of file display.hpp.

References _scroll_event.

Referenced by soundsource::manager::manager().

bool display::tile_on_screen ( const gamemap::location loc  ) 

Check if a tile is fully on screen.

Definition at line 1479 of file display.cpp.

References get_location_x(), get_location_y(), map_area(), and outside_area().

Referenced by unit_display::move_unit().

virtual void display::draw ( bool  update = true,
bool  force = false 
) [pure virtual]

Draws invalidated items.

If update is true, will also copy the display to the frame buffer. If force is true, will not skip frames, even if running behind.

Implemented in editor_display, and game_display.

Referenced by redraw_everything(), screenshot(), scroll_to_xy(), and set_zoom().

map_labels& display::labels (  )  [inline]

const map_labels& display::labels (  )  const [inline]

Definition at line 335 of file display.hpp.

References map_labels_.

void display::announce ( const std::string  msg,
const SDL_Color &  colour = font::GOOD_COLOUR 
)

Announce a message prominently.

Definition at line 1230 of file display.cpp.

References font::add_floating_label(), font::CENTER_ALIGN, h(), map_outside_area(), font::SIZE_XLARGE, and w().

Referenced by move_unit().

void display::recalculate_minimap (  )  [inline]

void display::redraw_minimap (  )  [inline]

Schedule the minimap to be redrawn.

Useful if units have moved about on the map.

Definition at line 347 of file display.hpp.

References redrawMinimap_.

Referenced by events::menu_handler::undo().

void display::set_report_content ( const reports::TYPE  which_report,
const std::string &  content 
)

Set what will be shown for the report with type which_report.

Note that this only works for some reports, i.e. reports that can not be deducted from the supplied arguments to generate_report, currently: SELECTED_TERRAIN, EDIT_LEFT_BUTTON_FUNCTION

Definition at line 1860 of file display.cpp.

References report_.

Referenced by map_editor::terrain_palette::update_report().

std::map<reports::TYPE, std::string> display::get_report_contents (  )  [inline]

Definition at line 355 of file display.hpp.

References report_.

void display::draw_border ( const gamemap::location loc,
const int  xpos,
const int  ypos 
) [protected, virtual]

Draws the border tile overlay.

The routine determines by itself which border it is on and draws an overlay accordingly. The definition of the border is stored in the 'main_map_border' part of the theme.

Parameters:
loc the map location of the tile
xpos the on-screen pixels x coordinate of the tile
ypos the on-screen pixels y coordinate of the tile

at the moment the border must be between 0.0 and 0.5 and the image should always be prepared for a 0.5 border. This way this code doesn't need modifications for other border sizes.

Definition at line 1242 of file display.cpp.

References theme::border(), image::get_image(), get_screen_surface(), gamemap::h(), map_, rect, image::SCALED_TO_ZOOM, screen, theme_, gamemap::w(), gamemap::location::x, gamemap::location::y, and zoom_.

Referenced by game_display::draw(), and editor_display::draw().

void display::draw_minimap (  )  [protected]

std::vector< surface > display::get_terrain_images ( const gamemap::location loc,
const std::string  timeid,
image::TYPE  type,
ADJACENT_TERRAIN_TYPE  terrain_type 
) [protected]

std::vector< std::string > display::get_fog_shroud_graphics ( const gamemap::location loc  )  [protected]

void display::draw_image_for_report ( surface img,
SDL_Rect &  rect 
) [protected]

void display::scroll_to_xy ( int  screenxpos,
int  screenypos,
SCROLL_TYPE  scroll_type 
) [protected]

void display::draw_text_in_hex ( const gamemap::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.

(0.5, 0.5) is the center. The font size is adjusted to the zoom factor and divided by 2 for tiny-gui.

Definition at line 930 of file display.cpp.

References font::BLACK_COLOUR, drawing_buffer_add(), gamemap::get_drawing_order(), get_location_x(), get_location_y(), font::get_rendered_text(), get_zoom_factor(), and hex_size().

Referenced by game_display::draw_movement_info().

void display::drawing_buffer_add ( const tdrawing_layer  layer,
const int  drawing_order,
const tblit blit 
) [inline]

Add an item to the drawing buffer.

Parameters:
layer The layer to draw on.
drawing_order The order in which to draw, needed for units.
blit The structure to blit.

Definition at line 533 of file display.hpp.

References drawing_buffer_.

Referenced by game_display::draw(), editor_display::draw(), game_display::draw_bar(), game_display::draw_movement_info(), draw_text_in_hex(), unit::redraw_unit(), and render_unit_image().

void display::drawing_buffer_commit (  )  [protected]

Draws the drawing_buffer_ and clears it.

Definition at line 661 of file display.cpp.

References drawing_buffer_, drawing_buffer_clear(), get_screen_surface(), map, map_area(), update_rect(), and zoom_.

Referenced by game_display::draw(), and editor_display::draw().

void display::drawing_buffer_clear (  )  [protected]

Clears the drawing buffer.

Definition at line 715 of file display.cpp.

References drawing_buffer_.

Referenced by drawing_buffer_commit().

void display::draw_all_panels (  )  [protected]

redraw all panels associated with the map display

Definition at line 893 of file display.cpp.

References buttons_, create_buttons(), draw_label(), draw_panel(), CVideo::getSurface(), theme::labels(), labels(), theme::panels(), screen, screen_, theme_, and video().

Referenced by draw_init().

void display::invalidate_locations_in_rect ( SDL_Rect  r  )  [protected]

Definition at line 1049 of file display.cpp.

References get_rect_hex_bounds(), invalidate(), loc, gamemap::location::x, and gamemap::location::y.

Referenced by scroll().

bool display::draw_init (  )  [protected]

Invalidate controls and panels when changed after they have been drawn initially.

Initiate a redraw.

Useful for dynamic theme modification.

May require redrawing panels and background.

Definition at line 1075 of file display.cpp.

References benchmark, theme::border(), DBG_DP, draw_all_panels(), draw_background(), gamemap::empty(), get_screen_surface(), get_visible_hex_bounds(), invalidateAll_, invalidated_, map_, map_outside_area(), panelsDrawn_, redraw_background_, redrawMinimap_, screen, theme_, update_rect(), gamemap::location::x, and gamemap::location::y.

Referenced by game_display::draw(), and editor_display::draw().

void display::draw_wrap ( bool  update,
bool  force,
bool  changed 
) [protected]


Member Data Documentation

CVideo& display::screen_ [protected]

const gamemap& display::map_ [protected]

const viewpoint* display::viewpoint_ [protected]

Definition at line 389 of file display.hpp.

Referenced by draw_minimap(), fogged(), game_display::set_team(), and shrouded().

int display::xpos_ [protected]

int display::ypos_ [protected]

theme display::theme_ [protected]

int display::zoom_ [protected]

int display::last_zoom_ [protected]

Definition at line 393 of file display.hpp.

Referenced by set_default_zoom().

Definition at line 395 of file display.hpp.

Referenced by draw_minimap(), and recalculate_minimap().

SDL_Rect display::minimap_location_ [protected]

bool display::redrawMinimap_ [protected]

Definition at line 397 of file display.hpp.

Referenced by draw_init(), draw_wrap(), recalculate_minimap(), redraw_minimap(), and scroll().

bool display::redraw_background_ [protected]

Definition at line 398 of file display.hpp.

Referenced by draw_init(), redraw_everything(), and set_zoom().

bool display::invalidateAll_ [protected]

Definition at line 399 of file display.hpp.

Referenced by draw_init(), game_display::invalidate(), invalidate_all(), and screenshot().

bool display::grid_ [protected]

Definition at line 400 of file display.hpp.

Referenced by game_display::draw(), editor_display::draw(), and set_grid().

int display::diagnostic_label_ [protected]

Definition at line 401 of file display.hpp.

Referenced by set_diagnostic().

bool display::panelsDrawn_ [protected]

Definition at line 402 of file display.hpp.

Referenced by draw_init(), invalidate_theme(), and redraw_everything().

double display::turbo_speed_ [protected]

Definition at line 403 of file display.hpp.

Referenced by set_turbo_speed(), and turbo_speed().

bool display::turbo_ [protected]

Definition at line 404 of file display.hpp.

Referenced by set_turbo(), and turbo_speed().

Definition at line 406 of file display.hpp.

Referenced by labels(), redraw_everything(), scroll(), and set_zoom().

Event raised when the map is being scrolled.

Definition at line 408 of file display.hpp.

Referenced by scroll(), and scroll_event().

int display::nextDraw_ [protected]

Holds the tick count for when the next drawing event is scheduled.

Drawing shouldn't occur before this time.

Definition at line 411 of file display.hpp.

Referenced by draw_wrap().

SDL_Rect display::reportRects_[reports::NUM_REPORTS] [protected]

Definition at line 414 of file display.hpp.

Referenced by display(), redraw_everything(), and refresh_report().

surface display::reportSurfaces_[reports::NUM_REPORTS] [protected]

Definition at line 415 of file display.hpp.

Referenced by redraw_everything(), and refresh_report().

reports::report display::reports_[reports::NUM_REPORTS] [protected]

Definition at line 416 of file display.hpp.

Referenced by redraw_everything(), and refresh_report().

std::map<reports::TYPE, std::string> display::report_ [protected]

Definition at line 417 of file display.hpp.

Referenced by game_display::draw_report(), get_report_contents(), and set_report_content().

std::vector<gui::button> display::buttons_ [protected]

Definition at line 420 of file display.hpp.

Referenced by clear_hex_overlay(), game_display::draw(), and set_hex_overlay().

CKey display::keys_ [protected]

Definition at line 426 of file display.hpp.

Referenced by turbo_speed().

Definition at line 524 of file display.hpp.

Referenced by drawing_buffer_add(), drawing_buffer_clear(), and drawing_buffer_commit().

bool display::map_screenshot_ [protected]

Used to indicate to drawing funtions that we are doing a map screenshot.

Definition at line 565 of file display.hpp.

Referenced by get_screen_surface(), map_area(), map_outside_area(), and screenshot().

int display::fps_handle_ [private]

Handle for the label which displays frames per second.

Definition at line 569 of file display.hpp.

Referenced by update_display().

bool display::idle_anim_ [private]

Definition at line 571 of file display.hpp.

Referenced by idle_anim(), and set_idle_anim().

double display::idle_anim_rate_ [private]

Definition at line 572 of file display.hpp.

Referenced by idle_anim_rate(), and set_idle_anim_rate().

Definition at line 574 of file display.hpp.

Referenced by get_screen_surface(), and screenshot().


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

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs