26 #define ERR_CONFIG LOG_STREAM(err, log_config)
29 : id_(cfg[
"id"].str())
30 , description_(cfg[
"description"].t_str())
31 , icon_(cfg[
"icon"].str()+
"~GS()")
32 , icon_completed_(cfg[
"icon"].str())
37 : id_(cfg[
"id"].str())
38 , name_(cfg[
"name"].t_str())
39 , name_completed_(cfg[
"name_completed"].t_str())
40 , description_(cfg[
"description"].t_str())
41 , description_completed_(cfg[
"description_completed"].t_str())
42 , icon_(cfg[
"icon"].str()+
"~GS()")
43 , icon_completed_(cfg[
"icon_completed"].str())
44 , hidden_(cfg[
"hidden"].to_bool())
46 , max_progress_(cfg[
"max_progress"].to_int(0))
47 , current_progress_(progress)
48 , sound_path_(cfg[
"sound"].str())
64 std::string sub_id = sub_ach[
"id"].str();
67 ERR_CONFIG <<
"Achievement " <<
id_ <<
" has a sub-achievement missing the id attribute:\n" << sub_ach.debug();
76 : display_name_(cfg[
"display_name"].t_str())
77 , content_for_(cfg[
"content_for"].str())
81 std::string
id = ach[
"id"].str();
85 }
else if(
id.find(
',') != std::string::npos) {
117 ERR_CONFIG <<
"Error processing mainline achievements, ignoring: " <<
e.what();
121 std::vector<std::string> dirs;
123 for(
const std::string& dir : dirs) {
128 ERR_CONFIG <<
"Error processing add-on " << dir <<
" achievements, ignoring: " <<
e.what();
158 if(achgrp[
"content_for"].str().empty()) {
159 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()
int progress_achievement(const std::string &content_for, const std::string &id, int limit, int max_progress, int amount)
Increments the achievement's current progress by amount if it hasn't already been completed.
bool achievement(const std::string &content_for, const std::string &id)
bool sub_achievement(const std::string &content_for, const std::string &id, const std::string &sub_id)
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)
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.
sub_achievement(const config &cfg, bool achieved)