The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Namespaces | Macros | Functions
udisplay.cpp File Reference
#include "global.hpp"
#include "units/udisplay.hpp"
#include "fake_unit_manager.hpp"
#include "fake_unit_ptr.hpp"
#include "game_board.hpp"
#include "game_display.hpp"
#include "game_preferences.hpp"
#include "log.hpp"
#include "mouse_events.hpp"
#include "resources.hpp"
#include "sound.hpp"
#include "terrain/filter.hpp"
#include "units/unit.hpp"
#include "units/animation_component.hpp"
#include "units/filter.hpp"
#include "units/map.hpp"
Include dependency graph for udisplay.cpp:

Go to the source code of this file.

Namespaces

 unit_display
 Contains a number of free functions which display units.
 

Macros

#define LOG_DP   LOG_STREAM(info, display)
 

Functions

static std::string number_and_text (int number, const std::string &text)
 Returns a string whose first line is number, centered over a second line, which consists of text. More...
 
static void teleport_unit_between (const map_location &a, const map_location &b, unit &temp_unit, display &disp)
 Animates a teleportation between hexes. More...
 
static int move_unit_between (const map_location &a, const map_location &b, unit_ptr temp_unit, unsigned int step_num, unsigned int step_left, unit_animator &animator, display &disp)
 Animates a single step between hexes. More...
 
void unit_display::move_unit (const std::vector< map_location > &path, unit_ptr u, bool animate, map_location::DIRECTION dir, bool force_scroll)
 Display a unit moving along a given path. More...
 
void unit_display::reset_helpers (const unit *attacker, const unit *defender)
 
void unit_display::unit_draw_weapon (const map_location &loc, unit &u, const attack_type *attack=nullptr, const attack_type *secondary_attack=nullptr, const map_location &defender_loc=map_location::null_location(), unit *defender=nullptr)
 Play a pre-fight animation First unit is the attacker, second unit the defender. More...
 
void unit_display::unit_sheath_weapon (const map_location &loc, unit *u=nullptr, const attack_type *attack=nullptr, const attack_type *secondary_attack=nullptr, const map_location &defender_loc=map_location::null_location(), unit *defender=nullptr)
 Play a post-fight animation Both unit can be set to null, only valid units will play their animation. More...
 
void unit_display::unit_die (const map_location &loc, unit &u, const attack_type *attack=nullptr, const attack_type *secondary_attack=nullptr, const map_location &winner_loc=map_location::null_location(), unit *winner=nullptr)
 Show a unit fading out. More...
 
void unit_display::unit_attack (display *disp, game_board &board,const map_location &a, const map_location &b, int damage, const attack_type &attack, const attack_type *secondary_attack, int swing, std::string hit_text, int drain_amount, std::string att_text, const std::vector< std::string > *extra_hit_sounds=nullptr)
 Make the unit on tile 'a' attack the unit on tile 'b'. More...
 
void unit_display::unit_recruited (const map_location &loc, const map_location &leader_loc)
 
void unit_display::unit_healing (unit &healed, const std::vector< unit * > &healers, int healing, const std::string &extra_text="")
 This will use a poisoning anim if healing<0. More...
 
void unit_display::wml_animation_internal (unit_animator &animator, const vconfig &cfg, const map_location &default_location=map_location::null_location())
 
void unit_display::wml_animation (const vconfig &cfg, const map_location &default_location=map_location::null_location())
 Parse a standard WML for animations and play the corresponding animation. More...
 

Macro Definition Documentation

#define LOG_DP   LOG_STREAM(info, display)

Definition at line 35 of file udisplay.cpp.

Function Documentation

static int move_unit_between ( const map_location a,
const map_location b,
unit_ptr  temp_unit,
unsigned int  step_num,
unsigned int  step_left,
unit_animator animator,
display disp 
)
static

Animates a single step between hexes.

This will return before the animation actually finishes, allowing other processing to occur during the animation.

Parameters
aThe starting hex.
bThe ending hex.
temp_unitThe unit to animate (historically, a temporary unit).
step_numThe number of steps taken so far (used to pick an animation).
step_leftThe number of steps remaining (used to pick an animation).
animatorThe unit_animator to use. This is assumed clear when we start, but will likely not be clear when we return.
dispThe game display. Assumed neither locked nor faked.
Returns
The animation potential until this animation will finish. INT_MIN indicates that no animation is pending.

Definition at line 118 of file udisplay.cpp.

References display::fogged(), unit_animator::get_animation_time_potential(), map_location::get_relative_dir(), unit_animation::INVALID, display::invalidate(), display::ONSCREEN, unit_animator::pause_animation(), unit_animator::replace_anim_if_invalid(), unit_animator::restart_animation(), display::scroll_to_tiles(), and unit_animator::start_animations().

Referenced by unit_display::unit_mover::proceed_to().

static std::string number_and_text ( int  number,
const std::string text 
)
static

Returns a string whose first line is number, centered over a second line, which consists of text.

If the number is 0, the first line is suppressed.

Definition at line 43 of file udisplay.cpp.

Referenced by unit_display::unit_attack(), and unit_display::unit_healing().

static void teleport_unit_between ( const map_location a,
const map_location b,
unit temp_unit,
display disp 
)
static

Animates a teleportation between hexes.

Parameters
aThe starting hex.
bThe ending hex.
temp_unitThe unit to animate (historically, a temporary unit).
dispThe game display. Assumed neither locked nor faked.

Definition at line 68 of file udisplay.cpp.

References unit_animator::add_animation(), unit::anim_comp(), display::fogged(), map_location::get_relative_dir(), display::invalidate(), display::ONSCREEN, events::pump(), display::scroll_to_tiles(), unit::set_facing(), unit::set_location(), unit_animation_component::set_standing(), unit_animator::start_animations(), display::update_display(), and unit_animator::wait_for_end().

Referenced by unit_display::unit_mover::proceed_to().