The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
achievements Class Reference

This class is responsible for reading all available achievements from mainline's and any add-ons' achievements.cfg files for use in achievements_dialog. More...

#include <achievements.hpp>

Public Member Functions

 achievements ()
 
void reload ()
 Reads the mainline achievements.cfg and then all the achievements of each installed add-on. More...
 
std::vector< achievement_group > & get_list ()
 

Private Member Functions

config read_achievements_file (const std::string &path)
 Reads an achievements.cfg file into a config. More...
 
void process_achievements_file (const config &cfg, const std::string &content_source)
 Processes a config object to add new achievements to achievement_list_. More...
 

Private Attributes

std::vector< achievement_groupachievement_list_
 

Detailed Description

This class is responsible for reading all available achievements from mainline's and any add-ons' achievements.cfg files for use in achievements_dialog.

Definition at line 97 of file achievements.hpp.

Constructor & Destructor Documentation

◆ achievements()

achievements::achievements ( )

Definition at line 93 of file achievements.cpp.

References reload().

Member Function Documentation

◆ get_list()

std::vector<achievement_group>& achievements::get_list ( )
inline

Definition at line 102 of file achievements.hpp.

References achievement_list_.

Referenced by game_config_manager::get_achievements().

◆ process_achievements_file()

void achievements::process_achievements_file ( const config cfg,
const std::string &  content_source 
)
private

Processes a config object to add new achievements to achievement_list_.

Parameters
cfgThe config containing additional achievements.
content_sourceThe source of the additional achievements - either mainline or an add-on.

Definition at line 154 of file achievements.cpp.

References achievement_list_, config::child_range(), and ERR_CONFIG.

Referenced by reload().

◆ read_achievements_file()

config achievements::read_achievements_file ( const std::string &  path)
private

Reads an achievements.cfg file into a config.

Parameters
pathThe path to the achievements.cfg file.
Returns
The config containing all the achievements.

Definition at line 138 of file achievements.cpp.

References filesystem::file_exists(), game_config::path, preprocess_file(), and read().

Referenced by reload().

◆ reload()

void achievements::reload ( )

Reads the mainline achievements.cfg and then all the achievements of each installed add-on.

This is intentionally handled separately from other WML loading so that: a) All achievements and their status are able to be displayed on the main menu right after Wesnoth starts and regardless of which add-ons are active. b) Add-ons can add additional achievements to other content, whether UMC or mainline. For example, a modification that adds more achievements for mainline campaigns.

NOTE: These are not in any way related to Steam achievements!

Definition at line 108 of file achievements.cpp.

References achievement_list_, e, ERR_CONFIG, filesystem::get_addons_dir(), filesystem::get_files_in_dir(), game_config::path, process_achievements_file(), and read_achievements_file().

Referenced by achievements(), and game_config_manager::load_game_config().

Member Data Documentation

◆ achievement_list_

std::vector<achievement_group> achievements::achievement_list_
private

Definition at line 111 of file achievements.hpp.

Referenced by get_list(), process_achievements_file(), and reload().


The documentation for this class was generated from the following files: