15#define GETTEXT_DOMAIN "wesnoth-lib"
32#define ERR_CONFIG LOG_STREAM(err, log_config)
41 , last_selected_(
prefs::get().selected_achievement_group())
42 , achievements_box_(
nullptr)
43 , content_names_(
nullptr)
49 std::vector<config> content_list;
50 content_names_ = &find_widget<menu_button>(
"selected_achievements_list");
59 selected = content_list.size();
63 content_list.emplace_back(
"label", list.display_name_);
66 if(content_list.size() > 0) {
83 int achieved_count = 0;
88 }
else if(ach.hidden_ && !ach.achieved_) {
92 const bool in_progress = ach.max_progress_ != 0 && ach.current_progress_ != -1;
93 const auto in_progress_name = !in_progress
97 {
"count", std::to_string(ach.current_progress_)},
98 {
"total", std::to_string(ach.max_progress_)}
103 {
"label", ach.achieved_
104 ? ach.icon_completed_
109 {
"label", ach.achieved_
110 ? ach.name_completed_
115 {
"label", ach.achieved_
124 achievement_progress.
set_percentage((ach.current_progress_ /
double(ach.max_progress_)) * 100);
135 auto& achieved_label = find_widget<label>(
"achievement_count");
136 achieved_label.set_label(
VGETTEXT(
"Completed $count/$total", {
137 {
"count", std::to_string(achieved_count)} ,
158 img->set_label(sub_ach.achieved_ ? sub_ach.icon_completed_ : sub_ach.icon_);
159 img->set_tooltip(sub_ach.description_);
162 ERR_CONFIG <<
"Too many sub achievements for ‘" << ach.
id_ <<
"’, ‘"
163 << sub_ach.id_ <<
"’ will not be displayed";
169 while(
auto img = newrow.
find_widget<
drawing>(
"sub_icon" + std::to_string(
i),
false,
false))
static lg::log_domain log_config("config")
static game_config_manager * get()
std::vector< achievement_group > & get_achievements()
void set_variable(const std::string &key, wfl::variant &&value)
virtual void post_show() override
Actions to be taken after the window has been shown.
menu_button * content_names_
listbox * achievements_box_
void set_achievements_row()
virtual void pre_show() override
Actions to be taken before showing the window.
std::string last_selected_
void set_sub_achievements(grid &newrow, const achievement &ach)
Abstract base class for all modal dialogs.
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 clear()
Removes all the rows in the listbox, clearing it.
void set_percentage(unsigned percentage)
Standard logging facilities (interface).
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
std::map< std::string, widget_item > widget_data
std::string span_color(const color_t &color, Args &&... data)
Applies Pango markup to the input specifying its display color.
A set of achievements tied to a particular content.
std::string content_for_
The internal ID used for this content.
std::vector< achievement > achievements_
The achievements associated to this content.
Represents a single achievement and its data.
std::string id_
The ID of the achievement.
std::vector< sub_achievement > sub_achievements_
The list of distinct sub-achievements for this achievement.
Represents a distinct sub-achievement within another achievement.