game_display Class Reference

#include <game_display.hpp>

Inheritance diagram for game_display:

Inheritance graph
[legend]
Collaboration diagram for game_display:

Collaboration graph
[legend]

List of all members.

Public Types

enum  MESSAGE_TYPE { MESSAGE_PUBLIC, MESSAGE_PRIVATE }
enum  tgame_mode { RUNNING, LINGER_SP, LINGER_MP }
 Sets the linger mode for the display. More...

Public Member Functions

 game_display (unit_map &units, CVideo &video, const gamemap &map, const gamestatus &status, const std::vector< team > &t, const config &theme_cfg, const config &cfg, const config &level)
 ~game_display ()
void new_turn ()
 Update lighting settings.
void adjust_colours (int r, int g, int b)
 Add r,g,b to the colours for all images displayed on the map.
void scroll_to_leader (unit_map &units, int side, SCROLL_TYPE scroll_type=ONSCREEN)
 Scrolls to the leader of a certain side.
void draw (bool update=true, bool force=false)
 Draw for the game display has to know about units.
virtual void select_hex (gamemap::location hex)
 Function to display a location as selected.
virtual void highlight_hex (gamemap::location hex)
 Function to highlight a location.
void display_unit_hex (gamemap::location hex)
 Change the unit to be displayed in the sidebar.
void highlight_reach (const paths &paths_list)
 Sets the paths that are currently displayed as available for the unit to move along.
void highlight_another_reach (const paths &paths_list)
 Add more paths to highlight.
void unhighlight_reach ()
 Reset highlighting of paths.
void set_route (const paths::route *route)
 Sets the route along which footsteps are drawn to show movement of a unit.
void float_label (const gamemap::location &loc, const std::string &text, int red, int green, int blue)
 Function to float a label above a tile.
std::vector< surfacefootsteps_images (const gamemap::location &loc)
 Function to return 2 half-hex footsteps images for the given location.
void draw_movement_info (const gamemap::location &loc)
 Draws the movement info (turns available) for a given location.
void invalidate (const gamemap::location &loc)
 Function to invalidate a specific tile for redrawing.
const gamestatusget_game_status ()
void draw_report (reports::TYPE report_num)
void invalidate_unit ()
 Function to invalidate that unit status displayed on the sidebar.
void invalidate_unit_after_move (const gamemap::location &src, const gamemap::location &dst)
 Same as invalidate_unit() if moving the displayed unit.
void place_temporary_unit (unit &u, const gamemap::location &loc)
 Temporarily place a unit on map (moving: can overlap others).
void remove_temporary_unit ()
void set_attack_indicator (const gamemap::location &src, const gamemap::location &dst)
 Set the attack direction indicator.
void clear_attack_indicator ()
const std::string attack_indicator_direction () const
 Function to get attack direction suffix.
void add_overlay (const gamemap::location &loc, const std::string &image, const std::string &halo="")
 Functions to add and remove overlays from locations.
void remove_overlay (const gamemap::location &loc)
 remove_overlay will remove all overlays on a tile.
void remove_single_overlay (const gamemap::location &loc, const std::string &toDelete)
 remove_single_overlay will remove a single overlay from a tile
void write_overlays (config &cfg) const
 Function to serialize overlay data.
t_translation::t_terrain get_terrain_on (int palx, int paly, int x, int y)
void set_team (size_t team, bool observe=false)
 Sets the team controlled by the player using the computer.
void set_playing_team (size_t team)
size_t get_playing_team () const
const std::vector< team > & get_teams ()
unit_mapget_units ()
const unit_mapget_const_units () const
size_t viewing_team () const
 The viewing team is the team currently viewing the game.
size_t playing_team () const
 The playing team is the team whose turn it is.
