16 #define GETTEXT_DOMAIN "wesnoth-lib"
32 #define ERR_CONFIG LOG_STREAM(err, log_config)
45 , achievements_box_(
nullptr)
46 , content_names_(
nullptr)
52 std::vector<config> content_list;
53 content_names_ = &find_widget<menu_button>(&win,
"selected_achievements_list",
false);
61 for(
const auto& list : groups) {
68 content_list.emplace_back(
"label", list.display_name_);
71 if(content_list.size() > 0) {
88 int achieved_count = 0;
93 }
else if(ach.hidden_ && !ach.achieved_) {
100 item[
"label"] = !ach.achieved_ ? ach.icon_ : ach.icon_completed_;
101 row.emplace(
"icon",
item);
105 if(ach.max_progress_ != 0 && ach.current_progress_ != -1) {
106 name +=
" ("+std::to_string(ach.current_progress_)+
"/"+std::to_string(ach.max_progress_)+
")";
108 item[
"label"] = name;
110 item[
"label"] = ach.name_completed_;
111 item[
"definition"] =
"gold_large";
113 row.emplace(
"name",
item);
116 item[
"label"] = ach.description_;
118 item[
"label"] =
"<span color='green'>"+ach.description_completed_+
"</span>";
120 row.emplace(
"description",
item);
124 if(ach.max_progress_ != 0 && ach.current_progress_ != -1) {
125 achievement_progress->
set_percentage((ach.current_progress_/
double(ach.max_progress_))*100);
137 label* achieved_label = find_widget<label>(
get_window(),
"achievement_count",
false,
true);
138 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)
This shows a dialog displaying achievements.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
menu_button * content_names_
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
listbox * achievements_box_
void set_achievements_row()
std::string last_selected_
void set_sub_achievements(grid &newrow, const achievement &ach)
Abstract base class for all modal dialogs.
window * get_window()
Returns a pointer to the dialog's window.
A drawing is widget with a fixed size and gives access to the canvas of the widget in the window inst...
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
A label displays text that can be wrapped but no scrollbars are provided.
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.
This object shows the progress of a certain action, or the value state of a certain item.
void set_percentage(unsigned percentage)
base class of top level items, the only item which needs to store the final canvases to draw on.
static std::string _(const char *str)
Standard logging facilities (interface).
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
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::pair< std::string, unsigned > item
Modify, read and display user preferences.
std::string selected_achievement_group()
void set_selected_achievement_group(const std::string &content_for)
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.