15 #define GETTEXT_DOMAIN "wesnoth-lib"
31 #define ERR_CONFIG LOG_STREAM(err, log_config)
43 , last_selected_(
prefs::
get().selected_achievement_group())
44 , achievements_box_(
nullptr)
45 , content_names_(
nullptr)
51 std::vector<config> content_list;
52 content_names_ = &find_widget<menu_button>(
"selected_achievements_list");
60 for(
const auto& list : groups) {
67 content_list.emplace_back(
"label", list.display_name_);
70 if(content_list.size() > 0) {
87 int achieved_count = 0;
92 }
else if(ach.hidden_ && !ach.achieved_) {
99 item[
"label"] = !ach.achieved_ ? ach.icon_ : ach.icon_completed_;
100 row.emplace(
"icon", item);
104 if(ach.max_progress_ != 0 && ach.current_progress_ != -1) {
105 name += (
formatter() <<
" (" << ach.current_progress_ <<
"/" << ach.max_progress_).str();
107 item[
"label"] = name;
109 item[
"label"] = ach.name_completed_;
110 item[
"definition"] =
"gold_large";
112 row.emplace(
"name", item);
115 item[
"label"] = ach.description_;
119 row.emplace(
"description", item);
123 if(ach.max_progress_ != 0 && ach.current_progress_ != -1) {
124 achievement_progress->
set_percentage((ach.current_progress_/
double(ach.max_progress_))*100);
136 label* achieved_label = find_widget<label>(
"achievement_count",
false,
true);
137 achieved_label->
set_label(
_(
"Completed")+
" "+std::to_string(achieved_count)+
"/"+std::to_string(list.
achievements_.size()));
constexpr int sub_achievements_limit
static lg::log_domain log_config("config")
static game_config_manager * get()
std::vector< achievement_group > & get_achievements()
A simple canvas which can be drawn upon.
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.
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
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)
static std::string _(const char *str)
Standard logging facilities (interface).
REGISTER_DIALOG(editor_edit_unit)
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
std::string img(const std::string &src, const std::string &align, const bool floating)
std::string span_color(const color_t &color, Args &&... data)
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::vector< sub_achievement > sub_achievements_
The list of distinct sub-achievements for this achievement.
Represents a distinct sub-achievement within another achievement.
t_string description_
The description of the sub-achievement to be shown in its tooltip.
std::string icon_completed_
The icon of the sub-achievement to show on the UI when completed.
std::string icon_
The icon of the sub-achievement to show on the UI when not completed.
bool achieved_
Whether the sub-achievement has been completed.