bool team_valid () const
const std::string current_team_name () const
void add_observer (const std::string &name)
void remove_observer (const std::string &name)
const std::set< std::string > & observers () const
void add_chat_message (const time_t &time, const std::string &speaker, int side, const std::string &msg, MESSAGE_TYPE type, bool bell)
void clear_chat_messages ()
void begin_game ()
virtual bool in_game () const
void draw_bar (const std::string &image, int xpos, int ypos, const int drawing_order, size_t height, double filled, const SDL_Color &col, fixed_t alpha)
void set_game_mode (const tgame_mode game_mode)

Static Public Member Functions

static game_displayget_singleton ()
static void debug_highlight (const gamemap::location &loc, fixed_t amount)
 Draws a cross on a tile to emphasize something there.
static void clear_debug_highlights ()

Private Types

typedef std::multimap
< gamemap::location, overlay
overlay_map
typedef std::map
< gamemap::location, unsigned
int > 
reach_map

Private Member Functions

void invalidate_animations ()
 Function to invalidate animated terrains which may have changed.
virtual void draw_minimap_units ()
 game_display (const game_display &)
void operator= (const game_display &)
void draw_sidebar ()
void draw_game_status ()
surface get_flag (const gamemap::location &loc)
const SDL_Rect & calculate_energy_bar (surface surf)
 Finds the start and end rows on the energy bar image.
void invalidate_route ()
void prune_chat_messages (bool remove_all=false)
void process_reachmap_changes ()

Private Attributes

unit_mapunits_
unittemp_unit_
gamemap::location temp_unit_loc_
gamemap::location attack_indicator_src_
gamemap::location attack_indicator_dst_
std::map< surface, SDL_Rect > energy_bar_rects_
paths::route route_
const gamestatusstatus_
const std::vector< team > & teams_
const configlevel_
bool invalidateUnit_
gamemap::location displayedUnitHex_
overlay_map overlays_
size_t currentTeam_
size_t activeTeam_
double sidebarScaling_
bool first_turn_
bool in_game_
std::set< std::string > observers_
std::vector< chat_messagechat_messages_
surface tod_hex_mask1
surface tod_hex_mask2
reach_map reach_map_
reach_map reach_map_old_
bool reach_map_changed_
tgame_mode game_mode_
std::vector< animated
< image::locator > > 
flags_
 Animated flags for each team.

Static Private Attributes

static std::map
< gamemap::location, fixed_t
debugHighlights_
static game_displaysingleton_ = NULL

Classes

struct  chat_message
struct  overlay


Detailed Description

Definition at line 41 of file game_display.hpp.


Member Typedef Documentation

typedef std::multimap<gamemap::location,overlay> game_display::overlay_map [private]

Definition at line 257 of file game_display.hpp.

typedef std::map<gamemap::location,unsigned int> game_display::reach_map [private]

Definition at line 288 of file game_display.hpp.


Member Enumeration Documentation

Enumerator:
MESSAGE_PUBLIC 
MESSAGE_PRIVATE 

Definition at line 186 of file game_display.hpp.

Sets the linger mode for the display.

There have been some discussions on what to do with fog and shroud the extra variables make it easier to modify the behaviour. There might even be a split between victory and defeat.

Todo:
if the current implementation is wanted we can change the stuff back to a boolean
Enumerator:
RUNNING  no linger overlay, show fog and shroud
LINGER_SP  linger overlay, show fog and shroud
LINGER_MP 

Definition at line 204 of file game_display.hpp.


Constructor & Destructor Documentation

game_display::game_display ( unit_map units,
CVideo video,
const gamemap map,
const gamestatus status,
const std::vector< team > &  t,
const config theme_cfg,
const config cfg,
const config level 
)

game_display::~game_display (  ) 

Definition at line 144 of file game_display.cpp.

References prune_chat_messages(), and singleton_.

game_display::game_display ( const game_display  )  [private]


Member Function Documentation

static game_display* game_display::get_singleton (  )  [inline, static]

void game_display::new_turn (  ) 

void game_display::adjust_colours ( int  r,
int  g,
int  b 
)

Add r,g,b to the colours for all images displayed on the map.

Used for special effects like flashes.

Definition at line 203 of file game_display.cpp.

