49 #define ERR_DP LOG_STREAM(err, log_display) 50 #define LOG_DP LOG_STREAM(info, log_display) 53 #define ERR_NG LOG_STREAM(err, log_engine) 70 display(&board, wb, reports_object, theme_cfg, level, false),
72 attack_indicator_src_(),
73 attack_indicator_dst_(),
105 const int niterations =
static_cast<int>(10/
turbo_speed());
106 const int frame_time = 30;
107 const int starting_ticks = SDL_GetTicks();
108 for(
int i = 0;
i != niterations; ++
i) {
110 if(old_mask !=
nullptr) {
116 if(new_mask !=
nullptr) {
124 const int cur_ticks = SDL_GetTicks();
125 const int wanted_ticks = starting_ticks +
i*frame_time;
126 if(cur_ticks < wanted_ticks) {
127 SDL_Delay(wanted_ticks - cur_ticks);
209 if (std::shared_ptr<wb::manager>
w =
wb_.lock()) {
222 if (std::shared_ptr<wb::manager>
w =
wb_.lock()) {
308 if (std::shared_ptr<wb::manager>
w =
wb_.lock()) {
311 if (!(
w->is_active() &&
w->has_temp_move()))
314 if (!footstepImages.empty()) {
343 if(!is_shrouded && on_map) {
350 std::string txt = std::to_string(debugH);
403 std::shared_ptr<wb::manager>
wb =
wb_.lock();
409 (wb && wb->get_temp_move_unit().valid()) ?
413 int move_cost = un->movement_cost(
get_map().get_terrain(loc));
415 0 : 100 - un->defense_modifier(
get_map().get_terrain(loc)));
416 std::stringstream def_text;
417 def_text << def <<
"%";
422 int def_font = w->second.turns > 0 ? 18 : 16;
427 if (w->second.invisible) {
437 if (w->second.capture) {
443 if (w->second.turns > 1 || (w->second.turns == 1 && loc !=
route_.
steps.back())) {
444 std::stringstream turns_text;
445 turns_text << w->second.turns;
460 int move_cost = selectedUnit->movement_cost(
get_map().get_terrain(loc));
462 0 : 100 - selectedUnit->defense_modifier(
get_map().get_terrain(loc)));
463 std::stringstream def_text;
464 def_text << def <<
"%";
476 if (reach !=
reach_map_.end() && reach->second > 1) {
477 const std::string num = std::to_string(reach->second);
485 std::vector<surface> res;
487 if (route_.
steps.size() < 2) {
491 std::vector<map_location>::const_iterator
i =
494 if( i == route_.
steps.end()) {
505 if (image_number < 1) {
514 const int first_half = (i == route_.
steps.begin()) ? 1 : 0;
516 const int second_half = (i+1 == route_.
steps.end()) ? 0 : 1;
518 for (
int h = first_half;
h <= second_half; ++
h) {
519 const std::string sense(
h==0 ?
"-in" :
"-out" );
522 std::string teleport_image =
534 dir = i->get_opposite_dir(dir);
535 rotate =
"~FL(horiz)~FL(vert)";
538 const std::string
image = foot_speed_prefix
539 + sense +
"-" + i->write_direction(dir)
546 if (teleport !=
nullptr) res.push_back(teleport);
570 const map_location enemy_unit_location = path_to_goal[0];
589 for(std::vector<map_location>::const_iterator
i =
route_.
steps.begin();
599 if(route !=
nullptr) {
657 return std::string();
The overlay used for the linger mode.
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
void invalidate_unit_after_move(const map_location &src, const map_location &dst)
Same as invalidate_unit() if moving the displayed unit.
virtual void select_hex(map_location hex)
::tod_manager * tod_manager
void set_game_mode(const game_mode mode)
reports * reports_object_
const team & get_team(int side) const
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.
game_mode
Sets the linger mode for the display.
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.
This class represents a single unit of a specific type.
void set_move(double xmove, double ymove)
virtual overlay_map & get_overlays() override
Inherited from display.
const time_of_day & get_previous_time_of_day() const
unit_iterator find_leader(int side)
map_location attack_indicator_src_
static const int UNREACHABLE
Magic value that signifies a hex is unreachable.
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.
std::set< map_location > units_that_can_reach_goal_
const std::set< std::string > & report_list()
bool is_shrouded(const display *disp, const map_location &loc)
Our definition of map labels being obscured is if the tile is obscured, or the tile below is obscured...
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Bottom half of image following the mouse.
map_location displayedUnitHex_
map_location selectedHex_
void set_font_size(int font_size)
virtual void post_commit() override
Hook for actions to take right after draw() calls drawing_buffer_commit No action here by default...
static unsigned int zoom_
The current zoom, in pixels (on screen) per 72 pixels (in the graphic assets), i.e., 72 means 100%.
drawing_layer
The layers to render something on.
virtual const gamemap & map() const =0
void new_turn()
Update lighting settings.
static std::map< map_location, int > debugHighlights_
Unit and team statistics.
t_translation::terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
Top half of image following the mouse.
static lg::log_domain log_display("display")
void highlight_another_reach(const pathfind::paths &paths_list, const map_location &goal=map_location::null_location())
Add more paths to highlight.
no linger overlay, show fog and shroud.
Object which defines a time of day with associated bonuses, image, sounds etc.
Image on the selected unit.
game_display(game_board &board, std::weak_ptr< wb::manager > wb, reports &reports_object, const config &theme_cfg, const config &level, bool dummy=false)
void scroll_to_leader(int side, SCROLL_TYPE scroll_type=ONSCREEN, bool force=true)
Scrolls to the leader of a certain side.
void adjust_surface_alpha(surface &surf, fixed_t amount)
double turbo_speed() const
virtual void draw_invalidated() override
Only called when there's actual redrawing to do.
unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
void set_lifetime(int lifetime)
std::map< map_location, std::vector< overlay > > overlay_map
Applies the planned unit map for the duration of the struct's life.
void recalculate_minimap()
Schedule the minimap for recalculation.
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.
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
virtual const time_of_day & get_time_of_day(const map_location &loc) const override
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
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.
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
std::size_t count(const map_location &loc) const
Structure which holds a single route and marks for special events.
const color_t YELLOW_COLOR
void needs_rebuild(bool b)
Sets whether the screen (map visuals) needs to be rebuilt. This is typically after the map has been c...
virtual void draw_sidebar() override
Called near the end of a draw operation, derived classes can use this to render a specific sidebar...
void invalidate_all()
Function to invalidate all tiles.
pathfind::marked_route route_
virtual void draw_hex(const map_location &loc) override
Redraws a single gamemap location.
std::vector< map_location > get_path(const const_iterator &) const
Returns the path going from the source point (included) to the destination point j (excluded)...
std::string attack_indicator_direction() const
Function to get attack direction suffix.
const color_t NORMAL_COLOR
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
std::unique_ptr< halo::manager > halo_man_
#define ftofxp(x)
IN: float or int - OUT: fixed_t.
Encapsulates the map of the game.
void float_label(const map_location &loc, const std::string &text, const color_t &color)
Function to float a label above a tile.
void set_color(const color_t &color)
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
unit_iterator find(std::size_t id)
void process_reachmap_changes()
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
std::string current_team_name() const
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
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.
virtual void highlight_hex(map_location hex) override
Function to highlight a location.
virtual void highlight_hex(map_location hex)
bool has_time_area() const
virtual void select_hex(map_location hex) override
Function to display a location as selected.
int get_location_y(const map_location &loc) const
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.
Movement info (defense%, etc...).
std::vector< std::string > foot_speed_prefix
virtual bool has_time_area() const override
static lg::log_domain log_engine("engine")
void drawing_buffer_add(const drawing_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.
bool show_floating_labels()
std::string foot_teleport_exit
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
const gamemap & get_map() const
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 ...
void redraw_unit(const unit &u) const
draw a unit.
bool unhighlight_reach()
Reset highlighting of paths.
color_t 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...
std::set< map_location > invalidated_
bool find(E event, F functor)
Tests whether an event handler is available.
const display_context * dc_
std::size_t viewing_team() const
The viewing team is the team currently viewing the game.
bool contains(const map_location &) const
this module manages the cache of images.
Standard logging facilities (interface).
CVideo & video()
Gets the underlying screen object.
Object which contains all the possible locations a unit can move to, with associated best routes to t...
virtual void pre_draw() override
game_display pre_draw does specific things related e.g.
static const map_location & null_location()
virtual void post_draw() override
Calls the whiteboard's post-draw method.
map_location attack_indicator_dst_
const std::unique_ptr< fake_unit_manager > fake_unit_man_
int side() const
The side this unit belongs to.
const_iterator find(const map_location &) const
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 clear_screen()
Clear the screen contents.
void set_route(const pathfind::marked_route *route)
Sets the route along which footsteps are drawn to show movement of a unit.
void clear_attack_indicator()
void display_unit_hex(map_location hex)
Change the unit to be displayed in the sidebar.
std::string::const_iterator iterator
unit_map::iterator find_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
void refresh_report(const std::string &report_name, const config *new_cfg=nullptr)
Redraws the specified report (if anything has changed).
void set_attack_indicator(const map_location &src, const map_location &dst)
Set the attack direction indicator.
std::weak_ptr< wb::manager > wb_
std::vector< map_location > & steps
Layer which holds the attack indicator.
Footsteps showing path from unit to mouse.
"black stripes" on unreachable hexes.
void rebuild_all()
Rebuild all dynamic terrain.
const std::vector< map_location > & route_
const std::unique_ptr< display_chat_manager > chat_man_
bool maybe_rebuild()
Rebuilds the screen if needs_rebuild(true) was previously called, and resets the flag.