The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
battle_prediction_pane Class Reference

#include <attack_prediction_display.hpp>

Inheritance diagram for battle_prediction_pane:
Inheritance graph

Public Member Functions

 battle_prediction_pane (const battle_context &bc, const map_location &attacker_loc, const map_location &defender_loc)
 
void draw_contents ()
 
bool left_side () const
 
void set_selection (int)
 
- Public Member Functions inherited from gui::preview_pane
 preview_pane (CVideo &video)
 
virtual ~preview_pane ()
 
virtual bool show_above () const
 
virtual sdl_handler_vector handler_members ()
 
- Public Member Functions inherited from gui::widget
SDL_Rect const & location () const
 
virtual void set_location (SDL_Rect const &rect)
 
void set_location (int x, int y)
 
void set_width (int w)
 
void set_height (int h)
 
void set_measurements (int w, int h)
 
int width () const
 
int height () const
 
bool focus (const SDL_Event *event)
 
void set_focus (bool focus)
 
virtual void hide (bool value=true)
 
bool hidden () const
 
virtual void enable (bool new_val=true)
 
bool enabled () const
 
void set_clip_rect (const SDL_Rect &rect)
 
void set_volatile (bool val=true)
 
void set_dirty (bool dirty=true)
 
bool dirty () const
 
const std::stringid () const
 
void set_id (const std::string &id)
 
void set_help_string (const std::string &str)
 
void set_tooltip_string (const std::string &str)
 
virtual void process_help_string (int mousex, int mousey)
 
virtual void process_tooltip_string (int mousex, int mousey)
 
- Public Member Functions inherited from events::sdl_handler
virtual void process_event ()
 
virtual bool requires_event_focus (const SDL_Event *=nullptr) const
 
virtual void join ()
 
virtual void join (context &c)
 
virtual void join_same (sdl_handler *parent)
 
virtual void leave ()
 
virtual void join_global ()
 
virtual void leave_global ()
 

Private Member Functions

void get_unit_strings (const battle_context_unit_stats &stats, const unit &u, const map_location &u_loc, float u_unscathed, const unit &opp, const map_location &opp_loc, const attack_type *opp_weapon, std::vector< std::string > &left_strings, std::vector< std::string > &right_strings, int &left_strings_width, int &right_strings_width, int &strings_width)
 
int get_strings_max_length (const std::vector< std::string > &strings)
 
void get_hp_prob_vector (const std::vector< double > &hp_dist, std::vector< std::pair< int, double > > &hp_prob_vector)
 
void draw_unit (int x_off, int damage_line_skip, int left_strings_width, const std::vector< std::string > &left_strings, const std::vector< std::string > &right_strings, const std::string &label, int label_width, surface &hp_distrib, int hp_distrib_width)
 
void get_hp_distrib_surface (const std::vector< std::pair< int, double > > &hp_prob_vector, const battle_context_unit_stats &stats, const battle_context_unit_stats &opp_stats, surface &surf, int &width, int &height)
 

Private Attributes

const map_locationattacker_loc_
 
const map_locationdefender_loc_
 
const unitattacker_
 
const unitdefender_
 
std::string attacker_label_
 
std::string defender_label_
 
int attacker_label_width_
 
int defender_label_width_
 
std::vector< std::stringattacker_left_strings_
 
std::vector< std::stringattacker_right_strings_
 
std::vector< std::stringdefender_left_strings_
 
std::vector< std::stringdefender_right_strings_
 
int attacker_strings_width_
 
int attacker_left_strings_width_
 
int attacker_right_strings_width_
 
int defender_strings_width_
 
int defender_left_strings_width_
 
int defender_right_strings_width_
 
int units_strings_height_
 
std::string hp_distrib_string_
 
surface attacker_hp_distrib_
 
surface defender_hp_distrib_
 
int hp_distrib_string_width_
 
int attacker_hp_distrib_width_
 
int defender_hp_distrib_width_
 
int attacker_hp_distrib_height_
 
int defender_hp_distrib_height_
 
int hp_distribs_height_
 
int attacker_width_
 
int defender_width_
 
int units_width_
 
int dialog_width_
 
int dialog_height_
 

Static Private Attributes

static const int inter_line_gap_ = 3
 
static const int inter_column_gap_ = 30
 
static const int inter_units_gap_ = 30
 
static const int max_hp_distrib_rows_ = 10
 

Additional Inherited Members

- Protected Member Functions inherited from gui::widget
 widget (widget const &o)
 
 widget (CVideo &video, const bool auto_join=true)
 
virtual ~widget ()
 
void bg_register (SDL_Rect const &rect)
 
void bg_restore () const
 
void bg_restore (SDL_Rect const &rect) const
 
void bg_update ()
 
void bg_cancel ()
 
CVideovideo () const
 
virtual void draw ()
 
virtual void update_location (SDL_Rect const &rect)
 
const SDL_Rect * clip_rect () const
 
virtual sdl_handler_vector member_handlers ()
 
virtual void handle_event (SDL_Event const &)
 
virtual void handle_window_event (SDL_Event const &event)
 
bool mouse_locked () const
 
void aquire_mouse_lock ()
 
void free_mouse_lock ()
 
- Protected Member Functions inherited from events::sdl_handler
 sdl_handler (const bool auto_join=true)
 
virtual ~sdl_handler ()
 
- Protected Attributes inherited from gui::widget
bool focus_
 

Detailed Description

Definition at line 27 of file attack_prediction_display.hpp.