References time_of_day::blue, gamestatus::get_time_of_day(), time_of_day::green, time_of_day::red, image::set_colour_adjustment(), and status_.

Referenced by play_controller::init_gui().

void game_display::scroll_to_leader ( unit_map units,
int  side,
SCROLL_TYPE  scroll_type = ONSCREEN 
)

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

Draw for the game display has to know about units.

Todo:
FIXME: must modify changed, but best to do it at the floating_label level

Todo:
FIXME: This changed can probably be smarter

Implements display.

Definition at line 272 of file game_display.cpp.

References display::ADJACENT_BACKGROUND, display::ADJACENT_FOGSHROUD, display::ADJACENT_FOREGROUND, attack_indicator_direction(), attack_indicator_dst_, attack_indicator_src_, image::BRIGHTENED, game_config::cross_image, currentTeam_, game_config::debug, debugHighlights_, display::draw_border(), display::draw_init(), draw_movement_info(), draw_sidebar(), display::draw_wrap(), display::drawing_buffer_add(), display::drawing_buffer_commit(), gamemap::empty(), unit_map::end(), unit_map::find(), find_visible_unit(), display::fogged(), t_translation::FOGGED, footsteps_images(), game_mode_, gamemap::get_drawing_order(), get_flag(), image::get_image(), display::get_location_x(), display::get_location_y(), display::get_screen_surface(), gamemap::get_terrain(), display::get_terrain_images(), gamemap::get_terrain_info(), gamestatus::get_time_of_day(), display::grid_, game_config::grid_image, display::hex_overlay_, time_of_day::id, time_of_day::image_mask, invalidate_animations(), display::invalidated_, is_shrouded(), display::LAYER_LINGER_OVERLAY, display::LAYER_TERRAIN_BG, display::LAYER_TERRAIN_FG, display::LAYER_TERRAIN_TMP_BG, display::LAYER_TERRAIN_TMP_FG, game_config::linger_image, display::map_, display::map_area(), terrain_type::minimap_image(), display::mouseover_hex_overlay_, display::mouseoverHex_, t_translation::OFF_MAP_USER, gamemap::on_board(), overlays_, process_reachmap_changes(), prune_chat_messages(), reach_map_, rects_overlap(), unit::redraw_unit(), halo::render(), RUNNING, image::SCALED_TO_HEX, screen, display::screen_, display::selected_hex_overlay_, display::selectedHex_, display::shrouded(), status_, display::tblit::surf, teams_, temp_unit_, temp_unit_loc_, timeofday_at(), tod_hex_mask1, tod_hex_mask2, units_, image::UNMASKED, game_config::unreachable_image, halo::unrender(), CVideo::update_locked(), t_translation::VOID_TERRAIN, and display::zoom_.

Referenced by dialogs::animate_unit_advancement(), apply_shroud_changes(), attack::attack(), events::mouse_handler::attack_enemy_(), playsingle_controller::before_human_turn(), do_replay_handle(), events::menu_handler::end_unit_turn(), attack::fire_event(), playsingle_controller::handle_generic_event(), playsingle_controller::init_gui(), events::mouse_handler::left_click(), playsingle_controller::linger(), playmp_controller::linger(), events::mouse_handler::mouse_press(), unit_display::move_unit(), move_unit(), ai_interface::move_unit_partial(), new_turn(), playsingle_controller::play_ai_turn(), playsingle_controller::play_human_turn(), playmp_controller::play_human_turn(), playmp_controller::play_network_turn(), playsingle_controller::play_side(), playmp_controller::play_side(), play_controller::play_slice(), events::menu_handler::recall(), events::menu_handler::recruit(), events::menu_handler::redo(), events::menu_handler::undo(), events::menu_handler::unit_hold_position(), unit_display::unit_recruited(), unit_animator::wait_for_end(), and unit_animator::wait_until().

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

Function to display a location as selected.

If a unit is in the location, and there is no unit in the currently highlighted hex, the unit will be displayed in the sidebar.

Reimplemented from display.

