00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ATTACK_PREDICTION_DISPLAY_H_INCLUDED
00018 #define ATTACK_PREDICTION_DISPLAY_H_INCLUDED
00019
00020 #include "actions.hpp"
00021 #include "show_dialog.hpp"
00022
00023
00024 class battle_prediction_pane : public gui::preview_pane
00025 {
00026 public:
00027
00028
00029 battle_prediction_pane(const battle_context& bc,
00030 const map_location& attacker_loc, const map_location& defender_loc);
00031
00032
00033 void draw_contents();
00034
00035
00036 bool left_side() const { return 1; }
00037
00038
00039 void set_selection(int) {}
00040
00041 private:
00042 const battle_context& bc_;
00043 const map_location& attacker_loc_;
00044 const map_location& defender_loc_;
00045 const unit& attacker_;
00046 const unit& defender_;
00047
00048
00049 static const int inter_line_gap_;
00050 static const int inter_column_gap_;
00051 static const int inter_units_gap_;
00052 static const int max_hp_distrib_rows_;
00053
00054
00055 std::string attacker_label_, defender_label_;
00056 int attacker_label_width_, defender_label_width_;
00057
00058 std::vector<std::string> attacker_left_strings_, attacker_right_strings_;
00059 std::vector<std::string> defender_left_strings_, defender_right_strings_;
00060 int attacker_strings_width_, attacker_left_strings_width_, attacker_right_strings_width_;
00061 int defender_strings_width_, defender_left_strings_width_, defender_right_strings_width_;
00062 int units_strings_height_;
00063
00064 std::string hp_distrib_string_;
00065 surface attacker_hp_distrib_, defender_hp_distrib_;
00066 int hp_distrib_string_width_;
00067 int attacker_hp_distrib_width_, defender_hp_distrib_width_;
00068 int attacker_hp_distrib_height_, defender_hp_distrib_height_, hp_distribs_height_;
00069
00070 int attacker_width_, defender_width_, units_width_;
00071 int dialog_width_, dialog_height_;
00072
00073
00074
00075 void get_unit_strings(const battle_context_unit_stats& stats,
00076 const unit& u, const map_location& u_loc, float u_unscathed,
00077 const unit& opp, const map_location& opp_loc, const attack_type *opp_weapon,
00078 std::vector<std::string>& left_strings, std::vector<std::string>& right_strings,
00079 int& left_strings_width, int& right_strings_width, int& strings_width);
00080
00081
00082 int get_strings_max_length(const std::vector<std::string>& strings);
00083
00084
00085
00086
00087
00088 void get_hp_prob_vector(const std::vector<double>& hp_dist,
00089 std::vector<std::pair<int, double> >& hp_prob_vector);
00090
00091
00092
00093 void draw_unit(int x_off, int damage_line_skip, int left_strings_width,
00094 const std::vector<std::string>& left_strings,
00095 const std::vector<std::string>& right_strings,
00096 const std::string& label, int label_width,
00097 surface& hp_distrib, int hp_distrib_width);
00098
00099
00100
00101
00102
00103
00104 void get_hp_distrib_surface(const std::vector<std::pair<int, double> >& hp_prob_vector,
00105 const battle_context_unit_stats& stats,
00106 const battle_context_unit_stats& opp_stats,
00107 surface& surf, int& width, int& height);
00108
00109
00110
00111
00112
00113
00114 Uint32 blend_rgb(const surface& surf, unsigned char r, unsigned char g, unsigned char b, unsigned char drop);
00115 };
00116
00117
00118
00119 class attack_prediction_displayer : public gui::dialog_button_action
00120 {
00121 public:
00122 attack_prediction_displayer(const std::vector<battle_context>& bc_vector,
00123 const map_location& attacker_loc, const map_location& defender_loc)
00124 : bc_vector_(bc_vector),
00125 attacker_loc_(attacker_loc), defender_loc_(defender_loc) {}
00126
00127 RESULT button_pressed(int selection);
00128
00129 private:
00130 const std::vector<battle_context>& bc_vector_;
00131 const map_location& attacker_loc_;
00132 const map_location& defender_loc_;
00133 };
00134
00135 #endif