15 #define GETTEXT_DOMAIN "wesnoth-lib"
31 #define ERR_CONFIG LOG_STREAM(err, log_config)
44 , achievements_box_(
nullptr)
45 , content_names_(
nullptr)
51 std::vector<config> content_list;
52 content_names_ = &find_widget<menu_button>(&win,
"selected_achievements_list",
false);
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 +=
" ("+std::to_string(ach.current_progress_)+
"/"+std::to_string(ach.max_progress_)+
")";
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_;
117 item[
"label"] =
"<span color='green'>"+ach.description_completed_+
"</span>";
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>(
get_window(),
"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)
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).
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::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.