Definition at line 209 of file game_display.cpp.

References display_unit_hex(), display::fogged(), display::select_hex(), and gamemap::location::valid().

Referenced by events::mouse_handler::left_click(), events::mouse_handler::move_unit_along_current_route(), events::mouse_handler::select_hex(), unit_display::unit_attack(), and events::menu_handler::unit_list().

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

Function to highlight a location.

If a unit is in the location, it will be displayed in the sidebar. Selection is used when a unit has been clicked on, while highlighting is used when a location has been moused over.

Reimplemented from display.

Definition at line 219 of file game_display.cpp.

References unit_map::count(), displayedUnitHex_, unit_map::end(), find_visible_unit(), display::highlight_hex(), display::invalidate_game_status(), invalidate_unit(), display::map_, display::mouseoverHex_, display::selectedHex_, teams_, units_, and viewing_team().

Referenced by events::mouse_handler::attack_enemy_(), and events::menu_handler::do_search().

void game_display::display_unit_hex ( gamemap::location  hex  ) 

Change the unit to be displayed in the sidebar.

This is used when selecting or highlighting is not wanted.

Definition at line 241 of file game_display.cpp.

References displayedUnitHex_, unit_map::end(), find_visible_unit(), invalidate_unit(), display::map_, teams_, units_, and viewing_team().

Referenced by ai_interface::move_unit_partial(), select_hex(), and unit_display::unit_healing().

void game_display::highlight_reach ( const paths paths_list  ) 

Sets the paths that are currently displayed as available for the unit to move along.

All other paths will be greyed out.

Definition at line 848 of file game_display.cpp.

References highlight_another_reach(), and unhighlight_reach().

Referenced by play_controller::handle_event(), events::mouse_handler::left_click(), events::mouse_handler::mouse_motion(), and events::mouse_handler::select_hex().

void game_display::highlight_another_reach ( const paths paths_list  ) 

Add more paths to highlight.

Print numbers where they overlap. Used only by Show Enemy Moves.

Definition at line 854 of file game_display.cpp.

References r, reach_map_, reach_map_changed_, and paths::routes.

Referenced by highlight_reach(), and events::menu_handler::show_enemy_moves().

void game_display::unhighlight_reach (  ) 

void game_display::set_route ( const paths::route route  ) 

void game_display::float_label ( const gamemap::location loc,
const std::string &  text,
int  red,
int  green,
int  blue 
)

std::vector< surface > game_display::footsteps_images ( const gamemap::location loc  ) 

Function to return 2 half-hex footsteps images for the given location.

Only loc is on the current route set by set_route.

Definition at line 758 of file game_display.cpp.

References unit_map::end(), unit_map::find(), game_config::foot_speed_prefix, game_config::foot_teleport_enter, game_config::foot_teleport_exit, image::get_image(), gamemap::get_terrain(), display::h(), display::map_, route_, gamemap::location::SOUTH_EAST, paths::route::steps, tiles_adjacent(), units_, and image::UNMASKED.

Referenced by draw().

void game_display::draw_movement_info ( const gamemap::location loc  ) 

void game_display::invalidate ( const gamemap::location loc  )  [virtual]

const gamestatus& game_display::get_game_status (  )  [inline]

Definition at line 112 of file game_display.hpp.

References status_.

void game_display::draw_report ( reports::TYPE  report_num  ) 

void game_display::invalidate_unit (  )  [inline]

void game_display::invalidate_unit_after_move ( const gamemap::location src,
const gamemap::location dst 
)

Same as invalidate_unit() if moving the displayed unit.

Definition at line 250 of file game_display.cpp.

References displayedUnitHex_, and invalidate_unit().

Referenced by unit_display::move_unit().

void game_display::invalidate_animations (  )  [private]

void game_display::draw_minimap_units (  )  [private, virtual]

void game_display::place_temporary_unit ( unit u,
const gamemap::location loc 
)

Temporarily place a unit on map (moving: can overlap others).

