26 #define ERR_AC LOG_STREAM(err , log_addons_client)
27 #define LOG_AC LOG_STREAM(info, log_addons_client)
30 void resolve_deps_recursive(
const addons_list& addons,
const std::string& base_id, std::set<std::string>& dest)
32 addons_list::const_iterator it = addons.find(base_id);
33 if(it == addons.end()) {
34 LOG_AC <<
"resolve_deps_recursive(): " << base_id <<
" not in add-ons list";
38 const std::vector<std::string>& base_deps = it->second.depends;
40 if(base_deps.empty()) {
44 for(
const std::string& dep : base_deps) {
46 LOG_AC << dep <<
" depends upon itself; breaking circular dependency";
48 }
else if(dest.find(dep) != dest.end()) {
49 LOG_AC << dep <<
" already in dependency tree; breaking circular dependency";
55 resolve_deps_recursive(addons, dep, dest);
62 supported = cfg[
"supported"].to_bool(
true);
63 title = cfg[
"title"].str();
76 id = cfg[
"name"].str();
77 title = cfg[
"title"].str();
79 icon = cfg[
"icon"].str();
81 versions.emplace(cfg[
"version"].str());
82 author = cfg[
"author"].str();
89 versions.emplace(version[
"version"].str());
94 for(
const config& locale : locales_as_configs) {
95 if(locale[
"supported"].to_bool(
true))
96 locales.emplace_back(locale[
"language"].str());
100 core = cfg[
"core"].str();
105 updated = cfg[
"timestamp"].to_time_t();
106 created = cfg[
"original_timestamp"].to_time_t();
114 cfg[
"title"] =
title;
126 version_cfg[
"version"] = version.str();
131 locale[
"language"] = element.first;
132 element.second.write(locale);
141 cfg[
"original_timestamp"] =
created;
149 cfg[
"title"] =
title;
169 std::string lang_name_short = locale_info.language();
170 std::string lang_name_long = lang_name_short;
171 if(!locale_info.country().empty()) {
172 lang_name_long +=
'_';
173 lang_name_long += locale_info.country();
175 if(!locale_info.variant().empty()) {
176 lang_name_long +=
'@';
177 lang_name_long += locale_info.variant();
178 lang_name_short +=
'@';
179 lang_name_short += locale_info.variant();
216 if(
info.valid() && !
info.description.empty()) {
217 return info.description;
226 if(local_title.empty())
233 std::string ret =
icon;
236 ERR_AC <<
"add-on '" <<
id <<
"' doesn't have an icon path set";
238 ERR_AC <<
"add-on '" <<
id <<
"' has an icon which cannot be found: '" << ret <<
"'";
239 }
else if(ret.find(
"units/") != std::string::npos && ret.find_first_of(
'~') == std::string::npos) {
241 LOG_AC <<
"add-on '" <<
id <<
"' uses a unit baseframe as icon without TC/RC specifications";
242 ret +=
"~RC(magenta>red)";
252 return _(
"addon_type^Campaign");
254 return _(
"addon_type^Scenario");
256 return _(
"addon_type^SP/MP Campaign");
258 return _(
"addon_type^MP era");
260 return _(
"addon_type^MP faction");
262 return _(
"addon_type^MP map-pack");
264 return _(
"addon_type^MP scenario");
266 return _(
"addon_type^MP campaign");
268 return _(
"addon_type^Modification");
270 return _(
"addon_type^Core");
272 return _(
"addon_type^Resources");
274 return _(
"addon_type^Other");
276 return _(
"addon_type^(unknown)");
282 std::set<std::string> deps;
283 resolve_deps_recursive(addons,
id, deps);
285 if(deps.find(
id) != deps.end()) {
286 LOG_AC <<
id <<
" depends upon itself; breaking circular dependency";
300 for(
const config& addon_cfg : addon_cfgs) {
301 const std::string&
id = addon_cfg[
"name"].str();
302 if(dest.find(
id) != dest.end()) {
303 ERR_AC <<
"add-ons list has multiple entries for '" <<
id <<
"', not good; ignoring them";
306 dest[
id].read(addon_cfg);
322 std::replace(ret.begin(), ret.end(),
'_',
' ');
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
boost::iterator_range< const_child_iterator > const_child_itors
config & add_child(config_key_type key)
Generic locator abstracting the location of an image.
Represents version numbers.
std::string str() const
Serializes the version number into string form.
Definitions for the interface to Wesnoth Markup Language (WML).
static std::string _(const char *str)
std::string id
Text to match against addon_info.tags()
std::string size_display_string(double size)
Get a human-readable representation of the specified byte count.
std::string make_addon_title(const std::string &id)
Replaces underscores to dress up file or dirnames as add-on titles.
static lg::log_domain log_addons_client("addons-client")
void read_addons_list(const config &cfg, addons_list &dest)
Parse the specified add-ons list WML into an actual addons_list object.
std::map< std::string, addon_info > addons_list
Standard logging facilities (interface).
std::string escape_text(const std::string &text)
Escapes the pango markup characters in a text.
bool exists(const image::locator &i_locator)
Returns true if the given image actually exists, without loading it.
const boost::locale::info & get_effective_locale_info()
A facet that holds general information about the effective locale.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
std::string si_string(double input, bool base2, const std::string &unit)
Convert into a string with an SI-postfix.
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::vector< std::string > split(const config_attribute_value &val)
static addon_info_translation invalid
void read(const config &cfg)
void write(config &cfg) const
std::vector< std::string > tags
void read(const config &cfg)
version_info current_version
std::string display_type() const
Get an add-on type identifier for display in the user's language.
std::map< std::string, addon_info_translation > info_translations
addon_info_translation translated_info() const
std::string display_title_translated() const
std::string description_translated() const
void write(config &cfg) const
std::string display_icon() const
Get an icon path fixed for display (e.g.
std::string display_title() const
Get a title or automatic title for display.
std::string display_title_translated_or_original() const
std::vector< std::string > depends
std::string display_title_full() const
std::set< std::string > resolve_dependencies(const addons_list &addons) const
Resolve an add-on's dependency tree in a recursive fashion.
std::set< version_info, std::greater< version_info > > versions
std::vector< std::string > locales
void write_minimal(config &cfg) const
Write only minimal WML used for state tracking (_info.cfg) files.
ADDON_TYPE get_addon_type(const std::string &str)
std::string get_addon_type_string(ADDON_TYPE type)
@ ADDON_SP_SCENARIO
Single-player scenario.
@ ADDON_MP_SCENARIO
Multiplayer scenario.
@ ADDON_MP_CAMPAIGN
Multiplayer campaign.
@ ADDON_MP_FACTION
Multiplayer faction.
@ ADDON_MEDIA
Miscellaneous content/media (unit packs, terrain packs, music packs, etc.).
@ ADDON_MP_ERA
Multiplayer era.
@ ADDON_CORE
Total Conversion Core.
@ ADDON_SP_CAMPAIGN
Single-player campaign.
@ ADDON_OTHER
an add-on that fits in no other category
@ ADDON_SP_MP_CAMPAIGN
Hybrid campaign.
@ ADDON_MP_MAPS
Multiplayer plain (no WML) map pack.
@ ADDON_MOD
Modification of the game.