15 #define GETTEXT_DOMAIN "wesnoth-lib"
40 #define LOG_DP LOG_STREAM(info, log_display)
50 , scroll_to_(scroll_to)
56 std::string lvl = std::to_string(
level);
59 return "<span color='#969696'>" + lvl +
"</span>";
60 }
else if(
level == 1) {
62 }
else if(
level == 2) {
63 return "<b>" + lvl +
"</b>";
65 return"<b><span color='#ffffff'>" + lvl +
"</span></b>";
72 return (*u).can_recruit() ?
"<span color='#cdad00'>" + str +
"</span>" : str;
78 const int moves_max = (*u).total_movement();
80 std::string color =
"#00ff00";
88 return formatter() <<
"<span color='" << color <<
"'>" <<
moves_left <<
"/" << moves_max <<
"</span>";
93 listbox& list = find_widget<listbox>(&
window,
"units_list",
false);
105 column[
"use_markup"] =
"true";
108 row_data.emplace(
"unit_type", column);
111 column[
"label"] = name;
112 row_data.emplace(
"unit_name", column);
115 row_data.emplace(
"unit_moves", column);
117 std::stringstream hp_str;
120 column[
"label"] = hp_str.str();
121 row_data.emplace(
"unit_hp", column);
124 row_data.emplace(
"unit_level", column);
126 std::stringstream exp_str;
133 exp_str <<
"</span>";
135 column[
"label"] = exp_str.str();
136 row_data.emplace(
"unit_experience", column);
139 row_data.emplace(
"unit_traits", column);
179 const int selected_row
180 = find_widget<listbox>(
get_window(),
"units_list",
false).get_selected_row();
182 if(selected_row == -1) {
186 find_widget<unit_preview_pane>(
get_window(),
"unit_details",
false)
193 const int selected_row = find_widget<listbox>(&
window,
"units_list",
false).get_selected_row();
206 if(
i->side() !=
gui.viewing_side()) {
215 gui.select_hex(scroll_to);
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Abstract base class for all modal dialogs.
int get_retval() const
Returns the cached window exit code.
window * get_window()
Returns a pointer to the dialog's window.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
map_location & scroll_to_
std::vector< unit_const_ptr > & unit_list_
void list_item_clicked()
Callbacks.
static bool execute(std::vector< unit_const_ptr > &units, map_location &scroll_to)
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.
void register_translatable_sorting_option(const int col, translatable_sorter_func_t f)
Registers a special sorting function specifically for translatable values.
void register_sorting_option(const int col, const Func &f)
void clear()
Removes all the rows in the listbox, clearing it.
base class of top level items, the only item which needs to store the final canvases to draw on.
void keyboard_capture(widget *widget)
const std::string & str() const
Container associating units to locations.
This class represents a single unit of a specific type.
bool invisible(const map_location &loc, bool see_all=true) const
int max_hitpoints() const
The max number of hitpoints this unit can have.
int level() const
The current level of this unit.
const t_string & type_name() const
Gets the translatable name of this unit's type.
int hitpoints() const
The current number of hitpoints this unit has.
bool get_state(const std::string &state) const
Check if the unit is affected by a status effect.
int experience() const
The current number of experience points this unit has.
unsigned int experience_to_advance() const
The number of experience points this unit needs to level up, or 0 if current XP > max XP.
int max_experience() const
The max number of experience points this unit can have.
const t_string & name() const
Gets this unit's translatable display name.
@ STATE_PETRIFIED
The unit is poisoned - it loses health each turn.
@ STATE_POISONED
The unit is slowed - it moves slower and does less damage.
bool can_advance() const
Checks whether this unit has any options to advance to.
color_t xp_color() const
Color for this unit's XP.
color_t hp_color() const
Color for this unit's current hitpoints.
const map_location & get_location() const
The current map location this unit is at.
const std::vector< t_string > & trait_names() const
Gets the names of the currently registered traits.
Define the common log macros for the gui toolkit.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
const std::string unicode_en_dash
std::string span_color(const color_t &color)
Returns a Pango formatting string using the provided color_t object.
static std::string format_level_string(const int level)
static std::string format_if_leader(unit_const_ptr u, const std::string &str)
static std::string format_movement_string(unit_const_ptr u)
void show_unit_list(display &gui)
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
@ OK
Dialog was closed with the OK button.
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::shared_ptr< const unit > unit_const_ptr
This file contains the settings handling of the widget library.
Encapsulates the map of the game.
static lg::log_domain log_display("display")