Constructor & Destructor Documentation

battle_prediction_pane::battle_prediction_pane ( const battle_context bc,
const map_location attacker_loc,
const map_location defender_loc 
)

Member Function Documentation

void battle_prediction_pane::draw_contents ( )
virtual
void battle_prediction_pane::draw_unit ( int  x_off,
int  damage_line_skip,
int  left_strings_width,
const std::vector< std::string > &  left_strings,
const std::vector< std::string > &  right_strings,
const std::string label,
int  label_width,
surface hp_distrib,
int  hp_distrib_width 
)
private
void battle_prediction_pane::get_hp_distrib_surface ( const std::vector< std::pair< int, double > > &  hp_prob_vector,
const battle_context_unit_stats stats,
const battle_context_unit_stats opp_stats,
surface surf,
int width,
int height 
)
private
void battle_prediction_pane::get_hp_prob_vector ( const std::vector< double > &  hp_dist,
std::vector< std::pair< int, double > > &  hp_prob_vector 
)
private

Definition at line 294 of file attack_prediction_display.cpp.

References i, max_hp_distrib_rows_, and sort().

Referenced by battle_prediction_pane().

int battle_prediction_pane::get_strings_max_length ( const std::vector< std::string > &  strings)
private

Definition at line 284 of file attack_prediction_display.cpp.

References i, font::line_width(), and font::SIZE_NORMAL.

Referenced by get_unit_strings().

void battle_prediction_pane::get_unit_strings ( const battle_context_unit_stats stats,
const unit u,
const map_location u_loc,
float  u_unscathed,
const unit opp,
const map_location opp_loc,
const attack_type opp_weapon,
std::vector< std::string > &  left_strings,
std::vector< std::string > &  right_strings,
int left_strings_width,
int right_strings_width,
int strings_width 
)
private
bool battle_prediction_pane::left_side ( ) const
inlinevirtual

Implements gui::preview_pane.

Definition at line 39 of file attack_prediction_display.hpp.

void battle_prediction_pane::set_selection ( int  )
inlinevirtual

Implements gui::preview_pane.

Definition at line 42 of file attack_prediction_display.hpp.

Member Data Documentation

const unit& battle_prediction_pane::attacker_
private

Definition at line 47 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

surface battle_prediction_pane::attacker_hp_distrib_
private

Definition at line 67 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

int battle_prediction_pane::attacker_hp_distrib_height_
private

Definition at line 70 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::attacker_hp_distrib_width_
private

Definition at line 69 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

std::string battle_prediction_pane::attacker_label_
private

Definition at line 57 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

int battle_prediction_pane::attacker_label_width_
private

Definition at line 58 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

std::vector<std::string> battle_prediction_pane::attacker_left_strings_
private

Definition at line 60 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

int battle_prediction_pane::attacker_left_strings_width_
private

Definition at line 62 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

const map_location& battle_prediction_pane::attacker_loc_
private

Definition at line 45 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

std::vector<std::string> battle_prediction_pane::attacker_right_strings_
private

Definition at line 60 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

int battle_prediction_pane::attacker_right_strings_width_
private

Definition at line 62 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::attacker_strings_width_
private

Definition at line 62 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::attacker_width_
private

Definition at line 72 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

const unit& battle_prediction_pane::defender_
private

Definition at line 48 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

surface battle_prediction_pane::defender_hp_distrib_
private

Definition at line 67 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

int battle_prediction_pane::defender_hp_distrib_height_
private

Definition at line 70 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::defender_hp_distrib_width_
private

Definition at line 69 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

std::string battle_prediction_pane::defender_label_
private

Definition at line 57 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

int battle_prediction_pane::defender_label_width_
private

Definition at line 58 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

std::vector<std::string> battle_prediction_pane::defender_left_strings_
private

Definition at line 61 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

int battle_prediction_pane::defender_left_strings_width_
private

Definition at line 63 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

const map_location& battle_prediction_pane::defender_loc_
private

Definition at line 46 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

std::vector<std::string> battle_prediction_pane::defender_right_strings_
private

Definition at line 61 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

int battle_prediction_pane::defender_right_strings_width_
private

Definition at line 63 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::defender_strings_width_
private

Definition at line 63 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::defender_width_
private

Definition at line 72 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::dialog_height_
private

Definition at line 73 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::dialog_width_
private

Definition at line 73 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

std::string battle_prediction_pane::hp_distrib_string_
private

Definition at line 66 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_unit().

int battle_prediction_pane::hp_distrib_string_width_
private

Definition at line 68 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_unit().

int battle_prediction_pane::hp_distribs_height_
private

Definition at line 70 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

const int battle_prediction_pane::inter_column_gap_ = 30
staticprivate

Definition at line 52 of file attack_prediction_display.hpp.

Referenced by draw_unit(), and get_unit_strings().

const int battle_prediction_pane::inter_line_gap_ = 3
staticprivate

Definition at line 51 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_unit().

const int battle_prediction_pane::inter_units_gap_ = 30
staticprivate

Definition at line 53 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), and draw_contents().

const int battle_prediction_pane::max_hp_distrib_rows_ = 10
staticprivate

Definition at line 54 of file attack_prediction_display.hpp.

Referenced by get_hp_prob_vector().

int battle_prediction_pane::units_strings_height_
private

Definition at line 64 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane().

int battle_prediction_pane::units_width_
private

Definition at line 72 of file attack_prediction_display.hpp.

Referenced by battle_prediction_pane(), draw_contents(), and draw_unit().


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