41 const
int best_weapon,
43 const
int leadership_bonus)
45 , selected_weapon_(-1)
46 , attacker_itor_(attacker_itor)
47 , defender_itor_(defender_itor)
48 , weapons_(std::move(weapons))
49 , best_weapon_(best_weapon)
50 , bc_widget_data_vector_(bc_widget_data_vector)
51 , leadership_bonus_(leadership_bonus)
57 const std::size_t
index = find_widget<listbox>(
"weapon_list").get_selected_row();
64 find_widget<button>(
"damage_calculation"),
67 find_widget<unit_preview_pane>(
"attacker_pane")
70 find_widget<unit_preview_pane>(
"defender_pane")
75 listbox& weapon_list = find_widget<listbox>(
"weapon_list");
Computes the statistics of a battle between an attacker and a defender unit.
Abstract base class for all modal dialogs.
virtual void post_show() override
Actions to be taken after the window has been shown.
int selected_weapon_
The index of the selected weapon.
unit_map::iterator defender_itor_
Iterator pointing to the defender.
const int leadership_bonus_
int best_weapon_
The best weapon, aka the one high-lighted.
std::vector< gui2::widget_data > bc_widget_data_vector_
virtual void pre_show() override
Actions to be taken before showing the window.
unit_map::iterator attacker_itor_
Iterator pointing to the attacker.
void damage_calc_callback()
std::vector< battle_context > weapons_
List of all battle contexts used for getting the weapons.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
bool select_row(const unsigned row, const bool select=true)
Selects a row.
unsigned get_item_count() const
Returns the number of items in the listbox.
void keyboard_capture(widget *widget)
Container associating units to locations.
REGISTER_DIALOG(editor_edit_unit)
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
std::map< std::string, widget_item > widget_data
@ OK
Dialog was closed with the OK button.
void unit_attack(display *disp, game_board &board, const map_location &a, const map_location &b, int damage, const attack_type &attack, const const_attack_ptr &secondary_attack, int swing, const std::string &hit_text, int drain_amount, const std::string &att_text, const std::vector< std::string > *extra_hit_sounds, bool attacking)
Make the unit on tile 'a' attack the unit on tile 'b'.
std::size_t index(std::string_view str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
std::string::const_iterator iterator
pointer get_shared_ptr() const
This is exactly the same as operator-> but it's slightly more readable, and can replace &*iter syntax...