Skip to content

Commit

Permalink
tunit_attack: refactored out display argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Feb 25, 2016
1 parent ec88475 commit 6612b71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
18 changes: 7 additions & 11 deletions src/gui/dialogs/unit_attack.cpp
Expand Up @@ -79,14 +79,12 @@ REGISTER_DIALOG(unit_attack)
tunit_attack::tunit_attack(const unit_map::iterator& attacker_itor,
const unit_map::iterator& defender_itor,
const std::vector<battle_context>& weapons,
const int best_weapon,
display* disp)
const int best_weapon)
: selected_weapon_(-1)
, attacker_itor_(attacker_itor)
, defender_itor_(defender_itor)
, weapons_(weapons)
, best_weapon_(best_weapon)
, disp_(disp)
{
}

Expand Down Expand Up @@ -255,13 +253,9 @@ static void set_weapon_info(twindow& window,
weapon_list.select_row(best_weapon);
}

void tunit_attack::profile_button_callback(const std::string& type)
void tunit_attack::profile_button_callback(twindow& window, const std::string& type)
{
if (!disp_) {
return;
}

help::show_unit_help(disp_->video(), type);
help::show_unit_help(window.video(), type);
}

void tunit_attack::damage_calc_callback(twindow& window)
Expand All @@ -277,11 +271,13 @@ void tunit_attack::pre_show(CVideo& /*video*/, twindow& window)
{
connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "attacker_profile", false),
boost::bind(&tunit_attack::profile_button_callback, this, (*attacker_itor_).type_id()));
boost::bind(&tunit_attack::profile_button_callback, this, boost::ref(window),
(*attacker_itor_).type_id()));

connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "defender_profile", false),
boost::bind(&tunit_attack::profile_button_callback, this, (*defender_itor_).type_id()));
boost::bind(&tunit_attack::profile_button_callback, this, boost::ref(window),
(*defender_itor_).type_id()));

connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "damage_calculation", false),
Expand Down
7 changes: 2 additions & 5 deletions src/gui/dialogs/unit_attack.hpp
Expand Up @@ -29,8 +29,7 @@ class tunit_attack : public tdialog
tunit_attack(const unit_map::iterator& attacker_itor,
const unit_map::iterator& defender_itor,
const std::vector<battle_context>& weapons,
const int best_weapon,
display* disp = NULL);
const int best_weapon);

/***** ***** ***** setters / getters for members ***** ****** *****/

Expand All @@ -49,7 +48,7 @@ class tunit_attack : public tdialog
/** Inherited from tdialog. */
void post_show(twindow& window);

void profile_button_callback(const std::string& type);
void profile_button_callback(twindow& window, const std::string& type);

void damage_calc_callback(twindow& window);

Expand All @@ -67,8 +66,6 @@ class tunit_attack : public tdialog

/** The best weapon, aka the one high-lighted. */
int best_weapon_;

display* disp_;
};

} // namespace gui2
Expand Down
3 changes: 1 addition & 2 deletions src/mouse_events.cpp
Expand Up @@ -978,8 +978,7 @@ int mouse_handler::show_attack_dialog(const map_location& attacker_loc, const ma
attacker
, defender
, bc_vector
, best
, gui_);
, best);

dlg.show(gui_->video());

Expand Down

0 comments on commit 6612b71

Please sign in to comment.