Definition at line 1078 of file game_display.cpp.

References invalidate(), temp_unit_, and temp_unit_loc_.

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

void game_display::remove_temporary_unit (  ) 

Definition at line 1085 of file game_display.cpp.

References unit::clear_haloes(), invalidate(), temp_unit_, and temp_unit_loc_.

Referenced by unit_display::move_unit().

void game_display::set_attack_indicator ( const gamemap::location src,
const gamemap::location dst 
)

Set the attack direction indicator.

Definition at line 1095 of file game_display.cpp.

References attack_indicator_dst_, attack_indicator_src_, and invalidate().

Referenced by clear_attack_indicator(), and events::mouse_handler::mouse_motion().

void game_display::clear_attack_indicator (  ) 

const std::string game_display::attack_indicator_direction (  )  const [inline]

Function to get attack direction suffix.

Definition at line 136 of file game_display.hpp.

References attack_indicator_dst_, attack_indicator_src_, gamemap::location::get_relative_dir(), and gamemap::location::write_direction().

Referenced by draw().

void game_display::add_overlay ( const gamemap::location loc,
const std::string &  image,
const std::string &  halo = "" 
)

Functions to add and remove overlays from locations.

An overlay is an image that is displayed on top of the tile. One tile may have multiple overlays.

Definition at line 1114 of file game_display.cpp.

References halo::add(), display::get_location_x(), display::get_location_y(), display::hex_size(), and overlays_.

Referenced by playsingle_controller::play_scenario().

void game_display::remove_overlay ( const gamemap::location loc  ) 

remove_overlay will remove all overlays on a tile.

Definition at line 1123 of file game_display.cpp.

References overlays_, and halo::remove().

void game_display::remove_single_overlay ( const gamemap::location loc,
const std::string &  toDelete 
)

remove_single_overlay will remove a single overlay from a tile

Definition at line 1135 of file game_display.cpp.

References overlays_, and halo::remove().

void game_display::write_overlays ( config cfg  )  const

Function to serialize overlay data.

Definition at line 1155 of file game_display.cpp.

References config::add_child(), and overlays_.

Referenced by game_events::write_events().

t_translation::t_terrain game_display::get_terrain_on ( int  palx,
int  paly,
int  x,
int  y 
)

void game_display::set_team ( size_t  team,
bool  observe = false 
)

void game_display::set_playing_team ( size_t  team  ) 

size_t game_display::get_playing_team (  )  const [inline]

const std::vector<team>& game_display::get_teams (  )  [inline]

Definition at line 164 of file game_display.hpp.

References teams_.

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

unit_map& game_display::get_units (  )  [inline]

const unit_map& game_display::get_const_units (  )  const [inline]

Definition at line 167 of file game_display.hpp.

References units_.

Referenced by unit_animation::matches().

void game_display::debug_highlight ( const gamemap::location loc,
fixed_t  amount 
) [static]

Draws a cross on a tile to emphasize something there.

It is used in debug mode, typically to show AI plans.

Definition at line 1072 of file game_display.cpp.

References game_config::debug, and debugHighlights_.

static void game_display::clear_debug_highlights (  )  [inline, static]

Definition at line 172 of file game_display.hpp.

References debugHighlights_.

Referenced by playsingle_controller::play_side().

size_t game_display::viewing_team (  )  const [inline]

size_t game_display::playing_team (  )  const [inline]

bool game_display::team_valid (  )  const [inline]

const std::string game_display::current_team_name (  )  const

Definition at line 1165 of file game_display.cpp.

References currentTeam_, team_valid(), and teams_.

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

void game_display::add_observer ( const std::string &  name  )  [inline]

Definition at line 182 of file game_display.hpp.

References observers_.

Referenced by turn_info::process_network_data().

void game_display::remove_observer ( const std::string &  name  )  [inline]

Definition at line 183 of file game_display.hpp.

References observers_.

Referenced by turn_info::process_network_data().

const std::set<std::string>& game_display::observers (  )  const [inline]

