15 #define GETTEXT_DOMAIN "wesnoth-lib" 40 #define LOG_DP LOG_STREAM(info, log_display) 49 , unit_list_(unit_list)
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";
84 }
else if(moves_left < moves_max) {
88 return formatter() <<
"<span color='" << color <<
"'>" << moves_left <<
"/" << moves_max <<
"</span>";
93 listbox& list = find_widget<listbox>(&
window,
"units_list",
false);
99 window.keyboard_capture(&list);
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);
167 const unit& u = *unit_list_[
i];
172 return !unit_list_[
i]->trait_names().empty() ? unit_list_[
i]->trait_names().front().str() :
""; });
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)
187 .set_displayed_unit(*
unit_list_[selected_row].
get());
193 const int selected_row = find_widget<listbox>(&
window,
"units_list",
false).get_selected_row();
210 unit_list.push_back(
i.get_shared_ptr());
Define the common log macros for the gui toolkit.
window(const builder_window::window_resolution &definition)
< Needs to be initialized in show.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
virtual void select_hex(map_location hex)
void list_item_clicked()
Callbacks.
This class represents a single unit of a specific type.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
bool get_state(const std::string &state) const
Check if the unit is affected by a status effect.
int hitpoints() const
The current number of hitpoints this unit has.
std::vector< unit_const_ptr > & unit_list_
void show_unit_list(display &gui)
The unit is slowed - it moves slower and does less damage.
const unit_map & get_units() const
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.
The unit is poisoned - it loses health each turn.
void register_translatable_sorting_option(const int col, translatable_sorter_func_t f)
Registers a special sorting function specifically for translatable values.
static std::string format_movement_string(unit_const_ptr u)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
map_location & scroll_to_
color_t hp_color() const
Color for this unit's current hitpoints.
unsigned int experience_to_advance() const
The number of experience points this unit needs to level up, or 0 if current XP > max XP...
std::shared_ptr< const unit > unit_const_ptr
static std::string format_level_string(const int level)
std::string span_color(const color_t &color)
Returns a Pango formatting string using the provided color_t object.
std::map< std::string, t_string > widget_item
This file contains the settings handling of the widget library.
void clear()
Removes all the rows in the listbox, clearing it.
color_t xp_color() const
Color for this unit's XP.
const t_string & name() const
Gets this unit's translatable display name.
static std::string format_if_leader(unit_const_ptr u, const std::string &str)
int max_experience() const
The max number of experience points this unit can have.
int level() const
The current level of this unit.
map_display and display: classes which take care of displaying the map and game-data on the screen...
const std::vector< t_string > & trait_names() const
Gets the names of the currently registered traits.
const t_string & type_name() const
Gets the translatable name of this unit's type.
window * get_window()
Returns a pointer to the dialog's window.
Encapsulates the map of the game.
bool invisible(const map_location &loc, bool see_all=true) const
static lg::log_domain log_display("display")
const std::string unicode_en_dash
void scroll_to_tile(const map_location &loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool force=true)
Scroll such that location loc is on-screen.
int max_hitpoints() const
The max number of hitpoints this unit can have.
static bool execute(std::vector< unit_const_ptr > &units, map_location &scroll_to)
int get_retval() const
Returns the cached window exit code.
int experience() const
The current number of experience points this unit has.
const map_location & get_location() const
The current map location this unit is at.
Abstract base class for all modal dialogs.
bool can_advance() const
Checks whether this unit has any options to advance to.
Container associating units to locations.
std::map< std::string, widget_item > widget_data
Dialog was closed with the OK button.
void register_sorting_option(const int col, const Func &f)
const std::string & str() const
base class of top level items, the only item which needs to store the final canvases to draw on...
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
unit_list(std::vector< unit_const_ptr > &unit_list, map_location &scroll_to)