16 #define GETTEXT_DOMAIN "wesnoth-lib" 39 , achievements_box_(nullptr)
40 , content_names_(nullptr)
46 std::vector<config> content_list;
47 content_names_ = &find_widget<menu_button>(&win,
"selected_achievements_list",
false);
58 for(
const auto& list : groups) {
61 int achieved_count = 0;
63 for(
const auto& ach : list.achievements_) {
71 item[
"label"] = !ach.achieved_ ? ach.icon_ : ach.icon_completed_;
72 row.emplace(
"icon", item);
74 if(ach.hidden_ && !ach.achieved_) {
75 item[
"label"] = ach.hidden_name_;
76 }
else if(!ach.achieved_) {
77 std::string name = ach.name_;
78 if(ach.max_progress_ != 0 && ach.current_progress_ != -1) {
79 name +=
" ("+std::to_string(ach.current_progress_)+
"/"+std::to_string(ach.max_progress_)+
")";
83 item[
"label"] =
"<span color='green'>"+ach.name_completed_+
"</span>";
85 row.emplace(
"name", item);
87 if(ach.hidden_ && !ach.achieved_) {
88 item[
"label"] = ach.hidden_hint_;
89 }
else if(!ach.achieved_) {
90 item[
"label"] = ach.description_;
92 item[
"label"] =
"<span color='green'>"+ach.description_completed_+
"</span>";
94 row.emplace(
"description", item);
98 if(ach.max_progress_ != 0 && ach.current_progress_ != -1) {
99 achievement_progress->
set_percentage((ach.current_progress_/
double(ach.max_progress_))*100);
105 label* achieved_label = find_widget<label>(&win,
"achievement_count",
false,
true);
106 achieved_label->
set_label(
_(
"Completed")+
" "+std::to_string(achieved_count)+
"/"+std::to_string(list.achievements_.size()));
110 content_list.emplace_back(
"label", list.display_name_);
112 if(content_list.size() > 0) {
125 int achieved_count = 0;
137 item[
"label"] = !ach.achieved_ ? ach.icon_ : ach.icon_completed_;
138 row.emplace(
"icon", item);
140 if(ach.hidden_ && !ach.achieved_) {
141 item[
"label"] = ach.hidden_name_;
142 }
else if(!ach.achieved_) {
143 item[
"label"] = ach.name_;
145 item[
"label"] =
"<span color='green'>"+ach.name_completed_+
"</span>";
147 row.emplace(
"name", item);
149 if(ach.hidden_ && !ach.achieved_) {
150 item[
"label"] = ach.hidden_hint_;
151 }
else if(!ach.achieved_) {
152 item[
"label"] = ach.description_;
154 item[
"label"] =
"<span color='green'>"+ach.description_completed_+
"</span>";
156 row.emplace(
"description", item);
160 if(ach.max_progress_ != 0 && ach.current_progress_ != -1) {
161 achievement_progress->
set_percentage((ach.current_progress_/
double(ach.max_progress_))*100);
167 label* achieved_label = find_widget<label>(
get_window(),
"achievement_count",
false,
true);
168 achieved_label->
set_label(
_(
"Completed")+
" "+std::to_string(achieved_count)+
"/"+std::to_string(list.
achievements_.size()));
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
listbox * achievements_box_
std::vector< achievement > achievements_
The achievements associated to this content.
void set_percentage(unsigned percentage)
This object shows the progress of a certain action, or the value state of a certain item...
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.
A label displays a text, the text can be wrapped but no scrollbars are provided.
static std::string _(const char *str)
This shows a dialog displaying achievements.
static game_config_manager * get()
std::map< std::string, t_string > widget_item
std::vector< achievement_group > & get_achievements()
menu_button * content_names_
void clear()
Removes all the rows in the listbox, clearing it.
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
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.
Abstract base class for all modal dialogs.
Standard logging facilities (interface).
std::map< std::string, widget_item > widget_data
A set of achievements tied to a particular content.
void set_achievements_content()
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
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.
std::pair< std::string, unsigned > item
static unsigned int selected_index_
variable of the most recently selected achievements, static to persist between closing and re-opening...