15 #define GETTEXT_DOMAIN "wesnoth-lib"
34 #define LOG_DP LOG_STREAM(info, log_display)
44 , scroll_to_(scroll_to)
50 std::string lvl = std::to_string(
level);
53 return "<span color='#969696'>" + lvl +
"</span>";
54 }
else if(
level == 1) {
56 }
else if(
level == 2) {
57 return "<b>" + lvl +
"</b>";
59 return"<b><span color='#ffffff'>" + lvl +
"</span></b>";
66 return (*u).can_recruit() ?
"<span color='#cdad00'>" + str +
"</span>" : str;
72 const int moves_max = (*u).total_movement();
74 std::string color =
"#00ff00";
82 return formatter() <<
"<span color='" << color <<
"'>" <<
moves_left <<
"/" << moves_max <<
"</span>";
87 listbox& list = find_widget<listbox>(&
window,
"units_list",
false);
99 column[
"use_markup"] =
"true";
102 row_data.emplace(
"unit_type", column);
105 column[
"label"] = name;
106 row_data.emplace(
"unit_name", column);
109 row_data.emplace(
"unit_moves", column);
111 std::stringstream hp_str;
114 column[
"label"] = hp_str.str();
115 row_data.emplace(
"unit_hp", column);
118 row_data.emplace(
"unit_level", column);
120 std::stringstream exp_str;
127 exp_str <<
"</span>";
129 column[
"label"] = exp_str.str();
130 row_data.emplace(
"unit_experience", column);
133 row_data.emplace(
"unit_traits", column);
173 const int selected_row
174 = find_widget<listbox>(
get_window(),
"units_list",
false).get_selected_row();
176 if(selected_row == -1) {
180 find_widget<unit_preview_pane>(
get_window(),
"unit_details",
false)
187 const int selected_row = find_widget<listbox>(&
window,
"units_list",
false).get_selected_row();
200 if(
i->side() !=
gui.viewing_side()) {
209 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.
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)
REGISTER_DIALOG(tod_new_schedule)
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
Encapsulates the map of the game.
static lg::log_domain log_display("display")