void game_display::add_chat_message ( const time_t &  time,
const std::string &  speaker,
int  side,
const std::string &  msg,
game_display::MESSAGE_TYPE  type,
bool  bell 
)

void game_display::clear_chat_messages (  )  [inline]

void game_display::begin_game (  ) 

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

Reimplemented from display.

Definition at line 193 of file game_display.hpp.

References in_game_.

void game_display::draw_bar ( const std::string &  image,
int  xpos,
int  ypos,
const int  drawing_order,
size_t  height,
double  filled,
const SDL_Color &  col,
fixed_t  alpha 
)

void game_display::set_game_mode ( const tgame_mode  game_mode  ) 

void game_display::operator= ( const game_display  )  [private]

void game_display::draw_sidebar (  )  [private]

void game_display::draw_game_status (  )  [private]

surface game_display::get_flag ( const gamemap::location loc  )  [private]

const SDL_Rect & game_display::calculate_energy_bar ( surface  surf  )  [private]

Finds the start and end rows on the energy bar image.

White pixels are substituted for the colour of the energy

Definition at line 957 of file game_display.cpp.

References boost::foreach_detail_::begin(), energy_bar_rects_, make_neutral_surface(), and surface_lock::pixels().

Referenced by draw_bar().

void game_display::invalidate_route (  )  [private]

Definition at line 915 of file game_display.cpp.

References invalidate(), route_, and paths::route::steps.

Referenced by set_route().

void game_display::prune_chat_messages ( bool  remove_all = false  )  [private]

void game_display::process_reachmap_changes (  )  [private]


Member Data Documentation

Definition at line 227 of file game_display.hpp.

Referenced by attack_indicator_direction(), draw(), and set_attack_indicator().

Definition at line 228 of file game_display.hpp.

Referenced by attack_indicator_direction(), draw(), and set_attack_indicator().

Definition at line 233 of file game_display.hpp.

Referenced by calculate_energy_bar().

Definition at line 237 of file game_display.hpp.

Referenced by adjust_colours(), draw(), draw_report(), get_game_status(), and new_turn().

const std::vector<team>& game_display::teams_ [private]

const config& game_display::level_ [private]

Definition at line 241 of file game_display.hpp.

Referenced by draw_report().

Definition at line 245 of file game_display.hpp.

Referenced by draw_sidebar(), and invalidate_unit().

size_t game_display::currentTeam_ [private]

size_t game_display::activeTeam_ [private]

Definition at line 261 of file game_display.hpp.

Referenced by draw_report(), get_playing_team(), playing_team(), and set_playing_team().

Definition at line 263 of file game_display.hpp.

bool game_display::first_turn_ [private]

Definition at line 265 of file game_display.hpp.

Referenced by new_turn().

bool game_display::in_game_ [private]

Definition at line 265 of file game_display.hpp.

Referenced by begin_game(), and in_game().

std::set<std::string> game_display::observers_ [private]

Definition at line 267 of file game_display.hpp.

Referenced by add_observer(), draw_report(), observers(), and remove_observer().

Definition at line 281 of file game_display.hpp.

Referenced by add_chat_message(), and prune_chat_messages().

Definition at line 285 of file game_display.hpp.

Referenced by draw(), and new_turn().

Definition at line 285 of file game_display.hpp.

Referenced by draw(), and new_turn().

Definition at line 290 of file game_display.hpp.

Referenced by process_reachmap_changes().

Definition at line 294 of file game_display.hpp.

Referenced by draw(), and set_game_mode().

Definition at line 297 of file game_display.hpp.

Referenced by clear_debug_highlights(), debug_highlight(), and draw().

std::vector<animated<image::locator> > game_display::flags_ [private]

Animated flags for each team.

Definition at line 300 of file game_display.hpp.

Referenced by game_display(), get_flag(), and invalidate_animations().

game_display * game_display::singleton_ = NULL [static, private]

Definition at line 302 of file game_display.hpp.

Referenced by game_display(), get_singleton(), and ~game_display().


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