15 #define GETTEXT_DOMAIN "wesnoth-lib"
25 #ifdef GUI2_EXPERIMENTAL_LISTBOX
78 const
int best_weapon)
79 : selected_weapon_(-1)
80 , attacker_itor_(attacker_itor)
81 , defender_itor_(defender_itor)
83 , best_weapon_(best_weapon)
91 T* widget = find_widget<T>(&window,
id,
false,
false);
93 widget->set_label(label);
103 traits += (traits.empty() ?
"" :
", ") + trait;
106 if (traits.empty()) {
110 std::stringstream str;
116 str <<
"<span color='#f5e6c1'>" << u.
type_name() <<
"</span>" <<
"\n";
118 str <<
"Lvl " << u.
level() <<
"\n";
122 str << traits <<
"\n";
144 res +=
"~BLIT(" +
overlay +
")";
155 find_widget<tcontrol>(&window,
"attacker_stats",
false);
167 find_widget<tcontrol>(&window,
"defender_stats",
false);
174 const std::vector<battle_context>& weapons,
175 const int best_weapon)
178 = find_widget<tlistbox>(&window,
"weapon_list",
false);
179 window.keyboard_capture(&weapon_list);
184 for(
const auto &
weapon : weapons)
192 *defender.
weapon : no_weapon;
194 const SDL_Color a_cth_color =
196 const SDL_Color d_cth_color =
203 if (!range.empty()) {
212 std::stringstream attacker_stats, defender_stats;
214 attacker_stats <<
"<b>" << attw_name <<
"</b>" <<
"\n"
216 << attw_apecials <<
"\n"
219 defender_stats <<
"<b>" << defw_name <<
"</b>" <<
"\n"
221 << defw_specials <<
"\n"
224 std::map<std::string, string_map>
data;
227 item[
"label"] = attacker_weapon.
icon();
228 data.insert(std::make_pair(
"attacker_weapon_icon", item));
230 item[
"label"] = attacker_stats.str();
231 item[
"use_markup"] =
"true";
232 data.insert(std::make_pair(
"attacker_weapon", item));
235 item[
"use_markup"] =
"true";
236 data.insert(std::make_pair(
"range", item));
238 item[
"label"] = defender_stats.str();
239 item[
"use_markup"] =
"true";
240 data.insert(std::make_pair(
"defender_weapon", item));
242 item[
"label"] = defender_weapon.
icon();
243 data.insert(std::make_pair(
"defender_weapon_icon", item));
248 assert(best_weapon < static_cast<int>(weapon_list.
get_item_count()));
260 = find_widget<tlistbox>(&window,
"weapon_list",
false).get_selected_row();
269 find_widget<tbutton>(&window,
"attacker_profile",
false),
271 (*attacker_itor_).type_id()));
274 find_widget<tbutton>(&window,
"defender_profile",
false),
276 (*defender_itor_).type_id()));
279 find_widget<tbutton>(&window,
"damage_calculation",
false),
const t_string & name() const
void post_show(twindow &window)
Inherited from tdialog.
std::string absolute_image() const
The name of the file to game_display (used in menus).
const std::string & team_color() const
int max_hitpoints() const
static void set_defender_info(twindow &window, const unit &u)
const t_string & name() const
The unit name for display.
const t_string & type_name() const
The unit type name.
void unit_attack(display *disp, game_board &board, const map_location &a, const map_location &b, int damage, const attack_type &attack, const attack_type *secondary_attack, int swing, std::string hit_text, int drain_amount, std::string att_text, const std::vector< std::string > *extra_hit_sounds)
Make the unit on tile 'a' attack the unit on tile 'b'.
void damage_calc_callback(twindow &window)
GLuint GLuint GLsizei GLenum type
SDL_Color int_to_color(const Uint32 rgb)
bool select_row(const unsigned row, const bool select=true)
Selectes a row.
REGISTER_DIALOG(label_settings)
void connect_signal_mouse_left_click(tdispatcher &dispatcher, const tsignal_function &signal)
Connects a signal handler for a left mouse button click.
const attack_type * weapon
The weapon used by the unit to attack the opponent, or nullptr if there is none.
SDL_Color xp_color() const
Colors for the unit's XP.
int best_weapon_
The best weapon, aka the one high-lighted.
std::string weapon_specials(bool only_active=false, bool is_backstab=false) const
Returns a comma-separated string of active names for the specials of *this.
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
const std::string & icon() const
static void set_weapon_info(twindow &window, const std::vector< battle_context > &weapons, const int best_weapon)
unsigned int chance_to_hit
Effective chance to hit as a percentage (all factors accounted for).
Uint32 red_to_green(int val, bool for_text)
Return a color corresponding to the value val red for val=0 to green for val=100, passing by yellow...
std::string span_color(const SDL_Color &color)
Creates pango markup of a color.
std::vector< battle_context > weapons_
List of all battle contexts used for getting the weapons.
int selected_weapon_
The index of the selected weapon.
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
virtual void set_use_markup(bool use_markup)
static UNUSEDNOWARN std::string _(const char *str)
static const std::string & leader_crown()
The path to the leader crown overlay.
int damage
Effective damage of the weapon (all factors accounted for).
Dialog is closed with ok button.
const std::vector< std::string > & overlays() const
unsigned get_item_count() const
Returns the number of items in the listbox.
unit_type::ALIGNMENT alignment() const
void pre_show(twindow &window)
Inherited from tdialog.
void add_row(const string_map &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
unit_map::iterator attacker_itor_
Iterator pointing to the attacker.
Computes the statistics of a battle between an attacker and a defender unit.
static std::string format_stats(const unit &u)
const std::string unicode_em_dash
static size_t id
Ids for the timers.
Structure describing the statistics of a unit involved in the battle.
std::map< std::string, t_string > string_map
static std::string get_image_mods(const unit &u)
void profile_button_callback(twindow &window, const std::string &type)
const std::string & range() const
Base class for all visible items.
GLuint const GLchar * name
int max_experience() const
const std::string weapon_numbers_sep
const std::vector< t_string > & trait_names() const
SDL_Color hp_color() const
Colors for the unit's current hitpoints.
symbol_table string_table
Container associating units to locations.
unit_map::iterator defender_itor_
Iterator pointing to the defender.
static std::string get_side_color_index(int side)
static void set_label(twindow &window, const std::string &id, const std::string &label)
void show_unit_help(CVideo &video, const std::string &show_topic, bool has_variations, bool hidden, int xloc, int yloc)
Open the help browser, show unit with id unit_id.
RESULT button_pressed(int selection)
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
static void set_attacker_info(twindow &window, const unit &u)