48 #include <boost/make_shared.hpp>
51 #define ERR_DP LOG_STREAM(err, log_display)
52 #define LOG_DP LOG_STREAM(info, log_display)
55 #define ERR_NG LOG_STREAM(err, log_engine)
77 display(&board, video, wb, reports_object, theme_cfg, level, false),
79 attack_indicator_src_(),
80 attack_indicator_dst_(),
99 static game_board dummy_board(boost::make_shared<terrain_type_data>(dummy_cfg), dummy_cfg2);
103 dummy_cfg, dummy_cfg,
true);
126 const int niterations =
static_cast<int>(10/
turbo_speed());
127 const int frame_time = 30;
128 const int starting_ticks = SDL_GetTicks();
129 for(
int i = 0;
i != niterations; ++
i) {
132 if(old_mask !=
nullptr) {
137 if(new_mask !=
nullptr) {
142 if(old_mask !=
nullptr) {
147 if(new_mask !=
nullptr) {
156 const int cur_ticks = SDL_GetTicks();
157 const int wanted_ticks = starting_ticks +
i*frame_time;
158 if(cur_ticks < wanted_ticks) {
159 SDL_Delay(wanted_ticks - cur_ticks);
381 if (!(
w->is_active() &&
w->has_temp_move()))
388 if (!footstepImages.empty()) {
441 if(!is_shrouded && on_map) {
506 (wb && wb->get_temp_move_unit().valid()) ?
510 int def = 100 - un->defense_modifier(
get_map().get_terrain(loc));
511 std::stringstream def_text;
512 def_text << def <<
"%";
517 int def_font = w->second.turns > 0 ? 18 : 16;
523 if (w->second.invisible) {
533 if (w->second.capture) {
538 if (w->second.invisible) {
548 if (w->second.capture) {
555 if (w->second.turns > 1 || (w->second.turns == 1 && loc !=
route_.
steps.back())) {
556 std::stringstream turns_text;
557 turns_text << w->second.turns;
572 int def = 100 - selectedUnit->defense_modifier(
get_map().get_terrain(loc));
573 std::stringstream def_text;
574 def_text << def <<
"%";
586 if (reach !=
reach_map_.end() && reach->second > 1) {
600 std::vector<sdl::timage>
res;
602 std::vector<surface>
res;
605 if (route_.
steps.size() < 2) {
609 std::vector<map_location>::const_iterator
i =
612 if( i == route_.
steps.end()) {
623 if (image_number < 1) {
629 sdl::timage teleport;
636 const int first_half = (i == route_.
steps.begin()) ? 1 : 0;
638 const int second_half = (i+1 == route_.
steps.end()) ? 0 : 1;
640 for (
int h = first_half;
h <= second_half; ++
h) {
660 dir = i->get_opposite_dir(dir);
661 rotate =
"~FL(horiz)~FL(vert)";
665 + sense +
"-" + i->write_direction(dir)
677 if (!teleport.
null()) res.push_back(teleport);
679 if (teleport !=
nullptr) res.push_back(teleport);
712 for(std::vector<map_location>::const_iterator
i = route_.
steps.begin();
713 i != route_.
steps.end(); ++
i) {
722 if(route !=
nullptr) {
725 route_.
steps.clear();
726 route_.
marks.clear();
void drawing_buffer_add(const tdrawing_layer layer, const map_location &loc, int x, int y, const surface &surf, const SDL_Rect &clip=SDL_Rect())
Add an item to the drawing buffer.
boost::scoped_ptr< fake_unit_manager > fake_unit_man_
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
virtual void highlight_hex(map_location hex)
Function to highlight a location.
void invalidate_unit_after_move(const map_location &src, const map_location &dst)
Same as invalidate_unit() if moving the displayed unit.
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
std::string attack_indicator_direction() const
Function to get attack direction suffix.
virtual void select_hex(map_location hex)
reports * reports_object_
static game_display * create_dummy_display(CVideo &video)
static int & debug_highlight(const map_location &loc)
annotate hex with number, useful for debugging or UI prototype
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
std::string image_mask
The image that is to be laid over all images while this time of day lasts.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
boost::weak_ptr< wb::manager > wb_
std::map< surface, SDL_Rect > energy_bar_rects_
void set_move(double xmove, double ymove)
size_t count(const map_location &loc) const
std::string current_team_name() const
unit_iterator find_leader(int side)
SDL_Color int_to_color(const Uint32 rgb)
map_location attack_indicator_src_
Top half of image following the mouse.
const time_of_day & get_time_of_day(int for_turn=0) const
Returns global time of day for the passed turn.
#define fxpdiv(x, y)
IN: unsigned and int - OUT: fixed_t.
virtual void draw_invalidated()
Only called when there's actual redrawing to do.
map_location mouseoverHex_
void invalidate_unit()
Function to invalidate that unit status displayed on the sidebar.
const std::set< std::string > & report_list()
Footsteps showing path from unit to mouse.
void float_label(const map_location &loc, const std::string &text, const SDL_Color &color)
Function to float a label above a tile.
Movement info (defense%, etc...).
Layer which holds the attack indicator.
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
map_location displayedUnitHex_
map_location selectedHex_
void set_font_size(int font_size)
void draw_text_in_hex(const map_location &loc, const tdrawing_layer layer, const std::string &text, size_t font_size, SDL_Color color, double x_in_hex=0.5, double y_in_hex=0.5)
Draw text on a hex.
virtual void draw()
Draws invalidated items.
const SDL_Color NORMAL_COLOR
no linger overlay, show fog and shroud.
void draw_invalidated()
Only called when there's actual redrawing to do.
virtual const gamemap & map() const =0
void new_turn()
Update lighting settings.
Uint32 red_to_green(int val, bool for_text)
Return a color corresponding to the value val red for val=0 to green for val=100, passing by yellow...
static std::map< map_location, int > debugHighlights_
Unit and team statistics.
int get_location_y(const map_location &loc) const
bool has_time_area() const
"black stripes" on unreachable hexes.
const time_of_day & get_previous_time_of_day() const
static lg::log_domain log_display("display")
GLdouble GLdouble GLdouble b
Object which defines a time of day with associated bonuses, image, sounds etc.
static std::vector< team > *& teams
tdrawing_layer
The layers to render something on.
void scroll_to_leader(int side, SCROLL_TYPE scroll_type=ONSCREEN, bool force=true)
Scrolls to the leader of a certain side.
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
const SDL_Color BAD_COLOR
const time_of_day & get_time_of_day(const map_location &loc) const
unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
void set_lifetime(int lifetime)
Applies the planned unit map for the duration of the struct's life.
void pre_draw()
game_display pre_draw does specific things related e.g.
void recalculate_minimap()
Schedule the minimap for recalculation.
virtual void select_hex(map_location hex)
Function to display a location as selected.
GLubyte GLubyte GLubyte GLubyte w
surface adjust_surface_alpha(const surface &surf, fixed_t amount, bool optimize)
std::vector< surface > footsteps_images(const map_location &loc, const pathfind::marked_route &route_, const display_context *dc_)
Function to return 2 half-hex footsteps images for the given location.
std::string foot_teleport_enter
bool is_shrouded(const display &disp, const map_location &loc)
void set_color(const SDL_Color &color)
void highlight_another_reach(const pathfind::paths &paths_list)
Add more paths to highlight.
bool invalidateGameStatus_
void highlight_reach(const pathfind::paths &paths_list)
Sets the paths that are currently displayed as available for the unit to move along.
void set_position(double xpos, double ypos)
virtual const unit_map & units() const =0
void set_game_mode(const tgame_mode game_mode)
Structure which holds a single route and marks for special events.
static const map_location & null_location()
void needs_rebuild(bool b)
Sets whether the screen (map visuals) needs to be rebuilt. This is typically after the map has been c...
void invalidate_all()
Function to invalidate all tiles.
pathfind::marked_route route_
void draw_sidebar()
Called near the end of a draw operation, derived classes can use this to render a specific sidebar...
tgame_mode
Sets the linger mode for the display.
Encapsulates the map of the game.
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
double turbo_speed() const
void process_reachmap_changes()
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
virtual const std::vector< team > & teams() const =0
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.
void unhighlight_reach()
Reset highlighting of paths.
virtual void highlight_hex(map_location hex)
void post_draw()
Calls the whiteboard's post-draw method.
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
GLfloat GLfloat GLfloat GLfloat h
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
DIRECTION
Valid directions which can be moved in our hexagonal world.
virtual void draw_hex(const map_location &loc)
Redraws a single gamemap location.
The overlay used for the linger mode.
std::vector< std::string > foot_speed_prefix
static lg::log_domain log_engine("engine")
const tod_manager * tod_manager_
GLuint const GLchar * name
t_translation::t_terrain get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
game_display(game_board &board, CVideo &video, boost::weak_ptr< wb::manager > wb, reports &reports_object, const tod_manager &tod_manager, const config &theme_cfg, const config &level, bool dummy=false)
std::map< map_location, unsigned int > reach_map
bool show_floating_labels()
std::string foot_teleport_exit
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 ...
bool has_time_area() const
const gamemap & get_map() const
std::set< map_location > invalidated_
bool find(E event, F functor)
Tests whether an event handler is available.
void post_commit()
Hook for actions to take right after draw() calls drawing_buffer_commit No action here by default...
void clear_screen()
Clear the screen contents.
Image on the selected unit.
const display_context * dc_
this module manages the cache of images.
void update_tod()
Add r,g,b from tod_manager to the map.
Standard logging facilities (interface).
void assign(const surface &o)
Object which contains all the possible locations a unit can move to, with associated best routes to t...
Bottom half of image following the mouse.
void set_playing_team(size_t team)
Sets the team controlled by the player using the computer.
map_location attack_indicator_dst_
const SDL_Color YELLOW_COLOR
unit_iterator find(size_t id)
size_t viewing_team() const
The viewing team is the team currently viewing the game.
boost::scoped_ptr< halo::manager > halo_man_
void draw_movement_info(const map_location &loc)
Draws the movement info (turns available) for a given location.
A config object defines a single node in a WML file, with access to child nodes.
void refresh_report(std::string const &report_name, const config *new_cfg=nullptr)
Redraws the specified report (if anything has changed).
void set_route(const pathfind::marked_route *route)
Sets the route along which footsteps are drawn to show movement of a unit.
boost::scoped_ptr< display_chat_manager > chat_man_
void clear_attack_indicator()
void redraw_unit(const unit &u) const
draw a unit.
void draw_hex(const map_location &loc)
Redraws a single gamemap location.
GLsizei const GLcharARB ** string
void display_unit_hex(map_location hex)
Change the unit to be displayed in the sidebar.
unit_map::iterator find_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
void set_attack_indicator(const map_location &src, const map_location &dst)
Set the attack direction indicator.
std::vector< map_location > & steps
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
void rebuild_all()
Rebuild all dynamic terrain.
const std::vector< map_location > & route_
void replace_overlay_map(overlay_map *overlays)
bool maybe_rebuild()
Rebuilds the screen if needs_rebuild(true) was previously called, and resets the flag.