25 #define ERR_CONFIG LOG_STREAM(err, log_config)
28 : id_(cfg[
"id"].str())
29 , description_(cfg[
"description"].t_str())
30 , icon_(cfg[
"icon"].str()+
"~GS()")
31 , icon_completed_(cfg[
"icon"].str())
36 : id_(cfg[
"id"].str())
37 , name_(cfg[
"name"].t_str())
38 , name_completed_(cfg[
"name_completed"].t_str())
39 , description_(cfg[
"description"].t_str())
40 , description_completed_(cfg[
"description_completed"].t_str())
41 , icon_(cfg[
"icon"].str()+
"~GS()")
42 , icon_completed_(cfg[
"icon_completed"].str())
43 , hidden_(cfg[
"hidden"].to_bool())
45 , max_progress_(cfg[
"max_progress"].to_int(0))
46 , current_progress_(progress)
47 , sound_path_(cfg[
"sound"].str())
63 std::string sub_id = sub_ach[
"id"].str();
66 ERR_CONFIG <<
"Achievement " <<
id_ <<
" has a sub-achievement missing the id attribute:\n" << sub_ach.debug();
75 : display_name_(cfg[
"display_name"].t_str())
76 , content_for_(cfg[
"content_for"].str())
80 std::string
id = ach[
"id"].str();
84 }
else if(
id.
find(
',') != std::string::npos) {
116 ERR_CONFIG <<
"Error processing mainline achievements, ignoring: " <<
e.what();
120 std::vector<std::string> dirs;
122 for(
const std::string& dir : dirs) {
127 ERR_CONFIG <<
"Error processing add-on " << dir <<
" achievements, ignoring: " <<
e.what();
157 if(achgrp[
"content_for"].str().empty()) {
158 ERR_CONFIG << content_source +
" achievement_group missing content_for attribute:\n" << achgrp.debug();
static lg::log_domain log_config("config")
void process_achievements_file(const config &cfg, const std::string &content_source)
Processes a config object to add new achievements to achievement_list_.
std::vector< achievement_group > achievement_list_
config read_achievements_file(const std::string &path)
Reads an achievements.cfg file into a config.
void reload()
Reads the mainline achievements.cfg and then all the achievements of each installed add-on.
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
Declarations for File-IO.
Standard logging facilities (interface).
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs, name_mode mode, filter_mode filter, reorder_mode reorder, file_tree_checksum *checksum)
Get a list of all files and/or directories in a given directory.
static bool file_exists(const bfs::path &fpath)
std::unique_ptr< std::istream > scoped_istream
std::string get_addons_dir()
auto * find(Container &container, const Value &value)
Convenience wrapper for using find on a container without needing to comare to end()
filesystem::scoped_istream preprocess_file(const std::string &fname, preproc_map *defines)
Function to use the WML preprocessor on a file.
void read(config &cfg, std::istream &in, abstract_validator *validator)
std::string content_for_
The internal ID used for this content.
std::vector< achievement > achievements_
The achievements associated to this content.
achievement_group(const config &cfg)
Represents a single achievement and its data.
std::string icon_completed_
The icon of the achievement to show on the UI if the achievement is completed.
t_string name_completed_
The name of the achievement to show on the UI if the achievement is completed.
achievement(const config &cfg, const std::string &content_for, bool achieved, int progress)
t_string description_completed_
The name of the achievement to show on the UI if the achievement is completed.
t_string name_
The name of the achievement to show on the UI.
bool achieved_
Whether the achievement has been completed.
std::string id_
The ID of the achievement.
int max_progress_
When the achievement's current progress matches or equals this value, then it should be marked as com...
t_string description_
The description of the achievement to show on the UI.
std::vector< sub_achievement > sub_achievements_
The list of distinct sub-achievements for this achievement.
Base class for all the errors encountered by the engine.
Represents a distinct sub-achievement within another achievement.
sub_achievement(const config &cfg, bool achieved)