27 #define ERR_AC LOG_STREAM(err , log_addons_client)
28 #define LOG_AC LOG_STREAM(info, log_addons_client)
31 void resolve_deps_recursive(
const addons_list& addons,
const std::string& base_id, std::set<std::string>& dest)
33 addons_list::const_iterator it = addons.find(base_id);
34 if(it == addons.end()) {
35 LOG_AC <<
"resolve_deps_recursive(): " << base_id <<
" not in add-ons list";
39 const std::vector<std::string>& base_deps = it->second.depends;
41 if(base_deps.empty()) {
45 for(
const std::string& dep : base_deps) {
47 LOG_AC << dep <<
" depends upon itself; breaking circular dependency";
49 }
else if(dest.find(dep) != dest.end()) {
50 LOG_AC << dep <<
" already in dependency tree; breaking circular dependency";
56 resolve_deps_recursive(addons, dep, dest);
63 supported = cfg[
"supported"].to_bool(
true);
64 title = cfg[
"title"].str();
77 id = cfg[
"name"].str();
78 title = cfg[
"title"].str();
80 icon = cfg[
"icon"].str();
82 versions.emplace(cfg[
"version"].str());
83 author = cfg[
"author"].str();
84 size = cfg[
"size"].to_int();
86 uploads = cfg[
"uploads"].to_int();
90 versions.emplace(version[
"version"].str());
95 for(
const config& locale : locales_as_configs) {
96 if(locale[
"supported"].to_bool(
true))
97 locales.emplace_back(locale[
"language"].str());
101 core = cfg[
"core"].str();
115 cfg[
"title"] =
title;
127 version_cfg[
"version"] = version.str();
132 locale[
"language"] = element.first;
133 element.second.write(locale);
150 cfg[
"title"] =
title;
170 std::string lang_name_short = locale_info.language();
171 std::string lang_name_long = lang_name_short;
172 if(!locale_info.country().empty()) {
173 lang_name_long +=
'_';
174 lang_name_long += locale_info.country();
176 if(!locale_info.variant().empty()) {
177 lang_name_long +=
'@';
178 lang_name_long += locale_info.variant();
179 lang_name_short +=
'@';
180 lang_name_short += locale_info.variant();
217 if(
info.valid() && !
info.description.empty()) {
218 return info.description;
227 if(local_title.empty())
234 std::string ret =
icon;
237 ERR_AC <<
"add-on '" <<
id <<
"' has an icon which cannot be found: '" << ret <<
"'";
238 }
else if(ret.find(
"units/") != std::string::npos && ret.find_first_of(
'~') == std::string::npos) {
240 LOG_AC <<
"add-on '" <<
id <<
"' uses a unit baseframe as icon without TC/RC specifications";
241 ret +=
"~RC(magenta>red)";
251 return _(
"addon_type^Campaign");
253 return _(
"addon_type^Scenario");
255 return _(
"addon_type^SP/MP Campaign");
257 return _(
"addon_type^MP era");
259 return _(
"addon_type^MP faction");
261 return _(
"addon_type^MP map-pack");
263 return _(
"addon_type^MP scenario");
265 return _(
"addon_type^MP campaign");
267 return _(
"addon_type^Modification");
269 return _(
"addon_type^Core");
271 return _(
"addon_type^Resources");
273 return _(
"addon_type^Other");
275 return _(
"addon_type^(unknown)");
281 std::set<std::string> deps;
282 resolve_deps_recursive(addons,
id, deps);
284 if(deps.find(
id) != deps.end()) {
285 LOG_AC <<
id <<
" depends upon itself; breaking circular dependency";
299 for(
const config& addon_cfg : addon_cfgs) {
300 const std::string&
id = addon_cfg[
"name"].str();
301 if(dest.find(
id) != dest.end()) {
302 ERR_AC <<
"add-ons list has multiple entries for '" <<
id <<
"', not good; ignoring them";
305 dest[
id].read(addon_cfg);
321 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).
auto serialize_timestamp(const std::chrono::system_clock::time_point &time)
auto parse_timestamp(long long val)
std::string escape_text(std::string_view 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(std::string_view 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::chrono::system_clock::time_point updated
std::string display_title() const
Get a title or automatic title for display.
std::string display_title_translated_or_original() const
std::chrono::system_clock::time_point created
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.