The Battle for Wesnoth  1.15.2+dev
unit_attack.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "actions/attack.hpp"
19 #include "units/map.hpp"
20 
21 namespace gui2
22 {
23 namespace dialogs
24 {
25 
26 class unit_attack : public modal_dialog
27 {
28 public:
29  unit_attack(const unit_map::iterator& attacker_itor,
30  const unit_map::iterator& defender_itor,
31  std::vector<battle_context>&& weapons,
32  const int best_weapon);
33 
34  /***** ***** ***** setters / getters for members ***** ****** *****/
35 
36  int get_selected_weapon() const
37  {
38  return selected_weapon_;
39  }
40 
41 private:
42  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
43  virtual const std::string& window_id() const override;
44 
45  /** Inherited from modal_dialog. */
46  virtual void pre_show(window& window) override;
47 
48  /** Inherited from modal_dialog. */
49  virtual void post_show(window& window) override;
50 
51  void damage_calc_callback(window& window);
52 
53  /** The index of the selected weapon. */
55 
56  /** Iterator pointing to the attacker. */
58 
59  /** Iterator pointing to the defender. */
61 
62  /** List of all battle contexts used for getting the weapons. */
63  std::vector<battle_context> weapons_;
64 
65  /** The best weapon, aka the one high-lighted. */
67 };
68 
69 } // namespace dialogs
70 } // namespace gui2
int best_weapon_
The best weapon, aka the one high-lighted.
Definition: unit_attack.hpp:66
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
Various functions that implement attacks and attack calculations.
std::vector< battle_context > weapons_
List of all battle contexts used for getting the weapons.
Definition: unit_attack.hpp:63
Generic file dialog.
Definition: field-fwd.hpp:22
unit_attack(const unit_map::iterator &attacker_itor, const unit_map::iterator &defender_itor, std::vector< battle_context > &&weapons, const int best_weapon)
Definition: unit_attack.cpp:72
void damage_calc_callback(window &window)
Definition: unit_attack.cpp:84
virtual void post_show(window &window) override
Inherited from modal_dialog.
Various uncategorised dialogs.
int selected_weapon_
The index of the selected weapon.
Definition: unit_attack.hpp:54
unit_map::iterator attacker_itor_
Iterator pointing to the attacker.
Definition: unit_attack.hpp:57
Abstract base class for all modal dialogs.
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Definition: unit_attack.cpp:90
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
unit_map::iterator defender_itor_
Iterator pointing to the defender.
Definition: unit_attack.hpp:60